honkit 6.0.4 → 6.1.5

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 (186) hide show
  1. package/lib/__tests__/__fixtures__/honkit/book.d.ts +7 -0
  2. package/lib/__tests__/__fixtures__/honkit/book.d.ts.map +1 -0
  3. package/lib/__tests__/__fixtures__/honkit/book.js +9 -0
  4. package/lib/__tests__/e2e.test.d.ts +2 -0
  5. package/lib/__tests__/e2e.test.d.ts.map +1 -0
  6. package/lib/__tests__/e2e.test.js +81 -0
  7. package/lib/__tests__/init.d.ts +2 -0
  8. package/lib/__tests__/init.d.ts.map +1 -0
  9. package/lib/__tests__/init.js +19 -0
  10. package/lib/__tests__/satisfies.d.ts +2 -0
  11. package/lib/__tests__/satisfies.d.ts.map +1 -0
  12. package/lib/__tests__/satisfies.js +11 -0
  13. package/lib/__tests__/snapshot-asciidoc.d.ts +2 -0
  14. package/lib/__tests__/snapshot-asciidoc.d.ts.map +1 -0
  15. package/lib/__tests__/snapshot-asciidoc.js +48 -0
  16. package/lib/__tests__/snapshot-honkit.d.ts +2 -0
  17. package/lib/__tests__/snapshot-honkit.d.ts.map +1 -0
  18. package/lib/__tests__/snapshot-honkit.js +48 -0
  19. package/lib/cli/__tests__/watch.test.d.ts +2 -0
  20. package/lib/cli/__tests__/watch.test.d.ts.map +1 -0
  21. package/lib/cli/__tests__/watch.test.js +194 -0
  22. package/lib/cli/serve.d.ts.map +1 -1
  23. package/lib/cli/serve.js +49 -43
  24. package/lib/cli/watch.d.ts +22 -6
  25. package/lib/cli/watch.d.ts.map +1 -1
  26. package/lib/cli/watch.js +24 -10
  27. package/lib/constants/__tests__/configSchema.d.ts +2 -0
  28. package/lib/constants/__tests__/configSchema.d.ts.map +1 -0
  29. package/lib/constants/__tests__/configSchema.js +41 -0
  30. package/lib/fs/__tests__/mock.d.ts +2 -0
  31. package/lib/fs/__tests__/mock.d.ts.map +1 -0
  32. package/lib/fs/__tests__/mock.js +68 -0
  33. package/lib/models/__tests__/config.d.ts +2 -0
  34. package/lib/models/__tests__/config.d.ts.map +1 -0
  35. package/lib/models/__tests__/config.js +164 -0
  36. package/lib/models/__tests__/glossary.d.ts +2 -0
  37. package/lib/models/__tests__/glossary.d.ts.map +1 -0
  38. package/lib/models/__tests__/glossary.js +38 -0
  39. package/lib/models/__tests__/glossaryEntry.d.ts +2 -0
  40. package/lib/models/__tests__/glossaryEntry.d.ts.map +1 -0
  41. package/lib/models/__tests__/glossaryEntry.js +16 -0
  42. package/lib/models/__tests__/page.d.ts +2 -0
  43. package/lib/models/__tests__/page.d.ts.map +1 -0
  44. package/lib/models/__tests__/page.js +26 -0
  45. package/lib/models/__tests__/plugin.d.ts +2 -0
  46. package/lib/models/__tests__/plugin.d.ts.map +1 -0
  47. package/lib/models/__tests__/plugin.js +50 -0
  48. package/lib/models/__tests__/pluginDependency.d.ts +2 -0
  49. package/lib/models/__tests__/pluginDependency.d.ts.map +1 -0
  50. package/lib/models/__tests__/pluginDependency.js +71 -0
  51. package/lib/models/__tests__/summary.d.ts +2 -0
  52. package/lib/models/__tests__/summary.d.ts.map +1 -0
  53. package/lib/models/__tests__/summary.js +115 -0
  54. package/lib/models/__tests__/summaryArticle.d.ts +2 -0
  55. package/lib/models/__tests__/summaryArticle.d.ts.map +1 -0
  56. package/lib/models/__tests__/summaryArticle.js +117 -0
  57. package/lib/models/__tests__/summaryPart.d.ts +2 -0
  58. package/lib/models/__tests__/summaryPart.d.ts.map +1 -0
  59. package/lib/models/__tests__/summaryPart.js +24 -0
  60. package/lib/models/__tests__/templateBlock.d.ts +2 -0
  61. package/lib/models/__tests__/templateBlock.d.ts.map +1 -0
  62. package/lib/models/__tests__/templateBlock.js +172 -0
  63. package/lib/models/__tests__/templateEngine.d.ts +2 -0
  64. package/lib/models/__tests__/templateEngine.d.ts.map +1 -0
  65. package/lib/models/__tests__/templateEngine.js +49 -0
  66. package/lib/modifiers/config/__tests__/addPlugin.d.ts +2 -0
  67. package/lib/modifiers/config/__tests__/addPlugin.d.ts.map +1 -0
  68. package/lib/modifiers/config/__tests__/addPlugin.js +30 -0
  69. package/lib/modifiers/config/__tests__/removePlugin.d.ts +2 -0
  70. package/lib/modifiers/config/__tests__/removePlugin.d.ts.map +1 -0
  71. package/lib/modifiers/config/__tests__/removePlugin.js +29 -0
  72. package/lib/modifiers/config/__tests__/togglePlugin.d.ts +2 -0
  73. package/lib/modifiers/config/__tests__/togglePlugin.d.ts.map +1 -0
  74. package/lib/modifiers/config/__tests__/togglePlugin.js +28 -0
  75. package/lib/modifiers/summary/__tests__/editPartTitle.d.ts +2 -0
  76. package/lib/modifiers/summary/__tests__/editPartTitle.d.ts.map +1 -0
  77. package/lib/modifiers/summary/__tests__/editPartTitle.js +41 -0
  78. package/lib/modifiers/summary/__tests__/insertArticle.d.ts +2 -0
  79. package/lib/modifiers/summary/__tests__/insertArticle.d.ts.map +1 -0
  80. package/lib/modifiers/summary/__tests__/insertArticle.js +72 -0
  81. package/lib/modifiers/summary/__tests__/insertPart.d.ts +2 -0
  82. package/lib/modifiers/summary/__tests__/insertPart.d.ts.map +1 -0
  83. package/lib/modifiers/summary/__tests__/insertPart.js +56 -0
  84. package/lib/modifiers/summary/__tests__/mergeAtLevel.d.ts +2 -0
  85. package/lib/modifiers/summary/__tests__/mergeAtLevel.d.ts.map +1 -0
  86. package/lib/modifiers/summary/__tests__/mergeAtLevel.js +45 -0
  87. package/lib/modifiers/summary/__tests__/moveArticle.d.ts +2 -0
  88. package/lib/modifiers/summary/__tests__/moveArticle.d.ts.map +1 -0
  89. package/lib/modifiers/summary/__tests__/moveArticle.js +66 -0
  90. package/lib/modifiers/summary/__tests__/moveArticleAfter.d.ts +2 -0
  91. package/lib/modifiers/summary/__tests__/moveArticleAfter.d.ts.map +1 -0
  92. package/lib/modifiers/summary/__tests__/moveArticleAfter.js +75 -0
  93. package/lib/modifiers/summary/__tests__/removeArticle.d.ts +2 -0
  94. package/lib/modifiers/summary/__tests__/removeArticle.d.ts.map +1 -0
  95. package/lib/modifiers/summary/__tests__/removeArticle.js +54 -0
  96. package/lib/output/__tests__/ebook.d.ts +2 -0
  97. package/lib/output/__tests__/ebook.d.ts.map +1 -0
  98. package/lib/output/__tests__/ebook.js +17 -0
  99. package/lib/output/__tests__/json.d.ts +2 -0
  100. package/lib/output/__tests__/json.d.ts.map +1 -0
  101. package/lib/output/__tests__/json.js +43 -0
  102. package/lib/output/__tests__/plugin-hooks.d.ts +2 -0
  103. package/lib/output/__tests__/plugin-hooks.d.ts.map +1 -0
  104. package/lib/output/__tests__/plugin-hooks.js +57 -0
  105. package/lib/output/__tests__/website.d.ts +2 -0
  106. package/lib/output/__tests__/website.d.ts.map +1 -0
  107. package/lib/output/__tests__/website.js +121 -0
  108. package/lib/output/modifiers/__tests__/addHeadingId.d.ts +2 -0
  109. package/lib/output/modifiers/__tests__/addHeadingId.d.ts.map +1 -0
  110. package/lib/output/modifiers/__tests__/addHeadingId.js +23 -0
  111. package/lib/output/modifiers/__tests__/annotateText.d.ts +2 -0
  112. package/lib/output/modifiers/__tests__/annotateText.d.ts.map +1 -0
  113. package/lib/output/modifiers/__tests__/annotateText.js +71 -0
  114. package/lib/output/modifiers/__tests__/fetchRemoteImages.d.ts +2 -0
  115. package/lib/output/modifiers/__tests__/fetchRemoteImages.d.ts.map +1 -0
  116. package/lib/output/modifiers/__tests__/fetchRemoteImages.js +69 -0
  117. package/lib/output/modifiers/__tests__/highlightCode.d.ts +2 -0
  118. package/lib/output/modifiers/__tests__/highlightCode.d.ts.map +1 -0
  119. package/lib/output/modifiers/__tests__/highlightCode.js +48 -0
  120. package/lib/output/modifiers/__tests__/inlinePng.d.ts +2 -0
  121. package/lib/output/modifiers/__tests__/inlinePng.d.ts.map +1 -0
  122. package/lib/output/modifiers/__tests__/inlinePng.js +22 -0
  123. package/lib/output/modifiers/__tests__/inlineSvg.d.ts +2 -0
  124. package/lib/output/modifiers/__tests__/inlineSvg.d.ts.map +1 -0
  125. package/lib/output/modifiers/__tests__/inlineSvg.js +42 -0
  126. package/lib/output/modifiers/__tests__/resolveImages.d.ts +2 -0
  127. package/lib/output/modifiers/__tests__/resolveImages.d.ts.map +1 -0
  128. package/lib/output/modifiers/__tests__/resolveImages.js +39 -0
  129. package/lib/output/modifiers/__tests__/resolveLinks.d.ts +2 -0
  130. package/lib/output/modifiers/__tests__/resolveLinks.d.ts.map +1 -0
  131. package/lib/output/modifiers/__tests__/resolveLinks.js +81 -0
  132. package/lib/output/modifiers/__tests__/svgToImg.d.ts +2 -0
  133. package/lib/output/modifiers/__tests__/svgToImg.d.ts.map +1 -0
  134. package/lib/output/modifiers/__tests__/svgToImg.js +29 -0
  135. package/lib/output/website/__tests__/i18n.d.ts +2 -0
  136. package/lib/output/website/__tests__/i18n.d.ts.map +1 -0
  137. package/lib/output/website/__tests__/i18n.js +40 -0
  138. package/lib/parse/__tests__/listAssets.d.ts +2 -0
  139. package/lib/parse/__tests__/listAssets.d.ts.map +1 -0
  140. package/lib/parse/__tests__/listAssets.js +63 -0
  141. package/lib/parse/__tests__/parseBook.d.ts +2 -0
  142. package/lib/parse/__tests__/parseBook.d.ts.map +1 -0
  143. package/lib/parse/__tests__/parseBook.js +77 -0
  144. package/lib/parse/__tests__/parseGlossary.d.ts +2 -0
  145. package/lib/parse/__tests__/parseGlossary.d.ts.map +1 -0
  146. package/lib/parse/__tests__/parseGlossary.js +32 -0
  147. package/lib/parse/__tests__/parseIgnore.d.ts +2 -0
  148. package/lib/parse/__tests__/parseIgnore.d.ts.map +1 -0
  149. package/lib/parse/__tests__/parseIgnore.js +37 -0
  150. package/lib/parse/__tests__/parsePageFromString.d.ts +2 -0
  151. package/lib/parse/__tests__/parsePageFromString.d.ts.map +1 -0
  152. package/lib/parse/__tests__/parsePageFromString.js +34 -0
  153. package/lib/parse/__tests__/parseReadme.d.ts +2 -0
  154. package/lib/parse/__tests__/parseReadme.d.ts.map +1 -0
  155. package/lib/parse/__tests__/parseReadme.js +33 -0
  156. package/lib/parse/__tests__/parseSummary.d.ts +2 -0
  157. package/lib/parse/__tests__/parseSummary.d.ts.map +1 -0
  158. package/lib/parse/__tests__/parseSummary.js +30 -0
  159. package/lib/plugins/__tests__/listDependencies.d.ts +2 -0
  160. package/lib/plugins/__tests__/listDependencies.d.ts.map +1 -0
  161. package/lib/plugins/__tests__/listDependencies.js +28 -0
  162. package/lib/plugins/__tests__/sortDependencies.d.ts +2 -0
  163. package/lib/plugins/__tests__/sortDependencies.d.ts.map +1 -0
  164. package/lib/plugins/__tests__/sortDependencies.js +28 -0
  165. package/lib/plugins/__tests__/validatePlugin.d.ts +2 -0
  166. package/lib/plugins/__tests__/validatePlugin.d.ts.map +1 -0
  167. package/lib/plugins/__tests__/validatePlugin.js +99 -0
  168. package/lib/templating/__tests__/conrefsLoader.d.ts +2 -0
  169. package/lib/templating/__tests__/conrefsLoader.d.ts.map +1 -0
  170. package/lib/templating/__tests__/conrefsLoader.js +90 -0
  171. package/lib/templating/__tests__/postRender.d.ts +2 -0
  172. package/lib/templating/__tests__/postRender.d.ts.map +1 -0
  173. package/lib/templating/__tests__/postRender.js +52 -0
  174. package/lib/templating/__tests__/replaceShortcuts.d.ts +2 -0
  175. package/lib/templating/__tests__/replaceShortcuts.d.ts.map +1 -0
  176. package/lib/templating/__tests__/replaceShortcuts.js +27 -0
  177. package/lib/utils/__tests__/git.d.ts +2 -0
  178. package/lib/utils/__tests__/git.d.ts.map +1 -0
  179. package/lib/utils/__tests__/git.js +46 -0
  180. package/lib/utils/__tests__/location.d.ts +2 -0
  181. package/lib/utils/__tests__/location.d.ts.map +1 -0
  182. package/lib/utils/__tests__/location.js +81 -0
  183. package/lib/utils/__tests__/path.d.ts +2 -0
  184. package/lib/utils/__tests__/path.d.ts.map +1 -0
  185. package/lib/utils/__tests__/path.js +19 -0
  186. package/package.json +17 -19
package/lib/cli/watch.js CHANGED
@@ -7,24 +7,37 @@ const path_1 = __importDefault(require("path"));
7
7
  const chokidar_1 = __importDefault(require("chokidar"));
8
8
  const parsers_1 = __importDefault(require("../parsers"));
9
9
  /**
10
- Watch a folder and resolve promise once a file is modified
11
-
12
- @param {string} dir
13
- @param callback
14
- @return {Promise}
10
+ * Watch a folder and call callback when a file is modified
11
+ *
12
+ * @param {WatchOptions} options
13
+ * @return {FSWatcher} The chokidar watcher instance
15
14
  */
16
- function watch(dir, callback) {
17
- dir = path_1.default.resolve(dir);
15
+ function watch(options) {
16
+ const { callback, outputFolder } = options;
17
+ const dir = path_1.default.resolve(options.watchDir);
18
18
  const toWatch = ["book.json", "book.js", "_layouts/**"];
19
19
  // Watch all parsable files
20
20
  parsers_1.default.extensions.forEach((ext) => {
21
21
  toWatch.push(`**/*${ext}`);
22
22
  });
23
+ // Build ignored patterns
24
+ // Always ignore _book and node_modules
25
+ // https://github.com/honkit/honkit/issues/269
26
+ const ignored = ["_book/**", "node_modules/**"];
27
+ // If a custom output folder is specified, ignore it too
28
+ // This prevents infinite rebuild loops when output folder is inside the watched directory
29
+ // https://github.com/honkit/honkit/issues/491
30
+ if (outputFolder) {
31
+ // Convert to forward slashes for glob pattern (Windows compatibility)
32
+ const outputRelative = path_1.default.relative(dir, path_1.default.resolve(dir, outputFolder)).replace(/\\/g, "/");
33
+ // Only add to ignored if the output folder is inside the watched directory
34
+ if (outputRelative && !outputRelative.startsWith("..") && !path_1.default.isAbsolute(outputRelative)) {
35
+ ignored.push(`${outputRelative}/**`);
36
+ }
37
+ }
23
38
  const watcher = chokidar_1.default.watch(toWatch, {
24
39
  cwd: dir,
25
- // prevent infinity loop
26
- // https://github.com/honkit/honkit/issues/269
27
- ignored: ["_book/**", "node_modules/**"],
40
+ ignored: ignored,
28
41
  ignoreInitial: true
29
42
  });
30
43
  watcher.on("all", (e, filepath) => {
@@ -33,5 +46,6 @@ function watch(dir, callback) {
33
46
  watcher.on("error", (err) => {
34
47
  callback(err);
35
48
  });
49
+ return watcher;
36
50
  }
37
51
  exports.default = watch;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=configSchema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configSchema.d.ts","sourceRoot":"","sources":["../../../src/constants/__tests__/configSchema.ts"],"names":[],"mappings":""}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const jsonschema_1 = __importDefault(require("jsonschema"));
7
+ const configSchema_1 = __importDefault(require("../configSchema"));
8
+ describe("configSchema", () => {
9
+ function validate(cfg) {
10
+ const v = new jsonschema_1.default.Validator();
11
+ return v.validate(cfg, configSchema_1.default, {
12
+ propertyName: "config",
13
+ });
14
+ }
15
+ describe("structure", () => {
16
+ test("should accept dot in filename", () => {
17
+ const result = validate({
18
+ structure: {
19
+ readme: "book-intro.adoc",
20
+ },
21
+ });
22
+ expect(result.errors.length).toBe(0);
23
+ });
24
+ test("should accept uppercase in filename", () => {
25
+ const result = validate({
26
+ structure: {
27
+ readme: "BOOK.adoc",
28
+ },
29
+ });
30
+ expect(result.errors.length).toBe(0);
31
+ });
32
+ test("should not accept filepath", () => {
33
+ const result = validate({
34
+ structure: {
35
+ readme: "folder/myFile.md",
36
+ },
37
+ });
38
+ expect(result.errors.length).toBe(1);
39
+ });
40
+ });
41
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=mock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../../src/fs/__tests__/mock.ts"],"names":[],"mappings":""}
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const mock_1 = __importDefault(require("../mock"));
7
+ describe("MockFS", () => {
8
+ const fs = (0, mock_1.default)({
9
+ "README.md": "Hello World",
10
+ "SUMMARY.md": "# Summary",
11
+ folder: {
12
+ "test.md": "Cool",
13
+ folder2: {
14
+ "hello.md": "Hello",
15
+ "world.md": "World"
16
+ }
17
+ }
18
+ });
19
+ describe("exists", () => {
20
+ test("must return true for a file", () => {
21
+ return fs.exists("README.md").then((result) => {
22
+ expect(result).toBeTruthy();
23
+ });
24
+ });
25
+ test("must return false for a non existing file", () => {
26
+ return fs.exists("README_NOTEXISTS.md").then((result) => {
27
+ expect(result).toBeFalsy();
28
+ });
29
+ });
30
+ test("must return true for a directory", () => {
31
+ return fs.exists("folder").then((result) => {
32
+ expect(result).toBeTruthy();
33
+ });
34
+ });
35
+ test("must return true for a deep file", () => {
36
+ return fs.exists("folder/test.md").then((result) => {
37
+ expect(result).toBeTruthy();
38
+ });
39
+ });
40
+ test("must return true for a deep file (2)", () => {
41
+ return fs.exists("folder/folder2/hello.md").then((result) => {
42
+ expect(result).toBeTruthy();
43
+ });
44
+ });
45
+ });
46
+ describe("readAsString", () => {
47
+ test("must return content for a file", () => {
48
+ return fs.readAsString("README.md").then((result) => {
49
+ expect(result).toBe("Hello World");
50
+ });
51
+ });
52
+ test("must return content for a deep file", () => {
53
+ return fs.readAsString("folder/test.md").then((result) => {
54
+ expect(result).toBe("Cool");
55
+ });
56
+ });
57
+ });
58
+ describe("readDir", () => {
59
+ test("must return content for a directory", () => {
60
+ return fs.readDir("./").then((files) => {
61
+ expect(files.size).toBe(3);
62
+ expect(files.includes("README.md")).toBeTruthy();
63
+ expect(files.includes("SUMMARY.md")).toBeTruthy();
64
+ expect(files.includes("folder/")).toBeTruthy();
65
+ });
66
+ });
67
+ });
68
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/models/__tests__/config.ts"],"names":[],"mappings":""}
@@ -0,0 +1,164 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const immutable_1 = __importDefault(require("immutable"));
7
+ const config_1 = __importDefault(require("../config"));
8
+ describe("Config", () => {
9
+ const config = config_1.default.createWithValues({
10
+ hello: {
11
+ world: 1,
12
+ test: "Hello",
13
+ isFalse: false,
14
+ },
15
+ });
16
+ describe("getValue", () => {
17
+ test("must return value as immutable", () => {
18
+ const value = config.getValue("hello");
19
+ expect(immutable_1.default.Map.isMap(value)).toBeTruthy();
20
+ });
21
+ test("must return deep value", () => {
22
+ const value = config.getValue("hello.world");
23
+ expect(value).toBe(1);
24
+ });
25
+ test("must return default value if non existant", () => {
26
+ const value = config.getValue("hello.nonExistant", "defaultValue");
27
+ expect(value).toBe("defaultValue");
28
+ });
29
+ test("must not return default value for falsy values", () => {
30
+ const value = config.getValue("hello.isFalse", "defaultValue");
31
+ expect(value).toBe(false);
32
+ });
33
+ });
34
+ describe("setValue", () => {
35
+ test("must set value as immutable", () => {
36
+ const testConfig = config.setValue("hello", {
37
+ cool: 1,
38
+ });
39
+ const value = testConfig.getValue("hello");
40
+ expect(immutable_1.default.Map.isMap(value)).toBeTruthy();
41
+ expect(value.size).toBe(1);
42
+ expect(value.has("cool")).toBeTruthy();
43
+ });
44
+ test("must set deep value", () => {
45
+ const testConfig = config.setValue("hello.world", 2);
46
+ const hello = testConfig.getValue("hello");
47
+ const world = testConfig.getValue("hello.world");
48
+ expect(immutable_1.default.Map.isMap(hello)).toBeTruthy();
49
+ expect(hello.size).toBe(3);
50
+ expect(world).toBe(2);
51
+ });
52
+ });
53
+ describe("toReducedVersion", () => {
54
+ test("must only return diffs for simple values", () => {
55
+ const _config = config_1.default.createWithValues({
56
+ gitbook: "3.0.0",
57
+ });
58
+ const reducedVersion = _config.toReducedVersion();
59
+ expect(reducedVersion.toJS()).toEqual({
60
+ gitbook: "3.0.0",
61
+ });
62
+ });
63
+ test("must only return diffs for deep values", () => {
64
+ const _config = config_1.default.createWithValues({
65
+ structure: {
66
+ readme: "intro.md",
67
+ },
68
+ });
69
+ const reducedVersion = _config.toReducedVersion();
70
+ expect(reducedVersion.toJS()).toEqual({
71
+ structure: {
72
+ readme: "intro.md",
73
+ },
74
+ });
75
+ });
76
+ });
77
+ describe("getPluginDependencies", () => {
78
+ const config = config_1.default.createWithValues({
79
+ plugins: [
80
+ "example",
81
+ "honkit-plugin-example",
82
+ "@example/example",
83
+ "@example/honkit-plugin-example",
84
+ "@honkit/honkit-plugin-example",
85
+ "-no-use",
86
+ "-honkit-plugin-no-use",
87
+ "-@honkit/honkit-plugin-no-use",
88
+ // GitBook logic - deprecated
89
+ "example-v@1.0.0",
90
+ "gitbook-plugin-example-v@1.0.0",
91
+ "example@git+ssh://samy@github.com/GitbookIO/plugin-ga.git",
92
+ ],
93
+ });
94
+ const dependencies = config.getPluginDependencies();
95
+ expect(dependencies.toJS()).toEqual([
96
+ {
97
+ enabled: true,
98
+ name: "example",
99
+ path: "",
100
+ version: "*",
101
+ },
102
+ {
103
+ enabled: true,
104
+ name: "honkit-plugin-example",
105
+ path: "",
106
+ version: "*",
107
+ },
108
+ {
109
+ enabled: true,
110
+ name: "@example/example",
111
+ path: "",
112
+ version: "*",
113
+ },
114
+ {
115
+ enabled: true,
116
+ name: "@example/honkit-plugin-example",
117
+ path: "",
118
+ version: "*",
119
+ },
120
+ {
121
+ enabled: true,
122
+ name: "@honkit/honkit-plugin-example",
123
+ path: "",
124
+ version: "*",
125
+ },
126
+ {
127
+ enabled: false,
128
+ name: "no-use",
129
+ path: "",
130
+ version: "*",
131
+ },
132
+ {
133
+ enabled: false,
134
+ name: "honkit-plugin-no-use",
135
+ path: "",
136
+ version: "*",
137
+ },
138
+ {
139
+ enabled: false,
140
+ name: "@honkit/honkit-plugin-no-use",
141
+ path: "",
142
+ version: "*",
143
+ },
144
+ {
145
+ enabled: true,
146
+ name: "example-v",
147
+ path: "",
148
+ version: "1.0.0",
149
+ },
150
+ {
151
+ enabled: true,
152
+ name: "gitbook-plugin-example-v",
153
+ path: "",
154
+ version: "1.0.0",
155
+ },
156
+ {
157
+ enabled: true,
158
+ name: "example",
159
+ path: "",
160
+ version: "git+ssh://samy@github.com/GitbookIO/plugin-ga.git",
161
+ },
162
+ ]);
163
+ });
164
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=glossary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glossary.d.ts","sourceRoot":"","sources":["../../../src/models/__tests__/glossary.ts"],"names":[],"mappings":""}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const file_1 = __importDefault(require("../file"));
7
+ const glossary_1 = __importDefault(require("../glossary"));
8
+ const glossaryEntry_1 = __importDefault(require("../glossaryEntry"));
9
+ describe("Glossary", () => {
10
+ const glossary = glossary_1.default.createFromEntries(new file_1.default(), [
11
+ {
12
+ name: "Hello World",
13
+ description: "Awesome!",
14
+ },
15
+ {
16
+ name: "JavaScript",
17
+ description: "This is a cool language",
18
+ },
19
+ ]);
20
+ describe("createFromEntries", () => {
21
+ test("must add all entries", () => {
22
+ const entries = glossary.getEntries();
23
+ expect(entries.size).toBe(2);
24
+ });
25
+ test("must add entries as GlossaryEntries", () => {
26
+ const entries = glossary.getEntries();
27
+ const entry = entries.get("hello-world");
28
+ expect(entry instanceof glossaryEntry_1.default).toBeTruthy();
29
+ });
30
+ });
31
+ describe("toText", () => {
32
+ test("return as markdown", () => {
33
+ return glossary.toText(".md").then((text) => {
34
+ expect(text).toContain("# Glossary");
35
+ });
36
+ });
37
+ });
38
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=glossaryEntry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glossaryEntry.d.ts","sourceRoot":"","sources":["../../../src/models/__tests__/glossaryEntry.ts"],"names":[],"mappings":""}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const glossaryEntry_1 = __importDefault(require("../glossaryEntry"));
7
+ describe("GlossaryEntry", () => {
8
+ describe("getID", () => {
9
+ test("must return a normalized ID", () => {
10
+ const entry = new glossaryEntry_1.default({
11
+ name: "Hello World",
12
+ });
13
+ expect(entry.getID()).toBe("hello-world");
14
+ });
15
+ });
16
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=page.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../../src/models/__tests__/page.ts"],"names":[],"mappings":""}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const immutable_1 = __importDefault(require("immutable"));
7
+ const page_1 = __importDefault(require("../page"));
8
+ describe("Page", () => {
9
+ describe("toText", () => {
10
+ test("must not prepend frontmatter if no attributes", () => {
11
+ const page = new page_1.default().merge({
12
+ content: "Hello World",
13
+ });
14
+ expect(page.toText()).toBe("Hello World");
15
+ });
16
+ test("must prepend frontmatter if attributes", () => {
17
+ const page = new page_1.default().merge({
18
+ content: "Hello World",
19
+ attributes: immutable_1.default.fromJS({
20
+ hello: "world",
21
+ }),
22
+ });
23
+ expect(page.toText()).toBe("---\nhello: world\n---\n\nHello World");
24
+ });
25
+ });
26
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/models/__tests__/plugin.ts"],"names":[],"mappings":""}
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const plugin_1 = __importDefault(require("../plugin"));
7
+ const immutable_1 = __importDefault(require("immutable"));
8
+ describe("Plugin", () => {
9
+ describe("createFromString", () => {
10
+ test("must parse name", () => {
11
+ const plugin = plugin_1.default.createFromString("hello");
12
+ expect(plugin.getName()).toBe("hello");
13
+ expect(plugin.getVersion()).toBe("*");
14
+ });
15
+ test("must parse version", () => {
16
+ const plugin = plugin_1.default.createFromString("hello@1.0.0");
17
+ expect(plugin.getName()).toBe("hello");
18
+ expect(plugin.getVersion()).toBe("1.0.0");
19
+ });
20
+ });
21
+ describe("getNpmId", () => {
22
+ it("should return package's name", () => {
23
+ const plugin = new plugin_1.default({
24
+ name: "testplugin",
25
+ version: "*",
26
+ path: "test.js",
27
+ package: immutable_1.default.fromJS({
28
+ name: "testplugin-name"
29
+ }),
30
+ content: immutable_1.default.fromJS({
31
+ hooks: {
32
+ "page:before": function (page) {
33
+ return page;
34
+ },
35
+ page: function (page) {
36
+ return page;
37
+ }
38
+ }
39
+ })
40
+ });
41
+ expect(plugin.getNpmID()).toBe("testplugin-name");
42
+ });
43
+ });
44
+ describe("isLoaded", () => {
45
+ test("must return false for empty plugin", () => {
46
+ const plugin = plugin_1.default.createFromString("hello");
47
+ expect(plugin.isLoaded()).toBe(false);
48
+ });
49
+ });
50
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=pluginDependency.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pluginDependency.d.ts","sourceRoot":"","sources":["../../../src/models/__tests__/pluginDependency.ts"],"names":[],"mappings":""}
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const immutable_1 = __importDefault(require("immutable"));
7
+ const pluginDependency_1 = __importDefault(require("../pluginDependency"));
8
+ describe("PluginDependency", () => {
9
+ describe("createFromString", () => {
10
+ test("must parse name", () => {
11
+ const plugin = pluginDependency_1.default.createFromString("hello");
12
+ expect(plugin.getName()).toBe("hello");
13
+ expect(plugin.getVersion()).toBe("*");
14
+ });
15
+ test("must parse state", () => {
16
+ const plugin = pluginDependency_1.default.createFromString("-hello");
17
+ expect(plugin.getName()).toBe("hello");
18
+ expect(plugin.isEnabled()).toBe(false);
19
+ });
20
+ describe("Version", () => {
21
+ test("must parse version", () => {
22
+ const plugin = pluginDependency_1.default.createFromString("hello@1.0.0");
23
+ expect(plugin.getName()).toBe("hello");
24
+ expect(plugin.getVersion()).toBe("1.0.0");
25
+ });
26
+ test("must parse semver", () => {
27
+ const plugin = pluginDependency_1.default.createFromString("hello@>=4.0.0");
28
+ expect(plugin.getName()).toBe("hello");
29
+ expect(plugin.getVersion()).toBe(">=4.0.0");
30
+ });
31
+ });
32
+ describe("GIT Version", () => {
33
+ test("must handle HTTPS urls", () => {
34
+ const plugin = pluginDependency_1.default.createFromString("hello@git+https://github.com/GitbookIO/plugin-ga.git");
35
+ expect(plugin.getName()).toBe("hello");
36
+ expect(plugin.getVersion()).toBe("git+https://github.com/GitbookIO/plugin-ga.git");
37
+ });
38
+ test("must handle SSH urls", () => {
39
+ const plugin = pluginDependency_1.default.createFromString("hello@git+ssh://samy@github.com/GitbookIO/plugin-ga.git");
40
+ expect(plugin.getName()).toBe("hello");
41
+ expect(plugin.getVersion()).toBe("git+ssh://samy@github.com/GitbookIO/plugin-ga.git");
42
+ });
43
+ });
44
+ describe("listToArray", () => {
45
+ test("must create an array from a list of plugin dependencies", () => {
46
+ const list = pluginDependency_1.default.listToArray(immutable_1.default.List([
47
+ pluginDependency_1.default.createFromString("hello@1.0.0"),
48
+ pluginDependency_1.default.createFromString("noversion"),
49
+ pluginDependency_1.default.createFromString("-disabled"),
50
+ ]));
51
+ expect(list).toEqual(["hello@1.0.0", "noversion", "-disabled"]);
52
+ });
53
+ });
54
+ describe("listFromArray", () => {
55
+ test("must create an array from a list of plugin dependencies", () => {
56
+ const arr = immutable_1.default.fromJS([
57
+ "hello@1.0.0",
58
+ {
59
+ name: "plugin-ga",
60
+ version: "git+ssh://samy@github.com/GitbookIO/plugin-ga.git",
61
+ },
62
+ ]);
63
+ const list = pluginDependency_1.default.listFromArray(arr);
64
+ expect(list.first().getName()).toBe("hello");
65
+ expect(list.first().getVersion()).toBe("1.0.0");
66
+ expect(list.last().getName()).toBe("plugin-ga");
67
+ expect(list.last().getVersion()).toBe("git+ssh://samy@github.com/GitbookIO/plugin-ga.git");
68
+ });
69
+ });
70
+ });
71
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=summary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"summary.d.ts","sourceRoot":"","sources":["../../../src/models/__tests__/summary.ts"],"names":[],"mappings":""}