pubm 0.0.2-9 → 0.0.4-0
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 +92 -56
- package/dist/index.cjs +72 -36
- package/dist/index.d.cts +11 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.js +68 -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,26 @@ var Git = class {
|
|
|
4684
4684
|
}
|
|
4685
4685
|
};
|
|
4686
4686
|
|
|
4687
|
+
// src/options.ts
|
|
4688
|
+
var defaultOptions = {
|
|
4689
|
+
testScript: "test",
|
|
4690
|
+
buildScript: "build",
|
|
4691
|
+
branch: "main",
|
|
4692
|
+
tag: "latest",
|
|
4693
|
+
registries: ["npm", "jsr"]
|
|
4694
|
+
};
|
|
4695
|
+
function resolveOptions(options2) {
|
|
4696
|
+
const nextOptions = { ...options2, ...defaultOptions };
|
|
4697
|
+
return nextOptions;
|
|
4698
|
+
}
|
|
4699
|
+
|
|
4700
|
+
// src/tasks/runner.ts
|
|
4701
|
+
import process10 from "node:process";
|
|
4702
|
+
import npmCli from "@npmcli/promise-spawn";
|
|
4703
|
+
import SemVer from "semver";
|
|
4704
|
+
import { isCI as isCI2 } from "std-env";
|
|
4705
|
+
import { exec as exec6 } from "tinyexec";
|
|
4706
|
+
|
|
4687
4707
|
// src/utils/cli.ts
|
|
4688
4708
|
var warningBadge = color.bgYellow(" Warning ");
|
|
4689
4709
|
function link2(text, url) {
|
|
@@ -5310,6 +5330,17 @@ var NpmRegistry = class extends Registry {
|
|
|
5310
5330
|
throw new NpmError("Failed to run `npm whoami`", { cause: error });
|
|
5311
5331
|
}
|
|
5312
5332
|
}
|
|
5333
|
+
async isLoggedIn() {
|
|
5334
|
+
try {
|
|
5335
|
+
await this.npm(["whoami"]);
|
|
5336
|
+
return true;
|
|
5337
|
+
} catch (error) {
|
|
5338
|
+
if (`${error}`.includes("ENEEDAUTH")) {
|
|
5339
|
+
return false;
|
|
5340
|
+
}
|
|
5341
|
+
throw new NpmError("Failed to run `npm whoami`", { cause: error });
|
|
5342
|
+
}
|
|
5343
|
+
}
|
|
5313
5344
|
async collaborators() {
|
|
5314
5345
|
try {
|
|
5315
5346
|
return JSON.parse(
|
|
@@ -5364,7 +5395,13 @@ var NpmRegistry = class extends Registry {
|
|
|
5364
5395
|
}
|
|
5365
5396
|
async publishProvenance() {
|
|
5366
5397
|
try {
|
|
5367
|
-
|
|
5398
|
+
try {
|
|
5399
|
+
await this.npm(["publish", "--provenance", "--access", "public"]);
|
|
5400
|
+
} catch (error) {
|
|
5401
|
+
if (`${error}`.includes("EOTP")) {
|
|
5402
|
+
return false;
|
|
5403
|
+
}
|
|
5404
|
+
}
|
|
5368
5405
|
return true;
|
|
5369
5406
|
} catch (error) {
|
|
5370
5407
|
throw new NpmError(
|
|
@@ -5381,7 +5418,7 @@ var NpmRegistry = class extends Registry {
|
|
|
5381
5418
|
try {
|
|
5382
5419
|
await this.npm(args);
|
|
5383
5420
|
} catch (error) {
|
|
5384
|
-
if (`${error}`.includes("
|
|
5421
|
+
if (`${error}`.includes("EOTP")) {
|
|
5385
5422
|
return false;
|
|
5386
5423
|
}
|
|
5387
5424
|
}
|
|
@@ -5584,6 +5621,11 @@ var npmAvailableCheckTasks = {
|
|
|
5584
5621
|
skip: (ctx) => !!ctx.preview,
|
|
5585
5622
|
task: async () => {
|
|
5586
5623
|
const npm = await npmRegistry();
|
|
5624
|
+
if (!await npm.isLoggedIn()) {
|
|
5625
|
+
throw new NpmAvailableError(
|
|
5626
|
+
"You are not logged in. Please log in first using `npm login`."
|
|
5627
|
+
);
|
|
5628
|
+
}
|
|
5587
5629
|
if (await npm.isPublished()) {
|
|
5588
5630
|
if (!await npm.hasPermission()) {
|
|
5589
5631
|
throw new NpmAvailableError(
|
|
@@ -5630,15 +5672,11 @@ var npmPublishTasks = {
|
|
|
5630
5672
|
"NODE_AUTH_TOKEN not found in the environment variables. Please set the token and try again."
|
|
5631
5673
|
);
|
|
5632
5674
|
}
|
|
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;
|
|
5675
|
+
const result = await npm.publishProvenance();
|
|
5676
|
+
if (!result) {
|
|
5677
|
+
throw new NpmAvailableError(
|
|
5678
|
+
`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 `
|
|
5679
|
+
);
|
|
5642
5680
|
}
|
|
5643
5681
|
}
|
|
5644
5682
|
}
|
|
@@ -5964,13 +6002,11 @@ var requiredConditionsCheckTask = (options2) => createListr({
|
|
|
5964
6002
|
var { open } = npmCli;
|
|
5965
6003
|
var { prerelease } = SemVer;
|
|
5966
6004
|
async function run(options2) {
|
|
5967
|
-
const git = new Git();
|
|
5968
6005
|
const ctx = {
|
|
5969
6006
|
...options2,
|
|
5970
6007
|
promptEnabled: !isCI2 && process10.stdin.isTTY,
|
|
5971
6008
|
npmOnly: options2.registries.every((registry) => registry !== "jsr"),
|
|
5972
|
-
jsrOnly: options2.registries.every((registry) => registry === "jsr")
|
|
5973
|
-
lastRev: await git.latestTag() || await git.firstCommit()
|
|
6009
|
+
jsrOnly: options2.registries.every((registry) => registry === "jsr")
|
|
5974
6010
|
};
|
|
5975
6011
|
try {
|
|
5976
6012
|
if (options2.contents) process10.chdir(options2.contents);
|
|
@@ -6037,32 +6073,32 @@ async function run(options2) {
|
|
|
6037
6073
|
title: "Bumping version",
|
|
6038
6074
|
skip: (ctx2) => !!ctx2.preview,
|
|
6039
6075
|
task: async (ctx2, task) => {
|
|
6040
|
-
const
|
|
6076
|
+
const git = new Git();
|
|
6041
6077
|
let tagCreated = false;
|
|
6042
6078
|
let commited = false;
|
|
6043
6079
|
addRollback(async () => {
|
|
6044
6080
|
if (tagCreated) {
|
|
6045
6081
|
console.log("Deleting tag...");
|
|
6046
|
-
await
|
|
6082
|
+
await git.deleteTag(`${await git.latestTag()}`);
|
|
6047
6083
|
}
|
|
6048
6084
|
if (commited) {
|
|
6049
6085
|
console.log("Reset commits...");
|
|
6050
|
-
await
|
|
6051
|
-
await
|
|
6052
|
-
await
|
|
6053
|
-
await
|
|
6086
|
+
await git.reset();
|
|
6087
|
+
await git.stash();
|
|
6088
|
+
await git.reset("HEAD^", "--hard");
|
|
6089
|
+
await git.popStash();
|
|
6054
6090
|
}
|
|
6055
6091
|
}, ctx2);
|
|
6056
|
-
await
|
|
6092
|
+
await git.reset();
|
|
6057
6093
|
const replaced = await replaceVersion(ctx2.version);
|
|
6058
6094
|
for (const replacedFile of replaced) {
|
|
6059
|
-
await
|
|
6095
|
+
await git.stage(replacedFile);
|
|
6060
6096
|
}
|
|
6061
6097
|
const nextVersion = `v${ctx2.version}`;
|
|
6062
|
-
const commit = await
|
|
6098
|
+
const commit = await git.commit(nextVersion);
|
|
6063
6099
|
commited = true;
|
|
6064
6100
|
task.output = "Creating tag...";
|
|
6065
|
-
await
|
|
6101
|
+
await git.createTag(nextVersion, commit);
|
|
6066
6102
|
tagCreated = true;
|
|
6067
6103
|
}
|
|
6068
6104
|
},
|
|
@@ -6087,11 +6123,11 @@ async function run(options2) {
|
|
|
6087
6123
|
title: "Pushing tags to GitHub",
|
|
6088
6124
|
skip: (ctx2) => !!ctx2.preview,
|
|
6089
6125
|
task: async (_, task) => {
|
|
6090
|
-
const
|
|
6091
|
-
const result = await
|
|
6126
|
+
const git = new Git();
|
|
6127
|
+
const result = await git.push("--follow-tags");
|
|
6092
6128
|
if (!result) {
|
|
6093
6129
|
task.title += " (Only tags were pushed because the release branch is protected. Please push the branch manually.)";
|
|
6094
|
-
await
|
|
6130
|
+
await git.push("--tags");
|
|
6095
6131
|
}
|
|
6096
6132
|
}
|
|
6097
6133
|
},
|
|
@@ -6099,16 +6135,17 @@ async function run(options2) {
|
|
|
6099
6135
|
skip: (ctx2) => options2.skipReleaseDraft || !!ctx2.preview,
|
|
6100
6136
|
title: "Creating release draft on GitHub",
|
|
6101
6137
|
task: async (ctx2, task) => {
|
|
6102
|
-
const
|
|
6103
|
-
const repositoryUrl = await
|
|
6104
|
-
const
|
|
6105
|
-
const
|
|
6138
|
+
const git = new Git();
|
|
6139
|
+
const repositoryUrl = await git.repository();
|
|
6140
|
+
const latestTag = `${await git.latestTag()}`;
|
|
6141
|
+
const lastRev = await git.previousTag(latestTag) || await git.firstCommit();
|
|
6142
|
+
const commits = (await git.commits(lastRev, `${latestTag}`)).slice(1);
|
|
6106
6143
|
let body = commits.map(
|
|
6107
6144
|
({ id, message }) => `- ${message.replace("#", `${repositoryUrl}/issues/`)} ${repositoryUrl}/commit/${id}`
|
|
6108
6145
|
).join("\n");
|
|
6109
6146
|
body += `
|
|
6110
6147
|
|
|
6111
|
-
${repositoryUrl}/compare/${
|
|
6148
|
+
${repositoryUrl}/compare/${lastRev}...${latestTag}`;
|
|
6112
6149
|
const releaseDraftUrl = new URL(
|
|
6113
6150
|
`${repositoryUrl}/releases/new`
|
|
6114
6151
|
);
|
|
@@ -6148,8 +6185,8 @@ async function pubm(options2) {
|
|
|
6148
6185
|
|
|
6149
6186
|
// src/tasks/required-missing-information.ts
|
|
6150
6187
|
import { ListrEnquirerPromptAdapter as ListrEnquirerPromptAdapter5 } from "@listr2/prompt-adapter-enquirer";
|
|
6151
|
-
import
|
|
6152
|
-
var { RELEASE_TYPES, SemVer: SemVer2, prerelease: prerelease2 } =
|
|
6188
|
+
import semver2 from "semver";
|
|
6189
|
+
var { RELEASE_TYPES, SemVer: SemVer2, prerelease: prerelease2 } = semver2;
|
|
6153
6190
|
var requiredMissingInformationTasks = (options2) => createListr({
|
|
6154
6191
|
...options2,
|
|
6155
6192
|
title: "Checking required information",
|
|
@@ -6277,8 +6314,7 @@ Update available! \`${name}\` ${color.red(currentVersion)} \u2192 ${color.green(
|
|
|
6277
6314
|
}
|
|
6278
6315
|
|
|
6279
6316
|
// src/cli.ts
|
|
6280
|
-
|
|
6281
|
-
var { RELEASE_TYPES: RELEASE_TYPES2, valid } = semver2;
|
|
6317
|
+
var { RELEASE_TYPES: RELEASE_TYPES2, valid } = semver3;
|
|
6282
6318
|
var options = [
|
|
6283
6319
|
{
|
|
6284
6320
|
rawName: "--test-script <script>",
|
package/dist/index.cjs
CHANGED
|
@@ -1939,6 +1939,7 @@ module.exports = __toCommonJS(src_exports);
|
|
|
1939
1939
|
// src/options.ts
|
|
1940
1940
|
var defaultOptions = {
|
|
1941
1941
|
testScript: "test",
|
|
1942
|
+
buildScript: "build",
|
|
1942
1943
|
branch: "main",
|
|
1943
1944
|
tag: "latest",
|
|
1944
1945
|
registries: ["npm", "jsr"]
|
|
@@ -4382,7 +4383,7 @@ var Listr = (_a23 = class {
|
|
|
4382
4383
|
}, __name(_a23, "Listr"), _a23);
|
|
4383
4384
|
|
|
4384
4385
|
// src/tasks/runner.ts
|
|
4385
|
-
var
|
|
4386
|
+
var import_semver3 = __toESM(require("semver"), 1);
|
|
4386
4387
|
var import_std_env = require("std-env");
|
|
4387
4388
|
var import_tinyexec5 = require("tinyexec");
|
|
4388
4389
|
|
|
@@ -4423,6 +4424,7 @@ function consoleError(error) {
|
|
|
4423
4424
|
}
|
|
4424
4425
|
|
|
4425
4426
|
// src/git.ts
|
|
4427
|
+
var import_semver = __toESM(require("semver"), 1);
|
|
4426
4428
|
var import_tinyexec = require("tinyexec");
|
|
4427
4429
|
var GitError = class extends AbstractError {
|
|
4428
4430
|
constructor() {
|
|
@@ -4452,6 +4454,23 @@ var Git = class {
|
|
|
4452
4454
|
return null;
|
|
4453
4455
|
}
|
|
4454
4456
|
}
|
|
4457
|
+
async tags() {
|
|
4458
|
+
try {
|
|
4459
|
+
return (await this.git(["tag", "-l"])).trim().split("\n").map((v) => v.slice(1)).sort(import_semver.default.compareIdentifiers);
|
|
4460
|
+
} catch (error) {
|
|
4461
|
+
throw new GitError("Failed to run `git config --get user.name`", {
|
|
4462
|
+
cause: error
|
|
4463
|
+
});
|
|
4464
|
+
}
|
|
4465
|
+
}
|
|
4466
|
+
async previousTag(tag) {
|
|
4467
|
+
try {
|
|
4468
|
+
const tags = await this.tags();
|
|
4469
|
+
return tags.at(tags.findIndex((t) => t === tag) - 1);
|
|
4470
|
+
} catch {
|
|
4471
|
+
return null;
|
|
4472
|
+
}
|
|
4473
|
+
}
|
|
4455
4474
|
async dryFetch() {
|
|
4456
4475
|
try {
|
|
4457
4476
|
return await this.git(["fetch", "--dry-run"]);
|
|
@@ -5317,6 +5336,17 @@ var NpmRegistry = class extends Registry {
|
|
|
5317
5336
|
throw new NpmError("Failed to run `npm whoami`", { cause: error });
|
|
5318
5337
|
}
|
|
5319
5338
|
}
|
|
5339
|
+
async isLoggedIn() {
|
|
5340
|
+
try {
|
|
5341
|
+
await this.npm(["whoami"]);
|
|
5342
|
+
return true;
|
|
5343
|
+
} catch (error) {
|
|
5344
|
+
if (`${error}`.includes("ENEEDAUTH")) {
|
|
5345
|
+
return false;
|
|
5346
|
+
}
|
|
5347
|
+
throw new NpmError("Failed to run `npm whoami`", { cause: error });
|
|
5348
|
+
}
|
|
5349
|
+
}
|
|
5320
5350
|
async collaborators() {
|
|
5321
5351
|
try {
|
|
5322
5352
|
return JSON.parse(
|
|
@@ -5371,7 +5401,13 @@ var NpmRegistry = class extends Registry {
|
|
|
5371
5401
|
}
|
|
5372
5402
|
async publishProvenance() {
|
|
5373
5403
|
try {
|
|
5374
|
-
|
|
5404
|
+
try {
|
|
5405
|
+
await this.npm(["publish", "--provenance", "--access", "public"]);
|
|
5406
|
+
} catch (error) {
|
|
5407
|
+
if (`${error}`.includes("EOTP")) {
|
|
5408
|
+
return false;
|
|
5409
|
+
}
|
|
5410
|
+
}
|
|
5375
5411
|
return true;
|
|
5376
5412
|
} catch (error) {
|
|
5377
5413
|
throw new NpmError(
|
|
@@ -5388,7 +5424,7 @@ var NpmRegistry = class extends Registry {
|
|
|
5388
5424
|
try {
|
|
5389
5425
|
await this.npm(args);
|
|
5390
5426
|
} catch (error) {
|
|
5391
|
-
if (`${error}`.includes("
|
|
5427
|
+
if (`${error}`.includes("EOTP")) {
|
|
5392
5428
|
return false;
|
|
5393
5429
|
}
|
|
5394
5430
|
}
|
|
@@ -5591,6 +5627,11 @@ var npmAvailableCheckTasks = {
|
|
|
5591
5627
|
skip: (ctx) => !!ctx.preview,
|
|
5592
5628
|
task: async () => {
|
|
5593
5629
|
const npm = await npmRegistry();
|
|
5630
|
+
if (!await npm.isLoggedIn()) {
|
|
5631
|
+
throw new NpmAvailableError(
|
|
5632
|
+
"You are not logged in. Please log in first using `npm login`."
|
|
5633
|
+
);
|
|
5634
|
+
}
|
|
5594
5635
|
if (await npm.isPublished()) {
|
|
5595
5636
|
if (!await npm.hasPermission()) {
|
|
5596
5637
|
throw new NpmAvailableError(
|
|
@@ -5637,15 +5678,11 @@ var npmPublishTasks = {
|
|
|
5637
5678
|
"NODE_AUTH_TOKEN not found in the environment variables. Please set the token and try again."
|
|
5638
5679
|
);
|
|
5639
5680
|
}
|
|
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;
|
|
5681
|
+
const result = await npm.publishProvenance();
|
|
5682
|
+
if (!result) {
|
|
5683
|
+
throw new NpmAvailableError(
|
|
5684
|
+
`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 `
|
|
5685
|
+
);
|
|
5649
5686
|
}
|
|
5650
5687
|
}
|
|
5651
5688
|
}
|
|
@@ -5830,13 +5867,13 @@ async function getRegistry(registryKey) {
|
|
|
5830
5867
|
}
|
|
5831
5868
|
|
|
5832
5869
|
// src/utils/engine-version.ts
|
|
5833
|
-
var
|
|
5870
|
+
var import_semver2 = require("semver");
|
|
5834
5871
|
var import_meta3 = {};
|
|
5835
5872
|
async function validateEngineVersion(engine, version2) {
|
|
5836
5873
|
const { engines } = await getPackageJson({
|
|
5837
5874
|
cwd: import_meta3.dirname
|
|
5838
5875
|
});
|
|
5839
|
-
return (0,
|
|
5876
|
+
return (0, import_semver2.satisfies)(version2, `${engines?.[engine]}`, {
|
|
5840
5877
|
includePrerelease: true
|
|
5841
5878
|
});
|
|
5842
5879
|
}
|
|
@@ -5970,15 +6007,13 @@ var requiredConditionsCheckTask = (options) => createListr({
|
|
|
5970
6007
|
|
|
5971
6008
|
// src/tasks/runner.ts
|
|
5972
6009
|
var { open } = import_promise_spawn.default;
|
|
5973
|
-
var { prerelease } =
|
|
6010
|
+
var { prerelease } = import_semver3.default;
|
|
5974
6011
|
async function run(options) {
|
|
5975
|
-
const git = new Git();
|
|
5976
6012
|
const ctx = {
|
|
5977
6013
|
...options,
|
|
5978
6014
|
promptEnabled: !import_std_env.isCI && import_node_process8.default.stdin.isTTY,
|
|
5979
6015
|
npmOnly: options.registries.every((registry) => registry !== "jsr"),
|
|
5980
|
-
jsrOnly: options.registries.every((registry) => registry === "jsr")
|
|
5981
|
-
lastRev: await git.latestTag() || await git.firstCommit()
|
|
6016
|
+
jsrOnly: options.registries.every((registry) => registry === "jsr")
|
|
5982
6017
|
};
|
|
5983
6018
|
try {
|
|
5984
6019
|
if (options.contents) import_node_process8.default.chdir(options.contents);
|
|
@@ -6045,32 +6080,32 @@ async function run(options) {
|
|
|
6045
6080
|
title: "Bumping version",
|
|
6046
6081
|
skip: (ctx2) => !!ctx2.preview,
|
|
6047
6082
|
task: async (ctx2, task) => {
|
|
6048
|
-
const
|
|
6083
|
+
const git = new Git();
|
|
6049
6084
|
let tagCreated = false;
|
|
6050
6085
|
let commited = false;
|
|
6051
6086
|
addRollback(async () => {
|
|
6052
6087
|
if (tagCreated) {
|
|
6053
6088
|
console.log("Deleting tag...");
|
|
6054
|
-
await
|
|
6089
|
+
await git.deleteTag(`${await git.latestTag()}`);
|
|
6055
6090
|
}
|
|
6056
6091
|
if (commited) {
|
|
6057
6092
|
console.log("Reset commits...");
|
|
6058
|
-
await
|
|
6059
|
-
await
|
|
6060
|
-
await
|
|
6061
|
-
await
|
|
6093
|
+
await git.reset();
|
|
6094
|
+
await git.stash();
|
|
6095
|
+
await git.reset("HEAD^", "--hard");
|
|
6096
|
+
await git.popStash();
|
|
6062
6097
|
}
|
|
6063
6098
|
}, ctx2);
|
|
6064
|
-
await
|
|
6099
|
+
await git.reset();
|
|
6065
6100
|
const replaced = await replaceVersion(ctx2.version);
|
|
6066
6101
|
for (const replacedFile of replaced) {
|
|
6067
|
-
await
|
|
6102
|
+
await git.stage(replacedFile);
|
|
6068
6103
|
}
|
|
6069
6104
|
const nextVersion = `v${ctx2.version}`;
|
|
6070
|
-
const commit = await
|
|
6105
|
+
const commit = await git.commit(nextVersion);
|
|
6071
6106
|
commited = true;
|
|
6072
6107
|
task.output = "Creating tag...";
|
|
6073
|
-
await
|
|
6108
|
+
await git.createTag(nextVersion, commit);
|
|
6074
6109
|
tagCreated = true;
|
|
6075
6110
|
}
|
|
6076
6111
|
},
|
|
@@ -6095,11 +6130,11 @@ async function run(options) {
|
|
|
6095
6130
|
title: "Pushing tags to GitHub",
|
|
6096
6131
|
skip: (ctx2) => !!ctx2.preview,
|
|
6097
6132
|
task: async (_, task) => {
|
|
6098
|
-
const
|
|
6099
|
-
const result = await
|
|
6133
|
+
const git = new Git();
|
|
6134
|
+
const result = await git.push("--follow-tags");
|
|
6100
6135
|
if (!result) {
|
|
6101
6136
|
task.title += " (Only tags were pushed because the release branch is protected. Please push the branch manually.)";
|
|
6102
|
-
await
|
|
6137
|
+
await git.push("--tags");
|
|
6103
6138
|
}
|
|
6104
6139
|
}
|
|
6105
6140
|
},
|
|
@@ -6107,16 +6142,17 @@ async function run(options) {
|
|
|
6107
6142
|
skip: (ctx2) => options.skipReleaseDraft || !!ctx2.preview,
|
|
6108
6143
|
title: "Creating release draft on GitHub",
|
|
6109
6144
|
task: async (ctx2, task) => {
|
|
6110
|
-
const
|
|
6111
|
-
const repositoryUrl = await
|
|
6112
|
-
const
|
|
6113
|
-
const
|
|
6145
|
+
const git = new Git();
|
|
6146
|
+
const repositoryUrl = await git.repository();
|
|
6147
|
+
const latestTag = `${await git.latestTag()}`;
|
|
6148
|
+
const lastRev = await git.previousTag(latestTag) || await git.firstCommit();
|
|
6149
|
+
const commits = (await git.commits(lastRev, `${latestTag}`)).slice(1);
|
|
6114
6150
|
let body = commits.map(
|
|
6115
6151
|
({ id, message }) => `- ${message.replace("#", `${repositoryUrl}/issues/`)} ${repositoryUrl}/commit/${id}`
|
|
6116
6152
|
).join("\n");
|
|
6117
6153
|
body += `
|
|
6118
6154
|
|
|
6119
|
-
${repositoryUrl}/compare/${
|
|
6155
|
+
${repositoryUrl}/compare/${lastRev}...${latestTag}`;
|
|
6120
6156
|
const releaseDraftUrl = new URL(
|
|
6121
6157
|
`${repositoryUrl}/releases/new`
|
|
6122
6158
|
);
|
package/dist/index.d.cts
CHANGED
|
@@ -85,6 +85,16 @@ interface Options {
|
|
|
85
85
|
registries?: RegistryType[];
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
+
/**
|
|
89
|
+
* Runs the `pubm` function with the provided options.
|
|
90
|
+
*
|
|
91
|
+
* This function executes the publish process using the specified options.
|
|
92
|
+
* The `version` field in the `options` parameter is required for the function
|
|
93
|
+
* to run correctly.
|
|
94
|
+
*
|
|
95
|
+
* @async
|
|
96
|
+
* @function
|
|
97
|
+
*/
|
|
88
98
|
declare function pubm(options: Options): Promise<void>;
|
|
89
99
|
|
|
90
|
-
export { pubm };
|
|
100
|
+
export { type Options, pubm };
|
package/dist/index.d.ts
CHANGED
|
@@ -85,6 +85,16 @@ interface Options {
|
|
|
85
85
|
registries?: RegistryType[];
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
+
/**
|
|
89
|
+
* Runs the `pubm` function with the provided options.
|
|
90
|
+
*
|
|
91
|
+
* This function executes the publish process using the specified options.
|
|
92
|
+
* The `version` field in the `options` parameter is required for the function
|
|
93
|
+
* to run correctly.
|
|
94
|
+
*
|
|
95
|
+
* @async
|
|
96
|
+
* @function
|
|
97
|
+
*/
|
|
88
98
|
declare function pubm(options: Options): Promise<void>;
|
|
89
99
|
|
|
90
|
-
export { pubm };
|
|
100
|
+
export { type Options, pubm };
|
package/dist/index.js
CHANGED
|
@@ -1930,6 +1930,7 @@ var init_cli_truncate = __esm({
|
|
|
1930
1930
|
// src/options.ts
|
|
1931
1931
|
var defaultOptions = {
|
|
1932
1932
|
testScript: "test",
|
|
1933
|
+
buildScript: "build",
|
|
1933
1934
|
branch: "main",
|
|
1934
1935
|
tag: "latest",
|
|
1935
1936
|
registries: ["npm", "jsr"]
|
|
@@ -4414,6 +4415,7 @@ function consoleError(error) {
|
|
|
4414
4415
|
}
|
|
4415
4416
|
|
|
4416
4417
|
// src/git.ts
|
|
4418
|
+
import semver from "semver";
|
|
4417
4419
|
import { exec as exec2 } from "tinyexec";
|
|
4418
4420
|
var GitError = class extends AbstractError {
|
|
4419
4421
|
constructor() {
|
|
@@ -4443,6 +4445,23 @@ var Git = class {
|
|
|
4443
4445
|
return null;
|
|
4444
4446
|
}
|
|
4445
4447
|
}
|
|
4448
|
+
async tags() {
|
|
4449
|
+
try {
|
|
4450
|
+
return (await this.git(["tag", "-l"])).trim().split("\n").map((v) => v.slice(1)).sort(semver.compareIdentifiers);
|
|
4451
|
+
} catch (error) {
|
|
4452
|
+
throw new GitError("Failed to run `git config --get user.name`", {
|
|
4453
|
+
cause: error
|
|
4454
|
+
});
|
|
4455
|
+
}
|
|
4456
|
+
}
|
|
4457
|
+
async previousTag(tag) {
|
|
4458
|
+
try {
|
|
4459
|
+
const tags = await this.tags();
|
|
4460
|
+
return tags.at(tags.findIndex((t) => t === tag) - 1);
|
|
4461
|
+
} catch {
|
|
4462
|
+
return null;
|
|
4463
|
+
}
|
|
4464
|
+
}
|
|
4446
4465
|
async dryFetch() {
|
|
4447
4466
|
try {
|
|
4448
4467
|
return await this.git(["fetch", "--dry-run"]);
|
|
@@ -5306,6 +5325,17 @@ var NpmRegistry = class extends Registry {
|
|
|
5306
5325
|
throw new NpmError("Failed to run `npm whoami`", { cause: error });
|
|
5307
5326
|
}
|
|
5308
5327
|
}
|
|
5328
|
+
async isLoggedIn() {
|
|
5329
|
+
try {
|
|
5330
|
+
await this.npm(["whoami"]);
|
|
5331
|
+
return true;
|
|
5332
|
+
} catch (error) {
|
|
5333
|
+
if (`${error}`.includes("ENEEDAUTH")) {
|
|
5334
|
+
return false;
|
|
5335
|
+
}
|
|
5336
|
+
throw new NpmError("Failed to run `npm whoami`", { cause: error });
|
|
5337
|
+
}
|
|
5338
|
+
}
|
|
5309
5339
|
async collaborators() {
|
|
5310
5340
|
try {
|
|
5311
5341
|
return JSON.parse(
|
|
@@ -5360,7 +5390,13 @@ var NpmRegistry = class extends Registry {
|
|
|
5360
5390
|
}
|
|
5361
5391
|
async publishProvenance() {
|
|
5362
5392
|
try {
|
|
5363
|
-
|
|
5393
|
+
try {
|
|
5394
|
+
await this.npm(["publish", "--provenance", "--access", "public"]);
|
|
5395
|
+
} catch (error) {
|
|
5396
|
+
if (`${error}`.includes("EOTP")) {
|
|
5397
|
+
return false;
|
|
5398
|
+
}
|
|
5399
|
+
}
|
|
5364
5400
|
return true;
|
|
5365
5401
|
} catch (error) {
|
|
5366
5402
|
throw new NpmError(
|
|
@@ -5377,7 +5413,7 @@ var NpmRegistry = class extends Registry {
|
|
|
5377
5413
|
try {
|
|
5378
5414
|
await this.npm(args);
|
|
5379
5415
|
} catch (error) {
|
|
5380
|
-
if (`${error}`.includes("
|
|
5416
|
+
if (`${error}`.includes("EOTP")) {
|
|
5381
5417
|
return false;
|
|
5382
5418
|
}
|
|
5383
5419
|
}
|
|
@@ -5580,6 +5616,11 @@ var npmAvailableCheckTasks = {
|
|
|
5580
5616
|
skip: (ctx) => !!ctx.preview,
|
|
5581
5617
|
task: async () => {
|
|
5582
5618
|
const npm = await npmRegistry();
|
|
5619
|
+
if (!await npm.isLoggedIn()) {
|
|
5620
|
+
throw new NpmAvailableError(
|
|
5621
|
+
"You are not logged in. Please log in first using `npm login`."
|
|
5622
|
+
);
|
|
5623
|
+
}
|
|
5583
5624
|
if (await npm.isPublished()) {
|
|
5584
5625
|
if (!await npm.hasPermission()) {
|
|
5585
5626
|
throw new NpmAvailableError(
|
|
@@ -5626,15 +5667,11 @@ var npmPublishTasks = {
|
|
|
5626
5667
|
"NODE_AUTH_TOKEN not found in the environment variables. Please set the token and try again."
|
|
5627
5668
|
);
|
|
5628
5669
|
}
|
|
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;
|
|
5670
|
+
const result = await npm.publishProvenance();
|
|
5671
|
+
if (!result) {
|
|
5672
|
+
throw new NpmAvailableError(
|
|
5673
|
+
`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 `
|
|
5674
|
+
);
|
|
5638
5675
|
}
|
|
5639
5676
|
}
|
|
5640
5677
|
}
|
|
@@ -5960,13 +5997,11 @@ var requiredConditionsCheckTask = (options) => createListr({
|
|
|
5960
5997
|
var { open } = npmCli;
|
|
5961
5998
|
var { prerelease } = SemVer;
|
|
5962
5999
|
async function run(options) {
|
|
5963
|
-
const git = new Git();
|
|
5964
6000
|
const ctx = {
|
|
5965
6001
|
...options,
|
|
5966
6002
|
promptEnabled: !isCI2 && process10.stdin.isTTY,
|
|
5967
6003
|
npmOnly: options.registries.every((registry) => registry !== "jsr"),
|
|
5968
|
-
jsrOnly: options.registries.every((registry) => registry === "jsr")
|
|
5969
|
-
lastRev: await git.latestTag() || await git.firstCommit()
|
|
6004
|
+
jsrOnly: options.registries.every((registry) => registry === "jsr")
|
|
5970
6005
|
};
|
|
5971
6006
|
try {
|
|
5972
6007
|
if (options.contents) process10.chdir(options.contents);
|
|
@@ -6033,32 +6068,32 @@ async function run(options) {
|
|
|
6033
6068
|
title: "Bumping version",
|
|
6034
6069
|
skip: (ctx2) => !!ctx2.preview,
|
|
6035
6070
|
task: async (ctx2, task) => {
|
|
6036
|
-
const
|
|
6071
|
+
const git = new Git();
|
|
6037
6072
|
let tagCreated = false;
|
|
6038
6073
|
let commited = false;
|
|
6039
6074
|
addRollback(async () => {
|
|
6040
6075
|
if (tagCreated) {
|
|
6041
6076
|
console.log("Deleting tag...");
|
|
6042
|
-
await
|
|
6077
|
+
await git.deleteTag(`${await git.latestTag()}`);
|
|
6043
6078
|
}
|
|
6044
6079
|
if (commited) {
|
|
6045
6080
|
console.log("Reset commits...");
|
|
6046
|
-
await
|
|
6047
|
-
await
|
|
6048
|
-
await
|
|
6049
|
-
await
|
|
6081
|
+
await git.reset();
|
|
6082
|
+
await git.stash();
|
|
6083
|
+
await git.reset("HEAD^", "--hard");
|
|
6084
|
+
await git.popStash();
|
|
6050
6085
|
}
|
|
6051
6086
|
}, ctx2);
|
|
6052
|
-
await
|
|
6087
|
+
await git.reset();
|
|
6053
6088
|
const replaced = await replaceVersion(ctx2.version);
|
|
6054
6089
|
for (const replacedFile of replaced) {
|
|
6055
|
-
await
|
|
6090
|
+
await git.stage(replacedFile);
|
|
6056
6091
|
}
|
|
6057
6092
|
const nextVersion = `v${ctx2.version}`;
|
|
6058
|
-
const commit = await
|
|
6093
|
+
const commit = await git.commit(nextVersion);
|
|
6059
6094
|
commited = true;
|
|
6060
6095
|
task.output = "Creating tag...";
|
|
6061
|
-
await
|
|
6096
|
+
await git.createTag(nextVersion, commit);
|
|
6062
6097
|
tagCreated = true;
|
|
6063
6098
|
}
|
|
6064
6099
|
},
|
|
@@ -6083,11 +6118,11 @@ async function run(options) {
|
|
|
6083
6118
|
title: "Pushing tags to GitHub",
|
|
6084
6119
|
skip: (ctx2) => !!ctx2.preview,
|
|
6085
6120
|
task: async (_, task) => {
|
|
6086
|
-
const
|
|
6087
|
-
const result = await
|
|
6121
|
+
const git = new Git();
|
|
6122
|
+
const result = await git.push("--follow-tags");
|
|
6088
6123
|
if (!result) {
|
|
6089
6124
|
task.title += " (Only tags were pushed because the release branch is protected. Please push the branch manually.)";
|
|
6090
|
-
await
|
|
6125
|
+
await git.push("--tags");
|
|
6091
6126
|
}
|
|
6092
6127
|
}
|
|
6093
6128
|
},
|
|
@@ -6095,16 +6130,17 @@ async function run(options) {
|
|
|
6095
6130
|
skip: (ctx2) => options.skipReleaseDraft || !!ctx2.preview,
|
|
6096
6131
|
title: "Creating release draft on GitHub",
|
|
6097
6132
|
task: async (ctx2, task) => {
|
|
6098
|
-
const
|
|
6099
|
-
const repositoryUrl = await
|
|
6100
|
-
const
|
|
6101
|
-
const
|
|
6133
|
+
const git = new Git();
|
|
6134
|
+
const repositoryUrl = await git.repository();
|
|
6135
|
+
const latestTag = `${await git.latestTag()}`;
|
|
6136
|
+
const lastRev = await git.previousTag(latestTag) || await git.firstCommit();
|
|
6137
|
+
const commits = (await git.commits(lastRev, `${latestTag}`)).slice(1);
|
|
6102
6138
|
let body = commits.map(
|
|
6103
6139
|
({ id, message }) => `- ${message.replace("#", `${repositoryUrl}/issues/`)} ${repositoryUrl}/commit/${id}`
|
|
6104
6140
|
).join("\n");
|
|
6105
6141
|
body += `
|
|
6106
6142
|
|
|
6107
|
-
${repositoryUrl}/compare/${
|
|
6143
|
+
${repositoryUrl}/compare/${lastRev}...${latestTag}`;
|
|
6108
6144
|
const releaseDraftUrl = new URL(
|
|
6109
6145
|
`${repositoryUrl}/releases/new`
|
|
6110
6146
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pubm",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4-0",
|
|
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
|