@eagleoutice/flowr 2.13.0 → 2.13.1
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/README.md +23 -23
- package/cli/common/options.d.ts +10 -0
- package/cli/common/options.js +2 -0
- package/cli/common/scripts-info.d.ts +10 -0
- package/cli/repl/commands/repl-commands.d.ts +8 -0
- package/cli/repl/commands/repl-commands.js +16 -3
- package/cli/repl/commands/repl-query.js +8 -0
- package/cli/slicer-app.d.ts +2 -0
- package/cli/slicer-app.js +2 -1
- package/config.d.ts +2 -0
- package/config.js +2 -1
- package/documentation/wiki-interface.js +1 -0
- package/documentation/wiki-query.js +4 -3
- package/package.json +1 -1
- package/project/context/flowr-analyzer-context.d.ts +2 -0
- package/project/context/flowr-analyzer-context.js +6 -0
- package/project/context/flowr-analyzer-files-context.d.ts +8 -0
- package/project/context/flowr-analyzer-files-context.js +40 -1
- package/project/dependency-version-space.d.ts +3 -1
- package/project/dependency-version-space.js +26 -20
- package/project/flowr-analyzer.d.ts +3 -0
- package/project/flowr-analyzer.js +4 -0
- package/queries/catalog/config-query/config-query-executor.js +3 -0
- package/queries/catalog/config-query/config-query-format.d.ts +5 -3
- package/queries/catalog/config-query/config-query-format.js +31 -21
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +21 -5
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +4 -2
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +16 -2
- package/queries/query.d.ts +4 -4
- package/util/schema.d.ts +2 -0
- package/util/schema.js +13 -0
- package/util/version.js +1 -1
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@ It offers a wide variety of features, for example:
|
|
|
24
24
|
|
|
25
25
|
```shell
|
|
26
26
|
$ docker run -it --rm eagleoutice/flowr # or npm run flowr
|
|
27
|
-
flowR repl v2.
|
|
27
|
+
flowR repl v2.13.0, R grammar v14 (tree-sitter engine)
|
|
28
28
|
R> :query @linter "read.csv(\"/root/x.txt\")"
|
|
29
29
|
```
|
|
30
30
|
|
|
@@ -33,17 +33,17 @@ It offers a wide variety of features, for example:
|
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
```text
|
|
36
|
-
Query: linter (
|
|
36
|
+
Query: linter (9 ms)
|
|
37
37
|
╰ Deprecated Functions (deprecated-functions): no findings
|
|
38
38
|
╰ File Path Validity (file-path-validity):
|
|
39
39
|
╰ certain:
|
|
40
40
|
╰ Path `/root/x.txt` at 1.1-23
|
|
41
|
-
╰ Metadata: totalReads: 1, totalUnknown: 0, totalWritesBeforeAlways: 0, totalValid: 0, searchTimeMs:
|
|
41
|
+
╰ Metadata: totalReads: 1, totalUnknown: 0, totalWritesBeforeAlways: 0, totalValid: 0, searchTimeMs: 1, processTimeMs: 0
|
|
42
42
|
╰ Seeded Randomness (seeded-randomness): no findings
|
|
43
43
|
╰ Absolute Paths (absolute-file-paths):
|
|
44
44
|
╰ certain:
|
|
45
45
|
╰ Path `/root/x.txt` at 1.1-23
|
|
46
|
-
╰ Metadata: totalConsidered: 1, totalUnknown: 0, searchTimeMs:
|
|
46
|
+
╰ Metadata: totalConsidered: 1, totalUnknown: 0, searchTimeMs: 1, processTimeMs: 0
|
|
47
47
|
╰ Unused Definitions (unused-definitions): no findings
|
|
48
48
|
╰ Network Functions (network-functions): no findings
|
|
49
49
|
╰ Dataframe Access Validation (dataframe-access-validation): no findings
|
|
@@ -54,7 +54,7 @@ It offers a wide variety of features, for example:
|
|
|
54
54
|
╰ Roxygen Arguments (roxygen-arguments): no findings
|
|
55
55
|
╰ No Leaked Credentials (no-leaked-credentials): no findings
|
|
56
56
|
╰ Undefined Symbol (undefined-symbol): no findings
|
|
57
|
-
All queries together required ≈
|
|
57
|
+
All queries together required ≈9 ms (1ms accuracy, total 9 ms)
|
|
58
58
|
```
|
|
59
59
|
|
|
60
60
|
|
|
@@ -76,12 +76,12 @@ It offers a wide variety of features, for example:
|
|
|
76
76
|
|
|
77
77
|
_Results (prettified and summarized):_
|
|
78
78
|
|
|
79
|
-
Query: **linter** (
|
|
79
|
+
Query: **linter** (11 ms)\
|
|
80
80
|
╰ **Deprecated Functions** (deprecated-functions): _no findings_\
|
|
81
81
|
╰ **File Path Validity** (file-path-validity):\
|
|
82
82
|
╰ certain:\
|
|
83
83
|
╰ Path `/root/x.txt` at 1.1-23\
|
|
84
|
-
╰ _Metadata_: totalReads: 1, totalUnknown: 0, totalWritesBeforeAlways: 0, totalValid: 0, searchTimeMs:
|
|
84
|
+
╰ _Metadata_: totalReads: 1, totalUnknown: 0, totalWritesBeforeAlways: 0, totalValid: 0, searchTimeMs: 1, processTimeMs: 0\
|
|
85
85
|
╰ **Seeded Randomness** (seeded-randomness): _no findings_\
|
|
86
86
|
╰ **Absolute Paths** (absolute-file-paths):\
|
|
87
87
|
╰ certain:\
|
|
@@ -97,11 +97,11 @@ It offers a wide variety of features, for example:
|
|
|
97
97
|
╰ **Roxygen Arguments** (roxygen-arguments): _no findings_\
|
|
98
98
|
╰ **No Leaked Credentials** (no-leaked-credentials): _no findings_\
|
|
99
99
|
╰ **Undefined Symbol** (undefined-symbol): _no findings_\
|
|
100
|
-
_All queries together required ≈
|
|
100
|
+
_All queries together required ≈11 ms (1ms accuracy, total 12 ms)_
|
|
101
101
|
|
|
102
102
|
<details> <summary style="color:gray">Show Detailed Results as Json</summary>
|
|
103
103
|
|
|
104
|
-
The analysis required
|
|
104
|
+
The analysis required _12.4 ms_ (including parsing and normalization and the query) within the generation environment.
|
|
105
105
|
|
|
106
106
|
In general, the JSON contains the Ids of the nodes in question as they are present in the normalized AST or the dataflow graph of flowR.
|
|
107
107
|
Please consult the [Interface](https://github.com/flowr-analysis/flowr/wiki/Interface) wiki page for more information on how to get those.
|
|
@@ -118,8 +118,8 @@ It offers a wide variety of features, for example:
|
|
|
118
118
|
".meta": {
|
|
119
119
|
"totalCalls": 0,
|
|
120
120
|
"totalFunctionDefinitions": 0,
|
|
121
|
-
"searchTimeMs":
|
|
122
|
-
"processTimeMs":
|
|
121
|
+
"searchTimeMs": 3,
|
|
122
|
+
"processTimeMs": 1
|
|
123
123
|
}
|
|
124
124
|
},
|
|
125
125
|
"file-path-validity": {
|
|
@@ -141,8 +141,8 @@ It offers a wide variety of features, for example:
|
|
|
141
141
|
"totalUnknown": 0,
|
|
142
142
|
"totalWritesBeforeAlways": 0,
|
|
143
143
|
"totalValid": 0,
|
|
144
|
-
"searchTimeMs":
|
|
145
|
-
"processTimeMs":
|
|
144
|
+
"searchTimeMs": 1,
|
|
145
|
+
"processTimeMs": 0
|
|
146
146
|
}
|
|
147
147
|
},
|
|
148
148
|
"seeded-randomness": {
|
|
@@ -153,7 +153,7 @@ It offers a wide variety of features, for example:
|
|
|
153
153
|
"callsWithAssignmentProducers": 0,
|
|
154
154
|
"callsWithNonConstantProducers": 0,
|
|
155
155
|
"callsWithOtherBranchProducers": 0,
|
|
156
|
-
"searchTimeMs":
|
|
156
|
+
"searchTimeMs": 1,
|
|
157
157
|
"processTimeMs": 0
|
|
158
158
|
}
|
|
159
159
|
},
|
|
@@ -182,7 +182,7 @@ It offers a wide variety of features, for example:
|
|
|
182
182
|
".meta": {
|
|
183
183
|
"totalConsidered": 0,
|
|
184
184
|
"searchTimeMs": 0,
|
|
185
|
-
"processTimeMs":
|
|
185
|
+
"processTimeMs": 1
|
|
186
186
|
}
|
|
187
187
|
},
|
|
188
188
|
"network-functions": {
|
|
@@ -262,16 +262,16 @@ It offers a wide variety of features, for example:
|
|
|
262
262
|
"subscript": 0
|
|
263
263
|
},
|
|
264
264
|
"searchTimeMs": 0,
|
|
265
|
-
"processTimeMs":
|
|
265
|
+
"processTimeMs": 3
|
|
266
266
|
}
|
|
267
267
|
}
|
|
268
268
|
},
|
|
269
269
|
".meta": {
|
|
270
|
-
"timing":
|
|
270
|
+
"timing": 11
|
|
271
271
|
}
|
|
272
272
|
},
|
|
273
273
|
".meta": {
|
|
274
|
-
"timing":
|
|
274
|
+
"timing": 11
|
|
275
275
|
}
|
|
276
276
|
}
|
|
277
277
|
```
|
|
@@ -335,7 +335,7 @@ It offers a wide variety of features, for example:
|
|
|
335
335
|
|
|
336
336
|
```shell
|
|
337
337
|
$ docker run -it --rm eagleoutice/flowr # or npm run flowr
|
|
338
|
-
flowR repl v2.
|
|
338
|
+
flowR repl v2.13.0, R grammar v14 (tree-sitter engine)
|
|
339
339
|
R> :query @static-slice (11@sum) file://test/testfiles/example.R
|
|
340
340
|
```
|
|
341
341
|
|
|
@@ -349,7 +349,7 @@ It offers a wide variety of features, for example:
|
|
|
349
349
|
N <- 10
|
|
350
350
|
for(i in 1:(N-1)) sum <- sum + i + w
|
|
351
351
|
sum
|
|
352
|
-
All queries together required ≈
|
|
352
|
+
All queries together required ≈6 ms (1ms accuracy, total 7 ms)
|
|
353
353
|
```
|
|
354
354
|
|
|
355
355
|
|
|
@@ -381,7 +381,7 @@ It offers a wide variety of features, for example:
|
|
|
381
381
|
</details>
|
|
382
382
|
|
|
383
383
|
* 🚀 **fast call-graph, data-, and control-flow graphs**\
|
|
384
|
-
Within just [<i><span title="This measurement is automatically fetched from the latest benchmark!">
|
|
384
|
+
Within just [<i><span title="This measurement is automatically fetched from the latest benchmark!">104.8 ms</span></i> (as of Jul 20, 2026)](https://flowr-analysis.github.io/flowr/wiki/stats/benchmark),
|
|
385
385
|
_flowR_ can analyze the data- and control-flow of the average real-world R script. See the [benchmarks](https://flowr-analysis.github.io/flowr/wiki/stats/benchmark) for more information,
|
|
386
386
|
and consult the [wiki pages](https://github.com/flowr-analysis/flowr/wiki/dataflow-graph) for more details on the [dataflow graphs](https://github.com/flowr-analysis/flowr/wiki/dataflow-graph) as well as [call graphs](https://github.com/flowr-analysis/flowr/wiki/dataflow-graph#perspectives-cg).
|
|
387
387
|
|
|
@@ -417,7 +417,7 @@ It offers a wide variety of features, for example:
|
|
|
417
417
|
|
|
418
418
|
```shell
|
|
419
419
|
$ docker run -it --rm eagleoutice/flowr # or npm run flowr
|
|
420
|
-
flowR repl v2.
|
|
420
|
+
flowR repl v2.13.0, R grammar v14 (tree-sitter engine)
|
|
421
421
|
R> :dataflow* test/testfiles/example.R
|
|
422
422
|
```
|
|
423
423
|
|
|
@@ -690,7 +690,7 @@ It offers a wide variety of features, for example:
|
|
|
690
690
|
```
|
|
691
691
|
|
|
692
692
|
|
|
693
|
-
(The analysis required
|
|
693
|
+
(The analysis required _3.4 ms_ (including parse and normalize, using the [tree-sitter](https://github.com/flowr-analysis/flowr/wiki/Engines) engine) within the generation environment. No [signature database](https://github.com/flowr-analysis/flowr/wiki/Signature-Database) is mounted for these generated graphs, so `library()` calls attach no package exports; base-R names are still qualified via the generated base-package store (e.g. `acf` as `stats::acf`).)
|
|
694
694
|
|
|
695
695
|
|
|
696
696
|
|
package/cli/common/options.d.ts
CHANGED
|
@@ -299,6 +299,16 @@ export declare const slicerOptions: [{
|
|
|
299
299
|
readonly name: "api";
|
|
300
300
|
readonly type: BooleanConstructor;
|
|
301
301
|
readonly description: "Instead of human-readable output, dump a lot of json with the results of all intermediate steps.";
|
|
302
|
+
}, {
|
|
303
|
+
readonly name: "config-file";
|
|
304
|
+
readonly type: StringConstructor;
|
|
305
|
+
readonly description: "The name of the configuration file to use";
|
|
306
|
+
readonly multiple: false;
|
|
307
|
+
}, {
|
|
308
|
+
readonly name: "config-json";
|
|
309
|
+
readonly type: StringConstructor;
|
|
310
|
+
readonly description: "The flowR configuration to use, as a JSON string";
|
|
311
|
+
readonly multiple: false;
|
|
302
312
|
}];
|
|
303
313
|
export declare const summarizerOptions: [{
|
|
304
314
|
readonly name: "verbose";
|
package/cli/common/options.js
CHANGED
|
@@ -68,6 +68,8 @@ exports.slicerOptions = [
|
|
|
68
68
|
{ name: 'inline-banner', alias: 'B', type: Boolean, description: 'Together with {bold --inline-full}: precede every inlined file with a banner comment naming it.' },
|
|
69
69
|
{ name: 'include-callees', type: Boolean, description: 'If slicing backward, continue past a function-definition boundary, also including the definition\'s binding and call sites.' },
|
|
70
70
|
{ name: 'api', type: Boolean, description: 'Instead of human-readable output, dump a lot of json with the results of all intermediate steps.' },
|
|
71
|
+
{ name: 'config-file', type: String, description: 'The name of the configuration file to use', multiple: false },
|
|
72
|
+
{ name: 'config-json', type: String, description: 'The flowR configuration to use, as a JSON string', multiple: false },
|
|
71
73
|
];
|
|
72
74
|
exports.summarizerOptions = [
|
|
73
75
|
{ name: 'verbose', alias: 'v', type: Boolean, description: 'Run with verbose logging' },
|
|
@@ -105,6 +105,16 @@ declare const _scripts: {
|
|
|
105
105
|
readonly name: "api";
|
|
106
106
|
readonly type: BooleanConstructor;
|
|
107
107
|
readonly description: "Instead of human-readable output, dump a lot of json with the results of all intermediate steps.";
|
|
108
|
+
}, {
|
|
109
|
+
readonly name: "config-file";
|
|
110
|
+
readonly type: StringConstructor;
|
|
111
|
+
readonly description: "The name of the configuration file to use";
|
|
112
|
+
readonly multiple: false;
|
|
113
|
+
}, {
|
|
114
|
+
readonly name: "config-json";
|
|
115
|
+
readonly type: StringConstructor;
|
|
116
|
+
readonly description: "The flowR configuration to use, as a JSON string";
|
|
117
|
+
readonly multiple: false;
|
|
108
118
|
}];
|
|
109
119
|
usageExample: string;
|
|
110
120
|
type: string;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { ReplCodeCommand, ReplCommand } from './repl-main';
|
|
2
|
+
import type { OptionDefinition } from 'command-line-usage';
|
|
2
3
|
import { scripts } from '../../common/scripts-info';
|
|
4
|
+
import type { FlowrConfig } from '../../../config';
|
|
3
5
|
export declare const helpCommand: ReplCommand;
|
|
4
6
|
/**
|
|
5
7
|
* All commands that should be available in the REPL.
|
|
@@ -28,6 +30,12 @@ declare const _commands: {
|
|
|
28
30
|
readonly signature: ReplCodeCommand;
|
|
29
31
|
};
|
|
30
32
|
export type ReplCommandNames = keyof typeof _commands | keyof typeof scripts;
|
|
33
|
+
/**
|
|
34
|
+
* The args a master script is forked with: `remainingLine` tokenized, plus `--config-json <analyzer.flowrConfig>`
|
|
35
|
+
* so it sees the repl's current (possibly `:query \@config`-edited) config -- unless the script does not support
|
|
36
|
+
* that option, or the user already named a config themselves.
|
|
37
|
+
*/
|
|
38
|
+
export declare function masterScriptArgs(remainingLine: string, config: FlowrConfig, scriptOptions: readonly OptionDefinition[]): string[];
|
|
31
39
|
/**
|
|
32
40
|
* Retrieve all REPL commands (including those generated from master scripts)
|
|
33
41
|
*/
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.helpCommand = void 0;
|
|
4
|
+
exports.masterScriptArgs = masterScriptArgs;
|
|
4
5
|
exports.getReplCommands = getReplCommands;
|
|
5
6
|
exports.getCommandNames = getCommandNames;
|
|
6
7
|
exports.getCommand = getCommand;
|
|
@@ -160,6 +161,18 @@ function hasModule(path) {
|
|
|
160
161
|
return false;
|
|
161
162
|
}
|
|
162
163
|
}
|
|
164
|
+
/**
|
|
165
|
+
* The args a master script is forked with: `remainingLine` tokenized, plus `--config-json <analyzer.flowrConfig>`
|
|
166
|
+
* so it sees the repl's current (possibly `:query \@config`-edited) config -- unless the script does not support
|
|
167
|
+
* that option, or the user already named a config themselves.
|
|
168
|
+
*/
|
|
169
|
+
function masterScriptArgs(remainingLine, config, scriptOptions) {
|
|
170
|
+
const args = (0, args_1.splitAtEscapeSensitive)(remainingLine);
|
|
171
|
+
if (scriptOptions.some(o => o.name === 'config-json') && !args.includes('--config-json') && !args.includes('--config-file')) {
|
|
172
|
+
args.push('--config-json', JSON.stringify(config));
|
|
173
|
+
}
|
|
174
|
+
return args;
|
|
175
|
+
}
|
|
163
176
|
/**
|
|
164
177
|
* Retrieve all REPL commands (including those generated from master scripts)
|
|
165
178
|
*/
|
|
@@ -168,7 +181,7 @@ function getReplCommands() {
|
|
|
168
181
|
return _commands;
|
|
169
182
|
}
|
|
170
183
|
commandsInitialized = true;
|
|
171
|
-
for (const [script, { target, description, type }] of Object.entries(scripts_info_1.scripts)) {
|
|
184
|
+
for (const [script, { target, description, type, options }] of Object.entries(scripts_info_1.scripts)) {
|
|
172
185
|
if (type === 'master script') {
|
|
173
186
|
_commands[script] = {
|
|
174
187
|
description,
|
|
@@ -176,7 +189,7 @@ function getReplCommands() {
|
|
|
176
189
|
script: true,
|
|
177
190
|
usageExample: `:${script} --help`,
|
|
178
191
|
isCodeCommand: false,
|
|
179
|
-
fn: async ({ output, remainingLine }) => {
|
|
192
|
+
fn: async ({ output, remainingLine, analyzer }) => {
|
|
180
193
|
// check if the target *module* exists in the current directory, else try two dirs up, otherwise, fail with a message
|
|
181
194
|
let path = `${__dirname}/${target}`;
|
|
182
195
|
if (!hasModule(path)) {
|
|
@@ -186,7 +199,7 @@ function getReplCommands() {
|
|
|
186
199
|
return;
|
|
187
200
|
}
|
|
188
201
|
}
|
|
189
|
-
await (0, execute_1.waitOnScript)(path, (
|
|
202
|
+
await (0, execute_1.waitOnScript)(path, masterScriptArgs(remainingLine, analyzer.flowrConfig, options), stdio => (0, execute_1.stdioCaptureProcessor)(stdio, msg => output.stdout(msg), msg => output.stderr(msg)));
|
|
190
203
|
}
|
|
191
204
|
};
|
|
192
205
|
}
|
|
@@ -157,12 +157,20 @@ async function processQueryArgs(output, analyzer, remainingArgs) {
|
|
|
157
157
|
analyzer
|
|
158
158
|
};
|
|
159
159
|
}
|
|
160
|
+
const ConfigLineRegex = /^(@config)(?:\s+([\s\S]*))?$/;
|
|
160
161
|
/**
|
|
161
162
|
* Function for splitting the input line.
|
|
162
163
|
* All input is treated as arguments, no R code is separated so that the individual queries can handle it.
|
|
164
|
+
* `@config` is passed its rest-of-line untouched, since its own `fromLine` reads a single raw token and the
|
|
165
|
+
* generic tokenizer would otherwise strip quotes out of a `+path=["a"]` value.
|
|
163
166
|
* @param line - The input line
|
|
164
167
|
*/
|
|
165
168
|
function parseArgs(line) {
|
|
169
|
+
const configMatch = ConfigLineRegex.exec(line);
|
|
170
|
+
if (configMatch) {
|
|
171
|
+
const [, name, rest] = configMatch;
|
|
172
|
+
return { rCode: undefined, remaining: rest === undefined ? [name] : [name, rest] };
|
|
173
|
+
}
|
|
166
174
|
const args = (0, args_1.splitAtEscapeSensitive)(line);
|
|
167
175
|
return {
|
|
168
176
|
rCode: undefined,
|
package/cli/slicer-app.d.ts
CHANGED
package/cli/slicer-app.js
CHANGED
|
@@ -31,7 +31,8 @@ async function getSlice() {
|
|
|
31
31
|
const slicer = new slicer_1.BenchmarkSlicer('r-shell');
|
|
32
32
|
(0, assert_1.guard)(options.input !== undefined, 'input must be given');
|
|
33
33
|
(0, assert_1.guard)(options.criterion !== undefined, 'a slicing criterion must be given');
|
|
34
|
-
const config = config_1.FlowrConfig.
|
|
34
|
+
const config = (options['config-json'] ? config_1.FlowrConfig.parse(options['config-json']) : undefined)
|
|
35
|
+
?? config_1.FlowrConfig.fromFile(options['config-file']);
|
|
35
36
|
await slicer.init(options['input-is-text']
|
|
36
37
|
? { request: 'text', content: options.input.replaceAll('\\n', '\n') }
|
|
37
38
|
: { request: 'file', content: options.input }, config, options['no-magic-comments'] ? auto_select_defaults_1.doNotAutoSelect : (0, magic_comments_1.makeMagicCommentHandler)(auto_select_defaults_1.doNotAutoSelect), undefined, options.inline, options['include-callees'], options['inline-full'] ? (options['inline-banner'] ? 'banner' : true) : undefined);
|
package/config.d.ts
CHANGED
|
@@ -156,6 +156,8 @@ export interface FlowrConfig extends MergeableRecord {
|
|
|
156
156
|
readonly project: {
|
|
157
157
|
/** Whether to resolve unknown paths loaded by the r project disk when trying to source/analyze files */
|
|
158
158
|
resolveUnknownPathsOnDisk: boolean;
|
|
159
|
+
/** Overwrite the {@link ProjectKind} flowR would otherwise infer from the analyzed files, e.g. when auto-detection guesses wrong. */
|
|
160
|
+
useProjectType?: ProjectKind;
|
|
159
161
|
/**
|
|
160
162
|
* The packages considered part of R itself, used e.g. by the project query to classify dependencies. If
|
|
161
163
|
* unset, flowR derives them (for the assumed R version) from the signature database via `baseRPackages`.
|
package/config.js
CHANGED
|
@@ -295,7 +295,8 @@ exports.FlowrConfig = {
|
|
|
295
295
|
project: joi_1.default.object({
|
|
296
296
|
resolveUnknownPathsOnDisk: joi_1.default.boolean().optional().description('Whether to resolve unknown paths loaded by the r project disk when trying to source/analyze files.'),
|
|
297
297
|
basePackages: joi_1.default.array().items(joi_1.default.string()).optional().description('The packages considered part of R itself (base and recommended); if unset, flowR uses its built-in list.'),
|
|
298
|
-
implicitSources: joi_1.default.array().items(joi_1.default.string()).optional().description('Files a framework loads on its own, without any source() call (e.g. global.R in a shiny app), in the order they are loaded; flowR orders the matching project files accordingly and analyzes them as one program. Entries are case-insensitive globs matched against the file path, a plain name matches any file with that name, and entries matching no project file are warned about. Usually set per project kind via specializeConfig.')
|
|
298
|
+
implicitSources: joi_1.default.array().items(joi_1.default.string()).optional().description('Files a framework loads on its own, without any source() call (e.g. global.R in a shiny app), in the order they are loaded; flowR orders the matching project files accordingly and analyzes them as one program. Entries are case-insensitive globs matched against the file path, a plain name matches any file with that name, and entries matching no project file are warned about. Usually set per project kind via specializeConfig.'),
|
|
299
|
+
useProjectType: joi_1.default.string().valid(...Object.values(project_kind_1.ProjectKind)).optional().description('Overwrite the project kind flowR would otherwise infer from the analyzed files, e.g. when auto-detection guesses wrong.')
|
|
299
300
|
}).description('Project specific configuration options.'),
|
|
300
301
|
linter: joi_1.default.object({
|
|
301
302
|
disabledRules: joi_1.default.array().items(joi_1.default.string()).description('Linting rule names excluded from the default rule set (a rule requested explicitly via a linter query still runs). Usually set per project kind via specializeConfig.')
|
|
@@ -235,6 +235,7 @@ The schema below documents every option; the ones you most likely want are:
|
|
|
235
235
|
loaded. Entries are globs (e.g. \`R/*.R\`) matched against the file path ignoring capitalization; one matching no file is reported.
|
|
236
236
|
- ${ctx.linkConfig('specializeConfig')}: overwrite (parts of) the configuration depending on the kind of project _flowR_ detects
|
|
237
237
|
(e.g. \`shiny-app\`), which is how a shiny app gets its implicit sources by default. What you configure directly wins.
|
|
238
|
+
- ${ctx.linkConfig('project.useProjectType')}: skip that detection and force a project kind yourself, when auto-detection guesses wrong.
|
|
238
239
|
- ${ctx.linkConfig('defaultPlugins')} and ${ctx.linkConfig('repl.plugins')}: the plugins to load for a new ${ctx.link(flowr_analyzer_1.FlowrAnalyzer)} and in the REPL
|
|
239
240
|
(use \`flowr:default\` to reference the former).
|
|
240
241
|
|
|
@@ -948,7 +948,7 @@ To find out what a script _uses_, reach for the ${(0, doc_query_1.linkToQueryOfN
|
|
|
948
948
|
buildExplanation: async (shell, ctx) => {
|
|
949
949
|
const exampleCode = 'library(dplyr)\nmutate(mtcars, across(everything(), round))';
|
|
950
950
|
return `
|
|
951
|
-
A script rarely says which version of a package it needs
|
|
951
|
+
A script rarely says which version of a package it needs, but it shows you. If it passes an argument that a function only
|
|
952
952
|
gained in some release, it cannot run on anything older. This query turns that observation into a concrete version range per dependency.
|
|
953
953
|
|
|
954
954
|
It combines two sources of evidence:
|
|
@@ -963,8 +963,8 @@ Two things can raise a lower bound: calling a function that did not exist yet, o
|
|
|
963
963
|
function only gained later. Consider a script calling \`dplyr::across\`:
|
|
964
964
|
${(0, doc_code_1.codeBlock)('r', exampleCode)}
|
|
965
965
|
|
|
966
|
-
\`across\` was only introduced in dplyr 1.0.0, so the script cannot run on anything older
|
|
967
|
-
|
|
966
|
+
\`across\` was only introduced in dplyr 1.0.0, so the script cannot run on anything older. The result names the function
|
|
967
|
+
that produced the bound:
|
|
968
968
|
|
|
969
969
|
${await (0, doc_query_1.showQuery)(shell, exampleCode, [{ type: 'guess-dep-versions' }], { showCode: false, collapseResult: true, ctx })}
|
|
970
970
|
|
|
@@ -973,6 +973,7 @@ The guess can be narrowed further:
|
|
|
973
973
|
* \`packages\` restricts it to the dependencies you care about,
|
|
974
974
|
* \`date\` caps every guess to releases available at that point in time (\`YYYY.MM.DD\`, also \`YYYY\` or \`YYYY.MM\`),
|
|
975
975
|
* \`clean\` ignores the declared constraints entirely and guesses purely from usage,
|
|
976
|
+
* \`disabled\` excludes individual evidence sources by name (repl: \`--disabled\` followed by their one-letter codes shown in the legend below, e.g. \`--disabled ds\` drops \`declared\` and \`signature\`),
|
|
976
977
|
* \`maxCandidates\` caps how many candidate versions are listed per dependency,
|
|
977
978
|
* \`maxIterations\` bounds the two fixpoint loops (packages constrain each other, so the guess is iterated until it settles), and
|
|
978
979
|
* \`explode\` additionally enumerates concrete version _combinations_ (\`order\`, \`prefer\`, and \`limit\` control which and how many).
|
package/package.json
CHANGED
|
@@ -102,6 +102,8 @@ export declare class FlowrAnalyzerContext implements ReadOnlyFlowrAnalyzerContex
|
|
|
102
102
|
* invalidated separately (see {@link FlowrAnalyzer.updateConfig}), as the results were computed under the old config.
|
|
103
103
|
*/
|
|
104
104
|
updateConfig(update: DeepPartial<FlowrConfig>): void;
|
|
105
|
+
/** Discards every {@link updateConfig} override made so far, reverting {@link config} back to {@link baseConfig} (specialized for the project kind). */
|
|
106
|
+
resetConfig(): void;
|
|
105
107
|
/** The project kind the effective {@link config} is specialized for, plus the overrides it applies, or `undefined` when no specialization is in effect. */
|
|
106
108
|
configSpecialization(): {
|
|
107
109
|
readonly kind: ProjectKind;
|
|
@@ -114,6 +114,12 @@ class FlowrAnalyzerContext {
|
|
|
114
114
|
throw e;
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
|
+
/** Discards every {@link updateConfig} override made so far, reverting {@link config} back to {@link baseConfig} (specialized for the project kind). */
|
|
118
|
+
resetConfig() {
|
|
119
|
+
this.runtimeOverrides = undefined;
|
|
120
|
+
this._effective = undefined;
|
|
121
|
+
this._effectiveOf = undefined;
|
|
122
|
+
}
|
|
117
123
|
/** The project kind the effective {@link config} is specialized for, plus the overrides it applies, or `undefined` when no specialization is in effect. */
|
|
118
124
|
configSpecialization() {
|
|
119
125
|
if (this.baseConfig.specializeConfig === undefined || this._classifying) {
|
|
@@ -132,6 +132,8 @@ export declare class FlowrAnalyzerFilesContext extends AbstractFlowrAnalyzerCont
|
|
|
132
132
|
/** cached {@link projectKind}, invalidated whenever the files change (added or reset) */
|
|
133
133
|
private projectKindCache;
|
|
134
134
|
private requestedRoots;
|
|
135
|
+
/** directories already scanned by {@link discoverImplicitSources}, so a sibling implicit source is not re-triggered for every file added from it */
|
|
136
|
+
private implicitSourceDirs;
|
|
135
137
|
/** cached {@link root}, fixed on first use as the ids built from it have to stay stable */
|
|
136
138
|
private rootCache;
|
|
137
139
|
private rootResolved;
|
|
@@ -167,6 +169,12 @@ export declare class FlowrAnalyzerFilesContext extends AbstractFlowrAnalyzerCont
|
|
|
167
169
|
* User-registered discovery plugins replace the built-in default; if none are registered, the default runs.
|
|
168
170
|
*/
|
|
169
171
|
private addRequest;
|
|
172
|
+
/**
|
|
173
|
+
* A single-file request otherwise skips project discovery entirely, so a sibling `project.implicitSources`
|
|
174
|
+
* entry (e.g. a shiny app's `s.R` next to the analyzed `t.R`) would never be found. If `implicitSources` is
|
|
175
|
+
* configured, scan `fileContent`'s directory once and add whatever matches.
|
|
176
|
+
*/
|
|
177
|
+
private discoverImplicitSources;
|
|
170
178
|
/**
|
|
171
179
|
* Add multiple files to the context. This is just a convenience method that calls {@link addFile} for each file.
|
|
172
180
|
*/
|
|
@@ -14,6 +14,7 @@ const log_1 = require("../../util/log");
|
|
|
14
14
|
const fs_1 = __importDefault(require("fs"));
|
|
15
15
|
const path_1 = __importDefault(require("path"));
|
|
16
16
|
const files_1 = require("../../util/files");
|
|
17
|
+
const glob_1 = require("../../util/glob");
|
|
17
18
|
const project_kind_1 = require("./project-kind");
|
|
18
19
|
const fileLog = log_1.log.getSubLogger({ name: 'flowr-analyzer-files-context' });
|
|
19
20
|
const notebookExtension = /\.(ipynb|rmd|qmd|rnw)$/;
|
|
@@ -57,6 +58,8 @@ class FlowrAnalyzerFilesContext extends abstract_flowr_analyzer_context_1.Abstra
|
|
|
57
58
|
/** cached {@link projectKind}, invalidated whenever the files change (added or reset) */
|
|
58
59
|
projectKindCache = undefined;
|
|
59
60
|
requestedRoots = [];
|
|
61
|
+
/** directories already scanned by {@link discoverImplicitSources}, so a sibling implicit source is not re-triggered for every file added from it */
|
|
62
|
+
implicitSourceDirs = new Set();
|
|
60
63
|
/** cached {@link root}, fixed on first use as the ids built from it have to stay stable */
|
|
61
64
|
rootCache = undefined;
|
|
62
65
|
rootResolved = false;
|
|
@@ -104,7 +107,7 @@ class FlowrAnalyzerFilesContext extends abstract_flowr_analyzer_context_1.Abstra
|
|
|
104
107
|
return this.consideredFiles;
|
|
105
108
|
}
|
|
106
109
|
projectKind() {
|
|
107
|
-
return this.projectKindCache ??= this.classifyProject();
|
|
110
|
+
return this.projectKindCache ??= this.ctx.config.project.useProjectType ?? this.classifyProject();
|
|
108
111
|
}
|
|
109
112
|
classifyProject() {
|
|
110
113
|
const descriptions = this.getFilesByRole(flowr_file_1.FileRole.Description);
|
|
@@ -195,6 +198,7 @@ class FlowrAnalyzerFilesContext extends abstract_flowr_analyzer_context_1.Abstra
|
|
|
195
198
|
if (request.request !== 'project') {
|
|
196
199
|
if (request.request === 'file') {
|
|
197
200
|
this.requestedRoots.push(path_1.default.dirname(request.content));
|
|
201
|
+
this.discoverImplicitSources(request.content);
|
|
198
202
|
}
|
|
199
203
|
this.loadingOrder.addRequest(request);
|
|
200
204
|
this.projectKindCache = undefined;
|
|
@@ -214,6 +218,41 @@ class FlowrAnalyzerFilesContext extends abstract_flowr_analyzer_context_1.Abstra
|
|
|
214
218
|
}
|
|
215
219
|
}
|
|
216
220
|
}
|
|
221
|
+
/**
|
|
222
|
+
* A single-file request otherwise skips project discovery entirely, so a sibling `project.implicitSources`
|
|
223
|
+
* entry (e.g. a shiny app's `s.R` next to the analyzed `t.R`) would never be found. If `implicitSources` is
|
|
224
|
+
* configured, scan `fileContent`'s directory once and add whatever matches.
|
|
225
|
+
*/
|
|
226
|
+
discoverImplicitSources(fileContent) {
|
|
227
|
+
const implicit = this.ctx.config.project.implicitSources;
|
|
228
|
+
if (!implicit || implicit.length === 0) {
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
const dir = path_1.default.dirname(fileContent);
|
|
232
|
+
if (this.implicitSourceDirs.has(dir)) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
this.implicitSourceDirs.add(dir);
|
|
236
|
+
if (!fs_1.default.existsSync(dir) || !fs_1.default.statSync(dir).isDirectory()) {
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
const matchers = implicit.map(entry => (0, glob_1.globMatcher)(entry));
|
|
240
|
+
const active = this.discoveryPlugins.length > 0
|
|
241
|
+
? this.discoveryPlugins
|
|
242
|
+
: [flowr_analyzer_project_discovery_plugin_1.FlowrAnalyzerProjectDiscoveryPlugin.defaultPlugin()];
|
|
243
|
+
for (const req of active.flatMap(p => p.processor(this.ctx, { request: 'project', content: dir }))) {
|
|
244
|
+
const filePath = (0, retriever_1.isParseRequest)(req) ? (req.request === 'file' ? req.content : undefined) : req.path();
|
|
245
|
+
if (filePath === undefined || filePath === fileContent || !matchers.some(m => m(filePath))) {
|
|
246
|
+
continue;
|
|
247
|
+
}
|
|
248
|
+
if ((0, retriever_1.isParseRequest)(req)) {
|
|
249
|
+
this.addRequest(req);
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
this.addFile(req, req.roles);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
217
256
|
/**
|
|
218
257
|
* Add multiple files to the context. This is just a convenience method that calls {@link addFile} for each file.
|
|
219
258
|
*/
|
|
@@ -142,11 +142,13 @@ export interface CountFactor {
|
|
|
142
142
|
export declare function countRunnableCombinations(hub: CountFactor | undefined, others: readonly CountFactor[]): number;
|
|
143
143
|
/** whether every requirement `pkg@ver` places on a co-guessed dependency is met by one of that partner's surviving versions */
|
|
144
144
|
export declare function versionMeetsPartners(src: PackageSignatureSource, pkg: string, ver: string, partnerSurvivors: ReadonlyMap<string, readonly string[]>, selfName: string, onReject?: (partner: string, constraint: string) => void): boolean;
|
|
145
|
+
/** an empty set, shared so callers that do not disable anything need not allocate one */
|
|
146
|
+
export declare const NoDisabledSources: ReadonlySet<ConstraintSource>;
|
|
145
147
|
/**
|
|
146
148
|
* Apply every constraint (declared, transitive, base-R, date, then signature usage) to a package's timeline. When an
|
|
147
149
|
* `observe` callback is given, emits the provenance of each constraint (including the signature lower bounds).
|
|
148
150
|
*/
|
|
149
|
-
export declare function survivingEntries(name: string, src: PackageSignatureSource | undefined, deps: ReadOnlyFlowrAnalyzerDependenciesContext, usage: PackageUsage | undefined, transitive: readonly TransitiveConstraint[], cutoff: Date | undefined, rVersion: string | undefined, observe?: ConstraintObserver,
|
|
151
|
+
export declare function survivingEntries(name: string, src: PackageSignatureSource | undefined, deps: ReadOnlyFlowrAnalyzerDependenciesContext, usage: PackageUsage | undefined, transitive: readonly TransitiveConstraint[], cutoff: Date | undefined, rVersion: string | undefined, observe?: ConstraintObserver, disabled?: ReadonlySet<ConstraintSource>, packageKey?: string): SurvivingEntries;
|
|
150
152
|
/** the sigdb package a target's version history is drawn from: `R` reuses `base` (their releases coincide), everything else is itself */
|
|
151
153
|
export declare function timelinePackageKey(name: string, sources: readonly PackageSignatureSource[]): string;
|
|
152
154
|
/** the ordered candidate list for one package, or `undefined` when nothing survives (shared by the query and the iterator) */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DefaultFixpointIterations = exports.DefaultExplodeLimit = void 0;
|
|
3
|
+
exports.NoDisabledSources = exports.DefaultFixpointIterations = exports.DefaultExplodeLimit = void 0;
|
|
4
4
|
exports.dateCutoff = dateCutoff;
|
|
5
5
|
exports.isoDay = isoDay;
|
|
6
6
|
exports.collectUsage = collectUsage;
|
|
@@ -393,27 +393,34 @@ function versionMeetsPartners(src, pkg, ver, partnerSurvivors, selfName, onRejec
|
|
|
393
393
|
}
|
|
394
394
|
return true;
|
|
395
395
|
}
|
|
396
|
+
/** an empty set, shared so callers that do not disable anything need not allocate one */
|
|
397
|
+
exports.NoDisabledSources = new Set();
|
|
396
398
|
/**
|
|
397
399
|
* Filter a version timeline by the declared range, transitive constraints, base-R version bound, and date cutoff,
|
|
398
400
|
* emitting each constraint to `observe` (when given) as it is applied -- so the filtering and its explanation cannot
|
|
399
|
-
* drift apart.
|
|
401
|
+
* drift apart. A source in `disabled` is skipped entirely: neither filtered on nor reported as evidence.
|
|
400
402
|
*/
|
|
401
|
-
function applyConstraints(timeline, name, declaredRange, declaredConstraints, transitive, base, rVersion, cutoff, observe) {
|
|
402
|
-
|
|
403
|
-
|
|
403
|
+
function applyConstraints(timeline, name, declaredRange, declaredConstraints, transitive, base, rVersion, cutoff, observe, disabled = exports.NoDisabledSources) {
|
|
404
|
+
let t = [...timeline];
|
|
405
|
+
if (!disabled.has('declared')) {
|
|
406
|
+
for (const c of declaredConstraints) {
|
|
407
|
+
observe?.({ source: 'declared', origin: 'project metadata', detail: `declared as ${c}`, bound: c });
|
|
408
|
+
}
|
|
409
|
+
t = declaredRange ? t.filter(e => r_version_1.RRange.satisfies(e.ver, declaredRange)) : t;
|
|
404
410
|
}
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
411
|
+
if (!disabled.has('transitive')) {
|
|
412
|
+
for (const c of transitive) {
|
|
413
|
+
observe?.({ source: 'transitive', origin: c.from, detail: `${c.from} requires ${name} ${c.range.raw}`, bound: c.range.raw });
|
|
414
|
+
t = t.filter(e => r_version_1.RRange.satisfies(e.ver, c.range));
|
|
415
|
+
}
|
|
409
416
|
}
|
|
410
417
|
// a base package's version *is* the R version, so it is bounded by the assumed/declared R (only when that is known)
|
|
411
|
-
const rv = base && rVersion ? r_version_1.RVersion.parse(rVersion) : undefined;
|
|
418
|
+
const rv = !disabled.has('base-r') && base && rVersion ? r_version_1.RVersion.parse(rVersion) : undefined;
|
|
412
419
|
if (rv) {
|
|
413
420
|
observe?.({ source: 'base-r', origin: `R ${rVersion}`, detail: `base package bounded by R ${rVersion}`, bound: `<=${rVersion}` });
|
|
414
421
|
t = t.filter(e => r_version_1.RVersion.compare(e.ver, rv.str) <= 0);
|
|
415
422
|
}
|
|
416
|
-
if (cutoff) {
|
|
423
|
+
if (cutoff && !disabled.has('date')) {
|
|
417
424
|
observe?.({ source: 'date', origin: isoDay(cutoff), detail: `only releases up to ${isoDay(cutoff)}`, bound: `<=${isoDay(cutoff)}` });
|
|
418
425
|
// base R is stored undated, so fall back to its R release date; a dated release must predate the cutoff, and an
|
|
419
426
|
// undated one is dropped -- except base R older than the release table (kept, as it predates any real cutoff)
|
|
@@ -428,13 +435,12 @@ function applyConstraints(timeline, name, declaredRange, declaredConstraints, tr
|
|
|
428
435
|
* Apply every constraint (declared, transitive, base-R, date, then signature usage) to a package's timeline. When an
|
|
429
436
|
* `observe` callback is given, emits the provenance of each constraint (including the signature lower bounds).
|
|
430
437
|
*/
|
|
431
|
-
function survivingEntries(name, src, deps, usage, transitive, cutoff, rVersion, observe,
|
|
438
|
+
function survivingEntries(name, src, deps, usage, transitive, cutoff, rVersion, observe, disabled = exports.NoDisabledSources, packageKey = name) {
|
|
432
439
|
// packageKey: sigdb package (R reuses base, others use themselves)
|
|
433
440
|
const getFn = makeFnResolver(src, packageKey);
|
|
434
|
-
|
|
435
|
-
const
|
|
436
|
-
const
|
|
437
|
-
const effectiveTransitive = ignoreDeclared ? [] : transitive;
|
|
441
|
+
const declaredRange = disabled.has('declared') ? undefined : deps.inferredVersion(name);
|
|
442
|
+
const declaredConstraints = disabled.has('declared') ? [] : (deps.getDependency(name)?.versionConstraints.map(c => c.raw) ?? []);
|
|
443
|
+
const effectiveTransitive = disabled.has('transitive') ? [] : transitive;
|
|
438
444
|
// contradiction is a constraint property, not an empty database
|
|
439
445
|
const unsatisfiable = constraintsContradict(declaredConstraints, declaredRange, effectiveTransitive);
|
|
440
446
|
if (!src) {
|
|
@@ -444,12 +450,12 @@ function survivingEntries(name, src, deps, usage, transitive, cutoff, rVersion,
|
|
|
444
450
|
const timeline = versionTimeline(src, packageKey);
|
|
445
451
|
const total = timeline.length;
|
|
446
452
|
// emit database coverage envelope as outer bounds
|
|
447
|
-
if (observe && timeline.length > 0) {
|
|
453
|
+
if (observe && timeline.length > 0 && !disabled.has('available')) {
|
|
448
454
|
observe({ source: 'available', origin: 'signature database', detail: `data available from ${timeline[0].ver}`, bound: `>=${timeline[0].ver}` });
|
|
449
455
|
observe({ source: 'available', origin: 'signature database', detail: `data available up to ${timeline[timeline.length - 1].ver}`, bound: `<=${timeline[timeline.length - 1].ver}` });
|
|
450
456
|
}
|
|
451
|
-
const preSignature = applyConstraints(timeline, name, declaredRange, declaredConstraints, effectiveTransitive, base, rVersion, cutoff, observe);
|
|
452
|
-
if (!usage) {
|
|
457
|
+
const preSignature = applyConstraints(timeline, name, declaredRange, declaredConstraints, effectiveTransitive, base, rVersion, cutoff, observe, disabled);
|
|
458
|
+
if (!usage || disabled.has('signature')) {
|
|
453
459
|
return { survivors: preSignature, preSignature, getFn, declaredRange, declaredConstraints, base, unsatisfiable, total };
|
|
454
460
|
}
|
|
455
461
|
// exclude base primitives from base packages (captured inconsistently, so absence is data gap not removal)
|
|
@@ -543,7 +549,7 @@ async function orderedCandidatesFor(analyzer, options) {
|
|
|
543
549
|
for (const name of targets.sort()) {
|
|
544
550
|
const packageKey = timelinePackageKey(name, sources);
|
|
545
551
|
const src = (0, reader_1.sourceForPackage)(sources, packageKey);
|
|
546
|
-
const surviving = survivingEntries(name, src, deps, usage.get(name), transitive.get(name) ?? [], cutoff, rVersion, undefined,
|
|
552
|
+
const surviving = survivingEntries(name, src, deps, usage.get(name), transitive.get(name) ?? [], cutoff, rVersion, undefined, exports.NoDisabledSources, packageKey);
|
|
547
553
|
const oc = orderedCandidatesOf(src, name, surviving, options.prefer?.[name], order);
|
|
548
554
|
if (oc) {
|
|
549
555
|
out.push(oc);
|
|
@@ -143,6 +143,8 @@ export interface ReadonlyFlowrAnalysisProvider<Parser extends KnownParser = Know
|
|
|
143
143
|
flowrConfig: FlowrConfig;
|
|
144
144
|
/** Merge a runtime update into the base config and invalidate the derived config and cached analysis, so it takes effect. */
|
|
145
145
|
updateConfig(update: DeepPartial<FlowrConfig>): void;
|
|
146
|
+
/** Discard every {@link updateConfig} override made so far and invalidate the cached analysis. */
|
|
147
|
+
resetConfig(): void;
|
|
146
148
|
}
|
|
147
149
|
/**
|
|
148
150
|
* Central class for conducting analyses with FlowR.
|
|
@@ -174,6 +176,7 @@ export declare class FlowrAnalyzer<Parser extends KnownParser = KnownParser> imp
|
|
|
174
176
|
inspectContext(): ReadOnlyFlowrAnalyzerContext;
|
|
175
177
|
reset(): void;
|
|
176
178
|
updateConfig(update: DeepPartial<FlowrConfig>): void;
|
|
179
|
+
resetConfig(): void;
|
|
177
180
|
parseStandalone(data: `${typeof fileProtocol}${string}` | string | RParseRequest): Tree;
|
|
178
181
|
normalizeStandalone(data: `${typeof fileProtocol}${string}` | string | RParseRequest): NormalizedAst;
|
|
179
182
|
addRequest(...request: (RAnalysisRequest | readonly RAnalysisRequest[] | `${typeof fileProtocol}${string}` | string)[]): this;
|
|
@@ -60,6 +60,10 @@ class FlowrAnalyzer {
|
|
|
60
60
|
// the parse/dataflow results were computed under the previous config, so they must be recomputed
|
|
61
61
|
this.cache.reset();
|
|
62
62
|
}
|
|
63
|
+
resetConfig() {
|
|
64
|
+
this.ctx.resetConfig();
|
|
65
|
+
this.cache.reset();
|
|
66
|
+
}
|
|
63
67
|
parseStandalone(data) {
|
|
64
68
|
const request = (0, retriever_1.isParseRequest)(data) ? data : (0, retriever_1.requestFromInput)(data);
|
|
65
69
|
if (this.parser.name === 'tree-sitter') {
|
|
@@ -8,6 +8,9 @@ const assert_1 = require("../../../util/assert");
|
|
|
8
8
|
* Executes the given configuration queries using the provided analyzer.
|
|
9
9
|
*/
|
|
10
10
|
function executeConfigQuery({ analyzer }, queries) {
|
|
11
|
+
if (queries.some(q => q.reset)) {
|
|
12
|
+
analyzer.resetConfig();
|
|
13
|
+
}
|
|
11
14
|
const updates = queries.map(q => q.update).filter(assert_1.isNotUndefined);
|
|
12
15
|
if (updates.length > 1) {
|
|
13
16
|
log_1.log.warn('Config query usually expects only up to one update, but got', updates.length);
|
|
@@ -13,6 +13,8 @@ export interface ConfigQuery extends BaseQueryFormat {
|
|
|
13
13
|
readonly update?: DeepPartial<FlowrConfig>;
|
|
14
14
|
/** a `.`-separated path to inspect (read) a single config value instead of dumping the whole config (repl: `path`, which also accepts a `*`/`**` glob) */
|
|
15
15
|
readonly inspect?: readonly string[];
|
|
16
|
+
/** discard every runtime update made so far, reverting to the config the analyzer was created with (repl: `+reset`) */
|
|
17
|
+
readonly reset?: boolean;
|
|
16
18
|
}
|
|
17
19
|
export interface ConfigQueryResult extends BaseQueryResult {
|
|
18
20
|
readonly config: FlowrConfig;
|
|
@@ -22,17 +24,17 @@ export interface ConfigQueryResult extends BaseQueryResult {
|
|
|
22
24
|
readonly overwrite: DeepPartial<FlowrConfig>;
|
|
23
25
|
};
|
|
24
26
|
}
|
|
25
|
-
declare function configReplCompleter(partialLine: readonly string[], startingNewArg: boolean,
|
|
27
|
+
declare function configReplCompleter(partialLine: readonly string[], startingNewArg: boolean, _config: FlowrConfig): CommandCompletions;
|
|
26
28
|
/**
|
|
27
29
|
* The first schema violation (an unknown key or a wrong-typed value) in a config update, or `undefined` if it is
|
|
28
30
|
* valid. Shared by the repl line parser and the {@link executeConfigQuery|executor}, so a programmatic or JSON-API
|
|
29
31
|
* update is validated exactly like a `:config +key=value` line and never merges junk or a mistyped value.
|
|
30
32
|
*/
|
|
31
33
|
export declare function validateConfigUpdate(update: DeepPartial<FlowrConfig>, formatter?: OutputFormatter): string | undefined;
|
|
32
|
-
declare function configQueryLineParser(output: ReplOutput, line: readonly string[],
|
|
34
|
+
declare function configQueryLineParser(output: ReplOutput, line: readonly string[], _config: FlowrConfig): ParsedQueryLine<'config'>;
|
|
33
35
|
export declare const ConfigQueryDefinition: {
|
|
34
36
|
readonly title: "Config Query";
|
|
35
|
-
readonly syntax: "@config [<path> | <glob>] | @config +<path>=<value>";
|
|
37
|
+
readonly syntax: "@config [<path> | <glob>] | @config +<path>=<value> | @config +reset";
|
|
36
38
|
readonly executor: typeof executeConfigQuery;
|
|
37
39
|
readonly asciiSummarizer: (formatter: OutputFormatter, _analyzer: unknown, queryResults: BaseQueryResult, result: string[], queries: readonly Query[]) => true;
|
|
38
40
|
readonly completer: typeof configReplCompleter;
|
|
@@ -14,7 +14,7 @@ const json_1 = require("../../../util/json");
|
|
|
14
14
|
const core_1 = require("../../../cli/repl/core");
|
|
15
15
|
const schema_1 = require("../../../util/schema");
|
|
16
16
|
const strings_1 = require("../../../util/text/strings");
|
|
17
|
-
function configReplCompleter(partialLine, startingNewArg,
|
|
17
|
+
function configReplCompleter(partialLine, startingNewArg, _config) {
|
|
18
18
|
// the config query is a single token
|
|
19
19
|
if (partialLine.length > 1 || (partialLine.length === 1 && startingNewArg)) {
|
|
20
20
|
return { completions: [] };
|
|
@@ -43,21 +43,21 @@ function configReplCompleter(partialLine, startingNewArg, config) {
|
|
|
43
43
|
// a glob reads several keys, so expand it to the paths it matches (the trailing segment completes as a prefix)
|
|
44
44
|
if (!update && raw.includes('*')) {
|
|
45
45
|
const matches = configGlobMatcher(raw.endsWith('*') ? raw : `${raw}*`);
|
|
46
|
-
const found =
|
|
46
|
+
const found = sortConfigPaths(configPaths().filter(matches)).map(p => p.join('.'));
|
|
47
47
|
return { completions: found, labels: new Map(found.map(p => [p, (0, core_1.describeCompletion)(p, configSchemaInfo(p.split('.')).type ?? '')])), preFiltered: true };
|
|
48
48
|
}
|
|
49
49
|
const path = raw.split('.').filter(p => p.length > 0);
|
|
50
50
|
const fullPath = path.slice();
|
|
51
51
|
const lastPath = token.endsWith('.') ? '' : path.pop() ?? '';
|
|
52
|
-
/* the schema knows every option, a value only those that are set */
|
|
53
|
-
const options = configSchemaKeys(path);
|
|
52
|
+
/* the schema knows every option, a value only those that are set; `reset` (top level, update only) is not a schema key but a fixed action */
|
|
53
|
+
const options = update && path.length === 0 ? [...configSchemaKeys(path), 'reset'] : configSchemaKeys(path);
|
|
54
54
|
const atLeaf = lastPath.length > 0 && options.includes(lastPath) && configSchemaInfo([...path, lastPath]).type !== 'object';
|
|
55
55
|
if (!atLeaf) {
|
|
56
56
|
const offered = (0, strings_1.matchByPrefixOrSubsequence)(options, lastPath);
|
|
57
57
|
const have = offered.map(k => `${sigil}${[...path, k].join('.')}`);
|
|
58
58
|
if (have.length > 0) {
|
|
59
59
|
// label starts with the full completion (incl. sigil) so readline keeps the sigil on common-prefix insertion
|
|
60
|
-
return { completions: [...lead, ...have], labels: new Map([...leadLabels, ...have.map((c, i) => [c, (0, core_1.describeCompletion)(c, configSchemaInfo([...path, offered[i]]).type ?? '')])]) };
|
|
60
|
+
return { completions: [...lead, ...have], labels: new Map([...leadLabels, ...have.map((c, i) => [c, offered[i] === 'reset' && path.length === 0 ? (0, core_1.describeCompletion)(c, 'discard runtime config updates') : (0, core_1.describeCompletion)(c, configSchemaInfo([...path, offered[i]]).type ?? '')])]) };
|
|
61
61
|
}
|
|
62
62
|
else if (lastPath.length > 0 && configSchemaKeys(fullPath).length > 0) {
|
|
63
63
|
return { completions: [`${sigil}${fullPath.join('.')}.`] };
|
|
@@ -79,16 +79,14 @@ function configReplCompleter(partialLine, startingNewArg, config) {
|
|
|
79
79
|
}
|
|
80
80
|
return { completions: [`${leaf}${update ? '=' : ''}`] };
|
|
81
81
|
}
|
|
82
|
-
/** every `.`-separated path
|
|
83
|
-
function
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
}
|
|
82
|
+
/** every `.`-separated path the config schema allows, intermediate objects included, for {@link configGlobMatcher} */
|
|
83
|
+
function configPaths() {
|
|
84
|
+
configSchemaDescription ??= config_1.FlowrConfig.Schema.describe();
|
|
85
|
+
return (0, schema_1.descriptionPaths)(configSchemaDescription);
|
|
86
|
+
}
|
|
87
|
+
/** shallower (fewer path segments) first, alphabetical among equally deep paths */
|
|
88
|
+
function sortConfigPaths(paths) {
|
|
89
|
+
return [...paths].sort((a, b) => a.length - b.length || a.join('.').localeCompare(b.join('.')));
|
|
92
90
|
}
|
|
93
91
|
/** matches a config path against a glob, `*` covering one segment and `**` any number (`**.enabled`, `solver.*`) */
|
|
94
92
|
function configGlobMatcher(pattern) {
|
|
@@ -170,8 +168,11 @@ function validateConfigUpdate(update, formatter = ansi_1.voidFormatter) {
|
|
|
170
168
|
}
|
|
171
169
|
return undefined;
|
|
172
170
|
}
|
|
173
|
-
function configQueryLineParser(output, line,
|
|
171
|
+
function configQueryLineParser(output, line, _config) {
|
|
174
172
|
const first = line[0] ?? '';
|
|
173
|
+
if (first === '+reset') {
|
|
174
|
+
return { query: [{ type: 'config', reset: true }] };
|
|
175
|
+
}
|
|
175
176
|
if (first.startsWith('+')) {
|
|
176
177
|
const [pathPart, ...valueParts] = first.slice(1).split('=');
|
|
177
178
|
// build the update object
|
|
@@ -185,7 +186,12 @@ function configQueryLineParser(output, line, config) {
|
|
|
185
186
|
value = JSON.parse(raw); // numbers, booleans, arrays, ...
|
|
186
187
|
}
|
|
187
188
|
catch {
|
|
188
|
-
|
|
189
|
+
try {
|
|
190
|
+
value = JSON.parse(raw.replace(/'([^']*)'/g, (_, s) => JSON.stringify(s))); // allow 'single' quotes too
|
|
191
|
+
}
|
|
192
|
+
catch {
|
|
193
|
+
value = raw; // fall back to a plain string
|
|
194
|
+
}
|
|
189
195
|
}
|
|
190
196
|
const update = path.reduceRight((acc, key) => ({ [key]: acc }), value);
|
|
191
197
|
const err = validateConfigUpdate(update, output.formatter);
|
|
@@ -199,7 +205,7 @@ function configQueryLineParser(output, line, config) {
|
|
|
199
205
|
if (first.includes('*')) {
|
|
200
206
|
// a glob reads several keys at once (inspection only, setting stays a single explicit key)
|
|
201
207
|
const matches = configGlobMatcher(first);
|
|
202
|
-
const found =
|
|
208
|
+
const found = sortConfigPaths(configPaths().filter(matches));
|
|
203
209
|
return found.length === 0
|
|
204
210
|
? configError(output, `No config key matches ${(0, ansi_1.bold)(first, output.formatter)}`)
|
|
205
211
|
: { query: found.map(p => ({ type: 'config', inspect: p })) };
|
|
@@ -285,14 +291,17 @@ function inspectedChildren(value, path, formatter) {
|
|
|
285
291
|
}
|
|
286
292
|
exports.ConfigQueryDefinition = {
|
|
287
293
|
title: 'Config Query',
|
|
288
|
-
syntax: '@config [<path> | <glob>] | @config +<path>=<value>',
|
|
294
|
+
syntax: '@config [<path> | <glob>] | @config +<path>=<value> | @config +reset',
|
|
289
295
|
executor: config_query_executor_1.executeConfigQuery,
|
|
290
296
|
asciiSummarizer: (formatter, _analyzer, queryResults, result, queries) => {
|
|
291
297
|
const out = queryResults;
|
|
292
298
|
result.push(`Query: ${(0, ansi_1.bold)('config', formatter)} (${(0, time_1.printAsMs)(out['.meta'].timing, 0)})`);
|
|
293
299
|
const configQueries = queries.filter(q => q.type === 'config');
|
|
294
300
|
const inspects = configQueries.filter(q => q.inspect).map(q => q.inspect);
|
|
295
|
-
if (configQueries.some(q => q.
|
|
301
|
+
if (configQueries.some(q => q.reset)) {
|
|
302
|
+
result.push(' ╰ Configuration reset to the analyzer\'s base config');
|
|
303
|
+
}
|
|
304
|
+
else if (configQueries.some(q => q.update)) {
|
|
296
305
|
const updatedKeys = configQueries.flatMap(q => q.update ? collectKeysFromUpdate(q.update) : []);
|
|
297
306
|
result.push(' ╰ Updated configuration:');
|
|
298
307
|
for (const key of updatedKeys) {
|
|
@@ -333,7 +342,8 @@ exports.ConfigQueryDefinition = {
|
|
|
333
342
|
schema: joi_1.default.object({
|
|
334
343
|
type: joi_1.default.string().valid('config').required().description('The type of the query.'),
|
|
335
344
|
update: joi_1.default.object().optional().description('An optional partial configuration to update the current configuration with before returning it. Only the provided fields will be updated, all other fields will remain unchanged.'),
|
|
336
|
-
inspect: joi_1.default.array().items(joi_1.default.string()).optional().description('An optional `.`-separated path (as a string array) to read a single configuration value instead of returning the whole configuration.')
|
|
345
|
+
inspect: joi_1.default.array().items(joi_1.default.string()).optional().description('An optional `.`-separated path (as a string array) to read a single configuration value instead of returning the whole configuration.'),
|
|
346
|
+
reset: joi_1.default.boolean().optional().description('If true, discard every prior update and revert to the config the analyzer was created with, before returning it.')
|
|
337
347
|
}).description('The config query retrieves the current configuration of the flowR instance and optionally also updates it.'),
|
|
338
348
|
flattenInvolvedNodes: () => []
|
|
339
349
|
};
|
|
@@ -6,6 +6,13 @@ const r_version_1 = require("../../../util/r-version");
|
|
|
6
6
|
const objects_1 = require("../../../util/objects");
|
|
7
7
|
const reader_1 = require("../../../project/sigdb/reader");
|
|
8
8
|
const dependency_version_space_1 = require("../../../project/dependency-version-space");
|
|
9
|
+
/** the sources `query` disables: `clean` is sugar for disabling `declared`+`transitive`, `disabled` adds any others by name */
|
|
10
|
+
function disabledSources(query) {
|
|
11
|
+
if (!query.clean && !query.disabled?.length) {
|
|
12
|
+
return dependency_version_space_1.NoDisabledSources;
|
|
13
|
+
}
|
|
14
|
+
return new Set([...(query.clean ? ['declared', 'transitive'] : []), ...(query.disabled ?? [])]);
|
|
15
|
+
}
|
|
9
16
|
/** collects and deduplicates provenance-carrying constraints */
|
|
10
17
|
class EvidenceCollector {
|
|
11
18
|
seen = new Set();
|
|
@@ -30,6 +37,8 @@ function mergeQueries(queries) {
|
|
|
30
37
|
let maxCandidates;
|
|
31
38
|
let maxIterations;
|
|
32
39
|
let explode;
|
|
40
|
+
const disabled = new Set();
|
|
41
|
+
let anyClean = false;
|
|
33
42
|
for (const q of queries) {
|
|
34
43
|
if (q.packages) {
|
|
35
44
|
for (const p of q.packages) {
|
|
@@ -54,6 +63,10 @@ function mergeQueries(queries) {
|
|
|
54
63
|
maxIterations = maxIterations === undefined ? q.maxIterations : Math.max(maxIterations, q.maxIterations);
|
|
55
64
|
}
|
|
56
65
|
explode ??= q.explode;
|
|
66
|
+
anyClean ||= q.clean === true;
|
|
67
|
+
for (const s of q.disabled ?? []) {
|
|
68
|
+
disabled.add(s);
|
|
69
|
+
}
|
|
57
70
|
}
|
|
58
71
|
// keep the tightest date, or any malformed date to report it
|
|
59
72
|
const date = earliestDate ?? anyDate;
|
|
@@ -63,7 +76,9 @@ function mergeQueries(queries) {
|
|
|
63
76
|
...(date ? { date } : {}),
|
|
64
77
|
...(maxCandidates !== undefined ? { maxCandidates } : {}),
|
|
65
78
|
...(maxIterations !== undefined ? { maxIterations } : {}),
|
|
66
|
-
...(explode ? { explode } : {})
|
|
79
|
+
...(explode ? { explode } : {}),
|
|
80
|
+
...(anyClean ? { clean: true } : {}),
|
|
81
|
+
...(disabled.size > 0 ? { disabled: [...disabled] } : {})
|
|
67
82
|
};
|
|
68
83
|
}
|
|
69
84
|
/** format version range string from survivors and declared constraints, honest about gaps */
|
|
@@ -150,12 +165,13 @@ async function executeGuessDepVersionsQuery({ analyzer }, queries) {
|
|
|
150
165
|
}
|
|
151
166
|
return entry;
|
|
152
167
|
};
|
|
168
|
+
const disabled = disabledSources(query);
|
|
153
169
|
// the guessed lower bound of every target under a set of transitive constraints (drives the mutual-constraint refinement)
|
|
154
170
|
const guessLowerBounds = (trans) => {
|
|
155
171
|
const out = new Map();
|
|
156
172
|
for (const name of sorted) {
|
|
157
173
|
const { key, src } = sourceFor(name);
|
|
158
|
-
const s = (0, dependency_version_space_1.survivingEntries)(name, src, deps, usage.get(name), trans.get(name) ?? [], cutoff, rVersion, undefined,
|
|
174
|
+
const s = (0, dependency_version_space_1.survivingEntries)(name, src, deps, usage.get(name), trans.get(name) ?? [], cutoff, rVersion, undefined, disabled, key);
|
|
159
175
|
if (s.survivors.length > 0) {
|
|
160
176
|
out.set(name, s.survivors[0].ver);
|
|
161
177
|
}
|
|
@@ -164,7 +180,7 @@ async function executeGuessDepVersionsQuery({ analyzer }, queries) {
|
|
|
164
180
|
};
|
|
165
181
|
const maxIterations = query.maxIterations ?? dependency_version_space_1.DefaultFixpointIterations;
|
|
166
182
|
let transitive = (0, dependency_version_space_1.collectTransitiveConstraints)(deps, sources);
|
|
167
|
-
if (!
|
|
183
|
+
if (!disabled.has('transitive')) {
|
|
168
184
|
let prev = '';
|
|
169
185
|
(0, dependency_version_space_1.iterateToFixpoint)(maxIterations, () => {
|
|
170
186
|
const pass = guessLowerBounds(transitive);
|
|
@@ -182,11 +198,11 @@ async function executeGuessDepVersionsQuery({ analyzer }, queries) {
|
|
|
182
198
|
const guessedAll = sorted.map(name => {
|
|
183
199
|
const { key, src } = sourceFor(name);
|
|
184
200
|
const evidence = new EvidenceCollector();
|
|
185
|
-
const surviving = (0, dependency_version_space_1.survivingEntries)(name, src, deps, usage.get(name), transitive.get(name) ?? [], cutoff, rVersion, evidence.add,
|
|
201
|
+
const surviving = (0, dependency_version_space_1.survivingEntries)(name, src, deps, usage.get(name), transitive.get(name) ?? [], cutoff, rVersion, evidence.add, disabled, key);
|
|
186
202
|
return { name, src, key, evidence, surviving };
|
|
187
203
|
});
|
|
188
204
|
const arcEntries = guessedAll.map(g => ({ name: g.name, src: g.src, key: g.key, survivors: g.surviving.survivors }));
|
|
189
|
-
const blockers = query.clean ? new Map() : (0, dependency_version_space_1.enforceArcConsistency)(arcEntries, maxIterations);
|
|
205
|
+
const blockers = query.clean || disabled.has('indirect') ? new Map() : (0, dependency_version_space_1.enforceArcConsistency)(arcEntries, maxIterations);
|
|
190
206
|
guessedAll.forEach((g, i) => {
|
|
191
207
|
g.surviving = { ...g.surviving, survivors: arcEntries[i].survivors };
|
|
192
208
|
const max = g.surviving.survivors.at(-1)?.ver;
|
|
@@ -28,6 +28,8 @@ export interface GuessDepVersionsQuery extends BaseQueryFormat {
|
|
|
28
28
|
readonly maxIterations?: number;
|
|
29
29
|
/** ignore the project's declared constraints (`DESCRIPTION` ranges, lockfile pins, transitive requirements); guess purely from code usage and the date/R bounds */
|
|
30
30
|
readonly clean?: boolean;
|
|
31
|
+
/** exclude these evidence sources from consideration entirely (repl: `--disabled` followed by their one-letter codes, e.g. `--disabled ds` for declared+signature) */
|
|
32
|
+
readonly disabled?: readonly ConstraintSource[];
|
|
31
33
|
/** also explode the guessed space into concrete per-dependency version assignments (see {@link GuessExplodeOptions}) */
|
|
32
34
|
readonly explode?: GuessExplodeOptions;
|
|
33
35
|
}
|
|
@@ -105,14 +107,14 @@ export interface GuessDepVersionsQueryResult extends BaseQueryResult {
|
|
|
105
107
|
/** a note, e.g. when the signature database is unavailable */
|
|
106
108
|
readonly message?: string;
|
|
107
109
|
}
|
|
108
|
-
/** parse a repl line: `[(clean[:<=YYYY])] [pkg ...] [--date YYYY.MM.DD] [--max N] [--iterations N] [--explode [--oldest] [--limit N] [--prefer pkg=ver ...]]` */
|
|
110
|
+
/** parse a repl line: `[(clean[:<=YYYY])] [pkg ...] [--date YYYY.MM.DD] [--max N] [--iterations N] [--disabled <letters>] [--explode [--oldest] [--limit N] [--prefer pkg=ver ...]]` */
|
|
109
111
|
declare function guessDepVersionsLineParser(_output: ReplOutput, line: readonly string[], _config: FlowrConfig): ParsedQueryLine<'guess-dep-versions'>;
|
|
110
112
|
export declare const GuessDepVersionsQueryDefinition: {
|
|
111
113
|
readonly title: "Guess Dependency Versions Query";
|
|
112
114
|
readonly executor: typeof executeGuessDepVersionsQuery;
|
|
113
115
|
readonly asciiSummarizer: (formatter: import("../../../util/text/ansi").OutputFormatter, _analyzer: import("../../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider<import("../../../r-bridge/parser").KnownParser>, queryResults: BaseQueryResult, result: string[], _query: readonly import("../../query").Query[]) => true;
|
|
114
116
|
readonly fromLine: typeof guessDepVersionsLineParser;
|
|
115
|
-
readonly syntax: "@guess-dep-versions [<pkg> ...] [(clean | <=YYYY.MM.DD)] [--date YYYY.MM.DD] [--max <n>] [--iterations <n>] [--explode [--oldest] [--limit <n>] [--prefer <pkg>=<ver>]] <code | file://path>";
|
|
117
|
+
readonly syntax: "@guess-dep-versions [<pkg> ...] [(clean | <=YYYY.MM.DD)] [--date YYYY.MM.DD] [--max <n>] [--iterations <n>] [--disabled <letters>] [--explode [--oldest] [--limit <n>] [--prefer <pkg>=<ver>]] <code | file://path>";
|
|
116
118
|
readonly schema: Joi.ObjectSchema<any>;
|
|
117
119
|
readonly flattenInvolvedNodes: () => NodeId[];
|
|
118
120
|
};
|
|
@@ -15,7 +15,7 @@ const config_1 = require("../../../config");
|
|
|
15
15
|
const guess_dep_versions_query_executor_1 = require("./guess-dep-versions-query-executor");
|
|
16
16
|
/** the default cap on how many surviving candidate versions are listed per dependency */
|
|
17
17
|
exports.DefaultCandidateCap = 16;
|
|
18
|
-
/** parse a repl line: `[(clean[:<=YYYY])] [pkg ...] [--date YYYY.MM.DD] [--max N] [--iterations N] [--explode [--oldest] [--limit N] [--prefer pkg=ver ...]]` */
|
|
18
|
+
/** parse a repl line: `[(clean[:<=YYYY])] [pkg ...] [--date YYYY.MM.DD] [--max N] [--iterations N] [--disabled <letters>] [--explode [--oldest] [--limit N] [--prefer pkg=ver ...]]` */
|
|
19
19
|
function guessDepVersionsLineParser(_output, line, _config) {
|
|
20
20
|
const packages = [];
|
|
21
21
|
const codeParts = [];
|
|
@@ -27,6 +27,7 @@ function guessDepVersionsLineParser(_output, line, _config) {
|
|
|
27
27
|
let order;
|
|
28
28
|
let limit;
|
|
29
29
|
const prefer = {};
|
|
30
|
+
const disabled = new Set();
|
|
30
31
|
// an optional parenthesised clause `(clean)`, `(<=2025)`, or `(clean:<=2025)`: `clean` drops declared constraints, a (`<=`-prefixed) date caps the window
|
|
31
32
|
const tokens = [...line];
|
|
32
33
|
const open = tokens.findIndex(t => t.startsWith('('));
|
|
@@ -78,6 +79,14 @@ function guessDepVersionsLineParser(_output, line, _config) {
|
|
|
78
79
|
else if (tok === '--only') {
|
|
79
80
|
packages.push(...(tokens[++i] ?? '').split(',').map(s => s.trim()).filter(s => s.length > 0));
|
|
80
81
|
}
|
|
82
|
+
else if (tok === '--disabled') {
|
|
83
|
+
for (const ch of tokens[++i] ?? '') {
|
|
84
|
+
const source = letterToSource[ch];
|
|
85
|
+
if (source) {
|
|
86
|
+
disabled.add(source);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
81
90
|
else if (!tok.startsWith('--')) {
|
|
82
91
|
// every bare token is the code to analyse (a `file://`/`watch://` target, a bare path -- auto-prepended to
|
|
83
92
|
// `file://` by the repl -- or inline R code); package filters are the explicit `--only` flag, so nothing is guessed
|
|
@@ -100,6 +109,7 @@ function guessDepVersionsLineParser(_output, line, _config) {
|
|
|
100
109
|
...(maxCandidates !== undefined && !Number.isNaN(maxCandidates) ? { maxCandidates } : {}),
|
|
101
110
|
...(maxIterations !== undefined && !Number.isNaN(maxIterations) ? { maxIterations } : {}),
|
|
102
111
|
...(clean ? { clean } : {}),
|
|
112
|
+
...(disabled.size > 0 ? { disabled: [...disabled] } : {}),
|
|
103
113
|
...explodeOpts
|
|
104
114
|
}]
|
|
105
115
|
};
|
|
@@ -133,6 +143,8 @@ const evidenceLetter = {
|
|
|
133
143
|
available: '#',
|
|
134
144
|
indirect: 'i'
|
|
135
145
|
};
|
|
146
|
+
/** inverse of {@link evidenceLetter}, decoding a `--disabled` flag's letters back to sources */
|
|
147
|
+
const letterToSource = Object.fromEntries(Object.entries(evidenceLetter).map(([source, letter]) => [letter, source]));
|
|
136
148
|
/** the tightest bound among a function's signature constraints for the given operator: highest `>=` or lowest `<=` */
|
|
137
149
|
function tightestBound(evs, op) {
|
|
138
150
|
let best, bestVer;
|
|
@@ -312,7 +324,7 @@ exports.GuessDepVersionsQueryDefinition = {
|
|
|
312
324
|
return true;
|
|
313
325
|
},
|
|
314
326
|
fromLine: guessDepVersionsLineParser,
|
|
315
|
-
syntax: '@guess-dep-versions [<pkg> ...] [(clean | <=YYYY.MM.DD)] [--date YYYY.MM.DD] [--max <n>] [--iterations <n>] [--explode [--oldest] [--limit <n>] [--prefer <pkg>=<ver>]] <code | file://path>',
|
|
327
|
+
syntax: '@guess-dep-versions [<pkg> ...] [(clean | <=YYYY.MM.DD)] [--date YYYY.MM.DD] [--max <n>] [--iterations <n>] [--disabled <letters>] [--explode [--oldest] [--limit <n>] [--prefer <pkg>=<ver>]] <code | file://path>',
|
|
316
328
|
schema: joi_1.default.object({
|
|
317
329
|
type: joi_1.default.string().valid('guess-dep-versions').required().description('The type of the query.'),
|
|
318
330
|
packages: joi_1.default.array().items(joi_1.default.string()).optional().description('Restrict the guess to these packages; omit to guess for every declared and used dependency.'),
|
|
@@ -320,6 +332,8 @@ exports.GuessDepVersionsQueryDefinition = {
|
|
|
320
332
|
maxCandidates: joi_1.default.number().integer().min(0).optional().description('Cap the number of candidate versions listed per dependency.'),
|
|
321
333
|
maxIterations: joi_1.default.number().integer().min(0).optional().description('Bound both fixpoint loops (mutual transitive refinement and arc consistency).'),
|
|
322
334
|
clean: joi_1.default.boolean().optional().description('Ignore the project declared constraints (DESCRIPTION/lockfile/transitive); guess purely from code usage and the date/R bounds.'),
|
|
335
|
+
disabled: joi_1.default.array().items(joi_1.default.string().valid('declared', 'transitive', 'signature', 'date', 'base-r', 'available', 'indirect')).optional()
|
|
336
|
+
.description('Exclude these evidence sources from consideration entirely (repl: --disabled followed by their one-letter codes, e.g. --disabled ds for declared+signature).'),
|
|
323
337
|
explode: joi_1.default.object({
|
|
324
338
|
order: joi_1.default.string().valid('newest', 'oldest').optional().description('Iterate each dependency newest-first (default) or oldest-first.'),
|
|
325
339
|
prefer: joi_1.default.object().pattern(joi_1.default.string(), joi_1.default.string()).optional().description('A version to prefer per dependency when it survives the constraints.'),
|
package/queries/query.d.ts
CHANGED
|
@@ -89,11 +89,11 @@ export declare const SupportedQueries: {
|
|
|
89
89
|
};
|
|
90
90
|
readonly config: {
|
|
91
91
|
readonly title: "Config Query";
|
|
92
|
-
readonly syntax: "@config [<path> | <glob>] | @config +<path>=<value>";
|
|
92
|
+
readonly syntax: "@config [<path> | <glob>] | @config +<path>=<value> | @config +reset";
|
|
93
93
|
readonly executor: typeof import("./catalog/config-query/config-query-executor").executeConfigQuery;
|
|
94
94
|
readonly asciiSummarizer: (formatter: OutputFormatter, _analyzer: unknown, queryResults: BaseQueryResult, result: string[], queries: readonly Query[]) => true;
|
|
95
|
-
readonly completer: (partialLine: readonly string[], startingNewArg: boolean,
|
|
96
|
-
readonly fromLine: (output: ReplOutput, line: readonly string[],
|
|
95
|
+
readonly completer: (partialLine: readonly string[], startingNewArg: boolean, _config: FlowrConfig) => CommandCompletions;
|
|
96
|
+
readonly fromLine: (output: ReplOutput, line: readonly string[], _config: FlowrConfig) => ParsedQueryLine<"config">;
|
|
97
97
|
readonly schema: Joi.ObjectSchema<any>;
|
|
98
98
|
readonly flattenInvolvedNodes: () => never[];
|
|
99
99
|
};
|
|
@@ -332,7 +332,7 @@ export declare const SupportedQueries: {
|
|
|
332
332
|
readonly executor: typeof import("./catalog/guess-dep-versions-query/guess-dep-versions-query-executor").executeGuessDepVersionsQuery;
|
|
333
333
|
readonly asciiSummarizer: (formatter: OutputFormatter, _analyzer: ReadonlyFlowrAnalysisProvider<import("../r-bridge/parser").KnownParser>, queryResults: BaseQueryResult, result: string[], _query: readonly Query[]) => true;
|
|
334
334
|
readonly fromLine: (_output: ReplOutput, line: readonly string[], _config: FlowrConfig) => ParsedQueryLine<"guess-dep-versions">;
|
|
335
|
-
readonly syntax: "@guess-dep-versions [<pkg> ...] [(clean | <=YYYY.MM.DD)] [--date YYYY.MM.DD] [--max <n>] [--iterations <n>] [--explode [--oldest] [--limit <n>] [--prefer <pkg>=<ver>]] <code | file://path>";
|
|
335
|
+
readonly syntax: "@guess-dep-versions [<pkg> ...] [(clean | <=YYYY.MM.DD)] [--date YYYY.MM.DD] [--max <n>] [--iterations <n>] [--disabled <letters>] [--explode [--oldest] [--limit <n>] [--prefer <pkg>=<ver>]] <code | file://path>";
|
|
336
336
|
readonly schema: Joi.ObjectSchema<any>;
|
|
337
337
|
readonly flattenInvolvedNodes: () => NodeId[];
|
|
338
338
|
};
|
package/util/schema.d.ts
CHANGED
|
@@ -30,6 +30,8 @@ export declare function firstUnknownSchemaSegment(description: Joi.Description,
|
|
|
30
30
|
* In contrast to the keys of a value, this covers the optional ones that are unset as well.
|
|
31
31
|
*/
|
|
32
32
|
export declare function descriptionPathKeys(description: Joi.Description, path: readonly string[]): string[];
|
|
33
|
+
/** every settable path in a schema description, intermediate objects included */
|
|
34
|
+
export declare function descriptionPaths(description: Joi.Description, path?: readonly string[]): string[][];
|
|
33
35
|
/**
|
|
34
36
|
* Describes a Joi schema in a human-readable way.
|
|
35
37
|
*/
|
package/util/schema.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.descriptionPathInfo = descriptionPathInfo;
|
|
|
4
4
|
exports.schemaPathInfo = schemaPathInfo;
|
|
5
5
|
exports.firstUnknownSchemaSegment = firstUnknownSchemaSegment;
|
|
6
6
|
exports.descriptionPathKeys = descriptionPathKeys;
|
|
7
|
+
exports.descriptionPaths = descriptionPaths;
|
|
7
8
|
exports.describeSchema = describeSchema;
|
|
8
9
|
exports.genericDescription = genericDescription;
|
|
9
10
|
exports.headerLine = headerLine;
|
|
@@ -112,6 +113,18 @@ function descriptionPathKeys(description, path) {
|
|
|
112
113
|
const valids = patternObject(node)?.keyValids?.map(v => String(v)) ?? [];
|
|
113
114
|
return [...keys, ...valids.filter(v => !keys.includes(v))];
|
|
114
115
|
}
|
|
116
|
+
/** every settable path in a schema description, intermediate objects included */
|
|
117
|
+
function descriptionPaths(description, path = []) {
|
|
118
|
+
const result = [];
|
|
119
|
+
for (const key of descriptionPathKeys(description, path)) {
|
|
120
|
+
const childPath = [...path, key];
|
|
121
|
+
result.push(childPath);
|
|
122
|
+
if (descriptionPathInfo(description, childPath).type === 'object') {
|
|
123
|
+
result.push(...descriptionPaths(description, childPath));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return result;
|
|
127
|
+
}
|
|
115
128
|
/**
|
|
116
129
|
* Describes a Joi schema in a human-readable way.
|
|
117
130
|
*/
|
package/util/version.js
CHANGED
|
@@ -42,7 +42,7 @@ const assert_1 = require("./assert");
|
|
|
42
42
|
const sigdb_download_1 = require("../project/sigdb/sigdb-download");
|
|
43
43
|
const doc_files_1 = require("../documentation/doc-util/doc-files");
|
|
44
44
|
// this is automatically replaced with the current version by release-it
|
|
45
|
-
const version = '2.13.
|
|
45
|
+
const version = '2.13.1';
|
|
46
46
|
// this is automatically replaced with the release date by release-it (regex-bumper, see package.json)
|
|
47
47
|
const versionDate = '2026-07-15T07:13:44Z';
|
|
48
48
|
/**
|