@ykdz/template 0.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/LICENSE +21 -0
- package/README.md +35 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +353 -0
- package/dist/declarations.d.ts +166 -0
- package/dist/declarations.d.ts.map +1 -0
- package/dist/declarations.js +340 -0
- package/dist/hono-api.d.ts +2 -0
- package/dist/hono-api.d.ts.map +1 -0
- package/dist/hono-api.js +247 -0
- package/dist/package-addition.d.ts +7 -0
- package/dist/package-addition.d.ts.map +1 -0
- package/dist/package-addition.js +580 -0
- package/dist/renderer.d.ts +44 -0
- package/dist/renderer.d.ts.map +1 -0
- package/dist/renderer.js +379 -0
- package/dist/rust-bin.d.ts +2 -0
- package/dist/rust-bin.d.ts.map +1 -0
- package/dist/rust-bin.js +206 -0
- package/dist/ts-lib.d.ts +2 -0
- package/dist/ts-lib.d.ts.map +1 -0
- package/dist/ts-lib.js +220 -0
- package/dist/vue-app.d.ts +2 -0
- package/dist/vue-app.d.ts.map +1 -0
- package/dist/vue-app.js +339 -0
- package/dist/vue-hono-app.d.ts +4 -0
- package/dist/vue-hono-app.d.ts.map +1 -0
- package/dist/vue-hono-app.js +484 -0
- package/package.json +54 -0
- package/templates/hono-api/src/app.ts +5 -0
- package/templates/hono-api/src/server.ts +14 -0
- package/templates/hono-api/test/app.test.ts +10 -0
- package/templates/hono-api/vitest.config.ts +13 -0
- package/templates/rust-bin/src/main.rs +18 -0
- package/templates/ts-lib/src/index.ts +7 -0
- package/templates/vue-app/env.d.ts +1 -0
- package/templates/vue-app/index.html +12 -0
- package/templates/vue-app/playwright.config.ts +20 -0
- package/templates/vue-app/src/App.vue +33 -0
- package/templates/vue-app/src/main.ts +6 -0
- package/templates/vue-app/src/stores/counter.ts +12 -0
- package/templates/vue-app/src/style.css +1 -0
- package/templates/vue-app/test/app.test.ts +13 -0
- package/templates/vue-app/test/e2e/app.spec.ts +9 -0
- package/templates/vue-app/vite.config.ts +13 -0
- package/templates/vue-app/vitest.config.ts +14 -0
- package/templates/vue-hono-app/api/src/index.ts +3 -0
- package/templates/vue-hono-app/api/src/runtime.ts +5 -0
- package/templates/vue-hono-app/api/src/server.ts +14 -0
- package/templates/vue-hono-app/api/test/app.test.ts +10 -0
- package/templates/vue-hono-app/api/vitest.config.ts +7 -0
- package/templates/vue-hono-app/web/env.d.ts +9 -0
- package/templates/vue-hono-app/web/index.html +12 -0
- package/templates/vue-hono-app/web/playwright.config.ts +21 -0
- package/templates/vue-hono-app/web/src/App.vue +42 -0
- package/templates/vue-hono-app/web/src/api.ts +8 -0
- package/templates/vue-hono-app/web/src/main.ts +6 -0
- package/templates/vue-hono-app/web/src/stores/counter.ts +12 -0
- package/templates/vue-hono-app/web/src/style.css +1 -0
- package/templates/vue-hono-app/web/test/app.test.ts +13 -0
- package/templates/vue-hono-app/web/test/e2e/app.spec.ts +10 -0
- package/templates/vue-hono-app/web/vite.config.ts +29 -0
- package/templates/vue-hono-app/web/vitest.config.ts +16 -0
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
export const builtInPresets = [
|
|
3
|
+
{
|
|
4
|
+
name: "ts-lib",
|
|
5
|
+
title: "TypeScript library",
|
|
6
|
+
description: "Strict TypeScript package with pnpm catalog tooling.",
|
|
7
|
+
generation: "supported",
|
|
8
|
+
supportedPackageManagers: ["pnpm"],
|
|
9
|
+
supportedProjectKinds: ["single-package"],
|
|
10
|
+
features: [
|
|
11
|
+
"pnpm-catalog",
|
|
12
|
+
"oxc-format-lint",
|
|
13
|
+
"strict-typescript",
|
|
14
|
+
"root-check",
|
|
15
|
+
"fix-command",
|
|
16
|
+
"devcontainer",
|
|
17
|
+
"github-actions",
|
|
18
|
+
"dependabot"
|
|
19
|
+
]
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: "hono-api",
|
|
23
|
+
title: "Hono API",
|
|
24
|
+
description: "Single-package Hono Node API with strict TypeScript tooling.",
|
|
25
|
+
generation: "supported",
|
|
26
|
+
supportedPackageManagers: ["pnpm"],
|
|
27
|
+
supportedProjectKinds: ["single-package"],
|
|
28
|
+
features: [
|
|
29
|
+
"pnpm-catalog",
|
|
30
|
+
"oxc-format-lint",
|
|
31
|
+
"strict-typescript",
|
|
32
|
+
"root-check",
|
|
33
|
+
"fix-command",
|
|
34
|
+
"devcontainer",
|
|
35
|
+
"github-actions",
|
|
36
|
+
"dependabot"
|
|
37
|
+
]
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: "vue-app",
|
|
41
|
+
title: "Vue app",
|
|
42
|
+
description: "Single-package Vue app with Vite, Tailwind, Pinia, and test tooling.",
|
|
43
|
+
generation: "supported",
|
|
44
|
+
supportedPackageManagers: ["pnpm"],
|
|
45
|
+
supportedProjectKinds: ["single-package"],
|
|
46
|
+
features: [
|
|
47
|
+
"pnpm-catalog",
|
|
48
|
+
"oxc-format-lint",
|
|
49
|
+
"strict-typescript",
|
|
50
|
+
"root-check",
|
|
51
|
+
"fix-command",
|
|
52
|
+
"devcontainer",
|
|
53
|
+
"github-actions",
|
|
54
|
+
"dependabot"
|
|
55
|
+
]
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: "vue-hono-app",
|
|
59
|
+
title: "Vue Hono app",
|
|
60
|
+
description: "Full-stack Vue and Hono workspace with Hono RPC typing.",
|
|
61
|
+
generation: "supported",
|
|
62
|
+
supportedPackageManagers: ["pnpm"],
|
|
63
|
+
supportedProjectKinds: ["multi-package"],
|
|
64
|
+
features: [
|
|
65
|
+
"pnpm-catalog",
|
|
66
|
+
"oxc-format-lint",
|
|
67
|
+
"strict-typescript",
|
|
68
|
+
"root-check",
|
|
69
|
+
"fix-command",
|
|
70
|
+
"devcontainer",
|
|
71
|
+
"github-actions",
|
|
72
|
+
"dependabot"
|
|
73
|
+
]
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: "rust-bin",
|
|
77
|
+
title: "Rust binary",
|
|
78
|
+
description: "Single-package Rust native binary with rustfmt, clippy, and cargo tests.",
|
|
79
|
+
generation: "supported",
|
|
80
|
+
supportedPackageManagers: [],
|
|
81
|
+
supportedProjectKinds: ["single-package"],
|
|
82
|
+
features: [
|
|
83
|
+
"root-check",
|
|
84
|
+
"fix-command",
|
|
85
|
+
"devcontainer",
|
|
86
|
+
"github-actions",
|
|
87
|
+
"dependabot",
|
|
88
|
+
"rustfmt-clippy",
|
|
89
|
+
"cargo-test"
|
|
90
|
+
]
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: "ts-app",
|
|
94
|
+
title: "TypeScript application",
|
|
95
|
+
description: "Future application preset metadata.",
|
|
96
|
+
generation: "future",
|
|
97
|
+
supportedPackageManagers: ["pnpm"],
|
|
98
|
+
supportedProjectKinds: ["single-package"],
|
|
99
|
+
features: []
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
name: "node-cli",
|
|
103
|
+
title: "Node.js CLI",
|
|
104
|
+
description: "Future command-line preset metadata.",
|
|
105
|
+
generation: "future",
|
|
106
|
+
supportedPackageManagers: ["pnpm"],
|
|
107
|
+
supportedProjectKinds: ["single-package"],
|
|
108
|
+
features: []
|
|
109
|
+
}
|
|
110
|
+
];
|
|
111
|
+
const featureNames = [
|
|
112
|
+
"pnpm-catalog",
|
|
113
|
+
"oxc-format-lint",
|
|
114
|
+
"strict-typescript",
|
|
115
|
+
"root-check",
|
|
116
|
+
"fix-command",
|
|
117
|
+
"devcontainer",
|
|
118
|
+
"github-actions",
|
|
119
|
+
"dependabot",
|
|
120
|
+
"rustfmt-clippy",
|
|
121
|
+
"cargo-test",
|
|
122
|
+
"native-binary-release"
|
|
123
|
+
];
|
|
124
|
+
export const presetFileJsonSchema = {
|
|
125
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
126
|
+
$id: "https://ykdz.dev/schemas/project-kit/preset-file.schema.json",
|
|
127
|
+
title: "Project Kit Preset File",
|
|
128
|
+
type: "object",
|
|
129
|
+
additionalProperties: false,
|
|
130
|
+
required: [
|
|
131
|
+
"schemaVersion",
|
|
132
|
+
"name",
|
|
133
|
+
"title",
|
|
134
|
+
"description",
|
|
135
|
+
"supportedPackageManagers",
|
|
136
|
+
"supportedProjectKinds",
|
|
137
|
+
"features"
|
|
138
|
+
],
|
|
139
|
+
properties: {
|
|
140
|
+
schemaVersion: { const: 1 },
|
|
141
|
+
name: { type: "string", minLength: 1 },
|
|
142
|
+
title: { type: "string", minLength: 1 },
|
|
143
|
+
description: { type: "string", minLength: 1 },
|
|
144
|
+
supportedPackageManagers: {
|
|
145
|
+
type: "array",
|
|
146
|
+
items: { enum: ["pnpm"] },
|
|
147
|
+
uniqueItems: true
|
|
148
|
+
},
|
|
149
|
+
supportedProjectKinds: {
|
|
150
|
+
type: "array",
|
|
151
|
+
minItems: 1,
|
|
152
|
+
items: { enum: ["single-package", "multi-package"] },
|
|
153
|
+
uniqueItems: true
|
|
154
|
+
},
|
|
155
|
+
features: {
|
|
156
|
+
type: "array",
|
|
157
|
+
items: { enum: featureNames },
|
|
158
|
+
uniqueItems: true
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
export const blueprintJsonSchema = {
|
|
163
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
164
|
+
$id: "https://ykdz.dev/schemas/project-kit/blueprint.schema.json",
|
|
165
|
+
title: "Project Kit Blueprint",
|
|
166
|
+
type: "object",
|
|
167
|
+
additionalProperties: false,
|
|
168
|
+
required: ["schemaVersion", "preset", "projectKind", "features"],
|
|
169
|
+
properties: {
|
|
170
|
+
schemaVersion: { const: 1 },
|
|
171
|
+
preset: { type: "string", minLength: 1 },
|
|
172
|
+
packageManager: { enum: ["pnpm"] },
|
|
173
|
+
projectKind: { enum: ["single-package", "multi-package"] },
|
|
174
|
+
features: {
|
|
175
|
+
type: "array",
|
|
176
|
+
items: { enum: featureNames },
|
|
177
|
+
uniqueItems: true
|
|
178
|
+
},
|
|
179
|
+
packages: {
|
|
180
|
+
type: "array",
|
|
181
|
+
items: {
|
|
182
|
+
type: "object",
|
|
183
|
+
additionalProperties: false,
|
|
184
|
+
required: ["name", "path"],
|
|
185
|
+
properties: {
|
|
186
|
+
name: { type: "string", minLength: 1 },
|
|
187
|
+
path: { type: "string", minLength: 1 }
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
const nonEmptyString = v.pipe(v.string(), v.minLength(1));
|
|
194
|
+
const packageManagerSchema = v.picklist(["pnpm"]);
|
|
195
|
+
const projectKindSchema = v.picklist(["single-package", "multi-package"]);
|
|
196
|
+
const featureNameSchema = v.picklist(featureNames);
|
|
197
|
+
export const presetFileSchema = v.strictObject({
|
|
198
|
+
schemaVersion: v.literal(1),
|
|
199
|
+
name: nonEmptyString,
|
|
200
|
+
title: nonEmptyString,
|
|
201
|
+
description: nonEmptyString,
|
|
202
|
+
supportedPackageManagers: v.array(packageManagerSchema),
|
|
203
|
+
supportedProjectKinds: v.pipe(v.array(projectKindSchema), v.minLength(1)),
|
|
204
|
+
features: v.array(featureNameSchema)
|
|
205
|
+
});
|
|
206
|
+
export const projectBlueprintSchema = v.strictObject({
|
|
207
|
+
schemaVersion: v.literal(1),
|
|
208
|
+
preset: nonEmptyString,
|
|
209
|
+
packageManager: v.optional(packageManagerSchema),
|
|
210
|
+
projectKind: projectKindSchema,
|
|
211
|
+
features: v.array(featureNameSchema),
|
|
212
|
+
packages: v.optional(v.array(v.strictObject({
|
|
213
|
+
name: nonEmptyString,
|
|
214
|
+
path: nonEmptyString
|
|
215
|
+
})))
|
|
216
|
+
});
|
|
217
|
+
function formatIssuePath(issue) {
|
|
218
|
+
if (!issue.path || issue.path.length === 0) {
|
|
219
|
+
return "$";
|
|
220
|
+
}
|
|
221
|
+
return issue.path.reduce((path, item) => `${path}.${String(item.key)}`, "$");
|
|
222
|
+
}
|
|
223
|
+
function shapeIssues(issues) {
|
|
224
|
+
return issues.map((issue) => ({
|
|
225
|
+
path: formatIssuePath(issue),
|
|
226
|
+
message: issue.message
|
|
227
|
+
}));
|
|
228
|
+
}
|
|
229
|
+
function duplicateIssues(values, path) {
|
|
230
|
+
const seen = new Set();
|
|
231
|
+
const duplicates = new Set();
|
|
232
|
+
for (const value of values) {
|
|
233
|
+
if (seen.has(value)) {
|
|
234
|
+
duplicates.add(value);
|
|
235
|
+
}
|
|
236
|
+
seen.add(value);
|
|
237
|
+
}
|
|
238
|
+
return [...duplicates].map((value) => ({
|
|
239
|
+
path,
|
|
240
|
+
message: `Duplicate value: ${value}`
|
|
241
|
+
}));
|
|
242
|
+
}
|
|
243
|
+
function generationSupportIssue(preset, path) {
|
|
244
|
+
if (preset.generation === "supported") {
|
|
245
|
+
return undefined;
|
|
246
|
+
}
|
|
247
|
+
return {
|
|
248
|
+
path,
|
|
249
|
+
message: `Preset ${preset.name} is not supported for generation in this version`
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
export function validatePresetFile(input) {
|
|
253
|
+
const result = v.safeParse(presetFileSchema, input);
|
|
254
|
+
if (!result.success) {
|
|
255
|
+
return { ok: false, issues: shapeIssues(result.issues) };
|
|
256
|
+
}
|
|
257
|
+
const semanticIssues = [
|
|
258
|
+
...duplicateIssues(result.output.supportedPackageManagers, "$.supportedPackageManagers"),
|
|
259
|
+
...duplicateIssues(result.output.supportedProjectKinds, "$.supportedProjectKinds"),
|
|
260
|
+
...duplicateIssues(result.output.features, "$.features")
|
|
261
|
+
];
|
|
262
|
+
const builtInPreset = findBuiltInPreset(result.output.name);
|
|
263
|
+
const unsupportedGeneration = builtInPreset
|
|
264
|
+
? generationSupportIssue(builtInPreset, "$.name")
|
|
265
|
+
: undefined;
|
|
266
|
+
if (unsupportedGeneration) {
|
|
267
|
+
semanticIssues.push(unsupportedGeneration);
|
|
268
|
+
}
|
|
269
|
+
if (semanticIssues.length > 0) {
|
|
270
|
+
return { ok: false, issues: semanticIssues };
|
|
271
|
+
}
|
|
272
|
+
return { ok: true, value: result.output };
|
|
273
|
+
}
|
|
274
|
+
export function findBuiltInPreset(name) {
|
|
275
|
+
return builtInPresets.find((preset) => preset.name === name);
|
|
276
|
+
}
|
|
277
|
+
export function validateProjectBlueprint(input) {
|
|
278
|
+
const result = v.safeParse(projectBlueprintSchema, input);
|
|
279
|
+
if (!result.success) {
|
|
280
|
+
return { ok: false, issues: shapeIssues(result.issues) };
|
|
281
|
+
}
|
|
282
|
+
const blueprint = result.output;
|
|
283
|
+
const preset = findBuiltInPreset(blueprint.preset);
|
|
284
|
+
const semanticIssues = [
|
|
285
|
+
...duplicateIssues(blueprint.features, "$.features")
|
|
286
|
+
];
|
|
287
|
+
if (!preset) {
|
|
288
|
+
semanticIssues.push({
|
|
289
|
+
path: "$.preset",
|
|
290
|
+
message: `Unknown built-in preset: ${blueprint.preset}`
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
else {
|
|
294
|
+
const unsupportedGeneration = generationSupportIssue(preset, "$.preset");
|
|
295
|
+
if (unsupportedGeneration) {
|
|
296
|
+
semanticIssues.push(unsupportedGeneration);
|
|
297
|
+
}
|
|
298
|
+
if (blueprint.packageManager &&
|
|
299
|
+
!preset.supportedPackageManagers.includes(blueprint.packageManager)) {
|
|
300
|
+
semanticIssues.push({
|
|
301
|
+
path: "$.packageManager",
|
|
302
|
+
message: `${blueprint.packageManager} is not supported by preset ${preset.name}`
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
if (!blueprint.packageManager && preset.supportedPackageManagers.length > 0) {
|
|
306
|
+
semanticIssues.push({
|
|
307
|
+
path: "$.packageManager",
|
|
308
|
+
message: `packageManager is required by preset ${preset.name}`
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
if (!preset.supportedProjectKinds.includes(blueprint.projectKind)) {
|
|
312
|
+
semanticIssues.push({
|
|
313
|
+
path: "$.projectKind",
|
|
314
|
+
message: `${blueprint.projectKind} is not supported by preset ${preset.name}`
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
const supportedFeatures = new Set(preset.features);
|
|
318
|
+
for (const feature of blueprint.features) {
|
|
319
|
+
if (!supportedFeatures.has(feature)) {
|
|
320
|
+
semanticIssues.push({
|
|
321
|
+
path: "$.features",
|
|
322
|
+
message: `${feature} is not supported by preset ${preset.name}`
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
if (blueprint.packages) {
|
|
328
|
+
if (blueprint.projectKind === "single-package" && blueprint.packages.length > 1) {
|
|
329
|
+
semanticIssues.push({
|
|
330
|
+
path: "$.packages",
|
|
331
|
+
message: "single-package blueprints support exactly one package"
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
semanticIssues.push(...duplicateIssues(blueprint.packages.map((projectPackage) => projectPackage.name), "$.packages.name"), ...duplicateIssues(blueprint.packages.map((projectPackage) => projectPackage.path), "$.packages.path"));
|
|
335
|
+
}
|
|
336
|
+
if (semanticIssues.length > 0) {
|
|
337
|
+
return { ok: false, issues: semanticIssues };
|
|
338
|
+
}
|
|
339
|
+
return { ok: true, value: blueprint };
|
|
340
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hono-api.d.ts","sourceRoot":"","sources":["../src/hono-api.ts"],"names":[],"mappings":"AAwPA,wBAAsB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAMzE"}
|
package/dist/hono-api.js
ADDED
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
import { renderNewProject } from "./renderer.js";
|
|
4
|
+
const features = [
|
|
5
|
+
"pnpm-catalog",
|
|
6
|
+
"oxc-format-lint",
|
|
7
|
+
"strict-typescript",
|
|
8
|
+
"root-check",
|
|
9
|
+
"fix-command",
|
|
10
|
+
"devcontainer",
|
|
11
|
+
"github-actions",
|
|
12
|
+
"dependabot"
|
|
13
|
+
];
|
|
14
|
+
const generatedBy = {
|
|
15
|
+
packageName: "@ykdz/template",
|
|
16
|
+
version: "0.0.0",
|
|
17
|
+
command: "template init --preset hono-api"
|
|
18
|
+
};
|
|
19
|
+
function projectNameFromDir(targetDir) {
|
|
20
|
+
return path.basename(path.resolve(targetDir));
|
|
21
|
+
}
|
|
22
|
+
function packageJson(projectName) {
|
|
23
|
+
return {
|
|
24
|
+
name: projectName,
|
|
25
|
+
version: "0.0.0",
|
|
26
|
+
private: true,
|
|
27
|
+
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
|
+
},
|
|
40
|
+
dependencies: {
|
|
41
|
+
"@hono/node-server": "catalog:",
|
|
42
|
+
hono: "catalog:"
|
|
43
|
+
},
|
|
44
|
+
devDependencies: {
|
|
45
|
+
"@types/node": "catalog:",
|
|
46
|
+
oxfmt: "catalog:",
|
|
47
|
+
oxlint: "catalog:",
|
|
48
|
+
"tsc-alias": "catalog:",
|
|
49
|
+
typescript: "catalog:",
|
|
50
|
+
vitest: "catalog:"
|
|
51
|
+
},
|
|
52
|
+
engines: {
|
|
53
|
+
node: ">=22.0.0"
|
|
54
|
+
},
|
|
55
|
+
packageManager: "pnpm@10.0.0"
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function operationsForHonoApi(projectName) {
|
|
59
|
+
return [
|
|
60
|
+
{
|
|
61
|
+
kind: "writeJson",
|
|
62
|
+
to: "package.json",
|
|
63
|
+
value: packageJson(projectName)
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
kind: "writeText",
|
|
67
|
+
to: "pnpm-workspace.yaml",
|
|
68
|
+
text: [
|
|
69
|
+
"packages:",
|
|
70
|
+
" - .",
|
|
71
|
+
"",
|
|
72
|
+
"catalog:",
|
|
73
|
+
' "@hono/node-server": ^2.0.6',
|
|
74
|
+
' "@types/node": ^24.0.0',
|
|
75
|
+
" hono: ^4.12.27",
|
|
76
|
+
" oxfmt: ^0.56.0",
|
|
77
|
+
" oxlint: ^1.71.0",
|
|
78
|
+
" tsc-alias: ^1.8.17",
|
|
79
|
+
" typescript: ^5.8.0",
|
|
80
|
+
" vitest: ^4.1.9",
|
|
81
|
+
""
|
|
82
|
+
].join("\n")
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
kind: "writeJson",
|
|
86
|
+
to: "tsconfig.json",
|
|
87
|
+
value: {
|
|
88
|
+
compilerOptions: {
|
|
89
|
+
module: "NodeNext",
|
|
90
|
+
moduleResolution: "NodeNext",
|
|
91
|
+
noEmitOnError: true,
|
|
92
|
+
paths: {
|
|
93
|
+
"@/*": ["./src/*"]
|
|
94
|
+
},
|
|
95
|
+
skipLibCheck: false,
|
|
96
|
+
strict: true,
|
|
97
|
+
target: "ES2022",
|
|
98
|
+
types: ["node", "vitest/globals"]
|
|
99
|
+
},
|
|
100
|
+
include: ["src/**/*.ts", "test/**/*.ts", "vitest.config.ts"]
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
kind: "writeJson",
|
|
105
|
+
to: "tsconfig.build.json",
|
|
106
|
+
value: {
|
|
107
|
+
extends: "./tsconfig.json",
|
|
108
|
+
compilerOptions: {
|
|
109
|
+
outDir: "dist",
|
|
110
|
+
rootDir: "src",
|
|
111
|
+
types: ["node"]
|
|
112
|
+
},
|
|
113
|
+
include: ["src/**/*.ts"]
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
kind: "writeJson",
|
|
118
|
+
to: ".oxlintrc.json",
|
|
119
|
+
value: {
|
|
120
|
+
categories: {
|
|
121
|
+
correctness: "error",
|
|
122
|
+
suspicious: "error"
|
|
123
|
+
},
|
|
124
|
+
plugins: ["typescript", "oxc"]
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
kind: "writeJson",
|
|
129
|
+
to: ".oxfmtrc.json",
|
|
130
|
+
value: {
|
|
131
|
+
printWidth: 100,
|
|
132
|
+
singleQuote: false,
|
|
133
|
+
trailingComma: "none"
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
kind: "writeText",
|
|
138
|
+
to: ".gitignore",
|
|
139
|
+
text: ["node_modules", "dist", ".env", ""].join("\n")
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
kind: "copyFile",
|
|
143
|
+
from: "src/app.ts",
|
|
144
|
+
to: "src/app.ts"
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
kind: "copyFile",
|
|
148
|
+
from: "src/server.ts",
|
|
149
|
+
to: "src/server.ts"
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
kind: "copyFile",
|
|
153
|
+
from: "test/app.test.ts",
|
|
154
|
+
to: "test/app.test.ts"
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
kind: "copyFile",
|
|
158
|
+
from: "vitest.config.ts",
|
|
159
|
+
to: "vitest.config.ts"
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
kind: "writeJson",
|
|
163
|
+
to: ".project-kit/blueprint.json",
|
|
164
|
+
value: {
|
|
165
|
+
schemaVersion: 1,
|
|
166
|
+
preset: "hono-api",
|
|
167
|
+
packageManager: "pnpm",
|
|
168
|
+
projectKind: "single-package",
|
|
169
|
+
features
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
kind: "writeJson",
|
|
174
|
+
to: ".project-kit/generated-by.json",
|
|
175
|
+
value: generatedBy
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
kind: "writeJson",
|
|
179
|
+
to: ".devcontainer/devcontainer.json",
|
|
180
|
+
value: {
|
|
181
|
+
name: `${projectName} API development`,
|
|
182
|
+
image: "mcr.microsoft.com/devcontainers/typescript-node:22",
|
|
183
|
+
postCreateCommand: "corepack enable && pnpm install",
|
|
184
|
+
customizations: {
|
|
185
|
+
vscode: {
|
|
186
|
+
extensions: ["oxc.oxc-vscode"]
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
kind: "writeText",
|
|
193
|
+
to: ".github/workflows/check.yml",
|
|
194
|
+
text: [
|
|
195
|
+
"name: Check",
|
|
196
|
+
"",
|
|
197
|
+
"on:",
|
|
198
|
+
" pull_request:",
|
|
199
|
+
" push:",
|
|
200
|
+
" branches:",
|
|
201
|
+
" - main",
|
|
202
|
+
"",
|
|
203
|
+
"jobs:",
|
|
204
|
+
" check:",
|
|
205
|
+
" runs-on: ubuntu-latest",
|
|
206
|
+
" steps:",
|
|
207
|
+
" - uses: actions/checkout@v4",
|
|
208
|
+
" - uses: pnpm/action-setup@v4",
|
|
209
|
+
" with:",
|
|
210
|
+
" version: 10.0.0",
|
|
211
|
+
" - uses: actions/setup-node@v4",
|
|
212
|
+
" with:",
|
|
213
|
+
" node-version: 22",
|
|
214
|
+
" - run: pnpm install",
|
|
215
|
+
" - run: pnpm run check",
|
|
216
|
+
""
|
|
217
|
+
].join("\n")
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
kind: "writeText",
|
|
221
|
+
to: ".github/dependabot.yml",
|
|
222
|
+
text: [
|
|
223
|
+
"version: 2",
|
|
224
|
+
"updates:",
|
|
225
|
+
" - package-ecosystem: npm",
|
|
226
|
+
" directory: /",
|
|
227
|
+
" schedule:",
|
|
228
|
+
" interval: weekly",
|
|
229
|
+
" - package-ecosystem: github-actions",
|
|
230
|
+
" directory: /",
|
|
231
|
+
" schedule:",
|
|
232
|
+
" interval: weekly",
|
|
233
|
+
""
|
|
234
|
+
].join("\n")
|
|
235
|
+
}
|
|
236
|
+
];
|
|
237
|
+
}
|
|
238
|
+
function templateSourceRoot() {
|
|
239
|
+
return path.join(path.dirname(fileURLToPath(import.meta.url)), "..", "templates", "hono-api");
|
|
240
|
+
}
|
|
241
|
+
export async function initHonoApiProject(targetDir) {
|
|
242
|
+
await renderNewProject({
|
|
243
|
+
sourceRoot: templateSourceRoot(),
|
|
244
|
+
targetRoot: targetDir,
|
|
245
|
+
operations: operationsForHonoApi(projectNameFromDir(targetDir))
|
|
246
|
+
});
|
|
247
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-addition.d.ts","sourceRoot":"","sources":["../src/package-addition.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,iBAAiB,GAAG;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAyoBF,wBAAsB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CA0C1E"}
|