@wolfstar/cli 2.3.1 → 2.6.0-next-20261007120201
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +83 -13
- package/dist/{_shared-BIQK0Bhm.js → _shared-CyzTojMA.js} +95 -20
- package/dist/_shared-CyzTojMA.js.map +1 -0
- package/dist/{bridge-BegCt_n2.js → bridge-Cbm0jX9h.js} +3 -236
- package/dist/bridge-Cbm0jX9h.js.map +1 -0
- package/dist/{build-DJcc95Yq.js → build-BbIEbOu3.js} +5 -5
- package/dist/{build-DJcc95Yq.js.map → build-BbIEbOu3.js.map} +1 -1
- package/dist/cli.js +1 -1
- package/dist/codegen-C2PY7RXA.js +262 -0
- package/dist/codegen-C2PY7RXA.js.map +1 -0
- package/dist/commands-3Tgwy6cj.js +16 -0
- package/dist/commands-3Tgwy6cj.js.map +1 -0
- package/dist/commands-3qXbxhXx.js +3 -0
- package/dist/{commands-Bh0K9iWX.js → commands-C-i3qYOz.js} +5 -93
- package/dist/commands-C-i3qYOz.js.map +1 -0
- package/dist/{completions-DMPlZ0S1.js → completions-Cs6YbuXO.js} +3 -3
- package/dist/{completions-DMPlZ0S1.js.map → completions-Cs6YbuXO.js.map} +1 -1
- package/dist/{dev-Owu3e3AO.js → dev-9YvzhtkU.js} +22 -215
- package/dist/dev-9YvzhtkU.js.map +1 -0
- package/dist/{diagnostics-BysbNnPD.js → diagnostics-Dn3CXa8J.js} +11 -2
- package/dist/diagnostics-Dn3CXa8J.js.map +1 -0
- package/dist/{doctor-DEtAAknK.js → doctor-CMGfbXS5.js} +15 -7
- package/dist/doctor-CMGfbXS5.js.map +1 -0
- package/dist/{hooks-Cy6F2bhH.js → hooks-D_RVS0ba.js} +13 -5
- package/dist/hooks-D_RVS0ba.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/{info-CKJVMWIT.js → info-eXsx1AfE.js} +5 -4
- package/dist/info-eXsx1AfE.js.map +1 -0
- package/dist/local-commands-CGBjc8KJ.js +95 -0
- package/dist/local-commands-CGBjc8KJ.js.map +1 -0
- package/dist/{locales-BJAP4HYf.js → locales-BzyEMQnX.js} +5 -5
- package/dist/{locales-BJAP4HYf.js.map → locales-BzyEMQnX.js.map} +1 -1
- package/dist/{nitro-B8u1iVgf.js → nitro-DufOgx8s.js} +2 -2
- package/dist/{nitro-B8u1iVgf.js.map → nitro-DufOgx8s.js.map} +1 -1
- package/dist/{prepare-BM93i3Rm.js → prepare-DKH0UIYA.js} +12 -8
- package/dist/prepare-DKH0UIYA.js.map +1 -0
- package/dist/{project-zlQStwsf.js → project-DBqQMFCk.js} +14 -3
- package/dist/project-DBqQMFCk.js.map +1 -0
- package/dist/{run-CHqwvZXf.js → run-DlNY1QM1.js} +2 -2
- package/dist/{run-CHqwvZXf.js.map → run-DlNY1QM1.js.map} +1 -1
- package/dist/tsc-9yHyx0L6.js +3 -0
- package/dist/{tsc-puVAcwmo.js → tsc-BArammxe.js} +3 -3
- package/dist/{tsc-puVAcwmo.js.map → tsc-BArammxe.js.map} +1 -1
- package/dist/{tsdown-Dwt3JhPw.js → tsdown-2i5h88vT.js} +2 -2
- package/dist/{tsdown-Dwt3JhPw.js.map → tsdown-2i5h88vT.js.map} +1 -1
- package/dist/{tui-nldGSD4c.js → tui-CB_qk2Z1.js} +2 -2
- package/dist/{tui-nldGSD4c.js.map → tui-CB_qk2Z1.js.map} +1 -1
- package/dist/tunnel-BNV5cuJz.js +236 -0
- package/dist/tunnel-BNV5cuJz.js.map +1 -0
- package/dist/typecheck-p_2rj9lL.js +66 -0
- package/dist/typecheck-p_2rj9lL.js.map +1 -0
- package/dist/typechecker-C3UOI2LF.js +213 -0
- package/dist/typechecker-C3UOI2LF.js.map +1 -0
- package/dist/{vite-YZUtv2Hk.js → vite-C5CN3xUu.js} +2 -2
- package/dist/{vite-YZUtv2Hk.js.map → vite-C5CN3xUu.js.map} +1 -1
- package/package.json +9 -9
- package/dist/_shared-BIQK0Bhm.js.map +0 -1
- package/dist/bridge-BegCt_n2.js.map +0 -1
- package/dist/codegen-aJSyPz-J.js +0 -124
- package/dist/codegen-aJSyPz-J.js.map +0 -1
- package/dist/commands-Bh0K9iWX.js.map +0 -1
- package/dist/commands-BlDTDvFO.js +0 -3
- package/dist/commands-CSB-pjgs.js +0 -15
- package/dist/commands-CSB-pjgs.js.map +0 -1
- package/dist/dev-Owu3e3AO.js.map +0 -1
- package/dist/diagnostics-BysbNnPD.js.map +0 -1
- package/dist/doctor-DEtAAknK.js.map +0 -1
- package/dist/hooks-Cy6F2bhH.js.map +0 -1
- package/dist/info-CKJVMWIT.js.map +0 -1
- package/dist/prepare-BM93i3Rm.js.map +0 -1
- package/dist/project-zlQStwsf.js.map +0 -1
- package/dist/tsc-C5l5TQGC.js +0 -3
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { t as readOwnPackageJson } from "./version-BzclCE19.js";
|
|
2
2
|
import { i as shouldUseColor } from "./output-mode-Bp7Da8vJ.js";
|
|
3
|
-
import { t as cliDiagnostics } from "./diagnostics-
|
|
4
|
-
import { t as findInstalledVersion } from "./project-
|
|
5
|
-
import { a as modulesPreloadWarning, d as resolveCwd, i as readProjectEnv, n as loadProject, r as withProjectEnv, t as applyEnvOptions, u as projectArgs } from "./hooks-
|
|
6
|
-
import { t as prepareProject } from "./_shared-
|
|
7
|
-
import { a as isAtLeast,
|
|
3
|
+
import { t as cliDiagnostics } from "./diagnostics-Dn3CXa8J.js";
|
|
4
|
+
import { t as findInstalledVersion } from "./project-DBqQMFCk.js";
|
|
5
|
+
import { a as modulesPreloadWarning, d as resolveCwd, i as readProjectEnv, n as loadProject, r as withProjectEnv, t as applyEnvOptions, u as projectArgs } from "./hooks-D_RVS0ba.js";
|
|
6
|
+
import { r as findLegacyRootTsconfig, t as prepareProject } from "./_shared-CyzTojMA.js";
|
|
7
|
+
import { a as isAtLeast, t as BRIDGE_FRAMEWORK_VERSION } from "./bridge-Cbm0jX9h.js";
|
|
8
|
+
import { n as endpointUrl, r as readDiscordCredentials } from "./tunnel-BNV5cuJz.js";
|
|
8
9
|
import { defineCommand } from "citty";
|
|
9
10
|
import { existsSync, readFileSync } from "node:fs";
|
|
10
11
|
import { delimiter, join } from "node:path";
|
|
@@ -155,7 +156,7 @@ async function collectChecks(config, hooks, options = {}) {
|
|
|
155
156
|
try {
|
|
156
157
|
const prepared = await prepareProject(config, hooks, true);
|
|
157
158
|
const stale = [
|
|
158
|
-
prepared.
|
|
159
|
+
...prepared.tsconfigs.filter((file) => file.status === "outdated").map((file) => show(file.path)),
|
|
159
160
|
prepared.status === "outdated" ? show(prepared.dts) : null,
|
|
160
161
|
prepared.modules?.status === "outdated" ? show(prepared.modules.path) : null
|
|
161
162
|
].filter((path) => path !== null);
|
|
@@ -169,6 +170,13 @@ async function collectChecks(config, hooks, options = {}) {
|
|
|
169
170
|
message: `Out of date: ${stale.join(", ")}`,
|
|
170
171
|
fix: "Run `stars prepare`."
|
|
171
172
|
});
|
|
173
|
+
const legacy = await findLegacyRootTsconfig(config);
|
|
174
|
+
if (legacy) checks.push({
|
|
175
|
+
name: "tsconfig",
|
|
176
|
+
status: "warn",
|
|
177
|
+
message: legacy.message,
|
|
178
|
+
...legacy.fix ? { fix: legacy.fix } : {}
|
|
179
|
+
});
|
|
172
180
|
} catch (error) {
|
|
173
181
|
checks.push({
|
|
174
182
|
name: "prepare",
|
|
@@ -331,4 +339,4 @@ var doctor_default = defineCommand({
|
|
|
331
339
|
|
|
332
340
|
//#endregion
|
|
333
341
|
export { doctor_default as default };
|
|
334
|
-
//# sourceMappingURL=doctor-
|
|
342
|
+
//# sourceMappingURL=doctor-CMGfbXS5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doctor-CMGfbXS5.js","names":[],"sources":["../src/commands/doctor.ts"],"sourcesContent":["import { displayPath, type ResolvedStarsConfig } from '@wolfstar/schema';\nimport { defineCommand } from 'citty';\nimport { createColors } from 'colorette';\nimport { existsSync, readFileSync } from 'node:fs';\nimport { createServer } from 'node:net';\nimport { delimiter, join } from 'node:path';\nimport { BRIDGE_FRAMEWORK_VERSION, isAtLeast } from '../dev/bridge.js';\nimport { endpointUrl, readDiscordCredentials } from '../dev/tunnel.js';\nimport { projectArgs, resolveCwd, type ProjectArgs } from '../utils/args.js';\nimport { cliDiagnostics } from '../utils/diagnostics.js';\nimport { loadProject, withProjectEnv, applyEnvOptions, type StarsHookable } from '../utils/hooks.js';\nimport { modulesPreloadWarning } from '../utils/modules.js';\nimport { shouldUseColor } from '../utils/output-mode.js';\nimport { findLegacyRootTsconfig } from '../utils/tsconfig.js';\nimport { readProjectEnv } from '../utils/project-env.js';\nimport { findInstalledVersion } from '../utils/project.js';\nimport { readOwnPackageJson } from '../utils/version.js';\nimport { prepareProject } from './_shared.js';\n\nexport type CheckStatus = 'ok' | 'info' | 'warn' | 'error';\n\nexport interface Check {\n\tname: string;\n\tstatus: CheckStatus;\n\tmessage: string;\n\t/** What to do about it. */\n\tfix?: string;\n}\n\nexport interface DoctorOptions extends ProjectArgs {\n\tjson?: boolean;\n\t/** Also asks Discord whether the token works and where the application's interactions go. */\n\tonline?: boolean;\n\tstdout?: NodeJS.WritableStream;\n\t/** Overrides for tests. */\n\tenv?: NodeJS.ProcessEnv;\n\tnodeVersion?: string;\n\tfetch?: typeof fetch;\n\tisPortFree?: (port: number, host: string) => Promise<boolean>;\n}\n\n/** The Node.js versions `@wolfstar/cli` runs on (`engines.node` of its `package.json`). */\nconst MINIMUM_NODE = 22;\n\n/**\n * Checks what a project needs before `stars dev` can do its job: the runtime, the framework, the credentials, the\n * interactions endpoint and the generated files. Each check says what is wrong and what to do about it; nothing is\n * changed.\n */\nexport async function collectChecks(config: ResolvedStarsConfig, hooks: StarsHookable, options: DoctorOptions = {}): Promise<Check[]> {\n\tconst env = options.env ?? process.env;\n\tconst checks: Check[] = [];\n\tconst show = (path: string) => displayPath(config.root, path);\n\n\tconst node = options.nodeVersion ?? process.version;\n\tconst major = Number.parseInt(node.replace(/^v/, ''), 10);\n\tchecks.push(\n\t\tmajor >= MINIMUM_NODE\n\t\t\t? { name: 'node', status: 'ok', message: `Node.js ${node}` }\n\t\t\t: { name: 'node', status: 'error', message: `Node.js ${node} is too old`, fix: `Use Node.js ${MINIMUM_NODE} or later.` }\n\t);\n\tconst wanted = readEnginesNode(config.root);\n\tconst minimum = wanted === null ? null : /^\\s*>=\\s*(\\d+)/.exec(wanted);\n\tif (minimum && major < Number(minimum[1])) {\n\t\tchecks.push({\n\t\t\tname: 'engines',\n\t\t\tstatus: 'warn',\n\t\t\tmessage: `The project asks for Node.js ${wanted}, this is ${node}`,\n\t\t\tfix: `Use Node.js ${wanted}.`\n\t\t});\n\t}\n\n\tchecks.push({ name: 'config', status: 'ok', message: config.configFile ? show(config.configFile) : 'no stars.config, running on defaults' });\n\tfor (const warning of [...config.warnings, modulesPreloadWarning(config)]) {\n\t\tif (warning) checks.push({ name: 'config', status: 'warn', message: warning.message, ...(warning.fix ? { fix: warning.fix } : {}) });\n\t}\n\n\tconst framework = findInstalledVersion(config.root, '@wolfstar/http-framework');\n\tif (framework === null) {\n\t\tchecks.push({\n\t\t\tname: 'framework',\n\t\t\tstatus: 'error',\n\t\t\tmessage: '@wolfstar/http-framework is not installed',\n\t\t\tfix: 'Install @wolfstar/http-framework in the project.'\n\t\t});\n\t} else if (isAtLeast(framework, BRIDGE_FRAMEWORK_VERSION)) {\n\t\tchecks.push({ name: 'framework', status: 'ok', message: `@wolfstar/http-framework v${framework}` });\n\t} else {\n\t\tchecks.push({\n\t\t\tname: 'framework',\n\t\t\tstatus: 'warn',\n\t\t\tmessage: `@wolfstar/http-framework v${framework} cannot report to the dev UI`,\n\t\t\tfix: `Update to ${BRIDGE_FRAMEWORK_VERSION} or later for the hmr, commands, interactions and http channels.`\n\t\t});\n\t}\n\n\tchecks.push({ name: 'entry', status: 'ok', message: `${show(config.entry)} (${config.build.tool})` });\n\tif (config.build.tool !== 'none' && !existsSync(config.build.output)) {\n\t\tchecks.push({\n\t\t\tname: 'build',\n\t\t\tstatus: 'info',\n\t\t\tmessage: `${show(config.build.output)} is not built yet`,\n\t\t\tfix: 'Run `stars build` (or `stars dev`).'\n\t\t});\n\t}\n\n\tconst values = { ...readProjectEnv(config), ...definedOnly(env), ...config.dev.env };\n\tconst credentials = readDiscordCredentials(config, env);\n\tchecks.push(\n\t\tcredentials\n\t\t\t? { name: 'token', status: 'ok', message: 'DISCORD_TOKEN is set' }\n\t\t\t: {\n\t\t\t\t\tname: 'token',\n\t\t\t\t\tstatus: 'error',\n\t\t\t\t\tmessage: 'DISCORD_TOKEN is not set',\n\t\t\t\t\tfix: 'Set DISCORD_TOKEN in the environment or in the project .env file.'\n\t\t\t\t}\n\t);\n\tchecks.push(\n\t\tvalues.DISCORD_PUBLIC_KEY\n\t\t\t? { name: 'public key', status: 'ok', message: 'DISCORD_PUBLIC_KEY is set' }\n\t\t\t: {\n\t\t\t\t\tname: 'public key',\n\t\t\t\t\tstatus: 'warn',\n\t\t\t\t\tmessage: 'DISCORD_PUBLIC_KEY is not set',\n\t\t\t\t\tfix: 'Set it in the project .env file, unless the bot passes `discordPublicKey` to its Client.'\n\t\t\t\t}\n\t);\n\tif (credentials && !credentials.applicationId) {\n\t\tchecks.push({\n\t\t\tname: 'application',\n\t\t\tstatus: 'warn',\n\t\t\tmessage: 'The Discord application id is not set',\n\t\t\tfix: 'Set DISCORD_APPLICATION_ID for `stars commands`.'\n\t\t});\n\t}\n\n\tif (config.dev.url) {\n\t\tconst url = new URL(config.dev.url);\n\t\tconst port = Number(url.port || (url.protocol === 'https:' ? 443 : 80));\n\t\tconst free = await (options.isPortFree ?? isPortFree)(port, url.hostname);\n\t\tchecks.push(\n\t\t\tfree\n\t\t\t\t? { name: 'port', status: 'ok', message: `${config.dev.url} is free` }\n\t\t\t\t: {\n\t\t\t\t\t\tname: 'port',\n\t\t\t\t\t\tstatus: 'warn',\n\t\t\t\t\t\tmessage: `Something already listens on ${config.dev.url}`,\n\t\t\t\t\t\tfix: 'Stop it, or set another HTTP_PORT, unless it is this bot running.'\n\t\t\t\t\t}\n\t\t);\n\t}\n\n\tconst { tunnel } = config.dev;\n\tif (tunnel.mode === 'off') {\n\t\tchecks.push({\n\t\t\tname: 'tunnel',\n\t\t\tstatus: 'info',\n\t\t\tmessage: 'No tunnel: Discord cannot reach a bot on localhost',\n\t\t\tfix: 'Set `dev.tunnel: true` for a cloudflared quick tunnel, or press t in `stars dev`.'\n\t\t});\n\t} else if (tunnel.mode === 'quick') {\n\t\tchecks.push(\n\t\t\tfindOnPath('cloudflared', env)\n\t\t\t\t? { name: 'tunnel', status: 'ok', message: 'cloudflared quick tunnel' }\n\t\t\t\t: { name: 'tunnel', status: 'info', message: 'cloudflared is not on the PATH: it is downloaded the first time the tunnel opens' }\n\t\t);\n\t} else {\n\t\tchecks.push({ name: 'tunnel', status: 'ok', message: tunnel.url });\n\t}\n\n\ttry {\n\t\tconst prepared = await prepareProject(config, hooks, true);\n\t\tconst stale = [\n\t\t\t...prepared.tsconfigs.filter((file) => file.status === 'outdated').map((file) => show(file.path)),\n\t\t\tprepared.status === 'outdated' ? show(prepared.dts) : null,\n\t\t\tprepared.modules?.status === 'outdated' ? show(prepared.modules.path) : null\n\t\t].filter((path) => path !== null);\n\t\tchecks.push(\n\t\t\tstale.length === 0\n\t\t\t\t? { name: 'prepare', status: 'ok', message: 'The generated files are up to date' }\n\t\t\t\t: { name: 'prepare', status: 'warn', message: `Out of date: ${stale.join(', ')}`, fix: 'Run `stars prepare`.' }\n\t\t);\n\t\tconst legacy = await findLegacyRootTsconfig(config);\n\t\tif (legacy) checks.push({ name: 'tsconfig', status: 'warn', message: legacy.message, ...(legacy.fix ? { fix: legacy.fix } : {}) });\n\t} catch (error) {\n\t\tchecks.push({ name: 'prepare', status: 'error', message: error instanceof Error ? error.message : String(error) });\n\t}\n\n\tif (options.online && credentials) checks.push(await checkApplication(credentials.token, config, options.fetch ?? fetch));\n\treturn checks;\n}\n\n/** Asks Discord who the token belongs to and where it sends interactions: the one thing only Discord knows. */\nasync function checkApplication(token: string, config: ResolvedStarsConfig, request: typeof fetch): Promise<Check> {\n\ttry {\n\t\tconst response = await request('https://discord.com/api/v10/applications/@me', {\n\t\t\theaders: { authorization: `Bot ${token}` },\n\t\t\tsignal: AbortSignal.timeout(10_000)\n\t\t});\n\t\tif (!response.ok) {\n\t\t\treturn {\n\t\t\t\tname: 'discord',\n\t\t\t\tstatus: 'error',\n\t\t\t\tmessage: `Discord answered ${response.status}`,\n\t\t\t\tfix: response.status === 401 ? 'Check DISCORD_TOKEN.' : 'Try again later.'\n\t\t\t};\n\t\t}\n\n\t\tconst application = (await response.json()) as { name?: string; interactions_endpoint_url?: string | null };\n\t\tconst endpoint = application.interactions_endpoint_url;\n\t\tconst name = application.name ?? 'the application';\n\t\tif (!endpoint) {\n\t\t\treturn {\n\t\t\t\tname: 'discord',\n\t\t\t\tstatus: 'warn',\n\t\t\t\tmessage: `${name} has no interactions endpoint URL`,\n\t\t\t\tfix: 'Set `dev.tunnel.updateEndpoint: true`, or set it in the Discord developer portal.'\n\t\t\t};\n\t\t}\n\n\t\tconst tunnel = config.dev.tunnel;\n\t\t// The whole endpoint: the same origin with another path, or a host that merely starts the same, is elsewhere.\n\t\tconst expected = tunnel.mode === 'url' ? endpointUrl(tunnel.url, tunnel.path) : null;\n\t\tif (expected !== null && normalizeUrl(endpoint) !== normalizeUrl(expected)) {\n\t\t\treturn {\n\t\t\t\tname: 'discord',\n\t\t\t\tstatus: 'warn',\n\t\t\t\tmessage: `${name} sends interactions to ${endpoint}, not to ${expected}`,\n\t\t\t\tfix: 'Set `dev.tunnel.updateEndpoint: true`, or update it in the Discord developer portal.'\n\t\t\t};\n\t\t}\n\n\t\treturn { name: 'discord', status: 'ok', message: `${name} sends interactions to ${endpoint}` };\n\t} catch (error) {\n\t\treturn { name: 'discord', status: 'warn', message: `Could not reach Discord: ${error instanceof Error ? error.message : String(error)}` };\n\t}\n}\n\n/** A URL without the difference a trailing slash makes, or the text itself when it is not one. */\nfunction normalizeUrl(url: string): string {\n\ttry {\n\t\tconst parsed = new URL(url);\n\t\treturn `${parsed.origin}${parsed.pathname.replace(/\\/+$/, '')}${parsed.search}`;\n\t} catch {\n\t\treturn url;\n\t}\n}\n\nfunction readEnginesNode(root: string): string | null {\n\ttry {\n\t\tconst parsed = JSON.parse(readFileSync(join(root, 'package.json'), 'utf-8')) as { engines?: { node?: unknown } };\n\t\treturn typeof parsed.engines?.node === 'string' ? parsed.engines.node : null;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nfunction definedOnly(env: NodeJS.ProcessEnv): Record<string, string> {\n\treturn Object.fromEntries(Object.entries(env).filter((entry): entry is [string, string] => entry[1] !== undefined));\n}\n\nfunction findOnPath(binary: string, env: NodeJS.ProcessEnv): boolean {\n\tconst extensions = process.platform === 'win32' ? ['.exe', '.cmd', ''] : [''];\n\treturn (env.PATH ?? '')\n\t\t.split(delimiter)\n\t\t.filter(Boolean)\n\t\t.some((directory) => extensions.some((extension) => existsSync(join(directory, `${binary}${extension}`))));\n}\n\n/** Whether nothing listens on `host:port`: the port is bound for an instant and released. */\nfunction isPortFree(port: number, host: string): Promise<boolean> {\n\treturn new Promise((resolve) => {\n\t\tconst server = createServer();\n\t\tserver.once('error', () => resolve(false));\n\t\tserver.listen({ port, host, exclusive: true }, () => server.close(() => resolve(true)));\n\t});\n}\n\nconst SYMBOLS: Record<CheckStatus, string> = { ok: '✔', info: 'ℹ', warn: '⚠', error: '✖' };\n\nexport function formatChecks(checks: readonly Check[], useColor: boolean): string {\n\tconst colors = createColors({ useColor });\n\tconst paint = { ok: colors.green, info: colors.cyan, warn: colors.yellow, error: colors.red };\n\tconst width = Math.max(...checks.map((check) => check.name.length));\n\tconst lines = checks.flatMap((check) => [\n\t\t` ${paint[check.status](SYMBOLS[check.status])} ${colors.dim(check.name.padEnd(width))} ${check.message}`,\n\t\t...(check.fix ? [` ${' '.repeat(width)} ${colors.dim(`→ ${check.fix}`)}`] : [])\n\t]);\n\tconst count = (status: CheckStatus) => checks.filter((check) => check.status === status).length;\n\tconst summary = count('error') > 0 ? colors.red(`${count('error')} error(s)`) : colors.green('no errors');\n\treturn [\n\t\tcolors.bold(`stars doctor ${colors.dim(`v${readOwnPackageJson().version}`)}`),\n\t\t...lines,\n\t\t'',\n\t\t` ${summary}, ${count('warn')} warning(s)`\n\t].join('\\n');\n}\n\nexport async function runDoctor(options: DoctorOptions): Promise<void> {\n\tconst stdout = options.stdout ?? process.stdout;\n\tconst project = await loadProject({ cwd: resolveCwd(options), configFile: options.config });\n\t// What `stars dev` would run with: `env:options` and varlock may change the port and the credentials.\n\tconst config = withProjectEnv(await applyEnvOptions(project.config, project.hooks));\n\tconst checks = await collectChecks(config, project.hooks, options);\n\tconst errors = checks.filter((check) => check.status === 'error').length;\n\n\tstdout.write(`${options.json ? JSON.stringify({ ok: errors === 0, checks }, null, 2) : formatChecks(checks, shouldUseColor())}\\n`);\n\tif (errors > 0) throw cliDiagnostics.DOCTOR_FAILED({ count: errors });\n}\n\nexport default defineCommand({\n\tmeta: {\n\t\tname: 'doctor',\n\t\tdescription: 'Check that the project is ready for `stars dev`: runtime, framework, credentials, endpoint, generated files'\n\t},\n\targs: {\n\t\t...projectArgs,\n\t\tjson: {\n\t\t\ttype: 'boolean',\n\t\t\tdescription: 'Print machine-readable JSON',\n\t\t\tdefault: false\n\t\t},\n\t\tonline: {\n\t\t\ttype: 'boolean',\n\t\t\tdescription: 'Also ask Discord whether the token works and where the application sends interactions',\n\t\t\tdefault: false\n\t\t}\n\t},\n\tasync run({ args }) {\n\t\tawait runDoctor({ config: args.config, cwd: args.cwd, json: args.json, online: args.online });\n\t}\n});\n"],"mappings":";;;;;;;;;;;;;;;;;AA0CA,MAAM,eAAe;;;;;;AAOrB,eAAsB,cAAc,QAA6B,OAAsB,UAAyB,CAAC,GAAqB;CACrI,MAAM,MAAM,QAAQ,OAAO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;EACL,GAAG;EACH,MAAM;GACL,MAAM;GACN,aAAa;GACb,SAAS;EACV;EACA,QAAQ;GACP,MAAM;GACN,aAAa;GACb,SAAS;EACV;CACD;CACA,MAAM,IAAI,EAAE,QAAQ;EACnB,MAAM,UAAU;GAAE,QAAQ,KAAK;GAAQ,KAAK,KAAK;GAAK,MAAM,KAAK;GAAM,QAAQ,KAAK;EAAO,CAAC;CAC7F;AACD,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { t as readOwnPackageJson } from "./version-BzclCE19.js";
|
|
2
|
-
import { t as cliDiagnostics } from "./diagnostics-
|
|
3
|
-
import { i as resolveFromProject, r as resolveBinary, t as findInstalledVersion } from "./project-
|
|
2
|
+
import { t as cliDiagnostics } from "./diagnostics-Dn3CXa8J.js";
|
|
3
|
+
import { i as resolveFromProject, r as resolveBinary, t as findInstalledVersion } from "./project-DBqQMFCk.js";
|
|
4
4
|
import { isAbsolute, join, resolve } from "node:path";
|
|
5
5
|
import { pathToFileURL } from "node:url";
|
|
6
|
-
import { loadConfigFile, readProjectEnvFiles, resolveStarsConfig } from "@wolfstar/schema";
|
|
6
|
+
import { assertModuleOptionsClaimed, loadConfigFile, readProjectEnvFiles, resolveStarsConfig } from "@wolfstar/schema";
|
|
7
7
|
import { envModuleSource, modulesModuleSource } from "@wolfstar/vite-server/internal";
|
|
8
8
|
import { execFileSync } from "node:child_process";
|
|
9
9
|
import { resolve as resolve$1, resolveSync } from "mlly";
|
|
@@ -115,9 +115,16 @@ async function resolveSpecifier(root, specifier) {
|
|
|
115
115
|
* Runs `setup` of every module in `modules` (see `@wolfstar/kit`) and returns the configuration carrying what they
|
|
116
116
|
* contributed: `runtime`, and `imports.presets` extended by `ctx.addImports`. Without modules the configuration is
|
|
117
117
|
* returned as it is.
|
|
118
|
+
*
|
|
119
|
+
* Afterwards, a top-level `stars.config` key that is not built in and that no installed module claimed with
|
|
120
|
+
* `meta.configKey` is an `UNKNOWN_OPTION` error: the schema keeps such keys aside (`moduleOptions`) because only the
|
|
121
|
+
* modules know which ones are theirs. That check runs without modules too, where every extra key is unknown.
|
|
118
122
|
*/
|
|
119
123
|
async function installModules(config, hooks) {
|
|
120
|
-
if (config.modules.length === 0)
|
|
124
|
+
if (config.modules.length === 0) {
|
|
125
|
+
assertModuleOptionsClaimed(config, []);
|
|
126
|
+
return config;
|
|
127
|
+
}
|
|
121
128
|
try {
|
|
122
129
|
const runtime = await setupModules({
|
|
123
130
|
config,
|
|
@@ -128,6 +135,7 @@ async function installModules(config, hooks) {
|
|
|
128
135
|
},
|
|
129
136
|
load: async (specifier) => import(await resolveSpecifier(config.root, specifier))
|
|
130
137
|
});
|
|
138
|
+
assertModuleOptionsClaimed(config, runtime.configKeys);
|
|
131
139
|
const presets = [...config.imports.presets, ...runtime.imports.filter((preset) => !config.imports.presets.includes(preset))];
|
|
132
140
|
return {
|
|
133
141
|
...config,
|
|
@@ -329,4 +337,4 @@ function reresolve(previous, source, change) {
|
|
|
329
337
|
|
|
330
338
|
//#endregion
|
|
331
339
|
export { modulesPreloadWarning as a, moduleImportArgs as c, resolveCwd as d, readProjectEnv as i, collectFlag as l, loadProject as n, prepareModulesPreload as o, withProjectEnv as r, envImportArgs as s, applyEnvOptions as t, projectArgs as u };
|
|
332
|
-
//# sourceMappingURL=hooks-
|
|
340
|
+
//# sourceMappingURL=hooks-D_RVS0ba.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks-D_RVS0ba.js","names":["resolveModule"],"sources":["../src/utils/args.ts","../src/utils/env-import.ts","../src/utils/modules.ts","../src/utils/project-env.ts","../src/utils/hooks.ts"],"sourcesContent":["import type { ArgsDef } from 'citty';\nimport { resolve } from 'node:path';\n\n/**\n * Arguments shared by every command that reads the project configuration.\n */\nexport const projectArgs = {\n\tconfig: {\n\t\ttype: 'string',\n\t\talias: 'c',\n\t\tdescription: 'Path to the configuration file (defaults to stars.config.* in the working directory)'\n\t},\n\tcwd: {\n\t\ttype: 'string',\n\t\tdescription: 'Working directory to run from (defaults to the current directory)'\n\t}\n} as const satisfies ArgsDef;\n\nexport interface ProjectArgs {\n\tconfig?: string;\n\tcwd?: string;\n}\n\n/**\n * Every value of a flag given more than once (`--channel a --channel=b`). citty keeps only the last one of a\n * repeated string flag, so a repeatable flag reads the raw arguments.\n */\nexport function collectFlag(rawArgs: readonly string[], name: string): string[] {\n\tconst values: string[] = [];\n\tfor (const [index, argument] of rawArgs.entries()) {\n\t\tif (argument === '--') break;\n\t\tif (argument.startsWith(`--${name}=`)) values.push(argument.slice(name.length + 3));\n\t\telse if (argument === `--${name}`) {\n\t\t\tconst next = rawArgs[index + 1];\n\t\t\tif (next !== undefined && !next.startsWith('-')) values.push(next);\n\t\t}\n\t}\n\n\treturn values;\n}\n\nexport function resolveCwd(args: ProjectArgs): string {\n\treturn args.cwd ? resolve(process.cwd(), args.cwd) : process.cwd();\n}\n","import type { ResolvedStarsConfig } from '@wolfstar/schema';\nimport { envModuleSource, modulesModuleSource } from '@wolfstar/vite-server/internal';\nimport { resolveSync } from 'mlly';\nimport { isAbsolute } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport { cliDiagnostics } from './diagnostics.js';\nimport { resolveFromProject } from './project.js';\n\n/** Build tools whose output never passes through the entry transform that registers `env`. */\nexport const UNTRANSFORMED_TOOLS = new Set<string>(['none', 'tsc']);\n\n/**\n * `node` arguments that register `env` before the entry runs, for the build tools the entry transform cannot reach.\n * The preload is a `data:` URL, so `.stars/` gets no generated runtime file; a `data:` URL cannot resolve bare\n * specifiers, so `@wolfstar/env-utilities` is resolved from the project first. When it cannot be resolved nothing is\n * preloaded, and the bot's own import of it reports the missing install.\n */\nexport function envImportArgs(config: ResolvedStarsConfig): string[] {\n\tif (!config.env.enabled || !UNTRANSFORMED_TOOLS.has(config.build.tool)) return [];\n\n\tconst resolved = resolveFromProject(config.root, '@wolfstar/env-utilities');\n\tif (resolved === null) return [];\n\n\tconst source = envModuleSource(config.env.options, pathToFileURL(resolved).href);\n\treturn ['--import', `data:text/javascript,${encodeURIComponent(source)}`];\n}\n\n/**\n * `node` arguments that register the runtime plugins of the installed modules (`ctx.addPlugin`) before the entry\n * runs, for the build tools the entry transform cannot reach. `@wolfstar/http-framework` and every plugin are resolved\n * from the project first, with the `import` condition (both are ESM), because a `data:` URL cannot resolve bare\n * specifiers; the framework is the bot's own copy, so `Client.use` reaches the `Client` the bot constructs. When the\n * framework is not installed nothing is preloaded, and the bot's own import of it reports the missing install.\n */\nexport function moduleImportArgs(config: ResolvedStarsConfig): string[] {\n\tconst plugins = config.runtime?.plugins ?? [];\n\tif (plugins.length === 0 || !UNTRANSFORMED_TOOLS.has(config.build.tool)) return [];\n\n\tconst url = pathToFileURL(`${config.root}/package.json`).href;\n\tlet framework: string;\n\ttry {\n\t\tframework = resolveSync('@wolfstar/http-framework', { url });\n\t} catch {\n\t\treturn [];\n\t}\n\n\tconst source = modulesModuleSource(plugins, {\n\t\tframework,\n\t\tresolve: (from) => {\n\t\t\tif (from.startsWith('file:')) return from;\n\t\t\tif (isAbsolute(from)) return pathToFileURL(from).href;\n\t\t\ttry {\n\t\t\t\treturn resolveSync(from, { url });\n\t\t\t} catch {\n\t\t\t\tthrow cliDiagnostics.DEPENDENCY_MISSING({\n\t\t\t\t\tname: from,\n\t\t\t\t\troot: config.root,\n\t\t\t\t\thint: 'Install the package of the module that registers this plugin.'\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t});\n\treturn ['--import', `data:text/javascript,${encodeURIComponent(source)}`];\n}\n","import { ModuleError, setupModules } from '@wolfstar/kit';\nimport { assertModuleOptionsClaimed, type ResolvedStarsConfig } from '@wolfstar/schema';\nimport { envModuleSource, modulesModuleSource } from '@wolfstar/vite-server/internal';\nimport { resolve as resolveModule } from 'mlly';\nimport { mkdir, readFile, writeFile } from 'node:fs/promises';\nimport type { Diagnostic } from 'nostics';\nimport { isAbsolute, join, resolve } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport { cliDiagnostics } from './diagnostics.js';\nimport { UNTRANSFORMED_TOOLS } from './env-import.js';\nimport type { StarsHookable } from './hooks.js';\nimport { findInstalledVersion } from './project.js';\nimport { readOwnPackageJson } from './version.js';\n\n/**\n * Where a module specifier is imported from: a relative or absolute path is a file of the project, a `file:` URL is\n * itself, anything else is a package resolved from the project root — with `mlly`, honouring the `import` condition,\n * because installed modules are ESM-only packages a CommonJS `require.resolve` cannot see.\n */\nasync function resolveSpecifier(root: string, specifier: string): Promise<string> {\n\tif (specifier.startsWith('file:')) return specifier;\n\tif (specifier.startsWith('.') || isAbsolute(specifier)) return pathToFileURL(resolve(root, specifier)).href;\n\treturn resolveModule(specifier, { url: pathToFileURL(`${root}/package.json`).href });\n}\n\n/**\n * Runs `setup` of every module in `modules` (see `@wolfstar/kit`) and returns the configuration carrying what they\n * contributed: `runtime`, and `imports.presets` extended by `ctx.addImports`. Without modules the configuration is\n * returned as it is.\n *\n * Afterwards, a top-level `stars.config` key that is not built in and that no installed module claimed with\n * `meta.configKey` is an `UNKNOWN_OPTION` error: the schema keeps such keys aside (`moduleOptions`) because only the\n * modules know which ones are theirs. That check runs without modules too, where every extra key is unknown.\n */\nexport async function installModules(config: ResolvedStarsConfig, hooks: StarsHookable): Promise<ResolvedStarsConfig> {\n\tif (config.modules.length === 0) {\n\t\tassertModuleOptionsClaimed(config, []);\n\t\treturn config;\n\t}\n\n\ttry {\n\t\tconst runtime = await setupModules({\n\t\t\tconfig,\n\t\t\thooks,\n\t\t\tversions: { framework: findInstalledVersion(config.root, '@wolfstar/http-framework'), stars: readOwnPackageJson().version },\n\t\t\tload: async (specifier) => import(await resolveSpecifier(config.root, specifier))\n\t\t});\n\n\t\tassertModuleOptionsClaimed(config, runtime.configKeys);\n\n\t\tconst presets = [...config.imports.presets, ...runtime.imports.filter((preset) => !config.imports.presets.includes(preset))];\n\t\treturn { ...config, runtime, imports: { ...config.imports, presets } };\n\t} catch (error) {\n\t\tif (error instanceof ModuleError) {\n\t\t\tthrow cliDiagnostics.MODULE_FAILED({ module: error.moduleName, reason: error.code, message: error.message, cause: error });\n\t\t}\n\n\t\tthrow error;\n\t}\n}\n\n/**\n * The warning for a project whose runtime plugins reach production only through a `node --import` preload, `null`\n * otherwise. It is not one of `config.warnings`: `stars dev` preloads the plugins itself, so there it would be noise\n * on every start. `stars build` and `stars prepare` report it.\n */\nexport function modulesPreloadWarning(config: ResolvedStarsConfig): Diagnostic | null {\n\tif (!needsPreload(config)) return null;\n\treturn cliDiagnostics.MODULES_PRELOAD_REQUIRED({\n\t\ttool: config.build.tool,\n\t\tplugins: [...new Set(config.runtime.plugins.map((plugin) => plugin.module))].join(', ')\n\t});\n}\n\n/** A build tool the entry transform cannot reach, with runtime plugins to register: they need a `node --import` preload. */\nfunction needsPreload(config: ResolvedStarsConfig): boolean {\n\treturn UNTRANSFORMED_TOOLS.has(config.build.tool) && (config.runtime?.plugins.length ?? 0) > 0;\n}\n\nexport interface ModulesPreloadResult {\n\t/** Absolute path of the preload file. */\n\tpath: string;\n\tstatus: 'written' | 'up-to-date' | 'outdated';\n}\n\n/**\n * Writes `.stars/modules.mjs`, the production counterpart of the preload `stars dev` passes to `node`: `node --import\n * ./.stars/modules.mjs <entry>` registers the runtime plugins of the installed modules for the build tools whose entry\n * cannot be transformed (`tsc`, `none`). Its specifiers are bare, so they resolve from the project's `node_modules`\n * like the bot's own imports. `null` when there is nothing to register.\n *\n * With `env` enabled it is preceded by `.stars/env.mjs`, a separate module imported first: imports of one module are\n * all evaluated before its body runs, so the environment could not be loaded ahead of the plugins from the same file,\n * and a plugin reading `process.env` while it is imported would see nothing.\n */\nexport async function prepareModulesPreload(config: ResolvedStarsConfig, check = false): Promise<ModulesPreloadResult | null> {\n\tif (!needsPreload(config)) return null;\n\n\tconst directory = join(config.root, '.stars');\n\tconst path = join(directory, 'modules.mjs');\n\tconst withEnv = config.env?.enabled === true;\n\t// An absolute path is a `file:` URL in the import, like in `moduleImportArgs`: Node rejects a Windows path there.\n\tconst plugins = modulesModuleSource(config.runtime.plugins, { resolve: (from) => (isAbsolute(from) ? pathToFileURL(from).href : from) });\n\tconst files = [\n\t\t{ path, content: withEnv ? `import \"./env.mjs\";\\n${plugins}` : plugins },\n\t\t...(withEnv ? [{ path: join(directory, 'env.mjs'), content: envModuleSource(config.env.options) }] : [])\n\t];\n\n\tif (check) {\n\t\tconst current = await Promise.all(files.map(async (file) => (await readFile(file.path, 'utf-8').catch(() => null)) === file.content));\n\t\treturn { path, status: current.every(Boolean) ? 'up-to-date' : 'outdated' };\n\t}\n\n\tawait mkdir(directory, { recursive: true });\n\tawait Promise.all(files.map((file) => writeFile(file.path, file.content)));\n\treturn { path, status: 'written' };\n}\n","import { readProjectEnvFiles, type ResolvedStarsConfig } from '@wolfstar/schema';\nimport { execFileSync } from 'node:child_process';\nimport { resolveBinary } from './project.js';\n\n/**\n * The variables the bot will load, for the CLI's own lookups (Discord credentials for the tunnel). With the default\n * loader these are the project's env files, read from `env.path`/`env.env`. With `loader: 'varlock'` they are what\n * `varlock load` resolves from the project's `.env.schema` — a dotenv file may be stale or absent there — and nothing\n * when varlock cannot be run, rather than values the bot never sees.\n */\nexport function readProjectEnv(config: ResolvedStarsConfig): Record<string, string> {\n\tconst { path, env = 'development', loader } = config.env.options;\n\tif (loader !== 'varlock') return readProjectEnvFiles(config.root, env, { path });\n\n\tconst binary = resolveBinary(config.root, 'varlock', 'varlock');\n\tif (binary === null) return {};\n\n\ttry {\n\t\t// The way the bot loads it: `@wolfstar/env-utilities` runs `varlock/auto-load` with no `--env` (it ignores\n\t\t// `env.env` with varlock), in the environment `stars dev` gives the bot.\n\t\tconst output = execFileSync(process.execPath, [binary, 'load', '--format', 'json'], {\n\t\t\tcwd: config.root,\n\t\t\t// Same order as `createSupervisor`: `NODE_ENV` is forced to development after `dev.env`, so it can't differ.\n\t\t\tenv: { ...process.env, ...config.dev.env, NODE_ENV: 'development' },\n\t\t\tencoding: 'utf8',\n\t\t\tstdio: ['ignore', 'pipe', 'ignore'],\n\t\t\ttimeout: 30_000\n\t\t});\n\t\tconst values = JSON.parse(output) as Record<string, unknown>;\n\t\treturn Object.fromEntries(\n\t\t\tObject.entries(values)\n\t\t\t\t.filter(([, value]) => value !== undefined && value !== null)\n\t\t\t\t.map(([key, value]) => [key, String(value)])\n\t\t);\n\t} catch {\n\t\treturn {};\n\t}\n}\n","import {\n\tloadConfigFile,\n\tresolveStarsConfig,\n\ttype LoadStarsConfigOptions,\n\ttype ResolveConfigOptions,\n\ttype ResolvedStarsConfig,\n\ttype StarsHookName,\n\ttype StarsHooks\n} from '@wolfstar/schema';\nimport { createHooks, type Hookable } from 'hookable';\nimport { installModules } from './modules.js';\nimport { readProjectEnv } from './project-env.js';\n\nexport type StarsHookable = Hookable<StarsHooks>;\n\n/** What each configuration loaded by {@link loadProject} was resolved from, so `env:options` can re-resolve it. */\nconst sources = new WeakMap<ResolvedStarsConfig, ResolveConfigOptions>();\n\n/** Registers the `hooks` of `stars.config` on a fresh `hookable` instance. */\nexport function createStarsHooks(config: ResolvedStarsConfig): StarsHookable {\n\tconst hooks = createHooks<StarsHooks>();\n\tfor (const [name, callbacks] of Object.entries(config.hooks) as [StarsHookName, readonly StarsHooks[StarsHookName][]][]) {\n\t\tfor (const callback of callbacks) hooks.hook(name, callback);\n\t}\n\n\treturn hooks;\n}\n\n/** Loads `stars.config`, registers its hooks and runs `config:resolved`. */\nexport async function loadProject(options: LoadStarsConfigOptions): Promise<{ config: ResolvedStarsConfig; hooks: StarsHookable }> {\n\tconst cwd = options.cwd ?? process.cwd();\n\tconst loaded = await loadConfigFile({ cwd, configFile: options.configFile });\n\tconst source: ResolveConfigOptions = { cwd, configFile: loaded.configFile, config: loaded.config, env: options.env };\n\tconst resolved = resolveStarsConfig(source);\n\tconst hooks = createStarsHooks(resolved);\n\t// Modules install before `config:resolved`, so that hook already sees what they contributed.\n\tconst config = await installModules(resolved, hooks);\n\tsources.set(config, source);\n\n\tawait hooks.callHook('config:resolved', config);\n\treturn { config, hooks };\n}\n\n/**\n * Runs `env:options` on a copy of the resolved `env` options and returns a configuration carrying the result, which\n * is what the builders write into the entry. The resolved configuration itself is left untouched.\n *\n * When the hook changes the options, the configuration is resolved again with them, so everything read from the env\n * files — the default `dev.url` port above all — matches what the bot will load.\n */\nexport async function applyEnvOptions(config: ResolvedStarsConfig, hooks: StarsHookable): Promise<ResolvedStarsConfig> {\n\tif (!config.env.enabled) return config;\n\n\tconst options = { ...config.env.options };\n\tawait hooks.callHook('env:options', options, config);\n\n\tconst source = sources.get(config);\n\tif (source === undefined || JSON.stringify(options) === JSON.stringify(config.env.options)) {\n\t\treturn { ...config, env: { ...config.env, options } };\n\t}\n\n\treturn reresolve(config, source, { config: { ...source.config, env: { ...options, enabled: true } } });\n}\n\n/**\n * With `loader: 'varlock'`, resolves the configuration again with the variables `varlock load` returns, so the\n * defaults `stars.config` derives from the environment — the `dev.url` port — match what the bot loads. Every other\n * configuration is returned as-is: the schema reads its env files directly.\n */\nexport function withProjectEnv(config: ResolvedStarsConfig): ResolvedStarsConfig {\n\tconst source = sources.get(config);\n\tif (source === undefined || !config.env.enabled || config.env.options.loader !== 'varlock') return config;\n\treturn reresolve(config, source, { projectEnv: readProjectEnv(config) });\n}\n\nfunction reresolve(previous: ResolvedStarsConfig, source: ResolveConfigOptions, change: Partial<ResolveConfigOptions>): ResolvedStarsConfig {\n\tconst next = { ...source, ...change };\n\tconst resolved = resolveStarsConfig(next);\n\t// Modules ran once, against the first resolution: what they contributed carries over to the new one.\n\tconst config = { ...resolved, runtime: previous.runtime, imports: { ...resolved.imports, presets: previous.imports.presets } };\n\tsources.set(config, next);\n\treturn config;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAMA,MAAa,cAAc;CAC1B,QAAQ;EACP,MAAM;EACN,OAAO;EACP,aAAa;CACd;CACA,KAAK;EACJ,MAAM;EACN,aAAa;CACd;AACD;;;;;AAWA,SAAgB,YAAY,SAA4B,MAAwB;CAC/E,MAAM,SAAmB,CAAC;CAC1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AAE,GAAG;EAAQ,GAAG;CAAO;CACpC,MAAM,WAAW,mBAAmB,IAAI;CAExC,MAAM,SAAS;EAAE,GAAG;EAAU,SAAS,SAAS;EAAS,SAAS;GAAE,GAAG,SAAS;GAAS,SAAS,SAAS,QAAQ;EAAQ;CAAE;CAC7H,QAAQ,IAAI,QAAQ,IAAI;CACxB,OAAO;AACR"}
|
package/dist/index.d.ts
CHANGED
|
@@ -38,6 +38,27 @@ export declare const cliDiagnostics: import("nostics").Diagnostics<{
|
|
|
38
38
|
readonly PREPARE_OUTDATED: {
|
|
39
39
|
why: (_p: {}) => string;
|
|
40
40
|
};
|
|
41
|
+
readonly TSCONFIG_LEGACY_EXTENDS: {
|
|
42
|
+
why: (p: {
|
|
43
|
+
file: string;
|
|
44
|
+
}) => string;
|
|
45
|
+
fix: (_p: {
|
|
46
|
+
file: string;
|
|
47
|
+
}) => string;
|
|
48
|
+
};
|
|
49
|
+
readonly TYPECHECK_FAILED: {
|
|
50
|
+
why: (p: {
|
|
51
|
+
projects: string;
|
|
52
|
+
}) => string;
|
|
53
|
+
};
|
|
54
|
+
readonly TYPECHECK_NO_PROJECT: {
|
|
55
|
+
why: (p: {
|
|
56
|
+
root: string;
|
|
57
|
+
}) => string;
|
|
58
|
+
fix: (_p: {
|
|
59
|
+
root: string;
|
|
60
|
+
}) => string;
|
|
61
|
+
};
|
|
41
62
|
readonly DISCORD_TOKEN_MISSING: {
|
|
42
63
|
why: (_p: {}) => string;
|
|
43
64
|
fix: (_p: {}) => string;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/run.ts","../src/utils/errors.ts","../src/utils/diagnostics.ts","../src/utils/output-mode.ts","../src/utils/theme.ts"],"mappings":";;wBA8BsB,QAAQ,kBAAyC;;;qBCxB1D;WACZ;WACA;WACA;WACA;WACA;WACA;;YAGW,mBAAmB,uBAAuB;;;;;;wBAgBhC,YAAY,iBAAiB;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,mBAAmB;qBAElB,QAAQ,SAAS,OAAO,WAAW;wBAoHhC,aAAa,SAAS,cAAc,MAAK,OAAO,aAA2B;UAI1E;;EAEhB;EACA,MAAM,OAAO;;EAEb,QAAQ;;;;;;wBAOO,sBAAsB,MAAM,KAAmB,SAAS,sBAAsB"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { t as runMain } from "./run-
|
|
1
|
+
import { t as runMain } from "./run-DlNY1QM1.js";
|
|
2
2
|
import { i as shouldUseColor, n as prefersReducedMotion, r as resolveOutputMode, t as isCIEnvironment } from "./output-mode-Bp7Da8vJ.js";
|
|
3
3
|
import { n as exitCodeOf, r as formatError, t as ExitCode } from "./errors-COFWKKKw.js";
|
|
4
|
-
import { t as cliDiagnostics } from "./diagnostics-
|
|
4
|
+
import { t as cliDiagnostics } from "./diagnostics-Dn3CXa8J.js";
|
|
5
5
|
import { n as THEME_SETTINGS, o as resolveTheme, s as resolveThemeSetting, t as THEMES } from "./theme-yS2h5dd_.js";
|
|
6
6
|
import { configDiagnostics, loadStarsConfig } from "@wolfstar/schema";
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as readOwnPackageJson } from "./version-BzclCE19.js";
|
|
2
2
|
import { i as shouldUseColor, r as resolveOutputMode } from "./output-mode-Bp7Da8vJ.js";
|
|
3
|
-
import { t as findInstalledVersion } from "./project-
|
|
4
|
-
import { a as modulesPreloadWarning, d as resolveCwd, n as loadProject, t as applyEnvOptions, u as projectArgs } from "./hooks-
|
|
3
|
+
import { t as findInstalledVersion } from "./project-DBqQMFCk.js";
|
|
4
|
+
import { a as modulesPreloadWarning, d as resolveCwd, n as loadProject, t as applyEnvOptions, u as projectArgs } from "./hooks-D_RVS0ba.js";
|
|
5
5
|
import { defineCommand } from "citty";
|
|
6
6
|
import { relative } from "node:path";
|
|
7
7
|
import { displayPath } from "@wolfstar/schema";
|
|
@@ -70,6 +70,7 @@ function formatInfo(info, useColor) {
|
|
|
70
70
|
row("options", describeOptions(info, colors)),
|
|
71
71
|
row("outDir", show(info.build.outDir)),
|
|
72
72
|
row("tsconfig", show(info.build.tsconfig)),
|
|
73
|
+
row("typechecks", info.dev.typecheck.projects.length > 0 ? info.dev.typecheck.projects.map(show).join(", ") : colors.dim("none")),
|
|
73
74
|
row("runs", show(info.build.output))
|
|
74
75
|
]),
|
|
75
76
|
section("Dev", [
|
|
@@ -89,7 +90,7 @@ function formatInfo(info, useColor) {
|
|
|
89
90
|
row("commands", `refresh: ${info.dev.commands.refresh}`),
|
|
90
91
|
row("hmr", info.dev.hmr ? "left to the bot when it hot reloads" : colors.dim("always restart"))
|
|
91
92
|
]),
|
|
92
|
-
section("Codegen", [row("i18n", info.codegen.i18n ? `${show(info.codegen.i18n.locales)} → ${show(info.codegen.i18n.output)}` : colors.dim("disabled"))]),
|
|
93
|
+
section("Codegen", [row("i18n", info.codegen.i18n ? `${show(info.codegen.i18n.locales)} → ${show(info.codegen.i18n.output)}` : colors.dim("disabled")), row("commands", info.codegen.commands ? show(info.codegen.commands.output) : colors.dim("disabled"))]),
|
|
93
94
|
section("Future", [row("compat", `v${info.future.compatibilityVersion} defaults`), ...info.warnings.map((warning) => row("warning", colors.yellow(warning)))]),
|
|
94
95
|
section("Env", [row("register", info.env.enabled ? colors.green(describeEnvOptions(info.env.options)) : colors.dim("disabled"))]),
|
|
95
96
|
section("Hooks", [row("registered", info.hooks.join(", ") || colors.dim("none"))]),
|
|
@@ -159,4 +160,4 @@ var info_default = defineCommand({
|
|
|
159
160
|
|
|
160
161
|
//#endregion
|
|
161
162
|
export { info_default as default };
|
|
162
|
-
//# sourceMappingURL=info-
|
|
163
|
+
//# sourceMappingURL=info-eXsx1AfE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"info-eXsx1AfE.js","names":[],"sources":["../src/commands/info.ts"],"sourcesContent":["import { displayPath, type ResolvedStarsConfig, type StarsEnvSetupOptions } from '@wolfstar/schema';\nimport { defineCommand } from 'citty';\nimport { createColors } from 'colorette';\nimport { arch, platform } from 'node:os';\nimport { relative } from 'node:path';\nimport { projectArgs, resolveCwd, type ProjectArgs } from '../utils/args.js';\nimport { applyEnvOptions, loadProject } from '../utils/hooks.js';\nimport { modulesPreloadWarning } from '../utils/modules.js';\nimport { resolveOutputMode, shouldUseColor } from '../utils/output-mode.js';\nimport { findInstalledVersion } from '../utils/project.js';\nimport { readOwnPackageJson } from '../utils/version.js';\n\nexport interface InfoOptions extends ProjectArgs {\n\tjson?: boolean;\n\tstdout?: NodeJS.WritableStream;\n}\n\nexport interface ProjectInfo {\n\tcli: { version: string; node: string; platform: string; outputMode: 'tui' | 'plain' };\n\tproject: {\n\t\tcwd: string;\n\t\troot: string;\n\t\tconfigFile: string | null;\n\t\tname: string | null;\n\t\tversion: string | null;\n\t\tentry: string;\n\t\tframeworkVersion: string | null;\n\t};\n\tbuild: ResolvedStarsConfig['build'];\n\tdev: ResolvedStarsConfig['dev'];\n\tcodegen: ResolvedStarsConfig['codegen'];\n\timports: ResolvedStarsConfig['imports'];\n\texperimental: ResolvedStarsConfig['experimental'];\n\tfuture: ResolvedStarsConfig['future'];\n\tenv: ResolvedStarsConfig['env'];\n\t/** The names of the hooks registered in `stars.config`, flattened (`build:done`). */\n\thooks: string[];\n\t/** The installed modules, and the runtime plugins they registered (`module → export from package`). */\n\tmodules: { installed: string[]; plugins: string[] };\n\t/** Non-fatal configuration diagnostics, as `CODE: message`. */\n\twarnings: string[];\n\t/**\n\t * The option names set in the `tsdown`/`vite` blocks. Only the names: the values hold plugins and callbacks,\n\t * which neither serialize to JSON nor read usefully on a terminal.\n\t */\n\toptions: { tsdown: string[]; vite: string[] };\n}\n\nexport function collectInfo(config: ResolvedStarsConfig): ProjectInfo {\n\treturn {\n\t\tcli: {\n\t\t\tversion: readOwnPackageJson().version,\n\t\t\tnode: process.version,\n\t\t\tplatform: `${platform()} ${arch()}`,\n\t\t\toutputMode: resolveOutputMode()\n\t\t},\n\t\tproject: {\n\t\t\tcwd: config.cwd,\n\t\t\troot: config.root,\n\t\t\tconfigFile: config.configFile,\n\t\t\tname: config.packageJson?.name ?? null,\n\t\t\tversion: config.packageJson?.version ?? null,\n\t\t\tentry: config.entry,\n\t\t\tframeworkVersion: findInstalledVersion(config.root, '@wolfstar/http-framework')\n\t\t},\n\t\tbuild: config.build,\n\t\tdev: config.dev,\n\t\tcodegen: config.codegen,\n\t\timports: config.imports,\n\t\texperimental: config.experimental,\n\t\tfuture: config.future,\n\t\tenv: config.env,\n\t\thooks: Object.keys(config.hooks),\n\t\tmodules: {\n\t\t\tinstalled: (config.runtime?.modules ?? []).map((module) => module.name),\n\t\t\tplugins: (config.runtime?.plugins ?? []).map((plugin) => `${plugin.module} → ${plugin.export} from ${plugin.from}`)\n\t\t},\n\t\twarnings: [...config.warnings, modulesPreloadWarning(config)]\n\t\t\t.filter((warning) => warning !== null)\n\t\t\t.map((warning) => `${warning.code}: ${warning.message}`),\n\t\toptions: { tsdown: Object.keys(config.tsdown), vite: Object.keys(config.vite) }\n\t};\n}\n\nexport function formatInfo(info: ProjectInfo, useColor: boolean): string {\n\tconst colors = createColors({ useColor });\n\tconst { root } = info.project;\n\tconst show = (path: string | null) => (path === null ? colors.dim('none') : displayPath(root, path));\n\tconst row = (label: string, value: string) => ` ${colors.dim(label.padEnd(12))}${value}`;\n\tconst section = (title: string, rows: string[]) => [colors.bold(title), ...rows].join('\\n');\n\n\treturn [\n\t\tsection(`stars ${colors.green(`v${info.cli.version}`)}`, [\n\t\t\trow('node', info.cli.node),\n\t\t\trow('platform', info.cli.platform),\n\t\t\trow('output', info.cli.outputMode),\n\t\t\trow(\n\t\t\t\t'framework',\n\t\t\t\tinfo.project.frameworkVersion\n\t\t\t\t\t? `@wolfstar/http-framework v${info.project.frameworkVersion}`\n\t\t\t\t\t: colors.yellow('@wolfstar/http-framework not installed')\n\t\t\t)\n\t\t]),\n\t\tsection('Project', [\n\t\t\trow(\n\t\t\t\t'name',\n\t\t\t\tinfo.project.name\n\t\t\t\t\t? `${info.project.name}${info.project.version ? colors.dim(` v${info.project.version}`) : ''}`\n\t\t\t\t\t: colors.dim('unnamed')\n\t\t\t),\n\t\t\trow('root', root),\n\t\t\trow(\n\t\t\t\t'config',\n\t\t\t\tinfo.project.configFile ? relative(root, info.project.configFile) || info.project.configFile : colors.dim('none (defaults)')\n\t\t\t),\n\t\t\trow('entry', show(info.project.entry))\n\t\t]),\n\t\tsection('Build', [\n\t\t\trow('tool', info.build.tool),\n\t\t\t// Which file the build tool is configured from: its own, or this project's `stars.config`.\n\t\t\trow('config', info.build.configFile ? show(info.build.configFile) : colors.dim('stars.config')),\n\t\t\trow('options', describeOptions(info, colors)),\n\t\t\trow('outDir', show(info.build.outDir)),\n\t\t\trow('tsconfig', show(info.build.tsconfig)),\n\t\t\t// Everything `stars typecheck` checks: the generated app and node projects from compatibility version 6 (a `tsc`\n\t\t\t// or `none` project keeps its own tsconfig for the bot and gets the node one on top).\n\t\t\trow('typechecks', info.dev.typecheck.projects.length > 0 ? info.dev.typecheck.projects.map(show).join(', ') : colors.dim('none')),\n\t\t\trow('runs', show(info.build.output))\n\t\t]),\n\t\tsection('Dev', [\n\t\t\trow('watch', info.dev.watch.map(show).join(', ')),\n\t\t\trow('debounce', `${info.dev.debounce}ms`),\n\t\t\trow('node args', info.dev.nodeArgs.join(' ') || colors.dim('none')),\n\t\t\trow('args', info.dev.args.join(' ') || colors.dim('none')),\n\t\t\trow('url', info.dev.url ?? colors.dim('unknown, set dev.url or HTTP_PORT')),\n\t\t\trow('health', info.dev.health ?? colors.dim('none')),\n\t\t\trow(\n\t\t\t\t'typecheck',\n\t\t\t\tinfo.dev.typecheck.enabled ? `${info.dev.typecheck.checker} → ${show(info.dev.typecheck.tsconfig)}` : colors.dim('disabled')\n\t\t\t),\n\t\t\trow('tunnel', describeTunnel(info.dev.tunnel, colors)),\n\t\t\trow('log file', info.dev.logFile ? show(info.dev.logFile) : colors.dim('disabled')),\n\t\t\trow('log dir', info.dev.logs.dir ? `${show(info.dev.logs.dir)} (keeps ${info.dev.logs.keep})` : colors.dim('disabled')),\n\t\t\trow('layout', info.dev.layout),\n\t\t\trow('channels', info.dev.logs.channels?.join(', ') ?? colors.dim('all')),\n\t\t\trow('levels', info.dev.logs.levels.join(', ')),\n\t\t\trow('commands', `refresh: ${info.dev.commands.refresh}`),\n\t\t\trow('hmr', info.dev.hmr ? 'left to the bot when it hot reloads' : colors.dim('always restart'))\n\t\t]),\n\t\tsection('Codegen', [\n\t\t\trow('i18n', info.codegen.i18n ? `${show(info.codegen.i18n.locales)} → ${show(info.codegen.i18n.output)}` : colors.dim('disabled')),\n\t\t\trow('commands', info.codegen.commands ? show(info.codegen.commands.output) : colors.dim('disabled'))\n\t\t]),\n\t\tsection('Future', [\n\t\t\trow('compat', `v${info.future.compatibilityVersion} defaults`),\n\t\t\t...info.warnings.map((warning) => row('warning', colors.yellow(warning)))\n\t\t]),\n\t\tsection('Env', [row('register', info.env.enabled ? colors.green(describeEnvOptions(info.env.options)) : colors.dim('disabled'))]),\n\t\tsection('Hooks', [row('registered', info.hooks.join(', ') || colors.dim('none'))]),\n\t\tsection('Modules', [\n\t\t\trow('installed', info.modules.installed.join(', ') || colors.dim('none')),\n\t\t\t...info.modules.plugins.map((plugin) => row('plugin', plugin))\n\t\t]),\n\t\tsection('Experimental', [\n\t\t\trow('vite', flag(info.experimental.enableVite, colors)),\n\t\t\trow('nitro', flag(info.experimental.enableNitro, colors)),\n\t\t\t...(info.experimental.enableNitro ? [row('nitro preset', info.experimental.nitro.preset)] : []),\n\t\t\trow('external', flag(info.experimental.enableExternalVite, colors))\n\t\t]),\n\t\tsection('Imports', [\n\t\t\trow('auto', info.imports.enabled ? colors.green('enabled') : colors.dim('disabled')),\n\t\t\trow('dirs', info.imports.dirs.map(show).join(', ')),\n\t\t\trow('presets', info.imports.presets.join(', ') || colors.dim('none')),\n\t\t\trow('dts', show(info.imports.dts))\n\t\t])\n\t].join('\\n\\n');\n}\n\nfunction describeOptions(info: ProjectInfo, colors: ReturnType<typeof createColors>): string {\n\tconst names = info.build.tool === 'vite' ? info.options.vite : info.options.tsdown;\n\treturn names.length > 0 ? names.join(', ') : colors.dim('none');\n}\n\nfunction describeEnvOptions(options: Readonly<StarsEnvSetupOptions>): string {\n\tconst entries = Object.entries(options).map(([key, value]) => `${key} ${String(value)}`);\n\treturn entries.length > 0 ? `enabled (${entries.join(', ')})` : 'enabled';\n}\n\nfunction flag(enabled: boolean, colors: ReturnType<typeof createColors>): string {\n\treturn enabled ? colors.green('enabled') : colors.dim('disabled');\n}\n\nfunction describeTunnel(tunnel: ResolvedStarsConfig['dev']['tunnel'], colors: ReturnType<typeof createColors>): string {\n\tswitch (tunnel.mode) {\n\t\tcase 'quick':\n\t\t\treturn 'cloudflared quick tunnel';\n\t\tcase 'url':\n\t\t\treturn tunnel.url;\n\t\tdefault:\n\t\t\treturn colors.dim('disabled');\n\t}\n}\n\nexport async function runInfo(options: InfoOptions): Promise<void> {\n\tconst stdout = options.stdout ?? process.stdout;\n\tconst project = await loadProject({ cwd: resolveCwd(options), configFile: options.config });\n\t// What the build would use: `env:options` may change the env files.\n\tconst config = await applyEnvOptions(project.config, project.hooks);\n\tconst info = collectInfo(config);\n\tstdout.write(`${options.json ? JSON.stringify(info, null, 2) : formatInfo(info, shouldUseColor())}\\n`);\n}\n\nexport default defineCommand({\n\tmeta: {\n\t\tname: 'info',\n\t\tdescription: 'Print the resolved project configuration and environment'\n\t},\n\targs: {\n\t\t...projectArgs,\n\t\tjson: {\n\t\t\ttype: 'boolean',\n\t\t\tdescription: 'Print machine-readable JSON',\n\t\t\tdefault: false\n\t\t}\n\t},\n\tasync run({ args }) {\n\t\tawait runInfo({ config: args.config, cwd: args.cwd, json: args.json });\n\t}\n});\n"],"mappings":";;;;;;;;;;;AAgDA,SAAgB,YAAY,QAA0C;CACrE,OAAO;EACN,KAAK;GACJ,SAAS,mBAAmB,CAAC,CAAC;GAC9B,MA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d;CACA,MAAM;EACL,GAAG;EACH,MAAM;GACL,MAAM;GACN,aAAa;GACb,SAAS;EACV;CACD;CACA,MAAM,IAAI,EAAE,QAAQ;EACnB,MAAM,QAAQ;GAAE,QAAQ,KAAK;GAAQ,KAAK,KAAK;GAAK,MAAM,KAAK;EAAK,CAAC;CACtE;AACD,CAAC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { t as cliDiagnostics } from "./diagnostics-Dn3CXa8J.js";
|
|
2
|
+
import { c as moduleImportArgs, s as envImportArgs } from "./hooks-D_RVS0ba.js";
|
|
3
|
+
import { i as bridgeImportArgs, o as parseBridgeMessage, r as DUMP_ENV, t as BRIDGE_FRAMEWORK_VERSION } from "./bridge-Cbm0jX9h.js";
|
|
4
|
+
import { existsSync } from "node:fs";
|
|
5
|
+
import { displayPath } from "@wolfstar/schema";
|
|
6
|
+
import { spawn } from "node:child_process";
|
|
7
|
+
|
|
8
|
+
//#region src/utils/local-commands.ts
|
|
9
|
+
/**
|
|
10
|
+
* The application commands the project defines, as the bot itself would register them.
|
|
11
|
+
*
|
|
12
|
+
* Commands are declared with builders and decorators that only exist once the bot's modules ran, so nothing short of
|
|
13
|
+
* running them knows the answer. This starts the built bot with the dev bridge in its "dump" mode: it loads its
|
|
14
|
+
* pieces, reports its registry over IPC and exits before it listens or talks to Discord.
|
|
15
|
+
*
|
|
16
|
+
* It is a plain start of the bot, not a `stars dev` session: `STARS_DEV` is not set, so commands a project only
|
|
17
|
+
* registers while developing are not part of what `stars commands deploy` deploys.
|
|
18
|
+
*/
|
|
19
|
+
async function readLocalCommands(config, options = {}) {
|
|
20
|
+
if (!existsSync(config.build.output)) throw cliDiagnostics.LOCAL_COMMANDS_UNAVAILABLE({
|
|
21
|
+
reason: `${displayPath(config.root, config.build.output)} does not exist`,
|
|
22
|
+
fix: "Run `stars build` first: the commands are read from the built bot."
|
|
23
|
+
});
|
|
24
|
+
const bridge = bridgeImportArgs(config);
|
|
25
|
+
if (bridge.length === 0) throw cliDiagnostics.LOCAL_COMMANDS_UNAVAILABLE({
|
|
26
|
+
reason: `@wolfstar/http-framework ${BRIDGE_FRAMEWORK_VERSION} or later is not installed in ${config.root}`,
|
|
27
|
+
fix: `Install @wolfstar/http-framework@^${BRIDGE_FRAMEWORK_VERSION} in the project.`
|
|
28
|
+
});
|
|
29
|
+
const child = spawn(process.execPath, [
|
|
30
|
+
...envImportArgs(config),
|
|
31
|
+
...moduleImportArgs(config),
|
|
32
|
+
...bridge,
|
|
33
|
+
...config.dev.nodeArgs,
|
|
34
|
+
config.build.output,
|
|
35
|
+
...config.dev.args
|
|
36
|
+
], {
|
|
37
|
+
cwd: config.root,
|
|
38
|
+
env: {
|
|
39
|
+
...process.env,
|
|
40
|
+
...config.dev.env,
|
|
41
|
+
NODE_ENV: process.env.NODE_ENV ?? "development",
|
|
42
|
+
[DUMP_ENV]: "1"
|
|
43
|
+
},
|
|
44
|
+
stdio: [
|
|
45
|
+
"ignore",
|
|
46
|
+
"ignore",
|
|
47
|
+
"pipe",
|
|
48
|
+
"ipc"
|
|
49
|
+
],
|
|
50
|
+
windowsHide: true
|
|
51
|
+
});
|
|
52
|
+
return new Promise((resolve, reject) => {
|
|
53
|
+
let stderr = "";
|
|
54
|
+
let settled = false;
|
|
55
|
+
const finish = (action) => {
|
|
56
|
+
if (settled) return;
|
|
57
|
+
settled = true;
|
|
58
|
+
clearTimeout(timer);
|
|
59
|
+
action();
|
|
60
|
+
};
|
|
61
|
+
const unavailable = (reason) => cliDiagnostics.LOCAL_COMMANDS_UNAVAILABLE({
|
|
62
|
+
reason,
|
|
63
|
+
fix: "Check that the bot starts with `stars dev`: it has to construct its `Client` and call `client.load()`."
|
|
64
|
+
});
|
|
65
|
+
const timer = setTimeout(() => {
|
|
66
|
+
child.kill("SIGKILL");
|
|
67
|
+
finish(() => reject(unavailable("the bot did not load its commands in time")));
|
|
68
|
+
}, options.timeout ?? 3e4);
|
|
69
|
+
child.stderr?.on("data", (chunk) => stderr = `${stderr}${chunk.toString()}`.slice(-2e3));
|
|
70
|
+
let snapshot = null;
|
|
71
|
+
child.on("message", (message) => {
|
|
72
|
+
const parsed = parseBridgeMessage(message);
|
|
73
|
+
if (parsed?.type !== "commands" || snapshot !== null) return;
|
|
74
|
+
snapshot = {
|
|
75
|
+
global: parsed.global,
|
|
76
|
+
guilds: parsed.guilds
|
|
77
|
+
};
|
|
78
|
+
setTimeout(() => child.kill("SIGKILL"), 2e3).unref();
|
|
79
|
+
});
|
|
80
|
+
child.once("error", (error) => finish(() => reject(unavailable(error.message))));
|
|
81
|
+
child.once("exit", (code) => {
|
|
82
|
+
if (snapshot !== null) {
|
|
83
|
+
const commands = snapshot;
|
|
84
|
+
finish(() => resolve(commands));
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const detail = stderr.trim().split("\n").at(-1);
|
|
88
|
+
finish(() => reject(unavailable(`the bot exited with code ${code} before loading its commands${detail ? ` (${detail})` : ""}`)));
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
//#endregion
|
|
94
|
+
export { readLocalCommands as t };
|
|
95
|
+
//# sourceMappingURL=local-commands-CGBjc8KJ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-commands-CGBjc8KJ.js","names":[],"sources":["../src/utils/local-commands.ts"],"sourcesContent":["import type { ResolvedStarsConfig } from '@wolfstar/schema';\nimport { displayPath } from '@wolfstar/schema';\nimport { spawn } from 'node:child_process';\nimport { existsSync } from 'node:fs';\nimport { BRIDGE_FRAMEWORK_VERSION, bridgeImportArgs, DUMP_ENV, parseBridgeMessage, type CommandSnapshot } from '../dev/bridge.js';\nimport { cliDiagnostics } from './diagnostics.js';\nimport { envImportArgs, moduleImportArgs } from './env-import.js';\n\nexport interface ReadLocalCommandsOptions {\n\t/** Milliseconds the bot gets to load its pieces. */\n\ttimeout?: number;\n}\n\n/**\n * The application commands the project defines, as the bot itself would register them.\n *\n * Commands are declared with builders and decorators that only exist once the bot's modules ran, so nothing short of\n * running them knows the answer. This starts the built bot with the dev bridge in its \"dump\" mode: it loads its\n * pieces, reports its registry over IPC and exits before it listens or talks to Discord.\n *\n * It is a plain start of the bot, not a `stars dev` session: `STARS_DEV` is not set, so commands a project only\n * registers while developing are not part of what `stars commands deploy` deploys.\n */\nexport async function readLocalCommands(config: ResolvedStarsConfig, options: ReadLocalCommandsOptions = {}): Promise<CommandSnapshot> {\n\tif (!existsSync(config.build.output)) {\n\t\tthrow cliDiagnostics.LOCAL_COMMANDS_UNAVAILABLE({\n\t\t\treason: `${displayPath(config.root, config.build.output)} does not exist`,\n\t\t\tfix: 'Run `stars build` first: the commands are read from the built bot.'\n\t\t});\n\t}\n\n\tconst bridge = bridgeImportArgs(config);\n\tif (bridge.length === 0) {\n\t\tthrow cliDiagnostics.LOCAL_COMMANDS_UNAVAILABLE({\n\t\t\treason: `@wolfstar/http-framework ${BRIDGE_FRAMEWORK_VERSION} or later is not installed in ${config.root}`,\n\t\t\tfix: `Install @wolfstar/http-framework@^${BRIDGE_FRAMEWORK_VERSION} in the project.`\n\t\t});\n\t}\n\n\tconst child = spawn(\n\t\tprocess.execPath,\n\t\t[...envImportArgs(config), ...moduleImportArgs(config), ...bridge, ...config.dev.nodeArgs, config.build.output, ...config.dev.args],\n\t\t{\n\t\t\tcwd: config.root,\n\t\t\t// The environment the commands are read under is the caller's: `NODE_ENV=production stars commands deploy`\n\t\t\t// deploys what a production start registers. Unset, it is development, like the project's env files.\n\t\t\tenv: { ...process.env, ...config.dev.env, NODE_ENV: process.env.NODE_ENV ?? 'development', [DUMP_ENV]: '1' },\n\t\t\tstdio: ['ignore', 'ignore', 'pipe', 'ipc'],\n\t\t\twindowsHide: true\n\t\t}\n\t);\n\n\treturn new Promise<CommandSnapshot>((resolve, reject) => {\n\t\tlet stderr = '';\n\t\tlet settled = false;\n\t\tconst finish = (action: () => void) => {\n\t\t\tif (settled) return;\n\t\t\tsettled = true;\n\t\t\tclearTimeout(timer);\n\t\t\taction();\n\t\t};\n\t\tconst unavailable = (reason: string) =>\n\t\t\tcliDiagnostics.LOCAL_COMMANDS_UNAVAILABLE({\n\t\t\t\treason,\n\t\t\t\tfix: 'Check that the bot starts with `stars dev`: it has to construct its `Client` and call `client.load()`.'\n\t\t\t});\n\n\t\tconst timer = setTimeout(() => {\n\t\t\tchild.kill('SIGKILL');\n\t\t\tfinish(() => reject(unavailable('the bot did not load its commands in time')));\n\t\t}, options.timeout ?? 30_000);\n\n\t\tchild.stderr?.on('data', (chunk: Buffer) => (stderr = `${stderr}${chunk.toString()}`.slice(-2000)));\n\t\tlet snapshot: CommandSnapshot | null = null;\n\t\tchild.on('message', (message) => {\n\t\t\tconst parsed = parseBridgeMessage(message);\n\t\t\tif (parsed?.type !== 'commands' || snapshot !== null) return;\n\t\t\tsnapshot = { global: parsed.global, guilds: parsed.guilds };\n\t\t\t// The bot exits on its own once the message is flushed. The answer waits for that: until then the process\n\t\t\t// still holds the project directory (its working directory), which Windows refuses to let go of.\n\t\t\tsetTimeout(() => child.kill('SIGKILL'), 2000).unref();\n\t\t});\n\t\tchild.once('error', (error) => finish(() => reject(unavailable(error.message))));\n\t\tchild.once('exit', (code) => {\n\t\t\tif (snapshot !== null) {\n\t\t\t\tconst commands = snapshot;\n\t\t\t\tfinish(() => resolve(commands));\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst detail = stderr.trim().split('\\n').at(-1);\n\t\t\tfinish(() => reject(unavailable(`the bot exited with code ${code} before loading its commands${detail ? ` (${detail})` : ''}`)));\n\t\t});\n\t});\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAuBA,eAAsB,kBAAkB,QAA6B,UAAoC,CAAC,GAA6B;CACtI,IAAI,CAAC,WAAW,OAAO,MAAM,MAAM,GAClC,MAAM,eAAe,2BAA2B;EAC/C,QAAQ,GAAG,YAAY,OAAO,MAAM,OAAO,MAAM,MAAM,EAAE;EACzD,KAAK;CACN,CAAC;CAGF,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,CAAC;EACD,MAAM,KAAK,UAAU,UAAU,aAAa,OAAO,YAAY,MAAM,OAAO,CAAC,CAAC,CAAC;EAC/E,MAAM,KAAK,SAAS,SAAS;GAC5B,IAAI,aAAa,MAAM;IACtB,MAAM,WAAW;IACjB,aAAa,QAAQ,QAAQ,CAAC;IAC9B;GACD;GAEA,MAAM,SAAS,OAAO,KAAK,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,GAAG,EAAE;GAC9C,aAAa,OAAO,YAAY,4BAA4B,KAAK,8BAA8B,SAAS,KAAK,OAAO,KAAK,IAAI,CAAC,CAAC;EAChI,CAAC;CACF,CAAC;AACF"}
|
|
@@ -12,20 +12,20 @@ async function createBuilder(config, hooks) {
|
|
|
12
12
|
return new ExternalBuilder(config);
|
|
13
13
|
}
|
|
14
14
|
if (config.experimental.enableNitro) {
|
|
15
|
-
const { NitroBuilder } = await import("./nitro-
|
|
15
|
+
const { NitroBuilder } = await import("./nitro-DufOgx8s.js");
|
|
16
16
|
return new NitroBuilder(config);
|
|
17
17
|
}
|
|
18
18
|
switch (config.build.tool) {
|
|
19
19
|
case "tsdown": {
|
|
20
|
-
const { TsdownBuilder } = await import("./tsdown-
|
|
20
|
+
const { TsdownBuilder } = await import("./tsdown-2i5h88vT.js");
|
|
21
21
|
return new TsdownBuilder(config, hooks);
|
|
22
22
|
}
|
|
23
23
|
case "vite": {
|
|
24
|
-
const { ViteBuilder } = await import("./vite-
|
|
24
|
+
const { ViteBuilder } = await import("./vite-C5CN3xUu.js");
|
|
25
25
|
return new ViteBuilder(config);
|
|
26
26
|
}
|
|
27
27
|
case "tsc": {
|
|
28
|
-
const { TscBuilder } = await import("./tsc-
|
|
28
|
+
const { TscBuilder } = await import("./tsc-9yHyx0L6.js");
|
|
29
29
|
return new TscBuilder(config);
|
|
30
30
|
}
|
|
31
31
|
case "none": {
|
|
@@ -94,4 +94,4 @@ var Locales = class extends EventEmitter {
|
|
|
94
94
|
|
|
95
95
|
//#endregion
|
|
96
96
|
export { createBuilder as n, Locales as t };
|
|
97
|
-
//# sourceMappingURL=locales-
|
|
97
|
+
//# sourceMappingURL=locales-BzyEMQnX.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locales-
|
|
1
|
+
{"version":3,"file":"locales-BzyEMQnX.js","names":[],"sources":["../src/builders/index.ts","../src/utils/locales.ts"],"sourcesContent":["import type { ResolvedStarsConfig } from '@wolfstar/schema';\nimport type { StarsHookable } from '../utils/hooks.js';\nimport type { Builder } from './types.js';\n\n/**\n * Creates the builder for `build.tool`. `hooks` reach the builders that expose hooks of their own (`tsdown:options`).\n */\nexport async function createBuilder(config: ResolvedStarsConfig, hooks?: StarsHookable): Promise<Builder> {\n\t// The project runs its own build, so the CLI only watches what it writes (see `ExternalBuilder`) — including when\n\t// it is driving `vite build` with its own `nitro()` plugin itself; `build.output` already points at Nitro's\n\t// `server/index.mjs` in that case (see `resolveBuild`).\n\tif (config.experimental.enableExternalVite) {\n\t\tconst { ExternalBuilder } = await import('./external.js');\n\t\treturn new ExternalBuilder(config);\n\t}\n\n\t// Nitro is itself a Vite plugin — there is no separate `nitro build` step — so it is handled before the\n\t// `build.tool` switch below, the same way `enableExternalVite` is.\n\tif (config.experimental.enableNitro) {\n\t\tconst { NitroBuilder } = await import('./nitro.js');\n\t\treturn new NitroBuilder(config);\n\t}\n\n\tswitch (config.build.tool) {\n\t\tcase 'tsdown': {\n\t\t\tconst { TsdownBuilder } = await import('./tsdown.js');\n\t\t\treturn new TsdownBuilder(config, hooks);\n\t\t}\n\t\tcase 'vite': {\n\t\t\tconst { ViteBuilder } = await import('./vite.js');\n\t\t\treturn new ViteBuilder(config);\n\t\t}\n\t\tcase 'tsc': {\n\t\t\tconst { TscBuilder } = await import('./tsc.js');\n\t\t\treturn new TscBuilder(config);\n\t\t}\n\t\tcase 'none': {\n\t\t\tconst { NoneBuilder } = await import('./none.js');\n\t\t\treturn new NoneBuilder(config);\n\t\t}\n\t}\n}\n\nexport type { Builder, BuilderEvents, BuildOutcome } from './types.js';\n","import { EventEmitter } from 'node:events';\nimport { cpSync, existsSync, mkdirSync, rmSync } from 'node:fs';\nimport { dirname, join, relative } from 'node:path';\nimport type { ResolvedStarsConfig } from '@wolfstar/schema';\nimport type { LogLevel } from './log-buffer.js';\n\nexport interface LocalesEvents {\n\tchange: [];\n\tlog: [level: LogLevel, text: string];\n}\n\n/** Keeps the conventional `src/locales` data directory next to the compiled application. */\nexport class Locales extends EventEmitter<LocalesEvents> {\n\treadonly source: string;\n\treadonly destination: string;\n\t#watcher: { close(): Promise<void> } | null = null;\n\n\tpublic constructor(private readonly config: ResolvedStarsConfig) {\n\t\tsuper();\n\t\tthis.source = join(config.root, 'src', 'locales');\n\t\tthis.destination = join(config.build.outDir, 'locales');\n\t}\n\n\tpublic copy(): boolean {\n\t\tif (this.config.build.tool === 'none' || !existsSync(this.source)) return false;\n\t\tmkdirSync(this.destination, { recursive: true });\n\t\tcpSync(this.source, this.destination, { recursive: true, force: true });\n\t\treturn true;\n\t}\n\n\tpublic async watch(): Promise<void> {\n\t\tif (this.config.build.tool === 'none' || !existsSync(this.source) || this.#watcher) return;\n\t\tconst { watch } = await import('chokidar');\n\t\tconst watcher = watch(this.source, { ignoreInitial: true });\n\t\tthis.#watcher = watcher;\n\n\t\twatcher.on('all', (event, path) => {\n\t\t\ttry {\n\t\t\t\tconst target = join(this.destination, relative(this.source, path));\n\t\t\t\tif (event === 'unlink' || event === 'unlinkDir') rmSync(target, { recursive: event === 'unlinkDir', force: true });\n\t\t\t\telse if (existsSync(path)) {\n\t\t\t\t\tmkdirSync(dirname(target), { recursive: true });\n\t\t\t\t\tcpSync(path, target, { recursive: event === 'addDir', force: true });\n\t\t\t\t}\n\t\t\t\tthis.emit('change');\n\t\t\t} catch (error) {\n\t\t\t\tthis.emit('log', 'error', `Failed to copy locales: ${error instanceof Error ? error.message : String(error)}`);\n\t\t\t}\n\t\t});\n\t\twatcher.on('error', (error) => this.emit('log', 'error', error instanceof Error ? error.message : String(error)));\n\t\tawait new Promise<void>((resolve) => watcher.once('ready', resolve));\n\t}\n\n\tpublic async close(): Promise<void> {\n\t\tconst watcher = this.#watcher;\n\t\tthis.#watcher = null;\n\t\tawait watcher?.close();\n\t}\n}\n"],"mappings":";;;;;;;;AAOA,eAAsB,cAAc,QAA6B,OAAyC;CAIzG,IAAI,OAAO,aAAa,oBAAoB;EAC3C,MAAM,EAAE,oBAAoB,MAAM,OAAO;EACzC,OAAO,IAAI,gBAAgB,MAAM;CAClC;CAIA,IAAI,OAAO,aAAa,aAAa;EACpC,MAAM,EAAE,iBAAiB,MAAM,OAAO;EACtC,OAAO,IAAI,aAAa,MAAM;CAC/B;CAEA,QAAQ,OAAO,MAAM,MAArB;EACC,KAAK,UAAU;GACd,MAAM,EAAE,kBAAkB,MAAM,OAAO;GACvC,OAAO,IAAI,cAAc,QAAQ,KAAK;EACvC;EACA,KAAK,QAAQ;GACZ,MAAM,EAAE,gBAAgB,MAAM,OAAO;GACrC,OAAO,IAAI,YAAY,MAAM;EAC9B;EACA,KAAK,OAAO;GACX,MAAM,EAAE,eAAe,MAAM,OAAO;GACpC,OAAO,IAAI,WAAW,MAAM;EAC7B;EACA,KAAK,QAAQ;GACZ,MAAM,EAAE,gBAAgB,MAAM,OAAO;GACrC,OAAO,IAAI,YAAY,MAAM;EAC9B;CACD;AACD;;;;;AC7BA,IAAa,UAAb,cAA6B,aAA4B;CAKpB;CAJpC,AAAS;CACT,AAAS;CACT,WAA8C;CAE9C,AAAO,YAAY,AAAiB,QAA6B;EAChE,MAAM;EAD6B;EAEnC,KAAK,SAAS,KAAK,OAAO,MAAM,OAAO,SAAS;EAChD,KAAK,cAAc,KAAK,OAAO,MAAM,QAAQ,SAAS;CACvD;CAEA,AAAO,OAAgB;EACtB,IAAI,KAAK,OAAO,MAAM,SAAS,UAAU,CAAC,WAAW,KAAK,MAAM,GAAG,OAAO;EAC1E,UAAU,KAAK,aAAa,EAAE,WAAW,KAAK,CAAC;EAC/C,OAAO,KAAK,QAAQ,KAAK,aAAa;GAAE,WAAW;GAAM,OAAO;EAAK,CAAC;EACtE,OAAO;CACR;CAEA,MAAa,QAAuB;EACnC,IAAI,KAAK,OAAO,MAAM,SAAS,UAAU,CAAC,WAAW,KAAK,MAAM,KAAK,KAAK,UAAU;EACpF,MAAM,EAAE,UAAU,MAAM,OAAO;EAC/B,MAAM,UAAU,MAAM,KAAK,QAAQ,EAAE,eAAe,KAAK,CAAC;EAC1D,KAAK,WAAW;EAEhB,QAAQ,GAAG,QAAQ,OAAO,SAAS;GAClC,IAAI;IACH,MAAM,SAAS,KAAK,KAAK,aAAa,SAAS,KAAK,QAAQ,IAAI,CAAC;IACjE,IAAI,UAAU,YAAY,UAAU,aAAa,OAAO,QAAQ;KAAE,WAAW,UAAU;KAAa,OAAO;IAAK,CAAC;SAC5G,IAAI,WAAW,IAAI,GAAG;KAC1B,UAAU,QAAQ,MAAM,GAAG,EAAE,WAAW,KAAK,CAAC;KAC9C,OAAO,MAAM,QAAQ;MAAE,WAAW,UAAU;MAAU,OAAO;KAAK,CAAC;IACpE;IACA,KAAK,KAAK,QAAQ;GACnB,SAAS,OAAO;IACf,KAAK,KAAK,OAAO,SAAS,2BAA2B,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GAAG;GAC9G;EACD,CAAC;EACD,QAAQ,GAAG,UAAU,UAAU,KAAK,KAAK,OAAO,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC,CAAC;EAChH,MAAM,IAAI,SAAe,YAAY,QAAQ,KAAK,SAAS,OAAO,CAAC;CACpE;CAEA,MAAa,QAAuB;EACnC,MAAM,UAAU,KAAK;EACrB,KAAK,WAAW;EAChB,MAAM,SAAS,MAAM;CACtB;AACD"}
|
|
@@ -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-DBqQMFCk.js";
|
|
3
3
|
import { NitroBuilder as NitroBuilder$1 } from "@wolfstar/nitro-server";
|
|
4
4
|
|
|
5
5
|
//#region src/builders/nitro.ts
|
|
@@ -15,4 +15,4 @@ var NitroBuilder = class extends NitroBuilder$1 {
|
|
|
15
15
|
|
|
16
16
|
//#endregion
|
|
17
17
|
export { NitroBuilder };
|
|
18
|
-
//# sourceMappingURL=nitro-
|
|
18
|
+
//# sourceMappingURL=nitro-DufOgx8s.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nitro-
|
|
1
|
+
{"version":3,"file":"nitro-DufOgx8s.js","names":["ServerBuilder"],"sources":["../src/builders/nitro.ts"],"sourcesContent":["import { NitroBuilder as ServerBuilder } from '@wolfstar/nitro-server';\nimport type { ResolvedStarsConfig } from '@wolfstar/schema';\nimport { pluginRegistrations } from '../utils/plugin-registrations.js';\nimport { importFromProject } from '../utils/project.js';\n\n/** Connect the server integration to the CLI's diagnostics and plugin discovery. */\nexport class NitroBuilder extends ServerBuilder {\n\tpublic constructor(config: ResolvedStarsConfig) {\n\t\tsuper(config, { importFromProject, pluginRegistrations });\n\t}\n}\n"],"mappings":";;;;;;AAMA,IAAa,eAAb,cAAkCA,eAAc;CAC/C,AAAO,YAAY,QAA6B;EAC/C,MAAM,QAAQ;GAAE;GAAmB;EAAoB,CAAC;CACzD;AACD"}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { i as shouldUseColor } from "./output-mode-Bp7Da8vJ.js";
|
|
2
|
-
import { t as cliDiagnostics } from "./diagnostics-
|
|
3
|
-
import { d as resolveCwd, n as loadProject, u as projectArgs } from "./hooks-
|
|
4
|
-
import { n as reportWarnings, t as prepareProject } from "./_shared-
|
|
2
|
+
import { t as cliDiagnostics } from "./diagnostics-Dn3CXa8J.js";
|
|
3
|
+
import { d as resolveCwd, n as loadProject, u as projectArgs } from "./hooks-D_RVS0ba.js";
|
|
4
|
+
import { n as reportWarnings, t as prepareProject } from "./_shared-CyzTojMA.js";
|
|
5
5
|
import { defineCommand } from "citty";
|
|
6
6
|
import { displayPath } from "@wolfstar/schema";
|
|
7
7
|
import { createColors } from "colorette";
|
|
8
8
|
|
|
9
9
|
//#region src/commands/prepare.ts
|
|
10
10
|
/**
|
|
11
|
-
* Generates `.stars/tsconfig.json` and
|
|
11
|
+
* Generates `.stars/tsconfig.app.json` and `.stars/tsconfig.node.json` (a single `.stars/tsconfig.json` below
|
|
12
|
+
* compatibility version 6) and `imports.dts` (see {@link StarsImportsConfig} in `@wolfstar/schema`), the way `nuxt
|
|
12
13
|
* prepare` regenerates `.nuxt/imports.d.ts`. Run automatically by `stars dev` and `stars build` before the first
|
|
13
14
|
* build; `--check` fails instead of writing, for CI.
|
|
14
15
|
*/
|
|
@@ -23,8 +24,11 @@ async function runPrepare(options) {
|
|
|
23
24
|
const result = await prepareProject(config, hooks, Boolean(options.check));
|
|
24
25
|
if (options.json) stdout.write(`${JSON.stringify(result, null, 2)}\n`);
|
|
25
26
|
else {
|
|
26
|
-
const
|
|
27
|
-
|
|
27
|
+
for (const file of result.tsconfigs) {
|
|
28
|
+
const paintConfig = file.status === "outdated" ? colors.red : colors.green;
|
|
29
|
+
const label = file.name === "tsconfig" ? "tsconfig" : `tsconfig ${file.name}`;
|
|
30
|
+
stdout.write(`${colors.dim("stars")} ${label}: ${paintConfig(file.status)} ${displayPath(config.root, file.path)}\n`);
|
|
31
|
+
}
|
|
28
32
|
if (result.modules) {
|
|
29
33
|
const paint = result.modules.status === "outdated" ? colors.red : colors.green;
|
|
30
34
|
stdout.write(`${colors.dim("stars")} modules: ${paint(result.modules.status)} ${displayPath(config.root, result.modules.path)}\n`);
|
|
@@ -34,7 +38,7 @@ async function runPrepare(options) {
|
|
|
34
38
|
stdout.write(`${colors.dim("stars")} imports: ${paint(result.status)} ${displayPath(config.root, result.dts)}\n`);
|
|
35
39
|
}
|
|
36
40
|
}
|
|
37
|
-
if (result.status === "outdated" || result.
|
|
41
|
+
if (result.status === "outdated" || result.tsconfigs.some((file) => file.status === "outdated") || result.modules?.status === "outdated") throw cliDiagnostics.PREPARE_OUTDATED({});
|
|
38
42
|
}
|
|
39
43
|
var prepare_default = defineCommand({
|
|
40
44
|
meta: {
|
|
@@ -66,4 +70,4 @@ var prepare_default = defineCommand({
|
|
|
66
70
|
|
|
67
71
|
//#endregion
|
|
68
72
|
export { prepare_default as default };
|
|
69
|
-
//# sourceMappingURL=prepare-
|
|
73
|
+
//# sourceMappingURL=prepare-DKH0UIYA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepare-DKH0UIYA.js","names":[],"sources":["../src/commands/prepare.ts"],"sourcesContent":["import { displayPath } from '@wolfstar/schema';\nimport { defineCommand } from 'citty';\nimport { createColors } from 'colorette';\nimport { projectArgs, resolveCwd, type ProjectArgs } from '../utils/args.js';\nimport { cliDiagnostics } from '../utils/diagnostics.js';\nimport { shouldUseColor } from '../utils/output-mode.js';\nimport { loadProject } from '../utils/hooks.js';\nimport { prepareProject, reportWarnings } from './_shared.js';\n\nexport { prepareProject } from './_shared.js';\n\nexport interface PrepareTaskOptions extends ProjectArgs {\n\tcheck?: boolean;\n\tjson?: boolean;\n\tstdout?: NodeJS.WritableStream;\n}\n\n/**\n * Generates `.stars/tsconfig.app.json` and `.stars/tsconfig.node.json` (a single `.stars/tsconfig.json` below\n * compatibility version 6) and `imports.dts` (see {@link StarsImportsConfig} in `@wolfstar/schema`), the way `nuxt\n * prepare` regenerates `.nuxt/imports.d.ts`. Run automatically by `stars dev` and `stars build` before the first\n * build; `--check` fails instead of writing, for CI.\n */\nexport async function runPrepare(options: PrepareTaskOptions): Promise<void> {\n\tconst stdout = options.stdout ?? process.stdout;\n\tconst colors = createColors({ useColor: shouldUseColor() && !options.json });\n\tconst { config, hooks } = await loadProject({ cwd: resolveCwd(options), configFile: options.config });\n\tawait reportWarnings(config, (text) => process.stderr.write(`${text}\\n`));\n\tconst result = await prepareProject(config, hooks, Boolean(options.check));\n\n\tif (options.json) {\n\t\tstdout.write(`${JSON.stringify(result, null, 2)}\\n`);\n\t} else {\n\t\tfor (const file of result.tsconfigs) {\n\t\t\tconst paintConfig = file.status === 'outdated' ? colors.red : colors.green;\n\t\t\tconst label = file.name === 'tsconfig' ? 'tsconfig' : `tsconfig ${file.name}`;\n\t\t\tstdout.write(`${colors.dim('stars')} ${label}: ${paintConfig(file.status)} ${displayPath(config.root, file.path)}\\n`);\n\t\t}\n\t\tif (result.modules) {\n\t\t\tconst paint = result.modules.status === 'outdated' ? colors.red : colors.green;\n\t\t\tstdout.write(`${colors.dim('stars')} modules: ${paint(result.modules.status)} ${displayPath(config.root, result.modules.path)}\\n`);\n\t\t}\n\t\tif (result.enabled) {\n\t\t\tconst paint = result.status === 'outdated' ? colors.red : colors.green;\n\t\t\tstdout.write(`${colors.dim('stars')} imports: ${paint(result.status)} ${displayPath(config.root, result.dts)}\\n`);\n\t\t}\n\t}\n\n\tif (result.status === 'outdated' || result.tsconfigs.some((file) => file.status === 'outdated') || result.modules?.status === 'outdated') {\n\t\tthrow cliDiagnostics.PREPARE_OUTDATED({});\n\t}\n}\n\nexport default defineCommand({\n\tmeta: {\n\t\tname: 'prepare',\n\t\tdescription: 'Generate TypeScript configuration and auto imports declarations'\n\t},\n\targs: {\n\t\t...projectArgs,\n\t\tcheck: {\n\t\t\ttype: 'boolean',\n\t\t\tdescription: 'Fail when the generated files are out of date instead of writing it',\n\t\t\tdefault: false\n\t\t},\n\t\tjson: {\n\t\t\ttype: 'boolean',\n\t\t\tdescription: 'Print machine-readable JSON',\n\t\t\tdefault: false\n\t\t}\n\t},\n\tasync run({ args }) {\n\t\tawait runPrepare({ config: args.config, cwd: args.cwd, check: args.check, json: args.json });\n\t}\n});\n"],"mappings":";;;;;;;;;;;;;;;AAuBA,eAAsB,WAAW,SAA4C;CAC5E,MAAM,SAAS,QAAQ,UAAU,QAAQ;CACzC,MAAM,SAAS,aAAa,EAAE,UAAU,eAAe,KA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