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

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 (45) hide show
  1. package/README.md +67 -60
  2. package/package.json +1 -1
  3. package/src/cli.js +177 -45
  4. package/src/install-command.d.ts +18 -10
  5. package/src/install-command.js +19 -12
  6. package/src/pm.js +30 -0
  7. package/src/template-builder.js +21 -71
  8. package/src/version.js +2 -12
  9. package/templates/README.tmpl +84 -48
  10. package/templates/app/components/badges.css +5 -0
  11. package/templates/app/components/page-404.css +7 -0
  12. package/templates/app/components/page-404.tsx.tmpl +32 -11
  13. package/templates/app/components/page-about.css +15 -0
  14. package/templates/app/components/page-about.tsx.tmpl +93 -0
  15. package/templates/app/components/page-home.css +23 -0
  16. package/templates/app/components/page-home.tsx.tmpl +113 -39
  17. package/templates/app/components/site-chrome.css +15 -0
  18. package/templates/app/head.tsx.tmpl +5 -15
  19. package/templates/app/islands/live-timer.css +9 -0
  20. package/templates/app/islands/live-timer.tsx.tmpl +54 -0
  21. package/templates/app/islands/my-counter.css +11 -0
  22. package/templates/app/islands/my-counter.tsx.tmpl +5 -21
  23. package/templates/app/routes/about.tsx.tmpl +10 -0
  24. package/templates/app/routes/api/ping.ts.tmpl +12 -0
  25. package/templates/app/routes/index.tsx.tmpl +2 -2
  26. package/templates/app/styles/recipes.css +43 -0
  27. package/templates/{tailwind → app/styles}/theme.css +83 -12
  28. package/templates/openelement.config.ts.tmpl +13 -3
  29. package/templates/package.json.tmpl +2 -0
  30. package/templates/tsconfig.json.tmpl +1 -0
  31. package/templates/vite.config.ts.tmpl +3 -3
  32. package/templates/app/components/page-blog-index.tsx.tmpl +0 -39
  33. package/templates/app/components/page-blog-welcome.tsx.tmpl +0 -57
  34. package/templates/app/components/page-contact.tsx.tmpl +0 -49
  35. package/templates/app/components/page-freshness.tsx.tmpl +0 -26
  36. package/templates/app/components/page-styles.ts.tmpl +0 -123
  37. package/templates/app/islands/app-shell.tsx.tmpl +0 -83
  38. package/templates/app/islands/only-ticker.tsx.tmpl +0 -51
  39. package/templates/app/routes/api/health.ts.tmpl +0 -7
  40. package/templates/app/routes/blog/index.tsx.tmpl +0 -10
  41. package/templates/app/routes/blog/welcome.tsx.tmpl +0 -7
  42. package/templates/app/routes/contact.tsx.tmpl +0 -36
  43. package/templates/app/routes/freshness.tsx.tmpl +0 -17
  44. package/templates/app/styles/tokens.css +0 -57
  45. package/templates/tailwind/vite.config.ts.tmpl +0 -38
package/README.md CHANGED
@@ -4,35 +4,55 @@ Project scaffolding CLI for openElement applications.
4
4
 
5
5
  Docs and guides: <https://openelement.org>.
6
6
 
7
- > 1.0 Alpha line: the supported creation entry for Element and Router. The
8
- > published npm versions and dist-tags are registry truth (query them with
9
- > `npm view @openelement/create dist-tags`); `latest` stays on the stable 0.43
10
- > line until a separately admitted stable release.
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.
7
+ > 1.0 line: the supported creation entry for Element and Router. The published
8
+ > npm versions and dist-tags are registry truth (query them with
9
+ > `npm view @openelement/create dist-tags`); `latest` rides the 1.0 line since
10
+ > the alpha.11 ruling, so a versionless install resolves the current 1.0
11
+ > prerelease.
12
+
13
+ `@openelement/create` generates a new openElement project from ONE template —
14
+ the showcase starter: a static-first landing page with two islands, a fully
15
+ static About page, an `/api/ping` server route, and a pure-CSS design-token
16
+ sheet (no Tailwind, no template variants). The generated project is a plain
17
+ Node/pnpm project.
15
18
 
16
19
  ## Usage (1.0 Alpha)
17
20
 
18
21
  ```bash
19
- npm create @openelement@alpha my-app
20
- cd my-app
21
- pnpm install
22
- pnpm dev
22
+ npm create @openelement my-app
23
+ ```
24
+
25
+ The CLI scaffolds, initializes git (when git is available), detects a package
26
+ manager (pnpm first, then npm), installs dependencies, and prints a boxed
27
+ handoff with the next commands. Flags (all optional):
28
+
29
+ | Flag | Default | Meaning |
30
+ | --- | --- | --- |
31
+ | `-t, --template <name>` | `showcase` | the template to scaffold; skips the interactive confirmation |
32
+ | `--install` / `--no-install` | install | dependency installation after scaffolding |
33
+ | `--start` | off | start the dev server after a successful install |
34
+ | `--git` / `--no-git` | git init | initialize a git repository (requires the scaffold's `.gitignore`) |
35
+
36
+ On a TTY the CLI asks exactly one question — confirming the template (Enter
37
+ accepts the default). Non-interactive runs (CI, packed consumers) skip the
38
+ prompt and take the defaults; pass `-t` to pin the template explicitly.
39
+
40
+ ```bash
41
+ npx @openelement/create my-app --no-install --no-git -t showcase
23
42
  ```
24
43
 
25
- `npm create @openelement@alpha` rides npm's initializer alias: a bare `@scope`
26
- resolves to `@scope/create` at the same tag, so the canonical spelling names
27
- the scope, and npm runs this package's generator. The version `@alpha` resolves
28
- to is registered in
29
- `the tracked release-state manifest` (currently `1.0.0-alpha.9`, a new baseline —
44
+ `npm create @openelement` rides npm's initializer alias: a bare `@scope`
45
+ resolves to `@scope/create` at the scope's default dist-tag — with no tag in
46
+ the command, that is `latest`, which the 1.0 line rides — so the canonical
47
+ spelling names no tag, and npm runs this package's generator. The version a
48
+ versionless install resolves is registered in
49
+ `the tracked release-state manifest` (currently `1.0.0-alpha.11`, a new baseline —
30
50
  not a 0.x upgrade, with no migration path from 0.x). Pin that exact version
31
51
  when reproducibility matters (verify against the live registry with
32
- `npm view @openelement/create dist-tags.alpha`):
52
+ `npm view @openelement/create dist-tags`):
33
53
 
34
54
  ```bash
35
- npm create @openelement@1.0.0-alpha.9 my-app
55
+ npm create @openelement@1.0.0-alpha.11 my-app
36
56
  ```
37
57
 
38
58
  The generated starter pins the exact `@openelement/*` versions it was built
@@ -40,26 +60,6 @@ from in its `package.json` dependencies.
40
60
 
41
61
  The canonical install command is exported from `@openelement/create/install-command` (one builder, every documented copy derives from it).
42
62
 
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
63
  ## The bootstrap is a plain npm invocation; the generated project is Node
64
64
 
65
65
  The documented bootstrap runs the generator through `npm create` (or the
@@ -70,8 +70,8 @@ generated project. The packed package ships two equivalent npm bins
70
70
  form must name one explicitly:
71
71
 
72
72
  ```bash
73
- npx @openelement/create@alpha my-app
74
- pnpm dlx --package=@openelement/create@alpha openelement-create my-app
73
+ npx @openelement/create my-app
74
+ pnpm dlx --package=@openelement/create openelement-create my-app
75
75
  ```
76
76
 
77
77
  The scaffolded project itself is Node-native: Node.js 24.2+ and
@@ -79,9 +79,9 @@ pnpm run its scripts.
79
79
 
80
80
  ## Stable 0.43 (maintenance line)
81
81
 
82
- The stable 0.43 line is still published, but it is not the Alpha install path.
83
- A versionless install resolves the npm `latest` dist-tag to it; pin the line
84
- explicitly instead:
82
+ The stable 0.43 line is still published, but it is not the 1.0 install path.
83
+ A versionless install resolves the npm `latest` dist-tag to the 1.0 line; pin
84
+ the maintenance line explicitly instead:
85
85
 
86
86
  ```bash
87
87
  npm create @openelement@0.43 my-app
@@ -94,30 +94,37 @@ npm create @openelement@0.43 my-app
94
94
  - **Generated project:** Node.js 24.2+ (the floor the packed `@openelement/*`
95
95
  engines declare and CI exercises; `.node-version` pins the development
96
96
  line) and pnpm for the lifecycle scripts.
97
+ - **git (optional):** `git init` runs by default and skips silently when git
98
+ is not on PATH.
97
99
 
98
100
  ## What It Creates
99
101
 
100
102
  - `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
103
+ and the lifecycle scripts (`dev`/`check`/`test`/`build`/`start`/`preview`)
104
104
  - `tsconfig.json` - the type-check surface for `pnpm check`: JSX authoring
105
105
  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:
106
+ - `vite.config.ts` - Vite build configuration only; framework options still
107
+ have exactly one home:
110
108
  - `openelement.config.ts` - the framework options. It is OPTIONAL and nearly
111
109
  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
110
+ design tokens from `app/styles/theme.css` (the @theme role sheet), structural document-head
111
+ content from `app/head.tsx`, the site title from `package.json`. Passing
112
+ framework options inline to `openElement()` while this file carries options
113
+ is a hard error, and an unknown key fails the build with the accepted-key
114
+ list.
115
+ - `app/` - the showcase application:
116
+ - `app/routes/` — page routes (`/`, `/about`, the styled 404), prerendered
117
+ at build time (SSG)
118
+ - `app/routes/api/ping.ts` — a request-time server route returning
119
+ `Response.json`
120
+ - `app/islands/` — the two islands (`my-counter` hydrating on idle,
121
+ `live-timer` client-only), the only code that ships JavaScript
122
+ - `app/components/` — compiled page elements and their style sheets
123
+ (`.css` files next to each element; `site-chrome.css`/`badges.css` are
124
+ the shared sheets)
125
+ - `app/styles/theme.css` — the @theme role sheet, Tailwind-ON single-default
126
+ scaffold form (dark values ride
127
+ `prefers-color-scheme`)
121
128
  - `public/` - static assets
122
129
  - `README.md` and `.gitignore` - starter docs and ignore rules
123
130
 
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.12",
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 latest — the current 1.0 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();
@@ -18,24 +18,32 @@ export declare const CREATE_PACKAGE_SPECIFIER = "@openelement/create";
18
18
  /**
19
19
  * The scope `npm create` resolves to {@linkcode CREATE_PACKAGE_SPECIFIER}:
20
20
  * npm's initializer alias maps a bare `@scope` (optionally `@scope@<tag>`) to
21
- * `@scope/create` at the same tag, so the canonical spelling never repeats the
22
- * `/create` suffix (owner-verified against npm's init alias rules).
21
+ * `@scope/create` at the same tag — untagged, at the scope's default dist-tag
22
+ * — so the canonical spelling never repeats the `/create` suffix
23
+ * (owner-verified against npm's init alias rules).
23
24
  */
24
25
  export declare const CREATE_NPM_CREATE_SCOPE = "@openelement";
25
- /** The dist-tag the documented install resolves; the exact version is registry truth. */
26
- export declare const CREATE_INSTALL_TAG = "alpha";
26
+ /**
27
+ * The dist-tag a versionless documented install resolves: npm's scope alias
28
+ * defaults to `latest`, which the 1.0 line rides since the alpha.11 ruling.
29
+ * The exact version is registry truth; the canonical spelling names no tag.
30
+ */
31
+ export declare const CREATE_INSTALL_TAG = "latest";
27
32
  /** Placeholder the usage text and the docs use in place of a project name. */
28
33
  export declare const CREATE_PROJECT_PLACEHOLDER = "<project-name>";
29
34
  /**
30
35
  * The documented install command shapes, all verified against the published
31
36
  * two-bin artifact (bins `openelement-create` and `create-openelement`, both
32
37
  * `src/cli.js`; npm 11 / pnpm 12):
33
- * - canonical: `npm create @openelement@<tag> <name>` — npm's `@scope`
34
- * initializer alias resolves it to `@openelement/create@<tag>` (#1507
35
- * revision, 2026-10-05; the former canonical `npm exec <pkg>@<tag> -- <name>`
36
- * remains a verified spelling through the same artifact)
37
- * - short form: `npx <pkg>@<tag> <name>`
38
- * - pnpm: `pnpm dlx --package=<pkg>@<tag> openelement-create <name>` — the
38
+ * - canonical: `npm create @openelement <name>` — versionless, so npm's
39
+ * `@scope` initializer alias resolves it to `@openelement/create` at the
40
+ * scope's default dist-tag `latest`, which the 1.0 line rides (the
41
+ * alpha.11 latest ruling). An explicit `@<tag>` remains a verified
42
+ * spelling for channel-specific copies (pins and other channels); the
43
+ * former canonical `npm exec <pkg>@<tag> -- <name>` remains a verified
44
+ * spelling through the same artifact (#1507 revision, 2026-10-05)
45
+ * - short form: `npx <pkg> <name>` (untagged resolves `latest`)
46
+ * - pnpm: `pnpm dlx --package=<pkg> openelement-create <name>` — the
39
47
  * explicit `--package` plus bin is required because the packed package
40
48
  * ships two bins, so a bare `pnpm dlx <pkg>` cannot resolve one (and no
41
49
  * package named `create-openelement` exists on the registry).
@@ -18,24 +18,32 @@ const CREATE_PACKAGE_SPECIFIER = "@openelement/create";
18
18
  /**
19
19
  * The scope `npm create` resolves to {@linkcode CREATE_PACKAGE_SPECIFIER}:
20
20
  * npm's initializer alias maps a bare `@scope` (optionally `@scope@<tag>`) to
21
- * `@scope/create` at the same tag, so the canonical spelling never repeats the
22
- * `/create` suffix (owner-verified against npm's init alias rules).
21
+ * `@scope/create` at the same tag — untagged, at the scope's default dist-tag
22
+ * — so the canonical spelling never repeats the `/create` suffix
23
+ * (owner-verified against npm's init alias rules).
23
24
  */
24
25
  const CREATE_NPM_CREATE_SCOPE = "@openelement";
25
- /** The dist-tag the documented install resolves; the exact version is registry truth. */
26
- const CREATE_INSTALL_TAG = "alpha";
26
+ /**
27
+ * The dist-tag a versionless documented install resolves: npm's scope alias
28
+ * defaults to `latest`, which the 1.0 line rides since the alpha.11 ruling.
29
+ * The exact version is registry truth; the canonical spelling names no tag.
30
+ */
31
+ const CREATE_INSTALL_TAG = "latest";
27
32
  /** Placeholder the usage text and the docs use in place of a project name. */
28
33
  const CREATE_PROJECT_PLACEHOLDER = "<project-name>";
29
34
  /**
30
35
  * The documented install command shapes, all verified against the published
31
36
  * two-bin artifact (bins `openelement-create` and `create-openelement`, both
32
37
  * `src/cli.js`; npm 11 / pnpm 12):
33
- * - canonical: `npm create @openelement@<tag> <name>` — npm's `@scope`
34
- * initializer alias resolves it to `@openelement/create@<tag>` (#1507
35
- * revision, 2026-10-05; the former canonical `npm exec <pkg>@<tag> -- <name>`
36
- * remains a verified spelling through the same artifact)
37
- * - short form: `npx <pkg>@<tag> <name>`
38
- * - pnpm: `pnpm dlx --package=<pkg>@<tag> openelement-create <name>` — the
38
+ * - canonical: `npm create @openelement <name>` — versionless, so npm's
39
+ * `@scope` initializer alias resolves it to `@openelement/create` at the
40
+ * scope's default dist-tag `latest`, which the 1.0 line rides (the
41
+ * alpha.11 latest ruling). An explicit `@<tag>` remains a verified
42
+ * spelling for channel-specific copies (pins and other channels); the
43
+ * former canonical `npm exec <pkg>@<tag> -- <name>` remains a verified
44
+ * spelling through the same artifact (#1507 revision, 2026-10-05)
45
+ * - short form: `npx <pkg> <name>` (untagged resolves `latest`)
46
+ * - pnpm: `pnpm dlx --package=<pkg> openelement-create <name>` — the
39
47
  * explicit `--package` plus bin is required because the packed package
40
48
  * ships two bins, so a bare `pnpm dlx <pkg>` cannot resolve one (and no
41
49
  * package named `create-openelement` exists on the registry).
@@ -45,8 +53,7 @@ const CREATE_PROJECT_PLACEHOLDER = "<project-name>";
45
53
  * invoked through plain Node tooling.
46
54
  */
47
55
  function createInstallCommand(projectName = CREATE_PROJECT_PLACEHOLDER, options = {}) {
48
- const tag = options.tag ?? "alpha";
49
- return `npm create ${CREATE_NPM_CREATE_SCOPE}@${tag} ${projectName}`;
56
+ return `npm create ${options.tag === void 0 ? CREATE_NPM_CREATE_SCOPE : `${CREATE_NPM_CREATE_SCOPE}@${options.tag}`} ${projectName}`;
50
57
  }
51
58
  //#endregion
52
59
  export { CREATE_INSTALL_TAG, CREATE_NPM_CREATE_SCOPE, CREATE_PACKAGE_SPECIFIER, CREATE_PROJECT_PLACEHOLDER, createInstallCommand };
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 };