create-react-on-rails-app 17.0.0-rc.0 → 17.0.0-rc.1
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-app.js +4 -3
- package/lib/index.js +28 -8
- package/lib/validators.js +2 -2
- package/package.json +1 -1
package/lib/create-app.js
CHANGED
|
@@ -138,9 +138,10 @@ function buildGeneratorArgs(options) {
|
|
|
138
138
|
if (options.template === 'typescript') {
|
|
139
139
|
args.push('--typescript');
|
|
140
140
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
141
|
+
// Always forward an explicit --rspack / --no-rspack so the generator never falls back to
|
|
142
|
+
// its own default. This keeps create-app's resolved choice authoritative regardless of what
|
|
143
|
+
// the generator's fresh-install default happens to be (now, or if it changes again later).
|
|
144
|
+
args.push(options.rspack ? '--rspack' : '--no-rspack');
|
|
144
145
|
// --rsc supersedes --pro because RSC mode already requires Pro and the generator accepts a single mode flag.
|
|
145
146
|
if (options.pro && !options.rsc) {
|
|
146
147
|
args.push('--pro');
|
package/lib/index.js
CHANGED
|
@@ -13,7 +13,7 @@ const prompt_js_1 = require("./prompt.js");
|
|
|
13
13
|
// Use require() for CJS compatibility - avoids __dirname + fs.readFileSync
|
|
14
14
|
// eslint-disable-next-line @typescript-eslint/no-require-imports, global-require
|
|
15
15
|
const packageJson = require('../package.json');
|
|
16
|
-
async function run(appName, rawOpts) {
|
|
16
|
+
async function run(appName, rawOpts, command) {
|
|
17
17
|
const { template } = rawOpts;
|
|
18
18
|
if (typeof template !== 'string' || (template !== 'javascript' && template !== 'typescript')) {
|
|
19
19
|
(0, utils_js_1.logError)(`Invalid template "${String(template)}". Must be "javascript" or "typescript".`);
|
|
@@ -33,6 +33,15 @@ async function run(appName, rawOpts) {
|
|
|
33
33
|
(0, utils_js_1.logError)('--standard cannot be combined with --pro or --rsc.');
|
|
34
34
|
process.exit(1);
|
|
35
35
|
}
|
|
36
|
+
// --webpack is a friendly alias for --no-rspack. Commander reports --no-rspack's declared
|
|
37
|
+
// default as rawOpts.rspack === true, so we use the option source to distinguish an explicit
|
|
38
|
+
// --rspack from the default and reject contradictory flags (--rspack --webpack).
|
|
39
|
+
const rspackExplicitlyTrue = rawOpts.rspack === true && command?.getOptionValueSource('rspack') === 'cli';
|
|
40
|
+
const webpackRequested = rawOpts.webpack === true;
|
|
41
|
+
if (webpackRequested && rspackExplicitlyTrue) {
|
|
42
|
+
(0, utils_js_1.logError)('Conflicting bundler flags: pass either --rspack or --webpack (alias for --no-rspack), not both.');
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
36
45
|
let pro = Boolean(rawOpts.pro);
|
|
37
46
|
let rsc = Boolean(rawOpts.rsc);
|
|
38
47
|
console.log('');
|
|
@@ -59,7 +68,15 @@ async function run(appName, rawOpts) {
|
|
|
59
68
|
const options = {
|
|
60
69
|
template,
|
|
61
70
|
packageManager: packageManager,
|
|
62
|
-
rspack
|
|
71
|
+
// Rspack is the default; an explicit --no-rspack or its --webpack alias selects Webpack.
|
|
72
|
+
// (rawOpts.rspack ?? true) makes the three inputs explicit: undefined (no flag) -> true,
|
|
73
|
+
// true (--rspack) -> true, false (--no-rspack) -> false.
|
|
74
|
+
// Footgun: re-adding `.option('--rspack', desc, false)` would default rawOpts.rspack to
|
|
75
|
+
// false and silently flip the default back to Webpack.
|
|
76
|
+
// Note: buildGeneratorArgs always forwards an explicit --rspack/--no-rspack to the Ruby
|
|
77
|
+
// generator, so the generator's own fresh-install fallback (fresh_install_rspack_default,
|
|
78
|
+
// which consults the Shakapacker version) is never reached via create-react-on-rails-app.
|
|
79
|
+
rspack: webpackRequested ? false : (rawOpts.rspack ?? true) === true,
|
|
63
80
|
pro,
|
|
64
81
|
rsc,
|
|
65
82
|
};
|
|
@@ -100,7 +117,7 @@ async function run(appName, rawOpts) {
|
|
|
100
117
|
else if (options.pro) {
|
|
101
118
|
modeLabel = ', mode: pro';
|
|
102
119
|
}
|
|
103
|
-
(0, utils_js_1.logInfo)(`Creating "${appName}" with template: ${options.template}, package manager: ${options.packageManager}${options.rspack ? '
|
|
120
|
+
(0, utils_js_1.logInfo)(`Creating "${appName}" with template: ${options.template}, package manager: ${options.packageManager}, bundler: ${options.rspack ? 'rspack' : 'webpack'}${modeLabel}`);
|
|
104
121
|
(0, create_app_js_1.createApp)(appName, options);
|
|
105
122
|
}
|
|
106
123
|
const program = new commander_1.Command();
|
|
@@ -113,7 +130,9 @@ program
|
|
|
113
130
|
.argument('<app-name>', 'Name of the application to create')
|
|
114
131
|
.option('-t, --template <type>', 'javascript or typescript', 'typescript')
|
|
115
132
|
.option('-p, --package-manager <pm>', 'npm or pnpm (auto-detected if not specified)')
|
|
116
|
-
.option('--rspack', 'Use Rspack
|
|
133
|
+
.option('--rspack', 'Use Rspack as the bundler (default, ~20x faster builds)')
|
|
134
|
+
.option('--no-rspack', 'Use Webpack instead of Rspack')
|
|
135
|
+
.option('--webpack', 'Use Webpack as the bundler (alias for --no-rspack)')
|
|
117
136
|
.option('--standard', 'Generate open-source React on Rails setup (skip prompt)')
|
|
118
137
|
.option('--pro', 'Generate React on Rails Pro setup (installs react_on_rails_pro)')
|
|
119
138
|
.option('--rsc', 'Generate React Server Components setup (installs react_on_rails_pro)')
|
|
@@ -124,8 +143,9 @@ Examples:
|
|
|
124
143
|
$ npx create-react-on-rails-app my-app --pro # skip prompt, use Pro
|
|
125
144
|
$ npx create-react-on-rails-app my-app --standard # skip prompt, use Standard
|
|
126
145
|
$ npx create-react-on-rails-app my-app --template javascript
|
|
127
|
-
$ npx create-react-on-rails-app my-app --rspack
|
|
128
|
-
$ npx create-react-on-rails-app my-app --
|
|
146
|
+
$ npx create-react-on-rails-app my-app --no-rspack # use Webpack instead of Rspack
|
|
147
|
+
$ npx create-react-on-rails-app my-app --webpack # same as --no-rspack
|
|
148
|
+
$ npx create-react-on-rails-app my-app --no-rspack --rsc
|
|
129
149
|
$ npx create-react-on-rails-app my-app --package-manager pnpm
|
|
130
150
|
|
|
131
151
|
When no mode flag (--standard, --pro, or --rsc) is given, an interactive prompt
|
|
@@ -152,9 +172,9 @@ The generated app includes one git commit per logical setup step.`)
|
|
|
152
172
|
--pro and --rsc support both JavaScript and TypeScript templates.
|
|
153
173
|
|
|
154
174
|
Documentation: https://reactonrails.com/docs/`)
|
|
155
|
-
.action(async (appName, opts) => {
|
|
175
|
+
.action(async (appName, opts, command) => {
|
|
156
176
|
try {
|
|
157
|
-
await run(appName, opts);
|
|
177
|
+
await run(appName, opts, command);
|
|
158
178
|
}
|
|
159
179
|
catch (error) {
|
|
160
180
|
if (error instanceof Error && error.message === prompt_js_1.PROMPT_CANCELLED) {
|
package/lib/validators.js
CHANGED
|
@@ -9,7 +9,7 @@ exports.validateAll = validateAll;
|
|
|
9
9
|
const utils_js_1 = require("./utils.js");
|
|
10
10
|
const MIN_NODE_VERSION = 18;
|
|
11
11
|
const MIN_RUBY_MAJOR = 3;
|
|
12
|
-
const MIN_RUBY_MINOR =
|
|
12
|
+
const MIN_RUBY_MINOR = 3;
|
|
13
13
|
const MIN_RAILS_MAJOR = 7;
|
|
14
14
|
const MIN_RAILS_MINOR = 0;
|
|
15
15
|
function validateNode() {
|
|
@@ -30,7 +30,7 @@ function validateRuby() {
|
|
|
30
30
|
return {
|
|
31
31
|
valid: false,
|
|
32
32
|
message: 'Ruby is not installed or not found in PATH.\n\n' +
|
|
33
|
-
|
|
33
|
+
`React on Rails requires Ruby ${MIN_RUBY_MAJOR}.${MIN_RUBY_MINOR}+.\n\n` +
|
|
34
34
|
'Popular installation options:\n' +
|
|
35
35
|
' - mise: https://mise.jdx.dev/ (recommended)\n' +
|
|
36
36
|
' - rbenv: https://github.com/rbenv/rbenv\n' +
|
package/package.json
CHANGED