@eagleoutice/flowr 2.17.0 → 2.17.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/config.d.ts +32 -0
- package/config.js +22 -2
- package/control-flow/semantic-cfg-guided-visitor.js +2 -0
- package/dataflow/environments/ambient-state-name.d.ts +4 -0
- package/dataflow/environments/ambient-state-name.js +4 -0
- package/dataflow/environments/built-in-proc-name.d.ts +4 -0
- package/dataflow/environments/built-in-proc-name.js +4 -0
- package/dataflow/environments/built-in-props.d.ts +18 -2
- package/dataflow/environments/built-in-props.js +26 -4
- package/dataflow/environments/built-in.d.ts +16 -6
- package/dataflow/environments/built-in.js +58 -7
- package/dataflow/environments/default-builtin-config.d.ts +1245 -159
- package/dataflow/environments/default-builtin-config.js +191 -38
- package/dataflow/environments/environment.d.ts +19 -2
- package/dataflow/environments/environment.js +90 -19
- package/dataflow/environments/identifier.d.ts +25 -1
- package/dataflow/environments/query-fn-props.js +4 -3
- package/dataflow/environments/resolve-by-name.js +5 -3
- package/dataflow/eval/resolve/node-value.d.ts +1 -1
- package/dataflow/eval/resolve/node-value.js +2 -2
- package/dataflow/eval/resolve/resolve-argument.js +1 -1
- package/dataflow/extractor.js +68 -17
- package/dataflow/fn/function-semantics.d.ts +1 -0
- package/dataflow/graph/df-helper.d.ts +34 -1
- package/dataflow/graph/df-helper.js +60 -0
- package/dataflow/info.d.ts +2 -0
- package/dataflow/info.js +4 -0
- package/dataflow/internal/linker.js +21 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.d.ts +4 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.js +3 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +18 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +144 -30
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +2 -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-assignment.js +10 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +8 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +43 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-env-contents.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-env-contents.js +5 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +67 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +4 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +27 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +2 -14
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +1 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +28 -10
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +134 -88
- package/dataflow/internal/process/functions/call/built-in/built-in-load.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-load.js +87 -10
- package/dataflow/internal/process/functions/call/built-in/built-in-local.d.ts +8 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-local.js +23 -12
- package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +7 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +28 -10
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +7 -5
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +2 -2
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +18 -15
- package/dataflow/internal/process/functions/call/named-call-handling.js +8 -4
- package/dataflow/internal/process/functions/call/quoted.d.ts +2 -0
- package/dataflow/internal/process/functions/call/quoted.js +8 -7
- package/documentation/wiki-dataflow-graph.js +20 -1
- package/linter/rules/network-functions.js +10 -2
- package/linter/rules/undefined-symbol.js +2 -2
- package/linter/rules/unused-import.js +11 -1
- package/package.json +1 -1
- package/project/attached-packages.d.ts +11 -6
- package/project/attached-packages.js +37 -9
- package/project/cache/flowr-analyzer-cache.d.ts +4 -0
- package/project/cache/flowr-analyzer-cache.js +11 -0
- package/project/context/flowr-analyzer-dependencies-context.d.ts +3 -0
- package/project/context/flowr-analyzer-dependencies-context.js +6 -0
- package/project/context/flowr-file.d.ts +2 -2
- package/project/context/flowr-file.js +2 -2
- package/project/plugins/file-plugins/files/flowr-manifest-files.d.ts +39 -4
- package/project/plugins/file-plugins/files/flowr-manifest-files.js +134 -30
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-manifest-file-plugin.d.ts +7 -0
- package/project/plugins/file-plugins/flowr-analyzer-manifest-file-plugin.js +14 -1
- package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.js +3 -3
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-manifest-file-plugin.d.ts +18 -5
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-manifest-file-plugin.js +43 -15
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.d.ts +12 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js +31 -2
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-on-demand-plugin.d.ts +58 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-on-demand-plugin.js +237 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.d.ts +8 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.js +8 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +7 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +24 -18
- package/project/plugins/plugin-registry.d.ts +5 -4
- package/project/plugins/plugin-registry.js +6 -0
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +4 -4
- package/project/sigdb/decode.js +13 -3
- package/project/sigdb/memory-source.d.ts +6 -4
- package/project/sigdb/memory-source.js +6 -5
- package/project/sigdb/on-demand/fetch.d.ts +18 -0
- package/project/sigdb/on-demand/fetch.js +127 -0
- package/project/sigdb/on-demand/package-sources.d.ts +40 -0
- package/project/sigdb/on-demand/package-sources.js +263 -0
- package/project/sigdb/on-demand/recoverer.d.ts +40 -0
- package/project/sigdb/on-demand/recoverer.js +169 -0
- package/project/sigdb/on-demand/remote-sources.d.ts +72 -0
- package/project/sigdb/on-demand/remote-sources.js +132 -0
- package/project/sigdb/on-demand/tar.d.ts +19 -0
- package/project/sigdb/on-demand/tar.js +119 -0
- package/queries/catalog/dependencies-query/function-info/derived-functions.d.ts +5 -0
- package/queries/catalog/dependencies-query/function-info/derived-functions.js +17 -1
- package/queries/catalog/dependencies-query/function-info/read-functions.js +3 -1
- package/queries/catalog/dependencies-query/function-info/write-functions.js +11 -1
- package/queries/catalog/signature-query/signature-query-executor.js +15 -1
- package/queries/catalog/signature-query/signature-query-format.d.ts +3 -2
- package/r-bridge/data/data.d.ts +31 -2
- package/r-bridge/data/data.js +25 -2
- package/r-bridge/lang-4.x/ast/model/model.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/model.js +6 -1
- package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +6 -1
- package/r-bridge/lang-4.x/ast/model/processing/node-id.js +12 -1
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.d.ts +4 -0
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +8 -0
- package/reconstruct/reconstruct.js +2 -5
- package/search/search-executor/search-enrichers.js +17 -2
- package/search/search-executor/search-generators.js +6 -2
- package/slicing/static/slice-call.d.ts +16 -0
- package/slicing/static/slice-call.js +42 -0
- package/slicing/static/static-slicer.js +6 -0
- package/taint-analysis/predefined/secret-analysis.js +7 -2
- package/taint-analysis/taint-mapping.d.ts +5 -2
- package/taint-analysis/taint-mapping.js +17 -6
- package/util/flowr-version.d.ts +1 -1
- package/util/flowr-version.js +2 -2
- package/util/r-version.js +4 -2
|
@@ -1,22 +1,50 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.metaPackageCore = metaPackageCore;
|
|
4
4
|
exports.attachedAlongside = attachedAlongside;
|
|
5
5
|
const arrays_1 = require("../util/collections/arrays");
|
|
6
|
+
const r_version_1 = require("../util/r-version");
|
|
6
7
|
/**
|
|
7
8
|
* Packages that attach further packages from their `.onAttach` hook, which no package metadata records: their core
|
|
8
9
|
* set sits in `Imports`, indistinguishable from the packages they merely use. Whoever loads one of them gets the
|
|
9
10
|
* whole set on the search path, so `library(tidyverse)` has to resolve `ggplot()`.
|
|
11
|
+
* Each entry lists, from the release it first appeared in, the core set in the order the hook attaches it (each
|
|
12
|
+
* on top of the last), as read from the hook's source in every CRAN release.
|
|
10
13
|
* `Depends` is handled generally by {@link attachedAlongside} and hence not repeated here.
|
|
11
14
|
*/
|
|
12
|
-
|
|
13
|
-
['tidyverse', [
|
|
14
|
-
|
|
15
|
-
'
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
['
|
|
15
|
+
const MetaPackageCores = new Map([
|
|
16
|
+
['tidyverse', [
|
|
17
|
+
['1.0.0', ['ggplot2', 'tibble', 'tidyr', 'readr', 'purrr', 'dplyr']],
|
|
18
|
+
['1.2.0', ['ggplot2', 'tibble', 'tidyr', 'readr', 'purrr', 'dplyr', 'stringr', 'forcats']],
|
|
19
|
+
['2.0.0', ['ggplot2', 'tibble', 'tidyr', 'readr', 'purrr', 'dplyr', 'stringr', 'forcats', 'lubridate']]
|
|
20
|
+
]],
|
|
21
|
+
['tidymodels', [
|
|
22
|
+
['0.0.1', ['ggplot2', 'tibble', 'purrr', 'dplyr', 'rsample', 'recipes', 'broom', 'yardstick', 'infer']],
|
|
23
|
+
['0.0.2', ['broom', 'dials', 'dplyr', 'ggplot2', 'infer', 'parsnip', 'purrr', 'recipes', 'rsample', 'tibble', 'yardstick']],
|
|
24
|
+
['0.1.0', ['broom', 'dials', 'dplyr', 'ggplot2', 'infer', 'parsnip', 'purrr', 'recipes', 'rsample', 'tibble', 'tune', 'workflows', 'yardstick']],
|
|
25
|
+
['0.1.1', ['broom', 'dials', 'dplyr', 'ggplot2', 'infer', 'modeldata', 'parsnip', 'purrr', 'recipes', 'rsample', 'tibble', 'tidyr', 'tune', 'workflows', 'yardstick']],
|
|
26
|
+
['0.1.3', ['broom', 'dials', 'dplyr', 'ggplot2', 'infer', 'modeldata', 'parsnip', 'purrr', 'recipes', 'rsample', 'tibble', 'tidyr', 'tune', 'workflows', 'workflowsets', 'yardstick']],
|
|
27
|
+
['1.4.1', ['broom', 'dials', 'dplyr', 'ggplot2', 'infer', 'modeldata', 'parsnip', 'purrr', 'recipes', 'rsample', 'tailor', 'tidyr', 'tune', 'workflows', 'workflowsets', 'yardstick']]
|
|
28
|
+
]],
|
|
29
|
+
['easystats', [
|
|
30
|
+
['0.5.2', ['insight', 'datawizard', 'bayestestR', 'performance', 'parameters', 'effectsize', 'modelbased', 'correlation', 'see', 'report']]
|
|
31
|
+
]],
|
|
32
|
+
['fpp3', [
|
|
33
|
+
['0.1', ['tibble', 'dplyr', 'tidyr', 'lubridate', 'ggplot2', 'tsibble', 'tsibbledata', 'feasts', 'fable']],
|
|
34
|
+
['0.5', ['tibble', 'dplyr', 'tidyr', 'lubridate', 'ggplot2', 'tsibble', 'tsibbledata', 'feasts', 'fable', 'fabletools']],
|
|
35
|
+
['1.0.1', ['tibble', 'dplyr', 'tidyr', 'lubridate', 'ggplot2', 'tsibble', 'tsibbledata', 'feasts', 'fable']],
|
|
36
|
+
['1.0.3', ['tibble', 'dplyr', 'tidyr', 'lubridate', 'ggplot2', 'tsibble', 'tsibbledata', 'ggtime', 'feasts', 'fable']]
|
|
37
|
+
]]
|
|
19
38
|
]);
|
|
39
|
+
/**
|
|
40
|
+
* The core set the {@link MetaPackageCores|meta-package} `pack` attaches from its `.onAttach` hook at `version`
|
|
41
|
+
* (the newest release's when unknown, the oldest one's for a version predating every recorded release), empty for any other package.
|
|
42
|
+
*/
|
|
43
|
+
function metaPackageCore(pack, version) {
|
|
44
|
+
const releases = MetaPackageCores.get(pack) ?? [];
|
|
45
|
+
const matching = version === undefined ? releases : releases.filter(([since]) => r_version_1.RVersion.compare(since, version) <= 0);
|
|
46
|
+
return (matching.at(-1) ?? releases[0])?.[1] ?? [];
|
|
47
|
+
}
|
|
20
48
|
/**
|
|
21
49
|
* The packages that end up on the search path alongside `pack` when it is attached: everything it `Depends` on
|
|
22
50
|
* (which R attaches with it) and, for a {@link MetaPackageCores|meta-package}, the core set it attaches itself.
|
|
@@ -26,6 +54,6 @@ function attachedAlongside(pack, sources, version) {
|
|
|
26
54
|
.flatMap(src => src.dependencies(pack, version) ?? [])
|
|
27
55
|
.filter(d => d.type === 0 /* DepType.Depends */ && d.name !== 'R')
|
|
28
56
|
.map(d => d.name);
|
|
29
|
-
return (0, arrays_1.uniqueArray)(
|
|
57
|
+
return { depends: (0, arrays_1.uniqueArray)(depends), onAttach: metaPackageCore(pack, version) };
|
|
30
58
|
}
|
|
31
59
|
//# sourceMappingURL=attached-packages.js.map
|
|
@@ -36,6 +36,10 @@ export declare class FlowrAnalyzerCache<Parser extends KnownParser> extends Flow
|
|
|
36
36
|
reset(): void;
|
|
37
37
|
private runTapeUntil;
|
|
38
38
|
private stepTapeUntil;
|
|
39
|
+
/** the normalized AST the dependency plugins already {@link FlowrAnalyzerDependenciesContext#prepare|prepared} for */
|
|
40
|
+
private prepared;
|
|
41
|
+
/** once the AST is there and the dataflow is not, the dependency plugins may wait for what the dataflow asks of them */
|
|
42
|
+
private prepareDataflow;
|
|
39
43
|
private storeIncrementalSnapshotIfAvailable;
|
|
40
44
|
/**
|
|
41
45
|
* Get the parse output for the request, parsing if necessary.
|
|
@@ -83,12 +83,23 @@ class FlowrAnalyzerCache extends flowr_cache_1.FlowrCache {
|
|
|
83
83
|
async stepTapeUntil(until) {
|
|
84
84
|
let g;
|
|
85
85
|
while ((g = until()) === undefined && this.pipeline.hasNextStep()) {
|
|
86
|
+
await this.prepareDataflow();
|
|
86
87
|
await this.pipeline.nextStep();
|
|
87
88
|
}
|
|
88
89
|
this.storeIncrementalSnapshotIfAvailable();
|
|
89
90
|
(0, assert_1.guard)(g !== undefined, 'Could not reach the desired pipeline step, invalid cache state(?)');
|
|
90
91
|
return g;
|
|
91
92
|
}
|
|
93
|
+
/** the normalized AST the dependency plugins already {@link FlowrAnalyzerDependenciesContext#prepare|prepared} for */
|
|
94
|
+
prepared;
|
|
95
|
+
/** once the AST is there and the dataflow is not, the dependency plugins may wait for what the dataflow asks of them */
|
|
96
|
+
async prepareDataflow() {
|
|
97
|
+
const { normalize, dataflow } = this.get();
|
|
98
|
+
if (normalize !== undefined && dataflow === undefined && this.prepared !== normalize) {
|
|
99
|
+
this.prepared = normalize;
|
|
100
|
+
await this.args.context.deps.prepare(normalize);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
92
103
|
storeIncrementalSnapshotIfAvailable() {
|
|
93
104
|
if (this.args.parser.name !== 'tree-sitter') {
|
|
94
105
|
return;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { NormalizedAst } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
1
2
|
import { AbstractFlowrAnalyzerContext } from './abstract-flowr-analyzer-context';
|
|
2
3
|
import { FlowrAnalyzerPackageVersionsPlugin, type SigDbLoadedInfo } from '../plugins/package-version-plugins/flowr-analyzer-package-versions-plugin';
|
|
3
4
|
import { Package } from '../plugins/package-version-plugins/package';
|
|
@@ -131,6 +132,8 @@ export declare class FlowrAnalyzerDependenciesContext extends AbstractFlowrAnaly
|
|
|
131
132
|
baseRSourceFingerprint(): string;
|
|
132
133
|
/** Mount an additional signature database/source by path (a plain `.sigs.ndjson`, a `.br`, or a manifest). */
|
|
133
134
|
addDatabaseSource(source: string): Promise<void>;
|
|
135
|
+
/** Lets every version plugin wait for what the dataflow of `ast` will ask of it, see {@link FlowrAnalyzerPackageVersionsPlugin#prepare}. */
|
|
136
|
+
prepare(ast: NormalizedAst): Promise<void>;
|
|
134
137
|
/** Eagerly mount every version plugin's signature database up front (see `solver.sigdb.eagerlyLoad`). */
|
|
135
138
|
eagerlyLoadSignatureDatabases(): void;
|
|
136
139
|
receive(event: InvalidationEvent): void;
|
|
@@ -104,6 +104,12 @@ class FlowrAnalyzerDependenciesContext extends abstract_flowr_analyzer_context_1
|
|
|
104
104
|
await p.addDatabaseSource(source);
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
|
+
/** Lets every version plugin wait for what the dataflow of `ast` will ask of it, see {@link FlowrAnalyzerPackageVersionsPlugin#prepare}. */
|
|
108
|
+
async prepare(ast) {
|
|
109
|
+
await Promise.all(this.plugins.map(p => p.prepare(this.ctx, ast)));
|
|
110
|
+
/* a package a plugin could not name before may resolve now */
|
|
111
|
+
this.resolvedMisses.clear();
|
|
112
|
+
}
|
|
107
113
|
/** Eagerly mount every version plugin's signature database up front (see `solver.sigdb.eagerlyLoad`). */
|
|
108
114
|
eagerlyLoadSignatureDatabases() {
|
|
109
115
|
for (const p of this.plugins) {
|
|
@@ -36,9 +36,9 @@ export declare enum FileRole {
|
|
|
36
36
|
Documentation = "documentation",
|
|
37
37
|
/** Signals separate license files, but please note, that DESCRIPTION files may contain license info too */
|
|
38
38
|
License = "license",
|
|
39
|
-
/** Files describing a project's virtual/pinned package environment, e.g., `renv.lock`, `rv.lock` or `
|
|
39
|
+
/** Files describing a project's virtual/pinned package environment, e.g., `renv.lock`, `rv.lock`, `uvr.lock` or rig's `rproj.lock`. */
|
|
40
40
|
VirtualEnv = "virtual-env",
|
|
41
|
-
/** A project manifest that is no `DESCRIPTION`, e.g. the `rproject.toml` of an rv project
|
|
41
|
+
/** A project manifest that is no `DESCRIPTION`, e.g. the `rproject.toml` of an rv project, the `uvr.toml` of a uvr project or the `rproj.toml` of a rig project. */
|
|
42
42
|
Manifest = "manifest",
|
|
43
43
|
/**
|
|
44
44
|
* R sources evaluated at startup, before any project code (`.Rprofile`, `Rprofile.site`).
|
|
@@ -36,9 +36,9 @@ var FileRole;
|
|
|
36
36
|
FileRole["Documentation"] = "documentation";
|
|
37
37
|
/** Signals separate license files, but please note, that DESCRIPTION files may contain license info too */
|
|
38
38
|
FileRole["License"] = "license";
|
|
39
|
-
/** Files describing a project's virtual/pinned package environment, e.g., `renv.lock`, `rv.lock` or `
|
|
39
|
+
/** Files describing a project's virtual/pinned package environment, e.g., `renv.lock`, `rv.lock`, `uvr.lock` or rig's `rproj.lock`. */
|
|
40
40
|
FileRole["VirtualEnv"] = "virtual-env";
|
|
41
|
-
/** A project manifest that is no `DESCRIPTION`, e.g. the `rproject.toml` of an rv project
|
|
41
|
+
/** A project manifest that is no `DESCRIPTION`, e.g. the `rproject.toml` of an rv project, the `uvr.toml` of a uvr project or the `rproj.toml` of a rig project. */
|
|
42
42
|
FileRole["Manifest"] = "manifest";
|
|
43
43
|
/**
|
|
44
44
|
* R sources evaluated at startup, before any project code (`.Rprofile`, `Rprofile.site`).
|
|
@@ -3,11 +3,20 @@ import type { DeepReadonly } from 'ts-essentials';
|
|
|
3
3
|
import type { DeclaredPackages } from '../../../context/flowr-analyzer-meta-context';
|
|
4
4
|
import { Package } from '../../package-version-plugins/package';
|
|
5
5
|
export declare const manifestFileLog: import("tslog").Logger<import("tslog").ILogObj>;
|
|
6
|
+
/** what a project manifest declares, whether it is a file of its own or a block within a script */
|
|
7
|
+
export interface ProjectManifest {
|
|
8
|
+
/** unlike the `Package` of a `DESCRIPTION` this is no namespace, such a project is no package */
|
|
9
|
+
projectName(): string | undefined;
|
|
10
|
+
/** `undefined` if the manifest only states a requirement like `>=4.0.0` */
|
|
11
|
+
rVersion(): string | undefined;
|
|
12
|
+
/** grouped as a `DESCRIPTION` groups them */
|
|
13
|
+
declares(): DeclaredPackages;
|
|
14
|
+
}
|
|
6
15
|
/**
|
|
7
|
-
* A project manifest that is no `DESCRIPTION` (an rv `rproject.toml`, a uvr `uvr.toml`).
|
|
16
|
+
* A project manifest that is no `DESCRIPTION` (an rv `rproject.toml`, a uvr `uvr.toml`, a rig `rproj.toml`).
|
|
8
17
|
* Prefer the static `from` method of the concrete subclass, which avoids re-wrapping and handles roles.
|
|
9
18
|
*/
|
|
10
|
-
export declare abstract class FlowrManifestFile<Content extends StringableContent = StringableContent> extends FlowrWrappedFile<Content> {
|
|
19
|
+
export declare abstract class FlowrManifestFile<Content extends StringableContent = StringableContent> extends FlowrWrappedFile<Content> implements ProjectManifest {
|
|
11
20
|
/** unlike the `Package` of a `DESCRIPTION` this is no namespace, such a project is no package */
|
|
12
21
|
abstract projectName(): string | undefined;
|
|
13
22
|
/** `undefined` if the manifest only states a requirement like `>=4.0.0` */
|
|
@@ -50,7 +59,33 @@ export declare class FlowrUvrManifestFile extends FlowrManifestFile<DeepReadonly
|
|
|
50
59
|
/** uvr usually states a requirement (`>=4.0.0`), which pins nothing; the `uvr.lock` holds the resolved version */
|
|
51
60
|
rVersion(): string | undefined;
|
|
52
61
|
declares(): DeclaredPackages;
|
|
53
|
-
/** a table mapping the name to a bare requirement (`">=3.0.0"`, `"*"`) or to one with its origin (`{ version = ..., git = ... }`) */
|
|
54
|
-
private packagesOf;
|
|
55
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* The tables of a [rig](https://rig.r-lib.org/proj-guide.html) project manifest (`src/rproj.rs` of rig), of which a
|
|
65
|
+
* script states `[dependencies]` in its inline block.
|
|
66
|
+
*/
|
|
67
|
+
interface RigManifest {
|
|
68
|
+
project?: {
|
|
69
|
+
name?: unknown;
|
|
70
|
+
};
|
|
71
|
+
dependencies?: unknown;
|
|
72
|
+
'linking-dependencies'?: unknown;
|
|
73
|
+
'dependency-groups'?: unknown;
|
|
74
|
+
'optional-dependencies'?: unknown;
|
|
75
|
+
}
|
|
76
|
+
/** The `rproj.toml` of a [rig](https://rig.r-lib.org/proj-guide.html) project, lifted by {@link FlowrRigProjectFile.from}. */
|
|
77
|
+
export declare class FlowrRigProjectFile extends FlowrManifestFile<DeepReadonly<RigManifest>> {
|
|
78
|
+
protected loadContent(): RigManifest;
|
|
79
|
+
projectName(): string | undefined;
|
|
80
|
+
rVersion(): string | undefined;
|
|
81
|
+
declares(): DeclaredPackages;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* The manifest a rig script states inline, read as rig reads it (`src/script_meta.rs` of rig): the one comment block
|
|
85
|
+
* opened by a line that is exactly `# /// script` (or `## /// script`), anywhere in the file, and closed by `# ///`
|
|
86
|
+
* with the same marker. Every line in between starts with that marker, and without it (and one space) the lines are
|
|
87
|
+
* TOML holding `[dependencies]`, `[[repository]]` and `[tool]`. As rig refuses to run the script otherwise, a second
|
|
88
|
+
* block, an unclosed block, a line without the marker, broken TOML or any other table declare nothing.
|
|
89
|
+
*/
|
|
90
|
+
export declare function rigScriptManifest(code: string, origin: string): ProjectManifest | undefined;
|
|
56
91
|
export {};
|
|
@@ -1,28 +1,65 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FlowrUvrManifestFile = exports.FlowrRProjectFile = exports.FlowrManifestFile = exports.manifestFileLog = void 0;
|
|
3
|
+
exports.FlowrRigProjectFile = exports.FlowrUvrManifestFile = exports.FlowrRProjectFile = exports.FlowrManifestFile = exports.manifestFileLog = void 0;
|
|
4
|
+
exports.rigScriptManifest = rigScriptManifest;
|
|
4
5
|
const flowr_file_1 = require("../../../context/flowr-file");
|
|
5
6
|
const package_1 = require("../../package-version-plugins/package");
|
|
6
7
|
const smol_toml_1 = require("smol-toml");
|
|
7
8
|
const log_1 = require("../../../../util/log");
|
|
8
9
|
exports.manifestFileLog = log_1.log.getSubLogger({ name: 'flowr-manifest-file' });
|
|
9
10
|
/**
|
|
10
|
-
* A project manifest that is no `DESCRIPTION` (an rv `rproject.toml`, a uvr `uvr.toml`).
|
|
11
|
+
* A project manifest that is no `DESCRIPTION` (an rv `rproject.toml`, a uvr `uvr.toml`, a rig `rproj.toml`).
|
|
11
12
|
* Prefer the static `from` method of the concrete subclass, which avoids re-wrapping and handles roles.
|
|
12
13
|
*/
|
|
13
14
|
class FlowrManifestFile extends flowr_file_1.FlowrWrappedFile {
|
|
14
15
|
/** the parsed TOML of the wrapped file, empty (with a warning) if it does not parse */
|
|
15
16
|
parseTomlContent() {
|
|
16
|
-
|
|
17
|
-
return (0, smol_toml_1.parse)(this.wrapped.content().toString());
|
|
18
|
-
}
|
|
19
|
-
catch (e) {
|
|
20
|
-
exports.manifestFileLog.warn(`Could not parse ${this.wrapped.path()}: ${e.message}`);
|
|
21
|
-
return {};
|
|
22
|
-
}
|
|
17
|
+
return parseTomlOrEmpty(this.wrapped.content().toString(), this.wrapped.path());
|
|
23
18
|
}
|
|
24
19
|
}
|
|
25
20
|
exports.FlowrManifestFile = FlowrManifestFile;
|
|
21
|
+
function parseTomlOrEmpty(toml, origin) {
|
|
22
|
+
try {
|
|
23
|
+
return (0, smol_toml_1.parse)(toml);
|
|
24
|
+
}
|
|
25
|
+
catch (e) {
|
|
26
|
+
exports.manifestFileLog.warn(`Could not parse ${origin}: ${e.message}`);
|
|
27
|
+
return {};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/** a requirement that starts with a version (`4.4`) pins one; `>= 4.4` or `*` only constrains */
|
|
31
|
+
function pinnedVersion(version) {
|
|
32
|
+
const trimmed = typeof version === 'string' ? version.trim() : '';
|
|
33
|
+
return /^\d/.test(trimmed) ? trimmed : undefined;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The entries of a table mapping a package name to a bare requirement (`">=3.0.0"`, `"*"`, `">= 1.0, < 2.0"`) or to
|
|
37
|
+
* one with its origin (`{ version = ..., git = ... }`), as uvr and rig write them. Anything else (an array such as
|
|
38
|
+
* rig's `include-groups`) names no package.
|
|
39
|
+
*/
|
|
40
|
+
function dependencyEntries(table) {
|
|
41
|
+
// an array is no such table, and its indices would pass as package names
|
|
42
|
+
if (!isTable(table)) {
|
|
43
|
+
return [];
|
|
44
|
+
}
|
|
45
|
+
return Object.entries(table).filter((e) => e[0].length > 0 && (typeof e[1] === 'string' || isTable(e[1])));
|
|
46
|
+
}
|
|
47
|
+
function isTable(value) {
|
|
48
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
49
|
+
}
|
|
50
|
+
function packageOf([name, spec]) {
|
|
51
|
+
const version = typeof spec === 'string' ? spec : spec.version;
|
|
52
|
+
// `*` accepts anything, so it constrains nothing
|
|
53
|
+
const range = typeof version === 'string' && version !== '*' ? package_1.Package.parsePkgVersionRange(undefined, version) : undefined;
|
|
54
|
+
return new package_1.Package({ name, type: 'package', versionConstraints: range ? [range] : undefined });
|
|
55
|
+
}
|
|
56
|
+
function packagesOf(table) {
|
|
57
|
+
return dependencyEntries(table).map(packageOf);
|
|
58
|
+
}
|
|
59
|
+
/** the packages of every table in `groups` (`[dependency-groups.dev]`, `[optional-dependencies.plot]`) */
|
|
60
|
+
function packagesOfGroups(groups) {
|
|
61
|
+
return isTable(groups) ? Object.values(groups).flatMap(packagesOf) : [];
|
|
62
|
+
}
|
|
26
63
|
/** The `rproject.toml` of an [rv](https://a2-ai.github.io/rv-docs/) project, lifted by {@link FlowrRProjectFile.from}. */
|
|
27
64
|
class FlowrRProjectFile extends FlowrManifestFile {
|
|
28
65
|
loadContent() {
|
|
@@ -69,34 +106,101 @@ class FlowrUvrManifestFile extends FlowrManifestFile {
|
|
|
69
106
|
}
|
|
70
107
|
/** uvr usually states a requirement (`>=4.0.0`), which pins nothing; the `uvr.lock` holds the resolved version */
|
|
71
108
|
rVersion() {
|
|
72
|
-
|
|
73
|
-
const trimmed = typeof version === 'string' ? version.trim() : '';
|
|
74
|
-
return /^\d/.test(trimmed) ? trimmed : undefined;
|
|
109
|
+
return pinnedVersion(this.content().project?.r_version);
|
|
75
110
|
}
|
|
76
111
|
declares() {
|
|
77
112
|
return {
|
|
78
|
-
imports:
|
|
79
|
-
suggests:
|
|
113
|
+
imports: packagesOf(this.content().dependencies),
|
|
114
|
+
suggests: packagesOf(this.content()['dev-dependencies'])
|
|
80
115
|
};
|
|
81
116
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
117
|
+
}
|
|
118
|
+
exports.FlowrUvrManifestFile = FlowrUvrManifestFile;
|
|
119
|
+
function rigRVersion(manifest) {
|
|
120
|
+
const deps = manifest.dependencies;
|
|
121
|
+
return isTable(deps) ? pinnedVersion(deps.R) : undefined;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Grouped as a `DESCRIPTION` groups them: `R` in `[dependencies]` is the requirement on R itself (`Depends`), an entry
|
|
125
|
+
* marked `enhances = true` is an `Enhances`, `[linking-dependencies]` is `LinkingTo`. Dependency groups and optional
|
|
126
|
+
* dependencies are reported but not needed to run the project, like `Suggests`.
|
|
127
|
+
*/
|
|
128
|
+
function rigDeclares(manifest) {
|
|
129
|
+
const deps = dependencyEntries(manifest.dependencies);
|
|
130
|
+
const enhances = (e) => typeof e[1] !== 'string' && e[1].enhances === true;
|
|
131
|
+
return {
|
|
132
|
+
depends: deps.filter(e => e[0] === 'R').map(packageOf),
|
|
133
|
+
imports: deps.filter(e => e[0] !== 'R' && !enhances(e)).map(packageOf),
|
|
134
|
+
enhances: deps.filter(enhances).map(packageOf),
|
|
135
|
+
linkingTo: packagesOf(manifest['linking-dependencies']),
|
|
136
|
+
suggests: [...packagesOfGroups(manifest['dependency-groups']), ...packagesOfGroups(manifest['optional-dependencies'])]
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
/** The `rproj.toml` of a [rig](https://rig.r-lib.org/proj-guide.html) project, lifted by {@link FlowrRigProjectFile.from}. */
|
|
140
|
+
class FlowrRigProjectFile extends FlowrManifestFile {
|
|
141
|
+
loadContent() {
|
|
142
|
+
return this.parseTomlContent();
|
|
143
|
+
}
|
|
144
|
+
projectName() {
|
|
145
|
+
const name = this.content().project?.name;
|
|
146
|
+
return typeof name === 'string' ? name : undefined;
|
|
147
|
+
}
|
|
148
|
+
rVersion() {
|
|
149
|
+
return rigRVersion(this.content());
|
|
150
|
+
}
|
|
151
|
+
declares() {
|
|
152
|
+
return rigDeclares(this.content());
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
exports.FlowrRigProjectFile = FlowrRigProjectFile;
|
|
156
|
+
/** the comment markers a rig script block may use, `##` first as `#` is its prefix */
|
|
157
|
+
const RigBlockMarkers = ['##', '#'];
|
|
158
|
+
/** the only tables a script block may hold, rig rejects the script for any other */
|
|
159
|
+
const RigScriptTables = new Set(['dependencies', 'repository', 'tool']);
|
|
160
|
+
/**
|
|
161
|
+
* The manifest a rig script states inline, read as rig reads it (`src/script_meta.rs` of rig): the one comment block
|
|
162
|
+
* opened by a line that is exactly `# /// script` (or `## /// script`), anywhere in the file, and closed by `# ///`
|
|
163
|
+
* with the same marker. Every line in between starts with that marker, and without it (and one space) the lines are
|
|
164
|
+
* TOML holding `[dependencies]`, `[[repository]]` and `[tool]`. As rig refuses to run the script otherwise, a second
|
|
165
|
+
* block, an unclosed block, a line without the marker, broken TOML or any other table declare nothing.
|
|
166
|
+
*/
|
|
167
|
+
function rigScriptManifest(code, origin) {
|
|
168
|
+
const lines = code.split('\n').map(l => l.replace(/\r$/, ''));
|
|
169
|
+
const opens = lines.flatMap((line, i) => {
|
|
170
|
+
const marker = RigBlockMarkers.find(m => line.trimEnd() === `${m} /// script`);
|
|
171
|
+
return marker === undefined ? [] : [{ i, marker }];
|
|
172
|
+
});
|
|
173
|
+
if (opens.length !== 1) {
|
|
174
|
+
return undefined;
|
|
175
|
+
}
|
|
176
|
+
const { i: start, marker } = opens[0];
|
|
177
|
+
const body = [];
|
|
178
|
+
for (const line of lines.slice(start + 1)) {
|
|
179
|
+
if (line.trimEnd() === `${marker} ///`) {
|
|
180
|
+
return rigScriptOf(body.join('\n'), origin);
|
|
87
181
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
if (name.length === 0) {
|
|
91
|
-
continue;
|
|
92
|
-
}
|
|
93
|
-
const version = typeof spec === 'string' ? spec : spec?.version;
|
|
94
|
-
// `*` accepts anything, so it constrains nothing
|
|
95
|
-
const range = typeof version === 'string' && version !== '*' ? package_1.Package.parsePkgVersionRange(undefined, version) : undefined;
|
|
96
|
-
out.push(new package_1.Package({ name, type: 'package', versionConstraints: range ? [range] : undefined }));
|
|
182
|
+
if (!line.startsWith(marker)) {
|
|
183
|
+
return undefined;
|
|
97
184
|
}
|
|
98
|
-
|
|
185
|
+
const rest = line.slice(marker.length);
|
|
186
|
+
body.push(rest.startsWith(' ') ? rest.slice(1) : rest);
|
|
99
187
|
}
|
|
188
|
+
return undefined;
|
|
189
|
+
}
|
|
190
|
+
function rigScriptOf(toml, origin) {
|
|
191
|
+
let parsed;
|
|
192
|
+
try {
|
|
193
|
+
parsed = (0, smol_toml_1.parse)(toml);
|
|
194
|
+
}
|
|
195
|
+
catch (e) {
|
|
196
|
+
exports.manifestFileLog.warn(`Could not parse the rig script block of ${origin}: ${e.message}`);
|
|
197
|
+
return undefined;
|
|
198
|
+
}
|
|
199
|
+
if (Object.keys(parsed).some(k => !RigScriptTables.has(k))) {
|
|
200
|
+
exports.manifestFileLog.warn(`The rig script block of ${origin} holds a table rig does not allow, rig would not run it`);
|
|
201
|
+
return undefined;
|
|
202
|
+
}
|
|
203
|
+
const manifest = { dependencies: parsed.dependencies };
|
|
204
|
+
return { projectName: () => undefined, rVersion: () => rigRVersion(manifest), declares: () => rigDeclares(manifest) };
|
|
100
205
|
}
|
|
101
|
-
exports.FlowrUvrManifestFile = FlowrUvrManifestFile;
|
|
102
206
|
//# sourceMappingURL=flowr-manifest-files.js.map
|
|
@@ -77,7 +77,7 @@ class FlowrRMarkdownFile extends flowr_file_1.FlowrFile {
|
|
|
77
77
|
ctx: this.context,
|
|
78
78
|
referenceChain: [this.path()]
|
|
79
79
|
});
|
|
80
|
-
if (childPath === undefined) {
|
|
80
|
+
if (childPath === undefined || childPath.length === 0) {
|
|
81
81
|
continue;
|
|
82
82
|
}
|
|
83
83
|
if (childPath.length > 1) {
|
|
@@ -23,4 +23,11 @@ export declare class FlowrAnalyzerUvrManifestFilePlugin extends FlowrAnalyzerMan
|
|
|
23
23
|
constructor(pathPattern?: RegExp);
|
|
24
24
|
process(_ctx: FlowrAnalyzerContext, file: FlowrFileProvider): [FlowrFileProvider, true];
|
|
25
25
|
}
|
|
26
|
+
/** Lifts a rig `rproj.toml` to a {@link FlowrRigProjectFile}. */
|
|
27
|
+
export declare class FlowrAnalyzerRigProjectFilePlugin extends FlowrAnalyzerManifestFilePlugin {
|
|
28
|
+
readonly name = "flowr-analyzer-rig-project-file-plugin";
|
|
29
|
+
readonly description = "Marks the rproj.toml manifest of a rig project.";
|
|
30
|
+
constructor(pathPattern?: RegExp);
|
|
31
|
+
process(_ctx: FlowrAnalyzerContext, file: FlowrFileProvider): [FlowrFileProvider, true];
|
|
32
|
+
}
|
|
26
33
|
export {};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FlowrAnalyzerUvrManifestFilePlugin = exports.FlowrAnalyzerRProjectFilePlugin = void 0;
|
|
3
|
+
exports.FlowrAnalyzerRigProjectFilePlugin = exports.FlowrAnalyzerUvrManifestFilePlugin = exports.FlowrAnalyzerRProjectFilePlugin = void 0;
|
|
4
4
|
const flowr_analyzer_file_plugin_1 = require("./flowr-analyzer-file-plugin");
|
|
5
5
|
const semver_1 = require("semver");
|
|
6
6
|
const flowr_file_1 = require("../../context/flowr-file");
|
|
7
7
|
const flowr_manifest_files_1 = require("./files/flowr-manifest-files");
|
|
8
8
|
const RProjectFilePattern = /^rproject\.toml$/i;
|
|
9
9
|
const UvrManifestFilePattern = /^uvr\.toml$/i;
|
|
10
|
+
const RigProjectFilePattern = /^rproj\.toml$/i;
|
|
10
11
|
/**
|
|
11
12
|
* Tags a project manifest with the {@link FileRole.Manifest} role and lifts it, so the meta plugins reading it
|
|
12
13
|
* can look it up by role.
|
|
@@ -38,4 +39,16 @@ class FlowrAnalyzerUvrManifestFilePlugin extends FlowrAnalyzerManifestFilePlugin
|
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
41
|
exports.FlowrAnalyzerUvrManifestFilePlugin = FlowrAnalyzerUvrManifestFilePlugin;
|
|
42
|
+
/** Lifts a rig `rproj.toml` to a {@link FlowrRigProjectFile}. */
|
|
43
|
+
class FlowrAnalyzerRigProjectFilePlugin extends FlowrAnalyzerManifestFilePlugin {
|
|
44
|
+
name = 'flowr-analyzer-rig-project-file-plugin';
|
|
45
|
+
description = 'Marks the rproj.toml manifest of a rig project.';
|
|
46
|
+
constructor(pathPattern = RigProjectFilePattern) {
|
|
47
|
+
super(pathPattern);
|
|
48
|
+
}
|
|
49
|
+
process(_ctx, file) {
|
|
50
|
+
return [flowr_manifest_files_1.FlowrRigProjectFile.from(file, flowr_file_1.FileRole.Manifest), true];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.FlowrAnalyzerRigProjectFilePlugin = FlowrAnalyzerRigProjectFilePlugin;
|
|
41
54
|
//# sourceMappingURL=flowr-analyzer-manifest-file-plugin.js.map
|
|
@@ -7,7 +7,7 @@ import { FileRole } from '../../context/flowr-file';
|
|
|
7
7
|
*/
|
|
8
8
|
export declare class FlowrAnalyzerVirtualEnvFilePlugin extends FlowrAnalyzerRoleFilePlugin {
|
|
9
9
|
readonly name = "flowr-analyzer-virtualenv-files-plugin";
|
|
10
|
-
readonly description = "Marks virtual-environment lockfiles (renv.lock, rv.lock, uvr.lock).";
|
|
10
|
+
readonly description = "Marks virtual-environment lockfiles (renv.lock, rv.lock, uvr.lock, packrat.lock, rig lockfiles).";
|
|
11
11
|
readonly version: SemVer;
|
|
12
12
|
protected readonly roles: FileRole[];
|
|
13
13
|
/**
|
|
@@ -4,15 +4,15 @@ exports.FlowrAnalyzerVirtualEnvFilePlugin = void 0;
|
|
|
4
4
|
const flowr_analyzer_file_plugin_1 = require("./flowr-analyzer-file-plugin");
|
|
5
5
|
const semver_1 = require("semver");
|
|
6
6
|
const flowr_file_1 = require("../../context/flowr-file");
|
|
7
|
-
/** Lockfiles pinning a project's package environment (`renv.lock`, `rv.lock`, `uvr.lock`, `packrat.lock`). */
|
|
8
|
-
const VirtualEnvFilePattern = /^(renv|rv|uvr|packrat)\.lock$/i;
|
|
7
|
+
/** Lockfiles pinning a project's package environment (`renv.lock`, `rv.lock`, `uvr.lock`, `packrat.lock`, rig's `rproj.lock` and `<script>.R.lock`). */
|
|
8
|
+
const VirtualEnvFilePattern = /^(renv|rv|uvr|packrat|rproj|.+\.r)\.lock$/i;
|
|
9
9
|
/**
|
|
10
10
|
* Tags a project's virtual-environment lockfiles with the {@link FileRole.VirtualEnv} role, so the version
|
|
11
11
|
* plugins that read them can look them up by role instead of scanning every project file.
|
|
12
12
|
*/
|
|
13
13
|
class FlowrAnalyzerVirtualEnvFilePlugin extends flowr_analyzer_file_plugin_1.FlowrAnalyzerRoleFilePlugin {
|
|
14
14
|
name = 'flowr-analyzer-virtualenv-files-plugin';
|
|
15
|
-
description = 'Marks virtual-environment lockfiles (renv.lock, rv.lock, uvr.lock).';
|
|
15
|
+
description = 'Marks virtual-environment lockfiles (renv.lock, rv.lock, uvr.lock, packrat.lock, rig lockfiles).';
|
|
16
16
|
version = new semver_1.SemVer('0.1.0');
|
|
17
17
|
roles = [flowr_file_1.FileRole.VirtualEnv];
|
|
18
18
|
/**
|
package/project/plugins/package-version-plugins/flowr-analyzer-meta-manifest-file-plugin.d.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { FlowrAnalyzerPackageVersionsPlugin } from './flowr-analyzer-package-versions-plugin';
|
|
2
2
|
import { SemVer } from 'semver';
|
|
3
3
|
import type { FlowrAnalyzerContext } from '../../context/flowr-analyzer-context';
|
|
4
|
-
import { FlowrRProjectFile, FlowrUvrManifestFile } from '../file-plugins/files/flowr-manifest-files';
|
|
5
|
-
/**
|
|
6
|
-
* Extracts the project metadata and the declared dependencies from a project manifest. The name is contributed
|
|
7
|
-
* without a namespace: such a project is no package, so `a::b` must not resolve against it.
|
|
8
|
-
*/
|
|
4
|
+
import { FlowrRigProjectFile, FlowrRProjectFile, FlowrUvrManifestFile } from '../file-plugins/files/flowr-manifest-files';
|
|
5
|
+
/** Extracts the project metadata and the declared dependencies from a project manifest. */
|
|
9
6
|
declare abstract class FlowrAnalyzerMetaManifestFilePlugin extends FlowrAnalyzerPackageVersionsPlugin {
|
|
10
7
|
readonly version: SemVer;
|
|
11
8
|
/** the manifest flavor this plugin reads, the others are left to their own plugin */
|
|
@@ -24,4 +21,20 @@ export declare class FlowrAnalyzerMetaUvrManifestFilePlugin extends FlowrAnalyze
|
|
|
24
21
|
readonly description = "Extracts project meta information and dependencies from a uvr.toml.";
|
|
25
22
|
protected readonly reads: typeof FlowrUvrManifestFile;
|
|
26
23
|
}
|
|
24
|
+
/** Reads a rig `rproj.toml`, whose dependency groups and optional dependencies land in `suggests`. */
|
|
25
|
+
export declare class FlowrAnalyzerMetaRigProjectFilePlugin extends FlowrAnalyzerMetaManifestFilePlugin {
|
|
26
|
+
readonly name = "flowr-analyzer-meta-rig-project-file-plugin";
|
|
27
|
+
readonly description = "Extracts project meta information and dependencies from a rig rproj.toml.";
|
|
28
|
+
protected readonly reads: typeof FlowrRigProjectFile;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Reads the inline `# /// script` block a rig script states its dependencies in (see {@link rigScriptManifest}),
|
|
32
|
+
* in R scripts and notebooks alike, as the code of a notebook is what its top is checked for.
|
|
33
|
+
*/
|
|
34
|
+
export declare class FlowrAnalyzerMetaRigScriptPlugin extends FlowrAnalyzerPackageVersionsPlugin {
|
|
35
|
+
readonly name = "flowr-analyzer-meta-rig-script-plugin";
|
|
36
|
+
readonly description = "Extracts the dependencies a rig script declares in its inline # /// script block.";
|
|
37
|
+
readonly version: SemVer;
|
|
38
|
+
process(ctx: FlowrAnalyzerContext): void;
|
|
39
|
+
}
|
|
27
40
|
export {};
|
|
@@ -1,31 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FlowrAnalyzerMetaUvrManifestFilePlugin = exports.FlowrAnalyzerMetaRProjectFilePlugin = void 0;
|
|
3
|
+
exports.FlowrAnalyzerMetaRigScriptPlugin = exports.FlowrAnalyzerMetaRigProjectFilePlugin = exports.FlowrAnalyzerMetaUvrManifestFilePlugin = exports.FlowrAnalyzerMetaRProjectFilePlugin = void 0;
|
|
4
4
|
const flowr_analyzer_package_versions_plugin_1 = require("./flowr-analyzer-package-versions-plugin");
|
|
5
5
|
const semver_1 = require("semver");
|
|
6
6
|
const flowr_file_1 = require("../../context/flowr-file");
|
|
7
7
|
const flowr_analyzer_meta_context_1 = require("../../context/flowr-analyzer-meta-context");
|
|
8
8
|
const flowr_manifest_files_1 = require("../file-plugins/files/flowr-manifest-files");
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
* without a namespace
|
|
10
|
+
* Contributes what a manifest declares: its metadata, and the packages needed to run the project. The name is
|
|
11
|
+
* contributed without a namespace, such a project is no package, so `a::b` must not resolve against it.
|
|
12
12
|
*/
|
|
13
|
+
function contributeManifest(ctx, manifest) {
|
|
14
|
+
const declares = manifest.declares();
|
|
15
|
+
ctx.meta.contribute({
|
|
16
|
+
name: manifest.projectName(),
|
|
17
|
+
rVersion: manifest.rVersion(),
|
|
18
|
+
declares
|
|
19
|
+
}, flowr_analyzer_meta_context_1.MetaPriority.Manifest);
|
|
20
|
+
// like a `DESCRIPTION` `Suggests`, anything but the imports (and depends) is reported but not needed to run the project
|
|
21
|
+
for (const pkg of [...declares.depends ?? [], ...declares.imports ?? []]) {
|
|
22
|
+
ctx.deps.addDeclaredDependency(pkg);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/** Extracts the project metadata and the declared dependencies from a project manifest. */
|
|
13
26
|
class FlowrAnalyzerMetaManifestFilePlugin extends flowr_analyzer_package_versions_plugin_1.FlowrAnalyzerPackageVersionsPlugin {
|
|
14
27
|
version = new semver_1.SemVer('0.1.0');
|
|
15
28
|
process(ctx) {
|
|
16
29
|
for (const file of ctx.files.getFilesByRole(flowr_file_1.FileRole.Manifest)) {
|
|
17
|
-
if (
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
const declares = file.declares();
|
|
21
|
-
ctx.meta.contribute({
|
|
22
|
-
name: file.projectName(),
|
|
23
|
-
rVersion: file.rVersion(),
|
|
24
|
-
declares
|
|
25
|
-
}, flowr_analyzer_meta_context_1.MetaPriority.Manifest);
|
|
26
|
-
// like a `DESCRIPTION` `Suggests`, anything but the imports is reported but not needed to run the project
|
|
27
|
-
for (const pkg of declares.imports ?? []) {
|
|
28
|
-
ctx.deps.addDeclaredDependency(pkg);
|
|
30
|
+
if (file instanceof this.reads) {
|
|
31
|
+
contributeManifest(ctx, file);
|
|
29
32
|
}
|
|
30
33
|
}
|
|
31
34
|
}
|
|
@@ -44,4 +47,29 @@ class FlowrAnalyzerMetaUvrManifestFilePlugin extends FlowrAnalyzerMetaManifestFi
|
|
|
44
47
|
reads = flowr_manifest_files_1.FlowrUvrManifestFile;
|
|
45
48
|
}
|
|
46
49
|
exports.FlowrAnalyzerMetaUvrManifestFilePlugin = FlowrAnalyzerMetaUvrManifestFilePlugin;
|
|
50
|
+
/** Reads a rig `rproj.toml`, whose dependency groups and optional dependencies land in `suggests`. */
|
|
51
|
+
class FlowrAnalyzerMetaRigProjectFilePlugin extends FlowrAnalyzerMetaManifestFilePlugin {
|
|
52
|
+
name = 'flowr-analyzer-meta-rig-project-file-plugin';
|
|
53
|
+
description = 'Extracts project meta information and dependencies from a rig rproj.toml.';
|
|
54
|
+
reads = flowr_manifest_files_1.FlowrRigProjectFile;
|
|
55
|
+
}
|
|
56
|
+
exports.FlowrAnalyzerMetaRigProjectFilePlugin = FlowrAnalyzerMetaRigProjectFilePlugin;
|
|
57
|
+
/**
|
|
58
|
+
* Reads the inline `# /// script` block a rig script states its dependencies in (see {@link rigScriptManifest}),
|
|
59
|
+
* in R scripts and notebooks alike, as the code of a notebook is what its top is checked for.
|
|
60
|
+
*/
|
|
61
|
+
class FlowrAnalyzerMetaRigScriptPlugin extends flowr_analyzer_package_versions_plugin_1.FlowrAnalyzerPackageVersionsPlugin {
|
|
62
|
+
name = 'flowr-analyzer-meta-rig-script-plugin';
|
|
63
|
+
description = 'Extracts the dependencies a rig script declares in its inline # /// script block.';
|
|
64
|
+
version = new semver_1.SemVer('0.1.0');
|
|
65
|
+
process(ctx) {
|
|
66
|
+
for (const file of ctx.files.getFilesByRole(flowr_file_1.FileRole.Source)) {
|
|
67
|
+
const manifest = (0, flowr_manifest_files_1.rigScriptManifest)(file.content().toString(), file.path());
|
|
68
|
+
if (manifest !== undefined) {
|
|
69
|
+
contributeManifest(ctx, manifest);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.FlowrAnalyzerMetaRigScriptPlugin = FlowrAnalyzerMetaRigScriptPlugin;
|
|
47
75
|
//# sourceMappingURL=flowr-analyzer-meta-manifest-file-plugin.js.map
|