create-vanilla-vite 1.1.0 → 1.2.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/CHANGELOG.md ADDED
@@ -0,0 +1,29 @@
1
+ # Changelog
2
+
3
+ ## 1.2.0 - 2026-11-11
4
+
5
+ - Added non-interactive scaffold options and optional Git initialization.
6
+ - Added the npm/pnpm scaffold smoke-test matrix and GitHub Actions CI.
7
+ - Added graceful backend shutdown and JSON error handling.
8
+ - Preserved child-process colors in the combined development runner.
9
+ - Made the `h` shortcut update LAN API and CORS environment settings for both workspaces.
10
+ - Added a frontend backend-health control when a backend is scaffolded.
11
+ - Preserved completed projects when cancelling the Git prompt and restored ignored env files from examples.
12
+ - Loaded backend `.env` files with dotenv and corrected TypeScript basic-server commands.
13
+ - Restricted Vite to port 5173 and added explicit Axios and icon-library selections.
14
+ - Shared basic Node routing/CORS logic across layouts and added JSON Express module routes and 404s.
15
+ - Defaulted dependency installation to the client and aligned pnpm build approvals with CI.
16
+ - Added highlighted dependency and shortcut banners to `npm run dev` / `pnpm dev`.
17
+ - Added `g` to cycle combined, side-by-side, and stacked log layouts; moved the dependency reminder out of scaffolding output.
18
+ - Replaced framed log panels with headings and simple dividers.
19
+ - Retained full development logs for the runner session across layout changes and app restarts.
20
+ - Recorded each development session in a root `.dev.log`, cleared at startup and used to redraw alternate log layouts.
21
+ - Cleaned up incomplete scaffolds on interruption and kept Vite config-shape mismatches non-fatal.
22
+ - Added bounded log replay, missing-env-template fallback, and consistent specific-origin CORS variation.
23
+ - Kept backend status controls development-only and documented strict-port and `--yes` update-check behavior.
24
+ - Expanded smoke checks for generated feature installs, CORS variation, and both pnpm build-approval keys.
25
+ - Changed the `c` development shortcut to clear the terminal and the current `.dev.log` contents.
26
+ - Added stricter CLI option validation, safe scaffold cancellation, install retry guidance, and Git-worktree detection.
27
+ - Added backend host binding and environment resets for reliable local and network hosting; protected active development logs with a runner lock.
28
+ - Expanded smoke coverage for frontend templates, fresh installs, CLI argument errors, and React lint scripts.
29
+ - Added bounded CI runs and release checks, smoke validation, pnpm version alignment, and npm provenance publishing.
package/README.md CHANGED
@@ -10,7 +10,7 @@ Create a Vite app with the official interactive setup. Choose React or any other
10
10
 
11
11
  ## Requirements
12
12
 
13
- - Node.js 20 or newer
13
+ - Node.js 20.6 or newer
14
14
  - npm or pnpm
15
15
 
16
16
  The commands below work in Windows PowerShell or Command Prompt as well as macOS and Linux terminals. pnpm commands require pnpm to be installed; npm is sufficient.
@@ -39,13 +39,51 @@ npm create vanilla-vite@latest
39
39
 
40
40
  The generator starts the official `create-vite@latest` wizard in `my-app-client`. Choose **React** for a React application, then select JavaScript or TypeScript. You can instead choose any other template offered by Vite. Afterward, choose whether to install Tailwind CSS v4 and Axios. For React templates, you can also choose React Router, which adds a `MainRouter` with Home and Login pages and navigation. The router starter uses Tailwind utility classes when Tailwind is selected, or a standalone stylesheet otherwise. You can also choose React Icons or `@animateicons/react`. The Yes option is preselected for each yes/no prompt, including adding a backend; choose No to skip an option. Frontend setup questions appear in cyan, and backend setup questions appear in yellow. The frontend wizard may install dependencies temporarily; the generator removes nested install files and Git metadata, configures one shared workspace, and installs all dependencies from the project root.
41
41
 
42
- The optional backend supports JavaScript or TypeScript, either basic Node.js or Express, and a simple or module-based folder layout. Express and the module-based layout are preselected by default; Express adds Express and dotenv, enables JSON parsing, and provides `GET /api/health`, returning `{ "status": "ok" }`. Both layouts create the `src/app` and `src/server` entry points. The simple layout has `routes`, `controllers`, `middleware`, and `config` folders; the module-based layout has `module`, `config`, `middleware`, and `utils` folders plus `mainRouter`. The `--default` flag selects the simple layout without prompting.
42
+ ### Non-interactive options
43
+
44
+ Use `--yes` to accept the default answers for generator prompts. It does not
45
+ answer the official create-vite template questions, so include `--template` to
46
+ skip those prompts as well. `--yes` also skips the npm update check. Individual
47
+ options select a value and skip that option's prompt:
48
+
49
+ ```bash
50
+ pnpm create vanilla-vite@latest my-app --yes --template=react --backend=basic --ts --structure=simple --tailwind --pm=pnpm
51
+ npm create vanilla-vite@latest my-app -- --template=react --backend=express --js --axios --icons=react-icons --router
52
+ ```
53
+
54
+ Available options are `--tailwind`, `--axios`, `--no-axios`, `--router`,
55
+ `--no-router`, and `--icons=react-icons|animateicons|none`;
56
+ `--backend=none|basic|express`; `--ts` or `--js` (these language flags apply
57
+ to the optional backend only);
58
+ `--structure=simple|module`; and `--pm=npm|pnpm`. `--no-tailwind` opts out of
59
+ Tailwind when using `--yes`. `--template=vanilla` passes a template directly to
60
+ create-vite. `--no-start` creates the project without starting its dev server.
61
+ The generator offers to initialize Git and make an initial commit; use
62
+ `--no-git` to skip this step.
63
+
64
+ The CLI checks npm for a newer version before scaffolding. Skip this check with
65
+ `--no-update-check`; it is also skipped automatically in CI. To avoid any
66
+ network exposure by default, Vite binds to localhost. Pass `--host` when
67
+ creating the project to make the frontend dev server available on your network:
68
+
69
+ ```bash
70
+ pnpm create vanilla-vite@latest my-app --host
71
+ npm create vanilla-vite@latest my-app -- --host
72
+ ```
73
+
74
+ For npm, also forward the update-check option with `--`:
75
+
76
+ ```bash
77
+ npm create vanilla-vite@latest my-app -- --no-update-check
78
+ ```
79
+
80
+ The optional backend supports JavaScript or TypeScript, either basic Node.js or Express, and a simple or module-based folder layout. Express and the module-based layout are preselected by default; Express adds Express, CORS, and dotenv, enables JSON parsing, and provides `GET /api/health`, returning `{ "status": "ok" }`. The basic Node.js server uses dotenv to load `.env`, supports CORS, returns the same health response, and responds with JSON 404s for unknown paths. In the Express module layout, `/` and `/api/health` return JSON and unknown paths return a JSON 404. When a backend is selected, the generated frontend includes a **Check connection** button that requests `/api/health` and reports whether the backend is reachable. This works with or without React Router and is omitted for frontend-only projects. Both backend layouts create the `src/app` and `src/server` entry points. The simple layout has `routes`, `controllers`, `middleware`, and `config` folders; the module-based layout has `module`, `config`, `middleware`, and `utils` folders plus `mainRouter`. The `--default` flag selects the simple layout without prompting.
43
81
 
44
82
  Pass `--default` after the project name to use the simple backend folder layout without prompting:
45
83
 
46
84
  ```bash
47
85
  pnpm create vanilla-vite@latest my-app --default
48
- npm create vanilla-vite@latest my-app --default
86
+ npm create vanilla-vite@latest my-app -- --default
49
87
  ```
50
88
 
51
89
  The generated project structure is:
@@ -59,7 +97,7 @@ my-app/
59
97
  └── pnpm-workspace.yaml # used by pnpm; npm uses package.json workspaces
60
98
  ```
61
99
 
62
- The frontend gets a `.env.local` file with `VITE_API_URL=http://localhost:4000`. If you choose a backend, it gets a `.env` file with `PORT=4000`. Both are ignored by Git.
100
+ The frontend gets a `.env.local` file with `VITE_API_URL=http://localhost:4000` and a tracked `.env.example` template. If you choose a backend, it gets a `.env` file with `PORT=4000`, `HOST=localhost`, and `CORS_ORIGIN=http://localhost:5173,http://127.0.0.1:5173`, plus its own `.env.example`. On startup, the development runner recreates either ignored local environment file from `.env.example` when it is missing. The local `.env` files are ignored by Git.
63
101
 
64
102
  ## Run the project
65
103
 
@@ -72,13 +110,18 @@ pnpm dev
72
110
  npm run dev
73
111
  ```
74
112
 
75
- This starts the frontend (bound to network interfaces with Vite's `--host` flag) and, if selected, the backend together. In an interactive terminal, press `r` to restart both apps, `c` to clear the terminal, or Ctrl+C to stop.
113
+ At startup, the runner displays the dependency commands and a highlighted shortcut panel. Only one development runner per project is supported; a second instance exits without clearing the active runner's log. Logs are combined by default. Press `g` to split client and server logs side by side with a divider, press it again to stack the logs with a horizontal divider, and once more to return to the combined view. The split layouts use headings and dividers rather than enclosing boxes. App output and runner notices are recorded in the root `.dev.log` file, which is cleared each time `dev` starts. New log lines append without clearing earlier output, including when either app restarts. Pressing `g` redraws the current view from that file. Press `r` to restart both apps, `h` to toggle network hosting, `c` to clear the terminal and empty `.dev.log`, or Ctrl+C to stop. Enabling `h` sets the client `VITE_API_URL` to the preferred LAN IPv4 address, binds the backend to `0.0.0.0`, and configures backend CORS for localhost and every detected IPv4 interface (including container bridges), then restarts both apps; disabling it restores localhost values. The selected hosting mode is kept when you later press `r`.
114
+ Pass `--host` when creating a project to start with network hosting enabled.
115
+ The generated Vite config enables `server.strictPort`; if port 5173 is already in
116
+ use, the client process stops with a port-in-use error rather than silently
117
+ switching ports.
76
118
 
77
- Run one workspace individually:
119
+ Run one workspace individually. Add `dev` to run it in development mode:
78
120
 
79
121
  ```bash
80
122
  pnpm client
81
123
  pnpm server
124
+ pnpm client dev
82
125
  ```
83
126
 
84
127
  Or with npm:
@@ -86,14 +129,27 @@ Or with npm:
86
129
  ```bash
87
130
  npm run client
88
131
  npm run server
132
+ npm run client -- dev
89
133
  ```
90
134
 
91
- The server commands are only available if you chose a backend. Add `-dev` to run a workspace in development mode, for example `pnpm client -dev` or `pnpm server -dev`.
135
+ The server commands are only available if you chose a backend.
136
+
137
+ Use the root `build` and `lint` scripts to run the matching script in every
138
+ workspace that defines it:
139
+
140
+ ```bash
141
+ pnpm build
142
+ pnpm lint
143
+ # or
144
+ npm run build
145
+ npm run lint
146
+ ```
92
147
 
93
148
  ## Add dependencies
94
149
 
95
150
  Always use one of these commands to add dependencies. The prompt lets you
96
- choose the project root, client, or server (if you created one):
151
+ choose the project root, client, or server (if you created one); the client is
152
+ selected by default, including when you press Esc:
97
153
 
98
154
  ```bash
99
155
  pnpm adD <package>
@@ -103,9 +159,12 @@ npm run add-dependency -- <package>
103
159
  ```
104
160
 
105
161
  Do not use `npm install`, `npm add`, `pnpm install`, or `pnpm add` directly to
106
- add packages. They bypass the location prompt or are blocked by the workspace
107
- install guard. npm requires `run` to invoke a project script, so `npm adD`
108
- without `run` is not valid.
162
+ add packages. They bypass the location prompt or may be blocked by the
163
+ workspace install guard. The guard runs only when the package manager invokes
164
+ the root `preinstall` hook; direct `npm install <package>` behavior varies by
165
+ npm version and is not blocked by versions that skip that hook. A failed or
166
+ aborted install can leave `node_modules` behind, causing a plain reinstall to
167
+ be blocked. Use one of the `adD` commands above to add dependencies.
109
168
 
110
169
  ## Development
111
170
 
@@ -119,6 +178,18 @@ pnpm exec node [Stored Path]/Vanilla-Vite/bin/create-template.mjs my-app
119
178
  npm exec -- node [Stored Path]/Vanilla-Vite/bin/create-template.mjs my-app
120
179
  ```
121
180
 
181
+ Run the scaffold smoke matrix (npm and pnpm, JavaScript and TypeScript,
182
+ frontend-only/basic Node/Express backends, with and without Tailwind) with:
183
+
184
+ ```bash
185
+ npm install
186
+ npm run test:smoke
187
+ ```
188
+
189
+ Use `npm run test:smoke -- --quick` for a smaller publish-time check,
190
+ `SMOKE_FILTER=<text> npm run test:smoke` to select matching cases, or
191
+ `SMOKE_KEEP=1 npm run test:smoke` to keep generated test projects for inspection.
192
+
122
193
  ## License
123
194
 
124
195
  ISC