create-kudzu 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.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +11 -0
  3. package/index.mjs +83 -0
  4. package/package.json +34 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 kudzujs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # create-kudzu
2
+
3
+ Create a Kudzu project:
4
+
5
+ ```bash
6
+ npm create kudzu@latest my-app
7
+ cd my-app
8
+ npm run dev
9
+ ```
10
+
11
+ Use `--no-install` to create the files without installing dependencies.
package/index.mjs ADDED
@@ -0,0 +1,83 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { spawnSync } from "node:child_process"
4
+ import { mkdir, readdir, writeFile } from "node:fs/promises"
5
+ import { basename, resolve } from "node:path"
6
+
7
+ const args = process.argv.slice(2)
8
+ const skipInstall = args.includes("--no-install")
9
+ const target = args.find(argument => !argument.startsWith("-")) ?? "kudzu-app"
10
+ const root = resolve(target)
11
+
12
+ try {
13
+ if ((await readdir(root)).length) throw new Error(`${target} is not empty`)
14
+ } catch (error) {
15
+ if (error.code !== "ENOENT") throw error
16
+ }
17
+
18
+ await mkdir(resolve(root, "src/pages"), { recursive: true })
19
+
20
+ const name = basename(root).toLowerCase().replace(/[^a-z0-9._-]+/g, "-") || "kudzu-app"
21
+ const files = {
22
+ "package.json": `${JSON.stringify({
23
+ name,
24
+ version: "0.0.0",
25
+ private: true,
26
+ type: "module",
27
+ scripts: {
28
+ dev: "kudzu dev",
29
+ build: "kudzu build"
30
+ },
31
+ dependencies: {
32
+ "@kudzujs/core": "^0.2.0"
33
+ }
34
+ }, null, 2)}\n`,
35
+ "tsconfig.json": `${JSON.stringify({
36
+ compilerOptions: {
37
+ target: "ES2022",
38
+ module: "ESNext",
39
+ moduleResolution: "Bundler",
40
+ jsx: "react-jsx",
41
+ jsxImportSource: "@kudzujs/core",
42
+ strict: true
43
+ }
44
+ }, null, 2)}\n`,
45
+ ".gitignore": "node_modules/\ndist/\n.kudzu/\n",
46
+ "src/pages/index.tsx": `import { useState } from "@kudzujs/core"
47
+
48
+ export default function HomePage() {
49
+ const [count, setCount] = useState(0)
50
+
51
+ return (
52
+ <main>
53
+ <p>Kudzu is growing.</p>
54
+ <h1>Count: {count}</h1>
55
+ <button onClick={() => setCount(count + 1)}>Grow +1</button>
56
+ </main>
57
+ )
58
+ }
59
+ `,
60
+ "src/style.css": `:root {
61
+ color: #f7f3ff;
62
+ background: #01020c;
63
+ font-family: system-ui, sans-serif;
64
+ }
65
+
66
+ body { margin: 0; }
67
+ main { display: grid; min-height: 100vh; place-content: center; text-align: center; }
68
+ p { color: #cfa8ff; }
69
+ h1 { font-size: clamp(3rem, 10vw, 7rem); margin: 0 0 2rem; }
70
+ button { padding: .8rem 1.2rem; color: white; background: #8d52ff; border: 0; border-radius: .5rem; cursor: pointer; }
71
+ `
72
+ }
73
+
74
+ await Promise.all(Object.entries(files).map(async ([file, content]) => {
75
+ await writeFile(resolve(root, file), content)
76
+ }))
77
+
78
+ if (!skipInstall) {
79
+ const result = spawnSync(process.platform === "win32" ? "npm.cmd" : "npm", ["install"], { cwd: root, stdio: "inherit" })
80
+ if (result.status !== 0) process.exit(result.status ?? 1)
81
+ }
82
+
83
+ console.log(`\nCreated ${name} in ${root}\n\n cd ${target}\n npm run dev\n`)
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "create-kudzu",
3
+ "version": "0.1.0",
4
+ "description": "Create a Kudzu project",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/kudzujs/kudzu.git",
10
+ "directory": "packages/create-kudzu"
11
+ },
12
+ "homepage": "https://kudzujs.cloud",
13
+ "engines": {
14
+ "node": ">=22"
15
+ },
16
+ "bin": {
17
+ "create-kudzu": "index.mjs"
18
+ },
19
+ "files": [
20
+ "index.mjs",
21
+ "README.md",
22
+ "LICENSE"
23
+ ],
24
+ "scripts": {
25
+ "test": "node --test ../../test/create-kudzu.test.mjs",
26
+ "prepublishOnly": "npm test"
27
+ },
28
+ "keywords": [
29
+ "kudzu",
30
+ "tsx",
31
+ "starter",
32
+ "scaffold"
33
+ ]
34
+ }