@eagleoutice/flowr 2.13.4 → 2.13.6
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 +29 -29
- package/cli/repl/core.js +10 -2
- package/config.d.ts +4 -1
- package/config.js +10 -1
- package/control-flow/cfg-dead-code.js +19 -4
- package/control-flow/extract-cfg.js +12 -4
- package/dataflow/environments/built-in-config.d.ts +6 -3
- package/dataflow/environments/built-in-eval-name.d.ts +20 -0
- package/dataflow/environments/built-in-eval-name.js +25 -0
- package/dataflow/environments/built-in-props.d.ts +175 -0
- package/dataflow/environments/built-in-props.js +207 -0
- package/dataflow/environments/built-in.d.ts +26 -22
- package/dataflow/environments/built-in.js +37 -10
- package/dataflow/environments/default-builtin-config.d.ts +1068 -95
- package/dataflow/environments/default-builtin-config.js +549 -216
- package/dataflow/environments/identifier.d.ts +24 -1
- package/dataflow/environments/identifier.js +24 -2
- package/dataflow/environments/query-fn-props.d.ts +102 -0
- package/dataflow/environments/query-fn-props.js +188 -0
- package/dataflow/eval/resolve/alias-tracking.d.ts +6 -5
- package/dataflow/eval/resolve/alias-tracking.js +45 -12
- package/dataflow/eval/resolve/match-arguments.d.ts +15 -0
- package/dataflow/eval/resolve/match-arguments.js +77 -0
- package/dataflow/eval/resolve/resolve-numbers.d.ts +202 -0
- package/dataflow/eval/resolve/resolve-numbers.js +163 -0
- package/dataflow/eval/resolve/resolve-operators.d.ts +60 -0
- package/dataflow/eval/resolve/resolve-operators.js +115 -0
- package/dataflow/eval/resolve/resolve-strings.d.ts +98 -0
- package/dataflow/eval/resolve/resolve-strings.js +116 -0
- package/dataflow/eval/resolve/resolve.d.ts +5 -37
- package/dataflow/eval/resolve/resolve.js +56 -134
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +5 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +1 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +1 -1
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +2 -1
- package/dataflow/internal/process/functions/call/known-call-handling.js +2 -1
- package/documentation/data/faq/faqs.js +11 -0
- package/documentation/doc-util/doc-types.js +1 -1
- package/documentation/wiki-analyzer.js +75 -0
- package/documentation/wiki-core.js +81 -16
- package/documentation/wiki-interface.js +3 -0
- package/linter/linter-rules.d.ts +10 -11
- package/linter/rules/deprecated-functions.js +5 -3
- package/linter/rules/function-finder-util.d.ts +2 -2
- package/linter/rules/function-finder-util.js +10 -3
- package/linter/rules/network-functions.d.ts +25 -5
- package/linter/rules/network-functions.js +51 -11
- package/linter/rules/problematic-inputs.d.ts +1 -1
- package/linter/rules/problematic-inputs.js +7 -1
- package/linter/rules/seeded-randomness.d.ts +5 -8
- package/linter/rules/seeded-randomness.js +18 -10
- package/linter/rules/unused-definition.js +29 -17
- package/package.json +4 -2
- package/project/cache/flowr-analyzer-cache.d.ts +4 -3
- package/project/cache/flowr-analyzer-cache.js +32 -13
- package/project/cache/flowr-cache.d.ts +39 -12
- package/project/cache/flowr-cache.js +5 -3
- package/project/context/flowr-analyzer-context.d.ts +8 -1
- package/project/context/flowr-analyzer-context.js +11 -1
- package/project/context/flowr-analyzer-dependencies-context.d.ts +8 -2
- package/project/context/flowr-analyzer-dependencies-context.js +43 -11
- package/project/context/flowr-analyzer-files-context.d.ts +8 -4
- package/project/context/flowr-analyzer-files-context.js +20 -1
- package/project/context/flowr-analyzer-incremental-analysis-context.d.ts +33 -0
- package/project/context/flowr-analyzer-incremental-analysis-context.js +63 -0
- package/project/context/flowr-analyzer-meta-context.d.ts +3 -1
- package/project/context/flowr-analyzer-meta-context.js +14 -0
- package/project/context/flowr-file.d.ts +25 -3
- package/project/context/flowr-file.js +24 -2
- package/project/dependency-version-space.d.ts +37 -0
- package/project/dependency-version-space.js +118 -26
- package/project/flowr-analyzer.d.ts +6 -0
- package/project/flowr-analyzer.js +6 -2
- package/project/incremental/incremental-parse/edit-computation.d.ts +7 -0
- package/project/incremental/incremental-parse/edit-computation.js +61 -0
- package/project/incremental/incremental-parse/incremental-parse.d.ts +12 -0
- package/project/incremental/incremental-parse/incremental-parse.js +37 -0
- package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +1 -1
- package/project/plugins/file-plugins/files/flowr-manifest-files.d.ts +57 -0
- package/project/plugins/file-plugins/files/flowr-manifest-files.js +121 -0
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +2 -2
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +2 -2
- package/project/plugins/file-plugins/files/flowr-sweave-file.d.ts +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-manifest-file-plugin.d.ts +33 -0
- package/project/plugins/file-plugins/flowr-analyzer-manifest-file-plugin.js +53 -0
- 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 +27 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-manifest-file-plugin.js +47 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.d.ts +7 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js +31 -3
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +10 -4
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +17 -4
- package/project/plugins/plugin-registry.d.ts +4 -4
- package/project/plugins/plugin-registry.js +7 -4
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +4 -4
- package/project/sigdb/reader.d.ts +7 -0
- package/project/sigdb/reader.js +12 -0
- package/queries/catalog/dependencies-query/function-info/derived-functions.d.ts +10 -0
- package/queries/catalog/dependencies-query/function-info/derived-functions.js +41 -0
- package/queries/catalog/dependencies-query/function-info/read-functions.js +13 -12
- package/queries/catalog/dependencies-query/function-info/write-functions.js +16 -23
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +33 -3
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +31 -0
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +9 -2
- package/queries/catalog/input-sources-query/input-source-functions.d.ts +8 -10
- package/queries/catalog/input-sources-query/input-source-functions.js +23 -388
- package/queries/catalog/input-sources-query/input-sources-query-format.d.ts +7 -0
- package/queries/catalog/input-sources-query/input-sources-query-format.js +27 -10
- package/queries/catalog/signature-query/signature-query-executor.d.ts +2 -1
- package/queries/catalog/signature-query/signature-query-executor.js +79 -3
- package/queries/catalog/signature-query/signature-query-format.d.ts +27 -0
- package/queries/catalog/signature-query/signature-query-render.js +21 -3
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.d.ts +6 -2
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +21 -2
- package/r-bridge/parser.d.ts +11 -1
- package/r-bridge/parser.js +7 -4
- package/r-bridge/shell-executor.d.ts +1 -0
- package/r-bridge/shell-executor.js +1 -0
- package/r-bridge/shell.d.ts +1 -0
- package/r-bridge/shell.js +1 -0
- package/search/flowr-search-filters.d.ts +1 -6
- package/search/flowr-search-filters.js +1 -8
- package/search/search-executor/search-enrichers.d.ts +2 -0
- package/search/search-executor/search-enrichers.js +29 -12
- package/util/version.js +1 -1
- package/project/plugins/file-plugins/files/flowr-rproject-file.d.ts +0 -31
- package/project/plugins/file-plugins/files/flowr-rproject-file.js +0 -66
- package/project/plugins/file-plugins/flowr-analyzer-rproject-file-plugin.d.ts +0 -22
- package/project/plugins/file-plugins/flowr-analyzer-rproject-file-plugin.js +0 -36
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-rproject-file-plugin.d.ts +0 -13
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-rproject-file-plugin.js +0 -32
|
@@ -55,6 +55,10 @@ class FlowrAnalyzer {
|
|
|
55
55
|
this.ctx.reset();
|
|
56
56
|
this.cache.reset();
|
|
57
57
|
}
|
|
58
|
+
receive(event) {
|
|
59
|
+
this.ctx.receive(event);
|
|
60
|
+
this.cache.receive(event);
|
|
61
|
+
}
|
|
58
62
|
updateConfig(update) {
|
|
59
63
|
this.ctx.updateConfig(update);
|
|
60
64
|
// the parse/dataflow results were computed under the previous config, so they must be recomputed
|
|
@@ -67,11 +71,11 @@ class FlowrAnalyzer {
|
|
|
67
71
|
parseStandalone(data) {
|
|
68
72
|
const request = (0, retriever_1.isParseRequest)(data) ? data : (0, retriever_1.requestFromInput)(data);
|
|
69
73
|
if (this.parser.name === 'tree-sitter') {
|
|
70
|
-
return this.parser.parse(request);
|
|
74
|
+
return this.parser.parse(request, this.ctx);
|
|
71
75
|
}
|
|
72
76
|
else {
|
|
73
77
|
const ts = new tree_sitter_executor_1.TreeSitterExecutor();
|
|
74
|
-
return ts.parse(request);
|
|
78
|
+
return ts.parse(request, this.ctx);
|
|
75
79
|
}
|
|
76
80
|
}
|
|
77
81
|
normalizeStandalone(data) {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type Parser from 'web-tree-sitter';
|
|
2
|
+
/**
|
|
3
|
+
* Computes a single minimal change region ({@link Parser.Edit}) that contains all modifications.
|
|
4
|
+
* @param oldContent - The original content.
|
|
5
|
+
* @param newContent - The changed content.
|
|
6
|
+
*/
|
|
7
|
+
export declare function computeEditRegion(oldContent: string, newContent: string): Parser.Edit;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.computeEditRegion = computeEditRegion;
|
|
4
|
+
/**
|
|
5
|
+
* Computes a single minimal change region ({@link Parser.Edit}) that contains all modifications.
|
|
6
|
+
* @param oldContent - The original content.
|
|
7
|
+
* @param newContent - The changed content.
|
|
8
|
+
*/
|
|
9
|
+
function computeEditRegion(oldContent, newContent) {
|
|
10
|
+
const oldLen = oldContent.length;
|
|
11
|
+
const newLen = newContent.length;
|
|
12
|
+
// 1) Longest common prefix
|
|
13
|
+
let startIndex = 0;
|
|
14
|
+
while (startIndex < oldLen &&
|
|
15
|
+
startIndex < newLen &&
|
|
16
|
+
oldContent[startIndex] === newContent[startIndex]) {
|
|
17
|
+
startIndex++;
|
|
18
|
+
}
|
|
19
|
+
// 2) Longest common suffix, without overlapping the prefix
|
|
20
|
+
let oldSuffixIndex = oldLen;
|
|
21
|
+
let newSuffixIndex = newLen;
|
|
22
|
+
while (oldSuffixIndex > startIndex &&
|
|
23
|
+
newSuffixIndex > startIndex &&
|
|
24
|
+
oldContent[oldSuffixIndex - 1] === newContent[newSuffixIndex - 1]) {
|
|
25
|
+
oldSuffixIndex--;
|
|
26
|
+
newSuffixIndex--;
|
|
27
|
+
}
|
|
28
|
+
const oldEndIndex = oldSuffixIndex;
|
|
29
|
+
const newEndIndex = newSuffixIndex;
|
|
30
|
+
const [startPosition, oldEndPosition] = indexesToPoints(oldContent, [startIndex, oldEndIndex]);
|
|
31
|
+
const [newEndPosition] = indexesToPoints(newContent, [newEndIndex]);
|
|
32
|
+
return {
|
|
33
|
+
startIndex,
|
|
34
|
+
oldEndIndex,
|
|
35
|
+
newEndIndex,
|
|
36
|
+
startPosition,
|
|
37
|
+
oldEndPosition,
|
|
38
|
+
newEndPosition,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function indexesToPoints(text, orderedIndexes) {
|
|
42
|
+
let row = 0;
|
|
43
|
+
let column = 0;
|
|
44
|
+
let currentIndex = 0;
|
|
45
|
+
const points = [];
|
|
46
|
+
for (const targetIndex of orderedIndexes) {
|
|
47
|
+
while (currentIndex < targetIndex) {
|
|
48
|
+
if (text[currentIndex] === '\n') {
|
|
49
|
+
row++;
|
|
50
|
+
column = 0;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
column++;
|
|
54
|
+
}
|
|
55
|
+
currentIndex++;
|
|
56
|
+
}
|
|
57
|
+
points.push({ row, column });
|
|
58
|
+
}
|
|
59
|
+
return points;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=edit-computation.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { FlowrAnalyzerContext } from '../../context/flowr-analyzer-context';
|
|
2
|
+
import type Parser from 'web-tree-sitter';
|
|
3
|
+
import type { FilePath } from '../../context/flowr-file';
|
|
4
|
+
export interface ReparseInfo {
|
|
5
|
+
readonly previousTree: Parser.Tree;
|
|
6
|
+
readonly editRegion: Parser.Edit | undefined;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Computes the information needed to reparse a file incrementally with tree-sitter.
|
|
10
|
+
* Returns `undefined` if incremental reparsing is not possible.
|
|
11
|
+
*/
|
|
12
|
+
export declare function computeReparseInfo(ctx: FlowrAnalyzerContext, filePath: FilePath): ReparseInfo | undefined;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.computeReparseInfo = computeReparseInfo;
|
|
4
|
+
const edit_computation_1 = require("./edit-computation");
|
|
5
|
+
/**
|
|
6
|
+
* Computes the information needed to reparse a file incrementally with tree-sitter.
|
|
7
|
+
* Returns `undefined` if incremental reparsing is not possible.
|
|
8
|
+
*/
|
|
9
|
+
function computeReparseInfo(ctx, filePath) {
|
|
10
|
+
const previousTree = ctx.inc.getOldParseResultOf(filePath);
|
|
11
|
+
if (!previousTree) {
|
|
12
|
+
// this file was not parsed before
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
const oldContent = ctx.inc.getOldContentOf(filePath);
|
|
16
|
+
if (oldContent === undefined) {
|
|
17
|
+
// this file has not been invalidated since the last parse, no reparse needed
|
|
18
|
+
return {
|
|
19
|
+
previousTree,
|
|
20
|
+
editRegion: undefined
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
const newContent = ctx.files.resolveRequest({ request: 'file', content: filePath }).r.content;
|
|
24
|
+
if (newContent === oldContent) {
|
|
25
|
+
// this file was invalidated, but the content did not change, no reparse needed
|
|
26
|
+
return {
|
|
27
|
+
previousTree,
|
|
28
|
+
editRegion: undefined
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const editRegion = (0, edit_computation_1.computeEditRegion)(oldContent, newContent);
|
|
32
|
+
return {
|
|
33
|
+
previousTree,
|
|
34
|
+
editRegion
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=incremental-parse.js.map
|
|
@@ -4,7 +4,7 @@ import { FlowrFile } from '../../../context/flowr-file';
|
|
|
4
4
|
* This decorates a text file and parses its contents as a Jupyter file.
|
|
5
5
|
* Finnaly, it provides access to the single cells, and all cells fused together as one R file.
|
|
6
6
|
*/
|
|
7
|
-
export declare class FlowrJupyterFile extends FlowrFile
|
|
7
|
+
export declare class FlowrJupyterFile extends FlowrFile {
|
|
8
8
|
private readonly wrapped;
|
|
9
9
|
/**
|
|
10
10
|
* Prefer the static {@link FlowrRMarkdownFile.from} method
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { type FlowrFileProvider, type FileRole, type StringableContent, FlowrFile } from '../../../context/flowr-file';
|
|
2
|
+
import type { DeepReadonly } from 'ts-essentials';
|
|
3
|
+
import type { DeclaredPackages } from '../../../context/flowr-analyzer-meta-context';
|
|
4
|
+
import { Package } from '../../package-version-plugins/package';
|
|
5
|
+
export declare const manifestFileLog: import("tslog").Logger<import("tslog").ILogObj>;
|
|
6
|
+
/** A project manifest that is no `DESCRIPTION` (an rv `rproject.toml`, a uvr `uvr.toml`). */
|
|
7
|
+
export declare abstract class FlowrManifestFile<Content extends StringableContent = StringableContent> extends FlowrFile<Content> {
|
|
8
|
+
protected readonly wrapped: FlowrFileProvider;
|
|
9
|
+
constructor(file: FlowrFileProvider);
|
|
10
|
+
/** unlike the `Package` of a `DESCRIPTION` this is no namespace, such a project is no package */
|
|
11
|
+
abstract projectName(): string | undefined;
|
|
12
|
+
/** `undefined` if the manifest only states a requirement like `>=4.0.0` */
|
|
13
|
+
abstract rVersion(): string | undefined;
|
|
14
|
+
/** grouped as a `DESCRIPTION` groups them */
|
|
15
|
+
abstract declares(): DeclaredPackages;
|
|
16
|
+
}
|
|
17
|
+
/** the `[project]` table of an `rproject.toml`, see https://a2-ai.github.io/rv-docs/config/ */
|
|
18
|
+
interface RvProject {
|
|
19
|
+
name?: unknown;
|
|
20
|
+
r_version?: unknown;
|
|
21
|
+
dependencies?: unknown;
|
|
22
|
+
}
|
|
23
|
+
/** The `rproject.toml` of an [rv](https://a2-ai.github.io/rv-docs/) project, lifted by {@link FlowrRProjectFile.from}. */
|
|
24
|
+
export declare class FlowrRProjectFile extends FlowrManifestFile<DeepReadonly<RvProject>> {
|
|
25
|
+
protected loadContent(): RvProject;
|
|
26
|
+
/** rproject lifter, this does not re-create if already an rproject file */
|
|
27
|
+
static from(file: FlowrFileProvider | FlowrRProjectFile, role?: FileRole): FlowrRProjectFile;
|
|
28
|
+
projectName(): string | undefined;
|
|
29
|
+
/** rv pins a concrete `r_version`, e.g. `4.5` */
|
|
30
|
+
rVersion(): string | undefined;
|
|
31
|
+
/** either a plain name or a table carrying it (`{ name = "ggplot2", repository = "new-rspm" }`) */
|
|
32
|
+
dependencies(): Package[];
|
|
33
|
+
/** rv does not group its dependencies, they are all needed to run the project */
|
|
34
|
+
declares(): DeclaredPackages;
|
|
35
|
+
}
|
|
36
|
+
/** the parts of a `uvr.toml` we read, see https://github.com/nbafrank/uvr */
|
|
37
|
+
interface UvrManifest {
|
|
38
|
+
project?: {
|
|
39
|
+
name?: unknown;
|
|
40
|
+
r_version?: unknown;
|
|
41
|
+
};
|
|
42
|
+
dependencies?: unknown;
|
|
43
|
+
'dev-dependencies'?: unknown;
|
|
44
|
+
}
|
|
45
|
+
/** The `uvr.toml` of a [uvr](https://github.com/nbafrank/uvr) project, lifted by {@link FlowrUvrManifestFile.from}. */
|
|
46
|
+
export declare class FlowrUvrManifestFile extends FlowrManifestFile<DeepReadonly<UvrManifest>> {
|
|
47
|
+
protected loadContent(): UvrManifest;
|
|
48
|
+
/** uvr manifest lifter, this does not re-create if already a uvr manifest file */
|
|
49
|
+
static from(file: FlowrFileProvider | FlowrUvrManifestFile, role?: FileRole): FlowrUvrManifestFile;
|
|
50
|
+
projectName(): string | undefined;
|
|
51
|
+
/** uvr usually states a requirement (`>=4.0.0`), which pins nothing; the `uvr.lock` holds the resolved version */
|
|
52
|
+
rVersion(): string | undefined;
|
|
53
|
+
declares(): DeclaredPackages;
|
|
54
|
+
/** a table mapping the name to a bare requirement (`">=3.0.0"`, `"*"`) or to one with its origin (`{ version = ..., git = ... }`) */
|
|
55
|
+
private packagesOf;
|
|
56
|
+
}
|
|
57
|
+
export {};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FlowrUvrManifestFile = exports.FlowrRProjectFile = exports.FlowrManifestFile = exports.manifestFileLog = void 0;
|
|
4
|
+
const flowr_file_1 = require("../../../context/flowr-file");
|
|
5
|
+
const package_1 = require("../../package-version-plugins/package");
|
|
6
|
+
const smol_toml_1 = require("smol-toml");
|
|
7
|
+
const log_1 = require("../../../../util/log");
|
|
8
|
+
exports.manifestFileLog = log_1.log.getSubLogger({ name: 'flowr-manifest-file' });
|
|
9
|
+
/** A project manifest that is no `DESCRIPTION` (an rv `rproject.toml`, a uvr `uvr.toml`). */
|
|
10
|
+
class FlowrManifestFile extends flowr_file_1.FlowrFile {
|
|
11
|
+
wrapped;
|
|
12
|
+
constructor(file) {
|
|
13
|
+
super(file.path(), file.roles);
|
|
14
|
+
this.wrapped = file;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.FlowrManifestFile = FlowrManifestFile;
|
|
18
|
+
/** The `rproject.toml` of an [rv](https://a2-ai.github.io/rv-docs/) project, lifted by {@link FlowrRProjectFile.from}. */
|
|
19
|
+
class FlowrRProjectFile extends FlowrManifestFile {
|
|
20
|
+
loadContent() {
|
|
21
|
+
try {
|
|
22
|
+
const toml = (0, smol_toml_1.parse)(this.wrapped.content().toString());
|
|
23
|
+
return toml.project ?? {};
|
|
24
|
+
}
|
|
25
|
+
catch (e) {
|
|
26
|
+
exports.manifestFileLog.warn(`Could not parse ${this.wrapped.path()}: ${e.message}`);
|
|
27
|
+
return {};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/** rproject lifter, this does not re-create if already an rproject file */
|
|
31
|
+
static from(file, role) {
|
|
32
|
+
if (role) {
|
|
33
|
+
file.assignRole(role);
|
|
34
|
+
}
|
|
35
|
+
return file instanceof FlowrRProjectFile ? file : new FlowrRProjectFile(file);
|
|
36
|
+
}
|
|
37
|
+
projectName() {
|
|
38
|
+
const name = this.content().name;
|
|
39
|
+
return typeof name === 'string' ? name : undefined;
|
|
40
|
+
}
|
|
41
|
+
/** rv pins a concrete `r_version`, e.g. `4.5` */
|
|
42
|
+
rVersion() {
|
|
43
|
+
const version = this.content().r_version;
|
|
44
|
+
return typeof version === 'string' ? version : undefined;
|
|
45
|
+
}
|
|
46
|
+
/** either a plain name or a table carrying it (`{ name = "ggplot2", repository = "new-rspm" }`) */
|
|
47
|
+
dependencies() {
|
|
48
|
+
const deps = this.content().dependencies;
|
|
49
|
+
if (!Array.isArray(deps)) {
|
|
50
|
+
return [];
|
|
51
|
+
}
|
|
52
|
+
const out = [];
|
|
53
|
+
for (const dep of deps) {
|
|
54
|
+
const name = typeof dep === 'string' ? dep : dep?.name;
|
|
55
|
+
if (typeof name === 'string' && name.length > 0) {
|
|
56
|
+
out.push(new package_1.Package({ name, type: 'package' }));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
61
|
+
/** rv does not group its dependencies, they are all needed to run the project */
|
|
62
|
+
declares() {
|
|
63
|
+
return { imports: this.dependencies() };
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.FlowrRProjectFile = FlowrRProjectFile;
|
|
67
|
+
/** The `uvr.toml` of a [uvr](https://github.com/nbafrank/uvr) project, lifted by {@link FlowrUvrManifestFile.from}. */
|
|
68
|
+
class FlowrUvrManifestFile extends FlowrManifestFile {
|
|
69
|
+
loadContent() {
|
|
70
|
+
try {
|
|
71
|
+
return (0, smol_toml_1.parse)(this.wrapped.content().toString());
|
|
72
|
+
}
|
|
73
|
+
catch (e) {
|
|
74
|
+
exports.manifestFileLog.warn(`Could not parse ${this.wrapped.path()}: ${e.message}`);
|
|
75
|
+
return {};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/** uvr manifest lifter, this does not re-create if already a uvr manifest file */
|
|
79
|
+
static from(file, role) {
|
|
80
|
+
if (role) {
|
|
81
|
+
file.assignRole(role);
|
|
82
|
+
}
|
|
83
|
+
return file instanceof FlowrUvrManifestFile ? file : new FlowrUvrManifestFile(file);
|
|
84
|
+
}
|
|
85
|
+
projectName() {
|
|
86
|
+
const name = this.content().project?.name;
|
|
87
|
+
return typeof name === 'string' ? name : undefined;
|
|
88
|
+
}
|
|
89
|
+
/** uvr usually states a requirement (`>=4.0.0`), which pins nothing; the `uvr.lock` holds the resolved version */
|
|
90
|
+
rVersion() {
|
|
91
|
+
const version = this.content().project?.r_version;
|
|
92
|
+
const trimmed = typeof version === 'string' ? version.trim() : '';
|
|
93
|
+
return /^\d/.test(trimmed) ? trimmed : undefined;
|
|
94
|
+
}
|
|
95
|
+
declares() {
|
|
96
|
+
return {
|
|
97
|
+
imports: this.packagesOf(this.content().dependencies),
|
|
98
|
+
suggests: this.packagesOf(this.content()['dev-dependencies'])
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
/** a table mapping the name to a bare requirement (`">=3.0.0"`, `"*"`) or to one with its origin (`{ version = ..., git = ... }`) */
|
|
102
|
+
packagesOf(table) {
|
|
103
|
+
// an array is no such table, and its indices would pass as package names
|
|
104
|
+
if (typeof table !== 'object' || table === null || Array.isArray(table)) {
|
|
105
|
+
return [];
|
|
106
|
+
}
|
|
107
|
+
const out = [];
|
|
108
|
+
for (const [name, spec] of Object.entries(table)) {
|
|
109
|
+
if (name.length === 0) {
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
const version = typeof spec === 'string' ? spec : spec?.version;
|
|
113
|
+
// `*` accepts anything, so it constrains nothing
|
|
114
|
+
const range = typeof version === 'string' && version !== '*' ? package_1.Package.parsePkgVersionRange(undefined, version) : undefined;
|
|
115
|
+
out.push(new package_1.Package({ name, type: 'package', versionConstraints: range ? [range] : undefined }));
|
|
116
|
+
}
|
|
117
|
+
return out;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
exports.FlowrUvrManifestFile = FlowrUvrManifestFile;
|
|
121
|
+
//# sourceMappingURL=flowr-manifest-files.js.map
|
|
@@ -3,10 +3,10 @@ import { FlowrFile } from '../../../context/flowr-file';
|
|
|
3
3
|
import { type Node } from 'commonmark';
|
|
4
4
|
import type { FlowrAnalyzerContext } from '../../../context/flowr-analyzer-context';
|
|
5
5
|
/**
|
|
6
|
-
* This decorates a text file and parses its contents as
|
|
6
|
+
* This decorates a text file and parses its contents as an R Markdown file.
|
|
7
7
|
* Finally, it provides access to the single cells, and all cells fused together as one R file.
|
|
8
8
|
*/
|
|
9
|
-
export declare class FlowrRMarkdownFile extends FlowrFile
|
|
9
|
+
export declare class FlowrRMarkdownFile extends FlowrFile {
|
|
10
10
|
private data?;
|
|
11
11
|
private mergedCode?;
|
|
12
12
|
private readonly wrapped;
|
|
@@ -15,7 +15,7 @@ const gray_matter_1 = __importDefault(require("gray-matter"));
|
|
|
15
15
|
const log_1 = require("../../../../util/log");
|
|
16
16
|
const built_in_source_1 = require("../../../../dataflow/internal/process/functions/call/built-in/built-in-source");
|
|
17
17
|
/**
|
|
18
|
-
* This decorates a text file and parses its contents as
|
|
18
|
+
* This decorates a text file and parses its contents as an R Markdown file.
|
|
19
19
|
* Finally, it provides access to the single cells, and all cells fused together as one R file.
|
|
20
20
|
*/
|
|
21
21
|
class FlowrRMarkdownFile extends flowr_file_1.FlowrFile {
|
|
@@ -86,7 +86,7 @@ class FlowrRMarkdownFile extends flowr_file_1.FlowrFile {
|
|
|
86
86
|
});
|
|
87
87
|
const rawChildFile = this.context.files.getFileByPath(childPath[0]);
|
|
88
88
|
if (rawChildFile !== undefined) {
|
|
89
|
-
block.code = FlowrRMarkdownFile.from(rawChildFile, this.context).content();
|
|
89
|
+
block.code = FlowrRMarkdownFile.from(rawChildFile, this.context).content().toString();
|
|
90
90
|
}
|
|
91
91
|
else {
|
|
92
92
|
log_1.log.warn(`Child file '${childPath[0]}' of '${this.path()}' did not load as RMD.`);
|
|
@@ -5,7 +5,7 @@ import { FlowrFile } from '../../../context/flowr-file';
|
|
|
5
5
|
* Finally, it provides access to the single cells, and all cells fused together as one R file.
|
|
6
6
|
* So far, this does *not* support `\Sexpr` calls.
|
|
7
7
|
*/
|
|
8
|
-
export declare class FlowrSweaveFile extends FlowrFile
|
|
8
|
+
export declare class FlowrSweaveFile extends FlowrFile {
|
|
9
9
|
private readonly wrapped;
|
|
10
10
|
private data?;
|
|
11
11
|
/**
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { FlowrAnalyzerFilePlugin } from './flowr-analyzer-file-plugin';
|
|
2
|
+
import { SemVer } from 'semver';
|
|
3
|
+
import type { PathLike } from 'fs';
|
|
4
|
+
import type { FlowrAnalyzerContext } from '../../context/flowr-analyzer-context';
|
|
5
|
+
import type { FlowrFileProvider } from '../../context/flowr-file';
|
|
6
|
+
/**
|
|
7
|
+
* Tags a project manifest with the {@link FileRole.Manifest} role and lifts it, so the meta plugins reading it
|
|
8
|
+
* can look it up by role.
|
|
9
|
+
*/
|
|
10
|
+
declare abstract class FlowrAnalyzerManifestFilePlugin extends FlowrAnalyzerFilePlugin {
|
|
11
|
+
readonly version: SemVer;
|
|
12
|
+
private readonly pathPattern;
|
|
13
|
+
/**
|
|
14
|
+
* @param pathPattern - The pattern to identify the manifest, see the respective subclass for its default.
|
|
15
|
+
*/
|
|
16
|
+
constructor(pathPattern: RegExp);
|
|
17
|
+
applies(file: PathLike): boolean;
|
|
18
|
+
}
|
|
19
|
+
/** Lifts an rv `rproject.toml` to a {@link FlowrRProjectFile}. */
|
|
20
|
+
export declare class FlowrAnalyzerRProjectFilePlugin extends FlowrAnalyzerManifestFilePlugin {
|
|
21
|
+
readonly name = "flowr-analyzer-rproject-file-plugin";
|
|
22
|
+
readonly description = "Marks the rproject.toml manifest of an rv project.";
|
|
23
|
+
constructor(pathPattern?: RegExp);
|
|
24
|
+
process(_ctx: FlowrAnalyzerContext, file: FlowrFileProvider): [FlowrFileProvider, true];
|
|
25
|
+
}
|
|
26
|
+
/** Lifts a uvr `uvr.toml` to a {@link FlowrUvrManifestFile}. */
|
|
27
|
+
export declare class FlowrAnalyzerUvrManifestFilePlugin extends FlowrAnalyzerManifestFilePlugin {
|
|
28
|
+
readonly name = "flowr-analyzer-uvr-manifest-file-plugin";
|
|
29
|
+
readonly description = "Marks the uvr.toml manifest of a uvr project.";
|
|
30
|
+
constructor(pathPattern?: RegExp);
|
|
31
|
+
process(_ctx: FlowrAnalyzerContext, file: FlowrFileProvider): [FlowrFileProvider, true];
|
|
32
|
+
}
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FlowrAnalyzerUvrManifestFilePlugin = exports.FlowrAnalyzerRProjectFilePlugin = void 0;
|
|
4
|
+
const flowr_analyzer_file_plugin_1 = require("./flowr-analyzer-file-plugin");
|
|
5
|
+
const semver_1 = require("semver");
|
|
6
|
+
const flowr_file_1 = require("../../context/flowr-file");
|
|
7
|
+
const built_in_source_1 = require("../../../dataflow/internal/process/functions/call/built-in/built-in-source");
|
|
8
|
+
const flowr_manifest_files_1 = require("./files/flowr-manifest-files");
|
|
9
|
+
const RProjectFilePattern = /^rproject\.toml$/i;
|
|
10
|
+
const UvrManifestFilePattern = /^uvr\.toml$/i;
|
|
11
|
+
/**
|
|
12
|
+
* Tags a project manifest with the {@link FileRole.Manifest} role and lifts it, so the meta plugins reading it
|
|
13
|
+
* can look it up by role.
|
|
14
|
+
*/
|
|
15
|
+
class FlowrAnalyzerManifestFilePlugin extends flowr_analyzer_file_plugin_1.FlowrAnalyzerFilePlugin {
|
|
16
|
+
version = new semver_1.SemVer('0.1.0');
|
|
17
|
+
pathPattern;
|
|
18
|
+
/**
|
|
19
|
+
* @param pathPattern - The pattern to identify the manifest, see the respective subclass for its default.
|
|
20
|
+
*/
|
|
21
|
+
constructor(pathPattern) {
|
|
22
|
+
super();
|
|
23
|
+
this.pathPattern = pathPattern;
|
|
24
|
+
}
|
|
25
|
+
applies(file) {
|
|
26
|
+
return this.pathPattern.test((0, built_in_source_1.platformBasename)(file.toString()));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/** Lifts an rv `rproject.toml` to a {@link FlowrRProjectFile}. */
|
|
30
|
+
class FlowrAnalyzerRProjectFilePlugin extends FlowrAnalyzerManifestFilePlugin {
|
|
31
|
+
name = 'flowr-analyzer-rproject-file-plugin';
|
|
32
|
+
description = 'Marks the rproject.toml manifest of an rv project.';
|
|
33
|
+
constructor(pathPattern = RProjectFilePattern) {
|
|
34
|
+
super(pathPattern);
|
|
35
|
+
}
|
|
36
|
+
process(_ctx, file) {
|
|
37
|
+
return [flowr_manifest_files_1.FlowrRProjectFile.from(file, flowr_file_1.FileRole.Manifest), true];
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.FlowrAnalyzerRProjectFilePlugin = FlowrAnalyzerRProjectFilePlugin;
|
|
41
|
+
/** Lifts a uvr `uvr.toml` to a {@link FlowrUvrManifestFile}. */
|
|
42
|
+
class FlowrAnalyzerUvrManifestFilePlugin extends FlowrAnalyzerManifestFilePlugin {
|
|
43
|
+
name = 'flowr-analyzer-uvr-manifest-file-plugin';
|
|
44
|
+
description = 'Marks the uvr.toml manifest of a uvr project.';
|
|
45
|
+
constructor(pathPattern = UvrManifestFilePattern) {
|
|
46
|
+
super(pathPattern);
|
|
47
|
+
}
|
|
48
|
+
process(_ctx, file) {
|
|
49
|
+
return [flowr_manifest_files_1.FlowrUvrManifestFile.from(file, flowr_file_1.FileRole.Manifest), true];
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.FlowrAnalyzerUvrManifestFilePlugin = FlowrAnalyzerUvrManifestFilePlugin;
|
|
53
|
+
//# sourceMappingURL=flowr-analyzer-manifest-file-plugin.js.map
|
|
@@ -9,7 +9,7 @@ import type { FlowrFileProvider } from '../../context/flowr-file';
|
|
|
9
9
|
*/
|
|
10
10
|
export declare class FlowrAnalyzerVirtualEnvFilePlugin extends FlowrAnalyzerFilePlugin {
|
|
11
11
|
readonly name = "flowr-analyzer-virtualenv-files-plugin";
|
|
12
|
-
readonly description = "Marks virtual-environment lockfiles (renv.lock, rv.lock).";
|
|
12
|
+
readonly description = "Marks virtual-environment lockfiles (renv.lock, rv.lock, uvr.lock).";
|
|
13
13
|
readonly version: SemVer;
|
|
14
14
|
private readonly pathPattern;
|
|
15
15
|
/**
|
|
@@ -5,15 +5,15 @@ 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 built_in_source_1 = require("../../../dataflow/internal/process/functions/call/built-in/built-in-source");
|
|
8
|
-
/** Lockfiles pinning a project's package environment (`renv.lock`, `rv.lock`, `packrat.lock`). */
|
|
9
|
-
const VirtualEnvFilePattern = /^(renv|rv|packrat)\.lock$/i;
|
|
8
|
+
/** Lockfiles pinning a project's package environment (`renv.lock`, `rv.lock`, `uvr.lock`, `packrat.lock`). */
|
|
9
|
+
const VirtualEnvFilePattern = /^(renv|rv|uvr|packrat)\.lock$/i;
|
|
10
10
|
/**
|
|
11
11
|
* Tags a project's virtual-environment lockfiles with the {@link FileRole.VirtualEnv} role, so the version
|
|
12
12
|
* plugins that read them can look them up by role instead of scanning every project file.
|
|
13
13
|
*/
|
|
14
14
|
class FlowrAnalyzerVirtualEnvFilePlugin extends flowr_analyzer_file_plugin_1.FlowrAnalyzerFilePlugin {
|
|
15
15
|
name = 'flowr-analyzer-virtualenv-files-plugin';
|
|
16
|
-
description = 'Marks virtual-environment lockfiles (renv.lock, rv.lock).';
|
|
16
|
+
description = 'Marks virtual-environment lockfiles (renv.lock, rv.lock, uvr.lock).';
|
|
17
17
|
version = new semver_1.SemVer('0.1.0');
|
|
18
18
|
pathPattern;
|
|
19
19
|
/**
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { FlowrAnalyzerPackageVersionsPlugin } from './flowr-analyzer-package-versions-plugin';
|
|
2
|
+
import { SemVer } from 'semver';
|
|
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
|
+
*/
|
|
9
|
+
declare abstract class FlowrAnalyzerMetaManifestFilePlugin extends FlowrAnalyzerPackageVersionsPlugin {
|
|
10
|
+
readonly version: SemVer;
|
|
11
|
+
/** the manifest flavor this plugin reads, the others are left to their own plugin */
|
|
12
|
+
protected abstract readonly reads: abstract new (...args: never[]) => object;
|
|
13
|
+
process(ctx: FlowrAnalyzerContext): void;
|
|
14
|
+
}
|
|
15
|
+
/** Reads an rv `rproject.toml`. */
|
|
16
|
+
export declare class FlowrAnalyzerMetaRProjectFilePlugin extends FlowrAnalyzerMetaManifestFilePlugin {
|
|
17
|
+
readonly name = "flowr-analyzer-meta-rproject-file-plugin";
|
|
18
|
+
readonly description = "Extracts project meta information and dependencies from an rproject.toml.";
|
|
19
|
+
protected readonly reads: typeof FlowrRProjectFile;
|
|
20
|
+
}
|
|
21
|
+
/** Reads a uvr `uvr.toml`, whose `[dev-dependencies]` land in `suggests`. */
|
|
22
|
+
export declare class FlowrAnalyzerMetaUvrManifestFilePlugin extends FlowrAnalyzerMetaManifestFilePlugin {
|
|
23
|
+
readonly name = "flowr-analyzer-meta-uvr-manifest-file-plugin";
|
|
24
|
+
readonly description = "Extracts project meta information and dependencies from a uvr.toml.";
|
|
25
|
+
protected readonly reads: typeof FlowrUvrManifestFile;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FlowrAnalyzerMetaUvrManifestFilePlugin = exports.FlowrAnalyzerMetaRProjectFilePlugin = void 0;
|
|
4
|
+
const flowr_analyzer_package_versions_plugin_1 = require("./flowr-analyzer-package-versions-plugin");
|
|
5
|
+
const semver_1 = require("semver");
|
|
6
|
+
const flowr_file_1 = require("../../context/flowr-file");
|
|
7
|
+
const flowr_analyzer_meta_context_1 = require("../../context/flowr-analyzer-meta-context");
|
|
8
|
+
const flowr_manifest_files_1 = require("../file-plugins/files/flowr-manifest-files");
|
|
9
|
+
/**
|
|
10
|
+
* Extracts the project metadata and the declared dependencies from a project manifest. The name is contributed
|
|
11
|
+
* without a namespace: such a project is no package, so `a::b` must not resolve against it.
|
|
12
|
+
*/
|
|
13
|
+
class FlowrAnalyzerMetaManifestFilePlugin extends flowr_analyzer_package_versions_plugin_1.FlowrAnalyzerPackageVersionsPlugin {
|
|
14
|
+
version = new semver_1.SemVer('0.1.0');
|
|
15
|
+
process(ctx) {
|
|
16
|
+
for (const file of ctx.files.getFilesByRole(flowr_file_1.FileRole.Manifest)) {
|
|
17
|
+
if (!(file instanceof this.reads)) {
|
|
18
|
+
continue;
|
|
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);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/** Reads an rv `rproject.toml`. */
|
|
34
|
+
class FlowrAnalyzerMetaRProjectFilePlugin extends FlowrAnalyzerMetaManifestFilePlugin {
|
|
35
|
+
name = 'flowr-analyzer-meta-rproject-file-plugin';
|
|
36
|
+
description = 'Extracts project meta information and dependencies from an rproject.toml.';
|
|
37
|
+
reads = flowr_manifest_files_1.FlowrRProjectFile;
|
|
38
|
+
}
|
|
39
|
+
exports.FlowrAnalyzerMetaRProjectFilePlugin = FlowrAnalyzerMetaRProjectFilePlugin;
|
|
40
|
+
/** Reads a uvr `uvr.toml`, whose `[dev-dependencies]` land in `suggests`. */
|
|
41
|
+
class FlowrAnalyzerMetaUvrManifestFilePlugin extends FlowrAnalyzerMetaManifestFilePlugin {
|
|
42
|
+
name = 'flowr-analyzer-meta-uvr-manifest-file-plugin';
|
|
43
|
+
description = 'Extracts project meta information and dependencies from a uvr.toml.';
|
|
44
|
+
reads = flowr_manifest_files_1.FlowrUvrManifestFile;
|
|
45
|
+
}
|
|
46
|
+
exports.FlowrAnalyzerMetaUvrManifestFilePlugin = FlowrAnalyzerMetaUvrManifestFilePlugin;
|
|
47
|
+
//# sourceMappingURL=flowr-analyzer-meta-manifest-file-plugin.js.map
|
package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.d.ts
CHANGED
|
@@ -23,3 +23,10 @@ export declare class FlowrAnalyzerPackageVersionsRvPlugin extends FlowrAnalyzerP
|
|
|
23
23
|
readonly version: SemVer;
|
|
24
24
|
process(ctx: FlowrAnalyzerContext): void;
|
|
25
25
|
}
|
|
26
|
+
/** Reads package versions from a `uvr.lock` (TOML). uvr pins are exact, the dev-dependencies among them. */
|
|
27
|
+
export declare class FlowrAnalyzerPackageVersionsUvrPlugin extends FlowrAnalyzerPackageVersionsPlugin {
|
|
28
|
+
readonly name = "flowr-analyzer-package-versions-uvr-plugin";
|
|
29
|
+
readonly description = "Extracts package versions from a uvr.lock lockfile.";
|
|
30
|
+
readonly version: SemVer;
|
|
31
|
+
process(ctx: FlowrAnalyzerContext): void;
|
|
32
|
+
}
|
package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FlowrAnalyzerPackageVersionsRvPlugin = exports.FlowrAnalyzerPackageVersionsPackratPlugin = exports.FlowrAnalyzerPackageVersionsRenvPlugin = exports.lockfileLog = void 0;
|
|
3
|
+
exports.FlowrAnalyzerPackageVersionsUvrPlugin = exports.FlowrAnalyzerPackageVersionsRvPlugin = exports.FlowrAnalyzerPackageVersionsPackratPlugin = exports.FlowrAnalyzerPackageVersionsRenvPlugin = exports.lockfileLog = 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 package_1 = require("./package");
|
|
@@ -10,9 +10,9 @@ const log_1 = require("../../../util/log");
|
|
|
10
10
|
const smol_toml_1 = require("smol-toml");
|
|
11
11
|
const flowr_analyzer_meta_context_1 = require("../../context/flowr-analyzer-meta-context");
|
|
12
12
|
exports.lockfileLog = log_1.log.getSubLogger({ name: 'flowr-analyzer-package-versions-lockfile-plugin' });
|
|
13
|
-
/** The {@link FileRole.VirtualEnv} lockfiles named `name` (e.g. `renv.lock`),
|
|
13
|
+
/** The {@link FileRole.VirtualEnv} lockfiles named `name` (e.g. `renv.lock`), matched case-insensitively like the role is assigned. */
|
|
14
14
|
function virtualEnvFiles(ctx, name) {
|
|
15
|
-
return ctx.files.getFilesByRole(flowr_file_1.FileRole.VirtualEnv).filter(f => (0, built_in_source_1.platformBasename)(f.path()) === name);
|
|
15
|
+
return ctx.files.getFilesByRole(flowr_file_1.FileRole.VirtualEnv).filter(f => (0, built_in_source_1.platformBasename)(f.path()).toLowerCase() === name);
|
|
16
16
|
}
|
|
17
17
|
function pin(ctx, name, version) {
|
|
18
18
|
const range = package_1.Package.parsePkgVersionRange(undefined, version);
|
|
@@ -122,4 +122,32 @@ class FlowrAnalyzerPackageVersionsRvPlugin extends flowr_analyzer_package_versio
|
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
exports.FlowrAnalyzerPackageVersionsRvPlugin = FlowrAnalyzerPackageVersionsRvPlugin;
|
|
125
|
+
/** Reads package versions from a `uvr.lock` (TOML). uvr pins are exact, the dev-dependencies among them. */
|
|
126
|
+
class FlowrAnalyzerPackageVersionsUvrPlugin extends flowr_analyzer_package_versions_plugin_1.FlowrAnalyzerPackageVersionsPlugin {
|
|
127
|
+
name = 'flowr-analyzer-package-versions-uvr-plugin';
|
|
128
|
+
description = 'Extracts package versions from a uvr.lock lockfile.';
|
|
129
|
+
version = new semver_1.SemVer('0.1.0');
|
|
130
|
+
process(ctx) {
|
|
131
|
+
for (const file of virtualEnvFiles(ctx, 'uvr.lock')) {
|
|
132
|
+
let lock;
|
|
133
|
+
try {
|
|
134
|
+
lock = (0, smol_toml_1.parse)(file.content().toString());
|
|
135
|
+
}
|
|
136
|
+
catch (e) {
|
|
137
|
+
exports.lockfileLog.warn(`Could not parse uvr.lock: ${e.message}`);
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
if (typeof lock.r?.version === 'string') {
|
|
141
|
+
ctx.meta.contribute({ rVersion: lock.r.version }, flowr_analyzer_meta_context_1.MetaPriority.Lockfile);
|
|
142
|
+
}
|
|
143
|
+
for (const pkg of Array.isArray(lock.package) ? lock.package : []) {
|
|
144
|
+
const { name, version } = pkg;
|
|
145
|
+
if (typeof name === 'string' && typeof version === 'string') {
|
|
146
|
+
pin(ctx, name, version);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
exports.FlowrAnalyzerPackageVersionsUvrPlugin = FlowrAnalyzerPackageVersionsUvrPlugin;
|
|
125
153
|
//# sourceMappingURL=flowr-analyzer-package-versions-lockfile-plugin.js.map
|