@eagleoutice/flowr 2.13.1 → 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.
Files changed (74) hide show
  1. package/cli/flowr.js +21 -5
  2. package/cli/repl/commands/repl-commands.js +11 -9
  3. package/cli/repl/commands/repl-query.js +1 -1
  4. package/cli/repl/commands/repl-signature.js +8 -1
  5. package/cli/repl/core.js +13 -10
  6. package/cli/repl/print-version.js +1 -1
  7. package/cli/repl/server/connection.d.ts +1 -1
  8. package/cli/repl/server/net.js +15 -0
  9. package/config.d.ts +29 -0
  10. package/config.js +54 -2
  11. package/data/sigdb/sigdb.remote.json +1 -1
  12. package/dataflow/environments/identifier.d.ts +9 -8
  13. package/dataflow/environments/identifier.js +21 -13
  14. package/dataflow/eval/resolve/resolve-working-directory.d.ts +29 -0
  15. package/dataflow/eval/resolve/resolve-working-directory.js +168 -0
  16. package/dataflow/extractor.js +2 -1
  17. package/dataflow/graph/df-helper.d.ts +3 -2
  18. package/dataflow/graph/df-helper.js +11 -15
  19. package/dataflow/graph/diff-dataflow-graph.js +1 -1
  20. package/dataflow/graph/graph-helper.js +2 -6
  21. package/dataflow/graph/graph.d.ts +24 -0
  22. package/dataflow/graph/graph.js +25 -1
  23. package/documentation/wiki-linter.js +1 -0
  24. package/documentation/wiki-mk/doc-context.d.ts +10 -0
  25. package/documentation/wiki-mk/doc-context.js +3 -0
  26. package/documentation/wiki-signature-database.js +16 -6
  27. package/linter/linter-rules.d.ts +24 -2
  28. package/linter/linter-rules.js +3 -1
  29. package/linter/rules/absolute-path.d.ts +4 -4
  30. package/linter/rules/absolute-path.js +7 -5
  31. package/linter/rules/file-path-validity.d.ts +1 -1
  32. package/linter/rules/file-path-validity.js +48 -8
  33. package/linter/rules/function-finder-util.d.ts +2 -1
  34. package/linter/rules/syntactically-valid.d.ts +58 -0
  35. package/linter/rules/syntactically-valid.js +203 -0
  36. package/linter/rules/undefined-symbol.js +3 -2
  37. package/package.json +5 -4
  38. package/project/context/classify-project-kind.d.ts +40 -0
  39. package/project/context/classify-project-kind.js +76 -0
  40. package/project/context/flowr-analyzer-dependencies-context.d.ts +23 -4
  41. package/project/context/flowr-analyzer-dependencies-context.js +23 -1
  42. package/project/context/flowr-analyzer-files-context.d.ts +10 -8
  43. package/project/context/flowr-analyzer-files-context.js +26 -67
  44. package/project/context/flowr-file.d.ts +5 -0
  45. package/project/context/flowr-file.js +5 -0
  46. package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.d.ts +12 -4
  47. package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.js +25 -10
  48. package/project/plugins/plugin-registry.d.ts +2 -1
  49. package/project/plugins/plugin-registry.js +4 -1
  50. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.d.ts +57 -2
  51. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +150 -28
  52. package/project/sigdb/decompress.d.ts +1 -1
  53. package/project/sigdb/decompress.js +4 -1
  54. package/project/sigdb/manifest.js +60 -26
  55. package/project/sigdb/sigdb-download.d.ts +6 -7
  56. package/project/sigdb/sigdb-download.js +30 -9
  57. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +0 -10
  58. package/queries/catalog/dependencies-query/dependencies-query-format.js +0 -106
  59. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +1 -1
  60. package/queries/catalog/linter-query/linter-query-format.js +9 -2
  61. package/queries/catalog/signature-query/signature-query-executor.js +3 -0
  62. package/queries/catalog/signature-query/signature-query-render.js +4 -4
  63. package/queries/query.js +9 -2
  64. package/r-bridge/data/data.d.ts +5 -0
  65. package/r-bridge/data/data.js +6 -0
  66. package/r-bridge/retriever.js +6 -1
  67. package/r-bridge/shell.js +5 -0
  68. package/search/flowr-search-filters.d.ts +2 -1
  69. package/util/files.d.ts +6 -4
  70. package/util/files.js +30 -8
  71. package/util/mermaid/dfg.js +1 -1
  72. package/util/text/ansi.d.ts +7 -3
  73. package/util/text/ansi.js +8 -5
  74. package/util/version.js +4 -4
@@ -15,17 +15,8 @@ const fs_1 = __importDefault(require("fs"));
15
15
  const path_1 = __importDefault(require("path"));
16
16
  const files_1 = require("../../util/files");
17
17
  const glob_1 = require("../../util/glob");
18
- const project_kind_1 = require("./project-kind");
18
+ const classify_project_kind_1 = require("./classify-project-kind");
19
19
  const fileLog = log_1.log.getSubLogger({ name: 'flowr-analyzer-files-context' });
20
- const notebookExtension = /\.(ipynb|rmd|qmd|rnw)$/;
21
- const shinyDescriptionTypes = new Set(['shiny', 'shiny-app', 'shinyapp']);
22
- /** the (lower-cased) file names a shiny app is assembled from; the app is `app.r`, or the `ui.r`+`server.r` pair */
23
- const shinyEntryFiles = new Set(['app.r', 'ui.r', 'server.r', 'global.r']);
24
- /**
25
- * Evidence that a file actually is part of a shiny app rather than just sharing a name: a load of the shiny stack
26
- * or a call to one of its entry points. Kept broad enough to also catch `bslib`/`shinydashboard`/`golem` apps.
27
- */
28
- const shinyUsage = /(?:library|require|requireNamespace|loadNamespace)\s*\(\s*['"]?(?:shiny|bslib|shinydashboard|shinyMobile|golem|flexdashboard)\b|\b(?:shinyApp|shinyServer|shinyUI|runApp|fluidPage|fluidRow|navbarPage|bootstrapPage|fillPage|dashboardPage|page_fluid|page_sidebar|page_navbar|pageWithSidebar)\s*\(/;
29
20
  function wrapFile(file, roles) {
30
21
  if (typeof file === 'string') {
31
22
  return new flowr_file_1.FlowrTextFile(file, roles);
@@ -109,20 +100,28 @@ class FlowrAnalyzerFilesContext extends abstract_flowr_analyzer_context_1.Abstra
109
100
  projectKind() {
110
101
  return this.projectKindCache ??= this.ctx.config.project.useProjectType ?? this.classifyProject();
111
102
  }
103
+ getRequestedRoots() {
104
+ return this.requestedRoots;
105
+ }
112
106
  classifyProject() {
107
+ const opts = (0, classify_project_kind_1.resolveClassifyOptions)(this.ctx.config.project.classification);
113
108
  const descriptions = this.getFilesByRole(flowr_file_1.FileRole.Description);
114
- // an explicit `Type: shiny` in the DESCRIPTION settles it without looking at any source
115
- if (descriptions.some(d => shinyDescriptionTypes.has(d.type() ?? ''))) {
116
- return project_kind_1.ProjectKind.ShinyApp;
117
- }
118
- // the readable entry files by (lower-cased) name, plus every known file name for the coarser checks below
109
+ const reader = (f) => () => {
110
+ try {
111
+ return f.content().toString();
112
+ }
113
+ catch {
114
+ return undefined;
115
+ }
116
+ };
117
+ // the readable entry files by (lower-cased) name, plus every known file name for the coarser checks
119
118
  const entries = new Map();
120
119
  const names = new Set();
121
120
  for (const f of this.getAllFiles()) {
122
121
  const name = path_1.default.basename(f.path()).toLowerCase();
123
122
  names.add(name);
124
- if (shinyEntryFiles.has(name)) {
125
- entries.set(name, f);
123
+ if (opts.shinyEntryFiles.has(name)) {
124
+ entries.set(name, reader(f));
126
125
  }
127
126
  }
128
127
  const pending = this.loadingOrder.getUnorderedRequests()
@@ -130,57 +129,16 @@ class FlowrAnalyzerFilesContext extends abstract_flowr_analyzer_context_1.Abstra
130
129
  for (const p of [...pending, ...this.consideredFiles]) {
131
130
  const name = path_1.default.basename(p).toLowerCase();
132
131
  names.add(name);
133
- if (shinyEntryFiles.has(name) && !entries.has(name)) {
134
- entries.set(name, this.getFileByPath(p) ?? new flowr_file_1.FlowrTextFile(p));
135
- }
136
- }
137
- if (this.isShinyApp(names, entries)) {
138
- return project_kind_1.ProjectKind.ShinyApp;
139
- }
140
- if (descriptions.length > 0) {
141
- return project_kind_1.ProjectKind.Package;
142
- }
143
- if (names.size === 0) {
144
- return project_kind_1.ProjectKind.Unknown;
145
- }
146
- for (const name of names) {
147
- if (notebookExtension.test(name)) {
148
- return project_kind_1.ProjectKind.Notebook;
149
- }
150
- }
151
- let rSources = 0;
152
- for (const name of names) {
153
- if (name.endsWith('.r')) {
154
- rSources++;
155
- }
156
- }
157
- return rSources <= 1 ? project_kind_1.ProjectKind.Script : project_kind_1.ProjectKind.Project;
158
- }
159
- /**
160
- * Whether the project is a shiny app: it has the canonical entry files (a single `app.R`, or the `ui.R`+`server.R`
161
- * pair -- a lone `server.R` is not enough) and one of them actually loads or calls the shiny stack. The usage
162
- * check keeps a coincidental `ui.R`/`server.R` pair from being mistaken for an app; only when none of the entry
163
- * files can be read do we fall back to trusting the file names alone.
164
- */
165
- isShinyApp(names, entries) {
166
- if (!names.has('app.r') && !(names.has('ui.r') && names.has('server.r'))) {
167
- return false;
168
- }
169
- let couldRead = false;
170
- for (const f of entries.values()) {
171
- let content;
172
- try {
173
- content = f.content().toString();
174
- }
175
- catch {
176
- continue;
177
- }
178
- couldRead = true;
179
- if (shinyUsage.test(content)) {
180
- return true;
132
+ if (opts.shinyEntryFiles.has(name) && !entries.has(name)) {
133
+ entries.set(name, reader(this.getFileByPath(p) ?? new flowr_file_1.FlowrTextFile(p)));
181
134
  }
182
135
  }
183
- return !couldRead;
136
+ return (0, classify_project_kind_1.classifyProjectKind)({
137
+ names,
138
+ entries,
139
+ descriptionTypes: descriptions.map(d => d.type() ?? ''),
140
+ descriptionCount: descriptions.length
141
+ }, opts);
184
142
  }
185
143
  /**
186
144
  * Add multiple requests to the context. This is just a convenience method that calls {@link addRequest} for each request.
@@ -332,7 +290,8 @@ class FlowrAnalyzerFilesContext extends abstract_flowr_analyzer_context_1.Abstra
332
290
  }
333
291
  return undefined;
334
292
  }
335
- catch {
293
+ catch (e) {
294
+ fileLog.warn(`Could not resolve '${p}': ${e instanceof Error ? e.message : String(e)}`);
336
295
  return undefined;
337
296
  }
338
297
  }
@@ -39,6 +39,11 @@ export declare enum FileRole {
39
39
  * These commonly bootstrap a package manager, e.g. by sourcing `packrat/init.R` or `renv/activate.R`.
40
40
  */
41
41
  Startup = "startup",
42
+ /**
43
+ * Environment-variable definitions read at startup (`.Renviron`, `Renviron.site`). These are `KEY=value`
44
+ * files, not R source, so they are labeled but not parsed as R.
45
+ */
46
+ Environment = "environment",
42
47
  /**
43
48
  * Catch-all for any file that provides usable R source code to incorporate into the analysis.
44
49
  * Please note, that the loading order/inclusion and even potential relevance of these source files
@@ -40,6 +40,11 @@ var FileRole;
40
40
  * These commonly bootstrap a package manager, e.g. by sourcing `packrat/init.R` or `renv/activate.R`.
41
41
  */
42
42
  FileRole["Startup"] = "startup";
43
+ /**
44
+ * Environment-variable definitions read at startup (`.Renviron`, `Renviron.site`). These are `KEY=value`
45
+ * files, not R source, so they are labeled but not parsed as R.
46
+ */
47
+ FileRole["Environment"] = "environment";
43
48
  /**
44
49
  * Catch-all for any file that provides usable R source code to incorporate into the analysis.
45
50
  * Please note, that the loading order/inclusion and even potential relevance of these source files
@@ -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
- /** {@link FlowrAnalyzerLoadingOrderRprofilePlugin} moves the tagged files to the front of the loading order. */
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 profiles (.Rprofile, Rprofile.site).";
18
+ readonly description = "Marks R startup files (.Rprofile, Rprofile.site, .Renviron, Renviron.site).";
12
19
  readonly version: SemVer;
13
- private readonly pathPattern;
14
- constructor(pathPattern?: RegExp);
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
- /** {@link FlowrAnalyzerLoadingOrderRprofilePlugin} moves the tagged files to the front of the loading order. */
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 profiles (.Rprofile, Rprofile.site).';
14
- version = new semver_1.SemVer('0.1.0');
15
- pathPattern;
16
- constructor(pathPattern = exports.RprofileFilePattern) {
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.pathPattern = pathPattern;
26
+ this.profilePattern = profilePattern;
27
+ this.environPattern = environPattern;
19
28
  }
20
29
  applies(file) {
21
- return this.pathPattern.test((0, built_in_source_1.platformBasename)(file.toString()));
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
- file.assignRole(flowr_file_1.FileRole.Startup);
25
- file.assignRole(flowr_file_1.FileRole.Source);
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 DefaultFlowrAnalyzerProjectDiscoveryPlugin} for the dummy default implementation.
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
- /** Configuration options for the {@link DefaultFlowrAnalyzerProjectDiscoveryPlugin}. */
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 DefaultFlowrAnalyzerProjectDiscoveryPlugin} for the dummy default implementation.
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 DefaultFlowrAnalyzerProjectDiscoveryPlugin();
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
- const discoverRSourcesRegex = /(\.(r|rmd|ipynb|qmd|rnw)|(^|[\\/])\.?Rprofile(\.site)?)$/i;
33
+ exports.discoverRSourcesRegex = /(\.(r|rmd|ipynb|qmd|rnw)|(^|[\\/])\.?Rprofile(\.site)?)$/i;
30
34
  // matched against the posix path relative to the project root
31
- const ignorePathsWith = /(^|\/)(\.git|\.svn|\.hg|node_modules|__pycache__|\.Rproj\.user|(packrat|renv|rv)\/(lib|library|src|staging|sandbox|bundles)[^/]*)(\/|$)/i;
32
- const excludeRequestsForPaths = /vignettes?|tests?|revdep|inst|data/i;
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
- * This is the default dummy implementation of the {@link FlowrAnalyzerProjectDiscoveryPlugin}.
35
- * It simply collects all files in the given folder and returns them as either {@link RParseRequest} (for R and Rmd files) or {@link FlowrTextFile} (for all other files).
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
- class DefaultFlowrAnalyzerProjectDiscoveryPlugin extends FlowrAnalyzerProjectDiscoveryPlugin {
38
- name = 'default-project-discovery-plugin';
39
- description = 'Does nothing, the default project discovery plugin.';
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 default project discovery plugin.
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(_context, args) {
60
- const requests = [];
61
- /* the dummy approach of collecting all files, group R and Rmd files, and be done with it */
62
- for (const file of (0, files_1.getAllFilesSync)(args.content, /.*/, this.ignorePathsRegex)) {
63
- const relativePath = path_1.default.relative(args.content, file);
64
- if (this.supportedExtensions.test(relativePath) && (!this.onlyTraversePaths || this.onlyTraversePaths.test(relativePath)) && !this.excludePathsRegex.test((0, built_in_source_1.platformDirname)(relativePath))) {
65
- requests.push({ content: file, request: 'file' });
66
- if (flowr_analyzer_rprofile_file_plugin_1.RprofileFilePattern.test((0, built_in_source_1.platformBasename)(relativePath))) {
67
- // parse requests skip the file plugins, so emit a file too to have the profile tagged
68
- requests.push(new flowr_file_1.FlowrTextFile(file));
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
- else {
72
- requests.push(new flowr_file_1.FlowrTextFile(file));
188
+ if (descriptionFilePattern.test(base)) {
189
+ descriptionCount++;
190
+ descriptionTypes.push(descriptionType(file));
73
191
  }
74
192
  }
75
- return requests;
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;