@ykdz/template 0.0.40 → 0.0.42

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 (87) hide show
  1. package/node_modules/@ykdz/template-builtin-presets/dist/src/foundation.js +144 -101
  2. package/node_modules/@ykdz/template-builtin-presets/dist/src/rust-bin/definition.js +29 -4
  3. package/node_modules/@ykdz/template-builtin-presets/dist/src/shared/vue.js +11 -2
  4. package/node_modules/@ykdz/template-builtin-presets/dist/src/ts-cli/definition.js +14 -4
  5. package/node_modules/@ykdz/template-builtin-presets/dist/src/ts-lib/definition.js +13 -0
  6. package/node_modules/@ykdz/template-builtin-presets/dist/src/vike-app/definition.js +44 -10
  7. package/node_modules/@ykdz/template-builtin-presets/dist/src/vue-app/definition.js +4 -1
  8. package/node_modules/@ykdz/template-builtin-presets/dist/src/vue-hono-app/definition.js +19 -8
  9. package/node_modules/@ykdz/template-builtin-presets/package.json +23 -10
  10. package/node_modules/@ykdz/template-builtin-presets/templates/foundation/.github/workflows/check-deployment-diagnostics.yml +30 -29
  11. package/node_modules/@ykdz/template-builtin-presets/templates/foundation/.github/workflows/check-deployment.yml +8 -21
  12. package/node_modules/@ykdz/template-builtin-presets/templates/foundation/.github/workflows/check-diagnostics.yml +21 -5
  13. package/node_modules/@ykdz/template-builtin-presets/templates/foundation/.github/workflows/check.yml +4 -2
  14. package/node_modules/@ykdz/template-builtin-presets/templates/foundation/AGENTS.md.template +9 -1
  15. package/node_modules/@ykdz/template-builtin-presets/templates/{shared/devcontainer/node-pnpm.Dockerfile → foundation/devcontainer/base.Dockerfile} +14 -1
  16. package/node_modules/@ykdz/template-builtin-presets/templates/foundation/gitignore +1 -0
  17. package/node_modules/@ykdz/template-builtin-presets/templates/foundation/pnpm-workspace.yaml +3 -0
  18. package/node_modules/@ykdz/template-builtin-presets/templates/foundation/scripts/node-test-count-reporter.ts +31 -0
  19. package/node_modules/@ykdz/template-builtin-presets/templates/foundation/scripts/run-rust-tests.ts +100 -0
  20. package/node_modules/@ykdz/template-builtin-presets/templates/foundation/scripts/run-turbo-boundaries.ts +74 -0
  21. package/node_modules/@ykdz/template-builtin-presets/templates/foundation/scripts/task-gates.ts +589 -0
  22. package/node_modules/@ykdz/template-builtin-presets/templates/foundation/turbo-projections/database-preparation.json +17 -0
  23. package/node_modules/@ykdz/template-builtin-presets/templates/foundation/turbo-projections/deployment.json +13 -0
  24. package/node_modules/@ykdz/template-builtin-presets/templates/foundation/turbo-projections/rust-toolchain.json +5 -0
  25. package/node_modules/@ykdz/template-builtin-presets/templates/foundation/turbo-projections/vue-hono-joint-e2e.json +13 -0
  26. package/node_modules/@ykdz/template-builtin-presets/templates/foundation/turbo.json +14 -15
  27. package/node_modules/@ykdz/template-builtin-presets/templates/foundation/typescript-config/turbo.json +30 -1
  28. package/node_modules/@ykdz/template-builtin-presets/templates/rust-bin/devcontainer/rust.Dockerfile +1 -5
  29. package/node_modules/@ykdz/template-builtin-presets/templates/rust-bin/tsconfig.scripts.json +12 -0
  30. package/node_modules/@ykdz/template-builtin-presets/templates/rust-bin/turbo.json +19 -4
  31. package/node_modules/@ykdz/template-builtin-presets/templates/shared/devcontainer/github-cli.Dockerfile +1 -3
  32. package/node_modules/@ykdz/template-builtin-presets/templates/shared/vue/TESTING.md +7 -0
  33. package/node_modules/@ykdz/template-builtin-presets/templates/shared/vue/src/components/CounterButton.vue +18 -0
  34. package/node_modules/@ykdz/template-builtin-presets/templates/shared/vue/test/counter.browser.test.ts +16 -0
  35. package/node_modules/@ykdz/template-builtin-presets/templates/shared/vue/test/{app.test.ts → counter.node.test.ts} +1 -0
  36. package/node_modules/@ykdz/template-builtin-presets/templates/shared/vue/tsconfig.test.json +1 -1
  37. package/node_modules/@ykdz/template-builtin-presets/templates/shared/vue/vitest.config.ts +50 -0
  38. package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/publication/check-artifact.ts +16 -5
  39. package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/publication/release.yml +5 -2
  40. package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/publication/turbo.json +5 -2
  41. package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/publication-setup/bridge.ts +1 -1
  42. package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/src/cli-command-identity.ts +0 -45
  43. package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/test/e2e/run-journeys.test.ts +11 -0
  44. package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/test/integration/command.test.ts +43 -39
  45. package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/test/unit/cli-command-identity.test.ts +52 -52
  46. package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/tsconfig.json +1 -1
  47. package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/turbo.json +58 -3
  48. package/node_modules/@ykdz/template-builtin-presets/templates/ts-lib/test/greet.test.ts +20 -0
  49. package/node_modules/@ykdz/template-builtin-presets/templates/ts-lib/tsconfig.json +1 -1
  50. package/node_modules/@ykdz/template-builtin-presets/templates/ts-lib/turbo.json +44 -1
  51. package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/db/test/todos.test.ts +8 -11
  52. package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/db/turbo.json +38 -1
  53. package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/db-migrations/turbo.json +44 -1
  54. package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/web/playwright.config.ts +18 -2
  55. package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/web/test/counter.browser.test.ts +14 -0
  56. package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/web/tsconfig.test.json +8 -2
  57. package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/web/turbo.json +61 -1
  58. package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/web/vitest.config.ts +29 -2
  59. package/node_modules/@ykdz/template-builtin-presets/templates/vue-app/src/App.vue +2 -12
  60. package/node_modules/@ykdz/template-builtin-presets/templates/vue-app/turbo.json +60 -2
  61. package/node_modules/@ykdz/template-builtin-presets/templates/vue-hono-app/api/test/app.test.ts +7 -6
  62. package/node_modules/@ykdz/template-builtin-presets/templates/vue-hono-app/api/tsconfig.json +2 -7
  63. package/node_modules/@ykdz/template-builtin-presets/templates/vue-hono-app/api/turbo.json +46 -1
  64. package/node_modules/@ykdz/template-builtin-presets/templates/vue-hono-app/web/src/App.vue +2 -11
  65. package/node_modules/@ykdz/template-builtin-presets/templates/vue-hono-app/web/turbo.json +57 -1
  66. package/node_modules/@ykdz/template-core/dist/ci-diagnostic-artifact.d.ts +1 -1
  67. package/node_modules/@ykdz/template-core/dist/ci-diagnostic-artifact.js +6 -3
  68. package/node_modules/@ykdz/template-core/dist/dependency-catalog.d.ts +0 -1
  69. package/node_modules/@ykdz/template-core/dist/dependency-catalog.js +0 -19
  70. package/node_modules/@ykdz/template-core/dist/module-graph.d.ts +0 -9
  71. package/node_modules/@ykdz/template-core/dist/module-graph.js +0 -40
  72. package/node_modules/@ykdz/template-core/dist/package-contribution.d.ts +2 -2
  73. package/node_modules/@ykdz/template-core/dist/package-contribution.js +2 -44
  74. package/node_modules/@ykdz/template-core/dist/pnpm-workspace.yaml +4 -1
  75. package/node_modules/@ykdz/template-core/dist/project-github.d.ts +0 -59
  76. package/node_modules/@ykdz/template-core/dist/project-github.js +7 -70
  77. package/node_modules/@ykdz/template-core/dist/renderer.d.ts +1 -0
  78. package/node_modules/@ykdz/template-core/dist/renderer.js +39 -1
  79. package/node_modules/@ykdz/template-core/dist/template-boundary-check.js +34 -16
  80. package/node_modules/@ykdz/template-core/package.json +0 -5
  81. package/package.json +4 -10
  82. package/node_modules/@ykdz/template-builtin-presets/templates/rust-bin/.github/workflows/check.yml +0 -23
  83. package/node_modules/@ykdz/template-builtin-presets/templates/ts-lib/.github/workflows/check.yml +0 -19
  84. package/node_modules/@ykdz/template-builtin-presets/templates/vue-app/.github/workflows/check.yml +0 -20
  85. package/node_modules/@ykdz/template-builtin-presets/templates/vue-app/vitest.config.ts +0 -8
  86. package/node_modules/@ykdz/template-builtin-presets/templates/vue-hono-app/api/vitest.config.ts +0 -15
  87. package/node_modules/@ykdz/template-builtin-presets/templates/vue-hono-app/web/vitest.config.ts +0 -10
@@ -47,6 +47,7 @@ export type MergeJsonTemplateOperation = {
47
47
  from: string;
48
48
  to: string;
49
49
  source: TemplateSourceHandle;
50
+ replacements?: Record<string, string>;
50
51
  multilineArrays?: string[];
51
52
  keyOrder?: readonly string[];
52
53
  nestedKeyOrder?: readonly string[];
@@ -124,13 +124,17 @@ async function renderMergeJson(operation, options) {
124
124
  }
125
125
  async function renderMergeJsonTemplate(operation, options) {
126
126
  const sourcePath = resolveTemplateSource(operation.source, operation.from);
127
+ const sourceText = await readFile(sourcePath, "utf8");
127
128
  let patch;
128
129
  try {
129
- patch = JSON.parse(await readFile(sourcePath, "utf8"));
130
+ patch = JSON.parse(sourceText);
130
131
  }
131
132
  catch (error) {
132
133
  throw new Error(`Invalid JSON Template Source ${operation.from}: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
133
134
  }
135
+ if (operation.replacements !== undefined) {
136
+ patch = replaceJsonTemplateVariables(patch, operation.replacements);
137
+ }
134
138
  await mergeJsonIntoFile({
135
139
  options,
136
140
  patch,
@@ -140,6 +144,40 @@ async function renderMergeJsonTemplate(operation, options) {
140
144
  nestedKeyOrder: operation.nestedKeyOrder,
141
145
  });
142
146
  }
147
+ function replaceJsonTemplateVariables(value, replacements) {
148
+ const used = new Set();
149
+ const replaceString = (source) => source.replaceAll(/\{\{([A-Za-z][A-Za-z0-9_]*)\}\}/g, (_placeholder, name) => {
150
+ const replacement = replacements[name];
151
+ if (replacement === undefined) {
152
+ throw new Error(`JSON 模板缺少变量:${name}`);
153
+ }
154
+ used.add(name);
155
+ return replacement;
156
+ });
157
+ const visit = (current) => {
158
+ if (typeof current === "string") {
159
+ return replaceString(current);
160
+ }
161
+ if (Array.isArray(current)) {
162
+ return current.map(visit);
163
+ }
164
+ if (typeof current === "object" && current !== null) {
165
+ const entries = Object.entries(current).map(([key, nestedValue]) => [replaceString(key), visit(nestedValue)]);
166
+ if (new Set(entries.map(([key]) => key)).size !== entries.length) {
167
+ throw new Error("JSON 模板变量替换后产生重复对象键");
168
+ }
169
+ return Object.fromEntries(entries);
170
+ }
171
+ return current;
172
+ };
173
+ const rendered = visit(value);
174
+ for (const name of Object.keys(replacements)) {
175
+ if (!used.has(name)) {
176
+ throw new Error(`JSON 模板替换项未被使用:${name}`);
177
+ }
178
+ }
179
+ return rendered;
180
+ }
143
181
  async function mergeJsonIntoFile(options) {
144
182
  const to = resolveContainedPath(options.options.targetRoot, options.toPath);
145
183
  let existing = {};
@@ -612,14 +612,20 @@ const workflowTemplateVariants = new Map([
612
612
  ".github/workflows/check-diagnostics.yml",
613
613
  {
614
614
  operationKind: "writeTextTemplate",
615
- replacementKeys: ["DIAGNOSTIC_OWNER_PATHS"],
615
+ replacementKeys: [
616
+ "PLAYWRIGHT_DIAGNOSTIC_OWNER_PATHS",
617
+ "VITEST_BROWSER_DIAGNOSTIC_OWNER_PATHS",
618
+ ],
616
619
  },
617
620
  ],
618
621
  [
619
622
  ".github/workflows/check-deployment-diagnostics.yml",
620
623
  {
621
624
  operationKind: "writeTextTemplate",
622
- replacementKeys: ["DIAGNOSTIC_OWNER_PATHS"],
625
+ replacementKeys: [
626
+ "PLAYWRIGHT_DIAGNOSTIC_OWNER_PATHS",
627
+ "VITEST_BROWSER_DIAGNOSTIC_OWNER_PATHS",
628
+ ],
623
629
  },
624
630
  ],
625
631
  ]);
@@ -650,20 +656,25 @@ function isSafePackageBoundaryPath(value) {
650
656
  function expectedDiagnosticOwnerPaths(options) {
651
657
  const blueprintPackagePaths = options.blueprint.packages.map((packageDefinition) => packageDefinition.path);
652
658
  if (!blueprintPackagePaths.every(isSafePackageBoundaryPath)) {
653
- return { valid: false, value: "" };
659
+ return { valid: false, playwright: "", vitestBrowser: "" };
654
660
  }
655
661
  const blueprintOwners = new Set(blueprintPackagePaths);
656
- const owners = new Set();
662
+ const owners = {
663
+ playwright: new Set(),
664
+ "vitest-browser": new Set(),
665
+ };
657
666
  for (const declaration of options.diagnosticArtifactDeclarations) {
658
667
  if (!isRecord(declaration) ||
659
668
  !hasExactKeys(declaration, ["kind", "owner"])) {
660
- return { valid: false, value: "" };
669
+ return { valid: false, playwright: "", vitestBrowser: "" };
661
670
  }
662
- if (declaration.kind !== "playwright" || !isRecord(declaration.owner)) {
663
- return { valid: false, value: "" };
671
+ if ((declaration.kind !== "playwright" &&
672
+ declaration.kind !== "vitest-browser") ||
673
+ !isRecord(declaration.owner)) {
674
+ return { valid: false, playwright: "", vitestBrowser: "" };
664
675
  }
665
676
  if (!hasExactKeys(declaration.owner, ["kind", "path"])) {
666
- return { valid: false, value: "" };
677
+ return { valid: false, playwright: "", vitestBrowser: "" };
667
678
  }
668
679
  const ownerPath = declaration.owner.path;
669
680
  const workspaceOwner = declaration.owner.kind === "workspace-orchestration" && ownerPath === ".";
@@ -672,13 +683,16 @@ function expectedDiagnosticOwnerPaths(options) {
672
683
  isSafePackageBoundaryPath(ownerPath) &&
673
684
  blueprintOwners.has(ownerPath);
674
685
  if (!workspaceOwner && !packageOwner) {
675
- return { valid: false, value: "" };
686
+ return { valid: false, playwright: "", vitestBrowser: "" };
676
687
  }
677
- owners.add(ownerPath);
688
+ owners[declaration.kind].add(ownerPath);
678
689
  }
679
690
  return {
680
691
  valid: true,
681
- value: [...owners].toSorted().join("\n "),
692
+ playwright: [...owners.playwright].toSorted().join("\n "),
693
+ vitestBrowser: [...owners["vitest-browser"]]
694
+ .toSorted()
695
+ .join("\n "),
682
696
  };
683
697
  }
684
698
  function sourceFileForWorkflowOperation(options) {
@@ -723,21 +737,25 @@ async function protectedWorkflowProjectionViolations(plans) {
723
737
  : undefined;
724
738
  const replacementValid = operation?.kind === "writeTextTemplate" &&
725
739
  hasExactReplacementKeys(operation.replacements, [
726
- "DIAGNOSTIC_OWNER_PATHS",
740
+ "PLAYWRIGHT_DIAGNOSTIC_OWNER_PATHS",
741
+ "VITEST_BROWSER_DIAGNOSTIC_OWNER_PATHS",
727
742
  ]) &&
728
- operation.replacements.DIAGNOSTIC_OWNER_PATHS ===
729
- expectedDiagnosticOwners.value;
743
+ operation.replacements.PLAYWRIGHT_DIAGNOSTIC_OWNER_PATHS ===
744
+ expectedDiagnosticOwners.playwright &&
745
+ operation.replacements.VITEST_BROWSER_DIAGNOSTIC_OWNER_PATHS ===
746
+ expectedDiagnosticOwners.vitestBrowser;
730
747
  const sourceBackedExactlyOnce = matchingOperations.length === 1 &&
731
748
  operation !== undefined &&
732
749
  (operation.kind === "copyFile" || operation.kind === "writeTextTemplate");
733
- const diagnosticsExpected = expectedDiagnosticOwners.value !== "";
750
+ const diagnosticsExpected = expectedDiagnosticOwners.playwright !== "" ||
751
+ expectedDiagnosticOwners.vitestBrowser !== "";
734
752
  const operationValid = expectedDiagnosticOwners.valid &&
735
753
  sourceBackedExactlyOnce &&
736
754
  variant !== undefined &&
737
755
  operation?.kind === variant.operationKind &&
738
756
  (operation.kind === "copyFile"
739
757
  ? variant.replacementKeys.length === 0 && !diagnosticsExpected
740
- : variant.replacementKeys.length === 1 &&
758
+ : variant.replacementKeys.length === 2 &&
741
759
  diagnosticsExpected &&
742
760
  replacementValid);
743
761
  if (operationValid)
@@ -36,10 +36,5 @@
36
36
  },
37
37
  "peerDependencies": {
38
38
  "typescript": ">=6 <7"
39
- },
40
- "turbo": {
41
- "tags": [
42
- "template-core"
43
- ]
44
39
  }
45
40
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ykdz/template",
3
- "version": "0.0.40",
3
+ "version": "0.0.42",
4
4
  "private": false,
5
5
  "description": "Project template generator for YKDZ starter projects.",
6
6
  "keywords": [
@@ -67,8 +67,7 @@
67
67
  "oxfmt": "^0.71.0",
68
68
  "oxlint": "^1.77.0",
69
69
  "oxlint-tsgolint": "^7.0.2001",
70
- "typescript-7": "npm:typescript@^7.0.2",
71
- "vitest": "^5.0.0"
70
+ "typescript-7": "npm:typescript@^7.0.2"
72
71
  },
73
72
  "bundleDependencies": [
74
73
  "@valibot/to-json-schema",
@@ -88,11 +87,6 @@
88
87
  "engines": {
89
88
  "node": "^24.21.0"
90
89
  },
91
- "turbo": {
92
- "tags": [
93
- "template-cli"
94
- ]
95
- },
96
90
  "scripts": {
97
91
  "build": "rm -rf dist && tsc -p tsconfig.build.json",
98
92
  "format:check": "oxfmt --list-different --config ../../oxfmt.config.ts .",
@@ -100,8 +94,8 @@
100
94
  "lint": "oxlint --quiet --format=unix --config ../../oxlint.config.ts --ignore-pattern dist .",
101
95
  "lint:fix": "oxlint --format=unix --config ../../oxlint.config.ts --ignore-pattern dist . --fix",
102
96
  "pack:bundled": "pnpm --config.node-linker=hoisted pack",
103
- "publish:bundled": "pnpm --config.node-linker=hoisted publish",
104
- "test": "vitest run --config vitest.config.ts test/unit test/integration --reporter=verbose",
97
+ "test": "node --conditions=source --experimental-strip-types --test --test-concurrency=2 --test-timeout=60000 --test-reporter=spec --test-reporter=@ykdz/template-builtin-presets/node-test-count-reporter --test-reporter-destination=stdout --test-reporter-destination=stderr 'test/**/*.light.test.ts'",
98
+ "test:integration": "node --conditions=source --experimental-strip-types --test --test-concurrency=1 --test-timeout=300000 --test-reporter=spec --test-reporter=@ykdz/template-builtin-presets/node-test-count-reporter --test-reporter-destination=stdout --test-reporter-destination=stderr 'test/**/*.integration.test.ts'",
105
99
  "test:e2e": "node --conditions=source test/e2e/check-source-and-distribution.ts",
106
100
  "typecheck": "tsc -p tsconfig.json --noEmit --pretty false"
107
101
  }
@@ -1,23 +0,0 @@
1
- name: Check
2
-
3
- on:
4
- pull_request:
5
- push:
6
- branches:
7
- - main
8
-
9
- jobs:
10
- check:
11
- runs-on: ubuntu-latest
12
- steps:
13
- - uses: actions/checkout@v7
14
- - uses: actions/setup-node@v7
15
- with:
16
- node-version-file: package.json
17
- - run: corepack enable
18
- - uses: dtolnay/rust-toolchain@stable
19
- with:
20
- components: rustfmt, clippy
21
- - uses: Swatinem/rust-cache@v2
22
- - run: pnpm install
23
- - run: pnpm run check
@@ -1,19 +0,0 @@
1
- name: Check
2
-
3
- on:
4
- pull_request:
5
- push:
6
- branches:
7
- - main
8
-
9
- jobs:
10
- check:
11
- runs-on: ubuntu-latest
12
- steps:
13
- - uses: actions/checkout@v7
14
- - uses: actions/setup-node@v7
15
- with:
16
- node-version-file: package.json
17
- - run: corepack enable
18
- - run: pnpm install
19
- - run: pnpm run check
@@ -1,20 +0,0 @@
1
- name: Check
2
-
3
- on:
4
- pull_request:
5
- push:
6
- branches:
7
- - main
8
-
9
- jobs:
10
- check:
11
- runs-on: ubuntu-latest
12
- steps:
13
- - uses: actions/checkout@v7
14
- - uses: actions/setup-node@v7
15
- with:
16
- node-version-file: package.json
17
- - run: corepack enable
18
- - run: pnpm install
19
- - run: pnpm --filter ./apps/web exec playwright install --with-deps chromium
20
- - run: pnpm run check
@@ -1,8 +0,0 @@
1
- import { defineConfig } from "vitest/config";
2
-
3
- export default defineConfig({
4
- test: {
5
- exclude: ["test/e2e/**", "node_modules/**", "dist/**"],
6
- globals: true,
7
- },
8
- });
@@ -1,15 +0,0 @@
1
- import { defineConfig } from "vitest/config";
2
-
3
- export default defineConfig({
4
- resolve: {
5
- conditions: ["source"],
6
- },
7
- ssr: {
8
- resolve: {
9
- conditions: ["source"],
10
- },
11
- },
12
- test: {
13
- globals: true,
14
- },
15
- });
@@ -1,10 +0,0 @@
1
- import vue from "@vitejs/plugin-vue";
2
- import { defineConfig } from "vitest/config";
3
-
4
- export default defineConfig({
5
- plugins: [vue()],
6
- test: {
7
- exclude: ["test/e2e/**", "node_modules/**", "dist/**"],
8
- globals: true,
9
- },
10
- });