@rcrsr/rill-cli 0.15.0 → 0.17.0
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/check/config.d.ts +0 -1
- package/dist/check/config.js +0 -1
- package/dist/check/fixer.d.ts +0 -1
- package/dist/check/fixer.js +0 -1
- package/dist/check/index.d.ts +0 -1
- package/dist/check/index.js +0 -1
- package/dist/check/rules/anti-patterns.d.ts +0 -1
- package/dist/check/rules/anti-patterns.js +0 -1
- package/dist/check/rules/closures.d.ts +0 -1
- package/dist/check/rules/closures.js +0 -1
- package/dist/check/rules/collections.d.ts +0 -1
- package/dist/check/rules/collections.js +0 -1
- package/dist/check/rules/conditionals.d.ts +0 -1
- package/dist/check/rules/conditionals.js +0 -1
- package/dist/check/rules/flow.d.ts +0 -1
- package/dist/check/rules/flow.js +0 -1
- package/dist/check/rules/formatting.d.ts +0 -1
- package/dist/check/rules/formatting.js +0 -1
- package/dist/check/rules/helpers.d.ts +0 -1
- package/dist/check/rules/helpers.js +0 -1
- package/dist/check/rules/index.d.ts +0 -1
- package/dist/check/rules/index.js +0 -1
- package/dist/check/rules/loops.d.ts +0 -1
- package/dist/check/rules/loops.js +0 -1
- package/dist/check/rules/naming.d.ts +0 -1
- package/dist/check/rules/naming.js +0 -1
- package/dist/check/rules/strings.d.ts +0 -1
- package/dist/check/rules/strings.js +0 -1
- package/dist/check/rules/types.d.ts +0 -1
- package/dist/check/rules/types.js +0 -1
- package/dist/check/rules/use-expressions.d.ts +0 -1
- package/dist/check/rules/use-expressions.js +0 -1
- package/dist/check/types.d.ts +0 -1
- package/dist/check/types.js +0 -1
- package/dist/check/validator.d.ts +0 -1
- package/dist/check/validator.js +0 -1
- package/dist/check/visitor.d.ts +0 -1
- package/dist/check/visitor.js +4 -2
- package/dist/cli-check.d.ts +0 -1
- package/dist/cli-check.js +0 -1
- package/dist/cli-error-enrichment.d.ts +0 -1
- package/dist/cli-error-enrichment.js +0 -1
- package/dist/cli-error-formatter.d.ts +0 -1
- package/dist/cli-error-formatter.js +0 -1
- package/dist/cli-eval.d.ts +0 -1
- package/dist/cli-eval.js +0 -1
- package/dist/cli-exec.d.ts +0 -1
- package/dist/cli-exec.js +0 -1
- package/dist/cli-explain.d.ts +0 -1
- package/dist/cli-explain.js +0 -1
- package/dist/cli-lsp-diagnostic.d.ts +0 -1
- package/dist/cli-lsp-diagnostic.js +0 -1
- package/dist/cli-module-loader.d.ts +0 -1
- package/dist/cli-module-loader.js +0 -1
- package/dist/cli-run.d.ts +0 -1
- package/dist/cli-run.js +47 -14
- package/dist/cli-shared.d.ts +0 -1
- package/dist/cli-shared.js +0 -1
- package/dist/run/runner.d.ts +8 -9
- package/dist/run/runner.js +22 -69
- package/dist/run/types.d.ts +1 -2
- package/dist/run/types.js +0 -1
- package/package.json +4 -3
- package/dist/check/config.d.ts.map +0 -1
- package/dist/check/config.js.map +0 -1
- package/dist/check/fixer.d.ts.map +0 -1
- package/dist/check/fixer.js.map +0 -1
- package/dist/check/index.d.ts.map +0 -1
- package/dist/check/index.js.map +0 -1
- package/dist/check/rules/anti-patterns.d.ts.map +0 -1
- package/dist/check/rules/anti-patterns.js.map +0 -1
- package/dist/check/rules/closures.d.ts.map +0 -1
- package/dist/check/rules/closures.js.map +0 -1
- package/dist/check/rules/collections.d.ts.map +0 -1
- package/dist/check/rules/collections.js.map +0 -1
- package/dist/check/rules/conditionals.d.ts.map +0 -1
- package/dist/check/rules/conditionals.js.map +0 -1
- package/dist/check/rules/flow.d.ts.map +0 -1
- package/dist/check/rules/flow.js.map +0 -1
- package/dist/check/rules/formatting.d.ts.map +0 -1
- package/dist/check/rules/formatting.js.map +0 -1
- package/dist/check/rules/helpers.d.ts.map +0 -1
- package/dist/check/rules/helpers.js.map +0 -1
- package/dist/check/rules/index.d.ts.map +0 -1
- package/dist/check/rules/index.js.map +0 -1
- package/dist/check/rules/loops.d.ts.map +0 -1
- package/dist/check/rules/loops.js.map +0 -1
- package/dist/check/rules/naming.d.ts.map +0 -1
- package/dist/check/rules/naming.js.map +0 -1
- package/dist/check/rules/strings.d.ts.map +0 -1
- package/dist/check/rules/strings.js.map +0 -1
- package/dist/check/rules/types.d.ts.map +0 -1
- package/dist/check/rules/types.js.map +0 -1
- package/dist/check/rules/use-expressions.d.ts.map +0 -1
- package/dist/check/rules/use-expressions.js.map +0 -1
- package/dist/check/types.d.ts.map +0 -1
- package/dist/check/types.js.map +0 -1
- package/dist/check/validator.d.ts.map +0 -1
- package/dist/check/validator.js.map +0 -1
- package/dist/check/visitor.d.ts.map +0 -1
- package/dist/check/visitor.js.map +0 -1
- package/dist/cli-check.d.ts.map +0 -1
- package/dist/cli-check.js.map +0 -1
- package/dist/cli-error-enrichment.d.ts.map +0 -1
- package/dist/cli-error-enrichment.js.map +0 -1
- package/dist/cli-error-formatter.d.ts.map +0 -1
- package/dist/cli-error-formatter.js.map +0 -1
- package/dist/cli-eval.d.ts.map +0 -1
- package/dist/cli-eval.js.map +0 -1
- package/dist/cli-exec.d.ts.map +0 -1
- package/dist/cli-exec.js.map +0 -1
- package/dist/cli-explain.d.ts.map +0 -1
- package/dist/cli-explain.js.map +0 -1
- package/dist/cli-lsp-diagnostic.d.ts.map +0 -1
- package/dist/cli-lsp-diagnostic.js.map +0 -1
- package/dist/cli-module-loader.d.ts.map +0 -1
- package/dist/cli-module-loader.js.map +0 -1
- package/dist/cli-run.d.ts.map +0 -1
- package/dist/cli-run.js.map +0 -1
- package/dist/cli-shared.d.ts.map +0 -1
- package/dist/cli-shared.js.map +0 -1
- package/dist/run/runner.d.ts.map +0 -1
- package/dist/run/runner.js.map +0 -1
- package/dist/run/types.d.ts.map +0 -1
- package/dist/run/types.js.map +0 -1
package/dist/check/config.d.ts
CHANGED
package/dist/check/config.js
CHANGED
package/dist/check/fixer.d.ts
CHANGED
package/dist/check/fixer.js
CHANGED
package/dist/check/index.d.ts
CHANGED
package/dist/check/index.js
CHANGED
package/dist/check/rules/flow.js
CHANGED
|
@@ -23,4 +23,3 @@ export declare function extractContextLine(line: number, source: string): string
|
|
|
23
23
|
* @returns true if expr is a bare $ reference, false otherwise
|
|
24
24
|
*/
|
|
25
25
|
export declare function isBareReference(expr: ExpressionNode | null | undefined): boolean;
|
|
26
|
-
//# sourceMappingURL=helpers.d.ts.map
|
package/dist/check/types.d.ts
CHANGED
package/dist/check/types.js
CHANGED
|
@@ -15,4 +15,3 @@ import type { CheckConfig, Diagnostic } from './types.js';
|
|
|
15
15
|
* @returns Array of diagnostics sorted by location
|
|
16
16
|
*/
|
|
17
17
|
export declare function validateScript(ast: ScriptNode, source: string, config: CheckConfig): Diagnostic[];
|
|
18
|
-
//# sourceMappingURL=validator.d.ts.map
|
package/dist/check/validator.js
CHANGED
package/dist/check/visitor.d.ts
CHANGED
package/dist/check/visitor.js
CHANGED
|
@@ -280,7 +280,10 @@ export function visitNode(node, context, visitor) {
|
|
|
280
280
|
break;
|
|
281
281
|
case 'TypeConstructor':
|
|
282
282
|
for (const arg of node.args) {
|
|
283
|
-
|
|
283
|
+
// arg.value is a TypeRef (not an ASTNode) — skip it
|
|
284
|
+
if (arg.defaultValue) {
|
|
285
|
+
visitNode(arg.defaultValue, context, visitor);
|
|
286
|
+
}
|
|
284
287
|
}
|
|
285
288
|
break;
|
|
286
289
|
case 'ClosureSigLiteral':
|
|
@@ -304,4 +307,3 @@ export function visitNode(node, context, visitor) {
|
|
|
304
307
|
// Exit callback after children
|
|
305
308
|
visitor.exit(node, context);
|
|
306
309
|
}
|
|
307
|
-
//# sourceMappingURL=visitor.js.map
|
package/dist/cli-check.d.ts
CHANGED
|
@@ -40,4 +40,3 @@ export declare function parseCheckArgs(argv: string[]): ParsedCheckArgs;
|
|
|
40
40
|
* @returns Formatted output string
|
|
41
41
|
*/
|
|
42
42
|
export declare function formatDiagnostics(file: string, diagnostics: Diagnostic[], format: 'text' | 'json', verbose: boolean): string;
|
|
43
|
-
//# sourceMappingURL=cli-check.d.ts.map
|
package/dist/cli-check.js
CHANGED
|
@@ -70,4 +70,3 @@ export declare function suggestSimilarNames(target: string, candidates: string[]
|
|
|
70
70
|
* @throws {TypeError} When source is not a string or error is null
|
|
71
71
|
*/
|
|
72
72
|
export declare function enrichError(error: RillError, source: string, scope?: ScopeInfo): EnrichedError;
|
|
73
|
-
//# sourceMappingURL=cli-error-enrichment.d.ts.map
|
|
@@ -42,4 +42,3 @@ export declare function formatError(error: EnrichedError, options: FormatOptions
|
|
|
42
42
|
* @throws {RangeError} Invalid span (start after end)
|
|
43
43
|
*/
|
|
44
44
|
export declare function renderCaretUnderline(span: SourceSpan, lineContent: string): string;
|
|
45
|
-
//# sourceMappingURL=cli-error-formatter.d.ts.map
|
package/dist/cli-eval.d.ts
CHANGED
package/dist/cli-eval.js
CHANGED
package/dist/cli-exec.d.ts
CHANGED
package/dist/cli-exec.js
CHANGED
package/dist/cli-explain.d.ts
CHANGED
package/dist/cli-explain.js
CHANGED
|
@@ -16,4 +16,3 @@ import type { RillValue } from '@rcrsr/rill';
|
|
|
16
16
|
* @throws Error if module not found or circular dependency detected
|
|
17
17
|
*/
|
|
18
18
|
export declare function loadModule(specifier: string, fromPath: string, cache: Map<string, Record<string, RillValue>>, chain?: Set<string>): Promise<Record<string, RillValue>>;
|
|
19
|
-
//# sourceMappingURL=cli-module-loader.d.ts.map
|
package/dist/cli-run.d.ts
CHANGED
package/dist/cli-run.js
CHANGED
|
@@ -26,7 +26,7 @@ Options:
|
|
|
26
26
|
--format <mode> Output format: human, json, compact (default: human)
|
|
27
27
|
--verbose Show full error details (default: false)
|
|
28
28
|
--max-stack-depth <n> Error stack frame limit (default: 10)
|
|
29
|
-
--create-bindings
|
|
29
|
+
--create-bindings [dir] Write bindings source to dir and exit (default: ./bindings)
|
|
30
30
|
--explain <code> Print error code documentation
|
|
31
31
|
--help Print this help message and exit
|
|
32
32
|
--version Print version and exit`.trimEnd();
|
|
@@ -38,17 +38,42 @@ const BASE_OPTIONS = {
|
|
|
38
38
|
format: { type: 'string' },
|
|
39
39
|
verbose: { type: 'boolean' },
|
|
40
40
|
'max-stack-depth': { type: 'string' },
|
|
41
|
-
'create-bindings': { type: 'boolean' },
|
|
42
41
|
help: { type: 'boolean' },
|
|
43
42
|
version: { type: 'boolean' },
|
|
44
43
|
explain: { type: 'string' },
|
|
45
44
|
};
|
|
46
45
|
// ============================================================
|
|
46
|
+
// CREATE-BINDINGS EXTRACTION
|
|
47
|
+
// ============================================================
|
|
48
|
+
/**
|
|
49
|
+
* Extract --create-bindings [dir] from argv before parseArgs.
|
|
50
|
+
* Handles the optional dir argument that parseArgs cannot natively support.
|
|
51
|
+
* Returns the filtered argv (with --create-bindings removed) and the resolved dir.
|
|
52
|
+
*/
|
|
53
|
+
function extractCreateBindings(argv) {
|
|
54
|
+
const idx = argv.indexOf('--create-bindings');
|
|
55
|
+
if (idx === -1) {
|
|
56
|
+
return { filteredArgv: argv, createBindings: undefined };
|
|
57
|
+
}
|
|
58
|
+
const next = argv[idx + 1];
|
|
59
|
+
if (next !== undefined && !next.startsWith('-')) {
|
|
60
|
+
return {
|
|
61
|
+
filteredArgv: [...argv.slice(0, idx), ...argv.slice(idx + 2)],
|
|
62
|
+
createBindings: next,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
filteredArgv: [...argv.slice(0, idx), ...argv.slice(idx + 1)],
|
|
67
|
+
createBindings: './bindings',
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
// ============================================================
|
|
47
71
|
// PARSE ARGS
|
|
48
72
|
// ============================================================
|
|
49
73
|
export function parseCliArgs(argv = process.argv.slice(2)) {
|
|
74
|
+
const { filteredArgv, createBindings } = extractCreateBindings(argv);
|
|
50
75
|
const { values, positionals } = parseArgs({
|
|
51
|
-
args:
|
|
76
|
+
args: filteredArgv,
|
|
52
77
|
options: BASE_OPTIONS,
|
|
53
78
|
allowPositionals: true,
|
|
54
79
|
strict: false,
|
|
@@ -77,7 +102,7 @@ export function parseCliArgs(argv = process.argv.slice(2)) {
|
|
|
77
102
|
verbose: values['verbose'] === true,
|
|
78
103
|
maxStackDepth,
|
|
79
104
|
explain: values['explain'],
|
|
80
|
-
createBindings
|
|
105
|
+
createBindings,
|
|
81
106
|
};
|
|
82
107
|
}
|
|
83
108
|
// ============================================================
|
|
@@ -96,8 +121,9 @@ function extractHandlerArgs(argv, params) {
|
|
|
96
121
|
type: param.type === 'bool' ? 'boolean' : 'string',
|
|
97
122
|
};
|
|
98
123
|
}
|
|
124
|
+
const { filteredArgv } = extractCreateBindings(argv);
|
|
99
125
|
const { values } = parseArgs({
|
|
100
|
-
args:
|
|
126
|
+
args: filteredArgv,
|
|
101
127
|
options: handlerOptions,
|
|
102
128
|
allowPositionals: true,
|
|
103
129
|
strict: false,
|
|
@@ -165,14 +191,20 @@ export async function main() {
|
|
|
165
191
|
throw err;
|
|
166
192
|
}
|
|
167
193
|
// Create bindings and exit early if --create-bindings was set
|
|
168
|
-
if (opts.createBindings
|
|
169
|
-
const
|
|
170
|
-
mkdirSync(
|
|
171
|
-
writeFileSync(
|
|
194
|
+
if (opts.createBindings !== undefined) {
|
|
195
|
+
const bindingsDir = resolve(dirname(configPath), opts.createBindings);
|
|
196
|
+
mkdirSync(bindingsDir, { recursive: true });
|
|
197
|
+
writeFileSync(resolve(bindingsDir, 'ext.rill'), project.extensionBindings + '\n');
|
|
172
198
|
if (project.config.context !== undefined) {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
199
|
+
writeFileSync(resolve(bindingsDir, 'context.rill'), project.contextBindings + '\n');
|
|
200
|
+
}
|
|
201
|
+
for (const dispose of project.disposes) {
|
|
202
|
+
try {
|
|
203
|
+
await dispose();
|
|
204
|
+
}
|
|
205
|
+
catch {
|
|
206
|
+
// Ignore dispose errors during cleanup
|
|
207
|
+
}
|
|
176
208
|
}
|
|
177
209
|
process.exit(0);
|
|
178
210
|
}
|
|
@@ -272,7 +304,9 @@ export async function main() {
|
|
|
272
304
|
...opts,
|
|
273
305
|
scriptPath,
|
|
274
306
|
};
|
|
275
|
-
const runResult = await runScript(runOpts, project.config, project.extTree,
|
|
307
|
+
const runResult = await runScript(runOpts, project.config, project.extTree, [
|
|
308
|
+
...project.disposes,
|
|
309
|
+
]);
|
|
276
310
|
if (runResult.output !== undefined) {
|
|
277
311
|
process.stdout.write(runResult.output + '\n');
|
|
278
312
|
}
|
|
@@ -294,4 +328,3 @@ if (shouldRunMain) {
|
|
|
294
328
|
process.exit(1);
|
|
295
329
|
});
|
|
296
330
|
}
|
|
297
|
-
//# sourceMappingURL=cli-run.js.map
|
package/dist/cli-shared.d.ts
CHANGED
package/dist/cli-shared.js
CHANGED
package/dist/run/runner.d.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Script runner for rill-run.
|
|
3
3
|
* Builds runtime options, executes rill scripts, and maps results to exit codes.
|
|
4
4
|
*/
|
|
5
|
-
import { type SchemeResolver } from '@rcrsr/rill';
|
|
6
|
-
import type {
|
|
5
|
+
import { type RillValue, type SchemeResolver } from '@rcrsr/rill';
|
|
6
|
+
import type { RillConfigFile } from '@rcrsr/rill-config';
|
|
7
7
|
import type { RunCliOptions } from './types.js';
|
|
8
8
|
export interface RunResult {
|
|
9
9
|
readonly exitCode: number;
|
|
@@ -11,14 +11,13 @@ export interface RunResult {
|
|
|
11
11
|
readonly errorOutput?: string | undefined;
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
|
-
* Build a custom module scheme resolver.
|
|
15
|
-
*
|
|
16
|
-
* -
|
|
17
|
-
* -
|
|
14
|
+
* Build a custom module scheme resolver using folder aliasing.
|
|
15
|
+
* Each config key maps to a directory. Dot-paths resolve to files within:
|
|
16
|
+
* - `module:alias.sub.path` → `{dir}/sub/path.rill`
|
|
17
|
+
* - `module:alias` → `{dir}/index.rill`
|
|
18
18
|
*/
|
|
19
|
-
export declare function buildModuleResolver(
|
|
19
|
+
export declare function buildModuleResolver(modulesConfig: Record<string, string>, configDir: string): SchemeResolver;
|
|
20
20
|
/**
|
|
21
21
|
* Run a rill script file with the given extension tree and config.
|
|
22
22
|
*/
|
|
23
|
-
export declare function runScript(opts: RunCliOptions, config: RillConfigFile, extTree:
|
|
24
|
-
//# sourceMappingURL=runner.d.ts.map
|
|
23
|
+
export declare function runScript(opts: RunCliOptions, config: RillConfigFile, extTree: Record<string, RillValue>, disposes: Array<() => void | Promise<void>>): Promise<RunResult>;
|