-
Notifications
You must be signed in to change notification settings - Fork 5.9k
feat(cli): add --save-exact and --exact flag to 'deno add' #31977
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
base: main
Are you sure you want to change the base?
Conversation
|
@dsherret @bartlomieju , rn i only did this for deno add, if you proceed, i will continue towards deno install amol@Amols-MacBook-Air deno %cd deno_test_add
amol@Amols-MacBook-Air deno_test_add %deno init
✅ Project initialized
Run these commands to get started
# Run the program
deno run main.ts
# Run the program and watch for file changes
deno task dev
# Run the tests
deno test
amol@Amols-MacBook-Air deno_test_add %cat deno.json
{
"tasks": {
"dev": "deno run --watch main.ts"
},
"imports": {
"@std/assert": "jsr:@std/assert@1"
}
}
amol@Amols-MacBook-Air deno_test_add %deno add jsr:@std/http --save-exact
error: unexpected argument '--save-exact' found
tip: a similar argument exists: '--unstable-net'
Usage: deno add <packages>...
amol@Amols-MacBook-Air deno_test_add %deno add jsr:@std/http
Add jsr:@std/[email protected]
amol@Amols-MacBook-Air deno_test_add %cat deno.json
{
"tasks": {
"dev": "deno run --watch main.ts"
},
"imports": {
"@std/assert": "jsr:@std/assert@1",
"@std/http": "jsr:@std/http@^1.0.23"
}
}
amol@Amols-MacBook-Air deno_test_add %deno remove jsr:@std/http
Removed @std/http
amol@Amols-MacBook-Air deno_test_add %cat deno.json
{
"tasks": {
"dev": "deno run --watch main.ts"
},
"imports": {
"@std/assert": "jsr:@std/assert@1"
}
}
amol@Amols-MacBook-Air deno_test_add %./target/debug/deno add jsr:@std/http --save-exact
zsh: no such file or directory: ./target/debug/deno
amol@Amols-MacBook-Air deno_test_add %../target/debug/deno add jsr:@std/http --save-exact
Add jsr:@std/[email protected]
amol@Amols-MacBook-Air deno_test_add %cat deno.json
{
"tasks": {
"dev": "deno run --watch main.ts"
},
"imports": {
"@std/assert": "jsr:@std/assert@1",
"@std/http": "jsr:@std/[email protected]"
}
}
amol@Amols-MacBook-Air deno_test_add %../target/debug/deno remove jsr:@std/http
Removed @std/http
amol@Amols-MacBook-Air deno_test_add %cat deno.json
{
"tasks": {
"dev": "deno run --watch main.ts"
},
"imports": {
"@std/assert": "jsr:@std/assert@1"
}
}
amol@Amols-MacBook-Air deno_test_add %../target/debug/deno add jsr:@std/http
Add jsr:@std/[email protected]
amol@Amols-MacBook-Air deno_test_add %cat deno.json
{
"tasks": {
"dev": "deno run --watch main.ts"
},
"imports": {
"@std/assert": "jsr:@std/assert@1",
"@std/http": "jsr:@std/http@^1.0.23"
}
}
amol@Amols-MacBook-Air deno_test_add %../target/debug/deno remove jsr:@std/http
Removed @std/http
amol@Amols-MacBook-Air deno_test_add %../target/debug/deno add jsr:@std/http --exact
Add jsr:@std/[email protected]
amol@Amols-MacBook-Air deno_test_add %cat deno.json
{
"tasks": {
"dev": "deno run --watch main.ts"
},
"imports": {
"@std/assert": "jsr:@std/assert@1",
"@std/http": "jsr:@std/[email protected]"
}
} |
…act version instead of carret Signed-off-by: Amol Yadav <[email protected]>
4a540a1 to
a7ed858
Compare
Signed-off-by: Amol Yadav <[email protected]>
Signed-off-by: Amol Yadav <[email protected]>
Signed-off-by: Amol Yadav <[email protected]>
|
I've resolved the CI failures. I added the --save-exact and --exact as alias argument definition to the All checks are passing now. Ready for review? Thanks! amol@Amols-MacBook-Air deno_test_add %cat deno.json
{
"tasks": {
"dev": "deno run --watch main.ts"
},
"imports": {
"@std/assert": "jsr:@std/assert@1"
}
}
amol@Amols-MacBook-Air deno_test_add %../target/debug/deno install jsr:@std/http --save-exact
Add jsr:@std/[email protected]
amol@Amols-MacBook-Air deno_test_add %cat deno.json
{
"tasks": {
"dev": "deno run --watch main.ts"
},
"imports": {
"@std/assert": "jsr:@std/assert@1",
"@std/http": "jsr:@std/[email protected]"
}
}
amol@Amols-MacBook-Air deno_test_add %../target/debug/deno install jsr:@zod/zod --exact
Add jsr:@zod/[email protected]
Installed 1 package in 2162ms
Reused 12 packages from cache
++++++++++++
Downloaded 1 package from JSR
+
Downloaded 0 packages from npm
Dependencies:
+ jsr:@zod/zod 4.3.6
amol@Amols-MacBook-Air deno_test_add %cat deno.json
{
"tasks": {
"dev": "deno run --watch main.ts"
},
"imports": {
"@std/assert": "jsr:@std/assert@1",
"@std/http": "jsr:@std/[email protected]",
"@zod/zod": "jsr:@zod/[email protected]"
}
}
amol@Amols-MacBook-Air deno_test_add %
|
|
@dsherret i guess it is a great DX feature! |
Fixes #30803
Description
This PR introduces the
--save-exactflag (and its alias--exact) to thedeno add. rn, deno defaults to prepending a caret (^) to installed versions (e.g.,^1.0.0). This flag allows users to opt-out of this behavior and save the exact version string (e.g.,1.0.0) todeno.jsonorpackage.json, aligning with the behavior found innpm,pnpm, andyarn.Changes
AddFlagsincli/args/flags.rsto includesave_exact.cli/tools/pm/mod.rsto pass this flag to the version selection logic.""instead of^when the flag is present.