@ykdz/template 0.0.12 → 0.0.14

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 (53) hide show
  1. package/node_modules/@ykdz/template-builtin-source/dist/templates/hono-api/projection.js +7 -34
  2. package/node_modules/@ykdz/template-builtin-source/dist/templates/registry.js +2 -0
  3. package/node_modules/@ykdz/template-builtin-source/dist/templates/rust-bin/projection.js +5 -3
  4. package/node_modules/@ykdz/template-builtin-source/dist/templates/ts-lib/projection.js +5 -32
  5. package/node_modules/@ykdz/template-builtin-source/dist/templates/vike-app/projection.d.ts +5 -0
  6. package/node_modules/@ykdz/template-builtin-source/dist/templates/vike-app/projection.js +57 -0
  7. package/node_modules/@ykdz/template-builtin-source/dist/templates/vue-app/projection.js +8 -36
  8. package/node_modules/@ykdz/template-builtin-source/dist/templates/vue-hono-app/projection.js +27 -74
  9. package/node_modules/@ykdz/template-builtin-source/templates/hono-api/turbo.json +8 -0
  10. package/node_modules/@ykdz/template-builtin-source/templates/preset-source.json +192 -4
  11. package/node_modules/@ykdz/template-builtin-source/templates/rust-bin/turbo.json +3 -0
  12. package/node_modules/@ykdz/template-builtin-source/templates/ts-lib/turbo.json +3 -0
  13. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/+server.ts +12 -0
  14. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/.env.example +1 -0
  15. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/.github/dependabot.yml +23 -0
  16. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/.github/workflows/check.yml +20 -0
  17. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/assets/logo.svg +1 -0
  18. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/components/CounterButton.vue +21 -0
  19. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/components/PageShell.vue +17 -0
  20. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/database/db.ts +14 -0
  21. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/database/queries/todos.ts +32 -0
  22. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/database/schema.ts +14 -0
  23. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/drizzle.config.ts +10 -0
  24. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/env.d.ts +6 -0
  25. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/global.d.ts +9 -0
  26. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/pages/+Head.vue +8 -0
  27. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/pages/+Layout.vue +9 -0
  28. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/pages/+config.ts +10 -0
  29. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/pages/index/+Page.telefunc.ts +13 -0
  30. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/pages/index/+Page.vue +89 -0
  31. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/pages/tailwind.css +7 -0
  32. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/playwright.config.ts +22 -0
  33. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/server/api.ts +5 -0
  34. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/server/app.ts +25 -0
  35. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/test/e2e/app.spec.ts +10 -0
  36. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/test/todos.test.ts +20 -0
  37. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/vite.config.ts +12 -0
  38. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/vitest.config.ts +8 -0
  39. package/node_modules/@ykdz/template-builtin-source/templates/vue-app/turbo.json +11 -0
  40. package/node_modules/@ykdz/template-builtin-source/templates/vue-hono-app/api/turbo.json +8 -0
  41. package/node_modules/@ykdz/template-builtin-source/templates/vue-hono-app/web/playwright.config.ts +1 -1
  42. package/node_modules/@ykdz/template-builtin-source/templates/vue-hono-app/web/src/api.ts +1 -4
  43. package/node_modules/@ykdz/template-builtin-source/templates/vue-hono-app/web/turbo.json +11 -0
  44. package/node_modules/@ykdz/template-core/dist/module-graph.d.ts +4 -0
  45. package/node_modules/@ykdz/template-core/dist/module-graph.js +64 -4
  46. package/node_modules/@ykdz/template-core/dist/package-addition.js +23 -34
  47. package/node_modules/@ykdz/template-core/dist/package-linking.js +14 -8
  48. package/node_modules/@ykdz/template-core/dist/pnpm-workspace.yaml +6 -0
  49. package/node_modules/@ykdz/template-core/dist/projection-capabilities.d.ts +1 -1
  50. package/node_modules/@ykdz/template-core/dist/projection-capabilities.js +355 -104
  51. package/node_modules/@ykdz/template-shared/dist/index.d.ts +9 -9
  52. package/node_modules/@ykdz/template-shared/dist/index.js +29 -11
  53. package/package.json +3 -3
@@ -0,0 +1,22 @@
1
+ import { defineConfig, devices } from "@playwright/test";
2
+
3
+ const previewUrl = "http://127.0.0.1:4173";
4
+
5
+ export default defineConfig({
6
+ testDir: "./test/e2e",
7
+ use: {
8
+ baseURL: previewUrl,
9
+ trace: "on-first-retry",
10
+ },
11
+ webServer: {
12
+ command: "PORT=4173 node dist/server/index.mjs",
13
+ reuseExistingServer: !process.env.CI,
14
+ url: previewUrl,
15
+ },
16
+ projects: [
17
+ {
18
+ name: "chromium",
19
+ use: { ...devices["Desktop Chrome"] },
20
+ },
21
+ ],
22
+ });
@@ -0,0 +1,5 @@
1
+ import { Hono } from "hono";
2
+
3
+ export const api = new Hono().get("/health", (c) =>
4
+ c.json({ ok: true, service: "vike-app" }),
5
+ );
@@ -0,0 +1,25 @@
1
+ import vike from "@vikejs/hono";
2
+ import { Hono } from "hono";
3
+ import { Telefunc } from "telefunc/node";
4
+
5
+ import { createDatabase } from "#/database/db";
6
+ import { api } from "#/server/api";
7
+
8
+ const telefunc = new Telefunc();
9
+
10
+ export const app = new Hono();
11
+
12
+ app.route("/api", api);
13
+
14
+ app.all("/_telefunc", async (c) => {
15
+ const response = await telefunc.serve({
16
+ request: c.req.raw,
17
+ context: {
18
+ db: createDatabase(),
19
+ },
20
+ });
21
+
22
+ return response ?? c.notFound();
23
+ });
24
+
25
+ vike(app);
@@ -0,0 +1,10 @@
1
+ import { expect, test } from "@playwright/test";
2
+
3
+ test("renders the Vike home page", async ({ page }) => {
4
+ await page.goto("/");
5
+ await expect(
6
+ page.getByRole("heading", { name: "Full-stack Vike app" }),
7
+ ).toBeVisible();
8
+ await page.getByRole("button", { name: "Count 0" }).click();
9
+ await expect(page.getByRole("button", { name: "Count 1" })).toBeVisible();
10
+ });
@@ -0,0 +1,20 @@
1
+ import { describe, expect, it } from "vitest";
2
+
3
+ import { createDatabase } from "#/database/db";
4
+ import { createTodo, listTodos } from "#/database/queries/todos";
5
+
6
+ describe("todo queries", () => {
7
+ it("creates and lists todos through Drizzle SQLite", async () => {
8
+ const db = createDatabase(":memory:");
9
+
10
+ db.run(
11
+ "CREATE TABLE todos (id integer PRIMARY KEY AUTOINCREMENT NOT NULL, title text NOT NULL, completed integer DEFAULT false NOT NULL, created_at text DEFAULT (CURRENT_TIMESTAMP) NOT NULL)",
12
+ );
13
+
14
+ await expect(createTodo(db, { title: "Ship" })).resolves.toMatchObject({
15
+ id: 1,
16
+ title: "Ship",
17
+ });
18
+ await expect(listTodos(db)).resolves.toMatchObject([{ title: "Ship" }]);
19
+ });
20
+ });
@@ -0,0 +1,12 @@
1
+ import tailwindcss from "@tailwindcss/vite";
2
+ import vue from "@vitejs/plugin-vue";
3
+ import telefunc from "telefunc/vite";
4
+ import vike from "vike/plugin";
5
+ import { defineConfig, type PluginOption } from "vite";
6
+
7
+ // oxlint-disable-next-line typescript/no-unsafe-type-assertion -- telefunc/vite currently types its plugin factory as any.
8
+ const telefuncPlugin = telefunc() as PluginOption;
9
+
10
+ export default defineConfig({
11
+ plugins: [vike(), telefuncPlugin, vue(), tailwindcss()],
12
+ });
@@ -0,0 +1,8 @@
1
+ import { defineConfig } from "vitest/config";
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ globals: true,
6
+ include: ["test/**/*.test.ts"],
7
+ },
8
+ });
@@ -0,0 +1,11 @@
1
+ {
2
+ "extends": ["//"],
3
+ "tasks": {
4
+ "build:run": {
5
+ "outputs": ["dist/**"]
6
+ },
7
+ "test:e2e:run": {
8
+ "cache": false
9
+ }
10
+ }
11
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": ["//"],
3
+ "tasks": {
4
+ "build:run": {
5
+ "outputs": ["dist/**"]
6
+ }
7
+ }
8
+ }
@@ -26,7 +26,7 @@ export default defineConfig({
26
26
  },
27
27
  webServer: [
28
28
  {
29
- command: `pnpm --dir ../api run build && PORT=${apiPort} pnpm --dir ../api run start`,
29
+ command: `pnpm --dir ../api run build:run && PORT=${apiPort} pnpm --dir ../api run start`,
30
30
  url: apiHealthUrl,
31
31
  reuseExistingServer: false,
32
32
  },
@@ -1,7 +1,4 @@
1
- // @template-anchor api-type-import-start
2
- import type { AppType } from "__API_PACKAGE__";
3
- import { hc } from "hono/client";
4
- // @template-anchor api-type-import-end
1
+ // @template-anchor api-type-imports
5
2
 
6
3
  const apiBaseUrl = import.meta.env.VITE_API_BASE_URL ?? "/";
7
4
 
@@ -0,0 +1,11 @@
1
+ {
2
+ "extends": ["//"],
3
+ "tasks": {
4
+ "build:run": {
5
+ "outputs": ["dist/**"]
6
+ },
7
+ "test:e2e:run": {
8
+ "cache": false
9
+ }
10
+ }
11
+ }
@@ -37,6 +37,10 @@ export type CheckPlan = {
37
37
  export type FixPlan = {
38
38
  readonly components: FixComponent[];
39
39
  };
40
+ export declare function checkComponentTaskName(component: CheckComponent): string;
41
+ export declare function fixComponentTaskName(component: FixComponent): string;
42
+ export declare function renderCheckLeafCommand(component: CheckComponent): string;
43
+ export declare function renderFixLeafCommand(component: FixComponent): string;
40
44
  export declare function renderRootCheckCommand(plan: CheckPlan): string;
41
45
  export declare function renderFixCommand(plan: FixPlan): string;
42
46
  export declare function renderPlaywrightBrowserInstallCommand(need: CheckEnvironmentNeed, options?: {
@@ -4,7 +4,61 @@ function renderTurboPackageFilter(owner) {
4
4
  }
5
5
  return `--filter './${owner.path}'`;
6
6
  }
7
- function renderCheckComponentCommand(component) {
7
+ export function checkComponentTaskName(component) {
8
+ return checkComponentTaskNames(component)[0] ?? "check:run";
9
+ }
10
+ function checkComponentTaskNames(component) {
11
+ switch (component.kind) {
12
+ case "typescript-typecheck":
13
+ case "turbo-package-typecheck":
14
+ return ["typecheck:run"];
15
+ case "oxc-lint":
16
+ case "cargo-clippy":
17
+ return ["lint:run"];
18
+ case "oxc-format-check":
19
+ case "rustfmt-check":
20
+ return ["format:check:run"];
21
+ case "build":
22
+ case "turbo-package-build":
23
+ return ["build:run"];
24
+ case "unit-test":
25
+ case "cargo-test":
26
+ case "turbo-package-test":
27
+ return ["test:run"];
28
+ case "e2e-test":
29
+ case "turbo-package-e2e-test":
30
+ return ["test:e2e:run"];
31
+ case "turbo-check":
32
+ case "turbo-package-check":
33
+ return [
34
+ "format:check:run",
35
+ "lint:run",
36
+ "typecheck:run",
37
+ "build:run",
38
+ "test:run",
39
+ "test:e2e:run",
40
+ ];
41
+ }
42
+ }
43
+ export function fixComponentTaskName(component) {
44
+ return fixComponentTaskNames(component)[0] ?? "fix:run";
45
+ }
46
+ function fixComponentTaskNames(component) {
47
+ switch (component.kind) {
48
+ case "oxc-format-write":
49
+ case "rustfmt-write":
50
+ return ["format:write:run"];
51
+ case "oxc-lint-fix":
52
+ return ["lint:fix:run"];
53
+ case "turbo-fix":
54
+ case "turbo-package-fix":
55
+ return ["format:write:run", "lint:fix:run"];
56
+ }
57
+ }
58
+ function uniqueTaskNames(taskNames) {
59
+ return [...new Set(taskNames)];
60
+ }
61
+ export function renderCheckLeafCommand(component) {
8
62
  switch (component.kind) {
9
63
  case "typescript-typecheck":
10
64
  return "pnpm run typecheck";
@@ -38,7 +92,7 @@ function renderCheckComponentCommand(component) {
38
92
  return "cargo test --workspace";
39
93
  }
40
94
  }
41
- function renderFixComponentCommand(component) {
95
+ export function renderFixLeafCommand(component) {
42
96
  switch (component.kind) {
43
97
  case "oxc-format-write":
44
98
  return "pnpm run format:write";
@@ -53,10 +107,16 @@ function renderFixComponentCommand(component) {
53
107
  }
54
108
  }
55
109
  export function renderRootCheckCommand(plan) {
56
- return plan.components.map(renderCheckComponentCommand).join(" && ");
110
+ return `turbo run ${uniqueTaskNames([
111
+ ...plan.components.flatMap(checkComponentTaskNames),
112
+ "check:run",
113
+ ]).join(" ")}`;
57
114
  }
58
115
  export function renderFixCommand(plan) {
59
- return plan.components.map(renderFixComponentCommand).join(" && ");
116
+ return `turbo run ${uniqueTaskNames([
117
+ ...plan.components.flatMap(fixComponentTaskNames),
118
+ "fix:run",
119
+ ]).join(" ")}`;
60
120
  }
61
121
  function playwrightBrowserInstallArgs(need, options = {}) {
62
122
  const installArgs = [
@@ -155,7 +155,8 @@ async function assertPackageLinkIntentConsumersAreTypeScriptBoundaries(options)
155
155
  const hasTypeScriptPackageShape = isRecord(manifest) &&
156
156
  manifest.type === "module" &&
157
157
  isRecord(scripts) &&
158
- typeof scripts.typecheck === "string";
158
+ (typeof scripts.typecheck === "string" ||
159
+ typeof scripts["typecheck:run"] === "string");
159
160
  if (hasTypeScriptPackageShape) {
160
161
  continue;
161
162
  }
@@ -380,43 +381,20 @@ async function consumerManifestUpdatesForPackageLinkIntents(options) {
380
381
  }
381
382
  return updates;
382
383
  }
383
- function workspacePackageGlobsFromBlueprint(blueprint) {
384
- const globs = [];
385
- for (const packageDefinition of blueprint.packages ?? []) {
386
- const [workspaceDir] = packageDefinition.path.split("/");
387
- if (!workspaceDir) {
388
- throw new Error(`Cannot update root Package Addition scripts: invalid package path ${packageDefinition.path}`);
389
- }
390
- const glob = `${workspaceDir}/*`;
391
- if (!globs.includes(glob)) {
392
- globs.push(glob);
393
- }
394
- }
395
- return globs;
396
- }
397
- function turboPackageTaskCommand(task, workspacePackageGlobs) {
398
- const filters = workspacePackageGlobs.map((glob) => `--filter './${glob}'`);
399
- return [`turbo run ${task}`, ...filters].join(" ");
400
- }
401
- function rootScriptWithTurboPackageTask(script, task, workspacePackageGlobs) {
402
- const commands = script.split(" && ");
403
- const turboCommandIndex = commands.findIndex((command) => command.startsWith(`turbo run ${task}`));
404
- if (turboCommandIndex === -1) {
405
- throw new Error(`Cannot update root Package Addition scripts: scripts.${task} must run Turbo package tasks`);
406
- }
407
- commands[turboCommandIndex] = turboPackageTaskCommand(task, workspacePackageGlobs);
408
- return commands.join(" && ");
409
- }
410
384
  function rootScriptWithTurboPackageTasks(options) {
411
385
  const rootCommands = options.script
412
386
  .split(" && ")
413
387
  .filter((command) => !command.startsWith("turbo run "));
414
- const turboCommands = options.taskNames.map((taskName) => turboPackageTaskCommand(taskName, options.workspacePackageGlobs));
415
- return [...rootCommands, ...turboCommands].join(" && ");
388
+ const turboCommand = [
389
+ "turbo run",
390
+ ...options.taskNames,
391
+ ...(options.concurrency === undefined ? [] : ["--concurrency=1"]),
392
+ ].join(" ");
393
+ return [...rootCommands, turboCommand].join(" && ");
416
394
  }
417
395
  function rootPackageJsonWithPackageTaskFilters(input, blueprint) {
396
+ void blueprint;
418
397
  assertRootPackageJson(input);
419
- const workspacePackageGlobs = workspacePackageGlobsFromBlueprint(blueprint);
420
398
  const checkScript = input.scripts.check;
421
399
  const fixScript = input.scripts.fix;
422
400
  if (checkScript === undefined || fixScript === undefined) {
@@ -428,10 +406,21 @@ function rootPackageJsonWithPackageTaskFilters(input, blueprint) {
428
406
  ...input.scripts,
429
407
  check: rootScriptWithTurboPackageTasks({
430
408
  script: checkScript,
431
- taskNames: ["check"],
432
- workspacePackageGlobs,
409
+ taskNames: [
410
+ "format:check:run",
411
+ "lint:run",
412
+ "typecheck:run",
413
+ "build:run",
414
+ "test:run",
415
+ "test:e2e:run",
416
+ "check:run",
417
+ ],
418
+ concurrency: 1,
419
+ }),
420
+ fix: rootScriptWithTurboPackageTasks({
421
+ script: fixScript,
422
+ taskNames: ["format:write:run", "lint:fix:run", "fix:run"],
433
423
  }),
434
- fix: rootScriptWithTurboPackageTask(fixScript, "fix", workspacePackageGlobs),
435
424
  },
436
425
  };
437
426
  }
@@ -67,16 +67,22 @@ export function planPackageLinks(definitions, intents = []) {
67
67
  }
68
68
  export function packageTurboTasks({ dependencyBuildsRequired, }) {
69
69
  return {
70
- typecheck: { dependsOn: ["^typecheck"] },
71
- build: dependencyBuildsRequired
72
- ? { dependsOn: ["^build"], outputs: ["dist/**"] }
70
+ "format:check:run": {},
71
+ "format:write:run": { cache: false },
72
+ "lint:run": {},
73
+ "lint:fix:run": { cache: false },
74
+ "typecheck:run": { dependsOn: ["^typecheck:run"] },
75
+ "build:run": dependencyBuildsRequired
76
+ ? { dependsOn: ["^build:run"], outputs: ["dist/**"] }
73
77
  : { outputs: ["dist/**"] },
74
- test: { dependsOn: ["^typecheck"] },
75
- "test:e2e": {
76
- dependsOn: dependencyBuildsRequired ? ["build", "^build"] : ["build"],
78
+ "test:run": { dependsOn: ["^typecheck:run"] },
79
+ "test:e2e:run": {
80
+ dependsOn: dependencyBuildsRequired
81
+ ? ["build:run", "^build:run"]
82
+ : ["build:run"],
77
83
  },
78
- check: { dependsOn: ["typecheck", "build", "test"] },
79
- fix: { cache: false },
84
+ "check:run": { cache: false },
85
+ "fix:run": { cache: false },
80
86
  };
81
87
  }
82
88
  export function packageManifestExposureFields(exposure) {
@@ -10,7 +10,10 @@ catalog:
10
10
  "@types/node": ^24.0.0
11
11
  "@types/web-bluetooth": ^0.0.21
12
12
  "@vitejs/plugin-vue": ^6.0.7
13
+ "@vikejs/hono": ^0.2.1
13
14
  "@vue/tsconfig": ^0.9.1
15
+ drizzle-kit: 1.0.0-beta.22
16
+ drizzle-orm: 1.0.0-beta.22
14
17
  execa: ^9.6.1
15
18
  hono: ^4.12.27
16
19
  oxfmt: ^0.57.0
@@ -18,12 +21,15 @@ catalog:
18
21
  oxlint-tsgolint: ^0.24.0
19
22
  pinia: ^3.0.4
20
23
  tailwindcss: ^4.3.2
24
+ telefunc: ^0.2.21
21
25
  tsc-alias: ^1.8.17
22
26
  tsx: ^4.22.4
23
27
  turbo: 2.10.2
24
28
  typescript: ^6.0.3
25
29
  valibot: ^1.4.2
26
30
  vite: ^8.1.2
31
+ vike: ^0.4.260
32
+ vike-vue: ^0.9.12
27
33
  vitest: ^4.1.9
28
34
  vue: ^3.5.39
29
35
  vue-tsc: ^3.3.6
@@ -5,7 +5,7 @@ import type { PresetBlueprintOptions, PresetPackageAdditionOptions, PresetPackag
5
5
  import type { PresetSourceManifestPreset } from "./preset-source.js";
6
6
  export { normalizePresetProjectionDeclaration, projectionCapabilityIssues, validateProjectionCapabilities, };
7
7
  export type { GithubMaintenanceCapabilityDeclaration, NodePnpmDevcontainerCapabilityDeclaration, OxcFormatLintCapabilityDeclaration, PresetProjectionDeclaration, ProjectionCapabilityDeclaration, ProjectionCapabilityKind, RustBinaryWorkspaceCapabilityDeclaration, StrictTypescriptRootCapabilityDeclaration, WorkspaceLibraryPackageCapabilityDeclaration, WorkspaceNodePackageDeclaration, WorkspaceNodePackageKind, WorkspaceNodePackagesCapabilityDeclaration, WorkspaceNodePackagePath, };
8
- export type ProjectionSourcePreset = "hono-api" | "rust-bin" | "ts-lib" | "vue-app" | "vue-hono-app";
8
+ export type ProjectionSourcePreset = "hono-api" | "rust-bin" | "ts-lib" | "vike-app" | "vue-app" | "vue-hono-app";
9
9
  export type PresetProjectionSourceRoots = {
10
10
  readonly preset: (sourcePreset: ProjectionSourcePreset) => string;
11
11
  readonly sharedOxc: () => string;