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