create-nowaki 0.1.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.
package/index.js ADDED
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env node
2
+ import { cp, mkdir, readdir } from "node:fs/promises";
3
+ import path from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+
6
+ const name = process.argv[2] ?? "nowaki-app";
7
+ const dest = path.resolve(process.cwd(), name);
8
+ const templateDir = path.join(
9
+ path.dirname(fileURLToPath(import.meta.url)),
10
+ "template",
11
+ );
12
+
13
+ // 既存の空でないディレクトリへの上書きは防ぐ
14
+ try {
15
+ const existing = await readdir(dest);
16
+ if (existing.length > 0) {
17
+ console.error(`✗ ディレクトリ "${name}" は空ではありません。中止します。`);
18
+ process.exit(1);
19
+ }
20
+ } catch {
21
+ // 存在しなければOK
22
+ }
23
+
24
+ await mkdir(dest, { recursive: true });
25
+ await cp(templateDir, dest, { recursive: true });
26
+
27
+ console.log(`\n🌀 Nowaki アプリを作成しました: ${name}\n`);
28
+ console.log("次のステップ:");
29
+ console.log(` cd ${name}`);
30
+ console.log(" pnpm install");
31
+ console.log(" nowaki dev\n");
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "create-nowaki",
3
+ "version": "0.1.0",
4
+ "description": "Scaffold a new Nowaki app",
5
+ "license": "MIT",
6
+ "author": "Voredge <dev@voredge.com>",
7
+ "homepage": "https://nowaki.dev",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/nowaki-dev/nowaki.git",
11
+ "directory": "packages/create-nowaki"
12
+ },
13
+ "bugs": "https://github.com/nowaki-dev/nowaki/issues",
14
+ "keywords": [
15
+ "nowaki",
16
+ "create",
17
+ "scaffold",
18
+ "starter",
19
+ "web-framework"
20
+ ],
21
+ "type": "module",
22
+ "bin": {
23
+ "create-nowaki": "index.js"
24
+ },
25
+ "files": [
26
+ "index.js",
27
+ "template"
28
+ ],
29
+ "engines": {
30
+ "node": ">=22"
31
+ },
32
+ "publishConfig": {
33
+ "access": "public"
34
+ }
35
+ }
@@ -0,0 +1,12 @@
1
+ import { useState } from "preact/hooks";
2
+
3
+ export default function Counter({ start = 0 }: { start?: number }) {
4
+ const [count, setCount] = useState(start);
5
+ return (
6
+ <div style="border:1px solid #ccc;padding:1rem;border-radius:8px;display:inline-flex;align-items:center;gap:1rem">
7
+ <button onClick={() => setCount((c) => c - 1)}>-</button>
8
+ <strong>{count}</strong>
9
+ <button onClick={() => setCount((c) => c + 1)}>+</button>
10
+ </div>
11
+ );
12
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "nowaki-app",
3
+ "private": true,
4
+ "type": "module",
5
+ "dependencies": {
6
+ "@nowaki-dev/runtime": "^0.1.0",
7
+ "preact": "^10.25.4",
8
+ "preact-render-to-string": "^6.5.13"
9
+ }
10
+ }
@@ -0,0 +1,19 @@
1
+ import Counter from "../islands/Counter.tsx";
2
+
3
+ export const title = "Nowaki App";
4
+
5
+ export const loader = async () => {
6
+ return { message: "Nowaki へようこそ 🌀" };
7
+ };
8
+
9
+ type Data = Awaited<ReturnType<typeof loader>>;
10
+
11
+ export default function Home({ data }: { data: Data }) {
12
+ return (
13
+ <main style="font-family:sans-serif;max-width:640px;margin:4rem auto">
14
+ <h1>{data.message}</h1>
15
+ <p>このカウンターだけがクライアントでハイドレートされる島です。</p>
16
+ <Counter start={0} />
17
+ </main>
18
+ );
19
+ }