text-runner-engine 7.1.0
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/README.md +36 -0
- package/dist/actions/actions.d.ts +11 -0
- package/dist/actions/actions.js +36 -0
- package/dist/actions/built-in/check-image.d.ts +4 -0
- package/dist/actions/built-in/check-image.js +59 -0
- package/dist/actions/built-in/check-link.d.ts +4 -0
- package/dist/actions/built-in/check-link.js +127 -0
- package/dist/actions/built-in/test.d.ts +3 -0
- package/dist/actions/built-in/test.js +4 -0
- package/dist/actions/export.d.ts +18 -0
- package/dist/actions/export.js +2 -0
- package/dist/actions/external-action-manager.d.ts +10 -0
- package/dist/actions/external-action-manager.js +44 -0
- package/dist/actions/finder.d.ts +29 -0
- package/dist/actions/finder.js +99 -0
- package/dist/actions/index.d.ts +37 -0
- package/dist/actions/index.js +3 -0
- package/dist/actions/name.d.ts +2 -0
- package/dist/actions/name.js +6 -0
- package/dist/activities/extract-dynamic.d.ts +5 -0
- package/dist/activities/extract-dynamic.js +29 -0
- package/dist/activities/extract-images-and-links.d.ts +5 -0
- package/dist/activities/extract-images-and-links.js +32 -0
- package/dist/activities/index.d.ts +20 -0
- package/dist/activities/index.js +14 -0
- package/dist/activities/normalize-action-name.d.ts +3 -0
- package/dist/activities/normalize-action-name.js +13 -0
- package/dist/ast/index.d.ts +3 -0
- package/dist/ast/index.js +3 -0
- package/dist/ast/node-list.d.ts +41 -0
- package/dist/ast/node-list.js +128 -0
- package/dist/ast/node.d.ts +49 -0
- package/dist/ast/node.js +53 -0
- package/dist/commands/command.d.ts +9 -0
- package/dist/commands/command.js +2 -0
- package/dist/commands/debug.d.ts +16 -0
- package/dist/commands/debug.js +122 -0
- package/dist/commands/dynamic.d.ts +13 -0
- package/dist/commands/dynamic.js +57 -0
- package/dist/commands/index.d.ts +7 -0
- package/dist/commands/index.js +7 -0
- package/dist/commands/run.d.ts +14 -0
- package/dist/commands/run.js +66 -0
- package/dist/commands/static.d.ts +13 -0
- package/dist/commands/static.js +60 -0
- package/dist/commands/unused.d.ts +13 -0
- package/dist/commands/unused.js +43 -0
- package/dist/configuration/data.d.ts +46 -0
- package/dist/configuration/data.js +2 -0
- package/dist/configuration/defaults.d.ts +5 -0
- package/dist/configuration/defaults.js +50 -0
- package/dist/configuration/index.d.ts +5 -0
- package/dist/configuration/index.js +4 -0
- package/dist/configuration/publication.d.ts +42 -0
- package/dist/configuration/publication.js +51 -0
- package/dist/configuration/publications.d.ts +9 -0
- package/dist/configuration/publications.js +25 -0
- package/dist/errors/error.d.ts +2 -0
- package/dist/errors/error.js +9 -0
- package/dist/errors/node-error.d.ts +3 -0
- package/dist/errors/node-error.js +5 -0
- package/dist/errors/user-error.d.ts +13 -0
- package/dist/errors/user-error.js +16 -0
- package/dist/events/index.d.ts +49 -0
- package/dist/events/index.js +13 -0
- package/dist/filesystem/absolute-dir.d.ts +25 -0
- package/dist/filesystem/absolute-dir.js +42 -0
- package/dist/filesystem/absolute-file.d.ts +18 -0
- package/dist/filesystem/absolute-file.js +28 -0
- package/dist/filesystem/full-dir.d.ts +11 -0
- package/dist/filesystem/full-dir.js +15 -0
- package/dist/filesystem/full-file.d.ts +22 -0
- package/dist/filesystem/full-file.js +35 -0
- package/dist/filesystem/full-link.d.ts +40 -0
- package/dist/filesystem/full-link.js +80 -0
- package/dist/filesystem/full-path.d.ts +31 -0
- package/dist/filesystem/full-path.js +61 -0
- package/dist/filesystem/get-filenames.d.ts +15 -0
- package/dist/filesystem/get-filenames.js +73 -0
- package/dist/filesystem/has-directory.d.ts +2 -0
- package/dist/filesystem/has-directory.js +11 -0
- package/dist/filesystem/index.d.ts +15 -0
- package/dist/filesystem/index.js +15 -0
- package/dist/filesystem/is-markdown-file.d.ts +2 -0
- package/dist/filesystem/is-markdown-file.js +11 -0
- package/dist/filesystem/location.d.ts +17 -0
- package/dist/filesystem/location.js +26 -0
- package/dist/filesystem/relative-dir.d.ts +6 -0
- package/dist/filesystem/relative-dir.js +7 -0
- package/dist/filesystem/relative-link.d.ts +16 -0
- package/dist/filesystem/relative-link.js +18 -0
- package/dist/filesystem/source-dir.d.ts +19 -0
- package/dist/filesystem/source-dir.js +35 -0
- package/dist/filesystem/unknown-link.d.ts +15 -0
- package/dist/filesystem/unknown-link.js +23 -0
- package/dist/helpers/add-leading-dot-unless-empty.d.ts +2 -0
- package/dist/helpers/add-leading-dot-unless-empty.js +10 -0
- package/dist/helpers/add-leading-slash.d.ts +2 -0
- package/dist/helpers/add-leading-slash.js +9 -0
- package/dist/helpers/add-trailing-slash.d.ts +2 -0
- package/dist/helpers/add-trailing-slash.js +7 -0
- package/dist/helpers/index.d.ts +16 -0
- package/dist/helpers/index.js +16 -0
- package/dist/helpers/is-external-link.d.ts +2 -0
- package/dist/helpers/is-external-link.js +5 -0
- package/dist/helpers/is-link-to-anchor-in-other-file.d.ts +2 -0
- package/dist/helpers/is-link-to-anchor-in-other-file.js +4 -0
- package/dist/helpers/is-link-to-anchor-in-same-file.d.ts +2 -0
- package/dist/helpers/is-link-to-anchor-in-same-file.js +4 -0
- package/dist/helpers/is-mailto-link.d.ts +2 -0
- package/dist/helpers/is-mailto-link.js +4 -0
- package/dist/helpers/remove-double-slash.d.ts +3 -0
- package/dist/helpers/remove-double-slash.js +6 -0
- package/dist/helpers/remove-leading-slash.d.ts +2 -0
- package/dist/helpers/remove-leading-slash.js +7 -0
- package/dist/helpers/remove-trailing-colon.d.ts +2 -0
- package/dist/helpers/remove-trailing-colon.js +9 -0
- package/dist/helpers/straighten-link.d.ts +3 -0
- package/dist/helpers/straighten-link.js +15 -0
- package/dist/helpers/trim-all-line-ends.d.ts +3 -0
- package/dist/helpers/trim-all-line-ends.js +5 -0
- package/dist/helpers/trim-extension.d.ts +2 -0
- package/dist/helpers/trim-extension.js +5 -0
- package/dist/helpers/unixify.d.ts +3 -0
- package/dist/helpers/unixify.js +6 -0
- package/dist/link-targets/find.d.ts +4 -0
- package/dist/link-targets/find.js +9 -0
- package/dist/link-targets/index.d.ts +15 -0
- package/dist/link-targets/index.js +3 -0
- package/dist/link-targets/list.d.ts +18 -0
- package/dist/link-targets/list.js +74 -0
- package/dist/link-targets/target-url.d.ts +2 -0
- package/dist/link-targets/target-url.js +8 -0
- package/dist/parsers/html/html-parser.d.ts +28 -0
- package/dist/parsers/html/html-parser.js +153 -0
- package/dist/parsers/html/index.d.ts +2 -0
- package/dist/parsers/html/index.js +2 -0
- package/dist/parsers/html/parse-html-files.d.ts +6 -0
- package/dist/parsers/html/parse-html-files.js +16 -0
- package/dist/parsers/index.d.ts +3 -0
- package/dist/parsers/index.js +3 -0
- package/dist/parsers/markdown/closing-tag-parser.d.ts +13 -0
- package/dist/parsers/markdown/closing-tag-parser.js +29 -0
- package/dist/parsers/markdown/index.d.ts +3 -0
- package/dist/parsers/markdown/index.js +3 -0
- package/dist/parsers/markdown/md-parser.d.ts +50 -0
- package/dist/parsers/markdown/md-parser.js +316 -0
- package/dist/parsers/markdown/open-node-tracker.d.ts +14 -0
- package/dist/parsers/markdown/open-node-tracker.js +33 -0
- package/dist/parsers/markdown/parse.d.ts +5 -0
- package/dist/parsers/markdown/parse.js +15 -0
- package/dist/parsers/tag-mapper.d.ts +31 -0
- package/dist/parsers/tag-mapper.js +112 -0
- package/dist/run/activity-collector.d.ts +29 -0
- package/dist/run/activity-collector.js +35 -0
- package/dist/run/index.d.ts +9 -0
- package/dist/run/index.js +5 -0
- package/dist/run/name-refiner.d.ts +13 -0
- package/dist/run/name-refiner.js +20 -0
- package/dist/run/output-collector.d.ts +13 -0
- package/dist/run/output-collector.js +30 -0
- package/dist/run/parallel.d.ts +11 -0
- package/dist/run/parallel.js +13 -0
- package/dist/run/run-activity.d.ts +8 -0
- package/dist/run/run-activity.js +76 -0
- package/dist/run/sequential.d.ts +7 -0
- package/dist/run/sequential.js +10 -0
- package/dist/run/stopwatch.d.ts +12 -0
- package/dist/run/stopwatch.js +19 -0
- package/dist/text-runner.d.ts +15 -0
- package/dist/text-runner.js +15 -0
- package/dist/workspace/create.d.ts +4 -0
- package/dist/workspace/create.js +10 -0
- package/dist/workspace/index.d.ts +2 -0
- package/dist/workspace/index.js +2 -0
- package/package.json +45 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { EventEmitter } from "events";
|
|
2
|
+
import * as actions from "../actions/index.js";
|
|
3
|
+
import { extractImagesAndLinks } from "../activities/extract-images-and-links.js";
|
|
4
|
+
import * as configuration from "../configuration/index.js";
|
|
5
|
+
import * as files from "../filesystem/index.js";
|
|
6
|
+
import * as linkTargets from "../link-targets/index.js";
|
|
7
|
+
import * as parser from "../parsers/index.js";
|
|
8
|
+
import * as run from "../run/index.js";
|
|
9
|
+
import * as workspace from "../workspace/index.js";
|
|
10
|
+
export class Static {
|
|
11
|
+
constructor(userConfig) {
|
|
12
|
+
this.userConfig = userConfig;
|
|
13
|
+
this.emitter = new EventEmitter();
|
|
14
|
+
}
|
|
15
|
+
emit(name, payload) {
|
|
16
|
+
this.emitter.emit(name, payload);
|
|
17
|
+
}
|
|
18
|
+
async execute() {
|
|
19
|
+
const originalDir = process.cwd();
|
|
20
|
+
try {
|
|
21
|
+
// step 1: determine full configuration
|
|
22
|
+
const config = await configuration.addDefaults(this.userConfig);
|
|
23
|
+
// step 2: create working dir
|
|
24
|
+
await workspace.create(config);
|
|
25
|
+
// step 3: find files
|
|
26
|
+
const filenames = await files.getFileNames(config);
|
|
27
|
+
if (filenames.length === 0) {
|
|
28
|
+
this.emit("result", { message: "no Markdown files found", status: "warning" });
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
// step 4: read and parse files
|
|
32
|
+
const ASTs = await parser.markdown.parse(filenames, config.sourceDir);
|
|
33
|
+
// step 5: find link targets
|
|
34
|
+
const targets = linkTargets.find(ASTs);
|
|
35
|
+
// step 6: extract activities
|
|
36
|
+
const links = extractImagesAndLinks(ASTs);
|
|
37
|
+
if (links.length === 0) {
|
|
38
|
+
this.emit("result", { message: "no activities found", status: "warning" });
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
// step 7: find actions
|
|
42
|
+
const actionFinder = await actions.Finder.loadStatic();
|
|
43
|
+
// step 8: execute the ActivityList
|
|
44
|
+
this.emit("start", { stepCount: links.length });
|
|
45
|
+
process.chdir(config.workspace.platformified());
|
|
46
|
+
const parResults = run.parallel(links, actionFinder, targets, config, this);
|
|
47
|
+
await Promise.all(parResults);
|
|
48
|
+
// step 9: cleanup
|
|
49
|
+
process.chdir(config.sourceDir.platformified());
|
|
50
|
+
}
|
|
51
|
+
finally {
|
|
52
|
+
process.chdir(originalDir);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
on(name, handler) {
|
|
56
|
+
this.emitter.on(name, handler);
|
|
57
|
+
return this;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=static.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { EventEmitter } from "events";
|
|
2
|
+
import * as configuration from "../configuration/index.js";
|
|
3
|
+
import * as events from "../events/index.js";
|
|
4
|
+
import { Command } from "./command.js";
|
|
5
|
+
export declare class Unused implements Command {
|
|
6
|
+
emitter: EventEmitter;
|
|
7
|
+
userConfig: configuration.APIData;
|
|
8
|
+
constructor(userConfig: configuration.APIData);
|
|
9
|
+
emit(name: events.Name, payload: events.Args): void;
|
|
10
|
+
execute(): Promise<void>;
|
|
11
|
+
on(name: events.Name, handler: events.Handler): this;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=unused.d.ts.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { EventEmitter } from "events";
|
|
2
|
+
import * as actions from "../actions/index.js";
|
|
3
|
+
import * as activities from "../activities/index.js";
|
|
4
|
+
import * as configuration from "../configuration/index.js";
|
|
5
|
+
import * as files from "../filesystem/index.js";
|
|
6
|
+
import * as parsers from "../parsers/index.js";
|
|
7
|
+
export class Unused {
|
|
8
|
+
constructor(userConfig) {
|
|
9
|
+
this.userConfig = userConfig;
|
|
10
|
+
this.emitter = new EventEmitter();
|
|
11
|
+
}
|
|
12
|
+
emit(name, payload) {
|
|
13
|
+
this.emitter.emit(name, payload);
|
|
14
|
+
}
|
|
15
|
+
async execute() {
|
|
16
|
+
// step 1: determine full configuration
|
|
17
|
+
const config = await configuration.addDefaults(this.userConfig);
|
|
18
|
+
// step 2: find files
|
|
19
|
+
const filenames = await files.getFileNames(config);
|
|
20
|
+
if (filenames.length === 0) {
|
|
21
|
+
this.emit("result", { message: "no Markdown files found", status: "warning" });
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
// step 3: read and parse files
|
|
25
|
+
const ASTs = await parsers.markdown.parse(filenames, config.sourceDir);
|
|
26
|
+
// step 4: extract activities
|
|
27
|
+
const usedActivityNames = activities.extractDynamic(ASTs, config.regionMarker).map(activity => activity.actionName);
|
|
28
|
+
// step 5: find defined activities
|
|
29
|
+
const definedActivityNames = (await actions.Finder.load(config.sourceDir)).customActionNames();
|
|
30
|
+
// step 6: identify unused activities
|
|
31
|
+
const unusedActivityNames = definedActivityNames.filter(definedActivityName => !usedActivityNames.includes(definedActivityName));
|
|
32
|
+
// step 7: write results
|
|
33
|
+
this.emit("output", "Unused activities:");
|
|
34
|
+
for (const unusedActivityName of unusedActivityNames) {
|
|
35
|
+
this.emit("output", `- ${unusedActivityName}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
on(name, handler) {
|
|
39
|
+
this.emitter.on(name, handler);
|
|
40
|
+
return this;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=unused.js.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import * as files from "../filesystem/index.js";
|
|
2
|
+
import { Publications } from "./publications.js";
|
|
3
|
+
/** configuration values used by the Text-Runner API */
|
|
4
|
+
export type APIData = Partial<CompleteAPIData>;
|
|
5
|
+
/** a full set of configuration values used by the Text-Runner API */
|
|
6
|
+
export type CompleteAPIData = SharedValues & StringDirs;
|
|
7
|
+
/** Configuration values used inside Text-Runner Engine */
|
|
8
|
+
export type Data = AbsoluteDirs & SharedValues;
|
|
9
|
+
interface AbsoluteDirs {
|
|
10
|
+
/** the root directory of the source code to test */
|
|
11
|
+
sourceDir: files.SourceDir;
|
|
12
|
+
/** the root directory of the workspace */
|
|
13
|
+
workspace: files.AbsoluteDirPath;
|
|
14
|
+
}
|
|
15
|
+
interface SharedValues {
|
|
16
|
+
/** the name of the default filename, set to '' if none is given */
|
|
17
|
+
defaultFile: string;
|
|
18
|
+
/** whether to empty the workspace before executing tests */
|
|
19
|
+
emptyWorkspace: boolean;
|
|
20
|
+
/** list of names or regexes of files to exclude */
|
|
21
|
+
exclude: string | string[];
|
|
22
|
+
/** glob of the files to test */
|
|
23
|
+
files: string;
|
|
24
|
+
/** link patterns to ignore */
|
|
25
|
+
ignoreLinkTargets: RegExp[];
|
|
26
|
+
/** whether to skip built-in tests that require a network connection */
|
|
27
|
+
online: boolean;
|
|
28
|
+
/** folder mappings */
|
|
29
|
+
publications: Publications;
|
|
30
|
+
/** the name of the attribute that denotes active regions */
|
|
31
|
+
regionMarker: string;
|
|
32
|
+
/** language in which to scaffold new steps */
|
|
33
|
+
scaffoldLanguage: "js" | "ts";
|
|
34
|
+
/** whether to display/emit skipped tests */
|
|
35
|
+
showSkipped: boolean;
|
|
36
|
+
/** whether to create the workspace in the system temp directory or locally */
|
|
37
|
+
systemTmp: boolean;
|
|
38
|
+
}
|
|
39
|
+
interface StringDirs {
|
|
40
|
+
/** the root directory of the source code to test */
|
|
41
|
+
sourceDir: string;
|
|
42
|
+
/** the root directory of the workspace */
|
|
43
|
+
workspace?: string;
|
|
44
|
+
}
|
|
45
|
+
export {};
|
|
46
|
+
//# sourceMappingURL=data.d.ts.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as configuration from "./index.js";
|
|
2
|
+
export declare function addDefaults(partial: configuration.APIData): Promise<configuration.Data>;
|
|
3
|
+
/** provides the default configuration values to use when no values are provided via CLI or config file */
|
|
4
|
+
export declare function defaults(): configuration.CompleteAPIData;
|
|
5
|
+
//# sourceMappingURL=defaults.d.ts.map
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as path from "path";
|
|
2
|
+
import * as tmp from "tmp-promise";
|
|
3
|
+
import { UserError } from "../errors/user-error.js";
|
|
4
|
+
import * as files from "../filesystem/index.js";
|
|
5
|
+
import { Publications } from "./publications.js";
|
|
6
|
+
export async function addDefaults(partial) {
|
|
7
|
+
const fullAPIData = defaults();
|
|
8
|
+
for (const [key, value] of Object.entries(partial)) {
|
|
9
|
+
if (value != null) {
|
|
10
|
+
// @ts-expect-error TypeScript is too stupid to realize that `key` has the correct type here
|
|
11
|
+
fullAPIData[key] = value;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
...fullAPIData,
|
|
16
|
+
sourceDir: new files.SourceDir(fullAPIData.sourceDir),
|
|
17
|
+
workspace: await getWorkspacePath(fullAPIData)
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/** provides the default configuration values to use when no values are provided via CLI or config file */
|
|
21
|
+
export function defaults() {
|
|
22
|
+
return {
|
|
23
|
+
defaultFile: "",
|
|
24
|
+
emptyWorkspace: true,
|
|
25
|
+
exclude: [],
|
|
26
|
+
files: "**/*.md",
|
|
27
|
+
ignoreLinkTargets: [],
|
|
28
|
+
online: false,
|
|
29
|
+
publications: new Publications(),
|
|
30
|
+
regionMarker: "type",
|
|
31
|
+
scaffoldLanguage: "js",
|
|
32
|
+
showSkipped: false,
|
|
33
|
+
sourceDir: process.cwd(),
|
|
34
|
+
systemTmp: false,
|
|
35
|
+
workspace: "tmp"
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
async function getWorkspacePath(config) {
|
|
39
|
+
if (config.systemTmp === false) {
|
|
40
|
+
return new files.AbsoluteDirPath(path.join(config.sourceDir, config.workspace || "") || "");
|
|
41
|
+
}
|
|
42
|
+
else if (config.systemTmp === true) {
|
|
43
|
+
const tmpDir = await tmp.dir();
|
|
44
|
+
return new files.AbsoluteDirPath(path.join(tmpDir.path, config.workspace || ""));
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
throw new UserError(`unknown 'systemTmp' setting: ${config.systemTmp}`, `Since version 5.0.0, the only valid settings for "systemTmp" are "true" and "false"`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=defaults.js.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as files from "../filesystem/index.js";
|
|
2
|
+
export interface PublicationConfig {
|
|
3
|
+
/** filesystem path of the src folder */
|
|
4
|
+
localPath: string;
|
|
5
|
+
/** which extension the Markdown files have when served as HTML */
|
|
6
|
+
publicExtension: string;
|
|
7
|
+
/** the corresponding URL path */
|
|
8
|
+
publicPath: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Publications map local folders (in the source code) to public URL paths.
|
|
12
|
+
* This is needed when verifying Markdown code that will be published as HTML somewhere,
|
|
13
|
+
* and the links in Markdown reference the public URLs of the Markdown pages.
|
|
14
|
+
*/
|
|
15
|
+
export declare class Publication implements PublicationConfig {
|
|
16
|
+
/** filesystem path of the src folder */
|
|
17
|
+
readonly localPath: string;
|
|
18
|
+
/** which extension the Markdown files have when served as HTML */
|
|
19
|
+
readonly publicExtension: string;
|
|
20
|
+
/** the corresponding URL path */
|
|
21
|
+
readonly publicPath: string;
|
|
22
|
+
constructor(args: {
|
|
23
|
+
localPath: string;
|
|
24
|
+
publicExtension: string;
|
|
25
|
+
publicPath: string;
|
|
26
|
+
});
|
|
27
|
+
/**
|
|
28
|
+
* Returns the public link under which the given file path would be published
|
|
29
|
+
* according to the rules of this publication
|
|
30
|
+
*/
|
|
31
|
+
publish(localPath: files.FullPath): files.FullLink;
|
|
32
|
+
/** indicates whether this publication applies to the given file path */
|
|
33
|
+
publishes(localPath: files.FullPath): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* provides the localPath for the given link
|
|
36
|
+
* mapped according to the rules of this publication.
|
|
37
|
+
*/
|
|
38
|
+
resolve(link: files.FullLink, defaultFile: string): files.FullPath;
|
|
39
|
+
/** indicates whether this publication maps the given link */
|
|
40
|
+
resolves(link: files.FullLink): boolean;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=publication.d.ts.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as files from "../filesystem/index.js";
|
|
2
|
+
import * as helpers from "../helpers/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Publications map local folders (in the source code) to public URL paths.
|
|
5
|
+
* This is needed when verifying Markdown code that will be published as HTML somewhere,
|
|
6
|
+
* and the links in Markdown reference the public URLs of the Markdown pages.
|
|
7
|
+
*/
|
|
8
|
+
export class Publication {
|
|
9
|
+
constructor(args) {
|
|
10
|
+
this.localPath = helpers.addLeadingSlash(helpers.addTrailingSlash(args.localPath));
|
|
11
|
+
this.publicPath = helpers.addLeadingSlash(args.publicPath);
|
|
12
|
+
this.publicExtension = helpers.addLeadingDotUnlessEmpty(args.publicExtension);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Returns the public link under which the given file path would be published
|
|
16
|
+
* according to the rules of this publication
|
|
17
|
+
*/
|
|
18
|
+
publish(localPath) {
|
|
19
|
+
const re = new RegExp("^" + this.localPath);
|
|
20
|
+
const linkPath = helpers.addLeadingSlash(localPath.unixified()).replace(re, this.publicPath);
|
|
21
|
+
const result = new files.FullLink(linkPath);
|
|
22
|
+
if (this.publicExtension == null) {
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
return result.withExtension(this.publicExtension);
|
|
26
|
+
}
|
|
27
|
+
/** indicates whether this publication applies to the given file path */
|
|
28
|
+
publishes(localPath) {
|
|
29
|
+
return helpers.addLeadingSlash(helpers.addTrailingSlash(localPath.unixified())).startsWith(this.localPath);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* provides the localPath for the given link
|
|
33
|
+
* mapped according to the rules of this publication.
|
|
34
|
+
*/
|
|
35
|
+
resolve(link, defaultFile) {
|
|
36
|
+
let result = link.rebase(this.publicPath, this.localPath);
|
|
37
|
+
result = result.withoutAnchor();
|
|
38
|
+
if (result.isLinkToDirectory()) {
|
|
39
|
+
result = result.append(new files.RelativeLink(defaultFile));
|
|
40
|
+
}
|
|
41
|
+
else if (result.hasExtension(this.publicExtension)) {
|
|
42
|
+
result = result.withExtension("md");
|
|
43
|
+
}
|
|
44
|
+
return new files.FullPath(result.value);
|
|
45
|
+
}
|
|
46
|
+
/** indicates whether this publication maps the given link */
|
|
47
|
+
resolves(link) {
|
|
48
|
+
return link.value.startsWith(this.publicPath);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=publication.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as files from "../filesystem/index.js";
|
|
2
|
+
import { Publication, PublicationConfig } from "./publication.js";
|
|
3
|
+
export declare class Publications extends Array<Publication> {
|
|
4
|
+
static fromConfigs(configs?: PublicationConfig[]): Publications;
|
|
5
|
+
forFilePath(filePath: files.FullPath): Publication | undefined;
|
|
6
|
+
publicationForLink(link: files.FullLink): Publication | undefined;
|
|
7
|
+
sorted(): Publications;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=publications.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Publication } from "./publication.js";
|
|
2
|
+
export class Publications extends Array {
|
|
3
|
+
// Creates a new Publications instance based on the given JSON data
|
|
4
|
+
static fromConfigs(configs = []) {
|
|
5
|
+
const result = new Publications();
|
|
6
|
+
for (const config of configs) {
|
|
7
|
+
result.push(new Publication(config));
|
|
8
|
+
}
|
|
9
|
+
return result;
|
|
10
|
+
}
|
|
11
|
+
// Returns the publication that matches the given filepath
|
|
12
|
+
forFilePath(filePath) {
|
|
13
|
+
return this.find(publication => publication.publishes(filePath));
|
|
14
|
+
}
|
|
15
|
+
// Returns the publication that applies for the given link
|
|
16
|
+
publicationForLink(link) {
|
|
17
|
+
return this.find(publication => publication.resolves(link));
|
|
18
|
+
}
|
|
19
|
+
// Returns these publications, sorted by public path
|
|
20
|
+
sorted() {
|
|
21
|
+
const sorted = this.sort((a, b) => (a.publicPath > b.publicPath ? -1 : 1));
|
|
22
|
+
return Publications.fromConfigs(sorted);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=publications.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as files from "../filesystem/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Represents a UserError that has not been printed via the formatter.
|
|
4
|
+
* This happens for user errors before the formatter could be instantiated
|
|
5
|
+
*/
|
|
6
|
+
export declare class UserError extends Error {
|
|
7
|
+
/** optional longer user-facing guidance on how to resolve the error */
|
|
8
|
+
readonly guidance: string;
|
|
9
|
+
readonly location: files.Location | undefined;
|
|
10
|
+
constructor(message: string, guidance: string, location?: files.Location);
|
|
11
|
+
}
|
|
12
|
+
export declare function isUserError(arg: unknown): arg is UserError;
|
|
13
|
+
//# sourceMappingURL=user-error.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a UserError that has not been printed via the formatter.
|
|
3
|
+
* This happens for user errors before the formatter could be instantiated
|
|
4
|
+
*/
|
|
5
|
+
export class UserError extends Error {
|
|
6
|
+
constructor(message, guidance, location) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.name = "UserError";
|
|
9
|
+
this.guidance = guidance;
|
|
10
|
+
this.location = location;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export function isUserError(arg) {
|
|
14
|
+
return arg instanceof Error && arg.name === "UserError";
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=user-error.js.map
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Activity } from "../activities/index.js";
|
|
2
|
+
export type Args = Failed | Skipped | Start | string | Success | Warning;
|
|
3
|
+
/** signals a failed activity */
|
|
4
|
+
export interface Failed {
|
|
5
|
+
readonly activity: Activity;
|
|
6
|
+
readonly error: Error;
|
|
7
|
+
readonly finalName: string;
|
|
8
|
+
/** captured output (via action.log) while executing the activity */
|
|
9
|
+
readonly output: string;
|
|
10
|
+
readonly status: "failed";
|
|
11
|
+
}
|
|
12
|
+
export type Handler = (arg: any) => void;
|
|
13
|
+
/** defines the events that a command can emit. */
|
|
14
|
+
export type Name = "finish" | "output" | "result" | "start";
|
|
15
|
+
export interface Result {
|
|
16
|
+
readonly status: ResultStatus;
|
|
17
|
+
}
|
|
18
|
+
export type ResultStatus = "failed" | "skipped" | "success" | "warning";
|
|
19
|
+
/** signals a skipped activity */
|
|
20
|
+
export interface Skipped {
|
|
21
|
+
readonly activity: Activity;
|
|
22
|
+
readonly finalName: string;
|
|
23
|
+
readonly output: string;
|
|
24
|
+
readonly status: "skipped";
|
|
25
|
+
}
|
|
26
|
+
/** signals the start of a test suite */
|
|
27
|
+
export interface Start {
|
|
28
|
+
readonly stepCount: number;
|
|
29
|
+
}
|
|
30
|
+
/** signals a successful activity */
|
|
31
|
+
export interface Success {
|
|
32
|
+
readonly activity: Activity;
|
|
33
|
+
readonly finalName: string;
|
|
34
|
+
/** captured output (via action.log) while executing the activity */
|
|
35
|
+
readonly output: string;
|
|
36
|
+
readonly status: "success";
|
|
37
|
+
}
|
|
38
|
+
/** signals an activity succeeded but with warnings */
|
|
39
|
+
export interface Warning {
|
|
40
|
+
readonly activity?: Activity;
|
|
41
|
+
readonly finalName?: string;
|
|
42
|
+
readonly message: string;
|
|
43
|
+
readonly status: "warning";
|
|
44
|
+
}
|
|
45
|
+
export declare function instanceOfFailed(event: Result): event is Failed;
|
|
46
|
+
export declare function instanceOfSkipped(event: Result): event is Skipped;
|
|
47
|
+
export declare function instanceOfSuccess(event: Result): event is Success;
|
|
48
|
+
export declare function instanceOfWarning(event: Result): event is Warning;
|
|
49
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function instanceOfFailed(event) {
|
|
2
|
+
return event.status === "failed";
|
|
3
|
+
}
|
|
4
|
+
export function instanceOfSkipped(event) {
|
|
5
|
+
return event.status === "skipped";
|
|
6
|
+
}
|
|
7
|
+
export function instanceOfSuccess(event) {
|
|
8
|
+
return event.status === "success";
|
|
9
|
+
}
|
|
10
|
+
export function instanceOfWarning(event) {
|
|
11
|
+
return event.status === "warning";
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as files from "./index.js";
|
|
2
|
+
/**
|
|
3
|
+
* represents an absolute path to a directory,
|
|
4
|
+
* i.e. path from filesystem root to the directory
|
|
5
|
+
*/
|
|
6
|
+
export declare class AbsoluteDirPath {
|
|
7
|
+
value: string;
|
|
8
|
+
constructor(value: string);
|
|
9
|
+
/** joins the given relative directory */
|
|
10
|
+
joinDir(other: files.RelativeDir): AbsoluteDirPath;
|
|
11
|
+
/** provides a path of this directory with the given path appended */
|
|
12
|
+
joinStr(...paths: string[]): string;
|
|
13
|
+
/** indicates whether this directory is the same as the given source dir */
|
|
14
|
+
matches(other: files.SourceDir): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Returns the path in the platform-specific format,
|
|
17
|
+
* i.e. using '\' on Windows and '/' everywhere else
|
|
18
|
+
*/
|
|
19
|
+
platformified(): string;
|
|
20
|
+
relativeStr(other: string): string;
|
|
21
|
+
toFullDir(sourceDir: files.SourceDir): files.FullDir;
|
|
22
|
+
/** Returns this absolute path using forward slashes as path separators */
|
|
23
|
+
unixified(): string;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=absolute-dir.d.ts.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as path from "path";
|
|
2
|
+
import * as helpers from "../helpers/index.js";
|
|
3
|
+
import * as files from "./index.js";
|
|
4
|
+
/**
|
|
5
|
+
* represents an absolute path to a directory,
|
|
6
|
+
* i.e. path from filesystem root to the directory
|
|
7
|
+
*/
|
|
8
|
+
export class AbsoluteDirPath {
|
|
9
|
+
constructor(value) {
|
|
10
|
+
this.value = helpers.unixify(value);
|
|
11
|
+
}
|
|
12
|
+
/** joins the given relative directory */
|
|
13
|
+
joinDir(other) {
|
|
14
|
+
return new AbsoluteDirPath(this.joinStr(other.value));
|
|
15
|
+
}
|
|
16
|
+
/** provides a path of this directory with the given path appended */
|
|
17
|
+
joinStr(...paths) {
|
|
18
|
+
return path.join(this.platformified(), ...paths);
|
|
19
|
+
}
|
|
20
|
+
/** indicates whether this directory is the same as the given source dir */
|
|
21
|
+
matches(other) {
|
|
22
|
+
return this.unixified() === other.unixified();
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Returns the path in the platform-specific format,
|
|
26
|
+
* i.e. using '\' on Windows and '/' everywhere else
|
|
27
|
+
*/
|
|
28
|
+
platformified() {
|
|
29
|
+
return this.value.replace(/\//g, path.sep);
|
|
30
|
+
}
|
|
31
|
+
relativeStr(other) {
|
|
32
|
+
return path.relative(this.platformified(), other);
|
|
33
|
+
}
|
|
34
|
+
toFullDir(sourceDir) {
|
|
35
|
+
return new files.FullDir(path.relative(sourceDir.platformified(), this.platformified()));
|
|
36
|
+
}
|
|
37
|
+
/** Returns this absolute path using forward slashes as path separators */
|
|
38
|
+
unixified() {
|
|
39
|
+
return this.value;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=absolute-dir.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as files from "./index.js";
|
|
2
|
+
/** represents an absolute path to a file, i.e. from filesystem root to the file */
|
|
3
|
+
export declare class AbsoluteFilePath {
|
|
4
|
+
value: string;
|
|
5
|
+
constructor(value: string);
|
|
6
|
+
/** provides the directory that contains this file */
|
|
7
|
+
directory(): files.AbsoluteDirPath;
|
|
8
|
+
/**
|
|
9
|
+
* provides this file path with platform specific path separators,
|
|
10
|
+
* i.e. '\' on Windows and '/' everywhere else
|
|
11
|
+
*/
|
|
12
|
+
platformified(): string;
|
|
13
|
+
/** provides the relative path from the given directory to this file */
|
|
14
|
+
toFullFile(sourceDir: files.SourceDir): files.FullFilePath;
|
|
15
|
+
/** provides this file path with forward slashes as path separators */
|
|
16
|
+
unixified(): string;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=absolute-file.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as path from "path";
|
|
2
|
+
import * as files from "./index.js";
|
|
3
|
+
/** represents an absolute path to a file, i.e. from filesystem root to the file */
|
|
4
|
+
export class AbsoluteFilePath {
|
|
5
|
+
constructor(value) {
|
|
6
|
+
this.value = value;
|
|
7
|
+
}
|
|
8
|
+
/** provides the directory that contains this file */
|
|
9
|
+
directory() {
|
|
10
|
+
return new files.AbsoluteDirPath(path.dirname(this.value) + "/");
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* provides this file path with platform specific path separators,
|
|
14
|
+
* i.e. '\' on Windows and '/' everywhere else
|
|
15
|
+
*/
|
|
16
|
+
platformified() {
|
|
17
|
+
return this.value.replace(/\//g, path.sep);
|
|
18
|
+
}
|
|
19
|
+
/** provides the relative path from the given directory to this file */
|
|
20
|
+
toFullFile(sourceDir) {
|
|
21
|
+
return new files.FullFilePath(path.relative(sourceDir.platformified(), this.platformified()));
|
|
22
|
+
}
|
|
23
|
+
/** provides this file path with forward slashes as path separators */
|
|
24
|
+
unixified() {
|
|
25
|
+
return this.value;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=absolute-file.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** represents the full path to a directory inside the document base, i.e. from the document root */
|
|
2
|
+
export declare class FullDir {
|
|
3
|
+
value: string;
|
|
4
|
+
constructor(value: string);
|
|
5
|
+
/**
|
|
6
|
+
* Returns the path in the platform-specific format,
|
|
7
|
+
* i.e. using '\' on Windows and '/' everywhere else
|
|
8
|
+
*/
|
|
9
|
+
platformified(): string;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=full-dir.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as path from "path";
|
|
2
|
+
/** represents the full path to a directory inside the document base, i.e. from the document root */
|
|
3
|
+
export class FullDir {
|
|
4
|
+
constructor(value) {
|
|
5
|
+
this.value = value;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Returns the path in the platform-specific format,
|
|
9
|
+
* i.e. using '\' on Windows and '/' everywhere else
|
|
10
|
+
*/
|
|
11
|
+
platformified() {
|
|
12
|
+
return this.value.replace(/\//g, path.sep);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=full-dir.js.map
|