@marktiderman/genesis-cli 1.17.2 → 1.17.3

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
@@ -352,7 +352,18 @@ doesn't fit, is a warning.
352
352
  | Codemod | Runs when | Changes |
353
353
  | --- | --- | --- |
354
354
  | `genesis-core-2-scope-names` | genesis-core crosses 2.0.0 | Genesis API usage only, never an app's own names that match (a view field means one inside `defineView(…)` or an object typed `ViewDefinition`/`ViewField`; the prop means an attribute of `<NativeResourceView>` or a key of an object typed `NativeResourceViewProps`; each with the name imported from Genesis): a view field's `timeZone: "practice"` → `"scope"`, NativeResourceView's `practiceTimeZone` (attribute or object key) → `scopeTimeZone`, `resolveZone("practice", …)` → `"scope"`, and DisplayTimeZones' `practice` (a `{ viewer, practice }` object's key, `.practice` on a value from `useDisplayTimeZones()` or typed `DisplayTimeZones`) → `scope`. `scope={{ practiceId }}` needs nothing (it is the app's own key in ResourceScope's open slot); when a file reads `scope.practiceId` and nothing declares it, the codemod prints the one-line `ResourceScope` augmentation that types it. The doctor's `removed-scope-name` rule finds what it would rewrite. |
355
- 3. Reinstalls, then refreshes every file in `genesis.lock.json` from the newly installed package:
355
+ 3. Reinstalls. With pnpm, a release younger than the app's `minimumReleaseAge` is installed in
356
+ loose mode and pnpm pins it in `minimumReleaseAgeExclude`, in the pnpm-workspace.yaml pnpm reads (the nearest one at or above the app, else beside the lockfile)
357
+ (`'@marktiderman/genesis-ui@2.26.0'`). pnpm 11.1.3's frozen install honours only the first pinned
358
+ version of a package, so a second pin (this upgrade's next to an earlier one's, or two versions
359
+ of one package) fails `pnpm install --frozen-lockfile` in CI with
360
+ `ERR_PNPM_MINIMUM_RELEASE_AGE_VIOLATION`. The upgrade replaces every Genesis entry with one
361
+ pattern, `'@marktiderman/genesis-*'` (and the umbrella by its bare name), which both a resolving
362
+ and a frozen install honour on pnpm 11; every other entry, comment and line is left as it is,
363
+ since the list is the app's supply-chain guard. Then it runs `pnpm dedupe` (`npm dedupe` with
364
+ npm; bun and yarn are skipped), so a Genesis package isn't left installed at two versions
365
+ (`duplicate-genesis-package`), and commits pnpm-workspace.yaml with `--pr`.
366
+ Then it refreshes every file in `genesis.lock.json` from the newly installed package:
356
367
  unchanged in the app, it takes the new version; changed by both, it is merged with `git
357
368
  merge-file` against the old version (the base); a conflict goes to `<file>.genesis-next` and
358
369
  your file is kept. `--keep-mine` never merges: the new text goes to `.genesis-next`. A file you
package/dist/cli.js CHANGED
@@ -1952,18 +1952,21 @@ var init_versions = __esm({
1952
1952
  UMBRELLA_PACKAGE = "@marktiderman/genesis";
1953
1953
  }
1954
1954
  });
1955
- function detectPackageManager(root) {
1955
+ function findLockfile(root) {
1956
1956
  let dir = path28.resolve(root);
1957
1957
  for (; ; ) {
1958
- if (existsSync(path28.join(dir, "pnpm-lock.yaml"))) return "pnpm";
1959
- if (existsSync(path28.join(dir, "bun.lock")) || existsSync(path28.join(dir, "bun.lockb"))) return "bun";
1960
- if (existsSync(path28.join(dir, "yarn.lock"))) return "yarn";
1961
- if (existsSync(path28.join(dir, "package-lock.json"))) return "npm";
1958
+ if (existsSync(path28.join(dir, "pnpm-lock.yaml"))) return { pm: "pnpm", dir };
1959
+ if (existsSync(path28.join(dir, "bun.lock")) || existsSync(path28.join(dir, "bun.lockb"))) return { pm: "bun", dir };
1960
+ if (existsSync(path28.join(dir, "yarn.lock"))) return { pm: "yarn", dir };
1961
+ if (existsSync(path28.join(dir, "package-lock.json"))) return { pm: "npm", dir };
1962
1962
  const parent = path28.dirname(dir);
1963
- if (parent === dir) return "npm";
1963
+ if (parent === dir) return null;
1964
1964
  dir = parent;
1965
1965
  }
1966
1966
  }
1967
+ function detectPackageManager(root) {
1968
+ return findLockfile(root)?.pm ?? "npm";
1969
+ }
1967
1970
  function addCommand(pm, specs, dev = false) {
1968
1971
  const flag = dev ? ["-D"] : [];
1969
1972
  if (pm === "npm") return ["npm", "install", ...flag, ...specs];
@@ -1972,6 +1975,11 @@ function addCommand(pm, specs, dev = false) {
1972
1975
  function installCommand(pm) {
1973
1976
  return pm === "yarn" ? ["yarn", "install"] : [pm, "install"];
1974
1977
  }
1978
+ function dedupeCommand(pm) {
1979
+ if (pm === "pnpm") return ["pnpm", "dedupe"];
1980
+ if (pm === "npm") return ["npm", "dedupe"];
1981
+ return null;
1982
+ }
1975
1983
  function pinnedVersion(root, name) {
1976
1984
  const release = readReleaseManifest(root);
1977
1985
  const fromRelease = release?.packages[name] ?? (name === "@marktiderman/genesis" ? release?.version : void 0);
@@ -6254,7 +6262,71 @@ function bumpSummary(version, changes, skipped) {
6254
6262
  ...skipped.length ? ["", "Left alone:", "", ...skipped.map((s) => `- \`${s.name}\` ${s.spec} in ${s.file}: ${s.why}`)] : []
6255
6263
  ].join("\n");
6256
6264
  }
6257
- var UMBRELLA, GENESIS3, EXACT, PLAIN, SECTIONS;
6265
+ function excludeReplacement(entry) {
6266
+ if (entry === GENESIS_PATTERN) return GENESIS_PATTERN;
6267
+ const at = entry.startsWith("@") ? entry.indexOf("@", 1) : entry.indexOf("@");
6268
+ const name = at === -1 ? entry : entry.slice(0, at);
6269
+ if (!GENESIS3.test(name)) return null;
6270
+ return name === UMBRELLA ? UMBRELLA : GENESIS_PATTERN;
6271
+ }
6272
+ function unquoteScalar(raw) {
6273
+ const s = raw.trim();
6274
+ if (s.length >= 2 && s.startsWith("'") && s.endsWith("'")) return s.slice(1, -1).replace(/''/g, "'");
6275
+ if (s.length >= 2 && s.startsWith('"') && s.endsWith('"')) return s.slice(1, -1);
6276
+ return s;
6277
+ }
6278
+ function normaliseReleaseAgeExcludes(text) {
6279
+ const eol = text.includes("\r\n") ? "\r\n" : "\n";
6280
+ const lines = text.split(/\r?\n/);
6281
+ const key2 = /^minimumReleaseAgeExclude:(.*)$/;
6282
+ const start = lines.findIndex((l) => key2.test(l));
6283
+ if (start === -1) return text;
6284
+ const seen = /* @__PURE__ */ new Set();
6285
+ const out = lines.slice(0, start);
6286
+ const flow = /^(\s*)\[(.*)\](\s*(?:#.*)?)$/.exec(key2.exec(lines[start])[1]);
6287
+ if (flow) {
6288
+ const kept = [];
6289
+ for (const raw of flow[2].split(",").map((s) => s.trim()).filter(Boolean)) {
6290
+ const replacement = excludeReplacement(unquoteScalar(raw));
6291
+ if (replacement === null) kept.push(raw);
6292
+ else if (!seen.has(replacement)) {
6293
+ seen.add(replacement);
6294
+ kept.push(`'${replacement}'`);
6295
+ }
6296
+ }
6297
+ return [...out, `minimumReleaseAgeExclude:${flow[1]}[${kept.join(", ")}]${flow[3]}`, ...lines.slice(start + 1)].join(eol);
6298
+ }
6299
+ const item = /^(\s*-\s+)('(?:[^']|'')*'|"[^"]*"|[^#\s][^#]*?)(\s+#.*)?\s*$/;
6300
+ out.push(lines[start]);
6301
+ let i = start + 1;
6302
+ for (; i < lines.length; i++) {
6303
+ const m = item.exec(lines[i]);
6304
+ if (!m) {
6305
+ if (/^\s*(#.*)?$/.test(lines[i])) {
6306
+ out.push(lines[i]);
6307
+ continue;
6308
+ }
6309
+ break;
6310
+ }
6311
+ const replacement = excludeReplacement(unquoteScalar(m[2]));
6312
+ if (replacement === null) out.push(lines[i]);
6313
+ else if (!seen.has(replacement)) {
6314
+ seen.add(replacement);
6315
+ out.push(`${m[1]}'${replacement}'${m[3] ?? ""}`);
6316
+ }
6317
+ }
6318
+ return [...out, ...lines.slice(i)].join(eol);
6319
+ }
6320
+ function pnpmWorkspaceFile(start, fallback, fs2) {
6321
+ for (let dir = start; ; ) {
6322
+ const file = fs2.join(dir, "pnpm-workspace.yaml");
6323
+ if (fs2.exists(file)) return file;
6324
+ const parent = fs2.dirname(dir);
6325
+ if (parent === dir) return fs2.join(fallback, "pnpm-workspace.yaml");
6326
+ dir = parent;
6327
+ }
6328
+ }
6329
+ var UMBRELLA, GENESIS3, EXACT, PLAIN, SECTIONS, GENESIS_PATTERN;
6258
6330
  var init_bump_core = __esm({
6259
6331
  "src/upgrade/bump-core.mjs"() {
6260
6332
  UMBRELLA = "@marktiderman/genesis";
@@ -6262,6 +6334,7 @@ var init_bump_core = __esm({
6262
6334
  EXACT = /^(\^|~|=)?(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)$/;
6263
6335
  PLAIN = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;
6264
6336
  SECTIONS = ["dependencies", "devDependencies", "optionalDependencies"];
6337
+ GENESIS_PATTERN = "@marktiderman/genesis-*";
6265
6338
  }
6266
6339
  });
6267
6340
 
@@ -9002,6 +9075,21 @@ function npmLookup(cwd) {
9002
9075
  }
9003
9076
  };
9004
9077
  }
9078
+ function readText(file) {
9079
+ try {
9080
+ return readFileSync(file, "utf8");
9081
+ } catch {
9082
+ return null;
9083
+ }
9084
+ }
9085
+ function tidyReleaseAgeExcludes(file) {
9086
+ const before = readText(file);
9087
+ if (before === null) return false;
9088
+ const after = normaliseReleaseAgeExcludes(before);
9089
+ if (after === before) return false;
9090
+ writeFileSync(file, after);
9091
+ return true;
9092
+ }
9005
9093
  function packageJsons(root) {
9006
9094
  try {
9007
9095
  const out = execFileSync("git", ["ls-files", "-z", "--", ":(glob)**/package.json"], { cwd: root, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] });
@@ -9074,12 +9162,30 @@ async function runUpgrade(options) {
9074
9162
  for (const f of changed) files.add(f);
9075
9163
  }
9076
9164
  const pm = detectPackageManager(root);
9165
+ let tidiedExcludes = null;
9077
9166
  if (!options.dryRun && options.install !== false && bumped.size) {
9167
+ const workspaceFile = pm === "pnpm" ? pnpmWorkspaceFile(path28.resolve(root), findLockfile(root)?.dir ?? root, { exists: existsSync, join: path28.join, dirname: path28.dirname }) : null;
9168
+ const workspaceBefore = workspaceFile ? readText(workspaceFile) : null;
9169
+ const tidy = () => {
9170
+ if (!workspaceFile || !tidyReleaseAgeExcludes(workspaceFile)) return;
9171
+ tidiedExcludes = path28.relative(root, workspaceFile);
9172
+ log(`${tidiedExcludes}: minimumReleaseAgeExclude names Genesis packages by '${GENESIS_PATTERN}', not one entry per version`);
9173
+ };
9078
9174
  if (typeof options.install === "function") options.install(root);
9079
9175
  else {
9080
9176
  log(`install: ${shellLine(installCommand(pm))}`);
9081
9177
  run(root, installCommand(pm));
9082
9178
  }
9179
+ tidy();
9180
+ const dedupe = options.dedupe ?? (typeof options.install === "function" ? false : true);
9181
+ const dedupeArgv = dedupeCommand(pm);
9182
+ if (typeof dedupe === "function") dedupe(root);
9183
+ else if (dedupe && dedupeArgv) {
9184
+ log(`dedupe: ${shellLine(dedupeArgv)}`);
9185
+ run(root, dedupeArgv);
9186
+ }
9187
+ if (dedupe) tidy();
9188
+ if (workspaceFile && readText(workspaceFile) !== workspaceBefore) files.add(path28.relative(root, workspaceFile));
9083
9189
  }
9084
9190
  const added = [];
9085
9191
  const newMigrations = [];
@@ -9158,6 +9264,7 @@ async function runUpgrade(options) {
9158
9264
  if (next.size) lines.push("", "Review and delete these before merging (not committed by --pr):", "", ...[...next].map((n) => `- ${n}`));
9159
9265
  if (lock.substitutions && Object.keys(lock.substitutions).length) lines.push("", `Templates renamed with genesis.lock.json's substitutions: ${Object.entries(lock.substitutions).map(([a, b]) => `${a} \u2192 ${b}`).join(", ")}.`);
9160
9266
  if (newMigrations.length) lines.push("", "New package migrations (run `genesis migrate` to copy them):", "", ...newMigrations.map((m) => `- ${m}`));
9267
+ if (tidiedExcludes) lines.push("", `pnpm pinned the new Genesis versions in \`${tidiedExcludes}\`'s \`minimumReleaseAgeExclude\` (they are younger than \`minimumReleaseAge\`); those entries are now \`'${GENESIS_PATTERN}'\`, which \`pnpm install --frozen-lockfile\` honours. Other entries are as they were.`);
9161
9268
  if (warnings.length) lines.push("", "Warnings:", "", ...warnings.map((w) => `- ${w}`));
9162
9269
  lines.push("", `\`genesis doctor\` ${doctor === "not run" ? "was not run" : doctor} after the upgrade.`);
9163
9270
  const summary = lines.join("\n");