@ykdz/template 0.0.4 → 0.0.6

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 (46) hide show
  1. package/dist/src/cli.js +79 -34
  2. package/dist/src/declarations.d.ts +36 -0
  3. package/dist/src/declarations.js +31 -2
  4. package/dist/src/generated-scenarios.d.ts +62 -0
  5. package/dist/src/generated-scenarios.js +361 -0
  6. package/dist/src/module-graph.d.ts +1 -1
  7. package/dist/src/module-graph.js +10 -2
  8. package/dist/src/package-addition-support.d.ts +5 -0
  9. package/dist/src/package-addition-support.js +4 -0
  10. package/dist/src/package-addition.d.ts +1 -0
  11. package/dist/src/package-addition.js +409 -69
  12. package/dist/src/package-linking.d.ts +55 -0
  13. package/dist/src/package-linking.js +116 -0
  14. package/dist/src/preset-projection.d.ts +4 -1
  15. package/dist/src/preset-source.d.ts +430 -0
  16. package/dist/src/preset-source.js +940 -0
  17. package/dist/src/projection-capabilities.d.ts +67 -0
  18. package/dist/src/projection-capabilities.js +2207 -0
  19. package/dist/src/renderer.js +20 -1
  20. package/dist/src/template-boundary-check.d.ts +7 -3
  21. package/dist/src/template-boundary-check.js +104 -10
  22. package/package.json +3 -2
  23. package/templates/hono-api/src/server.ts +1 -1
  24. package/templates/hono-api/test/app.test.ts +1 -1
  25. package/templates/preset-source.json +499 -0
  26. package/templates/ts-lib/src/index.ts +2 -2
  27. package/templates/ts-lib/src/name-schema.ts +3 -0
  28. package/templates/vue-app/playwright.package-addition.config.ts +22 -0
  29. package/templates/vue-app/src/App.vue +1 -1
  30. package/templates/vue-app/test/app.test.ts +1 -1
  31. package/templates/vue-hono-app/web/src/App.vue +2 -2
  32. package/templates/vue-hono-app/web/test/app.test.ts +1 -1
  33. package/dist/templates/hono-api/projection.d.ts +0 -6
  34. package/dist/templates/hono-api/projection.js +0 -538
  35. package/dist/templates/projection-plans.d.ts +0 -7
  36. package/dist/templates/projection-plans.js +0 -94
  37. package/dist/templates/registry.d.ts +0 -7
  38. package/dist/templates/registry.js +0 -42
  39. package/dist/templates/rust-bin/projection.d.ts +0 -9
  40. package/dist/templates/rust-bin/projection.js +0 -390
  41. package/dist/templates/ts-lib/projection.d.ts +0 -6
  42. package/dist/templates/ts-lib/projection.js +0 -523
  43. package/dist/templates/vue-app/projection.d.ts +0 -6
  44. package/dist/templates/vue-app/projection.js +0 -757
  45. package/dist/templates/vue-hono-app/projection.d.ts +0 -8
  46. package/dist/templates/vue-hono-app/projection.js +0 -693
@@ -1,523 +0,0 @@
1
- import { existsSync } from "node:fs";
2
- import path from "node:path";
3
- import { fileURLToPath } from "node:url";
4
- import { collectGeneratedManifestCatalogDependencies, renderGeneratedPnpmWorkspaceYaml, } from "../../src/dependency-catalog.js";
5
- import { checkedDockerfileFirstNodePnpmDevcontainer, nodePnpmToolLayer, } from "../../src/devcontainer.js";
6
- import { editorCustomizationForCapabilities } from "../../src/editor-customization.js";
7
- import { renderFixCommand, renderRootCheckCommand, } from "../../src/module-graph.js";
8
- import { renderNewProject } from "../../src/renderer.js";
9
- const generatedBy = {
10
- packageName: "@ykdz/template",
11
- version: "0.0.0",
12
- command: "template init --preset ts-lib",
13
- };
14
- export const tsLibPresetMetadata = {
15
- name: "ts-lib",
16
- title: "TypeScript library",
17
- description: "Strict TypeScript package with pnpm catalog tooling.",
18
- generation: "supported",
19
- supportedPackageManagers: ["pnpm"],
20
- supportedProjectKinds: ["multi-package"],
21
- features: [
22
- "pnpm-catalog",
23
- "oxc-format-lint",
24
- "strict-typescript",
25
- "root-check",
26
- "fix-command",
27
- "devcontainer",
28
- "github-actions",
29
- "dependabot",
30
- ],
31
- };
32
- const dependencyMaintenancePolicy = {
33
- ecosystems: ["npm", "github-actions", "docker"],
34
- interval: "weekly",
35
- };
36
- const tsLibPackageBoundary = {
37
- kind: "package-boundary",
38
- path: ".",
39
- };
40
- const tsLibRootBoundary = {
41
- kind: "workspace-orchestration",
42
- path: ".",
43
- };
44
- const tsLibWorkspacePackageBoundary = {
45
- kind: "package-boundary",
46
- path: "packages/*",
47
- };
48
- function planTsLibPackageChecks() {
49
- return {
50
- components: [
51
- { kind: "typescript-typecheck", owner: tsLibPackageBoundary },
52
- { kind: "oxc-lint", owner: tsLibPackageBoundary },
53
- { kind: "oxc-format-check", owner: tsLibPackageBoundary },
54
- { kind: "build", owner: tsLibPackageBoundary },
55
- ],
56
- environmentNeeds: [],
57
- };
58
- }
59
- function planTsLibRootChecks() {
60
- return {
61
- components: [
62
- { kind: "oxc-format-check", owner: tsLibRootBoundary },
63
- { kind: "oxc-lint", owner: tsLibRootBoundary },
64
- { kind: "typescript-typecheck", owner: tsLibRootBoundary },
65
- { kind: "turbo-package-check", owner: tsLibWorkspacePackageBoundary },
66
- ],
67
- environmentNeeds: [],
68
- };
69
- }
70
- function planTsLibPackageFixes() {
71
- return {
72
- components: [
73
- { kind: "oxc-format-write", owner: tsLibPackageBoundary },
74
- { kind: "oxc-lint-fix", owner: tsLibPackageBoundary },
75
- ],
76
- };
77
- }
78
- function planTsLibRootFixes() {
79
- return {
80
- components: [
81
- { kind: "oxc-format-write", owner: tsLibRootBoundary },
82
- { kind: "oxc-lint-fix", owner: tsLibRootBoundary },
83
- { kind: "turbo-package-fix", owner: tsLibWorkspacePackageBoundary },
84
- ],
85
- };
86
- }
87
- function projectNameFromDir(targetDir) {
88
- return path.basename(path.resolve(targetDir));
89
- }
90
- function packageScopeFromOptions(options) {
91
- return options.scope ?? projectNameFromDir(options.targetDir);
92
- }
93
- function packageName(packageScope, packageLeafName) {
94
- return `@${packageScope}/${packageLeafName}`;
95
- }
96
- export function tsLibBlueprint(options = { targetDir: process.cwd() }) {
97
- const packageScope = packageScopeFromOptions(options);
98
- const packageLeafName = projectNameFromDir(options.targetDir);
99
- return {
100
- schemaVersion: 1,
101
- preset: "ts-lib",
102
- packageManager: "pnpm",
103
- projectKind: "multi-package",
104
- features: [...tsLibPresetMetadata.features],
105
- packages: [
106
- {
107
- name: packageName(packageScope, packageLeafName),
108
- path: `packages/${packageLeafName}`,
109
- },
110
- ],
111
- };
112
- }
113
- function workspacePackagePath(context) {
114
- return `packages/${context.projectName.value}`;
115
- }
116
- function workspacePackageName(context) {
117
- const packageDefinition = context.blueprint.packages?.find((pkg) => pkg.path === workspacePackagePath(context));
118
- return (packageDefinition?.name ??
119
- packageName(context.projectName.value, context.projectName.value));
120
- }
121
- function projectTsLibRootPackageScripts() {
122
- return {
123
- check: renderRootCheckCommand(planTsLibRootChecks()),
124
- fix: renderFixCommand(planTsLibRootFixes()),
125
- "format:check": "oxfmt --check --config oxfmt.config.ts oxlint.config.ts oxfmt.config.ts",
126
- "format:write": "oxfmt --write --config oxfmt.config.ts oxlint.config.ts oxfmt.config.ts",
127
- lint: "oxlint --config oxlint.config.ts oxlint.config.ts oxfmt.config.ts --deny-warnings",
128
- "lint:fix": "oxlint --config oxlint.config.ts oxlint.config.ts oxfmt.config.ts --fix --deny-warnings",
129
- typecheck: "tsc -p tsconfig.config.json --noEmit",
130
- };
131
- }
132
- export function projectTsLibPackageScripts() {
133
- const checkPlan = planTsLibPackageChecks();
134
- const fixPlan = planTsLibPackageFixes();
135
- return {
136
- build: "tsc -p tsconfig.json && tsc-alias -p tsconfig.json",
137
- check: renderRootCheckCommand(checkPlan),
138
- fix: renderFixCommand(fixPlan),
139
- "format:check": "oxfmt --check --config ../../oxfmt.config.ts .",
140
- "format:write": "oxfmt --write --config ../../oxfmt.config.ts .",
141
- lint: "oxlint --config ../../oxlint.config.ts . --deny-warnings",
142
- "lint:fix": "oxlint --config ../../oxlint.config.ts . --fix --deny-warnings",
143
- typecheck: "tsc -p tsconfig.json --noEmit",
144
- };
145
- }
146
- function rootPackageJson(context, packageScripts) {
147
- return {
148
- name: context.projectName.value,
149
- version: "0.0.0",
150
- private: true,
151
- type: "module",
152
- scripts: packageScripts,
153
- devDependencies: {
154
- oxfmt: "catalog:",
155
- oxlint: "catalog:",
156
- turbo: "catalog:",
157
- typescript: "catalog:",
158
- },
159
- engines: {
160
- node: context.toolchain.nodeLtsMajor.value,
161
- },
162
- packageManager: context.toolchain.packageManagerPin.value,
163
- };
164
- }
165
- function libraryPackageJson(context) {
166
- return {
167
- name: workspacePackageName(context),
168
- version: "0.0.0",
169
- private: true,
170
- files: ["dist"],
171
- type: "module",
172
- exports: {
173
- ".": {
174
- default: "./dist/index.js",
175
- types: "./dist/index.d.ts",
176
- },
177
- },
178
- dependencies: {
179
- valibot: "catalog:",
180
- },
181
- scripts: projectTsLibPackageScripts(),
182
- devDependencies: {
183
- "@types/node": "catalog:",
184
- oxfmt: "catalog:",
185
- oxlint: "catalog:",
186
- "tsc-alias": "catalog:",
187
- typescript: "catalog:",
188
- },
189
- engines: {
190
- node: context.toolchain.nodeLtsMajor.value,
191
- },
192
- };
193
- }
194
- function generationRecord(context) {
195
- return {
196
- ...generatedBy,
197
- toolchain: {
198
- nodeLtsMajor: context.toolchain.nodeLtsMajor.value,
199
- packageManagerPin: context.toolchain.packageManagerPin.value,
200
- source: context.toolchain.source,
201
- },
202
- };
203
- }
204
- function operationsForTsLib(context, packageScripts, checkPlan) {
205
- const editorCustomization = editorCustomizationForCapabilities([
206
- "oxc-format-lint",
207
- ]);
208
- const developmentContainer = checkedDockerfileFirstNodePnpmDevcontainer({
209
- name: context.projectName.value,
210
- layer: nodePnpmToolLayer({
211
- nodeVersion: context.toolchain.nodeLtsMajor.value,
212
- packageManagerPin: context.toolchain.packageManagerPin.value,
213
- }),
214
- extensions: editorCustomization.extensions,
215
- settings: editorCustomization.settings,
216
- });
217
- const rootManifest = rootPackageJson(context, packageScripts);
218
- const packageManifest = libraryPackageJson(context);
219
- return [
220
- {
221
- kind: "writeJson",
222
- to: "package.json",
223
- value: rootManifest,
224
- },
225
- {
226
- kind: "writeText",
227
- to: "pnpm-workspace.yaml",
228
- text: renderGeneratedPnpmWorkspaceYaml({
229
- packages: ["packages/*"],
230
- dependencies: collectGeneratedManifestCatalogDependencies([
231
- rootManifest,
232
- packageManifest,
233
- ]),
234
- }),
235
- },
236
- {
237
- kind: "writeJson",
238
- to: "turbo.json",
239
- value: {
240
- tasks: {
241
- build: {
242
- dependsOn: ["^build"],
243
- outputs: ["dist/**"],
244
- },
245
- check: {
246
- dependsOn: ["^build"],
247
- },
248
- fix: {
249
- cache: false,
250
- },
251
- },
252
- },
253
- },
254
- {
255
- kind: "writeJson",
256
- to: "tsconfig.json",
257
- value: {
258
- files: [],
259
- references: [
260
- { path: `./${workspacePackagePath(context)}/tsconfig.json` },
261
- ],
262
- },
263
- },
264
- {
265
- kind: "writeJson",
266
- to: "tsconfig.config.json",
267
- value: {
268
- compilerOptions: {
269
- module: "NodeNext",
270
- moduleResolution: "NodeNext",
271
- noEmitOnError: true,
272
- skipLibCheck: false,
273
- strict: true,
274
- target: "ES2022",
275
- },
276
- include: ["oxlint.config.ts", "oxfmt.config.ts"],
277
- },
278
- },
279
- {
280
- kind: "writeJson",
281
- to: `${workspacePackagePath(context)}/package.json`,
282
- value: packageManifest,
283
- multilineArrays: ["files"],
284
- },
285
- {
286
- kind: "writeJson",
287
- to: `${workspacePackagePath(context)}/tsconfig.json`,
288
- value: {
289
- compilerOptions: {
290
- composite: true,
291
- declaration: true,
292
- declarationMap: true,
293
- module: "NodeNext",
294
- moduleResolution: "NodeNext",
295
- noEmitOnError: true,
296
- outDir: "dist",
297
- paths: {
298
- "@/*": ["./src/*"],
299
- },
300
- rootDir: "src",
301
- skipLibCheck: false,
302
- strict: true,
303
- target: "ES2022",
304
- types: ["node"],
305
- },
306
- include: ["src/**/*.ts"],
307
- },
308
- },
309
- {
310
- kind: "copyFile",
311
- sourceRoot: "sharedOxc",
312
- from: "node/oxlint.config.ts",
313
- to: "oxlint.config.ts",
314
- },
315
- {
316
- kind: "copyFile",
317
- sourceRoot: "sharedOxc",
318
- from: "oxfmt.config.ts",
319
- to: "oxfmt.config.ts",
320
- },
321
- {
322
- kind: "writeText",
323
- to: ".gitignore",
324
- text: [
325
- "node_modules",
326
- "dist",
327
- ".env",
328
- ".template/",
329
- ".pnpm-store/",
330
- "",
331
- ].join("\n"),
332
- },
333
- {
334
- kind: "copyFile",
335
- from: "src/index.ts",
336
- to: `${workspacePackagePath(context)}/src/index.ts`,
337
- },
338
- {
339
- kind: "writeJson",
340
- to: ".template/blueprint.json",
341
- value: context.blueprint,
342
- },
343
- {
344
- kind: "writeJson",
345
- to: ".template/generated-by.json",
346
- value: generationRecord(context),
347
- },
348
- {
349
- kind: "writeJson",
350
- to: ".devcontainer/devcontainer.json",
351
- value: developmentContainer.devcontainer,
352
- },
353
- {
354
- kind: "copyFile",
355
- sourceRoot: "sharedDevcontainer",
356
- from: "node-pnpm.Dockerfile",
357
- to: ".devcontainer/Dockerfile",
358
- },
359
- {
360
- kind: "writeJson",
361
- to: ".vscode/extensions.json",
362
- value: {
363
- recommendations: editorCustomization.extensions,
364
- },
365
- multilineArrays: ["recommendations"],
366
- },
367
- {
368
- kind: "writeJson",
369
- to: ".vscode/settings.json",
370
- value: editorCustomization.settings,
371
- },
372
- {
373
- kind: "copyFile",
374
- from: ".github/workflows/check.yml",
375
- to: ".github/workflows/check.yml",
376
- },
377
- {
378
- kind: "copyFile",
379
- from: ".github/dependabot.yml",
380
- to: ".github/dependabot.yml",
381
- },
382
- ];
383
- }
384
- function packageAdditionOperations(packagePath, packageName, nodeVersion) {
385
- return [
386
- {
387
- kind: "writeJson",
388
- to: `${packagePath}/package.json`,
389
- value: {
390
- name: packageName,
391
- version: "0.0.0",
392
- private: true,
393
- files: ["dist"],
394
- type: "module",
395
- exports: {
396
- ".": {
397
- default: "./dist/index.js",
398
- types: "./dist/index.d.ts",
399
- },
400
- },
401
- dependencies: {
402
- valibot: "catalog:",
403
- },
404
- scripts: projectTsLibPackageScripts(),
405
- devDependencies: {
406
- "@types/node": "catalog:",
407
- oxfmt: "catalog:",
408
- oxlint: "catalog:",
409
- "tsc-alias": "catalog:",
410
- typescript: "catalog:",
411
- },
412
- engines: {
413
- node: nodeVersion,
414
- },
415
- },
416
- multilineArrays: ["files"],
417
- },
418
- {
419
- kind: "writeJson",
420
- to: `${packagePath}/tsconfig.json`,
421
- value: {
422
- compilerOptions: {
423
- composite: true,
424
- declaration: true,
425
- declarationMap: true,
426
- module: "NodeNext",
427
- moduleResolution: "NodeNext",
428
- noEmitOnError: true,
429
- outDir: "dist",
430
- paths: {
431
- "@/*": ["./src/*"],
432
- },
433
- rootDir: "src",
434
- skipLibCheck: false,
435
- strict: true,
436
- target: "ES2022",
437
- types: ["node"],
438
- },
439
- include: ["src/**/*.ts"],
440
- },
441
- },
442
- {
443
- kind: "copyFile",
444
- from: "src/index.ts",
445
- to: `${packagePath}/src/index.ts`,
446
- },
447
- ];
448
- }
449
- function packageAdditionPlan(packageName, packagePath, nodeVersion) {
450
- const [workspaceCollection] = packagePath.split("/");
451
- return {
452
- packagePath,
453
- workspacePackageGlob: `${workspaceCollection}/*`,
454
- rootTsconfigReferences: [`./${packagePath}/tsconfig.json`],
455
- sourceRoot: templateSourceRoot(),
456
- sourceRoots: { sharedOxc: sharedOxcSourceRoot() },
457
- operations: packageAdditionOperations(packagePath, packageName, nodeVersion),
458
- };
459
- }
460
- function templateSourceRoot() {
461
- const projectionDir = path.dirname(fileURLToPath(import.meta.url));
462
- const publishedTemplateRoot = path.join(projectionDir, "..", "..", "..", "templates", "ts-lib");
463
- return existsSync(path.join(publishedTemplateRoot, "src", "index.ts"))
464
- ? publishedTemplateRoot
465
- : projectionDir;
466
- }
467
- function sharedOxcSourceRoot() {
468
- const projectionDir = path.dirname(fileURLToPath(import.meta.url));
469
- const publishedSharedRoot = path.join(projectionDir, "..", "..", "..", "templates", "shared", "oxc");
470
- return existsSync(path.join(publishedSharedRoot, "oxfmt.config.ts"))
471
- ? publishedSharedRoot
472
- : path.join(projectionDir, "..", "shared", "oxc");
473
- }
474
- function sharedDevcontainerSourceRoot() {
475
- const projectionDir = path.dirname(fileURLToPath(import.meta.url));
476
- const publishedSharedRoot = path.join(projectionDir, "..", "..", "..", "templates", "shared", "devcontainer");
477
- return existsSync(path.join(publishedSharedRoot, "node-pnpm.Dockerfile"))
478
- ? publishedSharedRoot
479
- : path.join(projectionDir, "..", "shared", "devcontainer");
480
- }
481
- export const tsLibPresetProjection = {
482
- metadata: tsLibPresetMetadata,
483
- capabilities: {
484
- packageAddition: {
485
- planPackageAddition({ packageName, packagePath, nodeVersion, }) {
486
- return packageAdditionPlan(packageName, packagePath, nodeVersion);
487
- },
488
- },
489
- },
490
- blueprint: tsLibBlueprint,
491
- project(context) {
492
- const checkPlan = planTsLibRootChecks();
493
- const fixPlan = planTsLibRootFixes();
494
- const packageScripts = projectTsLibRootPackageScripts();
495
- return {
496
- sourceRoot: templateSourceRoot(),
497
- sourceRoots: {
498
- sharedDevcontainer: sharedDevcontainerSourceRoot(),
499
- sharedOxc: sharedOxcSourceRoot(),
500
- },
501
- operations: operationsForTsLib(context, packageScripts, checkPlan),
502
- checkPlan,
503
- fixPlan,
504
- dependencyMaintenancePolicy,
505
- packageScripts,
506
- capabilities: {
507
- rootCheck: true,
508
- fixCommand: true,
509
- githubActions: true,
510
- dependabot: true,
511
- devcontainer: true,
512
- },
513
- };
514
- },
515
- async render({ targetDir, plan }) {
516
- await renderNewProject({
517
- sourceRoot: plan.sourceRoot,
518
- sourceRoots: plan.sourceRoots,
519
- targetRoot: targetDir,
520
- operations: [...plan.operations],
521
- });
522
- },
523
- };
@@ -1,6 +0,0 @@
1
- import type { BuiltInPreset, ProjectBlueprint } from "../../src/declarations.js";
2
- import type { PresetBlueprintOptions, PresetProjection } from "../../src/preset-projection.js";
3
- export declare const vueAppPresetMetadata: BuiltInPreset;
4
- export declare function vueAppBlueprint(options?: PresetBlueprintOptions): ProjectBlueprint;
5
- export declare function projectVueAppPackageScripts(): Record<string, string>;
6
- export declare const vueAppPresetProjection: PresetProjection;