create-rsc-kit 0.45.3 → 0.46.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/dist/init.d.ts +2 -0
- package/dist/init.js +10 -1
- package/dist/options.d.ts +8 -0
- package/dist/options.js +7 -0
- package/dist/templates.d.ts +2 -2
- package/dist/templates.js +7 -3
- package/package.json +1 -1
package/dist/init.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ export interface Detected {
|
|
|
13
13
|
laravel: boolean;
|
|
14
14
|
/** A Go module: the backend is Go, and answers host calls from its own server. */
|
|
15
15
|
go: boolean;
|
|
16
|
+
/** Bun's lockfile is here: the app's JavaScript is installed with Bun on purpose. */
|
|
17
|
+
bunLock: boolean;
|
|
16
18
|
host: Host | null;
|
|
17
19
|
sourceDir: string | null;
|
|
18
20
|
viteConfig: string | null;
|
package/dist/init.js
CHANGED
|
@@ -104,6 +104,7 @@ export function detect(dir) {
|
|
|
104
104
|
deps,
|
|
105
105
|
laravel,
|
|
106
106
|
go: existsSync(join(dir, 'go.mod')),
|
|
107
|
+
bunLock: existsSync(join(dir, 'bun.lock')) || existsSync(join(dir, 'bun.lockb')),
|
|
107
108
|
host,
|
|
108
109
|
// resources/js, the directory a Laravel app already keeps its JavaScript
|
|
109
110
|
// in, so the route tree is resources/js/app the way it is src/app
|
|
@@ -706,6 +707,8 @@ const INIT_HELP = `
|
|
|
706
707
|
--source-dir <dir> where app/ should live (detected, usually src)
|
|
707
708
|
--host=… bun | node | worker (detected from your deps)
|
|
708
709
|
laravel is detected from artisan, never asked
|
|
710
|
+
--runtime=… node | bun, a Laravel app's renderer (Node unless
|
|
711
|
+
a bun.lock is here)
|
|
709
712
|
--backend=<url> a backend answering host calls - a Go server, say, at
|
|
710
713
|
http://127.0.0.1:8080 (assumed when go.mod is here);
|
|
711
714
|
laravel reads APP_URL instead
|
|
@@ -781,7 +784,12 @@ export async function runInit(args) {
|
|
|
781
784
|
stdout.write(` ${dim('source')} ${flags.sourceDir ?? found.sourceDir ?? 'src'}\n`);
|
|
782
785
|
stdout.write(` ${dim('react')} ${found.hasReact ? 'already here' : 'will be added'}\n`);
|
|
783
786
|
const backendUrl = flags.backend ?? (found.go ? DEFAULT_BACKEND : undefined);
|
|
787
|
+
// Node unless the app's own lockfile says Bun: Bun merely being installed
|
|
788
|
+
// on this machine says nothing about the app.
|
|
789
|
+
const runtime = flags.runtime ?? (found.bunLock ? 'bun' : 'node');
|
|
784
790
|
if (found.host === 'laravel') {
|
|
791
|
+
const why = flags.runtime ? '' : found.bunLock ? ' (bun.lock is here; --runtime=node to switch)' : ' (no bun.lock; --runtime=bun to switch)';
|
|
792
|
+
stdout.write(` ${dim('runtime')} ${runtime === 'bun' ? 'Bun' : 'Node'}${dim(why)}\n`);
|
|
785
793
|
stdout.write(` ${dim('backend')} ${flags.backend ?? 'http://localhost'}\n`);
|
|
786
794
|
}
|
|
787
795
|
else if (backendUrl) {
|
|
@@ -835,6 +843,7 @@ export async function runInit(args) {
|
|
|
835
843
|
dir,
|
|
836
844
|
name: 'app',
|
|
837
845
|
host: flags.host ?? found.host ?? 'bun',
|
|
846
|
+
runtime,
|
|
838
847
|
compiler,
|
|
839
848
|
tailwind,
|
|
840
849
|
lint,
|
|
@@ -863,7 +872,7 @@ export async function runInit(args) {
|
|
|
863
872
|
// JavaScript side, which is ready to install either way.
|
|
864
873
|
let installed = false;
|
|
865
874
|
if (install) {
|
|
866
|
-
const pm = options.host === 'node' ? 'npm' : 'bun';
|
|
875
|
+
const pm = options.host === 'node' || (options.host === 'laravel' && runtime === 'node') ? 'npm' : 'bun';
|
|
867
876
|
stdout.write(`\n${dim('Installing dependencies…')}\n`);
|
|
868
877
|
installed = spawnSync(pm, ['install'], { cwd: dir, stdio: 'inherit' }).status === 0;
|
|
869
878
|
if (!installed) {
|
package/dist/options.d.ts
CHANGED
|
@@ -8,6 +8,11 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export type Host = 'bun' | 'node' | 'worker' | 'laravel';
|
|
10
10
|
export type Compiler = 'none' | 'oxc' | 'babel';
|
|
11
|
+
/**
|
|
12
|
+
* What a Laravel app's renderer runs on. The host is always `laravel` there,
|
|
13
|
+
* so `--host` cannot say it: Node unless the app's own lockfile says Bun.
|
|
14
|
+
*/
|
|
15
|
+
export type Runtime = 'node' | 'bun';
|
|
11
16
|
/**
|
|
12
17
|
* The validation library, asked once because everything schema-shaped hangs
|
|
13
18
|
* off it: typed environment variables, `action.input(schema)`, a form's
|
|
@@ -30,6 +35,8 @@ export interface Options {
|
|
|
30
35
|
*/
|
|
31
36
|
backend?: string;
|
|
32
37
|
validation: Validation;
|
|
38
|
+
/** A Laravel app's renderer: see Runtime. Read for no other host. */
|
|
39
|
+
runtime?: Runtime;
|
|
33
40
|
/**
|
|
34
41
|
* Typed environment variables through @t3-oss/env-core, read once at
|
|
35
42
|
* startup and refused with the variable named when one is missing or wrong.
|
|
@@ -69,6 +76,7 @@ export declare const VALIDATIONS: {
|
|
|
69
76
|
hint: string;
|
|
70
77
|
}[];
|
|
71
78
|
export declare function assertValidation(value: string): Validation;
|
|
79
|
+
export declare function assertRuntime(value: string): Runtime;
|
|
72
80
|
export declare const HOSTS: {
|
|
73
81
|
value: Host;
|
|
74
82
|
label: string;
|
package/dist/options.js
CHANGED
|
@@ -20,6 +20,11 @@ export function assertValidation(value) {
|
|
|
20
20
|
return value;
|
|
21
21
|
throw new Error(`--validation must be one of zod, valibot, arktype or none; got ${JSON.stringify(value)}`);
|
|
22
22
|
}
|
|
23
|
+
export function assertRuntime(value) {
|
|
24
|
+
if (value === 'node' || value === 'bun')
|
|
25
|
+
return value;
|
|
26
|
+
throw new Error(`--runtime must be node or bun; got ${JSON.stringify(value)}`);
|
|
27
|
+
}
|
|
23
28
|
export const HOSTS = [
|
|
24
29
|
{ value: 'bun', label: 'Bun', hint: 'and compiles to a single binary' },
|
|
25
30
|
{ value: 'node', label: 'Node', hint: 'the default everywhere else' },
|
|
@@ -144,6 +149,8 @@ export function parseArgs(argv) {
|
|
|
144
149
|
out.tailwind = false;
|
|
145
150
|
else if (arg.startsWith('--host='))
|
|
146
151
|
out.host = assertHost(arg.slice(7));
|
|
152
|
+
else if (arg.startsWith('--runtime='))
|
|
153
|
+
out.runtime = assertRuntime(arg.slice(10));
|
|
147
154
|
else if (arg.startsWith('--compiler='))
|
|
148
155
|
out.compiler = arg.slice(11);
|
|
149
156
|
else if (arg.startsWith('--validation='))
|
package/dist/templates.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Host, Options } from './options.js';
|
|
1
|
+
import type { Host, Options, Runtime } from './options.js';
|
|
2
2
|
export interface Paths {
|
|
3
3
|
/** Where the app/ route tree lives. */
|
|
4
4
|
sourceDir: string;
|
|
@@ -60,7 +60,7 @@ export declare function packageJson(o: Options): string;
|
|
|
60
60
|
* Netlify, Azure, Deno and the rest, and none of them need anything here — a
|
|
61
61
|
* preset is a string in a config file, not a server we write and keep working.
|
|
62
62
|
*/
|
|
63
|
-
export declare const preset: (host: Host) => string;
|
|
63
|
+
export declare const preset: (host: Host, runtime?: Runtime) => string;
|
|
64
64
|
/** @deprecated Nothing generates a server file. Kept until callers are gone. */
|
|
65
65
|
export declare const serverFile: (_host: Host) => string;
|
|
66
66
|
export declare function viteConfig(o: Options): string;
|
package/dist/templates.js
CHANGED
|
@@ -65,7 +65,11 @@ export function scripts(o) {
|
|
|
65
65
|
dev: 'vite',
|
|
66
66
|
build: 'vite build',
|
|
67
67
|
// What the build wrote. There is no server file to start any more.
|
|
68
|
-
|
|
68
|
+
// On Node the app's .env is passed in, as Bun reads it unasked, so
|
|
69
|
+
// RSC_HOST_CALL_SECRET and APP_URL are there.
|
|
70
|
+
start: o.runtime === 'bun'
|
|
71
|
+
? 'bun .output/server/index.mjs'
|
|
72
|
+
: 'node --env-file-if-exists=.env .output/server/index.mjs',
|
|
69
73
|
...lintScripts(o),
|
|
70
74
|
};
|
|
71
75
|
}
|
|
@@ -236,7 +240,7 @@ const sorted = (o) => Object.fromEntries(Object.entries(o).sort(([a], [b]) => a.
|
|
|
236
240
|
* Netlify, Azure, Deno and the rest, and none of them need anything here — a
|
|
237
241
|
* preset is a string in a config file, not a server we write and keep working.
|
|
238
242
|
*/
|
|
239
|
-
export const preset = (host) => host === 'worker' ? 'cloudflare_module' : host === 'node' ? 'node' : 'bun';
|
|
243
|
+
export const preset = (host, runtime = 'node') => host === 'worker' ? 'cloudflare_module' : host === 'laravel' ? runtime : host === 'node' ? 'node' : 'bun';
|
|
240
244
|
/** @deprecated Nothing generates a server file. Kept until callers are gone. */
|
|
241
245
|
export const serverFile = (_host) => 'server.ts';
|
|
242
246
|
export function viteConfig(o) {
|
|
@@ -278,7 +282,7 @@ export function viteConfig(o) {
|
|
|
278
282
|
// run it at all.
|
|
279
283
|
plugins.push(o.host === 'worker'
|
|
280
284
|
? `nitro({ preset: 'cloudflare_module', serveStatic: 'inline', compatibilityDate: '${new Date().toISOString().slice(0, 10)}' })`
|
|
281
|
-
: `nitro({ preset: ${JSON.stringify(preset(o.host))}, serveStatic: 'inline' })`);
|
|
285
|
+
: `nitro({ preset: ${JSON.stringify(preset(o.host, o.runtime))}, serveStatic: 'inline' })`);
|
|
282
286
|
plugins.push(`rscKit({
|
|
283
287
|
${options.join(',\n ')},
|
|
284
288
|
})`);
|