@cloudwerk/create-app 0.0.6 → 0.1.1
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 +65 -9
- package/package.json +5 -2
- package/template-api/cloudwerk.config.ts +3 -0
- package/{template → template-api}/package.json.tmpl +1 -0
- package/template-hono-jsx/_gitignore +5 -0
- package/template-hono-jsx/app/components/counter.tsx +13 -0
- package/template-hono-jsx/app/page.tsx +10 -0
- package/template-hono-jsx/app/route.ts +6 -0
- package/template-hono-jsx/cloudwerk.config.ts +7 -0
- package/template-hono-jsx/package.json.tmpl +24 -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/page.tsx +10 -0
- package/template-react/app/route.ts +6 -0
- package/{template → template-react}/cloudwerk.config.ts +3 -1
- package/template-react/package.json.tmpl +28 -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/app/routes → template-api/app}/route.ts +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,16 +178,18 @@ function printSuccessBanner(projectName, projectPath, pm) {
|
|
|
178
178
|
}
|
|
179
179
|
|
|
180
180
|
// src/versions.ts
|
|
181
|
-
var CORE_VERSION = "0.
|
|
182
|
-
var CLI_VERSION = "0.0
|
|
181
|
+
var CORE_VERSION = "0.7.1";
|
|
182
|
+
var CLI_VERSION = "0.7.0";
|
|
183
|
+
var UI_VERSION = "0.7.1";
|
|
183
184
|
|
|
184
185
|
// src/scaffold.ts
|
|
185
|
-
function getTemplateDir() {
|
|
186
|
+
function getTemplateDir(renderer) {
|
|
186
187
|
const __dirname = path2.dirname(fileURLToPath(import.meta.url));
|
|
187
|
-
|
|
188
|
+
const templateName = renderer === "none" ? "template-api" : `template-${renderer}`;
|
|
189
|
+
return path2.resolve(__dirname, "..", templateName);
|
|
188
190
|
}
|
|
189
191
|
function processTemplate(content, values) {
|
|
190
|
-
return content.replace(/\{\{name\}\}/g, values.name).replace(/\{\{coreVersion\}\}/g, values.coreVersion).replace(/\{\{cliVersion\}\}/g, values.cliVersion);
|
|
192
|
+
return content.replace(/\{\{name\}\}/g, values.name).replace(/\{\{coreVersion\}\}/g, values.coreVersion).replace(/\{\{cliVersion\}\}/g, values.cliVersion).replace(/\{\{uiVersion\}\}/g, values.uiVersion);
|
|
191
193
|
}
|
|
192
194
|
function isTemplateFile(fileName) {
|
|
193
195
|
return fileName.endsWith(".tmpl");
|
|
@@ -203,18 +205,20 @@ function getOutputFileName(fileName) {
|
|
|
203
205
|
}
|
|
204
206
|
async function scaffold(projectName, options = {}) {
|
|
205
207
|
const targetDir = options.targetDir || path2.resolve(process.cwd(), projectName);
|
|
208
|
+
const renderer = options.renderer || "hono-jsx";
|
|
206
209
|
const validation = validateProject(projectName, targetDir);
|
|
207
210
|
if (!validation.valid) {
|
|
208
211
|
throw new Error(validation.error);
|
|
209
212
|
}
|
|
210
|
-
const templateDir = getTemplateDir();
|
|
213
|
+
const templateDir = getTemplateDir(renderer);
|
|
211
214
|
if (!fs2.existsSync(templateDir)) {
|
|
212
215
|
throw new Error(`Template directory not found: ${templateDir}`);
|
|
213
216
|
}
|
|
214
217
|
const templateValues = {
|
|
215
218
|
name: projectName,
|
|
216
219
|
coreVersion: CORE_VERSION,
|
|
217
|
-
cliVersion: CLI_VERSION
|
|
220
|
+
cliVersion: CLI_VERSION,
|
|
221
|
+
uiVersion: UI_VERSION
|
|
218
222
|
};
|
|
219
223
|
logger.info(`Creating ${projectName}...`);
|
|
220
224
|
try {
|
|
@@ -253,12 +257,64 @@ async function copyTemplateRecursive(srcDir, destDir, values) {
|
|
|
253
257
|
}
|
|
254
258
|
}
|
|
255
259
|
|
|
260
|
+
// src/prompts.ts
|
|
261
|
+
import * as p from "@clack/prompts";
|
|
262
|
+
async function promptRenderer() {
|
|
263
|
+
const renderer = await p.select({
|
|
264
|
+
message: "Select UI renderer:",
|
|
265
|
+
options: [
|
|
266
|
+
{
|
|
267
|
+
value: "hono-jsx",
|
|
268
|
+
label: "Hono JSX (recommended)",
|
|
269
|
+
hint: "Lightweight (~3kb), Workers-optimized"
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
value: "react",
|
|
273
|
+
label: "React",
|
|
274
|
+
hint: "Full ecosystem, larger bundle (~45kb)"
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
value: "none",
|
|
278
|
+
label: "None (API only)",
|
|
279
|
+
hint: "No UI rendering, pure API routes"
|
|
280
|
+
}
|
|
281
|
+
]
|
|
282
|
+
});
|
|
283
|
+
if (p.isCancel(renderer)) {
|
|
284
|
+
p.cancel("Operation cancelled");
|
|
285
|
+
process.exit(0);
|
|
286
|
+
}
|
|
287
|
+
return renderer;
|
|
288
|
+
}
|
|
289
|
+
function isInteractiveMode(args) {
|
|
290
|
+
if (process.env.CI === "true" || process.env.CI === "1") {
|
|
291
|
+
return false;
|
|
292
|
+
}
|
|
293
|
+
if (args.includes("--renderer") || args.includes("-r")) {
|
|
294
|
+
return false;
|
|
295
|
+
}
|
|
296
|
+
if (!process.stdin.isTTY) {
|
|
297
|
+
return false;
|
|
298
|
+
}
|
|
299
|
+
return true;
|
|
300
|
+
}
|
|
301
|
+
|
|
256
302
|
// src/index.ts
|
|
257
303
|
var require2 = createRequire(import.meta.url);
|
|
258
304
|
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) => {
|
|
305
|
+
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
306
|
try {
|
|
261
|
-
|
|
307
|
+
let renderer = options.renderer;
|
|
308
|
+
const validRenderers = ["hono-jsx", "react", "none"];
|
|
309
|
+
if (renderer && !validRenderers.includes(renderer)) {
|
|
310
|
+
throw new Error(
|
|
311
|
+
`Invalid renderer "${renderer}". Valid options: ${validRenderers.join(", ")}`
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
if (isInteractiveMode(process.argv)) {
|
|
315
|
+
renderer = await promptRenderer();
|
|
316
|
+
}
|
|
317
|
+
await scaffold(projectName, { renderer });
|
|
262
318
|
} catch (error) {
|
|
263
319
|
logger.error(error.message);
|
|
264
320
|
process.exit(1);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudwerk/create-app",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
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,24 @@
|
|
|
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
|
+
"@cloudwerk/ui": "^{{uiVersion}}",
|
|
15
|
+
"hono": "^4.0.0"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"typescript": "^5.0.0",
|
|
19
|
+
"wrangler": "^4.0.0"
|
|
20
|
+
},
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=20"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -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,28 @@
|
|
|
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
|
+
"@cloudwerk/ui": "^{{uiVersion}}",
|
|
15
|
+
"hono": "^4.0.0",
|
|
16
|
+
"react": "^19.0.0",
|
|
17
|
+
"react-dom": "^19.0.0"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@types/react": "^19.0.0",
|
|
21
|
+
"@types/react-dom": "^19.0.0",
|
|
22
|
+
"typescript": "^5.0.0",
|
|
23
|
+
"wrangler": "^4.0.0"
|
|
24
|
+
},
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": ">=20"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -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
|