@plugjs/plug 0.0.1
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/LICENSE.md +211 -0
- package/NOTICE.md +13 -0
- package/README.md +7 -0
- package/dist/assert.cjs +72 -0
- package/dist/assert.cjs.map +6 -0
- package/dist/assert.mjs +41 -0
- package/dist/assert.mjs.map +6 -0
- package/dist/async.cjs +58 -0
- package/dist/async.cjs.map +6 -0
- package/dist/async.mjs +30 -0
- package/dist/async.mjs.map +6 -0
- package/dist/build.cjs +136 -0
- package/dist/build.cjs.map +6 -0
- package/dist/build.mjs +110 -0
- package/dist/build.mjs.map +6 -0
- package/dist/files.cjs +113 -0
- package/dist/files.cjs.map +6 -0
- package/dist/files.mjs +88 -0
- package/dist/files.mjs.map +6 -0
- package/dist/fork.cjs +177 -0
- package/dist/fork.cjs.map +6 -0
- package/dist/fork.mjs +151 -0
- package/dist/fork.mjs.map +6 -0
- package/dist/helpers.cjs +129 -0
- package/dist/helpers.cjs.map +6 -0
- package/dist/helpers.mjs +97 -0
- package/dist/helpers.mjs.map +6 -0
- package/dist/index.cjs +25 -0
- package/dist/index.cjs.map +6 -0
- package/dist/index.mjs +7 -0
- package/dist/index.mjs.map +6 -0
- package/dist/log/colors.cjs +129 -0
- package/dist/log/colors.cjs.map +6 -0
- package/dist/log/colors.mjs +93 -0
- package/dist/log/colors.mjs.map +6 -0
- package/dist/log/emit.cjs +109 -0
- package/dist/log/emit.cjs.map +6 -0
- package/dist/log/emit.mjs +83 -0
- package/dist/log/emit.mjs.map +6 -0
- package/dist/log/levels.cjs +75 -0
- package/dist/log/levels.cjs.map +6 -0
- package/dist/log/levels.mjs +41 -0
- package/dist/log/levels.mjs.map +6 -0
- package/dist/log/logger.cjs +129 -0
- package/dist/log/logger.cjs.map +6 -0
- package/dist/log/logger.mjs +104 -0
- package/dist/log/logger.mjs.map +6 -0
- package/dist/log/options.cjs +149 -0
- package/dist/log/options.cjs.map +6 -0
- package/dist/log/options.mjs +124 -0
- package/dist/log/options.mjs.map +6 -0
- package/dist/log/report.cjs +284 -0
- package/dist/log/report.cjs.map +6 -0
- package/dist/log/report.mjs +259 -0
- package/dist/log/report.mjs.map +6 -0
- package/dist/log/spinner.cjs +83 -0
- package/dist/log/spinner.cjs.map +6 -0
- package/dist/log/spinner.mjs +57 -0
- package/dist/log/spinner.mjs.map +6 -0
- package/dist/log.cjs +71 -0
- package/dist/log.cjs.map +6 -0
- package/dist/log.mjs +45 -0
- package/dist/log.mjs.map +6 -0
- package/dist/paths.cjs +158 -0
- package/dist/paths.cjs.map +6 -0
- package/dist/paths.mjs +122 -0
- package/dist/paths.mjs.map +6 -0
- package/dist/pipe.cjs +71 -0
- package/dist/pipe.cjs.map +6 -0
- package/dist/pipe.mjs +44 -0
- package/dist/pipe.mjs.map +6 -0
- package/dist/plugs/copy.cjs +95 -0
- package/dist/plugs/copy.cjs.map +6 -0
- package/dist/plugs/copy.mjs +64 -0
- package/dist/plugs/copy.mjs.map +6 -0
- package/dist/plugs/coverage/analysis.cjs +229 -0
- package/dist/plugs/coverage/analysis.cjs.map +6 -0
- package/dist/plugs/coverage/analysis.mjs +202 -0
- package/dist/plugs/coverage/analysis.mjs.map +6 -0
- package/dist/plugs/coverage/report.cjs +215 -0
- package/dist/plugs/coverage/report.cjs.map +6 -0
- package/dist/plugs/coverage/report.mjs +200 -0
- package/dist/plugs/coverage/report.mjs.map +6 -0
- package/dist/plugs/coverage.cjs +142 -0
- package/dist/plugs/coverage.cjs.map +6 -0
- package/dist/plugs/coverage.mjs +117 -0
- package/dist/plugs/coverage.mjs.map +6 -0
- package/dist/plugs/debug.cjs +50 -0
- package/dist/plugs/debug.cjs.map +6 -0
- package/dist/plugs/debug.mjs +25 -0
- package/dist/plugs/debug.mjs.map +6 -0
- package/dist/plugs/esbuild/bundle-locals.cjs +51 -0
- package/dist/plugs/esbuild/bundle-locals.cjs.map +6 -0
- package/dist/plugs/esbuild/bundle-locals.mjs +26 -0
- package/dist/plugs/esbuild/bundle-locals.mjs.map +6 -0
- package/dist/plugs/esbuild/check-dependencies.cjs +140 -0
- package/dist/plugs/esbuild/check-dependencies.cjs.map +6 -0
- package/dist/plugs/esbuild/check-dependencies.mjs +115 -0
- package/dist/plugs/esbuild/check-dependencies.mjs.map +6 -0
- package/dist/plugs/esbuild/fix-extensions.cjs +91 -0
- package/dist/plugs/esbuild/fix-extensions.cjs.map +6 -0
- package/dist/plugs/esbuild/fix-extensions.mjs +60 -0
- package/dist/plugs/esbuild/fix-extensions.mjs.map +6 -0
- package/dist/plugs/esbuild.cjs +109 -0
- package/dist/plugs/esbuild.cjs.map +6 -0
- package/dist/plugs/esbuild.mjs +83 -0
- package/dist/plugs/esbuild.mjs.map +6 -0
- package/dist/plugs/eslint/runner.cjs +91 -0
- package/dist/plugs/eslint/runner.cjs.map +6 -0
- package/dist/plugs/eslint/runner.mjs +68 -0
- package/dist/plugs/eslint/runner.mjs.map +6 -0
- package/dist/plugs/exec.cjs +128 -0
- package/dist/plugs/exec.cjs.map +6 -0
- package/dist/plugs/exec.mjs +96 -0
- package/dist/plugs/exec.mjs.map +6 -0
- package/dist/plugs/filter.cjs +59 -0
- package/dist/plugs/filter.cjs.map +6 -0
- package/dist/plugs/filter.mjs +34 -0
- package/dist/plugs/filter.mjs.map +6 -0
- package/dist/plugs/mocha/reporter.cjs +140 -0
- package/dist/plugs/mocha/reporter.cjs.map +6 -0
- package/dist/plugs/mocha/reporter.mjs +107 -0
- package/dist/plugs/mocha/reporter.mjs.map +6 -0
- package/dist/plugs/mocha/runner.cjs +73 -0
- package/dist/plugs/mocha/runner.cjs.map +6 -0
- package/dist/plugs/mocha/runner.mjs +44 -0
- package/dist/plugs/mocha/runner.mjs.map +6 -0
- package/dist/plugs/tsc/compiler.cjs +74 -0
- package/dist/plugs/tsc/compiler.cjs.map +6 -0
- package/dist/plugs/tsc/compiler.mjs +43 -0
- package/dist/plugs/tsc/compiler.mjs.map +6 -0
- package/dist/plugs/tsc/options.cjs +82 -0
- package/dist/plugs/tsc/options.cjs.map +6 -0
- package/dist/plugs/tsc/options.mjs +51 -0
- package/dist/plugs/tsc/options.mjs.map +6 -0
- package/dist/plugs/tsc/report.cjs +90 -0
- package/dist/plugs/tsc/report.cjs.map +6 -0
- package/dist/plugs/tsc/report.mjs +59 -0
- package/dist/plugs/tsc/report.mjs.map +6 -0
- package/dist/plugs/tsc/runner.cjs +101 -0
- package/dist/plugs/tsc/runner.cjs.map +6 -0
- package/dist/plugs/tsc/runner.mjs +72 -0
- package/dist/plugs/tsc/runner.mjs.map +6 -0
- package/dist/plugs.cjs +31 -0
- package/dist/plugs.cjs.map +6 -0
- package/dist/plugs.mjs +13 -0
- package/dist/plugs.mjs.map +6 -0
- package/dist/run.cjs +95 -0
- package/dist/run.cjs.map +6 -0
- package/dist/run.mjs +70 -0
- package/dist/run.mjs.map +6 -0
- package/dist/task.cjs +39 -0
- package/dist/task.cjs.map +6 -0
- package/dist/task.mjs +14 -0
- package/dist/task.mjs.map +6 -0
- package/dist/utils/asyncfs.cjs +143 -0
- package/dist/utils/asyncfs.cjs.map +6 -0
- package/dist/utils/asyncfs.mjs +83 -0
- package/dist/utils/asyncfs.mjs.map +6 -0
- package/dist/utils/caller.cjs +59 -0
- package/dist/utils/caller.cjs.map +6 -0
- package/dist/utils/caller.mjs +34 -0
- package/dist/utils/caller.mjs.map +6 -0
- package/dist/utils/match.cjs +69 -0
- package/dist/utils/match.cjs.map +6 -0
- package/dist/utils/match.mjs +38 -0
- package/dist/utils/match.mjs.map +6 -0
- package/dist/utils/options.cjs +41 -0
- package/dist/utils/options.cjs.map +6 -0
- package/dist/utils/options.mjs +16 -0
- package/dist/utils/options.mjs.map +6 -0
- package/dist/utils/walk.cjs +104 -0
- package/dist/utils/walk.cjs.map +6 -0
- package/dist/utils/walk.mjs +79 -0
- package/dist/utils/walk.mjs.map +6 -0
- package/extra/cli.mjs +212 -0
- package/extra/ts-loader.mjs +214 -0
- package/extra/webassembly.d.ts +11 -0
- package/package.json +57 -0
- package/src/assert.ts +47 -0
- package/src/async.ts +50 -0
- package/src/files.ts +129 -0
- package/src/fork.ts +263 -0
- package/src/helpers.ts +145 -0
- package/src/index.ts +20 -0
- package/src/log/colors.ts +119 -0
- package/src/log/emit.ts +125 -0
- package/src/log/levels.ts +65 -0
- package/src/log/logger.ts +171 -0
- package/src/log/options.ts +199 -0
- package/src/log/report.ts +433 -0
- package/src/log/spinner.ts +70 -0
- package/src/log.ts +68 -0
- package/src/paths.ts +213 -0
- package/src/pipe.ts +231 -0
- package/src/plugs/copy.ts +113 -0
- package/src/plugs/coverage/analysis.ts +395 -0
- package/src/plugs/coverage/report.ts +337 -0
- package/src/plugs/coverage.ts +194 -0
- package/src/plugs/debug.ts +35 -0
- package/src/plugs/esbuild/bundle-locals.ts +33 -0
- package/src/plugs/esbuild/check-dependencies.ts +158 -0
- package/src/plugs/esbuild/fix-extensions.ts +108 -0
- package/src/plugs/esbuild.ts +128 -0
- package/src/plugs/eslint/runner.ts +112 -0
- package/src/plugs/exec.ts +215 -0
- package/src/plugs/filter.ts +56 -0
- package/src/plugs/mocha/reporter.ts +152 -0
- package/src/plugs/mocha/runner.ts +77 -0
- package/src/plugs/tsc/compiler.ts +66 -0
- package/src/plugs/tsc/options.ts +97 -0
- package/src/plugs/tsc/report.ts +74 -0
- package/src/plugs/tsc/runner.ts +100 -0
- package/src/plugs.ts +33 -0
- package/src/run.ts +160 -0
- package/src/task.ts +26 -0
- package/src/utils/asyncfs.ts +82 -0
- package/src/utils/caller.ts +45 -0
- package/src/utils/match.ts +286 -0
- package/src/utils/options.ts +22 -0
- package/src/utils/walk.ts +136 -0
- package/types/assert.d.ts +18 -0
- package/types/async.d.ts +20 -0
- package/types/build.d.ts +56 -0
- package/types/files.d.ts +44 -0
- package/types/fork.d.ts +57 -0
- package/types/helpers.d.ts +49 -0
- package/types/index.d.ts +14 -0
- package/types/log/colors.d.ts +25 -0
- package/types/log/emit.d.ts +14 -0
- package/types/log/levels.d.ts +52 -0
- package/types/log/logger.d.ts +31 -0
- package/types/log/options.d.ts +40 -0
- package/types/log/report.d.ts +64 -0
- package/types/log/spinner.d.ts +2 -0
- package/types/log.d.ts +10 -0
- package/types/paths.d.ts +76 -0
- package/types/pipe.d.ts +152 -0
- package/types/plugs/copy.d.ts +27 -0
- package/types/plugs/coverage/analysis.d.ts +104 -0
- package/types/plugs/coverage/report.d.ts +53 -0
- package/types/plugs/coverage.d.ts +46 -0
- package/types/plugs/debug.d.ts +14 -0
- package/types/plugs/esbuild/bundle-locals.d.ts +6 -0
- package/types/plugs/esbuild/check-dependencies.d.ts +12 -0
- package/types/plugs/esbuild/fix-extensions.d.ts +29 -0
- package/types/plugs/esbuild.d.ts +24 -0
- package/types/plugs/eslint/runner.d.ts +22 -0
- package/types/plugs/exec.d.ts +90 -0
- package/types/plugs/filter.d.ts +23 -0
- package/types/plugs/mocha/reporter.d.ts +8 -0
- package/types/plugs/mocha/runner.d.ts +34 -0
- package/types/plugs/tsc/compiler.d.ts +24 -0
- package/types/plugs/tsc/options.d.ts +8 -0
- package/types/plugs/tsc/report.d.ts +5 -0
- package/types/plugs/tsc/runner.d.ts +13 -0
- package/types/plugs.d.ts +16 -0
- package/types/run.d.ts +89 -0
- package/types/task.d.ts +15 -0
- package/types/utils/asyncfs.d.ts +37 -0
- package/types/utils/caller.d.ts +7 -0
- package/types/utils/match.d.ts +216 -0
- package/types/utils/options.d.ts +15 -0
- package/types/utils/walk.d.ts +28 -0
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference path="../extra/webassembly.d.ts" />
|
|
2
|
+
export * from './assert.js';
|
|
3
|
+
export * from './build.js';
|
|
4
|
+
export * from './plugs.js';
|
|
5
|
+
export * from './log.js';
|
|
6
|
+
export * from './helpers.js';
|
|
7
|
+
export type { MatchOptions, MatchResult } from './utils/match.js';
|
|
8
|
+
export type { ParseOptions } from './utils/options.js';
|
|
9
|
+
export type { WalkOptions } from './utils/walk.js';
|
|
10
|
+
export type { AbsolutePath } from './paths.js';
|
|
11
|
+
export type { Files, FilesBuilder } from './files.js';
|
|
12
|
+
export type { FindOptions, Run } from './run.js';
|
|
13
|
+
export type { Pipe, Plug, PlugFunction } from './pipe.js';
|
|
14
|
+
export type { Task } from './task.js';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { AbsolutePath } from '../paths.js';
|
|
2
|
+
/** Colorize an {@link AbsolutePath}. */
|
|
3
|
+
export declare function $p(path: AbsolutePath): string;
|
|
4
|
+
/** Colorize a _task name_. */
|
|
5
|
+
export declare function $t(task: string): string;
|
|
6
|
+
/** Colorize milliseconds. */
|
|
7
|
+
export declare function $ms(millis: number): string;
|
|
8
|
+
/** Colorize in gray. */
|
|
9
|
+
export declare function $gry(string: any): string;
|
|
10
|
+
/** Colorize in red. */
|
|
11
|
+
export declare function $red(string: any): string;
|
|
12
|
+
/** Colorize in green. */
|
|
13
|
+
export declare function $grn(string: any): string;
|
|
14
|
+
/** Colorize in yellow. */
|
|
15
|
+
export declare function $ylw(string: any): string;
|
|
16
|
+
/** Colorize in blue. */
|
|
17
|
+
export declare function $blu(string: any): string;
|
|
18
|
+
/** Colorize in magenta. */
|
|
19
|
+
export declare function $mgt(string: any): string;
|
|
20
|
+
/** Colorize in cyan. */
|
|
21
|
+
export declare function $cyn(string: any): string;
|
|
22
|
+
/** Colorize in white. */
|
|
23
|
+
export declare function $wht(string: any): string;
|
|
24
|
+
/** Underline. */
|
|
25
|
+
export declare function $und(string: any): string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { LogLevel } from './levels.js';
|
|
2
|
+
/** Options for the {@link LogEmitter} function family */
|
|
3
|
+
export interface LogEmitterOptions {
|
|
4
|
+
taskName: string;
|
|
5
|
+
level: LogLevel;
|
|
6
|
+
indent?: number;
|
|
7
|
+
prefix?: string;
|
|
8
|
+
}
|
|
9
|
+
/** Emit a line (or multiple lines) of text to the log */
|
|
10
|
+
export declare type LogEmitter = (options: LogEmitterOptions, args: any[]) => void;
|
|
11
|
+
/** Emit in full colors! */
|
|
12
|
+
export declare const emitColor: LogEmitter;
|
|
13
|
+
/** Emit in plain text! (no colors) */
|
|
14
|
+
export declare const emitPlain: LogEmitter;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/** Define a branded type for log levels */
|
|
2
|
+
export declare type Level<N extends number> = N & {
|
|
3
|
+
__brand_log_level: never;
|
|
4
|
+
};
|
|
5
|
+
/** The `TRACE` log level */
|
|
6
|
+
export declare const TRACE: Level<10>;
|
|
7
|
+
/** The `DEBUG` log level */
|
|
8
|
+
export declare const DEBUG: Level<20>;
|
|
9
|
+
/** The `INFO` log level */
|
|
10
|
+
export declare const INFO: Level<30>;
|
|
11
|
+
/** The `NOTICE` log level (our default) */
|
|
12
|
+
export declare const NOTICE: Level<40>;
|
|
13
|
+
/** The `WARN` log level */
|
|
14
|
+
export declare const WARN: Level<50>;
|
|
15
|
+
/** The `ERROR` log level */
|
|
16
|
+
export declare const ERROR: Level<60>;
|
|
17
|
+
/** The `OFF` log level (no logs are emitted) */
|
|
18
|
+
export declare const OFF: Level<9007199254740991>;
|
|
19
|
+
/** All our known log levels */
|
|
20
|
+
export declare const logLevels: Readonly<{
|
|
21
|
+
TRACE: Level<10>;
|
|
22
|
+
DEBUG: Level<20>;
|
|
23
|
+
INFO: Level<30>;
|
|
24
|
+
NOTICE: Level<40>;
|
|
25
|
+
WARN: Level<50>;
|
|
26
|
+
ERROR: Level<60>;
|
|
27
|
+
OFF: Level<9007199254740991>;
|
|
28
|
+
}>;
|
|
29
|
+
/** The type of all our known log levels */
|
|
30
|
+
export declare type LogLevels = typeof logLevels;
|
|
31
|
+
/** ID of each one of our log levels (upper case) */
|
|
32
|
+
export declare type LogLevelKey = keyof LogLevels;
|
|
33
|
+
/** Canonical name of each one of our log levels (lower case) */
|
|
34
|
+
export declare type LogLevelName = Lowercase<LogLevelKey>;
|
|
35
|
+
/** A type identifying all our log level numbers */
|
|
36
|
+
export declare type LogLevel = LogLevels[LogLevelKey];
|
|
37
|
+
/** The type identifying a recognized log level as a `string`. */
|
|
38
|
+
export declare type LogLevelString = LogLevelKey | LogLevelName;
|
|
39
|
+
/**
|
|
40
|
+
* Convert a `string` (a {@link LogLevelString}) into a {@link LogLevel}.
|
|
41
|
+
*
|
|
42
|
+
* If the level specified is not a {@link LogLevelString}, the {@link NOTICE}
|
|
43
|
+
* level (our default) will be returned.
|
|
44
|
+
*/
|
|
45
|
+
export declare function getLevelNumber<L extends LogLevelString>(level: L): LogLevels[Uppercase<L>];
|
|
46
|
+
/**
|
|
47
|
+
* Convert a `number` (a {@link LogLevel}) into a {@link LogLevelName}.
|
|
48
|
+
*
|
|
49
|
+
* If the level specified is not precisely a {@link LogLevel}, the
|
|
50
|
+
* closer {@link LogLevelName} will be returned.
|
|
51
|
+
*/
|
|
52
|
+
export declare function getLevelName<L extends LogLevel>(level: L): LogLevelName;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { LogLevel } from './levels.js';
|
|
2
|
+
/** The basic interface giving access to log facilities. */
|
|
3
|
+
export interface Log {
|
|
4
|
+
/** Log a `TRACE` message */
|
|
5
|
+
trace(...args: [any, ...any]): this;
|
|
6
|
+
/** Log a `DEBUG` message */
|
|
7
|
+
debug(...args: [any, ...any]): this;
|
|
8
|
+
/** Log an `INFO` message */
|
|
9
|
+
info(...args: [any, ...any]): this;
|
|
10
|
+
/** Log a `NOTICE` message */
|
|
11
|
+
notice(...args: [any, ...any]): this;
|
|
12
|
+
/** Log a `WARNING` message */
|
|
13
|
+
warn(...args: [any, ...any]): this;
|
|
14
|
+
/** Log an `ERROR` message */
|
|
15
|
+
error(...args: [any, ...any]): this;
|
|
16
|
+
}
|
|
17
|
+
/** A {@link Logger} extends the basic {@link Log} adding some state. */
|
|
18
|
+
export interface Logger extends Log {
|
|
19
|
+
/** The current level for logging. */
|
|
20
|
+
level: LogLevel;
|
|
21
|
+
/** Enter a sub-level of logging, increasing indent */
|
|
22
|
+
enter(): this;
|
|
23
|
+
/** Enter a sub-level of logging, increasing indent */
|
|
24
|
+
enter(evel: LogLevel, message: string): this;
|
|
25
|
+
/** Leave a sub-level of logging, decreasing indent */
|
|
26
|
+
leave(): this;
|
|
27
|
+
/** Leave a sub-level of logging, decreasing indent */
|
|
28
|
+
leave(level: LogLevel, message: string): this;
|
|
29
|
+
}
|
|
30
|
+
/** Return a {@link Logger} associated with the specified task name. */
|
|
31
|
+
export declare function getLogger(task?: string): Logger;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
+
import { Writable } from 'node:stream';
|
|
4
|
+
import { InspectOptions } from 'node:util';
|
|
5
|
+
import { LogLevel } from './levels.js';
|
|
6
|
+
/** Options for our {@link Logger} instances */
|
|
7
|
+
export interface LogOptions {
|
|
8
|
+
/** The current output. */
|
|
9
|
+
output: Writable;
|
|
10
|
+
/** The current level for logging. */
|
|
11
|
+
level: LogLevel;
|
|
12
|
+
/** Whether to log in colors or not. */
|
|
13
|
+
colors: boolean;
|
|
14
|
+
/** Whether to enable the tasks spinner or not. */
|
|
15
|
+
spinner: boolean;
|
|
16
|
+
/** Width of the current terminal (if any) or `80`. */
|
|
17
|
+
lineLength: number;
|
|
18
|
+
/** The maximum length of a task name (for pretty alignment). */
|
|
19
|
+
taskLength: number;
|
|
20
|
+
/** The number of spaces used for indenting. */
|
|
21
|
+
indentSize: number;
|
|
22
|
+
/** Whether to show sources in reports or not. */
|
|
23
|
+
showSources: boolean;
|
|
24
|
+
/** The task name to be used by default if a task is not contextualized. */
|
|
25
|
+
defaultTaskName: string;
|
|
26
|
+
/** The options used by NodeJS for object inspection. */
|
|
27
|
+
readonly inspectOptions: InspectOptions;
|
|
28
|
+
/** Set an inspect option in {@link LogOptions.inspectOptions}). */
|
|
29
|
+
setInspectOption<K extends keyof InspectOptions>(key: K, value: InspectOptions[K]): void;
|
|
30
|
+
/** Add an event listener for the specified event. */
|
|
31
|
+
on(eventName: 'changed', listener: (logOptions: this) => void): this;
|
|
32
|
+
/** Add an event listener for the specified event triggering only once. */
|
|
33
|
+
once(eventName: 'changed', listener: (logOptions: this) => void): this;
|
|
34
|
+
/** Remove an event listener for the specified event. */
|
|
35
|
+
off(eventName: 'changed', listener: (logOptions: this) => void): this;
|
|
36
|
+
/** Convert for serialization, optionally overriding the default task name. */
|
|
37
|
+
fork(taskName?: string): Partial<LogOptions>;
|
|
38
|
+
}
|
|
39
|
+
/** Shared instance of our {@link LogOptions}. */
|
|
40
|
+
export declare const logOptions: LogOptions;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { AbsolutePath } from '../paths.js';
|
|
2
|
+
import { LogLevels } from './levels.js';
|
|
3
|
+
export declare type ReportLevel = LogLevels['NOTICE' | 'WARN' | 'ERROR'];
|
|
4
|
+
/** A record for a {@link Report} */
|
|
5
|
+
export interface ReportRecord {
|
|
6
|
+
/** The _level_ (or _severity_) of this {@link ReportRecord}. */
|
|
7
|
+
level: ReportLevel;
|
|
8
|
+
/** A detail message to associate with this {@link ReportRecord}. */
|
|
9
|
+
message: string | string[];
|
|
10
|
+
/**
|
|
11
|
+
* Tags to associate with this{@link ReportRecord}.
|
|
12
|
+
*
|
|
13
|
+
* Those are error categories, or error codes and are directly related with
|
|
14
|
+
* whatever produced the {@link Report}.
|
|
15
|
+
*/
|
|
16
|
+
tags?: string[] | string | null | undefined;
|
|
17
|
+
/** Line number in the source code (starting at `1`) */
|
|
18
|
+
line?: number | null | undefined;
|
|
19
|
+
/** Column number in the source code (starting at `1`) */
|
|
20
|
+
column?: number | null | undefined;
|
|
21
|
+
/** Number of characters involved (`-1` means until the end of the line ) */
|
|
22
|
+
length?: number | null | undefined;
|
|
23
|
+
/** The {@link AbsolutePath} of the file associated with this. */
|
|
24
|
+
file?: AbsolutePath | null | undefined;
|
|
25
|
+
/** The _real source code_ associated with this (for error higlighting). */
|
|
26
|
+
source?: string | null | undefined;
|
|
27
|
+
}
|
|
28
|
+
/** A {@link Report} that will standardise the way we output information. */
|
|
29
|
+
export interface Report {
|
|
30
|
+
/** The number of `notice` records _and_ annotations in this {@link Report}. */
|
|
31
|
+
readonly notices: number;
|
|
32
|
+
/** The number of `warning` records _and_ annotations in this {@link Report}. */
|
|
33
|
+
readonly warnings: number;
|
|
34
|
+
/** The number of `error` records _and_ annotations in this {@link Report}. */
|
|
35
|
+
readonly errors: number;
|
|
36
|
+
/** The number of `notice` records in this {@link Report}. */
|
|
37
|
+
readonly noticeRecords: number;
|
|
38
|
+
/** The number of `warning` records in this {@link Report}. */
|
|
39
|
+
readonly warningRecords: number;
|
|
40
|
+
/** The number of `error` records in this {@link Report}. */
|
|
41
|
+
readonly errorRecords: number;
|
|
42
|
+
/** The number of `notice` annotations in this {@link Report}. */
|
|
43
|
+
readonly noticeAnnotations: number;
|
|
44
|
+
/** The number of `warning` annotations in this {@link Report}. */
|
|
45
|
+
readonly warningAnnotations: number;
|
|
46
|
+
/** The number of `error` annotations in this {@link Report}. */
|
|
47
|
+
readonly errorAnnotations: number;
|
|
48
|
+
/** The number of _all_ records in this {@link Report} */
|
|
49
|
+
readonly records: number;
|
|
50
|
+
/** The number of _all_ annotations in this {@link Report} */
|
|
51
|
+
readonly annotations: number;
|
|
52
|
+
/** Checks whether this {@link Report} contains records or annotations */
|
|
53
|
+
readonly empty: boolean;
|
|
54
|
+
/** Add a new {@link ReportRecord | record} to this {@link Report}. */
|
|
55
|
+
add(...records: ReportRecord[]): this;
|
|
56
|
+
/** Add an annotation (small note) for a file in this report */
|
|
57
|
+
annotate(level: ReportLevel, file: AbsolutePath, note: string): this;
|
|
58
|
+
/** Attempt to load any source file missing from the reports */
|
|
59
|
+
loadSources(): Promise<void>;
|
|
60
|
+
/** Emit this {@link Report} and throw a build failure on error. */
|
|
61
|
+
done(showSources?: boolean | undefined): void;
|
|
62
|
+
}
|
|
63
|
+
/** Create a new {@link Report} with the given title */
|
|
64
|
+
export declare function createReport(title: string, taskName: string): Report;
|
package/types/log.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Log } from './log/logger.js';
|
|
2
|
+
export * from './log/colors.js';
|
|
3
|
+
export * from './log/levels.js';
|
|
4
|
+
export * from './log/logger.js';
|
|
5
|
+
export * from './log/options.js';
|
|
6
|
+
export * from './log/report.js';
|
|
7
|
+
/** The generic, shared `log` function type. */
|
|
8
|
+
export declare type LogFunction = ((...args: [any, ...any]) => void) & Log;
|
|
9
|
+
/** Our logging function (defaulting to the `NOTICE` level) */
|
|
10
|
+
export declare const log: LogFunction;
|
package/types/paths.d.ts
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/** A _branded_ `string` representing an _absolute_ path name */
|
|
2
|
+
export declare type AbsolutePath = string & {
|
|
3
|
+
__brand_absolute_path: never;
|
|
4
|
+
};
|
|
5
|
+
/** Resolve a path into an {@link AbsolutePath} */
|
|
6
|
+
export declare function resolveAbsolutePath(directory: AbsolutePath, ...paths: string[]): AbsolutePath;
|
|
7
|
+
/**
|
|
8
|
+
* Resolve a path as a relative path to the directory specified, returning the
|
|
9
|
+
* relative child path or `undefined` if the specified path was not a child.
|
|
10
|
+
*
|
|
11
|
+
* The `path` specified here _could_ also be another {@link AbsolutePath}
|
|
12
|
+
* therefore something like this will work:
|
|
13
|
+
*
|
|
14
|
+
* ```
|
|
15
|
+
* resolveRelativeChildPath('/foo', '/foo/bar')
|
|
16
|
+
* // will yield `bar`
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare function resolveRelativeChildPath(directory: AbsolutePath, ...paths: string[]): string | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Asserts that a path is a relative path to the directory specified, failing
|
|
22
|
+
* the build if it's not (see also {@link resolveRelativeChildPath}).
|
|
23
|
+
*/
|
|
24
|
+
export declare function assertRelativeChildPath(directory: AbsolutePath, ...paths: string[]): string;
|
|
25
|
+
/** Checks that the specified path is an {@link AbsolutePath} */
|
|
26
|
+
export declare function isAbsolutePath(path: string): path is AbsolutePath;
|
|
27
|
+
/** Asserts that the specified path is an {@link AbsolutePath} */
|
|
28
|
+
export declare function assertAbsolutePath(p: string): asserts p is AbsolutePath;
|
|
29
|
+
/** Return the {@link AbsolutePath} parent of another */
|
|
30
|
+
export declare function getAbsoluteParent(path: AbsolutePath): AbsolutePath;
|
|
31
|
+
/**
|
|
32
|
+
* Return the {@link process.cwd() | current working directory} as an
|
|
33
|
+
* {@link AbsolutePath}.
|
|
34
|
+
*/
|
|
35
|
+
export declare function getCurrentWorkingDirectory(): AbsolutePath;
|
|
36
|
+
/**
|
|
37
|
+
* Return the absolute path of a file relative to the given `__fileurl`, where
|
|
38
|
+
* `__fileurl` is either CommonJS's own `__filename` variable, or EcmaScript's
|
|
39
|
+
* `import.meta.url` (so either an absolute path name, or a `file:///...` url).
|
|
40
|
+
*
|
|
41
|
+
* If further `paths` are specified, those will be resolved as relative paths
|
|
42
|
+
* to the original `__fileurl` so we can easily write something like this:
|
|
43
|
+
*
|
|
44
|
+
* ```
|
|
45
|
+
* const dataFile = resolveFilename(__fileurl, 'data.json')
|
|
46
|
+
* // if we write this in "/foo/bar/baz.(ts|js|cjs|mjs)"
|
|
47
|
+
* // `dataFile` will now be "/foo/bar/data.json"
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare function requireFilename(__fileurl: string, ...paths: string[]): AbsolutePath;
|
|
51
|
+
/**
|
|
52
|
+
* Return the absolute path of a file which can be _required_ or _imported_
|
|
53
|
+
* by Node (or forked to via `child_process.fork`).
|
|
54
|
+
*
|
|
55
|
+
* This leverages {@link requireFilename} to figure out the starting point where
|
|
56
|
+
* to look for files, and will _try_ to match the same extension of `__fileurl`
|
|
57
|
+
* (so, `.ts` for `ts-node`, `.mjs` for ESM modules, ...).
|
|
58
|
+
*/
|
|
59
|
+
export declare function requireResolve(__fileurl: string, module: string): AbsolutePath;
|
|
60
|
+
/**
|
|
61
|
+
* Return the _common_ path amongst all specified paths.
|
|
62
|
+
*
|
|
63
|
+
* While the first `path` _must_ be an {@link AbsolutePath}, all other `paths`
|
|
64
|
+
* can be _relative_ and will be resolved against the first `path`.
|
|
65
|
+
*/
|
|
66
|
+
export declare function commonPath(path: AbsolutePath, ...paths: string[]): AbsolutePath;
|
|
67
|
+
/**
|
|
68
|
+
* Resolves the specified path as an {@link AbsolutePath} and checks it is a
|
|
69
|
+
* _file_, returning `undefined` if it is not.
|
|
70
|
+
*/
|
|
71
|
+
export declare function isFile(path: AbsolutePath, ...paths: string[]): AbsolutePath | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* Resolves the specified path as an {@link AbsolutePath} and checks it is a
|
|
74
|
+
* _directory_, returning `undefined` if it is not.
|
|
75
|
+
*/
|
|
76
|
+
export declare function isDirectory(path: AbsolutePath, ...paths: string[]): AbsolutePath | undefined;
|
package/types/pipe.d.ts
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { Files } from './files.js';
|
|
2
|
+
import { Run } from './run.js';
|
|
3
|
+
/**
|
|
4
|
+
* The {@link Plug} interface describes an extension mechanism for our build.
|
|
5
|
+
*/
|
|
6
|
+
export interface Plug<T extends Files | undefined> {
|
|
7
|
+
pipe(files: Files, run: Run): T | Promise<T>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* A type identifying a {@link Plug} as a `function`
|
|
11
|
+
*/
|
|
12
|
+
export declare type PlugFunction<T extends Files | undefined> = Plug<T>['pipe'];
|
|
13
|
+
/**
|
|
14
|
+
* A {@link Pipe} represents a sequence of operations performed by
|
|
15
|
+
* a series of {@link Plug | Plugs}.
|
|
16
|
+
*/
|
|
17
|
+
export interface Pipe {
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The {@link Pipe} abstract class exposes the prototype upon which all
|
|
21
|
+
* extension plugs will be installed on.
|
|
22
|
+
*/
|
|
23
|
+
export declare abstract class Pipe implements Pipe {
|
|
24
|
+
abstract plug(plug: Plug<Files> | PlugFunction<Files>): Pipe & Promise<Files>;
|
|
25
|
+
abstract plug(plug: Plug<undefined> | PlugFunction<undefined>): Promise<undefined>;
|
|
26
|
+
}
|
|
27
|
+
/** Implementation of our {@link Pipe}. */
|
|
28
|
+
export declare class PipeImpl<T extends Files | undefined> extends Pipe implements Promise<T> {
|
|
29
|
+
#private;
|
|
30
|
+
constructor(start: T | Promise<T>, run: Run);
|
|
31
|
+
plug<T extends Files | undefined>(arg: Plug<T> | PlugFunction<T>): Pipe & Promise<T>;
|
|
32
|
+
then<T1 = T, T2 = never>(onfulfilled?: ((value: T) => T1 | PromiseLike<T1>) | null | undefined, onrejected?: ((reason: any) => T2 | PromiseLike<T2>) | null | undefined): Promise<T1 | T2>;
|
|
33
|
+
catch<T0 = never>(onrejected?: ((reason: any) => T0 | PromiseLike<T0>) | null | undefined): Promise<T0 | T>;
|
|
34
|
+
finally(onfinally?: (() => void) | null | undefined): Promise<T>;
|
|
35
|
+
[Symbol.toStringTag]: string;
|
|
36
|
+
}
|
|
37
|
+
/** The names which can be installed as direct plugs. */
|
|
38
|
+
export declare type PlugName = string & Exclude<keyof Pipe, 'plug' | keyof Promise<Files>>;
|
|
39
|
+
/** A convenience type identifying a {@link Plug} constructor. */
|
|
40
|
+
export declare type PlugConstructor = new (...args: any) => Plug<Files | undefined>;
|
|
41
|
+
/** Convert the resulting type of a {@link Plug} for use in a {@link Pipe} */
|
|
42
|
+
declare type PlugReturnForPipe<T> = T extends Plug<infer R> ? R extends Files ? Promise<Files> & Pipe : R extends undefined ? Promise<undefined> : never : never;
|
|
43
|
+
/**
|
|
44
|
+
* Map constructors into an array of all known overloads.
|
|
45
|
+
*
|
|
46
|
+
* This is a _royal_ pain in the ass, as we need to distinguish between
|
|
47
|
+
* all possible number of overloads of a constructor... Limit to 5 of them!
|
|
48
|
+
*
|
|
49
|
+
* Also, the empty constructor (when specified in the overloads) will simply
|
|
50
|
+
* match the first case (most overloads) and generate functions somewhat like
|
|
51
|
+
*
|
|
52
|
+
* (...args: unknown[]) => never
|
|
53
|
+
* (...args: unknown[]) => never
|
|
54
|
+
* (...args: unknown[]) => never
|
|
55
|
+
* () => PlugReturnForPipe<R3>
|
|
56
|
+
* (arg: Options) => PlugReturnForPipe<R4>
|
|
57
|
+
*
|
|
58
|
+
* Somehow inferring the result to `Function` or the right type and ANDing all
|
|
59
|
+
* those together here doesn't work, so we create this array and we'll AND
|
|
60
|
+
* all its members in the PipeExtension<...> type.
|
|
61
|
+
*/
|
|
62
|
+
declare type PlugConstructorOverloads<T extends PlugConstructor> = T extends {
|
|
63
|
+
new (...args: infer A0): infer R0;
|
|
64
|
+
new (...args: infer A1): infer R1;
|
|
65
|
+
new (...args: infer A2): infer R2;
|
|
66
|
+
new (...args: infer A3): infer R3;
|
|
67
|
+
new (...args: infer A4): infer R4;
|
|
68
|
+
} ? [
|
|
69
|
+
R0 extends Plug<Files | undefined> ? ((...args: A0) => PlugReturnForPipe<R0>) : Function,
|
|
70
|
+
R1 extends Plug<Files | undefined> ? ((...args: A1) => PlugReturnForPipe<R1>) : Function,
|
|
71
|
+
R2 extends Plug<Files | undefined> ? ((...args: A2) => PlugReturnForPipe<R2>) : Function,
|
|
72
|
+
R3 extends Plug<Files | undefined> ? ((...args: A3) => PlugReturnForPipe<R3>) : Function,
|
|
73
|
+
R4 extends Plug<Files | undefined> ? ((...args: A4) => PlugReturnForPipe<R4>) : Function
|
|
74
|
+
] : T extends {
|
|
75
|
+
new (...args: infer A0): infer R0;
|
|
76
|
+
new (...args: infer A1): infer R1;
|
|
77
|
+
new (...args: infer A2): infer R2;
|
|
78
|
+
new (...args: infer A3): infer R3;
|
|
79
|
+
} ? [
|
|
80
|
+
R0 extends Plug<Files | undefined> ? (...args: A0) => PlugReturnForPipe<R0> : Function,
|
|
81
|
+
R1 extends Plug<Files | undefined> ? (...args: A1) => PlugReturnForPipe<R1> : Function,
|
|
82
|
+
R2 extends Plug<Files | undefined> ? (...args: A2) => PlugReturnForPipe<R2> : Function,
|
|
83
|
+
R3 extends Plug<Files | undefined> ? (...args: A3) => PlugReturnForPipe<R3> : Function
|
|
84
|
+
] : T extends {
|
|
85
|
+
new (...args: infer A0): infer R0;
|
|
86
|
+
new (...args: infer A1): infer R1;
|
|
87
|
+
new (...args: infer A2): infer R2;
|
|
88
|
+
} ? [
|
|
89
|
+
R0 extends Plug<Files | undefined> ? (...args: A0) => PlugReturnForPipe<R0> : Function,
|
|
90
|
+
R1 extends Plug<Files | undefined> ? (...args: A1) => PlugReturnForPipe<R1> : Function,
|
|
91
|
+
R2 extends Plug<Files | undefined> ? (...args: A2) => PlugReturnForPipe<R2> : Function
|
|
92
|
+
] : T extends {
|
|
93
|
+
new (...args: infer A0): infer R0;
|
|
94
|
+
new (...args: infer A1): infer R1;
|
|
95
|
+
} ? [
|
|
96
|
+
R0 extends Plug<Files | undefined> ? (...args: A0) => PlugReturnForPipe<R0> : Function,
|
|
97
|
+
R1 extends Plug<Files | undefined> ? (...args: A1) => PlugReturnForPipe<R1> : Function
|
|
98
|
+
] : T extends {
|
|
99
|
+
new (...args: infer A0): infer R0;
|
|
100
|
+
} ? [
|
|
101
|
+
R0 extends Plug<Files | undefined> ? (...args: A0) => PlugReturnForPipe<R0> : Function
|
|
102
|
+
] : never;
|
|
103
|
+
/**
|
|
104
|
+
* A convenience type to easily annotate installed {@link Plug Plugs}.
|
|
105
|
+
*
|
|
106
|
+
* See also {@link install}.
|
|
107
|
+
*
|
|
108
|
+
* ```
|
|
109
|
+
* export class Write implements Plug {
|
|
110
|
+
* // ... the plug implementation lives here
|
|
111
|
+
* }
|
|
112
|
+
*
|
|
113
|
+
* install('write', Write)
|
|
114
|
+
*
|
|
115
|
+
* declare module '../pipe' {
|
|
116
|
+
* export interface Pipe {
|
|
117
|
+
* write: PipeExtension<typeof Write>
|
|
118
|
+
* }
|
|
119
|
+
* }
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
export declare type PipeExtension<T extends PlugConstructor, A = PlugConstructorOverloads<T>> = A extends readonly [infer First, ...infer Rest] ? First & PipeExtension<T, Rest> : A extends readonly [infer Only] ? Only : Function;
|
|
123
|
+
/**
|
|
124
|
+
* Install a {@link Plug} into our {@link Pipe} prototype, and return a static
|
|
125
|
+
* creator function for the {@link Plug} itself.
|
|
126
|
+
*
|
|
127
|
+
* This allows our shorthand syntax for well-defined plugs such as:
|
|
128
|
+
*
|
|
129
|
+
* ```
|
|
130
|
+
* find('./src', '*.ts').write('./target')
|
|
131
|
+
* // Nicer and easier than...
|
|
132
|
+
* find('./src', '*.ts').plug(new Write('./target'))
|
|
133
|
+
* ```
|
|
134
|
+
*
|
|
135
|
+
* Use this alongside interface merging like:
|
|
136
|
+
*
|
|
137
|
+
* ```
|
|
138
|
+
* export class Write implements Plug {
|
|
139
|
+
* // ... the plug implementation lives here
|
|
140
|
+
* }
|
|
141
|
+
*
|
|
142
|
+
* install('write', Write)
|
|
143
|
+
*
|
|
144
|
+
* declare module '../pipe' {
|
|
145
|
+
* export interface Pipe {
|
|
146
|
+
* write: PipeExtension<typeof Write>
|
|
147
|
+
* }
|
|
148
|
+
* }
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
export declare function install<C extends PlugConstructor>(name: PlugName, ctor: C): void;
|
|
152
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Files } from '../files.js';
|
|
2
|
+
import { Plug } from '../pipe.js';
|
|
3
|
+
import { Run } from '../run.js';
|
|
4
|
+
/** Options for copying files */
|
|
5
|
+
export interface CopyOptions {
|
|
6
|
+
/** Whether to allow overwriting or not (default `false`). */
|
|
7
|
+
overwrite?: boolean;
|
|
8
|
+
/** If specified, use this `mode` (octal string) when creating files. */
|
|
9
|
+
mode?: string | number;
|
|
10
|
+
/** If specified, use this `mode` (octal string) when creating directories. */
|
|
11
|
+
dirMode?: string | number;
|
|
12
|
+
/** If specified, this function will be invoked to rename files. */
|
|
13
|
+
rename?: (relative: string) => string;
|
|
14
|
+
}
|
|
15
|
+
/** Copy the curent {@link Files} to a different directory */
|
|
16
|
+
export declare class Copy implements Plug<Files> {
|
|
17
|
+
private readonly _directory;
|
|
18
|
+
private readonly _options;
|
|
19
|
+
constructor(directory: string, options?: CopyOptions);
|
|
20
|
+
pipe(files: Files, run: Run): Promise<Files>;
|
|
21
|
+
}
|
|
22
|
+
declare module '../pipe.js' {
|
|
23
|
+
interface Pipe {
|
|
24
|
+
/** Copy the curent {@link Files} to a different directory */
|
|
25
|
+
copy: PipeExtension<typeof Copy>;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { RawSourceMap } from 'source-map';
|
|
2
|
+
import { Logger } from '../../log.js';
|
|
3
|
+
import { AbsolutePath } from '../../paths.js';
|
|
4
|
+
/** Coverage range */
|
|
5
|
+
export interface V8CoveredRange {
|
|
6
|
+
/** The offset in the script of the first character covered */
|
|
7
|
+
startOffset: number;
|
|
8
|
+
/** The offset (exclusive) in the script of the last character covered */
|
|
9
|
+
endOffset: number;
|
|
10
|
+
/** The number of times the specified offset was covered */
|
|
11
|
+
count: number;
|
|
12
|
+
}
|
|
13
|
+
/** Coverage report per function as invoked by Node */
|
|
14
|
+
export interface V8CoveredFunction {
|
|
15
|
+
/** The name of the function being covered */
|
|
16
|
+
functionName: string;
|
|
17
|
+
/** A flag indicating whether fine-grained (precise) coverage is available */
|
|
18
|
+
isBlockCoverage: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* The ranges covered.
|
|
21
|
+
*
|
|
22
|
+
* The first range indicates the whole function.
|
|
23
|
+
*/
|
|
24
|
+
ranges: V8CoveredRange[];
|
|
25
|
+
}
|
|
26
|
+
/** Coverage result for a particlar script as seen by Node */
|
|
27
|
+
export interface V8CoverageResult {
|
|
28
|
+
/** The script ID, uniquely identifying the script within the Node process */
|
|
29
|
+
scriptId: string;
|
|
30
|
+
/** The URL of the script (might not be unique, if the script is loaded multiple times) */
|
|
31
|
+
url: string;
|
|
32
|
+
/** Per-function report of coverage */
|
|
33
|
+
functions: V8CoveredFunction[];
|
|
34
|
+
}
|
|
35
|
+
/** Cached source map for a coverage result */
|
|
36
|
+
export interface V8SourceMapCache {
|
|
37
|
+
/** The line lengths (sans EOL) in the transpiled code */
|
|
38
|
+
lineLengths: number[];
|
|
39
|
+
/** The source map associated with the transpiled code */
|
|
40
|
+
data: RawSourceMap | null;
|
|
41
|
+
/** The url (if any) of the sourcemap, for resolving relative paths */
|
|
42
|
+
url: string | null;
|
|
43
|
+
}
|
|
44
|
+
/** The RAW coverage data as emitted by Node, parsed from JSON */
|
|
45
|
+
export interface V8CoverageData {
|
|
46
|
+
/**
|
|
47
|
+
* Coverage results, per script.
|
|
48
|
+
*
|
|
49
|
+
* The first element in the array describes the coverage for the whole script.
|
|
50
|
+
*/
|
|
51
|
+
'result': V8CoverageResult[];
|
|
52
|
+
/** Timestamp when coverage was taken */
|
|
53
|
+
'timestamp'?: number;
|
|
54
|
+
/** Source maps caches keyed by `result[?].url` */
|
|
55
|
+
'source-map-cache'?: Record<string, V8SourceMapCache>;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The bias for source map analisys (defaults to `least_upper_bound`).
|
|
59
|
+
*
|
|
60
|
+
* We use `least_upper_bound` here, as it's the _opposite_ of the default
|
|
61
|
+
* `greatest_lower_bound`, and we _reverse_ the lookup of the sourcemaps (from
|
|
62
|
+
* source code to generated code).
|
|
63
|
+
*/
|
|
64
|
+
export declare type SourceMapBias = 'greatest_lower_bound' | 'least_upper_bound' | 'none' | undefined;
|
|
65
|
+
/** Interface providing coverage data */
|
|
66
|
+
export interface CoverageAnalyser {
|
|
67
|
+
/** Return the number of coverage passes for the given location */
|
|
68
|
+
coverage(source: string, line: number, column: number): number;
|
|
69
|
+
/** Destroy this instance */
|
|
70
|
+
destroy(): void;
|
|
71
|
+
}
|
|
72
|
+
/** Basic abstract class implementing the {@link CoverageAnalyser} class */
|
|
73
|
+
declare abstract class CoverageAnalyserImpl implements CoverageAnalyser {
|
|
74
|
+
protected readonly _log: Logger;
|
|
75
|
+
constructor(_log: Logger);
|
|
76
|
+
abstract init(): Promise<this>;
|
|
77
|
+
abstract destroy(): void;
|
|
78
|
+
abstract coverage(source: string, line: number, column: number): number;
|
|
79
|
+
}
|
|
80
|
+
/** Associate one or more {@link CoverageAnalyser} with different sources */
|
|
81
|
+
export declare class SourcesCoverageAnalyser extends CoverageAnalyserImpl {
|
|
82
|
+
private readonly _filename;
|
|
83
|
+
private readonly _mappings;
|
|
84
|
+
constructor(log: Logger, _filename: AbsolutePath);
|
|
85
|
+
hasMappings(): boolean;
|
|
86
|
+
add(source: string, analyser: CoverageAnalyserImpl): void;
|
|
87
|
+
init(): Promise<this>;
|
|
88
|
+
destroy(): void;
|
|
89
|
+
coverage(source: string, line: number, column: number): number;
|
|
90
|
+
}
|
|
91
|
+
/** Combine multiple {@link CoverageAnalyser} instances together */
|
|
92
|
+
export declare class CombiningCoverageAnalyser extends CoverageAnalyserImpl {
|
|
93
|
+
private readonly _analysers;
|
|
94
|
+
add(analyser: CoverageAnalyserImpl): void;
|
|
95
|
+
init(): Promise<this>;
|
|
96
|
+
destroy(): void;
|
|
97
|
+
coverage(source: string, line: number, column: number): number;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Analyse coverage for the specified source files, using the data from the
|
|
101
|
+
* specified coverage files and produce a {@link CoverageReport}.
|
|
102
|
+
*/
|
|
103
|
+
export declare function createAnalyser(sourceFiles: AbsolutePath[], coverageFiles: AbsolutePath[], sourceMapBias: SourceMapBias, log: Logger): Promise<CoverageAnalyser>;
|
|
104
|
+
export {};
|