pubm 0.0.0-alpha.15 → 0.0.0-alpha.19

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
@@ -10,24 +10,63 @@ pubm
10
10
  publish manager for multiple registry (jsr, npm and private registries)
11
11
  <p>
12
12
 
13
- ## Why
13
+ ## Features
14
14
 
15
- - Customize with plugin
15
+ - Publish package to npm and jsr at once
16
+ - Customize (Soon)
16
17
  - GitHub release draft format
17
- - Adjust tasks (Add, Remove, Sorting)
18
+ - Adjust tasks (Add, Remove, Sorting tasks)
18
19
 
19
- It is designed to be easy to managing publish to multiple registry.
20
+ ## Prerequisites
21
+
22
+ - Node.js 18 or later
23
+ - npm 9 or later
24
+ - Git 2.11 or later
25
+
26
+ ## Install
27
+
28
+ ```bash
29
+ npm i -g pubm
30
+ ```
20
31
 
21
32
  ## Usage
22
33
 
23
34
  ```bash
24
- pubm [version]
35
+ Usage:
36
+ $ pubm [version]
37
+
38
+ Version can be:
39
+ major | premajor | minor | preminor | patch | prepatch | prerelease | 1.2.3
40
+
41
+ Options:
42
+ --test-script <script> The npm script to run tests before publishing (default: test)
43
+ --build-script <script> The npm script to run build before publishing (default: build)
44
+ -p, --preview Show tasks without actually executing publish
45
+ -b, --branch <name> Name of the release branch (default: main)
46
+ -a, --any-branch Show tasks without actually executing publish
47
+ --no-pre-check Skip prerequisites check task
48
+ --no-condition-check Skip required conditions check task
49
+ --no-tests Skip running tests before publishing
50
+ --no-build Skip build before publishing
51
+ --no-publish Skip publishing task
52
+ --no-release-draft Skip creating a GitHub release draft
53
+ -t, --tag <name> Publish under a specific dist-tag (default: latest)
54
+ -c, --contents <path> Subdirectory to publish
55
+ --no-save-token Do not save jsr tokens (request the token each time)
56
+ --registry <...registries> Target registries for publish
57
+ registry can be npm | jsr | https://url.for.private-registries (default: npm,jsr)
58
+ -h, --help Display this message
59
+ -v, --version Display version number
25
60
  ```
26
61
 
27
- ## Config file for publish
62
+ ## Config for publish
28
63
 
29
64
  You can have either package.json or jsr.json.
30
65
 
66
+ ### Configuration file (Soon)
67
+
68
+ `pubm.js` or `pubm.mjs`
69
+
31
70
 
32
71
  ## Tasks
33
72
 
@@ -36,35 +75,35 @@ You can have either package.json or jsr.json.
36
75
  pubm tasks
37
76
  </summary>
38
77
 
39
- - Notify new version
40
- - Checking required information
41
- - Select SemVer increment or specify new version
42
- - Select the tag for this pre-release version in npm: (if version is prerelease)
43
- - checking for the existence of either package.json or jsr.json
44
- - Prerequisite checks = skip-pre (for deployment reliability)
45
- - Checking if remote history is clean...
46
- - Checking if the local working tree is clean...
47
- - Checking if commits exist since the last release...
48
- - Verifying current branch is a release branch...
49
- - Checking git tag existence...
50
- - Required conditions checks (concurrently) = skip-required (for pubm tasks)
51
- - Verifying if npm CLI and jsr CLI are installed...
52
- - Ping registries...
53
- - Checking if test and build scripts exist...
54
- - Checking git version...
55
- - Checking available registries for publishing...
56
- - in jsr permission check token exist and ask token
57
- - if first time -> Checking package name availability...
58
- - if scoped package and scope reserved contact message
59
- - Running tests...
60
- - Building the project...
61
- - Bumping version...
62
- - Publishing... (concurrently)
63
- - npm
64
- - Running npm publish...
65
- - Verifying two-factor authentication...
66
- - jsr
67
- - Running jsr publish...
78
+ - Notify new version
79
+ - Checking required information
80
+ - Select SemVer increment or specify new version
81
+ - Select the tag for this pre-release version in npm: (if version is prerelease)
82
+ - checking for the existence of either package.json or jsr.json
83
+ - Prerequisite checks = skip-pre (for deployment reliability)
84
+ - Checking if remote history is clean...
85
+ - Checking if the local working tree is clean...
86
+ - Checking if commits exist since the last release...
87
+ - Verifying current branch is a release branch...
88
+ - Checking git tag existence...
89
+ - Required conditions checks (concurrently) = skip-required (for pubm tasks)
90
+ - Verifying if npm CLI and jsr CLI are installed...
91
+ - Ping registries...
92
+ - Checking if test and build scripts exist...
93
+ - Checking git version...
94
+ - Checking available registries for publishing...
95
+ - in jsr permission check token exist and ask token
96
+ - if first time -> Checking package name availability...
97
+ - if scoped package and scope reserved contact message
98
+ - Running tests...
99
+ - Building the project...
100
+ - Bumping version...
101
+ - Publishing... (concurrently)
102
+ - npm
103
+ - Running npm publish...
104
+ - Verifying two-factor authentication...
105
+ - jsr
106
+ - Running jsr publish...
68
107
  - Pushing tags to GitHub...
69
108
  - Creating release draft on GitHub...
70
109
  </details>
@@ -103,3 +142,15 @@ np tasks
103
142
  - Push tags
104
143
  - Release draft
105
144
  </details>
145
+
146
+ ## FAQ
147
+
148
+ ### Why does jsr only ask for tokens?
149
+
150
+ The only way to access jsr’s certified environment is through a direct API request with a token.
151
+
152
+ ### How is the jsr token stored? Is it secure?
153
+
154
+ The jsr token is encrypted and stored using various layers of information. As long as you have control over the local machine where pubm was run, it is highly unlikely the token can be compromised.
155
+
156
+ If you prefer not to save tokens, you can use the `--no-save-token` option, which will request the token each time.
@@ -1 +1 @@
1
- 2c2abf8d3c256c379227aa11b4fd4fa9135c8a95045eea658710f7f8b9fb142ad31c524b5a440994494d785cd19991a9
1
+ bb1b5e0897a25b17444b95266e3494d0e653bae57836260243bf54194f71cd729bf8abe6cdc4a6a86b5f03b4200033fc
package/bin/cli.js CHANGED
@@ -58,6 +58,7 @@ function resolveOptions(options2) {
58
58
  }
59
59
 
60
60
  // src/tasks/runner.ts
61
+ import process2 from "node:process";
61
62
  import npmCli from "@npmcli/promise-spawn";
62
63
  import { color as color5 } from "listr2";
63
64
  import SemVer from "semver";
@@ -366,13 +367,13 @@ function createListr(...args) {
366
367
  // src/utils/package.ts
367
368
  import { readFile, stat, writeFile } from "node:fs/promises";
368
369
  import path from "node:path";
369
- import process2 from "node:process";
370
+ import process from "node:process";
370
371
  var cachedPackageJson = {};
371
372
  var cachedJsrJson = {};
372
- async function patchCachedJsrJson(contents, { cwd = process2.cwd() } = {}) {
373
+ async function patchCachedJsrJson(contents, { cwd = process.cwd() } = {}) {
373
374
  cachedJsrJson[cwd] = { ...cachedJsrJson[cwd], ...contents };
374
375
  }
375
- async function findOutFile(file, { cwd = process2.cwd() } = {}) {
376
+ async function findOutFile(file, { cwd = process.cwd() } = {}) {
376
377
  let directory = cwd;
377
378
  let filePath = "";
378
379
  const { root } = path.parse(cwd);
@@ -390,7 +391,7 @@ async function findOutFile(file, { cwd = process2.cwd() } = {}) {
390
391
  return filePath;
391
392
  }
392
393
  async function getPackageJson({
393
- cwd = process2.cwd(),
394
+ cwd = process.cwd(),
394
395
  fallbackJsr = true
395
396
  } = {}) {
396
397
  if (cachedPackageJson[cwd]) return cachedPackageJson[cwd];
@@ -423,7 +424,7 @@ async function getPackageJson({
423
424
  }
424
425
  }
425
426
  async function getJsrJson({
426
- cwd = process2.cwd(),
427
+ cwd = process.cwd(),
427
428
  fallbackPackage = true
428
429
  } = {}) {
429
430
  if (cachedJsrJson[cwd]) return cachedJsrJson[cwd];
@@ -501,7 +502,7 @@ async function jsrJsonToPackageJson(jsrJson) {
501
502
  return convertedExports;
502
503
  }
503
504
  }
504
- async function version({ cwd = process2.cwd() } = {}) {
505
+ async function version({ cwd = process.cwd() } = {}) {
505
506
  let version2 = (await getPackageJson({ cwd }))?.version;
506
507
  if (!version2) {
507
508
  version2 = (await getJsrJson({ cwd }))?.version;
@@ -718,7 +719,7 @@ var JsrRegisry = class extends Registry {
718
719
  try {
719
720
  await exec2(
720
721
  "jsr",
721
- ["publish", "--allow-dirty", "--token", `${this.client.token}`],
722
+ ["publish", "--allow-dirty", "--token", `${JsrClient.token}`],
722
723
  {
723
724
  throwOnError: true
724
725
  }
@@ -754,14 +755,9 @@ var JsrRegisry = class extends Registry {
754
755
  return isValidPackageName(this.packageName);
755
756
  }
756
757
  };
757
- var JsrClient = class {
758
- constructor(apiEndpoint, token) {
758
+ var _JsrClient = class _JsrClient {
759
+ constructor(apiEndpoint) {
759
760
  this.apiEndpoint = apiEndpoint;
760
- this.token = token;
761
- if (!this.token) {
762
- const token2 = new Db().get("jsr-token");
763
- if (token2) this.token = token2;
764
- }
765
761
  }
766
762
  async fetch(endpoint, init) {
767
763
  const pubmVersion = await version({ cwd: import.meta.dirname });
@@ -769,7 +765,7 @@ var JsrClient = class {
769
765
  ...init,
770
766
  headers: {
771
767
  ...init?.headers,
772
- Authorization: `Bearer ${this.token}`,
768
+ Authorization: `Bearer ${_JsrClient.token}`,
773
769
  "User-Agent": `pubm/${pubmVersion}; https://github.com/syi0808/pubm`
774
770
  }
775
771
  });
@@ -904,6 +900,8 @@ var JsrClient = class {
904
900
  }
905
901
  }
906
902
  };
903
+ __publicField(_JsrClient, "token", new Db().get("jsr-token"));
904
+ var JsrClient = _JsrClient;
907
905
  async function jsrRegistry() {
908
906
  const jsrJson = await getJsrJson();
909
907
  return new JsrRegisry(jsrJson.name);
@@ -1063,10 +1061,10 @@ var jsrAvailableCheckTasks = {
1063
1061
  await jsr.client.deleteScope(`${getScope(jsr.packageName)}`);
1064
1062
  }
1065
1063
  }, ctx);
1066
- if (!jsr.client.token) {
1064
+ if (!JsrClient.token) {
1067
1065
  task.output = "Retrieving jsr API token";
1068
1066
  while (true) {
1069
- jsr.client.token = await task.prompt(ListrEnquirerPromptAdapter).run({
1067
+ JsrClient.token = await task.prompt(ListrEnquirerPromptAdapter).run({
1070
1068
  type: "password",
1071
1069
  message: `Please enter the jsr ${color3.bold("API token")}`,
1072
1070
  footer: `
@@ -1078,7 +1076,7 @@ Generate a token from ${color3.bold(link("jsr.io", "https://jsr.io/account/token
1078
1076
  } catch {
1079
1077
  }
1080
1078
  }
1081
- new Db().set("jsr-token", jsr.client.token);
1079
+ if (ctx.saveToken) new Db().set("jsr-token", JsrClient.token);
1082
1080
  }
1083
1081
  if (!isScopedPackage(jsr.packageName)) {
1084
1082
  let jsrName = new Db().get(jsr.packageName);
@@ -1203,6 +1201,7 @@ var NpmAvailableError = class extends AbstractError {
1203
1201
  };
1204
1202
  var npmAvailableCheckTasks = {
1205
1203
  title: "Checking npm avaliable for publising",
1204
+ skip: (ctx) => !!ctx.preview,
1206
1205
  task: async () => {
1207
1206
  const npm = await npmRegistry();
1208
1207
  if (await npm.isPublished()) {
@@ -1223,6 +1222,7 @@ More information: ${link("npm naming rules", "https://github.com/npm/validate-np
1223
1222
  };
1224
1223
  var npmPublishTasks = {
1225
1224
  title: "Running npm publish",
1225
+ skip: (ctx) => !!ctx.preview,
1226
1226
  task: async (_, task) => {
1227
1227
  const npm = await npmRegistry();
1228
1228
  task.output = "Publishing on npm...";
@@ -1573,6 +1573,7 @@ async function run(options2) {
1573
1573
  lastRev: await git.latestTag() || await git.firstCommit()
1574
1574
  };
1575
1575
  try {
1576
+ if (options2.contents) process2.chdir(options2.contents);
1576
1577
  await prerequisitesCheckTask({ skip: options2.skipPrerequisitesCheck }).run(
1577
1578
  ctx
1578
1579
  );
@@ -1616,6 +1617,7 @@ async function run(options2) {
1616
1617
  },
1617
1618
  {
1618
1619
  title: "Bumping version",
1620
+ skip: (ctx2) => !!ctx2.preview,
1619
1621
  task: async (ctx2, task) => {
1620
1622
  const git2 = new Git();
1621
1623
  let tagCreated = false;
@@ -1647,7 +1649,7 @@ async function run(options2) {
1647
1649
  }
1648
1650
  },
1649
1651
  {
1650
- skip: options2.skipPublish,
1652
+ skip: (ctx2) => options2.skipPublish || !!ctx2.preview,
1651
1653
  title: "Publishing",
1652
1654
  task: (ctx2, parentTask) => parentTask.newListr(
1653
1655
  ctx2.registries.map((registry) => {
@@ -1665,6 +1667,7 @@ async function run(options2) {
1665
1667
  },
1666
1668
  {
1667
1669
  title: "Pushing tags to GitHub",
1670
+ skip: (ctx2) => !!ctx2.preview,
1668
1671
  task: async (_, task) => {
1669
1672
  const git2 = new Git();
1670
1673
  const result = await git2.push("--follow-tags");
@@ -1675,7 +1678,7 @@ async function run(options2) {
1675
1678
  }
1676
1679
  },
1677
1680
  {
1678
- skip: options2.skipReleaseDraft,
1681
+ skip: (ctx2) => options2.skipReleaseDraft || !!ctx2.preview,
1679
1682
  title: "Creating release draft on GitHub",
1680
1683
  task: async (ctx2, task) => {
1681
1684
  const git2 = new Git();
@@ -1712,7 +1715,7 @@ ${repositoryUrl}/compare/${ctx2.lastRev}...${latestTag}`;
1712
1715
  } catch (e2) {
1713
1716
  consoleError(e2);
1714
1717
  await rollback();
1715
- process.exit(1);
1718
+ process2.exit(1);
1716
1719
  }
1717
1720
  }
1718
1721
 
@@ -1892,11 +1895,6 @@ var options = [
1892
1895
  description: "Skip required conditions check task",
1893
1896
  options: { type: Boolean }
1894
1897
  },
1895
- {
1896
- rawName: "--no-cleanup",
1897
- description: "Skip cleaning the `node_modules` directory",
1898
- options: { type: Boolean }
1899
- },
1900
1898
  {
1901
1899
  rawName: "--no-tests",
1902
1900
  description: "Skip running tests before publishing",
@@ -1917,29 +1915,24 @@ var options = [
1917
1915
  description: "Skip creating a GitHub release draft",
1918
1916
  options: { type: Boolean }
1919
1917
  },
1920
- {
1921
- rawName: "-y, --yolo",
1922
- description: "Skip both cleanup and tests",
1923
- options: { type: Boolean }
1924
- },
1925
1918
  {
1926
1919
  rawName: "-t, --tag <name>",
1927
1920
  description: "Publish under a specific dist-tag",
1928
1921
  options: { default: "latest", type: String }
1929
1922
  },
1930
- {
1931
- rawName: "--package-manager <name>",
1932
- description: `Use a specific package manager 'packageManager' field in package.json or package manager configuration file`,
1933
- options: { type: String }
1934
- },
1935
1923
  {
1936
1924
  rawName: "-c, --contents <path>",
1937
1925
  description: "Subdirectory to publish",
1938
1926
  options: { type: String }
1939
1927
  },
1928
+ {
1929
+ rawName: "--no-save-token",
1930
+ description: "Do not save jsr tokens (request the token each time)",
1931
+ options: { type: Boolean }
1932
+ },
1940
1933
  {
1941
1934
  rawName: "--registry <...registries>",
1942
- description: "Target registries for publish\nregistry can be npm | jsr | https://url.for.private-registries",
1935
+ description: "Target registries for publish\n registry can be npm | jsr | https://url.for.private-registries",
1943
1936
  options: { type: String, default: "npm,jsr" }
1944
1937
  }
1945
1938
  ];
@@ -1950,7 +1943,6 @@ for (const option of options) {
1950
1943
  function resolveCliOptions(options2) {
1951
1944
  return {
1952
1945
  ...options2,
1953
- skipCleanup: !options2.cleanup,
1954
1946
  skipPublish: !options2.publish,
1955
1947
  skipReleaseDraft: !options2.releaseDraft,
1956
1948
  skipTests: !options2.tests,
@@ -1986,6 +1978,9 @@ cli.help((sections) => {
1986
1978
  Version can be:
1987
1979
  ${RELEASE_TYPES2.join(" | ")} | 1.2.3`;
1988
1980
  sections.splice(2, 2);
1981
+ if (sections.at(2)) {
1982
+ sections[2].body = sections[2].body.replace(/ \(default: true\)/g, "");
1983
+ }
1989
1984
  sections.push({ body: "\n" });
1990
1985
  });
1991
1986
  (async () => {
package/dist/index.cjs CHANGED
@@ -49,6 +49,7 @@ function resolveOptions(options) {
49
49
  }
50
50
 
51
51
  // src/tasks/runner.ts
52
+ var import_node_process2 = __toESM(require("process"), 1);
52
53
  var import_promise_spawn = __toESM(require("@npmcli/promise-spawn"), 1);
53
54
  var import_listr26 = require("listr2");
54
55
  var import_semver2 = __toESM(require("semver"), 1);
@@ -748,7 +749,7 @@ var JsrRegisry = class extends Registry {
748
749
  try {
749
750
  await (0, import_tinyexec2.exec)(
750
751
  "jsr",
751
- ["publish", "--allow-dirty", "--token", `${this.client.token}`],
752
+ ["publish", "--allow-dirty", "--token", `${JsrClient.token}`],
752
753
  {
753
754
  throwOnError: true
754
755
  }
@@ -784,14 +785,9 @@ var JsrRegisry = class extends Registry {
784
785
  return isValidPackageName(this.packageName);
785
786
  }
786
787
  };
787
- var JsrClient = class {
788
- constructor(apiEndpoint, token) {
788
+ var _JsrClient = class _JsrClient {
789
+ constructor(apiEndpoint) {
789
790
  this.apiEndpoint = apiEndpoint;
790
- this.token = token;
791
- if (!this.token) {
792
- const token2 = new Db().get("jsr-token");
793
- if (token2) this.token = token2;
794
- }
795
791
  }
796
792
  async fetch(endpoint, init) {
797
793
  const pubmVersion = await version({ cwd: import_meta2.dirname });
@@ -799,7 +795,7 @@ var JsrClient = class {
799
795
  ...init,
800
796
  headers: {
801
797
  ...init?.headers,
802
- Authorization: `Bearer ${this.token}`,
798
+ Authorization: `Bearer ${_JsrClient.token}`,
803
799
  "User-Agent": `pubm/${pubmVersion}; https://github.com/syi0808/pubm`
804
800
  }
805
801
  });
@@ -934,6 +930,8 @@ var JsrClient = class {
934
930
  }
935
931
  }
936
932
  };
933
+ __publicField(_JsrClient, "token", new Db().get("jsr-token"));
934
+ var JsrClient = _JsrClient;
937
935
  async function jsrRegistry() {
938
936
  const jsrJson = await getJsrJson();
939
937
  return new JsrRegisry(jsrJson.name);
@@ -1093,10 +1091,10 @@ var jsrAvailableCheckTasks = {
1093
1091
  await jsr.client.deleteScope(`${getScope(jsr.packageName)}`);
1094
1092
  }
1095
1093
  }, ctx);
1096
- if (!jsr.client.token) {
1094
+ if (!JsrClient.token) {
1097
1095
  task.output = "Retrieving jsr API token";
1098
1096
  while (true) {
1099
- jsr.client.token = await task.prompt(import_prompt_adapter_enquirer.ListrEnquirerPromptAdapter).run({
1097
+ JsrClient.token = await task.prompt(import_prompt_adapter_enquirer.ListrEnquirerPromptAdapter).run({
1100
1098
  type: "password",
1101
1099
  message: `Please enter the jsr ${import_listr24.color.bold("API token")}`,
1102
1100
  footer: `
@@ -1108,7 +1106,7 @@ Generate a token from ${import_listr24.color.bold(link("jsr.io", "https://jsr.io
1108
1106
  } catch {
1109
1107
  }
1110
1108
  }
1111
- new Db().set("jsr-token", jsr.client.token);
1109
+ if (ctx.saveToken) new Db().set("jsr-token", JsrClient.token);
1112
1110
  }
1113
1111
  if (!isScopedPackage(jsr.packageName)) {
1114
1112
  let jsrName = new Db().get(jsr.packageName);
@@ -1233,6 +1231,7 @@ var NpmAvailableError = class extends AbstractError {
1233
1231
  };
1234
1232
  var npmAvailableCheckTasks = {
1235
1233
  title: "Checking npm avaliable for publising",
1234
+ skip: (ctx) => !!ctx.preview,
1236
1235
  task: async () => {
1237
1236
  const npm = await npmRegistry();
1238
1237
  if (await npm.isPublished()) {
@@ -1253,6 +1252,7 @@ More information: ${link("npm naming rules", "https://github.com/npm/validate-np
1253
1252
  };
1254
1253
  var npmPublishTasks = {
1255
1254
  title: "Running npm publish",
1255
+ skip: (ctx) => !!ctx.preview,
1256
1256
  task: async (_, task) => {
1257
1257
  const npm = await npmRegistry();
1258
1258
  task.output = "Publishing on npm...";
@@ -1604,6 +1604,7 @@ async function run(options) {
1604
1604
  lastRev: await git.latestTag() || await git.firstCommit()
1605
1605
  };
1606
1606
  try {
1607
+ if (options.contents) import_node_process2.default.chdir(options.contents);
1607
1608
  await prerequisitesCheckTask({ skip: options.skipPrerequisitesCheck }).run(
1608
1609
  ctx
1609
1610
  );
@@ -1647,6 +1648,7 @@ async function run(options) {
1647
1648
  },
1648
1649
  {
1649
1650
  title: "Bumping version",
1651
+ skip: (ctx2) => !!ctx2.preview,
1650
1652
  task: async (ctx2, task) => {
1651
1653
  const git2 = new Git();
1652
1654
  let tagCreated = false;
@@ -1678,7 +1680,7 @@ async function run(options) {
1678
1680
  }
1679
1681
  },
1680
1682
  {
1681
- skip: options.skipPublish,
1683
+ skip: (ctx2) => options.skipPublish || !!ctx2.preview,
1682
1684
  title: "Publishing",
1683
1685
  task: (ctx2, parentTask) => parentTask.newListr(
1684
1686
  ctx2.registries.map((registry) => {
@@ -1696,6 +1698,7 @@ async function run(options) {
1696
1698
  },
1697
1699
  {
1698
1700
  title: "Pushing tags to GitHub",
1701
+ skip: (ctx2) => !!ctx2.preview,
1699
1702
  task: async (_, task) => {
1700
1703
  const git2 = new Git();
1701
1704
  const result = await git2.push("--follow-tags");
@@ -1706,7 +1709,7 @@ async function run(options) {
1706
1709
  }
1707
1710
  },
1708
1711
  {
1709
- skip: options.skipReleaseDraft,
1712
+ skip: (ctx2) => options.skipReleaseDraft || !!ctx2.preview,
1710
1713
  title: "Creating release draft on GitHub",
1711
1714
  task: async (ctx2, task) => {
1712
1715
  const git2 = new Git();
@@ -1743,7 +1746,7 @@ ${repositoryUrl}/compare/${ctx2.lastRev}...${latestTag}`;
1743
1746
  } catch (e2) {
1744
1747
  consoleError(e2);
1745
1748
  await rollback();
1746
- process.exit(1);
1749
+ import_node_process2.default.exit(1);
1747
1750
  }
1748
1751
  }
1749
1752
 
package/dist/index.d.cts CHANGED
@@ -29,11 +29,6 @@ interface Options {
29
29
  * @default false
30
30
  */
31
31
  anyBranch?: boolean;
32
- /**
33
- * @description Skip cleaning the `node_modules` directory
34
- * @default false
35
- */
36
- skipCleanup?: boolean;
37
32
  /**
38
33
  * @description Skip running tests before publishing
39
34
  * @default false
@@ -64,25 +59,20 @@ interface Options {
64
59
  * @default false
65
60
  */
66
61
  skipConditionsCheck?: boolean;
67
- /**
68
- * @description Skip both cleanup and tests
69
- * @default false
70
- */
71
- yolo?: boolean;
72
62
  /**
73
63
  * @description Publish under a specific dist-tag
74
64
  * @default "latest"
75
65
  */
76
66
  tag?: string;
77
- /**
78
- * @description Use a specific package manager
79
- * @default 'packageManager' field in package.json or package manager configuration file
80
- */
81
- packageManager?: string;
82
67
  /**
83
68
  * @description Subdirectory to publish
84
69
  */
85
70
  contents?: string;
71
+ /**
72
+ * @description Do not save jsr tokens (request the token each time)
73
+ * @default true
74
+ */
75
+ saveToken?: boolean;
86
76
  /**
87
77
  * @description Target registries for publish
88
78
  * @default ['npm', 'jsr']
package/dist/index.d.ts CHANGED
@@ -29,11 +29,6 @@ interface Options {
29
29
  * @default false
30
30
  */
31
31
  anyBranch?: boolean;
32
- /**
33
- * @description Skip cleaning the `node_modules` directory
34
- * @default false
35
- */
36
- skipCleanup?: boolean;
37
32
  /**
38
33
  * @description Skip running tests before publishing
39
34
  * @default false
@@ -64,25 +59,20 @@ interface Options {
64
59
  * @default false
65
60
  */
66
61
  skipConditionsCheck?: boolean;
67
- /**
68
- * @description Skip both cleanup and tests
69
- * @default false
70
- */
71
- yolo?: boolean;
72
62
  /**
73
63
  * @description Publish under a specific dist-tag
74
64
  * @default "latest"
75
65
  */
76
66
  tag?: string;
77
- /**
78
- * @description Use a specific package manager
79
- * @default 'packageManager' field in package.json or package manager configuration file
80
- */
81
- packageManager?: string;
82
67
  /**
83
68
  * @description Subdirectory to publish
84
69
  */
85
70
  contents?: string;
71
+ /**
72
+ * @description Do not save jsr tokens (request the token each time)
73
+ * @default true
74
+ */
75
+ saveToken?: boolean;
86
76
  /**
87
77
  * @description Target registries for publish
88
78
  * @default ['npm', 'jsr']
package/dist/index.js CHANGED
@@ -15,6 +15,7 @@ function resolveOptions(options) {
15
15
  }
16
16
 
17
17
  // src/tasks/runner.ts
18
+ import process2 from "node:process";
18
19
  import npmCli from "@npmcli/promise-spawn";
19
20
  import { color as color5 } from "listr2";
20
21
  import SemVer from "semver";
@@ -360,13 +361,13 @@ function createListr(...args) {
360
361
  // src/utils/package.ts
361
362
  import { readFile, stat, writeFile } from "node:fs/promises";
362
363
  import path from "node:path";
363
- import process2 from "node:process";
364
+ import process from "node:process";
364
365
  var cachedPackageJson = {};
365
366
  var cachedJsrJson = {};
366
- async function patchCachedJsrJson(contents, { cwd = process2.cwd() } = {}) {
367
+ async function patchCachedJsrJson(contents, { cwd = process.cwd() } = {}) {
367
368
  cachedJsrJson[cwd] = { ...cachedJsrJson[cwd], ...contents };
368
369
  }
369
- async function findOutFile(file, { cwd = process2.cwd() } = {}) {
370
+ async function findOutFile(file, { cwd = process.cwd() } = {}) {
370
371
  let directory = cwd;
371
372
  let filePath = "";
372
373
  const { root } = path.parse(cwd);
@@ -384,7 +385,7 @@ async function findOutFile(file, { cwd = process2.cwd() } = {}) {
384
385
  return filePath;
385
386
  }
386
387
  async function getPackageJson({
387
- cwd = process2.cwd(),
388
+ cwd = process.cwd(),
388
389
  fallbackJsr = true
389
390
  } = {}) {
390
391
  if (cachedPackageJson[cwd]) return cachedPackageJson[cwd];
@@ -417,7 +418,7 @@ async function getPackageJson({
417
418
  }
418
419
  }
419
420
  async function getJsrJson({
420
- cwd = process2.cwd(),
421
+ cwd = process.cwd(),
421
422
  fallbackPackage = true
422
423
  } = {}) {
423
424
  if (cachedJsrJson[cwd]) return cachedJsrJson[cwd];
@@ -495,7 +496,7 @@ async function jsrJsonToPackageJson(jsrJson) {
495
496
  return convertedExports;
496
497
  }
497
498
  }
498
- async function version({ cwd = process2.cwd() } = {}) {
499
+ async function version({ cwd = process.cwd() } = {}) {
499
500
  let version2 = (await getPackageJson({ cwd }))?.version;
500
501
  if (!version2) {
501
502
  version2 = (await getJsrJson({ cwd }))?.version;
@@ -712,7 +713,7 @@ var JsrRegisry = class extends Registry {
712
713
  try {
713
714
  await exec2(
714
715
  "jsr",
715
- ["publish", "--allow-dirty", "--token", `${this.client.token}`],
716
+ ["publish", "--allow-dirty", "--token", `${JsrClient.token}`],
716
717
  {
717
718
  throwOnError: true
718
719
  }
@@ -748,14 +749,9 @@ var JsrRegisry = class extends Registry {
748
749
  return isValidPackageName(this.packageName);
749
750
  }
750
751
  };
751
- var JsrClient = class {
752
- constructor(apiEndpoint, token) {
752
+ var _JsrClient = class _JsrClient {
753
+ constructor(apiEndpoint) {
753
754
  this.apiEndpoint = apiEndpoint;
754
- this.token = token;
755
- if (!this.token) {
756
- const token2 = new Db().get("jsr-token");
757
- if (token2) this.token = token2;
758
- }
759
755
  }
760
756
  async fetch(endpoint, init) {
761
757
  const pubmVersion = await version({ cwd: import.meta.dirname });
@@ -763,7 +759,7 @@ var JsrClient = class {
763
759
  ...init,
764
760
  headers: {
765
761
  ...init?.headers,
766
- Authorization: `Bearer ${this.token}`,
762
+ Authorization: `Bearer ${_JsrClient.token}`,
767
763
  "User-Agent": `pubm/${pubmVersion}; https://github.com/syi0808/pubm`
768
764
  }
769
765
  });
@@ -898,6 +894,8 @@ var JsrClient = class {
898
894
  }
899
895
  }
900
896
  };
897
+ __publicField(_JsrClient, "token", new Db().get("jsr-token"));
898
+ var JsrClient = _JsrClient;
901
899
  async function jsrRegistry() {
902
900
  const jsrJson = await getJsrJson();
903
901
  return new JsrRegisry(jsrJson.name);
@@ -1057,10 +1055,10 @@ var jsrAvailableCheckTasks = {
1057
1055
  await jsr.client.deleteScope(`${getScope(jsr.packageName)}`);
1058
1056
  }
1059
1057
  }, ctx);
1060
- if (!jsr.client.token) {
1058
+ if (!JsrClient.token) {
1061
1059
  task.output = "Retrieving jsr API token";
1062
1060
  while (true) {
1063
- jsr.client.token = await task.prompt(ListrEnquirerPromptAdapter).run({
1061
+ JsrClient.token = await task.prompt(ListrEnquirerPromptAdapter).run({
1064
1062
  type: "password",
1065
1063
  message: `Please enter the jsr ${color3.bold("API token")}`,
1066
1064
  footer: `
@@ -1072,7 +1070,7 @@ Generate a token from ${color3.bold(link("jsr.io", "https://jsr.io/account/token
1072
1070
  } catch {
1073
1071
  }
1074
1072
  }
1075
- new Db().set("jsr-token", jsr.client.token);
1073
+ if (ctx.saveToken) new Db().set("jsr-token", JsrClient.token);
1076
1074
  }
1077
1075
  if (!isScopedPackage(jsr.packageName)) {
1078
1076
  let jsrName = new Db().get(jsr.packageName);
@@ -1197,6 +1195,7 @@ var NpmAvailableError = class extends AbstractError {
1197
1195
  };
1198
1196
  var npmAvailableCheckTasks = {
1199
1197
  title: "Checking npm avaliable for publising",
1198
+ skip: (ctx) => !!ctx.preview,
1200
1199
  task: async () => {
1201
1200
  const npm = await npmRegistry();
1202
1201
  if (await npm.isPublished()) {
@@ -1217,6 +1216,7 @@ More information: ${link("npm naming rules", "https://github.com/npm/validate-np
1217
1216
  };
1218
1217
  var npmPublishTasks = {
1219
1218
  title: "Running npm publish",
1219
+ skip: (ctx) => !!ctx.preview,
1220
1220
  task: async (_, task) => {
1221
1221
  const npm = await npmRegistry();
1222
1222
  task.output = "Publishing on npm...";
@@ -1567,6 +1567,7 @@ async function run(options) {
1567
1567
  lastRev: await git.latestTag() || await git.firstCommit()
1568
1568
  };
1569
1569
  try {
1570
+ if (options.contents) process2.chdir(options.contents);
1570
1571
  await prerequisitesCheckTask({ skip: options.skipPrerequisitesCheck }).run(
1571
1572
  ctx
1572
1573
  );
@@ -1610,6 +1611,7 @@ async function run(options) {
1610
1611
  },
1611
1612
  {
1612
1613
  title: "Bumping version",
1614
+ skip: (ctx2) => !!ctx2.preview,
1613
1615
  task: async (ctx2, task) => {
1614
1616
  const git2 = new Git();
1615
1617
  let tagCreated = false;
@@ -1641,7 +1643,7 @@ async function run(options) {
1641
1643
  }
1642
1644
  },
1643
1645
  {
1644
- skip: options.skipPublish,
1646
+ skip: (ctx2) => options.skipPublish || !!ctx2.preview,
1645
1647
  title: "Publishing",
1646
1648
  task: (ctx2, parentTask) => parentTask.newListr(
1647
1649
  ctx2.registries.map((registry) => {
@@ -1659,6 +1661,7 @@ async function run(options) {
1659
1661
  },
1660
1662
  {
1661
1663
  title: "Pushing tags to GitHub",
1664
+ skip: (ctx2) => !!ctx2.preview,
1662
1665
  task: async (_, task) => {
1663
1666
  const git2 = new Git();
1664
1667
  const result = await git2.push("--follow-tags");
@@ -1669,7 +1672,7 @@ async function run(options) {
1669
1672
  }
1670
1673
  },
1671
1674
  {
1672
- skip: options.skipReleaseDraft,
1675
+ skip: (ctx2) => options.skipReleaseDraft || !!ctx2.preview,
1673
1676
  title: "Creating release draft on GitHub",
1674
1677
  task: async (ctx2, task) => {
1675
1678
  const git2 = new Git();
@@ -1706,7 +1709,7 @@ ${repositoryUrl}/compare/${ctx2.lastRev}...${latestTag}`;
1706
1709
  } catch (e2) {
1707
1710
  consoleError(e2);
1708
1711
  await rollback();
1709
- process.exit(1);
1712
+ process2.exit(1);
1710
1713
  }
1711
1714
  }
1712
1715
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pubm",
3
- "version": "0.0.0-alpha.15",
3
+ "version": "0.0.0-alpha.19",
4
4
  "engines": {
5
5
  "node": ">=18",
6
6
  "git": ">=2.11.0"