@thegetty/quire-cli 1.0.0-rc.45 → 1.0.0-rc.47

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 (245) hide show
  1. package/CHANGELOG.md +0 -36
  2. package/README.md +0 -9
  3. package/bin/cli.js +1 -46
  4. package/package.json +10 -27
  5. package/src/Command.js +6 -26
  6. package/src/commands/README.md +122 -213
  7. package/src/commands/build.js +37 -45
  8. package/src/commands/clean.js +19 -33
  9. package/src/commands/conf.js +43 -0
  10. package/src/commands/create.js +14 -42
  11. package/src/commands/epub.js +31 -67
  12. package/src/commands/index.js +2 -9
  13. package/src/commands/info.js +86 -88
  14. package/src/commands/pdf.js +82 -63
  15. package/src/commands/preview.js +31 -32
  16. package/src/commands/validate.js +20 -64
  17. package/src/commands/version.js +43 -0
  18. package/src/errors/validation/validation-error.js +11 -20
  19. package/src/helpers/clean.js +1 -1
  20. package/src/helpers/is-quire.js +31 -0
  21. package/src/helpers/test-cwd.js +6 -5
  22. package/src/helpers/which.js +4 -10
  23. package/src/lib/11ty/README.md +19 -135
  24. package/src/lib/11ty/api.js +93 -235
  25. package/src/lib/11ty/cli.js +37 -112
  26. package/src/lib/11ty/index.js +5 -64
  27. package/src/lib/11ty/paths.js +103 -0
  28. package/src/lib/README.md +0 -330
  29. package/src/lib/conf/README.md +69 -86
  30. package/src/lib/conf/config.js +3 -5
  31. package/src/lib/conf/defaults.js +0 -65
  32. package/src/lib/conf/schema.js +9 -103
  33. package/src/lib/epub/README.md +2 -133
  34. package/src/lib/epub/epub.js +11 -36
  35. package/src/lib/epub/index.js +21 -111
  36. package/src/lib/epub/pandoc.js +4 -33
  37. package/src/lib/git/README.md +2 -151
  38. package/src/lib/git/index.js +13 -217
  39. package/src/lib/i18n/README.md +3 -0
  40. package/src/lib/i18n/config.js +53 -0
  41. package/src/lib/i18n/index.js +43 -0
  42. package/src/lib/i18n/localeService.js +58 -0
  43. package/src/lib/pdf/README.md +0 -131
  44. package/src/lib/pdf/index.js +21 -124
  45. package/src/lib/pdf/paged.js +52 -100
  46. package/src/lib/pdf/prince.js +37 -115
  47. package/src/lib/pdf/split.js +33 -61
  48. package/src/lib/quire/README.md +19 -0
  49. package/src/lib/quire/index.js +353 -0
  50. package/src/lib/reporter/README.md +2 -211
  51. package/src/lib/reporter/index.js +0 -607
  52. package/src/main.js +48 -221
  53. package/src/packageConfig.js +0 -17
  54. package/src/validators/utils.js +1 -2
  55. package/man/quire.1 +0 -341
  56. package/man/quire.1.md +0 -232
  57. package/schemas/config.schema.json +0 -194
  58. package/schemas/figures.schema.json +0 -56
  59. package/schemas/layout.schema.json +0 -5
  60. package/schemas/objects.schema.json +0 -62
  61. package/schemas/publication.schema.json +0 -140
  62. package/schemas/references.schema.json +0 -29
  63. package/src/Command.spec.js +0 -99
  64. package/src/commands/build.spec.js +0 -113
  65. package/src/commands/build.test.js +0 -397
  66. package/src/commands/clean.spec.js +0 -118
  67. package/src/commands/clean.test.js +0 -382
  68. package/src/commands/config.js +0 -238
  69. package/src/commands/config.spec.js +0 -107
  70. package/src/commands/config.test.js +0 -845
  71. package/src/commands/create.spec.js +0 -112
  72. package/src/commands/create.test.js +0 -415
  73. package/src/commands/doctor.js +0 -251
  74. package/src/commands/doctor.spec.js +0 -115
  75. package/src/commands/doctor.test.js +0 -1409
  76. package/src/commands/epub.spec.js +0 -114
  77. package/src/commands/epub.test.js +0 -503
  78. package/src/commands/help.js +0 -60
  79. package/src/commands/help.test.js +0 -132
  80. package/src/commands/info.spec.js +0 -72
  81. package/src/commands/info.test.js +0 -512
  82. package/src/commands/pdf.spec.js +0 -114
  83. package/src/commands/pdf.test.js +0 -464
  84. package/src/commands/preview.spec.js +0 -97
  85. package/src/commands/preview.test.js +0 -250
  86. package/src/commands/use.js +0 -56
  87. package/src/commands/use.spec.js +0 -61
  88. package/src/commands/use.test.js +0 -280
  89. package/src/commands/validate.spec.js +0 -90
  90. package/src/commands/validate.test.js +0 -378
  91. package/src/commands/workflows.js +0 -70
  92. package/src/errors/build/build-failed-error.js +0 -19
  93. package/src/errors/build/config-field-missing-error.js +0 -20
  94. package/src/errors/build/config-file-not-found-error.js +0 -20
  95. package/src/errors/build/index.js +0 -11
  96. package/src/errors/help/help-topic-not-found-error.js +0 -30
  97. package/src/errors/help/index.js +0 -8
  98. package/src/errors/index.js +0 -58
  99. package/src/errors/input/index.js +0 -8
  100. package/src/errors/input/invalid-input-error.js +0 -21
  101. package/src/errors/install/dependency-install-error.js +0 -19
  102. package/src/errors/install/directory-not-empty-error.js +0 -25
  103. package/src/errors/install/index.js +0 -12
  104. package/src/errors/install/invalid-path-error.js +0 -31
  105. package/src/errors/install/invalid-starter-error.js +0 -27
  106. package/src/errors/install/version-not-found-error.js +0 -35
  107. package/src/errors/output/epub-generation-error.js +0 -19
  108. package/src/errors/output/index.js +0 -14
  109. package/src/errors/output/invalid-epub-library-error.js +0 -20
  110. package/src/errors/output/invalid-pdf-library-error.js +0 -20
  111. package/src/errors/output/missing-build-output-error.js +0 -21
  112. package/src/errors/output/pdf-generation-error.js +0 -24
  113. package/src/errors/output/tool-not-found-error.js +0 -37
  114. package/src/errors/project/index.js +0 -10
  115. package/src/errors/project/not-in-project-error.js +0 -20
  116. package/src/errors/project/project-create-error.js +0 -21
  117. package/src/errors/quire-error.js +0 -27
  118. package/src/errors/validation/index.js +0 -3
  119. package/src/errors/validation/unknown-config-key-error.js +0 -27
  120. package/src/errors/validation/unknown-config-operation-error.js +0 -24
  121. package/src/helpers/docs-url.js +0 -32
  122. package/src/helpers/pager.js +0 -59
  123. package/src/helpers/pager.test.js +0 -85
  124. package/src/helpers/suggest-similar.js +0 -124
  125. package/src/helpers/suggest-similar.test.js +0 -108
  126. package/src/helpers/test-cwd.test.js +0 -192
  127. package/src/lib/11ty/index.test.js +0 -655
  128. package/src/lib/commander/index.js +0 -103
  129. package/src/lib/commander/index.test.js +0 -86
  130. package/src/lib/commander/options.js +0 -237
  131. package/src/lib/commander/options.test.js +0 -205
  132. package/src/lib/conf/build-status.js +0 -103
  133. package/src/lib/conf/build-status.test.js +0 -247
  134. package/src/lib/conf/config.test.js +0 -281
  135. package/src/lib/conf/format.js +0 -60
  136. package/src/lib/conf/format.test.js +0 -106
  137. package/src/lib/conf/helpers.js +0 -91
  138. package/src/lib/conf/helpers.test.js +0 -136
  139. package/src/lib/conf/index.js +0 -22
  140. package/src/lib/constants.js +0 -28
  141. package/src/lib/doctor/README.md +0 -667
  142. package/src/lib/doctor/checks/environment/cli-version.js +0 -62
  143. package/src/lib/doctor/checks/environment/cli-version.test.js +0 -132
  144. package/src/lib/doctor/checks/environment/git-available.js +0 -77
  145. package/src/lib/doctor/checks/environment/git-available.test.js +0 -52
  146. package/src/lib/doctor/checks/environment/index.js +0 -13
  147. package/src/lib/doctor/checks/environment/node-version.js +0 -66
  148. package/src/lib/doctor/checks/environment/node-version.test.js +0 -17
  149. package/src/lib/doctor/checks/environment/npm-available.js +0 -66
  150. package/src/lib/doctor/checks/environment/npm-available.test.js +0 -52
  151. package/src/lib/doctor/checks/environment/os-info.js +0 -48
  152. package/src/lib/doctor/checks/environment/os-info.test.js +0 -81
  153. package/src/lib/doctor/checks/environment/runtime-info.js +0 -51
  154. package/src/lib/doctor/checks/environment/runtime-info.test.js +0 -132
  155. package/src/lib/doctor/checks/outputs/epub-output.js +0 -119
  156. package/src/lib/doctor/checks/outputs/epub-output.test.js +0 -277
  157. package/src/lib/doctor/checks/outputs/index.js +0 -10
  158. package/src/lib/doctor/checks/outputs/pdf-output.js +0 -144
  159. package/src/lib/doctor/checks/outputs/pdf-output.test.js +0 -377
  160. package/src/lib/doctor/checks/outputs/stale-build.js +0 -122
  161. package/src/lib/doctor/checks/outputs/stale-build.test.js +0 -282
  162. package/src/lib/doctor/checks/project/data-files.js +0 -56
  163. package/src/lib/doctor/checks/project/data-files.test.js +0 -125
  164. package/src/lib/doctor/checks/project/dependencies.js +0 -53
  165. package/src/lib/doctor/checks/project/dependencies.test.js +0 -71
  166. package/src/lib/doctor/checks/project/index.js +0 -11
  167. package/src/lib/doctor/checks/project/quire-11ty.js +0 -98
  168. package/src/lib/doctor/checks/project/quire-11ty.test.js +0 -170
  169. package/src/lib/doctor/checks/project/quire-project.js +0 -38
  170. package/src/lib/doctor/checks/project/quire-project.test.js +0 -47
  171. package/src/lib/doctor/checks/tools/index.js +0 -10
  172. package/src/lib/doctor/checks/tools/pandoc-available.js +0 -82
  173. package/src/lib/doctor/checks/tools/pandoc-available.test.js +0 -73
  174. package/src/lib/doctor/checks/tools/prince-available.js +0 -81
  175. package/src/lib/doctor/checks/tools/prince-available.test.js +0 -73
  176. package/src/lib/doctor/constants.js +0 -39
  177. package/src/lib/doctor/formatDuration.js +0 -108
  178. package/src/lib/doctor/formatDuration.test.js +0 -76
  179. package/src/lib/doctor/formatters/human.js +0 -257
  180. package/src/lib/doctor/formatters/human.test.js +0 -463
  181. package/src/lib/doctor/formatters/index.js +0 -8
  182. package/src/lib/doctor/formatters/json.js +0 -78
  183. package/src/lib/doctor/formatters/json.test.js +0 -174
  184. package/src/lib/doctor/formatters/shared.js +0 -129
  185. package/src/lib/doctor/formatters/shared.test.js +0 -194
  186. package/src/lib/doctor/index.js +0 -271
  187. package/src/lib/doctor/index.test.js +0 -797
  188. package/src/lib/epub/engines.js +0 -46
  189. package/src/lib/epub/index.test.js +0 -518
  190. package/src/lib/epub/pandoc.test.js +0 -122
  191. package/src/lib/epub/schema.js +0 -21
  192. package/src/lib/error/README.md +0 -170
  193. package/src/lib/error/handler.js +0 -107
  194. package/src/lib/git/index.spec.js +0 -80
  195. package/src/lib/git/index.test.js +0 -453
  196. package/src/lib/help/frontmatter.js +0 -77
  197. package/src/lib/help/frontmatter.test.js +0 -139
  198. package/src/lib/help/index.js +0 -146
  199. package/src/lib/help/index.test.js +0 -188
  200. package/src/lib/help/topics/configuration.md +0 -77
  201. package/src/lib/help/topics/debugging.md +0 -69
  202. package/src/lib/help/topics/epub.md +0 -74
  203. package/src/lib/help/topics/pdf.md +0 -74
  204. package/src/lib/help/topics/publishing.md +0 -80
  205. package/src/lib/help/topics/workflows.md +0 -50
  206. package/src/lib/installer/index.js +0 -309
  207. package/src/lib/installer/index.spec.js +0 -83
  208. package/src/lib/installer/index.test.js +0 -545
  209. package/src/lib/logger/README.md +0 -424
  210. package/src/lib/logger/debug.js +0 -132
  211. package/src/lib/logger/debug.spec.js +0 -130
  212. package/src/lib/logger/debug.test.js +0 -128
  213. package/src/lib/logger/index.js +0 -228
  214. package/src/lib/logger/index.spec.js +0 -131
  215. package/src/lib/logger/index.test.js +0 -578
  216. package/src/lib/npm/README.md +0 -127
  217. package/src/lib/npm/index.js +0 -198
  218. package/src/lib/npm/index.spec.js +0 -60
  219. package/src/lib/npm/index.test.js +0 -355
  220. package/src/lib/pdf/engines.js +0 -46
  221. package/src/lib/pdf/index.test.js +0 -708
  222. package/src/lib/pdf/paged.test.js +0 -366
  223. package/src/lib/pdf/prince.test.js +0 -202
  224. package/src/lib/pdf/schema.js +0 -21
  225. package/src/lib/pdf/split.test.js +0 -445
  226. package/src/lib/platform.js +0 -95
  227. package/src/lib/process/manager.js +0 -110
  228. package/src/lib/process/manager.test.js +0 -55
  229. package/src/lib/project/build.js +0 -162
  230. package/src/lib/project/build.test.js +0 -275
  231. package/src/lib/project/config.js +0 -48
  232. package/src/lib/project/config.test.js +0 -134
  233. package/src/lib/project/detect.js +0 -47
  234. package/src/lib/project/detect.test.js +0 -157
  235. package/src/lib/project/index.js +0 -56
  236. package/src/lib/project/output-paths.js +0 -87
  237. package/src/lib/project/output-paths.test.js +0 -66
  238. package/src/lib/project/paths.js +0 -272
  239. package/src/lib/project/version.js +0 -110
  240. package/src/lib/project/version.test.js +0 -350
  241. package/src/lib/reporter/index.test.js +0 -862
  242. package/src/main.spec.js +0 -61
  243. package/src/main.test.js +0 -347
  244. package/src/validators/validate-data-files.js +0 -154
  245. package/src/validators/validate-data-files.test.js +0 -217
@@ -1,797 +0,0 @@
1
- import test from 'ava'
2
- import sinon from 'sinon'
3
- import esmock from 'esmock'
4
-
5
- /**
6
- * Index module tests
7
- *
8
- * Tests the barrel export, checkSections structure, and runner functions.
9
- * Individual check function tests are in the domain test files:
10
- * - checks/environment/*.test.js
11
- * - checks/tools/*.test.js
12
- * - checks/project/*.test.js
13
- * - checks/outputs/*.test.js
14
- */
15
-
16
- test.beforeEach((t) => {
17
- t.context.sandbox = sinon.createSandbox()
18
- })
19
-
20
- test.afterEach.always((t) => {
21
- t.context.sandbox.restore()
22
- })
23
-
24
- // ─────────────────────────────────────────────────────────────────────────────
25
- // Barrel export tests
26
- // ─────────────────────────────────────────────────────────────────────────────
27
-
28
- test('checks array exports all check definitions', async (t) => {
29
- const { checks } = await import('./index.js')
30
-
31
- t.true(Array.isArray(checks))
32
- t.is(checks.length, 15)
33
-
34
- const checkNames = checks.map((c) => c.name)
35
- t.true(checkNames.includes('Operating system'))
36
- t.true(checkNames.includes('Quire CLI version'))
37
- t.true(checkNames.includes('Node.js version'))
38
- t.true(checkNames.includes('Node.js runtime'))
39
- t.true(checkNames.includes('npm'))
40
- t.true(checkNames.includes('Git'))
41
- t.true(checkNames.includes('PrinceXML'))
42
- t.true(checkNames.includes('Pandoc'))
43
- t.true(checkNames.includes('Quire project'))
44
- t.true(checkNames.includes('Dependencies'))
45
- t.true(checkNames.includes('quire-11ty version'))
46
- t.true(checkNames.includes('Data files'))
47
- t.true(checkNames.includes('Build status'))
48
- t.true(checkNames.includes('PDF output'))
49
- t.true(checkNames.includes('EPUB output'))
50
-
51
- // Verify each check has a function
52
- for (const { check } of checks) {
53
- t.is(typeof check, 'function')
54
- }
55
- })
56
-
57
- test('checkSections exports checks organized by 4 sections', async (t) => {
58
- const { checkSections } = await import('./index.js')
59
-
60
- t.true(Array.isArray(checkSections))
61
- t.is(checkSections.length, 4)
62
-
63
- const sectionNames = checkSections.map((s) => s.name)
64
- t.true(sectionNames.includes('Environment'))
65
- t.true(sectionNames.includes('Tools'))
66
- t.true(sectionNames.includes('Project'))
67
- t.true(sectionNames.includes('Outputs'))
68
-
69
- // Environment section should have 6 checks
70
- const envSection = checkSections.find((s) => s.name === 'Environment')
71
- t.is(envSection.checks.length, 6)
72
- const envCheckNames = envSection.checks.map((c) => c.name)
73
- t.true(envCheckNames.includes('Operating system'))
74
- t.true(envCheckNames.includes('Quire CLI version'))
75
- t.true(envCheckNames.includes('Node.js version'))
76
- t.true(envCheckNames.includes('Node.js runtime'))
77
- t.true(envCheckNames.includes('npm'))
78
- t.true(envCheckNames.includes('Git'))
79
-
80
- // Tools section should have 2 checks
81
- const toolsSection = checkSections.find((s) => s.name === 'Tools')
82
- t.is(toolsSection.checks.length, 2)
83
- const toolCheckNames = toolsSection.checks.map((c) => c.name)
84
- t.true(toolCheckNames.includes('PrinceXML'))
85
- t.true(toolCheckNames.includes('Pandoc'))
86
-
87
- // Project section should have 4 checks
88
- const projectSection = checkSections.find((s) => s.name === 'Project')
89
- t.is(projectSection.checks.length, 4)
90
- const projectCheckNames = projectSection.checks.map((c) => c.name)
91
- t.true(projectCheckNames.includes('Quire project'))
92
- t.true(projectCheckNames.includes('Dependencies'))
93
- t.true(projectCheckNames.includes('quire-11ty version'))
94
- t.true(projectCheckNames.includes('Data files'))
95
-
96
- // Outputs section should have 3 checks
97
- const outputsSection = checkSections.find((s) => s.name === 'Outputs')
98
- t.is(outputsSection.checks.length, 3)
99
- const outputCheckNames = outputsSection.checks.map((c) => c.name)
100
- t.true(outputCheckNames.includes('Build status'))
101
- t.true(outputCheckNames.includes('PDF output'))
102
- t.true(outputCheckNames.includes('EPUB output'))
103
- })
104
-
105
- test('default export includes all expected functions', async (t) => {
106
- const doctor = await import('./index.js')
107
-
108
- // Runner functions
109
- t.is(typeof doctor.default.runAllChecks, 'function')
110
- t.is(typeof doctor.default.runAllChecksWithSections, 'function')
111
-
112
- // Check functions
113
- t.is(typeof doctor.default.checkOsInfo, 'function')
114
- t.is(typeof doctor.default.checkCliVersion, 'function')
115
- t.is(typeof doctor.default.checkNodeVersion, 'function')
116
- t.is(typeof doctor.default.checkRuntimeInfo, 'function')
117
- t.is(typeof doctor.default.checkNpmAvailable, 'function')
118
- t.is(typeof doctor.default.checkGitAvailable, 'function')
119
- t.is(typeof doctor.default.checkPrinceAvailable, 'function')
120
- t.is(typeof doctor.default.checkPandocAvailable, 'function')
121
- t.is(typeof doctor.default.checkQuireProject, 'function')
122
- t.is(typeof doctor.default.checkDependencies, 'function')
123
- t.is(typeof doctor.default.checkOutdatedQuire11ty, 'function')
124
- t.is(typeof doctor.default.checkDataFiles, 'function')
125
- t.is(typeof doctor.default.checkStaleBuild, 'function')
126
- t.is(typeof doctor.default.checkPdfOutput, 'function')
127
- t.is(typeof doctor.default.checkEpubOutput, 'function')
128
-
129
- // Collections
130
- t.truthy(doctor.default.checks)
131
- t.truthy(doctor.default.checkSections)
132
- })
133
-
134
- test('named exports match default export', async (t) => {
135
- const doctor = await import('./index.js')
136
-
137
- t.is(doctor.checkOsInfo, doctor.default.checkOsInfo)
138
- t.is(doctor.checkCliVersion, doctor.default.checkCliVersion)
139
- t.is(doctor.checkNodeVersion, doctor.default.checkNodeVersion)
140
- t.is(doctor.checkRuntimeInfo, doctor.default.checkRuntimeInfo)
141
- t.is(doctor.checkNpmAvailable, doctor.default.checkNpmAvailable)
142
- t.is(doctor.checkGitAvailable, doctor.default.checkGitAvailable)
143
- t.is(doctor.checkPrinceAvailable, doctor.default.checkPrinceAvailable)
144
- t.is(doctor.checkPandocAvailable, doctor.default.checkPandocAvailable)
145
- t.is(doctor.checkQuireProject, doctor.default.checkQuireProject)
146
- t.is(doctor.checkDependencies, doctor.default.checkDependencies)
147
- t.is(doctor.checkOutdatedQuire11ty, doctor.default.checkOutdatedQuire11ty)
148
- t.is(doctor.checkDataFiles, doctor.default.checkDataFiles)
149
- t.is(doctor.checkStaleBuild, doctor.default.checkStaleBuild)
150
- t.is(doctor.checkPdfOutput, doctor.default.checkPdfOutput)
151
- t.is(doctor.checkEpubOutput, doctor.default.checkEpubOutput)
152
- t.is(doctor.runAllChecks, doctor.default.runAllChecks)
153
- t.is(doctor.runAllChecksWithSections, doctor.default.runAllChecksWithSections)
154
- })
155
-
156
- test('constants are exported', async (t) => {
157
- const doctor = await import('./index.js')
158
-
159
- t.is(doctor.DOCS_BASE_URL, 'https://quire.getty.edu/docs-v1')
160
- t.is(doctor.REQUIRED_NODE_VERSION, 22)
161
- t.is(doctor.QUIRE_11TY_PACKAGE, '@thegetty/quire-11ty')
162
- t.deepEqual(doctor.SECTION_NAMES, ['environment', 'tools', 'project', 'outputs'])
163
- t.deepEqual(doctor.CHECK_IDS, [
164
- 'os', 'cli', 'node', 'runtime', 'npm', 'git',
165
- 'prince', 'pandoc',
166
- 'project', 'deps', '11ty', 'data',
167
- 'build', 'pdf', 'epub',
168
- ])
169
- })
170
-
171
- // ─────────────────────────────────────────────────────────────────────────────
172
- // Runner function tests
173
- // ─────────────────────────────────────────────────────────────────────────────
174
-
175
- test('runAllChecks runs all checks and returns results array', async (t) => {
176
- const { sandbox } = t.context
177
-
178
- // Create mock check functions
179
- const mockCheckOs = sandbox.stub().returns({ ok: true, message: 'macOS 14 (arm64)' })
180
- const mockCheckCli = sandbox.stub().returns({ ok: true, message: 'v1.0.0-rc.33' })
181
- const mockCheckNode = sandbox.stub().returns({ ok: true, message: 'v22' })
182
- const mockCheckRuntime = sandbox.stub().returns({ ok: true, message: 'Heap limit: 4096 MB' })
183
- const mockCheckNpm = sandbox.stub().resolves({ ok: true, message: '10.2.4' })
184
- const mockCheckGit = sandbox.stub().resolves({ ok: true, message: '2.43.0' })
185
- const mockCheckPrince = sandbox.stub().returns({ ok: true, message: 'installed' })
186
- const mockCheckPandoc = sandbox.stub().returns({ ok: true, message: 'installed' })
187
- const mockCheckProject = sandbox.stub().returns({ ok: true, message: '.quire' })
188
- const mockCheckDeps = sandbox.stub().returns({ ok: true, message: 'installed' })
189
- const mockCheckQuire11ty = sandbox.stub().resolves({ ok: true, message: 'v1.0.0' })
190
- const mockCheckData = sandbox.stub().returns({ ok: true, message: '3 files' })
191
- const mockCheckStale = sandbox.stub().returns({ ok: true, message: 'up to date' })
192
- const mockCheckPdf = sandbox.stub().returns({ ok: true, message: 'no PDF' })
193
- const mockCheckEpub = sandbox.stub().returns({ ok: true, message: 'no EPUB' })
194
-
195
- const { runAllChecks } = await esmock('./index.js', {
196
- './checks/environment/index.js': {
197
- checkOsInfo: mockCheckOs,
198
- checkCliVersion: mockCheckCli,
199
- checkNodeVersion: mockCheckNode,
200
- checkRuntimeInfo: mockCheckRuntime,
201
- checkNpmAvailable: mockCheckNpm,
202
- checkGitAvailable: mockCheckGit,
203
- },
204
- './checks/tools/index.js': {
205
- checkPrinceAvailable: mockCheckPrince,
206
- checkPandocAvailable: mockCheckPandoc,
207
- },
208
- './checks/project/index.js': {
209
- checkQuireProject: mockCheckProject,
210
- checkDependencies: mockCheckDeps,
211
- checkOutdatedQuire11ty: mockCheckQuire11ty,
212
- checkDataFiles: mockCheckData,
213
- },
214
- './checks/outputs/index.js': {
215
- checkStaleBuild: mockCheckStale,
216
- checkPdfOutput: mockCheckPdf,
217
- checkEpubOutput: mockCheckEpub,
218
- },
219
- })
220
-
221
- const results = await runAllChecks()
222
-
223
- t.true(Array.isArray(results))
224
- t.is(results.length, 15)
225
-
226
- // Verify each result has expected shape
227
- for (const result of results) {
228
- t.is(typeof result.name, 'string')
229
- t.is(typeof result.ok, 'boolean')
230
- }
231
-
232
- // Verify all checks were called
233
- t.true(mockCheckOs.calledOnce)
234
- t.true(mockCheckCli.calledOnce)
235
- t.true(mockCheckNode.calledOnce)
236
- t.true(mockCheckRuntime.calledOnce)
237
- t.true(mockCheckNpm.calledOnce)
238
- t.true(mockCheckGit.calledOnce)
239
- t.true(mockCheckPrince.calledOnce)
240
- t.true(mockCheckPandoc.calledOnce)
241
- t.true(mockCheckProject.calledOnce)
242
- t.true(mockCheckDeps.calledOnce)
243
- t.true(mockCheckQuire11ty.calledOnce)
244
- t.true(mockCheckData.calledOnce)
245
- t.true(mockCheckStale.calledOnce)
246
- t.true(mockCheckPdf.calledOnce)
247
- t.true(mockCheckEpub.calledOnce)
248
- })
249
-
250
- test('runAllChecksWithSections returns results organized by 4 sections', async (t) => {
251
- const { sandbox } = t.context
252
-
253
- // Create mock check functions
254
- const mockCheckOs = sandbox.stub().returns({ ok: true, message: 'macOS 14 (arm64)' })
255
- const mockCheckCli = sandbox.stub().returns({ ok: true, message: 'v1.0.0-rc.33' })
256
- const mockCheckNode = sandbox.stub().returns({ ok: true, message: 'v22' })
257
- const mockCheckRuntime = sandbox.stub().returns({ ok: true, message: 'Heap limit: 4096 MB' })
258
- const mockCheckNpm = sandbox.stub().resolves({ ok: true, message: '10.2.4' })
259
- const mockCheckGit = sandbox.stub().resolves({ ok: true, message: '2.43.0' })
260
- const mockCheckPrince = sandbox.stub().returns({ ok: true, message: 'installed' })
261
- const mockCheckPandoc = sandbox.stub().returns({ ok: true, message: 'installed' })
262
- const mockCheckProject = sandbox.stub().returns({ ok: true, message: '.quire' })
263
- const mockCheckDeps = sandbox.stub().returns({ ok: true, message: 'installed' })
264
- const mockCheckQuire11ty = sandbox.stub().resolves({ ok: true, message: 'v1.0.0' })
265
- const mockCheckData = sandbox.stub().returns({ ok: true, message: '3 files' })
266
- const mockCheckStale = sandbox.stub().returns({ ok: true, message: 'up to date' })
267
- const mockCheckPdf = sandbox.stub().returns({ ok: true, message: 'no PDF' })
268
- const mockCheckEpub = sandbox.stub().returns({ ok: true, message: 'no EPUB' })
269
-
270
- const { runAllChecksWithSections } = await esmock('./index.js', {
271
- './checks/environment/index.js': {
272
- checkOsInfo: mockCheckOs,
273
- checkCliVersion: mockCheckCli,
274
- checkNodeVersion: mockCheckNode,
275
- checkRuntimeInfo: mockCheckRuntime,
276
- checkNpmAvailable: mockCheckNpm,
277
- checkGitAvailable: mockCheckGit,
278
- },
279
- './checks/tools/index.js': {
280
- checkPrinceAvailable: mockCheckPrince,
281
- checkPandocAvailable: mockCheckPandoc,
282
- },
283
- './checks/project/index.js': {
284
- checkQuireProject: mockCheckProject,
285
- checkDependencies: mockCheckDeps,
286
- checkOutdatedQuire11ty: mockCheckQuire11ty,
287
- checkDataFiles: mockCheckData,
288
- },
289
- './checks/outputs/index.js': {
290
- checkStaleBuild: mockCheckStale,
291
- checkPdfOutput: mockCheckPdf,
292
- checkEpubOutput: mockCheckEpub,
293
- },
294
- })
295
-
296
- const sections = await runAllChecksWithSections()
297
-
298
- t.true(Array.isArray(sections))
299
- t.is(sections.length, 4)
300
-
301
- // Verify section structure
302
- const sectionNames = sections.map((s) => s.section)
303
- t.deepEqual(sectionNames, ['Environment', 'Tools', 'Project', 'Outputs'])
304
-
305
- // Verify each section has results
306
- for (const { section, results } of sections) {
307
- t.is(typeof section, 'string')
308
- t.true(Array.isArray(results))
309
- for (const result of results) {
310
- t.is(typeof result.name, 'string')
311
- t.is(typeof result.ok, 'boolean')
312
- }
313
- }
314
-
315
- // Verify section sizes
316
- const envSection = sections.find((s) => s.section === 'Environment')
317
- t.is(envSection.results.length, 6)
318
-
319
- const toolsSection = sections.find((s) => s.section === 'Tools')
320
- t.is(toolsSection.results.length, 2)
321
-
322
- const projectSection = sections.find((s) => s.section === 'Project')
323
- t.is(projectSection.results.length, 4)
324
-
325
- const outputsSection = sections.find((s) => s.section === 'Outputs')
326
- t.is(outputsSection.results.length, 3)
327
- })
328
-
329
- test('runAllChecksWithSections filters by section name', async (t) => {
330
- const { sandbox } = t.context
331
-
332
- // Create mock check functions
333
- const mockCheckOs = sandbox.stub().returns({ ok: true, message: 'macOS 14 (arm64)' })
334
- const mockCheckCli = sandbox.stub().returns({ ok: true, message: 'v1.0.0-rc.33' })
335
- const mockCheckNode = sandbox.stub().returns({ ok: true, message: 'v22' })
336
- const mockCheckRuntime = sandbox.stub().returns({ ok: true, message: 'Heap limit: 4096 MB' })
337
- const mockCheckNpm = sandbox.stub().resolves({ ok: true, message: '10.2.4' })
338
- const mockCheckGit = sandbox.stub().resolves({ ok: true, message: '2.43.0' })
339
- const mockCheckPrince = sandbox.stub().returns({ ok: true, message: 'installed' })
340
- const mockCheckPandoc = sandbox.stub().returns({ ok: true, message: 'installed' })
341
- const mockCheckProject = sandbox.stub().returns({ ok: true, message: '.quire' })
342
- const mockCheckDeps = sandbox.stub().returns({ ok: true, message: 'installed' })
343
- const mockCheckQuire11ty = sandbox.stub().resolves({ ok: true, message: 'v1.0.0' })
344
- const mockCheckData = sandbox.stub().returns({ ok: true, message: '3 files' })
345
- const mockCheckStale = sandbox.stub().returns({ ok: true, message: 'up to date' })
346
- const mockCheckPdf = sandbox.stub().returns({ ok: true, message: 'no PDF' })
347
- const mockCheckEpub = sandbox.stub().returns({ ok: true, message: 'no EPUB' })
348
-
349
- const { runAllChecksWithSections } = await esmock('./index.js', {
350
- './checks/environment/index.js': {
351
- checkOsInfo: mockCheckOs,
352
- checkCliVersion: mockCheckCli,
353
- checkNodeVersion: mockCheckNode,
354
- checkRuntimeInfo: mockCheckRuntime,
355
- checkNpmAvailable: mockCheckNpm,
356
- checkGitAvailable: mockCheckGit,
357
- },
358
- './checks/tools/index.js': {
359
- checkPrinceAvailable: mockCheckPrince,
360
- checkPandocAvailable: mockCheckPandoc,
361
- },
362
- './checks/project/index.js': {
363
- checkQuireProject: mockCheckProject,
364
- checkDependencies: mockCheckDeps,
365
- checkOutdatedQuire11ty: mockCheckQuire11ty,
366
- checkDataFiles: mockCheckData,
367
- },
368
- './checks/outputs/index.js': {
369
- checkStaleBuild: mockCheckStale,
370
- checkPdfOutput: mockCheckPdf,
371
- checkEpubOutput: mockCheckEpub,
372
- },
373
- })
374
-
375
- // Filter to environment section only (legacy array syntax)
376
- const sections = await runAllChecksWithSections(['environment'])
377
-
378
- t.is(sections.length, 1)
379
- t.is(sections[0].section, 'Environment')
380
- t.is(sections[0].results.length, 6)
381
-
382
- // Verify only environment checks were called
383
- t.true(mockCheckOs.calledOnce)
384
- t.true(mockCheckCli.calledOnce)
385
- t.true(mockCheckNode.calledOnce)
386
- t.true(mockCheckRuntime.calledOnce)
387
- t.true(mockCheckNpm.calledOnce)
388
- t.true(mockCheckGit.calledOnce)
389
-
390
- // Verify tools, project, and output checks were NOT called
391
- t.false(mockCheckPrince.called)
392
- t.false(mockCheckPandoc.called)
393
- t.false(mockCheckProject.called)
394
- t.false(mockCheckDeps.called)
395
- t.false(mockCheckQuire11ty.called)
396
- t.false(mockCheckData.called)
397
- t.false(mockCheckStale.called)
398
- t.false(mockCheckPdf.called)
399
- t.false(mockCheckEpub.called)
400
- })
401
-
402
- test('runAllChecksWithSections filters by check ID', async (t) => {
403
- const { sandbox } = t.context
404
-
405
- // Create mock check functions
406
- const mockCheckOs = sandbox.stub().returns({ ok: true, message: 'macOS 14 (arm64)' })
407
- const mockCheckCli = sandbox.stub().returns({ ok: true, message: 'v1.0.0-rc.33' })
408
- const mockCheckNode = sandbox.stub().returns({ ok: true, message: 'v22' })
409
- const mockCheckRuntime = sandbox.stub().returns({ ok: true, message: 'Heap limit: 4096 MB' })
410
- const mockCheckNpm = sandbox.stub().resolves({ ok: true, message: '10.2.4' })
411
- const mockCheckGit = sandbox.stub().resolves({ ok: true, message: '2.43.0' })
412
- const mockCheckPrince = sandbox.stub().returns({ ok: true, message: 'installed' })
413
- const mockCheckPandoc = sandbox.stub().returns({ ok: true, message: 'installed' })
414
- const mockCheckProject = sandbox.stub().returns({ ok: true, message: '.quire' })
415
- const mockCheckDeps = sandbox.stub().returns({ ok: true, message: 'installed' })
416
- const mockCheckQuire11ty = sandbox.stub().resolves({ ok: true, message: 'v1.0.0' })
417
- const mockCheckData = sandbox.stub().returns({ ok: true, message: '3 files' })
418
- const mockCheckStale = sandbox.stub().returns({ ok: true, message: 'up to date' })
419
- const mockCheckPdf = sandbox.stub().returns({ ok: true, message: 'no PDF' })
420
- const mockCheckEpub = sandbox.stub().returns({ ok: true, message: 'no EPUB' })
421
-
422
- const { runAllChecksWithSections } = await esmock('./index.js', {
423
- './checks/environment/index.js': {
424
- checkOsInfo: mockCheckOs,
425
- checkCliVersion: mockCheckCli,
426
- checkNodeVersion: mockCheckNode,
427
- checkRuntimeInfo: mockCheckRuntime,
428
- checkNpmAvailable: mockCheckNpm,
429
- checkGitAvailable: mockCheckGit,
430
- },
431
- './checks/tools/index.js': {
432
- checkPrinceAvailable: mockCheckPrince,
433
- checkPandocAvailable: mockCheckPandoc,
434
- },
435
- './checks/project/index.js': {
436
- checkQuireProject: mockCheckProject,
437
- checkDependencies: mockCheckDeps,
438
- checkOutdatedQuire11ty: mockCheckQuire11ty,
439
- checkDataFiles: mockCheckData,
440
- },
441
- './checks/outputs/index.js': {
442
- checkStaleBuild: mockCheckStale,
443
- checkPdfOutput: mockCheckPdf,
444
- checkEpubOutput: mockCheckEpub,
445
- },
446
- })
447
-
448
- // Filter to specific checks by ID (node and git from Environment)
449
- const sections = await runAllChecksWithSections({ checks: ['node', 'git'] })
450
-
451
- t.is(sections.length, 1)
452
- t.is(sections[0].section, 'Environment')
453
- t.is(sections[0].results.length, 2)
454
-
455
- // Verify result names match the requested checks
456
- const resultNames = sections[0].results.map((r) => r.name)
457
- t.true(resultNames.includes('Node.js version'))
458
- t.true(resultNames.includes('Git'))
459
-
460
- // Verify only requested checks were called
461
- t.true(mockCheckNode.calledOnce)
462
- t.true(mockCheckGit.calledOnce)
463
-
464
- // Verify other checks were NOT called
465
- t.false(mockCheckOs.called)
466
- t.false(mockCheckCli.called)
467
- t.false(mockCheckRuntime.called)
468
- t.false(mockCheckNpm.called)
469
- t.false(mockCheckPrince.called)
470
- t.false(mockCheckPandoc.called)
471
- t.false(mockCheckProject.called)
472
- t.false(mockCheckDeps.called)
473
- t.false(mockCheckQuire11ty.called)
474
- t.false(mockCheckData.called)
475
- t.false(mockCheckStale.called)
476
- t.false(mockCheckPdf.called)
477
- t.false(mockCheckEpub.called)
478
- })
479
-
480
- test('runAllChecksWithSections filters checks across multiple sections', async (t) => {
481
- const { sandbox } = t.context
482
-
483
- // Create mock check functions
484
- const mockCheckOs = sandbox.stub().returns({ ok: true, message: 'macOS 14 (arm64)' })
485
- const mockCheckCli = sandbox.stub().returns({ ok: true, message: 'v1.0.0-rc.33' })
486
- const mockCheckNode = sandbox.stub().returns({ ok: true, message: 'v22' })
487
- const mockCheckRuntime = sandbox.stub().returns({ ok: true, message: 'Heap limit: 4096 MB' })
488
- const mockCheckNpm = sandbox.stub().resolves({ ok: true, message: '10.2.4' })
489
- const mockCheckGit = sandbox.stub().resolves({ ok: true, message: '2.43.0' })
490
- const mockCheckPrince = sandbox.stub().returns({ ok: true, message: 'installed' })
491
- const mockCheckPandoc = sandbox.stub().returns({ ok: true, message: 'installed' })
492
- const mockCheckProject = sandbox.stub().returns({ ok: true, message: '.quire' })
493
- const mockCheckDeps = sandbox.stub().returns({ ok: true, message: 'installed' })
494
- const mockCheckQuire11ty = sandbox.stub().resolves({ ok: true, message: 'v1.0.0' })
495
- const mockCheckData = sandbox.stub().returns({ ok: true, message: '3 files' })
496
- const mockCheckStale = sandbox.stub().returns({ ok: true, message: 'up to date' })
497
- const mockCheckPdf = sandbox.stub().returns({ ok: true, message: 'no PDF' })
498
- const mockCheckEpub = sandbox.stub().returns({ ok: true, message: 'no EPUB' })
499
-
500
- const { runAllChecksWithSections } = await esmock('./index.js', {
501
- './checks/environment/index.js': {
502
- checkOsInfo: mockCheckOs,
503
- checkCliVersion: mockCheckCli,
504
- checkNodeVersion: mockCheckNode,
505
- checkRuntimeInfo: mockCheckRuntime,
506
- checkNpmAvailable: mockCheckNpm,
507
- checkGitAvailable: mockCheckGit,
508
- },
509
- './checks/tools/index.js': {
510
- checkPrinceAvailable: mockCheckPrince,
511
- checkPandocAvailable: mockCheckPandoc,
512
- },
513
- './checks/project/index.js': {
514
- checkQuireProject: mockCheckProject,
515
- checkDependencies: mockCheckDeps,
516
- checkOutdatedQuire11ty: mockCheckQuire11ty,
517
- checkDataFiles: mockCheckData,
518
- },
519
- './checks/outputs/index.js': {
520
- checkStaleBuild: mockCheckStale,
521
- checkPdfOutput: mockCheckPdf,
522
- checkEpubOutput: mockCheckEpub,
523
- },
524
- })
525
-
526
- // Filter to checks from different sections (node from Environment, pdf from Outputs)
527
- const sections = await runAllChecksWithSections({ checks: ['node', 'pdf'] })
528
-
529
- t.is(sections.length, 2)
530
-
531
- // Verify Environment section has only node check
532
- const envSection = sections.find((s) => s.section === 'Environment')
533
- t.truthy(envSection)
534
- t.is(envSection.results.length, 1)
535
- t.is(envSection.results[0].name, 'Node.js version')
536
-
537
- // Verify Outputs section has only pdf check
538
- const outputsSection = sections.find((s) => s.section === 'Outputs')
539
- t.truthy(outputsSection)
540
- t.is(outputsSection.results.length, 1)
541
- t.is(outputsSection.results[0].name, 'PDF output')
542
-
543
- // Verify only requested checks were called
544
- t.true(mockCheckNode.calledOnce)
545
- t.true(mockCheckPdf.calledOnce)
546
-
547
- // Project and Tools sections should not appear (no checks from them)
548
- const projectSection = sections.find((s) => s.section === 'Project')
549
- t.falsy(projectSection)
550
- const toolsSection = sections.find((s) => s.section === 'Tools')
551
- t.falsy(toolsSection)
552
- })
553
-
554
- test('runAllChecks handles async checks correctly', async (t) => {
555
- const { sandbox } = t.context
556
-
557
- // Mix of sync and async checks
558
- const mockSyncCheck = sandbox.stub().returns({ ok: true, message: 'sync' })
559
- const mockAsyncCheck = sandbox.stub().resolves({ ok: false, level: 'warn', message: 'async' })
560
-
561
- const { runAllChecks } = await esmock('./index.js', {
562
- './checks/environment/index.js': {
563
- checkOsInfo: mockSyncCheck,
564
- checkCliVersion: mockSyncCheck,
565
- checkNodeVersion: mockSyncCheck,
566
- checkRuntimeInfo: mockSyncCheck,
567
- checkNpmAvailable: mockAsyncCheck,
568
- checkGitAvailable: mockAsyncCheck,
569
- },
570
- './checks/tools/index.js': {
571
- checkPrinceAvailable: mockSyncCheck,
572
- checkPandocAvailable: mockSyncCheck,
573
- },
574
- './checks/project/index.js': {
575
- checkQuireProject: mockSyncCheck,
576
- checkDependencies: mockSyncCheck,
577
- checkOutdatedQuire11ty: mockAsyncCheck,
578
- checkDataFiles: mockSyncCheck,
579
- },
580
- './checks/outputs/index.js': {
581
- checkStaleBuild: mockSyncCheck,
582
- checkPdfOutput: mockSyncCheck,
583
- checkEpubOutput: mockSyncCheck,
584
- },
585
- })
586
-
587
- const results = await runAllChecks()
588
-
589
- t.is(results.length, 15)
590
-
591
- // Verify async results are properly awaited
592
- const asyncResults = results.filter((r) => r.message === 'async')
593
- t.is(asyncResults.length, 3)
594
- for (const result of asyncResults) {
595
- t.false(result.ok)
596
- t.is(result.level, 'warn')
597
- }
598
- })
599
-
600
- test('runAllChecks preserves all check result properties', async (t) => {
601
- const { sandbox } = t.context
602
-
603
- const fullResult = {
604
- ok: false,
605
- level: 'warn',
606
- message: 'Test message',
607
- remediation: 'Fix steps',
608
- docsUrl: 'https://example.com',
609
- }
610
-
611
- const { runAllChecks } = await esmock('./index.js', {
612
- './checks/environment/index.js': {
613
- checkOsInfo: sandbox.stub().returns({ ok: true, message: 'macOS 14' }),
614
- checkCliVersion: sandbox.stub().returns(fullResult),
615
- checkNodeVersion: sandbox.stub().returns({ ok: true, message: null }),
616
- checkRuntimeInfo: sandbox.stub().returns({ ok: true, message: 'Heap limit: 4096 MB' }),
617
- checkNpmAvailable: sandbox.stub().resolves({ ok: true, message: '10.2.4' }),
618
- checkGitAvailable: sandbox.stub().resolves({ ok: true, message: '2.43.0' }),
619
- },
620
- './checks/tools/index.js': {
621
- checkPrinceAvailable: sandbox.stub().returns({ ok: true, message: 'installed' }),
622
- checkPandocAvailable: sandbox.stub().returns({ ok: true, message: 'installed' }),
623
- },
624
- './checks/project/index.js': {
625
- checkQuireProject: sandbox.stub().returns({ ok: true, message: null }),
626
- checkDependencies: sandbox.stub().returns({ ok: true, message: 'installed' }),
627
- checkOutdatedQuire11ty: sandbox.stub().resolves({ ok: true, message: null }),
628
- checkDataFiles: sandbox.stub().returns({ ok: true, message: null }),
629
- },
630
- './checks/outputs/index.js': {
631
- checkStaleBuild: sandbox.stub().returns({ ok: true, message: null }),
632
- checkPdfOutput: sandbox.stub().returns({ ok: true, message: null }),
633
- checkEpubOutput: sandbox.stub().returns({ ok: true, message: null }),
634
- },
635
- })
636
-
637
- const results = await runAllChecks()
638
- const cliResult = results.find((r) => r.name === 'Quire CLI version')
639
-
640
- t.false(cliResult.ok)
641
- t.is(cliResult.level, 'warn')
642
- t.is(cliResult.message, 'Test message')
643
- t.is(cliResult.remediation, 'Fix steps')
644
- t.is(cliResult.docsUrl, 'https://example.com')
645
- })
646
-
647
- // ─────────────────────────────────────────────────────────────────────────────
648
- // Timeout tests
649
- // ─────────────────────────────────────────────────────────────────────────────
650
-
651
- test('DEFAULT_CHECK_TIMEOUT is exported and has reasonable value', async (t) => {
652
- const { DEFAULT_CHECK_TIMEOUT } = await import('./index.js')
653
-
654
- t.is(typeof DEFAULT_CHECK_TIMEOUT, 'number')
655
- t.is(DEFAULT_CHECK_TIMEOUT, 10000, 'default timeout should be 10 seconds')
656
- })
657
-
658
- test('runAllChecksWithSections handles slow checks with timeout', async (t) => {
659
- const { sandbox } = t.context
660
-
661
- // Create a check that takes longer than the timeout
662
- const slowCheck = sandbox.stub().callsFake(() =>
663
- new Promise((resolve) => setTimeout(() => resolve({ ok: true, message: 'slow' }), 200))
664
- )
665
- const fastCheck = sandbox.stub().returns({ ok: true, message: 'fast' })
666
-
667
- const { runAllChecksWithSections } = await esmock('./index.js', {
668
- './checks/environment/index.js': {
669
- checkOsInfo: fastCheck,
670
- checkCliVersion: fastCheck,
671
- checkNodeVersion: slowCheck,
672
- checkRuntimeInfo: fastCheck,
673
- checkNpmAvailable: fastCheck,
674
- checkGitAvailable: fastCheck,
675
- },
676
- './checks/tools/index.js': {
677
- checkPrinceAvailable: fastCheck,
678
- checkPandocAvailable: fastCheck,
679
- },
680
- './checks/project/index.js': {
681
- checkQuireProject: fastCheck,
682
- checkDependencies: fastCheck,
683
- checkOutdatedQuire11ty: fastCheck,
684
- checkDataFiles: fastCheck,
685
- },
686
- './checks/outputs/index.js': {
687
- checkStaleBuild: fastCheck,
688
- checkPdfOutput: fastCheck,
689
- checkEpubOutput: fastCheck,
690
- },
691
- })
692
-
693
- // Use a very short timeout (50ms) to trigger the timeout
694
- const sections = await runAllChecksWithSections({ checks: ['node'], timeout: 50 })
695
-
696
- t.is(sections.length, 1)
697
- const nodeResult = sections[0].results[0]
698
-
699
- // Should have timed out
700
- t.false(nodeResult.ok)
701
- t.is(nodeResult.level, 'timeout')
702
- t.regex(nodeResult.message, /skipped.*timed out/)
703
- t.truthy(nodeResult.remediation)
704
- })
705
-
706
- test('runAllChecksWithSections completes checks within timeout', async (t) => {
707
- const { sandbox } = t.context
708
-
709
- // Create a check that completes quickly
710
- const fastCheck = sandbox.stub().returns({ ok: true, message: 'fast' })
711
-
712
- const { runAllChecksWithSections } = await esmock('./index.js', {
713
- './checks/environment/index.js': {
714
- checkOsInfo: fastCheck,
715
- checkCliVersion: fastCheck,
716
- checkNodeVersion: fastCheck,
717
- checkRuntimeInfo: fastCheck,
718
- checkNpmAvailable: fastCheck,
719
- checkGitAvailable: fastCheck,
720
- },
721
- './checks/tools/index.js': {
722
- checkPrinceAvailable: fastCheck,
723
- checkPandocAvailable: fastCheck,
724
- },
725
- './checks/project/index.js': {
726
- checkQuireProject: fastCheck,
727
- checkDependencies: fastCheck,
728
- checkOutdatedQuire11ty: fastCheck,
729
- checkDataFiles: fastCheck,
730
- },
731
- './checks/outputs/index.js': {
732
- checkStaleBuild: fastCheck,
733
- checkPdfOutput: fastCheck,
734
- checkEpubOutput: fastCheck,
735
- },
736
- })
737
-
738
- // Use a long timeout - check should complete well before
739
- const sections = await runAllChecksWithSections({ checks: ['node'], timeout: 5000 })
740
-
741
- t.is(sections.length, 1)
742
- const nodeResult = sections[0].results[0]
743
-
744
- // Should have completed successfully
745
- t.true(nodeResult.ok)
746
- t.is(nodeResult.message, 'fast')
747
- })
748
-
749
- test('runAllChecksWithSections includes check id in results', async (t) => {
750
- const { sandbox } = t.context
751
-
752
- const fastCheck = sandbox.stub().returns({ ok: true, message: 'fast' })
753
-
754
- const { runAllChecksWithSections } = await esmock('./index.js', {
755
- './checks/environment/index.js': {
756
- checkOsInfo: fastCheck,
757
- checkCliVersion: fastCheck,
758
- checkNodeVersion: fastCheck,
759
- checkRuntimeInfo: fastCheck,
760
- checkNpmAvailable: fastCheck,
761
- checkGitAvailable: fastCheck,
762
- },
763
- './checks/tools/index.js': {
764
- checkPrinceAvailable: fastCheck,
765
- checkPandocAvailable: fastCheck,
766
- },
767
- './checks/project/index.js': {
768
- checkQuireProject: fastCheck,
769
- checkDependencies: fastCheck,
770
- checkOutdatedQuire11ty: fastCheck,
771
- checkDataFiles: fastCheck,
772
- },
773
- './checks/outputs/index.js': {
774
- checkStaleBuild: fastCheck,
775
- checkPdfOutput: fastCheck,
776
- checkEpubOutput: fastCheck,
777
- },
778
- })
779
-
780
- const sections = await runAllChecksWithSections({ checks: ['node', 'npm'] })
781
-
782
- // Each result should have an id property
783
- for (const { results } of sections) {
784
- for (const result of results) {
785
- t.truthy(result.id, 'result should have id property')
786
- t.is(typeof result.id, 'string')
787
- }
788
- }
789
-
790
- // Verify specific IDs
791
- const envSection = sections.find((s) => s.section === 'Environment')
792
- const nodeResult = envSection.results.find((r) => r.name === 'Node.js version')
793
- const npmResult = envSection.results.find((r) => r.name === 'npm')
794
-
795
- t.is(nodeResult.id, 'node')
796
- t.is(npmResult.id, 'npm')
797
- })