pubm 0.0.2-6 → 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 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 semver2 from "semver";
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
- await this.npm(["publish", "--provenance", "--access", "public"]);
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("OTP")) {
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,7 +5671,12 @@ 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
- await npm.publishProvenance();
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
+ );
5679
+ }
5634
5680
  }
5635
5681
  }
5636
5682
  };
@@ -5955,13 +6001,11 @@ var requiredConditionsCheckTask = (options2) => createListr({
5955
6001
  var { open } = npmCli;
5956
6002
  var { prerelease } = SemVer;
5957
6003
  async function run(options2) {
5958
- const git = new Git();
5959
6004
  const ctx = {
5960
6005
  ...options2,
5961
6006
  promptEnabled: !isCI2 && process10.stdin.isTTY,
5962
6007
  npmOnly: options2.registries.every((registry) => registry !== "jsr"),
5963
- jsrOnly: options2.registries.every((registry) => registry === "jsr"),
5964
- lastRev: await git.latestTag() || await git.firstCommit()
6008
+ jsrOnly: options2.registries.every((registry) => registry === "jsr")
5965
6009
  };
5966
6010
  try {
5967
6011
  if (options2.contents) process10.chdir(options2.contents);
@@ -6028,32 +6072,32 @@ async function run(options2) {
6028
6072
  title: "Bumping version",
6029
6073
  skip: (ctx2) => !!ctx2.preview,
6030
6074
  task: async (ctx2, task) => {
6031
- const git2 = new Git();
6075
+ const git = new Git();
6032
6076
  let tagCreated = false;
6033
6077
  let commited = false;
6034
6078
  addRollback(async () => {
6035
6079
  if (tagCreated) {
6036
6080
  console.log("Deleting tag...");
6037
- await git2.deleteTag(`${await git2.latestTag()}`);
6081
+ await git.deleteTag(`${await git.latestTag()}`);
6038
6082
  }
6039
6083
  if (commited) {
6040
6084
  console.log("Reset commits...");
6041
- await git2.reset();
6042
- await git2.stash();
6043
- await git2.reset("HEAD^", "--hard");
6044
- await git2.popStash();
6085
+ await git.reset();
6086
+ await git.stash();
6087
+ await git.reset("HEAD^", "--hard");
6088
+ await git.popStash();
6045
6089
  }
6046
6090
  }, ctx2);
6047
- await git2.reset();
6091
+ await git.reset();
6048
6092
  const replaced = await replaceVersion(ctx2.version);
6049
6093
  for (const replacedFile of replaced) {
6050
- await git2.stage(replacedFile);
6094
+ await git.stage(replacedFile);
6051
6095
  }
6052
6096
  const nextVersion = `v${ctx2.version}`;
6053
- const commit = await git2.commit(nextVersion);
6097
+ const commit = await git.commit(nextVersion);
6054
6098
  commited = true;
6055
6099
  task.output = "Creating tag...";
6056
- await git2.createTag(nextVersion, commit);
6100
+ await git.createTag(nextVersion, commit);
6057
6101
  tagCreated = true;
6058
6102
  }
6059
6103
  },
@@ -6078,11 +6122,11 @@ async function run(options2) {
6078
6122
  title: "Pushing tags to GitHub",
6079
6123
  skip: (ctx2) => !!ctx2.preview,
6080
6124
  task: async (_, task) => {
6081
- const git2 = new Git();
6082
- const result = await git2.push("--follow-tags");
6125
+ const git = new Git();
6126
+ const result = await git.push("--follow-tags");
6083
6127
  if (!result) {
6084
6128
  task.title += " (Only tags were pushed because the release branch is protected. Please push the branch manually.)";
6085
- await git2.push("--tags");
6129
+ await git.push("--tags");
6086
6130
  }
6087
6131
  }
6088
6132
  },
@@ -6090,16 +6134,17 @@ async function run(options2) {
6090
6134
  skip: (ctx2) => options2.skipReleaseDraft || !!ctx2.preview,
6091
6135
  title: "Creating release draft on GitHub",
6092
6136
  task: async (ctx2, task) => {
6093
- const git2 = new Git();
6094
- const repositoryUrl = await git2.repository();
6095
- const commits = (await git2.commits(ctx2.lastRev, `${await git2.latestTag()}`)).slice(1);
6096
- const latestTag = await git2.latestTag();
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);
6097
6142
  let body = commits.map(
6098
6143
  ({ id, message }) => `- ${message.replace("#", `${repositoryUrl}/issues/`)} ${repositoryUrl}/commit/${id}`
6099
6144
  ).join("\n");
6100
6145
  body += `
6101
6146
 
6102
- ${repositoryUrl}/compare/${ctx2.lastRev}...${latestTag}`;
6147
+ ${repositoryUrl}/compare/${lastRev}...${latestTag}`;
6103
6148
  const releaseDraftUrl = new URL(
6104
6149
  `${repositoryUrl}/releases/new`
6105
6150
  );
@@ -6139,8 +6184,8 @@ async function pubm(options2) {
6139
6184
 
6140
6185
  // src/tasks/required-missing-information.ts
6141
6186
  import { ListrEnquirerPromptAdapter as ListrEnquirerPromptAdapter5 } from "@listr2/prompt-adapter-enquirer";
6142
- import semver from "semver";
6143
- var { RELEASE_TYPES, SemVer: SemVer2, prerelease: prerelease2 } = semver;
6187
+ import semver2 from "semver";
6188
+ var { RELEASE_TYPES, SemVer: SemVer2, prerelease: prerelease2 } = semver2;
6144
6189
  var requiredMissingInformationTasks = (options2) => createListr({
6145
6190
  ...options2,
6146
6191
  title: "Checking required information",
@@ -6268,8 +6313,7 @@ Update available! \`${name}\` ${color.red(currentVersion)} \u2192 ${color.green(
6268
6313
  }
6269
6314
 
6270
6315
  // src/cli.ts
6271
- import { isCI as isCI3 } from "std-env";
6272
- var { RELEASE_TYPES: RELEASE_TYPES2, valid } = semver2;
6316
+ var { RELEASE_TYPES: RELEASE_TYPES2, valid } = semver3;
6273
6317
  var options = [
6274
6318
  {
6275
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 import_semver2 = __toESM(require("semver"), 1);
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
- await this.npm(["publish", "--provenance", "--access", "public"]);
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("OTP")) {
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,7 +5677,12 @@ 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
- await npm.publishProvenance();
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
+ );
5685
+ }
5641
5686
  }
5642
5687
  }
5643
5688
  };
@@ -5821,13 +5866,13 @@ async function getRegistry(registryKey) {
5821
5866
  }
5822
5867
 
5823
5868
  // src/utils/engine-version.ts
5824
- var import_semver = require("semver");
5869
+ var import_semver2 = require("semver");
5825
5870
  var import_meta3 = {};
5826
5871
  async function validateEngineVersion(engine, version2) {
5827
5872
  const { engines } = await getPackageJson({
5828
5873
  cwd: import_meta3.dirname
5829
5874
  });
5830
- return (0, import_semver.satisfies)(version2, `${engines?.[engine]}`, {
5875
+ return (0, import_semver2.satisfies)(version2, `${engines?.[engine]}`, {
5831
5876
  includePrerelease: true
5832
5877
  });
5833
5878
  }
@@ -5961,15 +6006,13 @@ var requiredConditionsCheckTask = (options) => createListr({
5961
6006
 
5962
6007
  // src/tasks/runner.ts
5963
6008
  var { open } = import_promise_spawn.default;
5964
- var { prerelease } = import_semver2.default;
6009
+ var { prerelease } = import_semver3.default;
5965
6010
  async function run(options) {
5966
- const git = new Git();
5967
6011
  const ctx = {
5968
6012
  ...options,
5969
6013
  promptEnabled: !import_std_env.isCI && import_node_process8.default.stdin.isTTY,
5970
6014
  npmOnly: options.registries.every((registry) => registry !== "jsr"),
5971
- jsrOnly: options.registries.every((registry) => registry === "jsr"),
5972
- lastRev: await git.latestTag() || await git.firstCommit()
6015
+ jsrOnly: options.registries.every((registry) => registry === "jsr")
5973
6016
  };
5974
6017
  try {
5975
6018
  if (options.contents) import_node_process8.default.chdir(options.contents);
@@ -6036,32 +6079,32 @@ async function run(options) {
6036
6079
  title: "Bumping version",
6037
6080
  skip: (ctx2) => !!ctx2.preview,
6038
6081
  task: async (ctx2, task) => {
6039
- const git2 = new Git();
6082
+ const git = new Git();
6040
6083
  let tagCreated = false;
6041
6084
  let commited = false;
6042
6085
  addRollback(async () => {
6043
6086
  if (tagCreated) {
6044
6087
  console.log("Deleting tag...");
6045
- await git2.deleteTag(`${await git2.latestTag()}`);
6088
+ await git.deleteTag(`${await git.latestTag()}`);
6046
6089
  }
6047
6090
  if (commited) {
6048
6091
  console.log("Reset commits...");
6049
- await git2.reset();
6050
- await git2.stash();
6051
- await git2.reset("HEAD^", "--hard");
6052
- await git2.popStash();
6092
+ await git.reset();
6093
+ await git.stash();
6094
+ await git.reset("HEAD^", "--hard");
6095
+ await git.popStash();
6053
6096
  }
6054
6097
  }, ctx2);
6055
- await git2.reset();
6098
+ await git.reset();
6056
6099
  const replaced = await replaceVersion(ctx2.version);
6057
6100
  for (const replacedFile of replaced) {
6058
- await git2.stage(replacedFile);
6101
+ await git.stage(replacedFile);
6059
6102
  }
6060
6103
  const nextVersion = `v${ctx2.version}`;
6061
- const commit = await git2.commit(nextVersion);
6104
+ const commit = await git.commit(nextVersion);
6062
6105
  commited = true;
6063
6106
  task.output = "Creating tag...";
6064
- await git2.createTag(nextVersion, commit);
6107
+ await git.createTag(nextVersion, commit);
6065
6108
  tagCreated = true;
6066
6109
  }
6067
6110
  },
@@ -6086,11 +6129,11 @@ async function run(options) {
6086
6129
  title: "Pushing tags to GitHub",
6087
6130
  skip: (ctx2) => !!ctx2.preview,
6088
6131
  task: async (_, task) => {
6089
- const git2 = new Git();
6090
- const result = await git2.push("--follow-tags");
6132
+ const git = new Git();
6133
+ const result = await git.push("--follow-tags");
6091
6134
  if (!result) {
6092
6135
  task.title += " (Only tags were pushed because the release branch is protected. Please push the branch manually.)";
6093
- await git2.push("--tags");
6136
+ await git.push("--tags");
6094
6137
  }
6095
6138
  }
6096
6139
  },
@@ -6098,16 +6141,17 @@ async function run(options) {
6098
6141
  skip: (ctx2) => options.skipReleaseDraft || !!ctx2.preview,
6099
6142
  title: "Creating release draft on GitHub",
6100
6143
  task: async (ctx2, task) => {
6101
- const git2 = new Git();
6102
- const repositoryUrl = await git2.repository();
6103
- const commits = (await git2.commits(ctx2.lastRev, `${await git2.latestTag()}`)).slice(1);
6104
- const latestTag = await git2.latestTag();
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);
6105
6149
  let body = commits.map(
6106
6150
  ({ id, message }) => `- ${message.replace("#", `${repositoryUrl}/issues/`)} ${repositoryUrl}/commit/${id}`
6107
6151
  ).join("\n");
6108
6152
  body += `
6109
6153
 
6110
- ${repositoryUrl}/compare/${ctx2.lastRev}...${latestTag}`;
6154
+ ${repositoryUrl}/compare/${lastRev}...${latestTag}`;
6111
6155
  const releaseDraftUrl = new URL(
6112
6156
  `${repositoryUrl}/releases/new`
6113
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
- await this.npm(["publish", "--provenance", "--access", "public"]);
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("OTP")) {
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,7 +5666,12 @@ 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
- await npm.publishProvenance();
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
+ );
5674
+ }
5630
5675
  }
5631
5676
  }
5632
5677
  };
@@ -5951,13 +5996,11 @@ var requiredConditionsCheckTask = (options) => createListr({
5951
5996
  var { open } = npmCli;
5952
5997
  var { prerelease } = SemVer;
5953
5998
  async function run(options) {
5954
- const git = new Git();
5955
5999
  const ctx = {
5956
6000
  ...options,
5957
6001
  promptEnabled: !isCI2 && process10.stdin.isTTY,
5958
6002
  npmOnly: options.registries.every((registry) => registry !== "jsr"),
5959
- jsrOnly: options.registries.every((registry) => registry === "jsr"),
5960
- lastRev: await git.latestTag() || await git.firstCommit()
6003
+ jsrOnly: options.registries.every((registry) => registry === "jsr")
5961
6004
  };
5962
6005
  try {
5963
6006
  if (options.contents) process10.chdir(options.contents);
@@ -6024,32 +6067,32 @@ async function run(options) {
6024
6067
  title: "Bumping version",
6025
6068
  skip: (ctx2) => !!ctx2.preview,
6026
6069
  task: async (ctx2, task) => {
6027
- const git2 = new Git();
6070
+ const git = new Git();
6028
6071
  let tagCreated = false;
6029
6072
  let commited = false;
6030
6073
  addRollback(async () => {
6031
6074
  if (tagCreated) {
6032
6075
  console.log("Deleting tag...");
6033
- await git2.deleteTag(`${await git2.latestTag()}`);
6076
+ await git.deleteTag(`${await git.latestTag()}`);
6034
6077
  }
6035
6078
  if (commited) {
6036
6079
  console.log("Reset commits...");
6037
- await git2.reset();
6038
- await git2.stash();
6039
- await git2.reset("HEAD^", "--hard");
6040
- await git2.popStash();
6080
+ await git.reset();
6081
+ await git.stash();
6082
+ await git.reset("HEAD^", "--hard");
6083
+ await git.popStash();
6041
6084
  }
6042
6085
  }, ctx2);
6043
- await git2.reset();
6086
+ await git.reset();
6044
6087
  const replaced = await replaceVersion(ctx2.version);
6045
6088
  for (const replacedFile of replaced) {
6046
- await git2.stage(replacedFile);
6089
+ await git.stage(replacedFile);
6047
6090
  }
6048
6091
  const nextVersion = `v${ctx2.version}`;
6049
- const commit = await git2.commit(nextVersion);
6092
+ const commit = await git.commit(nextVersion);
6050
6093
  commited = true;
6051
6094
  task.output = "Creating tag...";
6052
- await git2.createTag(nextVersion, commit);
6095
+ await git.createTag(nextVersion, commit);
6053
6096
  tagCreated = true;
6054
6097
  }
6055
6098
  },
@@ -6074,11 +6117,11 @@ async function run(options) {
6074
6117
  title: "Pushing tags to GitHub",
6075
6118
  skip: (ctx2) => !!ctx2.preview,
6076
6119
  task: async (_, task) => {
6077
- const git2 = new Git();
6078
- const result = await git2.push("--follow-tags");
6120
+ const git = new Git();
6121
+ const result = await git.push("--follow-tags");
6079
6122
  if (!result) {
6080
6123
  task.title += " (Only tags were pushed because the release branch is protected. Please push the branch manually.)";
6081
- await git2.push("--tags");
6124
+ await git.push("--tags");
6082
6125
  }
6083
6126
  }
6084
6127
  },
@@ -6086,16 +6129,17 @@ async function run(options) {
6086
6129
  skip: (ctx2) => options.skipReleaseDraft || !!ctx2.preview,
6087
6130
  title: "Creating release draft on GitHub",
6088
6131
  task: async (ctx2, task) => {
6089
- const git2 = new Git();
6090
- const repositoryUrl = await git2.repository();
6091
- const commits = (await git2.commits(ctx2.lastRev, `${await git2.latestTag()}`)).slice(1);
6092
- const latestTag = await git2.latestTag();
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);
6093
6137
  let body = commits.map(
6094
6138
  ({ id, message }) => `- ${message.replace("#", `${repositoryUrl}/issues/`)} ${repositoryUrl}/commit/${id}`
6095
6139
  ).join("\n");
6096
6140
  body += `
6097
6141
 
6098
- ${repositoryUrl}/compare/${ctx2.lastRev}...${latestTag}`;
6142
+ ${repositoryUrl}/compare/${lastRev}...${latestTag}`;
6099
6143
  const releaseDraftUrl = new URL(
6100
6144
  `${repositoryUrl}/releases/new`
6101
6145
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pubm",
3
- "version": "0.0.2-6",
3
+ "version": "0.0.3",
4
4
  "engines": {
5
5
  "node": ">=18",
6
6
  "git": ">=2.11.0"
@@ -50,7 +50,8 @@
50
50
  "@types/npmcli__promise-spawn": "^6.0.3",
51
51
  "@types/semver": "^7.5.8",
52
52
  "@vitest/coverage-v8": "^2.1.1",
53
- "pubm": "^0.0.2-1",
53
+ "jsr": "^0.13.2",
54
+ "pubm": "^0.0.2-14",
54
55
  "tsup": "^8.3.0",
55
56
  "typescript": "^5.6.2",
56
57
  "vitest": "^2.1.1"
@@ -1 +0,0 @@
1
- bb1b5e0897a25b17444b95266e3494d0e653bae57836260243bf54194f71cd729bf8abe6cdc4a6a86b5f03b4200033fc