also looking at this
fix(publish): an accepted npm upload no longer fails on a slow readback
#259
3 files
+117
-11
| @@ -899,6 +899,17 @@ fn whoamiAction(ctx: *cli.BaseCommand.ParseContext) !void { | ||
| 899 | 899 | std.process.exit(result.exit_code); |
| 900 | 900 | } |
| 901 | 901 | |
| 902 | /// `--confirm-timeout <seconds>` as milliseconds, or null for the default. | |
| 903 | /// | |
| 904 | /// Seconds at the command line because the thing being waited on is npm's | |
| 905 | /// propagation delay, which publishers talk about in minutes. | |
| 906 | fn confirmTimeoutMs(ctx: *cli.BaseCommand.ParseContext) ?u64 { | |
| 907 | const raw = ctx.getOption("confirm-timeout") orelse return null; | |
| 908 | const seconds = std.fmt.parseInt(u64, std.mem.trim(u8, raw, " \t"), 10) catch return null; | |
| 909 | if (seconds == 0) return null; | |
| 910 | return seconds * 1000; | |
| 911 | } | |
| 912 | ||
| 902 | 913 | fn publishAction(ctx: *cli.BaseCommand.ParseContext) !void { |
| 903 | 914 | const allocator = ctx.allocator; |
| 904 | 915 | |
| @@ -929,6 +940,7 @@ fn publishAction(ctx: *cli.BaseCommand.ParseContext) !void { | ||
| 929 | 940 | .skip_existing = !force_republish, |
| 930 | 941 | .ignore_scripts = ignore_scripts, |
| 931 | 942 | .readback = !ctx.hasOption("no-readback"), |
| 943 | .confirm_timeout_ms = confirmTimeoutMs(ctx), | |
| 932 | 944 | }; |
| 933 | 945 | |
| 934 | 946 | const result = try lib.commands.publishCommand(allocator, &[_][]const u8{}, options); |
| @@ -1428,6 +1440,7 @@ fn registryPublishAction(ctx: *cli.BaseCommand.ParseContext) !void { | ||
| 1428 | 1440 | .skip_existing = !force_republish, |
| 1429 | 1441 | .ignore_scripts = ignore_scripts, |
| 1430 | 1442 | .readback = !ctx.hasOption("no-readback"), |
| 1443 | .confirm_timeout_ms = confirmTimeoutMs(ctx), | |
| 1431 | 1444 | }; |
| 1432 | 1445 | |
| 1433 | 1446 | const result = try lib.commands.publishCommand(allocator, paths.items, npm_options); |
| @@ -3624,6 +3637,7 @@ pub fn main() !void { | ||
| 3624 | 3637 | _ = try npm_publish_cmd.addOption(npm_force_republish_opt); |
| 3625 | 3638 | const npm_no_readback_opt = cli.Option.init("no-readback", "no-readback", "Report an accepted upload without reading it back from the public registry (for a caller that verifies every package itself)", .bool); |
| 3626 | 3639 | _ = try npm_publish_cmd.addOption(npm_no_readback_opt); |
| 3640 | _ = try npm_publish_cmd.addOption(cli.Option.init("confirm-timeout", "confirm-timeout", "Seconds to wait for an accepted upload to become public before reporting it pending (default 600)", .string)); | |
| 3627 | 3641 | |
| 3628 | 3642 | const npm_ignore_scripts_opt = cli.Option.init("ignore-scripts", "ignore-scripts", "Don't run package lifecycle scripts (prepublishOnly/prepack/etc.); use with a separate build step", .bool); |
| 3629 | 3643 | _ = try npm_publish_cmd.addOption(npm_ignore_scripts_opt); |
| @@ -4711,6 +4725,7 @@ pub fn main() !void { | ||
| 4711 | 4725 | _ = try publish_cmd.addOption(pub_ignore_scripts_opt); |
| 4712 | 4726 | const pub_no_readback_opt = cli.Option.init("no-readback", "no-readback", "Report an accepted npm upload without reading it back from the public registry (for a caller that verifies every package itself)", .bool); |
| 4713 | 4727 | _ = try publish_cmd.addOption(pub_no_readback_opt); |
| 4728 | _ = try publish_cmd.addOption(cli.Option.init("confirm-timeout", "confirm-timeout", "Seconds to wait for an accepted npm upload to become public before reporting it pending (default 600)", .string)); | |
| 4714 | 4729 | |
| 4715 | 4730 | const pub_paths_arg = cli.Argument.init("paths", "Package directories or globs to publish (e.g., './packages/*'); defaults to auto-detecting packages/", .string) |
| 4716 | 4731 | .withRequired(false) |