@ykdz/template 0.0.6 → 0.0.7
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/src/cli.js +75 -30
- package/package.json +1 -1
package/dist/src/cli.js
CHANGED
|
@@ -12,7 +12,12 @@ import { renderNewProject } from "./renderer.js";
|
|
|
12
12
|
import { resolveToolchainVersions, } from "./toolchain-resolution.js";
|
|
13
13
|
function usage() {
|
|
14
14
|
return [
|
|
15
|
+
"Project Kit template CLI",
|
|
16
|
+
"",
|
|
15
17
|
"Usage:",
|
|
18
|
+
" template <command> [options]",
|
|
19
|
+
"",
|
|
20
|
+
"Commands:",
|
|
16
21
|
" template init <dir> --preset <name> --yes",
|
|
17
22
|
" template add package --preset <name> --name <name> [--path <package-path>] [--link-from <package-path>]...",
|
|
18
23
|
" template presets",
|
|
@@ -24,14 +29,14 @@ function usage() {
|
|
|
24
29
|
" template blueprint validate <path>",
|
|
25
30
|
"",
|
|
26
31
|
"Options:",
|
|
27
|
-
" --preset <name>
|
|
28
|
-
" --name <name>
|
|
29
|
-
" --path <path>
|
|
32
|
+
" --preset <name> Project preset to generate",
|
|
33
|
+
" --name <name> Package name to add",
|
|
34
|
+
" --path <path> Two-segment Package Path to add",
|
|
30
35
|
" --link-from <path> Existing consumer Package Path to link from; repeatable",
|
|
31
|
-
" --scope <name>
|
|
32
|
-
" --yes
|
|
33
|
-
" --dry-run
|
|
34
|
-
" --json
|
|
36
|
+
" --scope <name> Package scope for workspace package names",
|
|
37
|
+
" --yes Accept defaults for non-interactive generation",
|
|
38
|
+
" --dry-run Print the planned generation without writing files",
|
|
39
|
+
" --json Print machine-readable output",
|
|
35
40
|
].join("\n");
|
|
36
41
|
}
|
|
37
42
|
function printJson(value) {
|
|
@@ -56,10 +61,18 @@ function formatValidationIssues(issues) {
|
|
|
56
61
|
.map((issue) => ` - ${issue.path}: ${issue.message}`)
|
|
57
62
|
.join("\n");
|
|
58
63
|
}
|
|
64
|
+
function formatFieldRows(rows) {
|
|
65
|
+
const width = Math.max(...rows.map(([label]) => `${label}:`.length));
|
|
66
|
+
return rows.map(([label, value]) => ` ${`${label}:`.padEnd(width)} ${value}`);
|
|
67
|
+
}
|
|
59
68
|
function formatPresetCatalog() {
|
|
60
69
|
return [
|
|
61
70
|
"Built-in presets",
|
|
62
|
-
|
|
71
|
+
"",
|
|
72
|
+
...formatFieldRows(builtInPresets.map((preset) => [
|
|
73
|
+
preset.name,
|
|
74
|
+
`${preset.title} (${preset.generation}) - ${preset.description}`,
|
|
75
|
+
])),
|
|
63
76
|
].join("\n");
|
|
64
77
|
}
|
|
65
78
|
function parseInitOptions(args) {
|
|
@@ -145,23 +158,29 @@ function blueprintForInit(options) {
|
|
|
145
158
|
});
|
|
146
159
|
}
|
|
147
160
|
function formatBlueprintSummary(targetDir, blueprint) {
|
|
148
|
-
const
|
|
149
|
-
"
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
` Project kind: ${blueprint.projectKind}`,
|
|
161
|
+
const rows = [
|
|
162
|
+
["Target", targetDir],
|
|
163
|
+
["Preset", blueprint.preset],
|
|
164
|
+
["Project kind", blueprint.projectKind],
|
|
153
165
|
];
|
|
154
166
|
if (blueprint.packageManager) {
|
|
155
|
-
|
|
156
|
-
}
|
|
157
|
-
if (blueprint.packages) {
|
|
158
|
-
lines.push(" Packages:");
|
|
159
|
-
for (const pkg of blueprint.packages) {
|
|
160
|
-
lines.push(` - ${pkg.name} (${pkg.path})`);
|
|
161
|
-
}
|
|
167
|
+
rows.push(["Package manager", blueprint.packageManager]);
|
|
162
168
|
}
|
|
163
|
-
|
|
164
|
-
|
|
169
|
+
return [
|
|
170
|
+
"Project Blueprint",
|
|
171
|
+
"",
|
|
172
|
+
...formatFieldRows(rows),
|
|
173
|
+
...(blueprint.packages
|
|
174
|
+
? [
|
|
175
|
+
"",
|
|
176
|
+
" Packages:",
|
|
177
|
+
...blueprint.packages.map((pkg) => ` - ${pkg.name} (${pkg.path})`),
|
|
178
|
+
]
|
|
179
|
+
: []),
|
|
180
|
+
"",
|
|
181
|
+
" Features:",
|
|
182
|
+
...blueprint.features.map((feature) => ` - ${feature}`),
|
|
183
|
+
].join("\n");
|
|
165
184
|
}
|
|
166
185
|
function formatProjectionNextSteps(targetDir, projectionPlan) {
|
|
167
186
|
const steps = planNextStepInstructionsForProjection({
|
|
@@ -170,7 +189,11 @@ function formatProjectionNextSteps(targetDir, projectionPlan) {
|
|
|
170
189
|
});
|
|
171
190
|
return [
|
|
172
191
|
"Next Step Instructions:",
|
|
173
|
-
|
|
192
|
+
"",
|
|
193
|
+
...steps.flatMap((step, index) => [
|
|
194
|
+
` ${index + 1}. ${step.label}`,
|
|
195
|
+
` ${step.display}`,
|
|
196
|
+
]),
|
|
174
197
|
].join("\n");
|
|
175
198
|
}
|
|
176
199
|
function toolchainReport(toolchain) {
|
|
@@ -184,9 +207,12 @@ function toolchainReport(toolchain) {
|
|
|
184
207
|
function formatToolchainReport(toolchain) {
|
|
185
208
|
return [
|
|
186
209
|
"Toolchain Resolution:",
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
210
|
+
"",
|
|
211
|
+
...formatFieldRows([
|
|
212
|
+
["Source", toolchain.source],
|
|
213
|
+
["Node LTS major", toolchain.nodeLtsMajor.value],
|
|
214
|
+
["Package Manager Pin", toolchain.packageManagerPin.value],
|
|
215
|
+
]),
|
|
190
216
|
...toolchain.diagnostics.map((diagnostic) => ` ${diagnostic}`),
|
|
191
217
|
].join("\n");
|
|
192
218
|
}
|
|
@@ -256,10 +282,19 @@ function printInitComplete(options, blueprint, generationContext) {
|
|
|
256
282
|
});
|
|
257
283
|
return;
|
|
258
284
|
}
|
|
259
|
-
console.log(
|
|
285
|
+
console.log([
|
|
286
|
+
"Initialized project",
|
|
287
|
+
"",
|
|
288
|
+
...formatFieldRows([
|
|
289
|
+
["Preset", options.preset],
|
|
290
|
+
["Target", options.dir],
|
|
291
|
+
]),
|
|
292
|
+
].join("\n"));
|
|
260
293
|
if (generationContext) {
|
|
294
|
+
console.log("");
|
|
261
295
|
console.log(formatToolchainReport(generationContext.toolchain));
|
|
262
296
|
}
|
|
297
|
+
console.log("");
|
|
263
298
|
console.log(formatProjectionNextSteps(options.dir, projectionPlan));
|
|
264
299
|
}
|
|
265
300
|
function isInteractiveTerminal() {
|
|
@@ -438,8 +473,10 @@ async function main(args) {
|
|
|
438
473
|
}
|
|
439
474
|
console.log(formatBlueprintSummary(options.dir, blueprint));
|
|
440
475
|
if (generationContext) {
|
|
476
|
+
console.log("");
|
|
441
477
|
console.log(formatToolchainReport(generationContext.toolchain));
|
|
442
478
|
}
|
|
479
|
+
console.log("");
|
|
443
480
|
console.log(formatProjectionNextSteps(options.dir, projectionPlan));
|
|
444
481
|
return;
|
|
445
482
|
}
|
|
@@ -463,7 +500,15 @@ async function main(args) {
|
|
|
463
500
|
path: options.path,
|
|
464
501
|
linkFrom: options.linkFrom,
|
|
465
502
|
});
|
|
466
|
-
console.log(
|
|
503
|
+
console.log([
|
|
504
|
+
"Added package",
|
|
505
|
+
"",
|
|
506
|
+
...formatFieldRows([
|
|
507
|
+
["Preset", options.preset],
|
|
508
|
+
["Name", options.name],
|
|
509
|
+
...(options.path ? [["Path", options.path]] : []),
|
|
510
|
+
]),
|
|
511
|
+
].join("\n"));
|
|
467
512
|
return;
|
|
468
513
|
}
|
|
469
514
|
if (command === "--help" || command === "-h") {
|
|
@@ -474,8 +519,8 @@ async function main(args) {
|
|
|
474
519
|
}
|
|
475
520
|
main(process.argv.slice(2)).catch((error) => {
|
|
476
521
|
const message = error instanceof Error ? error.message : String(error);
|
|
477
|
-
console.error(message);
|
|
522
|
+
console.error(`Error: ${message}`);
|
|
478
523
|
console.error("");
|
|
479
|
-
console.error(usage
|
|
524
|
+
console.error("Run `template --help` for usage.");
|
|
480
525
|
process.exitCode = 1;
|
|
481
526
|
});
|