@devdogsuga/devtools 0.1.45 → 0.1.46

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.
@@ -121,7 +121,7 @@ async function checkEnv(root) {
121
121
  "PLATFORM_SENTRY_DSN",
122
122
  "PUBLISHABLE_KEY",
123
123
  "SCHEDULE_BUILDER_SENTRY_DSN"
124
- ];
124
+ ].filter((key) => registry.has(key));
125
125
  if (JSON.stringify(build) !== JSON.stringify(expectedBuild)) problems.push(`The build set is [${build.join(", ")}]; expected exactly [${expectedBuild.join(", ")}]. A change here changes what the build workflows read from \`<tier>-build\`: update both deliberately.`);
126
126
  for (const key of build) if (!variableSet.has(key)) problems.push(`${key} is build: true but is not in variableKeys(), so push cannot write it to the build environment.`);
127
127
  }
@@ -223,6 +223,8 @@ function git$1(root, args) {
223
223
  function basenames(output) {
224
224
  return output.split("\n").map((line) => line.trim()).filter(Boolean).map((path) => path.split("/").at(-1));
225
225
  }
226
+ /** `baseRef` names nothing in the repo being checked. */
227
+ var MigrationBaseError = class extends Error {};
226
228
  /**
227
229
  * Reads the two file lists from git and runs the pure check.
228
230
  *
@@ -233,6 +235,16 @@ function basenames(output) {
233
235
  * an edit to an existing migration, both legitimate, does not trip this.
234
236
  */
235
237
  function checkMigrationOrder(root, baseRef) {
238
+ try {
239
+ git$1(root, [
240
+ "rev-parse",
241
+ "--verify",
242
+ "--quiet",
243
+ `${baseRef}^{commit}`
244
+ ]);
245
+ } catch {
246
+ throw new MigrationBaseError(`${baseRef} is not a commit in ${root}. Migrations live in DevDogsUGA, so the base is a ref of that checkout (a Backstage CI checkout has only the pinned commit): pass --base <ref>, e.g. the previous devdogsuga.lock SHA.`);
247
+ }
236
248
  const baseFiles = basenames(git$1(root, [
237
249
  "ls-tree",
238
250
  "-r",
@@ -379,6 +391,14 @@ function deployMatrixApps(yamlText) {
379
391
  }
380
392
  return blocks;
381
393
  }
394
+ /**
395
+ * Apps with a `wrangler.jsonc` that are deliberately NOT in `workers.json`:
396
+ * `workers.json` is the managed set (deploy matrix, smoke tests, env registry,
397
+ * secret orphan sweep), and these are deployed by hand and have none of that.
398
+ * `apps/slides` is the hosted workshop deck, shipped with `pnpm run deploy`
399
+ * from its own directory (its `wrangler.jsonc` says so).
400
+ */
401
+ const HAND_DEPLOYED_APPS = ["apps/slides"];
382
402
  function sameSet(a, b) {
383
403
  return a.length === b.length && a.every((item) => b.includes(item));
384
404
  }
@@ -409,7 +429,7 @@ function checkWorkers(root, layout = layoutAt(root)) {
409
429
  }))];
410
430
  const dirOf = (relative) => join(roots.find((dir) => existsSync(join(dir, relative))) ?? root, relative);
411
431
  const withWrangler = scanned.filter((relative) => existsSync(join(dirOf(relative), "wrangler.jsonc")));
412
- for (const path of withWrangler.filter((p) => !paths.includes(p))) problems.push(`${path} has a wrangler.jsonc but is not in workers.json.`);
432
+ for (const path of withWrangler.filter((p) => !paths.includes(p) && !HAND_DEPLOYED_APPS.includes(p))) problems.push(`${path} has a wrangler.jsonc but is not in workers.json.`);
413
433
  for (const path of paths.filter((p) => !withWrangler.includes(p))) problems.push(`workers.json lists ${path}, which has no wrangler.jsonc.`);
414
434
  for (const path of paths) {
415
435
  const manifest = join(dirOf(path), "package.json");
@@ -453,6 +473,13 @@ function checkWorkers(root, layout = layoutAt(root)) {
453
473
  * beside it and a Vitest `test` needs a `test:watch`.
454
474
  *
455
475
  * The root package also carries the CLI runners (`devtools`, `backstage`).
476
+ *
477
+ * A repo can allow a name outside the vocabulary, with a reason, in the root
478
+ * `package.json`: `"devdogs": { "scriptExceptions": { "<package>#<script>":
479
+ * "<why>" } }`, where `<package>` is the package's name (`root` for the root
480
+ * package). The exception also covers the script's `pre`/`post` hooks.
481
+ * Exceptions that match no script are themselves a problem, so the list
482
+ * cannot rot.
456
483
  */
457
484
  const FIXED = /* @__PURE__ */ new Set([
458
485
  "dev",
@@ -508,18 +535,29 @@ function isAllowedScript(name, isRoot = false) {
508
535
  return pre?.[2] !== void 0 && isAllowedName(pre[2]);
509
536
  }
510
537
  /** One readable line per violation. Empty means the vocabulary holds. */
511
- function checkScriptVocabulary(packages) {
538
+ function checkScriptVocabulary(packages, exceptions = {}) {
512
539
  const problems = [];
513
- for (const { dir, scripts } of packages) {
540
+ const used = /* @__PURE__ */ new Set();
541
+ for (const { dir, name: packageName, scripts } of packages) {
514
542
  const names = Object.keys(scripts);
543
+ const owner = dir === "." ? "root" : packageName;
515
544
  for (const name of names) {
516
545
  if (isAllowedScript(name, dir === ".")) continue;
546
+ const excepted = [name, /^(?:pre|post)(.+)$/.exec(name)?.[1]].find((candidate) => candidate && `${owner}#${candidate}` in exceptions);
547
+ if (excepted) {
548
+ used.add(`${owner}#${excepted}`);
549
+ continue;
550
+ }
517
551
  const replacement = BANNED[name];
518
552
  problems.push(`${dir}: script "${name}" is not in the vocabulary` + (replacement ? ` (${replacement}).` : "."));
519
553
  }
520
554
  if (names.includes("lint") && !names.includes("lint:fix")) problems.push(`${dir}: has "lint" but no "lint:fix".`);
521
555
  if (/\bvitest\b/.test(scripts.test ?? "") && !names.includes("test:watch")) problems.push(`${dir}: runs Vitest in "test" but has no "test:watch".`);
522
556
  }
557
+ for (const key of Object.keys(exceptions)) {
558
+ if (used.has(key)) continue;
559
+ if (!packages.some(({ dir, name, scripts }) => `${dir === "." ? "root" : name}#` === key.slice(0, key.indexOf("#") + 1) && key.slice(key.indexOf("#") + 1) in scripts)) problems.push(`scriptExceptions: "${key}" matches no script.`);
560
+ }
523
561
  return problems;
524
562
  }
525
563
  /** The root and every workspace package's scripts. */
@@ -537,8 +575,14 @@ function readScriptPackages(root) {
537
575
  const workspace = join(root, "pnpm-workspace.yaml");
538
576
  return [".", ...existsSync(workspace) ? expandWorkspacePackages(root, workspaceGlobs(readFileSync(workspace, "utf8"))) : []].map(read).filter((pkg) => pkg !== null);
539
577
  }
578
+ /** The root manifest's `devdogs.scriptExceptions`, empty when it has none. */
579
+ function readScriptExceptions(root) {
580
+ const file = join(root, "package.json");
581
+ if (!existsSync(file)) return {};
582
+ return JSON.parse(readFileSync(file, "utf8")).devdogs?.scriptExceptions ?? {};
583
+ }
540
584
  function checkScripts(root) {
541
- return checkScriptVocabulary(readScriptPackages(root));
585
+ return checkScriptVocabulary(readScriptPackages(root), readScriptExceptions(root));
542
586
  }
543
587
  //#endregion
544
588
  //#region src/check/commands.ts
@@ -561,7 +605,14 @@ function report(name, problems, ok) {
561
605
  }
562
606
  function migrations(rest) {
563
607
  const base = flagValue(rest, "--base") ?? DEFAULT_BASE;
564
- const { baseLatest, violations } = checkMigrationOrder(resolveLayout().devdogsugaRoot, base);
608
+ let result;
609
+ try {
610
+ result = checkMigrationOrder(resolveLayout().devdogsugaRoot, base);
611
+ } catch (error) {
612
+ if (!(error instanceof MigrationBaseError)) throw error;
613
+ return report("migrations", [error.message], "");
614
+ }
615
+ const { baseLatest, violations } = result;
565
616
  return report("migrations", violations.map((v) => `${v.filename} (${v.timestamp}) sorts before ${base}'s newest migration (${baseLatest}). Recreate it with a fresh timestamp (\`devtools new-migration\`) and regenerate types.`), `in order (${base}'s newest: ${baseLatest ?? "none"}).`);
566
617
  }
567
618
  async function run(rest) {
package/dist/launch.js CHANGED
@@ -166,7 +166,7 @@ async function startStack() {
166
166
  * post-tier-resolution path.
167
167
  */
168
168
  async function dispatch(argv) {
169
- const { main } = await import("./cli-B_AiECh4.js");
169
+ const { main } = await import("./cli-CTw2q3TP.js");
170
170
  try {
171
171
  await main(argv);
172
172
  } catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devdogsuga/devtools",
3
- "version": "0.1.45",
3
+ "version": "0.1.46",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Contributor CLI for a DevDogsUGA checkout: the real tools with the session's tier filled in, a menu over them, and the checks CI runs. Ships built JS; run via `pnpm dlx @devdogsuga/devtools` (or the `devtools` bin once installed) from inside a DevDogsUGA clone.",
@@ -51,11 +51,11 @@
51
51
  "eslint": "^9.39.5",
52
52
  "tsdown": "^0.23.0",
53
53
  "vitest": "^4.1.11",
54
- "@devdogsuga/cli-core": "0.0.0",
54
+ "@devdogsuga/config": "0.1.3",
55
+ "@devdogsuga/db": "0.1.5",
55
56
  "@devdogsuga/env": "0.1.8",
56
57
  "@devdogsuga/telemetry": "0.1.5",
57
- "@devdogsuga/db": "0.1.5",
58
- "@devdogsuga/config": "0.1.3"
58
+ "@devdogsuga/cli-core": "0.0.0"
59
59
  },
60
60
  "scripts": {
61
61
  "build": "tsdown && node scripts/write-build-info.mjs && node ../../scripts/check-bundle-imports.mjs",