@wolfstar/cli 2.1.0 → 2.2.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/LICENSE +201 -201
- package/README.md +304 -304
- package/dist/{_shared-B-hRZDRS.js → _shared-DJrpalNQ.js} +12 -5
- package/dist/_shared-DJrpalNQ.js.map +1 -0
- package/dist/{build-CPnSLYME.js → build-CluOR8dJ.js} +5 -5
- package/dist/build-CluOR8dJ.js.map +1 -0
- package/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/{codegen-BqpLGLLs.js → codegen-D6V1i_fa.js} +4 -4
- package/dist/codegen-D6V1i_fa.js.map +1 -0
- package/dist/{commands-ExM8HILu.js → commands-BJ589_AC.js} +4 -4
- package/dist/commands-BJ589_AC.js.map +1 -0
- package/dist/{dev-4wpEQC7l.js → dev-DJJZN4NJ.js} +11 -30
- package/dist/dev-DJJZN4NJ.js.map +1 -0
- package/dist/{diagnostics-CZBVxlpj.js → diagnostics-3JRAy8Xj.js} +17 -1
- package/dist/diagnostics-3JRAy8Xj.js.map +1 -0
- package/dist/{errors-Crt4hu0b.js → errors-COFWKKKw.js} +5 -2
- package/dist/errors-COFWKKKw.js.map +1 -0
- package/dist/external-CxFKxwi3.js.map +1 -1
- package/dist/framework-auto-imports-Gu_PXSyr.js.map +1 -1
- package/dist/hooks-BfDFM38k.js +316 -0
- package/dist/hooks-BfDFM38k.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/{info-CdiQajgn.js → info-C1Kx_4Og.js} +4 -4
- package/dist/info-C1Kx_4Og.js.map +1 -0
- package/dist/{locales-C7X8VNmK.js → locales-BzOLRBVg.js} +5 -5
- package/dist/locales-BzOLRBVg.js.map +1 -0
- package/dist/log-buffer-CY82aqnb.js.map +1 -1
- package/dist/{nitro-sP2F3SQu.js → nitro-yjqZBh5L.js} +2 -2
- package/dist/nitro-yjqZBh5L.js.map +1 -0
- package/dist/none-uC_wi_l4.js.map +1 -1
- package/dist/output-mode-Bp7Da8vJ.js.map +1 -1
- package/dist/plain-B6z85uQP.js.map +1 -1
- package/dist/{prepare-B4ysyG6H.js → prepare-Cb45Z4re.js} +9 -5
- package/dist/prepare-Cb45Z4re.js.map +1 -0
- package/dist/{project-MD4dIo2X.js → project-D-8VIcyF.js} +2 -2
- package/dist/project-D-8VIcyF.js.map +1 -0
- package/dist/{run-Ddwrxe1O.js → run-BiLZqib3.js} +8 -8
- package/dist/run-BiLZqib3.js.map +1 -0
- package/dist/theme-3Fc_LI-2.js.map +1 -1
- package/dist/tsc-B931Ezh7.js +3 -0
- package/dist/{tsc-DO7D_uCl.js → tsc-DEBcwIO0.js} +3 -3
- package/dist/tsc-DEBcwIO0.js.map +1 -0
- package/dist/{tsdown-CD68G8_U.js → tsdown-DrWXld54.js} +2 -2
- package/dist/tsdown-DrWXld54.js.map +1 -0
- package/dist/tui-BRddrLQP.js.map +1 -1
- package/dist/{tunnel-DT1FH6oA.js → tunnel-DHSxOZKr.js} +2 -2
- package/dist/tunnel-DHSxOZKr.js.map +1 -0
- package/dist/version-BzclCE19.js.map +1 -1
- package/dist/{vite-CLyB6wl7.js → vite-Bf7nrJx7.js} +2 -2
- package/dist/vite-Bf7nrJx7.js.map +1 -0
- package/package.json +5 -4
- package/dist/_shared-B-hRZDRS.js.map +0 -1
- package/dist/build-CPnSLYME.js.map +0 -1
- package/dist/codegen-BqpLGLLs.js.map +0 -1
- package/dist/commands-ExM8HILu.js.map +0 -1
- package/dist/dev-4wpEQC7l.js.map +0 -1
- package/dist/diagnostics-CZBVxlpj.js.map +0 -1
- package/dist/errors-Crt4hu0b.js.map +0 -1
- package/dist/hooks-H9kjLCMk.js +0 -148
- package/dist/hooks-H9kjLCMk.js.map +0 -1
- package/dist/info-CdiQajgn.js.map +0 -1
- package/dist/locales-C7X8VNmK.js.map +0 -1
- package/dist/nitro-sP2F3SQu.js.map +0 -1
- package/dist/prepare-B4ysyG6H.js.map +0 -1
- package/dist/project-MD4dIo2X.js.map +0 -1
- package/dist/run-Ddwrxe1O.js.map +0 -1
- package/dist/tsc-DO7D_uCl.js.map +0 -1
- package/dist/tsc-YnAWKn3n.js +0 -3
- package/dist/tsdown-CD68G8_U.js.map +0 -1
- package/dist/tunnel-DT1FH6oA.js.map +0 -1
- package/dist/vite-CLyB6wl7.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plain-B6z85uQP.js","names":[],"sources":["../src/dev/tui/plain.ts"],"sourcesContent":["import { createColors } from 'colorette';\nimport type { DevService } from '../dev-service.js';\nimport type { LogEntry } from '../../utils/log-buffer.js';\n\nexport interface PlainRendererOptions {\n\tstdout?: NodeJS.WritableStream;\n\tcolor?: boolean;\n\t/** Whether to attach process signal handlers. */\n\tsignals?: boolean;\n}\n\nexport interface Renderer {\n\t/** Starts rendering. Resolves when the user asks to quit (or never, in plain mode without signals). */\n\tstart(): Promise<void>;\n\t/** Stops rendering and restores the terminal. */\n\tstop(): void;\n}\n\n/**\n * Line-oriented renderer for non-interactive terminals, CI and redirected output.\n */\nexport function createPlainRenderer(service: DevService, options: PlainRendererOptions = {}): Renderer {\n\tconst stdout = options.stdout ?? process.stdout;\n\tconst colors = createColors({ useColor: options.color ?? false });\n\tconst write = (text: string) => stdout.write(`${text}\\n`);\n\n\tconst prefixes = {\n\t\tstars: colors.cyan('stars'),\n\t\tbuild: colors.magenta('build'),\n\t\ttsc: colors.blue('tsc'),\n\t\ttunnel: colors.yellow('tunnel'),\n\t\tapp: null\n\t} as const;\n\n\tconst onEntry = (entry: LogEntry) => {\n\t\tconst prefix = prefixes[entry.source];\n\t\tif (!prefix) {\n\t\t\twrite(entry.text);\n\t\t\treturn;\n\t\t}\n\n\t\tconst paint =\n\t\t\tentry.level === 'error'\n\t\t\t\t? colors.red\n\t\t\t\t: entry.level === 'warn'\n\t\t\t\t\t? colors.yellow\n\t\t\t\t\t: entry.level === 'success'\n\t\t\t\t\t\t? colors.green\n\t\t\t\t\t\t: (value: string) => value;\n\t\twrite(`${prefix} ${paint(entry.text)}`);\n\t};\n\n\tconst onClear = () => write(`${prefixes.stars} logs cleared`);\n\n\treturn {\n\t\tstart() {\n\t\t\tservice.logs.on('entry', onEntry);\n\t\t\tservice.logs.on('clear', onClear);\n\t\t\treturn new Promise<void>(() => {});\n\t\t},\n\t\tstop() {\n\t\t\tservice.logs.off('entry', onEntry);\n\t\t\tservice.logs.off('clear', onClear);\n\t\t}\n\t};\n}\n"],"mappings":";;;;;;AAqBA,SAAgB,oBAAoB,SAAqB,UAAgC,CAAC,GAAa;CACtG,MAAM,SAAS,QAAQ,UAAU,QAAQ;CACzC,MAAM,SAAS,aAAa,EAAE,UAAU,QAAQ,SAAS,MAAM,CAAC;CAChE,MAAM,SAAS,SAAiB,OAAO,MAAM,GAAG,KAAK,GAAG;CAExD,MAAM,WAAW;EAChB,OAAO,OAAO,KAAK,OAAO;EAC1B,OAAO,OAAO,QAAQ,OAAO;EAC7B,KAAK,OAAO,KAAK,KAAK;EACtB,QAAQ,OAAO,OAAO,QAAQ;EAC9B,KAAK;CACN;CAEA,MAAM,WAAW,UAAoB;EACpC,MAAM,SAAS,SAAS,MAAM;EAC9B,IAAI,CAAC,QAAQ;GACZ,MAAM,MAAM,IAAI;GAChB;EACD;EAEA,MAAM,QACL,MAAM,UAAU,UACb,OAAO,MACP,MAAM,UAAU,SACf,OAAO,SACP,MAAM,UAAU,YACf,OAAO,SACN,UAAkB;EACzB,MAAM,GAAG,OAAO,GAAG,MAAM,MAAM,IAAI,GAAG;CACvC;CAEA,MAAM,gBAAgB,MAAM,GAAG,SAAS,MAAM,cAAc;CAE5D,OAAO;EACN,QAAQ;GACP,QAAQ,KAAK,GAAG,SAAS,OAAO;GAChC,QAAQ,KAAK,GAAG,SAAS,OAAO;GAChC,OAAO,IAAI,cAAoB,CAAC,CAAC;EAClC;EACA,OAAO;GACN,QAAQ,KAAK,IAAI,SAAS,OAAO;GACjC,QAAQ,KAAK,IAAI,SAAS,OAAO;EAClC;CACD;AACD"}
|
|
1
|
+
{"version":3,"file":"plain-B6z85uQP.js","names":[],"sources":["../src/dev/tui/plain.ts"],"sourcesContent":["import { createColors } from 'colorette';\r\nimport type { DevService } from '../dev-service.js';\r\nimport type { LogEntry } from '../../utils/log-buffer.js';\r\n\r\nexport interface PlainRendererOptions {\r\n\tstdout?: NodeJS.WritableStream;\r\n\tcolor?: boolean;\r\n\t/** Whether to attach process signal handlers. */\r\n\tsignals?: boolean;\r\n}\r\n\r\nexport interface Renderer {\r\n\t/** Starts rendering. Resolves when the user asks to quit (or never, in plain mode without signals). */\r\n\tstart(): Promise<void>;\r\n\t/** Stops rendering and restores the terminal. */\r\n\tstop(): void;\r\n}\r\n\r\n/**\r\n * Line-oriented renderer for non-interactive terminals, CI and redirected output.\r\n */\r\nexport function createPlainRenderer(service: DevService, options: PlainRendererOptions = {}): Renderer {\r\n\tconst stdout = options.stdout ?? process.stdout;\r\n\tconst colors = createColors({ useColor: options.color ?? false });\r\n\tconst write = (text: string) => stdout.write(`${text}\\n`);\r\n\r\n\tconst prefixes = {\r\n\t\tstars: colors.cyan('stars'),\r\n\t\tbuild: colors.magenta('build'),\r\n\t\ttsc: colors.blue('tsc'),\r\n\t\ttunnel: colors.yellow('tunnel'),\r\n\t\tapp: null\r\n\t} as const;\r\n\r\n\tconst onEntry = (entry: LogEntry) => {\r\n\t\tconst prefix = prefixes[entry.source];\r\n\t\tif (!prefix) {\r\n\t\t\twrite(entry.text);\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tconst paint =\r\n\t\t\tentry.level === 'error'\r\n\t\t\t\t? colors.red\r\n\t\t\t\t: entry.level === 'warn'\r\n\t\t\t\t\t? colors.yellow\r\n\t\t\t\t\t: entry.level === 'success'\r\n\t\t\t\t\t\t? colors.green\r\n\t\t\t\t\t\t: (value: string) => value;\r\n\t\twrite(`${prefix} ${paint(entry.text)}`);\r\n\t};\r\n\r\n\tconst onClear = () => write(`${prefixes.stars} logs cleared`);\r\n\r\n\treturn {\r\n\t\tstart() {\r\n\t\t\tservice.logs.on('entry', onEntry);\r\n\t\t\tservice.logs.on('clear', onClear);\r\n\t\t\treturn new Promise<void>(() => {});\r\n\t\t},\r\n\t\tstop() {\r\n\t\t\tservice.logs.off('entry', onEntry);\r\n\t\t\tservice.logs.off('clear', onClear);\r\n\t\t}\r\n\t};\r\n}\r\n"],"mappings":";;;;;;AAqBA,SAAgB,oBAAoB,SAAqB,UAAgC,CAAC,GAAa;CACtG,MAAM,SAAS,QAAQ,UAAU,QAAQ;CACzC,MAAM,SAAS,aAAa,EAAE,UAAU,QAAQ,SAAS,MAAM,CAAC;CAChE,MAAM,SAAS,SAAiB,OAAO,MAAM,GAAG,KAAK,GAAG;CAExD,MAAM,WAAW;EAChB,OAAO,OAAO,KAAK,OAAO;EAC1B,OAAO,OAAO,QAAQ,OAAO;EAC7B,KAAK,OAAO,KAAK,KAAK;EACtB,QAAQ,OAAO,OAAO,QAAQ;EAC9B,KAAK;CACN;CAEA,MAAM,WAAW,UAAoB;EACpC,MAAM,SAAS,SAAS,MAAM;EAC9B,IAAI,CAAC,QAAQ;GACZ,MAAM,MAAM,IAAI;GAChB;EACD;EAEA,MAAM,QACL,MAAM,UAAU,UACb,OAAO,MACP,MAAM,UAAU,SACf,OAAO,SACP,MAAM,UAAU,YACf,OAAO,SACN,UAAkB;EACzB,MAAM,GAAG,OAAO,GAAG,MAAM,MAAM,IAAI,GAAG;CACvC;CAEA,MAAM,gBAAgB,MAAM,GAAG,SAAS,MAAM,cAAc;CAE5D,OAAO;EACN,QAAQ;GACP,QAAQ,KAAK,GAAG,SAAS,OAAO;GAChC,QAAQ,KAAK,GAAG,SAAS,OAAO;GAChC,OAAO,IAAI,cAAoB,CAAC,CAAC;EAClC;EACA,OAAO;GACN,QAAQ,KAAK,IAAI,SAAS,OAAO;GACjC,QAAQ,KAAK,IAAI,SAAS,OAAO;EAClC;CACD;AACD"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { i as shouldUseColor } from "./output-mode-Bp7Da8vJ.js";
|
|
2
|
-
import { t as cliDiagnostics } from "./diagnostics-
|
|
3
|
-
import {
|
|
4
|
-
import { n as reportWarnings, t as prepareProject } from "./_shared-
|
|
2
|
+
import { t as cliDiagnostics } from "./diagnostics-3JRAy8Xj.js";
|
|
3
|
+
import { l as projectArgs, n as loadProject, u as resolveCwd } from "./hooks-BfDFM38k.js";
|
|
4
|
+
import { n as reportWarnings, t as prepareProject } from "./_shared-DJrpalNQ.js";
|
|
5
5
|
import { defineCommand } from "citty";
|
|
6
6
|
import { displayPath } from "@wolfstar/schema";
|
|
7
7
|
import { createColors } from "colorette";
|
|
@@ -25,12 +25,16 @@ async function runPrepare(options) {
|
|
|
25
25
|
else {
|
|
26
26
|
const paintConfig = result.tsconfig.status === "outdated" ? colors.red : colors.green;
|
|
27
27
|
stdout.write(`${colors.dim("stars")} tsconfig: ${paintConfig(result.tsconfig.status)} ${displayPath(config.root, result.tsconfig.path)}\n`);
|
|
28
|
+
if (result.modules) {
|
|
29
|
+
const paint = result.modules.status === "outdated" ? colors.red : colors.green;
|
|
30
|
+
stdout.write(`${colors.dim("stars")} modules: ${paint(result.modules.status)} ${displayPath(config.root, result.modules.path)}\n`);
|
|
31
|
+
}
|
|
28
32
|
if (result.enabled) {
|
|
29
33
|
const paint = result.status === "outdated" ? colors.red : colors.green;
|
|
30
34
|
stdout.write(`${colors.dim("stars")} imports: ${paint(result.status)} ${displayPath(config.root, result.dts)}\n`);
|
|
31
35
|
}
|
|
32
36
|
}
|
|
33
|
-
if (result.status === "outdated" || result.tsconfig.status === "outdated") throw cliDiagnostics.PREPARE_OUTDATED({});
|
|
37
|
+
if (result.status === "outdated" || result.tsconfig.status === "outdated" || result.modules?.status === "outdated") throw cliDiagnostics.PREPARE_OUTDATED({});
|
|
34
38
|
}
|
|
35
39
|
var prepare_default = defineCommand({
|
|
36
40
|
meta: {
|
|
@@ -62,4 +66,4 @@ var prepare_default = defineCommand({
|
|
|
62
66
|
|
|
63
67
|
//#endregion
|
|
64
68
|
export { prepare_default as default };
|
|
65
|
-
//# sourceMappingURL=prepare-
|
|
69
|
+
//# sourceMappingURL=prepare-Cb45Z4re.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepare-Cb45Z4re.js","names":[],"sources":["../src/commands/prepare.ts"],"sourcesContent":["import { displayPath } from '@wolfstar/schema';\r\nimport { defineCommand } from 'citty';\r\nimport { createColors } from 'colorette';\r\nimport { projectArgs, resolveCwd, type ProjectArgs } from '../utils/args.js';\r\nimport { cliDiagnostics } from '../utils/diagnostics.js';\r\nimport { shouldUseColor } from '../utils/output-mode.js';\r\nimport { loadProject } from '../utils/hooks.js';\r\nimport { prepareProject, reportWarnings } from './_shared.js';\r\n\r\nexport { prepareProject } from './_shared.js';\r\n\r\nexport interface PrepareTaskOptions extends ProjectArgs {\r\n\tcheck?: boolean;\r\n\tjson?: boolean;\r\n\tstdout?: NodeJS.WritableStream;\r\n}\r\n\r\n/**\r\n * Generates `.stars/tsconfig.json` and `imports.dts` (see {@link StarsImportsConfig} in `@wolfstar/schema`), the way `nuxt\r\n * prepare` regenerates `.nuxt/imports.d.ts`. Run automatically by `stars dev` and `stars build` before the first\r\n * build; `--check` fails instead of writing, for CI.\r\n */\r\nexport async function runPrepare(options: PrepareTaskOptions): Promise<void> {\r\n\tconst stdout = options.stdout ?? process.stdout;\r\n\tconst colors = createColors({ useColor: shouldUseColor() && !options.json });\r\n\tconst { config, hooks } = await loadProject({ cwd: resolveCwd(options), configFile: options.config });\r\n\tawait reportWarnings(config, (text) => process.stderr.write(`${text}\\n`));\r\n\tconst result = await prepareProject(config, hooks, Boolean(options.check));\r\n\r\n\tif (options.json) {\r\n\t\tstdout.write(`${JSON.stringify(result, null, 2)}\\n`);\r\n\t} else {\r\n\t\tconst paintConfig = result.tsconfig.status === 'outdated' ? colors.red : colors.green;\r\n\t\tstdout.write(`${colors.dim('stars')} tsconfig: ${paintConfig(result.tsconfig.status)} ${displayPath(config.root, result.tsconfig.path)}\\n`);\r\n\t\tif (result.modules) {\r\n\t\t\tconst paint = result.modules.status === 'outdated' ? colors.red : colors.green;\r\n\t\t\tstdout.write(`${colors.dim('stars')} modules: ${paint(result.modules.status)} ${displayPath(config.root, result.modules.path)}\\n`);\r\n\t\t}\r\n\t\tif (result.enabled) {\r\n\t\t\tconst paint = result.status === 'outdated' ? colors.red : colors.green;\r\n\t\t\tstdout.write(`${colors.dim('stars')} imports: ${paint(result.status)} ${displayPath(config.root, result.dts)}\\n`);\r\n\t\t}\r\n\t}\r\n\r\n\tif (result.status === 'outdated' || result.tsconfig.status === 'outdated' || result.modules?.status === 'outdated') {\r\n\t\tthrow cliDiagnostics.PREPARE_OUTDATED({});\r\n\t}\r\n}\r\n\r\nexport default defineCommand({\r\n\tmeta: {\r\n\t\tname: 'prepare',\r\n\t\tdescription: 'Generate TypeScript configuration and auto imports declarations'\r\n\t},\r\n\targs: {\r\n\t\t...projectArgs,\r\n\t\tcheck: {\r\n\t\t\ttype: 'boolean',\r\n\t\t\tdescription: 'Fail when the generated files are out of date instead of writing it',\r\n\t\t\tdefault: false\r\n\t\t},\r\n\t\tjson: {\r\n\t\t\ttype: 'boolean',\r\n\t\t\tdescription: 'Print machine-readable JSON',\r\n\t\t\tdefault: false\r\n\t\t}\r\n\t},\r\n\tasync run({ args }) {\r\n\t\tawait runPrepare({ config: args.config, cwd: args.cwd, check: args.check, json: args.json });\r\n\t}\r\n});\r\n"],"mappings":";;;;;;;;;;;;;;AAsBA,eAAsB,WAAW,SAA4C;CAC5E,MAAM,SAAS,QAAQ,UAAU,QAAQ;CACzC,MAAM,SAAS,aAAa,EAAE,UAAU,eAAe,KAAK,CAAC,QAAQ,KAAK,CAAC;CAC3E,MAAM,EAAE,QAAQ,UAAU,MAAM,YAAY;EAAE,KAAK,WAAW,OAAO;EAAG,YAAY,QAAQ;CAAO,CAA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W;GAAE,QAAQ,KAAK;GAAQ,KAAK,KAAK;GAAK,OAAO,KAAK;GAAO,MAAM,KAAK;EAAK,CAAC;CAC5F;AACD,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as cliDiagnostics } from "./diagnostics-
|
|
1
|
+
import { t as cliDiagnostics } from "./diagnostics-3JRAy8Xj.js";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import { existsSync, readFileSync } from "node:fs";
|
|
4
4
|
import { dirname, join } from "node:path";
|
|
@@ -64,4 +64,4 @@ function findInstalledVersion(root, name) {
|
|
|
64
64
|
|
|
65
65
|
//#endregion
|
|
66
66
|
export { resolveFromProject as i, importFromProject as n, resolveBinary as r, findInstalledVersion as t };
|
|
67
|
-
//# sourceMappingURL=project-
|
|
67
|
+
//# sourceMappingURL=project-D-8VIcyF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-D-8VIcyF.js","names":[],"sources":["../src/utils/project.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\r\nimport { createRequire } from 'node:module';\r\nimport { dirname, join } from 'node:path';\r\nimport { pathToFileURL } from 'node:url';\r\nimport { cliDiagnostics } from './diagnostics.js';\r\n\r\n/**\r\n * Resolves a module id from the project root, the way the project itself would.\r\n */\r\nexport function resolveFromProject(root: string, id: string): string | null {\r\n\ttry {\r\n\t\treturn createRequire(join(root, 'package.json')).resolve(id);\r\n\t} catch {\r\n\t\treturn null;\r\n\t}\r\n}\r\n\r\n/**\r\n * Imports a module from the project root, failing with an actionable error when it is not installed.\r\n */\r\nexport async function importFromProject<T>(root: string, id: string, hint: string): Promise<T> {\r\n\tconst resolved = resolveFromProject(root, id);\r\n\tif (!resolved) {\r\n\t\tthrow cliDiagnostics.DEPENDENCY_MISSING({ name: id, root, hint });\r\n\t}\r\n\r\n\treturn (await import(pathToFileURL(resolved).href)) as T;\r\n}\r\n\r\n/**\r\n * Resolves an executable a package declares in its `package.json#bin`, from the project's own `node_modules`.\r\n *\r\n * Going through `bin` rather than a hardcoded path is what makes this work across layouts: TypeScript 7 hides\r\n * `lib/tsc.js` behind its `exports` map, and packages move their entry points between releases.\r\n */\r\nexport function resolveBinary(root: string, packageName: string, binName: string): string | null {\r\n\tconst packageJsonPath = resolveFromProject(root, `${packageName}/package.json`);\r\n\tif (!packageJsonPath) return null;\r\n\r\n\ttry {\r\n\t\tconst packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8')) as { bin?: string | Record<string, string> };\r\n\t\tconst bin = typeof packageJson.bin === 'string' ? packageJson.bin : packageJson.bin?.[binName];\r\n\t\treturn bin ? join(dirname(packageJsonPath), bin) : null;\r\n\t} catch {\r\n\t\treturn null;\r\n\t}\r\n}\r\n\r\n/**\r\n * Finds the version of an installed package by walking `node_modules` up from `root`.\r\n */\r\nexport function findInstalledVersion(root: string, name: string): string | null {\r\n\tlet directory = root;\r\n\tfor (;;) {\r\n\t\tconst file = join(directory, 'node_modules', name, 'package.json');\r\n\t\tif (existsSync(file)) {\r\n\t\t\ttry {\r\n\t\t\t\tconst parsed = JSON.parse(readFileSync(file, 'utf-8')) as { version?: string };\r\n\t\t\t\treturn parsed.version ?? null;\r\n\t\t\t} catch {\r\n\t\t\t\treturn null;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tconst parent = dirname(directory);\r\n\t\tif (parent === directory) return null;\r\n\t\tdirectory = parent;\r\n\t}\r\n}\r\n"],"mappings":";;;;;;;;;;AASA,SAAgB,mBAAmB,MAAc,IAA2B;CAC3E,IAAI;EACH,OAAO,cAAc,KAAK,MAAM,cAAc,CAAC,CAAC,CAAC,QAAQ,EAAE;CAC5D,QAAQ;EACP,OAAO;CACR;AACD;;;;AAKA,eAAsB,kBAAqB,MAAc,IAAY,MAA0B;CAC9F,MAAM,WAAW,mBAAmB,MAAM,EAAE;CAC5C,IAAI,CAAC,UACJ,MAAM,eAAe,mBAAmB;EAAE,MAAM;EAAI;EAAM;CAAK,CAAC;CAGjE,OAAQ,MAAM,OAAO,cAAc,QAAQ,CAAC,CAAC;AAC9C;;;;;;;AAQA,SAAgB,cAAc,MAAc,aAAqB,SAAgC;CAChG,MAAM,kBAAkB,mBAAmB,MAAM,GAAG,YAAY,cAAc;CAC9E,IAAI,CAAC,iBAAiB,OAAO;CAE7B,IAAI;EACH,MAAM,cAAc,KAAK,MAAM,aAAa,iBAAiB,OAAO,CAAC;EACrE,MAAM,MAAM,OAAO,YAAY,QAAQ,WAAW,YAAY,MAAM,YAAY,MAAM;EACtF,OAAO,MAAM,KAAK,QAAQ,eAAe,GAAG,GAAG,IAAI;CACpD,QAAQ;EACP,OAAO;CACR;AACD;;;;AAKA,SAAgB,qBAAqB,MAAc,MAA6B;CAC/E,IAAI,YAAY;CAChB,SAAS;EACR,MAAM,OAAO,KAAK,WAAW,gBAAgB,MAAM,cAAc;EACjE,IAAI,WAAW,IAAI,GAClB,IAAI;GAEH,OADe,KAAK,MAAM,aAAa,MAAM,OAAO,CACxC,CAAC,CAAC,WAAW;EAC1B,QAAQ;GACP,OAAO;EACR;EAGD,MAAM,SAAS,QAAQ,SAAS;EAChC,IAAI,WAAW,WAAW,OAAO;EACjC,YAAY;CACb;AACD"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { t as readOwnPackageJson } from "./version-BzclCE19.js";
|
|
2
|
-
import { n as exitCodeOf, r as formatError } from "./errors-
|
|
2
|
+
import { n as exitCodeOf, r as formatError } from "./errors-COFWKKKw.js";
|
|
3
3
|
import { defineCommand, renderUsage, runCommand } from "citty";
|
|
4
4
|
import process from "node:process";
|
|
5
5
|
|
|
6
6
|
//#region src/commands/index.ts
|
|
7
7
|
const commands = {
|
|
8
|
-
dev: () => import("./dev-
|
|
9
|
-
build: () => import("./build-
|
|
10
|
-
info: () => import("./info-
|
|
11
|
-
codegen: () => import("./codegen-
|
|
12
|
-
prepare: () => import("./prepare-
|
|
13
|
-
commands: () => import("./commands-
|
|
8
|
+
dev: () => import("./dev-DJJZN4NJ.js").then((module) => module.default),
|
|
9
|
+
build: () => import("./build-CluOR8dJ.js").then((module) => module.default),
|
|
10
|
+
info: () => import("./info-C1Kx_4Og.js").then((module) => module.default),
|
|
11
|
+
codegen: () => import("./codegen-D6V1i_fa.js").then((module) => module.default),
|
|
12
|
+
prepare: () => import("./prepare-Cb45Z4re.js").then((module) => module.default),
|
|
13
|
+
commands: () => import("./commands-BJ589_AC.js").then((module) => module.default)
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
//#endregion
|
|
@@ -62,4 +62,4 @@ async function runMain(argv = process.argv.slice(2)) {
|
|
|
62
62
|
|
|
63
63
|
//#endregion
|
|
64
64
|
export { runMain as t };
|
|
65
|
-
//# sourceMappingURL=run-
|
|
65
|
+
//# sourceMappingURL=run-BiLZqib3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-BiLZqib3.js","names":["_runCommand"],"sources":["../src/commands/index.ts","../src/main.ts","../src/run.ts"],"sourcesContent":["import type { CommandDef } from 'citty';\r\n\r\n// citty types each command by its own arguments; the registry needs the erased form.\r\n// oxlint-disable-next-line typescript/no-explicit-any\r\ntype AnyCommand = CommandDef<any>;\r\n\r\nexport const commands: Record<string, () => Promise<AnyCommand>> = {\r\n\tdev: () => import('./dev.js').then((module) => module.default),\r\n\tbuild: () => import('./build.js').then((module) => module.default),\r\n\tinfo: () => import('./info.js').then((module) => module.default),\r\n\tcodegen: () => import('./codegen.js').then((module) => module.default),\r\n\tprepare: () => import('./prepare.js').then((module) => module.default),\r\n\tcommands: () => import('./commands.js').then((module) => module.default)\r\n};\r\n","import { defineCommand, type CommandDef } from 'citty';\r\nimport { commands } from './commands/index.js';\r\nimport { readOwnPackageJson } from './utils/version.js';\r\n\r\n// citty types each command by its own arguments; the registry needs the erased form.\r\n// oxlint-disable-next-line typescript/no-explicit-any\r\ntype AnyCommand = CommandDef<any>;\r\n\r\nconst packageJson = readOwnPackageJson();\r\n\r\nexport const main = defineCommand({\r\n\tmeta: {\r\n\t\tname: 'stars',\r\n\t\tversion: packageJson.version,\r\n\t\tdescription: packageJson.description\r\n\t},\r\n\tsubCommands: commands\r\n}) as AnyCommand;\r\n","import { renderUsage, runCommand as _runCommand, type CommandDef } from 'citty';\r\nimport process from 'node:process';\r\nimport { commands } from './commands/index.js';\r\nimport { main } from './main.js';\r\nimport { exitCodeOf, formatError } from './utils/errors.js';\r\nimport { readOwnPackageJson } from './utils/version.js';\r\n\r\n// citty types each command by its own arguments; the registry needs the erased form.\r\n// oxlint-disable-next-line typescript/no-explicit-any\r\ntype AnyCommand = CommandDef<any>;\r\n\r\n/**\r\n * Walks the command names of `stars <command> [<subcommand>] --help` so nested commands (`stars commands clean`)\r\n * render their own usage instead of their parent's.\r\n */\r\nasync function resolveHelpTarget(names: string[]): Promise<AnyCommand | null> {\r\n\tconst [first, ...rest] = names;\r\n\tif (!first || !Object.hasOwn(commands, first)) return null;\r\n\r\n\tlet command = await commands[first]!();\r\n\tfor (const name of rest) {\r\n\t\tconst resolved = typeof command.subCommands === 'function' ? await command.subCommands() : await command.subCommands;\r\n\t\tconst child: unknown = (resolved as Record<string, unknown> | undefined)?.[name];\r\n\t\tif (!child) break;\r\n\t\tcommand = (typeof child === 'function' ? await child() : child) as AnyCommand;\r\n\t}\r\n\r\n\treturn command;\r\n}\r\n\r\nexport async function runMain(argv: string[] = process.argv.slice(2)): Promise<void> {\r\n\tif (argv.includes('--version') || argv.includes('-V')) {\r\n\t\tconsole.log(readOwnPackageJson().version);\r\n\t\tprocess.exit(0);\r\n\t}\r\n\r\n\tif (argv.length === 0 || argv.includes('--help') || argv.includes('-h')) {\r\n\t\t// citty's showUsage logs through consola, which is muted in some environments; render and print directly.\r\n\t\tconst command = await resolveHelpTarget(argv.filter((argument) => !argument.startsWith('-')));\r\n\t\tconsole.log(await (command ? renderUsage(command, main) : renderUsage(main)));\r\n\t\tprocess.exit(0);\r\n\t}\r\n\r\n\ttry {\r\n\t\tawait _runCommand(main, {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,IAAI,KAAK,WAAW,KAAK,KAAK,SAAS,QAAQ,KAAK,KAAK,SAAS,IAAI,GAAG;EAExE,MAAM,UAAU,MAAM,kBAAkB,KAAK,QAAQ,aAAa,CAAC,SAAS,WAAW,GAAG,CAAC,CAAC;EAC5F,QAAQ,IAAI,OAAO,UAAU,YAAY,SAAS,IAAI,IAAI,YAAY,IAAI,EAAE;EAC5E,QAAQ,KAAK,CAAC;CACf;CAEA,IAAI;EACH,MAAMA,WAAY,MAAM,EAAE,SAAS,KAAK,CAAC;CAC1C,SAAS,OAAO;EACf,QAAQ,MAAM,MAAM,YAAY,KAAK,CAAC;EACtC,QAAQ,KAAK,WAAW,KAAK,CAAC;CAC/B;AACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme-3Fc_LI-2.js","names":[],"sources":["../src/utils/theme.ts"],"sourcesContent":["import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { homedir } from 'node:os';\nimport { dirname, join } from 'node:path';\n\n/** Every theme a user can pick, in the order the picker lists them. `auto` follows the terminal background. */\nexport const THEME_SETTINGS = ['auto', 'dark', 'light', 'dark-daltonized', 'light-daltonized', 'dark-ansi', 'light-ansi'] as const;\nexport type ThemeSetting = (typeof THEME_SETTINGS)[number];\nexport type ThemeName = Exclude<ThemeSetting, 'auto'>;\n\n/**\n * Semantic colour roles the TUI paints with, instead of hardcoded colour names. `undefined` leaves the terminal's own\n * foreground colour, which is the only legible choice for body text on both dark and light backgrounds.\n */\nexport interface Theme {\n\t/** The wordmark, progress bar and selection marker. */\n\tbrand: string;\n\turl: string;\n\ttunnel: string;\n\t/** Something is still building or starting. */\n\tbusy: string;\n\tsuccess: string;\n\twarning: string;\n\terror: string;\n\ttext: string | undefined;\n\t/** Foreground of a badge painted on `success`, `warning` or `busy`. */\n\tonBright: string;\n\t/** Foreground of a badge painted on `error`. */\n\tonError: string;\n}\n\nexport type ThemeToken = keyof Theme;\n\nexport const THEMES: Readonly<Record<ThemeName, Theme>> = {\n\tdark: {\n\t\tbrand: '#4ade80',\n\t\turl: '#22d3ee',\n\t\ttunnel: '#e879f9',\n\t\tbusy: '#facc15',\n\t\tsuccess: '#4ade80',\n\t\twarning: '#facc15',\n\t\terror: '#f87171',\n\t\ttext: undefined,\n\t\tonBright: '#000000',\n\t\tonError: '#000000'\n\t},\n\tlight: {\n\t\tbrand: '#15803d',\n\t\turl: '#0e7490',\n\t\ttunnel: '#a21caf',\n\t\tbusy: '#a16207',\n\t\tsuccess: '#15803d',\n\t\twarning: '#a16207',\n\t\terror: '#b91c1c',\n\t\ttext: undefined,\n\t\tonBright: '#ffffff',\n\t\tonError: '#ffffff'\n\t},\n\t// Okabe-Ito palette: blue/orange carry the good/bad distinction instead of green/red.\n\t'dark-daltonized': {\n\t\tbrand: '#56b4e9',\n\t\turl: '#56b4e9',\n\t\ttunnel: '#cc79a7',\n\t\tbusy: '#f0e442',\n\t\tsuccess: '#56b4e9',\n\t\twarning: '#e69f00',\n\t\terror: '#ff8a3d',\n\t\ttext: undefined,\n\t\tonBright: '#000000',\n\t\tonError: '#000000'\n\t},\n\t'light-daltonized': {\n\t\tbrand: '#0072b2',\n\t\turl: '#0072b2',\n\t\ttunnel: '#8e3b76',\n\t\tbusy: '#8a6500',\n\t\tsuccess: '#0072b2',\n\t\twarning: '#8a6500',\n\t\terror: '#b84a00',\n\t\ttext: undefined,\n\t\tonBright: '#ffffff',\n\t\tonError: '#ffffff'\n\t},\n\t// The 16 ANSI colours only, so the terminal's own palette decides what they look like.\n\t'dark-ansi': {\n\t\tbrand: 'greenBright',\n\t\turl: 'cyanBright',\n\t\ttunnel: 'magentaBright',\n\t\tbusy: 'yellowBright',\n\t\tsuccess: 'greenBright',\n\t\twarning: 'yellowBright',\n\t\terror: 'redBright',\n\t\ttext: undefined,\n\t\tonBright: 'black',\n\t\tonError: 'black'\n\t},\n\t'light-ansi': {\n\t\tbrand: 'green',\n\t\turl: 'cyan',\n\t\ttunnel: 'magenta',\n\t\tbusy: 'yellow',\n\t\tsuccess: 'green',\n\t\twarning: 'yellow',\n\t\terror: 'red',\n\t\ttext: undefined,\n\t\tonBright: 'white',\n\t\tonError: 'white'\n\t}\n};\n\nexport function isThemeSetting(value: unknown): value is ThemeSetting {\n\treturn typeof value === 'string' && (THEME_SETTINGS as readonly string[]).includes(value);\n}\n\n/**\n * Guesses whether the terminal background is light from `COLORFGBG` (`foreground;background`, set by rxvt, Konsole and\n * others). Without it the terminal is assumed dark, which matches most developer setups.\n */\nexport function detectTerminalBackground(env: NodeJS.ProcessEnv = process.env): 'dark' | 'light' {\n\tconst background = env.COLORFGBG?.split(';').at(-1);\n\tif (background === undefined || !/^\\d+$/.test(background)) return 'dark';\n\tconst index = Number(background);\n\treturn index === 7 || index === 15 ? 'light' : 'dark';\n}\n\nexport function resolveTheme(setting: ThemeSetting, env: NodeJS.ProcessEnv = process.env): ThemeName {\n\treturn setting === 'auto' ? detectTerminalBackground(env) : setting;\n}\n\nexport interface ThemeSettingSources {\n\t/** `--theme`. */\n\tflag?: string;\n\tenv?: NodeJS.ProcessEnv;\n\t/** The theme saved by the picker. */\n\tsaved?: ThemeSetting;\n}\n\n/**\n * Precedence: `--theme` › `STARS_THEME` › the saved preference › `auto`. An unknown `STARS_THEME` is ignored, since an\n * environment variable should not stop the dev server; an unknown `--theme` is the caller's to reject.\n */\nexport function resolveThemeSetting({ flag, env = process.env, saved }: ThemeSettingSources): ThemeSetting {\n\tif (isThemeSetting(flag)) return flag;\n\tconst fromEnv = env.STARS_THEME?.trim().toLowerCase();\n\tif (isThemeSetting(fromEnv)) return fromEnv;\n\treturn saved ?? 'auto';\n}\n\n/** Where preferences live: `$STARS_CONFIG_DIR`, else `$XDG_CONFIG_HOME/stars`, `%APPDATA%\\stars` or `~/.config/stars`. */\nexport function preferencesPath(env: NodeJS.ProcessEnv = process.env): string {\n\tconst directory =\n\t\tenv.STARS_CONFIG_DIR ??\n\t\tjoin((env.XDG_CONFIG_HOME || (process.platform === 'win32' ? env.APPDATA : undefined)) ?? join(homedir(), '.config'), 'stars');\n\treturn join(directory, 'preferences.json');\n}\n\nexport function readSavedTheme(env: NodeJS.ProcessEnv = process.env): ThemeSetting | undefined {\n\ttry {\n\t\tconst { theme } = JSON.parse(readFileSync(preferencesPath(env), 'utf8')) as { theme?: unknown };\n\t\treturn isThemeSetting(theme) ? theme : undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/** Persists the theme, keeping any other preference in the file. Returns whether it could be written. */\nexport function saveTheme(setting: ThemeSetting, env: NodeJS.ProcessEnv = process.env): boolean {\n\tconst path = preferencesPath(env);\n\ttry {\n\t\tlet existing: Record<string, unknown> = {};\n\t\ttry {\n\t\t\tconst parsed: unknown = JSON.parse(readFileSync(path, 'utf8'));\n\t\t\tif (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) existing = parsed as Record<string, unknown>;\n\t\t} catch {\n\t\t\t// No file yet, or a corrupt one: start over.\n\t\t}\n\t\tmkdirSync(dirname(path), { recursive: true });\n\t\twriteFileSync(path, `${JSON.stringify({ ...existing, theme: setting }, null, '\\t')}\\n`);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n"],"mappings":";;;;;;AAKA,MAAa,iBAAiB;CAAC;CAAQ;CAAQ;CAAS;CAAmB;CAAoB;CAAa;AAAY;AA2BxH,MAAa,SAA6C;CACzD,MAAM;EACL,OAAO;EACP,KAAK;EACL,QAAQ;EACR,MAAM;EACN,SAAS;EACT,SAAS;EACT,OAAO;EACP,MAAM;EACN,UAAU;EACV,SAAS;CACV;CACA,OAAO;EACN,OAAO;EACP,KAAK;EACL,QAAQ;EACR,MAAM;EACN,SAAS;EACT,SAAS;EACT,OAAO;EACP,MAAM;EACN,UAAU;EACV,SAAS;CACV;CAEA,mBAAmB;EAClB,OAAO;EACP,KAAK;EACL,QAAQ;EACR,MAAM;EACN,SAAS;EACT,SAAS;EACT,OAAO;EACP,MAAM;EACN,UAAU;EACV,SAAS;CACV;CACA,oBAA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B;AAC1C;AAEA,SAAgB,eAAe,MAAyB,QAAQ,KAA+B;CAC9F,IAAI;EACH,MAAM,EAAE,UAAU,KAAK,MAAM,aAAa,gBAAgB,GAAG,GAAG,MAAM,CAAC;EACvE,OAAO,eAAe,KAAK,IAAI,QAAQ;CACxC,QAAQ;EACP;CACD;AACD;;AAGA,SAAgB,UAAU,SAAuB,MAAyB,QAAQ,KAAc;CAC/F,MAAM,OAAO,gBAAgB,GAAG;CAChC,IAAI;EACH,IAAI,WAAoC,CAAC;EACzC,IAAI;GACH,MAAM,SAAkB,KAAK,MAAM,aAAa,MAAM,MAAM,CAAC;GAC7D,IAAI,UAAU,OAAO,WAAW,YAAY,CAAC,MAAM,QAAQ,MAAM,GAAG,WAAW;EAChF,QAAQ,CAER;EACA,UAAU,QAAQ,IAAI,GAAG,EAAE,WAAW,KAAK,CAAC;EAC5C,cAAc,MAAM,GAAG,KAAK,UAAU;GAAE,GAAG;GAAU,OAAO;EAAQ,GAAG,MAAM,GAAI,EAAE,GAAG;EACtF,OAAO;CACR,QAAQ;EACP,OAAO;CACR;AACD"}
|
|
1
|
+
{"version":3,"file":"theme-3Fc_LI-2.js","names":[],"sources":["../src/utils/theme.ts"],"sourcesContent":["import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';\r\nimport { homedir } from 'node:os';\r\nimport { dirname, join } from 'node:path';\r\n\r\n/** Every theme a user can pick, in the order the picker lists them. `auto` follows the terminal background. */\r\nexport const THEME_SETTINGS = ['auto', 'dark', 'light', 'dark-daltonized', 'light-daltonized', 'dark-ansi', 'light-ansi'] as const;\r\nexport type ThemeSetting = (typeof THEME_SETTINGS)[number];\r\nexport type ThemeName = Exclude<ThemeSetting, 'auto'>;\r\n\r\n/**\r\n * Semantic colour roles the TUI paints with, instead of hardcoded colour names. `undefined` leaves the terminal's own\r\n * foreground colour, which is the only legible choice for body text on both dark and light backgrounds.\r\n */\r\nexport interface Theme {\r\n\t/** The wordmark, progress bar and selection marker. */\r\n\tbrand: string;\r\n\turl: string;\r\n\ttunnel: string;\r\n\t/** Something is still building or starting. */\r\n\tbusy: string;\r\n\tsuccess: string;\r\n\twarning: string;\r\n\terror: string;\r\n\ttext: string | undefined;\r\n\t/** Foreground of a badge painted on `success`, `warning` or `busy`. */\r\n\tonBright: string;\r\n\t/** Foreground of a badge painted on `error`. */\r\n\tonError: string;\r\n}\r\n\r\nexport type ThemeToken = keyof Theme;\r\n\r\nexport const THEMES: Readonly<Record<ThemeName, Theme>> = {\r\n\tdark: {\r\n\t\tbrand: '#4ade80',\r\n\t\turl: '#22d3ee',\r\n\t\ttunnel: '#e879f9',\r\n\t\tbusy: '#facc15',\r\n\t\tsuccess: '#4ade80',\r\n\t\twarning: '#facc15',\r\n\t\terror: '#f87171',\r\n\t\ttext: undefined,\r\n\t\tonBright: '#000000',\r\n\t\tonError: '#000000'\r\n\t},\r\n\tlight: {\r\n\t\tbrand: '#15803d',\r\n\t\turl: '#0e7490',\r\n\t\ttunnel: '#a21caf',\r\n\t\tbusy: '#a16207',\r\n\t\tsuccess: '#15803d',\r\n\t\twarning: '#a16207',\r\n\t\terror: '#b91c1c',\r\n\t\ttext: undefined,\r\n\t\tonBright: '#ffffff',\r\n\t\tonError: '#ffffff'\r\n\t},\r\n\t// Okabe-Ito palette: blue/orange carry the good/bad distinction instead of green/red.\r\n\t'dark-daltonized': {\r\n\t\tbrand: '#56b4e9',\r\n\t\turl: '#56b4e9',\r\n\t\ttunnel: '#cc79a7',\r\n\t\tbusy: '#f0e442',\r\n\t\tsuccess: '#56b4e9',\r\n\t\twarning: '#e69f00',\r\n\t\terror: '#ff8a3d',\r\n\t\ttext: undefined,\r\n\t\tonBright: '#000000',\r\n\t\tonError: '#000000'\r\n\t},\r\n\t'light-daltonized': {\r\n\t\tbrand: '#0072b2',\r\n\t\turl: '#0072b2',\r\n\t\ttunnel: '#8e3b76',\r\n\t\tbusy: '#8a6500',\r\n\t\tsuccess: '#0072b2',\r\n\t\twarning: '#8a6500',\r\n\t\terror: '#b84a00',\r\n\t\ttext: undefined,\r\n\t\tonBright: '#ffffff',\r\n\t\tonError: '#ffffff'\r\n\t},\r\n\t// The 16 ANSI colours only, so the terminal's own palette decides what they look like.\r\n\t'dark-ansi': {\r\n\t\tbrand: 'greenBright',\r\n\t\turl: 'cyanBright',\r\n\t\ttunnel: 'magentaBright',\r\n\t\tbusy: 'yellowBright',\r\n\t\tsuccess: 'greenBright',\r\n\t\twarning: 'yellowBright',\r\n\t\terror: 'redBright',\r\n\t\ttext: undefined,\r\n\t\tonBright: 'black',\r\n\t\tonError: 'black'\r\n\t},\r\n\t'light-ansi': {\r\n\t\tbrand: 'green',\r\n\t\turl: 'cyan',\r\n\t\ttunnel: 'magenta',\r\n\t\tbusy: 'yellow',\r\n\t\tsuccess: 'green',\r\n\t\twarning: 'yellow',\r\n\t\terror: 'red',\r\n\t\ttext: undefined,\r\n\t\tonBright: 'white',\r\n\t\tonError: 'white'\r\n\t}\r\n};\r\n\r\nexport function isThemeSetting(value: unknown): value is ThemeSetting {\r\n\treturn typeof value === 'string' && (THEME_SETTINGS as readonly string[]).includes(value);\r\n}\r\n\r\n/**\r\n * Guesses whether the terminal background is light from `COLORFGBG` (`foreground;background`, set by rxvt, Konsole and\r\n * others). Without it the terminal is assumed dark, which matches most developer setups.\r\n */\r\nexport function detectTerminalBackground(env: NodeJS.ProcessEnv = process.env): 'dark' | 'light' {\r\n\tconst background = env.COLORFGBG?.split(';').at(-1);\r\n\tif (background === undefined || !/^\\d+$/.test(background)) return 'dark';\r\n\tconst index = Number(background);\r\n\treturn index === 7 || index === 15 ? 'light' : 'dark';\r\n}\r\n\r\nexport function resolveTheme(setting: ThemeSetting, env: NodeJS.ProcessEnv = process.env): ThemeName {\r\n\treturn setting === 'auto' ? detectTerminalBackground(env) : setting;\r\n}\r\n\r\nexport interface ThemeSettingSources {\r\n\t/** `--theme`. */\r\n\tflag?: string;\r\n\tenv?: NodeJS.ProcessEnv;\r\n\t/** The theme saved by the picker. */\r\n\tsaved?: ThemeSetting;\r\n}\r\n\r\n/**\r\n * Precedence: `--theme` › `STARS_THEME` › the saved preference › `auto`. An unknown `STARS_THEME` is ignored, since an\r\n * environment variable should not stop the dev server; an unknown `--theme` is the caller's to reject.\r\n */\r\nexport function resolveThemeSetting({ flag, env = process.env, saved }: ThemeSettingSources): ThemeSetting {\r\n\tif (isThemeSetting(flag)) return flag;\r\n\tconst fromEnv = env.STARS_THEME?.trim().toLowerCase();\r\n\tif (isThemeSetting(fromEnv)) return fromEnv;\r\n\treturn saved ?? 'auto';\r\n}\r\n\r\n/** Where preferences live: `$STARS_CONFIG_DIR`, else `$XDG_CONFIG_HOME/stars`, `%APPDATA%\\stars` or `~/.config/stars`. */\r\nexport function preferencesPath(env: NodeJS.ProcessEnv = process.env): string {\r\n\tconst directory =\r\n\t\tenv.STARS_CONFIG_DIR ??\r\n\t\tjoin((env.XDG_CONFIG_HOME || (process.platform === 'win32' ? env.APPDATA : undefined)) ?? join(homedir(), '.config'), 'stars');\r\n\treturn join(directory, 'preferences.json');\r\n}\r\n\r\nexport function readSavedTheme(env: NodeJS.ProcessEnv = process.env): ThemeSetting | undefined {\r\n\ttry {\r\n\t\tconst { theme } = JSON.parse(readFileSync(preferencesPath(env), 'utf8')) as { theme?: unknown };\r\n\t\treturn isThemeSetting(theme) ? theme : undefined;\r\n\t} catch {\r\n\t\treturn undefined;\r\n\t}\r\n}\r\n\r\n/** Persists the theme, keeping any other preference in the file. Returns whether it could be written. */\r\nexport function saveTheme(setting: ThemeSetting, env: NodeJS.ProcessEnv = process.env): boolean {\r\n\tconst path = preferencesPath(env);\r\n\ttry {\r\n\t\tlet existing: Record<string, unknown> = {};\r\n\t\ttry {\r\n\t\t\tconst parsed: unknown = JSON.parse(readFileSync(path, 'utf8'));\r\n\t\t\tif (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) existing = parsed as Record<string, unknown>;\r\n\t\t} catch {\r\n\t\t\t// No file yet, or a corrupt one: start over.\r\n\t\t}\r\n\t\tmkdirSync(dirname(path), { recursive: true });\r\n\t\twriteFileSync(path, `${JSON.stringify({ ...existing, theme: setting }, null, '\\t')}\\n`);\r\n\t\treturn true;\r\n\t} catch {\r\n\t\treturn false;\r\n\t}\r\n}\r\n"],"mappings":";;;;;;AAKA,MAAa,iBAAiB;CAAC;CAAQ;CAAQ;CAAS;CAAmB;CAAoB;CAAa;AAAY;AA2BxH,MAAa,SAA6C;CACzD,MAAM;EACL,OAAO;EACP,KAAK;EACL,QAAQ;EACR,MAAM;EACN,SAAS;EACT,SAAS;EACT,OAAO;EACP,MAAM;EACN,UAAU;EACV,SAAS;CACV;CACA,OAAO;EACN,OAAO;EACP,KAAK;EACL,QAAQ;EACR,MAAM;EACN,SAAS;EACT,SAAS;EACT,OAAO;EACP,MAAM;EACN,UAAU;EACV,SAAS;CACV;CAEA,mBAAmB;EAClB,OAAO;EACP,KAAK;EACL,QAAQ;EACR,MAAM;EACN,SAAS;EACT,SAAS;EACT,OAAO;EACP,MAAM;EACN,UAAU;EACV,SAAS;CACV;CACA,oBAAoB;EACnB,OAAO;EACP,KAAK;EACL,QAAQ;EACR,MAAM;EACN,SAAS;EACT,SAAS;EACT,OAAO;EACP,MAAM;EACN,UAAU;EACV,SAAS;CACV;CAEA,aAAa;EACZ,OAAO;EACP,KAAK;EACL,QAAQ;EACR,MAAM;EACN,SAAS;EACT,SAAS;EACT,OAAO;EACP,MAAM;EACN,UAAU;EACV,SAAS;CACV;CACA,cAAc;EACb,OAAO;EACP,KAAK;EACL,QAAQ;EACR,MAAM;EACN,SAAS;EACT,SAAS;EACT,OAAO;EACP,MAAM;EACN,UAAU;EACV,SAAS;CACV;AACD;AAEA,SAAgB,eAAe,OAAuC;CACrE,OAAO,OAAO,UAAU,YAAa,eAAqC,SAAS,KAAK;AACzF;;;;;AAMA,SAAgB,yBAAyB,MAAyB,QAAQ,KAAuB;CAChG,MAAM,aAAa,IAAI,WAAW,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE;CAClD,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AG;GAAU,OAAO;EAAQ,GAAG,MAAM,GAAI,EAAE,GAAG;EACtF,OAAO;CACR,QAAQ;EACP,OAAO;CACR;AACD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as cliDiagnostics } from "./diagnostics-
|
|
2
|
-
import { r as resolveBinary } from "./project-
|
|
1
|
+
import { t as cliDiagnostics } from "./diagnostics-3JRAy8Xj.js";
|
|
2
|
+
import { r as resolveBinary } from "./project-D-8VIcyF.js";
|
|
3
3
|
import { EventEmitter } from "node:events";
|
|
4
4
|
import { spawn } from "node:child_process";
|
|
5
5
|
|
|
@@ -260,4 +260,4 @@ function resolveTscBinary(root) {
|
|
|
260
260
|
|
|
261
261
|
//#endregion
|
|
262
262
|
export { createLineSplitter as i, resolveTscBinary as n, ProcessSupervisor as r, TscBuilder as t };
|
|
263
|
-
//# sourceMappingURL=tsc-
|
|
263
|
+
//# sourceMappingURL=tsc-DEBcwIO0.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tsc-DEBcwIO0.js","names":[],"sources":["../src/utils/process-supervisor.ts","../src/builders/tsc.ts"],"sourcesContent":["import { spawn, type ChildProcess } from 'node:child_process';\r\nimport { EventEmitter } from 'node:events';\r\n\r\nexport type ProcessState = 'idle' | 'starting' | 'running' | 'stopping' | 'stopped' | 'crashed';\r\n\r\nexport interface ProcessExit {\r\n\tcode: number | null;\r\n\tsignal: NodeJS.Signals | null;\r\n\t/** Whether the exit was requested through {@link ProcessSupervisor.stop}. */\r\n\trequested: boolean;\r\n}\r\n\r\nexport interface ProcessSupervisorOptions {\r\n\tcommand: string;\r\n\targs: readonly string[];\r\n\tcwd: string;\r\n\tenv: NodeJS.ProcessEnv;\r\n\t/** Milliseconds to wait after `SIGTERM` before sending `SIGKILL`. */\r\n\tkillTimeout: number;\r\n}\r\n\r\nexport interface ProcessSupervisorEvents {\r\n\tstate: [state: ProcessState];\r\n\tstdout: [line: string];\r\n\tstderr: [line: string];\r\n\texit: [exit: ProcessExit];\r\n\terror: [error: Error];\r\n}\r\n\r\n/**\r\n * Owns a single child process: starts it, streams its output line by line and stops it gracefully.\r\n */\r\nexport class ProcessSupervisor extends EventEmitter<ProcessSupervisorEvents> {\r\n\t#child: ChildProcess | null = null;\r\n\t#state: ProcessState = 'idle';\r\n\t#startedAt: number | null = null;\r\n\t#stopping: Promise<void> | null = null;\r\n\r\n\tpublic constructor(private readonly options: ProcessSupervisorOptions) {\r\n\t\tsuper();\r\n\t}\r\n\r\n\tpublic get state(): ProcessState {\r\n\t\treturn this.#state;\r\n\t}\r\n\r\n\tpublic get pid(): number | null {\r\n\t\treturn this.#child?.pid ?? null;\r\n\t}\r\n\r\n\tpublic get startedAt(): number | null {\r\n\t\treturn this.#startedAt;\r\n\t}\r\n\r\n\tpublic get running(): boolean {\r\n\t\treturn this.#state === 'starting' || this.#state === 'running';\r\n\t}\r\n\r\n\tpublic start(): void {\r\n\t\tif (this.#child) throw new Error('The process is already running, call stop() or restart() first.');\r\n\r\n\t\tconst { command, args, cwd, env } = this.options;\r\n\t\tthis.#setState('starting');\r\n\r\n\t\tconst child = spawn(command, args, { cwd, env, stdio: ['ignore', 'pipe', 'pipe'], windowsHide: true });\r\n\t\tthis.#child = child;\r\n\t\tthis.#startedAt = Date.now();\r\n\r\n\t\tlet requested = false;\r\n\t\tconst stdout = createLineSplitter((line) => this.emit('stdout', line));\r\n\t\tconst stderr = createLineSplitter((line) => this.emit('stderr', line));\r\n\t\tchild.stdout?.on('data', stdout.push);\r\n\t\tchild.stderr?.on('data', stderr.push);\r\n\r\n\t\tchild.once('spawn', () => {\r\n\t\t\tif (this.#child === child) this.#setState('running');\r\n\t\t});\r\n\r\n\t\tchild.once('error', (error) => {\r\n\t\t\tthis.emit('error', error);\r\n\t\t});\r\n\r\n\t\tchild.once('exit', (code, signal) => {\r\n\t\t\tstdout.flush();\r\n\t\t\tstderr.flush();\r\n\t\t\trequested = this.#state === 'stopping';\r\n\t\t\tthis.#child = null;\r\n\t\t\tthis.#startedAt = null;\r\n\t\t\tthis.#setState(requested || code === 0 ? 'stopped' : 'crashed');\r\n\t\t\tthis.emit('exit', { code, signal, requested });\r\n\t\t});\r\n\t}\r\n\r\n\t/**\r\n\t * Sends `SIGTERM`, escalates to `SIGKILL` after `killTimeout` and resolves once the process exited.\r\n\t */\r\n\tpublic stop(): Promise<void> {\r\n\t\tconst child = this.#child;\r\n\t\tif (!child) return Promise.resolve();\r\n\t\tif (this.#stopping) return this.#stopping;\r\n\r\n\t\tthis.#setState('stopping');\r\n\t\tthis.#stopping = new Promise<void>((resolve) => {\r\n\t\t\tconst timer = setTimeout(() => {\r\n\t\t\t\tif (child.exitCode === null && child.signalCode === null) child.kill('SIGKILL');\r\n\t\t\t}, this.options.killTimeout);\r\n\t\t\ttimer.unref();\r\n\r\n\t\t\tchild.once('exit', () => {\r\n\t\t\t\tclearTimeout(timer);\r\n\t\t\t\tthis.#stopping = null;\r\n\t\t\t\tresolve();\r\n\t\t\t});\r\n\r\n\t\t\tif (!child.kill('SIGTERM')) {\r\n\t\t\t\tclearTimeout(timer);\r\n\t\t\t\tthis.#stopping = null;\r\n\t\t\t\tresolve();\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\treturn this.#stopping;\r\n\t}\r\n\r\n\t/**\r\n\t * Sends `SIGKILL` right away, without waiting for the process to exit. Used to force a shutdown that is taking too long.\r\n\t */\r\n\tpublic kill(): void {\r\n\t\tconst child = this.#child;\r\n\t\tif (child && child.exitCode === null && child.signalCode === null) child.kill('SIGKILL');\r\n\t}\r\n\r\n\tpublic async restart(): Promise<void> {\r\n\t\tawait this.stop();\r\n\t\tthis.start();\r\n\t}\r\n\r\n\t#setState(state: ProcessState): void {\r\n\t\tif (this.#state === state) return;\r\n\t\tthis.#state = state;\r\n\t\tthis.emit('state', state);\r\n\t}\r\n}\r\n\r\n/**\r\n * Splits a byte stream into complete lines, keeping the trailing partial line until the next chunk.\r\n */\r\nexport function createLineSplitter(onLine: (line: string) => void) {\r\n\tlet remainder = '';\r\n\treturn {\r\n\t\tpush(chunk: Buffer | string) {\r\n\t\t\tremainder += chunk.toString();\r\n\t\t\tconst lines = remainder.split(/\\r?\\n/);\r\n\t\t\tremainder = lines.pop() ?? '';\r\n\t\t\tfor (const line of lines) onLine(line);\r\n\t\t},\r\n\t\tflush() {\r\n\t\t\tif (remainder.length > 0) onLine(remainder);\r\n\t\t\tremainder = '';\r\n\t\t}\r\n\t};\r\n}\r\n","import { spawn, type ChildProcess } from 'node:child_process';\r\nimport { EventEmitter } from 'node:events';\r\nimport type { ResolvedStarsConfig } from '@wolfstar/schema';\r\nimport { cliDiagnostics } from '../utils/diagnostics.js';\r\nimport { createLineSplitter } from '../utils/process-supervisor.js';\r\nimport { resolveBinary } from '../utils/project.js';\r\nimport type { Builder, BuilderEvents, BuildOutcome } from './types.js';\r\n\r\nconst INSTALL_HINT = \"Install it with `pnpm add -D typescript`, or set `build.tool` to 'tsdown' or 'none'.\";\r\nconst WATCH_START = /Starting (incremental )?compilation/;\r\nconst WATCH_DONE = /Found (\\d+) errors?\\. Watching for file changes/;\r\nconst ERROR_LINE = /error TS\\d+:/;\r\n\r\n/**\r\n * Builds through the project's `tsc -b`, parsing its output to report progress.\r\n */\r\nexport class TscBuilder extends EventEmitter<BuilderEvents> implements Builder {\r\n\tpublic readonly tool = 'tsc' as const;\r\n\t#child: ChildProcess | null = null;\r\n\t#startedAt = 0;\r\n\t#firstError: string | null = null;\r\n\r\n\tpublic constructor(private readonly config: ResolvedStarsConfig) {\r\n\t\tsuper();\r\n\t}\r\n\r\n\tpublic build(): Promise<BuildOutcome> {\r\n\t\tconst child = this.#spawn([]);\r\n\t\tthis.#begin();\r\n\r\n\t\treturn new Promise((resolve) => {\r\n\t\t\tchild.once('exit', (code) => {\r\n\t\t\t\tthis.#child = null;\r\n\t\t\t\tresolve(this.#finish(code === 0 ? null : (this.#firstError ?? `tsc exited with code ${code}`)));\r\n\t\t\t});\r\n\t\t});\r\n\t}\r\n\r\n\tpublic watch(): Promise<void> {\r\n\t\tthis.#spawn(['--watch', '--preserveWatchOutput']);\r\n\t\tthis.#begin();\r\n\t\treturn Promise.resolve();\r\n\t}\r\n\r\n\tpublic close(): Promise<void> {\r\n\t\tconst child = this.#child;\r\n\t\tthis.#child = null;\r\n\t\tif (!child || child.exitCode !== null) return Promise.resolve();\r\n\r\n\t\treturn new Promise((resolve) => {\r\n\t\t\tchild.once('exit', () => resolve());\r\n\t\t\tchild.kill();\r\n\t\t});\r\n\t}\r\n\r\n\t#spawn(extraArgs: string[]): ChildProcess {\r\n\t\tconst tsc = resolveTscBinary(this.config.root);\r\n\t\tif (!tsc) throw cliDiagnostics.DEPENDENCY_MISSING({ name: 'typescript', root: this.config.root, hint: INSTALL_HINT });\r\n\r\n\t\tconst child = spawn(process.execPath, [tsc, '-b', this.config.build.tsconfig!, '--pretty', 'false', ...extraArgs], {\r\n\t\t\tcwd: this.config.root,\r\n\t\t\tenv: process.env,\r\n\t\t\tstdio: ['ignore', 'pipe', 'pipe'],\r\n\t\t\twindowsHide: true\r\n\t\t});\r\n\t\tthis.#child = child;\r\n\r\n\t\tconst handleLine = (line: string) => this.#handleLine(line);\r\n\t\tconst stdout = createLineSplitter(handleLine);\r\n\t\tconst stderr = createLineSplitter(handleLine);\r\n\t\tchild.stdout?.on('data', stdout.push);\r\n\t\tchild.stderr?.on('data', stderr.push);\r\n\t\tchild.once('exit', () => {\r\n\t\t\tstdout.flush();\r\n\t\t\tstderr.flush();\r\n\t\t});\r\n\t\tchild.once('error', (error) => this.emit('log', 'error', error.message));\r\n\r\n\t\treturn child;\r\n\t}\r\n\r\n\t#handleLine(line: string): void {\r\n\t\tconst text = line.trim();\r\n\t\tif (text.length === 0) return;\r\n\r\n\t\tif (WATCH_START.test(text)) {\r\n\t\t\tif (this.#startedAt === 0) this.#begin();\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tif (ERROR_LINE.test(text)) {\r\n\t\t\tthis.#firstError ??= text;\r\n\t\t\tthis.emit('log', 'error', text);\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tconst done = WATCH_DONE.exec(text);\r\n\t\tif (done) {\r\n\t\t\tconst errors = Number(done[1]);\r\n\t\t\tthis.emit('log', errors === 0 ? 'success' : 'error', text);\r\n\t\t\tthis.#finish(errors === 0 ? null : (this.#firstError ?? text));\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tthis.emit('log', 'info', text);\r\n\t}\r\n\r\n\t#begin(): void {\r\n\t\tthis.#firstError = null;\r\n\t\tthis.#startedAt = performance.now();\r\n\t\tthis.emit('start');\r\n\t}\r\n\r\n\t#finish(message: string | null): BuildOutcome {\r\n\t\tconst outcome: BuildOutcome = { ok: message === null, durationMs: Math.round(performance.now() - this.#startedAt), message };\r\n\t\tthis.#startedAt = 0;\r\n\t\tthis.emit(outcome.ok ? 'success' : 'failure', outcome);\r\n\t\treturn outcome;\r\n\t}\r\n}\r\n\r\n/**\r\n * Locates the `tsc` script of the project's TypeScript through its `package.json#bin`, which works for both the\r\n * classic `lib/tsc.js` layout (TypeScript ≤ 6) and the native `bin/tsc` launcher (TypeScript 7, whose `exports` map\r\n * hides `lib/`).\r\n */\r\nexport function resolveTscBinary(root: string): string | null {\r\n\treturn resolveBinary(root, 'typescript', 'tsc');\r\n}\r\n"],"mappings":";;;;;;;;;AAgCA,IAAa,oBAAb,cAAuC,aAAsC;CAMxC;CALpC,SAA8B;CAC9B,SAAuB;CACvB,aAA4B;CAC5B,YAAkC;CAElC,AAAO,YAAY,AAAiB,SAAmC;EACtE,MAAM;EAD6B;CAEpC;CAEA,IAAW,QAAsB;EAChC,OAAO,KAAK;CACb;CAEA,IAAW,MAAqB;EAC/B,OAAO,KAAK,QAAQ,OAAO;CAC5B;CAEA,IAAW,YAA2B;EACrC,OAAO,KAAK;CACb;CAEA,IAAW,UAAmB;EAC7B,OAAO,KAAK,WAAW,cAAc,KAAK,WAAW;CACtD;CAEA,AAAO,QAAc;EACpB,IAAI,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A,YAAY,MAAoB;EAC/B,MAAM,OAAO,KAAK,KAAK;EACvB,IAAI,KAAK,WAAW,GAAG;EAEvB,IAAI,YAAY,KAAK,IAAI,GAAG;GAC3B,IAAI,KAAK,eAAe,GAAG,KAAK,OAAO;GACvC;EACD;EAEA,IAAI,WAAW,KAAK,IAAI,GAAG;GAC1B,KAAK,gBAAgB;GACrB,KAAK,KAAK,OAAO,SAAS,IAAI;GAC9B;EACD;EAEA,MAAM,OAAO,WAAW,KAAK,IAAI;EACjC,IAAI,MAAM;GACT,MAAM,SAAS,OAAO,KAAK,EAAE;GAC7B,KAAK,KAAK,OAAO,WAAW,IAAI,YAAY,SAAS,IAAI;GACzD,KAAK,QAAQ,WAAW,IAAI,OAAQ,KAAK,eAAe,IAAK;GAC7D;EACD;EAEA,KAAK,KAAK,OAAO,QAAQ,IAAI;CAC9B;CAEA,SAAe;EACd,KAAK,cAAc;EACnB,KAAK,aAAa,YAAY,IAAI;EAClC,KAAK,KAAK,OAAO;CAClB;CAEA,QAAQ,SAAsC;EAC7C,MAAM,UAAwB;GAAE,IAAI,YAAY;GAAM,YAAY,KAAK,MAAM,YAAY,IAAI,IAAI,KAAK,UAAU;GAAG;EAAQ;EAC3H,KAAK,aAAa;EAClB,KAAK,KAAK,QAAQ,KAAK,YAAY,WAAW,OAAO;EACrD,OAAO;CACR;AACD;;;;;;AAOA,SAAgB,iBAAiB,MAA6B;CAC7D,OAAO,cAAc,MAAM,cAAc,KAAK;AAC/C"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as pluginRegistrations } from "./plugin-registrations-Dr_BicfC.js";
|
|
2
|
-
import { n as importFromProject } from "./project-
|
|
2
|
+
import { n as importFromProject } from "./project-D-8VIcyF.js";
|
|
3
3
|
import { t as loadAutoImportsModule } from "./framework-auto-imports-Gu_PXSyr.js";
|
|
4
4
|
import { dirname, extname, relative, resolve } from "node:path";
|
|
5
5
|
import { EventEmitter } from "node:events";
|
|
@@ -251,4 +251,4 @@ function errorSummary(args) {
|
|
|
251
251
|
|
|
252
252
|
//#endregion
|
|
253
253
|
export { TsdownBuilder };
|
|
254
|
-
//# sourceMappingURL=tsdown-
|
|
254
|
+
//# sourceMappingURL=tsdown-DrWXld54.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tsdown-DrWXld54.js","names":[],"sources":["../src/builders/tsdown.ts"],"sourcesContent":["import { EventEmitter } from 'node:events';\r\nimport { dirname, extname, relative, resolve } from 'node:path';\r\nimport type { ResolvedStarsConfig } from '@wolfstar/schema';\r\nimport { loadAutoImportsModule } from '../utils/framework-auto-imports.js';\r\nimport type { StarsHookable } from '../utils/hooks.js';\r\nimport { pluginRegistrations } from '../utils/plugin-registrations.js';\r\nimport { importFromProject } from '../utils/project.js';\r\nimport type { Builder, BuilderEvents, BuildOutcome } from './types.js';\r\n\r\ntype TsdownModule = typeof import('tsdown');\r\ntype TsdownLogger = import('tsdown').Logger;\r\ntype TsdownHandle = import('tsdown').TsdownHandle;\r\ntype TsdownInlineConfig = NonNullable<Parameters<TsdownModule['build']>[0]>;\r\ntype TsdownOptions = Record<string, unknown>;\r\ntype AnyFunction = (...args: never[]) => unknown;\r\n\r\nconst INSTALL_HINT = \"Install it with `pnpm add -D tsdown`, or set `build.tool` to 'tsc' or 'none'.\";\r\nconst TYPESCRIPT_EXTENSIONS = new Set(['.ts', '.mts', '.cts']);\r\n/** `./src/lib` and `../shared` are paths; `preact/compat` is a module id and must be left alone. */\r\nconst RELATIVE_PATH = /^\\.\\.?[/\\\\]/;\r\n\r\n/**\r\n * Builds through the project's own `tsdown`, configured from `stars.config`.\r\n *\r\n * From `future.compatibilityVersion` 4 on this is the whole configuration: the entry's directory, `build.outDir` and\r\n * `build.tsconfig` produce the defaults a bot needs, the project's `tsdown` block is layered on top, and the auto\r\n * imports plugin is wired in — one configuration file instead of two. At 3 the project's own `tsdown.config.*` is\r\n * still loaded and everything here is merged over it by `tsdown` itself: scalars from `stars.config` win, and\r\n * `plugins` are appended rather than replaced.\r\n */\r\nexport class TsdownBuilder extends EventEmitter<BuilderEvents> implements Builder {\r\n\tpublic readonly tool = 'tsdown' as const;\r\n\t#handle: TsdownHandle | null = null;\r\n\t#hadError = false;\r\n\t#startedAt = 0;\r\n\r\n\tpublic constructor(\r\n\t\tprivate readonly config: ResolvedStarsConfig,\r\n\t\tprivate readonly hooks?: StarsHookable\r\n\t) {\r\n\t\tsuper();\r\n\t}\r\n\r\n\tpublic async build(): Promise<BuildOutcome> {\r\n\t\tconst tsdown = await this.#load();\r\n\t\tconst options = await this.#options();\r\n\t\tthis.#begin();\r\n\r\n\t\ttry {\r\n\t\t\tthis.#handle = await tsdown.build(options as TsdownInlineConfig);\r\n\t\t\treturn this.#finish(this.#hadError ? 'The build reported errors' : null);\r\n\t\t} catch (error) {\r\n\t\t\treturn this.#finish(error instanceof Error ? error.message : String(error));\r\n\t\t}\r\n\t}\r\n\r\n\tpublic async watch(): Promise<void> {\r\n\t\tconst tsdown = await this.#load();\r\n\t\tconst options = await this.#options();\r\n\r\n\t\tthis.#begin();\r\n\t\tthis.#handle = await tsdown.build(this.#watchOptions(options) as TsdownInlineConfig);\r\n\t}\r\n\r\n\tpublic async close(): Promise<void> {\r\n\t\tconst handle = this.#handle;\r\n\t\tthis.#handle = null;\r\n\t\tawait handle?.watch.close();\r\n\t}\r\n\r\n\t#load(): Promise<TsdownModule> {\r\n\t\treturn importFromProject<TsdownModule>(this.config.root, 'tsdown', INSTALL_HINT);\r\n\t}\r\n\r\n\t/**\r\n\t * The options handed to `tsdown.build()`, with the project's own `tsdown` block already layered on top of the\r\n\t * defaults (and of the plugins `stars` contributes).\r\n\t */\r\n\tasync #options(): Promise<TsdownOptions> {\r\n\t\tconst user = this.config.tsdown as TsdownOptions;\r\n\t\t// A `tsdown.config.*` (or `package.json#tsdown`) is the project's own; `build.configFile` is `null` from\r\n\t\t// compatibility version 4 on, where loading one is a configuration error rather than a fallback.\r\n\t\tconst defaults = this.config.build.configFile === null ? this.#defaults() : {};\r\n\t\tconst plugins = [pluginRegistrations(this.config), ...(await this.#plugins()), ...toArray(user.plugins)];\r\n\t\t// `plugins` and `alias` are added to rather than replaced: a project declaring one of its own would\r\n\t\t// otherwise silently drop the auto imports transform, or every `~`/`@` import in its sources.\r\n\t\tconst alias = { ...(defaults.alias as object), ...this.#alias(user.alias) };\r\n\r\n\t\tconst options: TsdownOptions = {\r\n\t\t\t...defaults,\r\n\t\t\t...user,\r\n\t\t\t...(plugins.length > 0 ? { plugins } : {}),\r\n\t\t\t...(Object.keys(alias).length > 0 ? { alias } : {})\r\n\t\t};\r\n\t\tawait this.hooks?.callHook('tsdown:options', options, this.config);\r\n\r\n\t\treturn {\r\n\t\t\t...options,\r\n\t\t\t// Last, and so not overridable (not even by `tsdown:options`): these are how the CLI talks to `tsdown` rather\r\n\t\t\t// than project build options — the project root it resolves from, its own compact progress UI, and the logger\r\n\t\t\t// that feeds diagnostics to the dev panel. `logLevel` also covers the few lifecycle messages tsdown writes\r\n\t\t\t// through its global logger.\r\n\t\t\tcwd: this.config.root,\r\n\t\t\tlogLevel: 'warn',\r\n\t\t\tcustomLogger: this.#logger()\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * What `stars.config` alone says the build is — the configuration a bot would otherwise write out by hand, taken\r\n\t * from the ones the WolfStar bots already keep next to theirs:\r\n\t *\r\n\t * - every source file next to the entry (minus tests), emitted one-to-one (`unbundle`) so the stores keep\r\n\t * loading pieces from `dist/commands` and friends at runtime;\r\n\t * - ESM on `platform: 'node'`, with the extension `build.output` — and so `stars dev`, `package.json#main` and\r\n\t * `node dist/…` — expects;\r\n\t * - sourcemaps and treeshaking on, minification off: a bot is deployed, not shipped, so readable stack traces\r\n\t * are worth more than bytes;\r\n\t * - dependencies left in `node_modules` rather than bundled into the output;\r\n\t * - Nuxt's own alias prefixes: `~` and `@` for the entry's directory, `~~` and `@@` for the project root;\r\n\t * - no declaration files: nothing consumes a bot's `dist/`, and emitting them roughly doubles the build. A\r\n\t * project that wants them sets `tsdown: { dts: true }`.\r\n\t *\r\n\t * Every one of these is overridable through the project's `tsdown` block.\r\n\t */\r\n\t#defaults(): TsdownOptions {\r\n\t\tconst { root, entry, build } = this.config;\r\n\t\tconst source = dirname(entry);\r\n\t\tconst sourceDir = relative(root, source) || '.';\r\n\t\tconst extensions = TYPESCRIPT_EXTENSIONS.has(extname(entry)) ? '{ts,mts,cts}' : '{js,mjs,cjs}';\r\n\r\n\t\treturn {\r\n\t\t\tconfig: false,\r\n\t\t\tentry: [`${sourceDir}/**/*.${extensions}`, `!${sourceDir}/**/*.{test,spec}.${extensions}`],\r\n\t\t\t// The prefixes Nuxt gives every project, pointing at the same two places its own do: the source\r\n\t\t\t// directory and the project root. A project's tsconfig needs the matching `paths` for them to type.\r\n\t\t\talias: { '~': source, '@': source, '~~': root, '@@': root },\r\n\t\t\tformat: 'esm',\r\n\t\t\tplatform: 'node',\r\n\t\t\tunbundle: true,\r\n\t\t\toutDir: build.outDir,\r\n\t\t\toutExtensions: () => ({ js: extname(build.output) }),\r\n\t\t\tsourcemap: true,\r\n\t\t\tclean: true,\r\n\t\t\ttreeshake: true,\r\n\t\t\tminify: false,\r\n\t\t\tdts: false,\r\n\t\t\tdeps: { neverBundle: true },\r\n\t\t\t...(build.tsconfig === null ? {} : { tsconfig: build.tsconfig })\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * The project's own aliases, with relative targets resolved against the project root the way every other path in\r\n\t * `stars.config` is. Module ids (`preact/compat`) and absolute paths are passed through untouched.\r\n\t */\r\n\t#alias(alias: unknown): Record<string, unknown> {\r\n\t\tif (alias === null || typeof alias !== 'object' || Array.isArray(alias)) return {};\r\n\r\n\t\treturn Object.fromEntries(\r\n\t\t\tObject.entries(alias as Record<string, unknown>).map(([key, value]) => [\r\n\t\t\t\tkey,\r\n\t\t\t\ttypeof value === 'string' && RELATIVE_PATH.test(value) ? resolve(this.config.root, value) : value\r\n\t\t\t])\r\n\t\t);\r\n\t}\r\n\r\n\t/**\r\n\t * The auto imports transform, the way `nuxt dev` wires its own into the build rather than asking the project to.\r\n\t * `stars dev`/`stars build` regenerate its declaration file (`stars prepare`) before the first build.\r\n\t */\r\n\tasync #plugins(): Promise<unknown[]> {\r\n\t\tif (!this.config.imports.enabled) return [];\r\n\r\n\t\tconst { autoImports } = await loadAutoImportsModule(this.config.root);\r\n\t\tconst { dirs, presets, exclude, dts } = this.config.imports;\r\n\t\treturn [await autoImports({ root: this.config.root, dirs, presets, exclude, dts })];\r\n\t}\r\n\r\n\t/**\r\n\t * Watch mode reports through the same events a single build does. The project's own `hooks`/`onSuccess` still\r\n\t * run: they are the reason a build is watched at all in some projects.\r\n\t */\r\n\t#watchOptions(options: TsdownOptions): TsdownOptions {\r\n\t\tconst hooks = (options.hooks ?? {}) as Record<string, unknown>;\r\n\t\tconst prepare = hooks['build:prepare'];\r\n\t\tconst before = hooks['build:before'];\r\n\t\tconst done = hooks['build:done'];\r\n\t\tconst success = options.onSuccess;\r\n\r\n\t\treturn {\r\n\t\t\t...options,\r\n\t\t\twatch: true,\r\n\t\t\t// tsdown's build:before runs once when the watcher is configured, not on every rebuild. Rolldown's\r\n\t\t\t// buildStart is the actual per-build boundary, including recovery after a failed compilation.\r\n\t\t\tplugins: [\r\n\t\t\t\t{\r\n\t\t\t\t\tname: 'stars:dev-progress',\r\n\t\t\t\t\tbuildStart: () => {\r\n\t\t\t\t\t\tif (this.#startedAt === 0) this.#begin();\r\n\t\t\t\t\t\tthis.emit('progress', 0.25, 'bundling app');\r\n\t\t\t\t\t}\r\n\t\t\t\t},\r\n\t\t\t\t...toArray(options.plugins)\r\n\t\t\t],\r\n\t\t\thooks: {\r\n\t\t\t\t...hooks,\r\n\t\t\t\t'build:prepare': async (...args: never[]) => {\r\n\t\t\t\t\tif (this.#startedAt === 0) this.#begin();\r\n\t\t\t\t\tif (typeof prepare === 'function') await (prepare as AnyFunction)(...args);\r\n\t\t\t\t},\r\n\t\t\t\t'build:before': async (...args: never[]) => {\r\n\t\t\t\t\tif (typeof before === 'function') await (before as AnyFunction)(...args);\r\n\t\t\t\t},\r\n\t\t\t\t'build:done': async (...args: never[]) => {\r\n\t\t\t\t\tthis.emit('progress', 0.5, 'finishing build');\r\n\t\t\t\t\tif (typeof done === 'function') await (done as AnyFunction)(...args);\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\tonSuccess: async (...args: never[]) => {\r\n\t\t\t\tif (typeof success === 'function') await (success as AnyFunction)(...args);\r\n\t\t\t\tthis.#finish(null);\r\n\t\t\t}\r\n\t\t};\r\n\t}\r\n\r\n\t#begin(): void {\r\n\t\tthis.#hadError = false;\r\n\t\tthis.#startedAt = performance.now();\r\n\t\tthis.emit('start');\r\n\t}\r\n\r\n\t#finish(message: string | null): BuildOutcome {\r\n\t\tconst outcome: BuildOutcome = {\r\n\t\t\tok: message === null && !this.#hadError,\r\n\t\t\tdurationMs: Math.round(performance.now() - this.#startedAt),\r\n\t\t\tmessage\r\n\t\t};\r\n\t\tthis.#startedAt = 0;\r\n\t\tthis.emit(outcome.ok ? 'success' : 'failure', outcome);\r\n\t\treturn outcome;\r\n\t}\r\n\r\n\t#logger(): TsdownLogger {\r\n\t\tconst log = (level: 'info' | 'warn' | 'error' | 'success', args: unknown[]) => {\r\n\t\t\t// tsdown passes its (possibly undefined) name label and other blanks as separate arguments.\r\n\t\t\tconst text = args\r\n\t\t\t\t.filter((argument) => argument !== undefined && argument !== null && argument !== false && argument !== '')\r\n\t\t\t\t.map((argument) => (argument instanceof Error ? (argument.stack ?? argument.message) : String(argument)))\r\n\t\t\t\t.join(' ');\r\n\t\t\tthis.emit('log', level, text);\r\n\t\t};\r\n\r\n\t\tconst warned = new Set<string>();\r\n\t\treturn {\r\n\t\t\t// `stars` owns the build progress and completion messages. Keeping tsdown at `warn` avoids copying its\r\n\t\t\t// entry list, target, output table and completion line into the dev session while preserving diagnostics\r\n\t\t\t// that need action from the project.\r\n\t\t\tlevel: 'warn',\r\n\t\t\tinfo: () => {},\r\n\t\t\twarn: (...args) => log('warn', args),\r\n\t\t\twarnOnce: (...args) => {\r\n\t\t\t\tconst key = args.map(String).join(' ');\r\n\t\t\t\tif (warned.has(key)) return;\r\n\t\t\t\twarned.add(key);\r\n\t\t\t\tlog('warn', args);\r\n\t\t\t},\r\n\t\t\terror: (...args) => {\r\n\t\t\t\tthis.#hadError = true;\r\n\t\t\t\tlog('error', args);\r\n\t\t\t\t// In watch mode tsdown never calls `onSuccess` after an error, report the failure now.\r\n\t\t\t\tif (this.#startedAt !== 0) this.#finish(errorSummary(args));\r\n\t\t\t},\r\n\t\t\tsuccess: () => {},\r\n\t\t\tclearScreen: () => {}\r\n\t\t};\r\n\t}\r\n}\r\n\r\nfunction toArray(value: unknown): unknown[] {\r\n\tif (value === undefined || value === null || value === false) return [];\r\n\treturn Array.isArray(value) ? value : [value];\r\n}\r\n\r\nfunction errorSummary(args: unknown[]): string {\r\n\tconst first = args[0];\r\n\tif (first instanceof Error) return first.message.split('\\n')[0] ?? 'Build failed';\r\n\treturn String(first ?? 'Build failed').split('\\n')[0] ?? 'Build failed';\r\n}\r\n"],"mappings":";;;;;;;AAgBA,MAAM,eAAe;AACrB,MAAM,wCAAwB,IAAI,IAAI;CAAC;CAAO;CAAQ;AAAM,CAAC;;AAE7D,MAAM,gBAAgB;;;;;;;;;;AAWtB,IAAa,gBAAb,cAAmC,aAA+C;CAO/D;CACA;CAPlB,AAAgB,OAAO;CACvB,UAA+B;CAC/B,YAAY;CACZ,aAAa;CAEb,AAAO,YACN,AAAiB,QACjB,AAAiB,OAChB;EACD,MAAM;EAHW;EACA;CAGlB;CAEA,MAAa,QAA+B;EAC3C,MAAM,SAAS,MAAM,KAAK,MAAM;EAChC,MAAM,UAAU,MAAM,KAAK,SAAS;EACpC,KAAK,OAAO;EAEZ,IAAI;GACH,KAAK,UAAU,MAAM,OAAO,MAAM,OAA6B;GAC/D,OAAO,KAAK,QAAQ,KAAK,YAAY,8BAA8B,IAAI;EAC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