create-donghanh 0.2.0 → 0.2.2
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/{src/index.ts → dist/index.js} +23 -50
- package/package.json +6 -3
- package/templates/kanban-gpt/operations/board-detail.tsx +1 -1
- package/templates/kanban-gpt/operations/list-boards.tsx +1 -1
- package/templates/kanban-gpt/package.json +3 -0
- package/templates/kanban-gpt/tsconfig.json +3 -1
- package/templates/minimal/package.json +5 -3
- package/templates/minimal/tsconfig.json +3 -1
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/index.ts
|
|
2
4
|
import fs from "node:fs";
|
|
3
5
|
import path from "node:path";
|
|
4
6
|
import readline from "node:readline";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
type Template = (typeof TEMPLATES)[number];
|
|
8
|
-
|
|
9
|
-
const DESCRIPTIONS: Record<Template, string> = {
|
|
7
|
+
var TEMPLATES = ["minimal", "kanban-gpt"];
|
|
8
|
+
var DESCRIPTIONS = {
|
|
10
9
|
minimal: "Hello world with D1 SQLite — 2 operations",
|
|
11
|
-
"kanban-gpt":
|
|
12
|
-
"Kanban board with Better Auth + Drizzle + GPT Store OAuth — 6 operations",
|
|
10
|
+
"kanban-gpt": "Kanban board with Better Auth + Drizzle + GPT Store OAuth — 6 operations"
|
|
13
11
|
};
|
|
14
|
-
|
|
15
|
-
async function prompt(question: string): Promise<string> {
|
|
12
|
+
async function prompt(question) {
|
|
16
13
|
const rl = readline.createInterface({
|
|
17
14
|
input: process.stdin,
|
|
18
|
-
output: process.stdout
|
|
15
|
+
output: process.stdout
|
|
19
16
|
});
|
|
20
17
|
return new Promise((resolve) => {
|
|
21
18
|
rl.question(question, (answer) => {
|
|
@@ -24,8 +21,7 @@ async function prompt(question: string): Promise<string> {
|
|
|
24
21
|
});
|
|
25
22
|
});
|
|
26
23
|
}
|
|
27
|
-
|
|
28
|
-
function copyDir(src: string, dest: string, replacements: [string, string][]) {
|
|
24
|
+
function copyDir(src, dest, replacements) {
|
|
29
25
|
fs.mkdirSync(dest, { recursive: true });
|
|
30
26
|
for (const entry of fs.readdirSync(src, { withFileTypes: true })) {
|
|
31
27
|
const srcPath = path.join(src, entry.name);
|
|
@@ -41,29 +37,22 @@ function copyDir(src: string, dest: string, replacements: [string, string][]) {
|
|
|
41
37
|
}
|
|
42
38
|
}
|
|
43
39
|
}
|
|
44
|
-
|
|
45
40
|
async function main() {
|
|
46
41
|
const args = process.argv.slice(2);
|
|
47
42
|
let target = args[0];
|
|
48
|
-
let template
|
|
49
|
-
|
|
50
|
-
// Parse --template / -t flag
|
|
43
|
+
let template;
|
|
51
44
|
const tIdx = args.indexOf("--template");
|
|
52
45
|
const tShortIdx = args.indexOf("-t");
|
|
53
46
|
const flagIdx = tIdx !== -1 ? tIdx : tShortIdx;
|
|
54
47
|
if (flagIdx !== -1 && args[flagIdx + 1]) {
|
|
55
|
-
template = args[flagIdx + 1]
|
|
56
|
-
// Remove flag and value from args
|
|
48
|
+
template = args[flagIdx + 1];
|
|
57
49
|
if (!target || target.startsWith("-")) {
|
|
58
50
|
target = undefined;
|
|
59
51
|
}
|
|
60
52
|
}
|
|
61
|
-
|
|
62
53
|
console.log();
|
|
63
|
-
console.log(" \
|
|
54
|
+
console.log(" \x1B[1m@donghanh\x1B[0m — Conversational UI Framework");
|
|
64
55
|
console.log();
|
|
65
|
-
|
|
66
|
-
// Prompt for target if not given
|
|
67
56
|
if (!target || target.startsWith("-")) {
|
|
68
57
|
target = await prompt(" Project name: ");
|
|
69
58
|
if (!target) {
|
|
@@ -71,63 +60,47 @@ async function main() {
|
|
|
71
60
|
process.exit(0);
|
|
72
61
|
}
|
|
73
62
|
}
|
|
74
|
-
|
|
75
|
-
// Prompt for template if not given
|
|
76
63
|
if (!template || !TEMPLATES.includes(template)) {
|
|
77
64
|
console.log();
|
|
78
65
|
console.log(" Templates:");
|
|
79
|
-
for (let i = 0;
|
|
80
|
-
console.log(
|
|
81
|
-
` \x1b[1m${i + 1}\x1b[0m) ${TEMPLATES[i]} — ${DESCRIPTIONS[TEMPLATES[i]]}`,
|
|
82
|
-
);
|
|
66
|
+
for (let i = 0;i < TEMPLATES.length; i++) {
|
|
67
|
+
console.log(` \x1B[1m${i + 1}\x1B[0m) ${TEMPLATES[i]} — ${DESCRIPTIONS[TEMPLATES[i]]}`);
|
|
83
68
|
}
|
|
84
69
|
console.log();
|
|
85
70
|
const choice = await prompt(" Select template (1-2): ");
|
|
86
71
|
const idx = Number.parseInt(choice, 10) - 1;
|
|
87
72
|
template = TEMPLATES[idx] ?? "minimal";
|
|
88
73
|
}
|
|
89
|
-
|
|
90
74
|
const destDir = path.resolve(target);
|
|
91
75
|
if (fs.existsSync(destDir)) {
|
|
92
|
-
console.log(
|
|
93
|
-
` \x1b[31mError:\x1b[0m Directory "${target}" already exists.`,
|
|
94
|
-
);
|
|
76
|
+
console.log(` \x1B[31mError:\x1B[0m Directory "${target}" already exists.`);
|
|
95
77
|
process.exit(1);
|
|
96
78
|
}
|
|
97
|
-
|
|
98
|
-
// Find templates directory
|
|
99
|
-
const templatesDir = path.join(
|
|
100
|
-
path.dirname(new URL(import.meta.url).pathname),
|
|
101
|
-
"..",
|
|
102
|
-
"templates",
|
|
103
|
-
);
|
|
79
|
+
const templatesDir = path.join(path.dirname(new URL(import.meta.url).pathname), "..", "templates");
|
|
104
80
|
const srcDir = path.join(templatesDir, template);
|
|
105
|
-
|
|
106
81
|
if (!fs.existsSync(srcDir)) {
|
|
107
|
-
console.log(` \
|
|
82
|
+
console.log(` \x1B[31mError:\x1B[0m Template "${template}" not found.`);
|
|
108
83
|
process.exit(1);
|
|
109
84
|
}
|
|
110
|
-
|
|
111
|
-
// Copy template with name replacement
|
|
112
85
|
const appName = path.basename(target);
|
|
113
86
|
copyDir(srcDir, destDir, [
|
|
114
87
|
["my-donghanh-app", appName],
|
|
115
88
|
["my-kanban-app", appName],
|
|
116
89
|
["my-donghanh-app-db", `${appName}-db`],
|
|
117
|
-
["my-kanban-db", `${appName}-db`]
|
|
90
|
+
["my-kanban-db", `${appName}-db`]
|
|
118
91
|
]);
|
|
119
|
-
|
|
120
92
|
console.log();
|
|
121
|
-
console.log(
|
|
122
|
-
` \x1b[32m✓\x1b[0m Created \x1b[1m${appName}\x1b[0m from \x1b[1m${template}\x1b[0m template`,
|
|
123
|
-
);
|
|
93
|
+
console.log(` \x1B[32m✓\x1B[0m Created \x1B[1m${appName}\x1B[0m from \x1B[1m${template}\x1B[0m template`);
|
|
124
94
|
console.log();
|
|
125
95
|
console.log(" Next steps:");
|
|
126
96
|
console.log(` cd ${target}`);
|
|
127
97
|
console.log(" bun install");
|
|
128
|
-
|
|
98
|
+
if (template === "minimal") {
|
|
99
|
+
console.log(" bun run db:init # initialize D1 database");
|
|
100
|
+
} else {
|
|
101
|
+
console.log(" bun run db:push # push schema to D1");
|
|
102
|
+
}
|
|
129
103
|
console.log(" bun run dev # start dev server");
|
|
130
104
|
console.log();
|
|
131
105
|
}
|
|
132
|
-
|
|
133
106
|
main().catch(console.error);
|
package/package.json
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-donghanh",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Scaffold a donghanh project — conversational UI with JSX",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|
|
8
|
-
"create-donghanh": "
|
|
8
|
+
"create-donghanh": "dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "bun build src/index.ts --outdir dist --target node"
|
|
9
12
|
},
|
|
10
13
|
"files": [
|
|
11
|
-
"
|
|
14
|
+
"dist",
|
|
12
15
|
"templates"
|
|
13
16
|
],
|
|
14
17
|
"repository": {
|
|
@@ -16,7 +16,7 @@ function BoardDetail({ data }: OperationProps<Data>) {
|
|
|
16
16
|
cards: col.cards.map(c => c.title),
|
|
17
17
|
}))} />
|
|
18
18
|
{columns.map(col => (
|
|
19
|
-
<Action
|
|
19
|
+
<Action operation="add-card" label={`Add card to ${col.name}`} variables={{ boardId: board.id, columnId: col.id }} />
|
|
20
20
|
))}
|
|
21
21
|
<Action operation="add-member" label="Add member" variables={{ boardId: board.id }} />
|
|
22
22
|
</Brief>
|
|
@@ -19,7 +19,7 @@ function ListBoards({ data }: OperationProps<Data>) {
|
|
|
19
19
|
You have {data.boards.length} board(s).
|
|
20
20
|
<Display data={data.boards.map(b => `${b.name} (${b.card_count} cards, ${b.member_count} members)`)} />
|
|
21
21
|
{data.boards.map(b => (
|
|
22
|
-
<Action
|
|
22
|
+
<Action operation="board-detail" label={`View ${b.name}`} variables={{ boardId: b.id }} />
|
|
23
23
|
))}
|
|
24
24
|
<Action operation="create-board" label="Create new board" />
|
|
25
25
|
</Brief>
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
"target": "ES2017",
|
|
4
4
|
"lib": ["esnext"],
|
|
5
|
+
"types": ["@cloudflare/workers-types", "node"],
|
|
5
6
|
"skipLibCheck": true,
|
|
6
7
|
"strict": true,
|
|
7
8
|
"noEmit": true,
|
|
@@ -10,5 +11,6 @@
|
|
|
10
11
|
"jsx": "react-jsx",
|
|
11
12
|
"jsxImportSource": "@donghanh/core"
|
|
12
13
|
},
|
|
13
|
-
"include": ["**/*.ts", "**/*.tsx"]
|
|
14
|
+
"include": ["**/*.ts", "**/*.tsx"],
|
|
15
|
+
"exclude": ["node_modules"]
|
|
14
16
|
}
|
|
@@ -5,14 +5,16 @@
|
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "wrangler dev",
|
|
8
|
-
"deploy": "wrangler deploy"
|
|
8
|
+
"deploy": "wrangler deploy",
|
|
9
|
+
"db:init": "wrangler d1 execute my-donghanh-app-db --local --file=schema.sql"
|
|
9
10
|
},
|
|
10
11
|
"dependencies": {
|
|
11
|
-
"@donghanh/core": "^0.1.
|
|
12
|
-
"@donghanh/hono": "^0.1.
|
|
12
|
+
"@donghanh/core": "^0.1.1",
|
|
13
|
+
"@donghanh/hono": "^0.1.1",
|
|
13
14
|
"hono": "^4.7.0"
|
|
14
15
|
},
|
|
15
16
|
"devDependencies": {
|
|
17
|
+
"@cloudflare/workers-types": "^4.0.0",
|
|
16
18
|
"wrangler": "^4.0.0",
|
|
17
19
|
"typescript": "^5.8.0"
|
|
18
20
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
"target": "ES2017",
|
|
4
4
|
"lib": ["esnext"],
|
|
5
|
+
"types": ["@cloudflare/workers-types"],
|
|
5
6
|
"skipLibCheck": true,
|
|
6
7
|
"strict": true,
|
|
7
8
|
"noEmit": true,
|
|
@@ -10,5 +11,6 @@
|
|
|
10
11
|
"jsx": "react-jsx",
|
|
11
12
|
"jsxImportSource": "@donghanh/core"
|
|
12
13
|
},
|
|
13
|
-
"include": ["**/*.ts", "**/*.tsx"]
|
|
14
|
+
"include": ["**/*.ts", "**/*.tsx"],
|
|
15
|
+
"exclude": ["node_modules"]
|
|
14
16
|
}
|