@theholocron/cli 5.0.0-alpha.243 → 5.0.0-alpha.244

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/dist/cli.mjs CHANGED
@@ -9113,17 +9113,18 @@ async function runNpmBumpVersions(input) {
9113
9113
  const print = input.print ?? ((line) => console.log(line));
9114
9114
  const logger = input.logger ?? getLogger();
9115
9115
  const cwd = input.cwd ?? process.cwd();
9116
- const { version, dryRun = false, group } = input;
9116
+ const { version, dryRun = false, group, excludeGroups } = input;
9117
9117
  const readFile = input.readFile ?? ((p) => readFileSync(p, "utf8"));
9118
9118
  const writeFile = input.writeFile ?? ((p, c) => writeFileSync(p, c));
9119
9119
  const listDir = input.listDir ?? ((p) => readdirSync(p));
9120
9120
  const isDir = input.isDir ?? ((p) => statSync(p).isDirectory());
9121
9121
  const bumped = [];
9122
9122
  const skipped = [];
9123
- print(`Bumping ${group ? `group ${group}` : "monorepo"} to ${version}${dryRun ? " (dry-run)" : ""}…`);
9123
+ print(`Bumping ${group ? `group ${group}` : excludeGroups?.length ? `monorepo, leaving out ${excludeGroups.join(", ")},` : "monorepo"} to ${version}${dryRun ? " (dry-run)" : ""}…`);
9124
9124
  logger.info({
9125
9125
  version,
9126
9126
  group,
9127
+ excludeGroups,
9127
9128
  dryRun: dryRun || void 0
9128
9129
  }, "npm bump-versions: start");
9129
9130
  function bumpFile(absPath, label) {
@@ -9150,6 +9151,7 @@ async function runNpmBumpVersions(input) {
9150
9151
  readFile,
9151
9152
  readText: readFile,
9152
9153
  ...group ? { group } : {},
9154
+ ...excludeGroups?.length ? { excludeGroups } : {},
9153
9155
  listDirs: (dir) => {
9154
9156
  let names;
9155
9157
  try {
@@ -9214,6 +9216,10 @@ const npmBumpVersionsArgs = (y) => y.positional("new-version", {
9214
9216
  }).option("group", {
9215
9217
  type: "string",
9216
9218
  describe: "Only this version group's packages: a folder of the repo (clients, observability). The root package.json is left alone. Omitted, the root and every workspace package move together."
9219
+ }).option("exclude-group", {
9220
+ type: "string",
9221
+ array: true,
9222
+ describe: "Leave this version group's packages alone (repeatable). The repo-wide bump uses it so it does not move a group that is released on its own."
9217
9223
  });
9218
9224
  //#endregion
9219
9225
  //#region src/commands/npm-bump-versions/npm-bump-versions.command.ts
@@ -9227,7 +9233,8 @@ const npmBumpVersionsCommand = {
9227
9233
  version: newVersion,
9228
9234
  cwd: argv.cwd,
9229
9235
  dryRun: argv.dryRun,
9230
- ...argv.group ? { group: argv.group } : {}
9236
+ ...argv.group ? { group: argv.group } : {},
9237
+ ...argv.excludeGroup?.length ? { excludeGroups: argv.excludeGroup } : {}
9231
9238
  })).status === "fail") process.exitCode = 1;
9232
9239
  }
9233
9240
  };
@@ -9290,9 +9297,9 @@ const defaultLogin = async (cwd) => {
9290
9297
  * and never the root `package.json`: a group that has no packages has nothing to
9291
9298
  * publish, not a single-package repo.
9292
9299
  */
9293
- function discoverManifests(cwd, group) {
9294
- const workspace = discoverWorkspacePackages(cwd, { ...group === void 0 ? {} : { group } });
9295
- if (group !== void 0) return workspace.map(({ manifest, relativeDir }) => ({
9300
+ function discoverManifests(cwd, scope = {}) {
9301
+ const workspace = discoverWorkspacePackages(cwd, scope);
9302
+ if (scope.group !== void 0) return workspace.map(({ manifest, relativeDir }) => ({
9296
9303
  manifest,
9297
9304
  dir: `./${relativeDir}`
9298
9305
  }));
@@ -9316,8 +9323,8 @@ function discoverManifests(cwd, group) {
9316
9323
  * mode needs both to check `npm view <pkg>@<version>` and publish one
9317
9324
  * workspace at a time.
9318
9325
  */
9319
- function discoverPublicPackageEntries(cwd, group) {
9320
- return discoverManifests(cwd, group).flatMap(({ manifest, dir }) => !manifest.private && manifest.name && manifest.version ? [{
9326
+ function discoverPublicPackageEntries(cwd, scope = {}) {
9327
+ return discoverManifests(cwd, scope).flatMap(({ manifest, dir }) => !manifest.private && manifest.name && manifest.version ? [{
9321
9328
  name: manifest.name,
9322
9329
  version: manifest.version,
9323
9330
  dir
@@ -9422,6 +9429,15 @@ async function resolveRepoIdentity(cwd, exec) {
9422
9429
  };
9423
9430
  }
9424
9431
  //#endregion
9432
+ //#region src/commands/publish/scope-of.ts
9433
+ /** The {@link WorkspaceScope} a publish input asks for; unset options stay unset. */
9434
+ function scopeOf({ group, excludeGroups }) {
9435
+ return {
9436
+ ...group === void 0 ? {} : { group },
9437
+ ...excludeGroups === void 0 ? {} : { excludeGroups }
9438
+ };
9439
+ }
9440
+ //#endregion
9425
9441
  //#region src/commands/publish/workspace-filter-args.ts
9426
9442
  /**
9427
9443
  * `-r --filter=./clients/* --filter=./observability` -- one filter per
@@ -9430,8 +9446,8 @@ async function resolveRepoIdentity(cwd, exec) {
9430
9446
  * invocation below so a repo with several package roots is covered the same as
9431
9447
  * a `packages/*`-only one.
9432
9448
  */
9433
- function workspaceFilterArgs(cwd, group) {
9434
- const found = discoverWorkspacePackages(cwd, { ...group === void 0 ? {} : { group } }).filter(({ manifest }) => !manifest.private);
9449
+ function workspaceFilterArgs(cwd, scope = {}) {
9450
+ const found = discoverWorkspacePackages(cwd, scope).filter(({ manifest }) => !manifest.private);
9435
9451
  const globs = resolveWorkspaceGlobs(cwd).include.filter((glob) => found.some(({ relativeDir }) => glob.endsWith("/*") ? relativeDir.startsWith(glob.slice(0, -1)) : relativeDir === glob));
9436
9452
  return globs.length > 0 ? ["-r", ...globs.map((glob) => `--filter=./${glob}`)] : [];
9437
9453
  }
@@ -9511,7 +9527,7 @@ async function runPublish(input = {}) {
9511
9527
  if ((await login(cwd)).exitCode !== 0) {
9512
9528
  const message = "npm login failed. Run `npm login --auth-type=web` (or `npm login`) manually, then re-run.";
9513
9529
  print(` ✗ ${message}`);
9514
- const packageNames = (input.packages ?? discoverPublicPackageEntries(cwd, input.group)).map((e) => e.name);
9530
+ const packageNames = (input.packages ?? discoverPublicPackageEntries(cwd, scopeOf(input))).map((e) => e.name);
9515
9531
  logger.warn({ reason: "npm login failed" }, "publish --initial: done");
9516
9532
  return {
9517
9533
  status: "fail",
@@ -9523,7 +9539,7 @@ async function runPublish(input = {}) {
9523
9539
  if (whoami.exitCode !== 0) {
9524
9540
  const message = "npm login completed but `npm whoami` still fails — check your npm account.";
9525
9541
  print(` ✗ ${message}`);
9526
- const packageNames = (input.packages ?? discoverPublicPackageEntries(cwd, input.group)).map((e) => e.name);
9542
+ const packageNames = (input.packages ?? discoverPublicPackageEntries(cwd, scopeOf(input))).map((e) => e.name);
9527
9543
  logger.warn({ reason: "npm whoami still fails after login" }, "publish --initial: done");
9528
9544
  return {
9529
9545
  status: "fail",
@@ -9536,7 +9552,7 @@ async function runPublish(input = {}) {
9536
9552
  print(style.dim(` ✓ authed as ${whoamiName}`));
9537
9553
  print("");
9538
9554
  if (otp) print(style.dim(` otp: <${otp.length} chars>`));
9539
- const discoveredEntries = input.packages ?? discoverPublicPackageEntries(cwd, input.group);
9555
+ const discoveredEntries = input.packages ?? discoverPublicPackageEntries(cwd, scopeOf(input));
9540
9556
  const nameWidth = Math.max(0, ...discoveredEntries.map((e) => e.name.length));
9541
9557
  const dirWidth = Math.max(0, ...discoveredEntries.map((e) => e.dir.length));
9542
9558
  const newEntries = input.packages ? [...discoveredEntries] : await filterNewPackages(discoveredEntries, cwd, exec, print, nameWidth, dirWidth);
@@ -9571,7 +9587,7 @@ async function runPublish(input = {}) {
9571
9587
  };
9572
9588
  }
9573
9589
  const publishArgs = [
9574
- ...workspaceFilterArgs(cwd, input.group).length > 0 ? ["-r", ...packageNames.map((name) => `--filter=${name}`)] : [],
9590
+ ...workspaceFilterArgs(cwd, scopeOf(input)).length > 0 ? ["-r", ...packageNames.map((name) => `--filter=${name}`)] : [],
9575
9591
  "publish",
9576
9592
  "--access",
9577
9593
  "public",
@@ -9668,11 +9684,12 @@ async function runSteadyPublish(input = {}) {
9668
9684
  const exec = input.exec ?? defaultExec$1;
9669
9685
  const provenance = input.provenance ?? true;
9670
9686
  const skipAlreadyPublished = input.skipAlreadyPublished ?? false;
9671
- const entries = input.packages ?? discoverPublicPackageEntries(cwd, input.group);
9687
+ const entries = input.packages ?? discoverPublicPackageEntries(cwd, scopeOf(input));
9672
9688
  const packageNames = entries.map((e) => e.name);
9673
9689
  print(`Holocron publish${dryRun ? " (dry-run)" : ""}`);
9674
9690
  print(` cwd: ${cwd}`);
9675
9691
  if (input.group) print(` group: ${input.group}`);
9692
+ if (input.excludeGroups?.length) print(` excluding groups: ${input.excludeGroups.join(", ")}`);
9676
9693
  print(` tag: ${tag}`);
9677
9694
  print(` provenance: ${provenance}`);
9678
9695
  if (skipAlreadyPublished) print(" skip-already-published: true");
@@ -9708,7 +9725,7 @@ async function runSteadyPublish(input = {}) {
9708
9725
  if (skipAlreadyPublished) for (const entry of entries) print(` … would check ${entry.name}@${entry.version}, publish if not already on npm`);
9709
9726
  else {
9710
9727
  const args = [
9711
- ...workspaceFilterArgs(cwd, input.group),
9728
+ ...workspaceFilterArgs(cwd, scopeOf(input)),
9712
9729
  "publish",
9713
9730
  ...baseFlags,
9714
9731
  ...otpFlags
@@ -9783,7 +9800,7 @@ async function runSteadyPublish(input = {}) {
9783
9800
  }
9784
9801
  print(" → publishing all public @theholocron/* packages…");
9785
9802
  const publish = await exec("pnpm", [
9786
- ...workspaceFilterArgs(cwd, input.group),
9803
+ ...workspaceFilterArgs(cwd, scopeOf(input)),
9787
9804
  "publish",
9788
9805
  ...baseFlags,
9789
9806
  ...otpFlags
@@ -9820,8 +9837,8 @@ async function runSteadyPublish(input = {}) {
9820
9837
  //#endregion
9821
9838
  //#region src/commands/publish/discover-public-packages.ts
9822
9839
  /** The names of `discoverPublicPackageEntries`' packages, without requiring a version. */
9823
- function discoverPublicPackages(cwd, group) {
9824
- return discoverManifests(cwd, group).flatMap(({ manifest }) => !manifest.private && manifest.name ? [manifest.name] : []);
9840
+ function discoverPublicPackages(cwd, scope = {}) {
9841
+ return discoverManifests(cwd, scope).flatMap(({ manifest }) => !manifest.private && manifest.name ? [manifest.name] : []);
9825
9842
  }
9826
9843
  //#endregion
9827
9844
  //#region src/commands/publish/is-eotp.ts
@@ -9867,7 +9884,7 @@ async function runSyncTrust(input) {
9867
9884
  const repo = input.repo ?? "theholocron/holocron";
9868
9885
  const dryRun = input.dryRun ?? false;
9869
9886
  const exec = input.exec ?? defaultExec$1;
9870
- const packageNames = input.packages ?? discoverPublicPackages(cwd, input.group);
9887
+ const packageNames = input.packages ?? discoverPublicPackages(cwd, scopeOf(input));
9871
9888
  const npm = "npx";
9872
9889
  const npmArgs = ["-y", "npm@latest"];
9873
9890
  print(`Holocron publish --sync-trust${dryRun ? " (dry-run)" : ""}`);
@@ -10037,6 +10054,10 @@ const publishArgs = (y) => y.option("initial", {
10037
10054
  }).option("group", {
10038
10055
  type: "string",
10039
10056
  describe: "Only this version group's packages: a folder of the repo (clients, observability). Omitted, every public package in the workspace."
10057
+ }).option("exclude-group", {
10058
+ type: "string",
10059
+ array: true,
10060
+ describe: "Everything except this version group (repeatable). The repo-wide release uses it so it does not take in a group that is released on its own."
10040
10061
  }).option("provenance", {
10041
10062
  type: "boolean",
10042
10063
  default: true,
@@ -10067,6 +10088,7 @@ const publishCommand = {
10067
10088
  newFile,
10068
10089
  dryRun: argv.dryRun,
10069
10090
  ...argv.group ? { group: argv.group } : {},
10091
+ ...argv.excludeGroup?.length ? { excludeGroups: argv.excludeGroup } : {},
10070
10092
  ...argv.repo ? { repo: argv.repo } : {}
10071
10093
  })).status === "fail") process.exitCode = 1;
10072
10094
  return;
@@ -10076,6 +10098,7 @@ const publishCommand = {
10076
10098
  cwd: argv.cwd,
10077
10099
  dryRun: argv.dryRun,
10078
10100
  ...argv.group ? { group: argv.group } : {},
10101
+ ...argv.excludeGroup?.length ? { excludeGroups: argv.excludeGroup } : {},
10079
10102
  ...argv.tag ? { tag: argv.tag } : {},
10080
10103
  ...otp ? { otp } : {}
10081
10104
  });
@@ -10089,6 +10112,7 @@ const publishCommand = {
10089
10112
  provenance: argv.provenance,
10090
10113
  skipAlreadyPublished: argv.skipAlreadyPublished,
10091
10114
  ...argv.group ? { group: argv.group } : {},
10115
+ ...argv.excludeGroup?.length ? { excludeGroups: argv.excludeGroup } : {},
10092
10116
  ...argv.tag ? { tag: argv.tag } : {},
10093
10117
  ...otp ? { otp } : {}
10094
10118
  })).status === "fail") process.exitCode = 1;