@plugjs/plug 0.0.12 → 0.0.15
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/{types → dist}/assert.d.ts +0 -0
- package/dist/async.cjs +20 -19
- package/dist/async.cjs.map +1 -1
- package/dist/async.d.ts +20 -0
- package/dist/async.mjs +18 -17
- package/dist/async.mjs.map +1 -1
- package/dist/build.cjs +144 -110
- package/dist/build.cjs.map +2 -2
- package/dist/build.d.ts +12 -0
- package/dist/build.mjs +146 -112
- package/dist/build.mjs.map +2 -2
- package/dist/files.cjs +2 -16
- package/dist/files.cjs.map +1 -1
- package/{types → dist}/files.d.ts +3 -10
- package/dist/files.mjs +3 -17
- package/dist/files.mjs.map +1 -1
- package/dist/fork.cjs +28 -40
- package/dist/fork.cjs.map +1 -1
- package/dist/fork.d.ts +36 -0
- package/dist/fork.mjs +29 -40
- package/dist/fork.mjs.map +1 -1
- package/dist/helpers.cjs +61 -63
- package/dist/helpers.cjs.map +2 -2
- package/dist/helpers.d.ts +21 -0
- package/dist/helpers.mjs +61 -64
- package/dist/helpers.mjs.map +2 -2
- package/dist/index.cjs +3 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +10 -0
- package/dist/index.mjs +3 -2
- package/dist/index.mjs.map +1 -1
- package/dist/log/colors.cjs +3 -1
- package/dist/log/colors.cjs.map +1 -1
- package/{types → dist}/log/colors.d.ts +2 -2
- package/dist/log/colors.mjs +3 -1
- package/dist/log/colors.mjs.map +1 -1
- package/{types → dist}/log/emit.d.ts +1 -1
- package/{types → dist}/log/levels.d.ts +0 -0
- package/dist/log/logger.cjs +4 -0
- package/dist/log/logger.cjs.map +1 -1
- package/{types → dist}/log/logger.d.ts +4 -1
- package/dist/log/logger.mjs +4 -0
- package/dist/log/logger.mjs.map +1 -1
- package/{types → dist}/log/options.d.ts +1 -1
- package/dist/log/report.cjs +4 -13
- package/dist/log/report.cjs.map +1 -1
- package/{types → dist}/log/report.d.ts +36 -4
- package/dist/log/report.mjs +3 -12
- package/dist/log/report.mjs.map +1 -1
- package/{types → dist}/log/spinner.d.ts +0 -0
- package/dist/log.cjs +1 -1
- package/dist/log.cjs.map +1 -1
- package/{types → dist}/log.d.ts +6 -6
- package/dist/log.mjs +2 -2
- package/dist/log.mjs.map +1 -1
- package/{types → dist}/paths.d.ts +0 -0
- package/dist/pipe.cjs +41 -34
- package/dist/pipe.cjs.map +1 -1
- package/dist/pipe.d.ts +182 -0
- package/dist/pipe.mjs +38 -32
- package/dist/pipe.mjs.map +1 -1
- package/dist/plugs/copy.cjs +15 -25
- package/dist/plugs/copy.cjs.map +2 -2
- package/dist/plugs/copy.d.ts +28 -0
- package/dist/plugs/copy.mjs +15 -17
- package/dist/plugs/copy.mjs.map +2 -2
- package/{types → dist}/plugs/coverage/analysis.d.ts +2 -2
- package/dist/plugs/coverage/report.cjs +4 -2
- package/dist/plugs/coverage/report.cjs.map +1 -1
- package/{types → dist}/plugs/coverage/report.d.ts +3 -3
- package/dist/plugs/coverage/report.mjs +4 -2
- package/dist/plugs/coverage/report.mjs.map +1 -1
- package/dist/plugs/coverage.cjs +23 -27
- package/dist/plugs/coverage.cjs.map +1 -1
- package/dist/plugs/coverage.d.ts +49 -0
- package/dist/plugs/coverage.mjs +24 -20
- package/dist/plugs/coverage.mjs.map +1 -1
- package/dist/plugs/debug.cjs +8 -37
- package/dist/plugs/debug.cjs.map +1 -1
- package/dist/plugs/debug.d.ts +7 -0
- package/dist/plugs/debug.mjs +24 -20
- package/dist/plugs/debug.mjs.map +1 -1
- package/{types → dist}/plugs/esbuild/bundle-locals.d.ts +0 -0
- package/{types → dist}/plugs/esbuild/fix-extensions.d.ts +0 -0
- package/dist/plugs/esbuild/fix-extensions.mjs +1 -1
- package/dist/plugs/esbuild/fix-extensions.mjs.map +1 -1
- package/dist/plugs/esbuild.cjs +14 -25
- package/dist/plugs/esbuild.cjs.map +1 -1
- package/dist/plugs/esbuild.d.ts +18 -0
- package/dist/plugs/esbuild.mjs +14 -17
- package/dist/plugs/esbuild.mjs.map +1 -1
- package/dist/plugs/eslint/runner.cjs +5 -6
- package/dist/plugs/eslint/runner.cjs.map +1 -1
- package/dist/plugs/eslint/runner.d.ts +8 -0
- package/dist/plugs/eslint/runner.mjs +6 -7
- package/dist/plugs/eslint/runner.mjs.map +1 -1
- package/dist/{task.cjs → plugs/eslint.cjs} +7 -24
- package/dist/plugs/eslint.cjs.map +6 -0
- package/dist/plugs/eslint.d.ts +34 -0
- package/dist/plugs/eslint.mjs +5 -0
- package/dist/plugs/eslint.mjs.map +6 -0
- package/dist/plugs/exec.cjs +20 -24
- package/dist/plugs/exec.cjs.map +1 -1
- package/dist/plugs/exec.d.ts +90 -0
- package/dist/plugs/exec.mjs +20 -23
- package/dist/plugs/exec.mjs.map +1 -1
- package/dist/plugs/filter.cjs +9 -19
- package/dist/plugs/filter.cjs.map +1 -1
- package/dist/plugs/filter.d.ts +29 -0
- package/dist/plugs/filter.mjs +10 -12
- package/dist/plugs/filter.mjs.map +1 -1
- package/dist/plugs/mocha/reporter.cjs +19 -6
- package/dist/plugs/mocha/reporter.cjs.map +1 -1
- package/{types → dist}/plugs/mocha/reporter.d.ts +0 -2
- package/dist/plugs/mocha/reporter.mjs +18 -4
- package/dist/plugs/mocha/reporter.mjs.map +1 -1
- package/dist/plugs/mocha/runner.cjs +4 -5
- package/dist/plugs/mocha/runner.cjs.map +1 -1
- package/dist/plugs/mocha/runner.d.ts +8 -0
- package/dist/plugs/mocha/runner.mjs +5 -6
- package/dist/plugs/mocha/runner.mjs.map +1 -1
- package/dist/plugs/mocha.cjs +22 -0
- package/dist/plugs/mocha.cjs.map +6 -0
- package/{types/plugs/mocha/runner.d.ts → dist/plugs/mocha.d.ts} +9 -8
- package/dist/plugs/mocha.mjs +5 -0
- package/dist/plugs/mocha.mjs.map +6 -0
- package/dist/plugs/rmf.cjs +4 -32
- package/dist/plugs/rmf.cjs.map +1 -1
- package/dist/plugs/rmf.d.ts +11 -0
- package/dist/plugs/rmf.mjs +25 -20
- package/dist/plugs/rmf.mjs.map +1 -1
- package/{types → dist}/plugs/tsc/compiler.d.ts +1 -1
- package/{types → dist}/plugs/tsc/options.d.ts +1 -1
- package/{types → dist}/plugs/tsc/report.d.ts +2 -2
- package/dist/plugs/tsc/runner.cjs +12 -11
- package/dist/plugs/tsc/runner.cjs.map +1 -1
- package/dist/plugs/tsc/runner.d.ts +8 -0
- package/dist/plugs/tsc/runner.mjs +12 -11
- package/dist/plugs/tsc/runner.mjs.map +1 -1
- package/dist/plugs/tsc.cjs +7 -0
- package/dist/plugs/tsc.cjs.map +6 -0
- package/dist/plugs/tsc.d.ts +36 -0
- package/dist/plugs/tsc.mjs +15 -0
- package/dist/plugs/tsc.mjs.map +6 -0
- package/dist/plugs.cjs +3 -5
- package/dist/plugs.cjs.map +1 -1
- package/dist/plugs.d.ts +10 -0
- package/dist/plugs.mjs +3 -5
- package/dist/plugs.mjs.map +1 -1
- package/dist/types.cjs +19 -0
- package/dist/types.cjs.map +6 -0
- package/dist/types.d.ts +72 -0
- package/dist/types.mjs +1 -0
- package/dist/types.mjs.map +6 -0
- package/{types → dist}/utils/asyncfs.d.ts +0 -0
- package/dist/utils/caller.cjs +8 -11
- package/dist/utils/caller.cjs.map +2 -2
- package/dist/utils/caller.d.ts +2 -0
- package/dist/utils/caller.mjs +8 -11
- package/dist/utils/caller.mjs.map +2 -2
- package/{types → dist}/utils/match.d.ts +0 -0
- package/dist/utils/options.cjs +4 -6
- package/dist/utils/options.cjs.map +1 -1
- package/dist/utils/options.d.ts +16 -0
- package/dist/utils/options.mjs +4 -6
- package/dist/utils/options.mjs.map +1 -1
- package/{types → dist}/utils/walk.d.ts +2 -2
- package/extra/cli.mjs +31 -20
- package/extra/ts-loader.mjs +6 -5
- package/package.json +10 -10
- package/src/async.ts +27 -19
- package/src/files.ts +6 -30
- package/src/fork.ts +35 -76
- package/src/helpers.ts +89 -101
- package/src/index.ts +10 -15
- package/src/log/colors.ts +4 -3
- package/src/log/emit.ts +4 -4
- package/src/log/logger.ts +12 -4
- package/src/log/options.ts +1 -1
- package/src/log/report.ts +10 -24
- package/src/log/spinner.ts +3 -3
- package/src/log.ts +9 -9
- package/src/paths.ts +1 -1
- package/src/pipe.ts +191 -178
- package/src/plugs/copy.ts +40 -31
- package/src/plugs/coverage/analysis.ts +4 -4
- package/src/plugs/coverage/report.ts +9 -6
- package/src/plugs/coverage.ts +68 -55
- package/src/plugs/debug.ts +22 -27
- package/src/plugs/esbuild/fix-extensions.ts +2 -2
- package/src/plugs/esbuild.ts +42 -46
- package/src/plugs/eslint/runner.ts +16 -31
- package/src/plugs/eslint.ts +42 -0
- package/src/plugs/exec.ts +93 -82
- package/src/plugs/filter.ts +42 -27
- package/src/plugs/mocha/reporter.ts +19 -5
- package/src/plugs/mocha/runner.ts +12 -38
- package/src/plugs/mocha.ts +41 -0
- package/src/plugs/rmf.ts +21 -25
- package/src/plugs/tsc/compiler.ts +1 -1
- package/src/plugs/tsc/options.ts +2 -2
- package/src/plugs/tsc/report.ts +2 -2
- package/src/plugs/tsc/runner.ts +24 -30
- package/src/plugs/tsc.ts +45 -0
- package/src/plugs.ts +10 -25
- package/src/types.ts +123 -0
- package/src/utils/caller.ts +11 -22
- package/src/utils/options.ts +49 -17
- package/src/utils/walk.ts +4 -4
- package/dist/run.cjs +0 -90
- package/dist/run.cjs.map +0 -6
- package/dist/run.mjs +0 -65
- package/dist/run.mjs.map +0 -6
- package/dist/task.cjs.map +0 -6
- package/dist/task.mjs +0 -14
- package/dist/task.mjs.map +0 -6
- package/src/run.ts +0 -159
- package/src/task.ts +0 -26
- package/types/async.d.ts +0 -20
- package/types/build.d.ts +0 -56
- package/types/fork.d.ts +0 -57
- package/types/helpers.d.ts +0 -43
- package/types/index.d.ts +0 -14
- package/types/pipe.d.ts +0 -152
- package/types/plugs/copy.d.ts +0 -27
- package/types/plugs/coverage.d.ts +0 -46
- package/types/plugs/debug.d.ts +0 -14
- package/types/plugs/esbuild.d.ts +0 -23
- package/types/plugs/eslint/runner.d.ts +0 -22
- package/types/plugs/exec.d.ts +0 -90
- package/types/plugs/filter.d.ts +0 -23
- package/types/plugs/rmf.d.ts +0 -15
- package/types/plugs/tsc/runner.d.ts +0 -13
- package/types/plugs.d.ts +0 -17
- package/types/run.d.ts +0 -89
- package/types/task.d.ts +0 -15
- package/types/utils/caller.d.ts +0 -7
- package/types/utils/options.d.ts +0 -15
package/src/plugs/tsc/runner.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import ts from 'typescript' // TypeScript does NOT support ESM modules
|
|
2
|
-
|
|
3
|
-
import { failure } from '../../assert
|
|
4
|
-
import { Files } from '../../files
|
|
5
|
-
import { $p, log } from '../../log
|
|
6
|
-
import { AbsolutePath, resolveFile } from '../../paths
|
|
7
|
-
import { Plug } from '../../pipe
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { updateReport } from './report.js'
|
|
1
|
+
import ts from 'typescript'; // TypeScript does NOT support ESM modules
|
|
2
|
+
|
|
3
|
+
import { failure } from '../../assert'
|
|
4
|
+
import { Files } from '../../files'
|
|
5
|
+
import { $p, log } from '../../log'
|
|
6
|
+
import { AbsolutePath, resolveFile } from '../../paths'
|
|
7
|
+
import { Context, PipeParameters, Plug } from '../../pipe'
|
|
8
|
+
import { parseOptions } from '../../utils/options'
|
|
9
|
+
import { TypeScriptHost } from './compiler'
|
|
10
|
+
import { getCompilerOptions } from './options'
|
|
11
|
+
import { updateReport } from './report'
|
|
13
12
|
|
|
14
13
|
/* ========================================================================== *
|
|
15
14
|
* WORKER PLUG *
|
|
@@ -19,20 +18,15 @@ export default class Tsc implements Plug<Files> {
|
|
|
19
18
|
private readonly _tsconfig?: string
|
|
20
19
|
private readonly _options: ts.CompilerOptions
|
|
21
20
|
|
|
22
|
-
constructor()
|
|
23
|
-
constructor(config: string)
|
|
24
|
-
constructor(options: ts.CompilerOptions)
|
|
25
|
-
constructor(config: string, options: ts.CompilerOptions)
|
|
26
|
-
|
|
27
|
-
constructor(...args: ParseOptions<ts.CompilerOptions>) {
|
|
21
|
+
constructor(...args: PipeParameters<'tsc'>) {
|
|
28
22
|
const { params: [ tsconfig ], options } = parseOptions(args, {})
|
|
29
23
|
this._tsconfig = tsconfig
|
|
30
24
|
this._options = options
|
|
31
25
|
}
|
|
32
26
|
|
|
33
|
-
async pipe(files: Files,
|
|
34
|
-
const baseDir =
|
|
35
|
-
const report =
|
|
27
|
+
async pipe(files: Files, context: Context): Promise<Files> {
|
|
28
|
+
const baseDir = context.resolve('.') // "this" directory, base of all relative paths
|
|
29
|
+
const report = context.log.report('TypeScript Report') // report used throughout
|
|
36
30
|
const overrides = { ...this._options } // clone our options
|
|
37
31
|
|
|
38
32
|
/*
|
|
@@ -40,13 +34,13 @@ export default class Tsc implements Plug<Files> {
|
|
|
40
34
|
* alongside the sources, otherwise checked in the current directory.
|
|
41
35
|
*/
|
|
42
36
|
const sourcesConfig = resolveFile(files.directory, 'tsconfig.json')
|
|
43
|
-
const tsconfig = this._tsconfig ?
|
|
44
|
-
sourcesConfig || resolveFile(
|
|
37
|
+
const tsconfig = this._tsconfig ? context.resolve(this._tsconfig) :
|
|
38
|
+
sourcesConfig || resolveFile(context.resolve('tsconfig.json'))
|
|
45
39
|
|
|
46
40
|
/* Root directory must always exist */
|
|
47
41
|
let rootDir: AbsolutePath
|
|
48
42
|
if (overrides.rootDir) {
|
|
49
|
-
rootDir = overrides.rootDir =
|
|
43
|
+
rootDir = overrides.rootDir = context.resolve(overrides.rootDir)
|
|
50
44
|
} else {
|
|
51
45
|
rootDir = overrides.rootDir = files.directory
|
|
52
46
|
}
|
|
@@ -54,24 +48,24 @@ export default class Tsc implements Plug<Files> {
|
|
|
54
48
|
/* Output directory _also_ must always exist */
|
|
55
49
|
let outDir: AbsolutePath
|
|
56
50
|
if (overrides.outDir) {
|
|
57
|
-
outDir = overrides.outDir =
|
|
51
|
+
outDir = overrides.outDir = context.resolve(overrides.outDir)
|
|
58
52
|
} else {
|
|
59
53
|
outDir = overrides.outDir = rootDir // default to the root directory
|
|
60
54
|
}
|
|
61
55
|
|
|
62
56
|
/* All other root paths */
|
|
63
57
|
if (overrides.rootDirs) {
|
|
64
|
-
overrides.rootDirs = overrides.rootDirs.map((dir) =>
|
|
58
|
+
overrides.rootDirs = overrides.rootDirs.map((dir) => context.resolve(dir))
|
|
65
59
|
}
|
|
66
60
|
|
|
67
61
|
/* The baseURL is resolved, as well */
|
|
68
|
-
if (overrides.baseUrl) overrides.baseUrl =
|
|
62
|
+
if (overrides.baseUrl) overrides.baseUrl = context.resolve(overrides.baseUrl)
|
|
69
63
|
|
|
70
64
|
/* We can now get our compiler options, and check any and all overrides */
|
|
71
65
|
const { errors, options } = await getCompilerOptions(
|
|
72
66
|
tsconfig, // resolved tsconfig.json from constructor, might be undefined
|
|
73
67
|
overrides, // overrides from constructor, might be an empty object
|
|
74
|
-
|
|
68
|
+
context.buildFile, // the build file where the overrides were specified,
|
|
75
69
|
baseDir) // base dir where to resolve overrides
|
|
76
70
|
|
|
77
71
|
/* Update report and fail on errors */
|
|
@@ -95,13 +89,13 @@ export default class Tsc implements Plug<Files> {
|
|
|
95
89
|
if (report.errors) report.done(true)
|
|
96
90
|
|
|
97
91
|
/* Write out all files asynchronously */
|
|
98
|
-
const builder =
|
|
92
|
+
const builder = Files.builder(outDir)
|
|
99
93
|
const promises: Promise<void>[] = []
|
|
100
94
|
const result = program.emit(undefined, (fileName, code) => {
|
|
101
95
|
promises.push(builder.write(fileName, code).then((file) => {
|
|
102
96
|
log.trace('Written', $p(file))
|
|
103
97
|
}).catch((error) => {
|
|
104
|
-
|
|
98
|
+
context.log.error('Error writing to', fileName, error)
|
|
105
99
|
throw failure() // no more logs!
|
|
106
100
|
}))
|
|
107
101
|
})
|
package/src/plugs/tsc.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { CompilerOptions } from 'typescript'
|
|
2
|
+
|
|
3
|
+
import { requireResolve } from '../paths'
|
|
4
|
+
import { installForking } from '../pipe'
|
|
5
|
+
|
|
6
|
+
declare module '../pipe' {
|
|
7
|
+
export interface Pipe {
|
|
8
|
+
/**
|
|
9
|
+
* Run the {@link https://www.typescriptlang.org/ TypeScript Compiler}
|
|
10
|
+
* over the input source files, using the default `tsconfig.json` file.
|
|
11
|
+
*/
|
|
12
|
+
tsc(): Pipe
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Run the {@link https://www.typescriptlang.org/ TypeScript Compiler}
|
|
16
|
+
* over the input source files, specifying the `tsconfig.json` file.
|
|
17
|
+
*
|
|
18
|
+
* @param configFile The `tsconfig.json` file to use.
|
|
19
|
+
*/
|
|
20
|
+
tsc(configFile: string): Pipe
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Run the {@link https://www.typescriptlang.org/ TypeScript Compiler}
|
|
24
|
+
* over the input source files, using the default `tsconfig.json` file
|
|
25
|
+
* and overriding some options
|
|
26
|
+
*
|
|
27
|
+
* @param options {@link CompilerOptions | Options} overriding what's
|
|
28
|
+
* currently specified in the default `tsconfig.json`.
|
|
29
|
+
*/
|
|
30
|
+
tsc(options: CompilerOptions): Pipe
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Run the {@link https://www.typescriptlang.org/ TypeScript Compiler}
|
|
34
|
+
* over the input source files, specifying the `tsconfig.json` file
|
|
35
|
+
* and overriding some options
|
|
36
|
+
*
|
|
37
|
+
* @param configFile The `tsconfig.json` file to use.
|
|
38
|
+
* @param options {@link CompilerOptions | Options} overriding what's
|
|
39
|
+
* currently specified in the specified `tsconfig.json`.
|
|
40
|
+
*/
|
|
41
|
+
tsc(configFile: string, options: CompilerOptions): Pipe
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
installForking('tsc', requireResolve(__fileurl, './tsc/runner'))
|
package/src/plugs.ts
CHANGED
|
@@ -2,33 +2,18 @@
|
|
|
2
2
|
* FORKING PLUGS *
|
|
3
3
|
* ========================================================================== */
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import type ESLint from './plugs/eslint/runner.js'
|
|
9
|
-
import type Mocha from './plugs/mocha/runner.js'
|
|
10
|
-
import type Tsc from './plugs/tsc/runner.js'
|
|
11
|
-
|
|
12
|
-
declare module './pipe.js' {
|
|
13
|
-
export interface Pipe {
|
|
14
|
-
eslint: PipeExtension<typeof ESLint>
|
|
15
|
-
mocha: PipeExtension<typeof Mocha>
|
|
16
|
-
tsc: PipeExtension<typeof Tsc>
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
installForking('eslint', requireResolve(__fileurl, './plugs/eslint/runner'))
|
|
21
|
-
installForking('mocha', requireResolve(__fileurl, './plugs/mocha/runner'))
|
|
22
|
-
installForking('tsc', requireResolve(__fileurl, './plugs/tsc/runner'))
|
|
5
|
+
export * from './plugs/eslint'
|
|
6
|
+
export * from './plugs/mocha'
|
|
7
|
+
export * from './plugs/tsc'
|
|
23
8
|
|
|
24
9
|
/* ========================================================================== *
|
|
25
10
|
* STANDARD IN-PROCESS PLUGS *
|
|
26
11
|
* ========================================================================== */
|
|
27
12
|
|
|
28
|
-
export * from './plugs/copy
|
|
29
|
-
export * from './plugs/coverage
|
|
30
|
-
export * from './plugs/debug
|
|
31
|
-
export * from './plugs/esbuild
|
|
32
|
-
export * from './plugs/exec
|
|
33
|
-
export * from './plugs/filter
|
|
34
|
-
export * from './plugs/rmf
|
|
13
|
+
export * from './plugs/copy'
|
|
14
|
+
export * from './plugs/coverage'
|
|
15
|
+
export * from './plugs/debug'
|
|
16
|
+
export * from './plugs/esbuild'
|
|
17
|
+
export * from './plugs/exec'
|
|
18
|
+
export * from './plugs/filter'
|
|
19
|
+
export * from './plugs/rmf'
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import type { Files } from './files'
|
|
2
|
+
import type { AbsolutePath } from './paths'
|
|
3
|
+
import type { Pipe } from './pipe'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A type describing the ultimate result of a {@link Plug}, {@link Pipe} or
|
|
7
|
+
* {@link Task}, that is either a {@link Files} instance or `undefined`.
|
|
8
|
+
*/
|
|
9
|
+
export type Result = Files | undefined
|
|
10
|
+
|
|
11
|
+
/* ========================================================================== *
|
|
12
|
+
* STATE AND CONTEXT *
|
|
13
|
+
* ========================================================================== */
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The {@link State} interface defines a component tracking the current
|
|
17
|
+
* _state_ of a build, caching the result of {@link Task}s, and tracking their
|
|
18
|
+
* invocation stack to avoid infinite loops.
|
|
19
|
+
*/
|
|
20
|
+
export interface State {
|
|
21
|
+
/** The cache of the result of {@link Task}s execution */
|
|
22
|
+
readonly cache: Map<Task, Promise<Result>>
|
|
23
|
+
/** The current {@link Task} invocation stack (to avoid infinite loops) */
|
|
24
|
+
readonly stack: Task[],
|
|
25
|
+
/** All {@link Tasks} available in this {@link State} */
|
|
26
|
+
readonly tasks: Tasks
|
|
27
|
+
/** All _properties_ available in this {@link State} */
|
|
28
|
+
readonly props: Props
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/* ========================================================================== *
|
|
32
|
+
* TASKS *
|
|
33
|
+
* ========================================================================== */
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The {@link Task} interface normalizes a task definition, associating it with
|
|
37
|
+
* its build file, its sibling {@link Task}s and available _properties_.
|
|
38
|
+
*/
|
|
39
|
+
export interface Task<T extends Result = Result> {
|
|
40
|
+
/** All _properties_ siblings to this {@link Task} */
|
|
41
|
+
readonly props: Props
|
|
42
|
+
/** All {@link Tasks} sibling to this {@link Task} */
|
|
43
|
+
readonly tasks: Tasks
|
|
44
|
+
/** The absolute file name where this {@link Task} was defined */
|
|
45
|
+
readonly buildFile: AbsolutePath,
|
|
46
|
+
/** Invoke a task from (possibly) a different {@link Context} */
|
|
47
|
+
call(state: State, taskName: string): Promise<T>
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The {@link TaskResult} type identifies _what_ can be returned by a
|
|
52
|
+
* {@link TaskDef | _task definition_}.
|
|
53
|
+
*/
|
|
54
|
+
export type TaskResult = Pipe | Promise<undefined> | Files | void | undefined
|
|
55
|
+
|
|
56
|
+
/** The {@link TaskDef} type identifies the _definition_ of a task. */
|
|
57
|
+
export type TaskDef<R extends TaskResult = TaskResult> = () => R | Promise<R>
|
|
58
|
+
|
|
59
|
+
/* ========================================================================== *
|
|
60
|
+
* TASKS AND PROPERTIES *
|
|
61
|
+
* ========================================================================== */
|
|
62
|
+
|
|
63
|
+
/** A type identifying all _properties_ of a {@link Context}. */
|
|
64
|
+
export type Props<D extends BuildDef = BuildDef> = {
|
|
65
|
+
readonly [ k in string & keyof D as D[k] extends string ? k : never ] : string
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** A type identifying all _tasks_ in a {@link Context} */
|
|
69
|
+
export type Tasks<D extends BuildDef = BuildDef> = {
|
|
70
|
+
readonly [ k in string & keyof D as D[k] extends TaskDef | Task ? k : never ] :
|
|
71
|
+
D[k] extends TaskDef<infer R> ?
|
|
72
|
+
R extends void | undefined ? Task<undefined> :
|
|
73
|
+
R extends Promise<undefined> ? Task<undefined> :
|
|
74
|
+
R extends Pipe ? Task<Files> :
|
|
75
|
+
R extends Files ? Task<Files> :
|
|
76
|
+
never :
|
|
77
|
+
D[k] extends Task ? D[k] :
|
|
78
|
+
never
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/* ========================================================================== *
|
|
82
|
+
* BUILD *
|
|
83
|
+
* ========================================================================== */
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* The {@link BuildDef} interface describes the _definition_ of a
|
|
87
|
+
* {@link Context}, that is the object passed to {@link build} to produce
|
|
88
|
+
* a {@link Build}.
|
|
89
|
+
*/
|
|
90
|
+
export interface BuildDef {
|
|
91
|
+
[ k : string ] : string | TaskDef | Task
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* The type that will be used for `this` when invoking
|
|
96
|
+
* {@link TaskDef | task definitions }.
|
|
97
|
+
*/
|
|
98
|
+
export type ThisBuild<D extends BuildDef> = {
|
|
99
|
+
readonly [ k in keyof D ] :
|
|
100
|
+
k extends string ?
|
|
101
|
+
D[k] extends TaskDef<infer R> ?
|
|
102
|
+
R extends Promise<undefined> | void | undefined ? () => Promise<undefined> :
|
|
103
|
+
R extends Pipe | Files ? () => Pipe & Promise<Files> :
|
|
104
|
+
never :
|
|
105
|
+
D[k] extends Task<infer R> ?
|
|
106
|
+
R extends undefined ? () => Promise<undefined> :
|
|
107
|
+
R extends Files ? () => Pipe & Promise<Files> :
|
|
108
|
+
never :
|
|
109
|
+
D[k] extends string ?
|
|
110
|
+
string :
|
|
111
|
+
never :
|
|
112
|
+
never
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* The {@link Build} type represents the collection of {@link Task}s
|
|
117
|
+
* and _properties_ compiled from a {@link BuildDef | build definition}.
|
|
118
|
+
*/
|
|
119
|
+
export type Build<
|
|
120
|
+
D extends BuildDef = BuildDef,
|
|
121
|
+
T extends Tasks<D> = Tasks<D>,
|
|
122
|
+
P extends Props<D> = Props<D>,
|
|
123
|
+
> = T & P
|
package/src/utils/caller.ts
CHANGED
|
@@ -1,44 +1,33 @@
|
|
|
1
1
|
import { statSync } from 'node:fs'
|
|
2
2
|
import { fileURLToPath } from 'node:url'
|
|
3
|
-
import { assert } from '../assert
|
|
4
|
-
import {
|
|
3
|
+
import { assert } from '../assert'
|
|
4
|
+
import { $p } from '../log'
|
|
5
|
+
import { AbsolutePath, assertAbsolutePath } from '../paths'
|
|
5
6
|
|
|
6
|
-
export
|
|
7
|
-
file: AbsolutePath,
|
|
8
|
-
line?: number | undefined,
|
|
9
|
-
column?: number | undefined,
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function findCaller(of: (...args: any[]) => any): Location {
|
|
7
|
+
export function findCaller(of: (...args: any[]) => any): AbsolutePath {
|
|
13
8
|
const oldPrepareStackTrace = Error.prepareStackTrace
|
|
14
9
|
|
|
15
10
|
try {
|
|
16
|
-
Error.prepareStackTrace = (_, stackTraces):
|
|
11
|
+
Error.prepareStackTrace = (_, stackTraces): AbsolutePath | undefined => {
|
|
17
12
|
const nullableFileOrUrl = stackTraces[0].getFileName()
|
|
18
13
|
if (! nullableFileOrUrl) return
|
|
19
14
|
|
|
20
|
-
const nullableLine = stackTraces[0].getColumnNumber()
|
|
21
|
-
const nullableColumn = stackTraces[0].getColumnNumber()
|
|
22
|
-
|
|
23
|
-
const line = typeof nullableLine === 'number' ? nullableLine : undefined
|
|
24
|
-
const column = typeof nullableColumn === 'number' ? nullableColumn : undefined
|
|
25
|
-
|
|
26
15
|
const file =
|
|
27
16
|
nullableFileOrUrl.startsWith('file:/') ?
|
|
28
17
|
fileURLToPath(nullableFileOrUrl) :
|
|
29
18
|
nullableFileOrUrl
|
|
30
19
|
|
|
31
20
|
assertAbsolutePath(file)
|
|
32
|
-
return
|
|
21
|
+
return file
|
|
33
22
|
}
|
|
34
23
|
|
|
35
|
-
const record: { stack?:
|
|
24
|
+
const record: { stack?: AbsolutePath } = {}
|
|
36
25
|
Error.captureStackTrace(record, of)
|
|
37
|
-
const
|
|
26
|
+
const file = record.stack
|
|
38
27
|
|
|
39
|
-
assert(
|
|
40
|
-
assert(statSync(
|
|
41
|
-
return
|
|
28
|
+
assert(file, 'Unable to determine build file name')
|
|
29
|
+
assert(statSync(file).isFile(), `Build file ${$p(file)} not found`)
|
|
30
|
+
return file
|
|
42
31
|
} finally {
|
|
43
32
|
Error.prepareStackTrace = oldPrepareStackTrace
|
|
44
33
|
}
|
package/src/utils/options.ts
CHANGED
|
@@ -1,22 +1,54 @@
|
|
|
1
|
-
|
|
2
|
-
export type
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
//
|
|
12
|
-
|
|
1
|
+
/** A type extacting string parameters from an arguments array */
|
|
2
|
+
export type ParsedParams<Args extends readonly any[]> =
|
|
3
|
+
// Normal tuple, we stop processing if the _first_ argument is not a string!
|
|
4
|
+
Args extends readonly [ infer First, ...infer Rest ] ?
|
|
5
|
+
First extends string ? [ First, ...ParsedParams<Rest> ] : [] :
|
|
6
|
+
|
|
7
|
+
// If not caught above, here "first" is the rest parameter in the tuple
|
|
8
|
+
Args extends readonly [ ...infer First, infer Rest ] ?
|
|
9
|
+
Rest extends string ? [ ...ParsedParams<First>, Rest ] : [ ...ParsedParams<First> ] :
|
|
10
|
+
|
|
11
|
+
// Not a tuple: normal string array or the end of our arguments
|
|
12
|
+
Args extends readonly string[] ? [ ...Args ] : []
|
|
13
|
+
|
|
14
|
+
/** A type extacting the (last) options type from an arguments array */
|
|
15
|
+
export type ParsedOptions<Args extends readonly any[]> = // , Defaults> =
|
|
16
|
+
Args extends readonly [ ...string[], infer Last ] ?
|
|
17
|
+
Last extends object ? // Record<any, any> ?
|
|
18
|
+
Last : // last arg is a record, defaults is null or undefined
|
|
19
|
+
never : // last arg is a string, defaults is null or undefined
|
|
20
|
+
never // args is not an array
|
|
21
|
+
|
|
22
|
+
/** Parserable arguments: a number of strings, followed by optional options */
|
|
23
|
+
export type ParseOptions<Options extends Record<any, any>> =
|
|
24
|
+
readonly [ ...params: string[] ] | readonly [ ...params: string[], options: Options ]
|
|
25
|
+
|
|
26
|
+
/** The return type from {@link ParseOptions} */
|
|
27
|
+
export interface ParsedResult<Args extends readonly any [], Options, Defaults> {
|
|
28
|
+
params: ParsedParams<Args>,
|
|
29
|
+
options: Defaults extends null | undefined ? Options | undefined : Options & Defaults
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Parse an array of arguments (a number of strings optionally followed by an
|
|
34
|
+
* options object into parameters and options.
|
|
35
|
+
*/
|
|
36
|
+
export function parseOptions<
|
|
37
|
+
Args extends ParseOptions<any>,
|
|
38
|
+
Options extends ParsedOptions<Args> = ParsedOptions<Args>,
|
|
39
|
+
Defaults extends ParsedOptions<Args> | null | undefined = undefined,
|
|
40
|
+
>(args: Args, defaults?: Defaults): ParsedResult<Args, Options, Defaults> {
|
|
13
41
|
const params: string[] = []
|
|
14
|
-
const
|
|
42
|
+
const clone: any[] = [ ...args ]
|
|
15
43
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
44
|
+
// Collect all strings at the beginning of our arguments array
|
|
45
|
+
while (typeof clone[0] === 'string') {
|
|
46
|
+
params.push(clone.shift())
|
|
19
47
|
}
|
|
20
48
|
|
|
21
|
-
|
|
49
|
+
// The options is the _last_ element in our arguments array (if any)
|
|
50
|
+
const options = Object.assign({}, defaults, clone.pop())
|
|
51
|
+
|
|
52
|
+
// All done
|
|
53
|
+
return { params, options } as ParsedResult<Args, Options, Defaults>
|
|
22
54
|
}
|
package/src/utils/walk.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Dir } from 'node:fs'
|
|
2
2
|
import { basename, join } from 'node:path'
|
|
3
|
-
import { $p, log } from '../log
|
|
4
|
-
import { AbsolutePath, resolveAbsolutePath } from '../paths
|
|
5
|
-
import { opendir, stat } from './asyncfs
|
|
6
|
-
import { match, MatchOptions } from './match
|
|
3
|
+
import { $p, log } from '../log'
|
|
4
|
+
import { AbsolutePath, resolveAbsolutePath } from '../paths'
|
|
5
|
+
import { opendir, stat } from './asyncfs'
|
|
6
|
+
import { match, MatchOptions } from './match'
|
|
7
7
|
|
|
8
8
|
/** Specific options for walking a directory */
|
|
9
9
|
export interface WalkOptions extends MatchOptions {
|
package/dist/run.cjs
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// run.ts
|
|
21
|
-
var run_exports = {};
|
|
22
|
-
__export(run_exports, {
|
|
23
|
-
RunImpl: () => RunImpl
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(run_exports);
|
|
26
|
-
var import_node_path = require("node:path");
|
|
27
|
-
var import_files = require("./files.cjs");
|
|
28
|
-
var import_log = require("./log.cjs");
|
|
29
|
-
var import_paths = require("./paths.cjs");
|
|
30
|
-
var import_pipe = require("./pipe.cjs");
|
|
31
|
-
var import_options = require("./utils/options.cjs");
|
|
32
|
-
var import_walk = require("./utils/walk.cjs");
|
|
33
|
-
var RunImpl = class {
|
|
34
|
-
taskName;
|
|
35
|
-
buildFile;
|
|
36
|
-
buildDir;
|
|
37
|
-
log;
|
|
38
|
-
constructor({ taskName, buildDir, buildFile, log }) {
|
|
39
|
-
this.taskName = taskName;
|
|
40
|
-
this.buildDir = buildDir;
|
|
41
|
-
this.buildFile = buildFile;
|
|
42
|
-
this.log = log || (0, import_log.getLogger)(taskName);
|
|
43
|
-
}
|
|
44
|
-
setLogLevel(level) {
|
|
45
|
-
this.log.level = (0, import_log.getLevelNumber)(level);
|
|
46
|
-
}
|
|
47
|
-
report(title) {
|
|
48
|
-
return (0, import_log.createReport)(title, this.taskName);
|
|
49
|
-
}
|
|
50
|
-
resolve(path, ...paths) {
|
|
51
|
-
if (path && path.startsWith("@")) {
|
|
52
|
-
const components = path.substring(1).split(import_node_path.sep).filter((s) => !!s);
|
|
53
|
-
return (0, import_paths.resolveAbsolutePath)(this.buildDir, ...components, ...paths);
|
|
54
|
-
}
|
|
55
|
-
if (!path)
|
|
56
|
-
return (0, import_paths.getCurrentWorkingDirectory)();
|
|
57
|
-
return (0, import_paths.resolveAbsolutePath)((0, import_paths.getCurrentWorkingDirectory)(), path, ...paths);
|
|
58
|
-
}
|
|
59
|
-
files(first, ...paths) {
|
|
60
|
-
if (typeof first === "string") {
|
|
61
|
-
return import_files.Files.builder(this.resolve(first, ...paths));
|
|
62
|
-
} else if (first) {
|
|
63
|
-
return import_files.Files.builder(first);
|
|
64
|
-
} else {
|
|
65
|
-
return import_files.Files.builder(this.resolve());
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
find(glob, ...args) {
|
|
69
|
-
const { params, options: { directory, ...options } } = (0, import_options.parseOptions)(args, {});
|
|
70
|
-
const promise = Promise.resolve().then(async () => {
|
|
71
|
-
const builder = this.files(directory || ".");
|
|
72
|
-
for await (const file of (0, import_walk.walk)(builder.directory, [glob, ...params], options)) {
|
|
73
|
-
builder.unchecked(file);
|
|
74
|
-
}
|
|
75
|
-
return builder.build();
|
|
76
|
-
});
|
|
77
|
-
return this.pipe(promise);
|
|
78
|
-
}
|
|
79
|
-
pipe(files) {
|
|
80
|
-
return new import_pipe.PipeImpl(files, this);
|
|
81
|
-
}
|
|
82
|
-
call(name) {
|
|
83
|
-
throw new Error(`Unable to call task "${name}"`);
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
87
|
-
0 && (module.exports = {
|
|
88
|
-
RunImpl
|
|
89
|
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AO,mBAAM,QAAQ,KAAK;AAAA,IAC5B,OAAO;AACL,aAAO,mBAAM,QAAQ,KAAK,QAAQ,CAAC;AAAA,IACrC;AAAA,EACF;AAAA,EAEA,KAAK,SAAiB,MAAwD;AAC5E,UAAM,EAAE,QAAQ,SAAS,EAAE,cAAc,QAAQ,EAAE,QAAI,6BAAa,MAAM,CAAC,CAAC;AAE5E,UAAM,UAAU,QAAQ,QAAQ,EAAE,KAAK,YAAY;AACjD,YAAM,UAAU,KAAK,MAAM,aAAa,GAAG;AAC3C,uBAAiB,YAAQ,kBAAK,QAAQ,WAAW,CAAE,MAAM,GAAG,MAAO,GAAG,OAAO,GAAG;AAC9E,gBAAQ,UAAU,IAAI;AAAA,MACxB;AACA,aAAO,QAAQ,MAAM;AAAA,IACvB,CAAC;AAED,WAAO,KAAK,KAAK,OAAO;AAAA,EAC1B;AAAA,EAEA,KAAK,OAAsD;AACzD,WAAO,IAAI,qBAAS,OAAO,IAAI;AAAA,EACjC;AAAA,EAEA,KAAK,MAA0C;AAC7C,UAAM,IAAI,MAAM,wBAAwB,OAAO;AAAA,EACjD;AACF;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|
package/dist/run.mjs
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
// run.ts
|
|
2
|
-
import { sep } from "node:path";
|
|
3
|
-
import { Files } from "./files.mjs";
|
|
4
|
-
import { createReport, getLevelNumber, getLogger } from "./log.mjs";
|
|
5
|
-
import { getCurrentWorkingDirectory, resolveAbsolutePath } from "./paths.mjs";
|
|
6
|
-
import { PipeImpl } from "./pipe.mjs";
|
|
7
|
-
import { parseOptions } from "./utils/options.mjs";
|
|
8
|
-
import { walk } from "./utils/walk.mjs";
|
|
9
|
-
var RunImpl = class {
|
|
10
|
-
taskName;
|
|
11
|
-
buildFile;
|
|
12
|
-
buildDir;
|
|
13
|
-
log;
|
|
14
|
-
constructor({ taskName, buildDir, buildFile, log }) {
|
|
15
|
-
this.taskName = taskName;
|
|
16
|
-
this.buildDir = buildDir;
|
|
17
|
-
this.buildFile = buildFile;
|
|
18
|
-
this.log = log || getLogger(taskName);
|
|
19
|
-
}
|
|
20
|
-
setLogLevel(level) {
|
|
21
|
-
this.log.level = getLevelNumber(level);
|
|
22
|
-
}
|
|
23
|
-
report(title) {
|
|
24
|
-
return createReport(title, this.taskName);
|
|
25
|
-
}
|
|
26
|
-
resolve(path, ...paths) {
|
|
27
|
-
if (path && path.startsWith("@")) {
|
|
28
|
-
const components = path.substring(1).split(sep).filter((s) => !!s);
|
|
29
|
-
return resolveAbsolutePath(this.buildDir, ...components, ...paths);
|
|
30
|
-
}
|
|
31
|
-
if (!path)
|
|
32
|
-
return getCurrentWorkingDirectory();
|
|
33
|
-
return resolveAbsolutePath(getCurrentWorkingDirectory(), path, ...paths);
|
|
34
|
-
}
|
|
35
|
-
files(first, ...paths) {
|
|
36
|
-
if (typeof first === "string") {
|
|
37
|
-
return Files.builder(this.resolve(first, ...paths));
|
|
38
|
-
} else if (first) {
|
|
39
|
-
return Files.builder(first);
|
|
40
|
-
} else {
|
|
41
|
-
return Files.builder(this.resolve());
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
find(glob, ...args) {
|
|
45
|
-
const { params, options: { directory, ...options } } = parseOptions(args, {});
|
|
46
|
-
const promise = Promise.resolve().then(async () => {
|
|
47
|
-
const builder = this.files(directory || ".");
|
|
48
|
-
for await (const file of walk(builder.directory, [glob, ...params], options)) {
|
|
49
|
-
builder.unchecked(file);
|
|
50
|
-
}
|
|
51
|
-
return builder.build();
|
|
52
|
-
});
|
|
53
|
-
return this.pipe(promise);
|
|
54
|
-
}
|
|
55
|
-
pipe(files) {
|
|
56
|
-
return new PipeImpl(files, this);
|
|
57
|
-
}
|
|
58
|
-
call(name) {
|
|
59
|
-
throw new Error(`Unable to call task "${name}"`);
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
export {
|
|
63
|
-
RunImpl
|
|
64
|
-
};
|
|
65
|
-
//# sour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