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.
Files changed (176) hide show
  1. package/README.md +36 -0
  2. package/dist/actions/actions.d.ts +11 -0
  3. package/dist/actions/actions.js +36 -0
  4. package/dist/actions/built-in/check-image.d.ts +4 -0
  5. package/dist/actions/built-in/check-image.js +59 -0
  6. package/dist/actions/built-in/check-link.d.ts +4 -0
  7. package/dist/actions/built-in/check-link.js +127 -0
  8. package/dist/actions/built-in/test.d.ts +3 -0
  9. package/dist/actions/built-in/test.js +4 -0
  10. package/dist/actions/export.d.ts +18 -0
  11. package/dist/actions/export.js +2 -0
  12. package/dist/actions/external-action-manager.d.ts +10 -0
  13. package/dist/actions/external-action-manager.js +44 -0
  14. package/dist/actions/finder.d.ts +29 -0
  15. package/dist/actions/finder.js +99 -0
  16. package/dist/actions/index.d.ts +37 -0
  17. package/dist/actions/index.js +3 -0
  18. package/dist/actions/name.d.ts +2 -0
  19. package/dist/actions/name.js +6 -0
  20. package/dist/activities/extract-dynamic.d.ts +5 -0
  21. package/dist/activities/extract-dynamic.js +29 -0
  22. package/dist/activities/extract-images-and-links.d.ts +5 -0
  23. package/dist/activities/extract-images-and-links.js +32 -0
  24. package/dist/activities/index.d.ts +20 -0
  25. package/dist/activities/index.js +14 -0
  26. package/dist/activities/normalize-action-name.d.ts +3 -0
  27. package/dist/activities/normalize-action-name.js +13 -0
  28. package/dist/ast/index.d.ts +3 -0
  29. package/dist/ast/index.js +3 -0
  30. package/dist/ast/node-list.d.ts +41 -0
  31. package/dist/ast/node-list.js +128 -0
  32. package/dist/ast/node.d.ts +49 -0
  33. package/dist/ast/node.js +53 -0
  34. package/dist/commands/command.d.ts +9 -0
  35. package/dist/commands/command.js +2 -0
  36. package/dist/commands/debug.d.ts +16 -0
  37. package/dist/commands/debug.js +122 -0
  38. package/dist/commands/dynamic.d.ts +13 -0
  39. package/dist/commands/dynamic.js +57 -0
  40. package/dist/commands/index.d.ts +7 -0
  41. package/dist/commands/index.js +7 -0
  42. package/dist/commands/run.d.ts +14 -0
  43. package/dist/commands/run.js +66 -0
  44. package/dist/commands/static.d.ts +13 -0
  45. package/dist/commands/static.js +60 -0
  46. package/dist/commands/unused.d.ts +13 -0
  47. package/dist/commands/unused.js +43 -0
  48. package/dist/configuration/data.d.ts +46 -0
  49. package/dist/configuration/data.js +2 -0
  50. package/dist/configuration/defaults.d.ts +5 -0
  51. package/dist/configuration/defaults.js +50 -0
  52. package/dist/configuration/index.d.ts +5 -0
  53. package/dist/configuration/index.js +4 -0
  54. package/dist/configuration/publication.d.ts +42 -0
  55. package/dist/configuration/publication.js +51 -0
  56. package/dist/configuration/publications.d.ts +9 -0
  57. package/dist/configuration/publications.js +25 -0
  58. package/dist/errors/error.d.ts +2 -0
  59. package/dist/errors/error.js +9 -0
  60. package/dist/errors/node-error.d.ts +3 -0
  61. package/dist/errors/node-error.js +5 -0
  62. package/dist/errors/user-error.d.ts +13 -0
  63. package/dist/errors/user-error.js +16 -0
  64. package/dist/events/index.d.ts +49 -0
  65. package/dist/events/index.js +13 -0
  66. package/dist/filesystem/absolute-dir.d.ts +25 -0
  67. package/dist/filesystem/absolute-dir.js +42 -0
  68. package/dist/filesystem/absolute-file.d.ts +18 -0
  69. package/dist/filesystem/absolute-file.js +28 -0
  70. package/dist/filesystem/full-dir.d.ts +11 -0
  71. package/dist/filesystem/full-dir.js +15 -0
  72. package/dist/filesystem/full-file.d.ts +22 -0
  73. package/dist/filesystem/full-file.js +35 -0
  74. package/dist/filesystem/full-link.d.ts +40 -0
  75. package/dist/filesystem/full-link.js +80 -0
  76. package/dist/filesystem/full-path.d.ts +31 -0
  77. package/dist/filesystem/full-path.js +61 -0
  78. package/dist/filesystem/get-filenames.d.ts +15 -0
  79. package/dist/filesystem/get-filenames.js +73 -0
  80. package/dist/filesystem/has-directory.d.ts +2 -0
  81. package/dist/filesystem/has-directory.js +11 -0
  82. package/dist/filesystem/index.d.ts +15 -0
  83. package/dist/filesystem/index.js +15 -0
  84. package/dist/filesystem/is-markdown-file.d.ts +2 -0
  85. package/dist/filesystem/is-markdown-file.js +11 -0
  86. package/dist/filesystem/location.d.ts +17 -0
  87. package/dist/filesystem/location.js +26 -0
  88. package/dist/filesystem/relative-dir.d.ts +6 -0
  89. package/dist/filesystem/relative-dir.js +7 -0
  90. package/dist/filesystem/relative-link.d.ts +16 -0
  91. package/dist/filesystem/relative-link.js +18 -0
  92. package/dist/filesystem/source-dir.d.ts +19 -0
  93. package/dist/filesystem/source-dir.js +35 -0
  94. package/dist/filesystem/unknown-link.d.ts +15 -0
  95. package/dist/filesystem/unknown-link.js +23 -0
  96. package/dist/helpers/add-leading-dot-unless-empty.d.ts +2 -0
  97. package/dist/helpers/add-leading-dot-unless-empty.js +10 -0
  98. package/dist/helpers/add-leading-slash.d.ts +2 -0
  99. package/dist/helpers/add-leading-slash.js +9 -0
  100. package/dist/helpers/add-trailing-slash.d.ts +2 -0
  101. package/dist/helpers/add-trailing-slash.js +7 -0
  102. package/dist/helpers/index.d.ts +16 -0
  103. package/dist/helpers/index.js +16 -0
  104. package/dist/helpers/is-external-link.d.ts +2 -0
  105. package/dist/helpers/is-external-link.js +5 -0
  106. package/dist/helpers/is-link-to-anchor-in-other-file.d.ts +2 -0
  107. package/dist/helpers/is-link-to-anchor-in-other-file.js +4 -0
  108. package/dist/helpers/is-link-to-anchor-in-same-file.d.ts +2 -0
  109. package/dist/helpers/is-link-to-anchor-in-same-file.js +4 -0
  110. package/dist/helpers/is-mailto-link.d.ts +2 -0
  111. package/dist/helpers/is-mailto-link.js +4 -0
  112. package/dist/helpers/remove-double-slash.d.ts +3 -0
  113. package/dist/helpers/remove-double-slash.js +6 -0
  114. package/dist/helpers/remove-leading-slash.d.ts +2 -0
  115. package/dist/helpers/remove-leading-slash.js +7 -0
  116. package/dist/helpers/remove-trailing-colon.d.ts +2 -0
  117. package/dist/helpers/remove-trailing-colon.js +9 -0
  118. package/dist/helpers/straighten-link.d.ts +3 -0
  119. package/dist/helpers/straighten-link.js +15 -0
  120. package/dist/helpers/trim-all-line-ends.d.ts +3 -0
  121. package/dist/helpers/trim-all-line-ends.js +5 -0
  122. package/dist/helpers/trim-extension.d.ts +2 -0
  123. package/dist/helpers/trim-extension.js +5 -0
  124. package/dist/helpers/unixify.d.ts +3 -0
  125. package/dist/helpers/unixify.js +6 -0
  126. package/dist/link-targets/find.d.ts +4 -0
  127. package/dist/link-targets/find.js +9 -0
  128. package/dist/link-targets/index.d.ts +15 -0
  129. package/dist/link-targets/index.js +3 -0
  130. package/dist/link-targets/list.d.ts +18 -0
  131. package/dist/link-targets/list.js +74 -0
  132. package/dist/link-targets/target-url.d.ts +2 -0
  133. package/dist/link-targets/target-url.js +8 -0
  134. package/dist/parsers/html/html-parser.d.ts +28 -0
  135. package/dist/parsers/html/html-parser.js +153 -0
  136. package/dist/parsers/html/index.d.ts +2 -0
  137. package/dist/parsers/html/index.js +2 -0
  138. package/dist/parsers/html/parse-html-files.d.ts +6 -0
  139. package/dist/parsers/html/parse-html-files.js +16 -0
  140. package/dist/parsers/index.d.ts +3 -0
  141. package/dist/parsers/index.js +3 -0
  142. package/dist/parsers/markdown/closing-tag-parser.d.ts +13 -0
  143. package/dist/parsers/markdown/closing-tag-parser.js +29 -0
  144. package/dist/parsers/markdown/index.d.ts +3 -0
  145. package/dist/parsers/markdown/index.js +3 -0
  146. package/dist/parsers/markdown/md-parser.d.ts +50 -0
  147. package/dist/parsers/markdown/md-parser.js +316 -0
  148. package/dist/parsers/markdown/open-node-tracker.d.ts +14 -0
  149. package/dist/parsers/markdown/open-node-tracker.js +33 -0
  150. package/dist/parsers/markdown/parse.d.ts +5 -0
  151. package/dist/parsers/markdown/parse.js +15 -0
  152. package/dist/parsers/tag-mapper.d.ts +31 -0
  153. package/dist/parsers/tag-mapper.js +112 -0
  154. package/dist/run/activity-collector.d.ts +29 -0
  155. package/dist/run/activity-collector.js +35 -0
  156. package/dist/run/index.d.ts +9 -0
  157. package/dist/run/index.js +5 -0
  158. package/dist/run/name-refiner.d.ts +13 -0
  159. package/dist/run/name-refiner.js +20 -0
  160. package/dist/run/output-collector.d.ts +13 -0
  161. package/dist/run/output-collector.js +30 -0
  162. package/dist/run/parallel.d.ts +11 -0
  163. package/dist/run/parallel.js +13 -0
  164. package/dist/run/run-activity.d.ts +8 -0
  165. package/dist/run/run-activity.js +76 -0
  166. package/dist/run/sequential.d.ts +7 -0
  167. package/dist/run/sequential.js +10 -0
  168. package/dist/run/stopwatch.d.ts +12 -0
  169. package/dist/run/stopwatch.js +19 -0
  170. package/dist/text-runner.d.ts +15 -0
  171. package/dist/text-runner.js +15 -0
  172. package/dist/workspace/create.d.ts +4 -0
  173. package/dist/workspace/create.js +10 -0
  174. package/dist/workspace/index.d.ts +2 -0
  175. package/dist/workspace/index.js +2 -0
  176. package/package.json +45 -0
@@ -0,0 +1,22 @@
1
+ import * as files from "./index.js";
2
+ /**
3
+ * represents a full path to a file,
4
+ * i.e. a path from the document base to a file.
5
+ */
6
+ export declare class FullFilePath {
7
+ private value;
8
+ constructor(value: string);
9
+ /** Returns the directory that contains this file */
10
+ directory(): files.FullPath;
11
+ /** Returns the file extension of this path */
12
+ extName(): string;
13
+ /**
14
+ * Returns the path in the platform-specific format,
15
+ * i.e. using '\' on Windows and '/' everywhere else
16
+ */
17
+ platformified(): string;
18
+ toFullFilePath(): FullFilePath;
19
+ /** Returns this absolute path using forward slashes as path separators */
20
+ unixified(): string;
21
+ }
22
+ //# sourceMappingURL=full-file.d.ts.map
@@ -0,0 +1,35 @@
1
+ import * as path from "path";
2
+ import * as files from "./index.js";
3
+ const sepRE = new RegExp("\\" + path.sep, "g");
4
+ /**
5
+ * represents a full path to a file,
6
+ * i.e. a path from the document base to a file.
7
+ */
8
+ export class FullFilePath {
9
+ constructor(value) {
10
+ this.value = value.replace(sepRE, "/");
11
+ }
12
+ /** Returns the directory that contains this file */
13
+ directory() {
14
+ return new files.FullPath(path.dirname(this.value) + "/");
15
+ }
16
+ /** Returns the file extension of this path */
17
+ extName() {
18
+ return path.extname(this.value);
19
+ }
20
+ /**
21
+ * Returns the path in the platform-specific format,
22
+ * i.e. using '\' on Windows and '/' everywhere else
23
+ */
24
+ platformified() {
25
+ return this.value.replace(/\//g, path.sep);
26
+ }
27
+ toFullFilePath() {
28
+ return this;
29
+ }
30
+ /** Returns this absolute path using forward slashes as path separators */
31
+ unixified() {
32
+ return this.value;
33
+ }
34
+ }
35
+ //# sourceMappingURL=full-file.js.map
@@ -0,0 +1,40 @@
1
+ import * as configuration from "../configuration/index.js";
2
+ import * as files from "./index.js";
3
+ /**
4
+ * Represents a link to another Markdown file,
5
+ * all the way from the root directory
6
+ * (i.e. a link starting with '/')
7
+ */
8
+ export declare class FullLink {
9
+ readonly value: string;
10
+ constructor(publicPath: string);
11
+ /** Returns the anchor part of this link */
12
+ anchor(): string;
13
+ /**
14
+ * Returns a new link that consists of this link
15
+ * with the given relative link appended
16
+ */
17
+ append(segment: files.RelativeLink): FullLink;
18
+ /** Returns a link to the containing directory */
19
+ directory(): FullLink;
20
+ hasAnchor(): boolean;
21
+ /** Returns whether this link has the given extension */
22
+ hasExtension(extension: string): boolean;
23
+ /** Returns whether this link points to a directory */
24
+ isLinkToDirectory(): boolean;
25
+ /** Returns the file path that this link has on the local filesystem */
26
+ localize(publications: configuration.Publications, defaultFile: string): files.FullFilePath | files.FullPath;
27
+ /**
28
+ * Returns a link where the old enclosing directory is replaced
29
+ * with the new enclosing directory
30
+ */
31
+ rebase(oldPath: string, newPath: string): FullLink;
32
+ urlDecoded(): FullLink;
33
+ /** Returns a link that contains the given anchor */
34
+ withAnchor(anchor: string): FullLink;
35
+ /** Returns another FullLink instance that uses the given file extension */
36
+ withExtension(newExtension: string): FullLink;
37
+ /** Returns a link that is this link without the anchor */
38
+ withoutAnchor(): FullLink;
39
+ }
40
+ //# sourceMappingURL=full-link.d.ts.map
@@ -0,0 +1,80 @@
1
+ import * as path from "path";
2
+ import * as helpers from "../helpers/index.js";
3
+ import * as files from "./index.js";
4
+ /**
5
+ * Represents a link to another Markdown file,
6
+ * all the way from the root directory
7
+ * (i.e. a link starting with '/')
8
+ */
9
+ export class FullLink {
10
+ constructor(publicPath) {
11
+ this.value = helpers.addLeadingSlash(helpers.removeDoubleSlash(helpers.unixify(publicPath)));
12
+ }
13
+ /** Returns the anchor part of this link */
14
+ anchor() {
15
+ return this.value.split("#")[1] || "";
16
+ }
17
+ /**
18
+ * Returns a new link that consists of this link
19
+ * with the given relative link appended
20
+ */
21
+ append(segment) {
22
+ return new FullLink(helpers.straightenLink(this.value + "/" + segment.value));
23
+ }
24
+ /** Returns a link to the containing directory */
25
+ directory() {
26
+ const withoutAnchor = this.withoutAnchor();
27
+ if (withoutAnchor.isLinkToDirectory()) {
28
+ return withoutAnchor;
29
+ }
30
+ return new FullLink(withoutAnchor.value.substr(0, withoutAnchor.value.lastIndexOf("/") + 1));
31
+ }
32
+ hasAnchor() {
33
+ return this.anchor() !== "";
34
+ }
35
+ /** Returns whether this link has the given extension */
36
+ hasExtension(extension) {
37
+ return path.extname(this.value) === helpers.addLeadingDotUnlessEmpty(extension);
38
+ }
39
+ /** Returns whether this link points to a directory */
40
+ isLinkToDirectory() {
41
+ return this.value.endsWith("/");
42
+ }
43
+ /** Returns the file path that this link has on the local filesystem */
44
+ localize(publications, defaultFile) {
45
+ const publication = publications.publicationForLink(this);
46
+ const result = publication
47
+ ? publication.resolve(this.urlDecoded(), defaultFile)
48
+ : new files.FullPath(this.urlDecoded().withoutAnchor().value);
49
+ // append the default file
50
+ if (result.extName() === "" && defaultFile) {
51
+ return result.append(defaultFile);
52
+ }
53
+ return result;
54
+ }
55
+ /**
56
+ * Returns a link where the old enclosing directory is replaced
57
+ * with the new enclosing directory
58
+ */
59
+ rebase(oldPath, newPath) {
60
+ const re = new RegExp("^" + oldPath);
61
+ return new FullLink(this.value.replace(re, newPath));
62
+ }
63
+ urlDecoded() {
64
+ return new FullLink(decodeURI(this.value));
65
+ }
66
+ /** Returns a link that contains the given anchor */
67
+ withAnchor(anchor) {
68
+ return new FullLink(this.withoutAnchor().value + "#" + anchor);
69
+ }
70
+ /** Returns another FullLink instance that uses the given file extension */
71
+ withExtension(newExtension) {
72
+ const extRE = new RegExp(path.extname(this.value) + "$");
73
+ return new FullLink(this.value.replace(extRE, helpers.addLeadingDotUnlessEmpty(newExtension)));
74
+ }
75
+ /** Returns a link that is this link without the anchor */
76
+ withoutAnchor() {
77
+ return new FullLink(this.value.split("#")[0]);
78
+ }
79
+ }
80
+ //# sourceMappingURL=full-link.js.map
@@ -0,0 +1,31 @@
1
+ import * as configuration from "../configuration/index.js";
2
+ import * as files from "./index.js";
3
+ /**
4
+ * represents a full path to either a file or a directory,
5
+ * i.e. a link from the document base root to the object
6
+ */
7
+ export declare class FullPath {
8
+ private readonly value;
9
+ constructor(value: string);
10
+ /** Returns a new file path with the given file name appended to the end of this file path */
11
+ append(fileName: string): files.FullFilePath;
12
+ /** Returns the directory that contains this file path */
13
+ directory(): FullPath;
14
+ /** Returns the file extension of this path */
15
+ extName(): string;
16
+ /** Returns whether this file path points to a directory */
17
+ isDirectory(): boolean;
18
+ joinStr(relPath: string): string;
19
+ /**
20
+ * Returns the path in the platform-specific format,
21
+ * i.e. using '\' on Windows and '/' everywhere else
22
+ */
23
+ platformified(): string;
24
+ /** Returns the public link under which this file path is published */
25
+ publicPath(publications: configuration.Publications): files.FullLink;
26
+ /** provides the FullFilePath if this path points to a file */
27
+ toFullFilePath(): files.FullFilePath;
28
+ /** Returns this absolute path using forward slashes as path separators */
29
+ unixified(): string;
30
+ }
31
+ //# sourceMappingURL=full-path.d.ts.map
@@ -0,0 +1,61 @@
1
+ import * as path from "path";
2
+ import * as helpers from "../helpers/index.js";
3
+ import * as files from "./index.js";
4
+ /**
5
+ * represents a full path to either a file or a directory,
6
+ * i.e. a link from the document base root to the object
7
+ */
8
+ export class FullPath {
9
+ constructor(value) {
10
+ this.value = helpers.removeLeadingSlash(helpers.unixify(value));
11
+ }
12
+ /** Returns a new file path with the given file name appended to the end of this file path */
13
+ append(fileName) {
14
+ return new files.FullFilePath(path.join(this.platformified(), fileName));
15
+ }
16
+ /** Returns the directory that contains this file path */
17
+ directory() {
18
+ if (this.isDirectory()) {
19
+ return this;
20
+ }
21
+ return new FullPath(path.dirname(this.value) + "/");
22
+ }
23
+ /** Returns the file extension of this path */
24
+ extName() {
25
+ return path.extname(this.value);
26
+ }
27
+ /** Returns whether this file path points to a directory */
28
+ isDirectory() {
29
+ return this.value.endsWith("/");
30
+ }
31
+ joinStr(relPath) {
32
+ return path.join(this.value, relPath);
33
+ }
34
+ /**
35
+ * Returns the path in the platform-specific format,
36
+ * i.e. using '\' on Windows and '/' everywhere else
37
+ */
38
+ platformified() {
39
+ return this.value.replace(/\//g, path.sep);
40
+ }
41
+ /** Returns the public link under which this file path is published */
42
+ publicPath(publications) {
43
+ const publication = publications.forFilePath(this);
44
+ if (publication == null) {
45
+ return new files.FullLink(this.unixified());
46
+ }
47
+ return publication.publish(this);
48
+ }
49
+ /** provides the FullFilePath if this path points to a file */
50
+ toFullFilePath() {
51
+ if (this.isDirectory()) {
52
+ throw new Error(`FullPath '${this.unixified()}' does tot point to a file`);
53
+ }
54
+ return new files.FullFilePath(this.value);
55
+ }
56
+ /** Returns this absolute path using forward slashes as path separators */
57
+ unixified() {
58
+ return this.value;
59
+ }
60
+ }
61
+ //# sourceMappingURL=full-path.js.map
@@ -0,0 +1,15 @@
1
+ import * as configuration from "../configuration/index.js";
2
+ import * as files from "./index.js";
3
+ /**
4
+ * Returns the FullPaths of all files/directories relative to the given sourceDir
5
+ * that match the given glob
6
+ */
7
+ export declare function getFileNames(config: configuration.Data): Promise<files.FullFilePath[]>;
8
+ /**
9
+ * returns all the markdown files in this directory and its children,
10
+ * relative to the given sourceDir
11
+ */
12
+ export declare function markdownFilesInDir(dirName: string, sourceDir: files.SourceDir): Promise<files.FullFilePath[]>;
13
+ /** Removes the given excluded files from the given list of filenames */
14
+ export declare function removeExcludedFiles(fileList: files.FullFilePath[], excluded: string | string[]): files.FullFilePath[];
15
+ //# sourceMappingURL=get-filenames.d.ts.map
@@ -0,0 +1,73 @@
1
+ import { globby } from "globby";
2
+ import isGlob from "is-glob";
3
+ import { UserError } from "../errors/user-error.js";
4
+ import * as files from "./index.js";
5
+ /**
6
+ * Returns the FullPaths of all files/directories relative to the given sourceDir
7
+ * that match the given glob
8
+ */
9
+ export async function getFileNames(config) {
10
+ let filenames = await getFiles(config);
11
+ filenames = removeExcludedFiles(filenames, config.exclude);
12
+ filenames = removeExcludedFiles(filenames, "node_modules");
13
+ if (config.emptyWorkspace === false) {
14
+ if (!config.workspace.matches(config.sourceDir)) {
15
+ const fullWorkspace = config.workspace.toFullDir(config.sourceDir);
16
+ filenames = removeExcludedFiles(filenames, fullWorkspace.platformified());
17
+ }
18
+ }
19
+ return filenames;
20
+ }
21
+ /**
22
+ * returns all the markdown files in this directory and its children,
23
+ * relative to the given sourceDir
24
+ */
25
+ export async function markdownFilesInDir(dirName, sourceDir) {
26
+ const allFiles = await globby(`${dirName}/**/*.md`);
27
+ return allFiles
28
+ .filter(file => !file.includes("node_modules"))
29
+ .sort()
30
+ .map(file => new files.AbsoluteFilePath(file).toFullFile(sourceDir));
31
+ }
32
+ /** Removes the given excluded files from the given list of filenames */
33
+ export function removeExcludedFiles(fileList, excluded) {
34
+ const excludedFilesArray = Array.isArray(excluded) ? excluded : [excluded];
35
+ const excludedRegexes = excludedFilesArray.map(file => new RegExp(file));
36
+ return fileList.filter(file => {
37
+ for (const excludedRegex of excludedRegexes) {
38
+ if (excludedRegex.test(file.unixified())) {
39
+ return false;
40
+ }
41
+ }
42
+ return true;
43
+ });
44
+ }
45
+ /**
46
+ * Returns files described by the given configuration.
47
+ * Filenames are relative to config.sourceDir.
48
+ */
49
+ async function getFiles(config) {
50
+ let fullGlob = config.sourceDir.joinStr(config.files);
51
+ if (process.platform === "win32") {
52
+ // globby cannot handle backslashes in globs,
53
+ // see https://github.com/sindresorhus/globby/issues/155#issuecomment-732961466
54
+ // and https://github.com/micromatch/micromatch#backslashes
55
+ fullGlob = fullGlob.replace(/\\/g, "/");
56
+ }
57
+ if (config.files === "") {
58
+ return markdownFilesInDir("", config.sourceDir);
59
+ }
60
+ else if (await files.hasDirectory(fullGlob)) {
61
+ return markdownFilesInDir(fullGlob, config.sourceDir);
62
+ }
63
+ else if (await files.isMarkdownFile(fullGlob)) {
64
+ return [new files.FullFilePath(config.files)];
65
+ }
66
+ else if (isGlob(config.files)) {
67
+ return config.sourceDir.fullFilesMatchingGlob(fullGlob);
68
+ }
69
+ else {
70
+ throw new UserError(`file or directory does not exist: ${config.files}`, "You can provide a glob expression or the path to a file or folder.");
71
+ }
72
+ }
73
+ //# sourceMappingURL=get-filenames.js.map
@@ -0,0 +1,2 @@
1
+ export declare function hasDirectory(dirname: string): Promise<boolean>;
2
+ //# sourceMappingURL=has-directory.d.ts.map
@@ -0,0 +1,11 @@
1
+ import { promises as fs } from "fs";
2
+ export async function hasDirectory(dirname) {
3
+ try {
4
+ const stats = await fs.stat(dirname);
5
+ return stats.isDirectory();
6
+ }
7
+ catch (e) {
8
+ return false;
9
+ }
10
+ }
11
+ //# sourceMappingURL=has-directory.js.map
@@ -0,0 +1,15 @@
1
+ export * from "./absolute-dir.js";
2
+ export * from "./absolute-file.js";
3
+ export * from "./full-dir.js";
4
+ export * from "./full-file.js";
5
+ export * from "./full-link.js";
6
+ export * from "./full-path.js";
7
+ export * from "./get-filenames.js";
8
+ export * from "./has-directory.js";
9
+ export * from "./is-markdown-file.js";
10
+ export * from "./location.js";
11
+ export * from "./relative-dir.js";
12
+ export * from "./relative-link.js";
13
+ export * from "./source-dir.js";
14
+ export * from "./unknown-link.js";
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,15 @@
1
+ export * from "./absolute-dir.js";
2
+ export * from "./absolute-file.js";
3
+ export * from "./full-dir.js";
4
+ export * from "./full-file.js";
5
+ export * from "./full-link.js";
6
+ export * from "./full-path.js";
7
+ export * from "./get-filenames.js";
8
+ export * from "./has-directory.js";
9
+ export * from "./is-markdown-file.js";
10
+ export * from "./location.js";
11
+ export * from "./relative-dir.js";
12
+ export * from "./relative-link.js";
13
+ export * from "./source-dir.js";
14
+ export * from "./unknown-link.js";
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,2 @@
1
+ export declare function isMarkdownFile(filepath: string): Promise<boolean>;
2
+ //# sourceMappingURL=is-markdown-file.d.ts.map
@@ -0,0 +1,11 @@
1
+ import { promises as fs } from "fs";
2
+ export async function isMarkdownFile(filepath) {
3
+ try {
4
+ const fileStats = await fs.stat(filepath);
5
+ return filepath.endsWith(".md") && fileStats.isFile();
6
+ }
7
+ catch (e) {
8
+ return false;
9
+ }
10
+ }
11
+ //# sourceMappingURL=is-markdown-file.js.map
@@ -0,0 +1,17 @@
1
+ import * as files from "./index.js";
2
+ /** represents a location inside the document base, i.e. a line inside a file */
3
+ export declare class Location {
4
+ file: files.FullFilePath;
5
+ line: number;
6
+ sourceDir: files.SourceDir;
7
+ constructor(sourceDir: files.SourceDir, file: files.FullFilePath, line: number);
8
+ /** provides an empty location for testing */
9
+ static scaffold(): Location;
10
+ /** provides the absolute path to the file in this location */
11
+ absoluteFilePath(): files.AbsoluteFilePath;
12
+ /** provides a copy of this Location with the given file */
13
+ withFile(file: files.FullFilePath): Location;
14
+ /** provides a copy of this Location with the given line */
15
+ withLine(line: number): Location;
16
+ }
17
+ //# sourceMappingURL=location.d.ts.map
@@ -0,0 +1,26 @@
1
+ import * as files from "./index.js";
2
+ /** represents a location inside the document base, i.e. a line inside a file */
3
+ export class Location {
4
+ constructor(sourceDir, file, line) {
5
+ this.sourceDir = sourceDir;
6
+ this.file = file;
7
+ this.line = line;
8
+ }
9
+ /** provides an empty location for testing */
10
+ static scaffold() {
11
+ return new Location(new files.SourceDir(""), new files.FullFilePath(""), 0);
12
+ }
13
+ /** provides the absolute path to the file in this location */
14
+ absoluteFilePath() {
15
+ return this.sourceDir.joinFullFile(this.file);
16
+ }
17
+ /** provides a copy of this Location with the given file */
18
+ withFile(file) {
19
+ return new Location(this.sourceDir, file, this.line);
20
+ }
21
+ /** provides a copy of this Location with the given line */
22
+ withLine(line) {
23
+ return new Location(this.sourceDir, this.file, line);
24
+ }
25
+ }
26
+ //# sourceMappingURL=location.js.map
@@ -0,0 +1,6 @@
1
+ /** represents a relative path to another directory */
2
+ export declare class RelativeDir {
3
+ value: string;
4
+ constructor(value: string);
5
+ }
6
+ //# sourceMappingURL=relative-dir.d.ts.map
@@ -0,0 +1,7 @@
1
+ /** represents a relative path to another directory */
2
+ export class RelativeDir {
3
+ constructor(value) {
4
+ this.value = value;
5
+ }
6
+ }
7
+ //# sourceMappingURL=relative-dir.js.map
@@ -0,0 +1,16 @@
1
+ import * as configuration from "../configuration/index.js";
2
+ import * as files from "./index.js";
3
+ /**
4
+ * A link relative to the current location,
5
+ * i.e. a link not starting with '/'
6
+ */
7
+ export declare class RelativeLink {
8
+ readonly value: string;
9
+ constructor(publicPath: string);
10
+ /**
11
+ * Assuming this relative link is in the given file,
12
+ * returns the absolute links that point to the same target as this relative link.
13
+ */
14
+ absolutify(containingLocation: files.Location, publications: configuration.Publications): files.FullLink;
15
+ }
16
+ //# sourceMappingURL=relative-link.d.ts.map
@@ -0,0 +1,18 @@
1
+ /**
2
+ * A link relative to the current location,
3
+ * i.e. a link not starting with '/'
4
+ */
5
+ export class RelativeLink {
6
+ constructor(publicPath) {
7
+ this.value = publicPath;
8
+ }
9
+ /**
10
+ * Assuming this relative link is in the given file,
11
+ * returns the absolute links that point to the same target as this relative link.
12
+ */
13
+ absolutify(containingLocation, publications) {
14
+ const urlOfDir = containingLocation.file.directory().publicPath(publications);
15
+ return urlOfDir.append(this);
16
+ }
17
+ }
18
+ //# sourceMappingURL=relative-link.js.map
@@ -0,0 +1,19 @@
1
+ import * as files from "./index.js";
2
+ /** represents the document base directory */
3
+ export declare class SourceDir {
4
+ value: string;
5
+ constructor(value: string);
6
+ fullFilesMatchingGlob(expression: string): Promise<files.FullFilePath[]>;
7
+ joinFullDir(dir: files.FullDir): files.AbsoluteDirPath;
8
+ joinFullFile(file: files.FullFilePath): files.AbsoluteFilePath;
9
+ /** provides a path of this directory with the given path appended */
10
+ joinStr(...paths: string[]): string;
11
+ /**
12
+ * Returns the path in the platform-specific format,
13
+ * i.e. using '\' on Windows and '/' everywhere else
14
+ */
15
+ platformified(): string;
16
+ /** Returns this absolute path using forward slashes as path separators */
17
+ unixified(): string;
18
+ }
19
+ //# sourceMappingURL=source-dir.d.ts.map
@@ -0,0 +1,35 @@
1
+ import { globby } from "globby";
2
+ import * as path from "path";
3
+ import * as files from "./index.js";
4
+ /** represents the document base directory */
5
+ export class SourceDir {
6
+ constructor(value) {
7
+ this.value = value;
8
+ }
9
+ async fullFilesMatchingGlob(expression) {
10
+ const allFiles = await globby(expression);
11
+ return allFiles.sort().map(file => new files.AbsoluteFilePath(file).toFullFile(this));
12
+ }
13
+ joinFullDir(dir) {
14
+ return new files.AbsoluteDirPath(path.join(this.platformified(), dir.platformified()));
15
+ }
16
+ joinFullFile(file) {
17
+ return new files.AbsoluteFilePath(path.join(this.platformified(), file.platformified()));
18
+ }
19
+ /** provides a path of this directory with the given path appended */
20
+ joinStr(...paths) {
21
+ return path.join(this.platformified(), ...paths);
22
+ }
23
+ /**
24
+ * Returns the path in the platform-specific format,
25
+ * i.e. using '\' on Windows and '/' everywhere else
26
+ */
27
+ platformified() {
28
+ return this.value.replace(/\//g, path.sep);
29
+ }
30
+ /** Returns this absolute path using forward slashes as path separators */
31
+ unixified() {
32
+ return this.value;
33
+ }
34
+ }
35
+ //# sourceMappingURL=source-dir.js.map
@@ -0,0 +1,15 @@
1
+ import * as configuration from "../configuration/index.js";
2
+ import * as files from "./index.js";
3
+ /**
4
+ * A link that isn't known yet whether it is relative or absolute
5
+ */
6
+ export declare class UnknownLink {
7
+ private readonly value;
8
+ constructor(publicPath: string);
9
+ absolutify(containingLocation: files.Location, publications: configuration.Publications): files.FullLink;
10
+ /**
11
+ * Returns whether this link is an absolute link
12
+ */
13
+ isAbsolute(): boolean;
14
+ }
15
+ //# sourceMappingURL=unknown-link.d.ts.map
@@ -0,0 +1,23 @@
1
+ import * as helpers from "../helpers/index.js";
2
+ import * as files from "./index.js";
3
+ /**
4
+ * A link that isn't known yet whether it is relative or absolute
5
+ */
6
+ export class UnknownLink {
7
+ constructor(publicPath) {
8
+ this.value = helpers.removeDoubleSlash(helpers.unixify(publicPath));
9
+ }
10
+ absolutify(containingLocation, publications) {
11
+ if (this.isAbsolute()) {
12
+ return new files.FullLink(this.value);
13
+ }
14
+ return new files.RelativeLink(this.value).absolutify(containingLocation, publications);
15
+ }
16
+ /**
17
+ * Returns whether this link is an absolute link
18
+ */
19
+ isAbsolute() {
20
+ return this.value.startsWith("/");
21
+ }
22
+ }
23
+ //# sourceMappingURL=unknown-link.js.map
@@ -0,0 +1,2 @@
1
+ export declare function addLeadingDotUnlessEmpty(text: string): string;
2
+ //# sourceMappingURL=add-leading-dot-unless-empty.d.ts.map
@@ -0,0 +1,10 @@
1
+ export function addLeadingDotUnlessEmpty(text) {
2
+ if (text === "") {
3
+ return text;
4
+ }
5
+ if (text.startsWith(".")) {
6
+ return text;
7
+ }
8
+ return "." + text;
9
+ }
10
+ //# sourceMappingURL=add-leading-dot-unless-empty.js.map
@@ -0,0 +1,2 @@
1
+ export declare function addLeadingSlash(filepath: string): string;
2
+ //# sourceMappingURL=add-leading-slash.d.ts.map
@@ -0,0 +1,9 @@
1
+ export function addLeadingSlash(filepath) {
2
+ if (filepath[0] === "/") {
3
+ return filepath;
4
+ }
5
+ else {
6
+ return "/" + filepath;
7
+ }
8
+ }
9
+ //# sourceMappingURL=add-leading-slash.js.map
@@ -0,0 +1,2 @@
1
+ export declare function addTrailingSlash(text: string): string;
2
+ //# sourceMappingURL=add-trailing-slash.d.ts.map