@ykdz/template 0.0.0

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 (64) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +35 -0
  3. package/dist/cli.d.ts +3 -0
  4. package/dist/cli.d.ts.map +1 -0
  5. package/dist/cli.js +353 -0
  6. package/dist/declarations.d.ts +166 -0
  7. package/dist/declarations.d.ts.map +1 -0
  8. package/dist/declarations.js +340 -0
  9. package/dist/hono-api.d.ts +2 -0
  10. package/dist/hono-api.d.ts.map +1 -0
  11. package/dist/hono-api.js +247 -0
  12. package/dist/package-addition.d.ts +7 -0
  13. package/dist/package-addition.d.ts.map +1 -0
  14. package/dist/package-addition.js +580 -0
  15. package/dist/renderer.d.ts +44 -0
  16. package/dist/renderer.d.ts.map +1 -0
  17. package/dist/renderer.js +379 -0
  18. package/dist/rust-bin.d.ts +2 -0
  19. package/dist/rust-bin.d.ts.map +1 -0
  20. package/dist/rust-bin.js +206 -0
  21. package/dist/ts-lib.d.ts +2 -0
  22. package/dist/ts-lib.d.ts.map +1 -0
  23. package/dist/ts-lib.js +220 -0
  24. package/dist/vue-app.d.ts +2 -0
  25. package/dist/vue-app.d.ts.map +1 -0
  26. package/dist/vue-app.js +339 -0
  27. package/dist/vue-hono-app.d.ts +4 -0
  28. package/dist/vue-hono-app.d.ts.map +1 -0
  29. package/dist/vue-hono-app.js +484 -0
  30. package/package.json +54 -0
  31. package/templates/hono-api/src/app.ts +5 -0
  32. package/templates/hono-api/src/server.ts +14 -0
  33. package/templates/hono-api/test/app.test.ts +10 -0
  34. package/templates/hono-api/vitest.config.ts +13 -0
  35. package/templates/rust-bin/src/main.rs +18 -0
  36. package/templates/ts-lib/src/index.ts +7 -0
  37. package/templates/vue-app/env.d.ts +1 -0
  38. package/templates/vue-app/index.html +12 -0
  39. package/templates/vue-app/playwright.config.ts +20 -0
  40. package/templates/vue-app/src/App.vue +33 -0
  41. package/templates/vue-app/src/main.ts +6 -0
  42. package/templates/vue-app/src/stores/counter.ts +12 -0
  43. package/templates/vue-app/src/style.css +1 -0
  44. package/templates/vue-app/test/app.test.ts +13 -0
  45. package/templates/vue-app/test/e2e/app.spec.ts +9 -0
  46. package/templates/vue-app/vite.config.ts +13 -0
  47. package/templates/vue-app/vitest.config.ts +14 -0
  48. package/templates/vue-hono-app/api/src/index.ts +3 -0
  49. package/templates/vue-hono-app/api/src/runtime.ts +5 -0
  50. package/templates/vue-hono-app/api/src/server.ts +14 -0
  51. package/templates/vue-hono-app/api/test/app.test.ts +10 -0
  52. package/templates/vue-hono-app/api/vitest.config.ts +7 -0
  53. package/templates/vue-hono-app/web/env.d.ts +9 -0
  54. package/templates/vue-hono-app/web/index.html +12 -0
  55. package/templates/vue-hono-app/web/playwright.config.ts +21 -0
  56. package/templates/vue-hono-app/web/src/App.vue +42 -0
  57. package/templates/vue-hono-app/web/src/api.ts +8 -0
  58. package/templates/vue-hono-app/web/src/main.ts +6 -0
  59. package/templates/vue-hono-app/web/src/stores/counter.ts +12 -0
  60. package/templates/vue-hono-app/web/src/style.css +1 -0
  61. package/templates/vue-hono-app/web/test/app.test.ts +13 -0
  62. package/templates/vue-hono-app/web/test/e2e/app.spec.ts +10 -0
  63. package/templates/vue-hono-app/web/vite.config.ts +29 -0
  64. package/templates/vue-hono-app/web/vitest.config.ts +16 -0
@@ -0,0 +1,6 @@
1
+ import { createPinia } from "pinia";
2
+ import { createApp } from "vue";
3
+ import App from "./App.vue";
4
+ import "./style.css";
5
+
6
+ createApp(App).use(createPinia()).mount("#app");
@@ -0,0 +1,12 @@
1
+ import { defineStore } from "pinia";
2
+ import { ref } from "vue";
3
+
4
+ export const useCounterStore = defineStore("counter", () => {
5
+ const count = ref(0);
6
+
7
+ function increment(): void {
8
+ count.value += 1;
9
+ }
10
+
11
+ return { count, increment };
12
+ });
@@ -0,0 +1 @@
1
+ @import "tailwindcss";
@@ -0,0 +1,13 @@
1
+ import { createPinia, setActivePinia } from "pinia";
2
+ import { useCounterStore } from "@/stores/counter";
3
+
4
+ describe("counter store", () => {
5
+ it("increments the count", () => {
6
+ setActivePinia(createPinia());
7
+ const counter = useCounterStore();
8
+
9
+ counter.increment();
10
+
11
+ expect(counter.count).toBe(1);
12
+ });
13
+ });
@@ -0,0 +1,9 @@
1
+ import { expect, test } from "@playwright/test";
2
+
3
+ test("renders and updates the counter", async ({ page }) => {
4
+ await page.goto("/");
5
+
6
+ await expect(page.getByRole("heading", { name: "Vue, Vite, Tailwind, and Pinia" })).toBeVisible();
7
+ await page.getByRole("button", { name: "Count is 0" }).click();
8
+ await expect(page.getByRole("button", { name: "Count is 1" })).toBeVisible();
9
+ });
@@ -0,0 +1,13 @@
1
+ import vue from "@vitejs/plugin-vue";
2
+ import tailwindcss from "@tailwindcss/vite";
3
+ import { fileURLToPath, URL } from "node:url";
4
+ import { defineConfig } from "vite";
5
+
6
+ export default defineConfig({
7
+ plugins: [vue(), tailwindcss()],
8
+ resolve: {
9
+ alias: {
10
+ "@": fileURLToPath(new URL("./src", import.meta.url))
11
+ }
12
+ }
13
+ });
@@ -0,0 +1,14 @@
1
+ import { fileURLToPath, URL } from "node:url";
2
+ import { defineConfig } from "vitest/config";
3
+
4
+ export default defineConfig({
5
+ resolve: {
6
+ alias: {
7
+ "@": fileURLToPath(new URL("./src", import.meta.url))
8
+ }
9
+ },
10
+ test: {
11
+ exclude: ["test/e2e/**", "node_modules/**", "dist/**"],
12
+ globals: true
13
+ }
14
+ });
@@ -0,0 +1,3 @@
1
+ import type { app } from "./runtime.js";
2
+
3
+ export type AppType = typeof app;
@@ -0,0 +1,5 @@
1
+ import { Hono } from "hono";
2
+
3
+ export const app = new Hono()
4
+ .basePath("/api")
5
+ .get("/health", (context) => context.json({ status: "ok" as const }));
@@ -0,0 +1,14 @@
1
+ import { serve } from "@hono/node-server";
2
+ import { app } from "./runtime.js";
3
+
4
+ const port = Number(process.env.PORT ?? 3000);
5
+
6
+ serve(
7
+ {
8
+ fetch: app.fetch,
9
+ port
10
+ },
11
+ (info) => {
12
+ console.log(`Hono API listening on http://localhost:${info.port}`);
13
+ }
14
+ );
@@ -0,0 +1,10 @@
1
+ import { app } from "../src/runtime.js";
2
+
3
+ describe("Hono API", () => {
4
+ it("responds to the health route", async () => {
5
+ const response = await app.request("/api/health");
6
+
7
+ expect(response.status).toBe(200);
8
+ await expect(response.json()).resolves.toEqual({ status: "ok" });
9
+ });
10
+ });
@@ -0,0 +1,7 @@
1
+ import { defineConfig } from "vitest/config";
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ globals: true
6
+ }
7
+ });
@@ -0,0 +1,9 @@
1
+ /// <reference types="vite/client" />
2
+
3
+ interface ImportMetaEnv {
4
+ readonly VITE_API_BASE_URL?: string;
5
+ }
6
+
7
+ interface ImportMeta {
8
+ readonly env: ImportMetaEnv;
9
+ }
@@ -0,0 +1,12 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Vue Hono app</title>
7
+ </head>
8
+ <body>
9
+ <div id="app"></div>
10
+ <script type="module" src="/src/main.ts"></script>
11
+ </body>
12
+ </html>
@@ -0,0 +1,21 @@
1
+ import { defineConfig, devices } from "@playwright/test";
2
+
3
+ export default defineConfig({
4
+ testDir: "./test/e2e",
5
+ use: {
6
+ baseURL: "http://localhost:4173",
7
+ ...devices["Desktop Chrome"]
8
+ },
9
+ webServer: [
10
+ {
11
+ command: "pnpm --dir ../api run build && PORT=8787 pnpm --dir ../api run start",
12
+ port: 8787,
13
+ reuseExistingServer: false
14
+ },
15
+ {
16
+ command: "VITE_API_BASE_URL=http://localhost:8787 pnpm run preview -- --host 127.0.0.1",
17
+ port: 4173,
18
+ reuseExistingServer: false
19
+ }
20
+ ]
21
+ });
@@ -0,0 +1,42 @@
1
+ <script setup lang="ts">
2
+ import { usePreferredDark } from "@vueuse/core";
3
+ import { storeToRefs } from "pinia";
4
+ import { computed, onMounted, ref } from "vue";
5
+ import { api } from "@/api";
6
+ import { useCounterStore } from "@/stores/counter";
7
+
8
+ const counter = useCounterStore();
9
+ const { count } = storeToRefs(counter);
10
+ const prefersDark = usePreferredDark();
11
+ const themeLabel = computed(() => (prefersDark.value ? "dark" : "light"));
12
+ const apiStatus = ref("checking");
13
+
14
+ onMounted(async () => {
15
+ const response = await api.api.health.$get();
16
+ const body = await response.json();
17
+ apiStatus.value = body.status;
18
+ });
19
+ </script>
20
+
21
+ <template>
22
+ <main class="min-h-screen bg-slate-950 text-white">
23
+ <section class="mx-auto flex min-h-screen max-w-3xl flex-col justify-center px-6 py-16">
24
+ <p class="text-sm font-medium uppercase tracking-wide text-cyan-300">Vue Hono app preset</p>
25
+ <h1 class="mt-4 text-4xl font-semibold">Vue, Hono, and typed RPC</h1>
26
+ <p class="mt-4 text-lg text-slate-300">
27
+ This generated workspace typechecks the web package against the API contract.
28
+ </p>
29
+ <div class="mt-8 flex flex-wrap items-center gap-4">
30
+ <button
31
+ class="rounded bg-cyan-300 px-4 py-2 font-semibold text-slate-950 hover:bg-cyan-200"
32
+ type="button"
33
+ @click="counter.increment()"
34
+ >
35
+ Count is {{ count }}
36
+ </button>
37
+ <span class="text-sm text-slate-400">Preferred theme: {{ themeLabel }}</span>
38
+ <span class="text-sm text-slate-400">API status: {{ apiStatus }}</span>
39
+ </div>
40
+ </section>
41
+ </main>
42
+ </template>
@@ -0,0 +1,8 @@
1
+ import { hc } from "hono/client";
2
+ // @template-anchor api-type-import-start
3
+ import type { AppType } from "__API_PACKAGE__";
4
+ // @template-anchor api-type-import-end
5
+
6
+ const apiBaseUrl = import.meta.env.VITE_API_BASE_URL ?? "/";
7
+
8
+ export const api = hc<AppType>(apiBaseUrl);
@@ -0,0 +1,6 @@
1
+ import { createPinia } from "pinia";
2
+ import { createApp } from "vue";
3
+ import App from "./App.vue";
4
+ import "./style.css";
5
+
6
+ createApp(App).use(createPinia()).mount("#app");
@@ -0,0 +1,12 @@
1
+ import { defineStore } from "pinia";
2
+ import { ref } from "vue";
3
+
4
+ export const useCounterStore = defineStore("counter", () => {
5
+ const count = ref(0);
6
+
7
+ function increment(): void {
8
+ count.value += 1;
9
+ }
10
+
11
+ return { count, increment };
12
+ });
@@ -0,0 +1 @@
1
+ @import "tailwindcss";
@@ -0,0 +1,13 @@
1
+ import { createPinia, setActivePinia } from "pinia";
2
+ import { useCounterStore } from "@/stores/counter";
3
+
4
+ describe("counter store", () => {
5
+ it("increments the count", () => {
6
+ setActivePinia(createPinia());
7
+ const counter = useCounterStore();
8
+
9
+ counter.increment();
10
+
11
+ expect(counter.count).toBe(1);
12
+ });
13
+ });
@@ -0,0 +1,10 @@
1
+ import { expect, test } from "@playwright/test";
2
+
3
+ test("renders the web app and calls the API", async ({ page }) => {
4
+ await page.goto("/");
5
+
6
+ await expect(page.getByRole("heading", { name: "Vue, Hono, and typed RPC" })).toBeVisible();
7
+ await expect(page.getByText("API status: ok")).toBeVisible();
8
+ await page.getByRole("button", { name: "Count is 0" }).click();
9
+ await expect(page.getByRole("button", { name: "Count is 1" })).toBeVisible();
10
+ });
@@ -0,0 +1,29 @@
1
+ import vue from "@vitejs/plugin-vue";
2
+ import tailwindcss from "@tailwindcss/vite";
3
+ import { fileURLToPath, URL } from "node:url";
4
+ import { defineConfig, loadEnv } from "vite";
5
+
6
+ export default defineConfig(({ mode }) => {
7
+ const env = loadEnv(mode, process.cwd(), "");
8
+ const apiBaseUrl =
9
+ process.env.VITE_API_BASE_URL ?? env.VITE_API_BASE_URL ?? "http://localhost:3000";
10
+
11
+ return {
12
+ plugins: [vue(), tailwindcss()],
13
+ resolve: {
14
+ alias: {
15
+ "@": fileURLToPath(new URL("./src", import.meta.url))
16
+ }
17
+ },
18
+ server: {
19
+ proxy: {
20
+ "/api": apiBaseUrl
21
+ }
22
+ },
23
+ preview: {
24
+ proxy: {
25
+ "/api": apiBaseUrl
26
+ }
27
+ }
28
+ };
29
+ });
@@ -0,0 +1,16 @@
1
+ import vue from "@vitejs/plugin-vue";
2
+ import { fileURLToPath, URL } from "node:url";
3
+ import { defineConfig } from "vitest/config";
4
+
5
+ export default defineConfig({
6
+ plugins: [vue()],
7
+ resolve: {
8
+ alias: {
9
+ "@": fileURLToPath(new URL("./src", import.meta.url))
10
+ }
11
+ },
12
+ test: {
13
+ exclude: ["test/e2e/**", "node_modules/**", "dist/**"],
14
+ globals: true
15
+ }
16
+ });