@sdxc/kit 2026.10.16 → 2026.10.20
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 +391 -20
- package/changelog.jsonl +1160 -1035
- package/config.schema.json +47 -1
- package/dist/author.d.ts +36 -0
- package/dist/author.js +107 -0
- package/dist/cli.js +12 -0
- package/dist/commands/create.js +9 -4
- 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 +72 -6
- package/dist/commands/make.js +127 -19
- 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 +18 -2
- package/dist/commands/run.js +35 -12
- package/dist/commands/scaffold.d.ts +29 -0
- package/dist/commands/scaffold.js +33 -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 +18 -0
- package/dist/config.js +28 -1
- package/dist/contract.d.ts +97 -3
- package/dist/contract.js +360 -26
- package/dist/create/templates.d.ts +8 -1
- package/dist/create/templates.js +26 -2
- package/dist/dependencies.d.ts +4 -1
- package/dist/dependencies.js +13 -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 +311 -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 +68 -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/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/init.d.ts +5 -3
- package/dist/init.js +15 -7
- 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 +32 -4
- package/dist/make/declare.js +405 -27
- 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 +16 -5
- package/dist/make/generate.js +43 -14
- 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 +47 -4
- package/dist/make/index.js +287 -25
- package/dist/make/kinds.d.ts +31 -3
- package/dist/make/kinds.js +82 -9
- 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 +7 -5
- package/dist/make/stubs.js +16 -5
- package/dist/make/test.d.ts +43 -0
- package/dist/make/test.js +149 -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 +37 -0
- package/dist/scaffold/index.js +613 -0
- package/dist/scaffold/render.d.ts +51 -0
- package/dist/scaffold/render.js +332 -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/testing.d.ts +12 -2
- package/dist/testing.js +22 -3
- 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/stubs/command.stub +4 -0
- package/stubs/command.test.stub +3 -0
- package/stubs/controller.api.resource.stub +23 -0
- package/stubs/controller.api.stub +21 -0
- package/stubs/controller.api.test.stub +18 -0
- package/stubs/controller.form.stub +40 -10
- package/stubs/controller.form.test.stub +61 -0
- package/stubs/controller.resource.form.stub +67 -0
- package/stubs/controller.resource.stub +28 -0
- package/stubs/controller.stub +15 -8
- package/stubs/controller.test.stub +3 -0
- package/stubs/email.stub +15 -38
- package/stubs/email.test.stub +12 -7
- package/stubs/factory.stub +4 -1
- package/stubs/initializer.stub +2 -0
- package/stubs/initializer.test.stub +3 -0
- package/stubs/job.cron.stub +4 -0
- package/stubs/job.stub +4 -0
- package/stubs/job.test.stub +3 -0
- package/stubs/mcp.resource.stub +3 -0
- package/stubs/mcp.stub +3 -0
- package/stubs/mcp.test.stub +3 -0
- package/stubs/middleware.stub +6 -1
- package/stubs/middleware.test.stub +3 -0
- package/stubs/model.stub +12 -3
- package/stubs/model.test.stub +3 -0
- package/stubs/policy.test.stub +36 -7
- 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 +2 -0
- package/stubs/scaffold.model.stub +35 -0
- package/stubs/scaffold.model.test.stub +25 -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/stubs/service.stub +4 -0
- package/stubs/service.test.stub +3 -0
- package/stubs/validator.stub +3 -0
- package/stubs/validator.test.stub +3 -0
- package/templates/app/.env.example +16 -0
- package/templates/app/AGENTS.md +163 -0
- package/templates/app/CLAUDE.md +1 -0
- package/templates/app/README.md +79 -37
- package/templates/app/app/commands/about.test.ts +1 -1
- 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/console.ts +6 -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 +46 -0
- package/templates/app/app/commands/db/migrate.ts +88 -0
- 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 +72 -1
- package/templates/app/app/commands/typegen.test.ts +17 -0
- package/templates/app/app/commands/typegen.ts +16 -0
- package/templates/app/app/emails/index.ts +10 -0
- package/templates/app/app/http/controllers/api/health.tsx +15 -0
- package/templates/app/app/http/controllers/api/not-found.tsx +16 -0
- package/templates/app/app/http/controllers/api/openapi.tsx +17 -0
- package/templates/app/app/http/controllers/home.tsx +21 -13
- package/templates/app/app/http/controllers/mcp.tsx +16 -0
- package/templates/app/app/http/controllers/not-found.tsx +23 -18
- package/templates/app/app/http/controllers/robots.test.ts +18 -0
- package/templates/app/app/http/controllers/robots.ts +24 -0
- package/templates/app/app/http/controllers/sitemap.test.ts +28 -0
- package/templates/app/app/http/controllers/sitemap.ts +25 -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 +19 -0
- package/templates/app/app/http/middleware/page.test.ts +43 -0
- package/templates/app/app/http/middleware/page.ts +51 -0
- package/templates/app/app/http/middleware/server-timing.test.ts +15 -0
- package/templates/app/app/http/middleware/server-timing.ts +42 -0
- package/templates/app/app/initializers/assets.ts +1 -1
- package/templates/app/app/initializers/captcha.ts +11 -0
- package/templates/app/app/initializers/cli.ts +68 -2
- package/templates/app/app/initializers/database.test.ts +18 -0
- package/templates/app/app/initializers/database.ts +18 -0
- package/templates/app/app/initializers/dispatcher.ts +26 -0
- package/templates/app/app/initializers/honeypot.ts +11 -0
- package/templates/app/app/initializers/i18n.test.ts +16 -0
- package/templates/app/app/initializers/i18n.ts +28 -0
- package/templates/app/app/initializers/local-database.test.ts +33 -0
- package/templates/app/app/initializers/local-database.ts +53 -0
- package/templates/app/app/initializers/mail-transport.test.ts +27 -0
- package/templates/app/app/initializers/mail-transport.ts +26 -0
- package/templates/app/app/initializers/mail.test.ts +27 -0
- package/templates/app/app/initializers/mail.ts +19 -0
- package/templates/app/app/initializers/mcp.ts +1 -1
- package/templates/app/app/initializers/openapi.ts +21 -0
- package/templates/app/app/initializers/router.test.ts +68 -0
- package/templates/app/app/initializers/router.tsx +81 -25
- package/templates/app/app/initializers/seo.ts +15 -0
- package/templates/app/app/initializers/session.test.ts +34 -0
- package/templates/app/app/initializers/session.ts +29 -0
- package/templates/app/app/initializers/spam.ts +10 -0
- 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/models/index.ts +10 -0
- 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 +92 -0
- package/templates/app/app/services/migrations.ts +117 -0
- package/templates/app/app/test/cloudflare-workers.ts +25 -0
- package/templates/app/app/test/local-database.ts +67 -0
- package/templates/app/app/test/session.ts +28 -0
- package/templates/app/bootstrap/cli.ts +1 -1
- package/templates/app/bootstrap/console.ts +13 -0
- package/templates/app/bootstrap/worker.ts +4 -4
- package/templates/app/cloudflare.config.ts +30 -2
- package/templates/app/config/constants.ts +19 -0
- package/templates/app/config/problems.ts +24 -0
- package/templates/app/config/security-policy.ts +34 -0
- package/templates/app/config/security-txt.ts +28 -0
- package/templates/app/database/migrations/.gitkeep +0 -0
- package/templates/app/database/seed.ts +12 -0
- package/templates/app/package.json +37 -6
- package/templates/app/resources/layouts/document.tsx +28 -7
- package/templates/app/resources/locales/en.json +10 -0
- package/templates/app/routes/api.ts +29 -0
- package/templates/app/routes/web.ts +6 -4
- package/templates/app/vite.config.ts +4 -0
- package/stubs/policy.stub +0 -13
- package/templates/app/config/router-context.d.ts +0 -20
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `sdxc models` handler: loads each model in the project's runtime and prints its table and
|
|
3
|
+
* how the migrations compare with it, as a list, one model in full, or JSON for an agent.
|
|
4
|
+
*
|
|
5
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
6
|
+
* @copyright Sergio Xalambrí 2026
|
|
7
|
+
*/
|
|
8
|
+
/** Prints every model as a row, or each named one in full. */
|
|
9
|
+
declare const _default: import("@sdxc/cli").CommandAction<import("@sdxc/cli").Command<{
|
|
10
|
+
readonly names: import("@sdxc/cli").Argument<string[]>;
|
|
11
|
+
}, {
|
|
12
|
+
readonly json: import("@sdxc/cli").Flag<boolean>;
|
|
13
|
+
}>, readonly [import("@sdxc/cli").CommandMiddleware<{
|
|
14
|
+
key: typeof import("../middleware.js").CurrentProject;
|
|
15
|
+
value: import("../middleware.js").Project;
|
|
16
|
+
property: "project";
|
|
17
|
+
}>]>;
|
|
18
|
+
export default _default;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `sdxc models` handler: loads each model in the project's runtime and prints its table and
|
|
3
|
+
* how the migrations compare with it, as a list, one model in full, or 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 { isFailure } from "@sdxc/result";
|
|
10
|
+
import { SDXC_COMMANDS } from "../contract.js";
|
|
11
|
+
import { project } from "../middleware.js";
|
|
12
|
+
import { formatModel, formatModelList, summarizeModels } from "../models.js";
|
|
13
|
+
/** Prints every model as a row, or each named one in full. */
|
|
14
|
+
export default createCommand(SDXC_COMMANDS.models, {
|
|
15
|
+
middleware: [project()],
|
|
16
|
+
/** Fails naming the model when one is unknown or cannot be loaded. */
|
|
17
|
+
async handler(ctx) {
|
|
18
|
+
let models = await summarizeModels(ctx, ctx.project, ctx.arguments.names);
|
|
19
|
+
if (isFailure(models))
|
|
20
|
+
return models;
|
|
21
|
+
if (ctx.flags.json)
|
|
22
|
+
ctx.stdout(`${JSON.stringify(models.data, null, 2)}\n`);
|
|
23
|
+
else if (ctx.arguments.names.length === 0)
|
|
24
|
+
ctx.stdout(formatModelList(models.data));
|
|
25
|
+
else
|
|
26
|
+
ctx.stdout(models.data.map(formatModel).join("\n"));
|
|
27
|
+
return success();
|
|
28
|
+
},
|
|
29
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
/** Reads the project's code and prints its notes. */
|
|
9
|
+
declare const _default: import("@sdxc/cli").CommandAction<import("@sdxc/cli").Command<Readonly<Record<string, import("@sdxc/cli").Argument<unknown>>>, {
|
|
10
|
+
readonly tag: import("@sdxc/cli").ValueFlag<string, false, true, false>;
|
|
11
|
+
readonly json: import("@sdxc/cli").Flag<boolean>;
|
|
12
|
+
}>, readonly [import("@sdxc/cli").CommandMiddleware<{
|
|
13
|
+
key: typeof import("../middleware.js").CurrentProject;
|
|
14
|
+
value: import("../middleware.js").Project;
|
|
15
|
+
property: "project";
|
|
16
|
+
}>]>;
|
|
17
|
+
export default _default;
|
|
@@ -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,12 +6,28 @@
|
|
|
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
|
-
* output on the terminal
|
|
14
|
-
*
|
|
29
|
+
* output on the terminal and the project's `node_modules/.bin` first on `PATH`, as a package
|
|
30
|
+
* script has it; the app's exit code is `sdxc run`'s, and only the app's messages print on failure.
|
|
15
31
|
*/
|
|
16
32
|
declare const _default: import("@sdxc/cli").CommandAction<import("@sdxc/cli").Command<{
|
|
17
33
|
readonly args: import("@sdxc/cli").Argument<string[]>;
|
package/dist/commands/run.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @copyright Sergio Xalambrí 2026
|
|
8
8
|
*/
|
|
9
9
|
import { stat } from "node:fs/promises";
|
|
10
|
-
import { join } from "node:path";
|
|
10
|
+
import { delimiter, join } from "node:path";
|
|
11
11
|
import { createCommand, ExecError, exit, failure, success } from "@sdxc/cli";
|
|
12
12
|
import { isFailure, isSuccess, wrap } from "@sdxc/result";
|
|
13
13
|
import { SDXC_COMMANDS } from "../contract.js";
|
|
@@ -16,10 +16,37 @@ 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
|
-
* output on the terminal
|
|
22
|
-
*
|
|
48
|
+
* output on the terminal and the project's `node_modules/.bin` first on `PATH`, as a package
|
|
49
|
+
* script has it; the app's exit code is `sdxc run`'s, and only the app's messages print on failure.
|
|
23
50
|
*/
|
|
24
51
|
export default createCommand(SDXC_COMMANDS.run, {
|
|
25
52
|
middleware: [project()],
|
|
@@ -30,17 +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 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, {
|
|
42
64
|
cwd: root,
|
|
43
65
|
stdio: "inherit",
|
|
66
|
+
env: { PATH: projectPath(root, ctx.env.PATH) },
|
|
44
67
|
});
|
|
45
68
|
if (isSuccess(ran))
|
|
46
69
|
return success();
|
|
@@ -0,0 +1,29 @@
|
|
|
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 dryRun: import("@sdxc/cli").Flag<boolean>;
|
|
20
|
+
}>, readonly [import("@sdxc/cli").CommandMiddleware<{
|
|
21
|
+
key: typeof import("../middleware.js").CurrentProject;
|
|
22
|
+
value: import("../middleware.js").Project;
|
|
23
|
+
property: "project";
|
|
24
|
+
}>, import("@sdxc/cli").CommandMiddleware<{
|
|
25
|
+
key: typeof import("../middleware.js").PackageRoot;
|
|
26
|
+
value: string;
|
|
27
|
+
property: "packageRoot";
|
|
28
|
+
}>]>;
|
|
29
|
+
export default _default;
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
dryRun: ctx.flags.dryRun,
|
|
26
|
+
skip: ctx.flags.skip,
|
|
27
|
+
api: ctx.flags.api,
|
|
28
|
+
});
|
|
29
|
+
if (isFailure(made))
|
|
30
|
+
return made;
|
|
31
|
+
return success();
|
|
32
|
+
},
|
|
33
|
+
});
|
|
@@ -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;
|