pubm 0.2.8 → 0.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -4486,7 +4486,7 @@ var Listr = (_a23 = class {
4486
4486
  // src/tasks/runner.ts
4487
4487
  var import_semver3 = __toESM(require("semver"), 1);
4488
4488
  var import_std_env = require("std-env");
4489
- var import_tinyexec8 = require("tinyexec");
4489
+ var import_tinyexec9 = require("tinyexec");
4490
4490
 
4491
4491
  // src/ecosystem/rust.ts
4492
4492
  var import_promises2 = require("fs/promises");
@@ -4608,6 +4608,7 @@ var RustEcosystem = class extends Ecosystem {
4608
4608
  };
4609
4609
 
4610
4610
  // src/error.ts
4611
+ var import_tinyexec2 = require("tinyexec");
4611
4612
  var AbstractError = class extends Error {
4612
4613
  constructor(message, { cause } = {}) {
4613
4614
  super(message, { cause });
@@ -4618,20 +4619,49 @@ var AbstractError = class extends Error {
4618
4619
  function replaceCode(code) {
4619
4620
  return code.replace(/`([^`].+)`/g, color.bold(color.underline("$1")));
4620
4621
  }
4622
+ function formatStderr(stderr) {
4623
+ return stderr.split("\n").map((line) => ` ${color.dim("\u2502")} ${line}`).join("\n");
4624
+ }
4625
+ function isNoisyCause(cause) {
4626
+ if (cause instanceof import_tinyexec2.NonZeroExitError) return true;
4627
+ if (cause instanceof Error && /Process exited with non-zero status/i.test(cause.message))
4628
+ return true;
4629
+ return false;
4630
+ }
4621
4631
  function formatError(error) {
4622
4632
  if (!(error instanceof Error)) return `${error}`;
4623
- const message = typeof error.message === "string" ? replaceCode(error.message) : (
4633
+ const rawMessage = typeof error.message === "string" ? error.message : (
4624
4634
  /* v8 ignore next */
4625
- formatError(error)
4635
+ String(error)
4626
4636
  );
4627
- let stringifyError = `${color.bgRed(` ${error.name} `)}${color.reset("")} ${message}
4637
+ const newlineIndex = rawMessage.indexOf("\n");
4638
+ let summary;
4639
+ let detail;
4640
+ if (newlineIndex !== -1) {
4641
+ summary = rawMessage.slice(0, newlineIndex);
4642
+ detail = rawMessage.slice(newlineIndex + 1);
4643
+ } else {
4644
+ summary = rawMessage;
4645
+ }
4646
+ let result = `${color.bgRed(` ${error.name} `)}${color.reset("")} ${replaceCode(summary)}
4628
4647
  `;
4629
- stringifyError += error.stack?.split("\n").slice(1).join("\n").replace(/at/g, color.dim("at")).replace(/\(([^(].+)\)/g, `(${color.blue("$1")})`);
4630
- if (error.cause) {
4631
- stringifyError += "\n\nCaused: ";
4632
- stringifyError += formatError(error.cause);
4648
+ if (detail) {
4649
+ result += `
4650
+ ${formatStderr(detail)}
4651
+ `;
4652
+ }
4653
+ if (process.env.DEBUG === "pubm" && error.stack) {
4654
+ result += error.stack.split("\n").slice(1).join("\n").replace(/at/g, color.dim("at")).replace(/\(([^(].+)\)/g, `(${color.blue("$1")})`);
4655
+ }
4656
+ if (error.cause && !isNoisyCause(error.cause)) {
4657
+ const causeMsg = error.cause instanceof Error ? error.cause.message : String(error.cause);
4658
+ if (causeMsg !== summary) {
4659
+ result += `
4660
+ ${color.dim("Caused by:")} `;
4661
+ result += formatError(error.cause);
4662
+ }
4633
4663
  }
4634
- return stringifyError;
4664
+ return result;
4635
4665
  }
4636
4666
  function consoleError(error) {
4637
4667
  let errorText = "\n";
@@ -4648,7 +4678,7 @@ function consoleError(error) {
4648
4678
 
4649
4679
  // src/git.ts
4650
4680
  var import_semver = __toESM(require("semver"), 1);
4651
- var import_tinyexec2 = require("tinyexec");
4681
+ var import_tinyexec3 = require("tinyexec");
4652
4682
  var GitError = class extends AbstractError {
4653
4683
  constructor() {
4654
4684
  super(...arguments);
@@ -4657,7 +4687,7 @@ var GitError = class extends AbstractError {
4657
4687
  };
4658
4688
  var Git = class {
4659
4689
  async git(args) {
4660
- const { stdout } = await (0, import_tinyexec2.exec)("git", args, { throwOnError: true });
4690
+ const { stdout } = await (0, import_tinyexec3.exec)("git", args, { throwOnError: true });
4661
4691
  return stdout;
4662
4692
  }
4663
4693
  async userName() {
@@ -4911,7 +4941,7 @@ var Git = class {
4911
4941
  async push(options) {
4912
4942
  const args = ["push", options].filter((v) => v);
4913
4943
  try {
4914
- const { stderr } = await (0, import_tinyexec2.exec)("git", args, { throwOnError: true });
4944
+ const { stderr } = await (0, import_tinyexec3.exec)("git", args, { throwOnError: true });
4915
4945
  if (`${stderr}`.includes("GH006")) {
4916
4946
  return false;
4917
4947
  }
@@ -4985,12 +5015,19 @@ var rollbacks = [];
4985
5015
  function addRollback(rollback2, context) {
4986
5016
  rollbacks.push({ fn: rollback2, ctx: context });
4987
5017
  }
5018
+ function rollbackLog(message) {
5019
+ console.log(` ${color.yellow("\u21A9")} ${message}`);
5020
+ }
5021
+ function rollbackError(message) {
5022
+ console.error(` ${color.red("\u2717")} ${message}`);
5023
+ }
4988
5024
  var called = false;
4989
5025
  async function rollback() {
4990
5026
  if (called) return void 0;
4991
5027
  called = true;
4992
5028
  if (rollbacks.length <= 0) return void 0;
4993
- console.log("Rollback...");
5029
+ console.log(`
5030
+ ${color.yellow("\u27F2")} ${color.yellow("Rolling back...")}`);
4994
5031
  const results = await Promise.allSettled(
4995
5032
  rollbacks.map(({ fn, ctx }) => fn(ctx))
4996
5033
  );
@@ -4999,15 +5036,15 @@ async function rollback() {
4999
5036
  );
5000
5037
  if (failures.length > 0) {
5001
5038
  for (const failure of failures) {
5002
- console.error(
5003
- `Rollback operation failed: ${failure.reason instanceof Error ? failure.reason.message : failure.reason}`
5039
+ rollbackError(
5040
+ failure.reason instanceof Error ? failure.reason.message : failure.reason
5004
5041
  );
5005
5042
  }
5006
5043
  console.log(
5007
- "Rollback completed with errors. Some operations may require manual recovery."
5044
+ `${color.red("\u2717")} ${color.red("Rollback completed with errors.")} Some operations may require manual recovery.`
5008
5045
  );
5009
5046
  } else {
5010
- console.log("Rollback completed");
5047
+ console.log(`${color.green("\u2713")} Rollback completed`);
5011
5048
  }
5012
5049
  }
5013
5050
 
@@ -5368,19 +5405,25 @@ var TOKEN_CONFIG = {
5368
5405
  envVar: "NODE_AUTH_TOKEN",
5369
5406
  dbKey: "npm-token",
5370
5407
  ghSecretName: "NODE_AUTH_TOKEN",
5371
- promptLabel: "npm access token"
5408
+ promptLabel: "npm access token",
5409
+ tokenUrl: "https://www.npmjs.com/settings/~/tokens/granular-access-tokens/new",
5410
+ tokenUrlLabel: "npmjs.com"
5372
5411
  },
5373
5412
  jsr: {
5374
5413
  envVar: "JSR_TOKEN",
5375
5414
  dbKey: "jsr-token",
5376
5415
  ghSecretName: "JSR_TOKEN",
5377
- promptLabel: "jsr API token"
5416
+ promptLabel: "jsr API token",
5417
+ tokenUrl: "https://jsr.io/account/tokens/create",
5418
+ tokenUrlLabel: "jsr.io"
5378
5419
  },
5379
5420
  crates: {
5380
5421
  envVar: "CARGO_REGISTRY_TOKEN",
5381
5422
  dbKey: "cargo-token",
5382
5423
  ghSecretName: "CARGO_REGISTRY_TOKEN",
5383
- promptLabel: "crates.io API token"
5424
+ promptLabel: "crates.io API token",
5425
+ tokenUrl: "https://crates.io/settings/tokens/new",
5426
+ tokenUrlLabel: "crates.io"
5384
5427
  }
5385
5428
  };
5386
5429
  function loadTokensFromDb(registries) {
@@ -5394,6 +5437,7 @@ function loadTokensFromDb(registries) {
5394
5437
  }
5395
5438
  return tokens;
5396
5439
  }
5440
+ var NPM_AUTH_ENV_VAR = "npm_config_//registry.npmjs.org/:_authToken";
5397
5441
  function injectTokensToEnv(tokens) {
5398
5442
  const originals = {};
5399
5443
  for (const [registry, token] of Object.entries(tokens)) {
@@ -5401,6 +5445,10 @@ function injectTokensToEnv(tokens) {
5401
5445
  if (!config) continue;
5402
5446
  originals[config.envVar] = process.env[config.envVar];
5403
5447
  process.env[config.envVar] = token;
5448
+ if (registry === "npm") {
5449
+ originals[NPM_AUTH_ENV_VAR] = process.env[NPM_AUTH_ENV_VAR];
5450
+ process.env[NPM_AUTH_ENV_VAR] = token;
5451
+ }
5404
5452
  }
5405
5453
  return () => {
5406
5454
  for (const [envVar, original] of Object.entries(originals)) {
@@ -5415,7 +5463,7 @@ function injectTokensToEnv(tokens) {
5415
5463
 
5416
5464
  // src/registry/crates.ts
5417
5465
  var import_node_path5 = __toESM(require("path"), 1);
5418
- var import_tinyexec3 = require("tinyexec");
5466
+ var import_tinyexec4 = require("tinyexec");
5419
5467
 
5420
5468
  // src/registry/registry.ts
5421
5469
  var Registry = class {
@@ -5435,6 +5483,14 @@ var CratesError = class extends AbstractError {
5435
5483
  }
5436
5484
  };
5437
5485
  var USER_AGENT = "pubm (https://github.com/syi0808/pubm)";
5486
+ function cleanCargoStderr(stderr) {
5487
+ return stderr.split("\n").filter((line) => {
5488
+ const trimmed = line.trim();
5489
+ if (trimmed === "Updating crates.io index") return false;
5490
+ if (trimmed === "") return false;
5491
+ return true;
5492
+ }).join("\n");
5493
+ }
5438
5494
  var CratesRegistry = class extends Registry {
5439
5495
  constructor() {
5440
5496
  super(...arguments);
@@ -5455,7 +5511,7 @@ var CratesRegistry = class extends Registry {
5455
5511
  }
5456
5512
  async isInstalled() {
5457
5513
  try {
5458
- await (0, import_tinyexec3.exec)("cargo", ["--version"]);
5514
+ await (0, import_tinyexec4.exec)("cargo", ["--version"]);
5459
5515
  return true;
5460
5516
  } catch {
5461
5517
  return false;
@@ -5496,12 +5552,12 @@ var CratesRegistry = class extends Registry {
5496
5552
  if (manifestDir) {
5497
5553
  args.push("--manifest-path", import_node_path5.default.join(manifestDir, "Cargo.toml"));
5498
5554
  }
5499
- await (0, import_tinyexec3.exec)("cargo", args, { throwOnError: true });
5555
+ await (0, import_tinyexec4.exec)("cargo", args, { throwOnError: true });
5500
5556
  return true;
5501
5557
  } catch (error) {
5502
- const stderr = error instanceof import_tinyexec3.NonZeroExitError ? error.output?.stderr : void 0;
5558
+ const stderr = error instanceof import_tinyexec4.NonZeroExitError ? error.output?.stderr : void 0;
5503
5559
  const message = stderr ? `Failed to run \`cargo publish\`:
5504
- ${stderr}` : "Failed to run `cargo publish`";
5560
+ ${cleanCargoStderr(stderr)}` : "Failed to run `cargo publish`";
5505
5561
  throw new CratesError(message, { cause: error });
5506
5562
  }
5507
5563
  }
@@ -5511,11 +5567,11 @@ ${stderr}` : "Failed to run `cargo publish`";
5511
5567
  if (manifestDir) {
5512
5568
  args.push("--manifest-path", import_node_path5.default.join(manifestDir, "Cargo.toml"));
5513
5569
  }
5514
- await (0, import_tinyexec3.exec)("cargo", args, { throwOnError: true });
5570
+ await (0, import_tinyexec4.exec)("cargo", args, { throwOnError: true });
5515
5571
  } catch (error) {
5516
- const stderr = error instanceof import_tinyexec3.NonZeroExitError ? error.output?.stderr : void 0;
5572
+ const stderr = error instanceof import_tinyexec4.NonZeroExitError ? error.output?.stderr : void 0;
5517
5573
  const message = stderr ? `Failed to run \`cargo publish --dry-run\`:
5518
- ${stderr}` : "Failed to run `cargo publish --dry-run`";
5574
+ ${cleanCargoStderr(stderr)}` : "Failed to run `cargo publish --dry-run`";
5519
5575
  throw new CratesError(message, { cause: error });
5520
5576
  }
5521
5577
  }
@@ -5637,7 +5693,7 @@ var cratesPublishTasks = createCratesPublishTask();
5637
5693
  var import_prompt_adapter_enquirer = require("@listr2/prompt-adapter-enquirer");
5638
5694
 
5639
5695
  // src/registry/jsr.ts
5640
- var import_tinyexec4 = require("tinyexec");
5696
+ var import_tinyexec5 = require("tinyexec");
5641
5697
 
5642
5698
  // src/utils/package-name.ts
5643
5699
  var import_node_module = require("module");
@@ -5648,7 +5704,7 @@ function getScope(packageName) {
5648
5704
  return packageName.match(/^@([^/]+)/)?.[1] ?? null;
5649
5705
  }
5650
5706
  function getScopeAndName(packageName) {
5651
- const matches = packageName.match(/^@([a-zA-Z0-9]+)\/([a-zA-Z0-9]+)$/);
5707
+ const matches = packageName.match(/^@([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_.-]+)$/);
5652
5708
  if (!matches) {
5653
5709
  throw new Error(
5654
5710
  `Invalid scoped package name: '${packageName}'. Expected format: @scope/name`
@@ -5694,7 +5750,7 @@ var JsrError = class extends AbstractError {
5694
5750
  function getApiEndpoint(registry) {
5695
5751
  const url = new URL(registry);
5696
5752
  url.host = `api.${url.host}`;
5697
- return `${url}`;
5753
+ return url.href.replace(/\/$/, "");
5698
5754
  }
5699
5755
  var JsrRegisry = class extends Registry {
5700
5756
  constructor(packageName, registry) {
@@ -5705,7 +5761,7 @@ var JsrRegisry = class extends Registry {
5705
5761
  this.client = new JsrClient(getApiEndpoint(this.registry));
5706
5762
  }
5707
5763
  async jsr(args) {
5708
- const { stdout } = await (0, import_tinyexec4.exec)("jsr", args, { throwOnError: true });
5764
+ const { stdout } = await (0, import_tinyexec5.exec)("jsr", args, { throwOnError: true });
5709
5765
  return stdout;
5710
5766
  }
5711
5767
  async isInstalled() {
@@ -5721,7 +5777,7 @@ var JsrRegisry = class extends Registry {
5721
5777
  }
5722
5778
  async ping() {
5723
5779
  try {
5724
- const { stdout } = await (0, import_tinyexec4.exec)(
5780
+ const { stdout } = await (0, import_tinyexec5.exec)(
5725
5781
  "ping",
5726
5782
  [new URL(this.registry).hostname, "-c", "1"],
5727
5783
  { throwOnError: true }
@@ -5736,7 +5792,7 @@ var JsrRegisry = class extends Registry {
5736
5792
  }
5737
5793
  async publish() {
5738
5794
  try {
5739
- await (0, import_tinyexec4.exec)(
5795
+ await (0, import_tinyexec5.exec)(
5740
5796
  "jsr",
5741
5797
  ["publish", "--allow-dirty", "--token", `${JsrClient.token}`],
5742
5798
  {
@@ -5746,7 +5802,7 @@ var JsrRegisry = class extends Registry {
5746
5802
  this.packageCreationUrls = void 0;
5747
5803
  return true;
5748
5804
  } catch (error) {
5749
- const stderr = error instanceof import_tinyexec4.NonZeroExitError ? error.output?.stderr : void 0;
5805
+ const stderr = error instanceof import_tinyexec5.NonZeroExitError ? error.output?.stderr : void 0;
5750
5806
  if (stderr?.includes("don't exist")) {
5751
5807
  const urls = [...stderr.matchAll(/https:\/\/jsr\.io\/new\S+/g)].map(
5752
5808
  (m) => m[0]
@@ -5767,7 +5823,7 @@ ${stderr}` : ""}`,
5767
5823
  }
5768
5824
  async dryRunPublish() {
5769
5825
  try {
5770
- await (0, import_tinyexec4.exec)(
5826
+ await (0, import_tinyexec5.exec)(
5771
5827
  "jsr",
5772
5828
  [
5773
5829
  "publish",
@@ -5779,9 +5835,14 @@ ${stderr}` : ""}`,
5779
5835
  { throwOnError: true }
5780
5836
  );
5781
5837
  } catch (error) {
5782
- throw new JsrError("Failed to run `jsr publish --dry-run`", {
5783
- cause: error
5784
- });
5838
+ const stderr = error instanceof import_tinyexec5.NonZeroExitError ? error.output?.stderr : void 0;
5839
+ throw new JsrError(
5840
+ `Failed to run \`jsr publish --dry-run\`${stderr ? `
5841
+ ${stderr}` : ""}`,
5842
+ {
5843
+ cause: error
5844
+ }
5845
+ );
5785
5846
  }
5786
5847
  }
5787
5848
  async version() {
@@ -5813,7 +5874,7 @@ ${stderr}` : ""}`,
5813
5874
  }
5814
5875
  }
5815
5876
  async hasPermission() {
5816
- return this.client.scopePermission(`${getScope(this.packageName)}`) !== null;
5877
+ return await this.client.scopePermission(`${getScope(this.packageName)}`) !== null;
5817
5878
  }
5818
5879
  async isPackageNameAvaliable() {
5819
5880
  return isValidPackageName(this.packageName);
@@ -6041,7 +6102,7 @@ async function jsrRegistry() {
6041
6102
  // src/registry/npm.ts
6042
6103
  var import_node_os = require("os");
6043
6104
  var import_node_path6 = require("path");
6044
- var import_tinyexec5 = require("tinyexec");
6105
+ var import_tinyexec6 = require("tinyexec");
6045
6106
  var NpmError = class extends AbstractError {
6046
6107
  constructor() {
6047
6108
  super(...arguments);
@@ -6054,7 +6115,7 @@ var NpmRegistry = class extends Registry {
6054
6115
  __publicField(this, "registry", "https://registry.npmjs.org");
6055
6116
  }
6056
6117
  async npm(args) {
6057
- const { stdout } = await (0, import_tinyexec5.exec)("npm", args, { throwOnError: true });
6118
+ const { stdout } = await (0, import_tinyexec6.exec)("npm", args, { throwOnError: true });
6058
6119
  return stdout;
6059
6120
  }
6060
6121
  async isInstalled() {
@@ -6111,7 +6172,7 @@ var NpmRegistry = class extends Registry {
6111
6172
  await this.npm(["whoami"]);
6112
6173
  return true;
6113
6174
  } catch (error) {
6114
- if (error instanceof import_tinyexec5.NonZeroExitError) {
6175
+ if (error instanceof import_tinyexec6.NonZeroExitError) {
6115
6176
  return false;
6116
6177
  }
6117
6178
  throw new NpmError("Failed to run `npm whoami`", { cause: error });
@@ -6178,7 +6239,7 @@ var NpmRegistry = class extends Registry {
6178
6239
  }
6179
6240
  async ping() {
6180
6241
  try {
6181
- await (0, import_tinyexec5.exec)("npm", ["ping"], { throwOnError: true });
6242
+ await (0, import_tinyexec6.exec)("npm", ["ping"], { throwOnError: true });
6182
6243
  return true;
6183
6244
  } catch (error) {
6184
6245
  throw new NpmError("Failed to run `npm ping`", { cause: error });
@@ -6189,7 +6250,7 @@ var NpmRegistry = class extends Registry {
6189
6250
  await this.npm(["publish", "--provenance", "--access", "public"]);
6190
6251
  return true;
6191
6252
  } catch (error) {
6192
- if (error instanceof import_tinyexec5.NonZeroExitError && error.output?.stderr.includes("EOTP")) {
6253
+ if (error instanceof import_tinyexec6.NonZeroExitError && error.output?.stderr.includes("EOTP")) {
6193
6254
  return false;
6194
6255
  }
6195
6256
  throw this.classifyPublishError(error);
@@ -6201,7 +6262,7 @@ var NpmRegistry = class extends Registry {
6201
6262
  await this.npm(args);
6202
6263
  return true;
6203
6264
  } catch (error) {
6204
- if (error instanceof import_tinyexec5.NonZeroExitError && error.output?.stderr.includes("EOTP")) {
6265
+ if (error instanceof import_tinyexec6.NonZeroExitError && error.output?.stderr.includes("EOTP")) {
6205
6266
  return false;
6206
6267
  }
6207
6268
  throw this.classifyPublishError(error);
@@ -6209,7 +6270,7 @@ var NpmRegistry = class extends Registry {
6209
6270
  }
6210
6271
  async dryRunPublish() {
6211
6272
  try {
6212
- await (0, import_tinyexec5.exec)("npm", ["publish", "--dry-run"], {
6273
+ await (0, import_tinyexec6.exec)("npm", ["publish", "--dry-run"], {
6213
6274
  throwOnError: true,
6214
6275
  nodeOptions: {
6215
6276
  env: {
@@ -6219,7 +6280,7 @@ var NpmRegistry = class extends Registry {
6219
6280
  }
6220
6281
  });
6221
6282
  } catch (error) {
6222
- const stderr = error instanceof import_tinyexec5.NonZeroExitError ? error.output?.stderr : void 0;
6283
+ const stderr = error instanceof import_tinyexec6.NonZeroExitError ? error.output?.stderr : void 0;
6223
6284
  throw new NpmError(
6224
6285
  `Failed to run \`npm publish --dry-run\`${stderr ? `
6225
6286
  ${stderr}` : ""}`,
@@ -6246,7 +6307,7 @@ ${stderr}` : ""}`,
6246
6307
  };
6247
6308
  }
6248
6309
  classifyPublishError(error) {
6249
- if (error instanceof import_tinyexec5.NonZeroExitError) {
6310
+ if (error instanceof import_tinyexec6.NonZeroExitError) {
6250
6311
  const stderr = error.output?.stderr ?? "";
6251
6312
  if (stderr.includes("EOTP")) {
6252
6313
  return new NpmError("OTP required for publishing", { cause: error });
@@ -6783,7 +6844,7 @@ var npmPublishTasks = {
6783
6844
  // src/tasks/preflight.ts
6784
6845
  var import_node_crypto2 = require("crypto");
6785
6846
  var import_prompt_adapter_enquirer4 = require("@listr2/prompt-adapter-enquirer");
6786
- var import_tinyexec6 = require("tinyexec");
6847
+ var import_tinyexec7 = require("tinyexec");
6787
6848
  var PreflightError = class extends AbstractError {
6788
6849
  constructor() {
6789
6850
  super(...arguments);
@@ -6796,10 +6857,18 @@ async function collectTokens(registries, task) {
6796
6857
  for (const registry of registries) {
6797
6858
  const config = TOKEN_CONFIG[registry];
6798
6859
  if (!config || tokens[registry]) continue;
6860
+ let { tokenUrl } = config;
6861
+ if (registry === "npm" && tokenUrl.includes("~")) {
6862
+ const result = await (0, import_tinyexec7.exec)("npm", ["whoami"]);
6863
+ const username = result.stdout.trim();
6864
+ if (username) tokenUrl = tokenUrl.replace("~", username);
6865
+ }
6799
6866
  task.output = `Enter ${config.promptLabel}`;
6800
6867
  const token = await task.prompt(import_prompt_adapter_enquirer4.ListrEnquirerPromptAdapter).run({
6801
6868
  type: "password",
6802
- message: `Enter ${config.promptLabel}`
6869
+ message: `Enter ${config.promptLabel}`,
6870
+ footer: `
6871
+ Generate a token from ${color.bold(link2(config.tokenUrlLabel, tokenUrl))}`
6803
6872
  });
6804
6873
  tokens[registry] = token;
6805
6874
  new Db().set(config.dbKey, token);
@@ -6810,7 +6879,7 @@ async function syncGhSecrets(tokens) {
6810
6879
  for (const [registry, token] of Object.entries(tokens)) {
6811
6880
  const config = TOKEN_CONFIG[registry];
6812
6881
  if (!config) continue;
6813
- const result = (0, import_tinyexec6.exec)("gh", ["secret", "set", config.ghSecretName], {
6882
+ const result = (0, import_tinyexec7.exec)("gh", ["secret", "set", config.ghSecretName], {
6814
6883
  throwOnError: true
6815
6884
  });
6816
6885
  const proc = result.process;
@@ -7004,10 +7073,10 @@ var prerequisitesCheckTask = (options) => {
7004
7073
  var import_prompt_adapter_enquirer6 = require("@listr2/prompt-adapter-enquirer");
7005
7074
 
7006
7075
  // src/registry/custom-registry.ts
7007
- var import_tinyexec7 = require("tinyexec");
7076
+ var import_tinyexec8 = require("tinyexec");
7008
7077
  var CustomRegistry = class extends NpmRegistry {
7009
7078
  async npm(args) {
7010
- const { stdout } = await (0, import_tinyexec7.exec)(
7079
+ const { stdout } = await (0, import_tinyexec8.exec)(
7011
7080
  "npm",
7012
7081
  args.concat("--registry", this.registry),
7013
7082
  { throwOnError: true }
@@ -7288,6 +7357,12 @@ async function run(options) {
7288
7357
  promptEnabled: !import_std_env.isCI && import_node_process8.default.stdin.isTTY
7289
7358
  };
7290
7359
  let cleanupEnv;
7360
+ const onSigint = async () => {
7361
+ cleanupEnv?.();
7362
+ await rollback();
7363
+ import_node_process8.default.exit(130);
7364
+ };
7365
+ import_node_process8.default.on("SIGINT", onSigint);
7291
7366
  try {
7292
7367
  if (options.contents) import_node_process8.default.chdir(options.contents);
7293
7368
  if (options.preflight) {
@@ -7329,7 +7404,7 @@ async function run(options) {
7329
7404
  task: async (ctx2) => {
7330
7405
  const packageManager = await getPackageManager();
7331
7406
  try {
7332
- await (0, import_tinyexec8.exec)(packageManager, ["run", ctx2.testScript], {
7407
+ await (0, import_tinyexec9.exec)(packageManager, ["run", ctx2.testScript], {
7333
7408
  throwOnError: true
7334
7409
  });
7335
7410
  } catch (error) {
@@ -7346,7 +7421,7 @@ async function run(options) {
7346
7421
  task: async (ctx2) => {
7347
7422
  const packageManager = await getPackageManager();
7348
7423
  try {
7349
- await (0, import_tinyexec8.exec)(packageManager, ["run", ctx2.buildScript], {
7424
+ await (0, import_tinyexec9.exec)(packageManager, ["run", ctx2.buildScript], {
7350
7425
  throwOnError: true
7351
7426
  });
7352
7427
  } catch (error) {
@@ -7367,23 +7442,28 @@ async function run(options) {
7367
7442
  addRollback(async () => {
7368
7443
  if (tagCreated) {
7369
7444
  try {
7370
- console.log("Deleting tag...");
7445
+ rollbackLog("Deleting tag");
7371
7446
  await git.deleteTag(`${await git.latestTag()}`);
7372
7447
  } catch (error) {
7373
- console.error(
7448
+ rollbackError(
7374
7449
  `Failed to delete tag: ${error instanceof Error ? error.message : error}`
7375
7450
  );
7376
7451
  }
7377
7452
  }
7378
7453
  if (commited) {
7379
7454
  try {
7380
- console.log("Reset commits...");
7455
+ rollbackLog("Resetting commits");
7381
7456
  await git.reset();
7382
- await git.stash();
7457
+ const dirty = await git.status() !== "";
7458
+ if (dirty) {
7459
+ await git.stash();
7460
+ }
7383
7461
  await git.reset("HEAD^", "--hard");
7384
- await git.popStash();
7462
+ if (dirty) {
7463
+ await git.popStash();
7464
+ }
7385
7465
  } catch (error) {
7386
- console.error(
7466
+ rollbackError(
7387
7467
  `Failed to reset commits: ${error instanceof Error ? error.message : error}`
7388
7468
  );
7389
7469
  }
@@ -7478,6 +7558,7 @@ ${repositoryUrl}/compare/${lastRev}...${latestTag}`;
7478
7558
  parts.push(`${color.bold(name)} on ${color.red("crates.io")}`);
7479
7559
  }
7480
7560
  }
7561
+ import_node_process8.default.removeListener("SIGINT", onSigint);
7481
7562
  if (options.preflight) {
7482
7563
  cleanupEnv?.();
7483
7564
  console.log(
@@ -7495,6 +7576,7 @@ ${repositoryUrl}/compare/${lastRev}...${latestTag}`;
7495
7576
  );
7496
7577
  }
7497
7578
  } catch (e2) {
7579
+ import_node_process8.default.removeListener("SIGINT", onSigint);
7498
7580
  cleanupEnv?.();
7499
7581
  consoleError(e2);
7500
7582
  await rollback();