@eagleoutice/flowr 2.13.0 → 2.13.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 +23 -23
- package/cli/common/options.d.ts +10 -0
- package/cli/common/options.js +2 -0
- package/cli/common/scripts-info.d.ts +10 -0
- package/cli/flowr.js +21 -5
- package/cli/repl/commands/repl-commands.d.ts +8 -0
- package/cli/repl/commands/repl-commands.js +27 -12
- package/cli/repl/commands/repl-query.js +9 -1
- package/cli/repl/commands/repl-signature.js +8 -1
- package/cli/repl/core.js +13 -10
- package/cli/repl/print-version.js +1 -1
- package/cli/repl/server/connection.d.ts +1 -1
- package/cli/repl/server/net.js +15 -0
- package/cli/slicer-app.d.ts +2 -0
- package/cli/slicer-app.js +2 -1
- package/config.d.ts +31 -0
- package/config.js +55 -2
- package/data/sigdb/sigdb.remote.json +1 -1
- package/dataflow/environments/identifier.d.ts +9 -8
- package/dataflow/environments/identifier.js +21 -13
- package/dataflow/eval/resolve/resolve-working-directory.d.ts +29 -0
- package/dataflow/eval/resolve/resolve-working-directory.js +168 -0
- package/dataflow/extractor.js +2 -1
- package/dataflow/graph/df-helper.d.ts +3 -2
- package/dataflow/graph/df-helper.js +11 -15
- package/dataflow/graph/diff-dataflow-graph.js +1 -1
- package/dataflow/graph/graph-helper.js +2 -6
- package/dataflow/graph/graph.d.ts +24 -0
- package/dataflow/graph/graph.js +25 -1
- package/documentation/wiki-interface.js +1 -0
- package/documentation/wiki-linter.js +1 -0
- package/documentation/wiki-mk/doc-context.d.ts +10 -0
- package/documentation/wiki-mk/doc-context.js +3 -0
- package/documentation/wiki-query.js +4 -3
- package/documentation/wiki-signature-database.js +16 -6
- package/linter/linter-rules.d.ts +24 -2
- package/linter/linter-rules.js +3 -1
- package/linter/rules/absolute-path.d.ts +4 -4
- package/linter/rules/absolute-path.js +7 -5
- package/linter/rules/file-path-validity.d.ts +1 -1
- package/linter/rules/file-path-validity.js +48 -8
- package/linter/rules/function-finder-util.d.ts +2 -1
- package/linter/rules/syntactically-valid.d.ts +58 -0
- package/linter/rules/syntactically-valid.js +203 -0
- package/linter/rules/undefined-symbol.js +3 -2
- package/package.json +5 -4
- package/project/context/classify-project-kind.d.ts +40 -0
- package/project/context/classify-project-kind.js +76 -0
- package/project/context/flowr-analyzer-context.d.ts +2 -0
- package/project/context/flowr-analyzer-context.js +6 -0
- package/project/context/flowr-analyzer-dependencies-context.d.ts +23 -4
- package/project/context/flowr-analyzer-dependencies-context.js +23 -1
- package/project/context/flowr-analyzer-files-context.d.ts +18 -8
- package/project/context/flowr-analyzer-files-context.js +66 -68
- package/project/context/flowr-file.d.ts +5 -0
- package/project/context/flowr-file.js +5 -0
- package/project/dependency-version-space.d.ts +3 -1
- package/project/dependency-version-space.js +26 -20
- package/project/flowr-analyzer.d.ts +3 -0
- package/project/flowr-analyzer.js +4 -0
- package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.d.ts +12 -4
- package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.js +25 -10
- package/project/plugins/plugin-registry.d.ts +2 -1
- package/project/plugins/plugin-registry.js +4 -1
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.d.ts +57 -2
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +150 -28
- package/project/sigdb/decompress.d.ts +1 -1
- package/project/sigdb/decompress.js +4 -1
- package/project/sigdb/manifest.js +60 -26
- package/project/sigdb/sigdb-download.d.ts +6 -7
- package/project/sigdb/sigdb-download.js +30 -9
- package/queries/catalog/config-query/config-query-executor.js +3 -0
- package/queries/catalog/config-query/config-query-format.d.ts +5 -3
- package/queries/catalog/config-query/config-query-format.js +31 -21
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +0 -10
- package/queries/catalog/dependencies-query/dependencies-query-format.js +0 -106
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +21 -5
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +4 -2
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +17 -3
- package/queries/catalog/linter-query/linter-query-format.js +9 -2
- package/queries/catalog/signature-query/signature-query-executor.js +3 -0
- package/queries/catalog/signature-query/signature-query-render.js +4 -4
- package/queries/query.d.ts +4 -4
- package/queries/query.js +9 -2
- package/r-bridge/data/data.d.ts +5 -0
- package/r-bridge/data/data.js +6 -0
- package/r-bridge/retriever.js +6 -1
- package/r-bridge/shell.js +5 -0
- package/search/flowr-search-filters.d.ts +2 -1
- package/util/files.d.ts +6 -4
- package/util/files.js +30 -8
- package/util/mermaid/dfg.js +1 -1
- package/util/schema.d.ts +2 -0
- package/util/schema.js +13 -0
- package/util/text/ansi.d.ts +7 -3
- package/util/text/ansi.js +8 -5
- package/util/version.js +4 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DefaultFixpointIterations = exports.DefaultExplodeLimit = void 0;
|
|
3
|
+
exports.NoDisabledSources = exports.DefaultFixpointIterations = exports.DefaultExplodeLimit = void 0;
|
|
4
4
|
exports.dateCutoff = dateCutoff;
|
|
5
5
|
exports.isoDay = isoDay;
|
|
6
6
|
exports.collectUsage = collectUsage;
|
|
@@ -393,27 +393,34 @@ function versionMeetsPartners(src, pkg, ver, partnerSurvivors, selfName, onRejec
|
|
|
393
393
|
}
|
|
394
394
|
return true;
|
|
395
395
|
}
|
|
396
|
+
/** an empty set, shared so callers that do not disable anything need not allocate one */
|
|
397
|
+
exports.NoDisabledSources = new Set();
|
|
396
398
|
/**
|
|
397
399
|
* Filter a version timeline by the declared range, transitive constraints, base-R version bound, and date cutoff,
|
|
398
400
|
* emitting each constraint to `observe` (when given) as it is applied -- so the filtering and its explanation cannot
|
|
399
|
-
* drift apart.
|
|
401
|
+
* drift apart. A source in `disabled` is skipped entirely: neither filtered on nor reported as evidence.
|
|
400
402
|
*/
|
|
401
|
-
function applyConstraints(timeline, name, declaredRange, declaredConstraints, transitive, base, rVersion, cutoff, observe) {
|
|
402
|
-
|
|
403
|
-
|
|
403
|
+
function applyConstraints(timeline, name, declaredRange, declaredConstraints, transitive, base, rVersion, cutoff, observe, disabled = exports.NoDisabledSources) {
|
|
404
|
+
let t = [...timeline];
|
|
405
|
+
if (!disabled.has('declared')) {
|
|
406
|
+
for (const c of declaredConstraints) {
|
|
407
|
+
observe?.({ source: 'declared', origin: 'project metadata', detail: `declared as ${c}`, bound: c });
|
|
408
|
+
}
|
|
409
|
+
t = declaredRange ? t.filter(e => r_version_1.RRange.satisfies(e.ver, declaredRange)) : t;
|
|
404
410
|
}
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
411
|
+
if (!disabled.has('transitive')) {
|
|
412
|
+
for (const c of transitive) {
|
|
413
|
+
observe?.({ source: 'transitive', origin: c.from, detail: `${c.from} requires ${name} ${c.range.raw}`, bound: c.range.raw });
|
|
414
|
+
t = t.filter(e => r_version_1.RRange.satisfies(e.ver, c.range));
|
|
415
|
+
}
|
|
409
416
|
}
|
|
410
417
|
// a base package's version *is* the R version, so it is bounded by the assumed/declared R (only when that is known)
|
|
411
|
-
const rv = base && rVersion ? r_version_1.RVersion.parse(rVersion) : undefined;
|
|
418
|
+
const rv = !disabled.has('base-r') && base && rVersion ? r_version_1.RVersion.parse(rVersion) : undefined;
|
|
412
419
|
if (rv) {
|
|
413
420
|
observe?.({ source: 'base-r', origin: `R ${rVersion}`, detail: `base package bounded by R ${rVersion}`, bound: `<=${rVersion}` });
|
|
414
421
|
t = t.filter(e => r_version_1.RVersion.compare(e.ver, rv.str) <= 0);
|
|
415
422
|
}
|
|
416
|
-
if (cutoff) {
|
|
423
|
+
if (cutoff && !disabled.has('date')) {
|
|
417
424
|
observe?.({ source: 'date', origin: isoDay(cutoff), detail: `only releases up to ${isoDay(cutoff)}`, bound: `<=${isoDay(cutoff)}` });
|
|
418
425
|
// base R is stored undated, so fall back to its R release date; a dated release must predate the cutoff, and an
|
|
419
426
|
// undated one is dropped -- except base R older than the release table (kept, as it predates any real cutoff)
|
|
@@ -428,13 +435,12 @@ function applyConstraints(timeline, name, declaredRange, declaredConstraints, tr
|
|
|
428
435
|
* Apply every constraint (declared, transitive, base-R, date, then signature usage) to a package's timeline. When an
|
|
429
436
|
* `observe` callback is given, emits the provenance of each constraint (including the signature lower bounds).
|
|
430
437
|
*/
|
|
431
|
-
function survivingEntries(name, src, deps, usage, transitive, cutoff, rVersion, observe,
|
|
438
|
+
function survivingEntries(name, src, deps, usage, transitive, cutoff, rVersion, observe, disabled = exports.NoDisabledSources, packageKey = name) {
|
|
432
439
|
// packageKey: sigdb package (R reuses base, others use themselves)
|
|
433
440
|
const getFn = makeFnResolver(src, packageKey);
|
|
434
|
-
|
|
435
|
-
const
|
|
436
|
-
const
|
|
437
|
-
const effectiveTransitive = ignoreDeclared ? [] : transitive;
|
|
441
|
+
const declaredRange = disabled.has('declared') ? undefined : deps.inferredVersion(name);
|
|
442
|
+
const declaredConstraints = disabled.has('declared') ? [] : (deps.getDependency(name)?.versionConstraints.map(c => c.raw) ?? []);
|
|
443
|
+
const effectiveTransitive = disabled.has('transitive') ? [] : transitive;
|
|
438
444
|
// contradiction is a constraint property, not an empty database
|
|
439
445
|
const unsatisfiable = constraintsContradict(declaredConstraints, declaredRange, effectiveTransitive);
|
|
440
446
|
if (!src) {
|
|
@@ -444,12 +450,12 @@ function survivingEntries(name, src, deps, usage, transitive, cutoff, rVersion,
|
|
|
444
450
|
const timeline = versionTimeline(src, packageKey);
|
|
445
451
|
const total = timeline.length;
|
|
446
452
|
// emit database coverage envelope as outer bounds
|
|
447
|
-
if (observe && timeline.length > 0) {
|
|
453
|
+
if (observe && timeline.length > 0 && !disabled.has('available')) {
|
|
448
454
|
observe({ source: 'available', origin: 'signature database', detail: `data available from ${timeline[0].ver}`, bound: `>=${timeline[0].ver}` });
|
|
449
455
|
observe({ source: 'available', origin: 'signature database', detail: `data available up to ${timeline[timeline.length - 1].ver}`, bound: `<=${timeline[timeline.length - 1].ver}` });
|
|
450
456
|
}
|
|
451
|
-
const preSignature = applyConstraints(timeline, name, declaredRange, declaredConstraints, effectiveTransitive, base, rVersion, cutoff, observe);
|
|
452
|
-
if (!usage) {
|
|
457
|
+
const preSignature = applyConstraints(timeline, name, declaredRange, declaredConstraints, effectiveTransitive, base, rVersion, cutoff, observe, disabled);
|
|
458
|
+
if (!usage || disabled.has('signature')) {
|
|
453
459
|
return { survivors: preSignature, preSignature, getFn, declaredRange, declaredConstraints, base, unsatisfiable, total };
|
|
454
460
|
}
|
|
455
461
|
// exclude base primitives from base packages (captured inconsistently, so absence is data gap not removal)
|
|
@@ -543,7 +549,7 @@ async function orderedCandidatesFor(analyzer, options) {
|
|
|
543
549
|
for (const name of targets.sort()) {
|
|
544
550
|
const packageKey = timelinePackageKey(name, sources);
|
|
545
551
|
const src = (0, reader_1.sourceForPackage)(sources, packageKey);
|
|
546
|
-
const surviving = survivingEntries(name, src, deps, usage.get(name), transitive.get(name) ?? [], cutoff, rVersion, undefined,
|
|
552
|
+
const surviving = survivingEntries(name, src, deps, usage.get(name), transitive.get(name) ?? [], cutoff, rVersion, undefined, exports.NoDisabledSources, packageKey);
|
|
547
553
|
const oc = orderedCandidatesOf(src, name, surviving, options.prefer?.[name], order);
|
|
548
554
|
if (oc) {
|
|
549
555
|
out.push(oc);
|
|
@@ -143,6 +143,8 @@ export interface ReadonlyFlowrAnalysisProvider<Parser extends KnownParser = Know
|
|
|
143
143
|
flowrConfig: FlowrConfig;
|
|
144
144
|
/** Merge a runtime update into the base config and invalidate the derived config and cached analysis, so it takes effect. */
|
|
145
145
|
updateConfig(update: DeepPartial<FlowrConfig>): void;
|
|
146
|
+
/** Discard every {@link updateConfig} override made so far and invalidate the cached analysis. */
|
|
147
|
+
resetConfig(): void;
|
|
146
148
|
}
|
|
147
149
|
/**
|
|
148
150
|
* Central class for conducting analyses with FlowR.
|
|
@@ -174,6 +176,7 @@ export declare class FlowrAnalyzer<Parser extends KnownParser = KnownParser> imp
|
|
|
174
176
|
inspectContext(): ReadOnlyFlowrAnalyzerContext;
|
|
175
177
|
reset(): void;
|
|
176
178
|
updateConfig(update: DeepPartial<FlowrConfig>): void;
|
|
179
|
+
resetConfig(): void;
|
|
177
180
|
parseStandalone(data: `${typeof fileProtocol}${string}` | string | RParseRequest): Tree;
|
|
178
181
|
normalizeStandalone(data: `${typeof fileProtocol}${string}` | string | RParseRequest): NormalizedAst;
|
|
179
182
|
addRequest(...request: (RAnalysisRequest | readonly RAnalysisRequest[] | `${typeof fileProtocol}${string}` | string)[]): this;
|
|
@@ -60,6 +60,10 @@ class FlowrAnalyzer {
|
|
|
60
60
|
// the parse/dataflow results were computed under the previous config, so they must be recomputed
|
|
61
61
|
this.cache.reset();
|
|
62
62
|
}
|
|
63
|
+
resetConfig() {
|
|
64
|
+
this.ctx.resetConfig();
|
|
65
|
+
this.cache.reset();
|
|
66
|
+
}
|
|
63
67
|
parseStandalone(data) {
|
|
64
68
|
const request = (0, retriever_1.isParseRequest)(data) ? data : (0, retriever_1.requestFromInput)(data);
|
|
65
69
|
if (this.parser.name === 'tree-sitter') {
|
|
@@ -5,13 +5,21 @@ import type { FlowrAnalyzerContext } from '../../context/flowr-analyzer-context'
|
|
|
5
5
|
import type { FlowrFileProvider } from '../../context/flowr-file';
|
|
6
6
|
/** `Rprofile.site` is the site-wide, `.Rprofile` the user/project profile. */
|
|
7
7
|
export declare const RprofileFilePattern: RegExp;
|
|
8
|
-
/**
|
|
8
|
+
/** `.Renviron` is the user/project environment file, `Renviron.site` the site-wide one. */
|
|
9
|
+
export declare const RenvironFilePattern: RegExp;
|
|
10
|
+
/**
|
|
11
|
+
* Marks R startup files: profiles (`.Rprofile`, `Rprofile.site`) are R source, so they get
|
|
12
|
+
* {@link FileRole.Startup} and {@link FileRole.Source}; environment files (`.Renviron`, `Renviron.site`) hold
|
|
13
|
+
* `KEY=value` definitions rather than R code, so they only get {@link FileRole.Environment}.
|
|
14
|
+
* The {@link FlowrAnalyzerLoadingOrderRprofilePlugin} moves the profile files to the front of the loading order.
|
|
15
|
+
*/
|
|
9
16
|
export declare class FlowrAnalyzerRprofileFilePlugin extends FlowrAnalyzerFilePlugin {
|
|
10
17
|
readonly name = "flowr-analyzer-rprofile-file-plugin";
|
|
11
|
-
readonly description = "Marks R startup
|
|
18
|
+
readonly description = "Marks R startup files (.Rprofile, Rprofile.site, .Renviron, Renviron.site).";
|
|
12
19
|
readonly version: SemVer;
|
|
13
|
-
private readonly
|
|
14
|
-
|
|
20
|
+
private readonly profilePattern;
|
|
21
|
+
private readonly environPattern;
|
|
22
|
+
constructor(profilePattern?: RegExp, environPattern?: RegExp);
|
|
15
23
|
applies(file: PathLike): boolean;
|
|
16
24
|
process(_ctx: FlowrAnalyzerContext, file: FlowrFileProvider): [FlowrFileProvider, true];
|
|
17
25
|
}
|
|
@@ -1,28 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FlowrAnalyzerRprofileFilePlugin = exports.RprofileFilePattern = void 0;
|
|
3
|
+
exports.FlowrAnalyzerRprofileFilePlugin = exports.RenvironFilePattern = exports.RprofileFilePattern = 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 built_in_source_1 = require("../../../dataflow/internal/process/functions/call/built-in/built-in-source");
|
|
8
8
|
/** `Rprofile.site` is the site-wide, `.Rprofile` the user/project profile. */
|
|
9
9
|
exports.RprofileFilePattern = /^(\.Rprofile|Rprofile\.site)$/i;
|
|
10
|
-
/**
|
|
10
|
+
/** `.Renviron` is the user/project environment file, `Renviron.site` the site-wide one. */
|
|
11
|
+
exports.RenvironFilePattern = /^(\.Renviron|Renviron\.site)$/i;
|
|
12
|
+
/**
|
|
13
|
+
* Marks R startup files: profiles (`.Rprofile`, `Rprofile.site`) are R source, so they get
|
|
14
|
+
* {@link FileRole.Startup} and {@link FileRole.Source}; environment files (`.Renviron`, `Renviron.site`) hold
|
|
15
|
+
* `KEY=value` definitions rather than R code, so they only get {@link FileRole.Environment}.
|
|
16
|
+
* The {@link FlowrAnalyzerLoadingOrderRprofilePlugin} moves the profile files to the front of the loading order.
|
|
17
|
+
*/
|
|
11
18
|
class FlowrAnalyzerRprofileFilePlugin extends flowr_analyzer_file_plugin_1.FlowrAnalyzerFilePlugin {
|
|
12
19
|
name = 'flowr-analyzer-rprofile-file-plugin';
|
|
13
|
-
description = 'Marks R startup
|
|
14
|
-
version = new semver_1.SemVer('0.
|
|
15
|
-
|
|
16
|
-
|
|
20
|
+
description = 'Marks R startup files (.Rprofile, Rprofile.site, .Renviron, Renviron.site).';
|
|
21
|
+
version = new semver_1.SemVer('0.2.0');
|
|
22
|
+
profilePattern;
|
|
23
|
+
environPattern;
|
|
24
|
+
constructor(profilePattern = exports.RprofileFilePattern, environPattern = exports.RenvironFilePattern) {
|
|
17
25
|
super();
|
|
18
|
-
this.
|
|
26
|
+
this.profilePattern = profilePattern;
|
|
27
|
+
this.environPattern = environPattern;
|
|
19
28
|
}
|
|
20
29
|
applies(file) {
|
|
21
|
-
|
|
30
|
+
const base = (0, built_in_source_1.platformBasename)(file.toString());
|
|
31
|
+
return this.profilePattern.test(base) || this.environPattern.test(base);
|
|
22
32
|
}
|
|
23
33
|
process(_ctx, file) {
|
|
24
|
-
|
|
25
|
-
|
|
34
|
+
if (this.environPattern.test((0, built_in_source_1.platformBasename)(file.path()))) {
|
|
35
|
+
file.assignRole(flowr_file_1.FileRole.Environment);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
file.assignRole(flowr_file_1.FileRole.Startup);
|
|
39
|
+
file.assignRole(flowr_file_1.FileRole.Source);
|
|
40
|
+
}
|
|
26
41
|
return [file, true];
|
|
27
42
|
}
|
|
28
43
|
}
|
|
@@ -23,12 +23,13 @@ import { FlowrAnalyzerMetaRProjectFilePlugin } from './package-version-plugins/f
|
|
|
23
23
|
import { FlowrAnalyzerMetaDescriptionFilePlugin } from './package-version-plugins/flowr-analyzer-meta-description-file-plugin';
|
|
24
24
|
import { FlowrAnalyzerSweaveFilePlugin } from './file-plugins/notebooks/flowr-analyzer-sweave-file-plugin';
|
|
25
25
|
import { FlowrAnalyzerGitignoreProjectDiscoveryPlugin, FlowrAnalyzerIgnoreFileProjectDiscoveryPlugin, FlowrAnalyzerRbuildignoreProjectDiscoveryPlugin } from './project-discovery/flowr-analyzer-ignore-file-project-discovery-plugin';
|
|
26
|
+
import { FlowrAnalyzerDefaultProjectDiscoveryPlugin, FlowrAnalyzerFullProjectDiscoveryPlugin } from './project-discovery/flowr-analyzer-project-discovery-plugin';
|
|
26
27
|
import { FlowrAnalyzerRprofileFilePlugin } from './file-plugins/flowr-analyzer-rprofile-file-plugin';
|
|
27
28
|
import { FlowrAnalyzerLoadingOrderRprofilePlugin } from './loading-order-plugins/flowr-analyzer-loading-order-rprofile-plugin';
|
|
28
29
|
/**
|
|
29
30
|
* The built-in Flowr Analyzer plugins that are always available.
|
|
30
31
|
*/
|
|
31
|
-
export declare const BuiltInPlugins: [["file:description", typeof FlowrAnalyzerDescriptionFilePlugin], ["versions:description", typeof FlowrAnalyzerPackageVersionsDescriptionFilePlugin], ["versions:sigdb", typeof FlowrAnalyzerPackageVersionsSigDbPlugin], ["versions:renv", typeof FlowrAnalyzerPackageVersionsRenvPlugin], ["versions:rv", typeof FlowrAnalyzerPackageVersionsRvPlugin], ["versions:packrat", typeof FlowrAnalyzerPackageVersionsPackratPlugin], ["versions:session-info", typeof FlowrAnalyzerPackageVersionsSessionInfoPlugin], ["loading-order:description", typeof FlowrAnalyzerLoadingOrderDescriptionFilePlugin], ["loading-order:implicit-sources", typeof FlowrAnalyzerLoadingOrderImplicitSourcesPlugin], ["loading-order:rprofile", typeof FlowrAnalyzerLoadingOrderRprofilePlugin], ["meta:description", typeof FlowrAnalyzerMetaDescriptionFilePlugin], ["meta:rproject", typeof FlowrAnalyzerMetaRProjectFilePlugin], ["file-roles:vignette", typeof FlowrAnalyzerMetaVignetteFilesPlugin], ["file-roles:test", typeof FlowrAnalyzerMetaTestFilesPlugin], ["file-roles:inst", typeof FlowrAnalyzerMetaInstFilesPlugin], ["file:rmd", typeof FlowrAnalyzerRmdFilePlugin], ["file:qmd", typeof FlowrAnalyzerQmdFilePlugin], ["file:rnw", typeof FlowrAnalyzerSweaveFilePlugin], ["file:ipynb", typeof FlowrAnalyzerJupyterFilePlugin], ["file:namespace", typeof FlowrAnalyzerNamespaceFilesPlugin], ["versions:namespace", typeof FlowrAnalyzerPackageVersionsNamespaceFilePlugin], ["file:news", typeof FlowrAnalyzerNewsFilePlugin], ["file:rda", typeof FlowrAnalyzerRdaFilePlugin], ["file:license", typeof FlowrAnalyzerLicenseFilePlugin], ["file:virtualenv", typeof FlowrAnalyzerVirtualEnvFilePlugin], ["file:rproject", typeof FlowrAnalyzerRProjectFilePlugin], ["file:rprofile", typeof FlowrAnalyzerRprofileFilePlugin], ["project-discovery:gitignore", typeof FlowrAnalyzerGitignoreProjectDiscoveryPlugin], ["project-discovery:rbuildignore", typeof FlowrAnalyzerRbuildignoreProjectDiscoveryPlugin], ["project-discovery:ignore-files", typeof FlowrAnalyzerIgnoreFileProjectDiscoveryPlugin]];
|
|
32
|
+
export declare const BuiltInPlugins: [["file:description", typeof FlowrAnalyzerDescriptionFilePlugin], ["versions:description", typeof FlowrAnalyzerPackageVersionsDescriptionFilePlugin], ["versions:sigdb", typeof FlowrAnalyzerPackageVersionsSigDbPlugin], ["versions:renv", typeof FlowrAnalyzerPackageVersionsRenvPlugin], ["versions:rv", typeof FlowrAnalyzerPackageVersionsRvPlugin], ["versions:packrat", typeof FlowrAnalyzerPackageVersionsPackratPlugin], ["versions:session-info", typeof FlowrAnalyzerPackageVersionsSessionInfoPlugin], ["loading-order:description", typeof FlowrAnalyzerLoadingOrderDescriptionFilePlugin], ["loading-order:implicit-sources", typeof FlowrAnalyzerLoadingOrderImplicitSourcesPlugin], ["loading-order:rprofile", typeof FlowrAnalyzerLoadingOrderRprofilePlugin], ["meta:description", typeof FlowrAnalyzerMetaDescriptionFilePlugin], ["meta:rproject", typeof FlowrAnalyzerMetaRProjectFilePlugin], ["file-roles:vignette", typeof FlowrAnalyzerMetaVignetteFilesPlugin], ["file-roles:test", typeof FlowrAnalyzerMetaTestFilesPlugin], ["file-roles:inst", typeof FlowrAnalyzerMetaInstFilesPlugin], ["file:rmd", typeof FlowrAnalyzerRmdFilePlugin], ["file:qmd", typeof FlowrAnalyzerQmdFilePlugin], ["file:rnw", typeof FlowrAnalyzerSweaveFilePlugin], ["file:ipynb", typeof FlowrAnalyzerJupyterFilePlugin], ["file:namespace", typeof FlowrAnalyzerNamespaceFilesPlugin], ["versions:namespace", typeof FlowrAnalyzerPackageVersionsNamespaceFilePlugin], ["file:news", typeof FlowrAnalyzerNewsFilePlugin], ["file:rda", typeof FlowrAnalyzerRdaFilePlugin], ["file:license", typeof FlowrAnalyzerLicenseFilePlugin], ["file:virtualenv", typeof FlowrAnalyzerVirtualEnvFilePlugin], ["file:rproject", typeof FlowrAnalyzerRProjectFilePlugin], ["file:rprofile", typeof FlowrAnalyzerRprofileFilePlugin], ["project-discovery:gitignore", typeof FlowrAnalyzerGitignoreProjectDiscoveryPlugin], ["project-discovery:rbuildignore", typeof FlowrAnalyzerRbuildignoreProjectDiscoveryPlugin], ["project-discovery:ignore-files", typeof FlowrAnalyzerIgnoreFileProjectDiscoveryPlugin], ["project-discovery:default", typeof FlowrAnalyzerDefaultProjectDiscoveryPlugin], ["project-discovery:full", typeof FlowrAnalyzerFullProjectDiscoveryPlugin]];
|
|
32
33
|
export type BuiltInFlowrPluginName = typeof BuiltInPlugins[number][0];
|
|
33
34
|
export type BuiltInFlowrPluginArgs<N extends BuiltInFlowrPluginName> = N extends typeof BuiltInPlugins[number][0] ? ConstructorParameters<Extract<typeof BuiltInPlugins[number], [N, PluginProducer]>[1]> : never;
|
|
34
35
|
type PluginProducer = new (...args: never[]) => FlowrAnalyzerPlugin;
|
|
@@ -29,6 +29,7 @@ const flowr_analyzer_meta_rproject_file_plugin_1 = require("./package-version-pl
|
|
|
29
29
|
const flowr_analyzer_meta_description_file_plugin_1 = require("./package-version-plugins/flowr-analyzer-meta-description-file-plugin");
|
|
30
30
|
const flowr_analyzer_sweave_file_plugin_1 = require("./file-plugins/notebooks/flowr-analyzer-sweave-file-plugin");
|
|
31
31
|
const flowr_analyzer_ignore_file_project_discovery_plugin_1 = require("./project-discovery/flowr-analyzer-ignore-file-project-discovery-plugin");
|
|
32
|
+
const flowr_analyzer_project_discovery_plugin_1 = require("./project-discovery/flowr-analyzer-project-discovery-plugin");
|
|
32
33
|
const flowr_analyzer_rprofile_file_plugin_1 = require("./file-plugins/flowr-analyzer-rprofile-file-plugin");
|
|
33
34
|
const flowr_analyzer_loading_order_rprofile_plugin_1 = require("./loading-order-plugins/flowr-analyzer-loading-order-rprofile-plugin");
|
|
34
35
|
/**
|
|
@@ -64,7 +65,9 @@ exports.BuiltInPlugins = [
|
|
|
64
65
|
['file:rprofile', flowr_analyzer_rprofile_file_plugin_1.FlowrAnalyzerRprofileFilePlugin],
|
|
65
66
|
['project-discovery:gitignore', flowr_analyzer_ignore_file_project_discovery_plugin_1.FlowrAnalyzerGitignoreProjectDiscoveryPlugin],
|
|
66
67
|
['project-discovery:rbuildignore', flowr_analyzer_ignore_file_project_discovery_plugin_1.FlowrAnalyzerRbuildignoreProjectDiscoveryPlugin],
|
|
67
|
-
['project-discovery:ignore-files', flowr_analyzer_ignore_file_project_discovery_plugin_1.FlowrAnalyzerIgnoreFileProjectDiscoveryPlugin]
|
|
68
|
+
['project-discovery:ignore-files', flowr_analyzer_ignore_file_project_discovery_plugin_1.FlowrAnalyzerIgnoreFileProjectDiscoveryPlugin],
|
|
69
|
+
['project-discovery:default', flowr_analyzer_project_discovery_plugin_1.FlowrAnalyzerDefaultProjectDiscoveryPlugin],
|
|
70
|
+
['project-discovery:full', flowr_analyzer_project_discovery_plugin_1.FlowrAnalyzerFullProjectDiscoveryPlugin]
|
|
68
71
|
];
|
|
69
72
|
/**
|
|
70
73
|
* The registry of built-in and user-registered Flowr Analyzer plugins.
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { FlowrAnalyzerPlugin, PluginType } from '../flowr-analyzer-plugin';
|
|
2
|
+
import type { FlowrAnalyzerContext } from '../../context/flowr-analyzer-context';
|
|
2
3
|
import type { RParseRequest } from '../../../r-bridge/retriever';
|
|
3
4
|
import type { RProjectAnalysisRequest } from '../../context/flowr-analyzer-files-context';
|
|
5
|
+
import { SemVer } from 'semver';
|
|
4
6
|
import { type FlowrFile } from '../../context/flowr-file';
|
|
5
7
|
/**
|
|
6
8
|
* This is the base class for all plugins that discover files in a project for analysis.
|
|
7
9
|
* These plugins interplay with the {@link FlowrAnalyzerFilesContext} to gather information about the files in the project.
|
|
8
|
-
* See {@link
|
|
10
|
+
* See {@link FlowrAnalyzerDefaultProjectDiscoveryPlugin} for the default implementation.
|
|
9
11
|
*
|
|
10
12
|
* In general, these plugins only trigger for a {@link RProjectAnalysisRequest} with the idea to discover all files in a project.
|
|
11
13
|
*/
|
|
@@ -13,7 +15,26 @@ export declare abstract class FlowrAnalyzerProjectDiscoveryPlugin extends FlowrA
|
|
|
13
15
|
readonly type = PluginType.ProjectDiscovery;
|
|
14
16
|
static defaultPlugin(): FlowrAnalyzerProjectDiscoveryPlugin;
|
|
15
17
|
}
|
|
16
|
-
|
|
18
|
+
export declare const discoverRSourcesRegex: RegExp;
|
|
19
|
+
export declare const ignorePathsWith: RegExp;
|
|
20
|
+
export declare const excludeRequestsForPaths: RegExp;
|
|
21
|
+
/** Options for {@link collectRequests}; unset fields fall back to the module defaults. */
|
|
22
|
+
export interface CollectRequestOptions {
|
|
23
|
+
/** the regex marking a path as an R source to parse (default {@link discoverRSourcesRegex}) */
|
|
24
|
+
readonly supportedExtensions?: RegExp;
|
|
25
|
+
/** directories whose R sources are collected as text rather than parsed (default {@link excludeRequestsForPaths}) */
|
|
26
|
+
readonly excludePathsRegex?: RegExp;
|
|
27
|
+
/** if set, only paths matching this regex are parsed as R */
|
|
28
|
+
readonly onlyTraversePaths?: RegExp;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Turn the walked `files` (absolute paths under `root`) into the discovery result: R sources become
|
|
32
|
+
* {@link RParseRequest}s, everything else -- and R sources under an excluded directory -- becomes a
|
|
33
|
+
* {@link FlowrTextFile}; `.Rprofile` files get both so they are tagged. This is the single emit implementation
|
|
34
|
+
* shared by the greedy and the intelligent discovery plugins.
|
|
35
|
+
*/
|
|
36
|
+
export declare function collectRequests(files: Iterable<string>, root: string, opts?: CollectRequestOptions): (RParseRequest | FlowrFile<string>)[];
|
|
37
|
+
/** Configuration options for the {@link FlowrAnalyzerFullProjectDiscoveryPlugin}. */
|
|
17
38
|
export interface ProjectDiscoveryConfig {
|
|
18
39
|
/** the regex to trigger R source file discovery on (and hence analyze them as R files) */
|
|
19
40
|
triggerOnExtensions?: RegExp;
|
|
@@ -24,3 +45,37 @@ export interface ProjectDiscoveryConfig {
|
|
|
24
45
|
/** if set, only paths matching this regex are traversed */
|
|
25
46
|
onlyTraversePaths?: RegExp;
|
|
26
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* The greedy discovery implementation: every file below the root becomes a {@link RParseRequest} (R and Rmd files)
|
|
50
|
+
* or a {@link FlowrTextFile} (the rest). This is what {@link FlowrAnalyzerDefaultProjectDiscoveryPlugin} falls back
|
|
51
|
+
* to in `full` mode.
|
|
52
|
+
*/
|
|
53
|
+
export declare class FlowrAnalyzerFullProjectDiscoveryPlugin extends FlowrAnalyzerProjectDiscoveryPlugin {
|
|
54
|
+
readonly name = "full-project-discovery-plugin";
|
|
55
|
+
readonly description = "Collects every file below the project root (greedy discovery).";
|
|
56
|
+
readonly version: SemVer;
|
|
57
|
+
private readonly supportedExtensions;
|
|
58
|
+
private readonly ignorePathsRegex;
|
|
59
|
+
private readonly excludePathsRegex;
|
|
60
|
+
private readonly onlyTraversePaths;
|
|
61
|
+
/**
|
|
62
|
+
* Creates a new instance of the greedy project discovery plugin.
|
|
63
|
+
* @param triggerOnExtensions - the regex to trigger R source file discovery on (and hence analyze them as R files)
|
|
64
|
+
* @param ignorePathsRegex - the regex to ignore certain paths entirely
|
|
65
|
+
* @param excludePathsRegex - the regex to exclude certain paths from being requested as R files (they are still collected as text files)
|
|
66
|
+
* @param onlyTraversePaths - if set, only paths matching this regex are traversed
|
|
67
|
+
*/
|
|
68
|
+
constructor({ triggerOnExtensions, ignorePathsRegex, excludePathsRegex, onlyTraversePaths }?: ProjectDiscoveryConfig);
|
|
69
|
+
process(context: FlowrAnalyzerContext, args: RProjectAnalysisRequest): (RParseRequest | FlowrFile<string>)[];
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* flowR's default discovery: walk the project once (pruning noise directories), classify the {@link ProjectKind}
|
|
73
|
+
* from what the walk sees, then keep only the files that kind needs. `project.discovery.full` restores the greedy
|
|
74
|
+
* {@link FlowrAnalyzerFullProjectDiscoveryPlugin}, `project.discovery.perKind` overrides the kept set per kind.
|
|
75
|
+
*/
|
|
76
|
+
export declare class FlowrAnalyzerDefaultProjectDiscoveryPlugin extends FlowrAnalyzerProjectDiscoveryPlugin {
|
|
77
|
+
readonly name = "default-project-discovery-plugin";
|
|
78
|
+
readonly description = "Detects the project kind and discovers only the files it needs (unless project.discovery.full).";
|
|
79
|
+
readonly version: SemVer;
|
|
80
|
+
process(context: FlowrAnalyzerContext, args: RProjectAnalysisRequest): (RParseRequest | FlowrFile<string>)[];
|
|
81
|
+
}
|
|
@@ -3,76 +3,198 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.FlowrAnalyzerProjectDiscoveryPlugin = void 0;
|
|
6
|
+
exports.FlowrAnalyzerDefaultProjectDiscoveryPlugin = exports.FlowrAnalyzerFullProjectDiscoveryPlugin = exports.excludeRequestsForPaths = exports.ignorePathsWith = exports.discoverRSourcesRegex = exports.FlowrAnalyzerProjectDiscoveryPlugin = void 0;
|
|
7
|
+
exports.collectRequests = collectRequests;
|
|
7
8
|
const flowr_analyzer_plugin_1 = require("../flowr-analyzer-plugin");
|
|
8
9
|
const semver_1 = require("semver");
|
|
9
10
|
const flowr_file_1 = require("../../context/flowr-file");
|
|
10
11
|
const files_1 = require("../../../util/files");
|
|
11
12
|
const built_in_source_1 = require("../../../dataflow/internal/process/functions/call/built-in/built-in-source");
|
|
13
|
+
const fs_1 = __importDefault(require("fs"));
|
|
12
14
|
const path_1 = __importDefault(require("path"));
|
|
15
|
+
const classify_project_kind_1 = require("../../context/classify-project-kind");
|
|
16
|
+
const glob_1 = require("../../../util/glob");
|
|
13
17
|
const flowr_analyzer_rprofile_file_plugin_1 = require("../file-plugins/flowr-analyzer-rprofile-file-plugin");
|
|
14
18
|
/**
|
|
15
19
|
* This is the base class for all plugins that discover files in a project for analysis.
|
|
16
20
|
* These plugins interplay with the {@link FlowrAnalyzerFilesContext} to gather information about the files in the project.
|
|
17
|
-
* See {@link
|
|
21
|
+
* See {@link FlowrAnalyzerDefaultProjectDiscoveryPlugin} for the default implementation.
|
|
18
22
|
*
|
|
19
23
|
* In general, these plugins only trigger for a {@link RProjectAnalysisRequest} with the idea to discover all files in a project.
|
|
20
24
|
*/
|
|
21
25
|
class FlowrAnalyzerProjectDiscoveryPlugin extends flowr_analyzer_plugin_1.FlowrAnalyzerPlugin {
|
|
22
26
|
type = flowr_analyzer_plugin_1.PluginType.ProjectDiscovery;
|
|
23
27
|
static defaultPlugin() {
|
|
24
|
-
return new
|
|
28
|
+
return new FlowrAnalyzerDefaultProjectDiscoveryPlugin();
|
|
25
29
|
}
|
|
26
30
|
}
|
|
27
31
|
exports.FlowrAnalyzerProjectDiscoveryPlugin = FlowrAnalyzerProjectDiscoveryPlugin;
|
|
28
32
|
// `.Rprofile`/`Rprofile.site` carry no extension but are plain R sources
|
|
29
|
-
|
|
33
|
+
exports.discoverRSourcesRegex = /(\.(r|rmd|ipynb|qmd|rnw)|(^|[\\/])\.?Rprofile(\.site)?)$/i;
|
|
30
34
|
// matched against the posix path relative to the project root
|
|
31
|
-
|
|
32
|
-
|
|
35
|
+
exports.ignorePathsWith = /(^|\/)(\.git|\.svn|\.hg|node_modules|__pycache__|\.Rproj\.user|Rtmp[^/]*|(packrat|renv|rv)\/(lib|library|src|staging|sandbox|bundles)[^/]*)(\/|$)/i;
|
|
36
|
+
exports.excludeRequestsForPaths = /vignettes?|tests?|revdep|inst|data/i;
|
|
33
37
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
38
|
+
* Turn the walked `files` (absolute paths under `root`) into the discovery result: R sources become
|
|
39
|
+
* {@link RParseRequest}s, everything else -- and R sources under an excluded directory -- becomes a
|
|
40
|
+
* {@link FlowrTextFile}; `.Rprofile` files get both so they are tagged. This is the single emit implementation
|
|
41
|
+
* shared by the greedy and the intelligent discovery plugins.
|
|
36
42
|
*/
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
43
|
+
function collectRequests(files, root, opts = {}) {
|
|
44
|
+
const supportedExtensions = opts.supportedExtensions ?? exports.discoverRSourcesRegex;
|
|
45
|
+
const excludePathsRegex = opts.excludePathsRegex ?? exports.excludeRequestsForPaths;
|
|
46
|
+
const onlyTraversePaths = opts.onlyTraversePaths;
|
|
47
|
+
const requests = [];
|
|
48
|
+
for (const file of files) {
|
|
49
|
+
const relativePath = path_1.default.relative(root, file);
|
|
50
|
+
if (supportedExtensions.test(relativePath) && (!onlyTraversePaths || onlyTraversePaths.test(relativePath)) && !excludePathsRegex.test((0, built_in_source_1.platformDirname)(relativePath))) {
|
|
51
|
+
requests.push({ content: file, request: 'file' });
|
|
52
|
+
if (flowr_analyzer_rprofile_file_plugin_1.RprofileFilePattern.test((0, built_in_source_1.platformBasename)(relativePath))) {
|
|
53
|
+
// parse requests skip the file plugins, so emit a file too to have the profile tagged
|
|
54
|
+
requests.push(new flowr_file_1.FlowrTextFile(file));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
requests.push(new flowr_file_1.FlowrTextFile(file));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return requests;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The greedy discovery implementation: every file below the root becomes a {@link RParseRequest} (R and Rmd files)
|
|
65
|
+
* or a {@link FlowrTextFile} (the rest). This is what {@link FlowrAnalyzerDefaultProjectDiscoveryPlugin} falls back
|
|
66
|
+
* to in `full` mode.
|
|
67
|
+
*/
|
|
68
|
+
class FlowrAnalyzerFullProjectDiscoveryPlugin extends FlowrAnalyzerProjectDiscoveryPlugin {
|
|
69
|
+
name = 'full-project-discovery-plugin';
|
|
70
|
+
description = 'Collects every file below the project root (greedy discovery).';
|
|
40
71
|
version = new semver_1.SemVer('0.0.0');
|
|
41
72
|
supportedExtensions;
|
|
42
73
|
ignorePathsRegex;
|
|
43
|
-
excludePathsRegex = excludeRequestsForPaths;
|
|
74
|
+
excludePathsRegex = exports.excludeRequestsForPaths;
|
|
44
75
|
onlyTraversePaths;
|
|
45
76
|
/**
|
|
46
|
-
* Creates a new instance of the
|
|
77
|
+
* Creates a new instance of the greedy project discovery plugin.
|
|
47
78
|
* @param triggerOnExtensions - the regex to trigger R source file discovery on (and hence analyze them as R files)
|
|
48
79
|
* @param ignorePathsRegex - the regex to ignore certain paths entirely
|
|
49
80
|
* @param excludePathsRegex - the regex to exclude certain paths from being requested as R files (they are still collected as text files)
|
|
50
81
|
* @param onlyTraversePaths - if set, only paths matching this regex are traversed
|
|
51
82
|
*/
|
|
52
|
-
constructor({ triggerOnExtensions = discoverRSourcesRegex, ignorePathsRegex = ignorePathsWith, excludePathsRegex = excludeRequestsForPaths, onlyTraversePaths } = {}) {
|
|
83
|
+
constructor({ triggerOnExtensions = exports.discoverRSourcesRegex, ignorePathsRegex = exports.ignorePathsWith, excludePathsRegex = exports.excludeRequestsForPaths, onlyTraversePaths } = {}) {
|
|
53
84
|
super();
|
|
54
85
|
this.supportedExtensions = triggerOnExtensions;
|
|
55
86
|
this.ignorePathsRegex = ignorePathsRegex;
|
|
56
87
|
this.excludePathsRegex = excludePathsRegex;
|
|
57
88
|
this.onlyTraversePaths = onlyTraversePaths;
|
|
58
89
|
}
|
|
59
|
-
process(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
90
|
+
process(context, args) {
|
|
91
|
+
if (!fs_1.default.existsSync(args.content)) {
|
|
92
|
+
return [];
|
|
93
|
+
}
|
|
94
|
+
const failOnInaccessiblePath = context.config.project.failOnInaccessiblePath ?? false;
|
|
95
|
+
return collectRequests((0, files_1.getAllFilesSync)(args.content, /.*/, this.ignorePathsRegex, args.content, failOnInaccessiblePath), args.content, { supportedExtensions: this.supportedExtensions, excludePathsRegex: this.excludePathsRegex, onlyTraversePaths: this.onlyTraversePaths });
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
exports.FlowrAnalyzerFullProjectDiscoveryPlugin = FlowrAnalyzerFullProjectDiscoveryPlugin;
|
|
99
|
+
// noise directories pruned from the scoped walk on top of `ignorePathsWith`: build output, checks, rendered docs and packaged data
|
|
100
|
+
const noiseDirs = /(^|\/)(\.git|\.svn|\.hg|node_modules|__pycache__|\.Rproj\.user|[^/]*\.Rcheck|(packrat|renv|rv)\/(lib|library|src|staging|sandbox|bundles|cache)[^/]*|build|dist|_build|_site|_book|\.quarto|\.cache|Rtmp[^/]*|man|inst\/(extdata|doc))(\/|$)/i;
|
|
101
|
+
// binary/data blobs, dropped even inside an otherwise kept directory
|
|
102
|
+
const noiseFiles = /\.(rds|rda|rdata|rd|png|jpe?g|gif|svg|pdf|ico|zip|tar|t?gz|bz2|xz|so|o|a|dll|dylib|exe|jar|woff2?|ttf|eot|feather|parquet|xls[xm]?|docx?|pptx?)$/i;
|
|
103
|
+
const descriptionFilePattern = /^DESCRIPTION(\.(txt|in))?$/i;
|
|
104
|
+
// metadata the analysis still needs when scoped (mirrors the file-role plugin patterns; local to avoid a cycle)
|
|
105
|
+
const metadataFilePatterns = [
|
|
106
|
+
descriptionFilePattern,
|
|
107
|
+
/^NAMESPACE(\.txt)?$/i,
|
|
108
|
+
/^NEWS(\.(rd|md))?$/i,
|
|
109
|
+
/^(renv|rv|packrat)\.lock$/i,
|
|
110
|
+
/^rproject\.toml$/i,
|
|
111
|
+
/license(\.md|\.txt)?$/i,
|
|
112
|
+
flowr_analyzer_rprofile_file_plugin_1.RprofileFilePattern,
|
|
113
|
+
flowr_analyzer_rprofile_file_plugin_1.RenvironFilePattern
|
|
114
|
+
];
|
|
115
|
+
const testOrVignetteDir = /(^|\/)(tests?|vignettes?)(\/|$)/i;
|
|
116
|
+
/** compile the `project.discovery.perKind` include/exclude globs into matchers */
|
|
117
|
+
function resolveRules(override) {
|
|
118
|
+
return {
|
|
119
|
+
include: (override?.include ?? []).map(glob_1.globMatcher),
|
|
120
|
+
exclude: (override?.exclude ?? []).map(glob_1.globMatcher)
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
/** over-approximating default: R sources, role metadata and `tests/`/`vignettes/` count as project files */
|
|
124
|
+
function keptByDefault(rel) {
|
|
125
|
+
const base = path_1.default.basename(rel);
|
|
126
|
+
return exports.discoverRSourcesRegex.test(rel) || metadataFilePatterns.some(p => p.test(base)) || testOrVignetteDir.test(rel);
|
|
127
|
+
}
|
|
128
|
+
/** whether root-relative `rel` is kept; an explicit `ignore` or `perKind` exclude wins over everything */
|
|
129
|
+
function keep(rel, rules, ignore) {
|
|
130
|
+
if (noiseFiles.test(rel) || ignore.some(m => m(rel)) || rules.exclude.some(m => m(rel))) {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
return keptByDefault(rel) || rules.include.some(m => m(rel));
|
|
134
|
+
}
|
|
135
|
+
/** the lower-cased `DESCRIPTION` `Type:` field, read without the full DCF parser to avoid a cycle */
|
|
136
|
+
function descriptionType(file) {
|
|
137
|
+
let content;
|
|
138
|
+
try {
|
|
139
|
+
content = fs_1.default.readFileSync(file, 'utf8');
|
|
140
|
+
}
|
|
141
|
+
catch {
|
|
142
|
+
return '';
|
|
143
|
+
}
|
|
144
|
+
const m = /^Type:[ \t]*(.+)$/im.exec(content.replace(/^\uFEFF/, ''));
|
|
145
|
+
return (m?.[1] ?? '').trim().toLowerCase();
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* flowR's default discovery: walk the project once (pruning noise directories), classify the {@link ProjectKind}
|
|
149
|
+
* from what the walk sees, then keep only the files that kind needs. `project.discovery.full` restores the greedy
|
|
150
|
+
* {@link FlowrAnalyzerFullProjectDiscoveryPlugin}, `project.discovery.perKind` overrides the kept set per kind.
|
|
151
|
+
*/
|
|
152
|
+
class FlowrAnalyzerDefaultProjectDiscoveryPlugin extends FlowrAnalyzerProjectDiscoveryPlugin {
|
|
153
|
+
name = 'default-project-discovery-plugin';
|
|
154
|
+
description = 'Detects the project kind and discovers only the files it needs (unless project.discovery.full).';
|
|
155
|
+
version = new semver_1.SemVer('1.0.0');
|
|
156
|
+
process(context, args) {
|
|
157
|
+
if (!fs_1.default.existsSync(args.content)) {
|
|
158
|
+
return [];
|
|
159
|
+
}
|
|
160
|
+
const root = args.content;
|
|
161
|
+
const failOn = context.config.project.failOnInaccessiblePath ?? false;
|
|
162
|
+
const discovery = context.config.project.discovery;
|
|
163
|
+
if (discovery?.full) {
|
|
164
|
+
return collectRequests((0, files_1.getAllFilesSync)(root, /.*/, exports.ignorePathsWith, root, failOn), root);
|
|
165
|
+
}
|
|
166
|
+
const opts = (0, classify_project_kind_1.resolveClassifyOptions)(context.config.project.classification);
|
|
167
|
+
// one walk gathers the candidate files and the classification signals, so the kind is known the moment it ends
|
|
168
|
+
const files = [];
|
|
169
|
+
const names = new Set();
|
|
170
|
+
const entries = new Map();
|
|
171
|
+
const descriptionTypes = [];
|
|
172
|
+
let descriptionCount = 0;
|
|
173
|
+
for (const file of (0, files_1.getAllFilesSync)(root, /.*/, noiseDirs, root, failOn)) {
|
|
174
|
+
files.push(file);
|
|
175
|
+
const base = path_1.default.basename(file);
|
|
176
|
+
const lower = base.toLowerCase();
|
|
177
|
+
names.add(lower);
|
|
178
|
+
if (opts.shinyEntryFiles.has(lower) && !entries.has(lower)) {
|
|
179
|
+
entries.set(lower, () => {
|
|
180
|
+
try {
|
|
181
|
+
return fs_1.default.readFileSync(file, 'utf8');
|
|
182
|
+
}
|
|
183
|
+
catch {
|
|
184
|
+
return undefined;
|
|
185
|
+
}
|
|
186
|
+
});
|
|
70
187
|
}
|
|
71
|
-
|
|
72
|
-
|
|
188
|
+
if (descriptionFilePattern.test(base)) {
|
|
189
|
+
descriptionCount++;
|
|
190
|
+
descriptionTypes.push(descriptionType(file));
|
|
73
191
|
}
|
|
74
192
|
}
|
|
75
|
-
|
|
193
|
+
const kind = (0, classify_project_kind_1.classifyProjectKind)({ names, entries, descriptionTypes, descriptionCount }, opts);
|
|
194
|
+
const rules = resolveRules(discovery?.perKind?.[kind]);
|
|
195
|
+
const ignore = (discovery?.ignore ?? []).map(glob_1.globMatcher);
|
|
196
|
+
return collectRequests(files.filter(f => keep(path_1.default.relative(root, f), rules, ignore)), root);
|
|
76
197
|
}
|
|
77
198
|
}
|
|
199
|
+
exports.FlowrAnalyzerDefaultProjectDiscoveryPlugin = FlowrAnalyzerDefaultProjectDiscoveryPlugin;
|
|
78
200
|
//# sourceMappingURL=flowr-analyzer-project-discovery-plugin.js.map
|
|
@@ -19,7 +19,7 @@ export declare function resolveSource(baseDir: string, relPath: string): string;
|
|
|
19
19
|
* back to the OS temp dir (so it works in a read-only Docker image where only `/tmp` is writable -- mount a
|
|
20
20
|
* volume at the cache dir to persist it).
|
|
21
21
|
*/
|
|
22
|
-
export declare function sigDbCacheDir(override?: string): string;
|
|
22
|
+
export declare function sigDbCacheDir(override?: string, create?: boolean): string;
|
|
23
23
|
/** read the (small) header line of a possibly-compressed bundle without decompressing the whole thing */
|
|
24
24
|
export declare function readHeaderOf(source: string): Promise<Record<string, unknown> | undefined>;
|
|
25
25
|
/** where an index for a decompressed source comes from -- a caller-supplied one (e.g. a manifest) or the sibling `.idx` */
|
|
@@ -72,13 +72,16 @@ function resolveSource(baseDir, relPath) {
|
|
|
72
72
|
* back to the OS temp dir (so it works in a read-only Docker image where only `/tmp` is writable -- mount a
|
|
73
73
|
* volume at the cache dir to persist it).
|
|
74
74
|
*/
|
|
75
|
-
function sigDbCacheDir(override) {
|
|
75
|
+
function sigDbCacheDir(override, create = true) {
|
|
76
76
|
const base = override
|
|
77
77
|
?? process.env.FLOWR_SIGDB_CACHE ?? process.env.FLOWR_CACHE_DIR
|
|
78
78
|
?? (process.env.XDG_CACHE_HOME ? node_path_1.default.join(process.env.XDG_CACHE_HOME, 'flowr') : undefined)
|
|
79
79
|
?? (process.env.LOCALAPPDATA ? node_path_1.default.join(process.env.LOCALAPPDATA, 'flowr', 'cache') : undefined)
|
|
80
80
|
?? node_path_1.default.join(node_os_1.default.homedir?.() || node_os_1.default.tmpdir(), '.cache', 'flowr');
|
|
81
81
|
const dir = node_path_1.default.join(base, 'sigdb');
|
|
82
|
+
if (!create) {
|
|
83
|
+
return dir;
|
|
84
|
+
}
|
|
82
85
|
try {
|
|
83
86
|
node_fs_1.default.mkdirSync(dir, { recursive: true });
|
|
84
87
|
return dir;
|