pubm 0.2.9 → 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/bin/cli.js +55 -18
- package/dist/index.cjs +49 -12
- package/dist/index.js +49 -12
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -4728,6 +4728,12 @@ import { createHash as createHash2 } from "node:crypto";
|
|
|
4728
4728
|
import { ListrEnquirerPromptAdapter } from "@listr2/prompt-adapter-enquirer";
|
|
4729
4729
|
import { exec as exec2 } from "tinyexec";
|
|
4730
4730
|
|
|
4731
|
+
// src/utils/cli.ts
|
|
4732
|
+
var warningBadge = color.bgYellow(" Warning ");
|
|
4733
|
+
function link2(text, url) {
|
|
4734
|
+
return `\x1B]8;;${url}\x07${text}\x1B]8;;\x07`;
|
|
4735
|
+
}
|
|
4736
|
+
|
|
4731
4737
|
// src/utils/db.ts
|
|
4732
4738
|
import { createCipheriv, createDecipheriv, createHash } from "node:crypto";
|
|
4733
4739
|
import { mkdirSync as mkdirSync5, readFileSync as readFileSync2, statSync, writeFileSync as writeFileSync4 } from "node:fs";
|
|
@@ -4805,19 +4811,25 @@ var TOKEN_CONFIG = {
|
|
|
4805
4811
|
envVar: "NODE_AUTH_TOKEN",
|
|
4806
4812
|
dbKey: "npm-token",
|
|
4807
4813
|
ghSecretName: "NODE_AUTH_TOKEN",
|
|
4808
|
-
promptLabel: "npm access token"
|
|
4814
|
+
promptLabel: "npm access token",
|
|
4815
|
+
tokenUrl: "https://www.npmjs.com/settings/~/tokens/granular-access-tokens/new",
|
|
4816
|
+
tokenUrlLabel: "npmjs.com"
|
|
4809
4817
|
},
|
|
4810
4818
|
jsr: {
|
|
4811
4819
|
envVar: "JSR_TOKEN",
|
|
4812
4820
|
dbKey: "jsr-token",
|
|
4813
4821
|
ghSecretName: "JSR_TOKEN",
|
|
4814
|
-
promptLabel: "jsr API token"
|
|
4822
|
+
promptLabel: "jsr API token",
|
|
4823
|
+
tokenUrl: "https://jsr.io/account/tokens/create",
|
|
4824
|
+
tokenUrlLabel: "jsr.io"
|
|
4815
4825
|
},
|
|
4816
4826
|
crates: {
|
|
4817
4827
|
envVar: "CARGO_REGISTRY_TOKEN",
|
|
4818
4828
|
dbKey: "cargo-token",
|
|
4819
4829
|
ghSecretName: "CARGO_REGISTRY_TOKEN",
|
|
4820
|
-
promptLabel: "crates.io API token"
|
|
4830
|
+
promptLabel: "crates.io API token",
|
|
4831
|
+
tokenUrl: "https://crates.io/settings/tokens/new",
|
|
4832
|
+
tokenUrlLabel: "crates.io"
|
|
4821
4833
|
}
|
|
4822
4834
|
};
|
|
4823
4835
|
function loadTokensFromDb(registries) {
|
|
@@ -4831,6 +4843,7 @@ function loadTokensFromDb(registries) {
|
|
|
4831
4843
|
}
|
|
4832
4844
|
return tokens;
|
|
4833
4845
|
}
|
|
4846
|
+
var NPM_AUTH_ENV_VAR = "npm_config_//registry.npmjs.org/:_authToken";
|
|
4834
4847
|
function injectTokensToEnv(tokens) {
|
|
4835
4848
|
const originals = {};
|
|
4836
4849
|
for (const [registry, token] of Object.entries(tokens)) {
|
|
@@ -4838,6 +4851,10 @@ function injectTokensToEnv(tokens) {
|
|
|
4838
4851
|
if (!config) continue;
|
|
4839
4852
|
originals[config.envVar] = process.env[config.envVar];
|
|
4840
4853
|
process.env[config.envVar] = token;
|
|
4854
|
+
if (registry === "npm") {
|
|
4855
|
+
originals[NPM_AUTH_ENV_VAR] = process.env[NPM_AUTH_ENV_VAR];
|
|
4856
|
+
process.env[NPM_AUTH_ENV_VAR] = token;
|
|
4857
|
+
}
|
|
4841
4858
|
}
|
|
4842
4859
|
return () => {
|
|
4843
4860
|
for (const [envVar, original] of Object.entries(originals)) {
|
|
@@ -4863,10 +4880,18 @@ async function collectTokens(registries, task) {
|
|
|
4863
4880
|
for (const registry of registries) {
|
|
4864
4881
|
const config = TOKEN_CONFIG[registry];
|
|
4865
4882
|
if (!config || tokens[registry]) continue;
|
|
4883
|
+
let { tokenUrl } = config;
|
|
4884
|
+
if (registry === "npm" && tokenUrl.includes("~")) {
|
|
4885
|
+
const result = await exec2("npm", ["whoami"]);
|
|
4886
|
+
const username = result.stdout.trim();
|
|
4887
|
+
if (username) tokenUrl = tokenUrl.replace("~", username);
|
|
4888
|
+
}
|
|
4866
4889
|
task.output = `Enter ${config.promptLabel}`;
|
|
4867
4890
|
const token = await task.prompt(ListrEnquirerPromptAdapter).run({
|
|
4868
4891
|
type: "password",
|
|
4869
|
-
message: `Enter ${config.promptLabel}
|
|
4892
|
+
message: `Enter ${config.promptLabel}`,
|
|
4893
|
+
footer: `
|
|
4894
|
+
Generate a token from ${color.bold(link2(config.tokenUrlLabel, tokenUrl))}`
|
|
4870
4895
|
});
|
|
4871
4896
|
tokens[registry] = token;
|
|
4872
4897
|
new Db().set(config.dbKey, token);
|
|
@@ -5617,12 +5642,6 @@ var RustEcosystem = class extends Ecosystem {
|
|
|
5617
5642
|
}
|
|
5618
5643
|
};
|
|
5619
5644
|
|
|
5620
|
-
// src/utils/cli.ts
|
|
5621
|
-
var warningBadge = color.bgYellow(" Warning ");
|
|
5622
|
-
function link2(text, url) {
|
|
5623
|
-
return `\x1B]8;;${url}\x07${text}\x1B]8;;\x07`;
|
|
5624
|
-
}
|
|
5625
|
-
|
|
5626
5645
|
// src/utils/crate-graph.ts
|
|
5627
5646
|
async function sortCratesByDependencyOrder(cratePaths) {
|
|
5628
5647
|
if (cratePaths.length <= 1) return cratePaths;
|
|
@@ -6230,7 +6249,7 @@ function getScope(packageName) {
|
|
|
6230
6249
|
return packageName.match(/^@([^/]+)/)?.[1] ?? null;
|
|
6231
6250
|
}
|
|
6232
6251
|
function getScopeAndName(packageName) {
|
|
6233
|
-
const matches = packageName.match(/^@([a-zA-Z0-
|
|
6252
|
+
const matches = packageName.match(/^@([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_.-]+)$/);
|
|
6234
6253
|
if (!matches) {
|
|
6235
6254
|
throw new Error(
|
|
6236
6255
|
`Invalid scoped package name: '${packageName}'. Expected format: @scope/name`
|
|
@@ -6275,7 +6294,7 @@ var JsrError = class extends AbstractError {
|
|
|
6275
6294
|
function getApiEndpoint(registry) {
|
|
6276
6295
|
const url = new URL(registry);
|
|
6277
6296
|
url.host = `api.${url.host}`;
|
|
6278
|
-
return
|
|
6297
|
+
return url.href.replace(/\/$/, "");
|
|
6279
6298
|
}
|
|
6280
6299
|
var JsrRegisry = class extends Registry {
|
|
6281
6300
|
constructor(packageName, registry) {
|
|
@@ -6360,9 +6379,14 @@ ${stderr}` : ""}`,
|
|
|
6360
6379
|
{ throwOnError: true }
|
|
6361
6380
|
);
|
|
6362
6381
|
} catch (error) {
|
|
6363
|
-
|
|
6364
|
-
|
|
6365
|
-
|
|
6382
|
+
const stderr = error instanceof NonZeroExitError3 ? error.output?.stderr : void 0;
|
|
6383
|
+
throw new JsrError(
|
|
6384
|
+
`Failed to run \`jsr publish --dry-run\`${stderr ? `
|
|
6385
|
+
${stderr}` : ""}`,
|
|
6386
|
+
{
|
|
6387
|
+
cause: error
|
|
6388
|
+
}
|
|
6389
|
+
);
|
|
6366
6390
|
}
|
|
6367
6391
|
}
|
|
6368
6392
|
async version() {
|
|
@@ -6394,7 +6418,7 @@ ${stderr}` : ""}`,
|
|
|
6394
6418
|
}
|
|
6395
6419
|
}
|
|
6396
6420
|
async hasPermission() {
|
|
6397
|
-
return this.client.scopePermission(`${getScope(this.packageName)}`) !== null;
|
|
6421
|
+
return await this.client.scopePermission(`${getScope(this.packageName)}`) !== null;
|
|
6398
6422
|
}
|
|
6399
6423
|
async isPackageNameAvaliable() {
|
|
6400
6424
|
return isValidPackageName(this.packageName);
|
|
@@ -7794,6 +7818,12 @@ async function run(options) {
|
|
|
7794
7818
|
promptEnabled: !isCI2 && process14.stdin.isTTY
|
|
7795
7819
|
};
|
|
7796
7820
|
let cleanupEnv;
|
|
7821
|
+
const onSigint = async () => {
|
|
7822
|
+
cleanupEnv?.();
|
|
7823
|
+
await rollback();
|
|
7824
|
+
process14.exit(130);
|
|
7825
|
+
};
|
|
7826
|
+
process14.on("SIGINT", onSigint);
|
|
7797
7827
|
try {
|
|
7798
7828
|
if (options.contents) process14.chdir(options.contents);
|
|
7799
7829
|
if (options.preflight) {
|
|
@@ -7885,9 +7915,14 @@ async function run(options) {
|
|
|
7885
7915
|
try {
|
|
7886
7916
|
rollbackLog("Resetting commits");
|
|
7887
7917
|
await git.reset();
|
|
7888
|
-
await git.
|
|
7918
|
+
const dirty = await git.status() !== "";
|
|
7919
|
+
if (dirty) {
|
|
7920
|
+
await git.stash();
|
|
7921
|
+
}
|
|
7889
7922
|
await git.reset("HEAD^", "--hard");
|
|
7890
|
-
|
|
7923
|
+
if (dirty) {
|
|
7924
|
+
await git.popStash();
|
|
7925
|
+
}
|
|
7891
7926
|
} catch (error) {
|
|
7892
7927
|
rollbackError(
|
|
7893
7928
|
`Failed to reset commits: ${error instanceof Error ? error.message : error}`
|
|
@@ -7984,6 +8019,7 @@ ${repositoryUrl}/compare/${lastRev}...${latestTag}`;
|
|
|
7984
8019
|
parts.push(`${color.bold(name)} on ${color.red("crates.io")}`);
|
|
7985
8020
|
}
|
|
7986
8021
|
}
|
|
8022
|
+
process14.removeListener("SIGINT", onSigint);
|
|
7987
8023
|
if (options.preflight) {
|
|
7988
8024
|
cleanupEnv?.();
|
|
7989
8025
|
console.log(
|
|
@@ -8001,6 +8037,7 @@ ${repositoryUrl}/compare/${lastRev}...${latestTag}`;
|
|
|
8001
8037
|
);
|
|
8002
8038
|
}
|
|
8003
8039
|
} catch (e2) {
|
|
8040
|
+
process14.removeListener("SIGINT", onSigint);
|
|
8004
8041
|
cleanupEnv?.();
|
|
8005
8042
|
consoleError(e2);
|
|
8006
8043
|
await rollback();
|
package/dist/index.cjs
CHANGED
|
@@ -5405,19 +5405,25 @@ var TOKEN_CONFIG = {
|
|
|
5405
5405
|
envVar: "NODE_AUTH_TOKEN",
|
|
5406
5406
|
dbKey: "npm-token",
|
|
5407
5407
|
ghSecretName: "NODE_AUTH_TOKEN",
|
|
5408
|
-
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"
|
|
5409
5411
|
},
|
|
5410
5412
|
jsr: {
|
|
5411
5413
|
envVar: "JSR_TOKEN",
|
|
5412
5414
|
dbKey: "jsr-token",
|
|
5413
5415
|
ghSecretName: "JSR_TOKEN",
|
|
5414
|
-
promptLabel: "jsr API token"
|
|
5416
|
+
promptLabel: "jsr API token",
|
|
5417
|
+
tokenUrl: "https://jsr.io/account/tokens/create",
|
|
5418
|
+
tokenUrlLabel: "jsr.io"
|
|
5415
5419
|
},
|
|
5416
5420
|
crates: {
|
|
5417
5421
|
envVar: "CARGO_REGISTRY_TOKEN",
|
|
5418
5422
|
dbKey: "cargo-token",
|
|
5419
5423
|
ghSecretName: "CARGO_REGISTRY_TOKEN",
|
|
5420
|
-
promptLabel: "crates.io API token"
|
|
5424
|
+
promptLabel: "crates.io API token",
|
|
5425
|
+
tokenUrl: "https://crates.io/settings/tokens/new",
|
|
5426
|
+
tokenUrlLabel: "crates.io"
|
|
5421
5427
|
}
|
|
5422
5428
|
};
|
|
5423
5429
|
function loadTokensFromDb(registries) {
|
|
@@ -5431,6 +5437,7 @@ function loadTokensFromDb(registries) {
|
|
|
5431
5437
|
}
|
|
5432
5438
|
return tokens;
|
|
5433
5439
|
}
|
|
5440
|
+
var NPM_AUTH_ENV_VAR = "npm_config_//registry.npmjs.org/:_authToken";
|
|
5434
5441
|
function injectTokensToEnv(tokens) {
|
|
5435
5442
|
const originals = {};
|
|
5436
5443
|
for (const [registry, token] of Object.entries(tokens)) {
|
|
@@ -5438,6 +5445,10 @@ function injectTokensToEnv(tokens) {
|
|
|
5438
5445
|
if (!config) continue;
|
|
5439
5446
|
originals[config.envVar] = process.env[config.envVar];
|
|
5440
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
|
+
}
|
|
5441
5452
|
}
|
|
5442
5453
|
return () => {
|
|
5443
5454
|
for (const [envVar, original] of Object.entries(originals)) {
|
|
@@ -5693,7 +5704,7 @@ function getScope(packageName) {
|
|
|
5693
5704
|
return packageName.match(/^@([^/]+)/)?.[1] ?? null;
|
|
5694
5705
|
}
|
|
5695
5706
|
function getScopeAndName(packageName) {
|
|
5696
|
-
const matches = packageName.match(/^@([a-zA-Z0-
|
|
5707
|
+
const matches = packageName.match(/^@([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_.-]+)$/);
|
|
5697
5708
|
if (!matches) {
|
|
5698
5709
|
throw new Error(
|
|
5699
5710
|
`Invalid scoped package name: '${packageName}'. Expected format: @scope/name`
|
|
@@ -5739,7 +5750,7 @@ var JsrError = class extends AbstractError {
|
|
|
5739
5750
|
function getApiEndpoint(registry) {
|
|
5740
5751
|
const url = new URL(registry);
|
|
5741
5752
|
url.host = `api.${url.host}`;
|
|
5742
|
-
return
|
|
5753
|
+
return url.href.replace(/\/$/, "");
|
|
5743
5754
|
}
|
|
5744
5755
|
var JsrRegisry = class extends Registry {
|
|
5745
5756
|
constructor(packageName, registry) {
|
|
@@ -5824,9 +5835,14 @@ ${stderr}` : ""}`,
|
|
|
5824
5835
|
{ throwOnError: true }
|
|
5825
5836
|
);
|
|
5826
5837
|
} catch (error) {
|
|
5827
|
-
|
|
5828
|
-
|
|
5829
|
-
|
|
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
|
+
);
|
|
5830
5846
|
}
|
|
5831
5847
|
}
|
|
5832
5848
|
async version() {
|
|
@@ -5858,7 +5874,7 @@ ${stderr}` : ""}`,
|
|
|
5858
5874
|
}
|
|
5859
5875
|
}
|
|
5860
5876
|
async hasPermission() {
|
|
5861
|
-
return this.client.scopePermission(`${getScope(this.packageName)}`) !== null;
|
|
5877
|
+
return await this.client.scopePermission(`${getScope(this.packageName)}`) !== null;
|
|
5862
5878
|
}
|
|
5863
5879
|
async isPackageNameAvaliable() {
|
|
5864
5880
|
return isValidPackageName(this.packageName);
|
|
@@ -6841,10 +6857,18 @@ async function collectTokens(registries, task) {
|
|
|
6841
6857
|
for (const registry of registries) {
|
|
6842
6858
|
const config = TOKEN_CONFIG[registry];
|
|
6843
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
|
+
}
|
|
6844
6866
|
task.output = `Enter ${config.promptLabel}`;
|
|
6845
6867
|
const token = await task.prompt(import_prompt_adapter_enquirer4.ListrEnquirerPromptAdapter).run({
|
|
6846
6868
|
type: "password",
|
|
6847
|
-
message: `Enter ${config.promptLabel}
|
|
6869
|
+
message: `Enter ${config.promptLabel}`,
|
|
6870
|
+
footer: `
|
|
6871
|
+
Generate a token from ${color.bold(link2(config.tokenUrlLabel, tokenUrl))}`
|
|
6848
6872
|
});
|
|
6849
6873
|
tokens[registry] = token;
|
|
6850
6874
|
new Db().set(config.dbKey, token);
|
|
@@ -7333,6 +7357,12 @@ async function run(options) {
|
|
|
7333
7357
|
promptEnabled: !import_std_env.isCI && import_node_process8.default.stdin.isTTY
|
|
7334
7358
|
};
|
|
7335
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);
|
|
7336
7366
|
try {
|
|
7337
7367
|
if (options.contents) import_node_process8.default.chdir(options.contents);
|
|
7338
7368
|
if (options.preflight) {
|
|
@@ -7424,9 +7454,14 @@ async function run(options) {
|
|
|
7424
7454
|
try {
|
|
7425
7455
|
rollbackLog("Resetting commits");
|
|
7426
7456
|
await git.reset();
|
|
7427
|
-
await git.
|
|
7457
|
+
const dirty = await git.status() !== "";
|
|
7458
|
+
if (dirty) {
|
|
7459
|
+
await git.stash();
|
|
7460
|
+
}
|
|
7428
7461
|
await git.reset("HEAD^", "--hard");
|
|
7429
|
-
|
|
7462
|
+
if (dirty) {
|
|
7463
|
+
await git.popStash();
|
|
7464
|
+
}
|
|
7430
7465
|
} catch (error) {
|
|
7431
7466
|
rollbackError(
|
|
7432
7467
|
`Failed to reset commits: ${error instanceof Error ? error.message : error}`
|
|
@@ -7523,6 +7558,7 @@ ${repositoryUrl}/compare/${lastRev}...${latestTag}`;
|
|
|
7523
7558
|
parts.push(`${color.bold(name)} on ${color.red("crates.io")}`);
|
|
7524
7559
|
}
|
|
7525
7560
|
}
|
|
7561
|
+
import_node_process8.default.removeListener("SIGINT", onSigint);
|
|
7526
7562
|
if (options.preflight) {
|
|
7527
7563
|
cleanupEnv?.();
|
|
7528
7564
|
console.log(
|
|
@@ -7540,6 +7576,7 @@ ${repositoryUrl}/compare/${lastRev}...${latestTag}`;
|
|
|
7540
7576
|
);
|
|
7541
7577
|
}
|
|
7542
7578
|
} catch (e2) {
|
|
7579
|
+
import_node_process8.default.removeListener("SIGINT", onSigint);
|
|
7543
7580
|
cleanupEnv?.();
|
|
7544
7581
|
consoleError(e2);
|
|
7545
7582
|
await rollback();
|
package/dist/index.js
CHANGED
|
@@ -5371,19 +5371,25 @@ var TOKEN_CONFIG = {
|
|
|
5371
5371
|
envVar: "NODE_AUTH_TOKEN",
|
|
5372
5372
|
dbKey: "npm-token",
|
|
5373
5373
|
ghSecretName: "NODE_AUTH_TOKEN",
|
|
5374
|
-
promptLabel: "npm access token"
|
|
5374
|
+
promptLabel: "npm access token",
|
|
5375
|
+
tokenUrl: "https://www.npmjs.com/settings/~/tokens/granular-access-tokens/new",
|
|
5376
|
+
tokenUrlLabel: "npmjs.com"
|
|
5375
5377
|
},
|
|
5376
5378
|
jsr: {
|
|
5377
5379
|
envVar: "JSR_TOKEN",
|
|
5378
5380
|
dbKey: "jsr-token",
|
|
5379
5381
|
ghSecretName: "JSR_TOKEN",
|
|
5380
|
-
promptLabel: "jsr API token"
|
|
5382
|
+
promptLabel: "jsr API token",
|
|
5383
|
+
tokenUrl: "https://jsr.io/account/tokens/create",
|
|
5384
|
+
tokenUrlLabel: "jsr.io"
|
|
5381
5385
|
},
|
|
5382
5386
|
crates: {
|
|
5383
5387
|
envVar: "CARGO_REGISTRY_TOKEN",
|
|
5384
5388
|
dbKey: "cargo-token",
|
|
5385
5389
|
ghSecretName: "CARGO_REGISTRY_TOKEN",
|
|
5386
|
-
promptLabel: "crates.io API token"
|
|
5390
|
+
promptLabel: "crates.io API token",
|
|
5391
|
+
tokenUrl: "https://crates.io/settings/tokens/new",
|
|
5392
|
+
tokenUrlLabel: "crates.io"
|
|
5387
5393
|
}
|
|
5388
5394
|
};
|
|
5389
5395
|
function loadTokensFromDb(registries) {
|
|
@@ -5397,6 +5403,7 @@ function loadTokensFromDb(registries) {
|
|
|
5397
5403
|
}
|
|
5398
5404
|
return tokens;
|
|
5399
5405
|
}
|
|
5406
|
+
var NPM_AUTH_ENV_VAR = "npm_config_//registry.npmjs.org/:_authToken";
|
|
5400
5407
|
function injectTokensToEnv(tokens) {
|
|
5401
5408
|
const originals = {};
|
|
5402
5409
|
for (const [registry, token] of Object.entries(tokens)) {
|
|
@@ -5404,6 +5411,10 @@ function injectTokensToEnv(tokens) {
|
|
|
5404
5411
|
if (!config) continue;
|
|
5405
5412
|
originals[config.envVar] = process.env[config.envVar];
|
|
5406
5413
|
process.env[config.envVar] = token;
|
|
5414
|
+
if (registry === "npm") {
|
|
5415
|
+
originals[NPM_AUTH_ENV_VAR] = process.env[NPM_AUTH_ENV_VAR];
|
|
5416
|
+
process.env[NPM_AUTH_ENV_VAR] = token;
|
|
5417
|
+
}
|
|
5407
5418
|
}
|
|
5408
5419
|
return () => {
|
|
5409
5420
|
for (const [envVar, original] of Object.entries(originals)) {
|
|
@@ -5659,7 +5670,7 @@ function getScope(packageName) {
|
|
|
5659
5670
|
return packageName.match(/^@([^/]+)/)?.[1] ?? null;
|
|
5660
5671
|
}
|
|
5661
5672
|
function getScopeAndName(packageName) {
|
|
5662
|
-
const matches = packageName.match(/^@([a-zA-Z0-
|
|
5673
|
+
const matches = packageName.match(/^@([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_.-]+)$/);
|
|
5663
5674
|
if (!matches) {
|
|
5664
5675
|
throw new Error(
|
|
5665
5676
|
`Invalid scoped package name: '${packageName}'. Expected format: @scope/name`
|
|
@@ -5704,7 +5715,7 @@ var JsrError = class extends AbstractError {
|
|
|
5704
5715
|
function getApiEndpoint(registry) {
|
|
5705
5716
|
const url = new URL(registry);
|
|
5706
5717
|
url.host = `api.${url.host}`;
|
|
5707
|
-
return
|
|
5718
|
+
return url.href.replace(/\/$/, "");
|
|
5708
5719
|
}
|
|
5709
5720
|
var JsrRegisry = class extends Registry {
|
|
5710
5721
|
constructor(packageName, registry) {
|
|
@@ -5789,9 +5800,14 @@ ${stderr}` : ""}`,
|
|
|
5789
5800
|
{ throwOnError: true }
|
|
5790
5801
|
);
|
|
5791
5802
|
} catch (error) {
|
|
5792
|
-
|
|
5793
|
-
|
|
5794
|
-
|
|
5803
|
+
const stderr = error instanceof NonZeroExitError3 ? error.output?.stderr : void 0;
|
|
5804
|
+
throw new JsrError(
|
|
5805
|
+
`Failed to run \`jsr publish --dry-run\`${stderr ? `
|
|
5806
|
+
${stderr}` : ""}`,
|
|
5807
|
+
{
|
|
5808
|
+
cause: error
|
|
5809
|
+
}
|
|
5810
|
+
);
|
|
5795
5811
|
}
|
|
5796
5812
|
}
|
|
5797
5813
|
async version() {
|
|
@@ -5823,7 +5839,7 @@ ${stderr}` : ""}`,
|
|
|
5823
5839
|
}
|
|
5824
5840
|
}
|
|
5825
5841
|
async hasPermission() {
|
|
5826
|
-
return this.client.scopePermission(`${getScope(this.packageName)}`) !== null;
|
|
5842
|
+
return await this.client.scopePermission(`${getScope(this.packageName)}`) !== null;
|
|
5827
5843
|
}
|
|
5828
5844
|
async isPackageNameAvaliable() {
|
|
5829
5845
|
return isValidPackageName(this.packageName);
|
|
@@ -6806,10 +6822,18 @@ async function collectTokens(registries, task) {
|
|
|
6806
6822
|
for (const registry of registries) {
|
|
6807
6823
|
const config = TOKEN_CONFIG[registry];
|
|
6808
6824
|
if (!config || tokens[registry]) continue;
|
|
6825
|
+
let { tokenUrl } = config;
|
|
6826
|
+
if (registry === "npm" && tokenUrl.includes("~")) {
|
|
6827
|
+
const result = await exec7("npm", ["whoami"]);
|
|
6828
|
+
const username = result.stdout.trim();
|
|
6829
|
+
if (username) tokenUrl = tokenUrl.replace("~", username);
|
|
6830
|
+
}
|
|
6809
6831
|
task.output = `Enter ${config.promptLabel}`;
|
|
6810
6832
|
const token = await task.prompt(ListrEnquirerPromptAdapter4).run({
|
|
6811
6833
|
type: "password",
|
|
6812
|
-
message: `Enter ${config.promptLabel}
|
|
6834
|
+
message: `Enter ${config.promptLabel}`,
|
|
6835
|
+
footer: `
|
|
6836
|
+
Generate a token from ${color.bold(link2(config.tokenUrlLabel, tokenUrl))}`
|
|
6813
6837
|
});
|
|
6814
6838
|
tokens[registry] = token;
|
|
6815
6839
|
new Db().set(config.dbKey, token);
|
|
@@ -7297,6 +7321,12 @@ async function run(options) {
|
|
|
7297
7321
|
promptEnabled: !isCI2 && process10.stdin.isTTY
|
|
7298
7322
|
};
|
|
7299
7323
|
let cleanupEnv;
|
|
7324
|
+
const onSigint = async () => {
|
|
7325
|
+
cleanupEnv?.();
|
|
7326
|
+
await rollback();
|
|
7327
|
+
process10.exit(130);
|
|
7328
|
+
};
|
|
7329
|
+
process10.on("SIGINT", onSigint);
|
|
7300
7330
|
try {
|
|
7301
7331
|
if (options.contents) process10.chdir(options.contents);
|
|
7302
7332
|
if (options.preflight) {
|
|
@@ -7388,9 +7418,14 @@ async function run(options) {
|
|
|
7388
7418
|
try {
|
|
7389
7419
|
rollbackLog("Resetting commits");
|
|
7390
7420
|
await git.reset();
|
|
7391
|
-
await git.
|
|
7421
|
+
const dirty = await git.status() !== "";
|
|
7422
|
+
if (dirty) {
|
|
7423
|
+
await git.stash();
|
|
7424
|
+
}
|
|
7392
7425
|
await git.reset("HEAD^", "--hard");
|
|
7393
|
-
|
|
7426
|
+
if (dirty) {
|
|
7427
|
+
await git.popStash();
|
|
7428
|
+
}
|
|
7394
7429
|
} catch (error) {
|
|
7395
7430
|
rollbackError(
|
|
7396
7431
|
`Failed to reset commits: ${error instanceof Error ? error.message : error}`
|
|
@@ -7487,6 +7522,7 @@ ${repositoryUrl}/compare/${lastRev}...${latestTag}`;
|
|
|
7487
7522
|
parts.push(`${color.bold(name)} on ${color.red("crates.io")}`);
|
|
7488
7523
|
}
|
|
7489
7524
|
}
|
|
7525
|
+
process10.removeListener("SIGINT", onSigint);
|
|
7490
7526
|
if (options.preflight) {
|
|
7491
7527
|
cleanupEnv?.();
|
|
7492
7528
|
console.log(
|
|
@@ -7504,6 +7540,7 @@ ${repositoryUrl}/compare/${lastRev}...${latestTag}`;
|
|
|
7504
7540
|
);
|
|
7505
7541
|
}
|
|
7506
7542
|
} catch (e2) {
|
|
7543
|
+
process10.removeListener("SIGINT", onSigint);
|
|
7507
7544
|
cleanupEnv?.();
|
|
7508
7545
|
consoleError(e2);
|
|
7509
7546
|
await rollback();
|