@ykdz/template 0.0.37 → 0.0.40
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/dist/application.d.ts +1 -52
- package/dist/application.js +0 -81
- package/dist/cli.js +14 -28
- package/dist/input-schemas.d.ts +30 -0
- package/dist/input-schemas.js +75 -0
- package/dist/main.d.ts +3 -14
- package/dist/main.js +496 -378
- package/dist/result-schemas.d.ts +222 -0
- package/dist/result-schemas.js +74 -0
- package/dist/standard-schema.d.ts +3 -0
- package/dist/standard-schema.js +29 -0
- package/node_modules/@standard-schema/spec/LICENSE +21 -0
- package/node_modules/@standard-schema/spec/README.md +198 -0
- package/node_modules/@standard-schema/spec/dist/index.cjs +18 -0
- package/node_modules/@standard-schema/spec/dist/index.d.cts +119 -0
- package/node_modules/@standard-schema/spec/dist/index.d.ts +119 -0
- package/node_modules/@standard-schema/spec/dist/index.js +0 -0
- package/node_modules/@standard-schema/spec/package.json +52 -0
- package/node_modules/@types/node/LICENSE +21 -0
- package/node_modules/@types/node/README.md +15 -0
- package/node_modules/@types/node/assert/strict.d.ts +111 -0
- package/node_modules/@types/node/assert.d.ts +1115 -0
- package/node_modules/@types/node/async_hooks.d.ts +619 -0
- package/node_modules/@types/node/buffer.buffer.d.ts +477 -0
- package/node_modules/@types/node/buffer.d.ts +1941 -0
- package/node_modules/@types/node/child_process.d.ts +1480 -0
- package/node_modules/@types/node/cluster.d.ts +578 -0
- package/node_modules/@types/node/compatibility/iterators.d.ts +21 -0
- package/node_modules/@types/node/console.d.ts +453 -0
- package/node_modules/@types/node/constants.d.ts +21 -0
- package/node_modules/@types/node/crypto.d.ts +5484 -0
- package/node_modules/@types/node/dgram.d.ts +715 -0
- package/node_modules/@types/node/diagnostics_channel.d.ts +576 -0
- package/node_modules/@types/node/dns/promises.d.ts +503 -0
- package/node_modules/@types/node/dns.d.ts +923 -0
- package/node_modules/@types/node/domain.d.ts +166 -0
- package/node_modules/@types/node/events.d.ts +967 -0
- package/node_modules/@types/node/fs/promises.d.ts +1354 -0
- package/node_modules/@types/node/fs.d.ts +4777 -0
- package/node_modules/@types/node/globals.d.ts +170 -0
- package/node_modules/@types/node/globals.typedarray.d.ts +41 -0
- package/node_modules/@types/node/http.d.ts +2246 -0
- package/node_modules/@types/node/http2.d.ts +2882 -0
- package/node_modules/@types/node/https.d.ts +585 -0
- package/node_modules/@types/node/index.d.ts +101 -0
- package/node_modules/@types/node/inspector.d.ts +323 -0
- package/node_modules/@types/node/inspector.generated.d.ts +4406 -0
- package/node_modules/@types/node/module.d.ts +844 -0
- package/node_modules/@types/node/net.d.ts +1197 -0
- package/node_modules/@types/node/os.d.ts +507 -0
- package/node_modules/@types/node/package.json +140 -0
- package/node_modules/@types/node/path.d.ts +200 -0
- package/node_modules/@types/node/perf_hooks.d.ts +1054 -0
- package/node_modules/@types/node/process.d.ts +2101 -0
- package/node_modules/@types/node/punycode.d.ts +117 -0
- package/node_modules/@types/node/querystring.d.ts +152 -0
- package/node_modules/@types/node/readline/promises.d.ts +161 -0
- package/node_modules/@types/node/readline.d.ts +600 -0
- package/node_modules/@types/node/repl.d.ts +438 -0
- package/node_modules/@types/node/sea.d.ts +162 -0
- package/node_modules/@types/node/sqlite.d.ts +1182 -0
- package/node_modules/@types/node/stream/consumers.d.ts +45 -0
- package/node_modules/@types/node/stream/promises.d.ts +90 -0
- package/node_modules/@types/node/stream/web.d.ts +596 -0
- package/node_modules/@types/node/stream.d.ts +1707 -0
- package/node_modules/@types/node/string_decoder.d.ts +67 -0
- package/node_modules/@types/node/test.d.ts +2656 -0
- package/node_modules/@types/node/timers/promises.d.ts +108 -0
- package/node_modules/@types/node/timers.d.ts +285 -0
- package/node_modules/@types/node/tls.d.ts +1314 -0
- package/node_modules/@types/node/trace_events.d.ts +197 -0
- package/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +473 -0
- package/node_modules/@types/node/ts5.6/compatibility/float16array.d.ts +71 -0
- package/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +36 -0
- package/node_modules/@types/node/ts5.6/index.d.ts +103 -0
- package/node_modules/@types/node/ts5.7/compatibility/float16array.d.ts +72 -0
- package/node_modules/@types/node/ts5.7/index.d.ts +103 -0
- package/node_modules/@types/node/tty.d.ts +209 -0
- package/node_modules/@types/node/url.d.ts +1103 -0
- package/node_modules/@types/node/util.d.ts +2376 -0
- package/node_modules/@types/node/v8.d.ts +1010 -0
- package/node_modules/@types/node/vm.d.ts +1160 -0
- package/node_modules/@types/node/wasi.d.ts +202 -0
- package/node_modules/@types/node/web-globals/abortcontroller.d.ts +34 -0
- package/node_modules/@types/node/web-globals/crypto.d.ts +32 -0
- package/node_modules/@types/node/web-globals/domexception.d.ts +68 -0
- package/node_modules/@types/node/web-globals/events.d.ts +97 -0
- package/node_modules/@types/node/web-globals/fetch.d.ts +62 -0
- package/node_modules/@types/node/web-globals/navigator.d.ts +25 -0
- package/node_modules/@types/node/web-globals/storage.d.ts +24 -0
- package/node_modules/@types/node/web-globals/streams.d.ts +22 -0
- package/node_modules/@types/node/worker_threads.d.ts +894 -0
- package/node_modules/@types/node/zlib.d.ts +768 -0
- package/node_modules/@valibot/to-json-schema/LICENSE.md +9 -0
- package/node_modules/@valibot/to-json-schema/README.md +475 -0
- package/node_modules/@valibot/to-json-schema/dist/index.cjs +800 -0
- package/node_modules/@valibot/to-json-schema/dist/index.d.cts +991 -0
- package/node_modules/@valibot/to-json-schema/dist/index.d.mts +991 -0
- package/node_modules/@valibot/to-json-schema/dist/index.min.cjs +1 -0
- package/node_modules/@valibot/to-json-schema/dist/index.min.mjs +1 -0
- package/node_modules/@valibot/to-json-schema/dist/index.mjs +795 -0
- package/node_modules/@valibot/to-json-schema/package.json +75 -0
- package/node_modules/@ykdz/cli-contract/LICENSE +21 -0
- package/node_modules/@ykdz/cli-contract/dist/atomic-variant-compiler.d.ts +17 -0
- package/node_modules/@ykdz/cli-contract/dist/atomic-variant-compiler.js +55 -0
- package/node_modules/@ykdz/cli-contract/dist/cli-contract.d.ts +1164 -0
- package/node_modules/@ykdz/cli-contract/dist/cli-contract.js +1408 -0
- package/node_modules/@ykdz/cli-contract/dist/cli-execution.d.ts +54 -0
- package/node_modules/@ykdz/cli-contract/dist/cli-execution.js +708 -0
- package/node_modules/@ykdz/cli-contract/dist/cli-invocation.d.ts +174 -0
- package/node_modules/@ykdz/cli-contract/dist/cli-invocation.js +524 -0
- package/node_modules/@ykdz/cli-contract/dist/cli-write-error.d.ts +10 -0
- package/node_modules/@ykdz/cli-contract/dist/cli-write-error.js +14 -0
- package/node_modules/@ykdz/cli-contract/dist/contract-definition-error.d.ts +260 -0
- package/node_modules/@ykdz/cli-contract/dist/contract-definition-error.js +130 -0
- package/node_modules/@ykdz/cli-contract/dist/contract-execution-error.d.ts +63 -0
- package/node_modules/@ykdz/cli-contract/dist/contract-execution-error.js +17 -0
- package/node_modules/@ykdz/cli-contract/dist/contract-schema-compiler.d.ts +6 -0
- package/node_modules/@ykdz/cli-contract/dist/contract-schema-compiler.js +532 -0
- package/node_modules/@ykdz/cli-contract/dist/contract-schema.d.ts +14 -0
- package/node_modules/@ykdz/cli-contract/dist/contract-schema.js +1 -0
- package/node_modules/@ykdz/cli-contract/dist/description.d.ts +2 -0
- package/node_modules/@ykdz/cli-contract/dist/description.js +13 -0
- package/node_modules/@ykdz/cli-contract/dist/index.d.ts +8 -0
- package/node_modules/@ykdz/cli-contract/dist/index.js +7 -0
- package/node_modules/@ykdz/cli-contract/dist/json-value.d.ts +4 -0
- package/node_modules/@ykdz/cli-contract/dist/json-value.js +64 -0
- package/node_modules/@ykdz/cli-contract/dist/node.d.ts +21 -0
- package/node_modules/@ykdz/cli-contract/dist/node.js +109 -0
- package/node_modules/@ykdz/cli-contract/dist/outcome-fact.d.ts +162 -0
- package/node_modules/@ykdz/cli-contract/dist/outcome-fact.js +113 -0
- package/node_modules/@ykdz/cli-contract/dist/outcome-wire.d.ts +53 -0
- package/node_modules/@ykdz/cli-contract/dist/outcome-wire.js +189 -0
- package/node_modules/@ykdz/cli-contract/dist/stream-variant-compiler.d.ts +16 -0
- package/node_modules/@ykdz/cli-contract/dist/stream-variant-compiler.js +45 -0
- package/node_modules/@ykdz/cli-contract/package.json +69 -0
- package/node_modules/@ykdz/template-builtin-presets/dist/src/foundation.d.ts +20 -0
- package/node_modules/@ykdz/template-builtin-presets/dist/src/foundation.js +27 -28
- package/node_modules/@ykdz/template-builtin-presets/dist/src/generation-record.d.ts +19 -0
- package/node_modules/@ykdz/template-builtin-presets/dist/src/generation-record.js +1 -1
- package/node_modules/@ykdz/template-builtin-presets/dist/src/index.d.ts +2 -1
- package/node_modules/@ykdz/template-builtin-presets/dist/src/index.js +2 -1
- package/node_modules/@ykdz/template-builtin-presets/dist/src/ts-cli/definition.js +9 -5
- package/node_modules/@ykdz/template-builtin-presets/dist/src/vike-app/definition.js +0 -4
- package/node_modules/@ykdz/template-builtin-presets/package.json +2 -1
- package/node_modules/@ykdz/template-builtin-presets/templates/foundation/AGENTS.md.template +10 -4
- package/node_modules/@ykdz/template-builtin-presets/templates/foundation/devcontainer.json +3 -0
- package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/publication/artifact.ts +128 -59
- package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/publication/handoff.ts +80 -8
- package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/publication/readiness.ts +7 -3
- package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/src/cli.ts +9 -19
- package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/src/main.ts +144 -60
- package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/src/standard-schema.ts +37 -0
- package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/test/e2e/journeys/lookup.journey.ts +71 -0
- package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/test/integration/command.test.ts +118 -59
- package/node_modules/@ykdz/template-core/dist/package-contribution.d.ts +0 -1
- package/node_modules/@ykdz/template-core/dist/pnpm-workspace.yaml +2 -1
- package/node_modules/@ykdz/template-core/dist/project-blueprint.d.ts +15 -0
- package/node_modules/@ykdz/template-core/dist/project-blueprint.js +1 -1
- package/node_modules/@ykdz/template-core/dist/project-github.d.ts +1 -1
- package/node_modules/undici-types/LICENSE +21 -0
- package/node_modules/undici-types/README.md +6 -0
- package/node_modules/undici-types/agent.d.ts +32 -0
- package/node_modules/undici-types/api.d.ts +43 -0
- package/node_modules/undici-types/balanced-pool.d.ts +30 -0
- package/node_modules/undici-types/cache-interceptor.d.ts +179 -0
- package/node_modules/undici-types/cache.d.ts +36 -0
- package/node_modules/undici-types/client-stats.d.ts +15 -0
- package/node_modules/undici-types/client.d.ts +123 -0
- package/node_modules/undici-types/connector.d.ts +36 -0
- package/node_modules/undici-types/content-type.d.ts +21 -0
- package/node_modules/undici-types/cookies.d.ts +30 -0
- package/node_modules/undici-types/diagnostics-channel.d.ts +74 -0
- package/node_modules/undici-types/dispatcher.d.ts +279 -0
- package/node_modules/undici-types/env-http-proxy-agent.d.ts +22 -0
- package/node_modules/undici-types/errors.d.ts +177 -0
- package/node_modules/undici-types/eventsource.d.ts +66 -0
- package/node_modules/undici-types/fetch.d.ts +211 -0
- package/node_modules/undici-types/formdata.d.ts +108 -0
- package/node_modules/undici-types/global-dispatcher.d.ts +9 -0
- package/node_modules/undici-types/global-origin.d.ts +7 -0
- package/node_modules/undici-types/h2c-client.d.ts +73 -0
- package/node_modules/undici-types/handlers.d.ts +15 -0
- package/node_modules/undici-types/header.d.ts +160 -0
- package/node_modules/undici-types/index.d.ts +91 -0
- package/node_modules/undici-types/interceptors.d.ts +80 -0
- package/node_modules/undici-types/mock-agent.d.ts +68 -0
- package/node_modules/undici-types/mock-call-history.d.ts +111 -0
- package/node_modules/undici-types/mock-client.d.ts +27 -0
- package/node_modules/undici-types/mock-errors.d.ts +12 -0
- package/node_modules/undici-types/mock-interceptor.d.ts +94 -0
- package/node_modules/undici-types/mock-pool.d.ts +27 -0
- package/node_modules/undici-types/package.json +55 -0
- package/node_modules/undici-types/patch.d.ts +29 -0
- package/node_modules/undici-types/pool-stats.d.ts +19 -0
- package/node_modules/undici-types/pool.d.ts +41 -0
- package/node_modules/undici-types/proxy-agent.d.ts +29 -0
- package/node_modules/undici-types/readable.d.ts +68 -0
- package/node_modules/undici-types/retry-agent.d.ts +8 -0
- package/node_modules/undici-types/retry-handler.d.ts +125 -0
- package/node_modules/undici-types/round-robin-pool.d.ts +41 -0
- package/node_modules/undici-types/snapshot-agent.d.ts +109 -0
- package/node_modules/undici-types/socks5-proxy-agent.d.ts +25 -0
- package/node_modules/undici-types/util.d.ts +18 -0
- package/node_modules/undici-types/utility.d.ts +7 -0
- package/node_modules/undici-types/webidl.d.ts +347 -0
- package/node_modules/undici-types/websocket.d.ts +188 -0
- package/package.json +5 -3
- package/dist/command-result.d.ts +0 -9
- package/dist/command-result.js +0 -231
- package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/test/e2e/journeys/greet.journey.ts +0 -46
- package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/test/unit/greet.test.ts +0 -15
- package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/devcontainer/docker-client.Dockerfile +0 -3
- package/node_modules/commander/LICENSE +0 -22
- package/node_modules/commander/Readme.md +0 -1172
- package/node_modules/commander/index.js +0 -21
- package/node_modules/commander/lib/argument.js +0 -147
- package/node_modules/commander/lib/command.js +0 -2790
- package/node_modules/commander/lib/error.js +0 -36
- package/node_modules/commander/lib/help.js +0 -731
- package/node_modules/commander/lib/option.js +0 -377
- package/node_modules/commander/lib/suggestSimilar.js +0 -99
- package/node_modules/commander/package-support.json +0 -19
- package/node_modules/commander/package.json +0 -64
- package/node_modules/commander/typings/index.d.ts +0 -1113
package/dist/application.d.ts
CHANGED
|
@@ -1,27 +1,13 @@
|
|
|
1
1
|
import { type GeneratedRepositoryPlan, type InitializationInputIssue, type PackageAdditionInputIssue, type NextStepInstruction, type ProjectBlueprint, type PublicationSetupHandoff, type ResolvedInitialization } from "@ykdz/template-builtin-presets";
|
|
2
2
|
import { type ProjectProjectionAction, type ProjectProjectionConflict } from "@ykdz/template-core/project-projection";
|
|
3
|
-
export type ConfirmationRequest = {
|
|
4
|
-
readonly message: string;
|
|
5
|
-
readonly prompt: string;
|
|
6
|
-
};
|
|
7
3
|
export type ApplicationRuntime = {
|
|
8
4
|
readonly cwd: string;
|
|
9
5
|
readonly env: Readonly<Record<string, string | undefined>>;
|
|
10
|
-
readonly tty: {
|
|
11
|
-
readonly stdin: boolean;
|
|
12
|
-
readonly stdout: boolean;
|
|
13
|
-
readonly stderr: boolean;
|
|
14
|
-
};
|
|
15
|
-
readonly confirmation: {
|
|
16
|
-
confirm(request: ConfirmationRequest): Promise<boolean>;
|
|
17
|
-
};
|
|
18
6
|
};
|
|
19
7
|
export type InitCommandOptions = {
|
|
20
8
|
readonly dir: string;
|
|
21
9
|
readonly preset: string;
|
|
22
|
-
readonly yes: boolean;
|
|
23
10
|
readonly dryRun: boolean;
|
|
24
|
-
readonly json: boolean;
|
|
25
11
|
readonly todo: boolean;
|
|
26
12
|
readonly name?: string;
|
|
27
13
|
readonly path?: string;
|
|
@@ -33,11 +19,8 @@ export type AddPackageCommandOptions = {
|
|
|
33
19
|
readonly path?: string;
|
|
34
20
|
readonly linkFrom: readonly string[];
|
|
35
21
|
readonly dryRun: boolean;
|
|
36
|
-
readonly json: boolean;
|
|
37
22
|
};
|
|
38
23
|
export type InitCommandResult = {
|
|
39
|
-
readonly schemaVersion: 1;
|
|
40
|
-
readonly command: "init";
|
|
41
24
|
readonly status: "success";
|
|
42
25
|
readonly dryRun: boolean;
|
|
43
26
|
readonly targetDir: string;
|
|
@@ -52,25 +35,11 @@ export type InitCommandResult = {
|
|
|
52
35
|
readonly path?: string;
|
|
53
36
|
};
|
|
54
37
|
} | {
|
|
55
|
-
readonly schemaVersion: 1;
|
|
56
|
-
readonly command: "init";
|
|
57
|
-
readonly status: "cancelled";
|
|
58
|
-
readonly code: "CANCELLED";
|
|
59
|
-
readonly targetDir: string;
|
|
60
|
-
} | {
|
|
61
|
-
readonly schemaVersion: 1;
|
|
62
|
-
readonly command: "init";
|
|
63
38
|
readonly status: "usage-error";
|
|
64
|
-
readonly code: "USAGE_INIT_INVALID";
|
|
65
39
|
readonly targetDir: string;
|
|
66
|
-
readonly issues: readonly
|
|
67
|
-
readonly code: "NON_INTERACTIVE_CONFIRMATION_REQUIRED";
|
|
68
|
-
})[];
|
|
40
|
+
readonly issues: readonly InitializationInputIssue[];
|
|
69
41
|
} | {
|
|
70
|
-
readonly schemaVersion: 1;
|
|
71
|
-
readonly command: "init";
|
|
72
42
|
readonly status: "operation-failure";
|
|
73
|
-
readonly code: "OPERATION_INIT_FAILED";
|
|
74
43
|
readonly phase: "preset" | "planning" | "preflight" | "materialization" | "render";
|
|
75
44
|
readonly targetDir: string;
|
|
76
45
|
readonly error: {
|
|
@@ -84,31 +53,21 @@ type PresetCatalogEntry = {
|
|
|
84
53
|
readonly description: string;
|
|
85
54
|
};
|
|
86
55
|
export type PresetCatalogCommandResult = {
|
|
87
|
-
readonly schemaVersion: 1;
|
|
88
|
-
readonly command: "presets";
|
|
89
56
|
readonly status: "success";
|
|
90
57
|
readonly presets: readonly PresetCatalogEntry[];
|
|
91
58
|
};
|
|
92
59
|
export type BlueprintValidationCommandResult = {
|
|
93
|
-
readonly schemaVersion: 1;
|
|
94
|
-
readonly command: "blueprint validate";
|
|
95
60
|
readonly status: "success";
|
|
96
61
|
readonly path: string;
|
|
97
62
|
} | {
|
|
98
|
-
readonly schemaVersion: 1;
|
|
99
|
-
readonly command: "blueprint validate";
|
|
100
63
|
readonly status: "invalid";
|
|
101
|
-
readonly code: "BLUEPRINT_INVALID";
|
|
102
64
|
readonly path: string;
|
|
103
65
|
readonly issues: readonly {
|
|
104
66
|
readonly path: string;
|
|
105
67
|
readonly message: string;
|
|
106
68
|
}[];
|
|
107
69
|
} | {
|
|
108
|
-
readonly schemaVersion: 1;
|
|
109
|
-
readonly command: "blueprint validate";
|
|
110
70
|
readonly status: "operation-failure";
|
|
111
|
-
readonly code: "OPERATION_BLUEPRINT_READ_FAILED" | "OPERATION_BLUEPRINT_PARSE_FAILED";
|
|
112
71
|
readonly path: string;
|
|
113
72
|
readonly reason: "not-found" | "permission-denied" | "not-a-file" | "unreadable" | "invalid-json";
|
|
114
73
|
readonly error: {
|
|
@@ -141,29 +100,19 @@ type PackageAdditionBusinessConflict = {
|
|
|
141
100
|
};
|
|
142
101
|
};
|
|
143
102
|
export type PackageAdditionCommandResult = {
|
|
144
|
-
readonly schemaVersion: 1;
|
|
145
|
-
readonly command: "add package";
|
|
146
103
|
readonly status: "success";
|
|
147
104
|
readonly dryRun: boolean;
|
|
148
105
|
readonly actions: readonly ProjectProjectionAction[];
|
|
149
106
|
} | {
|
|
150
|
-
readonly schemaVersion: 1;
|
|
151
|
-
readonly command: "add package";
|
|
152
107
|
readonly status: "conflict";
|
|
153
108
|
readonly dryRun: boolean;
|
|
154
109
|
readonly actions: readonly [];
|
|
155
110
|
readonly conflicts: readonly (PackageAdditionCoreConflict | PackageAdditionBusinessConflict)[];
|
|
156
111
|
} | {
|
|
157
|
-
readonly schemaVersion: 1;
|
|
158
|
-
readonly command: "add package";
|
|
159
112
|
readonly status: "usage-error";
|
|
160
|
-
readonly code: "USAGE_ADD_PACKAGE_INVALID";
|
|
161
113
|
readonly issues: readonly PackageAdditionInputIssue[];
|
|
162
114
|
} | {
|
|
163
|
-
readonly schemaVersion: 1;
|
|
164
|
-
readonly command: "add package";
|
|
165
115
|
readonly status: "operation-failure";
|
|
166
|
-
readonly code: "OPERATION_ADD_PACKAGE_FAILED";
|
|
167
116
|
readonly phase: "metadata" | "default" | "planning" | "reconciliation";
|
|
168
117
|
readonly error: {
|
|
169
118
|
readonly message: string;
|
package/dist/application.js
CHANGED
|
@@ -7,8 +7,6 @@ import { releaseToolchainSnapshot } from "@ykdz/template-core/release-toolchain-
|
|
|
7
7
|
import { renderNewProject } from "@ykdz/template-core/renderer";
|
|
8
8
|
export function listPresetCatalog() {
|
|
9
9
|
return {
|
|
10
|
-
schemaVersion: 1,
|
|
11
|
-
command: "presets",
|
|
12
10
|
status: "success",
|
|
13
11
|
presets: builtInPresetRegistry.all().map((definition) => ({
|
|
14
12
|
name: definition.metadata.name,
|
|
@@ -26,10 +24,6 @@ function toolchainReport() {
|
|
|
26
24
|
packageManagerPin: releaseToolchainSnapshot.packageManagerPin,
|
|
27
25
|
};
|
|
28
26
|
}
|
|
29
|
-
function formatRows(rows) {
|
|
30
|
-
const width = Math.max(...rows.map(([label]) => `${label}:`.length));
|
|
31
|
-
return rows.map(([label, value]) => ` ${`${label}:`.padEnd(width)} ${value}`);
|
|
32
|
-
}
|
|
33
27
|
function packageAdditionConflict(conflict) {
|
|
34
28
|
const { before, current, after, ...details } = conflict;
|
|
35
29
|
return {
|
|
@@ -52,10 +46,7 @@ export async function validateBlueprintFile(filePath, runtime) {
|
|
|
52
46
|
}
|
|
53
47
|
catch {
|
|
54
48
|
return {
|
|
55
|
-
schemaVersion: 1,
|
|
56
|
-
command: "blueprint validate",
|
|
57
49
|
status: "operation-failure",
|
|
58
|
-
code: "OPERATION_BLUEPRINT_PARSE_FAILED",
|
|
59
50
|
path: resolvedPath,
|
|
60
51
|
reason: "invalid-json",
|
|
61
52
|
error: {
|
|
@@ -67,17 +58,12 @@ export async function validateBlueprintFile(filePath, runtime) {
|
|
|
67
58
|
const result = validateProjectBlueprint(value);
|
|
68
59
|
if (!result.ok) {
|
|
69
60
|
return {
|
|
70
|
-
schemaVersion: 1,
|
|
71
|
-
command: "blueprint validate",
|
|
72
61
|
status: "invalid",
|
|
73
|
-
code: "BLUEPRINT_INVALID",
|
|
74
62
|
path: resolvedPath,
|
|
75
63
|
issues: result.issues,
|
|
76
64
|
};
|
|
77
65
|
}
|
|
78
66
|
return {
|
|
79
|
-
schemaVersion: 1,
|
|
80
|
-
command: "blueprint validate",
|
|
81
67
|
status: "success",
|
|
82
68
|
path: resolvedPath,
|
|
83
69
|
};
|
|
@@ -106,10 +92,7 @@ function readBlueprintFailure(filePath, error) {
|
|
|
106
92
|
"检查路径、文件权限和挂载状态后重试;若需要其他访问权限,请人工处理。",
|
|
107
93
|
];
|
|
108
94
|
return {
|
|
109
|
-
schemaVersion: 1,
|
|
110
|
-
command: "blueprint validate",
|
|
111
95
|
status: "operation-failure",
|
|
112
|
-
code: "OPERATION_BLUEPRINT_READ_FAILED",
|
|
113
96
|
path: filePath,
|
|
114
97
|
reason,
|
|
115
98
|
error: { message, suggestion },
|
|
@@ -126,10 +109,7 @@ function initOperationFailure(options) {
|
|
|
126
109
|
? "生成物料化"
|
|
127
110
|
: "目标目录渲染";
|
|
128
111
|
return {
|
|
129
|
-
schemaVersion: 1,
|
|
130
|
-
command: "init",
|
|
131
112
|
status: "operation-failure",
|
|
132
|
-
code: "OPERATION_INIT_FAILED",
|
|
133
113
|
phase: options.phase,
|
|
134
114
|
targetDir: options.targetDir,
|
|
135
115
|
error: {
|
|
@@ -139,18 +119,6 @@ function initOperationFailure(options) {
|
|
|
139
119
|
};
|
|
140
120
|
}
|
|
141
121
|
export async function runInit(options, runtime) {
|
|
142
|
-
if (!options.dryRun &&
|
|
143
|
-
!options.yes &&
|
|
144
|
-
(options.json || !runtime.tty.stdin || !runtime.tty.stdout)) {
|
|
145
|
-
return {
|
|
146
|
-
schemaVersion: 1,
|
|
147
|
-
command: "init",
|
|
148
|
-
status: "usage-error",
|
|
149
|
-
code: "USAGE_INIT_INVALID",
|
|
150
|
-
targetDir: options.dir,
|
|
151
|
-
issues: [{ code: "NON_INTERACTIVE_CONFIRMATION_REQUIRED" }],
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
122
|
const targetDir = path.resolve(runtime.cwd, options.dir);
|
|
155
123
|
const overrides = (options.name ?? options.path ?? options.scope) === undefined
|
|
156
124
|
? undefined
|
|
@@ -166,10 +134,7 @@ export async function runInit(options, runtime) {
|
|
|
166
134
|
});
|
|
167
135
|
if (input.status === "input-invalid") {
|
|
168
136
|
return {
|
|
169
|
-
schemaVersion: 1,
|
|
170
|
-
command: "init",
|
|
171
137
|
status: "usage-error",
|
|
172
|
-
code: "USAGE_INIT_INVALID",
|
|
173
138
|
targetDir: options.dir,
|
|
174
139
|
issues: input.issues,
|
|
175
140
|
};
|
|
@@ -181,10 +146,7 @@ export async function runInit(options, runtime) {
|
|
|
181
146
|
});
|
|
182
147
|
if (preparation.status === "input-invalid") {
|
|
183
148
|
return {
|
|
184
|
-
schemaVersion: 1,
|
|
185
|
-
command: "init",
|
|
186
149
|
status: "usage-error",
|
|
187
|
-
code: "USAGE_INIT_INVALID",
|
|
188
150
|
targetDir: options.dir,
|
|
189
151
|
issues: preparation.issues,
|
|
190
152
|
};
|
|
@@ -227,8 +189,6 @@ export async function runInit(options, runtime) {
|
|
|
227
189
|
});
|
|
228
190
|
}
|
|
229
191
|
const output = {
|
|
230
|
-
schemaVersion: 1,
|
|
231
|
-
command: "init",
|
|
232
192
|
status: "success",
|
|
233
193
|
dryRun: options.dryRun,
|
|
234
194
|
targetDir: options.dir,
|
|
@@ -245,35 +205,6 @@ export async function runInit(options, runtime) {
|
|
|
245
205
|
};
|
|
246
206
|
if (options.dryRun)
|
|
247
207
|
return output;
|
|
248
|
-
if (!options.yes &&
|
|
249
|
-
!(await runtime.confirmation.confirm({
|
|
250
|
-
message: [
|
|
251
|
-
"计划生成的项目",
|
|
252
|
-
"",
|
|
253
|
-
...formatRows([
|
|
254
|
-
["预设", resolved.preset],
|
|
255
|
-
["名称", resolved.packages.map(({ name }) => name).join(", ")],
|
|
256
|
-
[
|
|
257
|
-
"路径",
|
|
258
|
-
resolved.packages
|
|
259
|
-
.map(({ path: packagePath }) => packagePath)
|
|
260
|
-
.join(", "),
|
|
261
|
-
],
|
|
262
|
-
["Scope", resolved.scope],
|
|
263
|
-
["目标", options.dir],
|
|
264
|
-
["包数量", String(plan.blueprint.packages.length)],
|
|
265
|
-
]),
|
|
266
|
-
].join("\n"),
|
|
267
|
-
prompt: "生成这个项目?[y/N] ",
|
|
268
|
-
}))) {
|
|
269
|
-
return {
|
|
270
|
-
schemaVersion: 1,
|
|
271
|
-
command: "init",
|
|
272
|
-
status: "cancelled",
|
|
273
|
-
code: "CANCELLED",
|
|
274
|
-
targetDir: options.dir,
|
|
275
|
-
};
|
|
276
|
-
}
|
|
277
208
|
try {
|
|
278
209
|
await renderNewProject({
|
|
279
210
|
targetRoot: path.resolve(runtime.cwd, options.dir),
|
|
@@ -295,10 +226,7 @@ export async function runAddPackage(options, runtime) {
|
|
|
295
226
|
});
|
|
296
227
|
if (preparation.status === "input-invalid") {
|
|
297
228
|
return {
|
|
298
|
-
schemaVersion: 1,
|
|
299
|
-
command: "add package",
|
|
300
229
|
status: "usage-error",
|
|
301
|
-
code: "USAGE_ADD_PACKAGE_INVALID",
|
|
302
230
|
issues: preparation.issues,
|
|
303
231
|
};
|
|
304
232
|
}
|
|
@@ -307,8 +235,6 @@ export async function runAddPackage(options, runtime) {
|
|
|
307
235
|
}
|
|
308
236
|
if (preparation.status === "conflict") {
|
|
309
237
|
return {
|
|
310
|
-
schemaVersion: 1,
|
|
311
|
-
command: "add package",
|
|
312
238
|
status: "conflict",
|
|
313
239
|
dryRun: options.dryRun,
|
|
314
240
|
actions: [],
|
|
@@ -345,8 +271,6 @@ export async function runAddPackage(options, runtime) {
|
|
|
345
271
|
}
|
|
346
272
|
if (!reconciliation.ok) {
|
|
347
273
|
return {
|
|
348
|
-
schemaVersion: 1,
|
|
349
|
-
command: "add package",
|
|
350
274
|
status: "conflict",
|
|
351
275
|
dryRun: options.dryRun,
|
|
352
276
|
actions: [],
|
|
@@ -354,8 +278,6 @@ export async function runAddPackage(options, runtime) {
|
|
|
354
278
|
};
|
|
355
279
|
}
|
|
356
280
|
return {
|
|
357
|
-
schemaVersion: 1,
|
|
358
|
-
command: "add package",
|
|
359
281
|
status: "success",
|
|
360
282
|
dryRun: options.dryRun,
|
|
361
283
|
actions: reconciliation.actions,
|
|
@@ -363,10 +285,7 @@ export async function runAddPackage(options, runtime) {
|
|
|
363
285
|
}
|
|
364
286
|
function packageAdditionOperationFailure(phase, diagnostic) {
|
|
365
287
|
return {
|
|
366
|
-
schemaVersion: 1,
|
|
367
|
-
command: "add package",
|
|
368
288
|
status: "operation-failure",
|
|
369
|
-
code: "OPERATION_ADD_PACKAGE_FAILED",
|
|
370
289
|
phase,
|
|
371
290
|
error: diagnostic ?? {
|
|
372
291
|
message: "添加 Package 时发生操作失败。",
|
package/dist/cli.js
CHANGED
|
@@ -1,43 +1,29 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import { createInterface } from "node:readline/promises";
|
|
5
4
|
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { nodeCliOutput } from "@ykdz/cli-contract/node";
|
|
6
6
|
if (import.meta.url.endsWith(".ts")) {
|
|
7
7
|
process.env.TEMPLATE_REPOSITORY_ROOT ??= path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../..");
|
|
8
8
|
}
|
|
9
9
|
const require = createRequire(import.meta.url);
|
|
10
|
-
const packageManifest = require("../package.json");
|
|
11
10
|
const runtime = {
|
|
12
11
|
argv: process.argv,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
// 把进程事实的读取留在 runCli 的故障出口内。
|
|
13
|
+
get commandName() {
|
|
14
|
+
const manifest = require("../package.json");
|
|
15
|
+
const names = Object.keys(manifest.bin);
|
|
16
|
+
if (names.length !== 1)
|
|
17
|
+
throw new Error("CLI 包必须声明唯一命令。");
|
|
18
|
+
return names[0];
|
|
17
19
|
},
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
stdin: Boolean(process.stdin.isTTY),
|
|
22
|
-
stdout: Boolean(process.stdout.isTTY),
|
|
23
|
-
stderr: Boolean(process.stderr.isTTY),
|
|
20
|
+
write: nodeCliOutput({ stdout: process.stdout, stderr: process.stderr }),
|
|
21
|
+
get cwd() {
|
|
22
|
+
return process.cwd();
|
|
24
23
|
},
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
process.stdout.write(`${request.message}\n`);
|
|
29
|
-
const readline = createInterface({
|
|
30
|
-
input: process.stdin,
|
|
31
|
-
output: process.stdout,
|
|
32
|
-
});
|
|
33
|
-
try {
|
|
34
|
-
const answer = await readline.question(request.prompt);
|
|
35
|
-
return ["y", "yes"].includes(answer.trim().toLowerCase());
|
|
36
|
-
}
|
|
37
|
-
finally {
|
|
38
|
-
readline.close();
|
|
39
|
-
}
|
|
40
|
-
},
|
|
24
|
+
env: process.env,
|
|
25
|
+
get version() {
|
|
26
|
+
return require("../package.json").version;
|
|
41
27
|
},
|
|
42
28
|
};
|
|
43
29
|
const { runCli } = await import("#main");
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export declare function initializationInputSchema(cwd: string): import("@valibot/to-json-schema").StandardJsonSchema<{
|
|
2
|
+
dir: string;
|
|
3
|
+
preset: string;
|
|
4
|
+
name?: string | undefined;
|
|
5
|
+
path?: string | undefined;
|
|
6
|
+
scope?: string | undefined;
|
|
7
|
+
dryRun?: boolean | undefined;
|
|
8
|
+
todo?: boolean | undefined;
|
|
9
|
+
}, {
|
|
10
|
+
dir: string;
|
|
11
|
+
preset: string;
|
|
12
|
+
name?: string | undefined;
|
|
13
|
+
path?: string | undefined;
|
|
14
|
+
scope?: string | undefined;
|
|
15
|
+
dryRun: boolean;
|
|
16
|
+
todo: boolean;
|
|
17
|
+
}>;
|
|
18
|
+
export declare const packageAdditionInputSchema: import("@valibot/to-json-schema").StandardJsonSchema<{
|
|
19
|
+
preset: string;
|
|
20
|
+
name: string;
|
|
21
|
+
path?: string | undefined;
|
|
22
|
+
linkFrom?: string[] | undefined;
|
|
23
|
+
dryRun?: boolean | undefined;
|
|
24
|
+
}, {
|
|
25
|
+
preset: string;
|
|
26
|
+
name: string;
|
|
27
|
+
path?: string | undefined;
|
|
28
|
+
linkFrom: string[];
|
|
29
|
+
dryRun: boolean;
|
|
30
|
+
}>;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { validateGeneratedRepositoryInitializationInput, validateGeneratedRepositoryPackageAdditionInput, } from "@ykdz/template-builtin-presets";
|
|
3
|
+
import * as v from "valibot";
|
|
4
|
+
import { listPresetCatalog } from "./application.js";
|
|
5
|
+
import { standardSchema } from "./standard-schema.js";
|
|
6
|
+
const initializationMessages = {
|
|
7
|
+
PRESET_UNKNOWN: "请选择有效的预设。",
|
|
8
|
+
FIXED_TOPOLOGY_OVERRIDE: "固定拓扑预设不支持覆盖初始包名称或路径。",
|
|
9
|
+
INVALID_PACKAGE_NAME: "--name 必须是有效的无 scope 包叶名称。",
|
|
10
|
+
INVALID_PACKAGE_PATH: "--path 必须恰好包含两个安全路径段。",
|
|
11
|
+
RESERVED_PACKAGE_PATH: "--path 不能使用保留的工作区目录。",
|
|
12
|
+
INVALID_PACKAGE_SCOPE: "--scope 必须是不含空白字符的有效 npm scope。",
|
|
13
|
+
INVALID_REPOSITORY_SCOPE: "目标目录名无法作为默认 scope,请指定 --scope。",
|
|
14
|
+
CONFLICTING_PACKAGE_IDENTITY: "初始包身份与基础配置包冲突。",
|
|
15
|
+
};
|
|
16
|
+
export function initializationInputSchema(cwd) {
|
|
17
|
+
return standardSchema(v.pipe(v.object({
|
|
18
|
+
dir: v.pipe(v.string(), v.nonEmpty()),
|
|
19
|
+
preset: v.picklist(listPresetCatalog().presets.map(({ name }) => name)),
|
|
20
|
+
name: v.optional(v.pipe(v.string(), v.description("无 scope 的 npm 包叶名称;仅可配置主包的预设允许覆盖。"))),
|
|
21
|
+
path: v.optional(v.pipe(v.string(), v.description("两个安全路径段;不能使用保留目录;仅可配置主包的预设允许覆盖。"))),
|
|
22
|
+
scope: v.optional(v.pipe(v.string(), v.description("有效 npm scope;省略时使用目标目录名。"))),
|
|
23
|
+
dryRun: v.optional(v.boolean(), false),
|
|
24
|
+
todo: v.optional(v.boolean(), true),
|
|
25
|
+
}), v.rawCheck(({ dataset, addIssue }) => {
|
|
26
|
+
if (!dataset.typed)
|
|
27
|
+
return;
|
|
28
|
+
const { dir, preset, name, path: packagePath, scope } = dataset.value;
|
|
29
|
+
const result = validateGeneratedRepositoryInitializationInput({
|
|
30
|
+
preset,
|
|
31
|
+
targetDir: path.resolve(cwd, dir),
|
|
32
|
+
overrides: {
|
|
33
|
+
...(name === undefined ? {} : { name }),
|
|
34
|
+
...(packagePath === undefined ? {} : { path: packagePath }),
|
|
35
|
+
...(scope === undefined ? {} : { scope }),
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
if (result.status === "input-invalid") {
|
|
39
|
+
for (const issue of result.issues)
|
|
40
|
+
addIssue({ message: initializationMessages[issue.code] });
|
|
41
|
+
}
|
|
42
|
+
})), ["raw_check"]);
|
|
43
|
+
}
|
|
44
|
+
const additionMessages = {
|
|
45
|
+
PRESET_UNKNOWN: "请选择有效的预设。",
|
|
46
|
+
PRESET_NOT_ADDABLE: "该预设不支持新增包。",
|
|
47
|
+
INVALID_PACKAGE_NAME: "--name 必须是有效的无 scope 包叶名称。",
|
|
48
|
+
INVALID_PACKAGE_PATH: "--path 必须恰好包含两个安全路径段。",
|
|
49
|
+
RESERVED_PACKAGE_PATH: "--path 不能使用保留工作区目录。",
|
|
50
|
+
INVALID_LINK_FROM: "--link-from 必须恰好包含两个安全路径段。",
|
|
51
|
+
RESERVED_LINK_FROM: "--link-from 不能使用保留工作区目录。",
|
|
52
|
+
UNKNOWN_LINK_FROM: "指定的消费包不存在。",
|
|
53
|
+
UNSUPPORTED_LINK: "指定的包角色不支持此链接。",
|
|
54
|
+
};
|
|
55
|
+
export const packageAdditionInputSchema = standardSchema(v.pipe(v.object({
|
|
56
|
+
preset: v.picklist(listPresetCatalog().presets.map(({ name }) => name)),
|
|
57
|
+
name: v.pipe(v.string(), v.description("无 scope 的 npm 包叶名称。")),
|
|
58
|
+
path: v.optional(v.pipe(v.string(), v.description("两个安全路径段,不能使用保留工作区目录。"))),
|
|
59
|
+
linkFrom: v.optional(v.array(v.pipe(v.string(), v.description("消费包路径:两个安全路径段,不能使用保留工作区目录。"))), []),
|
|
60
|
+
dryRun: v.optional(v.boolean(), false),
|
|
61
|
+
}), v.rawCheck(({ dataset, addIssue }) => {
|
|
62
|
+
if (!dataset.typed)
|
|
63
|
+
return;
|
|
64
|
+
const input = dataset.value;
|
|
65
|
+
const result = validateGeneratedRepositoryPackageAdditionInput({
|
|
66
|
+
preset: input.preset,
|
|
67
|
+
packageLeafName: input.name,
|
|
68
|
+
linkFrom: input.linkFrom,
|
|
69
|
+
...(input.path === undefined ? {} : { packagePath: input.path }),
|
|
70
|
+
});
|
|
71
|
+
if (result.status === "input-invalid") {
|
|
72
|
+
for (const issue of result.issues)
|
|
73
|
+
addIssue({ message: additionMessages[issue.code] });
|
|
74
|
+
}
|
|
75
|
+
})), ["raw_check"]);
|
package/dist/main.d.ts
CHANGED
|
@@ -1,20 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type WriteCliOutput } from "@ykdz/cli-contract";
|
|
2
2
|
import { type ApplicationRuntime } from "./application.ts";
|
|
3
3
|
export type CliRuntime = ApplicationRuntime & {
|
|
4
4
|
readonly argv: readonly string[];
|
|
5
|
-
readonly
|
|
6
|
-
|
|
7
|
-
readonly stdout: {
|
|
8
|
-
write(chunk: string): unknown;
|
|
9
|
-
};
|
|
10
|
-
readonly stderr: {
|
|
11
|
-
write(chunk: string): unknown;
|
|
12
|
-
};
|
|
13
|
-
};
|
|
5
|
+
readonly write: WriteCliOutput;
|
|
6
|
+
readonly commandName: string;
|
|
14
7
|
readonly version: string;
|
|
15
8
|
};
|
|
16
|
-
export declare function createCliCommand(runtime: CliRuntime, commanderOutput?: {
|
|
17
|
-
stdout: string;
|
|
18
|
-
stderr: string;
|
|
19
|
-
}): Command;
|
|
20
9
|
export declare function runCli(runtime: CliRuntime): Promise<number>;
|