@sdxc/kit 2026.11.1 → 2026.11.4
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 +68 -0
- package/changelog.jsonl +260 -0
- package/config.schema.json +14 -0
- package/dist/ci/install.d.ts +15 -0
- package/dist/ci/install.js +27 -0
- package/dist/ci/locate.d.ts +23 -0
- package/dist/ci/locate.js +43 -0
- package/dist/cli.js +6 -0
- package/dist/commands/ci/clean.d.ts +11 -0
- package/dist/commands/ci/clean.js +15 -0
- package/dist/commands/ci/list.d.ts +16 -0
- package/dist/commands/ci/list.js +24 -0
- package/dist/commands/ci/run.d.ts +70 -0
- package/dist/commands/ci/run.js +43 -0
- package/dist/commands/ci/signoff.d.ts +15 -0
- package/dist/commands/ci/signoff.js +15 -0
- package/dist/commands/ci/verify.d.ts +17 -0
- package/dist/commands/ci/verify.js +15 -0
- package/dist/commands/create.js +3 -0
- package/dist/commands/pkg.d.ts +16 -0
- package/dist/commands/pkg.js +71 -0
- package/dist/commands/routes.d.ts +1 -1
- package/dist/config.d.ts +10 -4
- package/dist/config.js +8 -0
- package/dist/contract.d.ts +65 -1
- package/dist/contract.js +51 -0
- package/dist/create/workspace.d.ts +15 -0
- package/dist/create/workspace.js +42 -0
- package/dist/doctor/checks.js +4 -0
- package/dist/doctor/ci.d.ts +15 -0
- package/dist/doctor/ci.js +63 -0
- package/dist/doctor/translations.d.ts +19 -0
- package/dist/doctor/translations.js +144 -0
- package/dist/package-manager.d.ts +2 -0
- package/dist/package-manager.js +16 -2
- package/dist/pkg/catalog.d.ts +12 -0
- package/dist/pkg/catalog.js +153 -0
- package/dist/pkg/resolve.d.ts +67 -0
- package/dist/pkg/resolve.js +147 -0
- package/dist/upgrade/changelog.d.ts +2 -2
- package/dist/upgrade/project.d.ts +2 -2
- package/package.json +10 -8
- package/registry/ui/banner.json +16 -0
- package/registry/ui/confirm.json +8 -4
- package/registry/ui/group.json +2 -2
- package/registry/ui/input.json +2 -2
- package/registry/ui/link-button.json +2 -2
- package/registry/ui/property-list.json +18 -0
- package/registry/ui/relative-time.json +17 -0
- package/registry/ui/status-dot.json +16 -0
- package/registry/ui/text-field.json +7 -3
- package/registry/ui/timeline.json +16 -0
- package/registry/ui/typeset.json +2 -2
- package/templates/app/.config/sdxc/ci.ts +26 -0
- package/templates/app/.github/workflows/ci.yml +46 -0
- package/templates/app/README.md +4 -0
- package/templates/app/package.json +1 -0
- package/templates/app/public/_headers +4 -0
package/config.schema.json
CHANGED
|
@@ -276,6 +276,20 @@
|
|
|
276
276
|
"entry": "bootstrap/cli.ts"
|
|
277
277
|
}
|
|
278
278
|
},
|
|
279
|
+
"ci": {
|
|
280
|
+
"type": "object",
|
|
281
|
+
"properties": {
|
|
282
|
+
"script": {
|
|
283
|
+
"type": "string",
|
|
284
|
+
"default": ".config/sdxc/ci.ts",
|
|
285
|
+
"description": "CI script `sdxc ci` runs, relative to the project root"
|
|
286
|
+
}
|
|
287
|
+
},
|
|
288
|
+
"additionalProperties": false,
|
|
289
|
+
"default": {
|
|
290
|
+
"script": ".config/sdxc/ci.ts"
|
|
291
|
+
}
|
|
292
|
+
},
|
|
279
293
|
"format": {
|
|
280
294
|
"type": "array",
|
|
281
295
|
"items": {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The install a local `sdxc ci` runs before it loads the script: the project's package manager
|
|
3
|
+
* with its frozen-lockfile flag, so a run never tests a `node_modules` older than the lockfile,
|
|
4
|
+
* and a lockfile out of step with a manifest fails before any step runs.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import type { AnyCommandContext, ExitError } from "@sdxc/cli";
|
|
10
|
+
import type { Result } from "@sdxc/result";
|
|
11
|
+
/**
|
|
12
|
+
* Installs the dependencies of the project at `root` exactly as its lock file pins them, printing
|
|
13
|
+
* the command first and the install's output only when it fails, then exiting 1.
|
|
14
|
+
*/
|
|
15
|
+
export declare function frozenInstall(ctx: Pick<AnyCommandContext, "exec" | "stdout">, root: string): Promise<Result<undefined, ExitError>>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The install a local `sdxc ci` runs before it loads the script: the project's package manager
|
|
3
|
+
* with its frozen-lockfile flag, so a run never tests a `node_modules` older than the lockfile,
|
|
4
|
+
* and a lockfile out of step with a manifest fails before any step runs.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import { exit, success } from "@sdxc/cli";
|
|
10
|
+
import { isFailure } from "@sdxc/result";
|
|
11
|
+
import { projectPackageManager } from "../package-manager.js";
|
|
12
|
+
/**
|
|
13
|
+
* Installs the dependencies of the project at `root` exactly as its lock file pins them, printing
|
|
14
|
+
* the command first and the install's output only when it fails, then exiting 1.
|
|
15
|
+
*/
|
|
16
|
+
export async function frozenInstall(ctx, root) {
|
|
17
|
+
let manager = await projectPackageManager(root);
|
|
18
|
+
let command = manager.frozenInstall;
|
|
19
|
+
ctx.stdout(`Installing dependencies: ${command.join(" ")}\n`);
|
|
20
|
+
let installed = await ctx.exec(command, { cwd: root, stdio: "collect" });
|
|
21
|
+
if (isFailure(installed)) {
|
|
22
|
+
let output = "output" in installed.error ? installed.error.output : "";
|
|
23
|
+
ctx.stdout(output);
|
|
24
|
+
return exit(1, `${command.join(" ")} failed; the CI script did not run`);
|
|
25
|
+
}
|
|
26
|
+
return success();
|
|
27
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where `sdxc ci` finds its script: the nearest project at or above the current directory whose
|
|
3
|
+
* `ci.script` (`.config/sdxc/ci.ts` by default) exists. Run from a workspace below that project,
|
|
4
|
+
* the run is scoped to the workspace, so `sdxc ci` inside one app checks that app.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import type { Result } from "@sdxc/result";
|
|
10
|
+
/** The project a CI run belongs to. */
|
|
11
|
+
export interface CIProject {
|
|
12
|
+
/** The directory holding the script's project, where its commands run. */
|
|
13
|
+
root: string;
|
|
14
|
+
/** The script's absolute path. */
|
|
15
|
+
script: string;
|
|
16
|
+
/** The workspace the run started in, relative to `root`; `null` at the root itself. */
|
|
17
|
+
workspace: string | null;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The CI project for a run started in `cwd`. Each project from `cwd` upward is asked for its
|
|
21
|
+
* configured script; reaching the filesystem root without one is a failure naming the default.
|
|
22
|
+
*/
|
|
23
|
+
export declare function locateCI(cwd: string): Promise<Result<CIProject, Error>>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where `sdxc ci` finds its script: the nearest project at or above the current directory whose
|
|
3
|
+
* `ci.script` (`.config/sdxc/ci.ts` by default) exists. Run from a workspace below that project,
|
|
4
|
+
* the run is scoped to the workspace, so `sdxc ci` inside one app checks that app.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import { stat } from "node:fs/promises";
|
|
10
|
+
import { dirname, join, relative, resolve, sep } from "node:path";
|
|
11
|
+
import { failure, isFailure, isSuccess, success, wrap } from "@sdxc/result";
|
|
12
|
+
import { loadConfig } from "../config.js";
|
|
13
|
+
import { findProjectRoot } from "../project.js";
|
|
14
|
+
/** Whether `path` is a file. */
|
|
15
|
+
async function isFile(path) {
|
|
16
|
+
let found = await wrap(() => stat(path));
|
|
17
|
+
return isSuccess(found) && found.data.isFile();
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The CI project for a run started in `cwd`. Each project from `cwd` upward is asked for its
|
|
21
|
+
* configured script; reaching the filesystem root without one is a failure naming the default.
|
|
22
|
+
*/
|
|
23
|
+
export async function locateCI(cwd) {
|
|
24
|
+
let start = await findProjectRoot(cwd);
|
|
25
|
+
if (isFailure(start))
|
|
26
|
+
return start;
|
|
27
|
+
let directory = start.data;
|
|
28
|
+
while (true) {
|
|
29
|
+
let config = await loadConfig(directory);
|
|
30
|
+
if (isFailure(config))
|
|
31
|
+
return config;
|
|
32
|
+
let script = join(directory, config.data.config.ci.script);
|
|
33
|
+
if (await isFile(script)) {
|
|
34
|
+
let workspace = relative(directory, start.data).split(sep).join("/");
|
|
35
|
+
return success({ root: directory, script, workspace: workspace === "" ? null : workspace });
|
|
36
|
+
}
|
|
37
|
+
let parent = await findProjectRoot(dirname(directory));
|
|
38
|
+
if (isFailure(parent) || parent.data === directory) {
|
|
39
|
+
return failure(new Error(`No CI script at or above ${resolve(cwd)}; write one at .config/sdxc/ci.ts, or set ci.script in .config/sdxc.jsonc`));
|
|
40
|
+
}
|
|
41
|
+
directory = parent.data;
|
|
42
|
+
}
|
|
43
|
+
}
|
package/dist/cli.js
CHANGED
|
@@ -31,6 +31,11 @@ export function createSDXC(options = {}) {
|
|
|
31
31
|
middleware: [packageRoot(options.packageRoot)],
|
|
32
32
|
});
|
|
33
33
|
cli.map(SDXC_COMMANDS.create, lazy(() => import("./commands/create.js")));
|
|
34
|
+
cli.map(SDXC_COMMANDS.ci, lazy(() => import("./commands/ci/run.js")));
|
|
35
|
+
cli.map(SDXC_COMMANDS.ci.list, lazy(() => import("./commands/ci/list.js")));
|
|
36
|
+
cli.map(SDXC_COMMANDS.ci.signoff, lazy(() => import("./commands/ci/signoff.js")));
|
|
37
|
+
cli.map(SDXC_COMMANDS.ci.verify, lazy(() => import("./commands/ci/verify.js")));
|
|
38
|
+
cli.map(SDXC_COMMANDS.ci.clean, lazy(() => import("./commands/ci/clean.js")));
|
|
34
39
|
cli.map(SDXC_COMMANDS.deploy, lazy(() => import("./commands/deploy.js")));
|
|
35
40
|
cli.map(SDXC_COMMANDS.destroy, lazy(() => import("./commands/destroy.js")));
|
|
36
41
|
cli.map(SDXC_COMMANDS.doctor, lazy(() => import("./commands/doctor.js")));
|
|
@@ -67,6 +72,7 @@ export function createSDXC(options = {}) {
|
|
|
67
72
|
cli.map(SDXC_COMMANDS.make.do, lazy(() => import("./commands/make.js").then((module) => ({ default: module.durableObject }))));
|
|
68
73
|
cli.map(SDXC_COMMANDS.routes, lazy(() => import("./commands/routes.js")));
|
|
69
74
|
cli.map(SDXC_COMMANDS.scaffold, lazy(() => import("./commands/scaffold.js")));
|
|
75
|
+
cli.map(SDXC_COMMANDS.pkg, lazy(() => import("./commands/pkg.js")));
|
|
70
76
|
cli.map(SDXC_COMMANDS.run, lazy(() => import("./commands/run.js")));
|
|
71
77
|
cli.map(SDXC_COMMANDS.setup, lazy(() => import("./commands/setup.js")));
|
|
72
78
|
cli.map(SDXC_COMMANDS.ui.list, lazy(() => import("./commands/ui/list.js")));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `sdxc ci clean` handler: empties the step cache and run history `sdxc ci` keeps in the
|
|
3
|
+
* clone's git directory, leaving the signoff records `sdxc ci signoff` posts from.
|
|
4
|
+
*
|
|
5
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
6
|
+
* @copyright Sergio Xalambrí 2026
|
|
7
|
+
*/
|
|
8
|
+
declare const _default: import("@sdxc/cli").CommandAction<import("@sdxc/cli").Command<Readonly<Record<string, import("@sdxc/cli").Argument<unknown>>>, {
|
|
9
|
+
json: import("@sdxc/cli").Flag<boolean>;
|
|
10
|
+
}>, readonly []>;
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `sdxc ci clean` handler: empties the step cache and run history `sdxc ci` keeps in the
|
|
3
|
+
* clone's git directory, leaving the signoff records `sdxc ci signoff` posts from.
|
|
4
|
+
*
|
|
5
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
6
|
+
* @copyright Sergio Xalambrí 2026
|
|
7
|
+
*/
|
|
8
|
+
import { cleanAction } from "@sdxc/ci/command-line";
|
|
9
|
+
import { createCommand } from "@sdxc/cli";
|
|
10
|
+
import { SDXC_COMMANDS } from "../../contract.js";
|
|
11
|
+
export default createCommand(SDXC_COMMANDS.ci.clean, {
|
|
12
|
+
middleware: [],
|
|
13
|
+
/** Exits 2 outside a git repository, where there is no store to clean. */
|
|
14
|
+
handler: (ctx) => cleanAction(ctx, ctx.flags),
|
|
15
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `sdxc ci list` handler: lists the steps the project's CI script reaches when every step
|
|
3
|
+
* passes, or one matrix's entry keys for a CI host's job matrix, without running anything.
|
|
4
|
+
*
|
|
5
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
6
|
+
* @copyright Sergio Xalambrí 2026
|
|
7
|
+
*/
|
|
8
|
+
declare const _default: import("@sdxc/cli").CommandAction<import("@sdxc/cli").Command<Readonly<Record<string, import("@sdxc/cli").Argument<unknown>>>, {
|
|
9
|
+
matrix: import("@sdxc/cli").ValueFlag<string, false, false, false>;
|
|
10
|
+
json: import("@sdxc/cli").Flag<boolean>;
|
|
11
|
+
only: import("@sdxc/cli").ValueFlag<string, false, true, false>;
|
|
12
|
+
skip: import("@sdxc/cli").ValueFlag<string, false, true, false>;
|
|
13
|
+
scope: import("@sdxc/cli").ValueFlag<string, false, true, false>;
|
|
14
|
+
runner: import("@sdxc/cli").ValueFlag<"remote" | "local", false, false, false>;
|
|
15
|
+
}>, readonly []>;
|
|
16
|
+
export default _default;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `sdxc ci list` handler: lists the steps the project's CI script reaches when every step
|
|
3
|
+
* passes, or one matrix's entry keys for a CI host's job matrix, without running anything.
|
|
4
|
+
*
|
|
5
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
6
|
+
* @copyright Sergio Xalambrí 2026
|
|
7
|
+
*/
|
|
8
|
+
import { listAction } from "@sdxc/ci/command-line";
|
|
9
|
+
import { createCommand, exit } from "@sdxc/cli";
|
|
10
|
+
import { isFailure } from "@sdxc/result";
|
|
11
|
+
import { locateCI } from "../../ci/locate.js";
|
|
12
|
+
import { SDXC_COMMANDS } from "../../contract.js";
|
|
13
|
+
export default createCommand(SDXC_COMMANDS.ci.list, {
|
|
14
|
+
middleware: [],
|
|
15
|
+
/** Lists from the script's project, scoped like `sdxc ci` to the workspace it starts in. */
|
|
16
|
+
async handler(ctx) {
|
|
17
|
+
let located = await locateCI(ctx.cwd);
|
|
18
|
+
if (isFailure(located))
|
|
19
|
+
return exit(2, located.error.message);
|
|
20
|
+
let workspace = located.data.workspace;
|
|
21
|
+
let scope = ctx.flags.scope.length > 0 || workspace === null ? ctx.flags.scope : [workspace];
|
|
22
|
+
return listAction(ctx, located.data.script, { ...ctx.flags, scope }, located.data.root);
|
|
23
|
+
},
|
|
24
|
+
});
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `sdxc ci` handler: finds the project's CI script, installs dependencies with a frozen
|
|
3
|
+
* lockfile on a local run, scopes the run to the workspace it was started in, and runs the
|
|
4
|
+
* script exactly as `sdxc-ci run` would.
|
|
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").Group<Omit<{
|
|
10
|
+
readonly description: "Run the project's CI script (.config/sdxc/ci.ts), and sign green commits off on GitHub";
|
|
11
|
+
readonly flags: {
|
|
12
|
+
readonly install: import("@sdxc/cli").Flag<boolean>;
|
|
13
|
+
readonly push: import("@sdxc/cli").Flag<boolean>;
|
|
14
|
+
readonly signoff: import("@sdxc/cli").Flag<boolean>;
|
|
15
|
+
readonly cache: import("@sdxc/cli").Flag<boolean>;
|
|
16
|
+
readonly concurrency: import("@sdxc/cli").ValueFlag<number, false, false, false>;
|
|
17
|
+
readonly remote: import("@sdxc/cli").ValueFlag<string, false, false, false>;
|
|
18
|
+
readonly tokenEnv: import("@sdxc/cli").ValueFlag<string, true, false, false>;
|
|
19
|
+
readonly verbose: import("@sdxc/cli").Flag<boolean>;
|
|
20
|
+
readonly json: import("@sdxc/cli").Flag<boolean>;
|
|
21
|
+
readonly rerunFailed: import("@sdxc/cli").Flag<boolean>;
|
|
22
|
+
readonly only: import("@sdxc/cli").ValueFlag<string, false, true, false>;
|
|
23
|
+
readonly skip: import("@sdxc/cli").ValueFlag<string, false, true, false>;
|
|
24
|
+
readonly scope: import("@sdxc/cli").ValueFlag<string, false, true, false>;
|
|
25
|
+
readonly runner: import("@sdxc/cli").ValueFlag<"remote" | "local", false, false, false>;
|
|
26
|
+
};
|
|
27
|
+
readonly list: import("@sdxc/cli").Command<Readonly<Record<string, import("@sdxc/cli").Argument<unknown>>>, {
|
|
28
|
+
matrix: import("@sdxc/cli").ValueFlag<string, false, false, false>;
|
|
29
|
+
json: import("@sdxc/cli").Flag<boolean>;
|
|
30
|
+
only: import("@sdxc/cli").ValueFlag<string, false, true, false>;
|
|
31
|
+
skip: import("@sdxc/cli").ValueFlag<string, false, true, false>;
|
|
32
|
+
scope: import("@sdxc/cli").ValueFlag<string, false, true, false>;
|
|
33
|
+
runner: import("@sdxc/cli").ValueFlag<"remote" | "local", false, false, false>;
|
|
34
|
+
}>;
|
|
35
|
+
readonly signoff: import("@sdxc/cli").Command<{
|
|
36
|
+
readonly sha: import("@sdxc/cli").Argument<string | undefined>;
|
|
37
|
+
}, {
|
|
38
|
+
remote: import("@sdxc/cli").ValueFlag<string, false, false, false>;
|
|
39
|
+
tokenEnv: import("@sdxc/cli").ValueFlag<string, true, false, false>;
|
|
40
|
+
json: import("@sdxc/cli").Flag<boolean>;
|
|
41
|
+
}>;
|
|
42
|
+
readonly verify: import("@sdxc/cli").Command<{
|
|
43
|
+
readonly sha: import("@sdxc/cli").Argument<string>;
|
|
44
|
+
}, {
|
|
45
|
+
wait: import("@sdxc/cli").ValueFlag<string, false, false, false>;
|
|
46
|
+
repo: import("@sdxc/cli").ValueFlag<string, false, false, false>;
|
|
47
|
+
remote: import("@sdxc/cli").ValueFlag<string, false, false, false>;
|
|
48
|
+
tokenEnv: import("@sdxc/cli").ValueFlag<string, true, false, false>;
|
|
49
|
+
json: import("@sdxc/cli").Flag<boolean>;
|
|
50
|
+
}>;
|
|
51
|
+
readonly clean: import("@sdxc/cli").Command<Readonly<Record<string, import("@sdxc/cli").Argument<unknown>>>, {
|
|
52
|
+
json: import("@sdxc/cli").Flag<boolean>;
|
|
53
|
+
}>;
|
|
54
|
+
}, "description" | "hidden" | "arguments" | "flags" | "tasks">, Record<never, never>, {
|
|
55
|
+
readonly install: import("@sdxc/cli").Flag<boolean>;
|
|
56
|
+
readonly push: import("@sdxc/cli").Flag<boolean>;
|
|
57
|
+
readonly signoff: import("@sdxc/cli").Flag<boolean>;
|
|
58
|
+
readonly cache: import("@sdxc/cli").Flag<boolean>;
|
|
59
|
+
readonly concurrency: import("@sdxc/cli").ValueFlag<number, false, false, false>;
|
|
60
|
+
readonly remote: import("@sdxc/cli").ValueFlag<string, false, false, false>;
|
|
61
|
+
readonly tokenEnv: import("@sdxc/cli").ValueFlag<string, true, false, false>;
|
|
62
|
+
readonly verbose: import("@sdxc/cli").Flag<boolean>;
|
|
63
|
+
readonly json: import("@sdxc/cli").Flag<boolean>;
|
|
64
|
+
readonly rerunFailed: import("@sdxc/cli").Flag<boolean>;
|
|
65
|
+
readonly only: import("@sdxc/cli").ValueFlag<string, false, true, false>;
|
|
66
|
+
readonly skip: import("@sdxc/cli").ValueFlag<string, false, true, false>;
|
|
67
|
+
readonly scope: import("@sdxc/cli").ValueFlag<string, false, true, false>;
|
|
68
|
+
readonly runner: import("@sdxc/cli").ValueFlag<"remote" | "local", false, false, false>;
|
|
69
|
+
}>, readonly []>;
|
|
70
|
+
export default _default;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `sdxc ci` handler: finds the project's CI script, installs dependencies with a frozen
|
|
3
|
+
* lockfile on a local run, scopes the run to the workspace it was started in, and runs the
|
|
4
|
+
* script exactly as `sdxc-ci run` would.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import { detectRunner } from "@sdxc/ci";
|
|
10
|
+
import { runAction } from "@sdxc/ci/command-line";
|
|
11
|
+
import { createCommand, exit } from "@sdxc/cli";
|
|
12
|
+
import { isFailure } from "@sdxc/result";
|
|
13
|
+
import { frozenInstall } from "../../ci/install.js";
|
|
14
|
+
import { locateCI } from "../../ci/locate.js";
|
|
15
|
+
import { SDXC_COMMANDS } from "../../contract.js";
|
|
16
|
+
export default createCommand(SDXC_COMMANDS.ci, {
|
|
17
|
+
middleware: [],
|
|
18
|
+
/**
|
|
19
|
+
* Exits 2 without a script, 1 when the install or a step fails, and with the run's own code
|
|
20
|
+
* otherwise. A remote run skips the install, which the CI host's workflow already ran.
|
|
21
|
+
*/
|
|
22
|
+
async handler(ctx) {
|
|
23
|
+
let located = await locateCI(ctx.cwd);
|
|
24
|
+
if (isFailure(located))
|
|
25
|
+
return exit(2, located.error.message);
|
|
26
|
+
let runner = ctx.flags.runner ?? detectRunner(ctx.env);
|
|
27
|
+
if (runner === "local" && ctx.flags.install) {
|
|
28
|
+
let installed = await frozenInstall(ctx, located.data.root);
|
|
29
|
+
if (isFailure(installed))
|
|
30
|
+
return installed;
|
|
31
|
+
}
|
|
32
|
+
let workspace = located.data.workspace;
|
|
33
|
+
let scope = ctx.flags.scope.length > 0 || workspace === null ? ctx.flags.scope : [workspace];
|
|
34
|
+
return runAction({
|
|
35
|
+
cwd: ctx.cwd,
|
|
36
|
+
env: ctx.env,
|
|
37
|
+
stdout: ctx.stdout,
|
|
38
|
+
style: ctx.style,
|
|
39
|
+
signal: ctx.signal,
|
|
40
|
+
interactive: process.stdout.isTTY === true,
|
|
41
|
+
}, located.data.script, { ...ctx.flags, runner, scope }, located.data.root);
|
|
42
|
+
},
|
|
43
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `sdxc ci signoff` handler: posts the signoff an earlier green `sdxc ci` run recorded for a
|
|
3
|
+
* commit that has since reached GitHub.
|
|
4
|
+
*
|
|
5
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
6
|
+
* @copyright Sergio Xalambrí 2026
|
|
7
|
+
*/
|
|
8
|
+
declare const _default: import("@sdxc/cli").CommandAction<import("@sdxc/cli").Command<{
|
|
9
|
+
readonly sha: import("@sdxc/cli").Argument<string | undefined>;
|
|
10
|
+
}, {
|
|
11
|
+
remote: import("@sdxc/cli").ValueFlag<string, false, false, false>;
|
|
12
|
+
tokenEnv: import("@sdxc/cli").ValueFlag<string, true, false, false>;
|
|
13
|
+
json: import("@sdxc/cli").Flag<boolean>;
|
|
14
|
+
}>, readonly []>;
|
|
15
|
+
export default _default;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `sdxc ci signoff` handler: posts the signoff an earlier green `sdxc ci` run recorded for a
|
|
3
|
+
* commit that has since reached GitHub.
|
|
4
|
+
*
|
|
5
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
6
|
+
* @copyright Sergio Xalambrí 2026
|
|
7
|
+
*/
|
|
8
|
+
import { signoffAction } from "@sdxc/ci/command-line";
|
|
9
|
+
import { createCommand } from "@sdxc/cli";
|
|
10
|
+
import { SDXC_COMMANDS } from "../../contract.js";
|
|
11
|
+
export default createCommand(SDXC_COMMANDS.ci.signoff, {
|
|
12
|
+
middleware: [],
|
|
13
|
+
/** Exits 1 for a commit no green run recorded, so an untested commit is never marked green. */
|
|
14
|
+
handler: (ctx) => signoffAction(ctx, { ...ctx.flags, sha: ctx.arguments.sha }),
|
|
15
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `sdxc ci verify` handler: the gate a CI host runs first, answering through its exit code
|
|
3
|
+
* whether a contributor already signed the commit off.
|
|
4
|
+
*
|
|
5
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
6
|
+
* @copyright Sergio Xalambrí 2026
|
|
7
|
+
*/
|
|
8
|
+
declare const _default: import("@sdxc/cli").CommandAction<import("@sdxc/cli").Command<{
|
|
9
|
+
readonly sha: import("@sdxc/cli").Argument<string>;
|
|
10
|
+
}, {
|
|
11
|
+
wait: import("@sdxc/cli").ValueFlag<string, false, false, false>;
|
|
12
|
+
repo: import("@sdxc/cli").ValueFlag<string, false, false, false>;
|
|
13
|
+
remote: import("@sdxc/cli").ValueFlag<string, false, false, false>;
|
|
14
|
+
tokenEnv: import("@sdxc/cli").ValueFlag<string, true, false, false>;
|
|
15
|
+
json: import("@sdxc/cli").Flag<boolean>;
|
|
16
|
+
}>, readonly []>;
|
|
17
|
+
export default _default;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `sdxc ci verify` handler: the gate a CI host runs first, answering through its exit code
|
|
3
|
+
* whether a contributor already signed the commit off.
|
|
4
|
+
*
|
|
5
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
6
|
+
* @copyright Sergio Xalambrí 2026
|
|
7
|
+
*/
|
|
8
|
+
import { verifyAction } from "@sdxc/ci/command-line";
|
|
9
|
+
import { createCommand } from "@sdxc/cli";
|
|
10
|
+
import { SDXC_COMMANDS } from "../../contract.js";
|
|
11
|
+
export default createCommand(SDXC_COMMANDS.ci.verify, {
|
|
12
|
+
middleware: [],
|
|
13
|
+
/** Exits 0 when signed, 1 when not, 2 when GitHub cannot answer. */
|
|
14
|
+
handler: (ctx) => verifyAction(ctx, { ...ctx.flags, sha: ctx.arguments.sha }),
|
|
15
|
+
});
|
package/dist/commands/create.js
CHANGED
|
@@ -14,6 +14,7 @@ import { SDXC_COMMANDS } from "../contract.js";
|
|
|
14
14
|
import { describe, downloadTemplate, GitHubRefusal, githubToken } from "../create/github.js";
|
|
15
15
|
import { resolveTarget } from "../create/target.js";
|
|
16
16
|
import { completeBuiltin, creditTemplate, nameProject, parseTemplate, readBuiltinTemplate, writeTree, } from "../create/templates.js";
|
|
17
|
+
import { dropRootOwned, insideWorkspace } from "../create/workspace.js";
|
|
17
18
|
import { packageRoot } from "../middleware.js";
|
|
18
19
|
import { packageManager, scriptCommand } from "../package-manager.js";
|
|
19
20
|
/** The middleware `create` runs behind; it runs outside any project. */
|
|
@@ -32,6 +33,8 @@ export default createCommand(SDXC_COMMANDS.create, {
|
|
|
32
33
|
let fetched = await fetchTemplate(ctx, source.data, target.data.name, target.data.directory);
|
|
33
34
|
if (isFailure(fetched))
|
|
34
35
|
return fetched;
|
|
36
|
+
if (await insideWorkspace(target.data.directory))
|
|
37
|
+
dropRootOwned(fetched.data.tree);
|
|
35
38
|
let written = await writeTree(target.data.directory, fetched.data.tree);
|
|
36
39
|
if (isFailure(written))
|
|
37
40
|
return written;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `sdxc pkg` handler: runs an `@sdxc` package's command line with every token after its
|
|
3
|
+
* name as typed, from the copy the project installs or from npm, so one global `sdxc` reaches
|
|
4
|
+
* every package's command line. A mistyped name gets a suggestion and never runs.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Lists the packages when no name is given; exits 2 for a name without a command line, naming
|
|
11
|
+
* the closest one or where to request it; otherwise hands the package's exit code back.
|
|
12
|
+
*/
|
|
13
|
+
declare const _default: import("@sdxc/cli").CommandAction<import("@sdxc/cli").Command<{
|
|
14
|
+
readonly args: import("@sdxc/cli").Argument<string[]>;
|
|
15
|
+
}, Readonly<Record<string, import("@sdxc/cli").Flag<unknown>>>>, readonly []>;
|
|
16
|
+
export default _default;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `sdxc pkg` handler: runs an `@sdxc` package's command line with every token after its
|
|
3
|
+
* name as typed, from the copy the project installs or from npm, so one global `sdxc` reaches
|
|
4
|
+
* every package's command line. A mistyped name gets a suggestion and never runs.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import { createCommand, ExecError, exit, success } from "@sdxc/cli";
|
|
10
|
+
import { isSuccess } from "@sdxc/result";
|
|
11
|
+
import { SDXC_COMMANDS } from "../contract.js";
|
|
12
|
+
import { PACKAGE_COMMAND_LINES } from "../pkg/catalog.js";
|
|
13
|
+
import { installedBinary, lookupPackage, onPath, packageCommand, projectRelease, requestURL, } from "../pkg/resolve.js";
|
|
14
|
+
/**
|
|
15
|
+
* Tokens that ask `sdxc pkg` itself for help when they come first; after a package name they
|
|
16
|
+
* belong to that package's command line.
|
|
17
|
+
*/
|
|
18
|
+
const HELP_FLAGS = new Set(["--help", "-h", "help"]);
|
|
19
|
+
/** The packages with a command line, one per line with what each does, for a bare `sdxc pkg`. */
|
|
20
|
+
function listing() {
|
|
21
|
+
let names = Object.keys(PACKAGE_COMMAND_LINES);
|
|
22
|
+
let width = Math.max(...names.map((name) => name.length));
|
|
23
|
+
let rows = names.map((name) => ` ${name.padEnd(width)} ${PACKAGE_COMMAND_LINES[name]}`);
|
|
24
|
+
return [
|
|
25
|
+
"Usage: sdxc pkg <name> [command] [options]",
|
|
26
|
+
"",
|
|
27
|
+
"Run an @sdxc package's command line, from the project's copy or downloaded with bunx or npx.",
|
|
28
|
+
"Everything after <name> goes to the package; `sdxc pkg <name> --help` shows its commands.",
|
|
29
|
+
"",
|
|
30
|
+
"Packages with a command line:",
|
|
31
|
+
...rows,
|
|
32
|
+
"",
|
|
33
|
+
].join("\n");
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Lists the packages when no name is given; exits 2 for a name without a command line, naming
|
|
37
|
+
* the closest one or where to request it; otherwise hands the package's exit code back.
|
|
38
|
+
*/
|
|
39
|
+
export default createCommand(SDXC_COMMANDS.pkg, {
|
|
40
|
+
middleware: [],
|
|
41
|
+
/** Runs the named package's command line with its output on the terminal. */
|
|
42
|
+
async handler(ctx) {
|
|
43
|
+
let [input, ...args] = ctx.arguments.args;
|
|
44
|
+
if (input === undefined || HELP_FLAGS.has(input)) {
|
|
45
|
+
ctx.stdout(listing());
|
|
46
|
+
return success();
|
|
47
|
+
}
|
|
48
|
+
let found = lookupPackage(input);
|
|
49
|
+
if (found.kind === "without-command-line") {
|
|
50
|
+
return exit(2, `@sdxc/${found.name} has no command line yet.\nTell us what you'd use it for: ${requestURL(found.name)}`);
|
|
51
|
+
}
|
|
52
|
+
if (found.kind === "unknown") {
|
|
53
|
+
let hint = found.suggestion === undefined
|
|
54
|
+
? "Run `sdxc pkg` to list them."
|
|
55
|
+
: `Did you mean \`${["sdxc pkg", found.suggestion, ...args].join(" ")}\`?`;
|
|
56
|
+
return exit(2, `No @sdxc package command line is named "${found.name}". ${hint}`);
|
|
57
|
+
}
|
|
58
|
+
let binary = await installedBinary(ctx.cwd, found.name);
|
|
59
|
+
let bun = await onPath("bun", ctx.env.PATH);
|
|
60
|
+
let release = binary === null ? await projectRelease(ctx.cwd) : null;
|
|
61
|
+
let ran = await ctx.exec(packageCommand(found.name, args, binary, bun, release), {
|
|
62
|
+
cwd: ctx.cwd,
|
|
63
|
+
stdio: "inherit",
|
|
64
|
+
});
|
|
65
|
+
if (isSuccess(ran))
|
|
66
|
+
return success();
|
|
67
|
+
if (ran.error instanceof ExecError && ran.error.code !== null)
|
|
68
|
+
return exit(ran.error.code);
|
|
69
|
+
return ran;
|
|
70
|
+
},
|
|
71
|
+
});
|
|
@@ -16,7 +16,7 @@ declare const _default: import("@sdxc/cli").CommandAction<import("@sdxc/cli").Co
|
|
|
16
16
|
readonly contract: import("@sdxc/cli").ValueFlag<string, false, false, false>;
|
|
17
17
|
readonly unused: import("@sdxc/cli").Flag<boolean>;
|
|
18
18
|
readonly exceptPath: import("@sdxc/cli").ValueFlag<string, false, true, false>;
|
|
19
|
-
readonly sort: import("@sdxc/cli").ValueFlag<"name" | "
|
|
19
|
+
readonly sort: import("@sdxc/cli").ValueFlag<"name" | "method" | "pattern" | "controller", false, false, false>;
|
|
20
20
|
}>, readonly [import("@sdxc/cli").CommandMiddleware<{
|
|
21
21
|
key: typeof import("../middleware.js").CurrentProject;
|
|
22
22
|
value: import("../middleware.js").Project;
|
package/dist/config.d.ts
CHANGED
|
@@ -16,6 +16,9 @@ export declare const CONFIG_LOCATIONS: readonly [".config/sdxc.jsonc", "sdxc.jso
|
|
|
16
16
|
* a misspelt key is reported instead of silently ignored.
|
|
17
17
|
*/
|
|
18
18
|
export declare const CONFIG_SCHEMA: s.Schema<{
|
|
19
|
+
run?: {
|
|
20
|
+
entry?: string | undefined;
|
|
21
|
+
} | undefined;
|
|
19
22
|
$schema?: string | undefined;
|
|
20
23
|
format?: string[] | undefined;
|
|
21
24
|
ui?: {
|
|
@@ -62,11 +65,14 @@ export declare const CONFIG_SCHEMA: s.Schema<{
|
|
|
62
65
|
maxSurvived?: number | undefined;
|
|
63
66
|
} | undefined;
|
|
64
67
|
} | undefined;
|
|
65
|
-
|
|
66
|
-
|
|
68
|
+
ci?: {
|
|
69
|
+
script?: string | undefined;
|
|
67
70
|
} | undefined;
|
|
68
71
|
lock?: string | undefined;
|
|
69
72
|
}, {
|
|
73
|
+
run: {
|
|
74
|
+
entry: string;
|
|
75
|
+
};
|
|
70
76
|
ui: {
|
|
71
77
|
directory: string;
|
|
72
78
|
tests: boolean;
|
|
@@ -111,8 +117,8 @@ export declare const CONFIG_SCHEMA: s.Schema<{
|
|
|
111
117
|
maxSurvived: number;
|
|
112
118
|
};
|
|
113
119
|
};
|
|
114
|
-
|
|
115
|
-
|
|
120
|
+
ci: {
|
|
121
|
+
script: string;
|
|
116
122
|
};
|
|
117
123
|
lock: string;
|
|
118
124
|
$schema?: string | undefined;
|
package/dist/config.js
CHANGED
|
@@ -71,6 +71,8 @@ const DOCTOR_DEFAULTS = {
|
|
|
71
71
|
duplication: DOCTOR_DUPLICATION_DEFAULTS,
|
|
72
72
|
mutation: DOCTOR_MUTATION_DEFAULTS,
|
|
73
73
|
};
|
|
74
|
+
/** The `ci` group as a project with no `ci` key gets it. */
|
|
75
|
+
const CI_DEFAULTS = { script: ".config/sdxc/ci.ts" };
|
|
74
76
|
/** The `run` group as a project with no `run` key gets it. */
|
|
75
77
|
const RUN_DEFAULTS = { entry: "bootstrap/cli.ts" };
|
|
76
78
|
/**
|
|
@@ -173,6 +175,11 @@ export const CONFIG_SCHEMA = s.object({
|
|
|
173
175
|
description: "Module `sdxc run` starts, relative to the project root; apps keep the default",
|
|
174
176
|
}),
|
|
175
177
|
}, { unknownKeys: "error" }), RUN_DEFAULTS),
|
|
178
|
+
ci: s.defaulted(s.object({
|
|
179
|
+
script: s.defaulted(s.string(), CI_DEFAULTS.script).meta({
|
|
180
|
+
description: "CI script `sdxc ci` runs, relative to the project root",
|
|
181
|
+
}),
|
|
182
|
+
}, { unknownKeys: "error" }), CI_DEFAULTS),
|
|
176
183
|
format: s.optional(s.array(s.string()).pipe(checks.minItems(1))).meta({
|
|
177
184
|
description: "Command run on every file the CLI writes or edits, paths appended",
|
|
178
185
|
examples: [["bunx", "vp", "fmt", "--no-error-on-unmatched-pattern"]],
|
|
@@ -262,6 +269,7 @@ function configuredPaths(config) {
|
|
|
262
269
|
["doctor.crap.coverage", config.doctor.crap.coverage],
|
|
263
270
|
["doctor.mutation.report", config.doctor.mutation.report],
|
|
264
271
|
["run.entry", config.run.entry],
|
|
272
|
+
["ci.script", config.ci.script],
|
|
265
273
|
["lock", config.lock],
|
|
266
274
|
];
|
|
267
275
|
for (let [chain, folder] of Object.entries(config.make.migrations)) {
|