@rangular-framework/cli 1.0.1 → 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
|
}
|
|
@@ -460,7 +460,7 @@ export default function App() {
|
|
|
460
460
|
for (const d of result.diagnostics)
|
|
461
461
|
console.error((0, index_1.formatDiagnostic)(d, entryAbs));
|
|
462
462
|
if ((0, index_1.hasErrors)(result.diagnostics) || !result.code) {
|
|
463
|
-
console.error('
|
|
463
|
+
console.error('rangular: the starter component did not compile; the scaffold is incomplete');
|
|
464
464
|
process.exit(1);
|
|
465
465
|
}
|
|
466
466
|
write(path.join('src', 'AppRoot.tsx'), result.code);
|
|
@@ -472,7 +472,7 @@ path in the command is relative to that folder):
|
|
|
472
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('/')}
|
|
473
473
|
|
|
474
474
|
If the CLI is on your PATH, the same compile from this app folder is
|
|
475
|
-
just \`
|
|
475
|
+
just \`rangular build\`: with no arguments it compiles
|
|
476
476
|
\`src/app.component.ts\` into \`src/AppRoot.tsx\`.
|
|
477
477
|
|
|
478
478
|
Or run the same command with \`watch\` instead of \`build\` and it
|
|
@@ -491,11 +491,11 @@ the generated app behaves.` : `## Recompile after editing the component
|
|
|
491
491
|
|
|
492
492
|
Run this from the app folder:
|
|
493
493
|
|
|
494
|
-
|
|
494
|
+
rangular build
|
|
495
495
|
|
|
496
496
|
With no arguments, the build compiles \`src/app.component.ts\` and
|
|
497
497
|
writes \`src/AppRoot.tsx\`, the one shape every Rangular app follows.
|
|
498
|
-
The same compile spelled out is \`
|
|
498
|
+
The same compile spelled out is \`rangular build src/app.component.ts
|
|
499
499
|
--out src/AppRoot.tsx\`; pass the entry and \`--out\` yourself only
|
|
500
500
|
when an app steps outside that shape.
|
|
501
501
|
|
|
@@ -507,7 +507,7 @@ recompiles on every save.
|
|
|
507
507
|
The dev preview renders any app component as a phone-width page you
|
|
508
508
|
can click through. From the app folder:
|
|
509
509
|
|
|
510
|
-
|
|
510
|
+
rangular preview src/app.component.ts --out preview.html
|
|
511
511
|
|
|
512
512
|
Then open \`preview.html\` in this app folder in a browser. The
|
|
513
513
|
preview is interactive: handlers run and lists respond, exactly as
|
|
@@ -551,12 +551,12 @@ Rules the compiler enforces:
|
|
|
551
551
|
|
|
552
552
|
The verify loop:
|
|
553
553
|
|
|
554
|
-
1. Run:
|
|
554
|
+
1. Run: rangular verify
|
|
555
555
|
One gate: strict build, doctor, the app tests and a render
|
|
556
556
|
check. Strict mode is on in this app (rangular.json), so
|
|
557
557
|
warnings fail. Nothing is dropped or snapped quietly.
|
|
558
558
|
2. Fix every diagnostic it names. Read the fix and apply it.
|
|
559
|
-
3. Run
|
|
559
|
+
3. Run rangular verify again. Only a clean run means the work is done.
|
|
560
560
|
|
|
561
561
|
The full guide lives in the framework repo at docs/AI_GUIDE.md.
|
|
562
562
|
|
|
@@ -635,7 +635,7 @@ not run in the environment that wrote this scaffold; your first
|
|
|
635
635
|
}
|
|
636
636
|
console.log(`Run it: cd ${appDir} && npm install && npx expo start`);
|
|
637
637
|
}
|
|
638
|
-
/** `
|
|
638
|
+
/** `rangular init <dir>`: scaffold a starter project (Stage 5). */
|
|
639
639
|
function initProject(dirArg) {
|
|
640
640
|
const dir = path.resolve(dirArg);
|
|
641
641
|
if (fs.existsSync(dir) && fs.readdirSync(dir).length > 0) {
|
|
@@ -643,7 +643,7 @@ function initProject(dirArg) {
|
|
|
643
643
|
severity: 'error',
|
|
644
644
|
code: 'CLI_INIT_NOT_EMPTY',
|
|
645
645
|
message: `Cannot init into '${dirArg}': the directory is not empty`,
|
|
646
|
-
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',
|
|
647
647
|
}));
|
|
648
648
|
process.exit(1);
|
|
649
649
|
}
|
|
@@ -741,7 +741,7 @@ loose text, small tap targets) with the fix for each.
|
|
|
741
741
|
console.log(`Created a starter Rangular project in ${dirArg}`);
|
|
742
742
|
console.log(`Build it: node dist/packages/cli/src/cli.js build ${dirArg}/src/app.component.ts --out ${dirArg}/src/app.component.tsx`);
|
|
743
743
|
}
|
|
744
|
-
/** `
|
|
744
|
+
/** `rangular watch`: compile now, then recompile on every change (Stage 5). */
|
|
745
745
|
function startWatch(target, out, routesSpecifier) {
|
|
746
746
|
let watchers = [];
|
|
747
747
|
let timer;
|
|
@@ -845,7 +845,7 @@ function main() {
|
|
|
845
845
|
if (command === 'init') {
|
|
846
846
|
const dir = args.slice(1).find((a) => !a.startsWith('--'));
|
|
847
847
|
if (!dir)
|
|
848
|
-
fail('usage:
|
|
848
|
+
fail('usage: rangular init <dir> [--app]');
|
|
849
849
|
if (args.includes('--app'))
|
|
850
850
|
initApp(dir);
|
|
851
851
|
else
|
|
@@ -854,7 +854,7 @@ function main() {
|
|
|
854
854
|
}
|
|
855
855
|
let target = args[1];
|
|
856
856
|
let rest = args.slice(2);
|
|
857
|
-
// `
|
|
857
|
+
// `rangular build` on its own is the app-folder form (2026-11-21):
|
|
858
858
|
// no entry means src/app.component.ts, and the build branch
|
|
859
859
|
// defaults --out to AppRoot.tsx beside the entry. Every app
|
|
860
860
|
// follows that one shape, so the common case needs no
|
|
@@ -867,7 +867,7 @@ function main() {
|
|
|
867
867
|
if (!target) {
|
|
868
868
|
const fallback = path.join('src', 'app.component.ts');
|
|
869
869
|
if (!fs.existsSync(path.resolve(fallback))) {
|
|
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:
|
|
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>');
|
|
871
871
|
}
|
|
872
872
|
target = fallback;
|
|
873
873
|
}
|
|
@@ -1088,7 +1088,7 @@ function main() {
|
|
|
1088
1088
|
// "is not an @Input of <tag> (Class)". The first fix round
|
|
1089
1089
|
// matched only the built-in wording, so a child rename was
|
|
1090
1090
|
// named by its diagnostic and then skipped here (the 2026-11-29
|
|
1091
|
-
// guardrail test finding: [lable] on a child chip survived
|
|
1091
|
+
// guardrail test finding: [lable] on a child chip survived the
|
|
1092
1092
|
// fix while colour on a button was renamed). Both wordings
|
|
1093
1093
|
// name the same repair, so both are read.
|
|
1094
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"
|