@webjsdev/cli 0.10.25 → 0.10.26
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/lib/create.js +45 -28
- package/package.json +1 -1
- package/templates/AGENTS.md +11 -6
package/lib/create.js
CHANGED
|
@@ -39,9 +39,10 @@ function detectPackageManager() {
|
|
|
39
39
|
* Decide whether `webjs create` runs the post-scaffold install, per target
|
|
40
40
|
* runtime (#682). Node installs by default (it needs `node_modules` to run);
|
|
41
41
|
* Bun SKIPS by default (zero-install: `bun run dev` resolves deps on the fly,
|
|
42
|
-
* #675). Under Bun zero-install
|
|
43
|
-
*
|
|
44
|
-
*
|
|
42
|
+
* #675). Under Bun zero-install webjs pins a declared dep to its package.json
|
|
43
|
+
* version via the #685/#698 onLoad rewrite (a caret range now resolves the
|
|
44
|
+
* highest match, not absolute latest), so `bun install` is the path to a frozen
|
|
45
|
+
* lockfile, not a correctness fix. Explicit flags win: `--install` forces it
|
|
45
46
|
* on, `--no-install` forces it off. The CLI entry points call this and pass an
|
|
46
47
|
* explicit boolean to `scaffoldApp`, so the library default (no install unless
|
|
47
48
|
* `install: true`) is unchanged for programmatic callers.
|
|
@@ -57,9 +58,9 @@ export function resolveCreateInstall({ runtime, explicitInstall, noInstall } = {
|
|
|
57
58
|
}
|
|
58
59
|
|
|
59
60
|
/**
|
|
60
|
-
* Read the EXACT version of `@webjsdev/<pkg>` the scaffolding CLI ships with
|
|
61
|
-
* the generated `package.json`
|
|
62
|
-
* the
|
|
61
|
+
* Read the EXACT version of `@webjsdev/<pkg>` the scaffolding CLI ships with.
|
|
62
|
+
* `webjsdevRange` carets over this for the generated `package.json` (#700), so a
|
|
63
|
+
* fresh app tracks the line the CLI shipped. Walks the `require.resolve` node_modules search paths
|
|
63
64
|
* and fs-reads `<pkg>/package.json` directly: `@webjsdev/server` (and `ui`) hide
|
|
64
65
|
* `./package.json` behind `exports`, so a bare `require('<pkg>/package.json')`
|
|
65
66
|
* fails (same constraint #687 hit). Falls back to `'latest'` when the package is
|
|
@@ -83,18 +84,35 @@ function webjsdevVersion(pkg) {
|
|
|
83
84
|
}
|
|
84
85
|
|
|
85
86
|
/**
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
87
|
+
* The `@webjsdev/<pkg>` specifier for the generated `package.json` (#700): a
|
|
88
|
+
* caret range over the version the scaffolding CLI ships with, so a fresh app
|
|
89
|
+
* picks up patch updates the way an npm user expects (a `^0.x` caret stays
|
|
90
|
+
* within the minor). Bun zero-install resolves a normal caret range correctly
|
|
91
|
+
* since #698, so this no longer diverges from npm. Falls back to `'latest'` when
|
|
92
|
+
* the version is not resolvable (keeps `^latest` from ever being emitted).
|
|
93
|
+
* @param {string} pkg e.g. 'cli', 'core', 'server'
|
|
94
|
+
* @returns {string}
|
|
95
|
+
*/
|
|
96
|
+
function webjsdevRange(pkg) {
|
|
97
|
+
const v = webjsdevVersion(pkg);
|
|
98
|
+
return v === 'latest' ? 'latest' : '^' + v;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Third-party dep specifiers the scaffold ships (#700). These are template deps
|
|
103
|
+
* the CLI does NOT itself depend on, so they cannot be read from the CLI's
|
|
104
|
+
* closure (unlike `@webjsdev/*`). Since #698, Bun zero-install resolves a normal
|
|
105
|
+
* caret range correctly (highest match, not absolute latest), so `pg` is an
|
|
106
|
+
* idiomatic `^` range. Drizzle is PINNED to an exact RC: its 1.0 line is a
|
|
107
|
+
* PRERELEASE (`1.0.0-rc.3`), and Bun zero-install ENOENTs on a caret-prerelease
|
|
108
|
+
* inline specifier (`drizzle-orm@^1.0.0-rc.3`, verified on Bun 1.3.14) while the
|
|
109
|
+
* exact prerelease resolves, so drizzle must stay exact until the 1.0 stable
|
|
110
|
+
* ships. Refresh on a deliberate bump.
|
|
93
111
|
*/
|
|
94
112
|
const SCAFFOLD_DEP_VERSIONS = {
|
|
95
113
|
'drizzle-orm': '1.0.0-rc.3',
|
|
96
114
|
'drizzle-kit': '1.0.0-rc.3',
|
|
97
|
-
pg: '8.22.0',
|
|
115
|
+
pg: '^8.22.0',
|
|
98
116
|
};
|
|
99
117
|
|
|
100
118
|
/**
|
|
@@ -418,21 +436,19 @@ export async function scaffoldApp(name, cwd, opts = {}) {
|
|
|
418
436
|
// for relations v2. SQLite needs NO driver dependency: the connection
|
|
419
437
|
// uses the built-in node:sqlite (Node) / bun:sqlite (Bun) via Drizzle's
|
|
420
438
|
// node-sqlite / bun-sqlite adapters. Postgres still needs the pg driver.
|
|
421
|
-
//
|
|
422
|
-
//
|
|
423
|
-
//
|
|
424
|
-
//
|
|
425
|
-
// versions the scaffolding CLI itself ships with.
|
|
439
|
+
// Since #698 a normal caret range resolves correctly under bun
|
|
440
|
+
// zero-install, so @webjsdev/* and pg are idiomatic `^` ranges (#700).
|
|
441
|
+
// Drizzle stays EXACT: its 1.0 line is a prerelease RC, and bun ENOENTs
|
|
442
|
+
// on a caret-prerelease inline specifier, so a range would break it.
|
|
426
443
|
'drizzle-orm': SCAFFOLD_DEP_VERSIONS['drizzle-orm'],
|
|
427
444
|
...(dialect === 'postgres' ? { pg: SCAFFOLD_DEP_VERSIONS.pg } : {}),
|
|
428
|
-
'@webjsdev/cli':
|
|
429
|
-
'@webjsdev/core':
|
|
430
|
-
'@webjsdev/server':
|
|
445
|
+
'@webjsdev/cli': webjsdevRange('cli'),
|
|
446
|
+
'@webjsdev/core': webjsdevRange('core'),
|
|
447
|
+
'@webjsdev/server': webjsdevRange('server'),
|
|
431
448
|
},
|
|
432
449
|
devDependencies: {
|
|
433
|
-
// Exact pin
|
|
434
|
-
//
|
|
435
|
-
// exact version across runtimes (a range would diverge, #690).
|
|
450
|
+
// Exact pin: drizzle-kit shares drizzle-orm's prerelease 1.0 RC, which bun
|
|
451
|
+
// cannot resolve as a caret-prerelease range, so it stays exact (#700).
|
|
436
452
|
'drizzle-kit': SCAFFOLD_DEP_VERSIONS['drizzle-kit'],
|
|
437
453
|
...(dialect === 'postgres' ? { '@types/pg': '^8.11.0' } : {}),
|
|
438
454
|
// The TypeScript compiler, for `npm run typecheck` (webjs typecheck runs
|
|
@@ -1476,10 +1492,11 @@ For AI agents, read this before editing scaffolded files:
|
|
|
1476
1492
|
}
|
|
1477
1493
|
} else if (isBun) {
|
|
1478
1494
|
// Bun zero-install (#675): no install needed; `bun run dev` resolves deps on
|
|
1479
|
-
// the fly.
|
|
1480
|
-
//
|
|
1495
|
+
// the fly. Since #698 they resolve to their package.json versions (a caret
|
|
1496
|
+
// range to its highest match), so point at `bun install` for a frozen
|
|
1497
|
+
// lockfile and editor type intelligence, not a correctness fix.
|
|
1481
1498
|
console.log(`Skipped install. Bun resolves dependencies on the fly, so 'bun run dev' and 'bun run start' work as-is (no node_modules).`);
|
|
1482
|
-
console.log(`These resolve to
|
|
1499
|
+
console.log(`These resolve to the versions in package.json. Run 'bun install' in ${name}/ to freeze a lockfile and get editor type intelligence.\n`);
|
|
1483
1500
|
}
|
|
1484
1501
|
|
|
1485
1502
|
// Next-steps banner prints LAST so the actionable command is the
|
package/package.json
CHANGED
package/templates/AGENTS.md
CHANGED
|
@@ -415,12 +415,17 @@ bun run dev # or: bun run start (no install step required)
|
|
|
415
415
|
```
|
|
416
416
|
|
|
417
417
|
`bun create` does not run an install on Bun, so a fresh app serves immediately.
|
|
418
|
-
Under zero-install,
|
|
419
|
-
`bun.lock`
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
418
|
+
Under zero-install, Bun's runtime auto-install resolves a BARE import to LATEST
|
|
419
|
+
(it ignores `package.json` and `bun.lock`), so webjs rewrites each declared dep's
|
|
420
|
+
specifier to an inline-versioned one via an `onLoad` transform. The version is the
|
|
421
|
+
`bun.lock` exact when present, else the `package.json` value when it is an
|
|
422
|
+
inline-safe semver (an exact pin, or a caret / tilde / comparator range, which
|
|
423
|
+
Bun resolves to the highest match). A protocol range (`workspace:`, `file:`), a
|
|
424
|
+
wildcard (`*`), and a dist-tag (`latest`) stay at latest. Run `bun install` when
|
|
425
|
+
you want versions frozen identically across machines (it materializes
|
|
426
|
+
`node_modules` from the lockfile) or editor type intelligence. (To run a
|
|
427
|
+
Node-flavored app on Bun instead, force `bun --bun run dev`, which still expects
|
|
428
|
+
an install.)
|
|
424
429
|
|
|
425
430
|
On Node the `.ts` type-stripping is the built-in `module.stripTypeScriptTypes`;
|
|
426
431
|
on Bun (which has no built-in) it comes from `amaro` automatically, so the same
|