@deltabox/toolchain 1.11.3 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +316 -4
- package/README.md +21 -14
- package/dist/_virtual/_rolldown/runtime.js +1 -1
- package/dist/changelog.d.ts +7 -6
- package/dist/changelog.js +1 -1
- package/dist/cli/commands/index.js +1 -1
- package/dist/cli/commands/providers.js +1 -1
- package/dist/cli/commands/reset.js +1 -1
- package/dist/cli/commands/shared.js +1 -1
- package/dist/cli/commands/sync.js +1 -1
- package/dist/cli/commands/watch.js +1 -1
- package/dist/cli/config-selection.d.ts +23 -0
- package/dist/cli/config-selection.js +1 -0
- package/dist/cli/context.js +1 -1
- package/dist/cli/index.d.ts +5 -3
- package/dist/cli/index.js +1 -1
- package/dist/cli/register.js +1 -1
- package/dist/config.d.ts +8 -8
- package/dist/config.js +1 -1
- package/dist/core.d.ts +7 -6
- package/dist/core.js +1 -1
- package/dist/globals.d.ts +31 -0
- package/dist/globals.js +1 -0
- package/dist/index.d.ts +32 -11
- package/dist/index.js +1 -1
- package/dist/migrate.d.ts +3 -2
- package/dist/migrate.js +1 -1
- package/dist/package.js +1 -1
- package/dist/packages/biome/src/index.d.ts +2 -1
- package/dist/packages/biome/src/index.js +1 -1
- package/dist/packages/changelog/src/cli/index.js +1 -1
- package/dist/packages/changelog/src/index.d.ts +8 -7
- package/dist/packages/changelog/src/index.js +1 -1
- package/dist/packages/changelog/src/run-workflows.d.ts +19 -4
- package/dist/packages/changelog/src/run-workflows.js +1 -1
- package/dist/packages/changelog/src/run.d.ts +3 -3
- package/dist/packages/changelog/src/run.js +1 -1
- package/dist/packages/changelog/src/sync.d.ts +7 -4
- package/dist/packages/changelog/src/sync.js +1 -1
- package/dist/packages/changelog/src/utils/format.d.ts +2 -1
- package/dist/packages/changelog/src/utils/format.js +5 -5
- package/dist/packages/changelog/src/utils/git.js +1 -1
- package/dist/packages/changelog/src/utils/reformat.d.ts +2 -1
- package/dist/packages/changelog/src/utils/reformat.js +3 -3
- package/dist/packages/changelog/src/utils/summary.d.ts +25 -2
- package/dist/packages/changelog/src/utils/summary.js +3 -1
- package/dist/packages/changelog/src/utils/types.d.ts +34 -2
- package/dist/packages/changelog/src/utils/version.d.ts +1 -0
- package/dist/packages/changelog/src/utils/versioning.d.ts +25 -4
- package/dist/packages/changelog/src/utils/versioning.js +1 -1
- package/dist/packages/changelog/src/utils/write.js +1 -1
- package/dist/packages/changelog/src/workflows.d.ts +27 -7
- package/dist/packages/changelog/src/workflows.js +5 -5
- package/dist/packages/config/src/cli/index.js +1 -1
- package/dist/packages/config/src/collect.d.ts +10 -8
- package/dist/packages/config/src/collect.js +1 -1
- package/dist/packages/config/src/config-json.d.ts +4 -4
- package/dist/packages/config/src/config-json.js +1 -1
- package/dist/packages/config/src/engine.d.ts +14 -25
- package/dist/packages/config/src/engine.js +1 -1
- package/dist/packages/config/src/env-file.d.ts +4 -4
- package/dist/packages/config/src/env-file.js +2 -2
- package/dist/packages/config/src/env.d.ts +4 -6
- package/dist/packages/config/src/env.js +1 -1
- package/dist/packages/config/src/generators/cli.d.ts +6 -6
- package/dist/packages/config/src/generators/cli.js +1 -1
- package/dist/packages/config/src/generators/env.d.ts +9 -9
- package/dist/packages/config/src/generators/env.js +2 -2
- package/dist/packages/config/src/generators/index.d.ts +4 -4
- package/dist/packages/config/src/generators/index.js +1 -1
- package/dist/packages/config/src/generators/json.d.ts +5 -7
- package/dist/packages/config/src/generators/json.js +1 -1
- package/dist/packages/config/src/generators/markdown.d.ts +57 -35
- package/dist/packages/config/src/generators/markdown.js +18 -19
- package/dist/packages/config/src/generators/types.d.ts +28 -23
- package/dist/packages/config/src/generators/types.js +3 -3
- package/dist/packages/config/src/index.d.ts +9 -9
- package/dist/packages/config/src/index.js +1 -1
- package/dist/packages/config/src/schema.d.ts +31 -3
- package/dist/packages/config/src/schema.js +1 -1
- package/dist/packages/config/src/types.d.ts +134 -28
- package/dist/packages/core/src/editor-config.d.ts +14 -0
- package/dist/packages/core/src/editor-config.js +1 -0
- package/dist/packages/core/src/graph.js +1 -1
- package/dist/packages/core/src/index.d.ts +8 -7
- package/dist/packages/core/src/index.js +1 -1
- package/dist/packages/core/src/loader.d.ts +20 -2
- package/dist/packages/core/src/loader.js +1 -1
- package/dist/packages/core/src/manifest.d.ts +20 -1
- package/dist/packages/core/src/manifest.js +1 -1
- package/dist/packages/core/src/provider-registry.d.ts +48 -3
- package/dist/packages/core/src/provider-registry.js +1 -1
- package/dist/packages/core/src/reset.d.ts +15 -0
- package/dist/packages/core/src/reset.js +1 -1
- package/dist/packages/core/src/sync.d.ts +10 -0
- package/dist/packages/core/src/sync.js +1 -1
- package/dist/packages/core/src/watch.d.ts +9 -0
- package/dist/packages/core/src/watch.js +1 -1
- package/dist/packages/migrate/src/cli/index.js +1 -1
- package/dist/packages/migrate/src/index.d.ts +3 -2
- package/dist/packages/migrate/src/index.js +1 -1
- package/dist/packages/migrate/src/oxc.d.ts +13 -0
- package/dist/packages/migrate/src/oxc.js +1 -0
- package/dist/packages/migrate/src/registry.js +1 -1
- package/dist/packages/migrate/src/vite-target.js +1 -1
- package/dist/packages/migrate/src/vite.d.ts +25 -3
- package/dist/packages/migrate/src/vite.js +7 -2
- package/dist/packages/project/src/catalogs.d.ts +7 -0
- package/dist/packages/project/src/catalogs.js +1 -1
- package/dist/packages/project/src/cli/index.js +1 -1
- package/dist/packages/project/src/config.d.ts +6 -0
- package/dist/packages/project/src/config.js +1 -1
- package/dist/packages/project/src/index.d.ts +5 -4
- package/dist/packages/project/src/index.js +1 -1
- package/dist/packages/project/src/sync.js +1 -1
- package/dist/packages/project/src/typescript.d.ts +64 -12
- package/dist/packages/project/src/typescript.js +12 -7
- package/dist/packages/shared/src/changelog-groups.d.ts +59 -0
- package/dist/packages/shared/src/config-schema/biome.d.ts +10 -0
- package/dist/packages/shared/src/config-schema/biome.js +1 -0
- package/dist/packages/shared/src/config-schema/catalogs.d.ts +14 -0
- package/dist/packages/shared/src/config-schema/catalogs.js +1 -0
- package/dist/packages/shared/src/config-schema/changelog.d.ts +245 -0
- package/dist/packages/shared/src/config-schema/changelog.js +1 -0
- package/dist/packages/shared/src/config-schema/ci.d.ts +389 -0
- package/dist/packages/shared/src/config-schema/ci.js +1 -0
- package/dist/packages/shared/src/config-schema/format.d.ts +38 -0
- package/dist/packages/shared/src/config-schema/format.js +1 -0
- package/dist/packages/shared/src/config-schema/index.d.ts +1648 -0
- package/dist/packages/shared/src/config-schema/index.js +1 -0
- package/dist/packages/shared/src/config-schema/logger.d.ts +19 -0
- package/dist/packages/shared/src/config-schema/logger.js +1 -0
- package/dist/packages/shared/src/config-schema/meta.d.ts +16 -0
- package/dist/packages/shared/src/config-schema/meta.js +1 -0
- package/dist/packages/shared/src/config-schema/project.d.ts +35 -0
- package/dist/packages/shared/src/config-schema/project.js +1 -0
- package/dist/packages/shared/src/config-schema/providers.d.ts +9 -0
- package/dist/packages/shared/src/config-schema/providers.js +1 -0
- package/dist/packages/shared/src/config-schema/registry.d.ts +21 -0
- package/dist/packages/shared/src/config-schema/registry.js +1 -0
- package/dist/packages/shared/src/config-schema/templates.d.ts +81 -0
- package/dist/packages/shared/src/config-schema/templates.js +1 -0
- package/dist/packages/shared/src/config-schema/tsconfig.d.ts +30 -0
- package/dist/packages/shared/src/config-schema/tsconfig.js +1 -0
- package/dist/packages/shared/src/config-schema/vite.d.ts +26 -0
- package/dist/packages/shared/src/config-schema/vite.js +1 -0
- package/dist/packages/shared/src/config-schema/watch.d.ts +11 -0
- package/dist/packages/shared/src/config-schema/watch.js +1 -0
- package/dist/packages/shared/src/config-schema/workflow.d.ts +590 -0
- package/dist/packages/shared/src/config-schema/workflow.js +1 -0
- package/dist/packages/shared/src/config-types.d.ts +290 -90
- package/dist/packages/shared/src/fs-utils.js +1 -1
- package/dist/packages/shared/src/index.d.ts +26 -7
- package/dist/packages/shared/src/index.js +1 -1
- package/dist/packages/shared/src/logger.d.ts +26 -3
- package/dist/packages/shared/src/logger.js +1 -1
- package/dist/packages/shared/src/messages.d.ts +36 -0
- package/dist/packages/shared/src/messages.js +1 -0
- package/dist/packages/shared/src/object-utils.d.ts +5 -0
- package/dist/packages/shared/src/object-utils.js +1 -1
- package/dist/packages/shared/src/registry-policy.d.ts +17 -0
- package/dist/packages/shared/src/registry-policy.js +1 -0
- package/dist/packages/shared/src/toolchain.d.ts +90 -11
- package/dist/packages/shared/src/toolchain.js +1 -1
- package/dist/packages/shared/src/types.d.ts +6 -0
- package/dist/packages/shared/src/vite-defaults.d.ts +29 -0
- package/dist/packages/shared/src/vite-defaults.js +1 -0
- package/dist/packages/template/src/builtin.js +1 -1
- package/dist/packages/template/src/cli/index.js +1 -1
- package/dist/packages/template/src/global.d.ts +130 -0
- package/dist/packages/template/src/global.js +3 -0
- package/dist/packages/template/src/index.d.ts +3 -2
- package/dist/packages/template/src/index.js +1 -1
- package/dist/packages/template/src/online.d.ts +13 -4
- package/dist/packages/template/src/online.js +1 -1
- package/dist/packages/template/src/registry.d.ts +2 -1
- package/dist/packages/template/src/registry.js +1 -1
- package/dist/packages/template/src/scaffold.d.ts +5 -1
- package/dist/packages/template/src/scaffold.js +1 -1
- package/dist/packages/tsconfig/src/cli/generate/index.d.ts +3 -0
- package/dist/packages/tsconfig/src/cli/generate/index.js +1 -1
- package/dist/packages/tsconfig/src/cli/generate/utils.d.ts +10 -1
- package/dist/packages/tsconfig/src/cli/generate/utils.js +1 -1
- package/dist/packages/tsconfig/src/cli/index.js +1 -1
- package/dist/packages/tsconfig/src/index.d.ts +7 -4
- package/dist/packages/tsconfig/src/index.js +1 -1
- package/dist/packages/tsconfig/src/overrides.d.ts +74 -0
- package/dist/packages/tsconfig/src/overrides.js +1 -0
- package/dist/packages/tsconfig/src/resolve.d.ts +62 -0
- package/dist/packages/tsconfig/src/resolve.js +3 -0
- package/dist/packages/tsconfig/src/snapshots.d.ts +50 -0
- package/dist/packages/tsconfig/src/snapshots.js +1 -0
- package/dist/packages/tsconfig/src/sync.d.ts +14 -5
- package/dist/packages/tsconfig/src/sync.js +1 -1
- package/dist/packages/tsconfig/src/templates/tsconfig.default.js +1 -1
- package/dist/packages/tsconfig/src/templates.d.ts +12 -4
- package/dist/packages/tsconfig/src/templates.js +1 -1
- package/dist/packages/vite/src/index.d.ts +2 -2
- package/dist/packages/vite/src/index.js +1 -1
- package/dist/packages/vite/src/resolve.d.ts +13 -3
- package/dist/packages/vite/src/resolve.js +1 -1
- package/dist/packages/vite/src/sync.d.ts +46 -5
- package/dist/packages/vite/src/sync.js +5 -2
- package/dist/project.d.ts +4 -3
- package/dist/project.js +1 -1
- package/dist/providers.d.ts +11 -4
- package/dist/providers.js +1 -1
- package/dist/shared.d.ts +25 -6
- package/dist/shared.js +1 -1
- package/dist/sync.js +1 -1
- package/dist/template.d.ts +3 -2
- package/dist/template.js +1 -1
- package/dist/tooling.d.ts +21 -0
- package/dist/tooling.js +1 -0
- package/dist/tsconfig.d.ts +6 -3
- package/dist/tsconfig.js +1 -1
- package/dist/vite.d.ts +2 -2
- package/dist/vite.js +1 -1
- package/package.json +28 -23
- package/dist/packages/config/src/types.js +0 -1
- package/dist/packages/shared/src/config-schema.d.ts +0 -3928
- package/dist/packages/shared/src/config-schema.js +0 -1
|
@@ -10,7 +10,21 @@ export type LogChannel = 'out' | 'err';
|
|
|
10
10
|
export type Colors = ReturnType<typeof pc.createColors>;
|
|
11
11
|
/** Every valid level, most verbose first. */
|
|
12
12
|
export declare const LOG_LEVELS: readonly ['debug', 'info', 'warn', 'error', 'silent'];
|
|
13
|
+
/** A warning/error suppression rule: a message/id string or a RegExp. */
|
|
14
|
+
export type LogSuppression = string | RegExp;
|
|
15
|
+
export interface ToolchainLogger {
|
|
16
|
+
raw(message?: string): void;
|
|
17
|
+
rawError(message?: string): void;
|
|
18
|
+
write(channel: LogChannel, text: string): void;
|
|
19
|
+
debug(message?: string): void;
|
|
20
|
+
info(message?: string): void;
|
|
21
|
+
success(message?: string): void;
|
|
22
|
+
warn(message?: string, id?: string): void;
|
|
23
|
+
error(message?: string, id?: string): void;
|
|
24
|
+
}
|
|
13
25
|
export interface LoggerOptions {
|
|
26
|
+
/** Use a custom logger implementation instead of the built-in clack sink. */
|
|
27
|
+
logger?: ToolchainLogger;
|
|
14
28
|
/** Minimum level to print (default `info`). */
|
|
15
29
|
level?: LogLevel;
|
|
16
30
|
/**
|
|
@@ -20,8 +34,13 @@ export interface LoggerOptions {
|
|
|
20
34
|
color?: boolean;
|
|
21
35
|
/** Prefix non-indented lines with `<name>:` (default `dbx`). */
|
|
22
36
|
name?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Silence matching warnings/errors. A string matches an emitted id (exact)
|
|
39
|
+
* or a message substring; a `/pattern/flags` string or RegExp is a regex.
|
|
40
|
+
*/
|
|
41
|
+
suppress?: LogSuppression | LogSuppression[];
|
|
23
42
|
}
|
|
24
|
-
export interface Logger {
|
|
43
|
+
export interface Logger extends ToolchainLogger {
|
|
25
44
|
/** The configured level. */
|
|
26
45
|
readonly level: LogLevel;
|
|
27
46
|
/** A `picocolors` color set honoring the color setting. */
|
|
@@ -35,8 +54,8 @@ export interface Logger {
|
|
|
35
54
|
debug(message?: string): void;
|
|
36
55
|
info(message?: string): void;
|
|
37
56
|
success(message?: string): void;
|
|
38
|
-
warn(message?: string): void;
|
|
39
|
-
error(message?: string): void;
|
|
57
|
+
warn(message?: string, id?: string): void;
|
|
58
|
+
error(message?: string, id?: string): void;
|
|
40
59
|
}
|
|
41
60
|
/** Whether a value is a valid {@link LogLevel}. */
|
|
42
61
|
export declare function isLogLevel(value: unknown): value is LogLevel;
|
|
@@ -52,9 +71,13 @@ export declare function stripAnsi(text: string): string;
|
|
|
52
71
|
export declare function createLogger(options?: LoggerOptions): Logger;
|
|
53
72
|
/** A `dbx.config.*` `logger` section value. */
|
|
54
73
|
export interface LoggerConfig {
|
|
74
|
+
enabled?: boolean;
|
|
55
75
|
level?: LogLevel;
|
|
56
76
|
color?: boolean;
|
|
57
77
|
name?: string;
|
|
78
|
+
suppress?: LogSuppression | LogSuppression[];
|
|
79
|
+
/** A custom logger implementation (config files only). */
|
|
80
|
+
logger?: ToolchainLogger;
|
|
58
81
|
}
|
|
59
82
|
/** Apply the `logger` section from the loaded `dbx.config.*`. */
|
|
60
83
|
export declare function setLogConfig(options: LoggerConfig | boolean | undefined): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"node:path";import"node:url";import.meta.url;import{
|
|
1
|
+
import"node:path";import"node:url";import.meta.url;import{formatMessageId as e}from"./messages.js";import{log as t}from"@clack/prompts";import n from"picocolors";const r=[`debug`,`info`,`warn`,`error`,`silent`],i={debug:0,info:1,warn:2,error:3,silent:4};function a(e){return typeof e==`string`&&r.includes(e)}function o(e,t=`info`){return a(e)?e:t}function s(e){return e.replace(/\x1b\[[0-9;]*m/g,``)}function c(e){return e===void 0?[]:Array.isArray(e)?e:[e]}function l(e){if(e.length<2||!e.startsWith(`/`))return;let t=e.lastIndexOf(`/`);if(!(t<=0))try{return new RegExp(e.slice(1,t),e.slice(t+1))}catch{return}}function u(e,t,n){if(e instanceof RegExp)return e.test(t)||(n?e.test(n):!1);let r=l(e);if(r)return r.test(t)||(n?r.test(n):!1);let i=e.toLowerCase();return n!==void 0&&n.toLowerCase()===i||t.toLowerCase().includes(i)}function d(r={}){let a=o(r.level),s=i[a],l=n.createColors(r.color??!0),d=r.name?`${r.name}: `:``,f=c(r.suppress),p=(e,t)=>f.some(n=>u(n,e,t));typeof r.color==`boolean`&&h(r.color);let m=e=>!d||e===``||/^\s/.test(e)?e:`${d}${e}`,g=(t,n)=>n?`[${e(n)}] ${t}`:t,_=(e,t,n)=>{e(m(t),{spacing:0,...n?{output:n}:{}})},v=r.logger;return v?{level:a,colors:l,raw:(e=``)=>v.raw(e),rawError:(e=``)=>v.rawError(e),write:(e,t)=>v.write(e,t),debug:(e=``)=>{s<=i.debug&&v.debug(e)},info:(e=``)=>{s<=i.info&&v.info(e)},success:(e=``)=>{s<=i.info&&v.success(e)},warn:(e=``,t)=>{s<=i.warn&&!p(e,t)&&v.warn(e,t)},error:(e=``,t)=>{s<=i.error&&!p(e,t)&&v.error(e,t)}}:{level:a,colors:l,raw:(e=``)=>{process.stdout.write(`${e}\n`)},rawError:(e=``)=>{process.stderr.write(`${e}\n`)},write:(e,t)=>{e===`err`?process.stderr.write(t):process.stdout.write(t)},debug:(e=``)=>{s<=i.debug&&_(t.message,e)},info:(e=``)=>{s<=i.info&&_(t.info,e)},success:(e=``)=>{s<=i.info&&_(t.success,e)},warn:(e=``,n)=>{s<=i.warn&&!p(e,n)&&_(t.warn,g(e,n),process.stderr)},error:(e=``,n)=>{s<=i.error&&!p(e,n)&&_(t.error,g(e,n),process.stderr)}}}let f={},p={};function m(e){return!e||typeof e!=`object`?{}:e.enabled===!1?{level:`silent`}:{...a(e.level)?{level:e.level}:{},...typeof e.color==`boolean`?{color:e.color}:{},...typeof e.name==`string`?{name:e.name}:{},...e.suppress===void 0?{}:{suppress:e.suppress},...e.logger?{logger:e.logger}:{}}}function h(e){e?(delete process.env.NO_COLOR,process.env.FORCE_COLOR=`1`):(delete process.env.FORCE_COLOR,process.env.NO_COLOR=`1`)}function g(e=!0){let t={name:`dbx`,...f,...p};return e&&t.color===void 0&&(t.color=!0),d(t)}let _=g(!1);function v(e){f=m(e),_=g()}function y(e){p=e,_=g()}function b(e){y(e)}function x(){return p}function S(){return _}const C={get level(){return _.level},get colors(){return _.colors},raw:(e=``)=>_.raw(e),rawError:(e=``)=>_.rawError(e),write:(e,t)=>_.write(e,t),debug:(e=``)=>_.debug(e),info:(e=``)=>_.info(e),success:(e=``)=>_.success(e),warn:(e=``,t)=>_.warn(e,t),error:(e=``,t)=>_.error(e,t)};export{r as LOG_LEVELS,b as configureLogger,d as createLogger,x as getLogOverrides,S as getLogger,a as isLogLevel,C as logger,o as normalizeLogLevel,v as setLogConfig,y as setLogOverrides,s as stripAnsi};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import __tsdown_shims_path from 'node:path';
|
|
2
|
+
import __tsdown_shims_url from 'node:url';
|
|
3
|
+
//#region packages/shared/src/messages.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Central warning/error messages, keyed by a stable id.
|
|
6
|
+
*
|
|
7
|
+
* The keys double as logger ids, so consumers can silence a specific message
|
|
8
|
+
* with `logger.suppress` without matching its rendered text.
|
|
9
|
+
*/
|
|
10
|
+
/** Non-fatal messages emitted by sync tasks. */
|
|
11
|
+
export declare const WARNING_MAP: {
|
|
12
|
+
readonly 'fmt.conflict': 'Multiple formatters configured ({tools}); using {winner} (precedence) for editor settings.';
|
|
13
|
+
readonly 'lint.conflict': 'Multiple linters configured ({tools}); using {winner} (precedence) for editor settings.';
|
|
14
|
+
readonly 'fmt.no-tool': string;
|
|
15
|
+
readonly 'lint.no-tool': string;
|
|
16
|
+
readonly 'tsconfig.missing-file': 'tsconfig override target `{file}` was not found; skipping its {kind} override.';
|
|
17
|
+
readonly 'tsconfig.outside-root': 'tsconfig override target `{file}` is outside the project root; skipping it.';
|
|
18
|
+
readonly 'tsconfig.override-edited': '`{file}`: `{key}` changed after the override applied it; keeping the current value.';
|
|
19
|
+
readonly 'tsconfig.restore-reapply': string;
|
|
20
|
+
};
|
|
21
|
+
/** Error messages emitted by sync tasks. */
|
|
22
|
+
export declare const ERROR_MAP: {
|
|
23
|
+
readonly 'deprecated.section.biome': '`toolchain.biome` is deprecated: use `toolchain.fmt.biome` / `toolchain.lint.biome` instead.';
|
|
24
|
+
};
|
|
25
|
+
export type WarningId = keyof typeof WARNING_MAP;
|
|
26
|
+
export type ErrorId = keyof typeof ERROR_MAP;
|
|
27
|
+
export type MessageId = WarningId | ErrorId;
|
|
28
|
+
/** Render an id for logs/notifications (`fmt.conflict` -> `FMT_CONFLICT`). */
|
|
29
|
+
export declare function formatMessageId(id: string): string;
|
|
30
|
+
/** Replace `{name}` placeholders in a message template. */
|
|
31
|
+
export declare function formatMessage(template: string, values?: Record<string, string | number>): string;
|
|
32
|
+
/** The rendered warning message for an id. */
|
|
33
|
+
export declare function warningMessage(id: WarningId, values?: Record<string, string | number>): string;
|
|
34
|
+
/** The rendered error message for an id. */
|
|
35
|
+
export declare function errorMessage(id: ErrorId, values?: Record<string, string | number>): string;
|
|
36
|
+
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"node:path";import"node:url";import.meta.url;const e={"fmt.conflict":`Multiple formatters configured ({tools}); using {winner} (precedence) for editor settings.`,"lint.conflict":`Multiple linters configured ({tools}); using {winner} (precedence) for editor settings.`,"fmt.no-tool":"No formatter found (installed or in VS Code settings); falling back to Oxc defaults. Set `toolchain.fmt.oxc` or install a formatter to silence this.","lint.no-tool":"No linter found (installed or in VS Code settings); falling back to Oxc defaults. Set `toolchain.lint.oxc` or install a linter to silence this.","tsconfig.missing-file":"tsconfig override target `{file}` was not found; skipping its {kind} override.","tsconfig.outside-root":"tsconfig override target `{file}` is outside the project root; skipping it.","tsconfig.override-edited":"`{file}`: `{key}` changed after the override applied it; keeping the current value.","tsconfig.restore-reapply":"tsconfig overrides are still configured ({kinds}); the next `dbx sync` applies them again. Remove them from `toolchain.tsconfig.overrides` to keep the restored files."},t={"deprecated.section.biome":"`toolchain.biome` is deprecated: use `toolchain.fmt.biome` / `toolchain.lint.biome` instead."};function n(e){return e.replace(/[^a-zA-Z0-9]+/g,`_`).toUpperCase()}function r(e,t={}){return e.replace(/\{(\w+)\}/g,(e,n)=>n in t?String(t[n]):e)}function i(t,n){return r(e[t],n)}function a(e,n){return r(t[e],n)}export{t as ERROR_MAP,e as WARNING_MAP,a as errorMessage,r as formatMessage,n as formatMessageId,i as warningMessage};
|
|
@@ -12,4 +12,9 @@ export declare function isPlainObject(value: unknown): value is Record<string, u
|
|
|
12
12
|
export declare function deepMerge<T extends Record<string, any>>(target: T, ...sources: (Partial<T> | undefined)[]): T;
|
|
13
13
|
/** Map an object's values, keeping the keys. */
|
|
14
14
|
export declare function mapValues<V, R>(value: Record<string, V>, fn: (value: V, key: string) => R): Record<string, R>;
|
|
15
|
+
/**
|
|
16
|
+
* Layer typed overrides over a base object (shallow per level, objects merge
|
|
17
|
+
* recursively). Later overrides win; `undefined` leaves the base value alone.
|
|
18
|
+
*/
|
|
19
|
+
export declare function applyOverrides<T extends object>(base: T, ...overrides: Partial<T>[]): T;
|
|
15
20
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"node:path";import"node:url";import.meta.url;function e(e){if(!e)return e;let n=(Array.isArray(e)?e:Object.entries(e||{})).sort(([e],[n])=>t(e,n));return Array.isArray(e)?n:Object.fromEntries(n)}function t(e,t){return e.localeCompare(t)}function n(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function r(e,...t){let i={...e};for(let e of t)if(e)for(let[t,a]of Object.entries(e)){let e=i[t];n(e)&&n(a)?i[t]=r(e,a):a!==void 0&&(i[t]=a)}return i}function i(e,t){return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,t(n,e)]))}export{r as deepMerge,n as isPlainObject,i as mapValues,t as resolveSort,e as sort};
|
|
1
|
+
import"node:path";import"node:url";import.meta.url;function e(e){if(!e)return e;let n=(Array.isArray(e)?e:Object.entries(e||{})).sort(([e],[n])=>t(e,n));return Array.isArray(e)?n:Object.fromEntries(n)}function t(e,t){return e.localeCompare(t)}function n(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function r(e,...t){let i={...e};for(let e of t)if(e)for(let[t,a]of Object.entries(e)){let e=i[t];n(e)&&n(a)?i[t]=r(e,a):a!==void 0&&(i[t]=a)}return i}function i(e,t){return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,t(n,e)]))}function a(e,...t){if(t.length===0)return e;let r={...e};for(let e of t)if(e)for(let[t,i]of Object.entries(e)){if(i===void 0)continue;let e=r[t];r[t]=n(e)&&n(i)?a(e,i):i}return r}export{a as applyOverrides,r as deepMerge,n as isPlainObject,i as mapValues,t as resolveSort,e as sort};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import __tsdown_shims_path from 'node:path';
|
|
2
|
+
import __tsdown_shims_url from 'node:url';
|
|
3
|
+
//#region packages/shared/src/registry-policy.d.ts
|
|
4
|
+
/** A registry source allow/deny policy (host and path globs). */
|
|
5
|
+
export interface RegistryPolicy {
|
|
6
|
+
/** Allowed host/path globs. An empty list allows everything not denied. */
|
|
7
|
+
allow?: string[];
|
|
8
|
+
/** Denied host/path globs (checked first). */
|
|
9
|
+
deny?: string[];
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Whether a registry source is allowed by a policy. URLs are matched against
|
|
13
|
+
* the full URL, the host and `host/path`; local sources should be passed as an
|
|
14
|
+
* absolute path. A missing policy (or an empty deny + allow) allows everything.
|
|
15
|
+
*/
|
|
16
|
+
export declare function registrySourceAllowed(source: string, policy: RegistryPolicy | undefined): boolean;
|
|
17
|
+
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"node:path";import"node:url";import.meta.url;function e(e){let t=e.replace(/[.+^${}()|[\]\\]/g,`\\$&`).replace(/\*\*/g,`\0`).replace(/\*/g,`[^/]*`).replace(/\?/g,`.`).replace(/\u0000/g,`.*`);return RegExp(`^${t}$`,`i`)}function t(t,n){return!n||n.length===0?!1:n.some(n=>e(n.replace(/\\/g,`/`)).test(t))}function n(e,n){if(!n)return!0;let r=e.replace(/\\/g,`/`).replace(/\/+$/,``),i=[r];try{let e=new URL(r);i.push(e.host.toLowerCase(),`${e.host}${e.pathname}`.toLowerCase())}catch{}return i.some(e=>t(e,n.deny))?!1:!n.allow||n.allow.length===0||i.some(e=>t(e,n.allow))}export{n as registrySourceAllowed};
|
|
@@ -1,8 +1,23 @@
|
|
|
1
1
|
import __tsdown_shims_path from 'node:path';
|
|
2
2
|
import __tsdown_shims_url from 'node:url';
|
|
3
|
-
import { ChangelogVersioning, ChangelogVersioningConfig, ChangelogVersioningTarget,
|
|
3
|
+
import { ChangelogBranchesConfig, ChangelogCommitlintConfig, ChangelogConfig, ChangelogVersioning, ChangelogVersioningConfig, ChangelogVersioningTarget, ChangelogWorkflowSetting, CustomWorkflowSettings, DbxConfigSections, ProjectType, ToolchainBiomeConfig, ToolchainCatalogsConfig, ToolchainChangelogConfig, ToolchainCiConfig, ToolchainConfigSections, ToolchainFmtConfig, ToolchainLintConfig, ToolchainLoggerConfig, ToolchainProjectConfig, ToolchainProvidersConfig, ToolchainRegistryConfig, ToolchainRegistryPolicy, ToolchainTemplateKind, ToolchainTemplateSource, ToolchainTemplateSourceType, ToolchainTemplatesConfig, ToolchainTsconfigConfig, ToolchainTsconfigOverrides, ToolchainViteConfig, ToolchainVscodeSettings, ToolchainWatchConfig, WorkflowOptions, WorkflowSetting, WorkflowStep, WorkflowStepsConfig } from "./config-types.js";
|
|
4
4
|
import { Replacements } from "./template.js";
|
|
5
|
-
import {
|
|
5
|
+
import { biomeConfigSchema } from "./config-schema/biome.js";
|
|
6
|
+
import { catalogsConfigSchema } from "./config-schema/catalogs.js";
|
|
7
|
+
import { changelogBranchesConfigSchema, changelogCommitlintConfigSchema, changelogConfigSchema, changelogVersioningConfigSchema, changelogVersioningSchema, changelogVersioningTargetSchema, changelogWorkflowSettingSchema, legacyChangelogConfigSchema } from "./config-schema/changelog.js";
|
|
8
|
+
import { ciConfigSchema } from "./config-schema/ci.js";
|
|
9
|
+
import { fmtConfigSchema, lintConfigSchema, vscodeSettingsSchema } from "./config-schema/format.js";
|
|
10
|
+
import { loggerConfigSchema } from "./config-schema/logger.js";
|
|
11
|
+
import { ENABLED_DESCRIPTION, section, withEnabled } from "./config-schema/meta.js";
|
|
12
|
+
import { projectConfigSchema, projectTypeSchema } from "./config-schema/project.js";
|
|
13
|
+
import { providersConfigSchema } from "./config-schema/providers.js";
|
|
14
|
+
import { registryConfigSchema, registryPolicySchema } from "./config-schema/registry.js";
|
|
15
|
+
import { templateKindSchema, templateSourceSchema, templateSourceTypeSchema, templatesConfigSchema } from "./config-schema/templates.js";
|
|
16
|
+
import { tsconfigConfigSchema } from "./config-schema/tsconfig.js";
|
|
17
|
+
import { viteConfigSchema } from "./config-schema/vite.js";
|
|
18
|
+
import { watchConfigSchema } from "./config-schema/watch.js";
|
|
19
|
+
import { customWorkflowSettingsSchema, workflowConfigSchema, workflowOptionsSchema, workflowSettingSchema, workflowStepSchema, workflowStepsConfigSchema } from "./config-schema/workflow.js";
|
|
20
|
+
import { configSchema, dbxConfigSchema, toolchainConfigSchema } from "./config-schema/index.js";
|
|
6
21
|
import { Awaitable } from "./types.js";
|
|
7
22
|
//#region packages/shared/src/toolchain.d.ts
|
|
8
23
|
/** A summary of a sync run, handed to {@link ToolchainHooks.afterSync}. */
|
|
@@ -67,10 +82,18 @@ export type ToolchainConfig = ToolchainConfigSections & {
|
|
|
67
82
|
export interface DbxConfig {
|
|
68
83
|
toolchain?: ToolchainConfig;
|
|
69
84
|
}
|
|
85
|
+
/** A `dbx.config` callback: returns the config synchronously or as a promise. */
|
|
86
|
+
export type DbxConfigFunction = () => DbxConfig | Promise<DbxConfig>;
|
|
87
|
+
/** Everything {@link defineConfig} accepts: an object, a promise, or a callback. */
|
|
88
|
+
export type DbxConfigInput = DbxConfig | Promise<DbxConfig> | DbxConfigFunction;
|
|
70
89
|
/**
|
|
71
90
|
* Identity helper that gives a config file full type-checking + autocomplete.
|
|
72
|
-
* Mirrors Vite's `defineConfig`:
|
|
91
|
+
* Mirrors Vite's `defineConfig`: the argument may be an object, a promise, or a
|
|
92
|
+
* sync/async callback returning the config. The loader resolves it, so a config
|
|
93
|
+
* can do async work before returning `{ toolchain }`.
|
|
73
94
|
*/
|
|
95
|
+
export declare function defineConfig(config: Promise<DbxConfig>): Promise<DbxConfig>;
|
|
96
|
+
export declare function defineConfig(config: DbxConfigFunction): DbxConfigFunction;
|
|
74
97
|
export declare function defineConfig(config: DbxConfig): DbxConfig;
|
|
75
98
|
/**
|
|
76
99
|
* A config section that is enabled with `true`, disabled with `false`, or
|
|
@@ -97,12 +120,52 @@ export declare function sectionConfig<T extends object>(section: ToolchainSectio
|
|
|
97
120
|
export declare const CONFIG_FILE_NAMES: readonly ['dbx.config.ts', 'dbx.config.mts', 'dbx.config.js', 'dbx.config.mjs', 'dbx.config.cjs', 'dbx.config.json'];
|
|
98
121
|
/** Derive the `owner/name` slug from a repository URL. */
|
|
99
122
|
export declare function repoSlugFromUrl(repo: string | undefined): string | undefined;
|
|
123
|
+
/**
|
|
124
|
+
* The `ci` section's options, when the section is enabled. It is opt-in by
|
|
125
|
+
* presence, and `enabled: false` disables every nested workflow.
|
|
126
|
+
*/
|
|
127
|
+
export declare function resolveCiConfig(config?: ToolchainConfig): ToolchainCiConfig | undefined;
|
|
128
|
+
/**
|
|
129
|
+
* The changelog pipeline options, merging the manual `toolchain.changelog`
|
|
130
|
+
* section under `ci.changelog`. `ci.changelog` wins when it sets the same
|
|
131
|
+
* option; when it is enabled but not configured (`true`, a raw workflow string,
|
|
132
|
+
* or workflow-only options) the manual section's options still apply.
|
|
133
|
+
*/
|
|
134
|
+
export declare function resolveChangelogConfig(config?: ToolchainConfig): ChangelogConfig | undefined;
|
|
135
|
+
/** Default package-manager versions used when a config omits `packageManagerVersion`. */
|
|
136
|
+
export declare const DEFAULT_PACKAGE_MANAGER_VERSIONS: Record<string, string>;
|
|
137
|
+
/** Formatter tools, highest priority first. */
|
|
138
|
+
export declare const FORMATTER_PRECEDENCE: readonly ['oxc', 'biome', 'prettier', 'dprint'];
|
|
139
|
+
/** Linter tools, highest priority first. */
|
|
140
|
+
export declare const LINTER_PRECEDENCE: readonly ['oxc', 'biome', 'eslint'];
|
|
141
|
+
export type FormatterTool = (typeof FORMATTER_PRECEDENCE)[number];
|
|
142
|
+
export type LinterTool = (typeof LINTER_PRECEDENCE)[number];
|
|
143
|
+
/** The configured formatters, in precedence order (oxc includes `vite.fmt`). */
|
|
144
|
+
export declare function resolveFmtTools(config?: ToolchainConfig): FormatterTool[];
|
|
145
|
+
/** The configured linters, in precedence order (oxc includes `vite.lint`). */
|
|
146
|
+
export declare function resolveLintTools(config?: ToolchainConfig): LinterTool[];
|
|
147
|
+
/** The winning formatter for editor defaults. */
|
|
148
|
+
export declare function resolveFmtTool(config?: ToolchainConfig): FormatterTool | undefined;
|
|
149
|
+
/** The winning linter for editor defaults. */
|
|
150
|
+
export declare function resolveLintTool(config?: ToolchainConfig): LinterTool | undefined;
|
|
151
|
+
/** Merge `vite.fmt` over `fmt.oxc` (leaves/arrays in `vite.fmt` win). */
|
|
152
|
+
export declare function resolveOxcFmtConfig(config?: ToolchainConfig): unknown;
|
|
153
|
+
/** Merge `vite.lint` over `lint.oxc` (leaves/arrays in `vite.lint` win). */
|
|
154
|
+
export declare function resolveOxcLintConfig(config?: ToolchainConfig): unknown;
|
|
155
|
+
/** Whether the changelog workflow/pipeline is enabled (`ci.changelog`). */
|
|
156
|
+
export declare function changelogSectionEnabled(config?: ToolchainConfig): boolean;
|
|
157
|
+
/**
|
|
158
|
+
* Whether commitlint is enabled for the changelog pipeline. It defaults to
|
|
159
|
+
* `true`; set `ci.changelog.commitlint: false` (or `{ enabled: false }`) to
|
|
160
|
+
* generate changelogs without the Conventional-Commits rules.
|
|
161
|
+
*/
|
|
162
|
+
export declare function resolveCommitlintEnabled(changelog?: ChangelogConfig): boolean;
|
|
100
163
|
/**
|
|
101
164
|
* The resolved changelog branches. `main` defaults to `['main']`; `dev` has **no
|
|
102
165
|
* default** and reuses `main` when omitted, so a single-branch repo needs no
|
|
103
166
|
* `dev`. Each side accepts a glob or an array of globs.
|
|
104
167
|
*/
|
|
105
|
-
export declare function resolveChangelogBranches(changelog?:
|
|
168
|
+
export declare function resolveChangelogBranches(changelog?: ChangelogConfig): {
|
|
106
169
|
main: string[];
|
|
107
170
|
dev: string[];
|
|
108
171
|
};
|
|
@@ -122,6 +185,13 @@ export interface ManagedFile {
|
|
|
122
185
|
* JSON files, which are tracked via the manifest instead).
|
|
123
186
|
*/
|
|
124
187
|
header?: string;
|
|
188
|
+
/**
|
|
189
|
+
* Record the file in the manifest (default true). An untracked file is
|
|
190
|
+
* written and drift-checked like any other, but stays user-owned: it is
|
|
191
|
+
* never pruned by a later sync or removed by `dbx reset` (eg. a user
|
|
192
|
+
* tsconfig a `tsconfig.overrides` entry patches).
|
|
193
|
+
*/
|
|
194
|
+
track?: boolean;
|
|
125
195
|
}
|
|
126
196
|
/** The context handed to every {@link SyncTask}. */
|
|
127
197
|
export interface SyncContext {
|
|
@@ -131,12 +201,20 @@ export interface SyncContext {
|
|
|
131
201
|
projectType: ProjectType;
|
|
132
202
|
/** The loaded config. */
|
|
133
203
|
config: ToolchainConfig;
|
|
204
|
+
/** The project's own (unmerged) config, when loaded. */
|
|
205
|
+
ownConfig?: ToolchainConfig;
|
|
134
206
|
/** The resolved replacement tokens. */
|
|
135
207
|
tokens: Replacements;
|
|
136
208
|
/** Log a line (respects `--quiet`). */
|
|
137
209
|
log: (message: string) => void;
|
|
138
|
-
/** Emit a warning (respects `--quiet
|
|
139
|
-
warn: (message: string) => void;
|
|
210
|
+
/** Emit a warning (respects `--quiet` and `logger.suppress`). */
|
|
211
|
+
warn: (message: string, id?: string) => void;
|
|
212
|
+
/** Dry run: report drift without writing files (including snapshots). */
|
|
213
|
+
check?: boolean;
|
|
214
|
+
/** Repo-relative files the previous sync managed (from the manifest). */
|
|
215
|
+
managedFiles?: string[];
|
|
216
|
+
/** Extra manifest metadata tasks can persist between syncs. */
|
|
217
|
+
manifest?: Record<string, unknown>;
|
|
140
218
|
}
|
|
141
219
|
/** A unit of sync work exposed by a package. */
|
|
142
220
|
export interface SyncTask {
|
|
@@ -144,16 +222,17 @@ export interface SyncTask {
|
|
|
144
222
|
name: string;
|
|
145
223
|
/**
|
|
146
224
|
* Repo-relative globs to watch; a change re-runs this task. The config file
|
|
147
|
-
* itself is always watched, and re-runs every task.
|
|
225
|
+
* itself is always watched, and re-runs every task. A function derives the
|
|
226
|
+
* globs from the config (eg. custom tsconfig file names).
|
|
148
227
|
*/
|
|
149
|
-
watch?: string[];
|
|
228
|
+
watch?: string[] | ((config: ToolchainConfig) => string[]);
|
|
150
229
|
/**
|
|
151
230
|
* File names/suffixes the task does **not** own but that may appear in an
|
|
152
231
|
* older manifest. They are never deleted (even though they are no longer
|
|
153
232
|
* generated) and are dropped from the manifest, so a consumer can edit them
|
|
154
|
-
* freely — eg. `tsconfig.build.json`.
|
|
233
|
+
* freely — eg. `tsconfig.build.json`. A function derives them from the config.
|
|
155
234
|
*/
|
|
156
|
-
keep?: string[];
|
|
235
|
+
keep?: string[] | ((config: ToolchainConfig) => string[]);
|
|
157
236
|
/** Whether the task runs for the given config (default: always). */
|
|
158
237
|
enabled?: (config: ToolchainConfig) => boolean;
|
|
159
238
|
/**
|
|
@@ -168,4 +247,4 @@ export interface SyncTask {
|
|
|
168
247
|
run: (ctx: SyncContext) => Awaitable<ManagedFile[] | void>;
|
|
169
248
|
}
|
|
170
249
|
//#endregion
|
|
171
|
-
export {
|
|
250
|
+
export { ChangelogBranchesConfig, ChangelogCommitlintConfig, ChangelogConfig, ChangelogVersioning, ChangelogVersioningConfig, ChangelogVersioningTarget, ChangelogWorkflowSetting, CustomWorkflowSettings, DbxConfigSections, ENABLED_DESCRIPTION, ProjectType, ToolchainBiomeConfig, ToolchainCatalogsConfig, ToolchainChangelogConfig, ToolchainCiConfig, ToolchainConfigSections, ToolchainFmtConfig, ToolchainLintConfig, ToolchainLoggerConfig, ToolchainProjectConfig, ToolchainProvidersConfig, ToolchainRegistryConfig, ToolchainRegistryPolicy, ToolchainTemplateKind, ToolchainTemplateSource, ToolchainTemplateSourceType, ToolchainTemplatesConfig, ToolchainTsconfigConfig, ToolchainTsconfigOverrides, ToolchainViteConfig, ToolchainVscodeSettings, ToolchainWatchConfig, WorkflowOptions, WorkflowSetting, WorkflowStep, WorkflowStepsConfig, biomeConfigSchema, catalogsConfigSchema, changelogBranchesConfigSchema, changelogCommitlintConfigSchema, changelogConfigSchema, changelogVersioningConfigSchema, changelogVersioningSchema, changelogVersioningTargetSchema, changelogWorkflowSettingSchema, ciConfigSchema, configSchema, customWorkflowSettingsSchema, dbxConfigSchema, fmtConfigSchema, legacyChangelogConfigSchema, lintConfigSchema, loggerConfigSchema, projectConfigSchema, projectTypeSchema, providersConfigSchema, registryConfigSchema, registryPolicySchema, section, templateKindSchema, templateSourceSchema, templateSourceTypeSchema, templatesConfigSchema, toolchainConfigSchema, tsconfigConfigSchema, viteConfigSchema, vscodeSettingsSchema, watchConfigSchema, withEnabled, workflowConfigSchema, workflowOptionsSchema, workflowSettingSchema, workflowStepSchema, workflowStepsConfigSchema };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"node:path";import"node:url";import.meta.url;import{
|
|
1
|
+
import"node:path";import"node:url";import.meta.url;import{deepMerge as e,isPlainObject as t}from"./object-utils.js";import{ENABLED_DESCRIPTION as n,section as r,withEnabled as i}from"./config-schema/meta.js";import{biomeConfigSchema as a}from"./config-schema/biome.js";import{catalogsConfigSchema as o}from"./config-schema/catalogs.js";import{customWorkflowSettingsSchema as s,workflowConfigSchema as c,workflowOptionsSchema as l,workflowSettingSchema as u,workflowStepSchema as d,workflowStepsConfigSchema as f}from"./config-schema/workflow.js";import{changelogBranchesConfigSchema as p,changelogCommitlintConfigSchema as m,changelogConfigSchema as h,changelogVersioningConfigSchema as g,changelogVersioningSchema as _,changelogVersioningTargetSchema as v,changelogWorkflowSettingSchema as y,legacyChangelogConfigSchema as ee}from"./config-schema/changelog.js";import{ciConfigSchema as b}from"./config-schema/ci.js";import{fmtConfigSchema as x,lintConfigSchema as S,vscodeSettingsSchema as C}from"./config-schema/format.js";import{loggerConfigSchema as w}from"./config-schema/logger.js";import{projectConfigSchema as T,projectTypeSchema as E}from"./config-schema/project.js";import{providersConfigSchema as D}from"./config-schema/providers.js";import{registryConfigSchema as O,registryPolicySchema as k}from"./config-schema/registry.js";import{templateKindSchema as A,templateSourceSchema as j,templateSourceTypeSchema as M,templatesConfigSchema as N}from"./config-schema/templates.js";import{tsconfigConfigSchema as P}from"./config-schema/tsconfig.js";import{viteConfigSchema as F}from"./config-schema/vite.js";import{watchConfigSchema as I}from"./config-schema/watch.js";import{configSchema as L,dbxConfigSchema as R,toolchainConfigSchema as te}from"./config-schema/index.js";function z(e){return e}function B(e){return e===void 0?!1:typeof e==`boolean`?e:e.enabled!==!1}function V(e){return e!==void 0&&typeof e==`object`?e:void 0}const H=[`dbx.config.ts`,`dbx.config.mts`,`dbx.config.js`,`dbx.config.mjs`,`dbx.config.cjs`,`dbx.config.json`];function U(e){if(!e)return;let t=e.match(/github\.com[/:]([^/]+)\/([^/.]+?)(?:\.git)?$/);return t?.[1]&&t[2]?`${t[1]}/${t[2]}`:void 0}function W(e){return e===void 0?[]:Array.isArray(e)?e:[e]}function G(e={}){return B(e.ci)?V(e.ci):void 0}function K(t={}){let n=V(t.changelog),r=n&&B(n)?n:void 0,i=G(t)?.changelog;return i===void 0||i===!1||i===!0||typeof i==`string`||!B(i)?r:r?e(r,i):i}const q={yarn:`4.17.1`,pnpm:`10.11.1`,npm:`11.19.0`,bun:`1.3.0`},J=[`oxc`,`biome`,`prettier`,`dprint`],Y=[`oxc`,`biome`,`eslint`];function X(e){return B(e)?V(e):void 0}function Z(e={}){let t=X(e.fmt)??{},n=X(e.vite),r=/* @__PURE__ */ new Set;return n?.fmt!==void 0&&n.fmt!==!1&&r.add(`oxc`),t.oxc!==void 0&&t.oxc!==!1&&r.add(`oxc`),t.biome!==void 0&&t.biome!==!1&&r.add(`biome`),t.prettier!==void 0&&t.prettier!==!1&&r.add(`prettier`),t.dprint!==void 0&&t.dprint!==!1&&r.add(`dprint`),J.filter(e=>r.has(e))}function Q(e={}){let t=X(e.lint)??{},n=X(e.vite),r=/* @__PURE__ */ new Set;return n?.lint!==void 0&&n.lint!==!1&&r.add(`oxc`),t.oxc!==void 0&&t.oxc!==!1&&r.add(`oxc`),t.biome!==void 0&&t.biome!==!1&&r.add(`biome`),t.eslint!==void 0&&t.eslint!==!1&&r.add(`eslint`),Y.filter(e=>r.has(e))}function ne(e={}){return Z(e)[0]}function re(e={}){return Q(e)[0]}function ie(n={}){let r=X(n.fmt)?.oxc,i=X(n.vite)?.fmt;return i===void 0?r:i===!1?!1:i===!0?r??!0:r===void 0?i:t(r)&&t(i)?e(r,i):i}function ae(n={}){let r=X(n.lint)?.oxc,i=X(n.vite)?.lint;return i===void 0?r:i===!1?!1:i===!0?r??!0:r===void 0?i:t(r)&&t(i)?e(r,i):i}function oe(e={}){let t=G(e)?.changelog;return t===void 0?!1:typeof t==`boolean`?t:typeof t==`string`?t.trim().length>0:B(t)}function se(e){let t=e?.commitlint;return t===void 0?!0:typeof t==`boolean`?t:t.enabled!==!1}function $(e){let t=e?.branches??{},n=W(t.main);n.length===0&&n.push(`main`);let r=W(t.dev);return{main:n,dev:r.length>0?r:n}}function ce(e={}){let t=e.project??{},n=$(K(e)??{}),r=t.name??`app`,i=t.packageManager??`yarn`,a=t.packageManagerVersion??q[i]??`4.17.1`;return{name:r,scope:t.scope??``,author:t.author??``,license:t.license??`MIT`,homepage:t.homepage??``,repo:t.repo??``,repoSlug:U(t.repo)??``,description:t.description??``,nodeVersion:t.nodeVersion??`22`,packageManager:i,yarnVersion:a,packageManagerVersion:a,mainBranch:n.main[0]??`main`,devBranch:n.dev[0]??`main`}}export{H as CONFIG_FILE_NAMES,q as DEFAULT_PACKAGE_MANAGER_VERSIONS,n as ENABLED_DESCRIPTION,J as FORMATTER_PRECEDENCE,Y as LINTER_PRECEDENCE,a as biomeConfigSchema,o as catalogsConfigSchema,p as changelogBranchesConfigSchema,m as changelogCommitlintConfigSchema,h as changelogConfigSchema,oe as changelogSectionEnabled,g as changelogVersioningConfigSchema,_ as changelogVersioningSchema,v as changelogVersioningTargetSchema,y as changelogWorkflowSettingSchema,b as ciConfigSchema,L as configSchema,s as customWorkflowSettingsSchema,R as dbxConfigSchema,z as defineConfig,x as fmtConfigSchema,ee as legacyChangelogConfigSchema,S as lintConfigSchema,w as loggerConfigSchema,T as projectConfigSchema,E as projectTypeSchema,D as providersConfigSchema,O as registryConfigSchema,k as registryPolicySchema,U as repoSlugFromUrl,$ as resolveChangelogBranches,K as resolveChangelogConfig,G as resolveCiConfig,se as resolveCommitlintEnabled,ne as resolveFmtTool,Z as resolveFmtTools,re as resolveLintTool,Q as resolveLintTools,ie as resolveOxcFmtConfig,ae as resolveOxcLintConfig,ce as resolveTokens,r as section,V as sectionConfig,B as sectionEnabled,A as templateKindSchema,j as templateSourceSchema,M as templateSourceTypeSchema,N as templatesConfigSchema,te as toolchainConfigSchema,P as tsconfigConfigSchema,F as viteConfigSchema,C as vscodeSettingsSchema,I as watchConfigSchema,i as withEnabled,c as workflowConfigSchema,l as workflowOptionsSchema,u as workflowSettingSchema,d as workflowStepSchema,f as workflowStepsConfigSchema};
|
|
@@ -23,6 +23,8 @@ export interface ToolchainOption {
|
|
|
23
23
|
description: string;
|
|
24
24
|
/** Optional default value (stringified). */
|
|
25
25
|
default?: string;
|
|
26
|
+
/** Collect repeated occurrences into an array (eg. `--from a --from b`). */
|
|
27
|
+
multiple?: boolean;
|
|
26
28
|
}
|
|
27
29
|
/**
|
|
28
30
|
* The context handed to every command after the consumer's
|
|
@@ -36,10 +38,14 @@ export interface ToolchainCommandContext {
|
|
|
36
38
|
projectType: ProjectType;
|
|
37
39
|
/** The loaded tooling config (empty object when none was found). */
|
|
38
40
|
config: ToolchainConfig;
|
|
41
|
+
/** The project's own (unmerged) config, when loaded from a file. */
|
|
42
|
+
ownConfig?: ToolchainConfig;
|
|
39
43
|
/** The resolved replacement tokens. */
|
|
40
44
|
tokens: Replacements;
|
|
41
45
|
/** The config file that was loaded, if any. */
|
|
42
46
|
configPath?: string;
|
|
47
|
+
/** Whether config discovery was disabled (`dbx --no-config`). */
|
|
48
|
+
noConfig?: boolean;
|
|
43
49
|
/**
|
|
44
50
|
* Set when a `dbx.config.*` file failed to import (the CLI loads configs
|
|
45
51
|
* tolerantly so unrelated commands still work). Commands that cannot operate
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import __tsdown_shims_path from 'node:path';
|
|
2
|
+
import __tsdown_shims_url from 'node:url';
|
|
3
|
+
import { ViteUserConfig } from "vite-plus";
|
|
4
|
+
//#region packages/shared/src/vite-defaults.d.ts
|
|
5
|
+
/** The Oxfmt options accepted by Vite+ (`toolchain.vite.fmt`). */
|
|
6
|
+
export type ToolchainOxfmtConfig = NonNullable<ViteUserConfig['fmt']>;
|
|
7
|
+
/** The Oxlint options accepted by Vite+ (`toolchain.vite.lint`). */
|
|
8
|
+
export type ToolchainOxlintConfig = NonNullable<ViteUserConfig['lint']>;
|
|
9
|
+
/**
|
|
10
|
+
* Common paths Oxfmt should leave alone. Starts from the shared build/cache
|
|
11
|
+
* ignores and adds generated JSON/YAML, lockfiles, changelogs and the managed
|
|
12
|
+
* `vite.config.ts` shim.
|
|
13
|
+
*/
|
|
14
|
+
export declare const DEFAULT_FMT_IGNORE_PATTERNS: string[];
|
|
15
|
+
/**
|
|
16
|
+
* The Oxfmt options used when `vite.fmt` is `true`, and the base an options
|
|
17
|
+
* object is merged over. `sortImports` is intentionally left out: import order
|
|
18
|
+
* is project-specific, so consumers opt in with their own groups.
|
|
19
|
+
*/
|
|
20
|
+
export declare const DEFAULT_FMT_RULES: ToolchainOxfmtConfig;
|
|
21
|
+
/** Common paths Oxlint should leave alone. */
|
|
22
|
+
export declare const DEFAULT_LINT_IGNORE_PATTERNS: string[];
|
|
23
|
+
/**
|
|
24
|
+
* The Oxlint options used when `vite.lint` is `true`, and the base an options
|
|
25
|
+
* object is merged over. Framework/a11y rules are disabled by default (opt in
|
|
26
|
+
* per project); the remaining rules are non-blocking warnings.
|
|
27
|
+
*/
|
|
28
|
+
export declare const DEFAULT_LINT_RULES: ToolchainOxlintConfig;
|
|
29
|
+
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"node:path";import"node:url";import.meta.url;import{DEFAULT_IGNORE_PATTERNS as e}from"./ignore.js";const t=[...e,`**/.nuxt/**`,`**/.svelte-kit/**`,`**/.generated/**`,`**/generated/**`,`**/*.json`,`**/*.yml`,`**/*.yaml`,`**/*.lock`,`**/*.min.*`,`**/CHANGELOG.md`,`CHANGELOG.proposed.md`,`**/vite.config.ts`],n={useTabs:!1,tabWidth:4,printWidth:100,endOfLine:`lf`,insertFinalNewline:!0,singleQuote:!0,jsxSingleQuote:!1,quoteProps:`as-needed`,trailingComma:`es5`,semi:!0,arrowParens:`avoid`,bracketSpacing:!0,bracketSameLine:!1,singleAttributePerLine:!1,objectWrap:`preserve`,proseWrap:`preserve`,embeddedLanguageFormatting:`auto`,htmlWhitespaceSensitivity:`css`,vueIndentScriptAndStyle:!1,sortPackageJson:!1,ignorePatterns:t},r=[...e,`**/.nuxt/**`,`**/.svelte-kit/**`,`**/.generated/**`,`**/generated/**`,`**/*.min.*`,`**/vendor/**`],i={ignorePatterns:r,rules:{"jsx-a11y/alt-text":`off`,"jsx-a11y/aria-props":`off`,"jsx-a11y/click-events-have-key-events":`off`,"react/button-has-type":`off`,"react/react-in-jsx-scope":`off`,"react-hooks/exhaustive-deps":`off`,"typescript/no-empty-object-type":`off`,"typescript/no-explicit-any":`off`,"typescript/no-non-null-assertion":`off`,"typescript/no-useless-empty-export":`off`,eqeqeq:`warn`,"import/no-duplicates":`warn`,"no-alert":`warn`,"no-case-declarations":`off`,"no-console":`off`,"no-constant-condition":`off`,"no-control-regex":`off`,"no-debugger":`warn`,"no-inner-declarations":`off`,"no-return-assign":`off`,"no-unused-vars":`warn`,"no-useless-escape":`off`,"no-var":`warn`,"prefer-const":`warn`,"prefer-exponentiation-operator":`off`,"prefer-template":`off`}};export{t as DEFAULT_FMT_IGNORE_PATTERNS,n as DEFAULT_FMT_RULES,r as DEFAULT_LINT_IGNORE_PATTERNS,i as DEFAULT_LINT_RULES};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"node:path";import"node:url";import.meta.url;const e={name:`name`,prompt:`Project name`,default:`app`,required:!0},t=[e,{name:`scope`,prompt:`npm scope (optional)`,default:``},{name:`packageManager`,prompt:`Package manager`,default:`yarn`,options:[`yarn`,`pnpm`,`npm`,`bun`]},{name:`includeConfig`,prompt:`Include a dbx.config.ts?`,default:`yes`,options:[`yes`,`no`]}],n=[{id:`install`,prompt:`Install dependencies?`,default:!1,builtin:`install`}],r=[{id:`project`,name:`TypeScript project`,description:`A single-package TypeScript project (tsconfig, tsdown,
|
|
1
|
+
import"node:path";import"node:url";import.meta.url;const e={name:`name`,prompt:`Project name`,default:`app`,required:!0},t=[e,{name:`scope`,prompt:`npm scope (optional)`,default:``},{name:`packageManager`,prompt:`Package manager`,default:`yarn`,options:[`yarn`,`pnpm`,`npm`,`bun`]},{name:`includeConfig`,prompt:`Include a dbx.config.ts?`,default:`yes`,options:[`yes`,`no`]}],n=[{id:`install`,prompt:`Install dependencies?`,default:!1,builtin:`install`}],r=[{id:`project`,name:`TypeScript project`,description:`A single-package TypeScript project (tsconfig, tsdown, Vite+).`,kind:`project`,builtin:`single`,source:{type:`builtin`,locate:`project`},tags:[`typescript`,`library`],variables:t,actions:n},{id:`application`,name:`Application`,description:`A runnable application package (tsconfig, Vite+).`,kind:`application`,builtin:`application`,source:{type:`builtin`,locate:`application`},tags:[`application`,`app`],variables:t,actions:n},{id:`folder`,name:`Folder`,description:`A bare folder (a README) to drop files into.`,kind:`folder`,builtin:`folder`,source:{type:`builtin`,locate:`folder`},tags:[`folder`],variables:[e]},{id:`monorepo`,name:`Monorepo`,description:`A monorepo root (workspaces + monorepo tsconfig), no example package.`,kind:`project`,builtin:`monorepo-root`,source:{type:`builtin`,locate:`monorepo`},tags:[`monorepo`],variables:t,actions:n},{id:`monorepo-example`,name:`Monorepo (with example)`,description:`A monorepo root plus one example workspace package.`,kind:`project`,builtin:`monorepo-example`,source:{type:`builtin`,locate:`monorepo-example`},tags:[`monorepo`],variables:t,actions:n},{id:`workspace`,name:`Monorepo workspace`,description:`A workspace package added to an existing monorepo root.`,kind:`workspace`,builtin:`monorepo-workspace`,source:{type:`builtin`,locate:`workspace`},tags:[`monorepo`,`workspace`],variables:t,actions:n},{id:`vite-plus`,name:`Vite+ (interactive)`,description:"Create a new project through `vp create` (interactive or templated).",kind:`project`,source:{type:`vite-plus`,locate:``},tags:[`vite`,`vite-plus`],online:!0,variables:[e]},{id:`vite-plus-monorepo`,name:`Vite+ Monorepo`,description:"Create a Vite+ monorepo through `vp create vite:monorepo`.",kind:`project`,source:{type:`vite-plus`,locate:`vite:monorepo`},tags:[`vite`,`vite-plus`,`monorepo`],online:!0,variables:[e]},{id:`vite-plus-application`,name:`Vite+ Application`,description:"Create a Vite+ application through `vp create vite:application`.",kind:`application`,source:{type:`vite-plus`,locate:`vite:application`},tags:[`vite`,`vite-plus`,`application`],online:!0,variables:[e]},{id:`vite-plus-library`,name:`Vite+ Library`,description:"Create a Vite+ library through `vp create vite:library`.",kind:`project`,source:{type:`vite-plus`,locate:`vite:library`},tags:[`vite`,`vite-plus`,`library`],online:!0,variables:[e]},{id:`vite-plus-generator`,name:`Vite+ Generator`,description:"Scaffold a Vite+ code generator (`vp create vite:generator`, monorepo only).",kind:`project`,source:{type:`vite-plus`,locate:`vite:generator`},tags:[`vite`,`vite-plus`,`generator`],online:!0,variables:[e]}];export{r as BUILTIN_TEMPLATES};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as e}from"node:path";import"node:url";import.meta.url;import{logger as t}from"../../../shared/src/logger.js";import"../../../shared/src/index.js";import{TEMPLATE_MANIFEST as n,writeTemplateManifest as r}from"../local.js";import{parseSourceSpec as i}from"../online.js";import{addTemplateSource as a,loadTemplates as o,readTemplateRegistry as s,removeTemplateSource as c}from"../registry.js";import{scaffoldTemplate as l}from"../scaffold.js";import u from"node:fs";import{cancel as d,confirm as f,isCancel as p,select as m,text as h}from"@clack/prompts";const g={flags:`--cwd <dir>`,description:`Project root (default: cwd).`},_={flags:`--kind <kind>`,description:`project | workspace | application | folder | tooling | pipeline.`};function v(e){return{id:e.id,name:e.name,...e.description?{description:e.description}:{},kind:e.kind,type:e.source.type,online:!!e.online,...e.tags?{tags:e.tags}:{},...e.variables?{variables:e.variables}:{},...e.actions?{actions:e.actions}:{}}}function y(e){let t={};for(let n of e??[]){let e=n.indexOf(`=`);e!==-1&&(t[n.slice(0,e)]=n.slice(e+1))}return t}function b(e){return(e??[]).map(e=>{let t=e.indexOf(`:`);return t===-1?{name:e}:{name:e.slice(0,t),default:e.slice(t+1)}})}function x(e){return!!(process.stdin.isTTY&&process.stdout.isTTY)&&e.json!==!0}function S(){d(`Cancelled.`),process.exitCode=1}function C(){return[{name:`template:list`,description:`List templates (builtin + local + opted-in online sources).`,options:[g,{flags:`--online`,description:`Resolve online sources (npm/git).`},{flags:`--offline`,description:`Force offline (skip npm/git).`},_,{flags:`--registry`,description:`List only the .dbx/toolchain/templates.json sources.`},{flags:`--json`,description:`Print the templates as JSON.`}],run:async(e,n)=>{let r=e.cwd??n.cwd;if(e.registry){let n=s(r).sources;if(e.json){t.raw(JSON.stringify(n.map(e=>({key:`${e.type}:${e.locate}`,...e})),null,4));return}if(n.length===0){t.info(`the template registry is empty.`);return}for(let e of n)t.info(` ${`${e.type}:${e.locate}`.padEnd(40)} ${e.name??e.id??``}`);return}let i=!!e.online&&!e.offline,a=await o({cwd:r,config:n.config,online:i}),c=e.kind,l=c?a.filter(e=>e.kind===c):a;if(e.json)t.raw(JSON.stringify(l.map(v),null,4));else if(l.length===0)t.info(`no templates found.`);else for(let e of l){let n=[e.kind,e.source.type,e.online?`online`:`offline`].join(`, `);t.info(` ${e.id.padEnd(24)} ${e.name} [${n}]${e.description?`\n ${e.description}`:``}`)}}},{name:`template:init`,description:`Write a template.json to a directory, making it a local template.`,args:[{name:`dir`,description:`Directory (default: cwd).`,required:!1}],options:[g,_,{flags:`--name <name>`,description:`Display name (default: folder name).`},{flags:`--description <text>`,description:`Description.`},{flags:`--var <pair...>`,description:`Variable name[:default] (repeatable).`},{flags:`--tag <tag...>`,description:`Tag (repeatable).`},{flags:`--force`,description:`Overwrite an existing template.json.`},{flags:`--add`,description:`Also record the folder in .dbx/toolchain/templates.json.`},{flags:`--json`,description:`Print the manifest as JSON.`}],run:(i,o)=>{let s=e.resolve(o.cwd,String(i.dir??`.`)),c=e.join(s,n);if(u.existsSync(c)&&!i.force)throw Error(`template.json already exists at ${c} (use --force).`);let l=b(i.var),d={name:String(i.name??e.basename(s)),kind:i.kind??`folder`,...i.description?{description:String(i.description)}:{},...l.length?{variables:l}:{},...i.tag?{tags:i.tag}:{}};r(s,d),i.add&&a(o.cwd,{type:`local`,locate:s,kind:d.kind}),i.json?t.raw(JSON.stringify(d,null,4)):(t.info(`wrote ${c}`),i.add&&t.info(`registered the folder as a template.`))}},{name:`template:add`,description:`Record a template source in .dbx/toolchain/templates.json.`,args:[{name:`source`,description:`local path | git URL | @scope/create | type:locate`}],options:[g,{flags:`--type <type>`,description:`Force: builtin | local | npm | git | vite-plus.`},{flags:`--name <name>`,description:`Display name.`},_,{flags:`--ref <ref>`,description:`Git branch/tag/commit.`},{flags:`--subdir <dir>`,description:`Subdirectory within the source.`},{flags:`--json`,description:`Print the updated registry as JSON.`}],run:(n,o)=>{let s=i(String(n.source),o.cwd);n.type&&(s.type=n.type),n.name&&(s.name=String(n.name)),n.kind&&(s.kind=n.kind),n.ref&&(s.ref=String(n.ref)),n.subdir&&(s.subdir=String(n.subdir)),s.type===`local`&&!u.existsSync(e.join(s.locate,`template.json`))&&r(s.locate,{name:s.name??e.basename(s.locate),kind:n.kind??`folder`});let c=a(o.cwd,s);n.json?t.raw(JSON.stringify(c,null,4)):t.info(`added ${s.type}:${s.locate} (${c.sources.length} source(s)).`)}},{name:`template:remove`,description:`Remove a source from .dbx/toolchain/templates.json.`,args:[{name:`id`,description:`Source id or type:locate.`}],options:[g,{flags:`--json`,description:`Print the registry as JSON.`}],run:(e,n)=>{let{registry:r,removed:i}=c(n.cwd,String(e.id));e.json?t.raw(JSON.stringify(r,null,4)):i===0?(t.error(`no source matching "${e.id}".`),process.exitCode=1):t.info(`removed ${i} source(s) (${r.sources.length} left).`)}},{name:`template:info`,description:`Show one template by id.`,args:[{name:`id`,description:`The template id.`}],options:[g,{flags:`--online`,description:`Resolve online sources.`},{flags:`--json`,description:`Print the template as JSON (the default).`}],run:async(e,n)=>{let r=e.cwd??n.cwd,i=(await o({cwd:r,config:n.config,online:!!e.online})).find(t=>t.id===e.id);i?t.raw(JSON.stringify(v(i),null,4)):(t.error(`unknown template "${e.id}".`),process.exitCode=1)}},{name:`create`,description:`Scaffold a project from a template (builtin, local or Vite+).`,options:[{flags:`-t, --template <id>`,description:`Template id (see template:list).`},_,{flags:`-n, --name <name>`,description:`Project / package name.`},{flags:`-s, --scope <scope>`,description:`npm scope, eg. @acme.`},{flags:`-o, --out <dir>`,description:`Output directory (default: cwd).`},g,{flags:`--var <pair...>`,description:`Template variables as key=value (repeatable).`},{flags:`--action <id...>`,description:`Action id to run after scaffolding (repeatable).`},{flags:`--online`,description:`Resolve online templates too.`},{flags:`--json`,description:`Print the result as JSON.`}],run:async(n,r)=>{let i=n.out??r.cwd,a=n.kind,s=await o({cwd:r.cwd,config:r.config,online:!0}),c=x(n),u=String(n.template??``),d=n.name,g=n.scope;if(c&&!u&&!a){if(s.length===0)throw Error("No templates available. Pass --template <id> (see `dbx template:list`).");let e=await m({message:`Pick a template`,options:s.map(e=>({value:e.id,label:e.name,...e.description?{hint:e.description}:{}}))});if(p(e))return S();u=String(e)}if(c&&!d){let e=await h({message:`Project name`,placeholder:r.config.project?.name??`app`,defaultValue:r.config.project?.name??`app`});if(p(e))return S();d=String(e)}if(c&&!g){let e=await h({message:`npm scope (optional)`,placeholder:r.config.project?.scope??`@${d??`app`}`});if(p(e))return S();g=String(e)||void 0}let _=s.find(e=>e.id===u);if(!_&&!u&&a&&(_=s.find(e=>e.kind===a)),!_&&u&&(_={id:u,name:u,kind:a??`project`,source:{type:`vite-plus`,locate:u},online:!0}),!_)throw Error("No template selected. Pass --template <id> or --kind <kind> (see `dbx template:list`).");d===`.`&&(d=e.basename(e.resolve(i)));let v={...r.config.project,name:d??r.config.project?.name??`app`,...g?{scope:g}:{}},b=y(n.var),C=new Set(n.action??[]);if(c){for(let e of _.variables??[]){if(e.name===`name`||e.name===`scope`||b[e.name]!==void 0)continue;let t=e.prompt??e.name;if(e.options&&e.options.length>0){let n=await m({message:t,options:e.options.map(e=>({value:e,label:e})),...e.default?{initialValue:e.default}:{}});if(p(n))return S();b[e.name]=String(n)}else{let n=await h({message:t,...e.default?{placeholder:e.default,defaultValue:e.default}:{}});if(p(n))return S();let r=String(n??``);b[e.name]=r||(e.default??``)}}for(let e of _.actions??[]){if(C.has(e.id))continue;let t=await f({message:e.prompt??`Run ${e.id}?`,initialValue:e.default??!1});if(p(t))return S();t&&C.add(e.id)}}let w=await l(_,{cwd:i,tokens:v,variables:b,actions:[...C]});if(n.json)t.raw(JSON.stringify({template:_.id,out:i,...w},null,4));else if(_.source.type===`vite-plus`||_.source.type===`npm`||_.source.type===`git`)w.code&&(process.exitCode=w.code);else for(let e of w.written)t.info(`Created ${e}`)}}]}export{C as templateCommands};
|
|
1
|
+
import{default as e}from"node:path";import"node:url";import.meta.url;import{logger as t}from"../../../shared/src/logger.js";import{sectionConfig as n}from"../../../shared/src/toolchain.js";import"../../../shared/src/index.js";import{addGlobalProviderRegistry as r,addProjectProviderRegistry as i,removeGlobalProviderRegistry as a,removeProjectProviderRegistry as o,setGlobalProviderRegistries as s,setProjectProviderRegistries as c}from"../../../core/src/provider-registry.js";import"../../../core/src/index.js";import{TEMPLATE_MANIFEST as l,writeTemplateManifest as u}from"../local.js";import{addGlobalSource as d,addGlobalTemplate as f,addProjectRegistry as p,defaultGlobalTemplatesDir as m,existingTemplateIds as h,expandHome as g,listRegistries as _,loadGlobalTemplates as v,normalizeSearchPaths as y,readGlobalCliConfig as b,removeGlobalTemplate as x,removeProjectRegistry as S,resolveTemplateSearchPaths as C,uniqueTemplateId as w,writeGlobalCliConfig as T,writeProjectRegistries as E,writeVscodeSearchPaths as D}from"../global.js";import{parseSourceSpec as O}from"../online.js";import{addTemplateSource as k,loadTemplates as A,readTemplateRegistry as j,removeTemplateSource as M}from"../registry.js";import{scaffoldTemplate as N}from"../scaffold.js";import P from"node:fs";import{cancel as F,confirm as I,isCancel as L,select as R,text as z}from"@clack/prompts";const B={flags:`--cwd <dir>`,description:`Project root (default: cwd).`},V={flags:`--kind <kind>`,description:`project | workspace | application | folder | tooling | pipeline.`};function H(e){return{id:e.id,name:e.name,...e.description?{description:e.description}:{},kind:e.kind,type:e.source.type,online:!!e.online,...e.tags?{tags:e.tags}:{},...e.variables?{variables:e.variables}:{},...e.actions?{actions:e.actions}:{}}}function U(e){let t={};for(let n of e??[]){let e=n.indexOf(`=`);e!==-1&&(t[n.slice(0,e)]=n.slice(e+1))}return t}function W(e){return(e??[]).map(e=>{let t=e.indexOf(`:`);return t===-1?{name:e}:{name:e.slice(0,t),default:e.slice(t+1)}})}function G(e){return!!(process.stdin.isTTY&&process.stdout.isTTY)&&e.json!==!0}function K(){F(`Cancelled.`),process.exitCode=1}function q(){return[{name:`template:list`,description:`List templates (builtin + local + opted-in online sources).`,options:[B,{flags:`--online`,description:`Resolve online sources (npm/git).`},{flags:`--offline`,description:`Force offline (skip npm/git).`},{flags:`--global`,description:`Only the global registry templates.`},V,{flags:`--registry`,description:`List only the .dbx/toolchain/templates.json sources.`},{flags:`--json`,description:`Print the templates as JSON.`}],run:async(e,n)=>{let r=e.cwd??n.cwd;if(e.global){let n=await v(r);if(e.json){t.raw(JSON.stringify(n.templates.map(H),null,4));return}if(n.templates.length===0){t.info(`no global templates found.`);return}for(let e of n.templates)t.info(` ${e.id.padEnd(24)} ${e.name}`);return}if(e.registry){let n=j(r).sources;if(e.json){t.raw(JSON.stringify(n.map(e=>({key:`${e.type}:${e.locate}`,...e})),null,4));return}if(n.length===0){t.info(`the template registry is empty.`);return}for(let e of n)t.info(` ${`${e.type}:${e.locate}`.padEnd(40)} ${e.name??e.id??``}`);return}let i=!!e.online&&!e.offline,a=await A({cwd:r,config:n.config,online:i}),o=e.kind,s=o?a.filter(e=>e.kind===o):a;if(e.json)t.raw(JSON.stringify(s.map(H),null,4));else if(s.length===0)t.info(`no templates found.`);else for(let e of s){let n=[e.kind,e.source.type,e.online?`online`:`offline`].join(`, `);t.info(` ${e.id.padEnd(24)} ${e.name} [${n}]${e.description?`\n ${e.description}`:``}`)}}},{name:`template:init`,description:`Write a template.json to a directory, making it a local template.`,args:[{name:`dir`,description:`Directory (default: cwd).`,required:!1}],options:[B,V,{flags:`--name <name>`,description:`Display name (default: folder name).`},{flags:`--id <id>`,description:`Stable template id (default: folder name).`},{flags:`--description <text>`,description:`Description.`},{flags:`--var <pair...>`,description:`Variable name[:default] (repeatable).`},{flags:`--tag <tag...>`,description:`Tag (repeatable).`},{flags:`--force`,description:`Overwrite an existing template.json.`},{flags:`--add`,description:`Also record the folder in .dbx/toolchain/templates.json.`},{flags:`--no-global`,description:`Do not also store the template in the global registry.`},{flags:`--json`,description:`Print the manifest as JSON.`}],run:async(n,r)=>{let i=e.resolve(r.cwd,String(n.dir??`.`)),a=e.join(i,l);if(P.existsSync(a)&&!n.force)throw Error(`template.json already exists at ${a} (use --force).`);let o=W(n.var),s={name:String(n.name??e.basename(i)),kind:n.kind??`folder`,...n.description?{description:String(n.description)}:{},...o.length?{variables:o}:{},...n.tag?{tags:n.tag}:{}};if(u(i,s),n.add){let a=String(n.id??e.basename(i)),o=/* @__PURE__ */ new Set([...await h(r.cwd,{global:!1}),...j(r.cwd).sources.map(e=>e.id).filter(e=>!!e)]);if(o.has(a)){if(G(n)){let e=await z({message:`Template id "${a}" already exists. New id:`,placeholder:w(a,o),defaultValue:w(a,o)});if(L(e))return K();a=String(e)}else throw Error(`template id "${a}" already exists; pass --id <id> to rename it.`)}if(k(r.cwd,{type:`local`,locate:i,id:a,kind:s.kind}),n.global!==!1)try{f(i,a)}catch(e){t.warn(`could not add the template globally: ${String(e)}`)}}n.json?t.raw(JSON.stringify(s,null,4)):(t.info(`wrote ${a}`),n.add&&t.info(`registered the folder as a template.`))}},{name:`template:add`,description:`Record a template source in .dbx/toolchain/templates.json.`,args:[{name:`source`,description:`local path | git URL | @scope/create | type:locate`}],options:[B,{flags:`--type <type>`,description:`Force: builtin | local | npm | git | vite-plus | remote.`},{flags:`--name <name>`,description:`Display name.`},{flags:`--id <id>`,description:`Stable template id (default: inferred).`},V,{flags:`--ref <ref>`,description:`Git branch/tag/commit.`},{flags:`--registry <url>`,description:`Custom npm registry (default: the project package manager).`},{flags:`--subdir <dir>`,description:`Subdirectory within the source.`},{flags:`--no-global`,description:`Do not also register the source in the global registry.`},{flags:`--json`,description:`Print the updated registry as JSON.`}],run:async(n,r)=>{let i=O(String(n.source),r.cwd);n.type&&(i.type=n.type),n.name&&(i.name=String(n.name)),n.id&&(i.id=String(n.id)),n.kind&&(i.kind=n.kind),n.ref&&(i.ref=String(n.ref)),n.registry&&(i.registry=String(n.registry)),n.subdir&&(i.subdir=String(n.subdir));let a=i.id??(i.type===`builtin`?i.locate:i.type===`npm`?i.locate.split(`/`).pop()??i.locate:e.basename(i.locate.replace(/[\\/]+$/,``).replace(/\.git$/,``)).replace(/[^a-z0-9-_]/gi,`-`)),o=/* @__PURE__ */ new Set([...await h(r.cwd,{global:!1}),...j(r.cwd).sources.map(e=>e.id).filter(e=>!!e)]);if(a&&o.has(a)){if(G(n)){let e=await z({message:`Template id "${a}" already exists. New id:`,placeholder:w(a,o),defaultValue:w(a,o)});if(L(e))return K();i.id=String(e)}else throw Error(`template id "${a}" already exists; pass --id <id> to rename it.`)}else i.id===void 0&&a&&(i.id=a);i.type===`local`&&!P.existsSync(e.join(i.locate,`template.json`))&&u(i.locate,{name:i.name??e.basename(i.locate),kind:n.kind??`folder`});let s=k(r.cwd,i);if(n.global!==!1)try{i.type===`local`?f(i.locate,i.id??e.basename(i.locate)):d(i)}catch(e){t.warn(`could not register the source globally: ${String(e)}`)}n.json?t.raw(JSON.stringify(s,null,4)):t.info(`added ${i.type}:${i.locate} (${s.sources.length} source(s)).`)}},{name:`template:remove`,description:`Remove a source from .dbx/toolchain/templates.json.`,args:[{name:`id`,description:`Source id or type:locate.`}],options:[B,{flags:`--global`,description:`Remove the template from the global registry.`},{flags:`--json`,description:`Print the registry as JSON.`}],run:(e,n)=>{if(e.global){let n=x(String(e.id));if(e.json){t.raw(JSON.stringify({removed:n},null,4));return}if(!n){t.error(`no global template matching "${e.id}".`),process.exitCode=1;return}t.info(`removed global template "${e.id}".`);return}let{registry:r,removed:i}=M(n.cwd,String(e.id));e.json?t.raw(JSON.stringify(r,null,4)):i===0?(t.error(`no source matching "${e.id}".`),process.exitCode=1):t.info(`removed ${i} source(s) (${r.sources.length} left).`)}},{name:`template:registry`,description:`Manage the global template search paths (and sync them to the VS Code setting).`,options:[{flags:`--list`,description:`List the resolved search paths (default).`},{flags:`--add <path...>`,description:`Add global search path(s).`},{flags:`--remove <path...>`,description:`Remove global search path(s).`},{flags:`--set <path...>`,description:`Replace the global search paths.`},{flags:`--clear`,description:`Reset the global search paths to the default.`},{flags:`--vscode-dir <dir>`,description:`Record the VS Code user dir (its settings.json holds the paths).`},{flags:`--json`,description:`Print the resolved config as JSON.`}],run:e=>{let n=b();e.vscodeDir&&(n=T({vscodeDir:String(e.vscodeDir)}));let r=C(),i=r.paths;if(e.clear&&(i=[m()]),e.set&&(i=y(e.set)),e.add&&(i=y([...i,...e.add])),e.remove){let t=new Set(y(e.remove));i=i.filter(e=>!t.has(e))}let a=!!(e.clear||e.set||e.add||e.remove);a&&(n=T({registrySearchPaths:i}),(e.set||e.add||e.remove)&&n.vscodeDir&&D(n.vscodeDir,i));let o={paths:i,source:a?`cli`:r.source,defaultDir:m(),...n.vscodeDir?{vscodeDir:n.vscodeDir}:{}};if(e.json)t.raw(JSON.stringify(o,null,4));else{t.info(`global templates dir: ${m()}`);for(let e of i)t.info(` ${e}`);n.vscodeDir&&t.info(`VS Code user dir: ${n.vscodeDir}`),a&&t.info(`updated the CLI config and VS Code setting.`)}}},{name:`registry`,description:`List or manage the template/provider registries.`,options:[B,{flags:`--kind <kind>`,description:`What --add/--remove manages: templates | providers.`},{flags:`--add <path>`,description:`Add a registry path (or remote URL).`},{flags:`--remove <path>`,description:`Remove a registry path.`},{flags:`--set <path...>`,description:`Replace the registry search paths.`},{flags:`--clear`,description:`Clear the registry search paths.`},{flags:`--scope <scope>`,description:`project | global (default: global).`},{flags:`--json`,description:`Print the registries as JSON.`}],run:(e,n)=>{let l=e.cwd??n.cwd,u=e.scope??`global`,d=e.kind??`templates`,f=e.add??e.remove;if(e.set||e.clear){let t=e.clear?[]:y(e.set);d===`providers`?u===`global`?s(t):c(l,t):u===`global`?T({registrySearchPaths:t}):E(l,t)}else if(f){if(d===`providers`)u===`global`?e.add?r(f):a(f):e.add?i(l,f):o(l,f);else if(u===`global`){let t=b(),n=g(f),r=y(t.registrySearchPaths),i=e.add?[.../* @__PURE__ */ new Set([...r,n])]:r.filter(e=>e!==n);T({registrySearchPaths:i})}else e.add?p(l,f):S(l,f)}let m=_(l);if(e.json)t.raw(JSON.stringify(m,null,4));else for(let[e,n]of Object.entries(m)){t.info(e);for(let e of n)t.info(` [${e.scope}${e.remote?`, remote`:``}] ${e.path}`)}}},{name:`template:info`,description:`Show one template by id.`,args:[{name:`id`,description:`The template id.`}],options:[B,{flags:`--online`,description:`Resolve online sources.`},{flags:`--json`,description:`Print the template as JSON (the default).`}],run:async(e,n)=>{let r=e.cwd??n.cwd,i=(await A({cwd:r,config:n.config,online:!!e.online})).find(t=>t.id===e.id);i?t.raw(JSON.stringify(H(i),null,4)):(t.error(`unknown template "${e.id}".`),process.exitCode=1)}},{name:`create`,description:`Scaffold a project from a template (builtin, local or Vite+).`,options:[{flags:`-t, --template <id>`,description:`Template id (see template:list).`},V,{flags:`-n, --name <name>`,description:`Project / package name.`},{flags:`-s, --scope <scope>`,description:`npm scope, eg. @acme.`},{flags:`-o, --out <dir>`,description:`Output directory (default: cwd).`},B,{flags:`--var <pair...>`,description:`Template variables as key=value (repeatable).`},{flags:`--action <id...>`,description:`Action id to run after scaffolding (repeatable).`},{flags:`--online`,description:`Resolve online templates too.`},{flags:`--force`,description:`Overwrite existing files in the output directory.`},{flags:`--json`,description:`Print the result as JSON.`}],run:async(r,i)=>{let a=r.out??i.cwd,o=r.kind,s=await A({cwd:i.cwd,config:i.config,online:!!r.online}),c=G(r),l=String(r.template??``),u=r.name,d=r.scope;if(c&&!l&&!o){if(s.length===0)throw Error("No templates available. Pass --template <id> (see `dbx template:list`).");let e=await R({message:`Pick a template`,options:s.map(e=>({value:e.id,label:e.name,...e.description?{hint:e.description}:{}}))});if(L(e))return K();l=String(e)}if(c&&!u){let e=await z({message:`Project name`,placeholder:i.config.project?.name??`app`,defaultValue:i.config.project?.name??`app`});if(L(e))return K();u=String(e)}if(c&&!d){let e=await z({message:`npm scope (optional)`,placeholder:i.config.project?.scope??`@${u??`app`}`});if(L(e))return K();d=String(e)||void 0}let f=s.find(e=>e.id===l);if(!f&&!l&&o&&(f=s.find(e=>e.kind===o)),!f&&l&&(f={id:l,name:l,kind:o??`project`,source:{type:`vite-plus`,locate:l},online:!0}),!f)throw Error("No template selected. Pass --template <id> or --kind <kind> (see `dbx template:list`).");u===`.`&&(u=e.basename(e.resolve(a)));let p={...i.tokens,name:u??i.tokens.name??`app`,...d?{scope:d}:{}},m=U(r.var),h=new Set(r.action??[]);if(c){for(let e of f.variables??[]){if(e.name===`name`||e.name===`scope`||m[e.name]!==void 0)continue;let t=e.prompt??e.name;if(e.options&&e.options.length>0){let n=await R({message:t,options:e.options.map(e=>({value:e,label:e})),...e.default?{initialValue:e.default}:{}});if(L(n))return K();m[e.name]=String(n)}else{let n=await z({message:t,...e.default?{placeholder:e.default,defaultValue:e.default}:{}});if(L(n))return K();let r=String(n??``);m[e.name]=r||(e.default??``)}}for(let e of f.actions??[]){if(h.has(e.id))continue;let t=await I({message:e.prompt??`Run ${e.id}?`,initialValue:e.default??!1});if(L(t))return K();t&&h.add(e.id)}}for(let e of f.variables??[]){if(e.name===`name`||e.name===`scope`)continue;let t=p[e.name];m[e.name]===void 0&&(t==null||t===``)&&e.default!==void 0&&(m[e.name]=e.default)}let g=n(i.config.tsconfig),_=await N(f,{cwd:a,tokens:p,variables:m,actions:[...h],force:!!r.force,tsconfigRootFile:g?.rootFile??`tsconfig.workspaces.json`});if(r.json)t.raw(JSON.stringify({template:f.id,out:a,..._},null,4));else if(f.source.type===`vite-plus`||f.source.type===`npm`||f.source.type===`git`)_.code&&(process.exitCode=_.code);else for(let e of _.written)t.info(`Created ${e}`)}}]}export{q as templateCommands};
|