@cloudwerk/create-app 0.0.6 → 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/dist/index.js +61 -7
- package/package.json +5 -2
- package/template-hono-jsx/_gitignore +5 -0
- package/template-hono-jsx/app/components/counter.tsx +13 -0
- package/template-hono-jsx/app/routes/page.tsx +10 -0
- package/template-hono-jsx/app/routes/route.ts +6 -0
- package/template-hono-jsx/cloudwerk.config.ts +8 -0
- package/template-hono-jsx/package.json.tmpl +23 -0
- package/template-hono-jsx/tsconfig.json +16 -0
- package/template-hono-jsx/wrangler.toml.tmpl +6 -0
- package/template-react/_gitignore +5 -0
- package/template-react/app/components/counter.tsx +13 -0
- package/template-react/app/routes/page.tsx +10 -0
- package/template-react/app/routes/route.ts +6 -0
- package/template-react/cloudwerk.config.ts +8 -0
- package/template-react/package.json.tmpl +27 -0
- package/template-react/tsconfig.json +16 -0
- package/template-react/wrangler.toml.tmpl +6 -0
- /package/{template → template-api}/_gitignore +0 -0
- /package/{template → template-api}/app/routes/route.ts +0 -0
- /package/{template → template-api}/cloudwerk.config.ts +0 -0
- /package/{template → template-api}/package.json.tmpl +0 -0
- /package/{template → template-api}/tsconfig.json +0 -0
- /package/{template → template-api}/wrangler.toml.tmpl +0 -0
package/dist/index.js
CHANGED
|
@@ -178,13 +178,14 @@ function printSuccessBanner(projectName, projectPath, pm) {
|
|
|
178
178
|
}
|
|
179
179
|
|
|
180
180
|
// src/versions.ts
|
|
181
|
-
var CORE_VERSION = "0.0
|
|
182
|
-
var CLI_VERSION = "0.0
|
|
181
|
+
var CORE_VERSION = "0.3.0";
|
|
182
|
+
var CLI_VERSION = "0.4.0";
|
|
183
183
|
|
|
184
184
|
// src/scaffold.ts
|
|
185
|
-
function getTemplateDir() {
|
|
185
|
+
function getTemplateDir(renderer) {
|
|
186
186
|
const __dirname = path2.dirname(fileURLToPath(import.meta.url));
|
|
187
|
-
|
|
187
|
+
const templateName = renderer === "none" ? "template-api" : `template-${renderer}`;
|
|
188
|
+
return path2.resolve(__dirname, "..", templateName);
|
|
188
189
|
}
|
|
189
190
|
function processTemplate(content, values) {
|
|
190
191
|
return content.replace(/\{\{name\}\}/g, values.name).replace(/\{\{coreVersion\}\}/g, values.coreVersion).replace(/\{\{cliVersion\}\}/g, values.cliVersion);
|
|
@@ -203,11 +204,12 @@ function getOutputFileName(fileName) {
|
|
|
203
204
|
}
|
|
204
205
|
async function scaffold(projectName, options = {}) {
|
|
205
206
|
const targetDir = options.targetDir || path2.resolve(process.cwd(), projectName);
|
|
207
|
+
const renderer = options.renderer || "hono-jsx";
|
|
206
208
|
const validation = validateProject(projectName, targetDir);
|
|
207
209
|
if (!validation.valid) {
|
|
208
210
|
throw new Error(validation.error);
|
|
209
211
|
}
|
|
210
|
-
const templateDir = getTemplateDir();
|
|
212
|
+
const templateDir = getTemplateDir(renderer);
|
|
211
213
|
if (!fs2.existsSync(templateDir)) {
|
|
212
214
|
throw new Error(`Template directory not found: ${templateDir}`);
|
|
213
215
|
}
|
|
@@ -253,12 +255,64 @@ async function copyTemplateRecursive(srcDir, destDir, values) {
|
|
|
253
255
|
}
|
|
254
256
|
}
|
|
255
257
|
|
|
258
|
+
// src/prompts.ts
|
|
259
|
+
import * as p from "@clack/prompts";
|
|
260
|
+
async function promptRenderer() {
|
|
261
|
+
const renderer = await p.select({
|
|
262
|
+
message: "Select UI renderer:",
|
|
263
|
+
options: [
|
|
264
|
+
{
|
|
265
|
+
value: "hono-jsx",
|
|
266
|
+
label: "Hono JSX (recommended)",
|
|
267
|
+
hint: "Lightweight (~3kb), Workers-optimized"
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
value: "react",
|
|
271
|
+
label: "React",
|
|
272
|
+
hint: "Full ecosystem, larger bundle (~45kb)"
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
value: "none",
|
|
276
|
+
label: "None (API only)",
|
|
277
|
+
hint: "No UI rendering, pure API routes"
|
|
278
|
+
}
|
|
279
|
+
]
|
|
280
|
+
});
|
|
281
|
+
if (p.isCancel(renderer)) {
|
|
282
|
+
p.cancel("Operation cancelled");
|
|
283
|
+
process.exit(0);
|
|
284
|
+
}
|
|
285
|
+
return renderer;
|
|
286
|
+
}
|
|
287
|
+
function isInteractiveMode(args) {
|
|
288
|
+
if (process.env.CI === "true" || process.env.CI === "1") {
|
|
289
|
+
return false;
|
|
290
|
+
}
|
|
291
|
+
if (args.includes("--renderer") || args.includes("-r")) {
|
|
292
|
+
return false;
|
|
293
|
+
}
|
|
294
|
+
if (!process.stdin.isTTY) {
|
|
295
|
+
return false;
|
|
296
|
+
}
|
|
297
|
+
return true;
|
|
298
|
+
}
|
|
299
|
+
|
|
256
300
|
// src/index.ts
|
|
257
301
|
var require2 = createRequire(import.meta.url);
|
|
258
302
|
var pkg = require2("../package.json");
|
|
259
|
-
program.name("create-cloudwerk-app").description("Create a new Cloudwerk app").version(pkg.version).argument("<project-name>", "Name of the project to create").action(async (projectName) => {
|
|
303
|
+
program.name("create-cloudwerk-app").description("Create a new Cloudwerk app").version(pkg.version).argument("<project-name>", "Name of the project to create").option("-r, --renderer <type>", "UI renderer (hono-jsx, react, none)", "hono-jsx").action(async (projectName, options) => {
|
|
260
304
|
try {
|
|
261
|
-
|
|
305
|
+
let renderer = options.renderer;
|
|
306
|
+
const validRenderers = ["hono-jsx", "react", "none"];
|
|
307
|
+
if (renderer && !validRenderers.includes(renderer)) {
|
|
308
|
+
throw new Error(
|
|
309
|
+
`Invalid renderer "${renderer}". Valid options: ${validRenderers.join(", ")}`
|
|
310
|
+
);
|
|
311
|
+
}
|
|
312
|
+
if (isInteractiveMode(process.argv)) {
|
|
313
|
+
renderer = await promptRenderer();
|
|
314
|
+
}
|
|
315
|
+
await scaffold(projectName, { renderer });
|
|
262
316
|
} catch (error) {
|
|
263
317
|
logger.error(error.message);
|
|
264
318
|
process.exit(1);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudwerk/create-app",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Create a new Cloudwerk app",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -19,9 +19,12 @@
|
|
|
19
19
|
},
|
|
20
20
|
"files": [
|
|
21
21
|
"dist",
|
|
22
|
-
"template"
|
|
22
|
+
"template-hono-jsx",
|
|
23
|
+
"template-react",
|
|
24
|
+
"template-api"
|
|
23
25
|
],
|
|
24
26
|
"dependencies": {
|
|
27
|
+
"@clack/prompts": "^0.8.2",
|
|
25
28
|
"commander": "^12.1.0",
|
|
26
29
|
"fs-extra": "^11.0.0",
|
|
27
30
|
"picocolors": "^1.1.0"
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{name}}",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "cloudwerk dev",
|
|
8
|
+
"build": "cloudwerk build",
|
|
9
|
+
"deploy": "wrangler deploy"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@cloudwerk/core": "^{{coreVersion}}",
|
|
13
|
+
"@cloudwerk/cli": "^{{cliVersion}}",
|
|
14
|
+
"hono": "^4.0.0"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"typescript": "^5.0.0",
|
|
18
|
+
"wrangler": "^4.0.0"
|
|
19
|
+
},
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=20"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"esModuleInterop": true,
|
|
7
|
+
"strict": true,
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"declaration": true,
|
|
10
|
+
"outDir": "./dist",
|
|
11
|
+
"rootDir": "./app",
|
|
12
|
+
"jsx": "react-jsx",
|
|
13
|
+
"jsxImportSource": "hono/jsx"
|
|
14
|
+
},
|
|
15
|
+
"include": ["app/**/*", "cloudwerk.config.ts"]
|
|
16
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{name}}",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "cloudwerk dev",
|
|
8
|
+
"build": "cloudwerk build",
|
|
9
|
+
"deploy": "wrangler deploy"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@cloudwerk/core": "^{{coreVersion}}",
|
|
13
|
+
"@cloudwerk/cli": "^{{cliVersion}}",
|
|
14
|
+
"hono": "^4.0.0",
|
|
15
|
+
"react": "^19.0.0",
|
|
16
|
+
"react-dom": "^19.0.0"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@types/react": "^19.0.0",
|
|
20
|
+
"@types/react-dom": "^19.0.0",
|
|
21
|
+
"typescript": "^5.0.0",
|
|
22
|
+
"wrangler": "^4.0.0"
|
|
23
|
+
},
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=20"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"esModuleInterop": true,
|
|
7
|
+
"strict": true,
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"declaration": true,
|
|
10
|
+
"outDir": "./dist",
|
|
11
|
+
"rootDir": "./app",
|
|
12
|
+
"jsx": "react-jsx",
|
|
13
|
+
"jsxImportSource": "react"
|
|
14
|
+
},
|
|
15
|
+
"include": ["app/**/*", "cloudwerk.config.ts"]
|
|
16
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|