@ykdz/template 0.0.6 → 0.0.8

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 (118) hide show
  1. package/dist/{src/cli.js → cli.js} +101 -44
  2. package/node_modules/@ykdz/template-builtin-source/dist/src/index.d.ts +22 -0
  3. package/node_modules/@ykdz/template-builtin-source/dist/src/index.js +92 -0
  4. package/node_modules/@ykdz/template-builtin-source/dist/templates/hono-api/projection.d.ts +6 -0
  5. package/node_modules/@ykdz/template-builtin-source/dist/templates/hono-api/projection.js +230 -0
  6. package/node_modules/@ykdz/template-builtin-source/dist/templates/projection-plans.d.ts +7 -0
  7. package/node_modules/@ykdz/template-builtin-source/dist/templates/projection-plans.js +94 -0
  8. package/node_modules/@ykdz/template-builtin-source/dist/templates/registry.d.ts +2 -0
  9. package/node_modules/@ykdz/template-builtin-source/dist/templates/registry.js +15 -0
  10. package/node_modules/@ykdz/template-builtin-source/dist/templates/rust-bin/projection.d.ts +9 -0
  11. package/node_modules/@ykdz/template-builtin-source/dist/templates/rust-bin/projection.js +103 -0
  12. package/node_modules/@ykdz/template-builtin-source/dist/templates/ts-lib/projection.d.ts +6 -0
  13. package/node_modules/@ykdz/template-builtin-source/dist/templates/ts-lib/projection.js +214 -0
  14. package/node_modules/@ykdz/template-builtin-source/dist/templates/vue-app/projection.d.ts +6 -0
  15. package/node_modules/@ykdz/template-builtin-source/dist/templates/vue-app/projection.js +353 -0
  16. package/node_modules/@ykdz/template-builtin-source/dist/templates/vue-hono-app/projection.d.ts +8 -0
  17. package/node_modules/@ykdz/template-builtin-source/dist/templates/vue-hono-app/projection.js +203 -0
  18. package/node_modules/@ykdz/template-builtin-source/package.json +46 -0
  19. package/{templates → node_modules/@ykdz/template-builtin-source/templates}/shared/oxc/node/oxlint.config.ts +3 -0
  20. package/{templates → node_modules/@ykdz/template-builtin-source/templates}/shared/oxc/vue/oxlint.config.ts +3 -0
  21. package/{dist/src → node_modules/@ykdz/template-core/dist}/declarations.d.ts +7 -4
  22. package/{dist/src → node_modules/@ykdz/template-core/dist}/declarations.js +11 -13
  23. package/{dist/src → node_modules/@ykdz/template-core/dist}/dependency-catalog.js +2 -0
  24. package/{dist/src → node_modules/@ykdz/template-core/dist}/editor-customization.js +3 -1
  25. package/{dist/src → node_modules/@ykdz/template-core/dist}/generated-scenarios.d.ts +2 -0
  26. package/{dist/src → node_modules/@ykdz/template-core/dist}/generated-scenarios.js +16 -5
  27. package/node_modules/@ykdz/template-core/dist/package-addition.d.ts +12 -0
  28. package/{dist/src → node_modules/@ykdz/template-core/dist}/package-addition.js +11 -10
  29. package/{pnpm-workspace.yaml → node_modules/@ykdz/template-core/dist/pnpm-workspace.yaml} +3 -1
  30. package/{dist/src → node_modules/@ykdz/template-core/dist}/preset-source.d.ts +1 -3
  31. package/{dist/src → node_modules/@ykdz/template-core/dist}/preset-source.js +13 -29
  32. package/{dist/src → node_modules/@ykdz/template-core/dist}/projection-capabilities.d.ts +10 -2
  33. package/{dist/src → node_modules/@ykdz/template-core/dist}/projection-capabilities.js +22 -49
  34. package/{dist/src → node_modules/@ykdz/template-core/dist}/renderer.js +12 -4
  35. package/{dist/src → node_modules/@ykdz/template-core/dist}/runtime-paths.js +2 -0
  36. package/{dist/src → node_modules/@ykdz/template-core/dist}/toolchain-resolution.js +1 -1
  37. package/node_modules/@ykdz/template-core/package.json +27 -0
  38. package/package.json +14 -34
  39. package/README.md +0 -35
  40. package/dist/src/package-addition.d.ts +0 -8
  41. /package/dist/{src/cli.d.ts → cli.d.ts} +0 -0
  42. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/hono-api/.github/dependabot.yml +0 -0
  43. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/hono-api/.github/workflows/check.yml +0 -0
  44. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/hono-api/src/app.ts +0 -0
  45. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/hono-api/src/server.ts +0 -0
  46. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/hono-api/test/app.test.ts +0 -0
  47. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/hono-api/vitest.config.ts +0 -0
  48. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/preset-source.json +0 -0
  49. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/rust-bin/.github/dependabot.yml +0 -0
  50. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/rust-bin/.github/workflows/check.yml +0 -0
  51. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/rust-bin/rust-toolchain.toml +0 -0
  52. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/rust-bin/rustfmt.toml +0 -0
  53. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/rust-bin/src/main.rs +0 -0
  54. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/shared/devcontainer/browser-test.Dockerfile +0 -0
  55. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/shared/devcontainer/node-pnpm.Dockerfile +0 -0
  56. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/shared/devcontainer/rust.Dockerfile +0 -0
  57. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/shared/editor-customization/capabilities.json +0 -0
  58. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/shared/oxc/oxfmt.config.ts +0 -0
  59. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/ts-lib/.github/dependabot.yml +0 -0
  60. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/ts-lib/.github/workflows/check.yml +0 -0
  61. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/ts-lib/src/index.ts +0 -0
  62. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/ts-lib/src/name-schema.ts +0 -0
  63. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/vue-app/.github/dependabot.yml +0 -0
  64. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/vue-app/.github/workflows/check.yml +0 -0
  65. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/vue-app/env.d.ts +0 -0
  66. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/vue-app/index.html +0 -0
  67. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/vue-app/playwright.config.ts +0 -0
  68. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/vue-app/playwright.package-addition.config.ts +0 -0
  69. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/vue-app/src/App.vue +0 -0
  70. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/vue-app/src/main.ts +0 -0
  71. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/vue-app/src/stores/counter.ts +0 -0
  72. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/vue-app/src/style.css +0 -0
  73. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/vue-app/test/app.test.ts +0 -0
  74. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/vue-app/test/e2e/app.spec.ts +0 -0
  75. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/vue-app/vite.config.ts +0 -0
  76. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/vue-app/vitest.config.ts +0 -0
  77. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/vue-hono-app/.github/dependabot.yml +0 -0
  78. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/vue-hono-app/.github/workflows/check.yml +0 -0
  79. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/vue-hono-app/api/src/index.ts +0 -0
  80. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/vue-hono-app/api/src/runtime.ts +0 -0
  81. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/vue-hono-app/api/src/server.ts +0 -0
  82. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/vue-hono-app/api/test/app.test.ts +0 -0
  83. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/vue-hono-app/api/vitest.config.ts +0 -0
  84. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/vue-hono-app/web/env.d.ts +0 -0
  85. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/vue-hono-app/web/index.html +0 -0
  86. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/vue-hono-app/web/playwright.config.ts +0 -0
  87. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/vue-hono-app/web/src/App.vue +0 -0
  88. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/vue-hono-app/web/src/api.ts +0 -0
  89. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/vue-hono-app/web/src/main.ts +0 -0
  90. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/vue-hono-app/web/src/stores/counter.ts +0 -0
  91. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/vue-hono-app/web/src/style.css +0 -0
  92. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/vue-hono-app/web/test/app.test.ts +0 -0
  93. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/vue-hono-app/web/test/e2e/app.spec.ts +0 -0
  94. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/vue-hono-app/web/vite.config.ts +0 -0
  95. /package/{templates → node_modules/@ykdz/template-builtin-source/templates}/vue-hono-app/web/vitest.config.ts +0 -0
  96. /package/{dist/src → node_modules/@ykdz/template-core/dist}/dependency-catalog.d.ts +0 -0
  97. /package/{dist/src → node_modules/@ykdz/template-core/dist}/devcontainer.d.ts +0 -0
  98. /package/{dist/src → node_modules/@ykdz/template-core/dist}/devcontainer.js +0 -0
  99. /package/{dist/src → node_modules/@ykdz/template-core/dist}/editor-customization.d.ts +0 -0
  100. /package/{dist/src → node_modules/@ykdz/template-core/dist}/generation-context.d.ts +0 -0
  101. /package/{dist/src → node_modules/@ykdz/template-core/dist}/generation-context.js +0 -0
  102. /package/{dist/src → node_modules/@ykdz/template-core/dist}/module-graph.d.ts +0 -0
  103. /package/{dist/src → node_modules/@ykdz/template-core/dist}/module-graph.js +0 -0
  104. /package/{dist/src → node_modules/@ykdz/template-core/dist}/next-step-instructions.d.ts +0 -0
  105. /package/{dist/src → node_modules/@ykdz/template-core/dist}/next-step-instructions.js +0 -0
  106. /package/{dist/src → node_modules/@ykdz/template-core/dist}/package-addition-support.d.ts +0 -0
  107. /package/{dist/src → node_modules/@ykdz/template-core/dist}/package-addition-support.js +0 -0
  108. /package/{dist/src → node_modules/@ykdz/template-core/dist}/package-linking.d.ts +0 -0
  109. /package/{dist/src → node_modules/@ykdz/template-core/dist}/package-linking.js +0 -0
  110. /package/{dist/src → node_modules/@ykdz/template-core/dist}/preset-projection.d.ts +0 -0
  111. /package/{dist/src → node_modules/@ykdz/template-core/dist}/preset-projection.js +0 -0
  112. /package/{dist/src → node_modules/@ykdz/template-core/dist}/project-github.d.ts +0 -0
  113. /package/{dist/src → node_modules/@ykdz/template-core/dist}/project-github.js +0 -0
  114. /package/{dist/src → node_modules/@ykdz/template-core/dist}/renderer.d.ts +0 -0
  115. /package/{dist/src → node_modules/@ykdz/template-core/dist}/runtime-paths.d.ts +0 -0
  116. /package/{dist/src → node_modules/@ykdz/template-core/dist}/template-boundary-check.d.ts +0 -0
  117. /package/{dist/src → node_modules/@ykdz/template-core/dist}/template-boundary-check.js +0 -0
  118. /package/{dist/src → node_modules/@ykdz/template-core/dist}/toolchain-resolution.d.ts +0 -0
@@ -0,0 +1,94 @@
1
+ const rootPackageBoundary = {
2
+ kind: "package-boundary",
3
+ path: ".",
4
+ };
5
+ const apiPackageBoundary = {
6
+ kind: "package-boundary",
7
+ path: "apps/api",
8
+ };
9
+ const webPackageBoundary = {
10
+ kind: "package-boundary",
11
+ path: "apps/web",
12
+ };
13
+ function honoApiCheckComponents(owner) {
14
+ return [
15
+ { kind: "oxc-format-check", owner },
16
+ { kind: "oxc-lint", owner },
17
+ { kind: "typescript-typecheck", owner },
18
+ { kind: "build", owner },
19
+ { kind: "unit-test", owner },
20
+ ];
21
+ }
22
+ function vueAppCheckComponents(owner) {
23
+ return [
24
+ { kind: "oxc-format-check", owner },
25
+ { kind: "oxc-lint", owner },
26
+ { kind: "typescript-typecheck", owner },
27
+ { kind: "build", owner },
28
+ { kind: "unit-test", owner },
29
+ { kind: "e2e-test", owner },
30
+ ];
31
+ }
32
+ function nodeFixComponents(owner) {
33
+ return [
34
+ { kind: "oxc-format-write", owner },
35
+ { kind: "oxc-lint-fix", owner },
36
+ ];
37
+ }
38
+ export function selectNodeCheckComponents(target) {
39
+ switch (target) {
40
+ case "hono-api":
41
+ return honoApiCheckComponents(rootPackageBoundary);
42
+ case "vue-app":
43
+ return vueAppCheckComponents(rootPackageBoundary);
44
+ case "vue-hono-root":
45
+ return [{ kind: "turbo-check", owner: rootPackageBoundary }];
46
+ case "vue-hono-api":
47
+ return honoApiCheckComponents(apiPackageBoundary);
48
+ case "vue-hono-web":
49
+ return vueAppCheckComponents(webPackageBoundary);
50
+ }
51
+ }
52
+ export function selectNodeFixComponents(target) {
53
+ switch (target) {
54
+ case "hono-api":
55
+ case "vue-app":
56
+ return nodeFixComponents(rootPackageBoundary);
57
+ case "vue-hono-root":
58
+ return [{ kind: "turbo-fix", owner: rootPackageBoundary }];
59
+ case "vue-hono-api":
60
+ return nodeFixComponents(apiPackageBoundary);
61
+ case "vue-hono-web":
62
+ return nodeFixComponents(webPackageBoundary);
63
+ }
64
+ }
65
+ function checkEnvironmentNeeds(target) {
66
+ if (target === "vue-app") {
67
+ return [
68
+ {
69
+ kind: "playwright-browser-assets",
70
+ browser: "chromium",
71
+ owner: rootPackageBoundary,
72
+ },
73
+ ];
74
+ }
75
+ if (target === "vue-hono-root" || target === "vue-hono-web") {
76
+ return [
77
+ {
78
+ kind: "playwright-browser-assets",
79
+ browser: "chromium",
80
+ owner: webPackageBoundary,
81
+ },
82
+ ];
83
+ }
84
+ return [];
85
+ }
86
+ export function planNodeChecks(target) {
87
+ return {
88
+ components: selectNodeCheckComponents(target),
89
+ environmentNeeds: checkEnvironmentNeeds(target),
90
+ };
91
+ }
92
+ export function planNodeFixes(target) {
93
+ return { components: selectNodeFixComponents(target) };
94
+ }
@@ -0,0 +1,2 @@
1
+ import type { PresetProjection } from "@ykdz/template-core/preset-projection";
2
+ export declare function findBuiltInPresetProjection(name: string): PresetProjection | undefined;
@@ -0,0 +1,15 @@
1
+ import { honoApiPresetProjection } from "./hono-api/projection.js";
2
+ import { rustBinPresetProjection } from "./rust-bin/projection.js";
3
+ import { tsLibPresetProjection } from "./ts-lib/projection.js";
4
+ import { vueAppPresetProjection } from "./vue-app/projection.js";
5
+ import { vueHonoAppPresetProjection } from "./vue-hono-app/projection.js";
6
+ const testOnlyPresetProjections = [
7
+ tsLibPresetProjection,
8
+ honoApiPresetProjection,
9
+ vueAppPresetProjection,
10
+ vueHonoAppPresetProjection,
11
+ rustBinPresetProjection,
12
+ ];
13
+ export function findBuiltInPresetProjection(name) {
14
+ return testOnlyPresetProjections.find((projection) => projection.metadata.name === name);
15
+ }
@@ -0,0 +1,9 @@
1
+ import type { BuiltInPreset, ProjectBlueprint } from "@ykdz/template-core/declarations";
2
+ import { type CheckPlan, type FixPlan } from "@ykdz/template-core/module-graph";
3
+ import type { PresetBlueprintOptions, PresetProjection } from "@ykdz/template-core/preset-projection";
4
+ export declare const rustBinPresetMetadata: BuiltInPreset;
5
+ export declare function planRustBinChecks(): CheckPlan;
6
+ export declare function planRustBinFixes(): FixPlan;
7
+ export declare function rustBinBlueprint(options?: PresetBlueprintOptions): ProjectBlueprint;
8
+ export declare function projectRustBinPackageScripts(): Record<string, string>;
9
+ export declare const rustBinPresetProjection: PresetProjection;
@@ -0,0 +1,103 @@
1
+ import path from "node:path";
2
+ import { builtInPresetProjectionSourceRoots, loadBuiltInPresetProjectionDeclaration, } from "@ykdz/template-builtin-source";
3
+ import { renderFixCommand, renderRootCheckCommand, } from "@ykdz/template-core/module-graph";
4
+ import { PackageAdditionSupport } from "@ykdz/template-core/package-addition-support";
5
+ import { interpretPresetProjectionDeclaration } from "@ykdz/template-core/projection-capabilities";
6
+ import { renderNewProject } from "@ykdz/template-core/renderer";
7
+ export const rustBinPresetMetadata = {
8
+ name: "rust-bin",
9
+ title: "Rust binary",
10
+ description: "Rust native binary workspace with rustfmt, clippy, and cargo tests.",
11
+ generation: "supported",
12
+ supportedPackageManagers: ["pnpm"],
13
+ supportedProjectKinds: ["multi-package"],
14
+ packageAdditionSupport: PackageAdditionSupport.Unsupported,
15
+ features: [
16
+ "root-check",
17
+ "fix-command",
18
+ "devcontainer",
19
+ "github-actions",
20
+ "dependabot",
21
+ "rustfmt-clippy",
22
+ "cargo-test",
23
+ ],
24
+ };
25
+ const rustPackageBoundary = {
26
+ kind: "package-boundary",
27
+ path: ".",
28
+ };
29
+ function cargoPackageNameFromProjectName(projectName) {
30
+ const slug = projectName
31
+ .normalize("NFKD")
32
+ .replace(/[\u0300-\u036f]/g, "")
33
+ .toLowerCase()
34
+ .replace(/[^a-z0-9]+/g, "-")
35
+ .replace(/^-+|-+$/g, "");
36
+ return slug || "rust-bin";
37
+ }
38
+ function projectNameFromDir(targetDir) {
39
+ return path.basename(path.resolve(targetDir));
40
+ }
41
+ function rustWorkspacePackageName(projectName) {
42
+ return `${cargoPackageNameFromProjectName(projectName)}-native`;
43
+ }
44
+ function rustWorkspacePackagePath(projectName) {
45
+ return `packages/${cargoPackageNameFromProjectName(projectName)}`;
46
+ }
47
+ export function planRustBinChecks() {
48
+ return {
49
+ components: [
50
+ { kind: "rustfmt-check", owner: rustPackageBoundary },
51
+ { kind: "cargo-clippy", owner: rustPackageBoundary },
52
+ { kind: "cargo-test", owner: rustPackageBoundary },
53
+ ],
54
+ environmentNeeds: [],
55
+ };
56
+ }
57
+ export function planRustBinFixes() {
58
+ return {
59
+ components: [{ kind: "rustfmt-write", owner: rustPackageBoundary }],
60
+ };
61
+ }
62
+ export function rustBinBlueprint(options = { targetDir: process.cwd() }) {
63
+ const projectName = projectNameFromDir(options.targetDir);
64
+ return {
65
+ schemaVersion: 1,
66
+ preset: "rust-bin",
67
+ packageManager: "pnpm",
68
+ projectKind: "multi-package",
69
+ features: [...rustBinPresetMetadata.features],
70
+ packages: [
71
+ {
72
+ name: rustWorkspacePackageName(projectName),
73
+ path: rustWorkspacePackagePath(projectName),
74
+ },
75
+ ],
76
+ };
77
+ }
78
+ export function projectRustBinPackageScripts() {
79
+ return {
80
+ check: renderRootCheckCommand(planRustBinChecks()),
81
+ fix: renderFixCommand(planRustBinFixes()),
82
+ };
83
+ }
84
+ export const rustBinPresetProjection = {
85
+ metadata: rustBinPresetMetadata,
86
+ blueprint: rustBinBlueprint,
87
+ project(context) {
88
+ return interpretPresetProjectionDeclaration({
89
+ preset: rustBinPresetMetadata,
90
+ declaration: loadBuiltInPresetProjectionDeclaration("rust-bin"),
91
+ context,
92
+ sourceRoots: builtInPresetProjectionSourceRoots(),
93
+ });
94
+ },
95
+ async render({ targetDir, plan }) {
96
+ await renderNewProject({
97
+ sourceRoot: plan.sourceRoot,
98
+ sourceRoots: plan.sourceRoots,
99
+ targetRoot: targetDir,
100
+ operations: [...plan.operations],
101
+ });
102
+ },
103
+ };
@@ -0,0 +1,6 @@
1
+ import type { BuiltInPreset, ProjectBlueprint } from "@ykdz/template-core/declarations";
2
+ import type { PresetBlueprintOptions, PresetProjection } from "@ykdz/template-core/preset-projection";
3
+ export declare const tsLibPresetMetadata: BuiltInPreset;
4
+ export declare function tsLibBlueprint(options?: PresetBlueprintOptions): ProjectBlueprint;
5
+ export declare function projectTsLibPackageScripts(): Record<string, string>;
6
+ export declare const tsLibPresetProjection: PresetProjection;
@@ -0,0 +1,214 @@
1
+ import { existsSync } from "node:fs";
2
+ import path from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import { builtInPresetProjectionSourceRoots, loadBuiltInPresetProjectionDeclaration, } from "@ykdz/template-builtin-source";
5
+ import { renderFixCommand, renderRootCheckCommand, } from "@ykdz/template-core/module-graph";
6
+ import { PackageAdditionSupport } from "@ykdz/template-core/package-addition-support";
7
+ import { packageManifestExposureFields, planPackageLinks, } from "@ykdz/template-core/package-linking";
8
+ import { interpretPresetProjectionDeclaration } from "@ykdz/template-core/projection-capabilities";
9
+ import { renderNewProject, } from "@ykdz/template-core/renderer";
10
+ export const tsLibPresetMetadata = {
11
+ name: "ts-lib",
12
+ title: "TypeScript library",
13
+ description: "Strict TypeScript package with pnpm catalog tooling.",
14
+ generation: "supported",
15
+ supportedPackageManagers: ["pnpm"],
16
+ supportedProjectKinds: ["multi-package"],
17
+ packageAdditionSupport: PackageAdditionSupport.Supported,
18
+ features: [
19
+ "pnpm-catalog",
20
+ "oxc-format-lint",
21
+ "strict-typescript",
22
+ "root-check",
23
+ "fix-command",
24
+ "devcontainer",
25
+ "github-actions",
26
+ "dependabot",
27
+ ],
28
+ };
29
+ const tsLibPackageBoundary = {
30
+ kind: "package-boundary",
31
+ path: ".",
32
+ };
33
+ function planTsLibPackageChecks() {
34
+ return {
35
+ components: [
36
+ { kind: "typescript-typecheck", owner: tsLibPackageBoundary },
37
+ { kind: "oxc-lint", owner: tsLibPackageBoundary },
38
+ { kind: "oxc-format-check", owner: tsLibPackageBoundary },
39
+ ],
40
+ environmentNeeds: [],
41
+ };
42
+ }
43
+ function planTsLibPackageFixes() {
44
+ return {
45
+ components: [
46
+ { kind: "oxc-format-write", owner: tsLibPackageBoundary },
47
+ { kind: "oxc-lint-fix", owner: tsLibPackageBoundary },
48
+ ],
49
+ };
50
+ }
51
+ function projectNameFromDir(targetDir) {
52
+ return path.basename(path.resolve(targetDir));
53
+ }
54
+ function packageScopeFromOptions(options) {
55
+ return options.scope ?? projectNameFromDir(options.targetDir);
56
+ }
57
+ function scopedPackageName(packageScope, packageLeafName) {
58
+ return `@${packageScope}/${packageLeafName}`;
59
+ }
60
+ export function tsLibBlueprint(options = { targetDir: process.cwd() }) {
61
+ const packageScope = packageScopeFromOptions(options);
62
+ const packageLeafName = projectNameFromDir(options.targetDir);
63
+ return {
64
+ schemaVersion: 1,
65
+ preset: "ts-lib",
66
+ packageManager: "pnpm",
67
+ projectKind: "multi-package",
68
+ features: [...tsLibPresetMetadata.features],
69
+ packages: [
70
+ {
71
+ name: scopedPackageName(packageScope, packageLeafName),
72
+ path: `packages/${packageLeafName}`,
73
+ },
74
+ ],
75
+ };
76
+ }
77
+ export function projectTsLibPackageScripts() {
78
+ const checkPlan = planTsLibPackageChecks();
79
+ const fixPlan = planTsLibPackageFixes();
80
+ return {
81
+ check: renderRootCheckCommand(checkPlan),
82
+ fix: renderFixCommand(fixPlan),
83
+ "format:check": "oxfmt --check --config ../../oxfmt.config.ts .",
84
+ "format:write": "oxfmt --write --config ../../oxfmt.config.ts .",
85
+ lint: "oxlint --config ../../oxlint.config.ts . --deny-warnings",
86
+ "lint:fix": "oxlint --config ../../oxlint.config.ts . --fix --deny-warnings",
87
+ typecheck: "tsc -p tsconfig.json --noEmit",
88
+ };
89
+ }
90
+ function packageAdditionOperations(packagePath, packageNameValue, nodeVersion) {
91
+ const packageExposure = planPackageLinks([
92
+ {
93
+ name: packageNameValue,
94
+ path: packagePath,
95
+ role: "shared-library",
96
+ sourcePreset: "ts-lib",
97
+ },
98
+ ]).exposuresByPackagePath.get(packagePath);
99
+ if (packageExposure === undefined) {
100
+ throw new Error(`Missing Package Exposure for ${packagePath}`);
101
+ }
102
+ const exposureFields = packageManifestExposureFields(packageExposure);
103
+ return [
104
+ {
105
+ kind: "writeJson",
106
+ to: `${packagePath}/package.json`,
107
+ value: {
108
+ name: packageNameValue,
109
+ version: "0.0.0",
110
+ private: true,
111
+ type: "module",
112
+ imports: exposureFields.imports,
113
+ exports: exposureFields.exports,
114
+ dependencies: {
115
+ valibot: "catalog:",
116
+ },
117
+ scripts: projectTsLibPackageScripts(),
118
+ devDependencies: {
119
+ "@types/node": "catalog:",
120
+ oxfmt: "catalog:",
121
+ oxlint: "catalog:",
122
+ typescript: "catalog:",
123
+ },
124
+ engines: {
125
+ node: nodeVersion,
126
+ },
127
+ },
128
+ multilineArrays: ["files"],
129
+ },
130
+ {
131
+ kind: "writeJson",
132
+ to: `${packagePath}/tsconfig.json`,
133
+ value: {
134
+ compilerOptions: {
135
+ composite: true,
136
+ declaration: true,
137
+ declarationMap: true,
138
+ module: "NodeNext",
139
+ moduleResolution: "NodeNext",
140
+ noEmitOnError: true,
141
+ rootDir: "src",
142
+ skipLibCheck: false,
143
+ strict: true,
144
+ target: "ES2022",
145
+ types: ["node"],
146
+ },
147
+ include: ["src/**/*.ts"],
148
+ },
149
+ },
150
+ {
151
+ kind: "copyFile",
152
+ from: "src/index.ts",
153
+ to: `${packagePath}/src/index.ts`,
154
+ },
155
+ {
156
+ kind: "copyFile",
157
+ from: "src/name-schema.ts",
158
+ to: `${packagePath}/src/name-schema.ts`,
159
+ },
160
+ ];
161
+ }
162
+ function packageAdditionPlan(packageNameValue, packagePath, nodeVersion) {
163
+ const [workspaceCollection] = packagePath.split("/");
164
+ return {
165
+ packagePath,
166
+ workspacePackageGlob: `${workspaceCollection}/*`,
167
+ packageRole: "shared-library",
168
+ packageSourcePreset: "ts-lib",
169
+ sourceRoot: templateSourceRoot(),
170
+ sourceRoots: { sharedOxc: sharedOxcSourceRoot() },
171
+ operations: packageAdditionOperations(packagePath, packageNameValue, nodeVersion),
172
+ };
173
+ }
174
+ function templateSourceRoot() {
175
+ const projectionDir = path.dirname(fileURLToPath(import.meta.url));
176
+ const publishedTemplateRoot = path.join(projectionDir, "..", "..", "..", "templates", "ts-lib");
177
+ return existsSync(path.join(publishedTemplateRoot, "src", "index.ts"))
178
+ ? publishedTemplateRoot
179
+ : projectionDir;
180
+ }
181
+ function sharedOxcSourceRoot() {
182
+ const projectionDir = path.dirname(fileURLToPath(import.meta.url));
183
+ const publishedSharedRoot = path.join(projectionDir, "..", "..", "..", "templates", "shared", "oxc");
184
+ return existsSync(path.join(publishedSharedRoot, "oxfmt.config.ts"))
185
+ ? publishedSharedRoot
186
+ : path.join(projectionDir, "..", "shared", "oxc");
187
+ }
188
+ export const tsLibPresetProjection = {
189
+ metadata: tsLibPresetMetadata,
190
+ capabilities: {
191
+ packageAddition: {
192
+ planPackageAddition({ packageName, packagePath, nodeVersion, }) {
193
+ return packageAdditionPlan(packageName, packagePath, nodeVersion);
194
+ },
195
+ },
196
+ },
197
+ blueprint: tsLibBlueprint,
198
+ project(context) {
199
+ return interpretPresetProjectionDeclaration({
200
+ preset: tsLibPresetMetadata,
201
+ declaration: loadBuiltInPresetProjectionDeclaration("ts-lib"),
202
+ context,
203
+ sourceRoots: builtInPresetProjectionSourceRoots(),
204
+ });
205
+ },
206
+ async render({ targetDir, plan }) {
207
+ await renderNewProject({
208
+ sourceRoot: plan.sourceRoot,
209
+ sourceRoots: plan.sourceRoots,
210
+ targetRoot: targetDir,
211
+ operations: [...plan.operations],
212
+ });
213
+ },
214
+ };
@@ -0,0 +1,6 @@
1
+ import type { BuiltInPreset, ProjectBlueprint } from "@ykdz/template-core/declarations";
2
+ import type { PresetBlueprintOptions, PresetProjection } from "@ykdz/template-core/preset-projection";
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;