@sdxc/kit 2026.10.30 → 2026.11.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.
Files changed (162) hide show
  1. package/README.md +59 -0
  2. package/changelog.jsonl +346 -0
  3. package/config.schema.json +14 -0
  4. package/dist/ci/install.d.ts +15 -0
  5. package/dist/ci/install.js +27 -0
  6. package/dist/ci/locate.d.ts +23 -0
  7. package/dist/ci/locate.js +43 -0
  8. package/dist/cli.js +5 -0
  9. package/dist/commands/ci/list.d.ts +16 -0
  10. package/dist/commands/ci/list.js +24 -0
  11. package/dist/commands/ci/run.d.ts +65 -0
  12. package/dist/commands/ci/run.js +36 -0
  13. package/dist/commands/ci/signoff.d.ts +15 -0
  14. package/dist/commands/ci/signoff.js +15 -0
  15. package/dist/commands/ci/verify.d.ts +17 -0
  16. package/dist/commands/ci/verify.js +15 -0
  17. package/dist/commands/create.js +3 -0
  18. package/dist/commands/pkg.d.ts +16 -0
  19. package/dist/commands/pkg.js +71 -0
  20. package/dist/commands/routes.d.ts +1 -1
  21. package/dist/config.d.ts +10 -4
  22. package/dist/config.js +8 -0
  23. package/dist/contract.d.ts +60 -1
  24. package/dist/contract.js +46 -0
  25. package/dist/create/workspace.d.ts +15 -0
  26. package/dist/create/workspace.js +42 -0
  27. package/dist/doctor/checks.js +4 -0
  28. package/dist/doctor/ci.d.ts +15 -0
  29. package/dist/doctor/ci.js +63 -0
  30. package/dist/doctor/translations.d.ts +19 -0
  31. package/dist/doctor/translations.js +144 -0
  32. package/dist/make/declare.js +32 -11
  33. package/dist/package-manager.d.ts +2 -0
  34. package/dist/package-manager.js +16 -2
  35. package/dist/pkg/catalog.d.ts +12 -0
  36. package/dist/pkg/catalog.js +153 -0
  37. package/dist/pkg/resolve.d.ts +67 -0
  38. package/dist/pkg/resolve.js +147 -0
  39. package/dist/upgrade/changelog.d.ts +2 -2
  40. package/dist/upgrade/project.d.ts +2 -2
  41. package/package.json +10 -8
  42. package/registry/ui/accordion.json +2 -2
  43. package/registry/ui/alert-dialog.json +2 -2
  44. package/registry/ui/alert.json +2 -2
  45. package/registry/ui/aspect-ratio.json +2 -2
  46. package/registry/ui/avatar.json +6 -3
  47. package/registry/ui/badge.json +2 -2
  48. package/registry/ui/banner.json +16 -0
  49. package/registry/ui/breadcrumbs.json +2 -2
  50. package/registry/ui/button.json +5 -3
  51. package/registry/ui/calendar.json +2 -2
  52. package/registry/ui/card.json +2 -2
  53. package/registry/ui/carousel.json +2 -2
  54. package/registry/ui/checkbox-group.json +2 -2
  55. package/registry/ui/checkbox.json +2 -2
  56. package/registry/ui/combobox.json +2 -2
  57. package/registry/ui/command.json +2 -2
  58. package/registry/ui/confirm.json +8 -4
  59. package/registry/ui/cta-group.json +2 -2
  60. package/registry/ui/date-field.json +2 -2
  61. package/registry/ui/date-picker.json +2 -2
  62. package/registry/ui/date-range-picker.json +2 -2
  63. package/registry/ui/description.json +2 -2
  64. package/registry/ui/dialog-dismiss.json +13 -0
  65. package/registry/ui/dialog.json +2 -2
  66. package/registry/ui/disclosure.json +2 -2
  67. package/registry/ui/drawer.json +2 -2
  68. package/registry/ui/field-error.json +2 -2
  69. package/registry/ui/form.json +2 -2
  70. package/registry/ui/group.json +2 -2
  71. package/registry/ui/header.json +2 -2
  72. package/registry/ui/heading-scope.json +2 -2
  73. package/registry/ui/heading.json +3 -3
  74. package/registry/ui/highlight.json +3 -3
  75. package/registry/ui/hover-card.json +2 -2
  76. package/registry/ui/image-placeholder.json +2 -2
  77. package/registry/ui/input.json +2 -2
  78. package/registry/ui/item.json +2 -2
  79. package/registry/ui/keyboard.json +2 -2
  80. package/registry/ui/label.json +2 -2
  81. package/registry/ui/link-button.json +5 -3
  82. package/registry/ui/link.json +2 -2
  83. package/registry/ui/listbox.json +2 -2
  84. package/registry/ui/menu.json +2 -2
  85. package/registry/ui/meter.json +2 -2
  86. package/registry/ui/modal.json +2 -2
  87. package/registry/ui/nav-link.json +2 -2
  88. package/registry/ui/navigation-menu.json +2 -2
  89. package/registry/ui/number-field.json +2 -2
  90. package/registry/ui/otp-field.json +2 -2
  91. package/registry/ui/overlay-arrow.json +2 -2
  92. package/registry/ui/pagination.json +2 -2
  93. package/registry/ui/popover.json +2 -2
  94. package/registry/ui/progress-bar.json +2 -2
  95. package/registry/ui/property-list.json +18 -0
  96. package/registry/ui/radio-group.json +2 -2
  97. package/registry/ui/range-calendar.json +2 -2
  98. package/registry/ui/relative-time.json +17 -0
  99. package/registry/ui/scroll-area.json +2 -2
  100. package/registry/ui/search-field.json +2 -2
  101. package/registry/ui/section.json +2 -2
  102. package/registry/ui/select.json +2 -2
  103. package/registry/ui/selection-indicator.json +2 -2
  104. package/registry/ui/sentinel-row.json +2 -2
  105. package/registry/ui/separator.json +2 -2
  106. package/registry/ui/shared-element.json +2 -2
  107. package/registry/ui/sheet.json +2 -2
  108. package/registry/ui/sidebar.json +2 -2
  109. package/registry/ui/slider.json +2 -2
  110. package/registry/ui/spinner.json +2 -2
  111. package/registry/ui/status-dot.json +16 -0
  112. package/registry/ui/switch.json +2 -2
  113. package/registry/ui/tabs.json +2 -2
  114. package/registry/ui/tag-group.json +2 -2
  115. package/registry/ui/text-field.json +7 -3
  116. package/registry/ui/text.json +2 -2
  117. package/registry/ui/textarea.json +2 -2
  118. package/registry/ui/time-field.json +2 -2
  119. package/registry/ui/timeline.json +16 -0
  120. package/registry/ui/toggle-button.json +2 -2
  121. package/registry/ui/tooltip.json +2 -2
  122. package/registry/ui/typeset.json +2 -2
  123. package/registry/ui/youtube-embed.json +2 -2
  124. package/stubs/scaffold.controller.index.stub +1 -1
  125. package/templates/app/.config/sdxc/ci.ts +26 -0
  126. package/templates/app/.github/workflows/ci.yml +46 -0
  127. package/templates/app/README.md +4 -0
  128. package/templates/app/package.json +1 -0
  129. package/templates/app/public/_headers +4 -0
  130. package/registry/ui/attachment.json +0 -15
  131. package/registry/ui/bubble.json +0 -13
  132. package/registry/ui/chart.json +0 -13
  133. package/registry/ui/color-area.json +0 -13
  134. package/registry/ui/color-field.json +0 -20
  135. package/registry/ui/color-picker.json +0 -17
  136. package/registry/ui/color-slider.json +0 -13
  137. package/registry/ui/color-swatch-picker.json +0 -15
  138. package/registry/ui/color-swatch.json +0 -13
  139. package/registry/ui/color-wheel.json +0 -13
  140. package/registry/ui/context-menu.json +0 -16
  141. package/registry/ui/drop-indicator.json +0 -13
  142. package/registry/ui/drop-zone.json +0 -13
  143. package/registry/ui/empty.json +0 -15
  144. package/registry/ui/feature.json +0 -18
  145. package/registry/ui/file-trigger.json +0 -13
  146. package/registry/ui/grid-list.json +0 -18
  147. package/registry/ui/logo-cloud.json +0 -16
  148. package/registry/ui/marker.json +0 -13
  149. package/registry/ui/marketing-header.json +0 -18
  150. package/registry/ui/marketing-section.json +0 -16
  151. package/registry/ui/menubar.json +0 -13
  152. package/registry/ui/message-scroller.json +0 -16
  153. package/registry/ui/message.json +0 -13
  154. package/registry/ui/resizable.json +0 -13
  155. package/registry/ui/shortcut-list.json +0 -18
  156. package/registry/ui/skeleton.json +0 -13
  157. package/registry/ui/split.json +0 -16
  158. package/registry/ui/stat-strip.json +0 -16
  159. package/registry/ui/table.json +0 -16
  160. package/registry/ui/toast.json +0 -16
  161. package/registry/ui/toolbar.json +0 -13
  162. package/registry/ui/tree.json +0 -18
package/dist/contract.js CHANGED
@@ -6,6 +6,7 @@
6
6
  * @author [Sergio Xalambrí](https://sergiodxa.com)
7
7
  * @copyright Sergio Xalambrí 2026
8
8
  */
9
+ import { LIST_FLAGS, RUN_FLAGS, SIGNOFF_FLAGS, VERIFY_FLAGS } from "@sdxc/ci/command-line";
9
10
  import { argument, command, commands, flag, prompt } from "@sdxc/cli";
10
11
  import * as s from "remix/data-schema";
11
12
  import { BUILTIN_TEMPLATES, DEFAULT_TEMPLATE } from "./create/templates.js";
@@ -79,6 +80,41 @@ const FORCE_FLAG = flag.boolean("force", {
79
80
  });
80
81
  /** Every command `sdxc` takes. */
81
82
  export const SDXC_COMMANDS = commands({
83
+ ci: commands({
84
+ description: "Run the project's CI script (.config/sdxc/ci.ts), and sign green commits off on GitHub",
85
+ flags: {
86
+ ...RUN_FLAGS,
87
+ install: flag.boolean("install", {
88
+ default: true,
89
+ description: "Skip the frozen-lockfile install a local run starts with",
90
+ }),
91
+ },
92
+ list: command({
93
+ description: "Print the steps and matrix entries a fully passing run takes, without running any",
94
+ flags: LIST_FLAGS,
95
+ examples: ["ci list", "ci list --runner remote --matrix Workspaces --json"],
96
+ }),
97
+ signoff: command({
98
+ description: "Post the signoff an earlier green run recorded for a commit already on GitHub",
99
+ arguments: {
100
+ sha: argument(s.string(), {
101
+ optional: true,
102
+ valueName: "sha",
103
+ description: "The commit; HEAD when left out",
104
+ }),
105
+ },
106
+ flags: SIGNOFF_FLAGS,
107
+ examples: ["ci signoff", "ci signoff 1d9090458"],
108
+ }),
109
+ verify: command({
110
+ description: "Exit 0 when a contributor signed the commit off, 1 when nobody did, 2 when GitHub cannot be reached",
111
+ arguments: {
112
+ sha: argument(s.string(), { valueName: "sha", description: "The commit to check" }),
113
+ },
114
+ flags: VERIFY_FLAGS,
115
+ examples: ['ci verify "$GITHUB_SHA" --wait 60s'],
116
+ }),
117
+ }),
82
118
  create: command({
83
119
  description: "Write a new project from a built-in template or a GitHub repository",
84
120
  arguments: {
@@ -574,6 +610,16 @@ export const SDXC_COMMANDS = commands({
574
610
  "routes --except-path /api,/mcp --sort pattern",
575
611
  ],
576
612
  }),
613
+ pkg: command({
614
+ description: "Run an @sdxc package's command line through bunx or npx; with no name, list them",
615
+ arguments: {
616
+ args: argument.rest({
617
+ valueName: "name",
618
+ description: "The package's name, then its command and arguments, passed through as typed",
619
+ }),
620
+ },
621
+ examples: ["pkg", "pkg uuid v7", "pkg jwt decode < token.txt", "pkg email-auth --help"],
622
+ }),
577
623
  run: command({
578
624
  description: "Run the project's own command line (run.entry, default bootstrap/cli.ts)",
579
625
  arguments: {
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Projects created inside a monorepo: a directory below a `package.json` that declares
3
+ * `workspaces` belongs to that repository, whose root owns CI. The template's CI script and
4
+ * GitHub workflows are left out there, so the repository's own CI stays the only one.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ import type { TemplateTree } from "./templates.js";
10
+ /** Template paths a repository root owns, left out of a project created inside a workspace. */
11
+ export declare const ROOT_OWNED_PATHS: readonly string[];
12
+ /** Whether a `package.json` above `directory` declares `workspaces`. */
13
+ export declare function insideWorkspace(directory: string): Promise<boolean>;
14
+ /** Removes every root-owned file and directory from `tree`. */
15
+ export declare function dropRootOwned(tree: TemplateTree): void;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Projects created inside a monorepo: a directory below a `package.json` that declares
3
+ * `workspaces` belongs to that repository, whose root owns CI. The template's CI script and
4
+ * GitHub workflows are left out there, so the repository's own CI stays the only one.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ import { readFile } from "node:fs/promises";
10
+ import { dirname, join } from "node:path";
11
+ import { isSuccess, wrap } from "@sdxc/result";
12
+ /** Template paths a repository root owns, left out of a project created inside a workspace. */
13
+ export const ROOT_OWNED_PATHS = [".config/sdxc/ci.ts", ".github/"];
14
+ /** Whether a `package.json` above `directory` declares `workspaces`. */
15
+ export async function insideWorkspace(directory) {
16
+ let current = dirname(directory);
17
+ while (true) {
18
+ let text = await wrap(() => readFile(join(current, "package.json"), "utf8"));
19
+ if (isSuccess(text)) {
20
+ let manifest = wrap(() => JSON.parse(text.data));
21
+ if (isSuccess(manifest) && typeof manifest.data === "object" && manifest.data !== null) {
22
+ if ("workspaces" in manifest.data)
23
+ return true;
24
+ }
25
+ }
26
+ let parent = dirname(current);
27
+ if (parent === current)
28
+ return false;
29
+ current = parent;
30
+ }
31
+ }
32
+ /** Removes every root-owned file and directory from `tree`. */
33
+ export function dropRootOwned(tree) {
34
+ /** Whether `path` is one of the root-owned paths or sits below one. */
35
+ let owned = (path) => ROOT_OWNED_PATHS.some((root) => (root.endsWith("/") ? path.startsWith(root) : path === root));
36
+ for (let path of tree.files.keys())
37
+ if (owned(path))
38
+ tree.files.delete(path);
39
+ for (let path of tree.directories)
40
+ if (owned(`${path}/`) || owned(path))
41
+ tree.directories.delete(path);
42
+ }
@@ -6,6 +6,7 @@
6
6
  * @author [Sergio Xalambrí](https://sergiodxa.com)
7
7
  * @copyright Sergio Xalambrí 2026
8
8
  */
9
+ import { ciCheck } from "./ci.js";
9
10
  import { complexityCheck } from "./complexity.js";
10
11
  import { constantNamesCheck } from "./constant-names.js";
11
12
  import { crapCheck } from "./crap.js";
@@ -33,6 +34,7 @@ import { resultThrowsCheck } from "./result-throws.js";
33
34
  import { routesCheck } from "./routes.js";
34
35
  import { stackImportsCheck } from "./stack-imports.js";
35
36
  import { testRatioCheck } from "./test-ratio.js";
37
+ import { translationsCheck } from "./translations.js";
36
38
  import { typegenCheck } from "./typegen.js";
37
39
  import { uiCheck } from "./ui.js";
38
40
  /**
@@ -46,11 +48,13 @@ export const CHECKS = [
46
48
  remixCheck,
47
49
  envCheck,
48
50
  typegenCheck,
51
+ ciCheck,
49
52
  migrationsCheck,
50
53
  layoutCheck,
51
54
  routesCheck,
52
55
  modelsCheck,
53
56
  emailsCheck,
57
+ translationsCheck,
54
58
  jsdocCheck,
55
59
  complexityCheck,
56
60
  moduleSizeCheck,
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The `ci` check: the project's CI script loads and gives every step a name of its own.
3
+ * `--only`, `--skip` and a CI host's job matrix address steps by name, so two steps sharing
4
+ * one would run, skip or fail together.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ import type { Check } from "./check.js";
10
+ /**
11
+ * Fails when the script cannot load or two steps share an address (a name, prefixed by its
12
+ * matrix entry inside a matrix); skips a project without a script. Steps are listed the way
13
+ * `sdxc ci list` lists them, so nothing runs.
14
+ */
15
+ export declare const ciCheck: Check;
@@ -0,0 +1,63 @@
1
+ /**
2
+ * The `ci` check: the project's CI script loads and gives every step a name of its own.
3
+ * `--only`, `--skip` and a CI host's job matrix address steps by name, so two steps sharing
4
+ * one would run, skip or fail together.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ import { stat } from "node:fs/promises";
10
+ import { join } from "node:path";
11
+ import { loadScript, runScript } from "@sdxc/ci";
12
+ import { isFailure, isSuccess, wrap } from "@sdxc/result";
13
+ import { passed, skipped } from "./check.js";
14
+ /**
15
+ * Fails when the script cannot load or two steps share an address (a name, prefixed by its
16
+ * matrix entry inside a matrix); skips a project without a script. Steps are listed the way
17
+ * `sdxc ci list` lists them, so nothing runs.
18
+ */
19
+ export const ciCheck = {
20
+ name: "ci",
21
+ async run(context) {
22
+ let path = context.config.ci.script;
23
+ let found = await wrap(() => stat(join(context.root, path)));
24
+ if (!isSuccess(found) || !found.data.isFile())
25
+ return skipped(`No CI script at ${path}`);
26
+ let loaded = await loadScript(join(context.root, path), context.root);
27
+ if (isFailure(loaded)) {
28
+ return {
29
+ status: "fail",
30
+ message: `${path} does not load as a CI script`,
31
+ findings: [loaded.error.message],
32
+ fix: "Default-export defineCI(async (ci) => { … }) from @sdxc/ci, and install @sdxc/ci",
33
+ };
34
+ }
35
+ let listed = await runScript(loaded.data, {
36
+ root: context.root,
37
+ dryRun: true,
38
+ runner: "local",
39
+ });
40
+ let duplicates = duplicateLabels(listed.steps.map((step) => step.label));
41
+ let errors = listed.errors.map((error) => `${error.where ?? "the script"} threw: ${error.message.split("\n")[0]}`);
42
+ if (errors.length > 0 || duplicates.length > 0) {
43
+ return {
44
+ status: "fail",
45
+ message: `${path} has steps --only and --skip cannot tell apart, or throws while listing`,
46
+ findings: [...duplicates.map((label) => `"${label}" names more than one step`), ...errors],
47
+ fix: "Give each step its own name, such as one including the workspace it checks",
48
+ };
49
+ }
50
+ return passed(`${path} loads, and each of its ${listed.steps.length} steps has its own name`);
51
+ },
52
+ };
53
+ /** Every label that occurs more than once, in first-seen order. */
54
+ function duplicateLabels(labels) {
55
+ let seen = new Set();
56
+ let repeated = new Set();
57
+ for (let label of labels) {
58
+ if (seen.has(label))
59
+ repeated.add(label);
60
+ seen.add(label);
61
+ }
62
+ return [...repeated];
63
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * The `translations` check: every bundle in `resources/locales/` is read statically, each message
3
+ * is parsed as MessageFormat 2, and every language's keys are compared with the default
4
+ * language's, so a typo or a forgotten key shows up before a reader sees the fallback.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ import type { Check } from "./check.js";
10
+ /** The folder an app keeps one bundle per language in. */
11
+ export declare const LOCALES_FOLDER = "resources/locales";
12
+ /** The language every other bundle is compared with, when the app ships it. */
13
+ export declare const DEFAULT_LOCALE = "en";
14
+ /**
15
+ * Fails on a message that does not parse as MessageFormat 2, which renders as its key at
16
+ * runtime, and warns on a key one language has and the default language lacks, or the other
17
+ * way round, since a missing key falls back to the default language's copy.
18
+ */
19
+ export declare const translationsCheck: Check;
@@ -0,0 +1,144 @@
1
+ /**
2
+ * The `translations` check: every bundle in `resources/locales/` is read statically, each message
3
+ * is parsed as MessageFormat 2, and every language's keys are compared with the default
4
+ * language's, so a typo or a forgotten key shows up before a reader sees the fallback.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ import { readFile } from "node:fs/promises";
10
+ import { join } from "node:path";
11
+ import * as JSONC from "@sdxc/jsonc";
12
+ import { parse } from "@sdxc/messageformat";
13
+ import { isFailure, wrap } from "@sdxc/result";
14
+ import { Project } from "../routes/modules.js";
15
+ import { passed, skipped } from "./check.js";
16
+ import { listFiles } from "./files.js";
17
+ /** The folder an app keeps one bundle per language in. */
18
+ export const LOCALES_FOLDER = "resources/locales";
19
+ /** The language every other bundle is compared with, when the app ships it. */
20
+ export const DEFAULT_LOCALE = "en";
21
+ /** A bundle file directly in the folder, named by its BCP 47 language tag. */
22
+ const BUNDLE_FILE = /^([a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*)\.(?:[cm]?[jt]s|json)$/;
23
+ /**
24
+ * Fails on a message that does not parse as MessageFormat 2, which renders as its key at
25
+ * runtime, and warns on a key one language has and the default language lacks, or the other
26
+ * way round, since a missing key falls back to the default language's copy.
27
+ */
28
+ export const translationsCheck = {
29
+ name: "translations",
30
+ async run(context) {
31
+ let bundles = await readBundles(context.root);
32
+ if (bundles.length === 0)
33
+ return skipped(`No locale bundles in ${LOCALES_FOLDER}`);
34
+ let reference = bundles.find((bundle) => bundle.locale === DEFAULT_LOCALE) ?? bundles[0];
35
+ if (reference === undefined)
36
+ return skipped(`No locale bundles in ${LOCALES_FOLDER}`);
37
+ let invalid = bundles.flatMap(invalidMessages);
38
+ let missing = [];
39
+ let extra = [];
40
+ for (let bundle of bundles) {
41
+ if (bundle === reference)
42
+ continue;
43
+ for (let key of reference.messages.keys()) {
44
+ if (!bundle.messages.has(key))
45
+ missing.push(`${bundle.path} lacks ${key}`);
46
+ }
47
+ for (let key of bundle.messages.keys()) {
48
+ if (!reference.messages.has(key)) {
49
+ extra.push(`${bundle.path} has ${key}, which ${reference.locale} lacks`);
50
+ }
51
+ }
52
+ }
53
+ if (invalid.length > 0) {
54
+ return {
55
+ status: "fail",
56
+ message: `${count(invalid.length, "message")} not valid MessageFormat 2`,
57
+ findings: [...invalid, ...missing, ...extra],
58
+ fix: "Correct each message's syntax; a literal {, } or \\ is escaped with a backslash",
59
+ };
60
+ }
61
+ if (missing.length > 0 || extra.length > 0) {
62
+ let problems = [
63
+ missing.length === 0 ? null : `${count(missing.length, "key")} missing from a translation`,
64
+ extra.length === 0 ? null : `${count(extra.length, "key")} only in a translation`,
65
+ ].filter((problem) => problem !== null);
66
+ return {
67
+ status: "warn",
68
+ message: `Found ${problems.join(" and ")}`,
69
+ findings: [...missing, ...extra],
70
+ fix: `Translate each missing key, and remove or rename each key ${reference.locale} does not have`,
71
+ };
72
+ }
73
+ return passed(`${count(bundles.length, "locale")} with ${count(reference.messages.size, "key")}, every message valid`);
74
+ },
75
+ };
76
+ /** `count` with `noun`, pluralized by an `s` past one. */
77
+ function count(amount, noun) {
78
+ return `${amount} ${noun}${amount === 1 ? "" : "s"}`;
79
+ }
80
+ /**
81
+ * Every bundle directly in {@link LOCALES_FOLDER}, sorted by path. A module's default export is
82
+ * evaluated without running it, following imported sub-bundles; a file that does not read
83
+ * becomes a bundle with no messages.
84
+ */
85
+ async function readBundles(root) {
86
+ let project = new Project(root);
87
+ let bundles = [];
88
+ for (let path of await listFiles(root, LOCALES_FOLDER)) {
89
+ let name = path.slice(LOCALES_FOLDER.length + 1);
90
+ let locale = BUNDLE_FILE.exec(name)?.[1];
91
+ if (locale === undefined)
92
+ continue;
93
+ let messages = new Map();
94
+ if (path.endsWith(".json")) {
95
+ let text = await wrap(() => readFile(join(root, path), "utf8"));
96
+ let parsed = isFailure(text) ? null : JSONC.parse(text.data);
97
+ if (parsed !== null && !isFailure(parsed))
98
+ flattenJSON(parsed.data, "", messages);
99
+ }
100
+ else {
101
+ let module = await project.load(path);
102
+ if (module !== null)
103
+ flattenValue(await project.exportValue(module, "default"), "", messages);
104
+ }
105
+ bundles.push({ locale, path, messages });
106
+ }
107
+ return bundles;
108
+ }
109
+ /** Adds each message under a statically evaluated bundle to `messages` by its dotted key. */
110
+ function flattenValue(value, prefix, messages) {
111
+ if (value.kind !== "map") {
112
+ if (prefix !== "")
113
+ messages.set(prefix, value.kind === "string" ? value.value : null);
114
+ return;
115
+ }
116
+ for (let [key, entry] of value.entries) {
117
+ flattenValue(entry, prefix === "" ? key : `${prefix}.${key}`, messages);
118
+ }
119
+ }
120
+ /** Adds each message under a parsed JSON bundle to `messages` by its dotted key. */
121
+ function flattenJSON(value, prefix, messages) {
122
+ if (value === null || typeof value !== "object" || Array.isArray(value)) {
123
+ if (prefix !== "")
124
+ messages.set(prefix, typeof value === "string" ? value : null);
125
+ return;
126
+ }
127
+ for (let [key, entry] of Object.entries(value)) {
128
+ flattenJSON(entry, prefix === "" ? key : `${prefix}.${key}`, messages);
129
+ }
130
+ }
131
+ /** Each message in `bundle` that does not parse, with the parser's reason and offset. */
132
+ function invalidMessages(bundle) {
133
+ let found = [];
134
+ for (let [key, source] of bundle.messages) {
135
+ if (source === null)
136
+ continue;
137
+ let result = parse(source);
138
+ if (!isFailure(result))
139
+ continue;
140
+ let at = result.error.start === undefined ? "" : ` at ${result.error.start}`;
141
+ found.push(`${bundle.path} ${key}: ${result.error.type}${at} (${result.error.message})`);
142
+ }
143
+ return found;
144
+ }
@@ -12,6 +12,7 @@
12
12
  import { readdir, readFile } from "node:fs/promises";
13
13
  import { dirname, join, posix } from "node:path";
14
14
  import { addElement, addProperty, findModuleReferences, insertAfterLast } from "@sdxc/codemod";
15
+ import { iife } from "@sdxc/iife";
15
16
  import { failure, isFailure, isSuccess, success, wrap } from "@sdxc/result";
16
17
  import { literal, memberAccess } from "./generate.js";
17
18
  import { ensureImport, ensureTypeImport, resolvesTo, specifierFor } from "./imports.js";
@@ -194,13 +195,19 @@ async function declareController(request, root) {
194
195
  return { kind: "edits", path: path.join("."), edits };
195
196
  }
196
197
  /**
197
- * The sitemap decision a new page starts with: listed, or an empty list of pages when its pattern
198
- * has required params, so it is in the sitemap until the developer changes it. A `form` route
199
- * decides its page under `index`.
198
+ * The sitemap decision a new page starts with: listed, an empty list of pages when its pattern
199
+ * has required params, or left out when its last segment names a file (`/robots.txt`), which
200
+ * serves a document a crawler reads by name. A `form` route decides its page under `index`.
200
201
  */
201
202
  function sitemapDecision(helper, pattern) {
202
- let required = /[:*][A-Za-z_$]/.test(pattern.replace(/\([^)]*\)/g, ""));
203
- let page = required ? "[]" : "true";
203
+ let path = pattern.replace(/\([^)]*\)/g, "");
204
+ let required = /[:*][A-Za-z_$]/.test(path);
205
+ let file = /\.[A-Za-z0-9]+$/.test(path);
206
+ let page = iife(() => {
207
+ if (file)
208
+ return "false";
209
+ return required ? "[]" : "true";
210
+ });
204
211
  return helper === "form" ? `{ index: ${page} }` : page;
205
212
  }
206
213
  /**
@@ -744,9 +751,9 @@ function mapAfter(file, module, local, statement, call, factory) {
744
751
  return success(inserted.data.source);
745
752
  }
746
753
  /**
747
- * The initializer in `app/initializers/` that imports `module` and calls `factory`, else the
748
- * first that imports it, else (unless `importing` is required) one that calls `factory`; `null`
749
- * when none does. Test files are skipped.
754
+ * The initializer in `app/initializers/` that imports `module` and calls `factory`, else one that
755
+ * maps `module`'s entries, else the first that imports it, else (unless `importing` is required)
756
+ * one that calls `factory`; `null` when none does. Test files are skipped.
750
757
  */
751
758
  async function findInitializer(root, module, factory, importing = "preferred") {
752
759
  let folder = "app/initializers";
@@ -764,9 +771,11 @@ async function findInitializer(root, module, factory, importing = "preferred") {
764
771
  let aliased = await declaresAlias(root);
765
772
  for (let file of files)
766
773
  file.aliased = aliased;
767
- let calling = factory === null ? null : new RegExp(`\\b${factory}\\(`);
774
+ let calling = factory === null ? null : new RegExp(`\\b${callOf(factory)}`);
768
775
  let importers = files.filter((file) => file.references.some((reference) => reference.kind === "import" && resolvesTo(reference.specifier, file.path, module)));
769
- let found = importers.find((file) => calling?.test(file.source) ?? true) ?? importers[0];
776
+ let found = importers.find((file) => calling?.test(file.source) ?? true) ??
777
+ importers.find((file) => mapsFrom(file, module)) ??
778
+ importers[0];
770
779
  if (found !== undefined)
771
780
  return found;
772
781
  if (calling === null || importing === "required")
@@ -794,9 +803,21 @@ async function readSource(root, path) {
794
803
  }
795
804
  /** The variable the instance `factory` creates is bound to, such as `dispatcher` or `router`. */
796
805
  function instanceOf(file, factory) {
797
- let match = new RegExp(`(?:const|let|var)\\s+([A-Za-z_$][\\w$]*)\\s*=\\s*${factory}\\(`).exec(file.source);
806
+ let match = new RegExp(`(?:const|let|var)\\s+([A-Za-z_$][\\w$]*)\\s*=\\s*${callOf(factory)}`).exec(file.source);
798
807
  return match?.[1] ?? INSTANCE_NAMES[factory] ?? "dispatcher";
799
808
  }
809
+ /**
810
+ * The pattern of a call to `factory`, with or without type arguments, so a typed
811
+ * `createRouter<AppContext>(…)` is found like a plain `createRouter(…)`.
812
+ */
813
+ function callOf(factory) {
814
+ return `${factory}\\s*(?:<[^()]*>)?\\s*\\(`;
815
+ }
816
+ /** Whether `file` passes an entry of `module`'s default export to a `.map(…)` call. */
817
+ function mapsFrom(file, module) {
818
+ let local = defaultLocal(file, module);
819
+ return local !== null && new RegExp(`\\.map\\(\\s*${local}\\.`).test(file.source);
820
+ }
800
821
  /** The local name `file` binds the default export of `module` to, or `null`. */
801
822
  function defaultLocal(file, module) {
802
823
  for (let reference of file.references) {
@@ -10,6 +10,8 @@
10
10
  export interface PackageManager {
11
11
  name: "bun" | "npm" | "pnpm" | "yarn";
12
12
  install: string[];
13
+ /** Installs exactly what the lock file pins, failing when it is out of date with a manifest. */
14
+ frozenInstall: string[];
13
15
  /** The command prefix that downloads a package and runs its binary, the package spec appended. */
14
16
  dlx: string[];
15
17
  /** The command prefix that runs a `package.json` script. */
@@ -11,17 +11,31 @@ import { dirname, join } from "node:path";
11
11
  import { isFailure, isSuccess, wrap } from "@sdxc/result";
12
12
  /** The package managers by name, with the commands each one spells. */
13
13
  const PACKAGE_MANAGERS = {
14
- bun: { name: "bun", install: ["bun", "install"], dlx: ["bunx"], run: ["bun", "run"] },
15
- npm: { name: "npm", install: ["npm", "install"], dlx: ["npx", "--yes"], run: ["npm", "run"] },
14
+ bun: {
15
+ name: "bun",
16
+ install: ["bun", "install"],
17
+ frozenInstall: ["bun", "install", "--frozen-lockfile"],
18
+ dlx: ["bunx"],
19
+ run: ["bun", "run"],
20
+ },
21
+ npm: {
22
+ name: "npm",
23
+ install: ["npm", "install"],
24
+ frozenInstall: ["npm", "ci"],
25
+ dlx: ["npx", "--yes"],
26
+ run: ["npm", "run"],
27
+ },
16
28
  pnpm: {
17
29
  name: "pnpm",
18
30
  install: ["pnpm", "install"],
31
+ frozenInstall: ["pnpm", "install", "--frozen-lockfile"],
19
32
  dlx: ["pnpm", "dlx"],
20
33
  run: ["pnpm", "run"],
21
34
  },
22
35
  yarn: {
23
36
  name: "yarn",
24
37
  install: ["yarn", "install"],
38
+ frozenInstall: ["yarn", "install", "--immutable"],
25
39
  dlx: ["yarn", "dlx"],
26
40
  run: ["yarn", "run"],
27
41
  },
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The `@sdxc` packages `sdxc pkg` knows by name: those with a command line, each with what it
3
+ * does for `sdxc pkg --help`, and those without one, so a request for one gets an answer
4
+ * naming where to ask for it. A repository test holds both lists to the published packages.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ /** Every package with a command line, by name, with what its command line does. */
10
+ export declare const PACKAGE_COMMAND_LINES: Readonly<Record<string, string>>;
11
+ /** Every published package without a command line yet. */
12
+ export declare const PACKAGES_WITHOUT_COMMAND_LINES: readonly string[];