@sdxc/kit 2026.10.25 → 2026.10.27
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 +28 -15
- package/changelog.jsonl +58 -5
- package/dist/architecture/graph.d.ts +16 -3
- package/dist/architecture/graph.js +37 -19
- package/dist/architecture/layers.d.ts +10 -3
- package/dist/architecture/layers.js +38 -9
- package/dist/commands/destroy.d.ts +1 -1
- package/dist/commands/make.d.ts +5 -5
- package/dist/commands/make.js +11 -8
- package/dist/commands/scaffold.d.ts +1 -1
- package/dist/contract.d.ts +3 -3
- package/dist/doctor/checks.d.ts +2 -2
- package/dist/doctor/checks.js +14 -2
- package/dist/doctor/constant-names.d.ts +17 -0
- package/dist/doctor/constant-names.js +106 -0
- package/dist/doctor/dependencies.d.ts +3 -3
- package/dist/doctor/dependencies.js +3 -3
- package/dist/doctor/fan-out.d.ts +3 -2
- package/dist/doctor/fan-out.js +4 -3
- package/dist/doctor/fetch-param.d.ts +15 -0
- package/dist/doctor/fetch-param.js +37 -0
- package/dist/doctor/files.d.ts +2 -0
- package/dist/doctor/files.js +4 -0
- package/dist/doctor/local-const.d.ts +15 -0
- package/dist/doctor/local-const.js +54 -0
- package/dist/doctor/logger.d.ts +15 -0
- package/dist/doctor/logger.js +41 -0
- package/dist/doctor/orphans.d.ts +3 -3
- package/dist/doctor/orphans.js +33 -7
- package/dist/doctor/process-env.d.ts +15 -0
- package/dist/doctor/process-env.js +39 -0
- package/dist/doctor/project.js +17 -13
- package/dist/doctor/result-throws.d.ts +5 -4
- package/dist/doctor/result-throws.js +6 -5
- package/dist/doctor/source-rule.d.ts +35 -0
- package/dist/doctor/source-rule.js +52 -0
- package/dist/doctor/stack-imports.d.ts +15 -0
- package/dist/doctor/stack-imports.js +60 -0
- package/dist/doctor/syntax.d.ts +31 -0
- package/dist/doctor/syntax.js +56 -0
- package/dist/make/binding.d.ts +13 -8
- package/dist/make/binding.js +96 -64
- package/dist/make/from-model.js +2 -7
- package/dist/make/index.js +2 -7
- package/dist/package-manager.d.ts +6 -0
- package/dist/package-manager.js +25 -2
- package/dist/scaffold/index.js +2 -7
- package/dist/ui/commands.js +2 -5
- package/dist/ui/registry.d.ts +2 -2
- package/dist/upgrade/changelog.d.ts +2 -0
- package/dist/upgrade/changelog.js +2 -0
- package/dist/upgrade/project.d.ts +2 -2
- package/dist/upgrade/prompt.d.ts +3 -2
- package/dist/upgrade/prompt.js +43 -2
- package/package.json +3 -3
- package/stubs/scaffold.test-mcp.stub +5 -1
- package/templates/app/AGENTS.md +3 -1
- package/templates/app/app/commands/db/fresh.ts +20 -13
- package/templates/app/app/commands/db/migrate.ts +42 -32
- package/templates/app/app/http/controllers/api/openapi.test.ts +29 -0
- package/templates/app/app/http/controllers/api/openapi.tsx +8 -2
- package/templates/app/app/http/controllers/mcp.test.ts +16 -0
- package/templates/app/app/http/middleware/access.ts +6 -3
- package/templates/app/app/http/middleware/page.ts +3 -4
- package/templates/app/app/initializers/database.test.ts +6 -1
- package/templates/app/app/initializers/openapi.ts +5 -4
- package/templates/app/app/initializers/router.tsx +3 -4
- package/templates/app/app/test/cloudflare-workers.test.ts +27 -0
- package/templates/app/app/test/cloudflare-workers.ts +17 -4
- package/templates/app/app/test/database.ts +33 -0
- package/templates/app/app/test/mcp.ts +96 -0
- package/templates/app/resources/layouts/document.tsx +2 -3
package/dist/make/binding.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `sdxc make secret`, `make binding` and `make do`: edit `cloudflare.config.ts`, append
|
|
3
|
-
* `.env.example` for secrets, re-export a Durable Object from `bootstrap/worker.ts`, and
|
|
4
|
-
* `sdxc run typegen
|
|
3
|
+
* `.env.example` for secrets, re-export a Durable Object from `bootstrap/worker.ts`, and note
|
|
4
|
+
* `sdxc run typegen`, answering what changed for the project's `format` like every other kind.
|
|
5
5
|
*
|
|
6
6
|
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
7
|
* @copyright Sergio Xalambrí 2026
|
|
8
8
|
*/
|
|
9
9
|
import type { AnyCommandContext } from "@sdxc/cli";
|
|
10
10
|
import type { Result } from "@sdxc/result";
|
|
11
|
+
import type { Made } from "./index.js";
|
|
11
12
|
/** Binding kinds `make binding` accepts; `secret` also appends `.env.example`. */
|
|
12
13
|
export declare const BINDING_KINDS: readonly ["secret", "kv", "d1", "r2", "queue", "rateLimit", "sendEmail", "durableObject"];
|
|
13
14
|
/** One of {@link BINDING_KINDS}. */
|
|
@@ -16,27 +17,31 @@ export type BindingKind = (typeof BINDING_KINDS)[number];
|
|
|
16
17
|
export type DoRole = "model" | "service";
|
|
17
18
|
/** Context these makers need to print. */
|
|
18
19
|
export type BindingContext = Pick<AnyCommandContext, "stdout">;
|
|
19
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* Plans and optionally writes a `bindings.<kind>()` entry for `NAME`; `--force` replaces an
|
|
22
|
+
* existing declaration of `NAME` where it stands.
|
|
23
|
+
*/
|
|
20
24
|
export declare function makeBinding(ctx: BindingContext, root: string, input: {
|
|
21
25
|
kind: BindingKind;
|
|
22
26
|
name: string;
|
|
23
27
|
dryRun: boolean;
|
|
24
28
|
force: boolean;
|
|
25
|
-
}): Promise<Result<
|
|
29
|
+
}): Promise<Result<Made, Error>>;
|
|
26
30
|
/** `make secret NAME` — shorthand for `make binding secret NAME`. */
|
|
27
31
|
export declare function makeSecret(ctx: BindingContext, root: string, input: {
|
|
28
32
|
name: string;
|
|
29
33
|
dryRun: boolean;
|
|
30
34
|
force: boolean;
|
|
31
|
-
}): Promise<Result<
|
|
35
|
+
}): Promise<Result<Made, Error>>;
|
|
32
36
|
/**
|
|
33
37
|
* Writes a Durable Object class stub, re-exports it from `bootstrap/worker.ts`, and declares
|
|
34
|
-
* the binding plus `exports.durableObject` in `cloudflare.config.ts`.
|
|
38
|
+
* the binding plus `exports.durableObject` in `cloudflare.config.ts`. A name ending in `do`,
|
|
39
|
+
* in any case, gets the `DO` suffix once: `feed-do` and `FeedDO` both write `FeedDO`.
|
|
35
40
|
*/
|
|
36
|
-
export declare function makeDo(ctx: BindingContext, root: string,
|
|
41
|
+
export declare function makeDo(ctx: BindingContext, root: string, input: {
|
|
37
42
|
name: string;
|
|
38
43
|
role: DoRole;
|
|
39
44
|
binding?: string;
|
|
40
45
|
dryRun: boolean;
|
|
41
46
|
force: boolean;
|
|
42
|
-
}): Promise<Result<
|
|
47
|
+
}): Promise<Result<Made, Error>>;
|
package/dist/make/binding.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `sdxc make secret`, `make binding` and `make do`: edit `cloudflare.config.ts`, append
|
|
3
|
-
* `.env.example` for secrets, re-export a Durable Object from `bootstrap/worker.ts`, and
|
|
4
|
-
* `sdxc run typegen
|
|
3
|
+
* `.env.example` for secrets, re-export a Durable Object from `bootstrap/worker.ts`, and note
|
|
4
|
+
* `sdxc run typegen`, answering what changed for the project's `format` like every other kind.
|
|
5
5
|
*
|
|
6
6
|
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
7
|
* @copyright Sergio Xalambrí 2026
|
|
8
8
|
*/
|
|
9
|
-
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
9
|
+
import { mkdir, readFile, stat, writeFile } from "node:fs/promises";
|
|
10
10
|
import { dirname, join } from "node:path";
|
|
11
11
|
import { failure, isFailure, success, wrap } from "@sdxc/result";
|
|
12
12
|
import { addHeaderTags, headerTags, resolveAuthor } from "../author.js";
|
|
@@ -24,7 +24,16 @@ export const BINDING_KINDS = [
|
|
|
24
24
|
"sendEmail",
|
|
25
25
|
"durableObject",
|
|
26
26
|
];
|
|
27
|
-
/**
|
|
27
|
+
/** The entry point a Durable Object class is re-exported from, where Cloudflare finds it. */
|
|
28
|
+
const WORKER_FILE = "bootstrap/worker.ts";
|
|
29
|
+
/** The note every maker here ends with, since `env` is typed from the config it edited. */
|
|
30
|
+
const TYPEGEN_NOTE = "Next: sdxc run typegen\n";
|
|
31
|
+
/** What a dry run answers: nothing changed and nothing left to note. */
|
|
32
|
+
const NOTHING_MADE = { changed: [], notes: [] };
|
|
33
|
+
/**
|
|
34
|
+
* Plans and optionally writes a `bindings.<kind>()` entry for `NAME`; `--force` replaces an
|
|
35
|
+
* existing declaration of `NAME` where it stands.
|
|
36
|
+
*/
|
|
28
37
|
export async function makeBinding(ctx, root, input) {
|
|
29
38
|
let key = bindingKey(input.name);
|
|
30
39
|
if (isFailure(key))
|
|
@@ -36,7 +45,7 @@ export async function makeBinding(ctx, root, input) {
|
|
|
36
45
|
if (existing.has(key.data) && !input.force) {
|
|
37
46
|
return failure(new Error(`${key.data} is already declared in ${CONFIG_FILE}; pass --force to replace it`));
|
|
38
47
|
}
|
|
39
|
-
let bindingLine = bindingCall(input.kind, key.data);
|
|
48
|
+
let bindingLine = bindingCall(input.kind, key.data, config.data);
|
|
40
49
|
let afterConfig = insertEnvBinding(config.data, key.data, bindingLine);
|
|
41
50
|
if (isFailure(afterConfig))
|
|
42
51
|
return afterConfig;
|
|
@@ -60,16 +69,17 @@ export async function makeBinding(ctx, root, input) {
|
|
|
60
69
|
if (exampleEdit !== null) {
|
|
61
70
|
ctx.stdout(unifiedDiff(ENV_EXAMPLE_FILE, exampleEdit.before === "" ? null : exampleEdit.before, exampleEdit.after));
|
|
62
71
|
}
|
|
63
|
-
return success(
|
|
72
|
+
return success(NOTHING_MADE);
|
|
64
73
|
}
|
|
65
74
|
await writeFile(join(root, CONFIG_FILE), afterConfig.data);
|
|
66
|
-
ctx.stdout(`
|
|
75
|
+
ctx.stdout(`Edited ${CONFIG_FILE}\n`);
|
|
76
|
+
let changed = [CONFIG_FILE];
|
|
67
77
|
if (exampleEdit !== null) {
|
|
68
78
|
await writeFile(join(root, ENV_EXAMPLE_FILE), exampleEdit.after);
|
|
69
|
-
ctx.stdout(`
|
|
79
|
+
ctx.stdout(`Edited ${ENV_EXAMPLE_FILE}\n`);
|
|
80
|
+
changed.push(ENV_EXAMPLE_FILE);
|
|
70
81
|
}
|
|
71
|
-
|
|
72
|
-
return success(undefined);
|
|
82
|
+
return success({ changed, notes: [TYPEGEN_NOTE] });
|
|
73
83
|
}
|
|
74
84
|
/** `make secret NAME` — shorthand for `make binding secret NAME`. */
|
|
75
85
|
export async function makeSecret(ctx, root, input) {
|
|
@@ -77,18 +87,18 @@ export async function makeSecret(ctx, root, input) {
|
|
|
77
87
|
}
|
|
78
88
|
/**
|
|
79
89
|
* Writes a Durable Object class stub, re-exports it from `bootstrap/worker.ts`, and declares
|
|
80
|
-
* the binding plus `exports.durableObject` in `cloudflare.config.ts`.
|
|
90
|
+
* the binding plus `exports.durableObject` in `cloudflare.config.ts`. A name ending in `do`,
|
|
91
|
+
* in any case, gets the `DO` suffix once: `feed-do` and `FeedDO` both write `FeedDO`.
|
|
81
92
|
*/
|
|
82
|
-
export async function makeDo(ctx, root,
|
|
93
|
+
export async function makeDo(ctx, root, input) {
|
|
83
94
|
let parsed = parseName(input.name);
|
|
84
95
|
if (isFailure(parsed))
|
|
85
96
|
return parsed;
|
|
86
|
-
let
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
let
|
|
90
|
-
|
|
91
|
-
: success(snakeUpper(parsed.data.base.replace(/-?do$/, "") || parsed.data.base));
|
|
97
|
+
let stem = parseName(parsed.data.base.replace(/(.)-do$/, "$1"));
|
|
98
|
+
if (isFailure(stem))
|
|
99
|
+
return stem;
|
|
100
|
+
let className = `${stem.data.pascal}DO`;
|
|
101
|
+
let binding = input.binding !== undefined ? bindingKey(input.binding) : success(snakeUpper(stem.data.base));
|
|
92
102
|
if (isFailure(binding))
|
|
93
103
|
return binding;
|
|
94
104
|
let folder = input.role === "model" ? "app/models" : "app/services";
|
|
@@ -97,7 +107,7 @@ export async function makeDo(ctx, root, packageRoot, input) {
|
|
|
97
107
|
let config = await wrap(() => readFile(join(root, CONFIG_FILE), "utf8"));
|
|
98
108
|
if (isFailure(config))
|
|
99
109
|
return failure(new Error(`No ${CONFIG_FILE} in the project`));
|
|
100
|
-
let worker = await wrap(() => readFile(join(root,
|
|
110
|
+
let worker = await wrap(() => readFile(join(root, WORKER_FILE), "utf8"));
|
|
101
111
|
if (isFailure(worker))
|
|
102
112
|
return failure(new Error("No bootstrap/worker.ts in the project"));
|
|
103
113
|
let existing = declaredBindings(config.data);
|
|
@@ -114,9 +124,10 @@ export async function makeDo(ctx, root, packageRoot, input) {
|
|
|
114
124
|
if (input.dryRun) {
|
|
115
125
|
ctx.stdout(unifiedDiff(file, null, stub));
|
|
116
126
|
ctx.stdout(unifiedDiff(CONFIG_FILE, config.data, afterConfig.data));
|
|
117
|
-
ctx.stdout(unifiedDiff(
|
|
118
|
-
return success(
|
|
127
|
+
ctx.stdout(unifiedDiff(WORKER_FILE, worker.data, afterWorker));
|
|
128
|
+
return success(NOTHING_MADE);
|
|
119
129
|
}
|
|
130
|
+
let replaced = input.force && (await exists(join(root, file)));
|
|
120
131
|
await mkdir(dirname(join(root, file)), { recursive: true });
|
|
121
132
|
let written = await wrap(() => writeFile(join(root, file), stub, { flag: input.force ? "w" : "wx" }));
|
|
122
133
|
if (isFailure(written)) {
|
|
@@ -125,14 +136,20 @@ export async function makeDo(ctx, root, packageRoot, input) {
|
|
|
125
136
|
}
|
|
126
137
|
return written;
|
|
127
138
|
}
|
|
128
|
-
ctx.stdout(
|
|
139
|
+
ctx.stdout(`${replaced ? "Replaced" : "Wrote"} ${file}\n`);
|
|
129
140
|
await writeFile(join(root, CONFIG_FILE), afterConfig.data);
|
|
130
|
-
ctx.stdout(`
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
141
|
+
ctx.stdout(`Edited ${CONFIG_FILE}\n`);
|
|
142
|
+
let changed = [file, CONFIG_FILE];
|
|
143
|
+
if (afterWorker !== worker.data) {
|
|
144
|
+
await writeFile(join(root, WORKER_FILE), afterWorker);
|
|
145
|
+
ctx.stdout(`Edited ${WORKER_FILE}\n`);
|
|
146
|
+
changed.push(WORKER_FILE);
|
|
147
|
+
}
|
|
148
|
+
return success({ changed, notes: [TYPEGEN_NOTE] });
|
|
149
|
+
}
|
|
150
|
+
/** Whether `path` exists. */
|
|
151
|
+
async function exists(path) {
|
|
152
|
+
return !isFailure(await wrap(() => stat(path)));
|
|
136
153
|
}
|
|
137
154
|
/** `NAME` as an env binding key: already `SCREAMING_SNAKE` or derived from kebab/camel. */
|
|
138
155
|
function bindingKey(name) {
|
|
@@ -147,41 +164,60 @@ function bindingKey(name) {
|
|
|
147
164
|
function snakeUpper(kebab) {
|
|
148
165
|
return kebab.replaceAll("-", "_").toUpperCase();
|
|
149
166
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
167
|
+
/**
|
|
168
|
+
* The declaration `make binding` writes for `kind`. Named resources take the key in kebab case,
|
|
169
|
+
* after the Worker for a database or a queue, so a new binding never shares the template's; a
|
|
170
|
+
* rate limit takes the next namespace number `config` leaves free.
|
|
171
|
+
*/
|
|
172
|
+
function bindingCall(kind, key, config) {
|
|
173
|
+
let kebab = key.toLowerCase().replaceAll("_", "-");
|
|
174
|
+
switch (kind) {
|
|
175
|
+
case "secret":
|
|
176
|
+
case "sendEmail":
|
|
177
|
+
return `${key}: bindings.${kind}()`;
|
|
178
|
+
case "rateLimit":
|
|
179
|
+
return `${key}: bindings.rateLimit({ namespace: "${freeNamespace(config)}", simple: { limit: 100, period: 60 } })`;
|
|
180
|
+
case "kv":
|
|
181
|
+
return `${key}: bindings.kv({ id: "00000000000000000000000000000000" })`;
|
|
182
|
+
case "d1":
|
|
183
|
+
return `${key}: bindings.d1({ name: \`\${manifest.name}-${kebab}\`, id: "00000000-0000-4000-8000-000000000000" })`;
|
|
184
|
+
case "r2":
|
|
185
|
+
return `${key}: bindings.r2({ name: "${kebab}" })`;
|
|
186
|
+
case "queue":
|
|
187
|
+
return `${key}: bindings.queue({ name: \`\${manifest.name}-${kebab}\` })`;
|
|
188
|
+
default:
|
|
189
|
+
return `${key}: bindings.durableObject({ worker: manifest.name, exportName: "${pascalOf(kebab)}DO" })`;
|
|
163
190
|
}
|
|
164
|
-
if (kind === "r2")
|
|
165
|
-
return `${key}: bindings.r2({ name: "${key.toLowerCase()}" })`;
|
|
166
|
-
if (kind === "queue")
|
|
167
|
-
return `${key}: bindings.queue({ name: manifest.name })`;
|
|
168
|
-
return `${key}: bindings.durableObject({ worker: /* self */, exportName: "TODO" })`;
|
|
169
191
|
}
|
|
170
|
-
/**
|
|
192
|
+
/** One above the highest rate-limit namespace `config` declares, and `1001` when it declares none. */
|
|
193
|
+
function freeNamespace(config) {
|
|
194
|
+
let taken = [...config.matchAll(/namespace\s*:\s*"(\d+)"/g)].map((match) => Number(match[1]));
|
|
195
|
+
return Math.max(1000, ...taken) + 1;
|
|
196
|
+
}
|
|
197
|
+
/** `user-uploads` as `UserUploads`. */
|
|
198
|
+
function pascalOf(kebab) {
|
|
199
|
+
return kebab
|
|
200
|
+
.split("-")
|
|
201
|
+
.map((part) => `${part.charAt(0).toUpperCase()}${part.slice(1)}`)
|
|
202
|
+
.join("");
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Puts `line` into the Worker's `env: { … }` object: in place of an existing declaration of
|
|
206
|
+
* `key`, keeping its comment and position, or as the object's first entry.
|
|
207
|
+
*/
|
|
171
208
|
function insertEnvBinding(source, key, line) {
|
|
209
|
+
let declared = new RegExp(`^([ \\t]*)${key}\\s*:\\s*bindings\\.\\w+\\s*\\([^)]*\\)\\s*,?`, "m");
|
|
210
|
+
let existing = declared.exec(source);
|
|
211
|
+
if (existing !== null) {
|
|
212
|
+
let indent = existing[1] ?? "";
|
|
213
|
+
return success(`${source.slice(0, existing.index)}${indent}${line},${source.slice(existing.index + existing[0].length)}`);
|
|
214
|
+
}
|
|
172
215
|
let env = /env\s*:\s*\{/.exec(source);
|
|
173
|
-
if (env === null
|
|
216
|
+
if (env === null) {
|
|
174
217
|
return failure(new Error(`${CONFIG_FILE} has no env: { … } block to edit`));
|
|
175
218
|
}
|
|
176
219
|
let start = env.index + env[0].length;
|
|
177
|
-
|
|
178
|
-
let envAgain = /env\s*:\s*\{/.exec(stripped);
|
|
179
|
-
if (envAgain === null || envAgain.index === undefined) {
|
|
180
|
-
return failure(new Error(`${CONFIG_FILE} env block could not be re-found after cleanup`));
|
|
181
|
-
}
|
|
182
|
-
start = envAgain.index + envAgain[0].length;
|
|
183
|
-
let indent = "\t\t\t";
|
|
184
|
-
return success(`${stripped.slice(0, start)}\n${indent}${line},${stripped.slice(start)}`);
|
|
220
|
+
return success(`${source.slice(0, start)}\n\t\t\t${line},${source.slice(start)}`);
|
|
185
221
|
}
|
|
186
222
|
/** Declares the DO export and env binding in `cloudflare.config.ts`. */
|
|
187
223
|
function insertDurableObject(source, binding, className) {
|
|
@@ -217,20 +253,16 @@ function insertDurableObject(source, binding, className) {
|
|
|
217
253
|
/** Minimal Durable Object class stub; `@author` / `@copyright` are added by {@link makeDo}. */
|
|
218
254
|
function durableObjectStub(className) {
|
|
219
255
|
return `/**
|
|
220
|
-
* The ${className} Durable Object:
|
|
256
|
+
* The ${className} Durable Object: one instance per name, with storage of its own.
|
|
221
257
|
*/
|
|
222
258
|
|
|
223
259
|
import { DurableObject } from "cloudflare:workers";
|
|
224
260
|
|
|
225
261
|
/** Durable Object class re-exported from bootstrap/worker.ts for its binding. */
|
|
226
262
|
export class ${className} extends DurableObject<Cloudflare.Env> {
|
|
227
|
-
/**
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
* @param request - The inbound request.
|
|
231
|
-
*/
|
|
232
|
-
async fetch(request: Request): Promise<Response> {
|
|
233
|
-
return new Response("${className}", { status: 200 });
|
|
263
|
+
/** Answers every request a stub forwards with the class name, until the object serves its own. */
|
|
264
|
+
override fetch(): Response {
|
|
265
|
+
return new Response("${className}");
|
|
234
266
|
}
|
|
235
267
|
}
|
|
236
268
|
`;
|
package/dist/make/from-model.js
CHANGED
|
@@ -10,8 +10,7 @@ import { readdir, readFile, stat } from "node:fs/promises";
|
|
|
10
10
|
import { join } from "node:path";
|
|
11
11
|
import { pathToFileURL } from "node:url";
|
|
12
12
|
import { failure, isFailure, success, wrap } from "@sdxc/result";
|
|
13
|
-
import {
|
|
14
|
-
import { readManifest } from "../upgrade/project.js";
|
|
13
|
+
import { projectPackageManager } from "../package-manager.js";
|
|
15
14
|
import { KINDS } from "./kinds.js";
|
|
16
15
|
import { chainFolder } from "./migrations.js";
|
|
17
16
|
import { parseName } from "./names.js";
|
|
@@ -138,11 +137,7 @@ function isTableShape(value) {
|
|
|
138
137
|
}
|
|
139
138
|
/** `bun` for a project on Bun and `node` otherwise, as `sdxc run` decides. */
|
|
140
139
|
async function projectRuntime(root) {
|
|
141
|
-
let
|
|
142
|
-
let manager = await packageManager({
|
|
143
|
-
declared: isFailure(manifest) ? undefined : manifest.data.manifest.packageManager,
|
|
144
|
-
findLockFile: lockFileAtOrAbove(root),
|
|
145
|
-
});
|
|
140
|
+
let manager = await projectPackageManager(root);
|
|
146
141
|
return manager.name === "bun" ? "bun" : "node";
|
|
147
142
|
}
|
|
148
143
|
/** Every numbered SQL file of the chain at `folder`; a chain with no folder yet is empty. */
|
package/dist/make/index.js
CHANGED
|
@@ -15,9 +15,8 @@ import { failure, isFailure, success, wrap } from "@sdxc/result";
|
|
|
15
15
|
import { missingDependencies } from "../dependencies.js";
|
|
16
16
|
import { unifiedDiff } from "../diff.js";
|
|
17
17
|
import { formatFiles } from "../format.js";
|
|
18
|
-
import {
|
|
18
|
+
import { projectPackageManager } from "../package-manager.js";
|
|
19
19
|
import { columnSource, factorySource, parseFields, pluralize, resolveReferences, } from "../scaffold/fields.js";
|
|
20
|
-
import { readManifest } from "../upgrade/project.js";
|
|
21
20
|
import { declare, declaresAbilities, findRow } from "./declare.js";
|
|
22
21
|
import { planEmail } from "./email.js";
|
|
23
22
|
import { fieldMigration } from "./from-fields.js";
|
|
@@ -268,11 +267,7 @@ export async function makeUnformatted(ctx, project, packageRoot, input) {
|
|
|
268
267
|
ctx.stdout(`Edited ${edit.path}\n`);
|
|
269
268
|
}
|
|
270
269
|
if (dependencies.data !== null) {
|
|
271
|
-
let
|
|
272
|
-
let manager = await packageManager({
|
|
273
|
-
declared: isFailure(read) ? undefined : read.data.manifest.packageManager,
|
|
274
|
-
findLockFile: lockFileAtOrAbove(root),
|
|
275
|
-
});
|
|
270
|
+
let manager = await projectPackageManager(root);
|
|
276
271
|
let added = dependencies.data.added.map(({ name, version }) => `${name}@${version}`);
|
|
277
272
|
ctx.stdout(`Added ${added.join(", ")} to package.json; run ${manager.install.join(" ")}\n`);
|
|
278
273
|
}
|
|
@@ -29,6 +29,12 @@ export interface PackageManagerSources {
|
|
|
29
29
|
* lookup order, then the user agent, and npm when none of them names one it knows.
|
|
30
30
|
*/
|
|
31
31
|
export declare function packageManager(sources: PackageManagerSources): Promise<PackageManager>;
|
|
32
|
+
/**
|
|
33
|
+
* The package manager of the project at `root`: its `package.json` `packageManager` field, then
|
|
34
|
+
* the nearest lock file at or above it. Every command that prints an install reads it here, so
|
|
35
|
+
* they agree on the same project.
|
|
36
|
+
*/
|
|
37
|
+
export declare function projectPackageManager(root: string): Promise<PackageManager>;
|
|
32
38
|
/**
|
|
33
39
|
* Finds lock files in `root`, then in each directory above it, so a package inside a workspace
|
|
34
40
|
* takes the workspace's lock file and the nearest directory holding one decides.
|
package/dist/package-manager.js
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
7
|
* @copyright Sergio Xalambrí 2026
|
|
8
8
|
*/
|
|
9
|
-
import { stat } from "node:fs/promises";
|
|
9
|
+
import { readFile, stat } from "node:fs/promises";
|
|
10
10
|
import { dirname, join } from "node:path";
|
|
11
|
-
import { isSuccess, wrap } from "@sdxc/result";
|
|
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
14
|
bun: { name: "bun", install: ["bun", "install"], dlx: ["bunx"], run: ["bun", "run"] },
|
|
@@ -48,6 +48,29 @@ export async function packageManager(sources) {
|
|
|
48
48
|
return PACKAGE_MANAGERS[locked[1]];
|
|
49
49
|
return PACKAGE_MANAGERS[known(sources.userAgent?.split("/")[0]) ?? "npm"];
|
|
50
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* The package manager of the project at `root`: its `package.json` `packageManager` field, then
|
|
53
|
+
* the nearest lock file at or above it. Every command that prints an install reads it here, so
|
|
54
|
+
* they agree on the same project.
|
|
55
|
+
*/
|
|
56
|
+
export async function projectPackageManager(root) {
|
|
57
|
+
return packageManager({
|
|
58
|
+
declared: await declaredPackageManager(root),
|
|
59
|
+
findLockFile: lockFileAtOrAbove(root),
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
/** The `packageManager` field of the `package.json` at `root`, when it holds a string. */
|
|
63
|
+
async function declaredPackageManager(root) {
|
|
64
|
+
let text = await wrap(() => readFile(join(root, "package.json"), "utf8"));
|
|
65
|
+
if (isFailure(text))
|
|
66
|
+
return undefined;
|
|
67
|
+
let manifest = wrap(() => JSON.parse(text.data));
|
|
68
|
+
if (isFailure(manifest) || typeof manifest.data !== "object" || manifest.data === null) {
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
let declared = Reflect.get(manifest.data, "packageManager");
|
|
72
|
+
return typeof declared === "string" ? declared : undefined;
|
|
73
|
+
}
|
|
51
74
|
/**
|
|
52
75
|
* Finds lock files in `root`, then in each directory above it, so a package inside a workspace
|
|
53
76
|
* takes the workspace's lock file and the nearest directory holding one decides.
|
package/dist/scaffold/index.js
CHANGED
|
@@ -20,8 +20,7 @@ import { SCAFFOLD_PIECES } from "../make/kinds.js";
|
|
|
20
20
|
import { chainFolder, nextMigrationFile } from "../make/migrations.js";
|
|
21
21
|
import { parseName } from "../make/names.js";
|
|
22
22
|
import { loadStub, renderStub } from "../make/stubs.js";
|
|
23
|
-
import {
|
|
24
|
-
import { readManifest } from "../upgrade/project.js";
|
|
23
|
+
import { projectPackageManager } from "../package-manager.js";
|
|
25
24
|
import { parseFields, pluralize } from "./fields.js";
|
|
26
25
|
import { apiOperationNames, apiOperations, flagProperties, jsonProperties, localeBlock, placeholders, } from "./render.js";
|
|
27
26
|
/** The endpoints `--api` writes, in the order the contract declares them. */
|
|
@@ -148,11 +147,7 @@ export async function scaffold(ctx, project, packageRoot, input) {
|
|
|
148
147
|
ctx.stdout(`Edited ${edit.path}\n`);
|
|
149
148
|
}
|
|
150
149
|
if (dependencies.data !== null) {
|
|
151
|
-
let
|
|
152
|
-
let manager = await packageManager({
|
|
153
|
-
declared: isFailure(read) ? undefined : read.data.manifest.packageManager,
|
|
154
|
-
findLockFile: lockFileAtOrAbove(root),
|
|
155
|
-
});
|
|
150
|
+
let manager = await projectPackageManager(root);
|
|
156
151
|
let added = dependencies.data.added.map(({ name, version }) => `${name}@${version}`);
|
|
157
152
|
ctx.stdout(`Added ${added.join(", ")} to package.json; run ${manager.install.join(" ")}\n`);
|
|
158
153
|
}
|
package/dist/ui/commands.js
CHANGED
|
@@ -15,7 +15,7 @@ import { missingDependencies } from "../dependencies.js";
|
|
|
15
15
|
import { unifiedDiff } from "../diff.js";
|
|
16
16
|
import { formatFiles } from "../format.js";
|
|
17
17
|
import { readLock, removeUIEntry, renderLock, setUIEntry, uiEntries, uiEntry, writeLock, } from "../lock.js";
|
|
18
|
-
import {
|
|
18
|
+
import { projectPackageManager } from "../package-manager.js";
|
|
19
19
|
import { copyPath, pointAtCopies, pointBack, projectSources, readProjectFile } from "./imports.js";
|
|
20
20
|
import { readLayout } from "./layout.js";
|
|
21
21
|
import { readRegistry, withDependencies } from "./registry.js";
|
|
@@ -343,10 +343,7 @@ async function listImportedPackages(root, plan) {
|
|
|
343
343
|
if (edit.data === null)
|
|
344
344
|
return success(undefined);
|
|
345
345
|
plan.files.set(edit.data.path, { before: edit.data.before, after: edit.data.after });
|
|
346
|
-
let manager = await
|
|
347
|
-
declared: undefined,
|
|
348
|
-
findLockFile: lockFileAtOrAbove(root),
|
|
349
|
-
});
|
|
346
|
+
let manager = await projectPackageManager(root);
|
|
350
347
|
let added = edit.data.added.map(({ name, version }) => `${name}@${version}`).join(", ");
|
|
351
348
|
plan.report.push(`Added ${added} to package.json; run ${manager.install.join(" ")}`);
|
|
352
349
|
return success(undefined);
|
package/dist/ui/registry.d.ts
CHANGED
|
@@ -18,11 +18,11 @@ export declare const REGISTRY_ENTRY: s.Schema<{
|
|
|
18
18
|
path: string;
|
|
19
19
|
content: string;
|
|
20
20
|
};
|
|
21
|
-
exports: string[];
|
|
22
21
|
test: {
|
|
23
22
|
path: string;
|
|
24
23
|
content: string;
|
|
25
24
|
} | null;
|
|
25
|
+
exports: string[];
|
|
26
26
|
changedIn: string;
|
|
27
27
|
}, {
|
|
28
28
|
name: string;
|
|
@@ -31,11 +31,11 @@ export declare const REGISTRY_ENTRY: s.Schema<{
|
|
|
31
31
|
path: string;
|
|
32
32
|
content: string;
|
|
33
33
|
};
|
|
34
|
-
exports: string[];
|
|
35
34
|
test: {
|
|
36
35
|
path: string;
|
|
37
36
|
content: string;
|
|
38
37
|
} | null;
|
|
38
|
+
exports: string[];
|
|
39
39
|
changedIn: string;
|
|
40
40
|
}>;
|
|
41
41
|
/** A component as the installed release ships it. */
|
|
@@ -18,6 +18,7 @@ declare const ENTRY_SCHEMA: s.Schema<{
|
|
|
18
18
|
release: string;
|
|
19
19
|
package: string;
|
|
20
20
|
breaking: boolean;
|
|
21
|
+
correctedIn?: string | undefined;
|
|
21
22
|
}, {
|
|
22
23
|
type: string;
|
|
23
24
|
title: string;
|
|
@@ -25,6 +26,7 @@ declare const ENTRY_SCHEMA: s.Schema<{
|
|
|
25
26
|
release: string;
|
|
26
27
|
package: string;
|
|
27
28
|
breaking: boolean;
|
|
29
|
+
correctedIn?: string | undefined;
|
|
28
30
|
}>;
|
|
29
31
|
/** One commit's note as it applies to one package in one release. */
|
|
30
32
|
export type ChangelogEntry = s.InferOutput<typeof ENTRY_SCHEMA>;
|
|
@@ -22,6 +22,8 @@ const ENTRY_SCHEMA = s.object({
|
|
|
22
22
|
breaking: s.boolean(),
|
|
23
23
|
title: s.string(),
|
|
24
24
|
body: s.string(),
|
|
25
|
+
/** The release whose `Release-Note-For` correction replaced `body`; absent on an uncorrected note. */
|
|
26
|
+
correctedIn: s.optional(s.string()),
|
|
25
27
|
});
|
|
26
28
|
/**
|
|
27
29
|
* Every entry of the changelog in the `@sdxc/kit` package at `packageRoot`. A missing file, a line
|
|
@@ -12,15 +12,15 @@ declare const MANIFEST_SCHEMA: s.Schema<{
|
|
|
12
12
|
name?: string | undefined;
|
|
13
13
|
dependencies?: Record<string, string> | undefined;
|
|
14
14
|
devDependencies?: Record<string, string> | undefined;
|
|
15
|
-
optionalDependencies?: Record<string, string> | undefined;
|
|
16
15
|
packageManager?: string | undefined;
|
|
16
|
+
optionalDependencies?: Record<string, string> | undefined;
|
|
17
17
|
scripts?: Record<string, string> | undefined;
|
|
18
18
|
}, {
|
|
19
19
|
name?: string | undefined;
|
|
20
20
|
dependencies?: Record<string, string> | undefined;
|
|
21
21
|
devDependencies?: Record<string, string> | undefined;
|
|
22
|
-
optionalDependencies?: Record<string, string> | undefined;
|
|
23
22
|
packageManager?: string | undefined;
|
|
23
|
+
optionalDependencies?: Record<string, string> | undefined;
|
|
24
24
|
scripts?: Record<string, string> | undefined;
|
|
25
25
|
}>;
|
|
26
26
|
/** The project's `package.json` fields the upgrade reads. */
|
package/dist/upgrade/prompt.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The prompt `sdxc upgrade` hands an AI agent: the release notes of the packages the project
|
|
3
|
-
* imports, for every release it moved across, breaking changes first,
|
|
4
|
-
*
|
|
3
|
+
* imports, for every release it moved across, breaking changes first, then the corrections those
|
|
4
|
+
* releases made to notes it already had, the components to refresh, the commands that verify the
|
|
5
|
+
* edit, and where each package is documented.
|
|
5
6
|
*
|
|
6
7
|
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
8
|
* @copyright Sergio Xalambrí 2026
|
package/dist/upgrade/prompt.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The prompt `sdxc upgrade` hands an AI agent: the release notes of the packages the project
|
|
3
|
-
* imports, for every release it moved across, breaking changes first,
|
|
4
|
-
*
|
|
3
|
+
* imports, for every release it moved across, breaking changes first, then the corrections those
|
|
4
|
+
* releases made to notes it already had, the components to refresh, the commands that verify the
|
|
5
|
+
* edit, and where each package is documented.
|
|
5
6
|
*
|
|
6
7
|
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
8
|
* @copyright Sergio Xalambrí 2026
|
|
@@ -44,6 +45,7 @@ export function renderPrompt(input) {
|
|
|
44
45
|
let breaking = relevant.filter((entry) => entry.breaking);
|
|
45
46
|
let features = relevant.filter((entry) => !entry.breaking && entry.type === "feat");
|
|
46
47
|
let fixes = relevant.filter((entry) => !entry.breaking && FIX_TYPES.has(entry.type));
|
|
48
|
+
let corrected = correctedEntries(input);
|
|
47
49
|
let sections = [
|
|
48
50
|
[
|
|
49
51
|
from === input.to
|
|
@@ -68,6 +70,8 @@ export function renderPrompt(input) {
|
|
|
68
70
|
sections.push(entrySection("Features", features));
|
|
69
71
|
if (fixes.length > 0)
|
|
70
72
|
sections.push(entrySection("Fixes", fixes));
|
|
73
|
+
if (corrected.length > 0)
|
|
74
|
+
sections.push(correctedSection(corrected));
|
|
71
75
|
let older = olderReleases(input);
|
|
72
76
|
if (older !== null)
|
|
73
77
|
sections.push(older);
|
|
@@ -246,6 +250,43 @@ function earliestStart(input) {
|
|
|
246
250
|
}
|
|
247
251
|
return earliest;
|
|
248
252
|
}
|
|
253
|
+
/**
|
|
254
|
+
* The imported packages' notes from releases the project already had whose correction shipped
|
|
255
|
+
* in a release it moves across, so a changed migration step reaches a project past the original.
|
|
256
|
+
* Notes the prompt leaves to the GitHub Releases stay left out once corrected.
|
|
257
|
+
*/
|
|
258
|
+
function correctedEntries(input) {
|
|
259
|
+
let imported = new Set(input.packages);
|
|
260
|
+
let since = input.since ?? new Map();
|
|
261
|
+
return input.entries
|
|
262
|
+
.filter((entry) => {
|
|
263
|
+
let start = since.get(entry.package) ?? input.from;
|
|
264
|
+
return (entry.correctedIn !== undefined &&
|
|
265
|
+
imported.has(entry.package) &&
|
|
266
|
+
(entry.breaking || entry.type === "feat" || FIX_TYPES.has(entry.type)) &&
|
|
267
|
+
compare(entry.release, start) <= 0 &&
|
|
268
|
+
compare(entry.correctedIn, start) > 0 &&
|
|
269
|
+
compare(entry.correctedIn, input.to) <= 0);
|
|
270
|
+
})
|
|
271
|
+
.sort((a, b) => compare(a.release, b.release) || compareText(a.package, b.package));
|
|
272
|
+
}
|
|
273
|
+
/** The corrected notes, each naming the release it shipped in and the one that corrected it. */
|
|
274
|
+
function correctedSection(entries) {
|
|
275
|
+
let blocks = entries.map((entry) => {
|
|
276
|
+
let lines = [
|
|
277
|
+
`### ${entry.package}: ${entry.title}`,
|
|
278
|
+
`Released in ${entry.release}, corrected in ${entry.correctedIn}.`,
|
|
279
|
+
];
|
|
280
|
+
if (entry.body.trim() !== "")
|
|
281
|
+
lines.push(entry.body.trim());
|
|
282
|
+
return lines.join("\n\n");
|
|
283
|
+
});
|
|
284
|
+
return [
|
|
285
|
+
"## Corrected notes",
|
|
286
|
+
"These notes shipped in releases this project already had, and a later release replaced them. Check the code against each corrected note, and apply any migration step the original note left out or got wrong.",
|
|
287
|
+
...blocks,
|
|
288
|
+
].join("\n\n");
|
|
289
|
+
}
|
|
249
290
|
/** A heading and each entry under its own sub-heading with its full body. */
|
|
250
291
|
function entrySection(heading, entries) {
|
|
251
292
|
let blocks = entries.map((entry) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sdxc/kit",
|
|
3
|
-
"version": "2026.10.
|
|
3
|
+
"version": "2026.10.27",
|
|
4
4
|
"description": "The sdxc command line: start a Remix v3 app, generate its files, copy UI components into it and upgrade it",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"@sdxc/cli": "2026.10.24",
|
|
18
18
|
"@sdxc/codemod": "2026.10.23",
|
|
19
19
|
"@sdxc/cron": "2026.10.25",
|
|
20
|
-
"@sdxc/diagram": "2026.10.
|
|
20
|
+
"@sdxc/diagram": "2026.10.26",
|
|
21
21
|
"@sdxc/iife": "2026.10.23",
|
|
22
22
|
"@sdxc/json-schema": "2026.10.24",
|
|
23
23
|
"@sdxc/jsonc": "2026.10.16",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"remix": "3.1.0"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "33abc1099e147f3eb4af00cf5b25e50b8f1271a1",
|
|
33
33
|
"publishConfig": {
|
|
34
34
|
"access": "public"
|
|
35
35
|
},
|