Publish npm package to @kubevirt-ui-ext#7
Conversation
Signed-off-by: Radoslaw Szwajkowski <rszwajko@redhat.com>
WalkthroughThe npm publish workflow has been updated to replace the package scope from Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
.github/workflows/npm-publish.yml(2 hunks)package.json(1 hunks)
🔇 Additional comments (2)
package.json (1)
3-3: Version bump is appropriate for scope change.The patch version bump (1.0.0 → 1.0.1) is suitable since the package functionality remains unchanged; only the publication scope/organization is changing.
.github/workflows/npm-publish.yml (1)
42-42: Verify that the NPM_TOKEN_FOR_KUBEVIRT_UI_EXT secret is configured.The workflow now uses a new GitHub Actions secret (
NPM_TOKEN_FOR_KUBEVIRT_UI_EXT) for npm authentication. If this secret is not configured in the repository settings, the publish step will fail silently or with an unclear error.Please confirm that
NPM_TOKEN_FOR_KUBEVIRT_UI_EXThas been added to your repository's Actions secrets under Settings > Secrets and variables > Actions.
| #change the organization for npm | ||
| - run: sed -i -E 's/@kubevirt-ui/@kubevirt-ui-ext/' package.json |
There was a problem hiding this comment.
Sed regex is overly broad and will corrupt the repository URL.
The regex s/@kubevirt-ui/@kubevirt-ui-ext/ will replace all occurrences of @kubevirt-ui in package.json, including the repository URL at line 27. This will incorrectly rewrite the git URL from github.com/kubevirt-ui/... to github.com/kubevirt-ui-ext/..., breaking package metadata traceability.
Use a more specific regex that targets only the "name" field:
- - run: sed -i -E 's/@kubevirt-ui/@kubevirt-ui-ext/' package.json
+ - run: sed -i -E 's/"name": "@kubevirt-ui\/"/"name": "@kubevirt-ui-ext\/"/' package.jsonAlternatively, use a safer JSON-aware approach:
- - run: sed -i -E 's/@kubevirt-ui/@kubevirt-ui-ext/' package.json
+ - run: |
+ node -e "const pkg = require('./package.json'); pkg.name = pkg.name.replace('@kubevirt-ui/', '@kubevirt-ui-ext/'); require('fs').writeFileSync('./package.json', JSON.stringify(pkg, null, 2) + '\n');"📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| #change the organization for npm | |
| - run: sed -i -E 's/@kubevirt-ui/@kubevirt-ui-ext/' package.json | |
| #change the organization for npm | |
| - run: sed -i -E 's/"name": "@kubevirt-ui\/"/"name": "@kubevirt-ui-ext\/"/' package.json |
| #change the organization for npm | |
| - run: sed -i -E 's/@kubevirt-ui/@kubevirt-ui-ext/' package.json | |
| #change the organization for npm | |
| - run: | | |
| node -e "const pkg = require('./package.json'); pkg.name = pkg.name.replace('@kubevirt-ui/', '@kubevirt-ui-ext/'); require('fs').writeFileSync('./package.json', JSON.stringify(pkg, null, 2) + '\n');" |
There was a problem hiding this comment.
Is there a jq command that could easily patch the file?
There was a problem hiding this comment.
@sjd78, yes! jq is a much safer choice for modifying JSON files. Here's a command that will precisely target only the name field:
jq '.name |= sub("@kubevirt-ui/";"@kubevirt-ui-ext/")' package.json > tmp.json && mv tmp.json package.jsonIn the workflow step, it would look like:
#change the organization for npm
- run: jq '.name |= sub("@kubevirt-ui/";"@kubevirt-ui-ext/")' package.json > tmp.json && mv tmp.json package.jsonThis approach:
- ✅ Only modifies the
namefield - ✅ Preserves JSON formatting
- ✅ Won't accidentally replace
@kubevirt-uiin the repository URL - ✅
jqis pre-installed on GitHub Actionsubuntu-latestrunners
Follow the approach used in vnc-keymap projec. Support node version >= 20. Add workflow to build the package on each PR. Reference-Url: kubevirt-ui/vnc-keymaps#7 Signed-off-by: Radoslaw Szwajkowski <rszwajko@redhat.com>
Follow the approach used in vnc-keymap project. Support node version >= 20. Add workflow to build the package on each PR. Reference-Url: kubevirt-ui/vnc-keymaps#7 Signed-off-by: Radoslaw Szwajkowski <rszwajko@redhat.com>
Follow the approach used in vnc-keymap project. Support node version >= 20. Add workflow to build the package on each PR. Reference-Url: kubevirt-ui/vnc-keymaps#7 Signed-off-by: Radoslaw Szwajkowski <rszwajko@redhat.com>
Summary by CodeRabbit
Release Notes
✏️ Tip: You can customize this high-level summary in your review settings.