@fusion.dev/create-helix-app 0.227.0 → 0.228.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.
Files changed (3) hide show
  1. package/README.md +10 -5
  2. package/bin.mjs +19 -2
  3. package/package.json +3 -3
package/README.md CHANGED
@@ -3,17 +3,22 @@
3
3
  Starts a Helix project.
4
4
 
5
5
  ```sh
6
- npm create @fusion.dev/helix-app@latest my-app
6
+ npm create @fusion.dev/helix-app@latest
7
7
  ```
8
8
 
9
- Named without a template, it lists the templates and writes nothing: a
10
- scaffolder that picks for you writes a project you didn't choose. Name one after
11
- `--`, which is how `npm create` passes a flag on rather than reading it itself:
9
+ It asks for a project name and a template, then writes the project. It prints the
10
+ commands that install and start it, for the package manager you ran it with.
11
+
12
+ Name both on the command line to skip the questions. Outside a terminal, such as
13
+ in a script, a missing name is an error and a missing template lists the templates
14
+ and writes nothing.
12
15
 
13
16
  ```sh
14
- npm create @fusion.dev/helix-app@latest my-app -- --template react-vite
17
+ npm create @fusion.dev/helix-app@latest my-app --template react-vite
15
18
  ```
16
19
 
20
+ The same command works with `yarn create`, `pnpm create`, and `bun create`.
21
+
17
22
  | Template | What it is |
18
23
  |---|---|
19
24
  | `react-vite` | React and TypeScript on Vite. The shortest path to a running app. |
package/bin.mjs CHANGED
@@ -95,7 +95,24 @@ const newer = () => {
95
95
  the registry only if it is slower than the scaffold. */
96
96
  const checking = newer()
97
97
 
98
- const running = spawn(process.execPath, [helix, 'new', ...process.argv.slice(2)], {
98
+ /**
99
+ * What was asked, with the template put back where npm took it from.
100
+ *
101
+ * **npm reads `--template` as its own setting.** It drops the flag and passes the
102
+ * value on, so `npm create @fusion.dev/helix-app my-app --template react-vite`
103
+ * arrives here as two bare words, and `helix new` refused the second. Nothing
104
+ * else is two bare words, so every package manager can use the one command.
105
+ */
106
+ const asked = (args) =>
107
+ args.length === 2 && !args.some((one) => one.startsWith('-'))
108
+ ? [args[0], '--template', args[1]]
109
+ : args
110
+
111
+ /** The package manager that ran this, from what each one sets, or npm. */
112
+ const manager = () =>
113
+ /^(bun|pnpm|yarn)\//.exec(process.env.npm_config_user_agent ?? '')?.[1] ?? 'npm'
114
+
115
+ const running = spawn(process.execPath, [helix, 'new', ...asked(process.argv.slice(2))], {
99
116
  env: { ...process.env, HELIX_TEMPLATES: process.env.HELIX_TEMPLATES ?? templates },
100
117
  stdio: 'inherit',
101
118
  })
@@ -109,7 +126,7 @@ running.on('close', async (status) => {
109
126
  if (latest !== undefined) {
110
127
  console.error(
111
128
  `\nHelix ${latest} is out, and this is ${own.version}. For the newest templates:\n\n` +
112
- ` npm create ${own.name.replace('create-', '')}@latest\n`,
129
+ ` ${manager()} create ${own.name.replace('create-', '')}@latest\n`,
113
130
  )
114
131
  }
115
132
  process.exit(status ?? 70)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fusion.dev/create-helix-app",
3
3
  "description": "Starts a Helix project: `npm create @fusion.dev/helix-app`, which is `helix new` for somebody with no project yet.",
4
- "version": "0.227.0",
4
+ "version": "0.228.0",
5
5
  "license": "MIT",
6
6
  "author": "Fusion Development Group",
7
7
  "repository": {
@@ -21,8 +21,8 @@
21
21
  },
22
22
  "bugs": "https://github.com/project-fusion/fusion/issues",
23
23
  "dependencies": {
24
- "@fusion.dev/helix-cli": "0.227.0",
25
- "@fusion.dev/helix-templates": "0.227.0"
24
+ "@fusion.dev/helix-cli": "0.228.0",
25
+ "@fusion.dev/helix-templates": "0.228.0"
26
26
  },
27
27
  "homepage": "https://fusion.dev",
28
28
  "keywords": [