-
Notifications
You must be signed in to change notification settings - Fork 11
feat(pip): add pyproject.toml support via pip --dry-run --report #465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
6fb148d
feat(pip): add pyproject.toml support via pip --dry-run --report
ruromero 5aed939
fix(python): align pip pyproject _getDependencyData signature with ba…
ruromero 475deea
fix(python): only exclude root entry from pip report graph, not all d…
ruromero 3ef9468
refactor(test): parameterize pyproject SBOM tests and add doc comments
ruromero d3525b1
test(pip): add extras package to pip fixture for realistic extras fil…
ruromero 18a8947
test(pip): call pip directly instead of using env var overrides
ruromero 08f7bd1
fix(test): lower requires-python to >=3.9 to match CI Python version
ruromero d4b7007
fix(pip): clean up .egg-info directories created by pip --dry-run
ruromero d674093
test(pip): replace manual ignore assertions with golden SBOM tests
ruromero cd2ee30
fix(python): build true dependency graph instead of tree
ruromero af5587c
fix: use GraphEntry typedef instead of inline type in JSDoc
ruromero File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,3 +10,4 @@ build | |
| target | ||
| .npmrc | ||
| src/providers/*.wasm | ||
| *.egg-info | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| # Coding Conventions | ||
|
|
||
| <!-- This file documents project-specific coding standards for exhort-javascript-api. --> | ||
|
|
||
| ## Language and Framework | ||
|
|
||
| - **Primary Language**: JavaScript (ES modules, `"type": "module"` in package.json) | ||
| - **TypeScript**: Configuration present but code is primarily JavaScript with JSDoc | ||
| - **Node.js**: Requires Node >= 20.0.0, npm >= 11.5.1 | ||
| - **CLI**: `yargs` for command-line argument parsing | ||
| - **Parsing Libraries**: `fast-xml-parser`, `fast-toml`, `smol-toml`, `tree-sitter-requirements` | ||
|
|
||
| ## Code Style | ||
|
|
||
| - **Linter**: ESLint with recommended config + editorconfig + import plugins | ||
| - **Indentation**: Tabs (4 spaces for YAML/Markdown) | ||
| - **Line endings**: LF | ||
| - **Max line length**: 100 (120 for Markdown) | ||
| - **Charset**: UTF-8, final newline, trim trailing whitespace | ||
| - **Import ordering** (ESLint enforced): builtin, external, internal, parent, sibling, index — alphabetical within groups | ||
| - **Strict equality**: `eqeqeq: ["warn", "always", {"null": "never"}]` | ||
| - **Curly braces**: Required (`curly: "warn"`) | ||
| - **No throw literals**: `no-throw-literal: "warn"` | ||
| - **No Prettier** — ESLint + EditorConfig handle formatting | ||
|
|
||
| ## Naming Conventions | ||
|
|
||
| - **Classes**: PascalCase with underscore-separated language names (`Java_maven`, `Base_java`, `Javascript_npm`) | ||
| - **Files**: snake_case for providers (`base_java.js`, `javascript_npm.js`, `python_pip.js`) | ||
| - **Test files**: `*.test.js` suffix (`analysis.test.js`, `provider.test.js`) | ||
| - **Functions/Methods**: camelCase (`provideComponent()`, `provideStack()`, `validateLockFile()`) | ||
| - **Variables**: camelCase (`manifestPath`, `backendUrl`) | ||
| - **Constants**: UPPER_SNAKE_CASE (`ecosystem_maven`, `DEFAULT_WORKSPACE_DISCOVERY_IGNORE`) | ||
| - **Private class fields**: `#` prefix (`#manifest`, `#cmd`, `#ecosystem`) | ||
| - **Protected methods**: `_` prefix (`_lockFileName()`, `_cmdName()`, `_listCmdArgs()`) | ||
|
|
||
| ## File Organization | ||
|
|
||
| ``` | ||
| src/ | ||
| ├── index.js # Main export | ||
| ├── cli.js # CLI entry point | ||
| ├── analysis.js # API request handling | ||
| ├── provider.js # Provider matching logic | ||
| ├── workspace.js # Workspace discovery | ||
| ├── tools.js # Utilities | ||
| ├── sbom.js # SBOM handling | ||
| ├── cyclone_dx_sbom.js # CycloneDX SBOM generation | ||
| ├── providers/ # Ecosystem providers | ||
| │ ├── base_java.js | ||
| │ ├── base_javascript.js | ||
| │ ├── java_maven.js | ||
| │ ├── javascript_npm.js | ||
| │ ├── python_pip.js | ||
| │ ├── rust_cargo.js | ||
| │ └── processors/ # Specialized processors | ||
| ├── license/ # License detection | ||
| └── oci_image/ # OCI image analysis | ||
|
|
||
| test/ | ||
| ├── analysis.test.js | ||
| ├── provider.test.js | ||
| ├── tools.test.js | ||
| └── providers/ # Provider-specific tests | ||
| ``` | ||
|
|
||
| ## Error Handling | ||
|
|
||
| - **Throw Error objects**: `throw new Error("message")`, `throw new TypeError("message")` | ||
| - **No custom error classes** — uses built-in `Error` and `TypeError` | ||
| - **HTTP errors**: Check `resp.status`, throw with status code and response text | ||
| - **Async errors**: Bubble up naturally via async/await (no blanket try-catch) | ||
| - **Validation errors**: Thrown early with descriptive context (manifest type, lock file) | ||
|
|
||
| ## Testing Conventions | ||
|
|
||
| - **Framework**: Mocha with TDD UI (`suite()` / `test()`) | ||
| - **Assertions**: Chai with `expect()` syntax | ||
| - **Mocking**: Sinon for stubs; MSW (Mock Service Worker) for HTTP mocking | ||
| - **Module mocking**: `esmock` with experimental loader | ||
| - **Coverage**: C8 with 82% line coverage requirement | ||
| - **Test patterns**: `expect(res).to.deep.equal(...)`, `expect(() => ...).to.throw('message')` | ||
| - **Higher-order setup**: Functions like `interceptAndRun()` for test setup/teardown | ||
| - **Prefer real tool invocations over env var overrides**: Tests should call the actual ecosystem tools (pip, uv, poetry, mvn, npm, etc.) rather than injecting pre-recorded output via `TRUSTIFY_DA_*` environment variables. The CI environment has these tools available. Env var overrides (`TRUSTIFY_DA_PIP_REPORT`, `TRUSTIFY_DA_UV_EXPORT`, etc.) exist for users who lack the tool locally, but tests should exercise the real tool path to catch integration issues. | ||
| - **Golden SBOM files for every test fixture**: Every provider test fixture directory must include `expected_stack_sbom.json` and `expected_component_sbom.json` golden files. Tests must use the `SBOM_CASES` pattern to do a full `deep.equal` comparison of the provider output against these golden files. Manual partial assertions (e.g. checking a single component name) are not a substitute — they may be added as supplementary tests but never as the only verification for a fixture. | ||
|
|
||
| ## Commit Messages | ||
|
|
||
| - Likely Conventional Commits format | ||
| - DCO (Developer Certificate of Origin) required | ||
| - Semantic versioning (`0.3.0` in package.json) | ||
|
|
||
| ## Dependencies | ||
|
|
||
| - **Package manager**: npm with `package-lock.json` | ||
| - **Module system**: ES modules with explicit `.js` extensions in relative imports | ||
| - **Import convention**: `import fs from 'node:fs'` (node: protocol for built-ins) | ||
| - **Environment variables**: Prefixed with `TRUSTIFY_DA_` (e.g., `TRUSTIFY_DA_MVN_PATH`, `TRUSTIFY_DA_TOKEN`, `TRUSTIFY_DA_DEBUG`) | ||
| - **Multi-ecosystem support**: npm, pnpm, yarn, Maven, Gradle, pip, cargo, Go modules, Docker/Podman |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.