create-webjs 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/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # create-webjs
2
+
3
+ Scaffold a new [webjs](https://webjs.dev) app with one command, no global install required.
4
+
5
+ ```sh
6
+ npm create webjs@latest my-app
7
+ cd my-app && npm run dev
8
+ # → http://localhost:3000
9
+ ```
10
+
11
+ `npm create webjs@latest` is npm's documented shorthand for `npx create-webjs@latest`; both routes dispatch to this same package. Under the hood it calls [`@webjsdev/cli`](https://www.npmjs.com/package/@webjsdev/cli)'s `scaffoldApp()` and auto-runs the detected package manager's install in the new directory.
12
+
13
+ ## Templates
14
+
15
+ ```sh
16
+ npm create webjs@latest my-app # default: full-stack (pages + components + API + Prisma/SQLite)
17
+ npm create webjs@latest my-api -- --template api # backend-only (route handlers + modules, no SSR/UI)
18
+ npm create webjs@latest my-saas -- --template saas # auth + login/signup + protected dashboard + Prisma User model
19
+ ```
20
+
21
+ (The `--` separator before flags is npm's pass-through convention. Plain `npx create-webjs@latest my-app --template api` works without the separator.)
22
+
23
+ Only three templates exist; the CLI rejects anything else.
24
+
25
+ ## Options
26
+
27
+ | Flag | Default | Meaning |
28
+ |---|---|---|
29
+ | `--template <full-stack \| api \| saas>` | `full-stack` | Pick the scaffold variant. |
30
+ | `--no-install` | install runs | Skip the post-scaffold `<pm> install`. |
31
+ | `-h`, `--help` | | Show help. |
32
+
33
+ The package manager is detected from `npm_config_user_agent`: pnpm / yarn / bun users get their own.
34
+
35
+ ## Relationship to `@webjsdev/cli`
36
+
37
+ `create-webjs` is a thin scaffolding wrapper. The full CLI lives in [`@webjsdev/cli`](https://www.npmjs.com/package/@webjsdev/cli) (and its unscoped mirror [`webjsdev`](https://www.npmjs.com/package/webjsdev)), which installs globally to give you `webjs dev`, `webjs start`, `webjs create`, `webjs test`, `webjs check`, `webjs db`, and `webjs ui`. After scaffolding, `webjs <cmd>` is available locally via the new app's `node_modules/.bin`, and globally if you've run `npm i -g @webjsdev/cli` or `npm i -g webjsdev`.
38
+
39
+ ## License
40
+
41
+ MIT
@@ -0,0 +1,68 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * `create-webjs` is the `npx` / `npm create` entry point for scaffolding a
4
+ * webjs app.
5
+ *
6
+ * npm create webjs@latest my-app
7
+ * npx create-webjs@latest my-app
8
+ * npm create webjs@latest my-api -- --template api
9
+ * npm create webjs@latest my-saas -- --template saas --no-install
10
+ *
11
+ * This is a thin wrapper around `@webjsdev/cli`'s `scaffoldApp()`. Behaviour
12
+ * matches `webjs create` exactly, including auto-install (npm / pnpm / yarn /
13
+ * bun, detected from `npm_config_user_agent`). Pass `--no-install` to opt out.
14
+ *
15
+ * The package mirrors the create-next-app / create-react-app / create-astro
16
+ * pattern so the homepage hero is a single command and users don't need a
17
+ * global install of `@webjsdev/cli` to start. The `npm create <suffix>` form
18
+ * is npm's documented shorthand for `npx create-<suffix>`; both routes
19
+ * resolve to this same package and bin.
20
+ */
21
+ import { scaffoldApp } from '@webjsdev/cli/lib/create.js';
22
+
23
+ const TEMPLATES = ['full-stack', 'api', 'saas'];
24
+
25
+ const args = process.argv.slice(2);
26
+
27
+ function flagValue(name) {
28
+ const i = args.indexOf(name);
29
+ if (i === -1) return undefined;
30
+ return args[i + 1];
31
+ }
32
+
33
+ const usage = `Usage:
34
+ npm create webjs@latest <app-name> [-- --template full-stack|api|saas] [-- --no-install]
35
+ npx create-webjs@latest <app-name> [--template full-stack|api|saas] [--no-install]
36
+
37
+ Templates:
38
+ full-stack (default) pages + components + API + Prisma/SQLite
39
+ api route handlers + modules, no SSR/UI
40
+ saas auth + login/signup + protected dashboard + Prisma User model
41
+
42
+ Options:
43
+ --no-install skip running the package manager's install in the new directory
44
+ -h, --help show this help`;
45
+
46
+ if (args.length === 0 || args.includes('-h') || args.includes('--help')) {
47
+ console.log(usage);
48
+ process.exit(args.length === 0 ? 1 : 0);
49
+ }
50
+
51
+ const positional = args.filter((a) => !a.startsWith('-'));
52
+ const name = positional[0];
53
+ if (!name) {
54
+ console.error('Error: <app-name> is required.\n');
55
+ console.error(usage);
56
+ process.exit(1);
57
+ }
58
+
59
+ const template = flagValue('--template') || 'full-stack';
60
+ if (!TEMPLATES.includes(template)) {
61
+ console.error(`Error: unknown template '${template}'. Only ${TEMPLATES.join(' / ')} are supported.\n`);
62
+ console.error(usage);
63
+ process.exit(1);
64
+ }
65
+
66
+ const noInstall = args.includes('--no-install');
67
+
68
+ await scaffoldApp(name, process.cwd(), { template, install: !noInstall });
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "create-webjs",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "description": "Scaffold a new webjs app. `npm create webjs@latest my-app`.",
6
+ "bin": {
7
+ "create-webjs": "bin/create-webjs.js"
8
+ },
9
+ "files": [
10
+ "bin",
11
+ "README.md"
12
+ ],
13
+ "dependencies": {
14
+ "@webjsdev/cli": "^0.8.4"
15
+ },
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/webjsdev/webjs.git",
22
+ "directory": "packages/create-webjs"
23
+ },
24
+ "homepage": "https://github.com/webjsdev/webjs#readme",
25
+ "bugs": "https://github.com/webjsdev/webjs/issues",
26
+ "license": "MIT",
27
+ "keywords": [
28
+ "webjs",
29
+ "create",
30
+ "scaffold",
31
+ "starter",
32
+ "framework"
33
+ ],
34
+ "engines": {
35
+ "node": ">=24.0.0"
36
+ }
37
+ }