fix: allow optional optionalDependencies for development#6
Conversation
🦋 Changeset detectedLatest commit: 71d9533 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
WalkthroughThis update modifies the handling of Changes
Sequence Diagram(s)sequenceDiagram
participant Dev as Developer
participant NPI as napi-postinstall
participant NPM as npm Registry
Dev->>NPI: Run checkAndPreparePackage()
NPI->>NPI: Read package.json
alt napi.targets or napi.triples.additional missing
NPI-->>Dev: Throw error (missing fields)
else optionalDependencies missing
NPI-->>Dev: Return napi info (no error)
else All fields present
NPI->>NPI: Check optionalDependencies versions
alt Version mismatch or missing
NPI-->>Dev: Throw error
else
NPI->>NPM: Install native binary using napiVersion
NPM-->>NPI: Provide binary
NPI-->>Dev: Success
end
end
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
lib/types.d.tsOops! Something went wrong! :( ESLint: 9.24.0 Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@1stg/eslint-config' imported from /eslint.config.mjs src/helpers.tsOops! Something went wrong! :( ESLint: 9.24.0 Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@1stg/eslint-config' imported from /eslint.config.mjs lib/helpers.d.tsOops! Something went wrong! :( ESLint: 9.24.0 Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@1stg/eslint-config' imported from /eslint.config.mjs
📜 Recent review detailsConfiguration used: CodeRabbit UI ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (9)
🚧 Files skipped from review as they are similar to previous changes (6)
⏰ Context from checks skipped due to timeout of 90000ms (9)
🔇 Additional comments (3)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Pull Request Overview
This PR modifies version and dependency handling to support auto‐generated optionalDependencies during development while improving error messages for missing NAPI support fields.
- Updates error messages to reference "napi.triples.additional" instead of "optionalDependencies"
- Revises version comparison logic and uses optional chaining for optionalDependencies
- Adjusts helper functions to set sensible defaults for napi.binaryName and napi.packageName
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| test/basic.spec.ts | Error message updated in snapshot to require "napi.triples.additional" instead of the old field. |
| src/index.ts | Conditional version check and safe access to optionalDependencies have been improved. |
| src/helpers.ts | Refactored the early dependency check and initialized defaults for binaryName/packageName. |
| lib/index.js | Mirrors the changes in src/index.ts regarding version check and dependency access. |
| lib/helpers.js | Updated error message and default value assignments to align with the new field naming. |
Comments suppressed due to low confidence (3)
test/basic.spec.ts:23
- Ensure the updated error message clearly reflects the new required field 'napi.triples.additional' and update any related documentation or tests accordingly.
[Error: No `napi.targets` nor `napi.triples.additional` field found in `napi-postinstall`'s `package.json`. Please ensure the package is built with NAPI support.]
lib/helpers.js:55
- Verify that the error message now consistently references 'napi.triples.additional' and that any related test expectations are updated accordingly.
throw new Error(`No `napi.targets` nor `napi.triples.additional` field found in `${name}`'s `package.json`. Please ensure the package is built with NAPI support.`);
src/index.ts:197
- Confirm that skipping the version consistency check when napiVersion is undefined is intended; if not, consider handling this scenario explicitly.
if (checkVersion && napiVersion && version !== napiVersion) {
📊 Package size report 0.5%↑
Unchanged files
🤖 This report was automatically generated by pkg-size-action |
size-limit report 📦
|
commit: |
|
Deploy preview for napi-postinstall ready! ✅ Preview Built with commit 83ee2ef. |
the `optionalDependencies` field is auto generated on build
71d9533 to
83ee2ef
Compare
the
optionalDependenciesfield is auto generated on buildSummary by CodeRabbit
Bug Fixes
Tests
Chores