UNPKG

@eagleoutice/flowr-dev

Version:

Static Dataflow Analyzer and Program Slicer for the R Programming Language

41 lines (40 loc) 2.35 kB
import { ProjectKind } from './project-kind'; /** Lazily read a shiny-entry file's content; returns `undefined` when it cannot be read. */ export type ContentReader = () => string | undefined; /** The evidence {@link classifyProjectKind} works from. */ export interface ProjectKindSignals { /** lower-cased basenames of every file known so far */ readonly names: ReadonlySet<string>; /** shiny-entry basename to a reader for its content */ readonly entries: ReadonlyMap<string, ContentReader>; /** the lower-cased `Type:` of each known `DESCRIPTION` (`''` when absent) */ readonly descriptionTypes: readonly string[]; /** how many `DESCRIPTION` files are known */ readonly descriptionCount: number; } /** The configurable classification inputs, from `project.classification`. */ export interface ClassificationConfig { readonly shinyDescriptionTypes?: readonly string[]; readonly shinyEntryFiles?: readonly string[]; readonly shinyUsagePattern?: string; readonly notebookExtensions?: readonly string[]; } /** {@link ClassificationConfig} resolved to matchers, falling back to the built-in defaults. */ export interface ResolvedClassifyOptions { readonly shinyDescriptionTypes: ReadonlySet<string>; readonly shinyEntryFiles: ReadonlySet<string>; readonly shinyUsage: RegExp; readonly notebookExtension: RegExp; } /** Resolve {@link ClassificationConfig} into {@link ResolvedClassifyOptions}, using the built-in defaults for unset fields. */ export declare function resolveClassifyOptions(cfg?: ClassificationConfig): ResolvedClassifyOptions; /** * Whether the project is a shiny app: it has the canonical entry files (a single `app.R`, or the `ui.R`+`server.R` * pair) and one of them uses the shiny stack. When no entry file can be read we trust the file names alone. */ export declare function isShinyAppSignals(names: ReadonlySet<string>, entries: ReadonlyMap<string, ContentReader>, shinyUsagePattern?: RegExp): boolean; /** * Classify the {@link ProjectKind} from the given {@link ProjectKindSignals}. Shiny apps are detected first (they * often ship a `DESCRIPTION` too), then packages, then notebooks; the rest is a single-file `Script` or a `Project`. */ export declare function classifyProjectKind(signals: ProjectKindSignals, opts?: ResolvedClassifyOptions): ProjectKind;