@ykdz/template 0.0.1 → 0.0.2
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/cli.js +66 -89
- package/dist/declarations.js +1 -1
- package/dist/devcontainer.d.ts +17 -0
- package/dist/devcontainer.d.ts.map +1 -0
- package/dist/devcontainer.js +23 -0
- package/dist/generation-context.d.ts +24 -0
- package/dist/generation-context.d.ts.map +1 -0
- package/dist/generation-context.js +12 -0
- package/dist/hono-api.d.ts +1 -0
- package/dist/hono-api.d.ts.map +1 -1
- package/dist/hono-api.js +55 -53
- package/dist/module-graph.d.ts +45 -0
- package/dist/module-graph.d.ts.map +1 -0
- package/dist/module-graph.js +187 -0
- package/dist/next-step-instructions.d.ts +22 -0
- package/dist/next-step-instructions.d.ts.map +1 -0
- package/dist/next-step-instructions.js +99 -0
- package/dist/project-github.d.ts +36 -0
- package/dist/project-github.d.ts.map +1 -0
- package/dist/project-github.js +96 -0
- package/dist/renderer.d.ts.map +1 -1
- package/dist/renderer.js +0 -3
- package/dist/rust-bin.d.ts +7 -1
- package/dist/rust-bin.d.ts.map +1 -1
- package/dist/rust-bin.js +70 -36
- package/dist/toolchain-resolution.d.ts +35 -0
- package/dist/toolchain-resolution.d.ts.map +1 -0
- package/dist/toolchain-resolution.js +192 -0
- package/dist/ts-lib.d.ts +7 -1
- package/dist/ts-lib.d.ts.map +1 -1
- package/dist/ts-lib.js +87 -54
- package/dist/vue-app.d.ts +1 -0
- package/dist/vue-app.d.ts.map +1 -1
- package/dist/vue-app.js +70 -68
- package/dist/vue-hono-app.d.ts +3 -0
- package/dist/vue-hono-app.d.ts.map +1 -1
- package/dist/vue-hono-app.js +111 -107
- package/package.json +2 -1
- package/templates/rust-bin/.github/dependabot.yml +4 -0
- package/templates/rust-bin/.github/workflows/check.yml +6 -1
- package/dist/post-commands.d.ts +0 -40
- package/dist/post-commands.d.ts.map +0 -1
- package/dist/post-commands.js +0 -154
package/dist/cli.js
CHANGED
|
@@ -8,8 +8,10 @@ import { initTsLibProject } from "./ts-lib.js";
|
|
|
8
8
|
import { initVueHonoAppProject } from "./vue-hono-app.js";
|
|
9
9
|
import { initVueAppProject } from "./vue-app.js";
|
|
10
10
|
import { addPackage } from "./package-addition.js";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
11
|
+
import { assembleGenerationContext } from "./generation-context.js";
|
|
12
|
+
import { planNextStepInstructions, } from "./next-step-instructions.js";
|
|
13
|
+
import { blueprintJsonSchema, builtInPresets, presetFileJsonSchema, validatePresetFile, validateProjectBlueprint, } from "./declarations.js";
|
|
14
|
+
import { resolveToolchainVersions, } from "./toolchain-resolution.js";
|
|
13
15
|
function usage() {
|
|
14
16
|
return [
|
|
15
17
|
"Usage:",
|
|
@@ -26,9 +28,8 @@ function usage() {
|
|
|
26
28
|
" --name <name> Package name to add",
|
|
27
29
|
" --scope <name> Package scope for workspace package names",
|
|
28
30
|
" --yes Accept defaults for non-interactive generation",
|
|
29
|
-
" --ready Run template-maintained Post Commands after writing files",
|
|
30
31
|
" --dry-run Print the planned generation without writing files",
|
|
31
|
-
" --json Print machine-readable output"
|
|
32
|
+
" --json Print machine-readable output",
|
|
32
33
|
].join("\n");
|
|
33
34
|
}
|
|
34
35
|
function printJson(value) {
|
|
@@ -54,7 +55,7 @@ function formatValidationIssues(issues) {
|
|
|
54
55
|
function formatPresetCatalog() {
|
|
55
56
|
return [
|
|
56
57
|
"Built-in presets",
|
|
57
|
-
...builtInPresets.map((preset) => ` ${preset.name.padEnd(8)} ${preset.title} (${preset.generation}) - ${preset.description}`)
|
|
58
|
+
...builtInPresets.map((preset) => ` ${preset.name.padEnd(8)} ${preset.title} (${preset.generation}) - ${preset.description}`),
|
|
58
59
|
].join("\n");
|
|
59
60
|
}
|
|
60
61
|
function parseInitOptions(args) {
|
|
@@ -63,7 +64,6 @@ function parseInitOptions(args) {
|
|
|
63
64
|
let yes = false;
|
|
64
65
|
let dryRun = false;
|
|
65
66
|
let json = false;
|
|
66
|
-
let ready = false;
|
|
67
67
|
let scope;
|
|
68
68
|
for (let index = 2; index < args.length; index += 1) {
|
|
69
69
|
const arg = args[index];
|
|
@@ -75,10 +75,6 @@ function parseInitOptions(args) {
|
|
|
75
75
|
dryRun = true;
|
|
76
76
|
continue;
|
|
77
77
|
}
|
|
78
|
-
if (arg === "--ready") {
|
|
79
|
-
ready = true;
|
|
80
|
-
continue;
|
|
81
|
-
}
|
|
82
78
|
if (arg === "--json") {
|
|
83
79
|
json = true;
|
|
84
80
|
continue;
|
|
@@ -106,7 +102,7 @@ function parseInitOptions(args) {
|
|
|
106
102
|
if (!dir) {
|
|
107
103
|
throw new Error("init requires a target directory");
|
|
108
104
|
}
|
|
109
|
-
return { dir, preset, yes, dryRun, json,
|
|
105
|
+
return { dir, preset, yes, dryRun, json, scope };
|
|
110
106
|
}
|
|
111
107
|
function normalizeNpmScope(value) {
|
|
112
108
|
if (value !== value.trim() || /\s/.test(value)) {
|
|
@@ -139,7 +135,7 @@ function blueprintForInit(options) {
|
|
|
139
135
|
schemaVersion: 1,
|
|
140
136
|
preset: preset.name,
|
|
141
137
|
projectKind: preset.supportedProjectKinds[0],
|
|
142
|
-
features: [...preset.features]
|
|
138
|
+
features: [...preset.features],
|
|
143
139
|
};
|
|
144
140
|
if (preset.supportedPackageManagers[0]) {
|
|
145
141
|
blueprint.packageManager = preset.supportedPackageManagers[0];
|
|
@@ -147,7 +143,7 @@ function blueprintForInit(options) {
|
|
|
147
143
|
if (preset.name === "vue-hono-app") {
|
|
148
144
|
blueprint.packages = [
|
|
149
145
|
{ name: `@${packageScope}/web`, path: "apps/web" },
|
|
150
|
-
{ name: `@${packageScope}/api`, path: "apps/api" }
|
|
146
|
+
{ name: `@${packageScope}/api`, path: "apps/api" },
|
|
151
147
|
];
|
|
152
148
|
}
|
|
153
149
|
return blueprint;
|
|
@@ -157,7 +153,7 @@ function formatBlueprintSummary(targetDir, blueprint) {
|
|
|
157
153
|
"Project Blueprint",
|
|
158
154
|
` Target: ${targetDir}`,
|
|
159
155
|
` Preset: ${blueprint.preset}`,
|
|
160
|
-
` Project kind: ${blueprint.projectKind}
|
|
156
|
+
` Project kind: ${blueprint.projectKind}`,
|
|
161
157
|
];
|
|
162
158
|
if (blueprint.packageManager) {
|
|
163
159
|
lines.push(` Package manager: ${blueprint.packageManager}`);
|
|
@@ -171,64 +167,54 @@ function formatBlueprintSummary(targetDir, blueprint) {
|
|
|
171
167
|
lines.push(` Features: ${blueprint.features.join(", ")}`);
|
|
172
168
|
return lines.join("\n");
|
|
173
169
|
}
|
|
174
|
-
function formatPostCommand(command) {
|
|
175
|
-
return [command.command, ...command.args].join(" ");
|
|
176
|
-
}
|
|
177
|
-
function formatPostCommandPlan(commands) {
|
|
178
|
-
if (commands.length === 0) {
|
|
179
|
-
return ["Post Commands:", " (none)"].join("\n");
|
|
180
|
-
}
|
|
181
|
-
return [
|
|
182
|
-
"Post Commands:",
|
|
183
|
-
...commands.map((command) => ` ${command.label}: ${formatPostCommand(command)}`)
|
|
184
|
-
].join("\n");
|
|
185
|
-
}
|
|
186
|
-
function nextStepsForPreset(preset) {
|
|
187
|
-
if (preset === "rust-bin") {
|
|
188
|
-
return ["cd <target>", "./scripts/check"];
|
|
189
|
-
}
|
|
190
|
-
return ["cd <target>", "pnpm install", "pnpm run check"];
|
|
191
|
-
}
|
|
192
170
|
function formatNextSteps(targetDir, preset) {
|
|
171
|
+
const plan = planNextStepInstructions({ preset, targetDir });
|
|
193
172
|
return [
|
|
194
|
-
"Next
|
|
195
|
-
...
|
|
173
|
+
"Next Step Instructions:",
|
|
174
|
+
...plan.steps.map((step) => ` ${step.label}: ${step.display}`),
|
|
196
175
|
].join("\n");
|
|
197
176
|
}
|
|
198
|
-
function
|
|
177
|
+
function toolchainReport(toolchain) {
|
|
199
178
|
return {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
args: [...command.args],
|
|
205
|
-
cwd: command.cwd
|
|
206
|
-
})),
|
|
207
|
-
run: executions
|
|
208
|
-
.filter((execution) => execution.status === "run")
|
|
209
|
-
.map((execution) => ({
|
|
210
|
-
id: execution.command.id,
|
|
211
|
-
exitCode: execution.exitCode
|
|
212
|
-
})),
|
|
213
|
-
failed: executions
|
|
214
|
-
.filter((execution) => execution.status === "failed")
|
|
215
|
-
.map((execution) => ({
|
|
216
|
-
id: execution.command.id,
|
|
217
|
-
exitCode: execution.exitCode,
|
|
218
|
-
error: execution.error
|
|
219
|
-
})),
|
|
220
|
-
skipped
|
|
179
|
+
nodeLtsMajor: toolchain.nodeLtsMajor.value,
|
|
180
|
+
packageManagerPin: toolchain.packageManagerPin.value,
|
|
181
|
+
source: toolchain.source,
|
|
182
|
+
diagnostics: [...toolchain.diagnostics],
|
|
221
183
|
};
|
|
222
184
|
}
|
|
223
|
-
function
|
|
224
|
-
return
|
|
185
|
+
function formatToolchainReport(toolchain) {
|
|
186
|
+
return [
|
|
187
|
+
"Toolchain Resolution:",
|
|
188
|
+
` Source: ${toolchain.source}`,
|
|
189
|
+
` Node LTS major: ${toolchain.nodeLtsMajor.value}`,
|
|
190
|
+
` Package Manager Pin: ${toolchain.packageManagerPin.value}`,
|
|
191
|
+
...toolchain.diagnostics.map((diagnostic) => ` ${diagnostic}`),
|
|
192
|
+
].join("\n");
|
|
193
|
+
}
|
|
194
|
+
function toolchainResolutionSourceFromEnv() {
|
|
195
|
+
if (process.env.TEMPLATE_TOOLCHAIN_RESOLUTION === "online" ||
|
|
196
|
+
process.env.TEMPLATE_TOOLCHAIN_RESOLUTION === "bundled-fallback") {
|
|
197
|
+
return process.env.TEMPLATE_TOOLCHAIN_RESOLUTION;
|
|
198
|
+
}
|
|
199
|
+
return undefined;
|
|
225
200
|
}
|
|
226
|
-
function
|
|
227
|
-
|
|
201
|
+
async function generationContextForInit(options, blueprint) {
|
|
202
|
+
if (options.preset !== "ts-lib" && options.preset !== "rust-bin") {
|
|
203
|
+
return undefined;
|
|
204
|
+
}
|
|
205
|
+
return assembleGenerationContext({
|
|
206
|
+
targetDir: options.dir,
|
|
207
|
+
blueprint,
|
|
208
|
+
toolchain: await resolveToolchainVersions({
|
|
209
|
+
source: toolchainResolutionSourceFromEnv(),
|
|
210
|
+
nodeReleaseIndexUrl: process.env.TEMPLATE_TOOLCHAIN_NODE_RELEASE_INDEX_URL,
|
|
211
|
+
pnpmRegistryUrl: process.env.TEMPLATE_TOOLCHAIN_PNPM_REGISTRY_URL,
|
|
212
|
+
}),
|
|
213
|
+
});
|
|
228
214
|
}
|
|
229
|
-
async function generateInitProject(options) {
|
|
215
|
+
async function generateInitProject(options, generationContext) {
|
|
230
216
|
if (options.preset === "ts-lib") {
|
|
231
|
-
await initTsLibProject(options.dir);
|
|
217
|
+
await initTsLibProject(options.dir, { generationContext });
|
|
232
218
|
return;
|
|
233
219
|
}
|
|
234
220
|
if (options.preset === "hono-api") {
|
|
@@ -244,28 +230,28 @@ async function generateInitProject(options) {
|
|
|
244
230
|
return;
|
|
245
231
|
}
|
|
246
232
|
if (options.preset === "rust-bin") {
|
|
247
|
-
await initRustBinProject(options.dir);
|
|
233
|
+
await initRustBinProject(options.dir, { generationContext });
|
|
248
234
|
return;
|
|
249
235
|
}
|
|
250
236
|
throw new Error("Only the ts-lib, hono-api, vue-app, vue-hono-app, and rust-bin presets are supported in this version");
|
|
251
237
|
}
|
|
252
|
-
function printInitComplete(options, blueprint,
|
|
238
|
+
function printInitComplete(options, blueprint, generationContext) {
|
|
253
239
|
const preset = blueprint.preset;
|
|
240
|
+
const nextSteps = planNextStepInstructions({ preset, targetDir: options.dir }).steps;
|
|
254
241
|
if (options.json) {
|
|
255
242
|
printJson({
|
|
256
243
|
command: "init",
|
|
257
244
|
dryRun: false,
|
|
258
|
-
ready: options.ready,
|
|
259
245
|
targetDir: options.dir,
|
|
260
246
|
blueprint,
|
|
261
|
-
|
|
262
|
-
nextSteps
|
|
247
|
+
toolchain: generationContext ? toolchainReport(generationContext.toolchain) : undefined,
|
|
248
|
+
nextSteps,
|
|
263
249
|
});
|
|
264
250
|
return;
|
|
265
251
|
}
|
|
266
252
|
console.log(`Initialized ${options.preset} project in ${options.dir}`);
|
|
267
|
-
if (
|
|
268
|
-
console.log(
|
|
253
|
+
if (generationContext) {
|
|
254
|
+
console.log(formatToolchainReport(generationContext.toolchain));
|
|
269
255
|
}
|
|
270
256
|
console.log(formatNextSteps(options.dir, preset));
|
|
271
257
|
}
|
|
@@ -276,7 +262,7 @@ async function confirmInit(targetDir, blueprint) {
|
|
|
276
262
|
console.log(formatBlueprintSummary(targetDir, blueprint));
|
|
277
263
|
const readline = createInterface({
|
|
278
264
|
input: process.stdin,
|
|
279
|
-
output: process.stdout
|
|
265
|
+
output: process.stdout,
|
|
280
266
|
});
|
|
281
267
|
try {
|
|
282
268
|
const answer = await readline.question("Generate this project? [y/N] ");
|
|
@@ -365,23 +351,24 @@ async function main(args) {
|
|
|
365
351
|
const options = parseInitOptions(args);
|
|
366
352
|
const blueprint = blueprintForInit(options);
|
|
367
353
|
if (options.dryRun) {
|
|
368
|
-
const
|
|
354
|
+
const generationContext = await generationContextForInit(options, blueprint);
|
|
355
|
+
const nextSteps = planNextStepInstructions({
|
|
369
356
|
preset: blueprint.preset,
|
|
370
|
-
targetDir: options.dir
|
|
371
|
-
});
|
|
357
|
+
targetDir: options.dir,
|
|
358
|
+
}).steps;
|
|
372
359
|
if (options.json) {
|
|
373
360
|
printJson({
|
|
374
361
|
command: "init",
|
|
375
362
|
dryRun: true,
|
|
376
|
-
ready: options.ready,
|
|
377
363
|
targetDir: options.dir,
|
|
378
364
|
blueprint,
|
|
379
|
-
|
|
365
|
+
toolchain: generationContext ? toolchainReport(generationContext.toolchain) : undefined,
|
|
366
|
+
nextSteps,
|
|
380
367
|
});
|
|
381
368
|
return;
|
|
382
369
|
}
|
|
383
370
|
console.log(formatBlueprintSummary(options.dir, blueprint));
|
|
384
|
-
console.log(
|
|
371
|
+
console.log(formatNextSteps(options.dir, blueprint.preset));
|
|
385
372
|
return;
|
|
386
373
|
}
|
|
387
374
|
if (!options.yes && (options.json || !isInteractiveTerminal())) {
|
|
@@ -390,19 +377,9 @@ async function main(args) {
|
|
|
390
377
|
if (!options.yes && !(await confirmInit(options.dir, blueprint))) {
|
|
391
378
|
throw new Error("Init cancelled");
|
|
392
379
|
}
|
|
393
|
-
const
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
});
|
|
397
|
-
await generateInitProject(options);
|
|
398
|
-
const executions = options.ready ? await runPostCommands({ plan: postCommandPlan }) : [];
|
|
399
|
-
const failedExecution = failedPostCommand(executions);
|
|
400
|
-
printInitComplete(options, blueprint, postCommandReport(postCommandPlan.commands, executions, options.ready
|
|
401
|
-
? []
|
|
402
|
-
: skippedPostCommands(postCommandPlan.commands, "ready-mode-not-requested")));
|
|
403
|
-
if (failedExecution) {
|
|
404
|
-
throw new Error(failedExecution.error);
|
|
405
|
-
}
|
|
380
|
+
const generationContext = await generationContextForInit(options, blueprint);
|
|
381
|
+
await generateInitProject(options, generationContext);
|
|
382
|
+
printInitComplete(options, blueprint, generationContext);
|
|
406
383
|
return;
|
|
407
384
|
}
|
|
408
385
|
if (command === "add" && args[1] === "package") {
|
package/dist/declarations.js
CHANGED
|
@@ -77,7 +77,7 @@ export const builtInPresets = [
|
|
|
77
77
|
title: "Rust binary",
|
|
78
78
|
description: "Single-package Rust native binary with rustfmt, clippy, and cargo tests.",
|
|
79
79
|
generation: "supported",
|
|
80
|
-
supportedPackageManagers: [],
|
|
80
|
+
supportedPackageManagers: ["pnpm"],
|
|
81
81
|
supportedProjectKinds: ["single-package"],
|
|
82
82
|
features: [
|
|
83
83
|
"root-check",
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type DevcontainerNodeFeatureOptions = {
|
|
2
|
+
readonly nodeVersion: string;
|
|
3
|
+
readonly packageManagerPin: string;
|
|
4
|
+
};
|
|
5
|
+
export type DevcontainerNodeFeature = {
|
|
6
|
+
readonly version: string;
|
|
7
|
+
readonly pnpmVersion: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function pnpmVersionFromPackageManagerPin(packageManagerPin: string): string;
|
|
10
|
+
export declare function devcontainerNodeFeature(options: DevcontainerNodeFeatureOptions): Record<"ghcr.io/devcontainers/features/node:1", DevcontainerNodeFeature>;
|
|
11
|
+
export declare function nodePnpmDevcontainer(options: {
|
|
12
|
+
readonly name: string;
|
|
13
|
+
readonly nodeVersion: string;
|
|
14
|
+
readonly packageManagerPin: string;
|
|
15
|
+
readonly extensions: readonly string[];
|
|
16
|
+
}): Record<string, unknown>;
|
|
17
|
+
//# sourceMappingURL=devcontainer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"devcontainer.d.ts","sourceRoot":"","sources":["../src/devcontainer.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,8BAA8B,GAAG;IAC3C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;CACpC,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B,CAAC;AAEF,wBAAgB,gCAAgC,CAAC,iBAAiB,EAAE,MAAM,GAAG,MAAM,CAElF;AAED,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,8BAA8B,GACtC,MAAM,CAAC,uCAAuC,EAAE,uBAAuB,CAAC,CAO1E;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE;IAC5C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;CACxC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAW1B"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export function pnpmVersionFromPackageManagerPin(packageManagerPin) {
|
|
2
|
+
return packageManagerPin.replace(/^pnpm@/, "");
|
|
3
|
+
}
|
|
4
|
+
export function devcontainerNodeFeature(options) {
|
|
5
|
+
return {
|
|
6
|
+
"ghcr.io/devcontainers/features/node:1": {
|
|
7
|
+
version: options.nodeVersion,
|
|
8
|
+
pnpmVersion: pnpmVersionFromPackageManagerPin(options.packageManagerPin),
|
|
9
|
+
},
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export function nodePnpmDevcontainer(options) {
|
|
13
|
+
return {
|
|
14
|
+
name: options.name,
|
|
15
|
+
image: `mcr.microsoft.com/devcontainers/typescript-node:${options.nodeVersion}`,
|
|
16
|
+
features: devcontainerNodeFeature(options),
|
|
17
|
+
customizations: {
|
|
18
|
+
vscode: {
|
|
19
|
+
extensions: options.extensions,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { PackageManager, PresetName, ProjectBlueprint } from "./declarations.js";
|
|
2
|
+
import type { ResolvedToolchainVersions } from "./toolchain-resolution.js";
|
|
3
|
+
export type ProjectName = {
|
|
4
|
+
readonly kind: "ProjectName";
|
|
5
|
+
readonly value: string;
|
|
6
|
+
};
|
|
7
|
+
export type GenerationPackageManager = {
|
|
8
|
+
readonly kind: "PackageManager";
|
|
9
|
+
readonly value: PackageManager;
|
|
10
|
+
};
|
|
11
|
+
export type GenerationContext = {
|
|
12
|
+
readonly projectName: ProjectName;
|
|
13
|
+
readonly preset: PresetName;
|
|
14
|
+
readonly packageManager?: GenerationPackageManager;
|
|
15
|
+
readonly blueprint: ProjectBlueprint;
|
|
16
|
+
readonly toolchain: ResolvedToolchainVersions;
|
|
17
|
+
};
|
|
18
|
+
export type AssembleGenerationContextOptions = {
|
|
19
|
+
readonly targetDir: string;
|
|
20
|
+
readonly blueprint: ProjectBlueprint;
|
|
21
|
+
readonly toolchain: ResolvedToolchainVersions;
|
|
22
|
+
};
|
|
23
|
+
export declare function assembleGenerationContext(options: AssembleGenerationContextOptions): GenerationContext;
|
|
24
|
+
//# sourceMappingURL=generation-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generation-context.d.ts","sourceRoot":"","sources":["../src/generation-context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACtF,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAE3E,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAChC,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,cAAc,CAAC,EAAE,wBAAwB,CAAC;IACnD,QAAQ,CAAC,SAAS,EAAE,gBAAgB,CAAC;IACrC,QAAQ,CAAC,SAAS,EAAE,yBAAyB,CAAC;CAC/C,CAAC;AAEF,MAAM,MAAM,gCAAgC,GAAG;IAC7C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,gBAAgB,CAAC;IACrC,QAAQ,CAAC,SAAS,EAAE,yBAAyB,CAAC;CAC/C,CAAC;AAEF,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,gCAAgC,GACxC,iBAAiB,CAUnB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
export function assembleGenerationContext(options) {
|
|
3
|
+
return {
|
|
4
|
+
projectName: { kind: "ProjectName", value: path.basename(path.resolve(options.targetDir)) },
|
|
5
|
+
preset: options.blueprint.preset,
|
|
6
|
+
packageManager: options.blueprint.packageManager
|
|
7
|
+
? { kind: "PackageManager", value: options.blueprint.packageManager }
|
|
8
|
+
: undefined,
|
|
9
|
+
blueprint: options.blueprint,
|
|
10
|
+
toolchain: options.toolchain,
|
|
11
|
+
};
|
|
12
|
+
}
|
package/dist/hono-api.d.ts
CHANGED
package/dist/hono-api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hono-api.d.ts","sourceRoot":"","sources":["../src/hono-api.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hono-api.d.ts","sourceRoot":"","sources":["../src/hono-api.ts"],"names":[],"mappings":"AAiCA,wBAAgB,4BAA4B,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAarE;AAgLD,wBAAsB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAOzE"}
|
package/dist/hono-api.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
|
+
import { nodePnpmDevcontainer } from "./devcontainer.js";
|
|
4
|
+
import { planNodeChecks, planNodeFixes, renderFixCommand, renderRootCheckCommand, } from "./module-graph.js";
|
|
5
|
+
import { projectPresetDependabotConfig, projectPresetGithubCheckWorkflow } from "./project-github.js";
|
|
3
6
|
import { renderNewProject } from "./renderer.js";
|
|
4
7
|
const features = [
|
|
5
8
|
"pnpm-catalog",
|
|
@@ -9,37 +12,40 @@ const features = [
|
|
|
9
12
|
"fix-command",
|
|
10
13
|
"devcontainer",
|
|
11
14
|
"github-actions",
|
|
12
|
-
"dependabot"
|
|
15
|
+
"dependabot",
|
|
13
16
|
];
|
|
14
17
|
const generatedBy = {
|
|
15
18
|
packageName: "@ykdz/template",
|
|
16
19
|
version: "0.0.0",
|
|
17
|
-
command: "template init --preset hono-api"
|
|
20
|
+
command: "template init --preset hono-api",
|
|
18
21
|
};
|
|
19
22
|
function projectNameFromDir(targetDir) {
|
|
20
23
|
return path.basename(path.resolve(targetDir));
|
|
21
24
|
}
|
|
25
|
+
export function projectHonoApiPackageScripts() {
|
|
26
|
+
return {
|
|
27
|
+
build: "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",
|
|
28
|
+
check: renderRootCheckCommand(planNodeChecks("hono-api")),
|
|
29
|
+
fix: renderFixCommand(planNodeFixes("hono-api")),
|
|
30
|
+
"format:check": "oxfmt --check .",
|
|
31
|
+
"format:write": "oxfmt --write .",
|
|
32
|
+
lint: "oxlint . --deny-warnings",
|
|
33
|
+
"lint:fix": "oxlint . --fix --deny-warnings",
|
|
34
|
+
start: "node dist/server.js",
|
|
35
|
+
test: "vitest run",
|
|
36
|
+
typecheck: "tsc -p tsconfig.json --noEmit",
|
|
37
|
+
};
|
|
38
|
+
}
|
|
22
39
|
function packageJson(projectName) {
|
|
23
40
|
return {
|
|
24
41
|
name: projectName,
|
|
25
42
|
version: "0.0.0",
|
|
26
43
|
private: true,
|
|
27
44
|
type: "module",
|
|
28
|
-
scripts:
|
|
29
|
-
build: "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",
|
|
30
|
-
check: "pnpm run format:check && pnpm run lint && pnpm run typecheck && pnpm run build && pnpm run test",
|
|
31
|
-
fix: "pnpm run format:write && pnpm run lint:fix",
|
|
32
|
-
"format:check": "oxfmt --check .",
|
|
33
|
-
"format:write": "oxfmt --write .",
|
|
34
|
-
lint: "oxlint . --deny-warnings",
|
|
35
|
-
"lint:fix": "oxlint . --fix --deny-warnings",
|
|
36
|
-
start: "node dist/server.js",
|
|
37
|
-
test: "vitest run",
|
|
38
|
-
typecheck: "tsc -p tsconfig.json --noEmit"
|
|
39
|
-
},
|
|
45
|
+
scripts: projectHonoApiPackageScripts(),
|
|
40
46
|
dependencies: {
|
|
41
47
|
"@hono/node-server": "catalog:",
|
|
42
|
-
hono: "catalog:"
|
|
48
|
+
hono: "catalog:",
|
|
43
49
|
},
|
|
44
50
|
devDependencies: {
|
|
45
51
|
"@types/node": "catalog:",
|
|
@@ -47,12 +53,12 @@ function packageJson(projectName) {
|
|
|
47
53
|
oxlint: "catalog:",
|
|
48
54
|
"tsc-alias": "catalog:",
|
|
49
55
|
typescript: "catalog:",
|
|
50
|
-
vitest: "catalog:"
|
|
56
|
+
vitest: "catalog:",
|
|
51
57
|
},
|
|
52
58
|
engines: {
|
|
53
|
-
node: "22"
|
|
59
|
+
node: "22",
|
|
54
60
|
},
|
|
55
|
-
packageManager: "pnpm@10.0.0"
|
|
61
|
+
packageManager: "pnpm@10.0.0",
|
|
56
62
|
};
|
|
57
63
|
}
|
|
58
64
|
function operationsForHonoApi(projectName) {
|
|
@@ -60,7 +66,7 @@ function operationsForHonoApi(projectName) {
|
|
|
60
66
|
{
|
|
61
67
|
kind: "writeJson",
|
|
62
68
|
to: "package.json",
|
|
63
|
-
value: packageJson(projectName)
|
|
69
|
+
value: packageJson(projectName),
|
|
64
70
|
},
|
|
65
71
|
{
|
|
66
72
|
kind: "writeText",
|
|
@@ -78,8 +84,8 @@ function operationsForHonoApi(projectName) {
|
|
|
78
84
|
" tsc-alias: ^1.8.17",
|
|
79
85
|
" typescript: ^5.8.0",
|
|
80
86
|
" vitest: ^4.1.9",
|
|
81
|
-
""
|
|
82
|
-
].join("\n")
|
|
87
|
+
"",
|
|
88
|
+
].join("\n"),
|
|
83
89
|
},
|
|
84
90
|
{
|
|
85
91
|
kind: "writeJson",
|
|
@@ -90,15 +96,15 @@ function operationsForHonoApi(projectName) {
|
|
|
90
96
|
moduleResolution: "NodeNext",
|
|
91
97
|
noEmitOnError: true,
|
|
92
98
|
paths: {
|
|
93
|
-
"@/*": ["./src/*"]
|
|
99
|
+
"@/*": ["./src/*"],
|
|
94
100
|
},
|
|
95
101
|
skipLibCheck: false,
|
|
96
102
|
strict: true,
|
|
97
103
|
target: "ES2022",
|
|
98
|
-
types: ["node", "vitest/globals"]
|
|
104
|
+
types: ["node", "vitest/globals"],
|
|
99
105
|
},
|
|
100
|
-
include: ["src/**/*.ts", "test/**/*.ts", "vitest.config.ts"]
|
|
101
|
-
}
|
|
106
|
+
include: ["src/**/*.ts", "test/**/*.ts", "vitest.config.ts"],
|
|
107
|
+
},
|
|
102
108
|
},
|
|
103
109
|
{
|
|
104
110
|
kind: "writeJson",
|
|
@@ -108,47 +114,47 @@ function operationsForHonoApi(projectName) {
|
|
|
108
114
|
compilerOptions: {
|
|
109
115
|
outDir: "dist",
|
|
110
116
|
rootDir: "src",
|
|
111
|
-
types: ["node"]
|
|
117
|
+
types: ["node"],
|
|
112
118
|
},
|
|
113
|
-
include: ["src/**/*.ts"]
|
|
114
|
-
}
|
|
119
|
+
include: ["src/**/*.ts"],
|
|
120
|
+
},
|
|
115
121
|
},
|
|
116
122
|
{
|
|
117
123
|
kind: "copyFile",
|
|
118
124
|
sourceRoot: "sharedOxc",
|
|
119
125
|
from: "node/oxlint.config.ts",
|
|
120
|
-
to: "oxlint.config.ts"
|
|
126
|
+
to: "oxlint.config.ts",
|
|
121
127
|
},
|
|
122
128
|
{
|
|
123
129
|
kind: "copyFile",
|
|
124
130
|
sourceRoot: "sharedOxc",
|
|
125
131
|
from: "oxfmt.config.ts",
|
|
126
|
-
to: "oxfmt.config.ts"
|
|
132
|
+
to: "oxfmt.config.ts",
|
|
127
133
|
},
|
|
128
134
|
{
|
|
129
135
|
kind: "writeText",
|
|
130
136
|
to: ".gitignore",
|
|
131
|
-
text: ["node_modules", "dist", ".env", ""].join("\n")
|
|
137
|
+
text: ["node_modules", "dist", ".env", ""].join("\n"),
|
|
132
138
|
},
|
|
133
139
|
{
|
|
134
140
|
kind: "copyFile",
|
|
135
141
|
from: "src/app.ts",
|
|
136
|
-
to: "src/app.ts"
|
|
142
|
+
to: "src/app.ts",
|
|
137
143
|
},
|
|
138
144
|
{
|
|
139
145
|
kind: "copyFile",
|
|
140
146
|
from: "src/server.ts",
|
|
141
|
-
to: "src/server.ts"
|
|
147
|
+
to: "src/server.ts",
|
|
142
148
|
},
|
|
143
149
|
{
|
|
144
150
|
kind: "copyFile",
|
|
145
151
|
from: "test/app.test.ts",
|
|
146
|
-
to: "test/app.test.ts"
|
|
152
|
+
to: "test/app.test.ts",
|
|
147
153
|
},
|
|
148
154
|
{
|
|
149
155
|
kind: "copyFile",
|
|
150
156
|
from: "vitest.config.ts",
|
|
151
|
-
to: "vitest.config.ts"
|
|
157
|
+
to: "vitest.config.ts",
|
|
152
158
|
},
|
|
153
159
|
{
|
|
154
160
|
kind: "writeJson",
|
|
@@ -158,38 +164,34 @@ function operationsForHonoApi(projectName) {
|
|
|
158
164
|
preset: "hono-api",
|
|
159
165
|
packageManager: "pnpm",
|
|
160
166
|
projectKind: "single-package",
|
|
161
|
-
features
|
|
162
|
-
}
|
|
167
|
+
features,
|
|
168
|
+
},
|
|
163
169
|
},
|
|
164
170
|
{
|
|
165
171
|
kind: "writeJson",
|
|
166
172
|
to: ".project-kit/generated-by.json",
|
|
167
|
-
value: generatedBy
|
|
173
|
+
value: generatedBy,
|
|
168
174
|
},
|
|
169
175
|
{
|
|
170
176
|
kind: "writeJson",
|
|
171
177
|
to: ".devcontainer/devcontainer.json",
|
|
172
|
-
value: {
|
|
178
|
+
value: nodePnpmDevcontainer({
|
|
173
179
|
name: `${projectName} API development`,
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
extensions: ["oxc.oxc-vscode"]
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}
|
|
180
|
+
nodeVersion: "22",
|
|
181
|
+
packageManagerPin: "pnpm@10.0.0",
|
|
182
|
+
extensions: ["oxc.oxc-vscode"],
|
|
183
|
+
}),
|
|
182
184
|
},
|
|
183
185
|
{
|
|
184
|
-
kind: "
|
|
185
|
-
from: ".github/workflows/check.yml",
|
|
186
|
+
kind: "writeText",
|
|
186
187
|
to: ".github/workflows/check.yml",
|
|
188
|
+
text: projectPresetGithubCheckWorkflow("hono-api"),
|
|
187
189
|
},
|
|
188
190
|
{
|
|
189
|
-
kind: "
|
|
190
|
-
from: ".github/dependabot.yml",
|
|
191
|
+
kind: "writeText",
|
|
191
192
|
to: ".github/dependabot.yml",
|
|
192
|
-
|
|
193
|
+
text: projectPresetDependabotConfig("hono-api"),
|
|
194
|
+
},
|
|
193
195
|
];
|
|
194
196
|
}
|
|
195
197
|
function templateSourceRoot() {
|
|
@@ -203,6 +205,6 @@ export async function initHonoApiProject(targetDir) {
|
|
|
203
205
|
sourceRoot: templateSourceRoot(),
|
|
204
206
|
sourceRoots: { sharedOxc: sharedOxcSourceRoot() },
|
|
205
207
|
targetRoot: targetDir,
|
|
206
|
-
operations: operationsForHonoApi(projectNameFromDir(targetDir))
|
|
208
|
+
operations: operationsForHonoApi(projectNameFromDir(targetDir)),
|
|
207
209
|
});
|
|
208
210
|
}
|