@openelement/create 1.0.0-alpha.10 → 1.0.0-alpha.11

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 (43) hide show
  1. package/README.md +49 -44
  2. package/package.json +1 -1
  3. package/src/cli.js +177 -45
  4. package/src/pm.js +30 -0
  5. package/src/template-builder.js +21 -71
  6. package/src/version.js +2 -12
  7. package/templates/README.tmpl +84 -48
  8. package/templates/app/components/badges.css +5 -0
  9. package/templates/app/components/page-404.css +7 -0
  10. package/templates/app/components/page-404.tsx.tmpl +32 -11
  11. package/templates/app/components/page-about.css +15 -0
  12. package/templates/app/components/page-about.tsx.tmpl +93 -0
  13. package/templates/app/components/page-home.css +23 -0
  14. package/templates/app/components/page-home.tsx.tmpl +113 -39
  15. package/templates/app/components/site-chrome.css +15 -0
  16. package/templates/app/head.tsx.tmpl +5 -15
  17. package/templates/app/islands/live-timer.css +6 -0
  18. package/templates/app/islands/live-timer.tsx.tmpl +54 -0
  19. package/templates/app/islands/my-counter.css +11 -0
  20. package/templates/app/islands/my-counter.tsx.tmpl +5 -21
  21. package/templates/app/routes/about.tsx.tmpl +10 -0
  22. package/templates/app/routes/api/ping.ts.tmpl +12 -0
  23. package/templates/app/routes/index.tsx.tmpl +2 -2
  24. package/templates/app/styles/recipes.css +43 -0
  25. package/templates/{tailwind → app/styles}/theme.css +74 -12
  26. package/templates/openelement.config.ts.tmpl +11 -3
  27. package/templates/package.json.tmpl +2 -0
  28. package/templates/tsconfig.json.tmpl +1 -0
  29. package/templates/vite.config.ts.tmpl +3 -3
  30. package/templates/app/components/page-blog-index.tsx.tmpl +0 -39
  31. package/templates/app/components/page-blog-welcome.tsx.tmpl +0 -57
  32. package/templates/app/components/page-contact.tsx.tmpl +0 -49
  33. package/templates/app/components/page-freshness.tsx.tmpl +0 -26
  34. package/templates/app/components/page-styles.ts.tmpl +0 -123
  35. package/templates/app/islands/app-shell.tsx.tmpl +0 -83
  36. package/templates/app/islands/only-ticker.tsx.tmpl +0 -51
  37. package/templates/app/routes/api/health.ts.tmpl +0 -7
  38. package/templates/app/routes/blog/index.tsx.tmpl +0 -10
  39. package/templates/app/routes/blog/welcome.tsx.tmpl +0 -7
  40. package/templates/app/routes/contact.tsx.tmpl +0 -36
  41. package/templates/app/routes/freshness.tsx.tmpl +0 -17
  42. package/templates/app/styles/tokens.css +0 -57
  43. package/templates/tailwind/vite.config.ts.tmpl +0 -38
package/README.md CHANGED
@@ -9,30 +9,48 @@ Docs and guides: <https://openelement.org>.
9
9
  > `npm view @openelement/create dist-tags`); `latest` stays on the stable 0.43
10
10
  > line until a separately admitted stable release.
11
11
 
12
- `@openelement/create` generates a new openElement project with the recommended
13
- directory structure, a pnpm-scripted package manifest, Vite setup, and starter
14
- pages. The generated project is a plain Node/pnpm project.
12
+ `@openelement/create` generates a new openElement project from ONE template —
13
+ the showcase starter: a static-first landing page with two islands, a fully
14
+ static About page, an `/api/ping` server route, and a pure-CSS design-token
15
+ sheet (no Tailwind, no template variants). The generated project is a plain
16
+ Node/pnpm project.
15
17
 
16
18
  ## Usage (1.0 Alpha)
17
19
 
18
20
  ```bash
19
21
  npm create @openelement@alpha my-app
20
- cd my-app
21
- pnpm install
22
- pnpm dev
22
+ ```
23
+
24
+ The CLI scaffolds, initializes git (when git is available), detects a package
25
+ manager (pnpm first, then npm), installs dependencies, and prints a boxed
26
+ handoff with the next commands. Flags (all optional):
27
+
28
+ | Flag | Default | Meaning |
29
+ | --- | --- | --- |
30
+ | `-t, --template <name>` | `showcase` | the template to scaffold; skips the interactive confirmation |
31
+ | `--install` / `--no-install` | install | dependency installation after scaffolding |
32
+ | `--start` | off | start the dev server after a successful install |
33
+ | `--git` / `--no-git` | git init | initialize a git repository (requires the scaffold's `.gitignore`) |
34
+
35
+ On a TTY the CLI asks exactly one question — confirming the template (Enter
36
+ accepts the default). Non-interactive runs (CI, packed consumers) skip the
37
+ prompt and take the defaults; pass `-t` to pin the template explicitly.
38
+
39
+ ```bash
40
+ npx @openelement/create@alpha my-app --no-install --no-git -t showcase
23
41
  ```
24
42
 
25
43
  `npm create @openelement@alpha` rides npm's initializer alias: a bare `@scope`
26
44
  resolves to `@scope/create` at the same tag, so the canonical spelling names
27
45
  the scope, and npm runs this package's generator. The version `@alpha` resolves
28
46
  to is registered in
29
- `the tracked release-state manifest` (currently `1.0.0-alpha.9`, a new baseline —
47
+ `the tracked release-state manifest` (currently `1.0.0-alpha.10`, a new baseline —
30
48
  not a 0.x upgrade, with no migration path from 0.x). Pin that exact version
31
49
  when reproducibility matters (verify against the live registry with
32
50
  `npm view @openelement/create dist-tags.alpha`):
33
51
 
34
52
  ```bash
35
- npm create @openelement@1.0.0-alpha.9 my-app
53
+ npm create @openelement@1.0.0-alpha.10 my-app
36
54
  ```
37
55
 
38
56
  The generated starter pins the exact `@openelement/*` versions it was built
@@ -40,26 +58,6 @@ from in its `package.json` dependencies.
40
58
 
41
59
  The canonical install command is exported from `@openelement/create/install-command` (one builder, every documented copy derives from it).
42
60
 
43
- ## Tailwind form (the one scaffold question)
44
-
45
- The scaffold ships the **Tailwind-ON starter by default**: a preset-wired
46
- `vite.config.ts` (the `@openelement/router` Tailwind preset), the
47
- `app/styles/theme.css` `@theme` role sheet (semantic roles over the Tailwind
48
- default scale), and exact `tailwindcss` / `@tailwindcss/vite` pins in
49
- `devDependencies`. Interactively the CLI asks exactly one question —
50
- `Enable Tailwind CSS + @theme role sheet? (Y/n)` — and every non-interactive
51
- run (CI, packed consumers) takes the same `Y` default. Pass a flag to skip the
52
- question; the flags reach the generator through the spellings that forward
53
- trailing arguments (`npx`, `pnpm dlx`, or a directly invoked bin):
54
-
55
- ```bash
56
- npx @openelement/create@alpha my-app --no-tailwind # the minimal starter
57
- npx @openelement/create@alpha my-app --tailwind # explicit ON (the default)
58
- ```
59
-
60
- `--no-tailwind` generates the pre-#1524 minimal starter: no Tailwind
61
- dependency surface, no preset wiring, no role sheet.
62
-
63
61
  ## The bootstrap is a plain npm invocation; the generated project is Node
64
62
 
65
63
  The documented bootstrap runs the generator through `npm create` (or the
@@ -94,30 +92,37 @@ npm create @openelement@0.43 my-app
94
92
  - **Generated project:** Node.js 24.2+ (the floor the packed `@openelement/*`
95
93
  engines declare and CI exercises; `.node-version` pins the development
96
94
  line) and pnpm for the lifecycle scripts.
95
+ - **git (optional):** `git init` runs by default and skips silently when git
96
+ is not on PATH.
97
97
 
98
98
  ## What It Creates
99
99
 
100
100
  - `package.json` - starter dependencies (exact `@openelement/*` release pins)
101
- and the lifecycle scripts (`dev`/`check`/`test`/`build`/`start`/`preview`);
102
- the default (Tailwind-ON) form adds the exact `tailwindcss` and
103
- `@tailwindcss/vite` dev pins
101
+ and the lifecycle scripts (`dev`/`check`/`test`/`build`/`start`/`preview`)
104
102
  - `tsconfig.json` - the type-check surface for `pnpm check`: JSX authoring
105
103
  through the element import source, whole-`app/` coverage
106
- - `vite.config.ts` - Vite build configuration. On the default (Tailwind-ON)
107
- form it also applies the router's public Tailwind preset so the role sheet
108
- compiles into the linked bundle; framework options still have exactly one
109
- home:
104
+ - `vite.config.ts` - Vite build configuration only; framework options still
105
+ have exactly one home:
110
106
  - `openelement.config.ts` - the framework options. It is OPTIONAL and nearly
111
107
  empty by default; every option it omits comes from a file convention —
112
- design tokens from `app/styles/tokens.css`, the app shell from
113
- `app/islands/app-shell.tsx`, structural document-head content from
114
- `app/head.tsx`, the site title from `package.json`. Passing framework
115
- options inline to `openElement()` while this file carries options is a hard
116
- error, and an unknown key fails the build with the accepted-key list.
117
- - `app/` - application directory with starter pages and islands; the
118
- Tailwind-ON form adds `app/styles/theme.css`, the `@theme` role sheet
119
- - `app/routes/blog/` - the sample blog as compiled page routes (`index` list
120
- and `welcome` post), prerendered at build time
108
+ design tokens from `app/styles/theme.css` (the @theme role sheet), structural document-head
109
+ content from `app/head.tsx`, the site title from `package.json`. Passing
110
+ framework options inline to `openElement()` while this file carries options
111
+ is a hard error, and an unknown key fails the build with the accepted-key
112
+ list.
113
+ - `app/` - the showcase application:
114
+ - `app/routes/` — page routes (`/`, `/about`, the styled 404), prerendered
115
+ at build time (SSG)
116
+ - `app/routes/api/ping.ts` — a request-time server route returning
117
+ `Response.json`
118
+ - `app/islands/` — the two islands (`my-counter` hydrating on idle,
119
+ `live-timer` client-only), the only code that ships JavaScript
120
+ - `app/components/` — compiled page elements and their style sheets
121
+ (`.css` files next to each element; `site-chrome.css`/`badges.css` are
122
+ the shared sheets)
123
+ - `app/styles/theme.css` — the @theme role sheet, Tailwind-ON single-default
124
+ scaffold form (dark values ride
125
+ `prefers-color-scheme`)
121
126
  - `public/` - static assets
122
127
  - `README.md` and `.gitignore` - starter docs and ignore rules
123
128
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openelement/create",
3
- "version": "1.0.0-alpha.10",
3
+ "version": "1.0.0-alpha.11",
4
4
  "type": "module",
5
5
  "main": "./src/cli.js",
6
6
  "types": "./src/cli.d.ts",
package/src/cli.js CHANGED
@@ -1,27 +1,36 @@
1
1
  #!/usr/bin/env node
2
2
  import { buildTemplates, resolveVersions, validateProjectName } from "./template-builder.js";
3
3
  import { createInstallCommand } from "./install-command.js";
4
+ import { detectPackageManager } from "./pm.js";
5
+ import { spawn, spawnSync } from "node:child_process";
6
+ import { existsSync } from "node:fs";
4
7
  import { mkdir, stat, writeFile } from "node:fs/promises";
5
8
  import process from "node:process";
6
9
  import readline from "node:readline/promises";
7
10
  //#region src/cli.ts
8
11
  /**
9
- * @openelement/create - Minimal project scaffold for openElement framework.
12
+ * @openelement/create - project scaffold for the openElement framework.
10
13
  *
11
14
  * The install command this CLI documents is built by ./install-command.ts
12
15
  * (#1414): usage output, the guides and the homepage all render that one
13
16
  * string, so the documented command cannot drift from the shipped flags.
14
17
  *
15
- * openElement Architecture: Keep It Simple, Stupid.
16
- * One template, one question, instant start. The single question is the
17
- * Tailwind form (#1524): the default (and every non-interactive run) ships
18
- * the Tailwind-ON starter — preset-wired vite config, @theme role sheet, and
19
- * the exact tailwindcss/@tailwindcss/vite pins; `--no-tailwind` keeps the
20
- * pre-#1524 minimal template.
18
+ * One template (#1530): the showcase starter — a static-first landing page
19
+ * with two islands, a fully static About page, and an /api/ping server route.
20
+ * The interactive surface is one confirmation (the template) on a TTY; every
21
+ * other behavior is a flag with a default, so CI and packed consumers run
22
+ * without a prompt.
23
+ *
24
+ * Post-scaffold lifecycle: git init (default), dependency install via the
25
+ * detected package manager (pnpm first, then npm — default on), an optional
26
+ * dev-server start (--start), and a boxed handoff naming the next commands.
21
27
  *
22
28
  * L9: every failure mode exits 1 with one actionable message — never a
23
29
  * runtime stack trace.
24
30
  */
31
+ /** The one scaffold template (#1530). `-t/--template` pins it non-interactively. */
32
+ const TEMPLATE_NAME = "showcase";
33
+ const DOCS_URL = "https://openelement.org";
25
34
  function errorMessage(error) {
26
35
  return error instanceof Error ? error.message : String(error);
27
36
  }
@@ -46,54 +55,155 @@ function dirnameOf(path) {
46
55
  if (idx <= 0) return ".";
47
56
  return path.slice(0, idx);
48
57
  }
49
- /** The CLI flags and the project-name positional, parsed without a library. */
58
+ /** Pairwise flag reconciliation: a flag and its negation cannot both appear. */
59
+ function setExclusiveFlag(current, incoming, pair) {
60
+ if (current !== void 0 && current !== incoming) fail(`--${incoming ? "" : "no-"}${pair} and --${incoming ? "no-" : ""}${pair} are mutually exclusive.`);
61
+ return incoming;
62
+ }
63
+ /**
64
+ * The CLI flags and the project-name positional, parsed without a library.
65
+ * Unknown dash-args are rejected (L9) instead of silently ignored; only
66
+ * --help/-h short-circuits before parsing.
67
+ */
50
68
  function parseArgs(argv) {
51
- let name;
52
- let tailwind;
53
- for (const arg of argv) if (arg === "--tailwind") tailwind = true;
54
- else if (arg === "--no-tailwind") tailwind = false;
55
- else if (arg.startsWith("-")) continue;
56
- else if (name === void 0) name = arg;
57
- return {
58
- name,
59
- tailwind
69
+ const flags = {
70
+ start: false,
71
+ help: false
60
72
  };
73
+ for (let i = 0; i < argv.length; i++) {
74
+ let arg = argv[i];
75
+ if (arg.startsWith("--template=")) {
76
+ argv = [
77
+ ...argv.slice(0, i),
78
+ "--template",
79
+ arg.slice(11),
80
+ ...argv.slice(i + 1)
81
+ ];
82
+ arg = "--template";
83
+ }
84
+ switch (arg) {
85
+ case "-h":
86
+ case "--help":
87
+ flags.help = true;
88
+ break;
89
+ case "-t":
90
+ case "--template": {
91
+ const value = argv[++i];
92
+ if (value === void 0) fail(`--template requires a value (the template name).`);
93
+ flags.template = value;
94
+ break;
95
+ }
96
+ case "--install":
97
+ flags.install = setExclusiveFlag(flags.install, true, "install");
98
+ break;
99
+ case "--no-install":
100
+ flags.install = setExclusiveFlag(flags.install, false, "install");
101
+ break;
102
+ case "--start":
103
+ flags.start = true;
104
+ break;
105
+ case "--git":
106
+ flags.git = setExclusiveFlag(flags.git, true, "git");
107
+ break;
108
+ case "--no-git":
109
+ flags.git = setExclusiveFlag(flags.git, false, "git");
110
+ break;
111
+ default:
112
+ if (arg.startsWith("-")) fail(`Unknown flag "${arg}". Run with --help to see the available flags (a project name is a bare positional).`);
113
+ if (flags.name !== void 0) fail(`Unexpected extra argument "${arg}" — the project name is the single positional.`);
114
+ flags.name = arg;
115
+ }
116
+ }
117
+ return flags;
118
+ }
119
+ function printUsage() {
120
+ console.log(`Usage (Alpha): ${createInstallCommand()}`);
121
+ console.log("(a versionless install resolves the stable 0.43 line)");
122
+ console.log(` -t, --template <name> scaffold template (default: ${TEMPLATE_NAME})`);
123
+ console.log(" --install / --no-install");
124
+ console.log(" install dependencies after scaffolding (default: install)");
125
+ console.log(" --start start the dev server after a successful install");
126
+ console.log(" --git / --no-git initialize a git repository (default: git init)");
127
+ console.log(" -h, --help show this help");
61
128
  }
62
129
  /**
63
- * Resolve the Tailwind form: a flag wins without prompting; otherwise a TTY
64
- * asks the one scaffold question (default Y), and a non-TTY run (CI, packed
65
- * consumers) takes the same default without prompting.
130
+ * Resolve the template: a flag wins without prompting; a TTY confirms the
131
+ * choice with the one scaffold question (default accepts); a non-TTY run
132
+ * (CI, packed consumers) takes the default without prompting.
66
133
  */
67
- async function resolveTailwindForm(flag) {
68
- if (flag !== void 0) return flag;
69
- if (!process.stdin.isTTY || !process.stdout.isTTY) return true;
134
+ async function resolveTemplate(flag) {
135
+ if (flag !== void 0) {
136
+ if (flag !== TEMPLATE_NAME) fail(`Unknown template "${flag}". The available template is: ${TEMPLATE_NAME}.`);
137
+ return flag;
138
+ }
139
+ if (!process.stdin.isTTY || !process.stdout.isTTY) return TEMPLATE_NAME;
70
140
  const rl = readline.createInterface({
71
141
  input: process.stdin,
72
142
  output: process.stdout
73
143
  });
74
144
  try {
75
145
  for (;;) {
76
- const answer = (await rl.question("Enable Tailwind CSS + @theme role sheet? (Y/n) ")).trim().toLowerCase();
77
- if (answer === "" || answer === "y" || answer === "yes") return true;
78
- if (answer === "n" || answer === "no") return false;
79
- console.info(" please answer y (default) or n");
146
+ const answer = (await rl.question(`Template to scaffold (${TEMPLATE_NAME}): `)).trim();
147
+ if (answer === "") return TEMPLATE_NAME;
148
+ if (answer === TEMPLATE_NAME) return answer;
149
+ console.info(` unknown template "${answer}" — available: ${TEMPLATE_NAME}`);
80
150
  }
81
151
  } finally {
82
152
  rl.close();
83
153
  }
84
154
  }
155
+ /**
156
+ * `git init` in the scaffolded project. Git unavailable (ENOENT) is a silent
157
+ * skip (the ask's contract); any other failure prints one note line and keeps
158
+ * the scaffold successful — the repository is a convenience, not the product.
159
+ */
160
+ function initGitRepository(targetDir, relativeTarget) {
161
+ const result = spawnSync("git", ["init"], {
162
+ cwd: targetDir,
163
+ stdio: "ignore"
164
+ });
165
+ if (result.error !== void 0) {
166
+ if (result.error.code === "ENOENT") return;
167
+ console.info(` note: git init could not run (${errorMessage(result.error)}); skipping.`);
168
+ return;
169
+ }
170
+ if (result.status !== 0) {
171
+ console.info(` note: git init exited ${result.status ?? "unknown"} in ${relativeTarget}; skipping.`);
172
+ return;
173
+ }
174
+ console.info(" initialized git repository (with .gitignore)");
175
+ }
176
+ /** The boxed end-of-run handoff: where to go, what to run, where to read. */
177
+ function printHandoff(relativeTarget, pm, startRequested) {
178
+ const devCommand = pm ? `${pm} run dev` : "pnpm run dev";
179
+ const lines = [
180
+ "openElement project ready",
181
+ "",
182
+ `cd ${relativeTarget}`,
183
+ `${devCommand} # start the dev server`,
184
+ "",
185
+ `Docs: ${DOCS_URL}`
186
+ ];
187
+ if (startRequested) lines.push("", "The dev server is starting — press Ctrl-C to stop it.");
188
+ const width = Math.max(...lines.map((line) => line.length));
189
+ console.info(`┌─${"─".repeat(width)}─┐`);
190
+ for (const line of lines) console.info(`│ ${line.padEnd(width)} │`);
191
+ console.info(`└─${"─".repeat(width)}─┘`);
192
+ }
85
193
  async function main() {
86
- const argv = process.argv.slice(2);
87
- const { name: positionalName, tailwind: tailwindFlag } = parseArgs(argv);
88
- const name = positionalName;
89
- if (!name || name === "--help" || name === "-h") {
90
- console.log(`Usage (Alpha): ${createInstallCommand()}`);
91
- console.log("(a versionless install resolves the stable 0.43 line)");
92
- console.log(" --tailwind ship the Tailwind-ON starter (default)");
93
- console.log(" --no-tailwind ship the minimal starter without Tailwind");
94
- process.exit(name ? 0 : 1);
194
+ const flags = parseArgs(process.argv.slice(2));
195
+ if (flags.help) {
196
+ printUsage();
197
+ process.exit(0);
198
+ }
199
+ if (flags.start && flags.install === false) fail("--start needs the dependencies installed; drop --no-install (or scaffold first and run the dev server manually inside the project directory).");
200
+ const name = flags.name;
201
+ if (!name) {
202
+ console.error("error: a project name is required.");
203
+ console.error("");
204
+ printUsage();
205
+ process.exit(1);
95
206
  }
96
- if (argv.includes("--tailwind") && argv.includes("--no-tailwind")) fail("--tailwind and --no-tailwind are mutually exclusive.");
97
207
  const invalid = validateProjectName(name);
98
208
  if (invalid) fail(`Invalid project name "${name}". ${invalid}`);
99
209
  const targetDir = `${process.cwd().replace(/\/+$/, "")}/${name}`;
@@ -105,11 +215,11 @@ async function main() {
105
215
  } catch (error) {
106
216
  if (!isNotFound(error)) throw new Error(`Could not inspect target directory "${name}": ${errorMessage(error)}`);
107
217
  }
108
- const tailwind = await resolveTailwindForm(tailwindFlag);
218
+ const template = await resolveTemplate(flags.template);
109
219
  const v = resolveVersions();
110
220
  try {
111
221
  await mkdir(targetDir, { recursive: true });
112
- const TPL = await buildTemplates(v, name, { tailwind });
222
+ const TPL = await buildTemplates(v, name);
113
223
  for (const [path, content] of Object.entries(TPL)) {
114
224
  const fullPath = joinPosix(targetDir, path);
115
225
  await mkdir(dirnameOf(fullPath), { recursive: true });
@@ -120,12 +230,34 @@ async function main() {
120
230
  const detail = isPermissionDenied(error) ? `Permission denied. Check write permissions for ${targetDir}.` : errorMessage(error);
121
231
  throw new Error(`Failed to write project files in "${name}": ${detail} Remove the partially created directory before retrying.`);
122
232
  }
123
- console.info(`\nopenElement project created at ./${relativeTarget}/`);
124
- console.info(tailwind ? " Tailwind: ON — app/styles/theme.css carries the @theme role sheet." : " Tailwind: OFF — minimal starter, no Tailwind dependency surface.");
125
- console.info(`\n cd ${relativeTarget}`);
126
- console.info(" pnpm install");
127
- console.info(" pnpm dev");
128
- console.info(" See README.md for all scripts (check/test/build/start/preview)");
233
+ console.info(`\nopenElement project created at ./${relativeTarget}/ (template: ${template})`);
234
+ if (flags.git !== false) {
235
+ if (!existsSync(joinPosix(targetDir, ".gitignore"))) fail("The scaffold did not write .gitignore; refusing to initialize a repository that would track build output. Remove the directory and retry.");
236
+ initGitRepository(targetDir, relativeTarget);
237
+ }
238
+ let pm = null;
239
+ if (flags.install !== false) {
240
+ pm = detectPackageManager();
241
+ console.info(`\nInstalling dependencies with ${pm}...`);
242
+ const install = spawnSync(pm, ["install"], {
243
+ cwd: targetDir,
244
+ stdio: "inherit",
245
+ shell: process.platform === "win32"
246
+ });
247
+ if (install.error !== void 0) fail(`Could not run ${pm} (${errorMessage(install.error)}). The project files are complete at ./${relativeTarget}/ — install manually with: cd ${relativeTarget} && ${pm} install`);
248
+ if (install.status !== 0) fail(`${pm} install exited ${install.status ?? "unknown"}. The project files are complete at ./${relativeTarget}/ — inspect the output above, then retry manually with: cd ${relativeTarget} && ${pm} install`);
249
+ }
250
+ printHandoff(relativeTarget, pm, flags.start);
251
+ if (flags.start) {
252
+ if (pm === null) fail("--start needs a package manager; installation was skipped.");
253
+ const dev = spawn(pm, ["run", "dev"], {
254
+ cwd: targetDir,
255
+ stdio: "inherit",
256
+ shell: process.platform === "win32"
257
+ });
258
+ const code = await new Promise((resolve) => dev.once("exit", (c) => resolve(c ?? 1)));
259
+ process.exitCode = code;
260
+ }
129
261
  }
130
262
  try {
131
263
  await main();
package/src/pm.js ADDED
@@ -0,0 +1,30 @@
1
+ import { spawnSync } from "node:child_process";
2
+ import process from "node:process";
3
+ //#region src/pm.ts
4
+ /**
5
+ * Package-manager detection for the create CLI's install/start steps.
6
+ *
7
+ * A separate module (not cli.ts): the module is imported by the tests, and
8
+ * cli.ts executes the CLI at import time (top-level main), so anything the
9
+ * tests need to call must live beside it, not inside it.
10
+ */
11
+ /** One package-manager probe: spawn `<pm> --version` off-PATH failures give ENOENT. */
12
+ function packageManagerAvailable(pm) {
13
+ const probe = spawnSync(pm, ["--version"], {
14
+ stdio: "ignore",
15
+ shell: process.platform === "win32"
16
+ });
17
+ return probe.error === void 0 && probe.status === 0;
18
+ }
19
+ /**
20
+ * Package-manager detection (pnpm wins, npm is the floor). Both ship with
21
+ * Node-adjacent toolchains; the first probe that answers --version wins.
22
+ * Never returns: with no manager the CLI fails with the manual-install path.
23
+ */
24
+ function detectPackageManager() {
25
+ for (const pm of ["pnpm", "npm"]) if (packageManagerAvailable(pm)) return pm;
26
+ console.error("error: No package manager found (probed pnpm, then npm). Install one of them, then run the install step manually inside the project directory.");
27
+ process.exit(1);
28
+ }
29
+ //#endregion
30
+ export { detectPackageManager };
@@ -1,4 +1,4 @@
1
- import { CREATE_VERSION, TAILWIND_STARTER_PIN, VITE_STARTER_PIN } from "./version.js";
1
+ import { CREATE_VERSION, VITE_STARTER_PIN } from "./version.js";
2
2
  import { readFile } from "node:fs/promises";
3
3
  //#region src/template-builder.ts
4
4
  const MAX_PROJECT_NAME_LENGTH = 214;
@@ -41,100 +41,50 @@ const TEMPLATE_FILES = [
41
41
  ["tsconfig.json.tmpl", "tsconfig.json"],
42
42
  ["vite.config.ts.tmpl", "vite.config.ts"],
43
43
  ["openelement.config.ts.tmpl", "openelement.config.ts"],
44
- ["app/styles/tokens.css", "app/styles/tokens.css"],
44
+ ["app/styles/theme.css", "app/styles/theme.css"],
45
+ ["app/styles/recipes.css", "app/styles/recipes.css"],
45
46
  ["app/head.tsx.tmpl", "app/head.tsx"],
46
- ["app/islands/app-shell.tsx.tmpl", "app/islands/app-shell.tsx"],
47
- ["app/components/page-styles.ts.tmpl", "app/components/page-styles.ts"],
47
+ ["app/components/page-home.css", "app/components/page-home.css"],
48
+ ["app/components/page-about.css", "app/components/page-about.css"],
49
+ ["app/components/page-404.css", "app/components/page-404.css"],
50
+ ["app/components/badges.css", "app/components/badges.css"],
51
+ ["app/components/site-chrome.css", "app/components/site-chrome.css"],
48
52
  ["app/components/page-home.tsx.tmpl", "app/components/page-home.tsx"],
49
- ["app/components/page-freshness.tsx.tmpl", "app/components/page-freshness.tsx"],
53
+ ["app/components/page-about.tsx.tmpl", "app/components/page-about.tsx"],
50
54
  ["app/components/page-404.tsx.tmpl", "app/components/page-404.tsx"],
51
- ["app/components/page-contact.tsx.tmpl", "app/components/page-contact.tsx"],
52
- ["app/components/page-blog-index.tsx.tmpl", "app/components/page-blog-index.tsx"],
53
- ["app/components/page-blog-welcome.tsx.tmpl", "app/components/page-blog-welcome.tsx"],
54
- ["app/routes/404.tsx.tmpl", "app/routes/404.tsx"],
55
55
  ["app/routes/index.tsx.tmpl", "app/routes/index.tsx"],
56
- ["app/routes/freshness.tsx.tmpl", "app/routes/freshness.tsx"],
57
- ["app/routes/contact.tsx.tmpl", "app/routes/contact.tsx"],
58
- ["app/routes/blog/index.tsx.tmpl", "app/routes/blog/index.tsx"],
59
- ["app/routes/blog/welcome.tsx.tmpl", "app/routes/blog/welcome.tsx"],
60
- ["app/routes/api/health.ts.tmpl", "app/routes/api/health.ts"],
56
+ ["app/routes/about.tsx.tmpl", "app/routes/about.tsx"],
57
+ ["app/routes/404.tsx.tmpl", "app/routes/404.tsx"],
58
+ ["app/routes/api/ping.ts.tmpl", "app/routes/api/ping.ts"],
61
59
  ["app/islands/my-counter.tsx.tmpl", "app/islands/my-counter.tsx"],
62
- ["app/islands/only-ticker.tsx.tmpl", "app/islands/only-ticker.tsx"]
60
+ ["app/islands/my-counter.css", "app/islands/my-counter.css"],
61
+ ["app/islands/live-timer.tsx.tmpl", "app/islands/live-timer.tsx"],
62
+ ["app/islands/live-timer.css", "app/islands/live-timer.css"]
63
63
  ];
64
- /**
65
- * The Tailwind-ON overlay (#1524): the default scaffold replaces the plain
66
- * vite config with the preset-wired one and adds the @theme role sheet. The
67
- * overlay lives in templates/tailwind/ so the OFF form stays exactly the
68
- * pre-#1524 minimal starter. theme.css carries no scaffold tokens (like
69
- * tokens.css), so it ships as a plain payload file.
70
- */
71
- const TAILWIND_TEMPLATE_FILES = [["tailwind/vite.config.ts.tmpl", "vite.config.ts"], ["tailwind/theme.css", "app/styles/theme.css"]];
72
- /** The README section token the Tailwind-ON prose replaces (OFF removes it). */
73
- const TAILWIND_README_TOKEN = "${tailwind.section}";
74
- /** The devDependencies the Tailwind-ON scaffold adds (exact pins, no ranges). */
75
- const TAILWIND_DEV_DEPENDENCIES = {
76
- "@tailwindcss/vite": TAILWIND_STARTER_PIN,
77
- tailwindcss: TAILWIND_STARTER_PIN
78
- };
79
64
  function versionTokens(v) {
80
65
  return {
81
66
  ["${v.router}"]: v.router,
82
67
  ["${v.element}"]: v.element
83
68
  };
84
69
  }
85
- async function buildTemplates(v, projectName, options = {}) {
70
+ async function buildTemplates(v, projectName) {
86
71
  assertUnifiedProductVersions(v);
87
72
  const invalid = validateProjectName(projectName);
88
73
  if (invalid) throw new Error(`Invalid project name "${projectName}". ${invalid}`);
89
- const tailwind = options.tailwind ?? true;
90
74
  const templatesBase = new URL("../templates/", import.meta.url);
91
75
  const tokens = {
92
76
  ...versionTokens(v),
93
77
  ["${v.vite}"]: VITE_STARTER_PIN,
94
- ["${name}"]: projectName,
95
- [TAILWIND_README_TOKEN]: tailwind ? tailwindReadmeSection() : ""
78
+ ["${name}"]: projectName
96
79
  };
97
- const files = tailwind ? [...TEMPLATE_FILES, ...TAILWIND_TEMPLATE_FILES] : TEMPLATE_FILES;
98
- const entries = await Promise.all(files.map(async ([source, target]) => {
80
+ const entries = await Promise.all(TEMPLATE_FILES.map(async ([source, target]) => {
99
81
  let content = await readFile(new URL(source, templatesBase), "utf8");
100
82
  for (const [token, value] of Object.entries(tokens)) if (content.includes(token)) content = content.split(token).join(value);
101
- if (content.includes("${v.") || content.includes("${name}") || content.includes("${tailwind.")) throw new Error(`Unresolved scaffold token in starter template: ${source}`);
83
+ if (content.includes("${v.") || content.includes("${name}")) throw new Error(`Unresolved scaffold token in starter template: ${source}`);
102
84
  return [target, content];
103
85
  }));
104
- const byTarget = new Map(entries);
105
- if (tailwind) {
106
- const manifestPath = "package.json";
107
- const manifest = JSON.parse(byTarget.get(manifestPath));
108
- manifest.devDependencies = Object.fromEntries(Object.entries({
109
- ...manifest.devDependencies,
110
- ...TAILWIND_DEV_DEPENDENCIES
111
- }).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0));
112
- byTarget.set(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`);
113
- }
114
- const out = Object.fromEntries(byTarget);
86
+ const out = Object.fromEntries(entries);
115
87
  return Object.fromEntries(Object.entries(out).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0));
116
88
  }
117
- /**
118
- * The README prose the Tailwind-ON scaffold injects (the OFF form removes the
119
- * token line). One source here, so the generated README and the tests cannot
120
- * drift apart. The leading/trailing newline keeps the injected heading
121
- * blank-line separated in both replacements.
122
- */
123
- function tailwindReadmeSection() {
124
- return `
125
- ## Tailwind and the @theme role sheet
126
-
127
- This project was scaffolded with Tailwind enabled (pass \`--no-tailwind\` to
128
- \`@openelement/create\` for a starter without it). \`app/styles/theme.css\` is
129
- the @theme role sheet: semantic roles (background, primary, muted, ...) over
130
- the Tailwind default scale, with dark pairs and a forced-colors layer. The
131
- router's Tailwind preset compiles the sheet into one linked bundle during
132
- \`pnpm build\` and references it from every rendered page; the custom
133
- properties inherit into every shadow root, so pages and islands can consume
134
- the roles directly. \`pnpm dev\` serves the tokens convention instead — the
135
- compiled bundle exists in the build output. Extend the sheet by adding role
136
- lines; \`@openelement/ui\`'s theme.css documents the same contract.
137
- `;
138
- }
139
89
  //#endregion
140
- export { TAILWIND_DEV_DEPENDENCIES, TAILWIND_README_TOKEN, assertUnifiedProductVersions, buildTemplates, resolveVersions, validateProjectName };
90
+ export { assertUnifiedProductVersions, buildTemplates, resolveVersions, validateProjectName };
package/src/version.js CHANGED
@@ -1,6 +1,6 @@
1
1
  //#region src/version.ts
2
2
  /** The published CLI version, embedded so packed npm installs are self-contained. */
3
- const CREATE_VERSION = "1.0.0-alpha.10";
3
+ const CREATE_VERSION = "1.0.0-alpha.11";
4
4
  /**
5
5
  * The Vite release pinned into the generated starter's package.json (the
6
6
  * `${v.vite}` scaffold token in the npm/pnpm starter). Embedded for the same
@@ -9,15 +9,5 @@ const CREATE_VERSION = "1.0.0-alpha.10";
9
9
  * to the canonical dev pin.
10
10
  */
11
11
  const VITE_STARTER_PIN = "8.0.16";
12
- /**
13
- * The Tailwind line pinned into the generated starter's devDependencies (the
14
- * Tailwind-ON scaffold, #1524): both `tailwindcss` and `@tailwindcss/vite`,
15
- * exactly, aligned with the router's own dev pins. The 4.3.x line is the
16
- * preset's supported line (the v3-lts line is forbidden — see the router's
17
- * preset-tailwind module). Embedded like the other pins so packed npm
18
- * installs stay self-contained; the create tests anchor this copy to the
19
- * router manifest the way deps:vite-check anchors VITE_STARTER_PIN.
20
- */
21
- const TAILWIND_STARTER_PIN = "4.3.3";
22
12
  //#endregion
23
- export { CREATE_VERSION, TAILWIND_STARTER_PIN, VITE_STARTER_PIN };
13
+ export { CREATE_VERSION, VITE_STARTER_PIN };