@ykdz/template 0.0.11 → 0.0.13

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 (42) hide show
  1. package/node_modules/@ykdz/template-builtin-source/dist/templates/registry.js +2 -0
  2. package/node_modules/@ykdz/template-builtin-source/dist/templates/vike-app/projection.d.ts +5 -0
  3. package/node_modules/@ykdz/template-builtin-source/dist/templates/vike-app/projection.js +57 -0
  4. package/node_modules/@ykdz/template-builtin-source/dist/templates/vue-hono-app/projection.js +4 -7
  5. package/node_modules/@ykdz/template-builtin-source/templates/hono-api/vitest.config.ts +1 -0
  6. package/node_modules/@ykdz/template-builtin-source/templates/preset-source.json +176 -0
  7. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/+server.ts +12 -0
  8. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/.env.example +1 -0
  9. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/.github/dependabot.yml +23 -0
  10. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/.github/workflows/check.yml +20 -0
  11. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/assets/logo.svg +1 -0
  12. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/components/CounterButton.vue +21 -0
  13. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/components/PageShell.vue +17 -0
  14. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/database/db.ts +14 -0
  15. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/database/queries/todos.ts +32 -0
  16. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/database/schema.ts +14 -0
  17. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/drizzle.config.ts +10 -0
  18. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/env.d.ts +6 -0
  19. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/global.d.ts +9 -0
  20. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/pages/+Head.vue +8 -0
  21. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/pages/+Layout.vue +9 -0
  22. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/pages/+config.ts +10 -0
  23. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/pages/index/+Page.telefunc.ts +13 -0
  24. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/pages/index/+Page.vue +89 -0
  25. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/pages/tailwind.css +7 -0
  26. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/playwright.config.ts +22 -0
  27. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/server/api.ts +5 -0
  28. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/server/app.ts +25 -0
  29. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/test/e2e/app.spec.ts +10 -0
  30. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/test/todos.test.ts +20 -0
  31. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/vite.config.ts +12 -0
  32. package/node_modules/@ykdz/template-builtin-source/templates/vike-app/vitest.config.ts +8 -0
  33. package/node_modules/@ykdz/template-builtin-source/templates/vue-hono-app/api/vitest.config.ts +7 -0
  34. package/node_modules/@ykdz/template-builtin-source/templates/vue-hono-app/web/playwright.config.ts +23 -7
  35. package/node_modules/@ykdz/template-builtin-source/templates/vue-hono-app/web/src/api.ts +1 -4
  36. package/node_modules/@ykdz/template-core/dist/package-addition.js +5 -21
  37. package/node_modules/@ykdz/template-core/dist/pnpm-workspace.yaml +6 -0
  38. package/node_modules/@ykdz/template-core/dist/projection-capabilities.d.ts +1 -1
  39. package/node_modules/@ykdz/template-core/dist/projection-capabilities.js +227 -36
  40. package/node_modules/@ykdz/template-shared/dist/index.d.ts +9 -9
  41. package/node_modules/@ykdz/template-shared/dist/index.js +29 -11
  42. 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
+ });
@@ -1,6 +1,13 @@
1
+ import { fileURLToPath, URL } from "node:url";
2
+
1
3
  import { defineConfig } from "vitest/config";
2
4
 
3
5
  export default defineConfig({
6
+ resolve: {
7
+ alias: {
8
+ "#": fileURLToPath(new URL("./src", import.meta.url)),
9
+ },
10
+ },
4
11
  test: {
5
12
  globals: true,
6
13
  },
@@ -1,22 +1,38 @@
1
1
  import { defineConfig, devices } from "@playwright/test";
2
2
 
3
+ function workspacePortOffset(): number {
4
+ let hash = 0;
5
+
6
+ for (const character of process.cwd()) {
7
+ hash = (hash * 31 + character.charCodeAt(0)) % 5_000;
8
+ }
9
+
10
+ return hash * 2;
11
+ }
12
+
13
+ const fallbackApiPort = 43_000 + workspacePortOffset();
14
+ const fallbackWebPort = fallbackApiPort + 1;
15
+ const apiPort = Number(process.env.PLAYWRIGHT_API_PORT ?? fallbackApiPort);
16
+ const webPort = Number(process.env.PLAYWRIGHT_WEB_PORT ?? fallbackWebPort);
17
+ const apiBaseUrl = `http://127.0.0.1:${apiPort}`;
18
+ const apiHealthUrl = `${apiBaseUrl}/api/health`;
19
+ const webBaseUrl = `http://127.0.0.1:${webPort}`;
20
+
3
21
  export default defineConfig({
4
22
  testDir: "./test/e2e",
5
23
  use: {
6
- baseURL: "http://localhost:4173",
24
+ baseURL: webBaseUrl,
7
25
  ...devices["Desktop Chrome"],
8
26
  },
9
27
  webServer: [
10
28
  {
11
- command:
12
- "pnpm --dir ../api run build && PORT=8787 pnpm --dir ../api run start",
13
- port: 8787,
29
+ command: `pnpm --dir ../api run build && PORT=${apiPort} pnpm --dir ../api run start`,
30
+ url: apiHealthUrl,
14
31
  reuseExistingServer: false,
15
32
  },
16
33
  {
17
- command:
18
- "VITE_API_BASE_URL=http://localhost:8787 pnpm run preview -- --host 127.0.0.1",
19
- port: 4173,
34
+ command: `VITE_API_BASE_URL=${apiBaseUrl} pnpm run preview --host 127.0.0.1 --port ${webPort}`,
35
+ url: webBaseUrl,
20
36
  reuseExistingServer: false,
21
37
  },
22
38
  ],
@@ -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
 
@@ -396,7 +396,8 @@ function workspacePackageGlobsFromBlueprint(blueprint) {
396
396
  }
397
397
  function turboPackageTaskCommand(task, workspacePackageGlobs) {
398
398
  const filters = workspacePackageGlobs.map((glob) => `--filter './${glob}'`);
399
- return [`turbo run ${task}`, ...filters].join(" ");
399
+ const concurrency = task === "check" ? ["--concurrency=1"] : [];
400
+ return [`turbo run ${task}`, ...concurrency, ...filters].join(" ");
400
401
  }
401
402
  function rootScriptWithTurboPackageTask(script, task, workspacePackageGlobs) {
402
403
  const commands = script.split(" && ");
@@ -407,21 +408,6 @@ function rootScriptWithTurboPackageTask(script, task, workspacePackageGlobs) {
407
408
  commands[turboCommandIndex] = turboPackageTaskCommand(task, workspacePackageGlobs);
408
409
  return commands.join(" && ");
409
410
  }
410
- function turboTaskNamesForPackageManifests(manifests) {
411
- const taskNames = [];
412
- for (const taskName of [
413
- "typecheck",
414
- "build",
415
- "test",
416
- "test:e2e",
417
- "check",
418
- ]) {
419
- if (manifests.some((manifest) => typeof manifest.scripts?.[taskName] === "string")) {
420
- taskNames.push(taskName);
421
- }
422
- }
423
- return taskNames;
424
- }
425
411
  function rootScriptWithTurboPackageTasks(options) {
426
412
  const rootCommands = options.script
427
413
  .split(" && ")
@@ -429,11 +415,9 @@ function rootScriptWithTurboPackageTasks(options) {
429
415
  const turboCommands = options.taskNames.map((taskName) => turboPackageTaskCommand(taskName, options.workspacePackageGlobs));
430
416
  return [...rootCommands, ...turboCommands].join(" && ");
431
417
  }
432
- function rootPackageJsonWithPackageTaskFilters(input, blueprint, packageManifests) {
418
+ function rootPackageJsonWithPackageTaskFilters(input, blueprint) {
433
419
  assertRootPackageJson(input);
434
420
  const workspacePackageGlobs = workspacePackageGlobsFromBlueprint(blueprint);
435
- const taskNames = turboTaskNamesForPackageManifests(packageManifests);
436
- const rootCheckTaskNames = taskNames.filter((taskName) => taskName !== "test:e2e");
437
421
  const checkScript = input.scripts.check;
438
422
  const fixScript = input.scripts.fix;
439
423
  if (checkScript === undefined || fixScript === undefined) {
@@ -445,7 +429,7 @@ function rootPackageJsonWithPackageTaskFilters(input, blueprint, packageManifest
445
429
  ...input.scripts,
446
430
  check: rootScriptWithTurboPackageTasks({
447
431
  script: checkScript,
448
- taskNames: rootCheckTaskNames,
432
+ taskNames: ["check"],
449
433
  workspacePackageGlobs,
450
434
  }),
451
435
  fix: rootScriptWithTurboPackageTask(fixScript, "fix", workspacePackageGlobs),
@@ -539,7 +523,7 @@ async function planRootUpdates(root, blueprint, packageName, packagePath, packag
539
523
  manifestOverrides,
540
524
  });
541
525
  const workspaceText = pnpmWorkspaceYamlWithCatalogDependencies(workspaceTextWithPackageGlob(await readFile(path.join(root, "pnpm-workspace.yaml"), "utf8"), workspacePackageGlob), catalogDependenciesWithSharedOxcRuntimeDependencies(catalogDependencies, requiresSharedOxcConfiguration));
542
- const rootPackageJson = rootPackageJsonWithPackageTaskFilters(await readJson(path.join(root, "package.json")), nextBlueprint, packageManifests);
526
+ const rootPackageJson = rootPackageJsonWithPackageTaskFilters(await readJson(path.join(root, "package.json")), nextBlueprint);
543
527
  return {
544
528
  blueprint: nextBlueprint,
545
529
  rootPackageJson: rootPackageJsonWithSharedOxcRuntimeDependencies(rootPackageJson, requiresSharedOxcConfiguration),
@@ -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;