pubm 0.0.2-9 → 0.0.3
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/README.md +4 -1
- package/bin/cli.js +91 -56
- package/dist/index.cjs +71 -36
- package/dist/index.js +67 -32
- package/package.json +3 -6
- package/bin/.pubm/NjcyMGM5OTA3Yzk3MWMyZjEwYTYxOTQwMGZmOWM0ZTA= +0 -1
package/README.md
CHANGED
|
@@ -17,6 +17,7 @@ publish manager for multiple registry (jsr, npm and private registries)
|
|
|
17
17
|
## Features
|
|
18
18
|
|
|
19
19
|
- Publish package to npm and jsr at once
|
|
20
|
+
- Private registry support (Soon)
|
|
20
21
|
- Customize (Soon)
|
|
21
22
|
- GitHub release draft format
|
|
22
23
|
- Adjust tasks (Add, Remove, Sorting tasks)
|
|
@@ -26,6 +27,7 @@ publish manager for multiple registry (jsr, npm and private registries)
|
|
|
26
27
|
- Node.js 18 or later
|
|
27
28
|
- npm 9 or later
|
|
28
29
|
- Git 2.11 or later
|
|
30
|
+
- jsr
|
|
29
31
|
|
|
30
32
|
## Install
|
|
31
33
|
|
|
@@ -54,13 +56,14 @@ Options:
|
|
|
54
56
|
--no-build Skip build before publishing
|
|
55
57
|
--no-publish Skip publishing task
|
|
56
58
|
--no-release-draft Skip creating a GitHub release draft
|
|
59
|
+
--publish-only Run only publish task for latest tag
|
|
57
60
|
-t, --tag <name> Publish under a specific dist-tag (default: latest)
|
|
58
61
|
-c, --contents <path> Subdirectory to publish
|
|
59
62
|
--no-save-token Do not save jsr tokens (request the token each time)
|
|
60
63
|
--registry <...registries> Target registries for publish
|
|
61
64
|
registry can be npm | jsr | https://url.for.private-registries (default: npm,jsr)
|
|
62
65
|
-h, --help Display this message
|
|
63
|
-
-v, --version Display version number
|
|
66
|
+
-v, --version Display version number
|
|
64
67
|
```
|
|
65
68
|
|
|
66
69
|
## Config for publish
|
package/bin/cli.js
CHANGED
|
@@ -1931,7 +1931,8 @@ var init_cli_truncate = __esm({
|
|
|
1931
1931
|
|
|
1932
1932
|
// src/cli.ts
|
|
1933
1933
|
import cac from "cac";
|
|
1934
|
-
import
|
|
1934
|
+
import semver3 from "semver";
|
|
1935
|
+
import { isCI as isCI3 } from "std-env";
|
|
1935
1936
|
|
|
1936
1937
|
// node_modules/.pnpm/eventemitter3@5.0.1/node_modules/eventemitter3/index.mjs
|
|
1937
1938
|
var import_index = __toESM(require_eventemitter3(), 1);
|
|
@@ -4398,26 +4399,8 @@ function consoleError(error) {
|
|
|
4398
4399
|
`);
|
|
4399
4400
|
}
|
|
4400
4401
|
|
|
4401
|
-
// src/options.ts
|
|
4402
|
-
var defaultOptions = {
|
|
4403
|
-
testScript: "test",
|
|
4404
|
-
branch: "main",
|
|
4405
|
-
tag: "latest",
|
|
4406
|
-
registries: ["npm", "jsr"]
|
|
4407
|
-
};
|
|
4408
|
-
function resolveOptions(options2) {
|
|
4409
|
-
const nextOptions = { ...options2, ...defaultOptions };
|
|
4410
|
-
return nextOptions;
|
|
4411
|
-
}
|
|
4412
|
-
|
|
4413
|
-
// src/tasks/runner.ts
|
|
4414
|
-
import process10 from "node:process";
|
|
4415
|
-
import npmCli from "@npmcli/promise-spawn";
|
|
4416
|
-
import SemVer from "semver";
|
|
4417
|
-
import { isCI as isCI2 } from "std-env";
|
|
4418
|
-
import { exec as exec6 } from "tinyexec";
|
|
4419
|
-
|
|
4420
4402
|
// src/git.ts
|
|
4403
|
+
import semver from "semver";
|
|
4421
4404
|
import { exec as exec2 } from "tinyexec";
|
|
4422
4405
|
var GitError = class extends AbstractError {
|
|
4423
4406
|
constructor() {
|
|
@@ -4447,6 +4430,23 @@ var Git = class {
|
|
|
4447
4430
|
return null;
|
|
4448
4431
|
}
|
|
4449
4432
|
}
|
|
4433
|
+
async tags() {
|
|
4434
|
+
try {
|
|
4435
|
+
return (await this.git(["tag", "-l"])).trim().split("\n").map((v) => v.slice(1)).sort(semver.compareIdentifiers);
|
|
4436
|
+
} catch (error) {
|
|
4437
|
+
throw new GitError("Failed to run `git config --get user.name`", {
|
|
4438
|
+
cause: error
|
|
4439
|
+
});
|
|
4440
|
+
}
|
|
4441
|
+
}
|
|
4442
|
+
async previousTag(tag) {
|
|
4443
|
+
try {
|
|
4444
|
+
const tags = await this.tags();
|
|
4445
|
+
return tags.at(tags.findIndex((t) => t === tag) - 1);
|
|
4446
|
+
} catch {
|
|
4447
|
+
return null;
|
|
4448
|
+
}
|
|
4449
|
+
}
|
|
4450
4450
|
async dryFetch() {
|
|
4451
4451
|
try {
|
|
4452
4452
|
return await this.git(["fetch", "--dry-run"]);
|
|
@@ -4684,6 +4684,25 @@ var Git = class {
|
|
|
4684
4684
|
}
|
|
4685
4685
|
};
|
|
4686
4686
|
|
|
4687
|
+
// src/options.ts
|
|
4688
|
+
var defaultOptions = {
|
|
4689
|
+
testScript: "test",
|
|
4690
|
+
branch: "main",
|
|
4691
|
+
tag: "latest",
|
|
4692
|
+
registries: ["npm", "jsr"]
|
|
4693
|
+
};
|
|
4694
|
+
function resolveOptions(options2) {
|
|
4695
|
+
const nextOptions = { ...options2, ...defaultOptions };
|
|
4696
|
+
return nextOptions;
|
|
4697
|
+
}
|
|
4698
|
+
|
|
4699
|
+
// src/tasks/runner.ts
|
|
4700
|
+
import process10 from "node:process";
|
|
4701
|
+
import npmCli from "@npmcli/promise-spawn";
|
|
4702
|
+
import SemVer from "semver";
|
|
4703
|
+
import { isCI as isCI2 } from "std-env";
|
|
4704
|
+
import { exec as exec6 } from "tinyexec";
|
|
4705
|
+
|
|
4687
4706
|
// src/utils/cli.ts
|
|
4688
4707
|
var warningBadge = color.bgYellow(" Warning ");
|
|
4689
4708
|
function link2(text, url) {
|
|
@@ -5310,6 +5329,17 @@ var NpmRegistry = class extends Registry {
|
|
|
5310
5329
|
throw new NpmError("Failed to run `npm whoami`", { cause: error });
|
|
5311
5330
|
}
|
|
5312
5331
|
}
|
|
5332
|
+
async isLoggedIn() {
|
|
5333
|
+
try {
|
|
5334
|
+
await this.npm(["whoami"]);
|
|
5335
|
+
return true;
|
|
5336
|
+
} catch (error) {
|
|
5337
|
+
if (`${error}`.includes("ENEEDAUTH")) {
|
|
5338
|
+
return false;
|
|
5339
|
+
}
|
|
5340
|
+
throw new NpmError("Failed to run `npm whoami`", { cause: error });
|
|
5341
|
+
}
|
|
5342
|
+
}
|
|
5313
5343
|
async collaborators() {
|
|
5314
5344
|
try {
|
|
5315
5345
|
return JSON.parse(
|
|
@@ -5364,7 +5394,13 @@ var NpmRegistry = class extends Registry {
|
|
|
5364
5394
|
}
|
|
5365
5395
|
async publishProvenance() {
|
|
5366
5396
|
try {
|
|
5367
|
-
|
|
5397
|
+
try {
|
|
5398
|
+
await this.npm(["publish", "--provenance", "--access", "public"]);
|
|
5399
|
+
} catch (error) {
|
|
5400
|
+
if (`${error}`.includes("EOTP")) {
|
|
5401
|
+
return false;
|
|
5402
|
+
}
|
|
5403
|
+
}
|
|
5368
5404
|
return true;
|
|
5369
5405
|
} catch (error) {
|
|
5370
5406
|
throw new NpmError(
|
|
@@ -5381,7 +5417,7 @@ var NpmRegistry = class extends Registry {
|
|
|
5381
5417
|
try {
|
|
5382
5418
|
await this.npm(args);
|
|
5383
5419
|
} catch (error) {
|
|
5384
|
-
if (`${error}`.includes("
|
|
5420
|
+
if (`${error}`.includes("EOTP")) {
|
|
5385
5421
|
return false;
|
|
5386
5422
|
}
|
|
5387
5423
|
}
|
|
@@ -5584,6 +5620,11 @@ var npmAvailableCheckTasks = {
|
|
|
5584
5620
|
skip: (ctx) => !!ctx.preview,
|
|
5585
5621
|
task: async () => {
|
|
5586
5622
|
const npm = await npmRegistry();
|
|
5623
|
+
if (!await npm.isLoggedIn()) {
|
|
5624
|
+
throw new NpmAvailableError(
|
|
5625
|
+
"You are not logged in. Please log in first using `npm login`."
|
|
5626
|
+
);
|
|
5627
|
+
}
|
|
5587
5628
|
if (await npm.isPublished()) {
|
|
5588
5629
|
if (!await npm.hasPermission()) {
|
|
5589
5630
|
throw new NpmAvailableError(
|
|
@@ -5630,15 +5671,11 @@ var npmPublishTasks = {
|
|
|
5630
5671
|
"NODE_AUTH_TOKEN not found in the environment variables. Please set the token and try again."
|
|
5631
5672
|
);
|
|
5632
5673
|
}
|
|
5633
|
-
|
|
5634
|
-
|
|
5635
|
-
|
|
5636
|
-
|
|
5637
|
-
|
|
5638
|
-
`In CI environment, publishing with 2FA is not allowed. Please disable 2FA when accessing with a token from ${link2("npm", `https://www.npmjs.com/package/${npm.packageName}/access`)}.`
|
|
5639
|
-
);
|
|
5640
|
-
}
|
|
5641
|
-
throw error;
|
|
5674
|
+
const result = await npm.publishProvenance();
|
|
5675
|
+
if (!result) {
|
|
5676
|
+
throw new NpmAvailableError(
|
|
5677
|
+
`In CI environment, publishing with 2FA is not allowed. Please disable 2FA when accessing with a token from https://www.npmjs.com/package/${npm.packageName}/access `
|
|
5678
|
+
);
|
|
5642
5679
|
}
|
|
5643
5680
|
}
|
|
5644
5681
|
}
|
|
@@ -5964,13 +6001,11 @@ var requiredConditionsCheckTask = (options2) => createListr({
|
|
|
5964
6001
|
var { open } = npmCli;
|
|
5965
6002
|
var { prerelease } = SemVer;
|
|
5966
6003
|
async function run(options2) {
|
|
5967
|
-
const git = new Git();
|
|
5968
6004
|
const ctx = {
|
|
5969
6005
|
...options2,
|
|
5970
6006
|
promptEnabled: !isCI2 && process10.stdin.isTTY,
|
|
5971
6007
|
npmOnly: options2.registries.every((registry) => registry !== "jsr"),
|
|
5972
|
-
jsrOnly: options2.registries.every((registry) => registry === "jsr")
|
|
5973
|
-
lastRev: await git.latestTag() || await git.firstCommit()
|
|
6008
|
+
jsrOnly: options2.registries.every((registry) => registry === "jsr")
|
|
5974
6009
|
};
|
|
5975
6010
|
try {
|
|
5976
6011
|
if (options2.contents) process10.chdir(options2.contents);
|
|
@@ -6037,32 +6072,32 @@ async function run(options2) {
|
|
|
6037
6072
|
title: "Bumping version",
|
|
6038
6073
|
skip: (ctx2) => !!ctx2.preview,
|
|
6039
6074
|
task: async (ctx2, task) => {
|
|
6040
|
-
const
|
|
6075
|
+
const git = new Git();
|
|
6041
6076
|
let tagCreated = false;
|
|
6042
6077
|
let commited = false;
|
|
6043
6078
|
addRollback(async () => {
|
|
6044
6079
|
if (tagCreated) {
|
|
6045
6080
|
console.log("Deleting tag...");
|
|
6046
|
-
await
|
|
6081
|
+
await git.deleteTag(`${await git.latestTag()}`);
|
|
6047
6082
|
}
|
|
6048
6083
|
if (commited) {
|
|
6049
6084
|
console.log("Reset commits...");
|
|
6050
|
-
await
|
|
6051
|
-
await
|
|
6052
|
-
await
|
|
6053
|
-
await
|
|
6085
|
+
await git.reset();
|
|
6086
|
+
await git.stash();
|
|
6087
|
+
await git.reset("HEAD^", "--hard");
|
|
6088
|
+
await git.popStash();
|
|
6054
6089
|
}
|
|
6055
6090
|
}, ctx2);
|
|
6056
|
-
await
|
|
6091
|
+
await git.reset();
|
|
6057
6092
|
const replaced = await replaceVersion(ctx2.version);
|
|
6058
6093
|
for (const replacedFile of replaced) {
|
|
6059
|
-
await
|
|
6094
|
+
await git.stage(replacedFile);
|
|
6060
6095
|
}
|
|
6061
6096
|
const nextVersion = `v${ctx2.version}`;
|
|
6062
|
-
const commit = await
|
|
6097
|
+
const commit = await git.commit(nextVersion);
|
|
6063
6098
|
commited = true;
|
|
6064
6099
|
task.output = "Creating tag...";
|
|
6065
|
-
await
|
|
6100
|
+
await git.createTag(nextVersion, commit);
|
|
6066
6101
|
tagCreated = true;
|
|
6067
6102
|
}
|
|
6068
6103
|
},
|
|
@@ -6087,11 +6122,11 @@ async function run(options2) {
|
|
|
6087
6122
|
title: "Pushing tags to GitHub",
|
|
6088
6123
|
skip: (ctx2) => !!ctx2.preview,
|
|
6089
6124
|
task: async (_, task) => {
|
|
6090
|
-
const
|
|
6091
|
-
const result = await
|
|
6125
|
+
const git = new Git();
|
|
6126
|
+
const result = await git.push("--follow-tags");
|
|
6092
6127
|
if (!result) {
|
|
6093
6128
|
task.title += " (Only tags were pushed because the release branch is protected. Please push the branch manually.)";
|
|
6094
|
-
await
|
|
6129
|
+
await git.push("--tags");
|
|
6095
6130
|
}
|
|
6096
6131
|
}
|
|
6097
6132
|
},
|
|
@@ -6099,16 +6134,17 @@ async function run(options2) {
|
|
|
6099
6134
|
skip: (ctx2) => options2.skipReleaseDraft || !!ctx2.preview,
|
|
6100
6135
|
title: "Creating release draft on GitHub",
|
|
6101
6136
|
task: async (ctx2, task) => {
|
|
6102
|
-
const
|
|
6103
|
-
const repositoryUrl = await
|
|
6104
|
-
const
|
|
6105
|
-
const
|
|
6137
|
+
const git = new Git();
|
|
6138
|
+
const repositoryUrl = await git.repository();
|
|
6139
|
+
const latestTag = `${await git.latestTag()}`;
|
|
6140
|
+
const lastRev = await git.previousTag(latestTag) || await git.firstCommit();
|
|
6141
|
+
const commits = (await git.commits(lastRev, `${latestTag}`)).slice(1);
|
|
6106
6142
|
let body = commits.map(
|
|
6107
6143
|
({ id, message }) => `- ${message.replace("#", `${repositoryUrl}/issues/`)} ${repositoryUrl}/commit/${id}`
|
|
6108
6144
|
).join("\n");
|
|
6109
6145
|
body += `
|
|
6110
6146
|
|
|
6111
|
-
${repositoryUrl}/compare/${
|
|
6147
|
+
${repositoryUrl}/compare/${lastRev}...${latestTag}`;
|
|
6112
6148
|
const releaseDraftUrl = new URL(
|
|
6113
6149
|
`${repositoryUrl}/releases/new`
|
|
6114
6150
|
);
|
|
@@ -6148,8 +6184,8 @@ async function pubm(options2) {
|
|
|
6148
6184
|
|
|
6149
6185
|
// src/tasks/required-missing-information.ts
|
|
6150
6186
|
import { ListrEnquirerPromptAdapter as ListrEnquirerPromptAdapter5 } from "@listr2/prompt-adapter-enquirer";
|
|
6151
|
-
import
|
|
6152
|
-
var { RELEASE_TYPES, SemVer: SemVer2, prerelease: prerelease2 } =
|
|
6187
|
+
import semver2 from "semver";
|
|
6188
|
+
var { RELEASE_TYPES, SemVer: SemVer2, prerelease: prerelease2 } = semver2;
|
|
6153
6189
|
var requiredMissingInformationTasks = (options2) => createListr({
|
|
6154
6190
|
...options2,
|
|
6155
6191
|
title: "Checking required information",
|
|
@@ -6277,8 +6313,7 @@ Update available! \`${name}\` ${color.red(currentVersion)} \u2192 ${color.green(
|
|
|
6277
6313
|
}
|
|
6278
6314
|
|
|
6279
6315
|
// src/cli.ts
|
|
6280
|
-
|
|
6281
|
-
var { RELEASE_TYPES: RELEASE_TYPES2, valid } = semver2;
|
|
6316
|
+
var { RELEASE_TYPES: RELEASE_TYPES2, valid } = semver3;
|
|
6282
6317
|
var options = [
|
|
6283
6318
|
{
|
|
6284
6319
|
rawName: "--test-script <script>",
|
package/dist/index.cjs
CHANGED
|
@@ -4382,7 +4382,7 @@ var Listr = (_a23 = class {
|
|
|
4382
4382
|
}, __name(_a23, "Listr"), _a23);
|
|
4383
4383
|
|
|
4384
4384
|
// src/tasks/runner.ts
|
|
4385
|
-
var
|
|
4385
|
+
var import_semver3 = __toESM(require("semver"), 1);
|
|
4386
4386
|
var import_std_env = require("std-env");
|
|
4387
4387
|
var import_tinyexec5 = require("tinyexec");
|
|
4388
4388
|
|
|
@@ -4423,6 +4423,7 @@ function consoleError(error) {
|
|
|
4423
4423
|
}
|
|
4424
4424
|
|
|
4425
4425
|
// src/git.ts
|
|
4426
|
+
var import_semver = __toESM(require("semver"), 1);
|
|
4426
4427
|
var import_tinyexec = require("tinyexec");
|
|
4427
4428
|
var GitError = class extends AbstractError {
|
|
4428
4429
|
constructor() {
|
|
@@ -4452,6 +4453,23 @@ var Git = class {
|
|
|
4452
4453
|
return null;
|
|
4453
4454
|
}
|
|
4454
4455
|
}
|
|
4456
|
+
async tags() {
|
|
4457
|
+
try {
|
|
4458
|
+
return (await this.git(["tag", "-l"])).trim().split("\n").map((v) => v.slice(1)).sort(import_semver.default.compareIdentifiers);
|
|
4459
|
+
} catch (error) {
|
|
4460
|
+
throw new GitError("Failed to run `git config --get user.name`", {
|
|
4461
|
+
cause: error
|
|
4462
|
+
});
|
|
4463
|
+
}
|
|
4464
|
+
}
|
|
4465
|
+
async previousTag(tag) {
|
|
4466
|
+
try {
|
|
4467
|
+
const tags = await this.tags();
|
|
4468
|
+
return tags.at(tags.findIndex((t) => t === tag) - 1);
|
|
4469
|
+
} catch {
|
|
4470
|
+
return null;
|
|
4471
|
+
}
|
|
4472
|
+
}
|
|
4455
4473
|
async dryFetch() {
|
|
4456
4474
|
try {
|
|
4457
4475
|
return await this.git(["fetch", "--dry-run"]);
|
|
@@ -5317,6 +5335,17 @@ var NpmRegistry = class extends Registry {
|
|
|
5317
5335
|
throw new NpmError("Failed to run `npm whoami`", { cause: error });
|
|
5318
5336
|
}
|
|
5319
5337
|
}
|
|
5338
|
+
async isLoggedIn() {
|
|
5339
|
+
try {
|
|
5340
|
+
await this.npm(["whoami"]);
|
|
5341
|
+
return true;
|
|
5342
|
+
} catch (error) {
|
|
5343
|
+
if (`${error}`.includes("ENEEDAUTH")) {
|
|
5344
|
+
return false;
|
|
5345
|
+
}
|
|
5346
|
+
throw new NpmError("Failed to run `npm whoami`", { cause: error });
|
|
5347
|
+
}
|
|
5348
|
+
}
|
|
5320
5349
|
async collaborators() {
|
|
5321
5350
|
try {
|
|
5322
5351
|
return JSON.parse(
|
|
@@ -5371,7 +5400,13 @@ var NpmRegistry = class extends Registry {
|
|
|
5371
5400
|
}
|
|
5372
5401
|
async publishProvenance() {
|
|
5373
5402
|
try {
|
|
5374
|
-
|
|
5403
|
+
try {
|
|
5404
|
+
await this.npm(["publish", "--provenance", "--access", "public"]);
|
|
5405
|
+
} catch (error) {
|
|
5406
|
+
if (`${error}`.includes("EOTP")) {
|
|
5407
|
+
return false;
|
|
5408
|
+
}
|
|
5409
|
+
}
|
|
5375
5410
|
return true;
|
|
5376
5411
|
} catch (error) {
|
|
5377
5412
|
throw new NpmError(
|
|
@@ -5388,7 +5423,7 @@ var NpmRegistry = class extends Registry {
|
|
|
5388
5423
|
try {
|
|
5389
5424
|
await this.npm(args);
|
|
5390
5425
|
} catch (error) {
|
|
5391
|
-
if (`${error}`.includes("
|
|
5426
|
+
if (`${error}`.includes("EOTP")) {
|
|
5392
5427
|
return false;
|
|
5393
5428
|
}
|
|
5394
5429
|
}
|
|
@@ -5591,6 +5626,11 @@ var npmAvailableCheckTasks = {
|
|
|
5591
5626
|
skip: (ctx) => !!ctx.preview,
|
|
5592
5627
|
task: async () => {
|
|
5593
5628
|
const npm = await npmRegistry();
|
|
5629
|
+
if (!await npm.isLoggedIn()) {
|
|
5630
|
+
throw new NpmAvailableError(
|
|
5631
|
+
"You are not logged in. Please log in first using `npm login`."
|
|
5632
|
+
);
|
|
5633
|
+
}
|
|
5594
5634
|
if (await npm.isPublished()) {
|
|
5595
5635
|
if (!await npm.hasPermission()) {
|
|
5596
5636
|
throw new NpmAvailableError(
|
|
@@ -5637,15 +5677,11 @@ var npmPublishTasks = {
|
|
|
5637
5677
|
"NODE_AUTH_TOKEN not found in the environment variables. Please set the token and try again."
|
|
5638
5678
|
);
|
|
5639
5679
|
}
|
|
5640
|
-
|
|
5641
|
-
|
|
5642
|
-
|
|
5643
|
-
|
|
5644
|
-
|
|
5645
|
-
`In CI environment, publishing with 2FA is not allowed. Please disable 2FA when accessing with a token from ${link2("npm", `https://www.npmjs.com/package/${npm.packageName}/access`)}.`
|
|
5646
|
-
);
|
|
5647
|
-
}
|
|
5648
|
-
throw error;
|
|
5680
|
+
const result = await npm.publishProvenance();
|
|
5681
|
+
if (!result) {
|
|
5682
|
+
throw new NpmAvailableError(
|
|
5683
|
+
`In CI environment, publishing with 2FA is not allowed. Please disable 2FA when accessing with a token from https://www.npmjs.com/package/${npm.packageName}/access `
|
|
5684
|
+
);
|
|
5649
5685
|
}
|
|
5650
5686
|
}
|
|
5651
5687
|
}
|
|
@@ -5830,13 +5866,13 @@ async function getRegistry(registryKey) {
|
|
|
5830
5866
|
}
|
|
5831
5867
|
|
|
5832
5868
|
// src/utils/engine-version.ts
|
|
5833
|
-
var
|
|
5869
|
+
var import_semver2 = require("semver");
|
|
5834
5870
|
var import_meta3 = {};
|
|
5835
5871
|
async function validateEngineVersion(engine, version2) {
|
|
5836
5872
|
const { engines } = await getPackageJson({
|
|
5837
5873
|
cwd: import_meta3.dirname
|
|
5838
5874
|
});
|
|
5839
|
-
return (0,
|
|
5875
|
+
return (0, import_semver2.satisfies)(version2, `${engines?.[engine]}`, {
|
|
5840
5876
|
includePrerelease: true
|
|
5841
5877
|
});
|
|
5842
5878
|
}
|
|
@@ -5970,15 +6006,13 @@ var requiredConditionsCheckTask = (options) => createListr({
|
|
|
5970
6006
|
|
|
5971
6007
|
// src/tasks/runner.ts
|
|
5972
6008
|
var { open } = import_promise_spawn.default;
|
|
5973
|
-
var { prerelease } =
|
|
6009
|
+
var { prerelease } = import_semver3.default;
|
|
5974
6010
|
async function run(options) {
|
|
5975
|
-
const git = new Git();
|
|
5976
6011
|
const ctx = {
|
|
5977
6012
|
...options,
|
|
5978
6013
|
promptEnabled: !import_std_env.isCI && import_node_process8.default.stdin.isTTY,
|
|
5979
6014
|
npmOnly: options.registries.every((registry) => registry !== "jsr"),
|
|
5980
|
-
jsrOnly: options.registries.every((registry) => registry === "jsr")
|
|
5981
|
-
lastRev: await git.latestTag() || await git.firstCommit()
|
|
6015
|
+
jsrOnly: options.registries.every((registry) => registry === "jsr")
|
|
5982
6016
|
};
|
|
5983
6017
|
try {
|
|
5984
6018
|
if (options.contents) import_node_process8.default.chdir(options.contents);
|
|
@@ -6045,32 +6079,32 @@ async function run(options) {
|
|
|
6045
6079
|
title: "Bumping version",
|
|
6046
6080
|
skip: (ctx2) => !!ctx2.preview,
|
|
6047
6081
|
task: async (ctx2, task) => {
|
|
6048
|
-
const
|
|
6082
|
+
const git = new Git();
|
|
6049
6083
|
let tagCreated = false;
|
|
6050
6084
|
let commited = false;
|
|
6051
6085
|
addRollback(async () => {
|
|
6052
6086
|
if (tagCreated) {
|
|
6053
6087
|
console.log("Deleting tag...");
|
|
6054
|
-
await
|
|
6088
|
+
await git.deleteTag(`${await git.latestTag()}`);
|
|
6055
6089
|
}
|
|
6056
6090
|
if (commited) {
|
|
6057
6091
|
console.log("Reset commits...");
|
|
6058
|
-
await
|
|
6059
|
-
await
|
|
6060
|
-
await
|
|
6061
|
-
await
|
|
6092
|
+
await git.reset();
|
|
6093
|
+
await git.stash();
|
|
6094
|
+
await git.reset("HEAD^", "--hard");
|
|
6095
|
+
await git.popStash();
|
|
6062
6096
|
}
|
|
6063
6097
|
}, ctx2);
|
|
6064
|
-
await
|
|
6098
|
+
await git.reset();
|
|
6065
6099
|
const replaced = await replaceVersion(ctx2.version);
|
|
6066
6100
|
for (const replacedFile of replaced) {
|
|
6067
|
-
await
|
|
6101
|
+
await git.stage(replacedFile);
|
|
6068
6102
|
}
|
|
6069
6103
|
const nextVersion = `v${ctx2.version}`;
|
|
6070
|
-
const commit = await
|
|
6104
|
+
const commit = await git.commit(nextVersion);
|
|
6071
6105
|
commited = true;
|
|
6072
6106
|
task.output = "Creating tag...";
|
|
6073
|
-
await
|
|
6107
|
+
await git.createTag(nextVersion, commit);
|
|
6074
6108
|
tagCreated = true;
|
|
6075
6109
|
}
|
|
6076
6110
|
},
|
|
@@ -6095,11 +6129,11 @@ async function run(options) {
|
|
|
6095
6129
|
title: "Pushing tags to GitHub",
|
|
6096
6130
|
skip: (ctx2) => !!ctx2.preview,
|
|
6097
6131
|
task: async (_, task) => {
|
|
6098
|
-
const
|
|
6099
|
-
const result = await
|
|
6132
|
+
const git = new Git();
|
|
6133
|
+
const result = await git.push("--follow-tags");
|
|
6100
6134
|
if (!result) {
|
|
6101
6135
|
task.title += " (Only tags were pushed because the release branch is protected. Please push the branch manually.)";
|
|
6102
|
-
await
|
|
6136
|
+
await git.push("--tags");
|
|
6103
6137
|
}
|
|
6104
6138
|
}
|
|
6105
6139
|
},
|
|
@@ -6107,16 +6141,17 @@ async function run(options) {
|
|
|
6107
6141
|
skip: (ctx2) => options.skipReleaseDraft || !!ctx2.preview,
|
|
6108
6142
|
title: "Creating release draft on GitHub",
|
|
6109
6143
|
task: async (ctx2, task) => {
|
|
6110
|
-
const
|
|
6111
|
-
const repositoryUrl = await
|
|
6112
|
-
const
|
|
6113
|
-
const
|
|
6144
|
+
const git = new Git();
|
|
6145
|
+
const repositoryUrl = await git.repository();
|
|
6146
|
+
const latestTag = `${await git.latestTag()}`;
|
|
6147
|
+
const lastRev = await git.previousTag(latestTag) || await git.firstCommit();
|
|
6148
|
+
const commits = (await git.commits(lastRev, `${latestTag}`)).slice(1);
|
|
6114
6149
|
let body = commits.map(
|
|
6115
6150
|
({ id, message }) => `- ${message.replace("#", `${repositoryUrl}/issues/`)} ${repositoryUrl}/commit/${id}`
|
|
6116
6151
|
).join("\n");
|
|
6117
6152
|
body += `
|
|
6118
6153
|
|
|
6119
|
-
${repositoryUrl}/compare/${
|
|
6154
|
+
${repositoryUrl}/compare/${lastRev}...${latestTag}`;
|
|
6120
6155
|
const releaseDraftUrl = new URL(
|
|
6121
6156
|
`${repositoryUrl}/releases/new`
|
|
6122
6157
|
);
|
package/dist/index.js
CHANGED
|
@@ -4414,6 +4414,7 @@ function consoleError(error) {
|
|
|
4414
4414
|
}
|
|
4415
4415
|
|
|
4416
4416
|
// src/git.ts
|
|
4417
|
+
import semver from "semver";
|
|
4417
4418
|
import { exec as exec2 } from "tinyexec";
|
|
4418
4419
|
var GitError = class extends AbstractError {
|
|
4419
4420
|
constructor() {
|
|
@@ -4443,6 +4444,23 @@ var Git = class {
|
|
|
4443
4444
|
return null;
|
|
4444
4445
|
}
|
|
4445
4446
|
}
|
|
4447
|
+
async tags() {
|
|
4448
|
+
try {
|
|
4449
|
+
return (await this.git(["tag", "-l"])).trim().split("\n").map((v) => v.slice(1)).sort(semver.compareIdentifiers);
|
|
4450
|
+
} catch (error) {
|
|
4451
|
+
throw new GitError("Failed to run `git config --get user.name`", {
|
|
4452
|
+
cause: error
|
|
4453
|
+
});
|
|
4454
|
+
}
|
|
4455
|
+
}
|
|
4456
|
+
async previousTag(tag) {
|
|
4457
|
+
try {
|
|
4458
|
+
const tags = await this.tags();
|
|
4459
|
+
return tags.at(tags.findIndex((t) => t === tag) - 1);
|
|
4460
|
+
} catch {
|
|
4461
|
+
return null;
|
|
4462
|
+
}
|
|
4463
|
+
}
|
|
4446
4464
|
async dryFetch() {
|
|
4447
4465
|
try {
|
|
4448
4466
|
return await this.git(["fetch", "--dry-run"]);
|
|
@@ -5306,6 +5324,17 @@ var NpmRegistry = class extends Registry {
|
|
|
5306
5324
|
throw new NpmError("Failed to run `npm whoami`", { cause: error });
|
|
5307
5325
|
}
|
|
5308
5326
|
}
|
|
5327
|
+
async isLoggedIn() {
|
|
5328
|
+
try {
|
|
5329
|
+
await this.npm(["whoami"]);
|
|
5330
|
+
return true;
|
|
5331
|
+
} catch (error) {
|
|
5332
|
+
if (`${error}`.includes("ENEEDAUTH")) {
|
|
5333
|
+
return false;
|
|
5334
|
+
}
|
|
5335
|
+
throw new NpmError("Failed to run `npm whoami`", { cause: error });
|
|
5336
|
+
}
|
|
5337
|
+
}
|
|
5309
5338
|
async collaborators() {
|
|
5310
5339
|
try {
|
|
5311
5340
|
return JSON.parse(
|
|
@@ -5360,7 +5389,13 @@ var NpmRegistry = class extends Registry {
|
|
|
5360
5389
|
}
|
|
5361
5390
|
async publishProvenance() {
|
|
5362
5391
|
try {
|
|
5363
|
-
|
|
5392
|
+
try {
|
|
5393
|
+
await this.npm(["publish", "--provenance", "--access", "public"]);
|
|
5394
|
+
} catch (error) {
|
|
5395
|
+
if (`${error}`.includes("EOTP")) {
|
|
5396
|
+
return false;
|
|
5397
|
+
}
|
|
5398
|
+
}
|
|
5364
5399
|
return true;
|
|
5365
5400
|
} catch (error) {
|
|
5366
5401
|
throw new NpmError(
|
|
@@ -5377,7 +5412,7 @@ var NpmRegistry = class extends Registry {
|
|
|
5377
5412
|
try {
|
|
5378
5413
|
await this.npm(args);
|
|
5379
5414
|
} catch (error) {
|
|
5380
|
-
if (`${error}`.includes("
|
|
5415
|
+
if (`${error}`.includes("EOTP")) {
|
|
5381
5416
|
return false;
|
|
5382
5417
|
}
|
|
5383
5418
|
}
|
|
@@ -5580,6 +5615,11 @@ var npmAvailableCheckTasks = {
|
|
|
5580
5615
|
skip: (ctx) => !!ctx.preview,
|
|
5581
5616
|
task: async () => {
|
|
5582
5617
|
const npm = await npmRegistry();
|
|
5618
|
+
if (!await npm.isLoggedIn()) {
|
|
5619
|
+
throw new NpmAvailableError(
|
|
5620
|
+
"You are not logged in. Please log in first using `npm login`."
|
|
5621
|
+
);
|
|
5622
|
+
}
|
|
5583
5623
|
if (await npm.isPublished()) {
|
|
5584
5624
|
if (!await npm.hasPermission()) {
|
|
5585
5625
|
throw new NpmAvailableError(
|
|
@@ -5626,15 +5666,11 @@ var npmPublishTasks = {
|
|
|
5626
5666
|
"NODE_AUTH_TOKEN not found in the environment variables. Please set the token and try again."
|
|
5627
5667
|
);
|
|
5628
5668
|
}
|
|
5629
|
-
|
|
5630
|
-
|
|
5631
|
-
|
|
5632
|
-
|
|
5633
|
-
|
|
5634
|
-
`In CI environment, publishing with 2FA is not allowed. Please disable 2FA when accessing with a token from ${link2("npm", `https://www.npmjs.com/package/${npm.packageName}/access`)}.`
|
|
5635
|
-
);
|
|
5636
|
-
}
|
|
5637
|
-
throw error;
|
|
5669
|
+
const result = await npm.publishProvenance();
|
|
5670
|
+
if (!result) {
|
|
5671
|
+
throw new NpmAvailableError(
|
|
5672
|
+
`In CI environment, publishing with 2FA is not allowed. Please disable 2FA when accessing with a token from https://www.npmjs.com/package/${npm.packageName}/access `
|
|
5673
|
+
);
|
|
5638
5674
|
}
|
|
5639
5675
|
}
|
|
5640
5676
|
}
|
|
@@ -5960,13 +5996,11 @@ var requiredConditionsCheckTask = (options) => createListr({
|
|
|
5960
5996
|
var { open } = npmCli;
|
|
5961
5997
|
var { prerelease } = SemVer;
|
|
5962
5998
|
async function run(options) {
|
|
5963
|
-
const git = new Git();
|
|
5964
5999
|
const ctx = {
|
|
5965
6000
|
...options,
|
|
5966
6001
|
promptEnabled: !isCI2 && process10.stdin.isTTY,
|
|
5967
6002
|
npmOnly: options.registries.every((registry) => registry !== "jsr"),
|
|
5968
|
-
jsrOnly: options.registries.every((registry) => registry === "jsr")
|
|
5969
|
-
lastRev: await git.latestTag() || await git.firstCommit()
|
|
6003
|
+
jsrOnly: options.registries.every((registry) => registry === "jsr")
|
|
5970
6004
|
};
|
|
5971
6005
|
try {
|
|
5972
6006
|
if (options.contents) process10.chdir(options.contents);
|
|
@@ -6033,32 +6067,32 @@ async function run(options) {
|
|
|
6033
6067
|
title: "Bumping version",
|
|
6034
6068
|
skip: (ctx2) => !!ctx2.preview,
|
|
6035
6069
|
task: async (ctx2, task) => {
|
|
6036
|
-
const
|
|
6070
|
+
const git = new Git();
|
|
6037
6071
|
let tagCreated = false;
|
|
6038
6072
|
let commited = false;
|
|
6039
6073
|
addRollback(async () => {
|
|
6040
6074
|
if (tagCreated) {
|
|
6041
6075
|
console.log("Deleting tag...");
|
|
6042
|
-
await
|
|
6076
|
+
await git.deleteTag(`${await git.latestTag()}`);
|
|
6043
6077
|
}
|
|
6044
6078
|
if (commited) {
|
|
6045
6079
|
console.log("Reset commits...");
|
|
6046
|
-
await
|
|
6047
|
-
await
|
|
6048
|
-
await
|
|
6049
|
-
await
|
|
6080
|
+
await git.reset();
|
|
6081
|
+
await git.stash();
|
|
6082
|
+
await git.reset("HEAD^", "--hard");
|
|
6083
|
+
await git.popStash();
|
|
6050
6084
|
}
|
|
6051
6085
|
}, ctx2);
|
|
6052
|
-
await
|
|
6086
|
+
await git.reset();
|
|
6053
6087
|
const replaced = await replaceVersion(ctx2.version);
|
|
6054
6088
|
for (const replacedFile of replaced) {
|
|
6055
|
-
await
|
|
6089
|
+
await git.stage(replacedFile);
|
|
6056
6090
|
}
|
|
6057
6091
|
const nextVersion = `v${ctx2.version}`;
|
|
6058
|
-
const commit = await
|
|
6092
|
+
const commit = await git.commit(nextVersion);
|
|
6059
6093
|
commited = true;
|
|
6060
6094
|
task.output = "Creating tag...";
|
|
6061
|
-
await
|
|
6095
|
+
await git.createTag(nextVersion, commit);
|
|
6062
6096
|
tagCreated = true;
|
|
6063
6097
|
}
|
|
6064
6098
|
},
|
|
@@ -6083,11 +6117,11 @@ async function run(options) {
|
|
|
6083
6117
|
title: "Pushing tags to GitHub",
|
|
6084
6118
|
skip: (ctx2) => !!ctx2.preview,
|
|
6085
6119
|
task: async (_, task) => {
|
|
6086
|
-
const
|
|
6087
|
-
const result = await
|
|
6120
|
+
const git = new Git();
|
|
6121
|
+
const result = await git.push("--follow-tags");
|
|
6088
6122
|
if (!result) {
|
|
6089
6123
|
task.title += " (Only tags were pushed because the release branch is protected. Please push the branch manually.)";
|
|
6090
|
-
await
|
|
6124
|
+
await git.push("--tags");
|
|
6091
6125
|
}
|
|
6092
6126
|
}
|
|
6093
6127
|
},
|
|
@@ -6095,16 +6129,17 @@ async function run(options) {
|
|
|
6095
6129
|
skip: (ctx2) => options.skipReleaseDraft || !!ctx2.preview,
|
|
6096
6130
|
title: "Creating release draft on GitHub",
|
|
6097
6131
|
task: async (ctx2, task) => {
|
|
6098
|
-
const
|
|
6099
|
-
const repositoryUrl = await
|
|
6100
|
-
const
|
|
6101
|
-
const
|
|
6132
|
+
const git = new Git();
|
|
6133
|
+
const repositoryUrl = await git.repository();
|
|
6134
|
+
const latestTag = `${await git.latestTag()}`;
|
|
6135
|
+
const lastRev = await git.previousTag(latestTag) || await git.firstCommit();
|
|
6136
|
+
const commits = (await git.commits(lastRev, `${latestTag}`)).slice(1);
|
|
6102
6137
|
let body = commits.map(
|
|
6103
6138
|
({ id, message }) => `- ${message.replace("#", `${repositoryUrl}/issues/`)} ${repositoryUrl}/commit/${id}`
|
|
6104
6139
|
).join("\n");
|
|
6105
6140
|
body += `
|
|
6106
6141
|
|
|
6107
|
-
${repositoryUrl}/compare/${
|
|
6142
|
+
${repositoryUrl}/compare/${lastRev}...${latestTag}`;
|
|
6108
6143
|
const releaseDraftUrl = new URL(
|
|
6109
6144
|
`${repositoryUrl}/releases/new`
|
|
6110
6145
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pubm",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">=18",
|
|
6
6
|
"git": ">=2.11.0"
|
|
@@ -14,10 +14,7 @@
|
|
|
14
14
|
"bin": {
|
|
15
15
|
"pubm": "bin/cli.js"
|
|
16
16
|
},
|
|
17
|
-
"files": [
|
|
18
|
-
"dist",
|
|
19
|
-
"bin"
|
|
20
|
-
],
|
|
17
|
+
"files": ["dist", "bin"],
|
|
21
18
|
"exports": {
|
|
22
19
|
".": {
|
|
23
20
|
"types": "./dist/index.d.ts",
|
|
@@ -54,7 +51,7 @@
|
|
|
54
51
|
"@types/semver": "^7.5.8",
|
|
55
52
|
"@vitest/coverage-v8": "^2.1.1",
|
|
56
53
|
"jsr": "^0.13.2",
|
|
57
|
-
"pubm": "^0.0.2-
|
|
54
|
+
"pubm": "^0.0.2-14",
|
|
58
55
|
"tsup": "^8.3.0",
|
|
59
56
|
"typescript": "^5.6.2",
|
|
60
57
|
"vitest": "^2.1.1"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
bb1b5e0897a25b17444b95266e3494d0e653bae57836260243bf54194f71cd729bf8abe6cdc4a6a86b5f03b4200033fc
|