@eagleoutice/flowr 2.13.1 → 2.13.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/README.md +46 -44
- package/abstract-interpretation/data-frame/mappers/access-mapper.js +1 -0
- package/abstract-interpretation/data-frame/mappers/function-mapper.d.ts +1 -1
- package/abstract-interpretation/data-frame/mappers/function-mapper.js +3 -0
- package/abstract-interpretation/domains/state-domain-like.d.ts +1 -1
- package/cli/flowr.js +21 -5
- package/cli/repl/commands/repl-commands.js +11 -9
- package/cli/repl/commands/repl-query.js +1 -1
- package/cli/repl/commands/repl-signature.js +8 -1
- package/cli/repl/core.js +13 -10
- package/cli/repl/print-version.js +1 -1
- package/cli/repl/server/connection.d.ts +1 -1
- package/cli/repl/server/net.js +15 -0
- package/config.d.ts +37 -0
- package/config.js +63 -3
- package/control-flow/control-flow-graph.js +2 -1
- package/control-flow/semantic-cfg-guided-visitor.d.ts +1 -1
- package/core/steps/all/core/11-normalize-tree-sitter.d.ts +1 -1
- package/data/sigdb/sigdb.remote.json +1 -1
- package/dataflow/environments/append.d.ts +1 -1
- package/dataflow/environments/clone.d.ts +1 -1
- package/dataflow/environments/environment.d.ts +28 -4
- package/dataflow/environments/environment.js +66 -11
- package/dataflow/environments/identifier.d.ts +9 -8
- package/dataflow/environments/identifier.js +21 -13
- package/dataflow/environments/overwrite.d.ts +1 -1
- package/dataflow/eval/resolve/alias-tracking.d.ts +1 -1
- package/dataflow/eval/resolve/resolve-working-directory.d.ts +29 -0
- package/dataflow/eval/resolve/resolve-working-directory.js +168 -0
- package/dataflow/extractor.js +2 -1
- package/dataflow/graph/dataflowgraph-builder.d.ts +1 -1
- package/dataflow/graph/df-helper.d.ts +3 -2
- package/dataflow/graph/df-helper.js +11 -15
- package/dataflow/graph/diff-dataflow-graph.js +1 -1
- package/dataflow/graph/graph-helper.js +2 -6
- package/dataflow/graph/graph.d.ts +24 -0
- package/dataflow/graph/graph.js +25 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +7 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +51 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +5 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +15 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-list.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-dispatch.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +7 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +9 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-vector.d.ts +1 -1
- package/documentation/doc-readme.js +14 -12
- package/documentation/doc-util/doc-normalized-ast.d.ts +1 -1
- package/documentation/wiki-dataflow-graph.js +4 -24
- package/documentation/wiki-linter.js +1 -0
- package/documentation/wiki-mk/doc-context.d.ts +10 -0
- package/documentation/wiki-mk/doc-context.js +3 -0
- package/documentation/wiki-query.js +47 -0
- package/documentation/wiki-signature-database.js +18 -7
- package/linter/linter-rules.d.ts +24 -2
- package/linter/linter-rules.js +3 -1
- package/linter/rules/absolute-path.d.ts +4 -4
- package/linter/rules/absolute-path.js +7 -5
- package/linter/rules/dataframe-access-validation.d.ts +1 -1
- package/linter/rules/file-path-validity.d.ts +1 -1
- package/linter/rules/file-path-validity.js +48 -8
- package/linter/rules/function-finder-util.d.ts +2 -1
- package/linter/rules/syntactically-valid.d.ts +58 -0
- package/linter/rules/syntactically-valid.js +203 -0
- package/linter/rules/undefined-symbol-util.js +3 -1
- package/linter/rules/undefined-symbol.js +6 -6
- package/package.json +25 -12
- package/project/context/classify-project-kind.d.ts +40 -0
- package/project/context/classify-project-kind.js +76 -0
- package/project/context/flowr-analyzer-context.d.ts +4 -4
- package/project/context/flowr-analyzer-context.js +3 -3
- package/project/context/flowr-analyzer-dependencies-context.d.ts +34 -9
- package/project/context/flowr-analyzer-dependencies-context.js +30 -3
- package/project/context/flowr-analyzer-files-context.d.ts +10 -8
- package/project/context/flowr-analyzer-files-context.js +26 -67
- package/project/context/flowr-analyzer-meta-context.d.ts +1 -0
- package/project/context/flowr-file.d.ts +5 -0
- package/project/context/flowr-file.js +5 -0
- package/project/dependency-version-space.d.ts +118 -26
- package/project/dependency-version-space.js +343 -87
- package/project/plugins/file-plugins/files/flowr-description-file.d.ts +4 -0
- package/project/plugins/file-plugins/files/flowr-description-file.js +8 -1
- package/project/plugins/file-plugins/files/flowr-rda-file.js +27 -25
- package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.d.ts +12 -4
- package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.js +25 -10
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-sweave-file-plugin.d.ts +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-description-file-plugin.js +2 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +4 -4
- package/project/plugins/package-version-plugins/package.d.ts +27 -10
- package/project/plugins/package-version-plugins/package.js +50 -25
- package/project/plugins/plugin-registry.d.ts +2 -1
- package/project/plugins/plugin-registry.js +4 -1
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.d.ts +57 -2
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +150 -28
- package/project/sigdb/decompress.d.ts +1 -1
- package/project/sigdb/decompress.js +4 -1
- package/project/sigdb/manifest.js +60 -26
- package/project/sigdb/reader.d.ts +26 -16
- package/project/sigdb/reader.js +52 -21
- package/project/sigdb/sigdb-download.d.ts +6 -7
- package/project/sigdb/sigdb-download.js +30 -9
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +1 -1
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +2 -12
- package/queries/catalog/dependencies-query/dependencies-query-format.js +2 -108
- package/queries/catalog/does-call-query/does-call-query-format.d.ts +1 -1
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +39 -77
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +12 -0
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +54 -24
- package/queries/catalog/input-sources-query/input-source-functions.d.ts +13 -0
- package/queries/catalog/input-sources-query/input-source-functions.js +96 -1
- package/queries/catalog/input-sources-query/input-sources-query-executor.js +40 -4
- package/queries/catalog/input-sources-query/input-sources-query-format.js +21 -3
- package/queries/catalog/input-sources-query/input-types.d.ts +58 -0
- package/queries/catalog/input-sources-query/input-types.js +64 -0
- package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +62 -52
- package/queries/catalog/input-sources-query/simple-input-classifier.js +334 -101
- package/queries/catalog/linter-query/linter-query-format.js +9 -2
- package/queries/catalog/project-query/project-query-executor.js +1 -1
- package/queries/catalog/signature-query/signature-query-executor.d.ts +7 -1
- package/queries/catalog/signature-query/signature-query-executor.js +115 -39
- package/queries/catalog/signature-query/signature-query-format.d.ts +5 -1
- package/queries/catalog/signature-query/signature-query-format.js +1 -1
- package/queries/catalog/signature-query/signature-query-render.js +12 -7
- package/queries/query.js +9 -2
- package/r-bridge/data/data.d.ts +5 -0
- package/r-bridge/data/data.js +6 -0
- package/r-bridge/lang-4.x/ast/parser/json/format.js +1 -1
- package/r-bridge/retriever.d.ts +1 -1
- package/r-bridge/retriever.js +6 -1
- package/r-bridge/shell.js +5 -0
- package/search/flowr-search-filters.d.ts +2 -1
- package/search/flowr-search-printer.js +10 -8
- package/slicing/static/static-slicer.d.ts +2 -2
- package/util/files.d.ts +6 -4
- package/util/files.js +30 -8
- package/util/mermaid/dfg.js +1 -1
- package/util/objects.js +6 -4
- package/util/r-base-packages.d.ts +2 -0
- package/util/r-base-packages.js +3 -0
- package/util/r-license.js +1 -4
- package/util/r-version.d.ts +12 -0
- package/util/r-version.js +16 -0
- package/util/range.d.ts +6 -2
- package/util/range.js +33 -15
- package/util/text/ansi.d.ts +7 -3
- package/util/text/ansi.js +8 -5
- package/util/version.js +4 -4
|
@@ -3,76 +3,198 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.FlowrAnalyzerProjectDiscoveryPlugin = void 0;
|
|
6
|
+
exports.FlowrAnalyzerDefaultProjectDiscoveryPlugin = exports.FlowrAnalyzerFullProjectDiscoveryPlugin = exports.excludeRequestsForPaths = exports.ignorePathsWith = exports.discoverRSourcesRegex = exports.FlowrAnalyzerProjectDiscoveryPlugin = void 0;
|
|
7
|
+
exports.collectRequests = collectRequests;
|
|
7
8
|
const flowr_analyzer_plugin_1 = require("../flowr-analyzer-plugin");
|
|
8
9
|
const semver_1 = require("semver");
|
|
9
10
|
const flowr_file_1 = require("../../context/flowr-file");
|
|
10
11
|
const files_1 = require("../../../util/files");
|
|
11
12
|
const built_in_source_1 = require("../../../dataflow/internal/process/functions/call/built-in/built-in-source");
|
|
13
|
+
const fs_1 = __importDefault(require("fs"));
|
|
12
14
|
const path_1 = __importDefault(require("path"));
|
|
15
|
+
const classify_project_kind_1 = require("../../context/classify-project-kind");
|
|
16
|
+
const glob_1 = require("../../../util/glob");
|
|
13
17
|
const flowr_analyzer_rprofile_file_plugin_1 = require("../file-plugins/flowr-analyzer-rprofile-file-plugin");
|
|
14
18
|
/**
|
|
15
19
|
* This is the base class for all plugins that discover files in a project for analysis.
|
|
16
20
|
* These plugins interplay with the {@link FlowrAnalyzerFilesContext} to gather information about the files in the project.
|
|
17
|
-
* See {@link
|
|
21
|
+
* See {@link FlowrAnalyzerDefaultProjectDiscoveryPlugin} for the default implementation.
|
|
18
22
|
*
|
|
19
23
|
* In general, these plugins only trigger for a {@link RProjectAnalysisRequest} with the idea to discover all files in a project.
|
|
20
24
|
*/
|
|
21
25
|
class FlowrAnalyzerProjectDiscoveryPlugin extends flowr_analyzer_plugin_1.FlowrAnalyzerPlugin {
|
|
22
26
|
type = flowr_analyzer_plugin_1.PluginType.ProjectDiscovery;
|
|
23
27
|
static defaultPlugin() {
|
|
24
|
-
return new
|
|
28
|
+
return new FlowrAnalyzerDefaultProjectDiscoveryPlugin();
|
|
25
29
|
}
|
|
26
30
|
}
|
|
27
31
|
exports.FlowrAnalyzerProjectDiscoveryPlugin = FlowrAnalyzerProjectDiscoveryPlugin;
|
|
28
32
|
// `.Rprofile`/`Rprofile.site` carry no extension but are plain R sources
|
|
29
|
-
|
|
33
|
+
exports.discoverRSourcesRegex = /(\.(r|rmd|ipynb|qmd|rnw)|(^|[\\/])\.?Rprofile(\.site)?)$/i;
|
|
30
34
|
// matched against the posix path relative to the project root
|
|
31
|
-
|
|
32
|
-
|
|
35
|
+
exports.ignorePathsWith = /(^|\/)(\.git|\.svn|\.hg|node_modules|__pycache__|\.Rproj\.user|Rtmp[^/]*|(packrat|renv|rv)\/(lib|library|src|staging|sandbox|bundles)[^/]*)(\/|$)/i;
|
|
36
|
+
exports.excludeRequestsForPaths = /vignettes?|tests?|revdep|inst|data/i;
|
|
33
37
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
38
|
+
* Turn the walked `files` (absolute paths under `root`) into the discovery result: R sources become
|
|
39
|
+
* {@link RParseRequest}s, everything else -- and R sources under an excluded directory -- becomes a
|
|
40
|
+
* {@link FlowrTextFile}; `.Rprofile` files get both so they are tagged. This is the single emit implementation
|
|
41
|
+
* shared by the greedy and the intelligent discovery plugins.
|
|
36
42
|
*/
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
43
|
+
function collectRequests(files, root, opts = {}) {
|
|
44
|
+
const supportedExtensions = opts.supportedExtensions ?? exports.discoverRSourcesRegex;
|
|
45
|
+
const excludePathsRegex = opts.excludePathsRegex ?? exports.excludeRequestsForPaths;
|
|
46
|
+
const onlyTraversePaths = opts.onlyTraversePaths;
|
|
47
|
+
const requests = [];
|
|
48
|
+
for (const file of files) {
|
|
49
|
+
const relativePath = path_1.default.relative(root, file);
|
|
50
|
+
if (supportedExtensions.test(relativePath) && (!onlyTraversePaths || onlyTraversePaths.test(relativePath)) && !excludePathsRegex.test((0, built_in_source_1.platformDirname)(relativePath))) {
|
|
51
|
+
requests.push({ content: file, request: 'file' });
|
|
52
|
+
if (flowr_analyzer_rprofile_file_plugin_1.RprofileFilePattern.test((0, built_in_source_1.platformBasename)(relativePath))) {
|
|
53
|
+
// parse requests skip the file plugins, so emit a file too to have the profile tagged
|
|
54
|
+
requests.push(new flowr_file_1.FlowrTextFile(file));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
requests.push(new flowr_file_1.FlowrTextFile(file));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return requests;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The greedy discovery implementation: every file below the root becomes a {@link RParseRequest} (R and Rmd files)
|
|
65
|
+
* or a {@link FlowrTextFile} (the rest). This is what {@link FlowrAnalyzerDefaultProjectDiscoveryPlugin} falls back
|
|
66
|
+
* to in `full` mode.
|
|
67
|
+
*/
|
|
68
|
+
class FlowrAnalyzerFullProjectDiscoveryPlugin extends FlowrAnalyzerProjectDiscoveryPlugin {
|
|
69
|
+
name = 'full-project-discovery-plugin';
|
|
70
|
+
description = 'Collects every file below the project root (greedy discovery).';
|
|
40
71
|
version = new semver_1.SemVer('0.0.0');
|
|
41
72
|
supportedExtensions;
|
|
42
73
|
ignorePathsRegex;
|
|
43
|
-
excludePathsRegex = excludeRequestsForPaths;
|
|
74
|
+
excludePathsRegex = exports.excludeRequestsForPaths;
|
|
44
75
|
onlyTraversePaths;
|
|
45
76
|
/**
|
|
46
|
-
* Creates a new instance of the
|
|
77
|
+
* Creates a new instance of the greedy project discovery plugin.
|
|
47
78
|
* @param triggerOnExtensions - the regex to trigger R source file discovery on (and hence analyze them as R files)
|
|
48
79
|
* @param ignorePathsRegex - the regex to ignore certain paths entirely
|
|
49
80
|
* @param excludePathsRegex - the regex to exclude certain paths from being requested as R files (they are still collected as text files)
|
|
50
81
|
* @param onlyTraversePaths - if set, only paths matching this regex are traversed
|
|
51
82
|
*/
|
|
52
|
-
constructor({ triggerOnExtensions = discoverRSourcesRegex, ignorePathsRegex = ignorePathsWith, excludePathsRegex = excludeRequestsForPaths, onlyTraversePaths } = {}) {
|
|
83
|
+
constructor({ triggerOnExtensions = exports.discoverRSourcesRegex, ignorePathsRegex = exports.ignorePathsWith, excludePathsRegex = exports.excludeRequestsForPaths, onlyTraversePaths } = {}) {
|
|
53
84
|
super();
|
|
54
85
|
this.supportedExtensions = triggerOnExtensions;
|
|
55
86
|
this.ignorePathsRegex = ignorePathsRegex;
|
|
56
87
|
this.excludePathsRegex = excludePathsRegex;
|
|
57
88
|
this.onlyTraversePaths = onlyTraversePaths;
|
|
58
89
|
}
|
|
59
|
-
process(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
90
|
+
process(context, args) {
|
|
91
|
+
if (!fs_1.default.existsSync(args.content)) {
|
|
92
|
+
return [];
|
|
93
|
+
}
|
|
94
|
+
const failOnInaccessiblePath = context.config.project.failOnInaccessiblePath ?? false;
|
|
95
|
+
return collectRequests((0, files_1.getAllFilesSync)(args.content, /.*/, this.ignorePathsRegex, args.content, failOnInaccessiblePath), args.content, { supportedExtensions: this.supportedExtensions, excludePathsRegex: this.excludePathsRegex, onlyTraversePaths: this.onlyTraversePaths });
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
exports.FlowrAnalyzerFullProjectDiscoveryPlugin = FlowrAnalyzerFullProjectDiscoveryPlugin;
|
|
99
|
+
// noise directories pruned from the scoped walk on top of `ignorePathsWith`: build output, checks, rendered docs and packaged data
|
|
100
|
+
const noiseDirs = /(^|\/)(\.git|\.svn|\.hg|node_modules|__pycache__|\.Rproj\.user|[^/]*\.Rcheck|(packrat|renv|rv)\/(lib|library|src|staging|sandbox|bundles|cache)[^/]*|build|dist|_build|_site|_book|\.quarto|\.cache|Rtmp[^/]*|man|inst\/(extdata|doc))(\/|$)/i;
|
|
101
|
+
// binary/data blobs, dropped even inside an otherwise kept directory
|
|
102
|
+
const noiseFiles = /\.(rds|rda|rdata|rd|png|jpe?g|gif|svg|pdf|ico|zip|tar|t?gz|bz2|xz|so|o|a|dll|dylib|exe|jar|woff2?|ttf|eot|feather|parquet|xls[xm]?|docx?|pptx?)$/i;
|
|
103
|
+
const descriptionFilePattern = /^DESCRIPTION(\.(txt|in))?$/i;
|
|
104
|
+
// metadata the analysis still needs when scoped (mirrors the file-role plugin patterns; local to avoid a cycle)
|
|
105
|
+
const metadataFilePatterns = [
|
|
106
|
+
descriptionFilePattern,
|
|
107
|
+
/^NAMESPACE(\.txt)?$/i,
|
|
108
|
+
/^NEWS(\.(rd|md))?$/i,
|
|
109
|
+
/^(renv|rv|packrat)\.lock$/i,
|
|
110
|
+
/^rproject\.toml$/i,
|
|
111
|
+
/license(\.md|\.txt)?$/i,
|
|
112
|
+
flowr_analyzer_rprofile_file_plugin_1.RprofileFilePattern,
|
|
113
|
+
flowr_analyzer_rprofile_file_plugin_1.RenvironFilePattern
|
|
114
|
+
];
|
|
115
|
+
const testOrVignetteDir = /(^|\/)(tests?|vignettes?)(\/|$)/i;
|
|
116
|
+
/** compile the `project.discovery.perKind` include/exclude globs into matchers */
|
|
117
|
+
function resolveRules(override) {
|
|
118
|
+
return {
|
|
119
|
+
include: (override?.include ?? []).map(glob_1.globMatcher),
|
|
120
|
+
exclude: (override?.exclude ?? []).map(glob_1.globMatcher)
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
/** over-approximating default: R sources, role metadata and `tests/`/`vignettes/` count as project files */
|
|
124
|
+
function keptByDefault(rel) {
|
|
125
|
+
const base = path_1.default.basename(rel);
|
|
126
|
+
return exports.discoverRSourcesRegex.test(rel) || metadataFilePatterns.some(p => p.test(base)) || testOrVignetteDir.test(rel);
|
|
127
|
+
}
|
|
128
|
+
/** whether root-relative `rel` is kept; an explicit `ignore` or `perKind` exclude wins over everything */
|
|
129
|
+
function keep(rel, rules, ignore) {
|
|
130
|
+
if (noiseFiles.test(rel) || ignore.some(m => m(rel)) || rules.exclude.some(m => m(rel))) {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
return keptByDefault(rel) || rules.include.some(m => m(rel));
|
|
134
|
+
}
|
|
135
|
+
/** the lower-cased `DESCRIPTION` `Type:` field, read without the full DCF parser to avoid a cycle */
|
|
136
|
+
function descriptionType(file) {
|
|
137
|
+
let content;
|
|
138
|
+
try {
|
|
139
|
+
content = fs_1.default.readFileSync(file, 'utf8');
|
|
140
|
+
}
|
|
141
|
+
catch {
|
|
142
|
+
return '';
|
|
143
|
+
}
|
|
144
|
+
const m = /^Type:[ \t]*(.+)$/im.exec(content.replace(/^\uFEFF/, ''));
|
|
145
|
+
return (m?.[1] ?? '').trim().toLowerCase();
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* flowR's default discovery: walk the project once (pruning noise directories), classify the {@link ProjectKind}
|
|
149
|
+
* from what the walk sees, then keep only the files that kind needs. `project.discovery.full` restores the greedy
|
|
150
|
+
* {@link FlowrAnalyzerFullProjectDiscoveryPlugin}, `project.discovery.perKind` overrides the kept set per kind.
|
|
151
|
+
*/
|
|
152
|
+
class FlowrAnalyzerDefaultProjectDiscoveryPlugin extends FlowrAnalyzerProjectDiscoveryPlugin {
|
|
153
|
+
name = 'default-project-discovery-plugin';
|
|
154
|
+
description = 'Detects the project kind and discovers only the files it needs (unless project.discovery.full).';
|
|
155
|
+
version = new semver_1.SemVer('1.0.0');
|
|
156
|
+
process(context, args) {
|
|
157
|
+
if (!fs_1.default.existsSync(args.content)) {
|
|
158
|
+
return [];
|
|
159
|
+
}
|
|
160
|
+
const root = args.content;
|
|
161
|
+
const failOn = context.config.project.failOnInaccessiblePath ?? false;
|
|
162
|
+
const discovery = context.config.project.discovery;
|
|
163
|
+
if (discovery?.full) {
|
|
164
|
+
return collectRequests((0, files_1.getAllFilesSync)(root, /.*/, exports.ignorePathsWith, root, failOn), root);
|
|
165
|
+
}
|
|
166
|
+
const opts = (0, classify_project_kind_1.resolveClassifyOptions)(context.config.project.classification);
|
|
167
|
+
// one walk gathers the candidate files and the classification signals, so the kind is known the moment it ends
|
|
168
|
+
const files = [];
|
|
169
|
+
const names = new Set();
|
|
170
|
+
const entries = new Map();
|
|
171
|
+
const descriptionTypes = [];
|
|
172
|
+
let descriptionCount = 0;
|
|
173
|
+
for (const file of (0, files_1.getAllFilesSync)(root, /.*/, noiseDirs, root, failOn)) {
|
|
174
|
+
files.push(file);
|
|
175
|
+
const base = path_1.default.basename(file);
|
|
176
|
+
const lower = base.toLowerCase();
|
|
177
|
+
names.add(lower);
|
|
178
|
+
if (opts.shinyEntryFiles.has(lower) && !entries.has(lower)) {
|
|
179
|
+
entries.set(lower, () => {
|
|
180
|
+
try {
|
|
181
|
+
return fs_1.default.readFileSync(file, 'utf8');
|
|
182
|
+
}
|
|
183
|
+
catch {
|
|
184
|
+
return undefined;
|
|
185
|
+
}
|
|
186
|
+
});
|
|
70
187
|
}
|
|
71
|
-
|
|
72
|
-
|
|
188
|
+
if (descriptionFilePattern.test(base)) {
|
|
189
|
+
descriptionCount++;
|
|
190
|
+
descriptionTypes.push(descriptionType(file));
|
|
73
191
|
}
|
|
74
192
|
}
|
|
75
|
-
|
|
193
|
+
const kind = (0, classify_project_kind_1.classifyProjectKind)({ names, entries, descriptionTypes, descriptionCount }, opts);
|
|
194
|
+
const rules = resolveRules(discovery?.perKind?.[kind]);
|
|
195
|
+
const ignore = (discovery?.ignore ?? []).map(glob_1.globMatcher);
|
|
196
|
+
return collectRequests(files.filter(f => keep(path_1.default.relative(root, f), rules, ignore)), root);
|
|
76
197
|
}
|
|
77
198
|
}
|
|
199
|
+
exports.FlowrAnalyzerDefaultProjectDiscoveryPlugin = FlowrAnalyzerDefaultProjectDiscoveryPlugin;
|
|
78
200
|
//# sourceMappingURL=flowr-analyzer-project-discovery-plugin.js.map
|
|
@@ -19,7 +19,7 @@ export declare function resolveSource(baseDir: string, relPath: string): string;
|
|
|
19
19
|
* back to the OS temp dir (so it works in a read-only Docker image where only `/tmp` is writable -- mount a
|
|
20
20
|
* volume at the cache dir to persist it).
|
|
21
21
|
*/
|
|
22
|
-
export declare function sigDbCacheDir(override?: string): string;
|
|
22
|
+
export declare function sigDbCacheDir(override?: string, create?: boolean): string;
|
|
23
23
|
/** read the (small) header line of a possibly-compressed bundle without decompressing the whole thing */
|
|
24
24
|
export declare function readHeaderOf(source: string): Promise<Record<string, unknown> | undefined>;
|
|
25
25
|
/** where an index for a decompressed source comes from -- a caller-supplied one (e.g. a manifest) or the sibling `.idx` */
|
|
@@ -72,13 +72,16 @@ function resolveSource(baseDir, relPath) {
|
|
|
72
72
|
* back to the OS temp dir (so it works in a read-only Docker image where only `/tmp` is writable -- mount a
|
|
73
73
|
* volume at the cache dir to persist it).
|
|
74
74
|
*/
|
|
75
|
-
function sigDbCacheDir(override) {
|
|
75
|
+
function sigDbCacheDir(override, create = true) {
|
|
76
76
|
const base = override
|
|
77
77
|
?? process.env.FLOWR_SIGDB_CACHE ?? process.env.FLOWR_CACHE_DIR
|
|
78
78
|
?? (process.env.XDG_CACHE_HOME ? node_path_1.default.join(process.env.XDG_CACHE_HOME, 'flowr') : undefined)
|
|
79
79
|
?? (process.env.LOCALAPPDATA ? node_path_1.default.join(process.env.LOCALAPPDATA, 'flowr', 'cache') : undefined)
|
|
80
80
|
?? node_path_1.default.join(node_os_1.default.homedir?.() || node_os_1.default.tmpdir(), '.cache', 'flowr');
|
|
81
81
|
const dir = node_path_1.default.join(base, 'sigdb');
|
|
82
|
+
if (!create) {
|
|
83
|
+
return dir;
|
|
84
|
+
}
|
|
82
85
|
try {
|
|
83
86
|
node_fs_1.default.mkdirSync(dir, { recursive: true });
|
|
84
87
|
return dir;
|
|
@@ -18,6 +18,7 @@ const node_fs_1 = __importDefault(require("node:fs"));
|
|
|
18
18
|
const node_path_1 = __importDefault(require("node:path"));
|
|
19
19
|
const schema_1 = require("./schema");
|
|
20
20
|
const codec_1 = require("./codec");
|
|
21
|
+
const decompress_1 = require("./decompress");
|
|
21
22
|
exports.SigDbManifestMagic = 'flowr-sigdb-manifest';
|
|
22
23
|
exports.SigDbManifestSchema = 2;
|
|
23
24
|
/** write a {@link SigDbManifest} (compact JSON) plus a compressed copy per available codec (`.br` always, `.zst` when supported) beside it */
|
|
@@ -59,6 +60,20 @@ function readManifestDate(manifestFile) {
|
|
|
59
60
|
const SigDbScopeOrder = ['full', 'current', 'base'];
|
|
60
61
|
/** layouts a bundled sigdb may sit in, relative to a search root -- the root itself (e.g. a `$FLOWR_SIGDB_DIR` data mount), then the dev `src`, build `dist` and data-dir layouts */
|
|
61
62
|
const SigDbSubDirs = ['', 'data/sigdb', 'src/data/sigdb', 'dist/src/data/sigdb'];
|
|
63
|
+
function sigDbBundleDirs() {
|
|
64
|
+
if (typeof node_fs_1.default?.readdirSync !== 'function') {
|
|
65
|
+
return [];
|
|
66
|
+
}
|
|
67
|
+
try {
|
|
68
|
+
const bundles = node_path_1.default.join((0, decompress_1.sigDbCacheDir)(undefined, false), 'bundles');
|
|
69
|
+
return node_fs_1.default.readdirSync(bundles, { withFileTypes: true })
|
|
70
|
+
.filter(e => e.isDirectory())
|
|
71
|
+
.map(e => node_path_1.default.join(bundles, e.name));
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
return [];
|
|
75
|
+
}
|
|
76
|
+
}
|
|
62
77
|
/** roots to search for a bundled sigdb; extendable via `$FLOWR_SIGDB_DIR` (path-delimiter separated) */
|
|
63
78
|
function sigDbSearchRoots(extra) {
|
|
64
79
|
const roots = [...(extra ?? [])];
|
|
@@ -86,18 +101,25 @@ function defaultSigDbPath(scope, searchRoots) {
|
|
|
86
101
|
return undefined;
|
|
87
102
|
}
|
|
88
103
|
const scopes = scope ? [scope] : SigDbScopeOrder;
|
|
89
|
-
|
|
90
|
-
for (
|
|
91
|
-
for (const
|
|
92
|
-
for (const
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
return candidate;
|
|
97
|
-
}
|
|
104
|
+
const probe = (dir) => {
|
|
105
|
+
for (const sub of SigDbSubDirs) {
|
|
106
|
+
for (const s of scopes) {
|
|
107
|
+
for (const suffix of ['', ...(0, codec_1.readableExtsPreferred)()]) {
|
|
108
|
+
const candidate = node_path_1.default.join(dir, sub, `${s}.manifest.json${suffix}`);
|
|
109
|
+
if (node_fs_1.default.existsSync(candidate)) {
|
|
110
|
+
return candidate;
|
|
98
111
|
}
|
|
99
112
|
}
|
|
100
113
|
}
|
|
114
|
+
}
|
|
115
|
+
return undefined;
|
|
116
|
+
};
|
|
117
|
+
for (const root of sigDbSearchRoots(searchRoots)) {
|
|
118
|
+
for (let dir = root, i = 0; i < 10; i++) {
|
|
119
|
+
const hit = probe(dir);
|
|
120
|
+
if (hit !== undefined) {
|
|
121
|
+
return hit;
|
|
122
|
+
}
|
|
101
123
|
const parent = node_path_1.default.dirname(dir);
|
|
102
124
|
if (parent === dir) {
|
|
103
125
|
break;
|
|
@@ -105,6 +127,12 @@ function defaultSigDbPath(scope, searchRoots) {
|
|
|
105
127
|
dir = parent;
|
|
106
128
|
}
|
|
107
129
|
}
|
|
130
|
+
for (const bundle of sigDbBundleDirs()) {
|
|
131
|
+
const hit = probe(bundle);
|
|
132
|
+
if (hit !== undefined) {
|
|
133
|
+
return hit;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
108
136
|
return undefined;
|
|
109
137
|
}
|
|
110
138
|
/**
|
|
@@ -132,26 +160,29 @@ function defaultSigDbPaths(searchRoots) {
|
|
|
132
160
|
into.set(key, file);
|
|
133
161
|
}
|
|
134
162
|
};
|
|
135
|
-
|
|
136
|
-
for (
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
163
|
+
const scanDir = (base) => {
|
|
164
|
+
for (const sub of SigDbSubDirs) {
|
|
165
|
+
let entries;
|
|
166
|
+
try {
|
|
167
|
+
entries = node_fs_1.default.readdirSync(node_path_1.default.join(base, sub));
|
|
168
|
+
}
|
|
169
|
+
catch {
|
|
170
|
+
continue; // directory does not exist on this root
|
|
171
|
+
}
|
|
172
|
+
for (const file of entries) {
|
|
173
|
+
const full = node_path_1.default.join(base, sub, file);
|
|
174
|
+
if (new RegExp(`\\.manifest\\.json${codec_1.CompressedExtPattern}$`).test(file)) {
|
|
175
|
+
keep(manifests, (0, codec_1.stripCompressedExt)(file), full, node_path_1.default.join(base, sub));
|
|
144
176
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
if (new RegExp(`\\.manifest\\.json${codec_1.CompressedExtPattern}$`).test(file)) {
|
|
148
|
-
keep(manifests, (0, codec_1.stripCompressedExt)(file), full, node_path_1.default.join(dir, sub));
|
|
149
|
-
}
|
|
150
|
-
else if (new RegExp(`${schema_1.SigDbExt.replace(/\./g, '\\.')}${codec_1.CompressedExtPattern}$`).test(file) && !file.includes('.dict' + schema_1.SigDbExt)) {
|
|
151
|
-
keep(standalones, (0, codec_1.stripCompressedExt)(file), full, node_path_1.default.join(dir, sub));
|
|
152
|
-
}
|
|
177
|
+
else if (new RegExp(`${schema_1.SigDbExt.replace(/\./g, '\\.')}${codec_1.CompressedExtPattern}$`).test(file) && !file.includes('.dict' + schema_1.SigDbExt)) {
|
|
178
|
+
keep(standalones, (0, codec_1.stripCompressedExt)(file), full, node_path_1.default.join(base, sub));
|
|
153
179
|
}
|
|
154
180
|
}
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
for (const root of sigDbSearchRoots(searchRoots)) {
|
|
184
|
+
for (let dir = root, i = 0; i < 10; i++) {
|
|
185
|
+
scanDir(dir);
|
|
155
186
|
const parent = node_path_1.default.dirname(dir);
|
|
156
187
|
if (parent === dir) {
|
|
157
188
|
break;
|
|
@@ -159,6 +190,9 @@ function defaultSigDbPaths(searchRoots) {
|
|
|
159
190
|
dir = parent;
|
|
160
191
|
}
|
|
161
192
|
}
|
|
193
|
+
for (const bundle of sigDbBundleDirs()) {
|
|
194
|
+
scanDir(bundle);
|
|
195
|
+
}
|
|
162
196
|
// a standalone bundle is a `.sigs.ndjson` that is not a shard of a discovered manifest (`<manifest>.<shard>...`)
|
|
163
197
|
const prefixes = [...manifests.keys()].map(k => k.replace(/\.manifest\.json$/, ''));
|
|
164
198
|
const isShard = (name) => {
|
|
@@ -21,7 +21,7 @@ export interface PackageSignatureSource {
|
|
|
21
21
|
/** the export view of a package version (defaults to its latest) */
|
|
22
22
|
lookup(pkg: string, version?: string): LibraryExports | undefined;
|
|
23
23
|
/**
|
|
24
|
-
* The package that OWNS the class `className
|
|
24
|
+
* The package that OWNS the class `className`: an S3 class (a same-named constructor plus a registered method,
|
|
25
25
|
* see {@link LibraryExports.s3Classes}) or an S4 class (exported via `exportClasses`, see
|
|
26
26
|
* {@link LibraryExports.s4Classes}); S3 ownership wins a tie. `undefined` if none does. Without `version`, backed
|
|
27
27
|
* by a reverse index over every package's latest version, built once and cached.
|
|
@@ -72,6 +72,16 @@ export interface ShardStatus {
|
|
|
72
72
|
* version-guessing query build on.
|
|
73
73
|
*/
|
|
74
74
|
export declare function availableVersionEntries(src: PackageSignatureSource, pkg: string): AvailableVersion[];
|
|
75
|
+
/**
|
|
76
|
+
* The reverse index `class -> owning package` over `candidates`, at each one's latest version. S3 ownership (a
|
|
77
|
+
* same-named constructor plus a registered method) is a stronger signal than an S4 `exportClasses`, so S3-owned
|
|
78
|
+
* classes are indexed first and an S4 class only claims a name no S3 owner already took.
|
|
79
|
+
*
|
|
80
|
+
* Restricting the candidates is the targeted counterpart of {@link PackageSignatureSource.classOwner}: class names
|
|
81
|
+
* collide heavily across CRAN, so a whole-database answer is decided by database order, and deriving one means
|
|
82
|
+
* reading every package in the database.
|
|
83
|
+
*/
|
|
84
|
+
export declare function classOwnerIndexFor(src: PackageSignatureSource, candidates: Iterable<string>): Map<string, string>;
|
|
75
85
|
/** union view over multiple sources for the same package; routes queries to the appropriate source */
|
|
76
86
|
export declare class MergedSignatureSource implements PackageSignatureSource {
|
|
77
87
|
private readonly sources;
|
|
@@ -115,12 +125,6 @@ export interface OpenSyncOptions {
|
|
|
115
125
|
export interface OpenSyncFromOptions extends SigDbOpenOptions, OpenSyncOptions {
|
|
116
126
|
hash?: string;
|
|
117
127
|
}
|
|
118
|
-
/**
|
|
119
|
-
* Fast, partial reader for a single bundle. `open()`/`openSync()` load the string dictionary + `.idx`
|
|
120
|
-
* once (a single ranged read of the dictionary section -- no full parse), then every query seeks straight
|
|
121
|
-
* to one package blob on demand. `open()` additionally decompresses a `.br`/`.gz` source into a
|
|
122
|
-
* hash-keyed cache and reuses it on later startups. Implements {@link PackageSignatureSource}.
|
|
123
|
-
*/
|
|
124
128
|
export declare class SigDatabase implements PackageSignatureSource {
|
|
125
129
|
private closed;
|
|
126
130
|
/** parsed blobs by blob index so repeated lookups skip the re-read + JSON.parse; FIFO-bounded to cap memory */
|
|
@@ -134,10 +138,16 @@ export declare class SigDatabase implements PackageSignatureSource {
|
|
|
134
138
|
readonly content: SigDbContent | undefined;
|
|
135
139
|
private readonly cranBase;
|
|
136
140
|
private constructor();
|
|
141
|
+
/**
|
|
142
|
+
* Use an already-built {@link SigDb} directly, without writing or reading a file: its blobs simply start out in
|
|
143
|
+
* the cache. It holds exactly what a bundle carries, so every query answers as it would from disk; the
|
|
144
|
+
* {@link SigDbBuilder} plus this is all a test needs.
|
|
145
|
+
*/
|
|
146
|
+
static fromMemory(db: SigDb): SigDatabase;
|
|
137
147
|
/**
|
|
138
148
|
* Open a plain, seekable `.sigs.ndjson` synchronously. Pass `index` to skip reading the `.idx`,
|
|
139
149
|
* and `strings` to use an already-loaded shared dictionary instead of the file's own `d` section (for a
|
|
140
|
-
* blob-only shard). One ranged read loads the dictionary
|
|
150
|
+
* blob-only shard). One ranged read loads the dictionary, no readline overhead.
|
|
141
151
|
*/
|
|
142
152
|
static openSync(plainFile: string, opts?: OpenSyncOptions): SigDatabase;
|
|
143
153
|
/** open a `.sigs.ndjson`, `.br` or `.gz`; compressed sources are decompressed into a hash-keyed cache once */
|
|
@@ -185,7 +195,7 @@ export declare class SigDatabase implements PackageSignatureSource {
|
|
|
185
195
|
/** close the underlying file descriptor (idempotent; safe to call more than once) */
|
|
186
196
|
close(): void;
|
|
187
197
|
}
|
|
188
|
-
/** options for {@link SigDatabaseSet.openManifest}
|
|
198
|
+
/** options for {@link SigDatabaseSet.openManifest}: the base cache options plus per-shard enable/disable */
|
|
189
199
|
export interface SigDbSetOpenOptions extends SigDbOpenOptions {
|
|
190
200
|
/** only load these shard ids (e.g. `['base-current','current-top']`); omit to load all */
|
|
191
201
|
includeShards?: readonly string[];
|
|
@@ -220,7 +230,7 @@ export declare class SigDatabaseSet implements PackageSignatureSource {
|
|
|
220
230
|
private static assemble;
|
|
221
231
|
static openManifest(manifestFile: string, opts?: SigDbSetOpenOptions): Promise<SigDatabaseSet>;
|
|
222
232
|
/**
|
|
223
|
-
* Synchronous {@link openManifest}
|
|
233
|
+
* Synchronous {@link openManifest}, needing every shard to embed its index (the default for the bundles
|
|
224
234
|
* flowR ships). Shards and dictionaries still decompress lazily.
|
|
225
235
|
*/
|
|
226
236
|
static openManifestSync(manifestFile: string, opts?: SigDbSetOpenOptions): SigDatabaseSet;
|
|
@@ -228,7 +238,7 @@ export declare class SigDatabaseSet implements PackageSignatureSource {
|
|
|
228
238
|
private readonly dictCache;
|
|
229
239
|
/** load (and cache) a shared dictionary's strings, decompressing its `.br` into the cache once */
|
|
230
240
|
private dictionaryStrings;
|
|
231
|
-
/** lazily open a shard
|
|
241
|
+
/** lazily open a shard, decompressing its `.br` (and its shared dictionary) into the cache on first access */
|
|
232
242
|
private shard;
|
|
233
243
|
/**
|
|
234
244
|
* Warm the shards (and their shared dictionaries) needed for `pkgs`, or **everything** when omitted.
|
|
@@ -244,7 +254,7 @@ export declare class SigDatabaseSet implements PackageSignatureSource {
|
|
|
244
254
|
private warmShards;
|
|
245
255
|
/** the shard indices that can serve this package, preferred order; optionally requiring a specific version */
|
|
246
256
|
private route;
|
|
247
|
-
/** read (once) the blob from the shard with the most complete history
|
|
257
|
+
/** read (once) the blob from the shard with the most complete history: a `full` or `history` tier if present */
|
|
248
258
|
private historyBlob;
|
|
249
259
|
has(pkg: string): boolean;
|
|
250
260
|
/** whether any active shard actually carries the given version of a package (not just the package) */
|
|
@@ -254,9 +264,9 @@ export declare class SigDatabaseSet implements PackageSignatureSource {
|
|
|
254
264
|
packageNames(): string[];
|
|
255
265
|
/** the on-demand load state (opened + unpacked) of every shard in this set */
|
|
256
266
|
shardStatus(): ShardStatus[];
|
|
257
|
-
/** open (blocking) and return every shard database with its manifest ref
|
|
267
|
+
/** open (blocking) and return every shard database with its manifest ref, for whole-set verification */
|
|
258
268
|
allShards(): MountedShard[];
|
|
259
|
-
/** load (and cache) a shared dictionary's strings by id
|
|
269
|
+
/** load (and cache) a shared dictionary's strings by id, for verification/inspection */
|
|
260
270
|
sharedDictionary(id: string): string[];
|
|
261
271
|
/** the first non-empty result from the shards that can serve `pkg` (in preferred order: current before full) */
|
|
262
272
|
private firstOf;
|
|
@@ -270,7 +280,7 @@ export declare class SigDatabaseSet implements PackageSignatureSource {
|
|
|
270
280
|
isBaseR(pkg: string): boolean;
|
|
271
281
|
/** the R versions a base package was part of core (ascending); `undefined` if not a base package */
|
|
272
282
|
coreVersions(pkg: string): RVersion[] | undefined;
|
|
273
|
-
/** every known release of a package (version + date), ascending
|
|
283
|
+
/** every known release of a package (version + date), ascending, read once from the most complete shard */
|
|
274
284
|
releaseDates(pkg: string): VersionRelease[];
|
|
275
285
|
/** the release date of a package version (defaulting to the newest release), or `undefined` if unknown */
|
|
276
286
|
releaseDate(pkg: string, version?: string): Date | undefined;
|
|
@@ -284,7 +294,7 @@ export declare class SigDatabaseSet implements PackageSignatureSource {
|
|
|
284
294
|
}
|
|
285
295
|
/**
|
|
286
296
|
* Open a path-based source once, process-wide, synchronously. Returns the shared instance (opening it on the
|
|
287
|
-
* first call), or `undefined` if the path needs async opening (a `.br`/`.gz` bundle
|
|
297
|
+
* first call), or `undefined` if the path needs async opening (a `.br`/`.gz` bundle, use {@link getSharedSigSource}).
|
|
288
298
|
* Throws only if a sync-openable source fails to open.
|
|
289
299
|
*/
|
|
290
300
|
export declare function getSharedSigSourceSync(source: string): PackageSignatureSource | undefined;
|