Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
#change the organization for npm
- run: sed -i -E 's/@kubevirt-ui/@kubevirt-ui-ext/' package.json
Comment on lines +30 to +31
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot Dec 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

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.json

Alternatively, 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.

Suggested change
#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
Suggested change
#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');"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a jq command that could easily patch the file?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.json

In 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.json

This approach:

  • ✅ Only modifies the name field
  • ✅ Preserves JSON formatting
  • ✅ Won't accidentally replace @kubevirt-ui in the repository URL
  • jq is pre-installed on GitHub Actions ubuntu-latest runners

- uses: actions/setup-node@v6
with:
node-version: '22'
Expand All @@ -37,4 +39,4 @@ jobs:
- run: npm run build
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN_FOR_KUBEVIRT_UI_EXT }}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kubevirt-ui/vnc-keymaps",
"version": "1.0.0",
"version": "1.0.1",
"type": "module",
"publishConfig": {
"registry": "https://npm.pkg.github.com"
Expand Down