create-rsc-kit 0.6.0 → 0.7.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/index.js +16 -3
- package/dist/options.d.ts +1 -1
- package/dist/options.js +15 -3
- package/dist/templates.js +3 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -13,7 +13,18 @@ import { argv, exit, stdout } from 'node:process';
|
|
|
13
13
|
import { DEFAULT_COMPILER, HELP, HOSTS, publishedCore, assertInsideCwd, assertUsableName, defaultCore, parseArgs, } from './options.js';
|
|
14
14
|
import { Prompter, bold, cyan, dim } from './prompt.js';
|
|
15
15
|
import * as t from './templates.js';
|
|
16
|
-
|
|
16
|
+
// Same treatment as a refusal from write(): a bad flag is a decision this tool
|
|
17
|
+
// made, and it happens before the try/catch below because the flags are what
|
|
18
|
+
// everything else is built from.
|
|
19
|
+
const flags = (() => {
|
|
20
|
+
try {
|
|
21
|
+
return parseArgs(argv.slice(2));
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
stdout.write(`\n${bold('Cannot scaffold here.')}\n ${error.message}\n\n`);
|
|
25
|
+
exit(1);
|
|
26
|
+
}
|
|
27
|
+
})();
|
|
17
28
|
if (flags.help) {
|
|
18
29
|
stdout.write(HELP);
|
|
19
30
|
exit(0);
|
|
@@ -81,7 +92,7 @@ async function collect() {
|
|
|
81
92
|
const p = new Prompter();
|
|
82
93
|
try {
|
|
83
94
|
const dir = flags.dir ?? (await p.text('Directory', 'my-app'));
|
|
84
|
-
const host = await p.select('
|
|
95
|
+
const host = await p.select('Where will it run', HOSTS);
|
|
85
96
|
// Yes/no, not which: see DEFAULT_COMPILER.
|
|
86
97
|
const compiler = flags.compiler ?? ((await p.confirm('React Compiler', true)) ? DEFAULT_COMPILER : 'none');
|
|
87
98
|
const tailwind = flags.tailwind ?? (await p.confirm('Tailwind CSS', true));
|
|
@@ -165,6 +176,8 @@ function report(o) {
|
|
|
165
176
|
const steps = [
|
|
166
177
|
`cd ${relativeish(o.dir)}`,
|
|
167
178
|
...(o.install ? [] : [o.host === 'node' ? 'npm install' : 'bun install']),
|
|
179
|
+
// dev first: it is what someone wants next, and it needs no build.
|
|
180
|
+
`${pm} dev`,
|
|
168
181
|
`${pm} build`,
|
|
169
182
|
// A Worker has no start: wrangler runs it on workerd, or deploys it.
|
|
170
183
|
...(o.host === 'worker' ? [`${pm} preview`, `${pm} deploy`] : [`${pm} start`]),
|
|
@@ -172,7 +185,7 @@ function report(o) {
|
|
|
172
185
|
stdout.write(`\n${bold('Done.')} ${dim(o.dir)}\n\n`);
|
|
173
186
|
for (const step of steps)
|
|
174
187
|
stdout.write(` ${cyan(step)}\n`);
|
|
175
|
-
stdout.write(`\n${dim('
|
|
188
|
+
stdout.write(`\n${dim('Pages live in src/app. Where it deploys is the Nitro preset in vite.config.ts.')}\n\n`);
|
|
176
189
|
}
|
|
177
190
|
/** A path the user can paste, when it is under where they are. */
|
|
178
191
|
function relativeish(dir) {
|
package/dist/options.d.ts
CHANGED
|
@@ -93,4 +93,4 @@ export declare function assertUsableName(name: string): void;
|
|
|
93
93
|
* generator nobody can run without reading it first.
|
|
94
94
|
*/
|
|
95
95
|
export declare function assertInsideCwd(dir: string, cwd: string): void;
|
|
96
|
-
export declare const HELP = "\n create-rsc-kit \u2014 scaffold an RSC app\n\n Usage\n create-rsc-kit <dir> [options]\n bun create rsc-kit <dir> [options] (once published)\n\n Options\n --host=bun|
|
|
96
|
+
export declare const HELP = "\n create-rsc-kit \u2014 scaffold an RSC app\n\n Usage\n create-rsc-kit <dir> [options]\n bun create rsc-kit <dir> [options] (once published)\n\n Options\n --host=bun|node|worker where it runs \u2014 picks the Nitro preset\n --compiler=none|oxc|babel React Compiler (prompt offers oxc; babel by flag)\n --tailwind / --no-tailwind include Tailwind\n --lint / --no-lint include oxlint\n --source-dir <dir> where app/ lives (default: src)\n --init add to the project here, rather than scaffold\n --core=<spec> engine dependency, e.g. file:../rsc-kit/packages/core\n --no-install skip installing dependencies\n --no-git skip git init\n -y, --yes accept every default, ask nothing\n -h, --help this\n";
|
package/dist/options.js
CHANGED
|
@@ -12,8 +12,20 @@ import { fileURLToPath } from 'node:url';
|
|
|
12
12
|
export const HOSTS = [
|
|
13
13
|
{ value: 'bun', label: 'Bun', hint: 'and compiles to a single binary' },
|
|
14
14
|
{ value: 'node', label: 'Node', hint: 'the default everywhere else' },
|
|
15
|
-
{ value: 'worker', label: 'Cloudflare Workers', hint: '
|
|
15
|
+
{ value: 'worker', label: 'Cloudflare Workers', hint: 'deployed with wrangler, not started' },
|
|
16
16
|
];
|
|
17
|
+
/**
|
|
18
|
+
* `--host` reaches `preset()`, which has a fallback branch — so an unknown
|
|
19
|
+
* value would not fail, it would quietly scaffold a Bun app. The names that
|
|
20
|
+
* used to be valid here (`hono`, `elysia`) are exactly the ones someone still
|
|
21
|
+
* has in a script, so being told is the point.
|
|
22
|
+
*/
|
|
23
|
+
function assertHost(value) {
|
|
24
|
+
if (value === 'laravel' || HOSTS.some((host) => host.value === value))
|
|
25
|
+
return value;
|
|
26
|
+
throw new Error(`Unknown --host=${value}. Pick one of: ${HOSTS.map((host) => host.value).join(', ')}. ` +
|
|
27
|
+
'Anywhere else is a Nitro preset in vite.config.ts, not a flag here.');
|
|
28
|
+
}
|
|
17
29
|
/**
|
|
18
30
|
* Not asked as a three-way.
|
|
19
31
|
*
|
|
@@ -117,7 +129,7 @@ export function parseArgs(argv) {
|
|
|
117
129
|
else if (arg === '--no-tailwind')
|
|
118
130
|
out.tailwind = false;
|
|
119
131
|
else if (arg.startsWith('--host='))
|
|
120
|
-
out.host = arg.slice(7);
|
|
132
|
+
out.host = assertHost(arg.slice(7));
|
|
121
133
|
else if (arg.startsWith('--compiler='))
|
|
122
134
|
out.compiler = arg.slice(11);
|
|
123
135
|
else if (arg.startsWith('--core='))
|
|
@@ -167,7 +179,7 @@ export const HELP = `
|
|
|
167
179
|
bun create rsc-kit <dir> [options] (once published)
|
|
168
180
|
|
|
169
181
|
Options
|
|
170
|
-
--host=bun|
|
|
182
|
+
--host=bun|node|worker where it runs — picks the Nitro preset
|
|
171
183
|
--compiler=none|oxc|babel React Compiler (prompt offers oxc; babel by flag)
|
|
172
184
|
--tailwind / --no-tailwind include Tailwind
|
|
173
185
|
--lint / --no-lint include oxlint
|
package/dist/templates.js
CHANGED
|
@@ -175,9 +175,11 @@ export function viteConfig(o) {
|
|
|
175
175
|
// and rscKit tells plugin-rsc not to install a handler competing for that
|
|
176
176
|
// role. serveStatic: 'inline' embeds the built assets, without which a
|
|
177
177
|
// compiled binary serves pages and 404s every asset.
|
|
178
|
+
//
|
|
179
|
+
// Not optional, and not a flag on rscKit() either — the plugin builds for
|
|
180
|
+
// Nitro and nothing else, so a config without this line has no server.
|
|
178
181
|
plugins.push(`nitro({ preset: ${JSON.stringify(preset(o.host))}, serveStatic: 'inline' })`);
|
|
179
182
|
plugins.push(`rscKit({
|
|
180
|
-
nitro: true,
|
|
181
183
|
${options.join(',\n ')},
|
|
182
184
|
})`);
|
|
183
185
|
plugins.push(o.compiler === 'oxc' ? 'react({ compiler: true })' : 'react()');
|