@ykdz/template 0.0.3 → 0.0.5
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/README.md +1 -1
- package/dist/src/cli.d.ts +0 -1
- package/dist/src/cli.js +26 -2
- package/dist/src/declarations.d.ts +38 -3
- package/dist/src/declarations.js +75 -36
- package/dist/src/dependency-catalog.d.ts +9 -1
- package/dist/src/dependency-catalog.js +69 -0
- package/dist/src/devcontainer.d.ts +49 -9
- package/dist/src/devcontainer.js +192 -14
- package/dist/src/editor-customization.d.ts +0 -1
- package/dist/src/editor-customization.js +54 -47
- package/dist/src/generation-context.d.ts +0 -1
- package/dist/src/generation-context.js +4 -1
- package/dist/src/module-graph.d.ts +8 -5
- package/dist/src/module-graph.js +20 -2
- package/dist/src/next-step-instructions.d.ts +0 -1
- package/dist/src/next-step-instructions.js +35 -0
- package/dist/src/package-addition-support.d.ts +5 -0
- package/dist/src/package-addition-support.js +4 -0
- package/dist/src/package-addition.d.ts +2 -1
- package/dist/src/package-addition.js +557 -55
- package/dist/src/package-linking.d.ts +55 -0
- package/dist/src/package-linking.js +116 -0
- package/dist/src/preset-projection.d.ts +4 -2
- package/dist/src/project-github.d.ts +3 -2
- package/dist/src/project-github.js +24 -6
- package/dist/src/renderer.d.ts +16 -2
- package/dist/src/renderer.js +96 -12
- package/dist/src/runtime-paths.d.ts +0 -1
- package/dist/src/template-boundary-check.d.ts +34 -0
- package/dist/src/template-boundary-check.js +448 -0
- package/dist/src/toolchain-resolution.d.ts +0 -1
- package/dist/templates/hono-api/projection.d.ts +2 -3
- package/dist/templates/hono-api/projection.js +258 -76
- package/dist/templates/projection-plans.d.ts +0 -1
- package/dist/templates/registry.d.ts +0 -1
- package/dist/templates/registry.js +5 -2
- package/dist/templates/rust-bin/projection.d.ts +2 -3
- package/dist/templates/rust-bin/projection.js +171 -53
- package/dist/templates/ts-lib/projection.d.ts +2 -3
- package/dist/templates/ts-lib/projection.js +251 -87
- package/dist/templates/vue-app/projection.d.ts +2 -3
- package/dist/templates/vue-app/projection.js +266 -94
- package/dist/templates/vue-hono-app/projection.d.ts +0 -1
- package/dist/templates/vue-hono-app/projection.js +232 -108
- package/package.json +10 -5
- package/pnpm-workspace.yaml +1 -0
- package/templates/hono-api/.github/dependabot.yml +13 -0
- package/templates/hono-api/src/server.ts +1 -1
- package/templates/hono-api/test/app.test.ts +1 -1
- package/templates/rust-bin/.github/dependabot.yml +18 -1
- package/templates/rust-bin/rust-toolchain.toml +3 -0
- package/templates/rust-bin/rustfmt.toml +2 -0
- package/templates/shared/devcontainer/browser-test.Dockerfile +2 -0
- package/templates/shared/devcontainer/node-pnpm.Dockerfile +6 -0
- package/templates/shared/devcontainer/rust.Dockerfile +16 -0
- package/templates/shared/editor-customization/capabilities.json +56 -0
- package/templates/ts-lib/.github/dependabot.yml +13 -0
- package/templates/ts-lib/src/index.ts +5 -1
- package/templates/ts-lib/src/name-schema.ts +3 -0
- package/templates/vue-app/.github/dependabot.yml +13 -0
- package/templates/vue-app/.github/workflows/check.yml +1 -1
- package/templates/vue-app/src/App.vue +1 -1
- package/templates/vue-app/test/app.test.ts +1 -1
- package/templates/vue-hono-app/.github/dependabot.yml +13 -0
- package/templates/vue-hono-app/web/src/App.vue +2 -2
- package/templates/vue-hono-app/web/test/app.test.ts +1 -1
- package/dist/src/cli.d.ts.map +0 -1
- package/dist/src/declarations.d.ts.map +0 -1
- package/dist/src/dependency-catalog.d.ts.map +0 -1
- package/dist/src/devcontainer.d.ts.map +0 -1
- package/dist/src/editor-customization.d.ts.map +0 -1
- package/dist/src/generation-context.d.ts.map +0 -1
- package/dist/src/module-graph.d.ts.map +0 -1
- package/dist/src/next-step-instructions.d.ts.map +0 -1
- package/dist/src/package-addition.d.ts.map +0 -1
- package/dist/src/preset-projection.d.ts.map +0 -1
- package/dist/src/project-github.d.ts.map +0 -1
- package/dist/src/renderer.d.ts.map +0 -1
- package/dist/src/runtime-paths.d.ts.map +0 -1
- package/dist/src/toolchain-resolution.d.ts.map +0 -1
- package/dist/templates/hono-api/projection.d.ts.map +0 -1
- package/dist/templates/projection-plans.d.ts.map +0 -1
- package/dist/templates/registry.d.ts.map +0 -1
- package/dist/templates/rust-bin/projection.d.ts.map +0 -1
- package/dist/templates/ts-lib/projection.d.ts.map +0 -1
- package/dist/templates/vue-app/projection.d.ts.map +0 -1
- package/dist/templates/vue-hono-app/projection.d.ts.map +0 -1
- package/templates/hono-api/projection.ts +0 -453
- package/templates/projection-plans.ts +0 -135
- package/templates/registry.ts +0 -59
- package/templates/rust-bin/projection.ts +0 -346
- package/templates/ts-lib/projection.ts +0 -454
- package/templates/vue-app/projection.ts +0 -687
- package/templates/vue-hono-app/projection.ts +0 -669
|
@@ -1,453 +0,0 @@
|
|
|
1
|
-
import { existsSync } from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { fileURLToPath } from "node:url";
|
|
4
|
-
|
|
5
|
-
import type {
|
|
6
|
-
BuiltInPreset,
|
|
7
|
-
ProjectBlueprint,
|
|
8
|
-
} from "../../src/declarations.js";
|
|
9
|
-
import { renderGeneratedPnpmWorkspaceYaml } from "../../src/dependency-catalog.js";
|
|
10
|
-
import { nodePnpmDevcontainer } from "../../src/devcontainer.js";
|
|
11
|
-
import { editorCustomizationForCapabilities } from "../../src/editor-customization.js";
|
|
12
|
-
import type { GenerationContext } from "../../src/generation-context.js";
|
|
13
|
-
import {
|
|
14
|
-
type CheckPlan,
|
|
15
|
-
renderFixCommand,
|
|
16
|
-
renderRootCheckCommand,
|
|
17
|
-
} from "../../src/module-graph.js";
|
|
18
|
-
import type {
|
|
19
|
-
PresetPackageAdditionOptions,
|
|
20
|
-
PresetPackageAdditionPlan,
|
|
21
|
-
PresetProjection,
|
|
22
|
-
PresetProjectionPlan,
|
|
23
|
-
} from "../../src/preset-projection.js";
|
|
24
|
-
import {
|
|
25
|
-
projectCheckWorkflow,
|
|
26
|
-
projectDependabotConfig,
|
|
27
|
-
type DependencyMaintenancePolicy,
|
|
28
|
-
} from "../../src/project-github.js";
|
|
29
|
-
import { renderNewProject, type RenderOperation } from "../../src/renderer.js";
|
|
30
|
-
import { planNodeChecks, planNodeFixes } from "../projection-plans.js";
|
|
31
|
-
|
|
32
|
-
const generatedBy = {
|
|
33
|
-
packageName: "@ykdz/template",
|
|
34
|
-
version: "0.0.0",
|
|
35
|
-
command: "template init --preset hono-api",
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export const honoApiPresetMetadata: BuiltInPreset = {
|
|
39
|
-
name: "hono-api",
|
|
40
|
-
title: "Hono API",
|
|
41
|
-
description: "Single-package Hono Node API with strict TypeScript tooling.",
|
|
42
|
-
generation: "supported",
|
|
43
|
-
supportedPackageManagers: ["pnpm"],
|
|
44
|
-
supportedProjectKinds: ["single-package"],
|
|
45
|
-
features: [
|
|
46
|
-
"pnpm-catalog",
|
|
47
|
-
"oxc-format-lint",
|
|
48
|
-
"strict-typescript",
|
|
49
|
-
"root-check",
|
|
50
|
-
"fix-command",
|
|
51
|
-
"devcontainer",
|
|
52
|
-
"github-actions",
|
|
53
|
-
"dependabot",
|
|
54
|
-
],
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const dependencyMaintenancePolicy: DependencyMaintenancePolicy = {
|
|
58
|
-
ecosystems: ["npm", "github-actions"],
|
|
59
|
-
interval: "weekly",
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
export function honoApiBlueprint(): ProjectBlueprint {
|
|
63
|
-
return {
|
|
64
|
-
schemaVersion: 1,
|
|
65
|
-
preset: "hono-api",
|
|
66
|
-
packageManager: "pnpm",
|
|
67
|
-
projectKind: "single-package",
|
|
68
|
-
features: [...honoApiPresetMetadata.features],
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export function projectHonoApiPackageScripts(): Record<string, string> {
|
|
73
|
-
return {
|
|
74
|
-
build: "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",
|
|
75
|
-
check: renderRootCheckCommand(planNodeChecks("hono-api")),
|
|
76
|
-
fix: renderFixCommand(planNodeFixes("hono-api")),
|
|
77
|
-
"format:check": "oxfmt --check .",
|
|
78
|
-
"format:write": "oxfmt --write .",
|
|
79
|
-
lint: "oxlint . --deny-warnings",
|
|
80
|
-
"lint:fix": "oxlint . --fix --deny-warnings",
|
|
81
|
-
start: "node dist/server.js",
|
|
82
|
-
test: "vitest run",
|
|
83
|
-
typecheck: "tsc -p tsconfig.json --noEmit",
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function packageJson(
|
|
88
|
-
context: GenerationContext,
|
|
89
|
-
packageScripts: Record<string, string>,
|
|
90
|
-
): Record<string, unknown> {
|
|
91
|
-
return {
|
|
92
|
-
name: context.projectName.value,
|
|
93
|
-
version: "0.0.0",
|
|
94
|
-
private: true,
|
|
95
|
-
type: "module",
|
|
96
|
-
scripts: packageScripts,
|
|
97
|
-
dependencies: {
|
|
98
|
-
"@hono/node-server": "catalog:",
|
|
99
|
-
hono: "catalog:",
|
|
100
|
-
},
|
|
101
|
-
devDependencies: {
|
|
102
|
-
"@types/node": "catalog:",
|
|
103
|
-
oxfmt: "catalog:",
|
|
104
|
-
oxlint: "catalog:",
|
|
105
|
-
"tsc-alias": "catalog:",
|
|
106
|
-
typescript: "catalog:",
|
|
107
|
-
vitest: "catalog:",
|
|
108
|
-
},
|
|
109
|
-
engines: {
|
|
110
|
-
node: context.toolchain.nodeLtsMajor.value,
|
|
111
|
-
},
|
|
112
|
-
packageManager: context.toolchain.packageManagerPin.value,
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
function generationRecord(context: GenerationContext): Record<string, unknown> {
|
|
117
|
-
return {
|
|
118
|
-
...generatedBy,
|
|
119
|
-
toolchain: {
|
|
120
|
-
nodeLtsMajor: context.toolchain.nodeLtsMajor.value,
|
|
121
|
-
packageManagerPin: context.toolchain.packageManagerPin.value,
|
|
122
|
-
source: context.toolchain.source,
|
|
123
|
-
},
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function operationsForHonoApi(
|
|
128
|
-
context: GenerationContext,
|
|
129
|
-
packageScripts: Record<string, string>,
|
|
130
|
-
checkPlan: CheckPlan,
|
|
131
|
-
): RenderOperation[] {
|
|
132
|
-
const editorCustomization = editorCustomizationForCapabilities([
|
|
133
|
-
"oxc-format-lint",
|
|
134
|
-
"vitest",
|
|
135
|
-
]);
|
|
136
|
-
|
|
137
|
-
return [
|
|
138
|
-
{
|
|
139
|
-
kind: "writeJson",
|
|
140
|
-
to: "package.json",
|
|
141
|
-
value: packageJson(context, packageScripts),
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
kind: "writeText",
|
|
145
|
-
to: "pnpm-workspace.yaml",
|
|
146
|
-
text: renderGeneratedPnpmWorkspaceYaml({
|
|
147
|
-
dependencies: [
|
|
148
|
-
"@hono/node-server",
|
|
149
|
-
"@types/node",
|
|
150
|
-
"hono",
|
|
151
|
-
"oxfmt",
|
|
152
|
-
"oxlint",
|
|
153
|
-
"tsc-alias",
|
|
154
|
-
"typescript",
|
|
155
|
-
"vitest",
|
|
156
|
-
],
|
|
157
|
-
}),
|
|
158
|
-
},
|
|
159
|
-
{
|
|
160
|
-
kind: "writeJson",
|
|
161
|
-
to: "tsconfig.json",
|
|
162
|
-
value: {
|
|
163
|
-
compilerOptions: {
|
|
164
|
-
module: "NodeNext",
|
|
165
|
-
moduleResolution: "NodeNext",
|
|
166
|
-
noEmitOnError: true,
|
|
167
|
-
paths: {
|
|
168
|
-
"@/*": ["./src/*"],
|
|
169
|
-
},
|
|
170
|
-
skipLibCheck: false,
|
|
171
|
-
strict: true,
|
|
172
|
-
target: "ES2022",
|
|
173
|
-
types: ["node", "vitest/globals"],
|
|
174
|
-
},
|
|
175
|
-
include: ["src/**/*.ts", "test/**/*.ts", "vitest.config.ts"],
|
|
176
|
-
},
|
|
177
|
-
},
|
|
178
|
-
{
|
|
179
|
-
kind: "writeJson",
|
|
180
|
-
to: "tsconfig.build.json",
|
|
181
|
-
value: {
|
|
182
|
-
extends: "./tsconfig.json",
|
|
183
|
-
compilerOptions: {
|
|
184
|
-
outDir: "dist",
|
|
185
|
-
rootDir: "src",
|
|
186
|
-
types: ["node"],
|
|
187
|
-
},
|
|
188
|
-
include: ["src/**/*.ts"],
|
|
189
|
-
},
|
|
190
|
-
},
|
|
191
|
-
{
|
|
192
|
-
kind: "copyFile",
|
|
193
|
-
sourceRoot: "sharedOxc",
|
|
194
|
-
from: "node/oxlint.config.ts",
|
|
195
|
-
to: "oxlint.config.ts",
|
|
196
|
-
},
|
|
197
|
-
{
|
|
198
|
-
kind: "copyFile",
|
|
199
|
-
sourceRoot: "sharedOxc",
|
|
200
|
-
from: "oxfmt.config.ts",
|
|
201
|
-
to: "oxfmt.config.ts",
|
|
202
|
-
},
|
|
203
|
-
{
|
|
204
|
-
kind: "writeText",
|
|
205
|
-
to: ".gitignore",
|
|
206
|
-
text: ["node_modules", "dist", ".env", ""].join("\n"),
|
|
207
|
-
},
|
|
208
|
-
{ kind: "copyFile", from: "src/app.ts", to: "src/app.ts" },
|
|
209
|
-
{ kind: "copyFile", from: "src/server.ts", to: "src/server.ts" },
|
|
210
|
-
{ kind: "copyFile", from: "test/app.test.ts", to: "test/app.test.ts" },
|
|
211
|
-
{ kind: "copyFile", from: "vitest.config.ts", to: "vitest.config.ts" },
|
|
212
|
-
{
|
|
213
|
-
kind: "writeJson",
|
|
214
|
-
to: ".project-kit/blueprint.json",
|
|
215
|
-
value: honoApiBlueprint(),
|
|
216
|
-
},
|
|
217
|
-
{
|
|
218
|
-
kind: "writeJson",
|
|
219
|
-
to: ".project-kit/generated-by.json",
|
|
220
|
-
value: generationRecord(context),
|
|
221
|
-
},
|
|
222
|
-
{
|
|
223
|
-
kind: "writeJson",
|
|
224
|
-
to: ".devcontainer/devcontainer.json",
|
|
225
|
-
value: nodePnpmDevcontainer({
|
|
226
|
-
name: `${context.projectName.value} API development`,
|
|
227
|
-
nodeVersion: context.toolchain.nodeLtsMajor.value,
|
|
228
|
-
packageManagerPin: context.toolchain.packageManagerPin.value,
|
|
229
|
-
extensions: editorCustomization.extensions,
|
|
230
|
-
settings: editorCustomization.settings,
|
|
231
|
-
}),
|
|
232
|
-
},
|
|
233
|
-
{
|
|
234
|
-
kind: "writeJson",
|
|
235
|
-
to: ".vscode/extensions.json",
|
|
236
|
-
value: {
|
|
237
|
-
recommendations: editorCustomization.extensions,
|
|
238
|
-
},
|
|
239
|
-
multilineArrays: ["recommendations"],
|
|
240
|
-
},
|
|
241
|
-
{
|
|
242
|
-
kind: "writeJson",
|
|
243
|
-
to: ".vscode/settings.json",
|
|
244
|
-
value: editorCustomization.settings,
|
|
245
|
-
},
|
|
246
|
-
{
|
|
247
|
-
kind: "writeText",
|
|
248
|
-
to: ".github/workflows/check.yml",
|
|
249
|
-
text: projectCheckWorkflow({ checkPlan }),
|
|
250
|
-
},
|
|
251
|
-
{
|
|
252
|
-
kind: "writeText",
|
|
253
|
-
to: ".github/dependabot.yml",
|
|
254
|
-
text: projectDependabotConfig(dependencyMaintenancePolicy),
|
|
255
|
-
},
|
|
256
|
-
];
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
function packageAdditionOperations(
|
|
260
|
-
packagePath: string,
|
|
261
|
-
packageName: string,
|
|
262
|
-
nodeVersion: string,
|
|
263
|
-
): RenderOperation[] {
|
|
264
|
-
return [
|
|
265
|
-
{
|
|
266
|
-
kind: "writeJson",
|
|
267
|
-
to: `${packagePath}/package.json`,
|
|
268
|
-
value: {
|
|
269
|
-
name: packageName,
|
|
270
|
-
version: "0.0.0",
|
|
271
|
-
private: true,
|
|
272
|
-
type: "module",
|
|
273
|
-
scripts: projectHonoApiPackageScripts(),
|
|
274
|
-
dependencies: {
|
|
275
|
-
"@hono/node-server": "catalog:",
|
|
276
|
-
hono: "catalog:",
|
|
277
|
-
},
|
|
278
|
-
devDependencies: {
|
|
279
|
-
"@types/node": "catalog:",
|
|
280
|
-
oxfmt: "catalog:",
|
|
281
|
-
oxlint: "catalog:",
|
|
282
|
-
"tsc-alias": "catalog:",
|
|
283
|
-
typescript: "catalog:",
|
|
284
|
-
vitest: "catalog:",
|
|
285
|
-
},
|
|
286
|
-
engines: {
|
|
287
|
-
node: nodeVersion,
|
|
288
|
-
},
|
|
289
|
-
},
|
|
290
|
-
},
|
|
291
|
-
{
|
|
292
|
-
kind: "writeJson",
|
|
293
|
-
to: `${packagePath}/tsconfig.json`,
|
|
294
|
-
value: {
|
|
295
|
-
compilerOptions: {
|
|
296
|
-
composite: true,
|
|
297
|
-
module: "NodeNext",
|
|
298
|
-
moduleResolution: "NodeNext",
|
|
299
|
-
noEmitOnError: true,
|
|
300
|
-
paths: {
|
|
301
|
-
"@/*": ["./src/*"],
|
|
302
|
-
},
|
|
303
|
-
skipLibCheck: false,
|
|
304
|
-
strict: true,
|
|
305
|
-
target: "ES2022",
|
|
306
|
-
types: ["node", "vitest/globals"],
|
|
307
|
-
},
|
|
308
|
-
include: ["src/**/*.ts", "test/**/*.ts", "vitest.config.ts"],
|
|
309
|
-
},
|
|
310
|
-
},
|
|
311
|
-
{
|
|
312
|
-
kind: "writeJson",
|
|
313
|
-
to: `${packagePath}/tsconfig.build.json`,
|
|
314
|
-
value: {
|
|
315
|
-
extends: "./tsconfig.json",
|
|
316
|
-
compilerOptions: {
|
|
317
|
-
outDir: "dist",
|
|
318
|
-
rootDir: "src",
|
|
319
|
-
types: ["node"],
|
|
320
|
-
},
|
|
321
|
-
include: ["src/**/*.ts"],
|
|
322
|
-
},
|
|
323
|
-
},
|
|
324
|
-
{
|
|
325
|
-
kind: "copyFile",
|
|
326
|
-
sourceRoot: "sharedOxc",
|
|
327
|
-
from: "node/oxlint.config.ts",
|
|
328
|
-
to: `${packagePath}/oxlint.config.ts`,
|
|
329
|
-
},
|
|
330
|
-
{
|
|
331
|
-
kind: "copyFile",
|
|
332
|
-
sourceRoot: "sharedOxc",
|
|
333
|
-
from: "oxfmt.config.ts",
|
|
334
|
-
to: `${packagePath}/oxfmt.config.ts`,
|
|
335
|
-
},
|
|
336
|
-
{ kind: "copyFile", from: "src/app.ts", to: `${packagePath}/src/app.ts` },
|
|
337
|
-
{
|
|
338
|
-
kind: "copyFile",
|
|
339
|
-
from: "src/server.ts",
|
|
340
|
-
to: `${packagePath}/src/server.ts`,
|
|
341
|
-
},
|
|
342
|
-
{
|
|
343
|
-
kind: "copyFile",
|
|
344
|
-
from: "test/app.test.ts",
|
|
345
|
-
to: `${packagePath}/test/app.test.ts`,
|
|
346
|
-
},
|
|
347
|
-
{
|
|
348
|
-
kind: "copyFile",
|
|
349
|
-
from: "vitest.config.ts",
|
|
350
|
-
to: `${packagePath}/vitest.config.ts`,
|
|
351
|
-
},
|
|
352
|
-
];
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
function packageAdditionPlan(
|
|
356
|
-
packageLeafName: string,
|
|
357
|
-
packageName: string,
|
|
358
|
-
nodeVersion: string,
|
|
359
|
-
): PresetPackageAdditionPlan {
|
|
360
|
-
const packagePath = `apps/${packageLeafName}`;
|
|
361
|
-
|
|
362
|
-
return {
|
|
363
|
-
packagePath,
|
|
364
|
-
workspacePackageGlob: "apps/*",
|
|
365
|
-
rootTsconfigReferences: [`./${packagePath}/tsconfig.json`],
|
|
366
|
-
sourceRoot: templateSourceRoot(),
|
|
367
|
-
sourceRoots: { sharedOxc: sharedOxcSourceRoot() },
|
|
368
|
-
operations: packageAdditionOperations(
|
|
369
|
-
packagePath,
|
|
370
|
-
packageName,
|
|
371
|
-
nodeVersion,
|
|
372
|
-
),
|
|
373
|
-
};
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
function templateSourceRoot(): string {
|
|
377
|
-
const projectionDir = path.dirname(fileURLToPath(import.meta.url));
|
|
378
|
-
const publishedTemplateRoot = path.join(
|
|
379
|
-
projectionDir,
|
|
380
|
-
"..",
|
|
381
|
-
"..",
|
|
382
|
-
"..",
|
|
383
|
-
"templates",
|
|
384
|
-
"hono-api",
|
|
385
|
-
);
|
|
386
|
-
|
|
387
|
-
return existsSync(path.join(publishedTemplateRoot, "src", "app.ts"))
|
|
388
|
-
? publishedTemplateRoot
|
|
389
|
-
: projectionDir;
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
function sharedOxcSourceRoot(): string {
|
|
393
|
-
const projectionDir = path.dirname(fileURLToPath(import.meta.url));
|
|
394
|
-
const publishedSharedRoot = path.join(
|
|
395
|
-
projectionDir,
|
|
396
|
-
"..",
|
|
397
|
-
"..",
|
|
398
|
-
"..",
|
|
399
|
-
"templates",
|
|
400
|
-
"shared",
|
|
401
|
-
"oxc",
|
|
402
|
-
);
|
|
403
|
-
|
|
404
|
-
return existsSync(path.join(publishedSharedRoot, "oxfmt.config.ts"))
|
|
405
|
-
? publishedSharedRoot
|
|
406
|
-
: path.join(projectionDir, "..", "shared", "oxc");
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
export const honoApiPresetProjection: PresetProjection = {
|
|
410
|
-
metadata: honoApiPresetMetadata,
|
|
411
|
-
capabilities: {
|
|
412
|
-
packageAddition: {
|
|
413
|
-
planPackageAddition({
|
|
414
|
-
packageLeafName,
|
|
415
|
-
packageName,
|
|
416
|
-
nodeVersion,
|
|
417
|
-
}: PresetPackageAdditionOptions) {
|
|
418
|
-
return packageAdditionPlan(packageLeafName, packageName, nodeVersion);
|
|
419
|
-
},
|
|
420
|
-
},
|
|
421
|
-
},
|
|
422
|
-
blueprint: honoApiBlueprint,
|
|
423
|
-
project(context: GenerationContext): PresetProjectionPlan {
|
|
424
|
-
const checkPlan = planNodeChecks("hono-api");
|
|
425
|
-
const fixPlan = planNodeFixes("hono-api");
|
|
426
|
-
const packageScripts = projectHonoApiPackageScripts();
|
|
427
|
-
|
|
428
|
-
return {
|
|
429
|
-
sourceRoot: templateSourceRoot(),
|
|
430
|
-
sourceRoots: { sharedOxc: sharedOxcSourceRoot() },
|
|
431
|
-
operations: operationsForHonoApi(context, packageScripts, checkPlan),
|
|
432
|
-
checkPlan,
|
|
433
|
-
fixPlan,
|
|
434
|
-
dependencyMaintenancePolicy,
|
|
435
|
-
packageScripts,
|
|
436
|
-
capabilities: {
|
|
437
|
-
rootCheck: true,
|
|
438
|
-
fixCommand: true,
|
|
439
|
-
githubActions: true,
|
|
440
|
-
dependabot: true,
|
|
441
|
-
devcontainer: true,
|
|
442
|
-
},
|
|
443
|
-
};
|
|
444
|
-
},
|
|
445
|
-
async render({ targetDir, plan }): Promise<void> {
|
|
446
|
-
await renderNewProject({
|
|
447
|
-
sourceRoot: plan.sourceRoot,
|
|
448
|
-
sourceRoots: plan.sourceRoots,
|
|
449
|
-
targetRoot: targetDir,
|
|
450
|
-
operations: [...plan.operations],
|
|
451
|
-
});
|
|
452
|
-
},
|
|
453
|
-
};
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
CheckComponent,
|
|
3
|
-
CheckEnvironmentNeed,
|
|
4
|
-
CheckPlan,
|
|
5
|
-
ComponentOwner,
|
|
6
|
-
FixComponent,
|
|
7
|
-
FixPlan,
|
|
8
|
-
} from "../src/module-graph.js";
|
|
9
|
-
|
|
10
|
-
const rootPackageBoundary: ComponentOwner = {
|
|
11
|
-
kind: "package-boundary",
|
|
12
|
-
path: ".",
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const apiPackageBoundary: ComponentOwner = {
|
|
16
|
-
kind: "package-boundary",
|
|
17
|
-
path: "apps/api",
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const webPackageBoundary: ComponentOwner = {
|
|
21
|
-
kind: "package-boundary",
|
|
22
|
-
path: "apps/web",
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export type NodeCheckPlanTarget =
|
|
26
|
-
| "hono-api"
|
|
27
|
-
| "vue-app"
|
|
28
|
-
| "vue-hono-root"
|
|
29
|
-
| "vue-hono-api"
|
|
30
|
-
| "vue-hono-web";
|
|
31
|
-
|
|
32
|
-
export type NodeFixPlanTarget =
|
|
33
|
-
| "hono-api"
|
|
34
|
-
| "vue-app"
|
|
35
|
-
| "vue-hono-root"
|
|
36
|
-
| "vue-hono-api"
|
|
37
|
-
| "vue-hono-web";
|
|
38
|
-
|
|
39
|
-
function honoApiCheckComponents(owner: ComponentOwner): CheckComponent[] {
|
|
40
|
-
return [
|
|
41
|
-
{ kind: "oxc-format-check", owner },
|
|
42
|
-
{ kind: "oxc-lint", owner },
|
|
43
|
-
{ kind: "typescript-typecheck", owner },
|
|
44
|
-
{ kind: "build", owner },
|
|
45
|
-
{ kind: "unit-test", owner },
|
|
46
|
-
];
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function vueAppCheckComponents(owner: ComponentOwner): CheckComponent[] {
|
|
50
|
-
return [
|
|
51
|
-
{ kind: "oxc-format-check", owner },
|
|
52
|
-
{ kind: "oxc-lint", owner },
|
|
53
|
-
{ kind: "typescript-typecheck", owner },
|
|
54
|
-
{ kind: "build", owner },
|
|
55
|
-
{ kind: "unit-test", owner },
|
|
56
|
-
{ kind: "e2e-test", owner },
|
|
57
|
-
];
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function nodeFixComponents(owner: ComponentOwner): FixComponent[] {
|
|
61
|
-
return [
|
|
62
|
-
{ kind: "oxc-format-write", owner },
|
|
63
|
-
{ kind: "oxc-lint-fix", owner },
|
|
64
|
-
];
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export function selectNodeCheckComponents(
|
|
68
|
-
target: NodeCheckPlanTarget,
|
|
69
|
-
): CheckComponent[] {
|
|
70
|
-
switch (target) {
|
|
71
|
-
case "hono-api":
|
|
72
|
-
return honoApiCheckComponents(rootPackageBoundary);
|
|
73
|
-
case "vue-app":
|
|
74
|
-
return vueAppCheckComponents(rootPackageBoundary);
|
|
75
|
-
case "vue-hono-root":
|
|
76
|
-
return [{ kind: "turbo-check", owner: rootPackageBoundary }];
|
|
77
|
-
case "vue-hono-api":
|
|
78
|
-
return honoApiCheckComponents(apiPackageBoundary);
|
|
79
|
-
case "vue-hono-web":
|
|
80
|
-
return vueAppCheckComponents(webPackageBoundary);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export function selectNodeFixComponents(
|
|
85
|
-
target: NodeFixPlanTarget,
|
|
86
|
-
): FixComponent[] {
|
|
87
|
-
switch (target) {
|
|
88
|
-
case "hono-api":
|
|
89
|
-
case "vue-app":
|
|
90
|
-
return nodeFixComponents(rootPackageBoundary);
|
|
91
|
-
case "vue-hono-root":
|
|
92
|
-
return [{ kind: "turbo-fix", owner: rootPackageBoundary }];
|
|
93
|
-
case "vue-hono-api":
|
|
94
|
-
return nodeFixComponents(apiPackageBoundary);
|
|
95
|
-
case "vue-hono-web":
|
|
96
|
-
return nodeFixComponents(webPackageBoundary);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
function checkEnvironmentNeeds(
|
|
101
|
-
target: NodeCheckPlanTarget,
|
|
102
|
-
): CheckEnvironmentNeed[] {
|
|
103
|
-
if (target === "vue-app") {
|
|
104
|
-
return [
|
|
105
|
-
{
|
|
106
|
-
kind: "playwright-browser-assets",
|
|
107
|
-
browser: "chromium",
|
|
108
|
-
owner: rootPackageBoundary,
|
|
109
|
-
},
|
|
110
|
-
];
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
if (target === "vue-hono-root" || target === "vue-hono-web") {
|
|
114
|
-
return [
|
|
115
|
-
{
|
|
116
|
-
kind: "playwright-browser-assets",
|
|
117
|
-
browser: "chromium",
|
|
118
|
-
owner: webPackageBoundary,
|
|
119
|
-
},
|
|
120
|
-
];
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return [];
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export function planNodeChecks(target: NodeCheckPlanTarget): CheckPlan {
|
|
127
|
-
return {
|
|
128
|
-
components: selectNodeCheckComponents(target),
|
|
129
|
-
environmentNeeds: checkEnvironmentNeeds(target),
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
export function planNodeFixes(target: NodeFixPlanTarget): FixPlan {
|
|
134
|
-
return { components: selectNodeFixComponents(target) };
|
|
135
|
-
}
|
package/templates/registry.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import type { BuiltInPreset } from "../src/declarations.js";
|
|
2
|
-
import type { GenerationContext } from "../src/generation-context.js";
|
|
3
|
-
import type {
|
|
4
|
-
PresetProjection,
|
|
5
|
-
PresetProjectionPlan,
|
|
6
|
-
} from "../src/preset-projection.js";
|
|
7
|
-
import { honoApiPresetProjection } from "./hono-api/projection.js";
|
|
8
|
-
import { rustBinPresetProjection } from "./rust-bin/projection.js";
|
|
9
|
-
import { tsLibPresetProjection } from "./ts-lib/projection.js";
|
|
10
|
-
import { vueAppPresetProjection } from "./vue-app/projection.js";
|
|
11
|
-
import { vueHonoAppPresetProjection } from "./vue-hono-app/projection.js";
|
|
12
|
-
|
|
13
|
-
const futurePresetMetadata = [
|
|
14
|
-
{
|
|
15
|
-
name: "ts-app",
|
|
16
|
-
title: "TypeScript application",
|
|
17
|
-
description: "Future application preset metadata.",
|
|
18
|
-
generation: "future",
|
|
19
|
-
supportedPackageManagers: ["pnpm"],
|
|
20
|
-
supportedProjectKinds: ["single-package"],
|
|
21
|
-
features: [],
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
name: "node-cli",
|
|
25
|
-
title: "Node.js CLI",
|
|
26
|
-
description: "Future command-line preset metadata.",
|
|
27
|
-
generation: "future",
|
|
28
|
-
supportedPackageManagers: ["pnpm"],
|
|
29
|
-
supportedProjectKinds: ["single-package"],
|
|
30
|
-
features: [],
|
|
31
|
-
},
|
|
32
|
-
] satisfies readonly BuiltInPreset[];
|
|
33
|
-
|
|
34
|
-
export const builtInPresetProjections: readonly PresetProjection[] = [
|
|
35
|
-
tsLibPresetProjection,
|
|
36
|
-
honoApiPresetProjection,
|
|
37
|
-
vueAppPresetProjection,
|
|
38
|
-
vueHonoAppPresetProjection,
|
|
39
|
-
rustBinPresetProjection,
|
|
40
|
-
];
|
|
41
|
-
|
|
42
|
-
export const builtInPresetMetadata: readonly BuiltInPreset[] = [
|
|
43
|
-
...builtInPresetProjections.map((projection) => projection.metadata),
|
|
44
|
-
...futurePresetMetadata,
|
|
45
|
-
];
|
|
46
|
-
|
|
47
|
-
export function findBuiltInPresetProjection(
|
|
48
|
-
name: string,
|
|
49
|
-
): PresetProjection | undefined {
|
|
50
|
-
return builtInPresetProjections.find(
|
|
51
|
-
(projection) => projection.metadata.name === name,
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export function projectPresetThroughRegistry(
|
|
56
|
-
context: GenerationContext,
|
|
57
|
-
): PresetProjectionPlan | undefined {
|
|
58
|
-
return findBuiltInPresetProjection(context.preset)?.project(context);
|
|
59
|
-
}
|