@sdxc/kit 0.0.0-pre.1
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/LICENSE.md +21 -0
- package/README.md +93 -0
- package/config.schema.json +89 -0
- package/dist/bin.d.ts +9 -0
- package/dist/bin.js +10 -0
- package/dist/cli.d.ts +33 -0
- package/dist/cli.js +58 -0
- package/dist/commands/create.d.ts +20 -0
- package/dist/commands/create.js +164 -0
- package/dist/commands/init.d.ts +16 -0
- package/dist/commands/init.js +27 -0
- package/dist/commands/make.d.ts +335 -0
- package/dist/commands/make.js +152 -0
- package/dist/commands/run.d.ts +23 -0
- package/dist/commands/run.js +51 -0
- package/dist/commands/ui/add.d.ts +23 -0
- package/dist/commands/ui/add.js +50 -0
- package/dist/commands/ui/diff.d.ts +20 -0
- package/dist/commands/ui/diff.js +28 -0
- package/dist/commands/ui/list.d.ts +24 -0
- package/dist/commands/ui/list.js +45 -0
- package/dist/commands/ui/remove.d.ts +22 -0
- package/dist/commands/ui/remove.js +48 -0
- package/dist/commands/ui/update.d.ts +23 -0
- package/dist/commands/ui/update.js +37 -0
- package/dist/commands/upgrade.d.ts +30 -0
- package/dist/commands/upgrade.js +184 -0
- package/dist/config.d.ts +81 -0
- package/dist/config.js +157 -0
- package/dist/contract.d.ts +161 -0
- package/dist/contract.js +308 -0
- package/dist/create/github.d.ts +63 -0
- package/dist/create/github.js +172 -0
- package/dist/create/target.d.ts +31 -0
- package/dist/create/target.js +56 -0
- package/dist/create/templates.d.ts +62 -0
- package/dist/create/templates.js +228 -0
- package/dist/dependencies.d.ts +34 -0
- package/dist/dependencies.js +76 -0
- package/dist/diff.d.ts +14 -0
- package/dist/diff.js +103 -0
- package/dist/format.d.ts +21 -0
- package/dist/format.js +40 -0
- package/dist/init.d.ts +38 -0
- package/dist/init.js +92 -0
- package/dist/lock.d.ts +74 -0
- package/dist/lock.js +214 -0
- package/dist/make/declare.d.ts +54 -0
- package/dist/make/declare.js +495 -0
- package/dist/make/generate.d.ts +56 -0
- package/dist/make/generate.js +139 -0
- package/dist/make/imports.d.ts +43 -0
- package/dist/make/imports.js +104 -0
- package/dist/make/index.d.ts +43 -0
- package/dist/make/index.js +136 -0
- package/dist/make/kinds.d.ts +39 -0
- package/dist/make/kinds.js +95 -0
- package/dist/make/migrations.d.ts +21 -0
- package/dist/make/migrations.js +48 -0
- package/dist/make/names.d.ts +31 -0
- package/dist/make/names.js +47 -0
- package/dist/make/stubs.d.ts +44 -0
- package/dist/make/stubs.js +89 -0
- package/dist/middleware.d.ts +44 -0
- package/dist/middleware.js +49 -0
- package/dist/package-manager.d.ts +41 -0
- package/dist/package-manager.js +80 -0
- package/dist/project.d.ts +19 -0
- package/dist/project.js +42 -0
- package/dist/releases.d.ts +40 -0
- package/dist/releases.js +110 -0
- package/dist/testing.d.ts +47 -0
- package/dist/testing.js +126 -0
- package/dist/ui/commands.d.ts +114 -0
- package/dist/ui/commands.js +432 -0
- package/dist/ui/imports.d.ts +46 -0
- package/dist/ui/imports.js +160 -0
- package/dist/ui/layout.d.ts +48 -0
- package/dist/ui/layout.js +138 -0
- package/dist/ui/registry.d.ts +58 -0
- package/dist/ui/registry.js +82 -0
- package/dist/upgrade/changelog.d.ts +50 -0
- package/dist/upgrade/changelog.js +69 -0
- package/dist/upgrade/project.d.ts +62 -0
- package/dist/upgrade/project.js +132 -0
- package/dist/upgrade/prompt.d.ts +51 -0
- package/dist/upgrade/prompt.js +227 -0
- package/dist/upgrade/registry.d.ts +33 -0
- package/dist/upgrade/registry.js +50 -0
- package/lock.schema.json +60 -0
- package/package.json +45 -0
- package/stubs/command.stub +12 -0
- package/stubs/command.test.stub +18 -0
- package/stubs/controller.form.stub +33 -0
- package/stubs/controller.stub +17 -0
- package/stubs/controller.test.stub +15 -0
- package/stubs/email.stub +44 -0
- package/stubs/email.test.stub +16 -0
- package/stubs/factory.stub +10 -0
- package/stubs/initializer.stub +7 -0
- package/stubs/initializer.test.stub +13 -0
- package/stubs/job.cron.stub +12 -0
- package/stubs/job.stub +11 -0
- package/stubs/job.test.stub +15 -0
- package/stubs/mcp.resource.stub +12 -0
- package/stubs/mcp.stub +10 -0
- package/stubs/mcp.test.stub +15 -0
- package/stubs/middleware.stub +11 -0
- package/stubs/middleware.test.stub +13 -0
- package/stubs/migration.stub +1 -0
- package/stubs/model.stub +24 -0
- package/stubs/model.test.stub +15 -0
- package/stubs/policy.stub +13 -0
- package/stubs/policy.test.stub +17 -0
- package/stubs/service.stub +13 -0
- package/stubs/service.test.stub +14 -0
- package/stubs/validator.stub +14 -0
- package/stubs/validator.test.stub +22 -0
- package/templates/app/README.md +57 -0
- package/templates/app/app/commands/about.test.ts +29 -0
- package/templates/app/app/commands/about.ts +34 -0
- package/templates/app/app/commands/index.ts +15 -0
- package/templates/app/app/http/controllers/home.tsx +22 -0
- package/templates/app/app/http/controllers/not-found.tsx +25 -0
- package/templates/app/app/initializers/assets.ts +11 -0
- package/templates/app/app/initializers/cli.ts +35 -0
- package/templates/app/app/initializers/dispatcher.ts +18 -0
- package/templates/app/app/initializers/logger.ts +10 -0
- package/templates/app/app/initializers/mcp.ts +16 -0
- package/templates/app/app/initializers/router.tsx +65 -0
- package/templates/app/app/jobs/index.ts +10 -0
- package/templates/app/app/mcp/resources/index.ts +9 -0
- package/templates/app/app/mcp/tools/index.ts +10 -0
- package/templates/app/bootstrap/browser.ts +27 -0
- package/templates/app/bootstrap/cli.ts +9 -0
- package/templates/app/bootstrap/worker.ts +31 -0
- package/templates/app/cloudflare.config.ts +28 -0
- package/templates/app/config/router-context.d.ts +20 -0
- package/templates/app/gitignore +9 -0
- package/templates/app/package.json +38 -0
- package/templates/app/resources/layouts/document.tsx +58 -0
- package/templates/app/routes/web.ts +12 -0
- package/templates/app/tsconfig.json +40 -0
- package/templates/app/vite.config.ts +40 -0
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
/**
|
|
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, with the components to
|
|
4
|
+
* refresh, the commands that verify the edit, and where each package is documented.
|
|
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 { failure, isFailure, isSuccess, success, wrap } from "@sdxc/result";
|
|
12
|
+
import { compare } from "@sdxc/semver";
|
|
13
|
+
import { loadConfig } from "../config.js";
|
|
14
|
+
import { readLock, uiEntries } from "../lock.js";
|
|
15
|
+
import { lockFileAtOrAbove, packageManager } from "../package-manager.js";
|
|
16
|
+
import { scopedPackageOf } from "../releases.js";
|
|
17
|
+
import { entriesBetween, fullHistoryStart, readChangelog } from "./changelog.js";
|
|
18
|
+
import { projectImports, readManifest } from "./project.js";
|
|
19
|
+
/** Where each release's GitHub Release lives, `<RELEASES>/tag/v<version>`. */
|
|
20
|
+
const RELEASES = "https://github.com/sergiodxa/monorepo/releases";
|
|
21
|
+
/** Each package's reference page, as Markdown an agent reads directly. */
|
|
22
|
+
const DOCUMENTATION = "https://sdxc.sergiodxa.com/api";
|
|
23
|
+
/** Remix's release notes, `<REMIX_RELEASES>/tag/remix@<version>`. */
|
|
24
|
+
const REMIX_RELEASES = "https://github.com/remix-run/remix/releases";
|
|
25
|
+
/** The `package.json` scripts that verify a project, in the order the prompt lists them. */
|
|
26
|
+
const VERIFY_SCRIPTS = ["check", "typecheck", "test"];
|
|
27
|
+
/** Commit types whose notes describe a change to what a consumer receives, besides `feat`. */
|
|
28
|
+
const FIX_TYPES = new Set(["fix", "perf", "revert"]);
|
|
29
|
+
/**
|
|
30
|
+
* The prompt for moving from `input.from` to `input.to`, as Markdown. Only the imported
|
|
31
|
+
* packages' entries appear; notes typed docs, test, refactor, chore, style, ci or build state
|
|
32
|
+
* that a consumer has nothing to do, so they are left to the GitHub Releases.
|
|
33
|
+
*/
|
|
34
|
+
export function renderPrompt(input) {
|
|
35
|
+
let imported = new Set(input.packages);
|
|
36
|
+
let relevant = entriesBetween(input.entries, input.from, input.to)
|
|
37
|
+
.filter((entry) => imported.has(entry.package))
|
|
38
|
+
.sort((a, b) => compare(a.release, b.release) || compareText(a.package, b.package));
|
|
39
|
+
let breaking = relevant.filter((entry) => entry.breaking);
|
|
40
|
+
let features = relevant.filter((entry) => !entry.breaking && entry.type === "feat");
|
|
41
|
+
let fixes = relevant.filter((entry) => !entry.breaking && FIX_TYPES.has(entry.type));
|
|
42
|
+
let sections = [
|
|
43
|
+
[
|
|
44
|
+
`# Upgrade the @sdxc packages from ${input.from} to ${input.to}`,
|
|
45
|
+
`This project now depends on the @sdxc packages of release ${input.to}, installed. Update its code for the changes below, which are the release notes of the packages it imports for every release after ${input.from}. Apply each breaking change's migration wherever the code uses what it changed, adopt the features and fixes where they apply, then run the verification commands and fix what they report.`,
|
|
46
|
+
`Packages this project imports: ${[...input.packages].sort(compareText).map(code).join(", ")}.`,
|
|
47
|
+
].join("\n\n"),
|
|
48
|
+
];
|
|
49
|
+
if (input.remix !== null) {
|
|
50
|
+
sections.push([
|
|
51
|
+
"## Remix",
|
|
52
|
+
`\`remix\` moved from ${input.remix.from} to ${input.remix.to}, the version release ${input.to} requires. Read its release notes for changes the code needs: ${REMIX_RELEASES}/tag/remix%40${input.remix.to}`,
|
|
53
|
+
].join("\n\n"));
|
|
54
|
+
}
|
|
55
|
+
if (relevant.length === 0) {
|
|
56
|
+
sections.push("No release in between changed a package this project imports.");
|
|
57
|
+
}
|
|
58
|
+
if (breaking.length > 0)
|
|
59
|
+
sections.push(entrySection("Breaking changes", breaking));
|
|
60
|
+
if (features.length > 0)
|
|
61
|
+
sections.push(entrySection("Features", features));
|
|
62
|
+
if (fixes.length > 0)
|
|
63
|
+
sections.push(entrySection("Fixes", fixes));
|
|
64
|
+
let older = olderReleases(input);
|
|
65
|
+
if (older !== null)
|
|
66
|
+
sections.push(older);
|
|
67
|
+
if (input.components.length > 0) {
|
|
68
|
+
sections.push([
|
|
69
|
+
"## Vendored components",
|
|
70
|
+
"These copied components changed after the release they were copied from. Review each change with `sdxc ui diff`, and take it with `sdxc ui update` (an edited copy is left alone unless `--force`):",
|
|
71
|
+
input.components
|
|
72
|
+
.map((component) => `- \`${component.name}\`, copied from ${component.release}, changed in ${component.changedIn}: \`sdxc ui diff ${component.name}\`, then \`sdxc ui update ${component.name}\``)
|
|
73
|
+
.join("\n"),
|
|
74
|
+
].join("\n\n"));
|
|
75
|
+
}
|
|
76
|
+
if (input.verify.length > 0) {
|
|
77
|
+
sections.push([
|
|
78
|
+
"## Verify",
|
|
79
|
+
"Run these after editing and fix what they report:",
|
|
80
|
+
input.verify.map((command) => `- \`${command}\``).join("\n"),
|
|
81
|
+
].join("\n\n"));
|
|
82
|
+
}
|
|
83
|
+
sections.push([
|
|
84
|
+
"## Documentation",
|
|
85
|
+
[...input.packages]
|
|
86
|
+
.sort(compareText)
|
|
87
|
+
.map((name) => `- ${code(name)}: ${DOCUMENTATION}/${documentationSlug(name)}.md`)
|
|
88
|
+
.join("\n"),
|
|
89
|
+
].join("\n\n"));
|
|
90
|
+
return `${sections.join("\n\n")}\n`;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Gathers the prompt for the project at `root` from the `@sdxc/kit` at `packageRoot`, which is
|
|
94
|
+
* the target release: its version, its changelog, its component registry and its
|
|
95
|
+
* `remix` peer, compared with `remixFrom` when the bump changed `remix`.
|
|
96
|
+
*/
|
|
97
|
+
export async function buildPrompt(options) {
|
|
98
|
+
let own = await readOwnManifest(options.packageRoot);
|
|
99
|
+
if (isFailure(own))
|
|
100
|
+
return own;
|
|
101
|
+
let to = own.data.version;
|
|
102
|
+
if (compare(options.from, to) > 0) {
|
|
103
|
+
return failure(new Error(`--from ${options.from} is newer than this @sdxc/kit, ${to}`));
|
|
104
|
+
}
|
|
105
|
+
let entries = await readChangelog(options.packageRoot);
|
|
106
|
+
if (isFailure(entries))
|
|
107
|
+
return entries;
|
|
108
|
+
let project = await readManifest(options.root);
|
|
109
|
+
if (isFailure(project))
|
|
110
|
+
return project;
|
|
111
|
+
let manager = await packageManager({
|
|
112
|
+
declared: project.data.manifest.packageManager,
|
|
113
|
+
findLockFile: lockFileAtOrAbove(options.root),
|
|
114
|
+
});
|
|
115
|
+
let scripts = project.data.manifest.scripts ?? {};
|
|
116
|
+
let imports = await projectImports(options.root);
|
|
117
|
+
let packages = new Set();
|
|
118
|
+
for (let specifier of imports.keys()) {
|
|
119
|
+
let name = scopedPackageOf(specifier);
|
|
120
|
+
if (name !== null)
|
|
121
|
+
packages.add(name);
|
|
122
|
+
}
|
|
123
|
+
let components = await changedComponents(options.root, options.packageRoot);
|
|
124
|
+
if (isFailure(components))
|
|
125
|
+
return components;
|
|
126
|
+
let remixTo = own.data.remix;
|
|
127
|
+
let remix = options.remixFrom !== null && remixTo !== null && options.remixFrom !== remixTo
|
|
128
|
+
? { from: options.remixFrom, to: remixTo }
|
|
129
|
+
: null;
|
|
130
|
+
return success(renderPrompt({
|
|
131
|
+
from: options.from,
|
|
132
|
+
to,
|
|
133
|
+
entries: entries.data,
|
|
134
|
+
packages: [...packages],
|
|
135
|
+
remix,
|
|
136
|
+
components: components.data,
|
|
137
|
+
verify: VERIFY_SCRIPTS.filter((name) => scripts[name] !== undefined).map((name) => [...manager.run, name].join(" ")),
|
|
138
|
+
}));
|
|
139
|
+
}
|
|
140
|
+
/** The version and `remix` peer of the running kit, which are its release's. */
|
|
141
|
+
async function readOwnManifest(packageRoot) {
|
|
142
|
+
let text = await wrap(() => readFile(join(packageRoot, "package.json"), "utf8"));
|
|
143
|
+
if (isFailure(text))
|
|
144
|
+
return text;
|
|
145
|
+
let parsed = wrap(() => JSON.parse(text.data));
|
|
146
|
+
if (isFailure(parsed) || typeof parsed.data.version !== "string") {
|
|
147
|
+
return failure(new Error(`${packageRoot}/package.json has no version`));
|
|
148
|
+
}
|
|
149
|
+
let remix = parsed.data.peerDependencies?.remix;
|
|
150
|
+
return success({ version: parsed.data.version, remix: typeof remix === "string" ? remix : null });
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* The components the project's lock file records whose registry entry in the installed
|
|
154
|
+
* release names a later `changedIn` than the release the copy came from. Without a lock file
|
|
155
|
+
* there are none; a component the registry no longer has is left out, and an invalid lock fails.
|
|
156
|
+
*/
|
|
157
|
+
async function changedComponents(root, packageRoot) {
|
|
158
|
+
let config = await loadConfig(root);
|
|
159
|
+
if (isFailure(config))
|
|
160
|
+
return config;
|
|
161
|
+
let lock = await readLock(root, config.data.config);
|
|
162
|
+
if (isFailure(lock))
|
|
163
|
+
return lock;
|
|
164
|
+
let changed = [];
|
|
165
|
+
for (let entry of uiEntries(lock.data)) {
|
|
166
|
+
let changedIn = await registryChangedIn(packageRoot, entry.name);
|
|
167
|
+
if (changedIn !== null && compare(changedIn, entry.release) > 0) {
|
|
168
|
+
changed.push({ name: entry.name, release: entry.release, changedIn });
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return success(changed);
|
|
172
|
+
}
|
|
173
|
+
/** The `changedIn` of a component's registry entry, or `null` when the entry is missing or unreadable. */
|
|
174
|
+
async function registryChangedIn(packageRoot, name) {
|
|
175
|
+
let text = await wrap(() => readFile(join(packageRoot, "registry", "ui", `${name}.json`), "utf8"));
|
|
176
|
+
if (!isSuccess(text))
|
|
177
|
+
return null;
|
|
178
|
+
let parsed = wrap(() => JSON.parse(text.data));
|
|
179
|
+
if (!isSuccess(parsed))
|
|
180
|
+
return null;
|
|
181
|
+
return typeof parsed.data.changedIn === "string" ? parsed.data.changedIn : null;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* The note on releases older than the changelog's full window, which kept only their breaking
|
|
185
|
+
* entries, with a link to each one's GitHub Release; `null` when the move starts inside it.
|
|
186
|
+
*/
|
|
187
|
+
function olderReleases(input) {
|
|
188
|
+
let start = fullHistoryStart(input.to);
|
|
189
|
+
if (compare(input.from, start) >= 0)
|
|
190
|
+
return null;
|
|
191
|
+
let releases = [
|
|
192
|
+
...new Set(entriesBetween(input.entries, input.from, input.to)
|
|
193
|
+
.map((entry) => entry.release)
|
|
194
|
+
.filter((release) => compare(release, start) < 0)),
|
|
195
|
+
].sort(compare);
|
|
196
|
+
return [
|
|
197
|
+
"## Older releases",
|
|
198
|
+
`Releases after ${input.from} and before ${start} are summarized by their breaking changes only. Their full notes are on GitHub: ${RELEASES}`,
|
|
199
|
+
...(releases.length > 0
|
|
200
|
+
? [releases.map((release) => `- ${release}: ${RELEASES}/tag/v${release}`).join("\n")]
|
|
201
|
+
: []),
|
|
202
|
+
].join("\n\n");
|
|
203
|
+
}
|
|
204
|
+
/** A heading and each entry under its own sub-heading with its full body. */
|
|
205
|
+
function entrySection(heading, entries) {
|
|
206
|
+
let blocks = entries.map((entry) => {
|
|
207
|
+
let lines = [`### ${entry.package}: ${entry.title}`, `Released in ${entry.release}.`];
|
|
208
|
+
if (entry.body.trim() !== "")
|
|
209
|
+
lines.push(entry.body.trim());
|
|
210
|
+
return lines.join("\n\n");
|
|
211
|
+
});
|
|
212
|
+
return [`## ${heading}`, ...blocks].join("\n\n");
|
|
213
|
+
}
|
|
214
|
+
/** The reference page slug: a scoped package by its bare name. */
|
|
215
|
+
function documentationSlug(name) {
|
|
216
|
+
return name.startsWith("@sdxc/") ? name.slice("@sdxc/".length) : name;
|
|
217
|
+
}
|
|
218
|
+
function code(text) {
|
|
219
|
+
return `\`${text}\``;
|
|
220
|
+
}
|
|
221
|
+
function compareText(a, b) {
|
|
222
|
+
if (a < b)
|
|
223
|
+
return -1;
|
|
224
|
+
if (a > b)
|
|
225
|
+
return 1;
|
|
226
|
+
return 0;
|
|
227
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The npm registry as `sdxc upgrade` reads it: a release is a published `@sdxc/kit` version,
|
|
3
|
+
* which ships in every release, with the `remix` version it declares as its peer and the
|
|
4
|
+
* changelog it carries, so the bump knows all three before anything is installed.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import type { Result } from "@sdxc/result";
|
|
10
|
+
import type { ChangelogEntry } from "./changelog.js";
|
|
11
|
+
/** Where one published file of a version is served, `<PACKAGE_FILES>/<name>@<version>/<file>`. */
|
|
12
|
+
export declare const PACKAGE_FILES = "https://unpkg.com";
|
|
13
|
+
/**
|
|
14
|
+
* The package that marks each release and carries its changelog: every release that ships
|
|
15
|
+
* anything ships it, so its versions are exactly the release dates.
|
|
16
|
+
*/
|
|
17
|
+
export declare const RELEASE_PACKAGE = "@sdxc/kit";
|
|
18
|
+
/** A published release. */
|
|
19
|
+
export interface Release {
|
|
20
|
+
version: string;
|
|
21
|
+
/** The exact `remix` version the release pins as its peer, `null` when it declares none. */
|
|
22
|
+
remix: string | null;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The release `version` names, or the latest one when it is `null`. A version npm does not
|
|
26
|
+
* have is a failure naming it.
|
|
27
|
+
*/
|
|
28
|
+
export declare function fetchRelease(version: string | null, signal?: AbortSignal): Promise<Result<Release, Error>>;
|
|
29
|
+
/**
|
|
30
|
+
* The changelog of the release `version`, read from its `@sdxc/kit` before anything is
|
|
31
|
+
* installed so the upgrade can say what breaks on the way.
|
|
32
|
+
*/
|
|
33
|
+
export declare function fetchChangelog(version: string, signal?: AbortSignal): Promise<Result<ChangelogEntry[], Error>>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The npm registry as `sdxc upgrade` reads it: a release is a published `@sdxc/kit` version,
|
|
3
|
+
* which ships in every release, with the `remix` version it declares as its peer and the
|
|
4
|
+
* changelog it carries, so the bump knows all three before anything is installed.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import { failure, isFailure, success, wrap } from "@sdxc/result";
|
|
10
|
+
import { fetchPackument } from "../releases.js";
|
|
11
|
+
import { CHANGELOG_FILE, parseChangelog } from "./changelog.js";
|
|
12
|
+
/** Where one published file of a version is served, `<PACKAGE_FILES>/<name>@<version>/<file>`. */
|
|
13
|
+
export const PACKAGE_FILES = "https://unpkg.com";
|
|
14
|
+
/**
|
|
15
|
+
* The package that marks each release and carries its changelog: every release that ships
|
|
16
|
+
* anything ships it, so its versions are exactly the release dates.
|
|
17
|
+
*/
|
|
18
|
+
export const RELEASE_PACKAGE = "@sdxc/kit";
|
|
19
|
+
/**
|
|
20
|
+
* The release `version` names, or the latest one when it is `null`. A version npm does not
|
|
21
|
+
* have is a failure naming it.
|
|
22
|
+
*/
|
|
23
|
+
export async function fetchRelease(version, signal) {
|
|
24
|
+
let packument = await fetchPackument(RELEASE_PACKAGE, signal);
|
|
25
|
+
if (isFailure(packument))
|
|
26
|
+
return packument;
|
|
27
|
+
let target = version ?? packument.data.latest;
|
|
28
|
+
let peers = target === null ? undefined : packument.data.versions.get(target);
|
|
29
|
+
if (target === null || peers === undefined) {
|
|
30
|
+
return failure(new Error(`Release ${version ?? "latest"} is not published on npm`));
|
|
31
|
+
}
|
|
32
|
+
return success({ version: target, remix: peers.remix ?? null });
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The changelog of the release `version`, read from its `@sdxc/kit` before anything is
|
|
36
|
+
* installed so the upgrade can say what breaks on the way.
|
|
37
|
+
*/
|
|
38
|
+
export async function fetchChangelog(version, signal) {
|
|
39
|
+
let url = `${PACKAGE_FILES}/${RELEASE_PACKAGE}@${encodeURIComponent(version)}/${CHANGELOG_FILE}`;
|
|
40
|
+
let response = await wrap(() => fetch(url, { signal }));
|
|
41
|
+
if (isFailure(response))
|
|
42
|
+
return response;
|
|
43
|
+
if (!response.data.ok) {
|
|
44
|
+
return failure(new Error(`${url} answered ${response.data.status}`));
|
|
45
|
+
}
|
|
46
|
+
let text = await wrap(() => response.data.text());
|
|
47
|
+
if (isFailure(text))
|
|
48
|
+
return text;
|
|
49
|
+
return parseChangelog(text.data, url);
|
|
50
|
+
}
|
package/lock.schema.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"description": "One line of the sdxc lock file, which the CLI writes and the project commits",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"kind": {
|
|
7
|
+
"type": "string",
|
|
8
|
+
"description": "The command group that owns the entry"
|
|
9
|
+
},
|
|
10
|
+
"name": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"description": "The entry's identity within its kind"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"required": ["kind", "name"],
|
|
16
|
+
"anyOf": [
|
|
17
|
+
{
|
|
18
|
+
"type": "object",
|
|
19
|
+
"properties": {
|
|
20
|
+
"kind": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"const": "ui",
|
|
23
|
+
"description": "The command group that owns the entry"
|
|
24
|
+
},
|
|
25
|
+
"name": {
|
|
26
|
+
"type": "string",
|
|
27
|
+
"pattern": "^[a-z0-9][a-z0-9-]*$",
|
|
28
|
+
"description": "The component, as `@sdxc/ui/<name>` imports it"
|
|
29
|
+
},
|
|
30
|
+
"release": {
|
|
31
|
+
"type": "string",
|
|
32
|
+
"description": "The release the copy came from"
|
|
33
|
+
},
|
|
34
|
+
"files": {
|
|
35
|
+
"type": "object",
|
|
36
|
+
"additionalProperties": {
|
|
37
|
+
"type": "string",
|
|
38
|
+
"pattern": "^sha256-[A-Za-z0-9+/]+={0,2}$"
|
|
39
|
+
},
|
|
40
|
+
"propertyNames": {
|
|
41
|
+
"type": "string",
|
|
42
|
+
"pattern": "^[A-Za-z0-9][A-Za-z0-9._-]*$"
|
|
43
|
+
},
|
|
44
|
+
"description": "Each file written, relative to `ui.directory`, to the hash of its content"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"required": ["kind", "name", "release", "files"],
|
|
48
|
+
"additionalProperties": false
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"properties": {
|
|
52
|
+
"kind": {
|
|
53
|
+
"type": "string",
|
|
54
|
+
"pattern": "^(?!ui$)"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"description": "An entry of a kind this release does not define, kept as written"
|
|
58
|
+
}
|
|
59
|
+
]
|
|
60
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sdxc/kit",
|
|
3
|
+
"version": "0.0.0-pre.1",
|
|
4
|
+
"description": "The sdxc command line: start a Remix v3 app, generate its files, copy UI components into it and upgrade it",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"bin": {
|
|
7
|
+
"sdxc": "dist/bin.js"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": "./dist/cli.js",
|
|
12
|
+
"./config.schema.json": "./config.schema.json",
|
|
13
|
+
"./lock.schema.json": "./lock.schema.json"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@sdxc/cli": "0.0.0-pre.1",
|
|
17
|
+
"@sdxc/codemod": "0.0.0-pre.1",
|
|
18
|
+
"@sdxc/json-schema": "2026.10.14",
|
|
19
|
+
"@sdxc/jsonc": "0.0.0-pre.1",
|
|
20
|
+
"@sdxc/jsonl": "0.0.0-pre.1",
|
|
21
|
+
"@sdxc/result": "2026.10.13",
|
|
22
|
+
"@sdxc/semver": "2026.10.13"
|
|
23
|
+
},
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"remix": "3.0.0"
|
|
26
|
+
},
|
|
27
|
+
"gitHead": "09e495f090b662f7801e49a9f55a91cf16ae385f",
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public"
|
|
30
|
+
},
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "git+https://github.com/sergiodxa/monorepo.git",
|
|
34
|
+
"directory": "packages/kit"
|
|
35
|
+
},
|
|
36
|
+
"homepage": "https://sdxc.sergiodxa.com/api/kit",
|
|
37
|
+
"author": {
|
|
38
|
+
"name": "Sergio Xalambrí",
|
|
39
|
+
"url": "https://sergiodxa.com"
|
|
40
|
+
},
|
|
41
|
+
"funding": {
|
|
42
|
+
"type": "github",
|
|
43
|
+
"url": "https://github.com/sponsors/sergiodxa"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `{{command}}`: describe what it changes, what it prints, and whether it is safe to run twice.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { createCommand, success } from "@sdxc/cli";
|
|
6
|
+
|
|
7
|
+
import commandset from "~/app/commands";
|
|
8
|
+
|
|
9
|
+
export default createCommand(commandset{{member}}, (ctx) => {
|
|
10
|
+
ctx.stdout("{{title}}\n");
|
|
11
|
+
return success();
|
|
12
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `{{command}}` command, run through the app's command line.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { invoke } from "@sdxc/cli/test";
|
|
6
|
+
import { describe, expect, test } from "vitest";
|
|
7
|
+
|
|
8
|
+
import { cli } from "~/app/initializers/cli";
|
|
9
|
+
|
|
10
|
+
describe("{{command}}", () => {
|
|
11
|
+
test("runs and exits 0", async () => {
|
|
12
|
+
let run = await invoke(cli, [{{words}}]);
|
|
13
|
+
|
|
14
|
+
expect(run.code).toBe(0);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test.todo("does the {{title}} work");
|
|
18
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The {{title}} form: the page that shows it and the action that receives it. Describe what
|
|
3
|
+
* a submission changes and where the visitor lands afterwards.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { createController } from "remix/router";
|
|
7
|
+
|
|
8
|
+
import DocumentLayout from "~/resources/layouts/document";
|
|
9
|
+
import routes from "{{routes}}";
|
|
10
|
+
|
|
11
|
+
export default createController(routes.{{path}}, {
|
|
12
|
+
actions: {
|
|
13
|
+
/** Renders the form. */
|
|
14
|
+
index(ctx) {
|
|
15
|
+
return ctx.render(
|
|
16
|
+
<DocumentLayout assets={ctx.assets} title="{{title}}">
|
|
17
|
+
<h1>{{title}}</h1>
|
|
18
|
+
<form method="post" action={routes.{{path}}.action.href()}>
|
|
19
|
+
<button type="submit">Send</button>
|
|
20
|
+
</form>
|
|
21
|
+
</DocumentLayout>,
|
|
22
|
+
);
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
/** Receives a submission and sends the visitor back to the form. */
|
|
26
|
+
action() {
|
|
27
|
+
return new Response(null, {
|
|
28
|
+
status: 303,
|
|
29
|
+
headers: { location: routes.{{path}}.index.href() },
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The {{title}} page: describe what a visitor finds here and why the route exists.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { createAction } from "remix/router";
|
|
6
|
+
|
|
7
|
+
import DocumentLayout from "~/resources/layouts/document";
|
|
8
|
+
import routes from "{{routes}}";
|
|
9
|
+
|
|
10
|
+
/** Renders the {{title}} page. */
|
|
11
|
+
export default createAction(routes.{{path}}, (ctx) =>
|
|
12
|
+
ctx.render(
|
|
13
|
+
<DocumentLayout assets={ctx.assets} title="{{title}}">
|
|
14
|
+
<h1>{{title}}</h1>
|
|
15
|
+
</DocumentLayout>,
|
|
16
|
+
),
|
|
17
|
+
);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The {{title}} controller.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { describe, expect, test } from "vitest";
|
|
6
|
+
|
|
7
|
+
import controller from "{{specifier}}";
|
|
8
|
+
|
|
9
|
+
describe("{{name}}", () => {
|
|
10
|
+
test("exports what the router maps", () => {
|
|
11
|
+
expect(controller).toBeDefined();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test.todo("answers the {{title}} page");
|
|
15
|
+
});
|
package/stubs/email.stub
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The {{title}} email: describe who receives it and what it tells them.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { Handle } from "remix/component";
|
|
6
|
+
import type { Email as EmailContract } from "@sdxc/mail";
|
|
7
|
+
|
|
8
|
+
import { Email } from "@sdxc/mail";
|
|
9
|
+
|
|
10
|
+
/** What the {{title}} email says. */
|
|
11
|
+
export interface {{Name}}Copy {
|
|
12
|
+
heading: string;
|
|
13
|
+
body: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Renders the email's body from copy the caller wrote. */
|
|
17
|
+
function {{Name}}Body(handle: Handle<{{Name}}Copy>) {
|
|
18
|
+
return () => (
|
|
19
|
+
<Email.Layout preview={handle.props.heading} title={handle.props.heading}>
|
|
20
|
+
<Email.Heading>{handle.props.heading}</Email.Heading>
|
|
21
|
+
<Email.Text>{handle.props.body}</Email.Text>
|
|
22
|
+
</Email.Layout>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** The {{title}} email, addressed to one recipient. */
|
|
27
|
+
export class {{Name}}Email implements EmailContract {
|
|
28
|
+
constructor(
|
|
29
|
+
private recipient: string,
|
|
30
|
+
private copy: {{Name}}Copy,
|
|
31
|
+
) {}
|
|
32
|
+
|
|
33
|
+
get to() {
|
|
34
|
+
return { email: this.recipient };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
get subject() {
|
|
38
|
+
return this.copy.heading;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
body() {
|
|
42
|
+
return <{{Name}}Body {...this.copy} />;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The {{title}} email.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { describe, expect, test } from "vitest";
|
|
6
|
+
|
|
7
|
+
import { {{Name}}Email } from "{{specifier}}";
|
|
8
|
+
|
|
9
|
+
describe("{{Name}}Email", () => {
|
|
10
|
+
test("is addressed to its recipient under its heading", () => {
|
|
11
|
+
let email = new {{Name}}Email("ada@example.com", { heading: "Hello", body: "Welcome." });
|
|
12
|
+
|
|
13
|
+
expect(email.to).toEqual({ email: "ada@example.com" });
|
|
14
|
+
expect(email.subject).toBe("Hello");
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The {{title}} factory tests seed rows with, through the same model the app writes with.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { defineFactory } from "@sdxc/data-model/testing";
|
|
6
|
+
|
|
7
|
+
import { {{Name}} } from "{{model}}";
|
|
8
|
+
|
|
9
|
+
/** A complete {{title}} row; a test overrides only the fields it is about. */
|
|
10
|
+
export const {{Name}}Factory = defineFactory({{Name}}, {});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The {{title}} initializer.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { describe, expect, test } from "vitest";
|
|
6
|
+
|
|
7
|
+
import { {{key}} } from "{{specifier}}";
|
|
8
|
+
|
|
9
|
+
describe("{{key}}", () => {
|
|
10
|
+
test("is built once, at import", () => {
|
|
11
|
+
expect({{key}}).toBeDefined();
|
|
12
|
+
});
|
|
13
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The scheduled {{title}} job: describe what each run sweeps or reports, and why on this
|
|
3
|
+
* schedule.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { createJobHandler } from "@sdxc/jobs";
|
|
7
|
+
|
|
8
|
+
import jobs from "~/app/jobs";
|
|
9
|
+
|
|
10
|
+
export default createJobHandler(jobs.{{path}}, async (ctx) => {
|
|
11
|
+
ctx.log.set({ job: { name: "{{name}}" } });
|
|
12
|
+
});
|
package/stubs/job.stub
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The {{title}} job: describe what it changes and why it runs off the request.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { createJobHandler } from "@sdxc/jobs";
|
|
6
|
+
|
|
7
|
+
import jobs from "~/app/jobs";
|
|
8
|
+
|
|
9
|
+
export default createJobHandler(jobs.{{path}}, async (ctx) => {
|
|
10
|
+
ctx.log.set({ job: { name: "{{name}}" } });
|
|
11
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The {{title}} job.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { describe, expect, test } from "vitest";
|
|
6
|
+
|
|
7
|
+
import handler from "{{specifier}}";
|
|
8
|
+
|
|
9
|
+
describe("{{name}}", () => {
|
|
10
|
+
test("exports the handler the dispatcher maps", () => {
|
|
11
|
+
expect(handler).toBeDefined();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test.todo("does the {{title}} work");
|
|
15
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Answers the `{{uri}}` resource: describe what a read returns, and `null` for one that does
|
|
3
|
+
* not exist.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { createResource } from "@sdxc/mcp";
|
|
7
|
+
|
|
8
|
+
import resourceset from "~/app/mcp/resources";
|
|
9
|
+
|
|
10
|
+
export default createResource(resourceset.{{path}}, {
|
|
11
|
+
read: () => "# {{title}}\n",
|
|
12
|
+
});
|