@ykdz/template 0.0.3 → 0.0.4

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.
Files changed (84) hide show
  1. package/README.md +1 -1
  2. package/dist/src/cli.d.ts +0 -1
  3. package/dist/src/cli.js +14 -2
  4. package/dist/src/declarations.d.ts +2 -3
  5. package/dist/src/declarations.js +46 -36
  6. package/dist/src/dependency-catalog.d.ts +9 -1
  7. package/dist/src/dependency-catalog.js +69 -0
  8. package/dist/src/devcontainer.d.ts +49 -9
  9. package/dist/src/devcontainer.js +192 -14
  10. package/dist/src/editor-customization.d.ts +0 -1
  11. package/dist/src/editor-customization.js +54 -47
  12. package/dist/src/generation-context.d.ts +0 -1
  13. package/dist/src/generation-context.js +4 -1
  14. package/dist/src/module-graph.d.ts +8 -5
  15. package/dist/src/module-graph.js +10 -0
  16. package/dist/src/next-step-instructions.d.ts +0 -1
  17. package/dist/src/next-step-instructions.js +35 -0
  18. package/dist/src/package-addition.d.ts +1 -1
  19. package/dist/src/package-addition.js +170 -15
  20. package/dist/src/preset-projection.d.ts +1 -1
  21. package/dist/src/project-github.d.ts +3 -2
  22. package/dist/src/project-github.js +24 -6
  23. package/dist/src/renderer.d.ts +16 -2
  24. package/dist/src/renderer.js +95 -12
  25. package/dist/src/runtime-paths.d.ts +0 -1
  26. package/dist/src/template-boundary-check.d.ts +34 -0
  27. package/dist/src/template-boundary-check.js +448 -0
  28. package/dist/src/toolchain-resolution.d.ts +0 -1
  29. package/dist/templates/hono-api/projection.d.ts +2 -3
  30. package/dist/templates/hono-api/projection.js +230 -69
  31. package/dist/templates/projection-plans.d.ts +0 -1
  32. package/dist/templates/registry.d.ts +0 -1
  33. package/dist/templates/registry.js +2 -2
  34. package/dist/templates/rust-bin/projection.d.ts +2 -3
  35. package/dist/templates/rust-bin/projection.js +161 -53
  36. package/dist/templates/ts-lib/projection.d.ts +2 -3
  37. package/dist/templates/ts-lib/projection.js +215 -64
  38. package/dist/templates/vue-app/projection.d.ts +2 -3
  39. package/dist/templates/vue-app/projection.js +246 -83
  40. package/dist/templates/vue-hono-app/projection.d.ts +0 -1
  41. package/dist/templates/vue-hono-app/projection.js +191 -87
  42. package/package.json +10 -5
  43. package/pnpm-workspace.yaml +1 -0
  44. package/templates/hono-api/.github/dependabot.yml +13 -0
  45. package/templates/rust-bin/.github/dependabot.yml +18 -1
  46. package/templates/rust-bin/rust-toolchain.toml +3 -0
  47. package/templates/rust-bin/rustfmt.toml +2 -0
  48. package/templates/shared/devcontainer/browser-test.Dockerfile +2 -0
  49. package/templates/shared/devcontainer/node-pnpm.Dockerfile +6 -0
  50. package/templates/shared/devcontainer/rust.Dockerfile +16 -0
  51. package/templates/shared/editor-customization/capabilities.json +56 -0
  52. package/templates/ts-lib/.github/dependabot.yml +13 -0
  53. package/templates/ts-lib/src/index.ts +5 -1
  54. package/templates/vue-app/.github/dependabot.yml +13 -0
  55. package/templates/vue-app/.github/workflows/check.yml +1 -1
  56. package/templates/vue-hono-app/.github/dependabot.yml +13 -0
  57. package/dist/src/cli.d.ts.map +0 -1
  58. package/dist/src/declarations.d.ts.map +0 -1
  59. package/dist/src/dependency-catalog.d.ts.map +0 -1
  60. package/dist/src/devcontainer.d.ts.map +0 -1
  61. package/dist/src/editor-customization.d.ts.map +0 -1
  62. package/dist/src/generation-context.d.ts.map +0 -1
  63. package/dist/src/module-graph.d.ts.map +0 -1
  64. package/dist/src/next-step-instructions.d.ts.map +0 -1
  65. package/dist/src/package-addition.d.ts.map +0 -1
  66. package/dist/src/preset-projection.d.ts.map +0 -1
  67. package/dist/src/project-github.d.ts.map +0 -1
  68. package/dist/src/renderer.d.ts.map +0 -1
  69. package/dist/src/runtime-paths.d.ts.map +0 -1
  70. package/dist/src/toolchain-resolution.d.ts.map +0 -1
  71. package/dist/templates/hono-api/projection.d.ts.map +0 -1
  72. package/dist/templates/projection-plans.d.ts.map +0 -1
  73. package/dist/templates/registry.d.ts.map +0 -1
  74. package/dist/templates/rust-bin/projection.d.ts.map +0 -1
  75. package/dist/templates/ts-lib/projection.d.ts.map +0 -1
  76. package/dist/templates/vue-app/projection.d.ts.map +0 -1
  77. package/dist/templates/vue-hono-app/projection.d.ts.map +0 -1
  78. package/templates/hono-api/projection.ts +0 -453
  79. package/templates/projection-plans.ts +0 -135
  80. package/templates/registry.ts +0 -59
  81. package/templates/rust-bin/projection.ts +0 -346
  82. package/templates/ts-lib/projection.ts +0 -454
  83. package/templates/vue-app/projection.ts +0 -687
  84. package/templates/vue-hono-app/projection.ts +0 -669
@@ -1,669 +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
- PresetBlueprintOptions,
20
- PresetProjection,
21
- PresetProjectionPlan,
22
- } from "../../src/preset-projection.js";
23
- import {
24
- projectCheckWorkflow,
25
- projectDependabotConfig,
26
- type DependencyMaintenancePolicy,
27
- } from "../../src/project-github.js";
28
- import { renderNewProject, type RenderOperation } from "../../src/renderer.js";
29
- import { planNodeChecks, planNodeFixes } from "../projection-plans.js";
30
-
31
- const generatedBy = {
32
- packageName: "@ykdz/template",
33
- version: "0.0.0",
34
- command: "template init --preset vue-hono-app",
35
- };
36
-
37
- export const vueHonoAppPresetMetadata: BuiltInPreset = {
38
- name: "vue-hono-app",
39
- title: "Vue Hono app",
40
- description: "Full-stack Vue and Hono workspace with Hono RPC typing.",
41
- generation: "supported",
42
- supportedPackageManagers: ["pnpm"],
43
- supportedProjectKinds: ["multi-package"],
44
- features: [
45
- "pnpm-catalog",
46
- "oxc-format-lint",
47
- "strict-typescript",
48
- "root-check",
49
- "fix-command",
50
- "devcontainer",
51
- "github-actions",
52
- "dependabot",
53
- ],
54
- };
55
-
56
- const dependencyMaintenancePolicy: DependencyMaintenancePolicy = {
57
- ecosystems: ["npm", "github-actions"],
58
- interval: "weekly",
59
- };
60
-
61
- function projectNameFromDir(targetDir: string): string {
62
- return path.basename(path.resolve(targetDir));
63
- }
64
-
65
- function packageScopeFromOptions(options: PresetBlueprintOptions): string {
66
- return options.scope ?? projectNameFromDir(options.targetDir);
67
- }
68
-
69
- function packageName(packageScope: string, leaf: "api" | "web"): string {
70
- return `@${packageScope}/${leaf}`;
71
- }
72
-
73
- export function vueHonoAppBlueprint(
74
- options: PresetBlueprintOptions,
75
- ): ProjectBlueprint {
76
- const packageScope = packageScopeFromOptions(options);
77
-
78
- return {
79
- schemaVersion: 1,
80
- preset: "vue-hono-app",
81
- packageManager: "pnpm",
82
- projectKind: "multi-package",
83
- features: [...vueHonoAppPresetMetadata.features],
84
- packages: [
85
- { name: packageName(packageScope, "web"), path: "apps/web" },
86
- { name: packageName(packageScope, "api"), path: "apps/api" },
87
- ],
88
- };
89
- }
90
-
91
- export function projectVueHonoRootPackageScripts(): Record<string, string> {
92
- return {
93
- check: renderRootCheckCommand(planNodeChecks("vue-hono-root")),
94
- dev: "turbo run dev --parallel",
95
- fix: renderFixCommand(planNodeFixes("vue-hono-root")),
96
- };
97
- }
98
-
99
- export function projectVueHonoApiPackageScripts(): Record<string, string> {
100
- return {
101
- build: "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",
102
- check: renderRootCheckCommand(planNodeChecks("vue-hono-api")),
103
- dev: "tsx watch src/server.ts",
104
- fix: renderFixCommand(planNodeFixes("vue-hono-api")),
105
- "format:check": "oxfmt --check .",
106
- "format:write": "oxfmt --write .",
107
- lint: "oxlint . --deny-warnings",
108
- "lint:fix": "oxlint . --fix --deny-warnings",
109
- start: "node dist/server.js",
110
- test: "vitest run",
111
- typecheck: "tsc -p tsconfig.json --noEmit",
112
- };
113
- }
114
-
115
- export function projectVueHonoWebPackageScripts(): Record<string, string> {
116
- return {
117
- build: "vite build",
118
- check: renderRootCheckCommand(planNodeChecks("vue-hono-web")),
119
- dev: "vite",
120
- fix: renderFixCommand(planNodeFixes("vue-hono-web")),
121
- "format:check": "oxfmt --check .",
122
- "format:write": "oxfmt --write .",
123
- lint: "oxlint . --deny-warnings",
124
- "lint:fix": "oxlint . --fix --deny-warnings",
125
- preview: "vite preview",
126
- test: "vitest run",
127
- "test:e2e": "pnpm run build && playwright test",
128
- typecheck: "vue-tsc --build",
129
- };
130
- }
131
-
132
- function rootPackageJson(
133
- context: GenerationContext,
134
- packageScripts: Record<string, string>,
135
- ): Record<string, unknown> {
136
- return {
137
- name: context.projectName.value,
138
- version: "0.0.0",
139
- private: true,
140
- type: "module",
141
- scripts: packageScripts,
142
- devDependencies: {
143
- turbo: "catalog:",
144
- },
145
- engines: {
146
- node: context.toolchain.nodeLtsMajor.value,
147
- },
148
- packageManager: context.toolchain.packageManagerPin.value,
149
- };
150
- }
151
-
152
- function apiPackageJson(
153
- context: GenerationContext,
154
- packageScope: string,
155
- ): Record<string, unknown> {
156
- return {
157
- name: packageName(packageScope, "api"),
158
- version: "0.0.0",
159
- private: true,
160
- type: "module",
161
- types: "./dist/index.d.ts",
162
- exports: {
163
- ".": "./dist/index.js",
164
- },
165
- scripts: projectVueHonoApiPackageScripts(),
166
- dependencies: {
167
- "@hono/node-server": "catalog:",
168
- hono: "catalog:",
169
- },
170
- devDependencies: {
171
- "@types/node": "catalog:",
172
- oxfmt: "catalog:",
173
- oxlint: "catalog:",
174
- "tsc-alias": "catalog:",
175
- tsx: "catalog:",
176
- typescript: "catalog:",
177
- vitest: "catalog:",
178
- },
179
- engines: {
180
- node: context.toolchain.nodeLtsMajor.value,
181
- },
182
- };
183
- }
184
-
185
- function webPackageJson(
186
- context: GenerationContext,
187
- packageScope: string,
188
- ): Record<string, unknown> {
189
- return {
190
- name: packageName(packageScope, "web"),
191
- version: "0.0.0",
192
- private: true,
193
- type: "module",
194
- scripts: projectVueHonoWebPackageScripts(),
195
- dependencies: {
196
- [packageName(packageScope, "api")]: "workspace:*",
197
- "@vueuse/core": "catalog:",
198
- hono: "catalog:",
199
- pinia: "catalog:",
200
- vue: "catalog:",
201
- },
202
- devDependencies: {
203
- "@playwright/test": "catalog:",
204
- "@tailwindcss/vite": "catalog:",
205
- "@types/node": "catalog:",
206
- "@types/web-bluetooth": "catalog:",
207
- "@vitejs/plugin-vue": "catalog:",
208
- "@vue/tsconfig": "catalog:",
209
- oxfmt: "catalog:",
210
- oxlint: "catalog:",
211
- tailwindcss: "catalog:",
212
- typescript: "catalog:",
213
- vite: "catalog:",
214
- vitest: "catalog:",
215
- "vue-tsc": "catalog:",
216
- },
217
- engines: {
218
- node: context.toolchain.nodeLtsMajor.value,
219
- },
220
- };
221
- }
222
-
223
- function generationRecord(context: GenerationContext): Record<string, unknown> {
224
- return {
225
- ...generatedBy,
226
- toolchain: {
227
- nodeLtsMajor: context.toolchain.nodeLtsMajor.value,
228
- packageManagerPin: context.toolchain.packageManagerPin.value,
229
- source: context.toolchain.source,
230
- },
231
- };
232
- }
233
-
234
- function packageScopeFromBlueprint(context: GenerationContext): string {
235
- const apiPackage = context.blueprint.packages?.find(
236
- (pkg) => pkg.path === "apps/api",
237
- );
238
-
239
- if (apiPackage?.name.startsWith("@") && apiPackage.name.endsWith("/api")) {
240
- return apiPackage.name.slice(1, -"/api".length);
241
- }
242
-
243
- return context.projectName.value;
244
- }
245
-
246
- function operationsForVueHonoApp(
247
- context: GenerationContext,
248
- packageScripts: Record<string, string>,
249
- checkPlan: CheckPlan,
250
- ): RenderOperation[] {
251
- const packageScope = packageScopeFromBlueprint(context);
252
- const apiName = packageName(packageScope, "api");
253
- const webName = packageName(packageScope, "web");
254
- const editorCustomization = editorCustomizationForCapabilities(
255
- ["oxc-format-lint", "vue", "tailwind", "vitest"],
256
- {
257
- oxcConfigPaths: "nested",
258
- },
259
- );
260
-
261
- return [
262
- {
263
- kind: "writeJson",
264
- to: "package.json",
265
- value: rootPackageJson(context, packageScripts),
266
- },
267
- {
268
- kind: "writeText",
269
- to: "pnpm-workspace.yaml",
270
- text: renderGeneratedPnpmWorkspaceYaml({
271
- packages: ["apps/*"],
272
- dependencies: [
273
- "@hono/node-server",
274
- "@playwright/test",
275
- "@tailwindcss/vite",
276
- "@types/node",
277
- "@types/web-bluetooth",
278
- "@vitejs/plugin-vue",
279
- "@vue/tsconfig",
280
- "@vueuse/core",
281
- "hono",
282
- "oxfmt",
283
- "oxlint",
284
- "pinia",
285
- "tailwindcss",
286
- "tsc-alias",
287
- "tsx",
288
- "turbo",
289
- "typescript",
290
- "vite",
291
- "vitest",
292
- "vue",
293
- "vue-tsc",
294
- ],
295
- allowBuilds: {
296
- esbuild: true,
297
- },
298
- }),
299
- },
300
- {
301
- kind: "writeJson",
302
- to: "turbo.json",
303
- value: {
304
- tasks: {
305
- build: {
306
- dependsOn: ["^build"],
307
- outputs: ["dist/**"],
308
- },
309
- check: {
310
- dependsOn: ["^build"],
311
- },
312
- dev: {
313
- cache: false,
314
- persistent: true,
315
- },
316
- fix: {
317
- cache: false,
318
- },
319
- },
320
- },
321
- },
322
- {
323
- kind: "writeJson",
324
- to: "tsconfig.json",
325
- value: {
326
- files: [],
327
- references: [
328
- { path: "./apps/api/tsconfig.json" },
329
- { path: "./apps/web/tsconfig.app.json" },
330
- { path: "./apps/web/tsconfig.test.json" },
331
- { path: "./apps/web/tsconfig.node.json" },
332
- ],
333
- },
334
- },
335
- {
336
- kind: "writeJson",
337
- to: ".project-kit/blueprint.json",
338
- value: context.blueprint,
339
- },
340
- {
341
- kind: "writeJson",
342
- to: ".project-kit/generated-by.json",
343
- value: generationRecord(context),
344
- },
345
- {
346
- kind: "writeJson",
347
- to: ".devcontainer/devcontainer.json",
348
- value: nodePnpmDevcontainer({
349
- name: `${context.projectName.value} full-stack development`,
350
- nodeVersion: context.toolchain.nodeLtsMajor.value,
351
- packageManagerPin: context.toolchain.packageManagerPin.value,
352
- extensions: editorCustomization.extensions,
353
- settings: editorCustomization.settings,
354
- }),
355
- },
356
- {
357
- kind: "writeJson",
358
- to: ".vscode/extensions.json",
359
- value: {
360
- recommendations: editorCustomization.extensions,
361
- },
362
- multilineArrays: ["recommendations"],
363
- },
364
- {
365
- kind: "writeJson",
366
- to: ".vscode/settings.json",
367
- value: editorCustomization.settings,
368
- },
369
- {
370
- kind: "writeText",
371
- to: ".gitignore",
372
- text: [
373
- "node_modules",
374
- "dist",
375
- "playwright-report",
376
- "test-results",
377
- ".env",
378
- "",
379
- ].join("\n"),
380
- },
381
- {
382
- kind: "writeText",
383
- to: ".github/workflows/check.yml",
384
- text: projectCheckWorkflow({ checkPlan }),
385
- },
386
- {
387
- kind: "writeText",
388
- to: ".github/dependabot.yml",
389
- text: projectDependabotConfig(dependencyMaintenancePolicy),
390
- },
391
- {
392
- kind: "writeJson",
393
- to: "apps/api/package.json",
394
- value: apiPackageJson(context, packageScope),
395
- },
396
- {
397
- kind: "writeJson",
398
- to: "apps/api/tsconfig.json",
399
- value: {
400
- compilerOptions: {
401
- composite: true,
402
- declaration: true,
403
- declarationMap: true,
404
- module: "NodeNext",
405
- moduleResolution: "NodeNext",
406
- noEmitOnError: true,
407
- paths: {
408
- "@/*": ["./src/*"],
409
- },
410
- skipLibCheck: false,
411
- strict: true,
412
- target: "ES2022",
413
- types: ["node", "vitest/globals"],
414
- },
415
- include: ["src/**/*.ts", "test/**/*.ts", "vitest.config.ts"],
416
- },
417
- },
418
- {
419
- kind: "writeJson",
420
- to: "apps/api/tsconfig.build.json",
421
- value: {
422
- extends: "./tsconfig.json",
423
- compilerOptions: {
424
- outDir: "dist",
425
- rootDir: "src",
426
- types: ["node"],
427
- },
428
- include: ["src/**/*.ts"],
429
- },
430
- },
431
- {
432
- kind: "copyFile",
433
- sourceRoot: "sharedOxc",
434
- from: "node/oxlint.config.ts",
435
- to: "apps/api/oxlint.config.ts",
436
- },
437
- {
438
- kind: "copyFile",
439
- sourceRoot: "sharedOxc",
440
- from: "oxfmt.config.ts",
441
- to: "apps/api/oxfmt.config.ts",
442
- },
443
- { kind: "copyFile", from: "api/src/index.ts", to: "apps/api/src/index.ts" },
444
- {
445
- kind: "copyFile",
446
- from: "api/src/runtime.ts",
447
- to: "apps/api/src/runtime.ts",
448
- },
449
- {
450
- kind: "copyFile",
451
- from: "api/src/server.ts",
452
- to: "apps/api/src/server.ts",
453
- },
454
- {
455
- kind: "copyFile",
456
- from: "api/test/app.test.ts",
457
- to: "apps/api/test/app.test.ts",
458
- },
459
- {
460
- kind: "copyFile",
461
- from: "api/vitest.config.ts",
462
- to: "apps/api/vitest.config.ts",
463
- },
464
- {
465
- kind: "writeJson",
466
- to: "apps/web/package.json",
467
- value: webPackageJson(context, packageScope),
468
- },
469
- {
470
- kind: "writeJson",
471
- to: "apps/web/tsconfig.json",
472
- value: {
473
- files: [],
474
- references: [
475
- { path: "./tsconfig.app.json" },
476
- { path: "./tsconfig.test.json" },
477
- { path: "./tsconfig.node.json" },
478
- ],
479
- },
480
- },
481
- {
482
- kind: "writeJson",
483
- to: "apps/web/tsconfig.app.json",
484
- value: {
485
- extends: "@vue/tsconfig/tsconfig.dom.json",
486
- compilerOptions: {
487
- composite: true,
488
- module: "ESNext",
489
- moduleResolution: "Bundler",
490
- noEmitOnError: true,
491
- paths: {
492
- "@/*": ["./src/*"],
493
- [apiName]: ["../api/src/index.ts"],
494
- },
495
- skipLibCheck: false,
496
- strict: true,
497
- target: "ES2022",
498
- tsBuildInfoFile: "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
499
- types: ["web-bluetooth"],
500
- },
501
- include: ["env.d.ts", "src/**/*.ts", "src/**/*.vue"],
502
- references: [{ path: "../api/tsconfig.build.json" }],
503
- },
504
- },
505
- {
506
- kind: "writeJson",
507
- to: "apps/web/tsconfig.test.json",
508
- value: {
509
- extends: "./tsconfig.app.json",
510
- compilerOptions: {
511
- lib: ["ESNext", "DOM", "DOM.Iterable"],
512
- tsBuildInfoFile: "./node_modules/.tmp/tsconfig.test.tsbuildinfo",
513
- types: ["node", "vitest/globals", "web-bluetooth"],
514
- },
515
- include: ["env.d.ts", "src/**/*.ts", "src/**/*.vue", "test/**/*.ts"],
516
- references: [{ path: "../api/tsconfig.build.json" }],
517
- },
518
- },
519
- {
520
- kind: "writeJson",
521
- to: "apps/web/tsconfig.node.json",
522
- value: {
523
- compilerOptions: {
524
- composite: true,
525
- module: "ESNext",
526
- moduleResolution: "Bundler",
527
- noEmitOnError: true,
528
- lib: ["ESNext", "DOM", "DOM.Iterable"],
529
- outDir: "./node_modules/.tmp/tsconfig.node",
530
- skipLibCheck: false,
531
- strict: true,
532
- target: "ES2022",
533
- tsBuildInfoFile: "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
534
- types: ["node"],
535
- },
536
- include: ["playwright.config.ts", "vite.config.ts", "vitest.config.ts"],
537
- },
538
- },
539
- {
540
- kind: "copyFile",
541
- sourceRoot: "sharedOxc",
542
- from: "vue/oxlint.config.ts",
543
- to: "apps/web/oxlint.config.ts",
544
- },
545
- {
546
- kind: "copyFile",
547
- sourceRoot: "sharedOxc",
548
- from: "oxfmt.config.ts",
549
- to: "apps/web/oxfmt.config.ts",
550
- },
551
- { kind: "copyFile", from: "web/env.d.ts", to: "apps/web/env.d.ts" },
552
- { kind: "copyFile", from: "web/index.html", to: "apps/web/index.html" },
553
- {
554
- kind: "copyFile",
555
- from: "web/playwright.config.ts",
556
- to: "apps/web/playwright.config.ts",
557
- },
558
- {
559
- kind: "copyFile",
560
- from: "web/vite.config.ts",
561
- to: "apps/web/vite.config.ts",
562
- },
563
- {
564
- kind: "copyFile",
565
- from: "web/vitest.config.ts",
566
- to: "apps/web/vitest.config.ts",
567
- },
568
- { kind: "copyFile", from: "web/src/api.ts", to: "apps/web/src/api.ts" },
569
- {
570
- kind: "replaceAnchors",
571
- path: "apps/web/src/api.ts",
572
- language: "typescript",
573
- replacements: {
574
- "api-type-import-start": `import type { AppType } from "${apiName}";\nimport { hc } from "hono/client";\n/*`,
575
- "api-type-import-end": "*/",
576
- },
577
- },
578
- { kind: "copyFile", from: "web/src/App.vue", to: "apps/web/src/App.vue" },
579
- { kind: "copyFile", from: "web/src/main.ts", to: "apps/web/src/main.ts" },
580
- {
581
- kind: "copyFile",
582
- from: "web/src/style.css",
583
- to: "apps/web/src/style.css",
584
- },
585
- {
586
- kind: "copyFile",
587
- from: "web/src/stores/counter.ts",
588
- to: "apps/web/src/stores/counter.ts",
589
- },
590
- {
591
- kind: "copyFile",
592
- from: "web/test/app.test.ts",
593
- to: "apps/web/test/app.test.ts",
594
- },
595
- {
596
- kind: "copyFile",
597
- from: "web/test/e2e/app.spec.ts",
598
- to: "apps/web/test/e2e/app.spec.ts",
599
- },
600
- ];
601
- }
602
-
603
- function templateSourceRoot(): string {
604
- const projectionDir = path.dirname(fileURLToPath(import.meta.url));
605
- const publishedTemplateRoot = path.join(
606
- projectionDir,
607
- "..",
608
- "..",
609
- "..",
610
- "templates",
611
- "vue-hono-app",
612
- );
613
-
614
- return existsSync(path.join(publishedTemplateRoot, "web", "src", "App.vue"))
615
- ? publishedTemplateRoot
616
- : projectionDir;
617
- }
618
-
619
- function sharedOxcSourceRoot(): string {
620
- const projectionDir = path.dirname(fileURLToPath(import.meta.url));
621
- const publishedSharedRoot = path.join(
622
- projectionDir,
623
- "..",
624
- "..",
625
- "..",
626
- "templates",
627
- "shared",
628
- "oxc",
629
- );
630
-
631
- return existsSync(path.join(publishedSharedRoot, "oxfmt.config.ts"))
632
- ? publishedSharedRoot
633
- : path.join(projectionDir, "..", "shared", "oxc");
634
- }
635
-
636
- export const vueHonoAppPresetProjection: PresetProjection = {
637
- metadata: vueHonoAppPresetMetadata,
638
- blueprint: vueHonoAppBlueprint,
639
- project(context: GenerationContext): PresetProjectionPlan {
640
- const checkPlan = planNodeChecks("vue-hono-root");
641
- const fixPlan = planNodeFixes("vue-hono-root");
642
- const packageScripts = projectVueHonoRootPackageScripts();
643
-
644
- return {
645
- sourceRoot: templateSourceRoot(),
646
- sourceRoots: { sharedOxc: sharedOxcSourceRoot() },
647
- operations: operationsForVueHonoApp(context, packageScripts, checkPlan),
648
- checkPlan,
649
- fixPlan,
650
- dependencyMaintenancePolicy,
651
- packageScripts,
652
- capabilities: {
653
- rootCheck: true,
654
- fixCommand: true,
655
- githubActions: true,
656
- dependabot: true,
657
- devcontainer: true,
658
- },
659
- };
660
- },
661
- async render({ targetDir, plan }): Promise<void> {
662
- await renderNewProject({
663
- sourceRoot: plan.sourceRoot,
664
- sourceRoots: plan.sourceRoots,
665
- targetRoot: targetDir,
666
- operations: [...plan.operations],
667
- });
668
- },
669
- };