@rangular-framework/cli 1.0.0 → 1.0.2
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/cli/src/cli.js
CHANGED
|
@@ -36,14 +36,14 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
36
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
37
|
/**
|
|
38
38
|
* Rangular CLI:
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
39
|
+
* rangular build <component.ts> --out <file.tsx> [--json] [--source-map] [--routes <file>]
|
|
40
|
+
* rangular ast <template.html>
|
|
41
|
+
* rangular preview <component.ts> --out <file.html> [--json] [--routes <file>]
|
|
42
|
+
* rangular catalog [--out <dir>]
|
|
43
|
+
* rangular watch <component.ts> --out <file.tsx> [--routes <file>]
|
|
44
|
+
* rangular init <dir> [--app]
|
|
45
|
+
* rangular doctor <component.ts> [--json] [--routes <file>]
|
|
46
|
+
* rangular verify [<component.ts>] [--json] [--routes <file>] [--no-strict]
|
|
47
47
|
*
|
|
48
48
|
* --routes names the routes file (Stage 9); without it the compiler
|
|
49
49
|
* auto-discovers a sibling app.routes.ts next to the component.
|
|
@@ -62,7 +62,7 @@ const node_child_process_1 = require("node:child_process");
|
|
|
62
62
|
const path = __importStar(require("node:path"));
|
|
63
63
|
const index_1 = require("../../compiler/src/index");
|
|
64
64
|
function fail(message) {
|
|
65
|
-
console.error(`
|
|
65
|
+
console.error(`rangular: ${message}`);
|
|
66
66
|
process.exit(2);
|
|
67
67
|
}
|
|
68
68
|
function option(args, name) {
|
|
@@ -139,15 +139,15 @@ function printJson(payload) {
|
|
|
139
139
|
}
|
|
140
140
|
const USAGE = [
|
|
141
141
|
'Usage:',
|
|
142
|
-
'
|
|
143
|
-
'
|
|
144
|
-
'
|
|
145
|
-
'
|
|
146
|
-
'
|
|
147
|
-
'
|
|
148
|
-
'
|
|
149
|
-
'
|
|
150
|
-
'
|
|
142
|
+
' rangular build [<component.ts>] [--out <file.tsx>] [--json] [--source-map] [--routes <file>] [--strict | --no-strict]',
|
|
143
|
+
' rangular ast <template.html>',
|
|
144
|
+
' rangular preview <component.ts> --out <file.html> [--json] [--routes <file>]',
|
|
145
|
+
' rangular catalog [--out <dir>]',
|
|
146
|
+
' rangular watch <component.ts> --out <file.tsx> [--routes <file>]',
|
|
147
|
+
' rangular init <dir> [--app]',
|
|
148
|
+
' rangular doctor <component.ts> [--json] [--routes <file>] [--strict | --no-strict]',
|
|
149
|
+
' rangular verify [<component.ts>] [--json] [--routes <file>] [--no-strict]',
|
|
150
|
+
' rangular fix [<component.ts>] [--json] [--routes <file>]',
|
|
151
151
|
].join('\n');
|
|
152
152
|
/**
|
|
153
153
|
* The --routes flag (Stage 9) as a specifier the compiler can resolve
|
|
@@ -278,7 +278,7 @@ function fileDepOf(fromDir, toDir) {
|
|
|
278
278
|
return `file:${rel.startsWith('.') ? rel : `./${rel}`}`;
|
|
279
279
|
}
|
|
280
280
|
/**
|
|
281
|
-
* `
|
|
281
|
+
* `rangular init <dir> --app`: scaffold a real Expo app (Stage 12).
|
|
282
282
|
*
|
|
283
283
|
* A bare name (no path separators) creates the app at
|
|
284
284
|
* <repoRoot>/apps/<name>; an explicit path (absolute, or containing a
|
|
@@ -317,7 +317,7 @@ function initApp(dirArg) {
|
|
|
317
317
|
severity: 'error',
|
|
318
318
|
code: 'CLI_INIT_UNSAFE',
|
|
319
319
|
message: `Cannot init an app named '${dirArg}': a bare app name may only use letters, digits, dot, underscore and hyphen, and may not be . or ..`,
|
|
320
|
-
fix: 'Use a simple name, e.g.
|
|
320
|
+
fix: 'Use a simple name, e.g. rangular init my-app --app, or pass an explicit path',
|
|
321
321
|
}));
|
|
322
322
|
process.exit(1);
|
|
323
323
|
}
|
|
@@ -331,7 +331,7 @@ function initApp(dirArg) {
|
|
|
331
331
|
severity: 'error',
|
|
332
332
|
code: 'CLI_INIT_NOT_EMPTY',
|
|
333
333
|
message: `Cannot init an app into '${appDir}': the directory is not empty`,
|
|
334
|
-
fix: 'Pick a new directory name, or empty the directory first, e.g.
|
|
334
|
+
fix: 'Pick a new directory name, or empty the directory first, e.g. rangular init my-app --app',
|
|
335
335
|
}));
|
|
336
336
|
process.exit(1);
|
|
337
337
|
}
|
|
@@ -377,6 +377,18 @@ function initApp(dirArg) {
|
|
|
377
377
|
'babel-preset-expo': '~58.0.0',
|
|
378
378
|
typescript: '~5.9.2',
|
|
379
379
|
},
|
|
380
|
+
// Expo's 58.0.x patch family currently resolves fresh to a pair
|
|
381
|
+
// that cannot run together (@expo/cli 58.0.26 with
|
|
382
|
+
// @expo/metro-config 58.0.24 crashes on load, reading EXPO_DEBUG
|
|
383
|
+
// of undefined; proven 2026-11-30). These two pins hold the
|
|
384
|
+
// combination the tutorial's locked tree runs on, and a fresh
|
|
385
|
+
// scaffold plus npm install plus an Android export was proven
|
|
386
|
+
// green with exactly this set. Drop the pins when a later Expo
|
|
387
|
+
// patch family resolves consistently again.
|
|
388
|
+
overrides: {
|
|
389
|
+
'@expo/cli': '58.1.20',
|
|
390
|
+
'@expo/metro-config': '58.0.22',
|
|
391
|
+
},
|
|
380
392
|
}, null, 2) + '\n');
|
|
381
393
|
write('app.json', JSON.stringify({
|
|
382
394
|
expo: {
|
|
@@ -448,7 +460,7 @@ export default function App() {
|
|
|
448
460
|
for (const d of result.diagnostics)
|
|
449
461
|
console.error((0, index_1.formatDiagnostic)(d, entryAbs));
|
|
450
462
|
if ((0, index_1.hasErrors)(result.diagnostics) || !result.code) {
|
|
451
|
-
console.error('
|
|
463
|
+
console.error('rangular: the starter component did not compile; the scaffold is incomplete');
|
|
452
464
|
process.exit(1);
|
|
453
465
|
}
|
|
454
466
|
write(path.join('src', 'AppRoot.tsx'), result.code);
|
|
@@ -460,7 +472,7 @@ path in the command is relative to that folder):
|
|
|
460
472
|
node dist/packages/cli/src/cli.js build ${path.relative(repoRoot, entryAbs).split(path.sep).join('/')} --out ${path.relative(repoRoot, path.join(srcDir, 'AppRoot.tsx')).split(path.sep).join('/')}
|
|
461
473
|
|
|
462
474
|
If the CLI is on your PATH, the same compile from this app folder is
|
|
463
|
-
just \`
|
|
475
|
+
just \`rangular build\`: with no arguments it compiles
|
|
464
476
|
\`src/app.component.ts\` into \`src/AppRoot.tsx\`.
|
|
465
477
|
|
|
466
478
|
Or run the same command with \`watch\` instead of \`build\` and it
|
|
@@ -479,11 +491,11 @@ the generated app behaves.` : `## Recompile after editing the component
|
|
|
479
491
|
|
|
480
492
|
Run this from the app folder:
|
|
481
493
|
|
|
482
|
-
|
|
494
|
+
rangular build
|
|
483
495
|
|
|
484
496
|
With no arguments, the build compiles \`src/app.component.ts\` and
|
|
485
497
|
writes \`src/AppRoot.tsx\`, the one shape every Rangular app follows.
|
|
486
|
-
The same compile spelled out is \`
|
|
498
|
+
The same compile spelled out is \`rangular build src/app.component.ts
|
|
487
499
|
--out src/AppRoot.tsx\`; pass the entry and \`--out\` yourself only
|
|
488
500
|
when an app steps outside that shape.
|
|
489
501
|
|
|
@@ -495,7 +507,7 @@ recompiles on every save.
|
|
|
495
507
|
The dev preview renders any app component as a phone-width page you
|
|
496
508
|
can click through. From the app folder:
|
|
497
509
|
|
|
498
|
-
|
|
510
|
+
rangular preview src/app.component.ts --out preview.html
|
|
499
511
|
|
|
500
512
|
Then open \`preview.html\` in this app folder in a browser. The
|
|
501
513
|
preview is interactive: handlers run and lists respond, exactly as
|
|
@@ -539,12 +551,12 @@ Rules the compiler enforces:
|
|
|
539
551
|
|
|
540
552
|
The verify loop:
|
|
541
553
|
|
|
542
|
-
1. Run:
|
|
554
|
+
1. Run: rangular verify
|
|
543
555
|
One gate: strict build, doctor, the app tests and a render
|
|
544
556
|
check. Strict mode is on in this app (rangular.json), so
|
|
545
557
|
warnings fail. Nothing is dropped or snapped quietly.
|
|
546
558
|
2. Fix every diagnostic it names. Read the fix and apply it.
|
|
547
|
-
3. Run
|
|
559
|
+
3. Run rangular verify again. Only a clean run means the work is done.
|
|
548
560
|
|
|
549
561
|
The full guide lives in the framework repo at docs/AI_GUIDE.md.
|
|
550
562
|
|
|
@@ -623,7 +635,7 @@ not run in the environment that wrote this scaffold; your first
|
|
|
623
635
|
}
|
|
624
636
|
console.log(`Run it: cd ${appDir} && npm install && npx expo start`);
|
|
625
637
|
}
|
|
626
|
-
/** `
|
|
638
|
+
/** `rangular init <dir>`: scaffold a starter project (Stage 5). */
|
|
627
639
|
function initProject(dirArg) {
|
|
628
640
|
const dir = path.resolve(dirArg);
|
|
629
641
|
if (fs.existsSync(dir) && fs.readdirSync(dir).length > 0) {
|
|
@@ -631,7 +643,7 @@ function initProject(dirArg) {
|
|
|
631
643
|
severity: 'error',
|
|
632
644
|
code: 'CLI_INIT_NOT_EMPTY',
|
|
633
645
|
message: `Cannot init into '${dirArg}': the directory is not empty`,
|
|
634
|
-
fix: 'Pick a new directory name, or empty the directory first, e.g.
|
|
646
|
+
fix: 'Pick a new directory name, or empty the directory first, e.g. rangular init my-app',
|
|
635
647
|
}));
|
|
636
648
|
process.exit(1);
|
|
637
649
|
}
|
|
@@ -729,7 +741,7 @@ loose text, small tap targets) with the fix for each.
|
|
|
729
741
|
console.log(`Created a starter Rangular project in ${dirArg}`);
|
|
730
742
|
console.log(`Build it: node dist/packages/cli/src/cli.js build ${dirArg}/src/app.component.ts --out ${dirArg}/src/app.component.tsx`);
|
|
731
743
|
}
|
|
732
|
-
/** `
|
|
744
|
+
/** `rangular watch`: compile now, then recompile on every change (Stage 5). */
|
|
733
745
|
function startWatch(target, out, routesSpecifier) {
|
|
734
746
|
let watchers = [];
|
|
735
747
|
let timer;
|
|
@@ -833,7 +845,7 @@ function main() {
|
|
|
833
845
|
if (command === 'init') {
|
|
834
846
|
const dir = args.slice(1).find((a) => !a.startsWith('--'));
|
|
835
847
|
if (!dir)
|
|
836
|
-
fail('usage:
|
|
848
|
+
fail('usage: rangular init <dir> [--app]');
|
|
837
849
|
if (args.includes('--app'))
|
|
838
850
|
initApp(dir);
|
|
839
851
|
else
|
|
@@ -842,7 +854,7 @@ function main() {
|
|
|
842
854
|
}
|
|
843
855
|
let target = args[1];
|
|
844
856
|
let rest = args.slice(2);
|
|
845
|
-
// `
|
|
857
|
+
// `rangular build` on its own is the app-folder form (2026-11-21):
|
|
846
858
|
// no entry means src/app.component.ts, and the build branch
|
|
847
859
|
// defaults --out to AppRoot.tsx beside the entry. Every app
|
|
848
860
|
// follows that one shape, so the common case needs no
|
|
@@ -855,7 +867,7 @@ function main() {
|
|
|
855
867
|
if (!target) {
|
|
856
868
|
const fallback = path.join('src', 'app.component.ts');
|
|
857
869
|
if (!fs.existsSync(path.resolve(fallback))) {
|
|
858
|
-
fail('no entry file given and src/app.component.ts was not found here. Run the build from your app folder, or pass the entry file:
|
|
870
|
+
fail('no entry file given and src/app.component.ts was not found here. Run the build from your app folder, or pass the entry file: rangular build <entry> --out <file>');
|
|
859
871
|
}
|
|
860
872
|
target = fallback;
|
|
861
873
|
}
|
|
@@ -1076,7 +1088,7 @@ function main() {
|
|
|
1076
1088
|
// "is not an @Input of <tag> (Class)". The first fix round
|
|
1077
1089
|
// matched only the built-in wording, so a child rename was
|
|
1078
1090
|
// named by its diagnostic and then skipped here (the 2026-11-29
|
|
1079
|
-
// guardrail test finding: [lable] on a child chip survived
|
|
1091
|
+
// guardrail test finding: [lable] on a child chip survived the
|
|
1080
1092
|
// fix while colour on a button was renamed). Both wordings
|
|
1081
1093
|
// name the same repair, so both are read.
|
|
1082
1094
|
const bad = /^'([^']+)' is not a prop of <([a-z-]+)>/.exec(d.message)
|
|
@@ -132,7 +132,7 @@ function renderCatalogMarkdown(catalog) {
|
|
|
132
132
|
const lines = [];
|
|
133
133
|
lines.push('# Rangular catalog');
|
|
134
134
|
lines.push('');
|
|
135
|
-
lines.push(`Generated by \`
|
|
135
|
+
lines.push(`Generated by \`rangular catalog\` from the compiler, UI primitives and tokens, do not edit by hand. Version ${catalog.version}.`);
|
|
136
136
|
lines.push('');
|
|
137
137
|
lines.push('## Template tags');
|
|
138
138
|
lines.push('');
|
|
@@ -192,7 +192,7 @@ function renderCatalogMarkdown(catalog) {
|
|
|
192
192
|
for (const d of catalog.diagnostics)
|
|
193
193
|
lines.push(`| ${d.code} | ${d.meaning} |`);
|
|
194
194
|
lines.push('');
|
|
195
|
-
lines.push('Diagnostics also carry a `fix:` suggestion in human output and in `
|
|
195
|
+
lines.push('Diagnostics also carry a `fix:` suggestion in human output and in `rangular build --json`.');
|
|
196
196
|
lines.push('');
|
|
197
197
|
return lines.join('\n');
|
|
198
198
|
}
|
|
@@ -2857,7 +2857,7 @@ class Generator {
|
|
|
2857
2857
|
// the app throws at startup (guardrail test finding,
|
|
2858
2858
|
// 2026-11-29: a root component that injects Router, carries
|
|
2859
2859
|
// a screen and declares routes, but hosts no outlet,
|
|
2860
|
-
// passed
|
|
2860
|
+
// passed rangular verify and crashed with a ReferenceError in
|
|
2861
2861
|
// the web export). Name the shape here, at the read site,
|
|
2862
2862
|
// once per compilation. Child units never reach this
|
|
2863
2863
|
// branch (opts.entry is false), so a routed page component
|
|
@@ -501,7 +501,7 @@ function compileComponent(options) {
|
|
|
501
501
|
entryUsage.outlet ? 'a <router-outlet>' : '',
|
|
502
502
|
entryUsage.links ? 'routerLink' : '',
|
|
503
503
|
injectsRouter ? 'a Router/ActivatedRoute injection' : '',
|
|
504
|
-
].filter(Boolean).join(', ')}) but no routes file was found at '${routesSpecifier}'`, undefined, undefined, "Create app.routes.ts next to the root component: export const routes: Routes = [{ path: 'home', component: HomeComponent }]; or pass the routes file explicitly (
|
|
504
|
+
].filter(Boolean).join(', ')}) but no routes file was found at '${routesSpecifier}'`, undefined, undefined, "Create app.routes.ts next to the root component: export const routes: Routes = [{ path: 'home', component: HomeComponent }]; or pass the routes file explicitly (rangular build --routes <file>)"),
|
|
505
505
|
file: entryKey,
|
|
506
506
|
});
|
|
507
507
|
}
|
|
@@ -104,10 +104,10 @@ exports.DIAGNOSTIC_CODES = {
|
|
|
104
104
|
DOC_RAW_TEXT: 'Doctor: loose text sits directly inside a container element instead of a text element.',
|
|
105
105
|
DOC_TAP_TARGET: 'Doctor: an element with a (click) binding is sized below the 44 by 44 minimum tap target.',
|
|
106
106
|
DOC_IMG_SIZE: 'Doctor: an image element has no declared width and height.',
|
|
107
|
-
CLI_INIT_NOT_EMPTY: 'The
|
|
107
|
+
CLI_INIT_NOT_EMPTY: 'The rangular init command was pointed at a directory that is not empty.',
|
|
108
108
|
PIPE_UNKNOWN: 'A template uses a pipe that is neither a built-in pipe nor a @Pipe class resolved in this compilation; the JSON form lists the known pipes in the fix.',
|
|
109
109
|
GEN_VALIDATOR_ARG: 'A static minlength or maxlength attribute value is not a plain number; the validator was dropped instead of emitting the text into generated code.',
|
|
110
110
|
DIR_UNSUPPORTED: 'An attribute directive is outside the supported subset (a bracket selector, @Input fields, an ElementRef, and ngOnInit or setter bodies made only of this.el.nativeElement.style.<prop> assignments), or it is used on a host the subset cannot style; the directive applied no styles.',
|
|
111
111
|
PROJECTION_SELECT_UNSUPPORTED: 'An <ng-content> carries a select attribute; multi-slot projection is not supported yet, so the element behaves as the default slot and receives all projected children.',
|
|
112
|
-
CLI_INIT_UNSAFE: 'The
|
|
112
|
+
CLI_INIT_UNSAFE: 'The rangular init target name is not a safe directory name (letters, digits, dot, underscore and hyphen only, and not . or ..); nothing was written.',
|
|
113
113
|
};
|
package/dist/compiler/src/fix.js
CHANGED
|
@@ -20,7 +20,7 @@ function fixStyleText(text) {
|
|
|
20
20
|
const bare = /^(\s*)([a-zA-Z-]+)\s*:/.exec(decl);
|
|
21
21
|
if (bare && !css_1.SUPPORTED_STYLE_PROPERTIES.has(camelCase(bare[2]))) {
|
|
22
22
|
fixes.push({ code: 'CSS_UNSUPPORTED', detail: `removed '${bare[2]}' from '${selector.trim()}'` });
|
|
23
|
-
return `${bare[1]}/*
|
|
23
|
+
return `${bare[1]}/* rangular fix: removed '${bare[2]}' (CSS_UNSUPPORTED: not a supported property) */`;
|
|
24
24
|
}
|
|
25
25
|
return decl;
|
|
26
26
|
}
|
|
@@ -28,7 +28,7 @@ function fixStyleText(text) {
|
|
|
28
28
|
const prop = camelCase(rawProp);
|
|
29
29
|
if (!css_1.SUPPORTED_STYLE_PROPERTIES.has(prop)) {
|
|
30
30
|
fixes.push({ code: 'CSS_UNSUPPORTED', detail: `removed '${rawProp}' from '${selector.trim()}'` });
|
|
31
|
-
return `${lead}/*
|
|
31
|
+
return `${lead}/* rangular fix: removed '${rawProp}' (CSS_UNSUPPORTED: not a supported property) */${tail}`;
|
|
32
32
|
}
|
|
33
33
|
const value = Number(numText);
|
|
34
34
|
const snapped = (0, css_1.snapForProp)(prop, value);
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"bin": {
|
|
3
3
|
"rangular-framework": "dist/cli/src/cli.js",
|
|
4
|
-
"
|
|
4
|
+
"rangular": "dist/cli/src/cli.js"
|
|
5
5
|
},
|
|
6
6
|
"description": "Command line interface for the Rangular compiler.",
|
|
7
7
|
"license": "Apache-2.0",
|
|
8
8
|
"main": "dist/cli/src/cli.js",
|
|
9
9
|
"name": "@rangular-framework/cli",
|
|
10
|
-
"version": "1.0.
|
|
10
|
+
"version": "1.0.2",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"typescript": "^5.9.0",
|
|
13
13
|
"rxjs": "^7.8.2"
|