@ykdz/template 0.0.41 → 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 (81) hide show
  1. package/node_modules/@ykdz/template-builtin-presets/dist/src/foundation.js +111 -99
  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 +7 -1
  15. package/node_modules/@ykdz/template-builtin-presets/templates/foundation/gitignore +1 -0
  16. package/node_modules/@ykdz/template-builtin-presets/templates/foundation/pnpm-workspace.yaml +3 -0
  17. package/node_modules/@ykdz/template-builtin-presets/templates/foundation/scripts/node-test-count-reporter.ts +31 -0
  18. package/node_modules/@ykdz/template-builtin-presets/templates/foundation/scripts/run-rust-tests.ts +100 -0
  19. package/node_modules/@ykdz/template-builtin-presets/templates/foundation/scripts/run-turbo-boundaries.ts +74 -0
  20. package/node_modules/@ykdz/template-builtin-presets/templates/foundation/scripts/task-gates.ts +589 -0
  21. package/node_modules/@ykdz/template-builtin-presets/templates/foundation/turbo-projections/database-preparation.json +17 -0
  22. package/node_modules/@ykdz/template-builtin-presets/templates/foundation/turbo-projections/deployment.json +13 -0
  23. package/node_modules/@ykdz/template-builtin-presets/templates/foundation/turbo-projections/rust-toolchain.json +5 -0
  24. package/node_modules/@ykdz/template-builtin-presets/templates/foundation/turbo-projections/vue-hono-joint-e2e.json +13 -0
  25. package/node_modules/@ykdz/template-builtin-presets/templates/foundation/turbo.json +14 -15
  26. package/node_modules/@ykdz/template-builtin-presets/templates/foundation/typescript-config/turbo.json +30 -1
  27. package/node_modules/@ykdz/template-builtin-presets/templates/rust-bin/tsconfig.scripts.json +12 -0
  28. package/node_modules/@ykdz/template-builtin-presets/templates/rust-bin/turbo.json +19 -4
  29. package/node_modules/@ykdz/template-builtin-presets/templates/shared/vue/TESTING.md +7 -0
  30. package/node_modules/@ykdz/template-builtin-presets/templates/shared/vue/src/components/CounterButton.vue +18 -0
  31. package/node_modules/@ykdz/template-builtin-presets/templates/shared/vue/test/counter.browser.test.ts +16 -0
  32. package/node_modules/@ykdz/template-builtin-presets/templates/shared/vue/test/{app.test.ts → counter.node.test.ts} +1 -0
  33. package/node_modules/@ykdz/template-builtin-presets/templates/shared/vue/tsconfig.test.json +1 -1
  34. package/node_modules/@ykdz/template-builtin-presets/templates/shared/vue/vitest.config.ts +50 -0
  35. package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/publication/check-artifact.ts +16 -5
  36. package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/publication/release.yml +5 -2
  37. package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/publication/turbo.json +5 -2
  38. package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/publication-setup/bridge.ts +1 -1
  39. package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/src/cli-command-identity.ts +0 -45
  40. package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/test/e2e/run-journeys.test.ts +11 -0
  41. package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/test/integration/command.test.ts +43 -39
  42. package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/test/unit/cli-command-identity.test.ts +52 -52
  43. package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/tsconfig.json +1 -1
  44. package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/turbo.json +58 -3
  45. package/node_modules/@ykdz/template-builtin-presets/templates/ts-lib/test/greet.test.ts +20 -0
  46. package/node_modules/@ykdz/template-builtin-presets/templates/ts-lib/tsconfig.json +1 -1
  47. package/node_modules/@ykdz/template-builtin-presets/templates/ts-lib/turbo.json +44 -1
  48. package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/db/test/todos.test.ts +8 -11
  49. package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/db/turbo.json +38 -1
  50. package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/db-migrations/turbo.json +44 -1
  51. package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/web/playwright.config.ts +18 -2
  52. package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/web/test/counter.browser.test.ts +14 -0
  53. package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/web/tsconfig.test.json +8 -2
  54. package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/web/turbo.json +61 -1
  55. package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/web/vitest.config.ts +29 -2
  56. package/node_modules/@ykdz/template-builtin-presets/templates/vue-app/src/App.vue +2 -12
  57. package/node_modules/@ykdz/template-builtin-presets/templates/vue-app/turbo.json +60 -2
  58. package/node_modules/@ykdz/template-builtin-presets/templates/vue-hono-app/api/test/app.test.ts +7 -6
  59. package/node_modules/@ykdz/template-builtin-presets/templates/vue-hono-app/api/tsconfig.json +2 -7
  60. package/node_modules/@ykdz/template-builtin-presets/templates/vue-hono-app/api/turbo.json +46 -1
  61. package/node_modules/@ykdz/template-builtin-presets/templates/vue-hono-app/web/src/App.vue +2 -11
  62. package/node_modules/@ykdz/template-builtin-presets/templates/vue-hono-app/web/turbo.json +57 -1
  63. package/node_modules/@ykdz/template-core/dist/ci-diagnostic-artifact.d.ts +1 -1
  64. package/node_modules/@ykdz/template-core/dist/ci-diagnostic-artifact.js +6 -3
  65. package/node_modules/@ykdz/template-core/dist/module-graph.d.ts +0 -9
  66. package/node_modules/@ykdz/template-core/dist/module-graph.js +0 -40
  67. package/node_modules/@ykdz/template-core/dist/package-contribution.d.ts +2 -2
  68. package/node_modules/@ykdz/template-core/dist/package-contribution.js +2 -44
  69. package/node_modules/@ykdz/template-core/dist/pnpm-workspace.yaml +3 -0
  70. package/node_modules/@ykdz/template-core/dist/project-github.js +7 -3
  71. package/node_modules/@ykdz/template-core/dist/renderer.d.ts +1 -0
  72. package/node_modules/@ykdz/template-core/dist/renderer.js +39 -1
  73. package/node_modules/@ykdz/template-core/dist/template-boundary-check.js +34 -16
  74. package/node_modules/@ykdz/template-core/package.json +0 -5
  75. package/package.json +4 -10
  76. package/node_modules/@ykdz/template-builtin-presets/templates/rust-bin/.github/workflows/check.yml +0 -23
  77. package/node_modules/@ykdz/template-builtin-presets/templates/ts-lib/.github/workflows/check.yml +0 -19
  78. package/node_modules/@ykdz/template-builtin-presets/templates/vue-app/.github/workflows/check.yml +0 -20
  79. package/node_modules/@ykdz/template-builtin-presets/templates/vue-app/vitest.config.ts +0 -8
  80. package/node_modules/@ykdz/template-builtin-presets/templates/vue-hono-app/api/vitest.config.ts +0 -15
  81. package/node_modules/@ykdz/template-builtin-presets/templates/vue-hono-app/web/vitest.config.ts +0 -10
@@ -0,0 +1,100 @@
1
+ import { spawn } from "node:child_process";
2
+
3
+ const testSummary =
4
+ /^test result: (?:ok|FAILED)\. (\d+) passed; (\d+) failed; \d+ ignored;/u;
5
+ const ansiEscape = new RegExp(
6
+ `${String.fromCharCode(27)}\\[[0-?]*[ -/]*[@-~]`,
7
+ "gu",
8
+ );
9
+ const zeroTestDiagnostic =
10
+ "Cargo 未执行任何业务测试用例;请检查测试内容与 ignored 标记";
11
+ type InterruptSignal = "SIGINT" | "SIGTERM";
12
+
13
+ let executedTests = 0;
14
+ let stdoutRemainder = "";
15
+ let stderrRemainder = "";
16
+ let interruptedBy: InterruptSignal | undefined;
17
+
18
+ function countSummaryLine(line: string): void {
19
+ const match = testSummary.exec(line.replace(ansiEscape, ""));
20
+ if (match !== null) {
21
+ executedTests += Number(match[1]) + Number(match[2]);
22
+ }
23
+ }
24
+
25
+ function forwardSignal(signal: InterruptSignal): void {
26
+ if (cargo.exitCode === null && cargo.signalCode === null) {
27
+ interruptedBy = signal;
28
+ try {
29
+ if (process.platform !== "win32" && cargo.pid !== undefined) {
30
+ process.kill(-cargo.pid, signal);
31
+ } else {
32
+ cargo.kill(signal);
33
+ }
34
+ } catch {
35
+ cargo.kill(signal);
36
+ }
37
+ }
38
+ }
39
+
40
+ function forwardInterrupt(): void {
41
+ forwardSignal("SIGINT");
42
+ }
43
+
44
+ function forwardTerminate(): void {
45
+ forwardSignal("SIGTERM");
46
+ }
47
+
48
+ function consumeOutput(
49
+ chunk: Buffer,
50
+ stream: NodeJS.WriteStream,
51
+ remainder: string,
52
+ saveRemainder: (value: string) => void,
53
+ ): void {
54
+ stream.write(chunk);
55
+ const lines = `${remainder}${chunk.toString("utf8")}`.split(/\r?\n/u);
56
+ const lastLine = lines.pop();
57
+ for (const line of lines) countSummaryLine(line);
58
+ saveRemainder(lastLine ?? "");
59
+ }
60
+
61
+ const cargo = spawn("cargo", ["test", "--workspace"], {
62
+ stdio: ["inherit", "pipe", "pipe"],
63
+ detached: process.platform !== "win32",
64
+ });
65
+
66
+ process.on("SIGINT", forwardInterrupt);
67
+ process.on("SIGTERM", forwardTerminate);
68
+
69
+ cargo.stdout.on("data", (chunk: Buffer) =>
70
+ consumeOutput(chunk, process.stdout, stdoutRemainder, (value) => {
71
+ stdoutRemainder = value;
72
+ }),
73
+ );
74
+ cargo.stderr.on("data", (chunk: Buffer) =>
75
+ consumeOutput(chunk, process.stderr, stderrRemainder, (value) => {
76
+ stderrRemainder = value;
77
+ }),
78
+ );
79
+ cargo.once("error", (error) => {
80
+ process.stderr.write(`无法启动 Cargo 测试:${error.message}\n`);
81
+ process.exitCode = 1;
82
+ });
83
+ cargo.once("close", (code, signal) => {
84
+ process.off("SIGINT", forwardInterrupt);
85
+ process.off("SIGTERM", forwardTerminate);
86
+ countSummaryLine(stdoutRemainder);
87
+ countSummaryLine(stderrRemainder);
88
+
89
+ if (interruptedBy !== undefined) {
90
+ process.exitCode = interruptedBy === "SIGINT" ? 130 : 143;
91
+ } else if (code !== null && code !== 0) {
92
+ process.exitCode = code;
93
+ } else if (signal !== null) {
94
+ process.exitCode =
95
+ signal === "SIGINT" ? 130 : signal === "SIGTERM" ? 143 : 1;
96
+ } else if (executedTests === 0) {
97
+ process.stderr.write(`${zeroTestDiagnostic}\n`);
98
+ process.exitCode = 1;
99
+ }
100
+ });
@@ -0,0 +1,74 @@
1
+ import { spawn } from "node:child_process";
2
+ import { resolve } from "node:path";
3
+ import { pathToFileURL } from "node:url";
4
+
5
+ type InterruptSignal = "SIGINT" | "SIGTERM";
6
+
7
+ function exitStatus(
8
+ code: number | null,
9
+ signal: NodeJS.Signals | null,
10
+ interruptedBy: InterruptSignal | undefined,
11
+ spawnFailed: boolean,
12
+ ): number {
13
+ if (interruptedBy !== undefined) {
14
+ return interruptedBy === "SIGINT" ? 130 : 143;
15
+ }
16
+ if (spawnFailed) return 1;
17
+ if (code !== null) return code;
18
+ if (signal === "SIGINT") return 130;
19
+ if (signal === "SIGTERM") return 143;
20
+ return 1;
21
+ }
22
+
23
+ export async function runTurboBoundaries(cwd = process.cwd()): Promise<number> {
24
+ const turbo = spawn("pnpm", ["exec", "turbo", "boundaries", "--no-color"], {
25
+ cwd,
26
+ stdio: "inherit",
27
+ detached: process.platform !== "win32",
28
+ });
29
+ let interruptedBy: InterruptSignal | undefined;
30
+ let spawnFailed = false;
31
+
32
+ const forwardSignal = (signal: InterruptSignal): void => {
33
+ if (turbo.exitCode !== null || turbo.signalCode !== null) return;
34
+
35
+ interruptedBy ??= signal;
36
+ if (turbo.pid === undefined) return;
37
+ try {
38
+ if (process.platform !== "win32") {
39
+ process.kill(-turbo.pid, signal);
40
+ } else {
41
+ turbo.kill(signal);
42
+ }
43
+ } catch {
44
+ turbo.kill(signal);
45
+ }
46
+ };
47
+ const forwardInterrupt = (): void => forwardSignal("SIGINT");
48
+ const forwardTerminate = (): void => forwardSignal("SIGTERM");
49
+
50
+ process.on("SIGINT", forwardInterrupt);
51
+ process.on("SIGTERM", forwardTerminate);
52
+
53
+ return await new Promise<number>((resolveStatus) => {
54
+ turbo.once("spawn", () => {
55
+ if (interruptedBy !== undefined) forwardSignal(interruptedBy);
56
+ });
57
+ turbo.once("error", (error) => {
58
+ spawnFailed = true;
59
+ process.stderr.write(`无法运行 Turbo boundaries:${error.message}\n`);
60
+ });
61
+ turbo.once("close", (code, signal) => {
62
+ process.off("SIGINT", forwardInterrupt);
63
+ process.off("SIGTERM", forwardTerminate);
64
+ resolveStatus(exitStatus(code, signal, interruptedBy, spawnFailed));
65
+ });
66
+ });
67
+ }
68
+
69
+ if (
70
+ process.argv[1] !== undefined &&
71
+ import.meta.url === pathToFileURL(resolve(process.argv[1])).href
72
+ ) {
73
+ process.exitCode = await runTurboBoundaries();
74
+ }