@rs-x/cli 2.0.0-next.7 → 2.0.0-next.9
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) {
|
|
@@ -627,6 +671,15 @@ function removeFileOrDirectoryWithDryRun(targetPath, dryRun) {
|
|
|
627
671
|
fs.rmSync(targetPath, { recursive: true, force: true });
|
|
628
672
|
}
|
|
629
673
|
|
|
674
|
+
function resolveAngularProjectTsConfig(projectRoot) {
|
|
675
|
+
const appTsConfigPath = path.join(projectRoot, 'tsconfig.app.json');
|
|
676
|
+
if (fs.existsSync(appTsConfigPath)) {
|
|
677
|
+
return appTsConfigPath;
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
return path.join(projectRoot, 'tsconfig.json');
|
|
681
|
+
}
|
|
682
|
+
|
|
630
683
|
function toFileDependencySpec(fromDir, targetPath) {
|
|
631
684
|
const relative = path.relative(fromDir, targetPath).replace(/\\/gu, '/');
|
|
632
685
|
const normalized = relative.startsWith('.') ? relative : `./${relative}`;
|
|
@@ -1286,12 +1339,18 @@ function applyAngularDemoStarter(projectRoot, projectName, pm, flags) {
|
|
|
1286
1339
|
}
|
|
1287
1340
|
|
|
1288
1341
|
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
1342
|
+
const angularTsConfigPath = resolveAngularProjectTsConfig(projectRoot);
|
|
1343
|
+
const angularTsConfigRelative = path
|
|
1344
|
+
.relative(projectRoot, angularTsConfigPath)
|
|
1345
|
+
.replace(/\\/gu, '/');
|
|
1289
1346
|
packageJson.name = projectName;
|
|
1290
1347
|
packageJson.private = true;
|
|
1291
1348
|
packageJson.version = '0.1.0';
|
|
1292
1349
|
packageJson.scripts = {
|
|
1293
|
-
|
|
1294
|
-
|
|
1350
|
+
'build:rsx': `rsx build --project ${angularTsConfigRelative} --no-emit --prod`,
|
|
1351
|
+
'typecheck:rsx': `rsx typecheck --project ${angularTsConfigRelative}`,
|
|
1352
|
+
prebuild: 'npm run build:rsx',
|
|
1353
|
+
start: 'npm run build:rsx && ng serve',
|
|
1295
1354
|
build: 'ng build',
|
|
1296
1355
|
};
|
|
1297
1356
|
packageJson.rsx = {
|
|
@@ -1374,6 +1433,10 @@ function applyAngularDemoStarter(projectRoot, projectName, pm, flags) {
|
|
|
1374
1433
|
buildOptions.polyfills = polyfills;
|
|
1375
1434
|
build.options = buildOptions;
|
|
1376
1435
|
|
|
1436
|
+
if (build.configurations?.production?.budgets) {
|
|
1437
|
+
delete build.configurations.production.budgets;
|
|
1438
|
+
}
|
|
1439
|
+
|
|
1377
1440
|
if (dryRun) {
|
|
1378
1441
|
logInfo(`[dry-run] patch ${angularJsonPath}`);
|
|
1379
1442
|
} else {
|
|
@@ -1423,9 +1486,6 @@ async function runProjectWithTemplate(template, flags) {
|
|
|
1423
1486
|
withWorkingDirectory(projectRoot, () => {
|
|
1424
1487
|
if (normalizedTemplate === 'angular') {
|
|
1425
1488
|
applyAngularDemoStarter(projectRoot, projectName, pm, flags);
|
|
1426
|
-
if (!Boolean(flags['skip-vscode'])) {
|
|
1427
|
-
installVsCodeExtension(flags);
|
|
1428
|
-
}
|
|
1429
1489
|
return;
|
|
1430
1490
|
}
|
|
1431
1491
|
if (normalizedTemplate === 'react') {
|
|
@@ -2000,10 +2060,6 @@ function runInit(flags) {
|
|
|
2000
2060
|
}
|
|
2001
2061
|
}
|
|
2002
2062
|
|
|
2003
|
-
if (!skipVscode) {
|
|
2004
|
-
installVsCodeExtension(flags);
|
|
2005
|
-
}
|
|
2006
|
-
|
|
2007
2063
|
logOk('RS-X init completed.');
|
|
2008
2064
|
}
|
|
2009
2065
|
|
|
@@ -2471,96 +2527,15 @@ ${patchBlock}
|
|
|
2471
2527
|
logOk(`Patched ${nextConfigJs} with RS-X webpack loader.`);
|
|
2472
2528
|
}
|
|
2473
2529
|
|
|
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
2530
|
function runSetupReact(flags) {
|
|
2560
2531
|
const dryRun = Boolean(flags['dry-run']);
|
|
2561
2532
|
const pm = detectPackageManager(flags.pm);
|
|
2562
2533
|
const tag = resolveInstallTag(flags);
|
|
2563
2534
|
const projectRoot = process.cwd();
|
|
2535
|
+
const angularTsConfigPath = resolveAngularProjectTsConfig(projectRoot);
|
|
2536
|
+
const angularTsConfigRelative = path
|
|
2537
|
+
.relative(projectRoot, angularTsConfigPath)
|
|
2538
|
+
.replace(/\\/gu, '/');
|
|
2564
2539
|
const packageJsonPath = path.join(projectRoot, 'package.json');
|
|
2565
2540
|
if (!fs.existsSync(packageJsonPath)) {
|
|
2566
2541
|
logError(`package.json not found in ${projectRoot}`);
|
|
@@ -2593,9 +2568,6 @@ function runSetupReact(flags) {
|
|
|
2593
2568
|
logInfo('Skipping RS-X React bindings install (--skip-install).');
|
|
2594
2569
|
}
|
|
2595
2570
|
wireRsxVitePlugin(projectRoot, dryRun);
|
|
2596
|
-
if (!Boolean(flags['skip-vscode'])) {
|
|
2597
|
-
installVsCodeExtension(flags);
|
|
2598
|
-
}
|
|
2599
2571
|
logOk('RS-X React setup completed.');
|
|
2600
2572
|
}
|
|
2601
2573
|
|
|
@@ -2618,9 +2590,6 @@ function runSetupNext(flags) {
|
|
|
2618
2590
|
logInfo('Skipping RS-X React bindings install (--skip-install).');
|
|
2619
2591
|
}
|
|
2620
2592
|
wireRsxNextWebpack(process.cwd(), dryRun);
|
|
2621
|
-
if (!Boolean(flags['skip-vscode'])) {
|
|
2622
|
-
installVsCodeExtension(flags);
|
|
2623
|
-
}
|
|
2624
2593
|
logOk('RS-X Next.js setup completed.');
|
|
2625
2594
|
}
|
|
2626
2595
|
|
|
@@ -2643,9 +2612,6 @@ function runSetupVue(flags) {
|
|
|
2643
2612
|
logInfo('Skipping RS-X Vue bindings install (--skip-install).');
|
|
2644
2613
|
}
|
|
2645
2614
|
wireRsxVitePlugin(process.cwd(), dryRun);
|
|
2646
|
-
if (!Boolean(flags['skip-vscode'])) {
|
|
2647
|
-
installVsCodeExtension(flags);
|
|
2648
|
-
}
|
|
2649
2615
|
logOk('RS-X Vue setup completed.');
|
|
2650
2616
|
}
|
|
2651
2617
|
|
|
@@ -2684,13 +2650,13 @@ function runSetupAngular(flags) {
|
|
|
2684
2650
|
upsertScriptInPackageJson(
|
|
2685
2651
|
projectRoot,
|
|
2686
2652
|
'build:rsx',
|
|
2687
|
-
|
|
2653
|
+
`rsx build --project ${angularTsConfigRelative} --no-emit --prod`,
|
|
2688
2654
|
dryRun,
|
|
2689
2655
|
);
|
|
2690
2656
|
upsertScriptInPackageJson(
|
|
2691
2657
|
projectRoot,
|
|
2692
2658
|
'typecheck:rsx',
|
|
2693
|
-
|
|
2659
|
+
`rsx typecheck --project ${angularTsConfigRelative}`,
|
|
2694
2660
|
dryRun,
|
|
2695
2661
|
);
|
|
2696
2662
|
|
|
@@ -2700,14 +2666,11 @@ function runSetupAngular(flags) {
|
|
|
2700
2666
|
);
|
|
2701
2667
|
ensureAngularPolyfillsContainsFile({
|
|
2702
2668
|
projectRoot,
|
|
2703
|
-
configPath:
|
|
2669
|
+
configPath: angularTsConfigPath,
|
|
2704
2670
|
filePath: rsxRegistrationFile,
|
|
2705
2671
|
dryRun,
|
|
2706
2672
|
});
|
|
2707
2673
|
|
|
2708
|
-
if (!Boolean(flags['skip-vscode'])) {
|
|
2709
|
-
installVsCodeExtension(flags);
|
|
2710
|
-
}
|
|
2711
2674
|
logOk('RS-X Angular setup completed.');
|
|
2712
2675
|
}
|
|
2713
2676
|
|
|
@@ -2744,7 +2707,6 @@ function runSetupAuto(flags) {
|
|
|
2744
2707
|
const pm = detectPackageManager(flags.pm);
|
|
2745
2708
|
installRuntimePackages(pm, Boolean(flags['dry-run']), tag);
|
|
2746
2709
|
installCompilerPackages(pm, Boolean(flags['dry-run']), tag);
|
|
2747
|
-
installVsCodeExtension(flags);
|
|
2748
2710
|
}
|
|
2749
2711
|
|
|
2750
2712
|
function resolveProjectModule(projectRoot, moduleName) {
|
package/package.json
CHANGED
|
Binary file
|
|
@@ -22,7 +22,7 @@ type ThemeMode = 'light' | 'dark';
|
|
|
22
22
|
export class AppComponent implements OnInit {
|
|
23
23
|
private readonly _document = inject(DOCUMENT);
|
|
24
24
|
@HostBinding('class.theme-dark') public isDarkTheme = false;
|
|
25
|
-
public theme: ThemeMode = '
|
|
25
|
+
public theme: ThemeMode = 'dark';
|
|
26
26
|
|
|
27
27
|
public ngOnInit(): void {
|
|
28
28
|
this.theme = this.getInitialTheme();
|
|
@@ -41,7 +41,7 @@ export class AppComponent implements OnInit {
|
|
|
41
41
|
return storedTheme;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
return '
|
|
44
|
+
return 'dark';
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
private applyTheme(theme: ThemeMode): void {
|