pubm 0.1.4 → 0.1.6

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
@@ -2416,15 +2416,15 @@ var isCompatibleTerminal = tty && tty.isatty && tty.isatty(1) && env.TERM && !is
2416
2416
  var isCI = "CI" in env && ("GITHUB_ACTIONS" in env || "GITLAB_CI" in env || "CIRCLECI" in env);
2417
2417
  var isColorSupported = !isDisabled && (isForced || isWindows && !isDumbTerminal || isCompatibleTerminal || isCI);
2418
2418
  var replaceClose = (index, string, close, replace, head = string.substring(0, index) + replace, tail = string.substring(index + close.length), next = tail.indexOf(close)) => head + (next < 0 ? tail : replaceClose(next, tail, close, replace));
2419
- var clearBleed = (index, string, open3, close, replace) => index < 0 ? open3 + string + close : open3 + replaceClose(index, string, close, replace) + close;
2420
- var filterEmpty = (open3, close, replace = open3, at = open3.length + 1) => (string) => string || !(string === "" || string === void 0) ? clearBleed(
2419
+ var clearBleed = (index, string, open4, close, replace) => index < 0 ? open4 + string + close : open4 + replaceClose(index, string, close, replace) + close;
2420
+ var filterEmpty = (open4, close, replace = open4, at = open4.length + 1) => (string) => string || !(string === "" || string === void 0) ? clearBleed(
2421
2421
  ("" + string).indexOf(close, at),
2422
2422
  string,
2423
- open3,
2423
+ open4,
2424
2424
  close,
2425
2425
  replace
2426
2426
  ) : "";
2427
- var init = (open3, close, replace) => filterEmpty(`\x1B[${open3}m`, `\x1B[${close}m`, replace);
2427
+ var init = (open4, close, replace) => filterEmpty(`\x1B[${open4}m`, `\x1B[${close}m`, replace);
2428
2428
  var colors = {
2429
2429
  reset: init(0, 0),
2430
2430
  bold: init(1, 22, "\x1B[22m\x1B[1m"),
@@ -4945,7 +4945,8 @@ var Git = class {
4945
4945
  async revisionDiffsCount() {
4946
4946
  try {
4947
4947
  return Number.parseInt(
4948
- await this.git(["rev-list", "@{u}...HEAD", "--count", "--left-only"])
4948
+ await this.git(["rev-list", "@{u}...HEAD", "--count", "--left-only"]),
4949
+ 10
4949
4950
  );
4950
4951
  } catch (error) {
4951
4952
  throw new GitError(
@@ -5145,6 +5146,80 @@ var Git = class {
5145
5146
  }
5146
5147
  };
5147
5148
 
5149
+ // src/config/defaults.ts
5150
+ var defaultValidate = {
5151
+ cleanInstall: true,
5152
+ entryPoints: true,
5153
+ extraneousFiles: true
5154
+ };
5155
+ var defaultSnapshot = {
5156
+ useCalculatedVersion: false,
5157
+ prereleaseTemplate: "{tag}-{timestamp}"
5158
+ };
5159
+ var defaultConfig = {
5160
+ versioning: "independent",
5161
+ branch: "main",
5162
+ changelog: true,
5163
+ changelogFormat: "default",
5164
+ commit: false,
5165
+ access: "public",
5166
+ fixed: [],
5167
+ linked: [],
5168
+ updateInternalDependencies: "patch",
5169
+ ignore: [],
5170
+ tag: "latest",
5171
+ contents: ".",
5172
+ saveToken: true,
5173
+ releaseDraft: true,
5174
+ releaseNotes: true,
5175
+ registries: ["npm", "jsr"],
5176
+ rollbackStrategy: "individual"
5177
+ };
5178
+ function resolveConfig(config) {
5179
+ const packages = config.packages ?? [
5180
+ { path: ".", registries: ["npm", "jsr"] }
5181
+ ];
5182
+ return {
5183
+ ...defaultConfig,
5184
+ ...config,
5185
+ packages,
5186
+ validate: { ...defaultValidate, ...config.validate },
5187
+ snapshot: { ...defaultSnapshot, ...config.snapshot }
5188
+ };
5189
+ }
5190
+
5191
+ // src/config/loader.ts
5192
+ import { stat } from "node:fs/promises";
5193
+ import path6 from "node:path";
5194
+ var CONFIG_FILES = [
5195
+ "pubm.config.ts",
5196
+ "pubm.config.mts",
5197
+ "pubm.config.cts",
5198
+ "pubm.config.js",
5199
+ "pubm.config.mjs",
5200
+ "pubm.config.cjs"
5201
+ ];
5202
+ async function findConfigFile(cwd) {
5203
+ for (const file of CONFIG_FILES) {
5204
+ const filePath = path6.join(cwd, file);
5205
+ try {
5206
+ if ((await stat(filePath)).isFile()) {
5207
+ return filePath;
5208
+ }
5209
+ } catch {
5210
+ }
5211
+ }
5212
+ return null;
5213
+ }
5214
+ async function loadConfig(cwd = process.cwd()) {
5215
+ const configPath = await findConfigFile(cwd);
5216
+ if (!configPath) return null;
5217
+ const { createJiti } = await import("jiti");
5218
+ const jiti = createJiti(cwd, { interopDefault: true });
5219
+ const mod = await jiti.import(configPath);
5220
+ return mod.default ?? mod;
5221
+ }
5222
+
5148
5223
  // src/options.ts
5149
5224
  var defaultOptions = {
5150
5225
  testScript: "test",
@@ -5154,13 +5229,16 @@ var defaultOptions = {
5154
5229
  registries: ["npm", "jsr"]
5155
5230
  };
5156
5231
  function resolveOptions(options) {
5157
- const nextOptions = { ...options, ...defaultOptions };
5232
+ const defined = Object.fromEntries(
5233
+ Object.entries(options).filter(([, v]) => v !== void 0)
5234
+ );
5235
+ const nextOptions = { ...defaultOptions, ...defined };
5158
5236
  return nextOptions;
5159
5237
  }
5160
5238
 
5161
5239
  // src/tasks/runner.ts
5162
5240
  import process14 from "node:process";
5163
- import npmCli2 from "@npmcli/promise-spawn";
5241
+ import npmCli3 from "@npmcli/promise-spawn";
5164
5242
  import SemVer from "semver";
5165
5243
  import { isCI as isCI2 } from "std-env";
5166
5244
  import { exec as exec7 } from "tinyexec";
@@ -5211,9 +5289,71 @@ function createListr(...args) {
5211
5289
  }
5212
5290
 
5213
5291
  // src/utils/package.ts
5214
- import { readFile, stat, writeFile } from "node:fs/promises";
5215
- import path6 from "node:path";
5292
+ import { readFile as readFile2, stat as stat3, writeFile as writeFile2 } from "node:fs/promises";
5293
+ import path8 from "node:path";
5216
5294
  import process11 from "node:process";
5295
+
5296
+ // src/ecosystem/rust.ts
5297
+ import { readFile, stat as stat2, writeFile } from "node:fs/promises";
5298
+ import path7 from "node:path";
5299
+ import { parse, stringify } from "smol-toml";
5300
+
5301
+ // src/ecosystem/ecosystem.ts
5302
+ var Ecosystem = class {
5303
+ constructor(packagePath) {
5304
+ this.packagePath = packagePath;
5305
+ }
5306
+ };
5307
+
5308
+ // src/ecosystem/rust.ts
5309
+ var RustEcosystem = class extends Ecosystem {
5310
+ static async detect(packagePath) {
5311
+ try {
5312
+ return (await stat2(path7.join(packagePath, "Cargo.toml"))).isFile();
5313
+ } catch {
5314
+ return false;
5315
+ }
5316
+ }
5317
+ async readCargoToml() {
5318
+ const raw = await readFile(
5319
+ path7.join(this.packagePath, "Cargo.toml"),
5320
+ "utf-8"
5321
+ );
5322
+ return parse(raw);
5323
+ }
5324
+ async packageName() {
5325
+ const cargo = await this.readCargoToml();
5326
+ const pkg = cargo.package;
5327
+ return pkg.name;
5328
+ }
5329
+ async readVersion() {
5330
+ const cargo = await this.readCargoToml();
5331
+ const pkg = cargo.package;
5332
+ return pkg.version;
5333
+ }
5334
+ async writeVersion(newVersion) {
5335
+ const filePath = path7.join(this.packagePath, "Cargo.toml");
5336
+ const raw = await readFile(filePath, "utf-8");
5337
+ const cargo = parse(raw);
5338
+ const pkg = cargo.package;
5339
+ pkg.version = newVersion;
5340
+ await writeFile(filePath, stringify(cargo));
5341
+ }
5342
+ manifestFiles() {
5343
+ return ["Cargo.toml"];
5344
+ }
5345
+ defaultTestCommand() {
5346
+ return "cargo test";
5347
+ }
5348
+ defaultBuildCommand() {
5349
+ return "cargo build --release";
5350
+ }
5351
+ supportedRegistries() {
5352
+ return ["crates"];
5353
+ }
5354
+ };
5355
+
5356
+ // src/utils/package.ts
5217
5357
  var cachedPackageJson = {};
5218
5358
  var cachedJsrJson = {};
5219
5359
  function patchCachedJsrJson(contents, { cwd = process11.cwd() } = {}) {
@@ -5222,16 +5362,16 @@ function patchCachedJsrJson(contents, { cwd = process11.cwd() } = {}) {
5222
5362
  async function findOutFile(file, { cwd = process11.cwd() } = {}) {
5223
5363
  let directory = cwd;
5224
5364
  let filePath = "";
5225
- const { root } = path6.parse(cwd);
5365
+ const { root } = path8.parse(cwd);
5226
5366
  while (directory) {
5227
- filePath = path6.join(directory, file);
5367
+ filePath = path8.join(directory, file);
5228
5368
  try {
5229
- if ((await stat(filePath)).isFile()) {
5369
+ if ((await stat3(filePath)).isFile()) {
5230
5370
  break;
5231
5371
  }
5232
5372
  } catch {
5233
5373
  }
5234
- directory = path6.dirname(directory);
5374
+ directory = path8.dirname(directory);
5235
5375
  if (directory === root) return null;
5236
5376
  }
5237
5377
  return filePath;
@@ -5243,7 +5383,7 @@ async function getPackageJson({
5243
5383
  if (cachedPackageJson[cwd]) return cachedPackageJson[cwd];
5244
5384
  try {
5245
5385
  const packageJsonPath = await findOutFile("package.json");
5246
- const raw = packageJsonPath && (await readFile(packageJsonPath)).toString();
5386
+ const raw = packageJsonPath && (await readFile2(packageJsonPath)).toString();
5247
5387
  if (!raw) {
5248
5388
  if (!fallbackJsr) {
5249
5389
  throw new Error(
@@ -5276,7 +5416,7 @@ async function getJsrJson({
5276
5416
  if (cachedJsrJson[cwd]) return cachedJsrJson[cwd];
5277
5417
  try {
5278
5418
  const jsrJsonPath = await findOutFile("jsr.json");
5279
- const raw = jsrJsonPath && (await readFile(jsrJsonPath)).toString();
5419
+ const raw = jsrJsonPath && (await readFile2(jsrJsonPath)).toString();
5280
5420
  if (!raw) {
5281
5421
  if (!fallbackPackage) {
5282
5422
  throw new Error(
@@ -5360,14 +5500,14 @@ async function version({ cwd = process11.cwd() } = {}) {
5360
5500
  return version2;
5361
5501
  }
5362
5502
  var versionRegex = /("version"\s*:\s*")[^"]*(")/;
5363
- async function replaceVersion(version2) {
5503
+ async function replaceVersion(version2, packages) {
5364
5504
  const results = await Promise.all([
5365
5505
  (async () => {
5366
5506
  const packageJsonPath = await findOutFile("package.json");
5367
5507
  if (!packageJsonPath) return void 0;
5368
- const packageJson = (await readFile(packageJsonPath)).toString();
5508
+ const packageJson = (await readFile2(packageJsonPath)).toString();
5369
5509
  try {
5370
- await writeFile(
5510
+ await writeFile2(
5371
5511
  packageJsonPath,
5372
5512
  packageJson.replace(versionRegex, `$1${version2}$2`)
5373
5513
  );
@@ -5382,9 +5522,9 @@ async function replaceVersion(version2) {
5382
5522
  (async () => {
5383
5523
  const jsrJsonPath = await findOutFile("jsr.json");
5384
5524
  if (!jsrJsonPath) return void 0;
5385
- const jsrJson = (await readFile(jsrJsonPath)).toString();
5525
+ const jsrJson = (await readFile2(jsrJsonPath)).toString();
5386
5526
  try {
5387
- await writeFile(
5527
+ await writeFile2(
5388
5528
  jsrJsonPath,
5389
5529
  jsrJson.replace(versionRegex, `$1${version2}$2`)
5390
5530
  );
@@ -5395,7 +5535,19 @@ async function replaceVersion(version2) {
5395
5535
  );
5396
5536
  }
5397
5537
  return "jsr.json";
5398
- })()
5538
+ })(),
5539
+ ...(packages ?? []).filter((pkg) => pkg.registries.includes("crates")).map(async (pkg) => {
5540
+ const eco = new RustEcosystem(path8.resolve(pkg.path));
5541
+ try {
5542
+ await eco.writeVersion(version2);
5543
+ } catch (error) {
5544
+ throw new AbstractError(
5545
+ `Failed to write version to Cargo.toml at ${pkg.path}: ${error instanceof Error ? error.message : error}`,
5546
+ { cause: error }
5547
+ );
5548
+ }
5549
+ return path8.join(pkg.path, "Cargo.toml");
5550
+ })
5399
5551
  ]);
5400
5552
  return results.filter((v) => v);
5401
5553
  }
@@ -5416,67 +5568,26 @@ async function getPackageManager() {
5416
5568
  return "npm";
5417
5569
  }
5418
5570
 
5419
- // src/ecosystem/rust.ts
5420
- import { readFile as readFile2, stat as stat2, writeFile as writeFile2 } from "node:fs/promises";
5421
- import path7 from "node:path";
5422
- import { parse, stringify } from "smol-toml";
5423
-
5424
- // src/ecosystem/ecosystem.ts
5425
- var Ecosystem = class {
5426
- constructor(packagePath) {
5427
- this.packagePath = packagePath;
5428
- }
5429
- };
5430
-
5431
- // src/ecosystem/rust.ts
5432
- var RustEcosystem = class extends Ecosystem {
5433
- static async detect(packagePath) {
5434
- try {
5435
- return (await stat2(path7.join(packagePath, "Cargo.toml"))).isFile();
5436
- } catch {
5437
- return false;
5571
+ // src/utils/registries.ts
5572
+ function collectRegistries(ctx) {
5573
+ if (ctx.packages?.length) {
5574
+ const seen = /* @__PURE__ */ new Set();
5575
+ const result = [];
5576
+ for (const pkg of ctx.packages) {
5577
+ for (const reg of pkg.registries) {
5578
+ if (!seen.has(reg)) {
5579
+ seen.add(reg);
5580
+ result.push(reg);
5581
+ }
5582
+ }
5438
5583
  }
5584
+ return result;
5439
5585
  }
5440
- async readCargoToml() {
5441
- const raw = await readFile2(
5442
- path7.join(this.packagePath, "Cargo.toml"),
5443
- "utf-8"
5444
- );
5445
- return parse(raw);
5446
- }
5447
- async packageName() {
5448
- const cargo = await this.readCargoToml();
5449
- const pkg = cargo.package;
5450
- return pkg.name;
5451
- }
5452
- async readVersion() {
5453
- const cargo = await this.readCargoToml();
5454
- const pkg = cargo.package;
5455
- return pkg.version;
5456
- }
5457
- async writeVersion(newVersion) {
5458
- const filePath = path7.join(this.packagePath, "Cargo.toml");
5459
- const raw = await readFile2(filePath, "utf-8");
5460
- const cargo = parse(raw);
5461
- const pkg = cargo.package;
5462
- pkg.version = newVersion;
5463
- await writeFile2(filePath, stringify(cargo));
5464
- }
5465
- manifestFiles() {
5466
- return ["Cargo.toml"];
5467
- }
5468
- defaultTestCommand() {
5469
- return "cargo test";
5470
- }
5471
- defaultBuildCommand() {
5472
- return "cargo build --release";
5473
- }
5474
- supportedRegistries() {
5475
- return ["crates"];
5476
- }
5477
- };
5586
+ return ctx.registries;
5587
+ }
5478
5588
 
5479
5589
  // src/registry/crates.ts
5590
+ import path9 from "node:path";
5480
5591
  import { exec as exec3 } from "tinyexec";
5481
5592
 
5482
5593
  // src/registry/registry.ts
@@ -5550,9 +5661,13 @@ var CratesRegistry = class extends Registry {
5550
5661
  );
5551
5662
  }
5552
5663
  }
5553
- async publish() {
5664
+ async publish(manifestDir) {
5554
5665
  try {
5555
- await exec3("cargo", ["publish"], { throwOnError: true });
5666
+ const args = ["publish"];
5667
+ if (manifestDir) {
5668
+ args.push("--manifest-path", path9.join(manifestDir, "Cargo.toml"));
5669
+ }
5670
+ await exec3("cargo", args, { throwOnError: true });
5556
5671
  return true;
5557
5672
  } catch (error) {
5558
5673
  throw new CratesError("Failed to run `cargo publish`", {
@@ -5608,39 +5723,48 @@ var CratesError2 = class extends AbstractError {
5608
5723
  this.stack = "";
5609
5724
  }
5610
5725
  };
5611
- async function getCrateName() {
5612
- const eco = new RustEcosystem(process.cwd());
5726
+ async function getCrateName(packagePath) {
5727
+ const eco = new RustEcosystem(packagePath ?? process.cwd());
5613
5728
  return await eco.packageName();
5614
5729
  }
5615
- var cratesAvailableCheckTasks = {
5616
- title: "Checking crates.io availability",
5617
- task: async () => {
5618
- const packageName = await getCrateName();
5619
- const registry = new CratesRegistry(packageName);
5620
- if (!await registry.isInstalled()) {
5621
- throw new CratesError2(
5622
- "cargo is not installed. Please install Rust toolchain to proceed."
5623
- );
5730
+ function createCratesAvailableCheckTask(packagePath) {
5731
+ const label = packagePath ? ` (${packagePath})` : "";
5732
+ return {
5733
+ title: `Checking crates.io availability${label}`,
5734
+ task: async () => {
5735
+ const packageName = await getCrateName(packagePath);
5736
+ const registry = new CratesRegistry(packageName);
5737
+ if (!await registry.isInstalled()) {
5738
+ throw new CratesError2(
5739
+ "cargo is not installed. Please install Rust toolchain to proceed."
5740
+ );
5741
+ }
5742
+ if (!await registry.hasPermission()) {
5743
+ throw new CratesError2(
5744
+ "No crates.io credentials found. Run `cargo login` or set CARGO_REGISTRY_TOKEN."
5745
+ );
5746
+ }
5624
5747
  }
5625
- if (!await registry.hasPermission()) {
5626
- throw new CratesError2(
5627
- "No crates.io credentials found. Run `cargo login` or set CARGO_REGISTRY_TOKEN."
5628
- );
5748
+ };
5749
+ }
5750
+ function createCratesPublishTask(packagePath) {
5751
+ const label = packagePath ? ` (${packagePath})` : "";
5752
+ return {
5753
+ title: `Publishing to crates.io${label}`,
5754
+ task: async () => {
5755
+ const packageName = await getCrateName(packagePath);
5756
+ const registry = new CratesRegistry(packageName);
5757
+ await registry.publish(packagePath);
5629
5758
  }
5630
- }
5631
- };
5632
- var cratesPublishTasks = {
5633
- title: "Publishing to crates.io",
5634
- task: async () => {
5635
- const packageName = await getCrateName();
5636
- const registry = new CratesRegistry(packageName);
5637
- await registry.publish();
5638
- }
5639
- };
5759
+ };
5760
+ }
5761
+ var cratesAvailableCheckTasks = createCratesAvailableCheckTask();
5762
+ var cratesPublishTasks = createCratesPublishTask();
5640
5763
 
5641
5764
  // src/tasks/jsr.ts
5642
5765
  import process12 from "node:process";
5643
5766
  import { ListrEnquirerPromptAdapter } from "@listr2/prompt-adapter-enquirer";
5767
+ import npmCli from "@npmcli/promise-spawn";
5644
5768
 
5645
5769
  // src/registry/jsr.ts
5646
5770
  import { exec as exec4, NonZeroExitError } from "tinyexec";
@@ -5648,7 +5772,7 @@ import { exec as exec4, NonZeroExitError } from "tinyexec";
5648
5772
  // src/utils/db.ts
5649
5773
  import { createCipheriv, createDecipheriv, createHash } from "node:crypto";
5650
5774
  import { mkdirSync as mkdirSync5, readFileSync as readFileSync3, statSync, writeFileSync as writeFileSync4 } from "node:fs";
5651
- import path8 from "node:path";
5775
+ import path10 from "node:path";
5652
5776
  var a = "aes-256-cbc";
5653
5777
  var n = statSync(import.meta.dirname);
5654
5778
  var k = `${n.rdev}${n.birthtimeMs}${n.nlink}${n.gid}`;
@@ -5663,7 +5787,7 @@ function d(g, h) {
5663
5787
  }
5664
5788
  var Db = class {
5665
5789
  constructor() {
5666
- __publicField(this, "path", path8.resolve(import.meta.dirname, ".pubm"));
5790
+ __publicField(this, "path", path10.resolve(import.meta.dirname, ".pubm"));
5667
5791
  try {
5668
5792
  if (!statSync(this.path).isDirectory()) {
5669
5793
  mkdirSync5(this.path);
@@ -5681,7 +5805,7 @@ var Db = class {
5681
5805
  set(field, value) {
5682
5806
  try {
5683
5807
  writeFileSync4(
5684
- path8.resolve(
5808
+ path10.resolve(
5685
5809
  this.path,
5686
5810
  Buffer.from(e(field, field)).toString("base64")
5687
5811
  ),
@@ -5695,7 +5819,7 @@ var Db = class {
5695
5819
  }
5696
5820
  }
5697
5821
  get(field) {
5698
- const filePath = path8.resolve(
5822
+ const filePath = path10.resolve(
5699
5823
  this.path,
5700
5824
  Buffer.from(e(field, field)).toString("base64")
5701
5825
  );
@@ -5777,6 +5901,7 @@ var JsrRegisry = class extends Registry {
5777
5901
  super(packageName, registry);
5778
5902
  __publicField(this, "registry", "https://jsr.io");
5779
5903
  __publicField(this, "client");
5904
+ __publicField(this, "packageCreationUrls");
5780
5905
  this.client = new JsrClient(getApiEndpoint(this.registry));
5781
5906
  }
5782
5907
  async jsr(args) {
@@ -5818,9 +5943,19 @@ var JsrRegisry = class extends Registry {
5818
5943
  throwOnError: true
5819
5944
  }
5820
5945
  );
5946
+ this.packageCreationUrls = void 0;
5821
5947
  return true;
5822
5948
  } catch (error) {
5823
5949
  const stderr = error instanceof NonZeroExitError ? error.output?.stderr : void 0;
5950
+ if (stderr?.includes("don't exist")) {
5951
+ const urls = [...stderr.matchAll(/https:\/\/jsr\.io\/new\S+/g)].map(
5952
+ (m) => m[0]
5953
+ );
5954
+ if (urls.length > 0) {
5955
+ this.packageCreationUrls = urls;
5956
+ return false;
5957
+ }
5958
+ }
5824
5959
  throw new JsrError(
5825
5960
  `Failed to run \`jsr publish --allow-dirty --token ***\`${stderr ? `
5826
5961
  ${stderr}` : ""}`,
@@ -6261,6 +6396,7 @@ async function npmRegistry() {
6261
6396
  }
6262
6397
 
6263
6398
  // src/tasks/jsr.ts
6399
+ var { open } = npmCli;
6264
6400
  var JsrAvailableError = class extends AbstractError {
6265
6401
  constructor(message, { cause } = {}) {
6266
6402
  super(message, { cause });
@@ -6441,7 +6577,39 @@ var jsrPublishTasks = {
6441
6577
  }
6442
6578
  JsrClient.token = jsrTokenEnv;
6443
6579
  }
6444
- await jsr.publish();
6580
+ let result = await jsr.publish();
6581
+ if (!result && jsr.packageCreationUrls) {
6582
+ if (ctx.promptEnabled) {
6583
+ task.title = "Running jsr publish (package creation needed)";
6584
+ const urls = jsr.packageCreationUrls;
6585
+ const maxAttempts = 3;
6586
+ task.output = `Package doesn't exist on jsr. Create it at:
6587
+ ${urls.map((url) => ` ${color.cyan(url)}`).join("\n")}`;
6588
+ open(urls[0]);
6589
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) {
6590
+ await task.prompt(ListrEnquirerPromptAdapter).run({
6591
+ type: "input",
6592
+ message: `Press ${color.bold("enter")} after creating the package on jsr.io${attempt > 1 ? ` (attempt ${attempt}/${maxAttempts})` : ""}`
6593
+ });
6594
+ result = await jsr.publish();
6595
+ if (result) break;
6596
+ if (attempt < maxAttempts) {
6597
+ task.output = "Package still doesn't exist. Please create it and try again.";
6598
+ }
6599
+ }
6600
+ if (!result) {
6601
+ throw new JsrAvailableError(
6602
+ "Package creation not completed after 3 attempts."
6603
+ );
6604
+ }
6605
+ task.title = "Running jsr publish (package created)";
6606
+ } else {
6607
+ throw new JsrAvailableError(
6608
+ `Package doesn't exist on jsr. Create it at:
6609
+ ${jsr.packageCreationUrls.join("\n")}`
6610
+ );
6611
+ }
6612
+ }
6445
6613
  }
6446
6614
  };
6447
6615
 
@@ -6449,8 +6617,8 @@ var jsrPublishTasks = {
6449
6617
  import { spawn } from "node:child_process";
6450
6618
  import process13 from "node:process";
6451
6619
  import { ListrEnquirerPromptAdapter as ListrEnquirerPromptAdapter2 } from "@listr2/prompt-adapter-enquirer";
6452
- import npmCli from "@npmcli/promise-spawn";
6453
- var { open } = npmCli;
6620
+ import npmCli2 from "@npmcli/promise-spawn";
6621
+ var { open: open2 } = npmCli2;
6454
6622
  var NpmAvailableError = class extends AbstractError {
6455
6623
  constructor(message, { cause } = {}) {
6456
6624
  super(message, { cause });
@@ -6480,7 +6648,7 @@ var npmAvailableCheckTasks = {
6480
6648
  if (urlMatch && !opened) {
6481
6649
  opened = true;
6482
6650
  task.output = `Login at: ${color.cyan(urlMatch[0])}`;
6483
- open(urlMatch[0]);
6651
+ open2(urlMatch[0]);
6484
6652
  child.stdin?.write("\n");
6485
6653
  }
6486
6654
  };
@@ -6488,9 +6656,7 @@ var npmAvailableCheckTasks = {
6488
6656
  child.stderr?.on("data", onData);
6489
6657
  child.on(
6490
6658
  "close",
6491
- (code) => code === 0 ? resolve() : reject(
6492
- new Error(`npm login exited with code ${code}`)
6493
- )
6659
+ (code) => code === 0 ? resolve() : reject(new Error(`npm login exited with code ${code}`))
6494
6660
  );
6495
6661
  child.on("error", reject);
6496
6662
  });
@@ -6793,7 +6959,7 @@ var requiredConditionsCheckTask = (options) => createListr({
6793
6959
  {
6794
6960
  title: "Ping registries",
6795
6961
  task: (ctx, parentTask2) => parentTask2.newListr(
6796
- ctx.registries.map((registryKey) => ({
6962
+ collectRegistries(ctx).map((registryKey) => ({
6797
6963
  title: `Ping to ${registryKey}`,
6798
6964
  task: async () => {
6799
6965
  const registry = await getRegistry(registryKey);
@@ -6810,7 +6976,9 @@ var requiredConditionsCheckTask = (options) => createListr({
6810
6976
  task: async (_2, parentTask2) => parentTask2.newListr(
6811
6977
  [
6812
6978
  {
6813
- enabled: (ctx) => ctx.registries.some((registry) => registry !== "jsr"),
6979
+ enabled: (ctx) => collectRegistries(ctx).some(
6980
+ (registry) => registry !== "jsr"
6981
+ ),
6814
6982
  title: "Verifying if npm are installed",
6815
6983
  task: async () => {
6816
6984
  const npm = await npmRegistry();
@@ -6822,7 +6990,9 @@ var requiredConditionsCheckTask = (options) => createListr({
6822
6990
  }
6823
6991
  },
6824
6992
  {
6825
- enabled: (ctx) => ctx.registries.some((registry) => registry === "jsr"),
6993
+ enabled: (ctx) => collectRegistries(ctx).some(
6994
+ (registry) => registry === "jsr"
6995
+ ),
6826
6996
  title: "Verifying if jsr are installed",
6827
6997
  task: async (_3, task) => {
6828
6998
  const jsr = await jsrRegistry();
@@ -6853,7 +7023,7 @@ var requiredConditionsCheckTask = (options) => createListr({
6853
7023
  },
6854
7024
  {
6855
7025
  title: "Checking if test and build scripts exist",
6856
- skip: (ctx) => !needsPackageScripts(ctx.registries),
7026
+ skip: (ctx) => !needsPackageScripts(collectRegistries(ctx)),
6857
7027
  task: async (ctx) => {
6858
7028
  const { scripts } = await getPackageJson();
6859
7029
  const errors = [];
@@ -6881,23 +7051,42 @@ var requiredConditionsCheckTask = (options) => createListr({
6881
7051
  },
6882
7052
  {
6883
7053
  title: "Checking available registries for publishing",
6884
- task: (ctx, parentTask2) => parentTask2.newListr(
6885
- ctx.registries.map((registryKey) => {
6886
- switch (registryKey) {
6887
- case "npm":
6888
- return npmAvailableCheckTasks;
6889
- case "jsr":
6890
- return jsrAvailableCheckTasks;
6891
- case "crates":
6892
- return cratesAvailableCheckTasks;
6893
- default:
6894
- return npmAvailableCheckTasks;
6895
- }
6896
- }),
6897
- {
6898
- concurrent: true
7054
+ task: (ctx, parentTask2) => {
7055
+ if (ctx.packages?.length) {
7056
+ const tasks = ctx.packages.flatMap(
7057
+ (pkg) => pkg.registries.map((registryKey) => {
7058
+ switch (registryKey) {
7059
+ case "npm":
7060
+ return npmAvailableCheckTasks;
7061
+ case "jsr":
7062
+ return jsrAvailableCheckTasks;
7063
+ case "crates":
7064
+ return createCratesAvailableCheckTask(pkg.path);
7065
+ default:
7066
+ return npmAvailableCheckTasks;
7067
+ }
7068
+ })
7069
+ );
7070
+ return parentTask2.newListr(tasks, { concurrent: true });
6899
7071
  }
6900
- )
7072
+ return parentTask2.newListr(
7073
+ collectRegistries(ctx).map((registryKey) => {
7074
+ switch (registryKey) {
7075
+ case "npm":
7076
+ return npmAvailableCheckTasks;
7077
+ case "jsr":
7078
+ return jsrAvailableCheckTasks;
7079
+ case "crates":
7080
+ return cratesAvailableCheckTasks;
7081
+ default:
7082
+ return npmAvailableCheckTasks;
7083
+ }
7084
+ }),
7085
+ {
7086
+ concurrent: true
7087
+ }
7088
+ );
7089
+ }
6901
7090
  }
6902
7091
  ],
6903
7092
  {
@@ -6907,8 +7096,30 @@ var requiredConditionsCheckTask = (options) => createListr({
6907
7096
  });
6908
7097
 
6909
7098
  // src/tasks/runner.ts
6910
- var { open: open2 } = npmCli2;
7099
+ var { open: open3 } = npmCli3;
6911
7100
  var { prerelease } = SemVer;
7101
+ function registryTask(registry) {
7102
+ switch (registry) {
7103
+ case "npm":
7104
+ return npmPublishTasks;
7105
+ case "jsr":
7106
+ return jsrPublishTasks;
7107
+ case "crates":
7108
+ return cratesPublishTasks;
7109
+ default:
7110
+ return npmPublishTasks;
7111
+ }
7112
+ }
7113
+ function collectPublishTasks(ctx) {
7114
+ if (ctx.packages?.length) {
7115
+ return ctx.packages.flatMap(
7116
+ (pkg) => pkg.registries.map(
7117
+ (reg) => reg === "crates" ? createCratesPublishTask(pkg.path) : registryTask(reg)
7118
+ )
7119
+ );
7120
+ }
7121
+ return collectRegistries(ctx).map(registryTask);
7122
+ }
6912
7123
  async function run(options) {
6913
7124
  const ctx = {
6914
7125
  ...options,
@@ -6927,21 +7138,9 @@ async function run(options) {
6927
7138
  await createListr(
6928
7139
  options.publishOnly ? {
6929
7140
  title: "Publishing",
6930
- task: (ctx2, parentTask) => parentTask.newListr(
6931
- ctx2.registries.map((registry) => {
6932
- switch (registry) {
6933
- case "npm":
6934
- return npmPublishTasks;
6935
- case "jsr":
6936
- return jsrPublishTasks;
6937
- case "crates":
6938
- return cratesPublishTasks;
6939
- default:
6940
- return npmPublishTasks;
6941
- }
6942
- }),
6943
- { concurrent: true }
6944
- )
7141
+ task: (ctx2, parentTask) => parentTask.newListr(collectPublishTasks(ctx2), {
7142
+ concurrent: true
7143
+ })
6945
7144
  } : [
6946
7145
  {
6947
7146
  skip: options.skipTests,
@@ -7010,7 +7209,10 @@ async function run(options) {
7010
7209
  }
7011
7210
  }, ctx2);
7012
7211
  await git.reset();
7013
- const replaced = await replaceVersion(ctx2.version);
7212
+ const replaced = await replaceVersion(
7213
+ ctx2.version,
7214
+ ctx2.packages
7215
+ );
7014
7216
  for (const replacedFile of replaced) {
7015
7217
  await git.stage(replacedFile);
7016
7218
  }
@@ -7025,21 +7227,9 @@ async function run(options) {
7025
7227
  {
7026
7228
  skip: (ctx2) => options.skipPublish || !!ctx2.preview,
7027
7229
  title: "Publishing",
7028
- task: (ctx2, parentTask) => parentTask.newListr(
7029
- ctx2.registries.map((registry) => {
7030
- switch (registry) {
7031
- case "npm":
7032
- return npmPublishTasks;
7033
- case "jsr":
7034
- return jsrPublishTasks;
7035
- case "crates":
7036
- return cratesPublishTasks;
7037
- default:
7038
- return npmPublishTasks;
7039
- }
7040
- }),
7041
- { concurrent: true }
7042
- )
7230
+ task: (ctx2, parentTask) => parentTask.newListr(collectPublishTasks(ctx2), {
7231
+ concurrent: true
7232
+ })
7043
7233
  },
7044
7234
  {
7045
7235
  title: "Pushing tags to GitHub",
@@ -7079,7 +7269,7 @@ ${repositoryUrl}/compare/${lastRev}...${latestTag}`;
7079
7269
  );
7080
7270
  const linkUrl = link2("Link", releaseDraftUrl.toString());
7081
7271
  task.title += ` ${linkUrl}`;
7082
- await open2(releaseDraftUrl.toString());
7272
+ await open3(releaseDraftUrl.toString());
7083
7273
  }
7084
7274
  }
7085
7275
  ]
@@ -7103,13 +7293,9 @@ ${repositoryUrl}/compare/${lastRev}...${latestTag}`;
7103
7293
  import process15 from "node:process";
7104
7294
  import { inc } from "semver";
7105
7295
 
7106
- // src/config/loader.ts
7107
- import { stat as stat3 } from "node:fs/promises";
7108
- import path9 from "node:path";
7109
-
7110
7296
  // src/monorepo/discover.ts
7111
7297
  import { existsSync as existsSync6, readdirSync as readdirSync3, statSync as statSync2 } from "node:fs";
7112
- import path10 from "node:path";
7298
+ import path11 from "node:path";
7113
7299
  import micromatch from "micromatch";
7114
7300
 
7115
7301
  // src/monorepo/workspace.ts
@@ -7122,14 +7308,25 @@ import micromatch2 from "micromatch";
7122
7308
 
7123
7309
  // src/validate/entry-points.ts
7124
7310
  import { existsSync as existsSync7 } from "node:fs";
7125
- import path11 from "node:path";
7311
+ import path12 from "node:path";
7126
7312
 
7127
7313
  // src/validate/extraneous-files.ts
7128
7314
  import micromatch3 from "micromatch";
7129
7315
 
7130
7316
  // src/index.ts
7131
7317
  async function pubm(options) {
7132
- const resolvedOptions = resolveOptions({ ...options });
7318
+ const config = await loadConfig();
7319
+ const configOptions = {};
7320
+ if (config) {
7321
+ const resolved = resolveConfig(config);
7322
+ if (resolved.packages) {
7323
+ configOptions.packages = resolved.packages;
7324
+ }
7325
+ if (!options.registries && resolved.registries) {
7326
+ configOptions.registries = resolved.registries;
7327
+ }
7328
+ }
7329
+ const resolvedOptions = resolveOptions({ ...configOptions, ...options });
7133
7330
  await run(resolvedOptions);
7134
7331
  }
7135
7332