@wolfstar/cli 2.1.0 → 2.3.0-next-20261004131917
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 +203 -42
- package/dist/{_shared-B-hRZDRS.js → _shared-BIQK0Bhm.js} +12 -5
- package/dist/_shared-BIQK0Bhm.js.map +1 -0
- package/dist/bridge-BvkmlAOZ.js +410 -0
- package/dist/bridge-BvkmlAOZ.js.map +1 -0
- package/dist/{build-CPnSLYME.js → build-DJcc95Yq.js} +5 -5
- package/dist/{build-CPnSLYME.js.map → build-DJcc95Yq.js.map} +1 -1
- package/dist/cli.js +1 -1
- package/dist/{codegen-BqpLGLLs.js → codegen-aJSyPz-J.js} +4 -4
- package/dist/{codegen-BqpLGLLs.js.map → codegen-aJSyPz-J.js.map} +1 -1
- package/dist/command-diff-BK912Hjc.js +78 -0
- package/dist/command-diff-BK912Hjc.js.map +1 -0
- package/dist/commands-CIPWQtF0.js +3 -0
- package/dist/commands-Clpbqq3K.js +15 -0
- package/dist/commands-Clpbqq3K.js.map +1 -0
- package/dist/{commands-ExM8HILu.js → commands-DVC7ky6f.js} +259 -9
- package/dist/commands-DVC7ky6f.js.map +1 -0
- package/dist/completions-D2KYtrrv.js +161 -0
- package/dist/completions-D2KYtrrv.js.map +1 -0
- package/dist/{dev-4wpEQC7l.js → dev-oPPVR7d_.js} +432 -45
- package/dist/dev-oPPVR7d_.js.map +1 -0
- package/dist/{diagnostics-CZBVxlpj.js → diagnostics-BysbNnPD.js} +38 -1
- package/dist/diagnostics-BysbNnPD.js.map +1 -0
- package/dist/doctor-DkVUwgDd.js +334 -0
- package/dist/doctor-DkVUwgDd.js.map +1 -0
- package/dist/{errors-Crt4hu0b.js → errors-COFWKKKw.js} +5 -2
- package/dist/errors-COFWKKKw.js.map +1 -0
- package/dist/hooks-Cy6F2bhH.js +332 -0
- package/dist/hooks-Cy6F2bhH.js.map +1 -0
- package/dist/index.d.ts +75 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/{info-CdiQajgn.js → info-CKJVMWIT.js} +16 -5
- package/dist/info-CKJVMWIT.js.map +1 -0
- package/dist/{locales-C7X8VNmK.js → locales-BJAP4HYf.js} +5 -5
- package/dist/{locales-C7X8VNmK.js.map → locales-BJAP4HYf.js.map} +1 -1
- package/dist/log-view-B7uJEnMR.js +342 -0
- package/dist/log-view-B7uJEnMR.js.map +1 -0
- package/dist/{nitro-sP2F3SQu.js → nitro-B8u1iVgf.js} +2 -2
- package/dist/{nitro-sP2F3SQu.js.map → nitro-B8u1iVgf.js.map} +1 -1
- package/dist/{plain-B6z85uQP.js → plain-DG7cy0Kk.js} +7 -2
- package/dist/plain-DG7cy0Kk.js.map +1 -0
- package/dist/{prepare-B4ysyG6H.js → prepare-BM93i3Rm.js} +9 -5
- package/dist/prepare-BM93i3Rm.js.map +1 -0
- package/dist/{project-MD4dIo2X.js → project-zlQStwsf.js} +2 -2
- package/dist/{project-MD4dIo2X.js.map → project-zlQStwsf.js.map} +1 -1
- package/dist/{run-Ddwrxe1O.js → run-DMM2YlP3.js} +3 -13
- package/dist/run-DMM2YlP3.js.map +1 -0
- package/dist/{theme-3Fc_LI-2.js → theme-yS2h5dd_.js} +25 -1
- package/dist/theme-yS2h5dd_.js.map +1 -0
- package/dist/tsc-C5l5TQGC.js +3 -0
- package/dist/{tsc-DO7D_uCl.js → tsc-puVAcwmo.js} +24 -5
- package/dist/tsc-puVAcwmo.js.map +1 -0
- package/dist/{tsdown-CD68G8_U.js → tsdown-Dwt3JhPw.js} +2 -2
- package/dist/{tsdown-CD68G8_U.js.map → tsdown-Dwt3JhPw.js.map} +1 -1
- package/dist/{tui-BRddrLQP.js → tui-nldGSD4c.js} +913 -141
- package/dist/tui-nldGSD4c.js.map +1 -0
- package/dist/{vite-CLyB6wl7.js → vite-YZUtv2Hk.js} +2 -2
- package/dist/{vite-CLyB6wl7.js.map → vite-YZUtv2Hk.js.map} +1 -1
- package/package.json +5 -4
- package/dist/_shared-B-hRZDRS.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/log-buffer-CY82aqnb.js +0 -72
- package/dist/log-buffer-CY82aqnb.js.map +0 -1
- package/dist/plain-B6z85uQP.js.map +0 -1
- package/dist/prepare-B4ysyG6H.js.map +0 -1
- package/dist/run-Ddwrxe1O.js.map +0 -1
- package/dist/theme-3Fc_LI-2.js.map +0 -1
- package/dist/tsc-DO7D_uCl.js.map +0 -1
- package/dist/tsc-YnAWKn3n.js +0 -3
- package/dist/tui-BRddrLQP.js.map +0 -1
- package/dist/tunnel-DT1FH6oA.js +0 -175
- package/dist/tunnel-DT1FH6oA.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doctor-DkVUwgDd.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 { 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\tprepared.tsconfig.status === 'outdated' ? show(prepared.tsconfig.path) : null,\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} 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":";;;;;;;;;;;;;;;;AAyCA,MAAM,eAAe;;;;;;AAOrB,eAAsB,cAAc,QAA6B,OAAsB,UAAyB,CAAC,GAAqB;CACrI,MAAM,MAAM,QAAQ,OAAO,QAAQ;CACnC,MAAM,SAAkB,CAAC;CACzB,MAAM,QAAQ,SAAiB,YAAY,OAAO,MAAM,IAAI;CAE5D,MAAM,OAAO,QAAQ,eAAe,QAAQ;CAC5C,MAAM,QAAQ,OAAO,SAAS,KAAK,QAAQ,MAAM,EAAE,GAAG,EAAE;CACxD,OAAO,KACN,SAAS,eACN;EAAE,MAAM;EAAQ,QAAQ;EAAM,SAAS,WAAW;CAAO,IACzD;EAAE,MAAM;EAAQ,QAAQ;EAAS,SAAS,WAAW,KAAK;EAAc,KAAK,eAAe,aAAa;CAAY,CACzH;CACA,MAAM,SAAS,gBAAgB,OAAO,IAAI;CAC1C,MAAM,UAAU,WAAW,OAAO,OAAO,iBAAiB,KAAK,MAAM;CACrE,IAAI,WAAW,QAAQ,OAAO,QAAQ,EAAE,GACvC,OAAO,KAAK;EACX,MAAM;EACN,QAAQ;EACR,SAAS,gCAAgC,OAAO,YAAY;EAC5D,KAAK,eAAe,OAAO;CA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AQ,QAAQ,KAAK,CACzC,GAAG,QAAQ,OAAO,OAAO;CACjE,MAAM,SAAS,OAAO,QAAQ,UAAU,MAAM,WAAW,OAAO,CAAC,CAAC;CAElE,OAAO,MAAM,GAAG,QAAQ,OAAO,KAAK,UAAU;EAAE,IAAI,WAAW;EAAG;CAAO,GAAG,MAAM,CAAC,IAAI,aAAa,QAAQ,eAAe,CAAC,EAAE,GAAG;CACjI,IAAI,SAAS,GAAG,MAAM,eAAe,cAAc,EAAE,OAAO,OAAO,CAAC;AACrE;AAEA,qBAAe,cAAc;CAC5B,MAAM;EACL,MAAM;EACN,aAAa;CACd;CACA,MAAM;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"}
|
|
@@ -16,7 +16,10 @@ const ExitCode = {
|
|
|
16
16
|
/** Every `stars.config.*` diagnostic code maps to {@link ExitCode.InvalidConfig}; everything else defaults to `Error`. */
|
|
17
17
|
const CONFIG_DIAGNOSTIC_CODES = new Set(Object.keys(configDiagnostics));
|
|
18
18
|
/** CLI-local diagnostic codes whose exit code isn't the default {@link ExitCode.Error}. */
|
|
19
|
-
const CLI_EXIT_CODES = {
|
|
19
|
+
const CLI_EXIT_CODES = {
|
|
20
|
+
BUILD_FAILED: ExitCode.BuildFailed,
|
|
21
|
+
MODULE_FAILED: ExitCode.InvalidConfig
|
|
22
|
+
};
|
|
20
23
|
/**
|
|
21
24
|
* Formats an error for the terminal: a `Diagnostic` (from `stars.config.*` validation, via
|
|
22
25
|
* `@wolfstar/schema`'s `configDiagnostics`, or from the CLI's own `cliDiagnostics`) renders through
|
|
@@ -53,4 +56,4 @@ function exitCodeOf(error) {
|
|
|
53
56
|
|
|
54
57
|
//#endregion
|
|
55
58
|
export { renderCrashReport as i, exitCodeOf as n, formatError as r, ExitCode as t };
|
|
56
|
-
//# sourceMappingURL=errors-
|
|
59
|
+
//# sourceMappingURL=errors-COFWKKKw.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors-COFWKKKw.js","names":[],"sources":["../src/utils/errors.ts"],"sourcesContent":["import { configDiagnostics } from '@wolfstar/schema';\nimport { createColors } from 'colorette';\nimport { Diagnostic } from 'nostics';\nimport { ansiFormatter } from 'nostics/formatters/ansi';\nimport { shouldUseColor } from './output-mode.js';\n\nexport const ExitCode = {\n\tOk: 0,\n\tError: 1,\n\tInvalidConfig: 2,\n\tBuildFailed: 3,\n\tInterrupted: 130,\n\tTerminated: 143\n} as const;\n\nexport type ExitCode = (typeof ExitCode)[keyof typeof ExitCode];\n\n/** Every `stars.config.*` diagnostic code maps to {@link ExitCode.InvalidConfig}; everything else defaults to `Error`. */\nconst CONFIG_DIAGNOSTIC_CODES = new Set<string>(Object.keys(configDiagnostics));\n\n/** CLI-local diagnostic codes whose exit code isn't the default {@link ExitCode.Error}. */\nconst CLI_EXIT_CODES: Partial<Record<string, ExitCode>> = {\n\tBUILD_FAILED: ExitCode.BuildFailed,\n\tMODULE_FAILED: ExitCode.InvalidConfig\n};\n\n/**\n * Formats an error for the terminal: a `Diagnostic` (from `stars.config.*` validation, via\n * `@wolfstar/schema`'s `configDiagnostics`, or from the CLI's own `cliDiagnostics`) renders through\n * nostics' own ANSI formatter — message, `fix`, `sources` and `docs` — everything else falls back to a crash report.\n */\nexport async function formatError(error: unknown): Promise<string> {\n\tif (error instanceof Diagnostic) {\n\t\tconst colors = createColors({ useColor: shouldUseColor() });\n\t\treturn ansiFormatter(colors)(error);\n\t}\n\n\t// citty's CLIError (unknown command, missing argument): the message is enough.\n\tif (error instanceof Error && error.name === 'CLIError') return error.message;\n\tif (error instanceof Error) return renderCrashReport(error);\n\treturn String(error);\n}\n\n/**\n * Renders an unexpected error (a bug, not something the CLI already explains through a `Diagnostic`) as a\n * sourcemapped, syntax-highlighted report — frames and a snippet of the original source instead of a stack trace\n * pointing into the bundled `dist/cli.js`.\n */\nexport async function renderCrashReport(error: unknown, cwd: string = process.cwd()): Promise<string> {\n\tconst { createReport, fsLoader, renderAnsi } = await import('my-bad');\n\tconst report = await createReport(error, { cwd, loaders: [fsLoader()] });\n\treturn renderAnsi(report, { cwd });\n}\n\nexport function exitCodeOf(error: unknown): ExitCode {\n\tif (error instanceof Diagnostic) {\n\t\tif (CONFIG_DIAGNOSTIC_CODES.has(error.code)) return ExitCode.InvalidConfig;\n\t\treturn CLI_EXIT_CODES[error.code] ?? ExitCode.Error;\n\t}\n\n\treturn ExitCode.Error;\n}\n"],"mappings":";;;;;;;AAMA,MAAa,WAAW;CACvB,IAAI;CACJ,OAAO;CACP,eAAe;CACf,aAAa;CACb,aAAa;CACb,YAAY;AACb;;AAKA,MAAM,0BAA0B,IAAI,IAAY,OAAO,KAAK,iBAAiB,CAAC;;AAG9E,MAAM,iBAAoD;CACzD,cAAc,SAAS;CACvB,eAAe,SAAS;AACzB;;;;;;AAOA,eAAsB,YAAY,OAAiC;CAClE,IAAI,iBAAiB,YAAY;EAChC,MAAM,SAAS,aAAa,EAAE,UAAU,eAAe,EAAE,CAAC;EAC1D,OAAO,cAAc,MAAM,CAAC,CAAC,KAAK;CACnC;CAGA,IAAI,iBAAiB,SAAS,MAAM,SAAS,YAAY,OAAO,MAAM;CACtE,IAAI,iBAAiB,OAAO,OAAO,kBAAkB,KAAK;CAC1D,OAAO,OAAO,KAAK;AACpB;;;;;;AAOA,eAAsB,kBAAkB,OAAgB,MAAc,QAAQ,IAAI,GAAoB;CACrG,MAAM,EAAE,cAAc,UAAU,eAAe,MAAM,OAAO;CAE5D,OAAO,WAAW,MADG,aAAa,OAAO;EAAE;EAAK,SAAS,CAAC,SAAS,CAAC;CAAE,CAAC,GAC7C,EAAE,IAAI,CAAC;AAClC;AAEA,SAAgB,WAAW,OAA0B;CACpD,IAAI,iBAAiB,YAAY;EAChC,IAAI,wBAAwB,IAAI,MAAM,IAAI,GAAG,OAAO,SAAS;EAC7D,OAAO,eAAe,MAAM,SAAS,SAAS;CAC/C;CAEA,OAAO,SAAS;AACjB"}
|
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
import { t as readOwnPackageJson } from "./version-BzclCE19.js";
|
|
2
|
+
import { t as cliDiagnostics } from "./diagnostics-BysbNnPD.js";
|
|
3
|
+
import { i as resolveFromProject, r as resolveBinary, t as findInstalledVersion } from "./project-zlQStwsf.js";
|
|
4
|
+
import { isAbsolute, join, resolve } from "node:path";
|
|
5
|
+
import { pathToFileURL } from "node:url";
|
|
6
|
+
import { loadConfigFile, readProjectEnvFiles, resolveStarsConfig } from "@wolfstar/schema";
|
|
7
|
+
import { envModuleSource, modulesModuleSource } from "@wolfstar/vite-server/internal";
|
|
8
|
+
import { execFileSync } from "node:child_process";
|
|
9
|
+
import { resolve as resolve$1, resolveSync } from "mlly";
|
|
10
|
+
import { createHooks } from "hookable";
|
|
11
|
+
import { ModuleError, setupModules } from "@wolfstar/kit";
|
|
12
|
+
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
13
|
+
|
|
14
|
+
//#region src/utils/args.ts
|
|
15
|
+
/**
|
|
16
|
+
* Arguments shared by every command that reads the project configuration.
|
|
17
|
+
*/
|
|
18
|
+
const projectArgs = {
|
|
19
|
+
config: {
|
|
20
|
+
type: "string",
|
|
21
|
+
alias: "c",
|
|
22
|
+
description: "Path to the configuration file (defaults to stars.config.* in the working directory)"
|
|
23
|
+
},
|
|
24
|
+
cwd: {
|
|
25
|
+
type: "string",
|
|
26
|
+
description: "Working directory to run from (defaults to the current directory)"
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Every value of a flag given more than once (`--channel a --channel=b`). citty keeps only the last one of a
|
|
31
|
+
* repeated string flag, so a repeatable flag reads the raw arguments.
|
|
32
|
+
*/
|
|
33
|
+
function collectFlag(rawArgs, name) {
|
|
34
|
+
const values = [];
|
|
35
|
+
for (const [index, argument] of rawArgs.entries()) {
|
|
36
|
+
if (argument === "--") break;
|
|
37
|
+
if (argument.startsWith(`--${name}=`)) values.push(argument.slice(name.length + 3));
|
|
38
|
+
else if (argument === `--${name}`) {
|
|
39
|
+
const next = rawArgs[index + 1];
|
|
40
|
+
if (next !== void 0 && !next.startsWith("-")) values.push(next);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return values;
|
|
44
|
+
}
|
|
45
|
+
function resolveCwd(args) {
|
|
46
|
+
return args.cwd ? resolve(process.cwd(), args.cwd) : process.cwd();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
//#endregion
|
|
50
|
+
//#region src/utils/env-import.ts
|
|
51
|
+
/** Build tools whose output never passes through the entry transform that registers `env`. */
|
|
52
|
+
const UNTRANSFORMED_TOOLS = /* @__PURE__ */ new Set(["none", "tsc"]);
|
|
53
|
+
/**
|
|
54
|
+
* `node` arguments that register `env` before the entry runs, for the build tools the entry transform cannot reach.
|
|
55
|
+
* The preload is a `data:` URL, so `.stars/` gets no generated runtime file; a `data:` URL cannot resolve bare
|
|
56
|
+
* specifiers, so `@wolfstar/env-utilities` is resolved from the project first. When it cannot be resolved nothing is
|
|
57
|
+
* preloaded, and the bot's own import of it reports the missing install.
|
|
58
|
+
*/
|
|
59
|
+
function envImportArgs(config) {
|
|
60
|
+
if (!config.env.enabled || !UNTRANSFORMED_TOOLS.has(config.build.tool)) return [];
|
|
61
|
+
const resolved = resolveFromProject(config.root, "@wolfstar/env-utilities");
|
|
62
|
+
if (resolved === null) return [];
|
|
63
|
+
const source = envModuleSource(config.env.options, pathToFileURL(resolved).href);
|
|
64
|
+
return ["--import", `data:text/javascript,${encodeURIComponent(source)}`];
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* `node` arguments that register the runtime plugins of the installed modules (`ctx.addPlugin`) before the entry
|
|
68
|
+
* runs, for the build tools the entry transform cannot reach. `@wolfstar/http-framework` and every plugin are resolved
|
|
69
|
+
* from the project first, with the `import` condition (both are ESM), because a `data:` URL cannot resolve bare
|
|
70
|
+
* specifiers; the framework is the bot's own copy, so `Client.use` reaches the `Client` the bot constructs. When the
|
|
71
|
+
* framework is not installed nothing is preloaded, and the bot's own import of it reports the missing install.
|
|
72
|
+
*/
|
|
73
|
+
function moduleImportArgs(config) {
|
|
74
|
+
const plugins = config.runtime?.plugins ?? [];
|
|
75
|
+
if (plugins.length === 0 || !UNTRANSFORMED_TOOLS.has(config.build.tool)) return [];
|
|
76
|
+
const url = pathToFileURL(`${config.root}/package.json`).href;
|
|
77
|
+
let framework;
|
|
78
|
+
try {
|
|
79
|
+
framework = resolveSync("@wolfstar/http-framework", { url });
|
|
80
|
+
} catch {
|
|
81
|
+
return [];
|
|
82
|
+
}
|
|
83
|
+
const source = modulesModuleSource(plugins, {
|
|
84
|
+
framework,
|
|
85
|
+
resolve: (from) => {
|
|
86
|
+
if (from.startsWith("file:")) return from;
|
|
87
|
+
if (isAbsolute(from)) return pathToFileURL(from).href;
|
|
88
|
+
try {
|
|
89
|
+
return resolveSync(from, { url });
|
|
90
|
+
} catch {
|
|
91
|
+
throw cliDiagnostics.DEPENDENCY_MISSING({
|
|
92
|
+
name: from,
|
|
93
|
+
root: config.root,
|
|
94
|
+
hint: "Install the package of the module that registers this plugin."
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
return ["--import", `data:text/javascript,${encodeURIComponent(source)}`];
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
//#endregion
|
|
103
|
+
//#region src/utils/modules.ts
|
|
104
|
+
/**
|
|
105
|
+
* Where a module specifier is imported from: a relative or absolute path is a file of the project, a `file:` URL is
|
|
106
|
+
* itself, anything else is a package resolved from the project root — with `mlly`, honouring the `import` condition,
|
|
107
|
+
* because installed modules are ESM-only packages a CommonJS `require.resolve` cannot see.
|
|
108
|
+
*/
|
|
109
|
+
async function resolveSpecifier(root, specifier) {
|
|
110
|
+
if (specifier.startsWith("file:")) return specifier;
|
|
111
|
+
if (specifier.startsWith(".") || isAbsolute(specifier)) return pathToFileURL(resolve(root, specifier)).href;
|
|
112
|
+
return resolve$1(specifier, { url: pathToFileURL(`${root}/package.json`).href });
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Runs `setup` of every module in `modules` (see `@wolfstar/kit`) and returns the configuration carrying what they
|
|
116
|
+
* contributed: `runtime`, and `imports.presets` extended by `ctx.addImports`. Without modules the configuration is
|
|
117
|
+
* returned as it is.
|
|
118
|
+
*/
|
|
119
|
+
async function installModules(config, hooks) {
|
|
120
|
+
if (config.modules.length === 0) return config;
|
|
121
|
+
try {
|
|
122
|
+
const runtime = await setupModules({
|
|
123
|
+
config,
|
|
124
|
+
hooks,
|
|
125
|
+
versions: {
|
|
126
|
+
framework: findInstalledVersion(config.root, "@wolfstar/http-framework"),
|
|
127
|
+
stars: readOwnPackageJson().version
|
|
128
|
+
},
|
|
129
|
+
load: async (specifier) => import(await resolveSpecifier(config.root, specifier))
|
|
130
|
+
});
|
|
131
|
+
const presets = [...config.imports.presets, ...runtime.imports.filter((preset) => !config.imports.presets.includes(preset))];
|
|
132
|
+
return {
|
|
133
|
+
...config,
|
|
134
|
+
runtime,
|
|
135
|
+
imports: {
|
|
136
|
+
...config.imports,
|
|
137
|
+
presets
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
} catch (error) {
|
|
141
|
+
if (error instanceof ModuleError) throw cliDiagnostics.MODULE_FAILED({
|
|
142
|
+
module: error.moduleName,
|
|
143
|
+
reason: error.code,
|
|
144
|
+
message: error.message,
|
|
145
|
+
cause: error
|
|
146
|
+
});
|
|
147
|
+
throw error;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* The warning for a project whose runtime plugins reach production only through a `node --import` preload, `null`
|
|
152
|
+
* otherwise. It is not one of `config.warnings`: `stars dev` preloads the plugins itself, so there it would be noise
|
|
153
|
+
* on every start. `stars build` and `stars prepare` report it.
|
|
154
|
+
*/
|
|
155
|
+
function modulesPreloadWarning(config) {
|
|
156
|
+
if (!needsPreload(config)) return null;
|
|
157
|
+
return cliDiagnostics.MODULES_PRELOAD_REQUIRED({
|
|
158
|
+
tool: config.build.tool,
|
|
159
|
+
plugins: [...new Set(config.runtime.plugins.map((plugin) => plugin.module))].join(", ")
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
/** A build tool the entry transform cannot reach, with runtime plugins to register: they need a `node --import` preload. */
|
|
163
|
+
function needsPreload(config) {
|
|
164
|
+
return UNTRANSFORMED_TOOLS.has(config.build.tool) && (config.runtime?.plugins.length ?? 0) > 0;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Writes `.stars/modules.mjs`, the production counterpart of the preload `stars dev` passes to `node`: `node --import
|
|
168
|
+
* ./.stars/modules.mjs <entry>` registers the runtime plugins of the installed modules for the build tools whose entry
|
|
169
|
+
* cannot be transformed (`tsc`, `none`). Its specifiers are bare, so they resolve from the project's `node_modules`
|
|
170
|
+
* like the bot's own imports. `null` when there is nothing to register.
|
|
171
|
+
*
|
|
172
|
+
* With `env` enabled it is preceded by `.stars/env.mjs`, a separate module imported first: imports of one module are
|
|
173
|
+
* all evaluated before its body runs, so the environment could not be loaded ahead of the plugins from the same file,
|
|
174
|
+
* and a plugin reading `process.env` while it is imported would see nothing.
|
|
175
|
+
*/
|
|
176
|
+
async function prepareModulesPreload(config, check = false) {
|
|
177
|
+
if (!needsPreload(config)) return null;
|
|
178
|
+
const directory = join(config.root, ".stars");
|
|
179
|
+
const path = join(directory, "modules.mjs");
|
|
180
|
+
const withEnv = config.env?.enabled === true;
|
|
181
|
+
const plugins = modulesModuleSource(config.runtime.plugins, { resolve: (from) => isAbsolute(from) ? pathToFileURL(from).href : from });
|
|
182
|
+
const files = [{
|
|
183
|
+
path,
|
|
184
|
+
content: withEnv ? `import "./env.mjs";\n${plugins}` : plugins
|
|
185
|
+
}, ...withEnv ? [{
|
|
186
|
+
path: join(directory, "env.mjs"),
|
|
187
|
+
content: envModuleSource(config.env.options)
|
|
188
|
+
}] : []];
|
|
189
|
+
if (check) return {
|
|
190
|
+
path,
|
|
191
|
+
status: (await Promise.all(files.map(async (file) => await readFile(file.path, "utf-8").catch(() => null) === file.content))).every(Boolean) ? "up-to-date" : "outdated"
|
|
192
|
+
};
|
|
193
|
+
await mkdir(directory, { recursive: true });
|
|
194
|
+
await Promise.all(files.map((file) => writeFile(file.path, file.content)));
|
|
195
|
+
return {
|
|
196
|
+
path,
|
|
197
|
+
status: "written"
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
//#endregion
|
|
202
|
+
//#region src/utils/project-env.ts
|
|
203
|
+
/**
|
|
204
|
+
* The variables the bot will load, for the CLI's own lookups (Discord credentials for the tunnel). With the default
|
|
205
|
+
* loader these are the project's env files, read from `env.path`/`env.env`. With `loader: 'varlock'` they are what
|
|
206
|
+
* `varlock load` resolves from the project's `.env.schema` — a dotenv file may be stale or absent there — and nothing
|
|
207
|
+
* when varlock cannot be run, rather than values the bot never sees.
|
|
208
|
+
*/
|
|
209
|
+
function readProjectEnv(config) {
|
|
210
|
+
const { path, env = "development", loader } = config.env.options;
|
|
211
|
+
if (loader !== "varlock") return readProjectEnvFiles(config.root, env, { path });
|
|
212
|
+
const binary = resolveBinary(config.root, "varlock", "varlock");
|
|
213
|
+
if (binary === null) return {};
|
|
214
|
+
try {
|
|
215
|
+
const output = execFileSync(process.execPath, [
|
|
216
|
+
binary,
|
|
217
|
+
"load",
|
|
218
|
+
"--format",
|
|
219
|
+
"json"
|
|
220
|
+
], {
|
|
221
|
+
cwd: config.root,
|
|
222
|
+
env: {
|
|
223
|
+
...process.env,
|
|
224
|
+
...config.dev.env,
|
|
225
|
+
NODE_ENV: "development"
|
|
226
|
+
},
|
|
227
|
+
encoding: "utf8",
|
|
228
|
+
stdio: [
|
|
229
|
+
"ignore",
|
|
230
|
+
"pipe",
|
|
231
|
+
"ignore"
|
|
232
|
+
],
|
|
233
|
+
timeout: 3e4
|
|
234
|
+
});
|
|
235
|
+
const values = JSON.parse(output);
|
|
236
|
+
return Object.fromEntries(Object.entries(values).filter(([, value]) => value !== void 0 && value !== null).map(([key, value]) => [key, String(value)]));
|
|
237
|
+
} catch {
|
|
238
|
+
return {};
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
//#endregion
|
|
243
|
+
//#region src/utils/hooks.ts
|
|
244
|
+
/** What each configuration loaded by {@link loadProject} was resolved from, so `env:options` can re-resolve it. */
|
|
245
|
+
const sources = /* @__PURE__ */ new WeakMap();
|
|
246
|
+
/** Registers the `hooks` of `stars.config` on a fresh `hookable` instance. */
|
|
247
|
+
function createStarsHooks(config) {
|
|
248
|
+
const hooks = createHooks();
|
|
249
|
+
for (const [name, callbacks] of Object.entries(config.hooks)) for (const callback of callbacks) hooks.hook(name, callback);
|
|
250
|
+
return hooks;
|
|
251
|
+
}
|
|
252
|
+
/** Loads `stars.config`, registers its hooks and runs `config:resolved`. */
|
|
253
|
+
async function loadProject(options) {
|
|
254
|
+
const cwd = options.cwd ?? process.cwd();
|
|
255
|
+
const loaded = await loadConfigFile({
|
|
256
|
+
cwd,
|
|
257
|
+
configFile: options.configFile
|
|
258
|
+
});
|
|
259
|
+
const source = {
|
|
260
|
+
cwd,
|
|
261
|
+
configFile: loaded.configFile,
|
|
262
|
+
config: loaded.config,
|
|
263
|
+
env: options.env
|
|
264
|
+
};
|
|
265
|
+
const resolved = resolveStarsConfig(source);
|
|
266
|
+
const hooks = createStarsHooks(resolved);
|
|
267
|
+
const config = await installModules(resolved, hooks);
|
|
268
|
+
sources.set(config, source);
|
|
269
|
+
await hooks.callHook("config:resolved", config);
|
|
270
|
+
return {
|
|
271
|
+
config,
|
|
272
|
+
hooks
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Runs `env:options` on a copy of the resolved `env` options and returns a configuration carrying the result, which
|
|
277
|
+
* is what the builders write into the entry. The resolved configuration itself is left untouched.
|
|
278
|
+
*
|
|
279
|
+
* When the hook changes the options, the configuration is resolved again with them, so everything read from the env
|
|
280
|
+
* files — the default `dev.url` port above all — matches what the bot will load.
|
|
281
|
+
*/
|
|
282
|
+
async function applyEnvOptions(config, hooks) {
|
|
283
|
+
if (!config.env.enabled) return config;
|
|
284
|
+
const options = { ...config.env.options };
|
|
285
|
+
await hooks.callHook("env:options", options, config);
|
|
286
|
+
const source = sources.get(config);
|
|
287
|
+
if (source === void 0 || JSON.stringify(options) === JSON.stringify(config.env.options)) return {
|
|
288
|
+
...config,
|
|
289
|
+
env: {
|
|
290
|
+
...config.env,
|
|
291
|
+
options
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
return reresolve(config, source, { config: {
|
|
295
|
+
...source.config,
|
|
296
|
+
env: {
|
|
297
|
+
...options,
|
|
298
|
+
enabled: true
|
|
299
|
+
}
|
|
300
|
+
} });
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* With `loader: 'varlock'`, resolves the configuration again with the variables `varlock load` returns, so the
|
|
304
|
+
* defaults `stars.config` derives from the environment — the `dev.url` port — match what the bot loads. Every other
|
|
305
|
+
* configuration is returned as-is: the schema reads its env files directly.
|
|
306
|
+
*/
|
|
307
|
+
function withProjectEnv(config) {
|
|
308
|
+
const source = sources.get(config);
|
|
309
|
+
if (source === void 0 || !config.env.enabled || config.env.options.loader !== "varlock") return config;
|
|
310
|
+
return reresolve(config, source, { projectEnv: readProjectEnv(config) });
|
|
311
|
+
}
|
|
312
|
+
function reresolve(previous, source, change) {
|
|
313
|
+
const next = {
|
|
314
|
+
...source,
|
|
315
|
+
...change
|
|
316
|
+
};
|
|
317
|
+
const resolved = resolveStarsConfig(next);
|
|
318
|
+
const config = {
|
|
319
|
+
...resolved,
|
|
320
|
+
runtime: previous.runtime,
|
|
321
|
+
imports: {
|
|
322
|
+
...resolved.imports,
|
|
323
|
+
presets: previous.imports.presets
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
sources.set(config, next);
|
|
327
|
+
return config;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
//#endregion
|
|
331
|
+
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-Cy6F2bhH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks-Cy6F2bhH.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 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 */\nexport async function installModules(config: ResolvedStarsConfig, hooks: StarsHookable): Promise<ResolvedStarsConfig> {\n\tif (config.modules.length === 0) return config;\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\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;CAC1B,KAAK,MAAM,CAAC,OAAO,aAAa,QAAQ,QAAQ,GAAG;EAClD,IAAI,aAAa,MAAM;EACvB,IAAI,SAAS,WAAW,KAAK,KAAK,EAAE,GAAG,OAAO,KAAK,SAAS,MAAM,KAAK,SAAS,CAAC,CAAC;OAC7E,IAAI,aAAa,KAAK,QAAQ;GAClC,MAAM,OAAO,QAAQ,QAAQ;GAC7B,IAAI,SAAS,UAAa,CAAC,KAAK,WAAW,GAAG,GAAG,OAAO,KAAK,IAAI;EAClE;CACD;CAEA,OAAO;AACR;AAEA,SAAgB,WAAW,MAA2B;CACrD,OAAO,KAAK,MAAM,QAAQ,QAAQ,IAAI,GAAG,KAAK,GAAG,IAAI,QAAQ,IAAI;AAClE;;;;;AClCA,MAAa,sCAAsB,IAAI,IAAY,CAAC,QAAQ,KAAK,CAAC;;;;;;;AAQlE,SAAgB,cAAc,QAAuC;CACpE,IAAI,CAAC,OAAO,IAAI,WAAW,CAAC,oBAAoB,IAAI,OAAO,MAAM,IAAI,GAAG,OAAO,CAAC;CAEhF,MAAM,WAAW,mBAAmB,OAAO,MAAM,yBAAyB;CAC1E,IAAI,aAAa,MAAM,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;CAAE;CAGrD,OAAO,UAAU,QAAQ,QAAQ,EAAE,QAAQ;EAAE,GAAG,OAAO;EAAQ,KAAK;GAAE,GAAG;GAAS,SAAS;EAAK;CAAE,EAAE,CAAC;AACtG;;;;;;AAOA,SAAgB,eAAe,QAAkD;CAChF,MAAM,SAAS,QAAQ,IAAI,MAAM;CACjC,IAAI,WAAW,UAAa,CAAC,OAAO,IAAI,WAAW,OAAO,IAAI,QAAQ,WAAW,WAAW,OAAO;CACnG,OAAO,UAAU,QAAQ,QAAQ,EAAE,YAAY,eAAe,MAAM,EAAE,CAAC;AACxE;AAEA,SAAS,UAAU,UAA+B,QAA8B,QAA4D;CAC3I,MAAM,OAAO;EAAE,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
|
@@ -76,6 +76,41 @@ export declare const cliDiagnostics: import("nostics").Diagnostics<{
|
|
|
76
76
|
why: (_p: {}) => string;
|
|
77
77
|
fix: (_p: {}) => string;
|
|
78
78
|
};
|
|
79
|
+
readonly DEPLOY_CONFIRMATION_REQUIRED: {
|
|
80
|
+
why: (_p: {}) => string;
|
|
81
|
+
fix: (_p: {}) => string;
|
|
82
|
+
};
|
|
83
|
+
readonly COMMANDS_DIFFER: {
|
|
84
|
+
why: (p: {
|
|
85
|
+
count: number;
|
|
86
|
+
}) => string;
|
|
87
|
+
fix: (_p: {
|
|
88
|
+
count: number;
|
|
89
|
+
}) => string;
|
|
90
|
+
};
|
|
91
|
+
readonly LOCAL_COMMANDS_UNAVAILABLE: {
|
|
92
|
+
why: (p: {
|
|
93
|
+
reason: string;
|
|
94
|
+
fix: string;
|
|
95
|
+
}) => string;
|
|
96
|
+
fix: (p: {
|
|
97
|
+
reason: string;
|
|
98
|
+
fix: string;
|
|
99
|
+
}) => string;
|
|
100
|
+
};
|
|
101
|
+
readonly DOCTOR_FAILED: {
|
|
102
|
+
why: (p: {
|
|
103
|
+
count: number;
|
|
104
|
+
}) => string;
|
|
105
|
+
};
|
|
106
|
+
readonly UNKNOWN_SHELL: {
|
|
107
|
+
why: (p: {
|
|
108
|
+
shell: string;
|
|
109
|
+
}) => string;
|
|
110
|
+
fix: (_p: {
|
|
111
|
+
shell: string;
|
|
112
|
+
}) => string;
|
|
113
|
+
};
|
|
79
114
|
readonly INVALID_THEME: {
|
|
80
115
|
why: (p: {
|
|
81
116
|
theme: string;
|
|
@@ -86,6 +121,18 @@ export declare const cliDiagnostics: import("nostics").Diagnostics<{
|
|
|
86
121
|
themes: string;
|
|
87
122
|
}) => string;
|
|
88
123
|
};
|
|
124
|
+
readonly INVALID_OPTION: {
|
|
125
|
+
why: (p: {
|
|
126
|
+
option: string;
|
|
127
|
+
value: string;
|
|
128
|
+
allowed: string;
|
|
129
|
+
}) => string;
|
|
130
|
+
fix: (p: {
|
|
131
|
+
option: string;
|
|
132
|
+
value: string;
|
|
133
|
+
allowed: string;
|
|
134
|
+
}) => string;
|
|
135
|
+
};
|
|
89
136
|
readonly CODEGEN_OUTDATED: {
|
|
90
137
|
why: (_p: {}) => string;
|
|
91
138
|
};
|
|
@@ -101,6 +148,28 @@ export declare const cliDiagnostics: import("nostics").Diagnostics<{
|
|
|
101
148
|
hint: string;
|
|
102
149
|
}) => string;
|
|
103
150
|
};
|
|
151
|
+
readonly MODULE_FAILED: {
|
|
152
|
+
why: (p: {
|
|
153
|
+
module: string;
|
|
154
|
+
reason: string;
|
|
155
|
+
message: string;
|
|
156
|
+
}) => string;
|
|
157
|
+
fix: (p: {
|
|
158
|
+
module: string;
|
|
159
|
+
reason: string;
|
|
160
|
+
message: string;
|
|
161
|
+
}) => string;
|
|
162
|
+
};
|
|
163
|
+
readonly MODULES_PRELOAD_REQUIRED: {
|
|
164
|
+
why: (p: {
|
|
165
|
+
tool: string;
|
|
166
|
+
plugins: string;
|
|
167
|
+
}) => string;
|
|
168
|
+
fix: (_p: {
|
|
169
|
+
tool: string;
|
|
170
|
+
plugins: string;
|
|
171
|
+
}) => string;
|
|
172
|
+
};
|
|
104
173
|
readonly CODEGEN_FAILED: {
|
|
105
174
|
why: (p: {
|
|
106
175
|
code: number | null;
|
|
@@ -160,6 +229,12 @@ interface Theme {
|
|
|
160
229
|
success: string;
|
|
161
230
|
warning: string;
|
|
162
231
|
error: string;
|
|
232
|
+
/** The `info`, `debug` and `trace` level badges of the dashboard's log stream. */
|
|
233
|
+
info: string;
|
|
234
|
+
debug: string;
|
|
235
|
+
trace: string;
|
|
236
|
+
/** Names worth finding in a log line: a command, a piece, a channel that is switched on. */
|
|
237
|
+
accent: string;
|
|
163
238
|
text: string | undefined;
|
|
164
239
|
/** Foreground of a badge painted on `success`, `warning` or `busy`. */
|
|
165
240
|
onBright: 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;;;;;;
|
|
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;wBAuBnC,WAAW,iBAAiB;;;;;;;;;;;;;;;;qBCvC/B,kCAAc;;IAKxB,MAAG;;;IAGH,MAAG;IACH,MAA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EhB;EACA,MAAM,OAAO;;EAEb,QAAQ;;;;;;wBAOO,sBAAsB,MAAM,KAAmB,SAAS,sBAAsB"}
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { t as runMain } from "./run-
|
|
1
|
+
import { t as runMain } from "./run-DMM2YlP3.js";
|
|
2
2
|
import { i as shouldUseColor, n as prefersReducedMotion, r as resolveOutputMode, t as isCIEnvironment } from "./output-mode-Bp7Da8vJ.js";
|
|
3
|
-
import { n as exitCodeOf, r as formatError, t as ExitCode } from "./errors-
|
|
4
|
-
import { t as cliDiagnostics } from "./diagnostics-
|
|
5
|
-
import { n as THEME_SETTINGS, o as resolveTheme, s as resolveThemeSetting, t as THEMES } from "./theme-
|
|
3
|
+
import { n as exitCodeOf, r as formatError, t as ExitCode } from "./errors-COFWKKKw.js";
|
|
4
|
+
import { t as cliDiagnostics } from "./diagnostics-BysbNnPD.js";
|
|
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
|
|
|
8
8
|
export { ExitCode, THEMES, THEME_SETTINGS, cliDiagnostics, configDiagnostics, exitCodeOf, formatError, isCIEnvironment, loadStarsConfig, prefersReducedMotion, resolveOutputMode, resolveTheme, resolveThemeSetting, runMain, shouldUseColor };
|
|
@@ -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
|
|
3
|
+
import { t as findInstalledVersion } from "./project-zlQStwsf.js";
|
|
4
|
+
import { a as modulesPreloadWarning, d as resolveCwd, n as loadProject, t as applyEnvOptions, u as projectArgs } from "./hooks-Cy6F2bhH.js";
|
|
5
5
|
import { defineCommand } from "citty";
|
|
6
6
|
import { relative } from "node:path";
|
|
7
7
|
import { displayPath } from "@wolfstar/schema";
|
|
@@ -34,7 +34,11 @@ function collectInfo(config) {
|
|
|
34
34
|
future: config.future,
|
|
35
35
|
env: config.env,
|
|
36
36
|
hooks: Object.keys(config.hooks),
|
|
37
|
-
|
|
37
|
+
modules: {
|
|
38
|
+
installed: (config.runtime?.modules ?? []).map((module) => module.name),
|
|
39
|
+
plugins: (config.runtime?.plugins ?? []).map((plugin) => `${plugin.module} → ${plugin.export} from ${plugin.from}`)
|
|
40
|
+
},
|
|
41
|
+
warnings: [...config.warnings, modulesPreloadWarning(config)].filter((warning) => warning !== null).map((warning) => `${warning.code}: ${warning.message}`),
|
|
38
42
|
options: {
|
|
39
43
|
tsdown: Object.keys(config.tsdown),
|
|
40
44
|
vite: Object.keys(config.vite)
|
|
@@ -77,12 +81,19 @@ function formatInfo(info, useColor) {
|
|
|
77
81
|
row("health", info.dev.health ?? colors.dim("none")),
|
|
78
82
|
row("typecheck", info.dev.typecheck.enabled ? `${info.dev.typecheck.checker} → ${show(info.dev.typecheck.tsconfig)}` : colors.dim("disabled")),
|
|
79
83
|
row("tunnel", describeTunnel(info.dev.tunnel, colors)),
|
|
80
|
-
row("log file", info.dev.logFile ? show(info.dev.logFile) : colors.dim("disabled"))
|
|
84
|
+
row("log file", info.dev.logFile ? show(info.dev.logFile) : colors.dim("disabled")),
|
|
85
|
+
row("log dir", info.dev.logs.dir ? `${show(info.dev.logs.dir)} (keeps ${info.dev.logs.keep})` : colors.dim("disabled")),
|
|
86
|
+
row("layout", info.dev.layout),
|
|
87
|
+
row("channels", info.dev.logs.channels?.join(", ") ?? colors.dim("all")),
|
|
88
|
+
row("levels", info.dev.logs.levels.join(", ")),
|
|
89
|
+
row("commands", `refresh: ${info.dev.commands.refresh}`),
|
|
90
|
+
row("hmr", info.dev.hmr ? "left to the bot when it hot reloads" : colors.dim("always restart"))
|
|
81
91
|
]),
|
|
82
92
|
section("Codegen", [row("i18n", info.codegen.i18n ? `${show(info.codegen.i18n.locales)} → ${show(info.codegen.i18n.output)}` : colors.dim("disabled"))]),
|
|
83
93
|
section("Future", [row("compat", `v${info.future.compatibilityVersion} defaults`), ...info.warnings.map((warning) => row("warning", colors.yellow(warning)))]),
|
|
84
94
|
section("Env", [row("register", info.env.enabled ? colors.green(describeEnvOptions(info.env.options)) : colors.dim("disabled"))]),
|
|
85
95
|
section("Hooks", [row("registered", info.hooks.join(", ") || colors.dim("none"))]),
|
|
96
|
+
section("Modules", [row("installed", info.modules.installed.join(", ") || colors.dim("none")), ...info.modules.plugins.map((plugin) => row("plugin", plugin))]),
|
|
86
97
|
section("Experimental", [
|
|
87
98
|
row("vite", flag(info.experimental.enableVite, colors)),
|
|
88
99
|
row("nitro", flag(info.experimental.enableNitro, colors)),
|
|
@@ -148,4 +159,4 @@ var info_default = defineCommand({
|
|
|
148
159
|
|
|
149
160
|
//#endregion
|
|
150
161
|
export { info_default as default };
|
|
151
|
-
//# sourceMappingURL=info-
|
|
162
|
+
//# sourceMappingURL=info-CKJVMWIT.js.map
|