pubm 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/cli.js CHANGED
@@ -4442,7 +4442,7 @@ var Git = class {
4442
4442
  async previousTag(tag) {
4443
4443
  try {
4444
4444
  const tags = await this.tags();
4445
- return tags.at(tags.findIndex((t) => t === tag) - 1);
4445
+ return tags.at(tags.findIndex((t) => t === tag) - 1) ?? null;
4446
4446
  } catch {
4447
4447
  return null;
4448
4448
  }
@@ -4478,7 +4478,7 @@ var Git = class {
4478
4478
  }
4479
4479
  async revisionDiffsCount() {
4480
4480
  try {
4481
- return await Number.parseInt(
4481
+ return Number.parseInt(
4482
4482
  await this.git(["rev-list", "@{u}...HEAD", "--count", "--left-only"])
4483
4483
  );
4484
4484
  } catch (error) {
@@ -4518,7 +4518,7 @@ var Git = class {
4518
4518
  }
4519
4519
  async version() {
4520
4520
  try {
4521
- return (await this.git(["--version"])).trim().match(/\d+\.\d+\.\d+/)?.[0];
4521
+ return `${(await this.git(["--version"])).trim().match(/\d+\.\d+\.\d+/)?.[0]}`;
4522
4522
  } catch (error) {
4523
4523
  throw new GitError("Failed to run `git --version`", {
4524
4524
  cause: error
@@ -4687,6 +4687,7 @@ var Git = class {
4687
4687
  // src/options.ts
4688
4688
  var defaultOptions = {
4689
4689
  testScript: "test",
4690
+ buildScript: "build",
4690
4691
  branch: "main",
4691
4692
  tag: "latest",
4692
4693
  registries: ["npm", "jsr"]
@@ -4738,7 +4739,7 @@ import path from "node:path";
4738
4739
  import process7 from "node:process";
4739
4740
  var cachedPackageJson = {};
4740
4741
  var cachedJsrJson = {};
4741
- async function patchCachedJsrJson(contents, { cwd = process7.cwd() } = {}) {
4742
+ function patchCachedJsrJson(contents, { cwd = process7.cwd() } = {}) {
4742
4743
  cachedJsrJson[cwd] = { ...cachedJsrJson[cwd], ...contents };
4743
4744
  }
4744
4745
  async function findOutFile(file, { cwd = process7.cwd() } = {}) {
@@ -4849,7 +4850,7 @@ async function packageJsonToJsrJson(packageJson) {
4849
4850
  return convertedExports;
4850
4851
  }
4851
4852
  }
4852
- async function jsrJsonToPackageJson(jsrJson) {
4853
+ function jsrJsonToPackageJson(jsrJson) {
4853
4854
  return {
4854
4855
  name: jsrJson.name,
4855
4856
  version: jsrJson.version,
@@ -4989,13 +4990,13 @@ function isScopedPackage(packageName) {
4989
4990
  return /^@[^/]+\/[^@][\w.-]*$/.test(packageName);
4990
4991
  }
4991
4992
  function getScope(packageName) {
4992
- return packageName.match(/^@([^/]+)/)?.[1];
4993
+ return packageName.match(/^@([^/]+)/)?.[1] ?? null;
4993
4994
  }
4994
4995
  function getScopeAndName(packageName) {
4995
4996
  const matches = packageName.match(/^@([a-zA-Z0-9]+)\/([a-zA-Z0-9]+)$/);
4996
4997
  const scope = matches?.[1];
4997
4998
  const name = matches?.[2];
4998
- return [scope, name];
4999
+ return [`${scope}`, `${name}`];
4999
5000
  }
5000
5001
  var scopedPackagePattern = /^(?:@([^/]+?)[/])?([^/]+?)$/;
5001
5002
  var blacklist = ["node_modules", "favicon.ico"];
@@ -5885,7 +5886,7 @@ var requiredConditionsCheckTask = (options2) => createListr({
5885
5886
  [
5886
5887
  {
5887
5888
  title: "Ping registries",
5888
- task: async (ctx, parentTask2) => parentTask2.newListr(
5889
+ task: (ctx, parentTask2) => parentTask2.newListr(
5889
5890
  ctx.registries.map((registryKey) => ({
5890
5891
  title: `Ping to ${registryKey}`,
5891
5892
  task: async () => {
@@ -5974,7 +5975,7 @@ var requiredConditionsCheckTask = (options2) => createListr({
5974
5975
  },
5975
5976
  {
5976
5977
  title: "Checking available registries for publishing",
5977
- task: async (ctx, parentTask2) => parentTask2.newListr(
5978
+ task: (ctx, parentTask2) => parentTask2.newListr(
5978
5979
  ctx.registries.map((registryKey) => {
5979
5980
  switch (registryKey) {
5980
5981
  case "npm":
@@ -6412,50 +6413,52 @@ function resolveCliOptions(options2) {
6412
6413
  skipConditionsCheck: !options2.conditionCheck
6413
6414
  };
6414
6415
  }
6415
- cli.command("[version]").action(async (nextVersion, options2) => {
6416
- console.clear();
6417
- if (!isCI3) {
6418
- await notifyNewVersion();
6419
- }
6420
- const context = {
6421
- version: nextVersion,
6422
- tag: options2.tag
6423
- };
6424
- try {
6425
- if (isCI3) {
6426
- if (options2.publishOnly) {
6427
- const git = new Git();
6428
- const latestVersion = (await git.latestTag())?.slice(1);
6429
- if (!latestVersion) {
6430
- throw new Error(
6431
- "Cannot find the latest tag. Please ensure tags exist in the repository."
6432
- );
6433
- }
6434
- if (!valid(latestVersion)) {
6416
+ cli.command("[version]").action(
6417
+ async (nextVersion, options2) => {
6418
+ console.clear();
6419
+ if (!isCI3) {
6420
+ await notifyNewVersion();
6421
+ }
6422
+ const context = {
6423
+ version: nextVersion,
6424
+ tag: options2.tag
6425
+ };
6426
+ try {
6427
+ if (isCI3) {
6428
+ if (options2.publishOnly) {
6429
+ const git = new Git();
6430
+ const latestVersion = (await git.latestTag())?.slice(1);
6431
+ if (!latestVersion) {
6432
+ throw new Error(
6433
+ "Cannot find the latest tag. Please ensure tags exist in the repository."
6434
+ );
6435
+ }
6436
+ if (!valid(latestVersion)) {
6437
+ throw new Error(
6438
+ "Cannot parse the latest tag to a valid SemVer version. Please check the tag format."
6439
+ );
6440
+ }
6441
+ context.version = latestVersion;
6442
+ } else {
6435
6443
  throw new Error(
6436
- "Cannot parse the latest tag to a valid SemVer version. Please check the tag format."
6444
+ "Version must be set in the CI environment. Please define the version before proceeding."
6437
6445
  );
6438
6446
  }
6439
- context.version = latestVersion;
6440
6447
  } else {
6441
- throw new Error(
6442
- "Version must be set in the CI environment. Please define the version before proceeding."
6443
- );
6448
+ await requiredMissingInformationTasks().run(context);
6444
6449
  }
6445
- } else {
6446
- await requiredMissingInformationTasks().run(context);
6447
- }
6448
- await pubm(
6449
- resolveCliOptions({
6450
- ...options2,
6451
- version: context.version,
6452
- tag: context.tag
6453
- })
6454
- );
6455
- } catch (e2) {
6456
- consoleError(e2);
6450
+ await pubm(
6451
+ resolveCliOptions({
6452
+ ...options2,
6453
+ version: context.version,
6454
+ tag: context.tag
6455
+ })
6456
+ );
6457
+ } catch (e2) {
6458
+ consoleError(e2);
6459
+ }
6457
6460
  }
6458
- });
6461
+ );
6459
6462
  cli.help((sections) => {
6460
6463
  sections[1].body += `
6461
6464
 
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"]
@@ -4465,7 +4466,7 @@ var Git = class {
4465
4466
  async previousTag(tag) {
4466
4467
  try {
4467
4468
  const tags = await this.tags();
4468
- return tags.at(tags.findIndex((t) => t === tag) - 1);
4469
+ return tags.at(tags.findIndex((t) => t === tag) - 1) ?? null;
4469
4470
  } catch {
4470
4471
  return null;
4471
4472
  }
@@ -4501,7 +4502,7 @@ var Git = class {
4501
4502
  }
4502
4503
  async revisionDiffsCount() {
4503
4504
  try {
4504
- return await Number.parseInt(
4505
+ return Number.parseInt(
4505
4506
  await this.git(["rev-list", "@{u}...HEAD", "--count", "--left-only"])
4506
4507
  );
4507
4508
  } catch (error) {
@@ -4541,7 +4542,7 @@ var Git = class {
4541
4542
  }
4542
4543
  async version() {
4543
4544
  try {
4544
- return (await this.git(["--version"])).trim().match(/\d+\.\d+\.\d+/)?.[0];
4545
+ return `${(await this.git(["--version"])).trim().match(/\d+\.\d+\.\d+/)?.[0]}`;
4545
4546
  } catch (error) {
4546
4547
  throw new GitError("Failed to run `git --version`", {
4547
4548
  cause: error
@@ -4742,7 +4743,7 @@ var import_node_path = __toESM(require("path"), 1);
4742
4743
  var import_node_process5 = __toESM(require("process"), 1);
4743
4744
  var cachedPackageJson = {};
4744
4745
  var cachedJsrJson = {};
4745
- async function patchCachedJsrJson(contents, { cwd = import_node_process5.default.cwd() } = {}) {
4746
+ function patchCachedJsrJson(contents, { cwd = import_node_process5.default.cwd() } = {}) {
4746
4747
  cachedJsrJson[cwd] = { ...cachedJsrJson[cwd], ...contents };
4747
4748
  }
4748
4749
  async function findOutFile(file, { cwd = import_node_process5.default.cwd() } = {}) {
@@ -4853,7 +4854,7 @@ async function packageJsonToJsrJson(packageJson) {
4853
4854
  return convertedExports;
4854
4855
  }
4855
4856
  }
4856
- async function jsrJsonToPackageJson(jsrJson) {
4857
+ function jsrJsonToPackageJson(jsrJson) {
4857
4858
  return {
4858
4859
  name: jsrJson.name,
4859
4860
  version: jsrJson.version,
@@ -4994,13 +4995,13 @@ function isScopedPackage(packageName) {
4994
4995
  return /^@[^/]+\/[^@][\w.-]*$/.test(packageName);
4995
4996
  }
4996
4997
  function getScope(packageName) {
4997
- return packageName.match(/^@([^/]+)/)?.[1];
4998
+ return packageName.match(/^@([^/]+)/)?.[1] ?? null;
4998
4999
  }
4999
5000
  function getScopeAndName(packageName) {
5000
5001
  const matches = packageName.match(/^@([a-zA-Z0-9]+)\/([a-zA-Z0-9]+)$/);
5001
5002
  const scope = matches?.[1];
5002
5003
  const name = matches?.[2];
5003
- return [scope, name];
5004
+ return [`${scope}`, `${name}`];
5004
5005
  }
5005
5006
  var scopedPackagePattern = /^(?:@([^/]+?)[/])?([^/]+?)$/;
5006
5007
  var blacklist = ["node_modules", "favicon.ico"];
@@ -5892,7 +5893,7 @@ var requiredConditionsCheckTask = (options) => createListr({
5892
5893
  [
5893
5894
  {
5894
5895
  title: "Ping registries",
5895
- task: async (ctx, parentTask2) => parentTask2.newListr(
5896
+ task: (ctx, parentTask2) => parentTask2.newListr(
5896
5897
  ctx.registries.map((registryKey) => ({
5897
5898
  title: `Ping to ${registryKey}`,
5898
5899
  task: async () => {
@@ -5981,7 +5982,7 @@ var requiredConditionsCheckTask = (options) => createListr({
5981
5982
  },
5982
5983
  {
5983
5984
  title: "Checking available registries for publishing",
5984
- task: async (ctx, parentTask2) => parentTask2.newListr(
5985
+ task: (ctx, parentTask2) => parentTask2.newListr(
5985
5986
  ctx.registries.map((registryKey) => {
5986
5987
  switch (registryKey) {
5987
5988
  case "npm":
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"]
@@ -4456,7 +4457,7 @@ var Git = class {
4456
4457
  async previousTag(tag) {
4457
4458
  try {
4458
4459
  const tags = await this.tags();
4459
- return tags.at(tags.findIndex((t) => t === tag) - 1);
4460
+ return tags.at(tags.findIndex((t) => t === tag) - 1) ?? null;
4460
4461
  } catch {
4461
4462
  return null;
4462
4463
  }
@@ -4492,7 +4493,7 @@ var Git = class {
4492
4493
  }
4493
4494
  async revisionDiffsCount() {
4494
4495
  try {
4495
- return await Number.parseInt(
4496
+ return Number.parseInt(
4496
4497
  await this.git(["rev-list", "@{u}...HEAD", "--count", "--left-only"])
4497
4498
  );
4498
4499
  } catch (error) {
@@ -4532,7 +4533,7 @@ var Git = class {
4532
4533
  }
4533
4534
  async version() {
4534
4535
  try {
4535
- return (await this.git(["--version"])).trim().match(/\d+\.\d+\.\d+/)?.[0];
4536
+ return `${(await this.git(["--version"])).trim().match(/\d+\.\d+\.\d+/)?.[0]}`;
4536
4537
  } catch (error) {
4537
4538
  throw new GitError("Failed to run `git --version`", {
4538
4539
  cause: error
@@ -4733,7 +4734,7 @@ import path from "node:path";
4733
4734
  import process7 from "node:process";
4734
4735
  var cachedPackageJson = {};
4735
4736
  var cachedJsrJson = {};
4736
- async function patchCachedJsrJson(contents, { cwd = process7.cwd() } = {}) {
4737
+ function patchCachedJsrJson(contents, { cwd = process7.cwd() } = {}) {
4737
4738
  cachedJsrJson[cwd] = { ...cachedJsrJson[cwd], ...contents };
4738
4739
  }
4739
4740
  async function findOutFile(file, { cwd = process7.cwd() } = {}) {
@@ -4844,7 +4845,7 @@ async function packageJsonToJsrJson(packageJson) {
4844
4845
  return convertedExports;
4845
4846
  }
4846
4847
  }
4847
- async function jsrJsonToPackageJson(jsrJson) {
4848
+ function jsrJsonToPackageJson(jsrJson) {
4848
4849
  return {
4849
4850
  name: jsrJson.name,
4850
4851
  version: jsrJson.version,
@@ -4984,13 +4985,13 @@ function isScopedPackage(packageName) {
4984
4985
  return /^@[^/]+\/[^@][\w.-]*$/.test(packageName);
4985
4986
  }
4986
4987
  function getScope(packageName) {
4987
- return packageName.match(/^@([^/]+)/)?.[1];
4988
+ return packageName.match(/^@([^/]+)/)?.[1] ?? null;
4988
4989
  }
4989
4990
  function getScopeAndName(packageName) {
4990
4991
  const matches = packageName.match(/^@([a-zA-Z0-9]+)\/([a-zA-Z0-9]+)$/);
4991
4992
  const scope = matches?.[1];
4992
4993
  const name = matches?.[2];
4993
- return [scope, name];
4994
+ return [`${scope}`, `${name}`];
4994
4995
  }
4995
4996
  var scopedPackagePattern = /^(?:@([^/]+?)[/])?([^/]+?)$/;
4996
4997
  var blacklist = ["node_modules", "favicon.ico"];
@@ -5880,7 +5881,7 @@ var requiredConditionsCheckTask = (options) => createListr({
5880
5881
  [
5881
5882
  {
5882
5883
  title: "Ping registries",
5883
- task: async (ctx, parentTask2) => parentTask2.newListr(
5884
+ task: (ctx, parentTask2) => parentTask2.newListr(
5884
5885
  ctx.registries.map((registryKey) => ({
5885
5886
  title: `Ping to ${registryKey}`,
5886
5887
  task: async () => {
@@ -5969,7 +5970,7 @@ var requiredConditionsCheckTask = (options) => createListr({
5969
5970
  },
5970
5971
  {
5971
5972
  title: "Checking available registries for publishing",
5972
- task: async (ctx, parentTask2) => parentTask2.newListr(
5973
+ task: (ctx, parentTask2) => parentTask2.newListr(
5973
5974
  ctx.registries.map((registryKey) => {
5974
5975
  switch (registryKey) {
5975
5976
  case "npm":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pubm",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "engines": {
5
5
  "node": ">=18",
6
6
  "git": ">=2.11.0"