mirror of
https://github.com/safedep/pmg.git
synced 2026-08-03 07:24:09 +02:00
* upgrade go version to 1.25.1 * introduce doc for steps for creating a new pkg manager * Update docs/package-manager.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Sahil Bansal <bansalsahil315@gmail.com> * Update docs/package-manager.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Sahil Bansal <bansalsahil315@gmail.com> * Update docs/package-manager.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Sahil Bansal <bansalsahil315@gmail.com> --------- Signed-off-by: Sahil Bansal <bansalsahil315@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2.5 KiB
2.5 KiB
Steps to introduce a new Package Manager
Use this checklist to add a new package manager ecosystem (e.g., npm or PyPI). Keep changes consistent with existing patterns.
-
Create a new CLI command
- Add a new cmd in
cmd/(e.g.,cmd/npm/orcmd/pypi/). - Follow existing command patterns for the chosen ecosystem.
- Wire flags, args, and output format similarly to other cmds.
- Add a new cmd in
-
Define Package Manager config
- Introduce config logic in
packagemanager/npm/orpackagemanager/pypi/depending on the ecosystem. - Keep interfaces and structs consistent with other managers.
- Introduce config logic in
-
Implement or update the parser
- For npm: update the existing parser to support the new manager specifics.
- For PyPI: define a new parser as needed.
- Ensure it extracts all the required information & matches other parser's structure.
-
Add parser tests
- Create unit tests for the new parser covering:
- Single dependency
- Multiple dependencies
- Edge cases (e.g., missing fields, malformed entries)
- Create unit tests for the new parser covering:
-
Create an extractor
- In
extractor/, add an extractor for the new ecosystem underextractor/npmorextractor/pypi. - Update the
NewExtractorManagerto include the newly introducedPackageManagerExtractor. - Update
getExtractorForFileto recognize and support the ecosystem’s manifests/lockfiles.
- In
-
Register alias
- In
internal/alias/alias.go, add the new package manager’s alias toDefaultConfig.packageManagers. - Verify default alias and invocation match conventions.
- In
-
Add analytics
- Define a new analytics event similar to existing ones.
- Implement a
Trackfunction for the event. - Invoke tracking in the new package manager cmd.
-
Update documentation
- Update the README to list the new supported package manager.
- Add usage examples consistent with existing examples.
-
Add e2e workflow
- In
.github/workflows/pmg-e2e.yml, add an e2e job for the new manager. - Mirror structure and steps used by other ecosystems.
- In
-
Verify end-to-end behavior
- Test the CLI locally for:
- Single package installation
- Multiple package installation
- Suspicious package handling
- Malicious package blocking
- Manifests/lockfiles installation flow
pmg setup installto verify alias is set and works
- Test the CLI locally for:
-
Consistency pass
- Confirm naming, errors, logs, and UX align with existing ecosystems.
- Ensure code follows project patterns and is covered by tests.