create-davepi-ui 0.1.0 → 0.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/README.md +4 -4
- package/bin/index.js +10 -8
- package/bin/sync-templates.js +8 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ Scaffolder for new [davepi-ui](https://github.com/projik/davepi-ui) admin projec
|
|
|
7
7
|
```bash
|
|
8
8
|
npx create-davepi-ui my-admin --api-url http://localhost:4001
|
|
9
9
|
cd my-admin
|
|
10
|
-
|
|
10
|
+
npm run dev
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
## Flags
|
|
@@ -15,14 +15,14 @@ pnpm dev
|
|
|
15
15
|
| Flag | Default | Purpose |
|
|
16
16
|
|---|---|---|
|
|
17
17
|
| `--api-url <url>` | `http://localhost:4001` | davepi backend base URL written to `.env` |
|
|
18
|
-
| `--no-install` | off | Skip post-scaffold `
|
|
18
|
+
| `--no-install` | off | Skip post-scaffold `npm install` |
|
|
19
19
|
|
|
20
20
|
## What it does
|
|
21
21
|
|
|
22
|
-
1. Copies the bundled template (Vite + React Router + shadcn + `@davepi/ui-react`).
|
|
22
|
+
1. Copies the bundled template (Vite + React Router + shadcn + `@davepi/ui-react`). Lock files are filtered out so the scaffolded project picks its own package manager — npm by default, matching the davepi backend.
|
|
23
23
|
2. Rewrites `package.json` — pins `@davepi/ui-*` deps to the published versions matching this scaffolder, sets `private: true`, drops upstream repo metadata.
|
|
24
24
|
3. Writes `.env` with `VITE_API_URL`.
|
|
25
|
-
4. Runs `
|
|
25
|
+
4. Runs `npm install` (unless `--no-install`).
|
|
26
26
|
|
|
27
27
|
## License
|
|
28
28
|
|
package/bin/index.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* - rewrites `package.json` with the new project name + pinned
|
|
10
10
|
* published versions of @davepi/ui-* (no workspace: protocol)
|
|
11
11
|
* - writes `.env` carrying VITE_API_URL
|
|
12
|
-
* - runs `
|
|
12
|
+
* - runs `npm install` (skip with --no-install)
|
|
13
13
|
* - prints the next three commands
|
|
14
14
|
*
|
|
15
15
|
* No `inquirer`, no progress bars — keeps the failure surface small.
|
|
@@ -58,7 +58,7 @@ function usage() {
|
|
|
58
58
|
out('');
|
|
59
59
|
out('Flags:');
|
|
60
60
|
out(' --api-url <url> davepi backend base URL (default: http://localhost:4001)');
|
|
61
|
-
out(' --no-install skip the post-scaffold `
|
|
61
|
+
out(' --no-install skip the post-scaffold `npm install`');
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
function copyTree(src, dst, skip) {
|
|
@@ -198,16 +198,18 @@ function main() {
|
|
|
198
198
|
rewritePackageJson(pkgPath, name, resolvePinnedVersions());
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
-
// Write a starter `.env` so the user can run `
|
|
201
|
+
// Write a starter `.env` so the user can run `npm run dev` immediately.
|
|
202
202
|
fs.writeFileSync(path.join(target, '.env'), `VITE_API_URL=${apiUrl}\n`);
|
|
203
203
|
|
|
204
204
|
if (!skipInstall) {
|
|
205
205
|
out('Installing dependencies…');
|
|
206
206
|
// spawnSync with an argument array — no shell, no interpolation,
|
|
207
|
-
// so the only program ever invoked is the literal `
|
|
208
|
-
|
|
207
|
+
// so the only program ever invoked is the literal `npm`. npm ships
|
|
208
|
+
// as `.cmd` shim on Windows, hence the platform-specific name.
|
|
209
|
+
const npmCmd = process.platform === 'win32' ? 'npm.cmd' : 'npm';
|
|
210
|
+
const r = spawnSync(npmCmd, ['install'], { cwd: target, stdio: 'inherit' });
|
|
209
211
|
if (r.status !== 0) {
|
|
210
|
-
err('
|
|
212
|
+
err('npm install failed. You can re-run it from the project directory.');
|
|
211
213
|
}
|
|
212
214
|
}
|
|
213
215
|
|
|
@@ -215,8 +217,8 @@ function main() {
|
|
|
215
217
|
out('Done.');
|
|
216
218
|
out('');
|
|
217
219
|
out(` cd ${name}`);
|
|
218
|
-
if (skipInstall) out('
|
|
219
|
-
out('
|
|
220
|
+
if (skipInstall) out(' npm install');
|
|
221
|
+
out(' npm run dev');
|
|
220
222
|
out('');
|
|
221
223
|
out(`Backend expected at ${apiUrl}. Edit .env to point elsewhere.`);
|
|
222
224
|
}
|
package/bin/sync-templates.js
CHANGED
|
@@ -45,6 +45,14 @@ const SKIP = new Set([
|
|
|
45
45
|
'.astro',
|
|
46
46
|
'.env',
|
|
47
47
|
'.env.local',
|
|
48
|
+
// Skip lock files — davepi-ui itself uses pnpm because it's a
|
|
49
|
+
// monorepo, but the scaffolded admin is a plain Vite app that uses
|
|
50
|
+
// npm. Keeps the package-manager surface aligned with the davepi
|
|
51
|
+
// backend the user already runs via `npm install`. The scaffolded
|
|
52
|
+
// `npm install` writes a fresh package-lock.json.
|
|
53
|
+
'pnpm-lock.yaml',
|
|
54
|
+
'yarn.lock',
|
|
55
|
+
'package-lock.json',
|
|
48
56
|
]);
|
|
49
57
|
|
|
50
58
|
function copyTree(src, dst) {
|
package/package.json
CHANGED