@sdxc/kit 2026.10.17 → 2026.10.21
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 +397 -22
- package/changelog.jsonl +1171 -1092
- package/config.schema.json +53 -1
- package/dist/cli.js +12 -0
- package/dist/commands/deploy.d.ts +23 -0
- package/dist/commands/deploy.js +167 -0
- package/dist/commands/destroy.d.ts +22 -0
- package/dist/commands/destroy.js +92 -0
- package/dist/commands/doctor.d.ts +26 -0
- package/dist/commands/doctor.js +65 -0
- package/dist/commands/initializers.d.ts +16 -0
- package/dist/commands/initializers.js +23 -0
- package/dist/commands/make.d.ts +78 -6
- package/dist/commands/make.js +134 -20
- package/dist/commands/middleware.d.ts +16 -0
- package/dist/commands/middleware.js +21 -0
- package/dist/commands/models.d.ts +18 -0
- package/dist/commands/models.js +29 -0
- package/dist/commands/notes.d.ts +17 -0
- package/dist/commands/notes.js +27 -0
- package/dist/commands/routes.d.ts +25 -0
- package/dist/commands/routes.js +50 -0
- package/dist/commands/run.d.ts +16 -0
- package/dist/commands/run.js +32 -11
- package/dist/commands/scaffold.d.ts +30 -0
- package/dist/commands/scaffold.js +34 -0
- package/dist/commands/schedule.d.ts +16 -0
- package/dist/commands/schedule.js +21 -0
- package/dist/commands/stats.d.ts +16 -0
- package/dist/commands/stats.js +21 -0
- package/dist/commands/ui/update.d.ts +6 -3
- package/dist/commands/ui/update.js +24 -7
- package/dist/commands/upgrade.d.ts +3 -1
- package/dist/commands/upgrade.js +88 -23
- package/dist/config.d.ts +20 -0
- package/dist/config.js +32 -1
- package/dist/contract.d.ts +101 -3
- package/dist/contract.js +371 -26
- package/dist/create/templates.js +3 -2
- package/dist/dependencies.d.ts +5 -1
- package/dist/dependencies.js +16 -1
- package/dist/deploy/plan.d.ts +49 -0
- package/dist/deploy/plan.js +68 -0
- package/dist/destroy.d.ts +40 -0
- package/dist/destroy.js +317 -0
- package/dist/doctor/check.d.ts +71 -0
- package/dist/doctor/check.js +53 -0
- package/dist/doctor/checks.d.ts +23 -0
- package/dist/doctor/checks.js +70 -0
- package/dist/doctor/define.d.ts +59 -0
- package/dist/doctor/define.js +16 -0
- package/dist/doctor/emails.d.ts +18 -0
- package/dist/doctor/emails.js +243 -0
- package/dist/doctor/env.d.ts +26 -0
- package/dist/doctor/env.js +88 -0
- package/dist/doctor/files.d.ts +14 -0
- package/dist/doctor/files.js +34 -0
- package/dist/doctor/fixture.d.ts +23 -0
- package/dist/doctor/fixture.js +46 -0
- package/dist/doctor/install.d.ts +17 -0
- package/dist/doctor/install.js +37 -0
- package/dist/doctor/installed.d.ts +11 -0
- package/dist/doctor/installed.js +79 -0
- package/dist/doctor/jsdoc.d.ts +44 -0
- package/dist/doctor/jsdoc.js +201 -0
- package/dist/doctor/layout.d.ts +23 -0
- package/dist/doctor/layout.js +83 -0
- package/dist/doctor/migrations.d.ts +16 -0
- package/dist/doctor/migrations.js +96 -0
- package/dist/doctor/models.d.ts +13 -0
- package/dist/doctor/models.js +69 -0
- package/dist/doctor/pins.d.ts +15 -0
- package/dist/doctor/pins.js +79 -0
- package/dist/doctor/project.d.ts +58 -0
- package/dist/doctor/project.js +261 -0
- package/dist/doctor/remix.d.ts +14 -0
- package/dist/doctor/remix.js +44 -0
- package/dist/doctor/routes.d.ts +11 -0
- package/dist/doctor/routes.js +49 -0
- package/dist/doctor/typegen.d.ts +13 -0
- package/dist/doctor/typegen.js +57 -0
- package/dist/doctor/ui.d.ts +14 -0
- package/dist/doctor/ui.js +51 -0
- package/dist/initializers.d.ts +25 -0
- package/dist/initializers.js +89 -0
- package/dist/lock.d.ts +2 -2
- package/dist/make/actions.d.ts +23 -0
- package/dist/make/actions.js +82 -0
- package/dist/make/declare.d.ts +31 -3
- package/dist/make/declare.js +284 -9
- package/dist/make/email.d.ts +23 -0
- package/dist/make/email.js +111 -0
- package/dist/make/from-fields.d.ts +30 -0
- package/dist/make/from-fields.js +162 -0
- package/dist/make/from-model.d.ts +39 -0
- package/dist/make/from-model.js +161 -0
- package/dist/make/generate.d.ts +25 -5
- package/dist/make/generate.js +76 -22
- package/dist/make/guard.d.ts +35 -0
- package/dist/make/guard.js +73 -0
- package/dist/make/imports.d.ts +6 -0
- package/dist/make/imports.js +19 -0
- package/dist/make/index.d.ts +49 -4
- package/dist/make/index.js +290 -29
- package/dist/make/kinds.d.ts +34 -2
- package/dist/make/kinds.js +92 -8
- package/dist/make/mount.d.ts +25 -0
- package/dist/make/mount.js +135 -0
- package/dist/make/schema-diff.d.ts +58 -0
- package/dist/make/schema-diff.js +609 -0
- package/dist/make/schema.d.ts +76 -0
- package/dist/make/schema.js +206 -0
- package/dist/make/stubs.d.ts +14 -7
- package/dist/make/stubs.js +24 -8
- package/dist/make/test.d.ts +43 -0
- package/dist/make/test.js +150 -0
- package/dist/make/trigger.d.ts +31 -0
- package/dist/make/trigger.js +163 -0
- package/dist/models.d.ts +42 -0
- package/dist/models.js +149 -0
- package/dist/notes.d.ts +28 -0
- package/dist/notes.js +66 -0
- package/dist/reference.d.ts +27 -0
- package/dist/reference.js +103 -0
- package/dist/releases.d.ts +9 -0
- package/dist/releases.js +29 -8
- package/dist/routes/chains.d.ts +34 -0
- package/dist/routes/chains.js +95 -0
- package/dist/routes/filter.d.ts +53 -0
- package/dist/routes/filter.js +147 -0
- package/dist/routes/format.d.ts +23 -0
- package/dist/routes/format.js +123 -0
- package/dist/routes/helpers.d.ts +21 -0
- package/dist/routes/helpers.js +165 -0
- package/dist/routes/index.d.ts +56 -0
- package/dist/routes/index.js +167 -0
- package/dist/routes/modules.d.ts +116 -0
- package/dist/routes/modules.js +235 -0
- package/dist/routes/parse.d.ts +161 -0
- package/dist/routes/parse.js +621 -0
- package/dist/routes/routers.d.ts +69 -0
- package/dist/routes/routers.js +327 -0
- package/dist/scaffold/fields.d.ts +129 -0
- package/dist/scaffold/fields.js +421 -0
- package/dist/scaffold/index.d.ts +39 -0
- package/dist/scaffold/index.js +622 -0
- package/dist/scaffold/render.d.ts +61 -0
- package/dist/scaffold/render.js +417 -0
- package/dist/schedule.d.ts +45 -0
- package/dist/schedule.js +124 -0
- package/dist/stats.d.ts +37 -0
- package/dist/stats.js +126 -0
- package/dist/ui/commands.d.ts +10 -3
- package/dist/ui/commands.js +85 -15
- package/dist/ui/registry.d.ts +8 -8
- package/dist/upgrade/agents.d.ts +49 -0
- package/dist/upgrade/agents.js +110 -0
- package/dist/upgrade/changelog.d.ts +2 -2
- package/dist/upgrade/project.d.ts +4 -0
- package/dist/upgrade/project.js +11 -1
- package/dist/upgrade/prompt.d.ts +11 -0
- package/dist/upgrade/prompt.js +50 -7
- package/package.json +6 -4
- package/registry/ui/alert-dialog.json +2 -2
- package/registry/ui/attachment.json +2 -2
- package/registry/ui/calendar.json +2 -2
- package/registry/ui/color-picker.json +2 -2
- package/registry/ui/command.json +2 -2
- package/registry/ui/date-picker.json +2 -2
- package/registry/ui/date-range-picker.json +2 -2
- package/registry/ui/dialog.json +2 -2
- package/registry/ui/file-trigger.json +2 -2
- package/registry/ui/heading-scope.json +2 -2
- package/registry/ui/message-scroller.json +2 -2
- package/registry/ui/number-field.json +2 -2
- package/registry/ui/range-calendar.json +2 -2
- package/registry/ui/resizable.json +2 -2
- package/registry/ui/select.json +2 -2
- package/registry/ui/shared-element.json +2 -2
- package/registry/ui/sidebar.json +3 -3
- package/registry/ui/typeset.json +3 -3
- package/stubs/command.spec.stub +15 -0
- package/stubs/controller.api.resource.stub +23 -0
- package/stubs/controller.api.spec.stub +15 -0
- package/stubs/controller.form.stub +2 -2
- package/stubs/controller.form.test.stub +2 -2
- package/stubs/controller.resource.form.stub +67 -0
- package/stubs/controller.resource.stub +28 -0
- package/stubs/controller.spec.stub +15 -0
- package/stubs/email.stub +9 -14
- package/stubs/email.test.stub +9 -9
- package/stubs/factory.stub +1 -1
- package/stubs/mcp.spec.stub +16 -0
- package/stubs/model.stub +3 -3
- package/stubs/policy.test.stub +34 -8
- package/stubs/scaffold.api.create.stub +34 -0
- package/stubs/scaffold.api.create.test.stub +37 -0
- package/stubs/scaffold.api.destroy.stub +34 -0
- package/stubs/scaffold.api.destroy.test.stub +44 -0
- package/stubs/scaffold.api.index.stub +23 -0
- package/stubs/scaffold.api.index.test.stub +31 -0
- package/stubs/scaffold.api.show.stub +27 -0
- package/stubs/scaffold.api.show.test.stub +41 -0
- package/stubs/scaffold.api.update.stub +44 -0
- package/stubs/scaffold.api.update.test.stub +46 -0
- package/stubs/scaffold.command.create.stub +22 -0
- package/stubs/scaffold.command.create.test.stub +30 -0
- package/stubs/scaffold.command.delete.stub +20 -0
- package/stubs/scaffold.command.delete.test.stub +39 -0
- package/stubs/scaffold.command.list.stub +18 -0
- package/stubs/scaffold.command.list.test.stub +31 -0
- package/stubs/scaffold.command.show.stub +19 -0
- package/stubs/scaffold.command.show.test.stub +37 -0
- package/stubs/scaffold.controller.destroy.stub +35 -0
- package/stubs/scaffold.controller.destroy.test.stub +65 -0
- package/stubs/scaffold.controller.edit.stub +97 -0
- package/stubs/scaffold.controller.edit.test.stub +91 -0
- package/stubs/scaffold.controller.index.stub +55 -0
- package/stubs/scaffold.controller.index.test.stub +32 -0
- package/stubs/scaffold.controller.new.stub +70 -0
- package/stubs/scaffold.controller.new.test.stub +81 -0
- package/stubs/scaffold.controller.show.stub +59 -0
- package/stubs/scaffold.controller.show.test.stub +43 -0
- package/stubs/scaffold.factory.stub +16 -0
- package/stubs/scaffold.form.stub +75 -0
- package/stubs/scaffold.mcp.create.stub +24 -0
- package/stubs/scaffold.mcp.create.test.stub +36 -0
- package/stubs/scaffold.mcp.delete.stub +31 -0
- package/stubs/scaffold.mcp.delete.test.stub +43 -0
- package/stubs/scaffold.mcp.get.stub +21 -0
- package/stubs/scaffold.mcp.get.test.stub +31 -0
- package/stubs/scaffold.mcp.list.stub +23 -0
- package/stubs/scaffold.mcp.list.test.stub +25 -0
- package/stubs/scaffold.mcp.update.stub +37 -0
- package/stubs/scaffold.mcp.update.test.stub +40 -0
- package/stubs/scaffold.migration.stub +3 -0
- package/stubs/scaffold.model.stub +35 -0
- package/stubs/scaffold.model.test.stub +25 -0
- package/stubs/scaffold.spec.stub +7 -0
- package/stubs/scaffold.test-database.stub +33 -0
- package/stubs/scaffold.test-mcp.stub +92 -0
- package/stubs/scaffold.validator.stub +18 -0
- package/stubs/scaffold.validator.test.stub +26 -0
- package/templates/app/AGENTS.md +167 -0
- package/templates/app/CLAUDE.md +1 -0
- package/templates/app/README.md +33 -15
- package/templates/app/app/commands/console.test.ts +26 -0
- package/templates/app/app/commands/console.ts +19 -0
- package/templates/app/app/commands/db/fresh.test.ts +57 -0
- package/templates/app/app/commands/db/fresh.ts +37 -0
- package/templates/app/app/commands/db/migrate.test.ts +17 -1
- package/templates/app/app/commands/db/migrate.ts +51 -18
- package/templates/app/app/commands/db/prepare.test.ts +39 -0
- package/templates/app/app/commands/db/prepare.ts +35 -0
- package/templates/app/app/commands/db/seed.test.ts +38 -0
- package/templates/app/app/commands/db/seed.ts +26 -0
- package/templates/app/app/commands/deploy.test.ts +34 -0
- package/templates/app/app/commands/deploy.ts +18 -0
- package/templates/app/app/commands/emails/preview.test.tsx +63 -0
- package/templates/app/app/commands/emails/preview.ts +24 -0
- package/templates/app/app/commands/index.ts +57 -2
- package/templates/app/app/commands/typegen.test.ts +20 -1
- package/templates/app/app/commands/typegen.ts +16 -2
- package/templates/app/app/emails/index.ts +10 -0
- package/templates/app/app/http/middleware/access.test.ts +43 -0
- package/templates/app/app/http/middleware/access.ts +41 -0
- package/templates/app/app/http/middleware/api.ts +12 -3
- package/templates/app/app/http/middleware/page.test.ts +4 -1
- package/templates/app/app/http/middleware/page.ts +7 -5
- package/templates/app/app/initializers/cli.ts +35 -2
- package/templates/app/app/initializers/dispatcher.ts +9 -1
- package/templates/app/app/initializers/mail-transport.test.ts +33 -0
- package/templates/app/app/initializers/mail-transport.ts +26 -0
- package/templates/app/app/initializers/mail.test.ts +17 -17
- package/templates/app/app/initializers/mail.ts +15 -7
- package/templates/app/app/initializers/router.test.ts +7 -0
- package/templates/app/app/initializers/router.tsx +13 -3
- package/templates/app/app/jobs/email.test.tsx +70 -0
- package/templates/app/app/jobs/email.ts +16 -0
- package/templates/app/app/jobs/index.ts +6 -2
- package/templates/app/app/policies/abilities.ts +13 -0
- package/templates/app/app/policies/policy.test.ts +15 -0
- package/templates/app/app/policies/policy.ts +30 -0
- package/templates/app/app/services/commands.ts +30 -0
- package/templates/app/app/services/migrations.test.ts +48 -1
- package/templates/app/app/services/migrations.ts +66 -9
- package/templates/app/app/test/cloudflare-workers.ts +2 -0
- package/templates/app/app/test/local-database.ts +67 -0
- package/templates/app/app/test/session.ts +28 -0
- package/templates/app/bootstrap/console.ts +13 -0
- package/templates/app/cloudflare.config.ts +3 -3
- package/templates/app/database/seed.ts +12 -0
- package/templates/app/package.json +3 -1
- package/templates/app/spec/config.jsonc +16 -0
- package/stubs/policy.stub +0 -16
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `sdxc notes` handler: lists every note comment in the project's layout folders, grouped
|
|
3
|
+
* by file, or as JSON for an agent, with `--tag` choosing the tags.
|
|
4
|
+
*
|
|
5
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
6
|
+
* @copyright Sergio Xalambrí 2026
|
|
7
|
+
*/
|
|
8
|
+
import { createCommand, success } from "@sdxc/cli";
|
|
9
|
+
import { SDXC_COMMANDS } from "../contract.js";
|
|
10
|
+
import { project } from "../middleware.js";
|
|
11
|
+
import { DEFAULT_TAGS, formatNotes, projectNotes } from "../notes.js";
|
|
12
|
+
/** Reads the project's code and prints its notes. */
|
|
13
|
+
export default createCommand(SDXC_COMMANDS.notes, {
|
|
14
|
+
middleware: [project()],
|
|
15
|
+
/** Always succeeds once the project is found; a project without notes says so. */
|
|
16
|
+
async handler(ctx) {
|
|
17
|
+
let tags = ctx.flags.tag.length > 0 ? ctx.flags.tag.map((tag) => tag.toUpperCase()) : DEFAULT_TAGS;
|
|
18
|
+
let notes = await projectNotes(ctx.project.root, tags);
|
|
19
|
+
if (ctx.flags.json)
|
|
20
|
+
ctx.stdout(`${JSON.stringify(notes, null, 2)}\n`);
|
|
21
|
+
else if (notes.length === 0)
|
|
22
|
+
ctx.stdout(`No ${tags.join(", ")} notes found.\n`);
|
|
23
|
+
else
|
|
24
|
+
ctx.stdout(formatNotes(notes));
|
|
25
|
+
return success();
|
|
26
|
+
},
|
|
27
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `sdxc routes` handler: prints every route of the project, its controller and the
|
|
3
|
+
* middleware that runs for it, as a table, one block per route, or JSON an agent parses,
|
|
4
|
+
* narrowed by its filters first. Diagnostics go to stderr, so stdout holds the listing alone.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
/** Reads the project's contracts and routers and prints what they declare and map. */
|
|
10
|
+
declare const _default: import("@sdxc/cli").CommandAction<import("@sdxc/cli").Command<Readonly<Record<string, import("@sdxc/cli").Argument<unknown>>>, {
|
|
11
|
+
readonly json: import("@sdxc/cli").Flag<boolean>;
|
|
12
|
+
readonly expanded: import("@sdxc/cli").Flag<boolean>;
|
|
13
|
+
readonly grep: import("@sdxc/cli").ValueFlag<string, false, false, false>;
|
|
14
|
+
readonly controller: import("@sdxc/cli").ValueFlag<string, false, false, false>;
|
|
15
|
+
readonly method: import("@sdxc/cli").ValueFlag<string, false, false, false>;
|
|
16
|
+
readonly contract: import("@sdxc/cli").ValueFlag<string, false, false, false>;
|
|
17
|
+
readonly unused: import("@sdxc/cli").Flag<boolean>;
|
|
18
|
+
readonly exceptPath: import("@sdxc/cli").ValueFlag<string, false, true, false>;
|
|
19
|
+
readonly sort: import("@sdxc/cli").ValueFlag<"name" | "pattern" | "controller" | "method", false, false, false>;
|
|
20
|
+
}>, readonly [import("@sdxc/cli").CommandMiddleware<{
|
|
21
|
+
key: typeof import("../middleware.js").CurrentProject;
|
|
22
|
+
value: import("../middleware.js").Project;
|
|
23
|
+
property: "project";
|
|
24
|
+
}>]>;
|
|
25
|
+
export default _default;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `sdxc routes` handler: prints every route of the project, its controller and the
|
|
3
|
+
* middleware that runs for it, as a table, one block per route, or JSON an agent parses,
|
|
4
|
+
* narrowed by its filters first. Diagnostics go to stderr, so stdout holds the listing alone.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import { createCommand, success } from "@sdxc/cli";
|
|
10
|
+
import { SDXC_COMMANDS } from "../contract.js";
|
|
11
|
+
import { project } from "../middleware.js";
|
|
12
|
+
import { filterRoutes, hasFilters, sortRoutes, unmappedControllers } from "../routes/filter.js";
|
|
13
|
+
import { formatExpanded, formatJSON, formatTable } from "../routes/format.js";
|
|
14
|
+
import { listRoutes, unimportedControllers } from "../routes/index.js";
|
|
15
|
+
/** Reads the project's contracts and routers and prints what they declare and map. */
|
|
16
|
+
export default createCommand(SDXC_COMMANDS.routes, {
|
|
17
|
+
middleware: [project()],
|
|
18
|
+
/**
|
|
19
|
+
* Always succeeds once the project is found: a route it cannot read is a diagnostic, and a
|
|
20
|
+
* filter that matches nothing prints an empty result. With `--unused`, each controller file
|
|
21
|
+
* no route maps is reported on stderr too, so `--json` stays an array of routes.
|
|
22
|
+
*/
|
|
23
|
+
async handler(ctx) {
|
|
24
|
+
let listing = await listRoutes(ctx.project.root);
|
|
25
|
+
let filters = {
|
|
26
|
+
grep: ctx.flags.grep,
|
|
27
|
+
controller: ctx.flags.controller,
|
|
28
|
+
method: ctx.flags.method,
|
|
29
|
+
contract: ctx.flags.contract,
|
|
30
|
+
unused: ctx.flags.unused,
|
|
31
|
+
exceptPath: ctx.flags.exceptPath,
|
|
32
|
+
};
|
|
33
|
+
let filtered = sortRoutes(filterRoutes(listing, filters), ctx.flags.sort);
|
|
34
|
+
if (ctx.flags.json)
|
|
35
|
+
ctx.stdout(formatJSON(filtered));
|
|
36
|
+
else if (filtered.routes.length === 0 && hasFilters(filters)) {
|
|
37
|
+
ctx.stdout(filters.unused ? "No unused routes found.\n" : "No routes match.\n");
|
|
38
|
+
}
|
|
39
|
+
else
|
|
40
|
+
ctx.stdout(ctx.flags.expanded ? formatExpanded(filtered) : formatTable(filtered));
|
|
41
|
+
for (let diagnostic of listing.diagnostics)
|
|
42
|
+
ctx.stderr(`${diagnostic}\n`);
|
|
43
|
+
if (filters.unused) {
|
|
44
|
+
let files = unmappedControllers(await unimportedControllers(ctx.project.root), listing, filters);
|
|
45
|
+
for (let file of files)
|
|
46
|
+
ctx.stderr(`${file}: no route maps this controller\n`);
|
|
47
|
+
}
|
|
48
|
+
return success();
|
|
49
|
+
},
|
|
50
|
+
});
|
package/dist/commands/run.d.ts
CHANGED
|
@@ -6,8 +6,24 @@
|
|
|
6
6
|
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
7
|
* @copyright Sergio Xalambrí 2026
|
|
8
8
|
*/
|
|
9
|
+
import type { Result } from "@sdxc/result";
|
|
9
10
|
/** Where the app layout puts an app's command line, relative to the project root. */
|
|
10
11
|
export declare const CLI_ENTRY = "bootstrap/cli.ts";
|
|
12
|
+
/**
|
|
13
|
+
* `PATH` with the project's `node_modules/.bin` first, as a package script has it, so a child
|
|
14
|
+
* runs the project's own `cf` or `vp` in place of a global one.
|
|
15
|
+
*
|
|
16
|
+
* @param root - The project root
|
|
17
|
+
* @param path - The run's `PATH`
|
|
18
|
+
*/
|
|
19
|
+
export declare function projectPath(root: string, path: string | undefined): string;
|
|
20
|
+
/**
|
|
21
|
+
* The command that starts the project's command line with `args`: under Bun for a project on
|
|
22
|
+
* Bun and under Node otherwise.
|
|
23
|
+
*
|
|
24
|
+
* @param root - The project root, whose `package.json` and lock file name the package manager
|
|
25
|
+
*/
|
|
26
|
+
export declare function commandLine(root: string, args: readonly string[]): Promise<Result<string[], Error>>;
|
|
11
27
|
/**
|
|
12
28
|
* Runs `bootstrap/cli.ts` under Bun for a project on Bun and under Node otherwise, with its
|
|
13
29
|
* output on the terminal and the project's `node_modules/.bin` first on `PATH`, as a package
|
package/dist/commands/run.js
CHANGED
|
@@ -16,6 +16,33 @@ import { lockFileAtOrAbove, packageManager } from "../package-manager.js";
|
|
|
16
16
|
import { readManifest } from "../upgrade/project.js";
|
|
17
17
|
/** Where the app layout puts an app's command line, relative to the project root. */
|
|
18
18
|
export const CLI_ENTRY = "bootstrap/cli.ts";
|
|
19
|
+
/**
|
|
20
|
+
* `PATH` with the project's `node_modules/.bin` first, as a package script has it, so a child
|
|
21
|
+
* runs the project's own `cf` or `vp` in place of a global one.
|
|
22
|
+
*
|
|
23
|
+
* @param root - The project root
|
|
24
|
+
* @param path - The run's `PATH`
|
|
25
|
+
*/
|
|
26
|
+
export function projectPath(root, path) {
|
|
27
|
+
let bin = join(root, "node_modules", ".bin");
|
|
28
|
+
return path === undefined ? bin : `${bin}${delimiter}${path}`;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The command that starts the project's command line with `args`: under Bun for a project on
|
|
32
|
+
* Bun and under Node otherwise.
|
|
33
|
+
*
|
|
34
|
+
* @param root - The project root, whose `package.json` and lock file name the package manager
|
|
35
|
+
*/
|
|
36
|
+
export async function commandLine(root, args) {
|
|
37
|
+
let manifest = await readManifest(root);
|
|
38
|
+
if (isFailure(manifest))
|
|
39
|
+
return manifest;
|
|
40
|
+
let manager = await packageManager({
|
|
41
|
+
declared: manifest.data.manifest.packageManager,
|
|
42
|
+
findLockFile: lockFileAtOrAbove(root),
|
|
43
|
+
});
|
|
44
|
+
return success([manager.name === "bun" ? "bun" : "node", CLI_ENTRY, ...args]);
|
|
45
|
+
}
|
|
19
46
|
/**
|
|
20
47
|
* Runs `bootstrap/cli.ts` under Bun for a project on Bun and under Node otherwise, with its
|
|
21
48
|
* output on the terminal and the project's `node_modules/.bin` first on `PATH`, as a package
|
|
@@ -30,19 +57,13 @@ export default createCommand(SDXC_COMMANDS.run, {
|
|
|
30
57
|
if (!isSuccess(await wrap(() => stat(entry)))) {
|
|
31
58
|
return failure(new Error(`${CLI_ENTRY} not found in ${root}; an app's command line starts there`));
|
|
32
59
|
}
|
|
33
|
-
let
|
|
34
|
-
if (isFailure(
|
|
35
|
-
return
|
|
36
|
-
let
|
|
37
|
-
declared: manifest.data.manifest.packageManager,
|
|
38
|
-
findLockFile: lockFileAtOrAbove(root),
|
|
39
|
-
});
|
|
40
|
-
let runtime = manager.name === "bun" ? "bun" : "node";
|
|
41
|
-
let bin = join(root, "node_modules", ".bin");
|
|
42
|
-
let ran = await ctx.exec([runtime, CLI_ENTRY, ...ctx.arguments.args], {
|
|
60
|
+
let command = await commandLine(root, ctx.arguments.args);
|
|
61
|
+
if (isFailure(command))
|
|
62
|
+
return command;
|
|
63
|
+
let ran = await ctx.exec(command.data, {
|
|
43
64
|
cwd: root,
|
|
44
65
|
stdio: "inherit",
|
|
45
|
-
env: { PATH:
|
|
66
|
+
env: { PATH: projectPath(root, ctx.env.PATH) },
|
|
46
67
|
});
|
|
47
68
|
if (isSuccess(ran))
|
|
48
69
|
return success();
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `sdxc scaffold` handler: a resource's model, migration, factory, validator, abilities, pages
|
|
3
|
+
* and, on request, MCP tools and app commands, each declared and mapped as `sdxc make` does.
|
|
4
|
+
* `createSDXC()` maps it through `lazy()`.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
declare const _default: import("@sdxc/cli").CommandAction<import("@sdxc/cli").Command<{
|
|
10
|
+
readonly name: import("@sdxc/cli").Argument<string>;
|
|
11
|
+
readonly fields: import("@sdxc/cli").Argument<string[]>;
|
|
12
|
+
}, {
|
|
13
|
+
readonly plural: import("@sdxc/cli").ValueFlag<string, false, false, false>;
|
|
14
|
+
readonly mcp: import("@sdxc/cli").Flag<boolean>;
|
|
15
|
+
readonly command: import("@sdxc/cli").Flag<boolean>;
|
|
16
|
+
readonly api: import("@sdxc/cli").Flag<boolean>;
|
|
17
|
+
readonly skip: import("@sdxc/cli").ValueFlag<"validator" | "model" | "migration" | "factory" | "policy" | "pages", false, true, false>;
|
|
18
|
+
readonly test: import("@sdxc/cli").Flag<boolean | undefined>;
|
|
19
|
+
readonly spec: import("@sdxc/cli").Flag<boolean | undefined>;
|
|
20
|
+
readonly dryRun: import("@sdxc/cli").Flag<boolean>;
|
|
21
|
+
}>, readonly [import("@sdxc/cli").CommandMiddleware<{
|
|
22
|
+
key: typeof import("../middleware.js").CurrentProject;
|
|
23
|
+
value: import("../middleware.js").Project;
|
|
24
|
+
property: "project";
|
|
25
|
+
}>, import("@sdxc/cli").CommandMiddleware<{
|
|
26
|
+
key: typeof import("../middleware.js").PackageRoot;
|
|
27
|
+
value: string;
|
|
28
|
+
property: "packageRoot";
|
|
29
|
+
}>]>;
|
|
30
|
+
export default _default;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `sdxc scaffold` handler: a resource's model, migration, factory, validator, abilities, pages
|
|
3
|
+
* and, on request, MCP tools and app commands, each declared and mapped as `sdxc make` does.
|
|
4
|
+
* `createSDXC()` maps it through `lazy()`.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import { createCommand, success } from "@sdxc/cli";
|
|
10
|
+
import { isFailure } from "@sdxc/result";
|
|
11
|
+
import { SDXC_COMMANDS } from "../contract.js";
|
|
12
|
+
import { packageRoot, project } from "../middleware.js";
|
|
13
|
+
import { scaffold } from "../scaffold/index.js";
|
|
14
|
+
export default createCommand(SDXC_COMMANDS.scaffold, {
|
|
15
|
+
middleware: [project(), packageRoot()],
|
|
16
|
+
/** Writes nothing when any part of the plan is refused; `--dry-run` prints the plan instead. */
|
|
17
|
+
async handler(ctx) {
|
|
18
|
+
let made = await scaffold(ctx, ctx.project, ctx.packageRoot, {
|
|
19
|
+
name: ctx.arguments.name,
|
|
20
|
+
fields: ctx.arguments.fields,
|
|
21
|
+
plural: ctx.flags.plural,
|
|
22
|
+
mcp: ctx.flags.mcp,
|
|
23
|
+
command: ctx.flags.command,
|
|
24
|
+
test: ctx.flags.test,
|
|
25
|
+
spec: ctx.flags.spec,
|
|
26
|
+
dryRun: ctx.flags.dryRun,
|
|
27
|
+
skip: ctx.flags.skip,
|
|
28
|
+
api: ctx.flags.api,
|
|
29
|
+
});
|
|
30
|
+
if (isFailure(made))
|
|
31
|
+
return made;
|
|
32
|
+
return success();
|
|
33
|
+
},
|
|
34
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `sdxc schedule` handler: prints every scheduled job with its next run and the trigger
|
|
3
|
+
* that fires it, as a table, or as JSON for an agent.
|
|
4
|
+
*
|
|
5
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
6
|
+
* @copyright Sergio Xalambrí 2026
|
|
7
|
+
*/
|
|
8
|
+
/** Reads the job declarations and the trigger files and prints the schedule. */
|
|
9
|
+
declare const _default: import("@sdxc/cli").CommandAction<import("@sdxc/cli").Command<Readonly<Record<string, import("@sdxc/cli").Argument<unknown>>>, {
|
|
10
|
+
readonly json: import("@sdxc/cli").Flag<boolean>;
|
|
11
|
+
}>, readonly [import("@sdxc/cli").CommandMiddleware<{
|
|
12
|
+
key: typeof import("../middleware.js").CurrentProject;
|
|
13
|
+
value: import("../middleware.js").Project;
|
|
14
|
+
property: "project";
|
|
15
|
+
}>]>;
|
|
16
|
+
export default _default;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `sdxc schedule` handler: prints every scheduled job with its next run and the trigger
|
|
3
|
+
* that fires it, as a table, or as JSON for an agent.
|
|
4
|
+
*
|
|
5
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
6
|
+
* @copyright Sergio Xalambrí 2026
|
|
7
|
+
*/
|
|
8
|
+
import { createCommand, success } from "@sdxc/cli";
|
|
9
|
+
import { SDXC_COMMANDS } from "../contract.js";
|
|
10
|
+
import { project } from "../middleware.js";
|
|
11
|
+
import { formatSchedule, listSchedule } from "../schedule.js";
|
|
12
|
+
/** Reads the job declarations and the trigger files and prints the schedule. */
|
|
13
|
+
export default createCommand(SDXC_COMMANDS.schedule, {
|
|
14
|
+
middleware: [project()],
|
|
15
|
+
/** Always succeeds once the project is found; a job no trigger fires is a row that says so. */
|
|
16
|
+
async handler(ctx) {
|
|
17
|
+
let listing = await listSchedule(ctx.project.root);
|
|
18
|
+
ctx.stdout(ctx.flags.json ? `${JSON.stringify(listing, null, 2)}\n` : formatSchedule(listing));
|
|
19
|
+
return success();
|
|
20
|
+
},
|
|
21
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `sdxc stats` handler: prints the lines of code per kind of code the app layout names and
|
|
3
|
+
* the code to test ratio, as a table, or as JSON for an agent.
|
|
4
|
+
*
|
|
5
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
6
|
+
* @copyright Sergio Xalambrí 2026
|
|
7
|
+
*/
|
|
8
|
+
/** Counts the project's code and prints the table. */
|
|
9
|
+
declare const _default: import("@sdxc/cli").CommandAction<import("@sdxc/cli").Command<Readonly<Record<string, import("@sdxc/cli").Argument<unknown>>>, {
|
|
10
|
+
readonly json: import("@sdxc/cli").Flag<boolean>;
|
|
11
|
+
}>, readonly [import("@sdxc/cli").CommandMiddleware<{
|
|
12
|
+
key: typeof import("../middleware.js").CurrentProject;
|
|
13
|
+
value: import("../middleware.js").Project;
|
|
14
|
+
property: "project";
|
|
15
|
+
}>]>;
|
|
16
|
+
export default _default;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `sdxc stats` handler: prints the lines of code per kind of code the app layout names and
|
|
3
|
+
* the code to test ratio, as a table, or as JSON for an agent.
|
|
4
|
+
*
|
|
5
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
6
|
+
* @copyright Sergio Xalambrí 2026
|
|
7
|
+
*/
|
|
8
|
+
import { createCommand, success } from "@sdxc/cli";
|
|
9
|
+
import { SDXC_COMMANDS } from "../contract.js";
|
|
10
|
+
import { project } from "../middleware.js";
|
|
11
|
+
import { formatStats, projectStats } from "../stats.js";
|
|
12
|
+
/** Counts the project's code and prints the table. */
|
|
13
|
+
export default createCommand(SDXC_COMMANDS.stats, {
|
|
14
|
+
middleware: [project()],
|
|
15
|
+
/** Always succeeds once the project is found; an empty project prints a table of totals. */
|
|
16
|
+
async handler(ctx) {
|
|
17
|
+
let stats = await projectStats(ctx.project.root);
|
|
18
|
+
ctx.stdout(ctx.flags.json ? `${JSON.stringify(stats, null, 2)}\n` : formatStats(stats));
|
|
19
|
+
return success();
|
|
20
|
+
},
|
|
21
|
+
});
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The `sdxc ui update` handler: replaces copied files with the installed version. A file the
|
|
3
|
-
* project edited is replaced only with `--force`, or when the user says yes on a terminal
|
|
3
|
+
* project edited is replaced only with `--force`, or when the user says yes on a terminal;
|
|
4
|
+
* `--all` covers every copy and leaves edited files without asking, so it is safe unattended.
|
|
4
5
|
*
|
|
5
6
|
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
6
7
|
* @copyright Sergio Xalambrí 2026
|
|
7
8
|
*/
|
|
8
|
-
/** Updates the named copies and prints what it replaced and
|
|
9
|
+
/** Updates the named copies, or every copy with `--all`, and prints what it replaced and left. */
|
|
9
10
|
declare const _default: import("@sdxc/cli").CommandAction<import("@sdxc/cli").Command<{
|
|
10
|
-
readonly components: import("@sdxc/cli").Argument<
|
|
11
|
+
readonly components: import("@sdxc/cli").Argument<string[]>;
|
|
11
12
|
}, {
|
|
13
|
+
readonly all: import("@sdxc/cli").Flag<boolean>;
|
|
14
|
+
readonly withDeps: import("@sdxc/cli").Flag<boolean>;
|
|
12
15
|
readonly force: import("@sdxc/cli").Flag<boolean>;
|
|
13
16
|
readonly dryRun: import("@sdxc/cli").Flag<boolean>;
|
|
14
17
|
}>, readonly [import("@sdxc/cli").CommandMiddleware<{
|
|
@@ -1,26 +1,43 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The `sdxc ui update` handler: replaces copied files with the installed version. A file the
|
|
3
|
-
* project edited is replaced only with `--force`, or when the user says yes on a terminal
|
|
3
|
+
* project edited is replaced only with `--force`, or when the user says yes on a terminal;
|
|
4
|
+
* `--all` covers every copy and leaves edited files without asking, so it is safe unattended.
|
|
4
5
|
*
|
|
5
6
|
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
6
7
|
* @copyright Sergio Xalambrí 2026
|
|
7
8
|
*/
|
|
8
|
-
import { createCommand, success } from "@sdxc/cli";
|
|
9
|
+
import { createCommand, success, usage } from "@sdxc/cli";
|
|
9
10
|
import { isFailure, success as succeed } from "@sdxc/result";
|
|
10
11
|
import { SDXC_COMMANDS } from "../../contract.js";
|
|
12
|
+
import { uiEntries } from "../../lock.js";
|
|
11
13
|
import { packageRoot, project } from "../../middleware.js";
|
|
12
14
|
import { finishPlan, loadContext, planUpdate } from "../../ui/commands.js";
|
|
13
|
-
/** Updates the named copies and prints what it replaced and
|
|
15
|
+
/** Updates the named copies, or every copy with `--all`, and prints what it replaced and left. */
|
|
14
16
|
export default createCommand(SDXC_COMMANDS.ui.update, {
|
|
15
17
|
middleware: [project(), packageRoot()],
|
|
16
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Exits 2 when neither names nor `--all` are given, or both are. Without a terminal and
|
|
20
|
+
* without `--force`, every edited file is left as it is.
|
|
21
|
+
*/
|
|
17
22
|
async handler(ctx) {
|
|
23
|
+
let named = ctx.arguments.components;
|
|
24
|
+
let all = ctx.flags.all;
|
|
25
|
+
if (named.length === 0 && !all)
|
|
26
|
+
return usage("Name the copies to update, or pass --all");
|
|
27
|
+
if (named.length > 0 && all)
|
|
28
|
+
return usage("Name the copies to update or pass --all, not both");
|
|
18
29
|
let context = await loadContext(ctx.project, ctx.packageRoot);
|
|
19
30
|
if (isFailure(context))
|
|
20
31
|
return context;
|
|
21
|
-
let
|
|
22
|
-
|
|
23
|
-
|
|
32
|
+
let names = all ? uiEntries(context.data.lock).map((entry) => entry.name) : named;
|
|
33
|
+
if (names.length === 0) {
|
|
34
|
+
ctx.stdout("No component is copied; sdxc ui add copies one\n");
|
|
35
|
+
return success();
|
|
36
|
+
}
|
|
37
|
+
let plan = await planUpdate(context.data, names, {
|
|
38
|
+
withDeps: ctx.flags.withDeps,
|
|
39
|
+
overwrite: (path) => ctx.flags.force || all
|
|
40
|
+
? Promise.resolve(succeed(ctx.flags.force))
|
|
24
41
|
: ctx.prompt.confirm({
|
|
25
42
|
message: `${path} is edited; replace it with the installed version?`,
|
|
26
43
|
default: false,
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
*/
|
|
9
9
|
/**
|
|
10
10
|
* Exits 0 when done or already up to date, 1 when the upgrade failed or the target is older.
|
|
11
|
-
*
|
|
11
|
+
* A target equal to the project's release still re-pins what lags behind it, `remix` included,
|
|
12
|
+
* so "up to date" means no pin moves. Progress goes to stderr; stdout carries only the prompt.
|
|
12
13
|
*/
|
|
13
14
|
declare const _default: import("@sdxc/cli").CommandAction<import("@sdxc/cli").Command<{
|
|
14
15
|
readonly version: import("@sdxc/cli").Argument<string | undefined>;
|
|
@@ -17,6 +18,7 @@ declare const _default: import("@sdxc/cli").CommandAction<import("@sdxc/cli").Co
|
|
|
17
18
|
readonly output: import("@sdxc/cli").ValueFlag<string, false, false, false>;
|
|
18
19
|
readonly prompt: import("@sdxc/cli").Flag<boolean>;
|
|
19
20
|
readonly from: import("@sdxc/cli").ValueFlag<string, false, false, false>;
|
|
21
|
+
readonly since: import("@sdxc/cli").ValueFlag<string, false, true, false>;
|
|
20
22
|
readonly remixFrom: import("@sdxc/cli").ValueFlag<string, false, false, false>;
|
|
21
23
|
}>, readonly [import("@sdxc/cli").CommandMiddleware<{
|
|
22
24
|
key: typeof import("../middleware.js").CurrentProject;
|
package/dist/commands/upgrade.js
CHANGED
|
@@ -14,16 +14,17 @@ import { compare } from "@sdxc/semver";
|
|
|
14
14
|
import { SDXC_COMMANDS } from "../contract.js";
|
|
15
15
|
import { packageRoot, project } from "../middleware.js";
|
|
16
16
|
import { lockFileAtOrAbove, packageManager } from "../package-manager.js";
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import { bumpManifest, currentRelease, listedScopedPackages, lists, projectImports, readManifest, } from "../upgrade/project.js";
|
|
17
|
+
import { datedPin, fetchPackuments, scopedPackageOf, versionAtRelease, versionsAt, } from "../releases.js";
|
|
18
|
+
import { AGENTS_FILE, planAgentsFile, writeAgentsFile } from "../upgrade/agents.js";
|
|
19
|
+
import { bumpManifest, currentRelease, listedScopedPackages, lists, pinnedRelease, projectImports, readManifest, } from "../upgrade/project.js";
|
|
20
20
|
import { buildPrompt } from "../upgrade/prompt.js";
|
|
21
21
|
import { fetchChangelog, fetchRelease, RELEASE_PACKAGE } from "../upgrade/registry.js";
|
|
22
22
|
/** The middleware `upgrade` runs behind. */
|
|
23
23
|
const UPGRADE_MIDDLEWARE = [project(), packageRoot()];
|
|
24
24
|
/**
|
|
25
25
|
* Exits 0 when done or already up to date, 1 when the upgrade failed or the target is older.
|
|
26
|
-
*
|
|
26
|
+
* A target equal to the project's release still re-pins what lags behind it, `remix` included,
|
|
27
|
+
* so "up to date" means no pin moves. Progress goes to stderr; stdout carries only the prompt.
|
|
27
28
|
*/
|
|
28
29
|
export default createCommand(SDXC_COMMANDS.upgrade, {
|
|
29
30
|
middleware: UPGRADE_MIDDLEWARE,
|
|
@@ -57,13 +58,37 @@ export default createCommand(SDXC_COMMANDS.upgrade, {
|
|
|
57
58
|
if (order < 0) {
|
|
58
59
|
return failure(new Error(`Release ${release.version} is older than the project's ${current}; upgrade only moves forward`));
|
|
59
60
|
}
|
|
60
|
-
|
|
61
|
-
|
|
61
|
+
let pins = await ctx.task(`Resolving ${scoped.length} @sdxc packages at ${release.version}`, async (task) => {
|
|
62
|
+
let packuments = await fetchPackuments(scoped, task.signal);
|
|
63
|
+
if (isFailure(packuments))
|
|
64
|
+
return packuments;
|
|
65
|
+
let versions = versionsAt(packuments.data, release.version);
|
|
66
|
+
if (isFailure(versions))
|
|
67
|
+
return versions;
|
|
68
|
+
return success({
|
|
69
|
+
versions: versions.data,
|
|
70
|
+
since: laggingSince(manifest, packuments.data, current),
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
if (isFailure(pins))
|
|
74
|
+
return pins;
|
|
75
|
+
let { since } = pins.data;
|
|
76
|
+
let versions = Object.fromEntries(pins.data.versions);
|
|
77
|
+
if (release.remix !== null && lists(manifest, "remix"))
|
|
78
|
+
versions.remix = release.remix;
|
|
79
|
+
let bumped = bumpManifest(text, versions);
|
|
80
|
+
if (bumped.bumps.length === 0) {
|
|
81
|
+
ctx.stderr(`The @sdxc packages are up to date at ${release.version}\n`);
|
|
62
82
|
return success();
|
|
63
83
|
}
|
|
64
|
-
let imports = await projectImports(root);
|
|
65
84
|
if (changelog !== null) {
|
|
66
|
-
let
|
|
85
|
+
let imports = await projectImports(root);
|
|
86
|
+
let proceed = await confirmBreaking(ctx, changelog, {
|
|
87
|
+
from: current,
|
|
88
|
+
since,
|
|
89
|
+
to: release.version,
|
|
90
|
+
imports,
|
|
91
|
+
});
|
|
67
92
|
if (isFailure(proceed))
|
|
68
93
|
return proceed;
|
|
69
94
|
if (!proceed.data) {
|
|
@@ -71,13 +96,6 @@ export default createCommand(SDXC_COMMANDS.upgrade, {
|
|
|
71
96
|
return success();
|
|
72
97
|
}
|
|
73
98
|
}
|
|
74
|
-
let pins = await ctx.task(`Resolving ${scoped.length} @sdxc packages at ${release.version}`, (task) => resolveRelease(scoped, release.version, task.signal));
|
|
75
|
-
if (isFailure(pins))
|
|
76
|
-
return pins;
|
|
77
|
-
let versions = Object.fromEntries(pins.data);
|
|
78
|
-
if (release.remix !== null && lists(manifest, "remix"))
|
|
79
|
-
versions.remix = release.remix;
|
|
80
|
-
let bumped = bumpManifest(text, versions);
|
|
81
99
|
let written = await wrap(() => writeFile(resolve(root, "package.json"), bumped.text));
|
|
82
100
|
if (isFailure(written))
|
|
83
101
|
return written;
|
|
@@ -96,6 +114,7 @@ export default createCommand(SDXC_COMMANDS.upgrade, {
|
|
|
96
114
|
"--prompt",
|
|
97
115
|
"--from",
|
|
98
116
|
current,
|
|
117
|
+
...[...since].flatMap(([name, pinned]) => ["--since", `${name}@${pinned}`]),
|
|
99
118
|
...(remixFrom === null ? [] : ["--remix-from", remixFrom]),
|
|
100
119
|
...(output === null ? [] : ["--output", output]),
|
|
101
120
|
];
|
|
@@ -113,16 +132,41 @@ export default createCommand(SDXC_COMMANDS.upgrade, {
|
|
|
113
132
|
return success();
|
|
114
133
|
},
|
|
115
134
|
});
|
|
116
|
-
/**
|
|
135
|
+
/**
|
|
136
|
+
* Rewrites the sdxc section of the project's `AGENTS.md` from this kit's release, then prints
|
|
137
|
+
* the prompt for that release, or writes it to `output`.
|
|
138
|
+
*/
|
|
117
139
|
async function printPrompt(ctx, from, output) {
|
|
140
|
+
let since = new Map();
|
|
141
|
+
for (let value of ctx.flags.since) {
|
|
142
|
+
let at = value.lastIndexOf("@");
|
|
143
|
+
let pinned = at > 0 ? datedPin(value.slice(at + 1)) : null;
|
|
144
|
+
if (pinned === null) {
|
|
145
|
+
return usage("--since takes <package>@<version>, such as @sdxc/jwt@2026.9.4");
|
|
146
|
+
}
|
|
147
|
+
since.set(value.slice(0, at), pinned);
|
|
148
|
+
}
|
|
149
|
+
let agents = await planAgentsFile(ctx.project.root, ctx.packageRoot);
|
|
150
|
+
if (isFailure(agents))
|
|
151
|
+
return agents;
|
|
118
152
|
let prompt = await buildPrompt({
|
|
119
153
|
root: ctx.project.root,
|
|
120
154
|
packageRoot: ctx.packageRoot,
|
|
121
155
|
from,
|
|
122
156
|
remixFrom: ctx.flags.remixFrom ?? null,
|
|
157
|
+
since,
|
|
158
|
+
...(agents.data === null ? {} : { agents: agents.data.status }),
|
|
123
159
|
});
|
|
124
160
|
if (isFailure(prompt))
|
|
125
161
|
return prompt;
|
|
162
|
+
if (agents.data !== null) {
|
|
163
|
+
let refreshed = await writeAgentsFile(ctx.project.root, agents.data);
|
|
164
|
+
if (isFailure(refreshed))
|
|
165
|
+
return refreshed;
|
|
166
|
+
if (agents.data.status === "refreshed") {
|
|
167
|
+
ctx.stderr(`${AGENTS_FILE}: refreshed the sdxc section\n`);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
126
170
|
if (output === null) {
|
|
127
171
|
ctx.stdout(prompt.data);
|
|
128
172
|
return success();
|
|
@@ -135,7 +179,7 @@ async function printPrompt(ctx, from, output) {
|
|
|
135
179
|
return success();
|
|
136
180
|
}
|
|
137
181
|
/**
|
|
138
|
-
* Finds the release `version` names on npm, and,
|
|
182
|
+
* Finds the release `version` names on npm, and, unless it is older than `current`, the
|
|
139
183
|
* changelog it ships. A changelog the CDN cannot serve is `null`, which skips the question
|
|
140
184
|
* about breaking changes rather than the upgrade.
|
|
141
185
|
*/
|
|
@@ -145,7 +189,7 @@ async function lookUp(ctx, version, current) {
|
|
|
145
189
|
if (isFailure(release))
|
|
146
190
|
return release;
|
|
147
191
|
task.update(`Found release ${release.data.version}`);
|
|
148
|
-
if (compare(release.data.version, current)
|
|
192
|
+
if (compare(release.data.version, current) < 0) {
|
|
149
193
|
return success({ release: release.data, changelog: null });
|
|
150
194
|
}
|
|
151
195
|
let changelog = await fetchChangelog(release.data.version, task.signal);
|
|
@@ -156,21 +200,42 @@ async function lookUp(ctx, version, current) {
|
|
|
156
200
|
});
|
|
157
201
|
}
|
|
158
202
|
/**
|
|
159
|
-
*
|
|
160
|
-
*
|
|
203
|
+
* The release each listed `@sdxc/*` package is pinned to when that pin is older than its version
|
|
204
|
+
* at `current`, by name, so the prompt covers its changes from its own pin; a package at its
|
|
205
|
+
* version, or pinned to no dated release, is left out and covered from `current`.
|
|
206
|
+
*/
|
|
207
|
+
function laggingSince(manifest, packuments, current) {
|
|
208
|
+
let since = new Map();
|
|
209
|
+
for (let packument of packuments) {
|
|
210
|
+
let pinned = pinnedRelease(manifest, packument.name);
|
|
211
|
+
let expected = versionAtRelease(packument, current);
|
|
212
|
+
if (pinned !== null && expected !== null && compare(pinned, expected) < 0) {
|
|
213
|
+
since.set(packument.name, pinned);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return since;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Lists the breaking changes the move brings to packages the project imports, each package's
|
|
220
|
+
* from its entry in `since` or else `from`, up to `to`, and asks whether to go on. Without a
|
|
221
|
+
* terminal the upgrade goes on; with none to list nothing is asked.
|
|
161
222
|
*
|
|
162
223
|
* @returns Whether to bump `package.json`
|
|
163
224
|
*/
|
|
164
|
-
async function confirmBreaking(ctx, changelog,
|
|
225
|
+
async function confirmBreaking(ctx, changelog, range) {
|
|
165
226
|
let imported = new Set();
|
|
166
|
-
for (let specifier of imports.keys()) {
|
|
227
|
+
for (let specifier of range.imports.keys()) {
|
|
167
228
|
let name = scopedPackageOf(specifier);
|
|
168
229
|
if (name !== null)
|
|
169
230
|
imported.add(name);
|
|
170
231
|
}
|
|
171
|
-
let breaking =
|
|
232
|
+
let breaking = changelog.filter((entry) => entry.breaking &&
|
|
233
|
+
imported.has(entry.package) &&
|
|
234
|
+
compare(entry.release, range.since.get(entry.package) ?? range.from) > 0 &&
|
|
235
|
+
compare(entry.release, range.to) <= 0);
|
|
172
236
|
if (breaking.length === 0)
|
|
173
237
|
return success(true);
|
|
238
|
+
let to = range.to;
|
|
174
239
|
let count = breaking.length === 1 ? "1 breaking change" : `${breaking.length} breaking changes`;
|
|
175
240
|
ctx.stderr(`Release ${to} brings ${count} to packages this project imports:\n`);
|
|
176
241
|
for (let entry of breaking) {
|