@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
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.OnDemandRecoverer = exports.onDemandLog = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const remote_sources_1 = require("./remote-sources");
|
|
10
|
+
const package_sources_1 = require("./package-sources");
|
|
11
|
+
const tar_1 = require("./tar");
|
|
12
|
+
const log_1 = require("../../../util/log");
|
|
13
|
+
exports.onDemandLog = log_1.log.getSubLogger({ name: 'sigdb-on-demand' });
|
|
14
|
+
/** the version of the cache entries, a different one is fetched again */
|
|
15
|
+
const CacheSchema = 1;
|
|
16
|
+
/** how many packages are fetched at once */
|
|
17
|
+
const Parallel = 4;
|
|
18
|
+
function isCacheEntry(value, name) {
|
|
19
|
+
const entry = value;
|
|
20
|
+
const pkg = entry?.package;
|
|
21
|
+
return typeof entry === 'object' && entry !== null && entry.schema === CacheSchema && entry.name === name && typeof entry.at === 'number'
|
|
22
|
+
&& (pkg === undefined || (pkg.name === name && Array.isArray(pkg.exported) && Array.isArray(pkg.functions) && Array.isArray(pkg.s4Classes)));
|
|
23
|
+
}
|
|
24
|
+
/** whether what was asked for back then answers what is asked now */
|
|
25
|
+
function answers(entry, request) {
|
|
26
|
+
return (request.version === undefined || entry.request.version === request.version)
|
|
27
|
+
&& (request.github === undefined || entry.request.github === request.github);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Recovers packages no signature database knows from their sources: asks each {@link OnDemandSource} in turn for
|
|
31
|
+
* archives, reads `DESCRIPTION`, `NAMESPACE`, and `R/` from the first one that holds the package, and caches the
|
|
32
|
+
* result (or that no source had it) as one JSON file per package, so later analyses need no network.
|
|
33
|
+
*/
|
|
34
|
+
class OnDemandRecoverer {
|
|
35
|
+
options;
|
|
36
|
+
args;
|
|
37
|
+
now;
|
|
38
|
+
constructor(options, args) {
|
|
39
|
+
this.options = options;
|
|
40
|
+
this.args = args;
|
|
41
|
+
this.now = args.now ?? Date.now;
|
|
42
|
+
}
|
|
43
|
+
cacheFile(name) {
|
|
44
|
+
return path_1.default.join(this.args.cacheDir, `${name}.json`);
|
|
45
|
+
}
|
|
46
|
+
readEntry(name) {
|
|
47
|
+
if (!(0, remote_sources_1.isPackageName)(name)) {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
try {
|
|
51
|
+
const entry = JSON.parse(fs_1.default.readFileSync(this.cacheFile(name), 'utf8'));
|
|
52
|
+
return isCacheEntry(entry, name) ? entry : undefined;
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
writeEntry(entry) {
|
|
59
|
+
try {
|
|
60
|
+
fs_1.default.mkdirSync(this.args.cacheDir, { recursive: true });
|
|
61
|
+
const file = this.cacheFile(entry.name);
|
|
62
|
+
const tmp = `${file}.${process.pid}.${Math.random().toString(36).slice(2)}.part`;
|
|
63
|
+
fs_1.default.writeFileSync(tmp, JSON.stringify(entry));
|
|
64
|
+
fs_1.default.renameSync(tmp, file);
|
|
65
|
+
}
|
|
66
|
+
catch (e) {
|
|
67
|
+
exports.onDemandLog.warn(`cannot cache ${entry.name} in ${this.args.cacheDir}: ${e.message}`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/** The package as fetched before, `undefined` if it never was or no source had it. */
|
|
71
|
+
cached(name) {
|
|
72
|
+
const found = (0, package_sources_1.sanitizeRecovered)(this.readEntry(name)?.package);
|
|
73
|
+
return found?.name === name ? found : undefined;
|
|
74
|
+
}
|
|
75
|
+
/** whether the cache answers `request`, with the package or with a recent miss */
|
|
76
|
+
settled(request) {
|
|
77
|
+
const entry = this.readEntry(request.name);
|
|
78
|
+
if (entry === undefined || !answers(entry, request)) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
const retry = (this.options.retryAfterHours ?? 24) * 60 * 60 * 1000;
|
|
82
|
+
return entry.package !== undefined || this.now() - entry.at < retry;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Fetches the packages of `requests` the cache does not answer yet, at most `maxPackages` of them, and returns
|
|
86
|
+
* those it recovered. A failing source is logged and the next one tried, so this never throws.
|
|
87
|
+
*/
|
|
88
|
+
async recover(requests) {
|
|
89
|
+
if (this.options.offline) {
|
|
90
|
+
return [];
|
|
91
|
+
}
|
|
92
|
+
const wanted = requests.filter(r => (0, remote_sources_1.isPackageName)(r.name) && !this.settled(r)).slice(0, this.options.maxPackages ?? 25);
|
|
93
|
+
const recovered = [];
|
|
94
|
+
for (let i = 0; i < wanted.length; i += Parallel) {
|
|
95
|
+
const batch = await Promise.all(wanted.slice(i, i + Parallel).map(r => this.recoverOne(r)));
|
|
96
|
+
recovered.push(...batch.filter(p => p !== undefined));
|
|
97
|
+
}
|
|
98
|
+
return recovered;
|
|
99
|
+
}
|
|
100
|
+
async recoverOne(request) {
|
|
101
|
+
const failures = [];
|
|
102
|
+
const tryArchive = async (archive) => {
|
|
103
|
+
try {
|
|
104
|
+
const found = await this.fromArchive(request, archive);
|
|
105
|
+
if (found !== undefined) {
|
|
106
|
+
exports.onDemandLog.info(`recovered ${found.name}${found.version ? ` ${found.version}` : ''} from ${archive.url}`);
|
|
107
|
+
this.writeEntry({ schema: CacheSchema, name: request.name, request: { version: request.version, github: request.github }, at: this.now(), package: found });
|
|
108
|
+
}
|
|
109
|
+
return found;
|
|
110
|
+
}
|
|
111
|
+
catch (e) {
|
|
112
|
+
failures.push(`${archive.url}: ${e.message}`);
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
/* in the order of the sources, but every sure archive before any fallback */
|
|
117
|
+
const fallbacks = [];
|
|
118
|
+
for (const source of this.args.sources) {
|
|
119
|
+
let archives;
|
|
120
|
+
try {
|
|
121
|
+
archives = await source.archives(request, this.args.fetch);
|
|
122
|
+
}
|
|
123
|
+
catch (e) {
|
|
124
|
+
failures.push(`${source.name}: ${e.message}`);
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
for (const archive of archives) {
|
|
128
|
+
if (archive.fallback) {
|
|
129
|
+
fallbacks.push(archive);
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
const found = await tryArchive(archive);
|
|
133
|
+
if (found !== undefined) {
|
|
134
|
+
return found;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
for (const archive of fallbacks) {
|
|
139
|
+
const found = await tryArchive(archive);
|
|
140
|
+
if (found !== undefined) {
|
|
141
|
+
return found;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (failures.length > 0) {
|
|
145
|
+
/* a failure may be the network's rather than the package's, so the next analysis asks again */
|
|
146
|
+
exports.onDemandLog.warn(`cannot recover ${request.name}: ${failures.join(', ')}`);
|
|
147
|
+
return undefined;
|
|
148
|
+
}
|
|
149
|
+
exports.onDemandLog.info(`cannot recover ${request.name}: no source has it`);
|
|
150
|
+
this.writeEntry({ schema: CacheSchema, name: request.name, request: { version: request.version, github: request.github }, at: this.now(), missing: 'no source has it' });
|
|
151
|
+
return undefined;
|
|
152
|
+
}
|
|
153
|
+
async fromArchive(request, archive) {
|
|
154
|
+
const maxBytes = (this.options.maxArchiveMb ?? 32) * 1024 * 1024;
|
|
155
|
+
const bytes = await this.args.fetch(archive.url, maxBytes);
|
|
156
|
+
if (bytes === undefined) {
|
|
157
|
+
return undefined;
|
|
158
|
+
}
|
|
159
|
+
const prefix = archive.subdir === undefined ? '' : `${archive.subdir.replace(/\/$/, '')}/`;
|
|
160
|
+
/* what an archive unpacks to is held in memory at once, so it gets a bound of its own */
|
|
161
|
+
const entries = (0, tar_1.readTarEntries)(bytes, p => p.startsWith(prefix) && (0, package_sources_1.isRecoveredFile)(p.slice(prefix.length)), { ...tar_1.DefaultTarLimits, maxArchiveBytes: Math.min(3 * maxBytes, tar_1.DefaultTarLimits.maxArchiveBytes) });
|
|
162
|
+
const files = new Map([...entries].map(([p, b]) => [p.slice(prefix.length), b.toString('utf8')]));
|
|
163
|
+
const found = (0, package_sources_1.sanitizeRecovered)((0, package_sources_1.recoverPackage)(files, this.args.parse, archive.origin));
|
|
164
|
+
/* a mirror may hold another package under that name, a repository one named differently */
|
|
165
|
+
return found?.name === request.name ? found : undefined;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
exports.OnDemandRecoverer = OnDemandRecoverer;
|
|
169
|
+
//# sourceMappingURL=recoverer.js.map
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where an on-demand signature source looks for the source of a package no database knows: CRAN, Bioconductor,
|
|
3
|
+
* and GitHub repositories, each as an {@link OnDemandSource}. A plugin may hand in sources of its own (an
|
|
4
|
+
* r-universe, a company mirror) next to these.
|
|
5
|
+
*/
|
|
6
|
+
/** A package to recover, with what the analyzed project says about where it comes from. */
|
|
7
|
+
export interface PackageRequest {
|
|
8
|
+
readonly name: string;
|
|
9
|
+
/** the version the project pins, if any */
|
|
10
|
+
readonly version?: string;
|
|
11
|
+
/** the GitHub repository the project installs it from, `owner/repo[/subdir][@ref]` */
|
|
12
|
+
readonly github?: string;
|
|
13
|
+
}
|
|
14
|
+
/** One archive that may hold the package source. */
|
|
15
|
+
export interface PackageArchive {
|
|
16
|
+
/** a `.tar.gz` (or plain `.tar`) of the package source */
|
|
17
|
+
readonly url: string;
|
|
18
|
+
/** what the recovered package says it came from, like `cran` or `github:masurp/ggmirt` */
|
|
19
|
+
readonly origin: string;
|
|
20
|
+
/** the directory of the package within the archive, for a repository holding more than the package */
|
|
21
|
+
readonly subdir?: string;
|
|
22
|
+
/**
|
|
23
|
+
* only worth a try once no source has the package for sure: a mirror of every package that ever was on CRAN
|
|
24
|
+
* also holds the ancient copy of one that moved to Bioconductor (`limma`)
|
|
25
|
+
*/
|
|
26
|
+
readonly fallback?: true;
|
|
27
|
+
}
|
|
28
|
+
/** Downloads `url`, `undefined` if the server does not have it. Throws on every other failure. */
|
|
29
|
+
export type FetchBytes = (url: string, maxBytes: number) => Promise<Buffer | undefined>;
|
|
30
|
+
/** A place to look for package sources. */
|
|
31
|
+
export interface OnDemandSource {
|
|
32
|
+
/** the name the configuration lists it under (`solver.sigdb.onDemand.sources`) */
|
|
33
|
+
readonly name: string;
|
|
34
|
+
/** the archives that may hold the package, most likely first, none if this source cannot have it */
|
|
35
|
+
archives(request: PackageRequest, fetch: FetchBytes): Promise<readonly PackageArchive[]>;
|
|
36
|
+
}
|
|
37
|
+
/** what a source may be configured with, see `solver.sigdb.onDemand` */
|
|
38
|
+
export interface OnDemandSourceOptions {
|
|
39
|
+
/** the CRAN `src/contrib/` to fetch tarballs from */
|
|
40
|
+
readonly cranMirror?: string;
|
|
41
|
+
/** the Bioconductor host */
|
|
42
|
+
readonly bioconductorMirror?: string;
|
|
43
|
+
/** the Bioconductor release (`release`, `devel`, or a number like `3.20`) */
|
|
44
|
+
readonly bioconductorRelease?: string;
|
|
45
|
+
/** whether to use the read-only GitHub mirrors of CRAN (`cran/<pkg>`) and Bioconductor (`bioc/<pkg>`), which keep every version as a tag */
|
|
46
|
+
readonly githubMirrors?: boolean;
|
|
47
|
+
}
|
|
48
|
+
/** A GitHub remote as `remotes`/`pak` write it: `owner/repo`, optionally `/subdir`, `@ref`, `#pr`, or a `github::` prefix. */
|
|
49
|
+
export declare function parseGitHubRemote(remote: string): {
|
|
50
|
+
owner: string;
|
|
51
|
+
repo: string;
|
|
52
|
+
subdir?: string;
|
|
53
|
+
ref?: string;
|
|
54
|
+
} | undefined;
|
|
55
|
+
/** A package name R accepts, which is all that may go into a URL built from one. */
|
|
56
|
+
export declare function isPackageName(name: string): boolean;
|
|
57
|
+
/** The repository a project names for the package, or nothing. */
|
|
58
|
+
export declare const GitHubSource: OnDemandSource;
|
|
59
|
+
/**
|
|
60
|
+
* CRAN: a pinned version from the GitHub mirror or CRAN itself (current or archived), else the current version
|
|
61
|
+
* the CRAN index lists. A package CRAN no longer lists is a {@link PackageArchive#fallback} from the mirror.
|
|
62
|
+
*/
|
|
63
|
+
export declare function cranSource(options?: OnDemandSourceOptions): OnDemandSource;
|
|
64
|
+
/** the `Package`/`Version` pairs of a `PACKAGES` index */
|
|
65
|
+
export declare function parsePackagesIndex(index: string): Map<string, string>;
|
|
66
|
+
/**
|
|
67
|
+
* Bioconductor: the release tarball the repository index lists, else the GitHub mirror. A Bioconductor release
|
|
68
|
+
* only keeps its current version of a package, so an older pinned one falls back to the mirror's newest.
|
|
69
|
+
*/
|
|
70
|
+
export declare function bioconductorSource(options?: OnDemandSourceOptions): OnDemandSource;
|
|
71
|
+
/** The sources flowR knows by name, configured with `options`. */
|
|
72
|
+
export declare function builtInOnDemandSources(options?: OnDemandSourceOptions): ReadonlyMap<string, OnDemandSource>;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.GitHubSource = void 0;
|
|
7
|
+
exports.parseGitHubRemote = parseGitHubRemote;
|
|
8
|
+
exports.isPackageName = isPackageName;
|
|
9
|
+
exports.cranSource = cranSource;
|
|
10
|
+
exports.parsePackagesIndex = parsePackagesIndex;
|
|
11
|
+
exports.bioconductorSource = bioconductorSource;
|
|
12
|
+
exports.builtInOnDemandSources = builtInOnDemandSources;
|
|
13
|
+
const zlib_1 = __importDefault(require("zlib"));
|
|
14
|
+
const GitHubArchive = (owner, repo, ref) => `https://codeload.github.com/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}/tar.gz/${ref.split('/').map(encodeURIComponent).join('/')}`;
|
|
15
|
+
/** A GitHub remote as `remotes`/`pak` write it: `owner/repo`, optionally `/subdir`, `@ref`, `#pr`, or a `github::` prefix. */
|
|
16
|
+
function parseGitHubRemote(remote) {
|
|
17
|
+
const match = /^(?:github::)?([A-Za-z0-9-]+)\/([A-Za-z0-9._-]+)((?:\/[A-Za-z0-9._-]+)*)(?:@([A-Za-z0-9._/-]+)|#(\d+))?$/.exec(remote.trim());
|
|
18
|
+
/* no step may leave the repository (`..`) or name a hidden file */
|
|
19
|
+
if (match === null || [match[2], ...(match[3] ?? '').split('/'), ...(match[4] ?? '').split('/')].some(p => p === '..' || p === '.' || p.startsWith('.') && p.length > 0)) {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
const [, owner, repo, subdir, ref, pr] = match;
|
|
23
|
+
return {
|
|
24
|
+
owner,
|
|
25
|
+
repo: repo.replace(/\.git$/, ''),
|
|
26
|
+
subdir: subdir ? subdir.slice(1) : undefined,
|
|
27
|
+
ref: pr ? `refs/pull/${pr}/head` : ref
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/** A package name R accepts, which is all that may go into a URL built from one. */
|
|
31
|
+
function isPackageName(name) {
|
|
32
|
+
return /^[A-Za-z][A-Za-z0-9.]*[A-Za-z0-9]$/.test(name);
|
|
33
|
+
}
|
|
34
|
+
/** a version as it may go into a URL */
|
|
35
|
+
function isVersion(version) {
|
|
36
|
+
return version !== undefined && /^[0-9][0-9.-]*$/.test(version);
|
|
37
|
+
}
|
|
38
|
+
/** The repository a project names for the package, or nothing. */
|
|
39
|
+
exports.GitHubSource = {
|
|
40
|
+
name: 'github',
|
|
41
|
+
archives(request) {
|
|
42
|
+
const remote = request.github === undefined ? undefined : parseGitHubRemote(request.github);
|
|
43
|
+
if (remote === undefined) {
|
|
44
|
+
return Promise.resolve([]);
|
|
45
|
+
}
|
|
46
|
+
return Promise.resolve([{ url: GitHubArchive(remote.owner, remote.repo, remote.ref ?? 'HEAD'), origin: `github:${remote.owner}/${remote.repo}`, subdir: remote.subdir }]);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
/** the `PACKAGES` index at `url` (fetched once), empty if it cannot be had */
|
|
50
|
+
function packagesIndex(url, fetch, cache) {
|
|
51
|
+
let index = cache.get(url);
|
|
52
|
+
if (index === undefined) {
|
|
53
|
+
index = fetch(url, 64 * 1024 * 1024)
|
|
54
|
+
.then(b => b === undefined ? new Map() : parsePackagesIndex((b[0] === 0x1f && b[1] === 0x8b ? zlib_1.default.gunzipSync(b) : b).toString('utf8')))
|
|
55
|
+
.catch(() => new Map());
|
|
56
|
+
cache.set(url, index);
|
|
57
|
+
}
|
|
58
|
+
return index;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* CRAN: a pinned version from the GitHub mirror or CRAN itself (current or archived), else the current version
|
|
62
|
+
* the CRAN index lists. A package CRAN no longer lists is a {@link PackageArchive#fallback} from the mirror.
|
|
63
|
+
*/
|
|
64
|
+
function cranSource(options = {}) {
|
|
65
|
+
const mirror = (options.cranMirror ?? 'https://cloud.r-project.org/src/contrib/').replace(/\/?$/, '/');
|
|
66
|
+
const github = options.githubMirrors !== false;
|
|
67
|
+
const indices = new Map();
|
|
68
|
+
const ofVersion = (name, version) => {
|
|
69
|
+
const file = `${name}_${version}.tar.gz`;
|
|
70
|
+
return [
|
|
71
|
+
...github ? [{ url: GitHubArchive('cran', name, `refs/tags/${version}`), origin: 'cran' }] : [],
|
|
72
|
+
{ url: `${mirror}${file}`, origin: 'cran' },
|
|
73
|
+
{ url: `${mirror}Archive/${name}/${file}`, origin: 'cran' }
|
|
74
|
+
];
|
|
75
|
+
};
|
|
76
|
+
return {
|
|
77
|
+
name: 'cran',
|
|
78
|
+
async archives({ name, version }, fetch) {
|
|
79
|
+
if (isVersion(version)) {
|
|
80
|
+
return ofVersion(name, version);
|
|
81
|
+
}
|
|
82
|
+
const current = (await packagesIndex(`${mirror}PACKAGES.gz`, fetch, indices)).get(name);
|
|
83
|
+
if (current !== undefined && isVersion(current)) {
|
|
84
|
+
return ofVersion(name, current);
|
|
85
|
+
}
|
|
86
|
+
return github ? [{ url: GitHubArchive('cran', name, 'HEAD'), origin: 'cran', fallback: true }] : [];
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/** the Bioconductor repositories a package may live in */
|
|
91
|
+
const BioconductorRepositories = ['bioc', 'data/annotation', 'data/experiment', 'workflows', 'books'];
|
|
92
|
+
/** the `Package`/`Version` pairs of a `PACKAGES` index */
|
|
93
|
+
function parsePackagesIndex(index) {
|
|
94
|
+
const versions = new Map();
|
|
95
|
+
for (const entry of index.split(/\r?\n\s*\r?\n/)) {
|
|
96
|
+
const pkg = /^Package:\s*(\S+)/m.exec(entry)?.[1];
|
|
97
|
+
const version = /^Version:\s*(\S+)/m.exec(entry)?.[1];
|
|
98
|
+
if (pkg !== undefined && version !== undefined) {
|
|
99
|
+
versions.set(pkg, version);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return versions;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Bioconductor: the release tarball the repository index lists, else the GitHub mirror. A Bioconductor release
|
|
106
|
+
* only keeps its current version of a package, so an older pinned one falls back to the mirror's newest.
|
|
107
|
+
*/
|
|
108
|
+
function bioconductorSource(options = {}) {
|
|
109
|
+
const host = (options.bioconductorMirror ?? 'https://bioconductor.org').replace(/\/$/, '');
|
|
110
|
+
const release = options.bioconductorRelease ?? 'release';
|
|
111
|
+
const indices = new Map();
|
|
112
|
+
return {
|
|
113
|
+
name: 'bioconductor',
|
|
114
|
+
async archives({ name }, fetch) {
|
|
115
|
+
for (const repo of BioconductorRepositories) {
|
|
116
|
+
const version = (await packagesIndex(`${host}/packages/${release}/${repo}/src/contrib/PACKAGES`, fetch, indices)).get(name);
|
|
117
|
+
if (version !== undefined && isVersion(version)) {
|
|
118
|
+
return [
|
|
119
|
+
{ url: `${host}/packages/${release}/${repo}/src/contrib/${name}_${version}.tar.gz`, origin: 'bioconductor' },
|
|
120
|
+
...options.githubMirrors !== false ? [{ url: GitHubArchive('bioc', name, 'HEAD'), origin: 'bioconductor' }] : []
|
|
121
|
+
];
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return options.githubMirrors !== false ? [{ url: GitHubArchive('bioc', name, 'HEAD'), origin: 'bioconductor', fallback: true }] : [];
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
/** The sources flowR knows by name, configured with `options`. */
|
|
129
|
+
function builtInOnDemandSources(options = {}) {
|
|
130
|
+
return new Map([exports.GitHubSource, cranSource(options), bioconductorSource(options)].map(s => [s.name, s]));
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=remote-sources.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** How much an archive may unpack to, so a hostile or broken one cannot exhaust the memory. */
|
|
2
|
+
export interface TarLimits {
|
|
3
|
+
/** the most bytes the (decompressed) archive may hold */
|
|
4
|
+
readonly maxArchiveBytes: number;
|
|
5
|
+
/** the most bytes a single kept file may hold, a bigger one is skipped */
|
|
6
|
+
readonly maxFileBytes: number;
|
|
7
|
+
/** the most files to keep */
|
|
8
|
+
readonly maxFiles: number;
|
|
9
|
+
}
|
|
10
|
+
export declare const DefaultTarLimits: TarLimits;
|
|
11
|
+
/** the error for an archive that is not a tar (or gzip'ed tar) flowR can read */
|
|
12
|
+
export declare class TarError extends Error {
|
|
13
|
+
constructor(message: string);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The regular files of a tar archive, gzip'ed or not, whose path below the top directory `keep` accepts,
|
|
17
|
+
* all held in memory: nothing is written to disk, so no entry can reach outside of where it belongs.
|
|
18
|
+
*/
|
|
19
|
+
export declare function readTarEntries(archive: Buffer, keep: (path: string) => boolean, limits?: TarLimits): Map<string, Buffer>;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.TarError = exports.DefaultTarLimits = void 0;
|
|
7
|
+
exports.readTarEntries = readTarEntries;
|
|
8
|
+
const zlib_1 = __importDefault(require("zlib"));
|
|
9
|
+
exports.DefaultTarLimits = { maxArchiveBytes: 128 * 1024 * 1024, maxFileBytes: 8 * 1024 * 1024, maxFiles: 5000 };
|
|
10
|
+
/** the error for an archive that is not a tar (or gzip'ed tar) flowR can read */
|
|
11
|
+
class TarError extends Error {
|
|
12
|
+
constructor(message) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.name = 'TarError';
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.TarError = TarError;
|
|
18
|
+
const Block = 512;
|
|
19
|
+
function field(header, offset, length) {
|
|
20
|
+
const raw = header.subarray(offset, offset + length);
|
|
21
|
+
const end = raw.indexOf(0);
|
|
22
|
+
return raw.subarray(0, end < 0 ? raw.length : end).toString('utf8');
|
|
23
|
+
}
|
|
24
|
+
function octal(header, offset, length) {
|
|
25
|
+
/* GNU tar stores big sizes in base-256, marked by the high bit of the first byte */
|
|
26
|
+
if ((header[offset] & 0x80) !== 0) {
|
|
27
|
+
let value = 0;
|
|
28
|
+
for (let i = offset + 1; i < offset + length; i++) {
|
|
29
|
+
value = value * 256 + header[i];
|
|
30
|
+
}
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
const text = field(header, offset, length).trim();
|
|
34
|
+
const value = text.length === 0 ? 0 : parseInt(text, 8);
|
|
35
|
+
if (!Number.isFinite(value) || value < 0) {
|
|
36
|
+
throw new TarError(`invalid number "${text}" in a tar header`);
|
|
37
|
+
}
|
|
38
|
+
return value;
|
|
39
|
+
}
|
|
40
|
+
/** the `path` record of a pax extended header, which overrides the name of the entry after it */
|
|
41
|
+
function paxPath(data) {
|
|
42
|
+
let at = 0;
|
|
43
|
+
while (at < data.length) {
|
|
44
|
+
const space = data.indexOf(0x20, at);
|
|
45
|
+
if (space < 0) {
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
const length = parseInt(data.subarray(at, space).toString('ascii'), 10);
|
|
49
|
+
if (!Number.isFinite(length) || length <= 0) {
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
const record = data.subarray(space + 1, at + length - 1).toString('utf8');
|
|
53
|
+
if (record.startsWith('path=')) {
|
|
54
|
+
return record.slice(5);
|
|
55
|
+
}
|
|
56
|
+
at += length;
|
|
57
|
+
}
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
/** the path without the directory every entry of a package tarball sits in (`ggmirt-HEAD/R/a.R` becomes `R/a.R`), `undefined` for one leaving it */
|
|
61
|
+
function relativeEntryPath(name) {
|
|
62
|
+
const parts = name.replaceAll('\\', '/').split('/').filter(p => p.length > 0 && p !== '.');
|
|
63
|
+
if (parts.length < 2 || parts.includes('..') || name.startsWith('/')) {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
return parts.slice(1).join('/');
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The regular files of a tar archive, gzip'ed or not, whose path below the top directory `keep` accepts,
|
|
70
|
+
* all held in memory: nothing is written to disk, so no entry can reach outside of where it belongs.
|
|
71
|
+
*/
|
|
72
|
+
function readTarEntries(archive, keep, limits = exports.DefaultTarLimits) {
|
|
73
|
+
let tar = archive;
|
|
74
|
+
if (archive.length >= 2 && archive[0] === 0x1f && archive[1] === 0x8b) {
|
|
75
|
+
try {
|
|
76
|
+
tar = zlib_1.default.gunzipSync(archive, { maxOutputLength: limits.maxArchiveBytes });
|
|
77
|
+
}
|
|
78
|
+
catch (e) {
|
|
79
|
+
throw new TarError(`cannot decompress the archive: ${e.message}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const files = new Map();
|
|
83
|
+
let longName;
|
|
84
|
+
for (let at = 0; at + Block <= tar.length;) {
|
|
85
|
+
const header = tar.subarray(at, at + Block);
|
|
86
|
+
if (header.every(b => b === 0)) {
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
const size = octal(header, 124, 12);
|
|
90
|
+
const type = String.fromCharCode(header[156] || 0x30);
|
|
91
|
+
const start = at + Block;
|
|
92
|
+
if (start + size > tar.length) {
|
|
93
|
+
throw new TarError('the archive ends within an entry');
|
|
94
|
+
}
|
|
95
|
+
const data = tar.subarray(start, start + size);
|
|
96
|
+
at = start + Math.ceil(size / Block) * Block;
|
|
97
|
+
if (type === 'L' || type === 'x') {
|
|
98
|
+
longName = type === 'L' ? field(data, 0, data.length) : paxPath(data) ?? longName;
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
const magic = field(header, 257, 6);
|
|
102
|
+
const prefix = magic.startsWith('ustar') ? field(header, 345, 155) : '';
|
|
103
|
+
const name = longName ?? (prefix ? `${prefix}/${field(header, 0, 100)}` : field(header, 0, 100));
|
|
104
|
+
longName = undefined;
|
|
105
|
+
if (type !== '0' && type !== '\0' && type !== '7') {
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
const relative = relativeEntryPath(name);
|
|
109
|
+
if (relative === undefined || size > limits.maxFileBytes || !keep(relative)) {
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
if (files.size >= limits.maxFiles) {
|
|
113
|
+
throw new TarError(`the archive holds more than ${limits.maxFiles} wanted files`);
|
|
114
|
+
}
|
|
115
|
+
files.set(relative, Buffer.from(data));
|
|
116
|
+
}
|
|
117
|
+
return files;
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=tar.js.map
|
|
@@ -9,3 +9,8 @@ import type { BuiltInDefinitions } from '../../../../dataflow/environments/built
|
|
|
9
9
|
* wrote them down.
|
|
10
10
|
*/
|
|
11
11
|
export declare function functionInfosFromProps(props: PropSelector, except: readonly FunctionInfo[], definitions: BuiltInDefinitions): FunctionInfo[];
|
|
12
|
+
/**
|
|
13
|
+
* The entries of `entries` for built-ins telling the files they read from the ones they write ({@link FnSig.resources}),
|
|
14
|
+
* like `unzip(zipfile, exdir)`, which are entries of both categories, each with its own argument.
|
|
15
|
+
*/
|
|
16
|
+
export declare function readingAndWritingApart(entries: readonly FunctionInfo[], definitions: BuiltInDefinitions): ReadonlySet<FunctionInfo>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.functionInfosFromProps = functionInfosFromProps;
|
|
4
|
+
exports.readingAndWritingApart = readingAndWritingApart;
|
|
4
5
|
const function_semantics_1 = require("../../../../dataflow/fn/function-semantics");
|
|
5
6
|
const built_in_props_1 = require("../../../../dataflow/environments/built-in-props");
|
|
6
7
|
const query_fn_props_1 = require("../../../../dataflow/environments/query-fn-props");
|
|
@@ -29,12 +30,13 @@ function functionInfosFromProps(props, except, definitions) {
|
|
|
29
30
|
/* a bare name speaks for every package: an entry written down without one, and whatever a link points at */
|
|
30
31
|
const takenEverywhere = new Set(except.flatMap(f => [...f.package === undefined ? [f.name] : [], ...linkTargets(f)]));
|
|
31
32
|
const found = [];
|
|
33
|
+
const written = Array.isArray(props) ? props.includes(built_in_props_1.SemanticCallTag.Writes) : props === built_in_props_1.SemanticCallTag.Writes;
|
|
32
34
|
for (const d of definitions) {
|
|
33
35
|
const info = d.type !== 'constant' ? d.config : undefined;
|
|
34
36
|
if (info?.sig === undefined || !function_semantics_1.FunctionSemantics.call.props.hasAny(info) || !function_semantics_1.FunctionSemantics.call.props.hasAll(info, props)) {
|
|
35
37
|
continue;
|
|
36
38
|
}
|
|
37
|
-
const argIdx = info.sig.findIndex(([, p]) => (p & built_in_props_1.ArgProp.Resource) !== 0);
|
|
39
|
+
const argIdx = built_in_props_1.FnSig.resources(info.sig, written).findIndex(([, p]) => (p & built_in_props_1.ArgProp.Resource) !== 0);
|
|
38
40
|
if (argIdx < 0) {
|
|
39
41
|
continue;
|
|
40
42
|
}
|
|
@@ -49,4 +51,18 @@ function functionInfosFromProps(props, except, definitions) {
|
|
|
49
51
|
}
|
|
50
52
|
return found;
|
|
51
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* The entries of `entries` for built-ins telling the files they read from the ones they write ({@link FnSig.resources}),
|
|
56
|
+
* like `unzip(zipfile, exdir)`, which are entries of both categories, each with its own argument.
|
|
57
|
+
*/
|
|
58
|
+
function readingAndWritingApart(entries, definitions) {
|
|
59
|
+
const apart = new Set();
|
|
60
|
+
for (const d of definitions) {
|
|
61
|
+
const sig = d.type !== 'constant' ? d.config?.sig : undefined;
|
|
62
|
+
if (sig !== undefined && built_in_props_1.FnSig.resources(sig, true) !== sig) {
|
|
63
|
+
(0, query_fn_props_1.builtInNames)(d).forEach(id => apart.add(identifier_1.Identifier.toString(id)));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return new Set(entries.filter(f => apart.has(writtenAs(f))));
|
|
67
|
+
}
|
|
52
68
|
//# sourceMappingURL=derived-functions.js.map
|
|
@@ -46,8 +46,10 @@ const ReadFunctionsWithMore = [
|
|
|
46
46
|
];
|
|
47
47
|
/** The read entries the given built-in definitions imply, together with the ones written down here. */
|
|
48
48
|
function computeReadFunctions(definitions) {
|
|
49
|
+
/* copying reads the file it copies */
|
|
50
|
+
const apart = (0, derived_functions_1.readingAndWritingApart)(other_path_functions_1.OtherPathFunctions, definitions);
|
|
49
51
|
return [
|
|
50
|
-
...(0, derived_functions_1.functionInfosFromProps)([built_in_props_1.SemanticCallTag.File, built_in_props_1.SemanticCallTag.Reads], [...ReadFunctionsWithMore, ...other_path_functions_1.OtherPathFunctions, ...source_functions_1.SourceFunctions], definitions),
|
|
52
|
+
...(0, derived_functions_1.functionInfosFromProps)([built_in_props_1.SemanticCallTag.File, built_in_props_1.SemanticCallTag.Reads], [...ReadFunctionsWithMore, ...other_path_functions_1.OtherPathFunctions.filter(f => !apart.has(f)), ...source_functions_1.SourceFunctions], definitions),
|
|
51
53
|
...ReadFunctionsWithMore
|
|
52
54
|
];
|
|
53
55
|
}
|
|
@@ -15,6 +15,8 @@ const OutputRedirects = [
|
|
|
15
15
|
const WriteFunctionsWithMore = [
|
|
16
16
|
{ package: 'base', name: 'save.image', argIdx: 0, argName: 'file', resolveValue: true, defaultValue: '.RData' },
|
|
17
17
|
{ package: 'utils', name: 'write.csv', argIdx: 1, argName: 'file', resolveValue: true },
|
|
18
|
+
/* the write happens in the `GET` it configures, which the dataflow cannot tell, so only this category knows it */
|
|
19
|
+
{ package: 'httr', name: 'write_disk', argIdx: 0, argName: 'path', resolveValue: true },
|
|
18
20
|
/* without a `plot`, it saves `last_plot()` */
|
|
19
21
|
{ package: 'ggplot2', name: 'ggsave', argIdx: 0, argName: 'filename', resolveValue: true, linkTo: [default_builtin_config_1.LinkToLastGgPlot] },
|
|
20
22
|
{
|
|
@@ -53,6 +55,13 @@ const WriteFunctionsWithMore = [
|
|
|
53
55
|
{ package: 'base', name: 'file.symlink', argIdx: 1, argName: 'to', resolveValue: true },
|
|
54
56
|
{ package: 'base', name: 'file.link', argIdx: 1, argName: 'to', resolveValue: true },
|
|
55
57
|
{ package: 'utils', name: 'download.file', argIdx: 1, argName: 'destfile', resolveValue: true },
|
|
58
|
+
/* an archive unpacks into the working directory unless told otherwise */
|
|
59
|
+
{ package: 'utils', name: 'unzip', argIdx: 5, argName: 'exdir', resolveValue: true, defaultValue: '.', invisible: true },
|
|
60
|
+
{ package: 'utils', name: 'untar', argIdx: 3, argName: 'exdir', resolveValue: true, defaultValue: '.', invisible: true },
|
|
61
|
+
{ package: 'zip', name: 'unzip', argIdx: 4, argName: 'exdir', resolveValue: true, defaultValue: '.', invisible: true },
|
|
62
|
+
{ package: 'archive', name: 'archive_extract', argIdx: 1, argName: 'dir', resolveValue: true, defaultValue: '.', invisible: true },
|
|
63
|
+
/* the name the file has with the extension added or dropped, `Unknown` of the query format, which imports this module */
|
|
64
|
+
...['gzip', 'gunzip', 'bzip2', 'bunzip2', 'compressFile', 'decompressFile'].map(name => ({ package: 'R.utils', name, argIdx: 1, argName: 'destname', resolveValue: true, defaultValue: 'unknown', invisible: true })),
|
|
56
65
|
{ package: 'base', name: 'file', argIdx: 0, argName: 'description', resolveValue: true, ignoreIf: 'mode-only-read', additionalArgs: { mode: { argIdx: 1, argName: 'open', resolveValue: true } } },
|
|
57
66
|
{ package: 'base', name: 'url', argIdx: 0, argName: 'description', resolveValue: true, ignoreIf: 'mode-only-read', additionalArgs: { mode: { argIdx: 1, argName: 'open', resolveValue: true } } },
|
|
58
67
|
{ package: 'grDevices', name: 'jpeg', argIdx: 0, argName: 'filename', resolveValue: true },
|
|
@@ -97,8 +106,9 @@ const WriteFunctionsWithMore = [
|
|
|
97
106
|
];
|
|
98
107
|
/** The write entries the given built-in definitions imply, together with the ones written down here. */
|
|
99
108
|
function computeWriteFunctions(definitions, read = (0, read_functions_1.computeReadFunctions)(definitions)) {
|
|
109
|
+
const apart = (0, derived_functions_1.readingAndWritingApart)(read, definitions);
|
|
100
110
|
return [
|
|
101
|
-
...(0, derived_functions_1.functionInfosFromProps)([built_in_props_1.SemanticCallTag.File, built_in_props_1.SemanticCallTag.Writes], [...WriteFunctionsWithMore, ...other_path_functions_1.OtherPathFunctions, ...read], definitions),
|
|
111
|
+
...(0, derived_functions_1.functionInfosFromProps)([built_in_props_1.SemanticCallTag.File, built_in_props_1.SemanticCallTag.Writes], [...WriteFunctionsWithMore, ...other_path_functions_1.OtherPathFunctions, ...read.filter(f => !apart.has(f))], definitions),
|
|
102
112
|
...WriteFunctionsWithMore
|
|
103
113
|
];
|
|
104
114
|
}
|
|
@@ -401,6 +401,20 @@ function signatureCallGraphUrl(src, pkg, version, root, maxNodes) {
|
|
|
401
401
|
const subgraphs = [...byOwner].flatMap(([owner, decls]) => [` subgraph ${owner}`, ...decls, ' end']);
|
|
402
402
|
return mermaid_1.Mermaid.codeToUrl(['flowchart LR', ...subgraphs, ...ungrouped, ...edges].join('\n'));
|
|
403
403
|
}
|
|
404
|
+
/** what `library(pkg)` puts on the search path besides `pkg`: its `Depends` and a meta-package's core set, and theirs in turn */
|
|
405
|
+
function attachedClosure(src, pkg, version) {
|
|
406
|
+
const attached = new Set([pkg]);
|
|
407
|
+
const visit = (p, at) => {
|
|
408
|
+
const { depends, onAttach } = (0, attached_packages_1.attachedAlongside)(p, [src], at);
|
|
409
|
+
for (const next of [...depends, ...onAttach].filter(n => !attached.has(n))) {
|
|
410
|
+
attached.add(next);
|
|
411
|
+
visit(next, undefined);
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
visit(pkg, version);
|
|
415
|
+
attached.delete(pkg);
|
|
416
|
+
return [...attached];
|
|
417
|
+
}
|
|
404
418
|
/** the full view of a package: version, kind, export breakdown, dependencies, and every function's view */
|
|
405
419
|
function signaturePackageInfo(src, pkg, resolved) {
|
|
406
420
|
const exports = src.lookup(pkg, resolved) ?? src.lookup(pkg);
|
|
@@ -414,7 +428,7 @@ function signaturePackageInfo(src, pkg, resolved) {
|
|
|
414
428
|
const deps = (src.dependencies(pkg, resolved) ?? src.dependencies(pkg) ?? [])
|
|
415
429
|
.map(d => (0, objects_1.compactRecord)({ type: schema_1.DepTypeNames[d.type], name: d.name, constraint: d.constraint }));
|
|
416
430
|
const release = src.releaseDate(pkg, resolved);
|
|
417
|
-
const attaches = (
|
|
431
|
+
const attaches = attachedClosure(src, pkg, resolved);
|
|
418
432
|
return (0, objects_1.compactRecord)({
|
|
419
433
|
name: pkg,
|
|
420
434
|
version: exports.version,
|
|
@@ -161,8 +161,9 @@ export interface SignaturePackageView {
|
|
|
161
161
|
readonly coreVersions?: readonly string[];
|
|
162
162
|
readonly dependencies: readonly SignatureDependencyView[];
|
|
163
163
|
/**
|
|
164
|
-
* The packages that end up on the search path together with this one,
|
|
165
|
-
* mistaken for everything `library(<name>)` brings into
|
|
164
|
+
* The packages that end up on the search path together with this one, its `Depends` and a meta-package's core set,
|
|
165
|
+
* and theirs in turn, so that {@link exportsTotal} is not mistaken for everything `library(<name>)` brings into
|
|
166
|
+
* scope. Only what the database states; the analysis itself answers with `Dataflow.library.attaches`.
|
|
166
167
|
*/
|
|
167
168
|
readonly attaches?: readonly string[];
|
|
168
169
|
readonly functions: readonly SignatureFunctionView[];
|