@@ -428,6 +428,7 @@ pub struct PublishFlags {
428
428
pub allow_slow_types : bool ,
429
429
pub allow_dirty : bool ,
430
430
pub no_provenance : bool ,
431
+ pub set_version : Option < String > ,
431
432
}
432
433
433
434
#[ derive( Clone , Debug , Eq , PartialEq ) ]
@@ -1391,7 +1392,7 @@ pub fn flags_from_vec(args: Vec<OsString>) -> clap::error::Result<Flags> {
1391
1392
"uninstall" => uninstall_parse ( & mut flags, & mut m) ,
1392
1393
"upgrade" => upgrade_parse ( & mut flags, & mut m) ,
1393
1394
"vendor" => vendor_parse ( & mut flags, & mut m) ,
1394
- "publish" => publish_parse ( & mut flags, & mut m) ,
1395
+ "publish" => publish_parse ( & mut flags, & mut m) ? ,
1395
1396
_ => unreachable ! ( ) ,
1396
1397
}
1397
1398
} else {
@@ -3225,42 +3226,51 @@ fn publish_subcommand() -> Command {
3225
3226
command ( "publish" , "Publish the current working directory's package or workspace to JSR" , UnstableArgsConfig :: ResolutionOnly )
3226
3227
. defer ( |cmd| {
3227
3228
cmd
3228
- . arg (
3229
- Arg :: new ( "token" )
3230
- . long ( "token" )
3231
- . help ( "The API token to use when publishing. If unset, interactive authentication is be used" )
3232
- . help_heading ( PUBLISH_HEADING )
3233
- )
3229
+ . arg (
3230
+ Arg :: new ( "token" )
3231
+ . long ( "token" )
3232
+ . help ( "The API token to use when publishing. If unset, interactive authentication is be used" )
3233
+ . help_heading ( PUBLISH_HEADING )
3234
+ )
3234
3235
. arg ( config_arg ( ) )
3235
3236
. arg ( no_config_arg ( ) )
3236
3237
. arg (
3237
3238
Arg :: new ( "dry-run" )
3238
3239
. long ( "dry-run" )
3239
3240
. help ( "Prepare the package for publishing performing all checks and validations without uploading" )
3240
3241
. action ( ArgAction :: SetTrue )
3241
- . help_heading ( PUBLISH_HEADING ) ,
3242
+ . help_heading ( PUBLISH_HEADING ) ,
3242
3243
)
3243
3244
. arg (
3244
3245
Arg :: new ( "allow-slow-types" )
3245
3246
. long ( "allow-slow-types" )
3246
3247
. help ( "Allow publishing with slow types" )
3247
3248
. action ( ArgAction :: SetTrue )
3248
- . help_heading ( PUBLISH_HEADING ) ,
3249
+ . help_heading ( PUBLISH_HEADING ) ,
3249
3250
)
3250
3251
. arg (
3251
3252
Arg :: new ( "allow-dirty" )
3252
3253
. long ( "allow-dirty" )
3253
3254
. help ( "Allow publishing if the repository has uncommitted changed" )
3254
3255
. action ( ArgAction :: SetTrue )
3255
- . help_heading ( PUBLISH_HEADING ) ,
3256
- ) . arg (
3257
- Arg :: new ( "no-provenance" )
3258
- . long ( "no-provenance" )
3259
- . help ( cstr ! ( "Disable provenance attestation.
3256
+ . help_heading ( PUBLISH_HEADING ) ,
3257
+ )
3258
+ . arg (
3259
+ Arg :: new ( "no-provenance" )
3260
+ . long ( "no-provenance" )
3261
+ . help ( cstr ! ( "Disable provenance attestation.
3260
3262
<p(245)>Enabled by default on Github actions, publicly links the package to where it was built and published from.</>" ) )
3261
- . action ( ArgAction :: SetTrue )
3262
- . help_heading ( PUBLISH_HEADING )
3263
- )
3263
+ . action ( ArgAction :: SetTrue )
3264
+ . help_heading ( PUBLISH_HEADING )
3265
+ )
3266
+ . arg (
3267
+ Arg :: new ( "set-version" )
3268
+ . long ( "set-version" )
3269
+ . help ( "Set version for a package to be published.
3270
+ <p(245)>This flag can be used while publishing individual packages and cannot be used in a workspace.</>" )
3271
+ . value_name ( "VERSION" )
3272
+ . help_heading ( PUBLISH_HEADING )
3273
+ )
3264
3274
. arg ( check_arg ( /* type checks by default */ true ) )
3265
3275
. arg ( no_check_arg ( ) )
3266
3276
} )
@@ -5229,7 +5239,10 @@ fn vendor_parse(flags: &mut Flags, _matches: &mut ArgMatches) {
5229
5239
flags. subcommand = DenoSubcommand :: Vendor
5230
5240
}
5231
5241
5232
- fn publish_parse ( flags : & mut Flags , matches : & mut ArgMatches ) {
5242
+ fn publish_parse (
5243
+ flags : & mut Flags ,
5244
+ matches : & mut ArgMatches ,
5245
+ ) -> clap:: error:: Result < ( ) > {
5233
5246
flags. type_check_mode = TypeCheckMode :: Local ; // local by default
5234
5247
unstable_args_parse ( flags, matches, UnstableArgsConfig :: ResolutionOnly ) ;
5235
5248
no_check_arg_parse ( flags, matches) ;
@@ -5242,7 +5255,10 @@ fn publish_parse(flags: &mut Flags, matches: &mut ArgMatches) {
5242
5255
allow_slow_types : matches. get_flag ( "allow-slow-types" ) ,
5243
5256
allow_dirty : matches. get_flag ( "allow-dirty" ) ,
5244
5257
no_provenance : matches. get_flag ( "no-provenance" ) ,
5258
+ set_version : matches. remove_one :: < String > ( "set-version" ) ,
5245
5259
} ) ;
5260
+
5261
+ Ok ( ( ) )
5246
5262
}
5247
5263
5248
5264
fn compile_args_parse (
@@ -10769,6 +10785,7 @@ mod tests {
10769
10785
"--allow-slow-types" ,
10770
10786
"--allow-dirty" ,
10771
10787
"--token=asdf" ,
10788
+ "--set-version=1.0.1" ,
10772
10789
] ) ;
10773
10790
assert_eq ! (
10774
10791
r. unwrap( ) ,
@@ -10779,6 +10796,7 @@ mod tests {
10779
10796
allow_slow_types: true ,
10780
10797
allow_dirty: true ,
10781
10798
no_provenance: true ,
10799
+ set_version: Some ( "1.0.1" . to_string( ) ) ,
10782
10800
} ) ,
10783
10801
type_check_mode: TypeCheckMode :: Local ,
10784
10802
..Flags :: default ( )
0 commit comments