sordo 0.4.0 → 1.0.0
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/CHANGELOG.md +6 -116
- package/README.md +8 -175
- package/bin/sordo.ts +1 -4
- package/package.json +17 -41
- package/src/agents-md.ts +1 -0
- package/src/ai.ts +1 -0
- package/src/build.ts +1 -0
- package/src/client.ts +1 -0
- package/src/config.ts +1 -0
- package/src/dev.ts +1 -0
- package/src/index.ts +1 -55
- package/src/middleware.ts +1 -0
- package/src/plugin.ts +1 -0
- package/src/render.ts +1 -0
- package/src/router.ts +1 -0
- package/src/server.ts +1 -0
- package/CLAUDE.md +0 -124
- package/src/adapters/bun.ts +0 -59
- package/src/adapters/edge.ts +0 -75
- package/src/adapters/types.ts +0 -43
- package/src/agents-md/collect.ts +0 -113
- package/src/agents-md/generate.ts +0 -44
- package/src/agents-md/index.ts +0 -9
- package/src/agents-md/render.ts +0 -150
- package/src/agents-md/subprocess-entry.ts +0 -92
- package/src/agents-md/subprocess-runner.ts +0 -111
- package/src/agents-md/write.ts +0 -38
- package/src/agents-md/zod-to-json-schema.ts +0 -18
- package/src/ai/context.ts +0 -72
- package/src/ai/define.ts +0 -15
- package/src/ai/errors.ts +0 -51
- package/src/ai/index.ts +0 -36
- package/src/ai/middleware.ts +0 -21
- package/src/ai/registry.ts +0 -96
- package/src/ai/run.ts +0 -185
- package/src/ai/scan.ts +0 -42
- package/src/ai/stream.ts +0 -71
- package/src/ai/triggers.ts +0 -124
- package/src/ai/types.ts +0 -67
- package/src/ai/validate.ts +0 -82
- package/src/build/assets.ts +0 -48
- package/src/build/client-entry.ts +0 -43
- package/src/build/css.ts +0 -102
- package/src/build/embedded.ts +0 -66
- package/src/build/hash.ts +0 -21
- package/src/build/index.ts +0 -480
- package/src/build/macros/agents-hash.macro.ts +0 -9
- package/src/build/macros/agents.macro.ts +0 -21
- package/src/build/macros/env.macro.ts +0 -25
- package/src/build/macros/inline-assets.macro.ts +0 -28
- package/src/build/macros/manifest.macro.ts +0 -8
- package/src/build/macros/routes.macro.ts +0 -10
- package/src/build/page-entry.ts +0 -136
- package/src/build/scan-islands.ts +0 -39
- package/src/build/server-entry.ts +0 -256
- package/src/cli/ansi.ts +0 -41
- package/src/cli/build.ts +0 -195
- package/src/cli/commands/add/apply.ts +0 -31
- package/src/cli/commands/add/component-diff.ts +0 -116
- package/src/cli/commands/add/diff.ts +0 -153
- package/src/cli/commands/add/internal.ts +0 -41
- package/src/cli/commands/add/load-catalog.ts +0 -22
- package/src/cli/commands/add/peer-deps.ts +0 -115
- package/src/cli/commands/add/registry-fetch.ts +0 -122
- package/src/cli/commands/add/shadcn.ts +0 -285
- package/src/cli/commands/add/source.ts +0 -273
- package/src/cli/commands/add/stamper.ts +0 -73
- package/src/cli/commands/add/tokens.ts +0 -81
- package/src/cli/commands/add/ui-paths.ts +0 -113
- package/src/cli/commands/add.ts +0 -427
- package/src/cli/commands/deploy.ts +0 -143
- package/src/cli/commands/migrate.ts +0 -149
- package/src/cli/commands/secret.ts +0 -316
- package/src/cli/commands/ui/build.ts +0 -111
- package/src/cli/commands/ui/init.ts +0 -135
- package/src/cli/commands/ui/migrate/git-guard.ts +0 -19
- package/src/cli/commands/ui/migrate/radix.ts +0 -67
- package/src/cli/commands/ui/migrate/rtl.ts +0 -148
- package/src/cli/commands/ui/shadcn.ts +0 -82
- package/src/cli/commands/ui/view.ts +0 -63
- package/src/cli/commands/ui.ts +0 -86
- package/src/cli/commands/update.ts +0 -134
- package/src/cli/commands/upgrade.ts +0 -53
- package/src/cli/commands/view.ts +0 -34
- package/src/cli/dev.ts +0 -393
- package/src/cli/doctor/config-checks.ts +0 -63
- package/src/cli/doctor/deps.ts +0 -295
- package/src/cli/doctor/hydrate.ts +0 -65
- package/src/cli/doctor/monorepo.ts +0 -158
- package/src/cli/doctor/probes.ts +0 -16
- package/src/cli/doctor/report.ts +0 -72
- package/src/cli/doctor/toolchain.ts +0 -95
- package/src/cli/doctor/types.ts +0 -36
- package/src/cli/doctor.ts +0 -127
- package/src/cli/index.ts +0 -168
- package/src/cli/log.ts +0 -135
- package/src/cli/run/affected.ts +0 -79
- package/src/cli/run/cache-key.ts +0 -177
- package/src/cli/run/cache-store.ts +0 -0
- package/src/cli/run/files.ts +0 -96
- package/src/cli/run/git.ts +0 -13
- package/src/cli/run/runner.ts +0 -189
- package/src/cli/run/workspace.ts +0 -216
- package/src/cli/run.ts +0 -184
- package/src/cli/start.ts +0 -99
- package/src/cli/update-check.ts +0 -157
- package/src/client/index.ts +0 -65
- package/src/client/link.tsx +0 -61
- package/src/client/page.ts +0 -250
- package/src/config/define.ts +0 -5
- package/src/config/env.ts +0 -36
- package/src/config/load.ts +0 -152
- package/src/config/schema.ts +0 -135
- package/src/config/secrets.ts +0 -108
- package/src/dev/client.ts +0 -112
- package/src/dev/hot.ts +0 -24
- package/src/dev/index.ts +0 -4
- package/src/dev/tree.ts +0 -95
- package/src/dev/watcher.ts +0 -95
- package/src/internal/hmr-client.ts +0 -52
- package/src/internal/open-in-editor.ts +0 -23
- package/src/internal/runtime.ts +0 -30
- package/src/middleware/cookie-jar.ts +0 -135
- package/src/middleware/cookies.ts +0 -60
- package/src/middleware/index.ts +0 -127
- package/src/middleware/request-id.ts +0 -22
- package/src/middleware/response-helpers.ts +0 -25
- package/src/plugin/index.ts +0 -109
- package/src/render/bootstrap.ts +0 -44
- package/src/render/dev-error.tsx +0 -73
- package/src/render/index.tsx +0 -261
- package/src/render/island.tsx +0 -33
- package/src/render/meta.tsx +0 -48
- package/src/render/shell.tsx +0 -41
- package/src/router/conflict.ts +0 -20
- package/src/router/filesystem.ts +0 -37
- package/src/router/index.ts +0 -247
- package/src/router/match.ts +0 -91
- package/src/router/pattern.ts +0 -88
- package/src/server/index.ts +0 -250
- package/src/server/inline-assets.ts +0 -39
- package/src/types.ts +0 -53
- package/src/ui/schema.ts +0 -68
- package/src/ui/types.ts +0 -10
- package/templates/_internal/cn.ts +0 -6
- package/templates/_internal/slot.ts +0 -50
- package/templates/_internal/variants.ts +0 -1
- package/templates/themes/neutral/tokens.css +0 -46
- package/templates/themes/slate/tokens.css +0 -46
- package/templates/themes/stone/tokens.css +0 -46
- package/templates/themes/zinc/tokens.css +0 -46
- package/templates/tokens.css +0 -46
package/src/cli/doctor/types.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
// Shared shapes for `sordo doctor` (cli/20-doctor). Every check produces a
|
|
2
|
-
// `Finding`; the report aggregates them into a `DoctorReport`.
|
|
3
|
-
|
|
4
|
-
export type Status = "pass" | "warn" | "fail" | "skip";
|
|
5
|
-
|
|
6
|
-
export type Group = "Toolchain" | "Dependencies" | "Config" | "Monorepo";
|
|
7
|
-
|
|
8
|
-
/** Fixed render order; groups with no findings are omitted from the report. */
|
|
9
|
-
export const GROUP_ORDER: readonly Group[] = [
|
|
10
|
-
"Toolchain",
|
|
11
|
-
"Dependencies",
|
|
12
|
-
"Config",
|
|
13
|
-
"Monorepo",
|
|
14
|
-
];
|
|
15
|
-
|
|
16
|
-
export interface Finding {
|
|
17
|
-
id: string;
|
|
18
|
-
group: Group;
|
|
19
|
-
status: Status;
|
|
20
|
-
/** One-line human summary (no ANSI — color is applied at render time). */
|
|
21
|
-
detail: string;
|
|
22
|
-
/** The exact command to run, when there is one. */
|
|
23
|
-
remedy?: string;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export interface Summary {
|
|
27
|
-
failed: number;
|
|
28
|
-
warning: number;
|
|
29
|
-
passed: number;
|
|
30
|
-
skipped: number;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export interface DoctorReport {
|
|
34
|
-
checks: Finding[];
|
|
35
|
-
summary: Summary;
|
|
36
|
-
}
|
package/src/cli/doctor.ts
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
// `sordo doctor` — aggregate read-only project-hygiene checks into one report
|
|
2
|
-
// with a concrete remedy per finding and a CI-friendly exit code. Phase 1 is
|
|
3
|
-
// report-only: it never installs or mutates. See cli/20-doctor.
|
|
4
|
-
|
|
5
|
-
import { join } from "node:path";
|
|
6
|
-
import { loadConfigOrUsage } from "../config/load.ts";
|
|
7
|
-
import { checkConfig } from "./doctor/config-checks.ts";
|
|
8
|
-
import { checkDeps, SEVERITY_ORDER, type Severity } from "./doctor/deps.ts";
|
|
9
|
-
import { checkHydration } from "./doctor/hydrate.ts";
|
|
10
|
-
import { checkMonorepo } from "./doctor/monorepo.ts";
|
|
11
|
-
import { renderJson, renderText, summarize } from "./doctor/report.ts";
|
|
12
|
-
import { checkToolchain } from "./doctor/toolchain.ts";
|
|
13
|
-
import type { DoctorReport, Summary } from "./doctor/types.ts";
|
|
14
|
-
import type { CliContext } from "./index.ts";
|
|
15
|
-
import { EXIT, log } from "./log.ts";
|
|
16
|
-
|
|
17
|
-
const CONFIG_CANDIDATES = [
|
|
18
|
-
"sordo.config.ts",
|
|
19
|
-
"sordo.config.js",
|
|
20
|
-
"sordo.config.mjs",
|
|
21
|
-
];
|
|
22
|
-
|
|
23
|
-
interface DoctorArgs {
|
|
24
|
-
json: boolean;
|
|
25
|
-
offline: boolean;
|
|
26
|
-
noAudit: boolean;
|
|
27
|
-
noOutdated: boolean;
|
|
28
|
-
strict: boolean;
|
|
29
|
-
auditLevel: string;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function parseArgs(argv: string[]): DoctorArgs {
|
|
33
|
-
const out: DoctorArgs = {
|
|
34
|
-
json: false,
|
|
35
|
-
offline: false,
|
|
36
|
-
noAudit: false,
|
|
37
|
-
noOutdated: false,
|
|
38
|
-
strict: false,
|
|
39
|
-
auditLevel: "high",
|
|
40
|
-
};
|
|
41
|
-
for (let i = 0; i < argv.length; i++) {
|
|
42
|
-
const a = argv[i];
|
|
43
|
-
if (a === undefined) continue;
|
|
44
|
-
if (a === "--json") out.json = true;
|
|
45
|
-
else if (a === "--offline") out.offline = true;
|
|
46
|
-
else if (a === "--no-audit") out.noAudit = true;
|
|
47
|
-
else if (a === "--no-outdated") out.noOutdated = true;
|
|
48
|
-
else if (a === "--strict") out.strict = true;
|
|
49
|
-
else if (a === "--audit-level") out.auditLevel = String(argv[++i]);
|
|
50
|
-
else if (a.startsWith("--audit-level="))
|
|
51
|
-
out.auditLevel = a.slice("--audit-level=".length);
|
|
52
|
-
}
|
|
53
|
-
return out;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
async function hasConfig(cwd: string, configPath?: string): Promise<boolean> {
|
|
57
|
-
if (configPath) return Bun.file(configPath).exists();
|
|
58
|
-
for (const name of CONFIG_CANDIDATES) {
|
|
59
|
-
if (await Bun.file(join(cwd, name)).exists()) return true;
|
|
60
|
-
}
|
|
61
|
-
return false;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export async function runDoctor(
|
|
65
|
-
argv: string[],
|
|
66
|
-
ctx: CliContext = { cwd: process.cwd(), verbose: false },
|
|
67
|
-
): Promise<number> {
|
|
68
|
-
const args = parseArgs(argv);
|
|
69
|
-
|
|
70
|
-
if (!SEVERITY_ORDER.includes(args.auditLevel as Severity)) {
|
|
71
|
-
log.error(
|
|
72
|
-
`invalid --audit-level "${args.auditLevel}" (expected ${SEVERITY_ORDER.join(" | ")})`,
|
|
73
|
-
);
|
|
74
|
-
return EXIT.USAGE;
|
|
75
|
-
}
|
|
76
|
-
const auditLevel = args.auditLevel as Severity;
|
|
77
|
-
|
|
78
|
-
// Pre-flight: exit 2 when doctor cannot run at all.
|
|
79
|
-
if (!Bun.which("bun")) {
|
|
80
|
-
log.error("`bun` not found in PATH — doctor cannot run.");
|
|
81
|
-
return EXIT.USAGE;
|
|
82
|
-
}
|
|
83
|
-
if (!(await hasConfig(ctx.cwd, ctx.configPath))) {
|
|
84
|
-
log.error(
|
|
85
|
-
"not a sordo project (no sordo.config.ts found). Run inside a sordo app.",
|
|
86
|
-
);
|
|
87
|
-
return EXIT.USAGE;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// `appDir` for the single-React check; tolerate an invalid config here (C.7
|
|
91
|
-
// reports it) by falling back to the conventional ./app.
|
|
92
|
-
const loaded = await loadConfigOrUsage({
|
|
93
|
-
cwd: ctx.cwd,
|
|
94
|
-
configPath: ctx.configPath,
|
|
95
|
-
});
|
|
96
|
-
const appDir =
|
|
97
|
-
"config" in loaded ? loaded.config.appDir : join(ctx.cwd, "app");
|
|
98
|
-
const hydrateDefault =
|
|
99
|
-
"config" in loaded ? loaded.config.render.hydrate : "off";
|
|
100
|
-
|
|
101
|
-
const toolchain = checkToolchain(ctx.cwd);
|
|
102
|
-
const [deps, config, monorepo, hydration] = await Promise.all([
|
|
103
|
-
checkDeps(ctx.cwd, {
|
|
104
|
-
offline: args.offline,
|
|
105
|
-
noAudit: args.noAudit,
|
|
106
|
-
noOutdated: args.noOutdated,
|
|
107
|
-
auditLevel,
|
|
108
|
-
}),
|
|
109
|
-
checkConfig(ctx.cwd, ctx.configPath),
|
|
110
|
-
checkMonorepo(ctx.cwd, appDir, import.meta.dir),
|
|
111
|
-
checkHydration(ctx.cwd, appDir, hydrateDefault),
|
|
112
|
-
]);
|
|
113
|
-
|
|
114
|
-
const checks = [...toolchain, ...deps, ...config, ...hydration, ...monorepo];
|
|
115
|
-
const report: DoctorReport = { checks, summary: summarize(checks) };
|
|
116
|
-
|
|
117
|
-
process.stdout.write(args.json ? renderJson(report) : renderText(report));
|
|
118
|
-
|
|
119
|
-
return decideExit(report.summary, args.strict);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/** A fail always gates; under `--strict` a warning gates too. `skip` never does. */
|
|
123
|
-
export function decideExit(summary: Summary, strict: boolean): number {
|
|
124
|
-
if (summary.failed > 0) return EXIT.ERROR;
|
|
125
|
-
if (strict && summary.warning > 0) return EXIT.ERROR;
|
|
126
|
-
return EXIT.OK;
|
|
127
|
-
}
|
package/src/cli/index.ts
DELETED
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import { isAbsolute, resolve } from "node:path";
|
|
2
|
-
import pkg from "../../package.json" with { type: "json" };
|
|
3
|
-
import { runBuild } from "./build.ts";
|
|
4
|
-
import { runDeploy } from "./commands/deploy.ts";
|
|
5
|
-
import { runMigrate } from "./commands/migrate.ts";
|
|
6
|
-
import { runSecret } from "./commands/secret.ts";
|
|
7
|
-
import { runUpgrade } from "./commands/upgrade.ts";
|
|
8
|
-
import { REEXEC_FLAG, runDev } from "./dev.ts";
|
|
9
|
-
import { runDoctor } from "./doctor.ts";
|
|
10
|
-
import { EXIT, log, setVerbose } from "./log.ts";
|
|
11
|
-
import { runRun } from "./run.ts";
|
|
12
|
-
import { notifyUpdate } from "./update-check.ts";
|
|
13
|
-
|
|
14
|
-
const FRAMEWORK_VERSION = (pkg as { version: string }).version;
|
|
15
|
-
|
|
16
|
-
export interface CliContext {
|
|
17
|
-
cwd: string;
|
|
18
|
-
configPath?: string;
|
|
19
|
-
verbose: boolean;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface GlobalFlags extends CliContext {
|
|
23
|
-
noUpdateCheck: boolean;
|
|
24
|
-
rest: string[];
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// `null` means a long-running dev server now owns the process: don't exit.
|
|
28
|
-
export async function main(argv: string[]): Promise<number | null> {
|
|
29
|
-
const globals = extractGlobals(argv);
|
|
30
|
-
setVerbose(globals.verbose);
|
|
31
|
-
|
|
32
|
-
const [cmd, ...rest] = globals.rest;
|
|
33
|
-
|
|
34
|
-
if (cmd === "--version" || cmd === "-v") {
|
|
35
|
-
log.info(FRAMEWORK_VERSION);
|
|
36
|
-
return EXIT.OK;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (cmd === undefined || cmd === "help" || cmd === "--help" || cmd === "-h") {
|
|
40
|
-
printHelp();
|
|
41
|
-
return EXIT.OK;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const ctx: CliContext = {
|
|
45
|
-
cwd: globals.cwd,
|
|
46
|
-
configPath: globals.configPath,
|
|
47
|
-
verbose: globals.verbose,
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
// Prints from cache (instant) and refreshes in the background; never blocks.
|
|
51
|
-
// Skipped in the re-exec'd dev child: the parent already printed it, and
|
|
52
|
-
// `bun --hot` would repeat it on every edit.
|
|
53
|
-
if (process.env[REEXEC_FLAG] !== "1") {
|
|
54
|
-
await notifyUpdate(FRAMEWORK_VERSION, globals.noUpdateCheck);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
switch (cmd) {
|
|
58
|
-
case "dev":
|
|
59
|
-
return runDev(rest, ctx);
|
|
60
|
-
case "build":
|
|
61
|
-
return runBuild(rest, ctx);
|
|
62
|
-
case "start": {
|
|
63
|
-
const { runStart } = await import("./start.ts");
|
|
64
|
-
return runStart(rest, ctx);
|
|
65
|
-
}
|
|
66
|
-
case "run":
|
|
67
|
-
return runRun(rest, ctx);
|
|
68
|
-
case "deploy":
|
|
69
|
-
return runDeploy(rest, ctx);
|
|
70
|
-
case "secret":
|
|
71
|
-
return runSecret(rest, ctx);
|
|
72
|
-
case "doctor":
|
|
73
|
-
return runDoctor(rest, ctx);
|
|
74
|
-
// Import the UI commands lazily so `dev`/`build`/`deploy`/`secret`
|
|
75
|
-
// don't load them.
|
|
76
|
-
case "add": {
|
|
77
|
-
const { runAdd } = await import("./commands/add.ts");
|
|
78
|
-
return runAdd(rest, ctx);
|
|
79
|
-
}
|
|
80
|
-
case "ui": {
|
|
81
|
-
const { runUi } = await import("./commands/ui.ts");
|
|
82
|
-
return runUi(rest, ctx);
|
|
83
|
-
}
|
|
84
|
-
case "view": {
|
|
85
|
-
const { runView } = await import("./commands/view.ts");
|
|
86
|
-
return runView(rest, ctx);
|
|
87
|
-
}
|
|
88
|
-
case "update": {
|
|
89
|
-
const { runUpdate } = await import("./commands/update.ts");
|
|
90
|
-
return runUpdate(rest, ctx);
|
|
91
|
-
}
|
|
92
|
-
case "upgrade":
|
|
93
|
-
return runUpgrade(rest, ctx);
|
|
94
|
-
case "migrate":
|
|
95
|
-
return runMigrate(rest, ctx);
|
|
96
|
-
default:
|
|
97
|
-
log.error(`unknown command: ${cmd}`);
|
|
98
|
-
printHelp();
|
|
99
|
-
return EXIT.USAGE;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function extractGlobals(argv: string[]): GlobalFlags {
|
|
104
|
-
const rest: string[] = [];
|
|
105
|
-
let cwd = process.cwd();
|
|
106
|
-
let configPath: string | undefined;
|
|
107
|
-
let verbose = false;
|
|
108
|
-
let noUpdateCheck = false;
|
|
109
|
-
|
|
110
|
-
for (let i = 0; i < argv.length; i++) {
|
|
111
|
-
const a = argv[i];
|
|
112
|
-
if (a === undefined) continue;
|
|
113
|
-
if (a === "--cwd") {
|
|
114
|
-
const v = argv[++i];
|
|
115
|
-
if (v !== undefined) cwd = absolutize(v);
|
|
116
|
-
} else if (a.startsWith("--cwd=")) {
|
|
117
|
-
cwd = absolutize(a.slice(6));
|
|
118
|
-
} else if (a === "--config") {
|
|
119
|
-
const v = argv[++i];
|
|
120
|
-
if (v !== undefined) configPath = absolutize(v);
|
|
121
|
-
} else if (a.startsWith("--config=")) {
|
|
122
|
-
configPath = absolutize(a.slice(9));
|
|
123
|
-
} else if (a === "--verbose") {
|
|
124
|
-
verbose = true;
|
|
125
|
-
} else if (a === "--no-update-check") {
|
|
126
|
-
noUpdateCheck = true;
|
|
127
|
-
} else {
|
|
128
|
-
rest.push(a);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
return { cwd, configPath, verbose, noUpdateCheck, rest };
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
function absolutize(p: string): string {
|
|
135
|
-
return isAbsolute(p) ? p : resolve(process.cwd(), p);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
function printHelp(): void {
|
|
139
|
-
process.stdout.write(`sordo — Bun-native full-stack meta-framework
|
|
140
|
-
|
|
141
|
-
Usage:
|
|
142
|
-
sordo <command> [flags]
|
|
143
|
-
|
|
144
|
-
Commands:
|
|
145
|
-
dev Start the dev server (bun --hot by default).
|
|
146
|
-
build Produce a production bundle for the configured target.
|
|
147
|
-
start Run the production server from the last build (bun target).
|
|
148
|
-
run Run a workspace task with output caching + affected detection.
|
|
149
|
-
deploy Build then dispatch to an installed deploy plugin.
|
|
150
|
-
secret Manage dev-time secrets in the OS keychain.
|
|
151
|
-
doctor Run project hygiene checks (deps, config, monorepo).
|
|
152
|
-
add Stamp UI components (shadcn/ui, local, or registry) into your project.
|
|
153
|
-
ui UI catalog setup (sordo ui init).
|
|
154
|
-
view Print a component's source before stamping.
|
|
155
|
-
update Re-stamp components from the catalog after showing the diff.
|
|
156
|
-
upgrade Update the project's sordo dependency to the newest release.
|
|
157
|
-
migrate Codemods: radix imports / RTL logical properties.
|
|
158
|
-
help Show this message.
|
|
159
|
-
|
|
160
|
-
Global flags:
|
|
161
|
-
--cwd <path> Project root (default: process.cwd()).
|
|
162
|
-
--config <path> Explicit config file (default: discovery in cwd).
|
|
163
|
-
--verbose Verbose diagnostics (include stacks).
|
|
164
|
-
--no-update-check Skip the "update available" banner.
|
|
165
|
-
--version, -v Print version.
|
|
166
|
-
--help, -h Show this message.
|
|
167
|
-
`);
|
|
168
|
-
}
|
package/src/cli/log.ts
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
export const EXIT = {
|
|
2
|
-
OK: 0,
|
|
3
|
-
ERROR: 1,
|
|
4
|
-
USAGE: 2,
|
|
5
|
-
INTERRUPTED: 130,
|
|
6
|
-
} as const;
|
|
7
|
-
|
|
8
|
-
export type ExitCode = (typeof EXIT)[keyof typeof EXIT];
|
|
9
|
-
|
|
10
|
-
let verbose = false;
|
|
11
|
-
|
|
12
|
-
export function setVerbose(value: boolean): void {
|
|
13
|
-
verbose = value;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function isVerbose(): boolean {
|
|
17
|
-
return verbose;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function isTTY(stream: NodeJS.WriteStream): boolean {
|
|
21
|
-
return Boolean(stream?.isTTY);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function colorEnabled(stream: NodeJS.WriteStream): boolean {
|
|
25
|
-
if (process.env.NO_COLOR) return false;
|
|
26
|
-
return isTTY(stream);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const C = {
|
|
30
|
-
reset: "\x1b[0m",
|
|
31
|
-
dim: "\x1b[2m",
|
|
32
|
-
green: "\x1b[32m",
|
|
33
|
-
yellow: "\x1b[33m",
|
|
34
|
-
red: "\x1b[31m",
|
|
35
|
-
cyan: "\x1b[36m",
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
function paint(stream: NodeJS.WriteStream, code: string, msg: string): string {
|
|
39
|
-
return colorEnabled(stream) ? `${code}${msg}${C.reset}` : msg;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export type Color = "green" | "yellow" | "red" | "dim" | "cyan";
|
|
43
|
-
|
|
44
|
-
// Single source of truth for the CLI palette, so `sordo doctor` and any other
|
|
45
|
-
// formatted report tint with the same TTY/NO_COLOR-gated codes as `log`.
|
|
46
|
-
export function colorize(
|
|
47
|
-
stream: NodeJS.WriteStream,
|
|
48
|
-
color: Color,
|
|
49
|
-
msg: string,
|
|
50
|
-
): string {
|
|
51
|
-
return paint(stream, C[color], msg);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export const log = {
|
|
55
|
-
info(msg: string): void {
|
|
56
|
-
process.stdout.write(`${msg}\n`);
|
|
57
|
-
},
|
|
58
|
-
success(msg: string): void {
|
|
59
|
-
process.stdout.write(`${paint(process.stdout, C.green, "✓")} ${msg}\n`);
|
|
60
|
-
},
|
|
61
|
-
warn(msg: string): void {
|
|
62
|
-
process.stderr.write(`${paint(process.stderr, C.yellow, "⚠")} ${msg}\n`);
|
|
63
|
-
},
|
|
64
|
-
error(msg: string): void {
|
|
65
|
-
process.stderr.write(`${paint(process.stderr, C.red, "✗")} ${msg}\n`);
|
|
66
|
-
},
|
|
67
|
-
dim(msg: string): void {
|
|
68
|
-
process.stdout.write(`${paint(process.stdout, C.dim, msg)}\n`);
|
|
69
|
-
},
|
|
70
|
-
debug(msg: string): void {
|
|
71
|
-
if (!verbose) return;
|
|
72
|
-
process.stderr.write(`${paint(process.stderr, C.dim, msg)}\n`);
|
|
73
|
-
},
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
// Ask a yes/no question on stderr and read one line from stdin. Returns false
|
|
77
|
-
// on EOF / non-affirmative input. Callers gate this on a TTY and an explicit
|
|
78
|
-
// `--yes` escape hatch (cli/15 show-before-stamp).
|
|
79
|
-
export async function confirm(question: string): Promise<boolean> {
|
|
80
|
-
process.stderr.write(`${question} [y/N] `);
|
|
81
|
-
const line = await new Promise<string>((resolveLine) => {
|
|
82
|
-
const onData = (chunk: Buffer): void => {
|
|
83
|
-
process.stdin.pause();
|
|
84
|
-
process.stdin.off("data", onData);
|
|
85
|
-
resolveLine(chunk.toString());
|
|
86
|
-
};
|
|
87
|
-
process.stdin.resume();
|
|
88
|
-
process.stdin.on("data", onData);
|
|
89
|
-
});
|
|
90
|
-
return /^\s*y(es)?\s*$/i.test(line);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export interface FormatErrorInput {
|
|
94
|
-
title: string;
|
|
95
|
-
file?: string;
|
|
96
|
-
line?: number;
|
|
97
|
-
col?: number;
|
|
98
|
-
reason?: string;
|
|
99
|
-
tip?: string;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export function formatError(input: FormatErrorInput): string {
|
|
103
|
-
const out: string[] = [];
|
|
104
|
-
out.push(`${paint(process.stderr, C.red, "✗")} ${input.title}`);
|
|
105
|
-
if (input.file) {
|
|
106
|
-
const loc =
|
|
107
|
-
input.line !== undefined
|
|
108
|
-
? `${input.file}:${input.line}${input.col !== undefined ? `:${input.col}` : ""}`
|
|
109
|
-
: input.file;
|
|
110
|
-
out.push(` File: ${loc}`);
|
|
111
|
-
}
|
|
112
|
-
if (input.reason) out.push(` Reason: ${input.reason}`);
|
|
113
|
-
if (input.tip) out.push(` → Tip: ${input.tip}`);
|
|
114
|
-
return out.join("\n");
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
export function printError(input: FormatErrorInput): void {
|
|
118
|
-
process.stderr.write(`${formatError(input)}\n`);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export type SigintHandler = () => void | Promise<void>;
|
|
122
|
-
|
|
123
|
-
let sigintInstalled = false;
|
|
124
|
-
|
|
125
|
-
export function installSigintHandler(onSignal?: SigintHandler): void {
|
|
126
|
-
if (sigintInstalled) return;
|
|
127
|
-
sigintInstalled = true;
|
|
128
|
-
process.on("SIGINT", async () => {
|
|
129
|
-
try {
|
|
130
|
-
if (onSignal) await onSignal();
|
|
131
|
-
} finally {
|
|
132
|
-
process.exit(EXIT.INTERRUPTED);
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
}
|
package/src/cli/run/affected.ts
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
// Affected detection for `sordo run --affected` (framework/27-task-runner-cache).
|
|
2
|
-
// Diff the working tree against a base ref, map changed files to their owning
|
|
3
|
-
// workspace packages, then take the reverse-graph closure (a package + every
|
|
4
|
-
// package that transitively depends on it). This is an OPTIMIZATION layer: with
|
|
5
|
-
// the `internalDepKeys` term in the cache key, running the task across all
|
|
6
|
-
// packages is already correct — unchanged packages are cache hits. `--affected`
|
|
7
|
-
// merely skips even the hit lookups.
|
|
8
|
-
|
|
9
|
-
import { gitEnv } from "./git.ts";
|
|
10
|
-
import { dependentsClosure, type Workspace } from "./workspace.ts";
|
|
11
|
-
|
|
12
|
-
/** All affected package names, or "all" when the change set is repo-wide /
|
|
13
|
-
* undeterminable (root-level change, or git unavailable). */
|
|
14
|
-
export type Affected = Set<string> | "all";
|
|
15
|
-
|
|
16
|
-
export interface AffectedOptions {
|
|
17
|
-
since?: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const DEFAULT_BASE = "origin/main";
|
|
21
|
-
|
|
22
|
-
export async function computeAffected(
|
|
23
|
-
ws: Workspace,
|
|
24
|
-
opts: AffectedOptions = {},
|
|
25
|
-
): Promise<Affected> {
|
|
26
|
-
const ref = opts.since ?? DEFAULT_BASE;
|
|
27
|
-
|
|
28
|
-
const base = await mergeBase(ws.root, ref);
|
|
29
|
-
if (base === null) return "all"; // shallow clone / detached / unknown ref
|
|
30
|
-
|
|
31
|
-
const changed = await changedFiles(ws.root, base);
|
|
32
|
-
if (changed === null) return "all";
|
|
33
|
-
|
|
34
|
-
const seeds = new Set<string>();
|
|
35
|
-
for (const file of changed) {
|
|
36
|
-
const owner = ws.fileToPackage(file);
|
|
37
|
-
if (owner === null) return "all"; // a root-level change touches everything
|
|
38
|
-
seeds.add(owner);
|
|
39
|
-
}
|
|
40
|
-
return dependentsClosure(ws, seeds);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
async function mergeBase(root: string, ref: string): Promise<string | null> {
|
|
44
|
-
const res = await Bun.$`git merge-base ${ref} HEAD`
|
|
45
|
-
.cwd(root)
|
|
46
|
-
.env(gitEnv())
|
|
47
|
-
.nothrow()
|
|
48
|
-
.quiet();
|
|
49
|
-
if (res.exitCode !== 0) return null;
|
|
50
|
-
const sha = res.stdout.toString().trim();
|
|
51
|
-
return sha === "" ? null : sha;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
async function changedFiles(
|
|
55
|
-
root: string,
|
|
56
|
-
base: string,
|
|
57
|
-
): Promise<string[] | null> {
|
|
58
|
-
const diff = await Bun.$`git diff --name-only ${base}...HEAD`
|
|
59
|
-
.cwd(root)
|
|
60
|
-
.env(gitEnv())
|
|
61
|
-
.nothrow()
|
|
62
|
-
.quiet();
|
|
63
|
-
if (diff.exitCode !== 0) return null;
|
|
64
|
-
|
|
65
|
-
// Include untracked-but-not-ignored files so a brand-new package/file counts.
|
|
66
|
-
const untracked = await Bun.$`git ls-files --others --exclude-standard`
|
|
67
|
-
.cwd(root)
|
|
68
|
-
.env(gitEnv())
|
|
69
|
-
.nothrow()
|
|
70
|
-
.quiet();
|
|
71
|
-
|
|
72
|
-
const files = new Set<string>();
|
|
73
|
-
for (const line of diff.stdout.toString().split("\n"))
|
|
74
|
-
if (line !== "") files.add(line);
|
|
75
|
-
if (untracked.exitCode === 0)
|
|
76
|
-
for (const line of untracked.stdout.toString().split("\n"))
|
|
77
|
-
if (line !== "") files.add(line);
|
|
78
|
-
return [...files];
|
|
79
|
-
}
|