@rangular-framework/cli 1.0.1 → 1.0.3
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 +53 -35
- package/dist/compiler/src/catalog.js +2 -2
- package/dist/compiler/src/codegen/generate.js +1 -1
- package/dist/compiler/src/compile.js +1 -1
- package/dist/compiler/src/diagnostics.js +2 -2
- package/dist/compiler/src/fix.js +2 -2
- package/package.json +5 -3
- package/postinstall.js +16 -0
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
|
|
@@ -306,6 +306,22 @@ function fileDepOf(fromDir, toDir) {
|
|
|
306
306
|
* device-verified from this environment, and the app README
|
|
307
307
|
* says so.
|
|
308
308
|
*/
|
|
309
|
+
/** The maintainer note: printed at the end of every init, in the
|
|
310
|
+
* same words the CLI package's postinstall script prints after an
|
|
311
|
+
* install. npm hides install script output on current versions, so
|
|
312
|
+
* init is where most developers actually see it. The wording is
|
|
313
|
+
* pinned by tests/publish.test.ts; change both places together. */
|
|
314
|
+
function printMaintainerNote() {
|
|
315
|
+
console.log(`
|
|
316
|
+
You are all set. Rangular is ready.
|
|
317
|
+
|
|
318
|
+
New versions, new lessons and fixes are announced here first:
|
|
319
|
+
X (twitter): @bigyan_chap
|
|
320
|
+
GitHub: github.com/bigyanchap
|
|
321
|
+
LinkedIn: https://www.linkedin.com/in/bigyanchap/
|
|
322
|
+
|
|
323
|
+
Built and maintained by Bigyan Chapagain. Issues and ideas are welcome.`);
|
|
324
|
+
}
|
|
309
325
|
function initApp(dirArg) {
|
|
310
326
|
const repoRoot = rgRepoRoot();
|
|
311
327
|
const checkout = isCheckoutRoot(repoRoot);
|
|
@@ -317,7 +333,7 @@ function initApp(dirArg) {
|
|
|
317
333
|
severity: 'error',
|
|
318
334
|
code: 'CLI_INIT_UNSAFE',
|
|
319
335
|
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.
|
|
336
|
+
fix: 'Use a simple name, e.g. rangular init my-app --app, or pass an explicit path',
|
|
321
337
|
}));
|
|
322
338
|
process.exit(1);
|
|
323
339
|
}
|
|
@@ -331,7 +347,7 @@ function initApp(dirArg) {
|
|
|
331
347
|
severity: 'error',
|
|
332
348
|
code: 'CLI_INIT_NOT_EMPTY',
|
|
333
349
|
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.
|
|
350
|
+
fix: 'Pick a new directory name, or empty the directory first, e.g. rangular init my-app --app',
|
|
335
351
|
}));
|
|
336
352
|
process.exit(1);
|
|
337
353
|
}
|
|
@@ -460,7 +476,7 @@ export default function App() {
|
|
|
460
476
|
for (const d of result.diagnostics)
|
|
461
477
|
console.error((0, index_1.formatDiagnostic)(d, entryAbs));
|
|
462
478
|
if ((0, index_1.hasErrors)(result.diagnostics) || !result.code) {
|
|
463
|
-
console.error('
|
|
479
|
+
console.error('rangular: the starter component did not compile; the scaffold is incomplete');
|
|
464
480
|
process.exit(1);
|
|
465
481
|
}
|
|
466
482
|
write(path.join('src', 'AppRoot.tsx'), result.code);
|
|
@@ -472,7 +488,7 @@ path in the command is relative to that folder):
|
|
|
472
488
|
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
489
|
|
|
474
490
|
If the CLI is on your PATH, the same compile from this app folder is
|
|
475
|
-
just \`
|
|
491
|
+
just \`rangular build\`: with no arguments it compiles
|
|
476
492
|
\`src/app.component.ts\` into \`src/AppRoot.tsx\`.
|
|
477
493
|
|
|
478
494
|
Or run the same command with \`watch\` instead of \`build\` and it
|
|
@@ -491,11 +507,11 @@ the generated app behaves.` : `## Recompile after editing the component
|
|
|
491
507
|
|
|
492
508
|
Run this from the app folder:
|
|
493
509
|
|
|
494
|
-
|
|
510
|
+
rangular build
|
|
495
511
|
|
|
496
512
|
With no arguments, the build compiles \`src/app.component.ts\` and
|
|
497
513
|
writes \`src/AppRoot.tsx\`, the one shape every Rangular app follows.
|
|
498
|
-
The same compile spelled out is \`
|
|
514
|
+
The same compile spelled out is \`rangular build src/app.component.ts
|
|
499
515
|
--out src/AppRoot.tsx\`; pass the entry and \`--out\` yourself only
|
|
500
516
|
when an app steps outside that shape.
|
|
501
517
|
|
|
@@ -507,7 +523,7 @@ recompiles on every save.
|
|
|
507
523
|
The dev preview renders any app component as a phone-width page you
|
|
508
524
|
can click through. From the app folder:
|
|
509
525
|
|
|
510
|
-
|
|
526
|
+
rangular preview src/app.component.ts --out preview.html
|
|
511
527
|
|
|
512
528
|
Then open \`preview.html\` in this app folder in a browser. The
|
|
513
529
|
preview is interactive: handlers run and lists respond, exactly as
|
|
@@ -551,12 +567,12 @@ Rules the compiler enforces:
|
|
|
551
567
|
|
|
552
568
|
The verify loop:
|
|
553
569
|
|
|
554
|
-
1. Run:
|
|
570
|
+
1. Run: rangular verify
|
|
555
571
|
One gate: strict build, doctor, the app tests and a render
|
|
556
572
|
check. Strict mode is on in this app (rangular.json), so
|
|
557
573
|
warnings fail. Nothing is dropped or snapped quietly.
|
|
558
574
|
2. Fix every diagnostic it names. Read the fix and apply it.
|
|
559
|
-
3. Run
|
|
575
|
+
3. Run rangular verify again. Only a clean run means the work is done.
|
|
560
576
|
|
|
561
577
|
The full guide lives in the framework repo at docs/AI_GUIDE.md.
|
|
562
578
|
|
|
@@ -634,8 +650,9 @@ not run in the environment that wrote this scaffold; your first
|
|
|
634
650
|
console.log(`Note: a bare name places the app under the Rangular repo's apps folder (${appDir}), not the current directory.`);
|
|
635
651
|
}
|
|
636
652
|
console.log(`Run it: cd ${appDir} && npm install && npx expo start`);
|
|
653
|
+
printMaintainerNote();
|
|
637
654
|
}
|
|
638
|
-
/** `
|
|
655
|
+
/** `rangular init <dir>`: scaffold a starter project (Stage 5). */
|
|
639
656
|
function initProject(dirArg) {
|
|
640
657
|
const dir = path.resolve(dirArg);
|
|
641
658
|
if (fs.existsSync(dir) && fs.readdirSync(dir).length > 0) {
|
|
@@ -643,7 +660,7 @@ function initProject(dirArg) {
|
|
|
643
660
|
severity: 'error',
|
|
644
661
|
code: 'CLI_INIT_NOT_EMPTY',
|
|
645
662
|
message: `Cannot init into '${dirArg}': the directory is not empty`,
|
|
646
|
-
fix: 'Pick a new directory name, or empty the directory first, e.g.
|
|
663
|
+
fix: 'Pick a new directory name, or empty the directory first, e.g. rangular init my-app',
|
|
647
664
|
}));
|
|
648
665
|
process.exit(1);
|
|
649
666
|
}
|
|
@@ -740,8 +757,9 @@ loose text, small tap targets) with the fix for each.
|
|
|
740
757
|
fs.writeFileSync(path.join(dir, '.gitignore'), 'node_modules\ndist\n');
|
|
741
758
|
console.log(`Created a starter Rangular project in ${dirArg}`);
|
|
742
759
|
console.log(`Build it: node dist/packages/cli/src/cli.js build ${dirArg}/src/app.component.ts --out ${dirArg}/src/app.component.tsx`);
|
|
760
|
+
printMaintainerNote();
|
|
743
761
|
}
|
|
744
|
-
/** `
|
|
762
|
+
/** `rangular watch`: compile now, then recompile on every change (Stage 5). */
|
|
745
763
|
function startWatch(target, out, routesSpecifier) {
|
|
746
764
|
let watchers = [];
|
|
747
765
|
let timer;
|
|
@@ -845,7 +863,7 @@ function main() {
|
|
|
845
863
|
if (command === 'init') {
|
|
846
864
|
const dir = args.slice(1).find((a) => !a.startsWith('--'));
|
|
847
865
|
if (!dir)
|
|
848
|
-
fail('usage:
|
|
866
|
+
fail('usage: rangular init <dir> [--app]');
|
|
849
867
|
if (args.includes('--app'))
|
|
850
868
|
initApp(dir);
|
|
851
869
|
else
|
|
@@ -854,7 +872,7 @@ function main() {
|
|
|
854
872
|
}
|
|
855
873
|
let target = args[1];
|
|
856
874
|
let rest = args.slice(2);
|
|
857
|
-
// `
|
|
875
|
+
// `rangular build` on its own is the app-folder form (2026-11-21):
|
|
858
876
|
// no entry means src/app.component.ts, and the build branch
|
|
859
877
|
// defaults --out to AppRoot.tsx beside the entry. Every app
|
|
860
878
|
// follows that one shape, so the common case needs no
|
|
@@ -867,7 +885,7 @@ function main() {
|
|
|
867
885
|
if (!target) {
|
|
868
886
|
const fallback = path.join('src', 'app.component.ts');
|
|
869
887
|
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:
|
|
888
|
+
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
889
|
}
|
|
872
890
|
target = fallback;
|
|
873
891
|
}
|
|
@@ -1088,7 +1106,7 @@ function main() {
|
|
|
1088
1106
|
// "is not an @Input of <tag> (Class)". The first fix round
|
|
1089
1107
|
// matched only the built-in wording, so a child rename was
|
|
1090
1108
|
// named by its diagnostic and then skipped here (the 2026-11-29
|
|
1091
|
-
// guardrail test finding: [lable] on a child chip survived
|
|
1109
|
+
// guardrail test finding: [lable] on a child chip survived the
|
|
1092
1110
|
// fix while colour on a button was renamed). Both wordings
|
|
1093
1111
|
// name the same repair, so both are read.
|
|
1094
1112
|
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,22 +1,24 @@
|
|
|
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.3",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"typescript": "^5.9.0",
|
|
13
13
|
"rxjs": "^7.8.2"
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
|
-
"dist"
|
|
16
|
+
"dist",
|
|
17
|
+
"postinstall.js"
|
|
17
18
|
],
|
|
18
19
|
"scripts": {
|
|
19
20
|
"build": "tsc -p tsconfig.publish.json",
|
|
21
|
+
"postinstall": "node postinstall.js",
|
|
20
22
|
"prepack": "npm run build"
|
|
21
23
|
},
|
|
22
24
|
"publishConfig": {
|
package/postinstall.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// The install note: printed once, right after the CLI is installed.
|
|
2
|
+
// It only prints. It reads nothing, writes nothing, and a failure
|
|
3
|
+
// here must never fail the install itself.
|
|
4
|
+
try {
|
|
5
|
+
console.log(`
|
|
6
|
+
You are all set. Rangular is ready.
|
|
7
|
+
|
|
8
|
+
New versions, new lessons and fixes are announced here first:
|
|
9
|
+
X (twitter): @bigyan_chap
|
|
10
|
+
GitHub: github.com/bigyanchap
|
|
11
|
+
LinkedIn: https://www.linkedin.com/in/bigyanchap/
|
|
12
|
+
|
|
13
|
+
Built and maintained by Bigyan Chapagain. Issues and ideas are welcome.`);
|
|
14
|
+
} catch {
|
|
15
|
+
// Silent by design: the note is a courtesy, not a step.
|
|
16
|
+
}
|