@plexus-ms/cli 0.7.0 → 0.8.0

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.
Files changed (2) hide show
  1. package/dist/plx.js +23 -7
  2. package/package.json +2 -2
package/dist/plx.js CHANGED
@@ -7731,7 +7731,7 @@ async function exists(ctx, path3) {
7731
7731
 
7732
7732
  // ../lib/dist/changeset.js
7733
7733
  var import_yaml2 = __toESM(require_dist(), 1);
7734
- import { join as join3 } from "node:path";
7734
+ import { dirname, join as join3 } from "node:path";
7735
7735
 
7736
7736
  // ../lib/dist/io.js
7737
7737
  import { spawn } from "node:child_process";
@@ -7824,6 +7824,7 @@ function body(step) {
7824
7824
  // ../lib/dist/changeset.js
7825
7825
  var CHANGESET_DIR = ".changeset";
7826
7826
  var FIELDS = ["dependencies", "optionalDependencies", "peerDependencies"];
7827
+ var TEST_FILE = /\.test\.[cm]?[jt]sx?$|\/testing\//;
7827
7828
  function changesetPath(branch) {
7828
7829
  const slug = branch.replace(/^(renovate|dependabot)\//, "").replace(/[^a-z0-9]+/gi, "-").replace(/^-|-$/g, "").toLowerCase();
7829
7830
  return `${CHANGESET_DIR}/bot-${slug || "branch"}.md`;
@@ -7831,11 +7832,19 @@ function changesetPath(branch) {
7831
7832
  function planChangeset(input) {
7832
7833
  const path3 = changesetPath(input.branch);
7833
7834
  const changes = [];
7835
+ const sources = [];
7834
7836
  const releases = {};
7835
7837
  for (const diff of input.packages) {
7836
7838
  const { before, after } = diff;
7837
7839
  if (!before || !after?.name || after.private || input.ignore.includes(after.name))
7838
7840
  continue;
7841
+ const src = `${dirname(diff.path)}/src/`;
7842
+ for (const file of input.files ?? []) {
7843
+ if (!file.startsWith(src) || TEST_FILE.test(file))
7844
+ continue;
7845
+ sources.push({ package: after.name, file });
7846
+ releases[after.name] ??= "patch";
7847
+ }
7839
7848
  for (const field of FIELDS) {
7840
7849
  const names = /* @__PURE__ */ new Set([...Object.keys(before[field] ?? {}), ...Object.keys(after[field] ?? {})]);
7841
7850
  for (const dependency of [...names].sort()) {
@@ -7851,19 +7860,23 @@ function planChangeset(input) {
7851
7860
  }
7852
7861
  }
7853
7862
  const root = input.root;
7854
- if (changes.length === 0) {
7863
+ if (changes.length === 0 && sources.length === 0) {
7855
7864
  const remove = run("rm", ["-f", path3], root ? { cwd: root } : {});
7856
- return { path: path3, releases, changes, plan: input.exists ? [remove] : [] };
7865
+ return { path: path3, releases, changes, sources, plan: input.exists ? [remove] : [] };
7857
7866
  }
7858
7867
  const header = Object.entries(releases).sort(([a], [b]) => a.localeCompare(b)).map(([name, bump]) => `'${name}': ${bump}`);
7859
- const lines = [...new Set(changes.map(describeChange))].sort((a, b) => a.localeCompare(b));
7868
+ const described = [
7869
+ ...changes.map(describeChange),
7870
+ ...sources.map((s) => `Update the version pinned in \`${s.file}\``)
7871
+ ];
7872
+ const lines = [...new Set(described)].sort((a, b) => a.localeCompare(b));
7860
7873
  const content = `---
7861
7874
  ${header.join("\n")}
7862
7875
  ---
7863
7876
 
7864
7877
  ${lines.join("\n")}
7865
7878
  `;
7866
- return { path: path3, releases, changes, content, plan: [write(root ? join3(root, path3) : path3, content)] };
7879
+ return { path: path3, releases, changes, sources, content, plan: [write(root ? join3(root, path3) : path3, content)] };
7867
7880
  }
7868
7881
  function describeChange(c) {
7869
7882
  const peer = c.field === "peerDependencies" ? " (peer)" : "";
@@ -7936,6 +7949,7 @@ async function readChangeset(ctx, dir, base, branch) {
7936
7949
  catalogsBefore: parseCatalogs(await show("pnpm-workspace.yaml")),
7937
7950
  catalogsAfter: parseCatalogs(workspaceAfter),
7938
7951
  ignore,
7952
+ files: (await git2(["diff", "--name-only", mergeBase, "HEAD"])).split("\n").filter(Boolean),
7939
7953
  exists: entries.some((e) => !e.directory && `${CHANGESET_DIR}/${e.name}` === path3),
7940
7954
  root: dir
7941
7955
  });
@@ -8944,7 +8958,7 @@ async function preflightSelf(ctx, running) {
8944
8958
  return;
8945
8959
  }
8946
8960
  if (compareTrains(running, latest) < 0)
8947
- throw new Error(`plx ${running} is behind ${latest}, the newest release; update it first: mise cache clear && mise up npm:${SELF_PACKAGE}`);
8961
+ throw new Error(`plx ${running} is behind ${latest}, the newest release; update it first: mise up npm:${SELF_PACKAGE}`);
8948
8962
  }
8949
8963
 
8950
8964
  // ../lib/dist/ship.js
@@ -13915,7 +13929,9 @@ function register(program2) {
13915
13929
  // src/commands/changeset.ts
13916
13930
  import { resolve as resolve2 } from "node:path";
13917
13931
  function register2(program2) {
13918
- program2.command("changeset").description("write the changeset a dependency bump owes: a patch per package whose runtime dependencies moved").argument("[dir]", "a checkout of the package repo, on the bump branch", ".").option("--base <ref>", "the trunk the branch is diffed against, at the merge base", "origin/main").option("--branch <name>", "the branch name that names the file (default: the checked-out branch)").action(async (dir, opts, command) => {
13932
+ program2.command("changeset").description(
13933
+ "write the changeset a dependency bump owes: a patch per package whose runtime dependencies or shipped source moved"
13934
+ ).argument("[dir]", "a checkout of the package repo, on the bump branch", ".").option("--base <ref>", "the trunk the branch is diffed against, at the merge base", "origin/main").option("--branch <name>", "the branch name that names the file (default: the checked-out branch)").action(async (dir, opts, command) => {
13919
13935
  const ctx = contextOf2(command);
13920
13936
  const changeset = await readChangeset(ctx, resolve2(dir), opts.base, opts.branch);
13921
13937
  await ctx.apply(changeset.plan);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plexus-ms/cli",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "plx, the Plexus command-line tool: a single-script adapter over @plexus-ms/lib",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "type": "module",
@@ -24,7 +24,7 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "@inquirer/prompts": "^8.7.4",
27
- "@plexus-ms/lib": "0.7.0",
27
+ "@plexus-ms/lib": "0.8.0",
28
28
  "commander": "^15.0.0"
29
29
  },
30
30
  "devDependencies": {