@rs-x/cli 2.0.0-next.7 → 2.0.0-next.8
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/bin/rsx.cjs
CHANGED
|
@@ -5,7 +5,15 @@ const path = require('node:path');
|
|
|
5
5
|
const readline = require('node:readline/promises');
|
|
6
6
|
const { spawnSync } = require('node:child_process');
|
|
7
7
|
|
|
8
|
-
const CLI_VERSION =
|
|
8
|
+
const CLI_VERSION = (() => {
|
|
9
|
+
try {
|
|
10
|
+
const packageJsonPath = path.join(__dirname, '..', 'package.json');
|
|
11
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
12
|
+
return packageJson.version ?? '0.0.0';
|
|
13
|
+
} catch {
|
|
14
|
+
return '0.0.0';
|
|
15
|
+
}
|
|
16
|
+
})();
|
|
9
17
|
const VS_CODE_EXTENSION_ID = 'rs-x.rs-x-vscode-extension';
|
|
10
18
|
const ANGULAR_DEMO_TEMPLATE_DIR = path.join(
|
|
11
19
|
__dirname,
|
|
@@ -268,14 +276,50 @@ function installVsCodeExtension(flags) {
|
|
|
268
276
|
return;
|
|
269
277
|
}
|
|
270
278
|
|
|
271
|
-
|
|
279
|
+
installBundledVsix(dryRun, force);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
function resolveBundledVsix() {
|
|
283
|
+
const packageRoot = path.resolve(__dirname, '..');
|
|
284
|
+
const candidates = fs
|
|
285
|
+
.readdirSync(packageRoot)
|
|
286
|
+
.filter((name) => /^rs-x-vscode-extension-.*\.vsix$/u.test(name))
|
|
287
|
+
.map((name) => path.join(packageRoot, name));
|
|
288
|
+
|
|
289
|
+
if (candidates.length === 0) {
|
|
290
|
+
return null;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
const latest = candidates
|
|
294
|
+
.map((fullPath) => ({
|
|
295
|
+
fullPath,
|
|
296
|
+
mtimeMs: fs.statSync(fullPath).mtimeMs,
|
|
297
|
+
}))
|
|
298
|
+
.sort((a, b) => b.mtimeMs - a.mtimeMs)[0];
|
|
299
|
+
|
|
300
|
+
return latest?.fullPath ?? null;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
function installBundledVsix(dryRun, force) {
|
|
304
|
+
const bundledVsix = resolveBundledVsix();
|
|
305
|
+
if (!bundledVsix) {
|
|
306
|
+
logWarn(
|
|
307
|
+
'No bundled VSIX found in @rs-x/cli. Skipping VS Code extension install.',
|
|
308
|
+
);
|
|
309
|
+
logInfo(
|
|
310
|
+
'If you are developing in the rs-x repo, use `rsx install vscode --local` instead.',
|
|
311
|
+
);
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
const args = ['--install-extension', bundledVsix];
|
|
272
316
|
if (force) {
|
|
273
317
|
args.push('--force');
|
|
274
318
|
}
|
|
275
319
|
|
|
276
|
-
logInfo(`Installing ${
|
|
320
|
+
logInfo(`Installing bundled VSIX from ${bundledVsix}...`);
|
|
277
321
|
run('code', args, { dryRun });
|
|
278
|
-
logOk('VS Code extension installed.');
|
|
322
|
+
logOk('VS Code extension installed from bundled VSIX.');
|
|
279
323
|
}
|
|
280
324
|
|
|
281
325
|
function installLocalVsix(dryRun, force) {
|
|
@@ -1423,9 +1467,6 @@ async function runProjectWithTemplate(template, flags) {
|
|
|
1423
1467
|
withWorkingDirectory(projectRoot, () => {
|
|
1424
1468
|
if (normalizedTemplate === 'angular') {
|
|
1425
1469
|
applyAngularDemoStarter(projectRoot, projectName, pm, flags);
|
|
1426
|
-
if (!Boolean(flags['skip-vscode'])) {
|
|
1427
|
-
installVsCodeExtension(flags);
|
|
1428
|
-
}
|
|
1429
1470
|
return;
|
|
1430
1471
|
}
|
|
1431
1472
|
if (normalizedTemplate === 'react') {
|
|
@@ -2000,10 +2041,6 @@ function runInit(flags) {
|
|
|
2000
2041
|
}
|
|
2001
2042
|
}
|
|
2002
2043
|
|
|
2003
|
-
if (!skipVscode) {
|
|
2004
|
-
installVsCodeExtension(flags);
|
|
2005
|
-
}
|
|
2006
|
-
|
|
2007
2044
|
logOk('RS-X init completed.');
|
|
2008
2045
|
}
|
|
2009
2046
|
|
|
@@ -2471,91 +2508,6 @@ ${patchBlock}
|
|
|
2471
2508
|
logOk(`Patched ${nextConfigJs} with RS-X webpack loader.`);
|
|
2472
2509
|
}
|
|
2473
2510
|
|
|
2474
|
-
function wireRsxAngularWebpack(projectRoot, dryRun) {
|
|
2475
|
-
const angularJsonPath = path.join(projectRoot, 'angular.json');
|
|
2476
|
-
if (!fs.existsSync(angularJsonPath)) {
|
|
2477
|
-
logWarn('angular.json not found. Skipping Angular build integration.');
|
|
2478
|
-
return;
|
|
2479
|
-
}
|
|
2480
|
-
|
|
2481
|
-
createRsxWebpackLoaderFile(projectRoot, dryRun);
|
|
2482
|
-
|
|
2483
|
-
const webpackConfigPath = path.join(projectRoot, 'rsx-angular-webpack.cjs');
|
|
2484
|
-
const webpackConfigSource = `const path = require('node:path');
|
|
2485
|
-
|
|
2486
|
-
module.exports = {
|
|
2487
|
-
module: {
|
|
2488
|
-
rules: [
|
|
2489
|
-
{
|
|
2490
|
-
test: /\\.[jt]sx?$/u,
|
|
2491
|
-
exclude: /node_modules/u,
|
|
2492
|
-
use: [
|
|
2493
|
-
{
|
|
2494
|
-
loader: path.resolve(__dirname, './rsx-webpack-loader.cjs'),
|
|
2495
|
-
},
|
|
2496
|
-
],
|
|
2497
|
-
},
|
|
2498
|
-
],
|
|
2499
|
-
},
|
|
2500
|
-
};
|
|
2501
|
-
`;
|
|
2502
|
-
|
|
2503
|
-
if (dryRun) {
|
|
2504
|
-
logInfo(`[dry-run] create ${webpackConfigPath}`);
|
|
2505
|
-
} else {
|
|
2506
|
-
fs.writeFileSync(webpackConfigPath, webpackConfigSource, 'utf8');
|
|
2507
|
-
logOk(`Created ${webpackConfigPath}`);
|
|
2508
|
-
}
|
|
2509
|
-
|
|
2510
|
-
const angularJson = JSON.parse(fs.readFileSync(angularJsonPath, 'utf8'));
|
|
2511
|
-
const projects = angularJson.projects ?? {};
|
|
2512
|
-
const projectNames = Object.keys(projects);
|
|
2513
|
-
if (projectNames.length === 0) {
|
|
2514
|
-
logWarn('No Angular projects found in angular.json.');
|
|
2515
|
-
return;
|
|
2516
|
-
}
|
|
2517
|
-
|
|
2518
|
-
const patchPath = 'rsx-angular-webpack.cjs';
|
|
2519
|
-
for (const projectName of projectNames) {
|
|
2520
|
-
const project = projects[projectName];
|
|
2521
|
-
const architect = project.architect ?? project.targets;
|
|
2522
|
-
if (!architect?.build) {
|
|
2523
|
-
continue;
|
|
2524
|
-
}
|
|
2525
|
-
|
|
2526
|
-
const build = architect.build;
|
|
2527
|
-
if (build.builder !== '@angular-builders/custom-webpack:browser') {
|
|
2528
|
-
build.builder = '@angular-builders/custom-webpack:browser';
|
|
2529
|
-
}
|
|
2530
|
-
build.options = build.options ?? {};
|
|
2531
|
-
build.options.customWebpackConfig = build.options.customWebpackConfig ?? {};
|
|
2532
|
-
build.options.customWebpackConfig.path = patchPath;
|
|
2533
|
-
|
|
2534
|
-
if (architect.serve) {
|
|
2535
|
-
const serve = architect.serve;
|
|
2536
|
-
if (serve.builder !== '@angular-builders/custom-webpack:dev-server') {
|
|
2537
|
-
serve.builder = '@angular-builders/custom-webpack:dev-server';
|
|
2538
|
-
}
|
|
2539
|
-
serve.options = serve.options ?? {};
|
|
2540
|
-
serve.options.buildTarget =
|
|
2541
|
-
serve.options.buildTarget ?? `${projectName}:build`;
|
|
2542
|
-
serve.options.browserTarget =
|
|
2543
|
-
serve.options.browserTarget ?? `${projectName}:build`;
|
|
2544
|
-
}
|
|
2545
|
-
}
|
|
2546
|
-
|
|
2547
|
-
if (dryRun) {
|
|
2548
|
-
logInfo(`[dry-run] patch ${angularJsonPath}`);
|
|
2549
|
-
} else {
|
|
2550
|
-
fs.writeFileSync(
|
|
2551
|
-
angularJsonPath,
|
|
2552
|
-
`${JSON.stringify(angularJson, null, 2)}\n`,
|
|
2553
|
-
'utf8',
|
|
2554
|
-
);
|
|
2555
|
-
logOk(`Patched ${angularJsonPath} for RS-X Angular webpack integration.`);
|
|
2556
|
-
}
|
|
2557
|
-
}
|
|
2558
|
-
|
|
2559
2511
|
function runSetupReact(flags) {
|
|
2560
2512
|
const dryRun = Boolean(flags['dry-run']);
|
|
2561
2513
|
const pm = detectPackageManager(flags.pm);
|
|
@@ -2593,9 +2545,6 @@ function runSetupReact(flags) {
|
|
|
2593
2545
|
logInfo('Skipping RS-X React bindings install (--skip-install).');
|
|
2594
2546
|
}
|
|
2595
2547
|
wireRsxVitePlugin(projectRoot, dryRun);
|
|
2596
|
-
if (!Boolean(flags['skip-vscode'])) {
|
|
2597
|
-
installVsCodeExtension(flags);
|
|
2598
|
-
}
|
|
2599
2548
|
logOk('RS-X React setup completed.');
|
|
2600
2549
|
}
|
|
2601
2550
|
|
|
@@ -2618,9 +2567,6 @@ function runSetupNext(flags) {
|
|
|
2618
2567
|
logInfo('Skipping RS-X React bindings install (--skip-install).');
|
|
2619
2568
|
}
|
|
2620
2569
|
wireRsxNextWebpack(process.cwd(), dryRun);
|
|
2621
|
-
if (!Boolean(flags['skip-vscode'])) {
|
|
2622
|
-
installVsCodeExtension(flags);
|
|
2623
|
-
}
|
|
2624
2570
|
logOk('RS-X Next.js setup completed.');
|
|
2625
2571
|
}
|
|
2626
2572
|
|
|
@@ -2643,9 +2589,6 @@ function runSetupVue(flags) {
|
|
|
2643
2589
|
logInfo('Skipping RS-X Vue bindings install (--skip-install).');
|
|
2644
2590
|
}
|
|
2645
2591
|
wireRsxVitePlugin(process.cwd(), dryRun);
|
|
2646
|
-
if (!Boolean(flags['skip-vscode'])) {
|
|
2647
|
-
installVsCodeExtension(flags);
|
|
2648
|
-
}
|
|
2649
2592
|
logOk('RS-X Vue setup completed.');
|
|
2650
2593
|
}
|
|
2651
2594
|
|
|
@@ -2705,9 +2648,6 @@ function runSetupAngular(flags) {
|
|
|
2705
2648
|
dryRun,
|
|
2706
2649
|
});
|
|
2707
2650
|
|
|
2708
|
-
if (!Boolean(flags['skip-vscode'])) {
|
|
2709
|
-
installVsCodeExtension(flags);
|
|
2710
|
-
}
|
|
2711
2651
|
logOk('RS-X Angular setup completed.');
|
|
2712
2652
|
}
|
|
2713
2653
|
|
|
@@ -2744,7 +2684,6 @@ function runSetupAuto(flags) {
|
|
|
2744
2684
|
const pm = detectPackageManager(flags.pm);
|
|
2745
2685
|
installRuntimePackages(pm, Boolean(flags['dry-run']), tag);
|
|
2746
2686
|
installCompilerPackages(pm, Boolean(flags['dry-run']), tag);
|
|
2747
|
-
installVsCodeExtension(flags);
|
|
2748
2687
|
}
|
|
2749
2688
|
|
|
2750
2689
|
function resolveProjectModule(projectRoot, moduleName) {
|
package/package.json
CHANGED
|
index e703202..b11675c 100644
|
|
|
Binary file
|