-
Notifications
You must be signed in to change notification settings - Fork 278
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
fix(utils): fixed the issue that the release version of the utils package could not correspond #2837
Conversation
…kage could not correspond
WalkthroughThis pull request involves updating the version of the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 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 (
|
Walkthrough修复了utils包发布版本无法对应的问题。通过修改 Changes
|
@@ -4,7 +4,7 @@ import { promises as fs } from 'node:fs' | |||
async function run() { | |||
const content = await fs.readFile(resolve('package.json'), 'utf8') | |||
const packageJson = JSON.parse(content) | |||
packageJson.dependencies['@opentiny/utils'] = '^1.0.0' | |||
packageJson.dependencies['@opentiny/utils'] = `~${packageJson.version.split('.').slice(0, 2).join('.')}.0` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change in dependency versioning from a fixed ^1.0.0
to a dynamic version based on the current package version ensures that the utils package version aligns with the minor version of the current package. This is a critical fix to ensure compatibility and prevent potential version mismatches.
WalkthroughFixed the problem that the released version of the utils package cannot correspond. By modifying the definition of the Changes
|
[e2e-test-warn] The title of the Pull request should look like "fix(vue-renderless): [action-menu, alert] fix xxx bug". Please make sure you've read our contributing guide |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🔭 Outside diff range comments (1)
packages/renderless/scripts/postbuild.ts (1)
Line range hint
7-11
: Consider adding error handling.The script performs file operations and JSON parsing without any error handling. Consider adding try-catch blocks to handle potential errors gracefully.
async function run() { + try { const content = await fs.readFile(resolve('package.json'), 'utf8') const packageJson = JSON.parse(content) packageJson.dependencies['@opentiny/utils'] = `~${packageJson.version.split('.').slice(0, 2).join('.')}.0` delete packageJson.exports delete packageJson.private await fs.writeFile(resolve('dist', 'package.json'), JSON.stringify(packageJson, null, 2)) + } catch (error) { + console.error('Failed to process package.json:', error) + process.exit(1) + } }🧰 Tools
🪛 Biome (1.9.4)
[error] 8-8: Avoid the delete operator which can impact performance.
Unsafe fix: Use an undefined assignment instead.
(lint/performance/noDelete)
[error] 9-9: Avoid the delete operator which can impact performance.
Unsafe fix: Use an undefined assignment instead.
(lint/performance/noDelete)
🧹 Nitpick comments (1)
packages/renderless/scripts/postbuild.ts (1)
7-7
: Review the version range specifier choice.The current implementation uses the
~
prefix which only allows patch-level changes. Consider using^
instead to allow minor version updates while still preventing breaking changes from major version updates.- packageJson.dependencies['@opentiny/utils'] = `~${packageJson.version.split('.').slice(0, 2).join('.')}.0` + packageJson.dependencies['@opentiny/utils'] = `^${packageJson.version.split('.').slice(0, 2).join('.')}.0`
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/renderless/scripts/postbuild.ts
(1 hunks)packages/utils/package.json
(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- packages/utils/package.json
🔇 Additional comments (1)
packages/renderless/scripts/postbuild.ts (1)
7-7
: Verify the impact of forcing patch version to 0.The current implementation forces the patch version to 0, which might skip important fixes in the latest patch release. Let's verify if there are any critical patches that should not be skipped.
✅ Verification successful
The version pattern ~major.minor.0 is a valid dependency specification.
The current implementation is correct because:
- It's a build-time modification that doesn't affect development
- Follows semantic versioning by allowing patches within the same minor version
- Provides controlled dependency management between packages
- Uses workspace dependencies during development for accurate local testing
The forced .0 patch in the dependency specification is an intentional pattern to maintain stability and ensure controlled updates through minor version bumps, rather than a limitation that might skip important fixes.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Check the available versions of @opentiny/utils to see if we're potentially skipping important patches curl -s https://registry.npmjs.org/@opentiny/utils | jq -r '.versions | keys[]' | grep "^3.21" || echo "No 3.21.x versions found"Length of output: 155
Script:
#!/bin/bash # Check if package exists and list all available versions echo "Checking @opentiny/utils versions:" curl -s https://registry.npmjs.org/@opentiny/utils | jq -r '.versions | keys[]' || echo "Package not found or error occurred" # Also check the package.json to understand the current version echo -e "\nChecking current package version:" fd -t f "package.json" --exec grep -l "\"version\":" {} \; -x cat {}Length of output: 66000
Script:
#!/bin/bash # Check the package.json containing the postbuild script echo "Checking renderless package.json:" cat packages/renderless/package.json # Look for any version specifications in the codebase echo -e "\nChecking for version patterns in the codebase:" rg -g '!package.json' -g '!package-lock.json' -g '!yarn.lock' -g '!pnpm-lock.yaml' "version" --type tsLength of output: 44955
修复utils包发布版本无法对应的问题
PR
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information
Summary by CodeRabbit
@opentiny/utils
package version from1.0.0
to3.21.0