@gesslar/bedoc 1.3.3 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/types/cli.d.ts +2 -2
- package/dist/types/core/ActionManager.d.ts +18 -18
- package/dist/types/core/Configuration.d.ts +11 -11
- package/dist/types/core/ConfigurationParameters.d.ts +24 -24
- package/dist/types/core/Conveyor.d.ts +34 -32
- package/dist/types/core/Core.d.ts +26 -31
- package/dist/types/core/Logger.d.ts +8 -0
- package/package.json +10 -1
- package/src/cli.js +5 -0
- package/src/core/Conveyor.js +18 -3
- package/src/core/Core.js +14 -4
- package/src/core/Logger.js +1 -1
package/dist/types/cli.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
export {}
|
|
3
|
-
//# sourceMappingURL=cli.d.ts.map
|
|
2
|
+
export {}
|
|
3
|
+
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -2,26 +2,26 @@ import Logger from './Logger';
|
|
|
2
2
|
import HookManager from './HookManager';
|
|
3
3
|
|
|
4
4
|
export interface ActionDefinition {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
action: string;
|
|
6
|
+
contract: Record<string, unknown>;
|
|
7
|
+
meta: Record<string, unknown>;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export default class ActionManager {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
11
|
+
constructor(actionDefinition: ActionDefinition, logger: Logger);
|
|
12
|
+
get action(): ActionDefinition;
|
|
13
|
+
set hookManager(hookManager: HookManager);
|
|
14
|
+
get hookManager(): HookManager;
|
|
15
|
+
get contract(): Record<string, unknown>;
|
|
16
|
+
get meta(): Record<string, unknown>;
|
|
17
|
+
get log(): Logger;
|
|
18
|
+
setupAction(): Promise<void>;
|
|
19
|
+
runAction({ file, content }: {
|
|
20
|
+
file: string;
|
|
21
|
+
content: string;
|
|
22
|
+
}): Promise<string>;
|
|
23
|
+
cleanupAction(): Promise<void>;
|
|
24
|
+
toString(): string;
|
|
25
|
+
#private;
|
|
26
26
|
}
|
|
27
27
|
//# sourceMappingURL=ActionManager.d.ts.map
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EnvironmentType } from './Core';
|
|
2
2
|
|
|
3
3
|
interface ConfigurationOption {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
value: unknown;
|
|
5
|
+
source: string;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
interface ConfigurationOptions {
|
|
9
|
-
|
|
9
|
+
[key: string]: ConfigurationOption;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
interface ValidateParams {
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
options: ConfigurationOptions;
|
|
14
|
+
source: EnvironmentType;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
interface ValidationResult {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
status: 'success';
|
|
19
|
+
validated: boolean;
|
|
20
|
+
[key: string]: unknown;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export default class Configuration {
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
validate({ options, source }: ValidateParams): Promise<ValidationResult>;
|
|
25
|
+
#private;
|
|
26
26
|
}
|
|
27
27
|
//# sourceMappingURL=Configuration.d.ts.map
|
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
import TypeSpec from './util/TypeSpec';
|
|
2
2
|
|
|
3
3
|
interface PathConfig {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
type: 'file' | 'directory';
|
|
5
|
+
mustExist: boolean;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
interface ConfigurationParameter {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
short: string;
|
|
10
|
+
param?: string;
|
|
11
|
+
description: string;
|
|
12
|
+
type: TypeSpec;
|
|
13
|
+
required: boolean;
|
|
14
|
+
default?: boolean | number | string;
|
|
15
|
+
path?: PathConfig;
|
|
16
|
+
exclusiveOf?: string;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
interface ConfigurationParametersType {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
20
|
+
input: ConfigurationParameter;
|
|
21
|
+
exclude: ConfigurationParameter;
|
|
22
|
+
language: ConfigurationParameter;
|
|
23
|
+
format: ConfigurationParameter;
|
|
24
|
+
maxConcurrent: ConfigurationParameter;
|
|
25
|
+
hooks: ConfigurationParameter;
|
|
26
|
+
output: ConfigurationParameter;
|
|
27
|
+
parser: ConfigurationParameter;
|
|
28
|
+
printer: ConfigurationParameter;
|
|
29
|
+
hookTimeout: ConfigurationParameter;
|
|
30
|
+
mock: ConfigurationParameter;
|
|
31
|
+
config: ConfigurationParameter;
|
|
32
|
+
debug: ConfigurationParameter;
|
|
33
|
+
debugLevel: ConfigurationParameter;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
export const ConfigurationParameters: Readonly<ConfigurationParametersType>;
|
|
@@ -3,45 +3,47 @@ import Logger from './Logger';
|
|
|
3
3
|
import { FileMap } from './util/FDUtil';
|
|
4
4
|
|
|
5
5
|
interface ProcessResult {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
status: 'success' | 'error' | 'warning';
|
|
7
|
+
file?: FileMap;
|
|
8
|
+
error?: Error;
|
|
9
|
+
warning?: string;
|
|
10
|
+
result?: string;
|
|
11
|
+
destFile?: string;
|
|
12
|
+
content?: string;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
interface ConveyResult {
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
export interface ConveyResult {
|
|
16
|
+
succeeded: Array<{ input: FileMap; output: FileMap }>;
|
|
17
|
+
errored: Array<{ input: FileMap; error: Error }>;
|
|
18
|
+
warned: Array<{ input: FileMap; warning: string }>;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
export default class Conveyor {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
constructor(
|
|
23
|
+
parse: ActionManager,
|
|
24
|
+
print: ActionManager,
|
|
25
|
+
logger: Logger,
|
|
26
|
+
output: FileMap
|
|
27
|
+
);
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
readonly parse: ActionManager;
|
|
30
|
+
readonly print: ActionManager;
|
|
31
|
+
readonly logger: Logger;
|
|
32
|
+
readonly output: FileMap;
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Processes files with a concurrency limit.
|
|
36
|
+
*
|
|
37
|
+
* @param files - List of files to process.
|
|
38
|
+
* @param maxConcurrent - Maximum number of concurrent tasks.
|
|
39
|
+
* @returns Resolves when all files are processed.
|
|
40
|
+
*/
|
|
41
|
+
convey(files: FileMap[], maxConcurrent?: number): Promise<ConveyResult>;
|
|
41
42
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
#succeeded: Array<{ input: FileMap; output: FileMap }>;
|
|
44
|
+
#errored: Array<{ input: FileMap; error: Error }>;
|
|
45
|
+
#warned: Array<{ input: FileMap; warning: string }>;
|
|
46
|
+
#processFile(file: FileMap): Promise<ProcessResult>;
|
|
47
|
+
#writeOutput(destFile: string, content: string): Promise<ProcessResult>;
|
|
46
48
|
}
|
|
47
49
|
//# sourceMappingURL=Conveyor.d.ts.map
|
|
@@ -1,53 +1,48 @@
|
|
|
1
1
|
import Logger from './Logger';
|
|
2
2
|
import ActionManager from './ActionManager';
|
|
3
|
-
import {
|
|
3
|
+
import { ConveyResult} from './Conveyor';
|
|
4
4
|
|
|
5
5
|
export const Environment: Readonly<{
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
EXTENSION: 'extension';
|
|
7
|
+
NPM: 'npm';
|
|
8
|
+
ACTION: 'action';
|
|
9
|
+
CLI: 'cli';
|
|
10
10
|
}>;
|
|
11
11
|
|
|
12
12
|
export type EnvironmentType = typeof Environment[keyof typeof Environment];
|
|
13
13
|
|
|
14
14
|
interface CoreOptions {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
debug?: boolean;
|
|
16
|
+
debugLevel?: number;
|
|
17
|
+
name?: string;
|
|
18
|
+
[key: string]: unknown;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
interface CoreConstructorOptions extends CoreOptions {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
hooks?: string;
|
|
23
|
+
hooksTimeout?: number;
|
|
24
|
+
output?: string;
|
|
25
|
+
maxConcurrent?: number;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
interface NewParams {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
interface ProcessResult {
|
|
34
|
-
succeeded: Array<{ input: FileMap; output: FileMap }>;
|
|
35
|
-
errored: Array<{ input: FileMap; error: Error }>;
|
|
29
|
+
options: CoreOptions;
|
|
30
|
+
source: EnvironmentType;
|
|
36
31
|
}
|
|
37
32
|
|
|
38
33
|
export default class Core {
|
|
39
|
-
|
|
34
|
+
static new({ options, source }: NewParams): Promise<Core>;
|
|
40
35
|
|
|
41
|
-
|
|
36
|
+
constructor(options: CoreConstructorOptions);
|
|
42
37
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
38
|
+
readonly options: CoreConstructorOptions;
|
|
39
|
+
readonly logger: Logger;
|
|
40
|
+
readonly packageJson: Record<string, unknown>;
|
|
41
|
+
readonly debugOptions: {
|
|
42
|
+
name: string | null;
|
|
43
|
+
debugLevel: number;
|
|
44
|
+
};
|
|
45
|
+
readonly actions: Record<string, ActionManager>;
|
|
51
46
|
|
|
52
|
-
|
|
47
|
+
processFiles(glob: string | string[], startTime?: [number, number]): Promise<ConveyResult>;
|
|
53
48
|
}
|
|
@@ -10,6 +10,14 @@ interface LoggerOptions {
|
|
|
10
10
|
type LogLevel = 'debug' | 'warn' | 'info' | 'error';
|
|
11
11
|
type DebugLevel = 0 | 1 | 2 | 3 | 4;
|
|
12
12
|
|
|
13
|
+
export declare const loggerColours: {
|
|
14
|
+
debug: string[];
|
|
15
|
+
info: string;
|
|
16
|
+
warn: string;
|
|
17
|
+
error: string;
|
|
18
|
+
reset: string;
|
|
19
|
+
};
|
|
20
|
+
|
|
13
21
|
/**
|
|
14
22
|
* Logger class
|
|
15
23
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gesslar/bedoc",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.2",
|
|
4
4
|
"description": "Pluggable documentation engine for any language and format",
|
|
5
5
|
"publisher": "gesslar",
|
|
6
6
|
"main": "./src/core/Core.js",
|
|
@@ -18,6 +18,13 @@
|
|
|
18
18
|
".": {
|
|
19
19
|
"import": "./src/core/Core.js",
|
|
20
20
|
"types": "./dist/types/core/Core.d.ts"
|
|
21
|
+
},
|
|
22
|
+
"./BeDoc": {
|
|
23
|
+
"import": "./src/core/Core.js",
|
|
24
|
+
"types": "./dist/types/core/Core.d.ts"
|
|
25
|
+
},
|
|
26
|
+
"./*": {
|
|
27
|
+
"types": "./dist/types/*"
|
|
21
28
|
}
|
|
22
29
|
},
|
|
23
30
|
"type": "module",
|
|
@@ -38,6 +45,8 @@
|
|
|
38
45
|
},
|
|
39
46
|
"devDependencies": {
|
|
40
47
|
"@stylistic/eslint-plugin-js": "^3.0.0",
|
|
48
|
+
"@typescript-eslint/eslint-plugin": "^8.22.0",
|
|
49
|
+
"@typescript-eslint/parser": "^8.22.0",
|
|
41
50
|
"axios": "^1.7.9",
|
|
42
51
|
"chokidar": "^4.0.3",
|
|
43
52
|
"eslint": "^9.18.0",
|
package/src/cli.js
CHANGED
|
@@ -75,6 +75,11 @@ const {resolveDirectory} = FDUtil
|
|
|
75
75
|
const filesToProcess = bedoc.options.input.map(f => f.absolutePath)
|
|
76
76
|
const result = await bedoc.processFiles(filesToProcess)
|
|
77
77
|
const errored = result.errored
|
|
78
|
+
const warned = result.warned
|
|
79
|
+
|
|
80
|
+
if(warned.length > 0)
|
|
81
|
+
warned.forEach(w => bedoc.logger.warn(w.warning))
|
|
82
|
+
|
|
78
83
|
if(errored.length > 0)
|
|
79
84
|
throw new AggregateError(errored.map(e => e.error), "Error processing files")
|
|
80
85
|
} catch(error) {
|
package/src/core/Conveyor.js
CHANGED
|
@@ -6,6 +6,7 @@ const {readFile, writeFile, composeFilename} = FDUtil
|
|
|
6
6
|
|
|
7
7
|
export default class Conveyor {
|
|
8
8
|
#succeeded = []
|
|
9
|
+
#warned = []
|
|
9
10
|
#errored = []
|
|
10
11
|
|
|
11
12
|
constructor(parse, print, logger, output) {
|
|
@@ -33,8 +34,10 @@ export default class Conveyor {
|
|
|
33
34
|
const slot = Promise.race(semaphore) // Wait for an available slot
|
|
34
35
|
semaphore.push(slot.then(async() => {
|
|
35
36
|
const result = await this.#processFile(file)
|
|
36
|
-
if(result.status === "success"
|
|
37
|
+
if(result.status === "success")
|
|
37
38
|
this.#succeeded.push({input: file, output: result.file})
|
|
39
|
+
else if(result.status === "warning")
|
|
40
|
+
this.#warned.push({input: file, warning: result.warning})
|
|
38
41
|
else {
|
|
39
42
|
this.#errored.push({input: file, error: result.error})
|
|
40
43
|
}
|
|
@@ -49,7 +52,11 @@ export default class Conveyor {
|
|
|
49
52
|
await this.parse.cleanupAction()
|
|
50
53
|
await this.print.cleanupAction()
|
|
51
54
|
|
|
52
|
-
return {
|
|
55
|
+
return {
|
|
56
|
+
succeeded: this.#succeeded,
|
|
57
|
+
errored: this.#errored,
|
|
58
|
+
warned: this.#warned
|
|
59
|
+
}
|
|
53
60
|
}
|
|
54
61
|
|
|
55
62
|
/**
|
|
@@ -78,7 +85,15 @@ export default class Conveyor {
|
|
|
78
85
|
if(parseResult.status === "error")
|
|
79
86
|
return parseResult
|
|
80
87
|
|
|
81
|
-
|
|
88
|
+
if(parseResult.status === "warning")
|
|
89
|
+
debug("Parsed file successfully, but with warnings: `%s`", 2, file.path)
|
|
90
|
+
else
|
|
91
|
+
debug("Parsed file successfully: `%s`", 2, file.path)
|
|
92
|
+
|
|
93
|
+
if(!parseResult.result?.functions?.length) {
|
|
94
|
+
const mess = format("No functions found in `%s`. No file written.", file.path)
|
|
95
|
+
return {status: "warning", file, warning: mess}
|
|
96
|
+
}
|
|
82
97
|
|
|
83
98
|
// Step 3: Print file
|
|
84
99
|
const printResult = await print.runAction({
|
package/src/core/Core.js
CHANGED
|
@@ -2,7 +2,7 @@ import process from "node:process"
|
|
|
2
2
|
|
|
3
3
|
import Discovery from "./Discovery.js"
|
|
4
4
|
import HookManager from "./HookManager.js"
|
|
5
|
-
import Logger from "./Logger.js"
|
|
5
|
+
import Logger, {loggerColours} from "./Logger.js"
|
|
6
6
|
import ParseManager from "./action/ParseManager.js"
|
|
7
7
|
import PrintManager from "./action/PrintManager.js"
|
|
8
8
|
import Conveyor from "./Conveyor.js"
|
|
@@ -149,11 +149,21 @@ export default class Core {
|
|
|
149
149
|
|
|
150
150
|
// Grab the results
|
|
151
151
|
const totalFiles = input.length
|
|
152
|
-
const errored = result.errored
|
|
153
152
|
const succeeded = result.succeeded
|
|
153
|
+
const warned = result.warned
|
|
154
|
+
const errored = result.errored
|
|
155
|
+
|
|
156
|
+
const {
|
|
157
|
+
info: succeedColour, warn: warnColour, error: errorColour, reset
|
|
158
|
+
} = loggerColours
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
const success = `${succeedColour}${succeeded.length}${reset}`
|
|
162
|
+
const warn = `${warnColour}${warned.length}${reset}`
|
|
163
|
+
const error = `${errorColour}${errored.length}${reset}`
|
|
154
164
|
|
|
155
|
-
const message = `Processed ${totalFiles} files: ${
|
|
156
|
-
|
|
165
|
+
const message = `Processed ${totalFiles} files: ${success} succeeded, ${error} errored, ` +
|
|
166
|
+
`${warn} warned in ${processEnd}ms [total: ${endTime}ms]`
|
|
157
167
|
|
|
158
168
|
this.logger.debug(message, 1)
|
|
159
169
|
|
package/src/core/Logger.js
CHANGED
|
@@ -33,7 +33,7 @@ import * as StringUtil from "./util/StringUtil.js"
|
|
|
33
33
|
const {resolveFilename} = FDUtil
|
|
34
34
|
const {capitalize} = StringUtil
|
|
35
35
|
|
|
36
|
-
const loggerColours = {
|
|
36
|
+
export const loggerColours = {
|
|
37
37
|
debug: [
|
|
38
38
|
"\x1b[38;5;19m", // Debug level 0: Dark blue
|
|
39
39
|
"\x1b[38;5;27m", // Debug level 1: Medium blue
|