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

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,90 +0,0 @@
1
- import { Command, Option } from 'commander'
2
- import program from '#src/main.js'
3
- import test from 'ava'
4
-
5
- /**
6
- * Command Contract/Interface Tests
7
- *
8
- * Verifies the command's public API and Commander.js integration.
9
- * @see docs/testing-commands.md
10
- */
11
-
12
- test.before((t) => {
13
- // Get the registered command (from program.commands) once and share across all tests
14
- t.context.command = program.commands.find((cmd) => cmd.name() === 'validate')
15
- })
16
-
17
- test('command is registered in CLI program', (t) => {
18
- const { command } = t.context
19
-
20
- t.truthy(command, 'command "validate" should be registered in program')
21
- t.true(command instanceof Command, 'registered command should be Commander.js Command instance')
22
- })
23
-
24
- test('registered command has correct metadata', (t) => {
25
- const { command } = t.context
26
-
27
- t.is(command.name(), 'validate')
28
- t.truthy(command.description())
29
- t.is(typeof command._actionHandler, 'function', 'command should have action handler')
30
- })
31
-
32
- test('registered command has no arguments', (t) => {
33
- const { command } = t.context
34
- const registeredArguments = command.registeredArguments
35
-
36
- t.is(registeredArguments.length, 0, 'validate command should have no arguments')
37
- })
38
-
39
- test('registered command has correct options', (t) => {
40
- const { command } = t.context
41
-
42
- // Get all options
43
- const jsonOption = command.options.find((opt) => opt.long === '--json')
44
- const quietOption = command.options.find((opt) => opt.long === '--quiet')
45
- const verboseOption = command.options.find((opt) => opt.long === '--verbose')
46
- const debugOption = command.options.find((opt) => opt.long === '--debug')
47
-
48
- // Verify all options exist
49
- t.truthy(jsonOption, '--json option should exist')
50
- t.truthy(quietOption, '--quiet option should exist')
51
- t.truthy(verboseOption, '--verbose option should exist')
52
- t.truthy(debugOption, '--debug option should exist')
53
-
54
- // Verify they are Option instances
55
- t.true(jsonOption instanceof Option, '--json should be Option instance')
56
- t.true(quietOption instanceof Option, '--quiet should be Option instance')
57
- t.true(verboseOption instanceof Option, '--verbose should be Option instance')
58
- t.true(debugOption instanceof Option, '--debug should be Option instance')
59
-
60
- // Verify option properties
61
- t.is(jsonOption.long, '--json')
62
- t.truthy(jsonOption.description)
63
- t.false(jsonOption.required, '--json should not require a value')
64
-
65
- t.is(quietOption.long, '--quiet')
66
- t.is(quietOption.short, '-q')
67
- t.truthy(quietOption.description)
68
- t.false(quietOption.required, '--quiet should not require a value')
69
-
70
- t.is(verboseOption.long, '--verbose')
71
- t.is(verboseOption.short, '-v')
72
- t.truthy(verboseOption.description)
73
- t.false(verboseOption.required, '--verbose should not require a value')
74
-
75
- t.is(debugOption.long, '--debug')
76
- t.truthy(debugOption.description)
77
- t.false(debugOption.required, '--debug should not require a value')
78
- })
79
-
80
- test('command options are accessible via public API', (t) => {
81
- const { command } = t.context
82
-
83
- // Test that options can be accessed the way Commander.js does
84
- const optionNames = command.options.map((opt) => opt.long)
85
-
86
- t.true(optionNames.includes('--json'))
87
- t.true(optionNames.includes('--quiet'))
88
- t.true(optionNames.includes('--verbose'))
89
- t.true(optionNames.includes('--debug'))
90
- })
@@ -1,378 +0,0 @@
1
- import test from 'ava'
2
- import { Volume, createFsFromVolume } from 'memfs'
3
- import sinon from 'sinon'
4
- import esmock from 'esmock'
5
- import { ValidationError } from '#src/errors/index.js'
6
-
7
- test.beforeEach((t) => {
8
- // Create sinon sandbox for mocking
9
- t.context.sandbox = sinon.createSandbox()
10
-
11
- // Create in-memory file system
12
- t.context.vol = new Volume()
13
- t.context.fs = createFsFromVolume(t.context.vol)
14
-
15
- // Setup mock directory structure
16
- t.context.vol.fromJSON({
17
- '/project/content/_data/config.yaml': 'title: Quire Test Project\nidentifier:\n isbn: "978-0-12345-678-9"',
18
- '/project/content/_data/publication.yaml': 'title: Test Publication',
19
- '/project/package.json': JSON.stringify({ name: 'test-project' })
20
- })
21
-
22
- t.context.projectRoot = '/project'
23
-
24
- // Stub console methods to suppress output during tests
25
- // Create mock logger (no global console stubbing needed!)
26
- t.context.mockLogger = {
27
- info: t.context.sandbox.stub(),
28
- error: t.context.sandbox.stub(),
29
- debug: t.context.sandbox.stub(),
30
- log: t.context.sandbox.stub(),
31
- warn: t.context.sandbox.stub()
32
- }
33
- // mockLogger already created above
34
- // mockLogger already created above
35
- })
36
-
37
- test.afterEach.always((t) => {
38
- // Restore all mocks
39
- t.context.sandbox.restore()
40
-
41
- // Clear in-memory file system
42
- t.context.vol.reset()
43
- })
44
-
45
- test('validate command should find and validate YAML files', async (t) => {
46
- const { sandbox, fs, mockLogger } = t.context
47
-
48
- // Mock yamlValidation function
49
- const mockYamlValidation = sandbox.stub()
50
-
51
- // Mock testcwd helper
52
- const mockTestcwd = sandbox.stub()
53
-
54
- // Use esmock to replace imports
55
- const ValidateCommand = await esmock('./validate.js', {
56
- '../validators/validate-yaml.js': {
57
- default: mockYamlValidation
58
- },
59
- '#lib/project/index.js': {
60
- default: { getProjectRoot: () => '/project' }
61
- },
62
- '#helpers/test-cwd.js': {
63
- default: mockTestcwd
64
- },
65
- '#lib/logger/index.js': {
66
- logger: mockLogger
67
- },
68
- 'fs-extra': fs
69
- })
70
-
71
- const command = new ValidateCommand()
72
- command.name = sandbox.stub().returns('validate')
73
-
74
- // Run action
75
- command.action({}, command)
76
-
77
- // Should validate both YAML files
78
- t.true(mockYamlValidation.callCount >= 2, 'should validate multiple YAML files')
79
- })
80
-
81
- test('validate command should handle validation errors', async (t) => {
82
- const { sandbox, fs, mockLogger } = t.context
83
-
84
- // Mock yamlValidation function to throw error
85
- const validationError = new Error('Invalid YAML')
86
- validationError.reason = 'Invalid YAML: missing required field'
87
- const mockYamlValidation = sandbox.stub().throws(validationError)
88
-
89
- // Mock testcwd helper
90
- const mockTestcwd = sandbox.stub()
91
-
92
- // Use esmock to replace imports
93
- const ValidateCommand = await esmock('./validate.js', {
94
- '../validators/validate-yaml.js': {
95
- default: mockYamlValidation
96
- },
97
- '#lib/project/index.js': {
98
- default: { getProjectRoot: () => '/project' }
99
- },
100
- '#helpers/test-cwd.js': {
101
- default: mockTestcwd
102
- },
103
- '#lib/logger/index.js': {
104
- logger: mockLogger
105
- },
106
- 'fs-extra': fs
107
- })
108
-
109
- const command = new ValidateCommand()
110
- command.name = sandbox.stub().returns('validate')
111
- command.logger = mockLogger
112
-
113
- // Run action - should throw ValidationError when there are validation errors
114
- const error = t.throws(() => command.action({}, command), { instanceOf: ValidationError })
115
-
116
- t.is(error.code, 'VALIDATION_FAILED', 'error should have correct code')
117
- t.is(error.exitCode, 4, 'error should have validation exit code')
118
- t.true(mockYamlValidation.called, 'validation should be attempted')
119
- t.true(mockLogger.error.called, 'errors should be logged')
120
- })
121
-
122
- test('validate command should call testcwd in preAction', async (t) => {
123
- const { sandbox, fs, mockLogger } = t.context
124
-
125
- // Mock yamlValidation function
126
- const mockYamlValidation = sandbox.stub()
127
-
128
- // Mock testcwd helper
129
- const mockTestcwd = sandbox.stub()
130
-
131
- // Use esmock to replace imports
132
- const ValidateCommand = await esmock('./validate.js', {
133
- '../validators/validate-yaml.js': {
134
- default: mockYamlValidation
135
- },
136
- '#lib/project/index.js': {
137
- default: { getProjectRoot: () => '/project' }
138
- },
139
- '#helpers/test-cwd.js': {
140
- default: mockTestcwd
141
- },
142
- '#lib/logger/index.js': {
143
- logger: mockLogger
144
- },
145
- 'fs-extra': fs
146
- })
147
-
148
- const command = new ValidateCommand()
149
- command.name = sandbox.stub().returns('validate')
150
-
151
- // Run preAction
152
- command.preAction({}, command)
153
-
154
- t.true(mockTestcwd.called, 'testcwd should be called in preAction')
155
- })
156
-
157
- test('validate command should filter YAML files correctly', async (t) => {
158
- const { sandbox, fs, vol, mockLogger } = t.context
159
-
160
- // Add non-YAML files
161
- vol.fromJSON({
162
- '/project/content/_data/data.json': '{"key": "value"}',
163
- '/project/content/_data/README.md': '# README',
164
- '/project/content/_data/script.js': 'console.log("test")'
165
- })
166
-
167
- // Mock yamlValidation function
168
- const mockYamlValidation = sandbox.stub()
169
-
170
- // Mock testcwd helper
171
- const mockTestcwd = sandbox.stub()
172
-
173
- // Use esmock to replace imports
174
- const ValidateCommand = await esmock('./validate.js', {
175
- '../validators/validate-yaml.js': {
176
- default: mockYamlValidation
177
- },
178
- '#lib/project/index.js': {
179
- default: { getProjectRoot: () => '/project' }
180
- },
181
- '#helpers/test-cwd.js': {
182
- default: mockTestcwd
183
- },
184
- '#lib/logger/index.js': {
185
- logger: mockLogger
186
- },
187
- 'fs-extra': fs
188
- })
189
-
190
- const command = new ValidateCommand()
191
- command.name = sandbox.stub().returns('validate')
192
-
193
- // Run action
194
- command.action({}, command)
195
-
196
- // Should only validate YAML files (config.yaml and publication.yaml from beforeEach)
197
- t.is(mockYamlValidation.callCount, 2, 'should only validate YAML files')
198
- })
199
-
200
- test('validate command should pass debug option through', async (t) => {
201
- const { sandbox, fs, mockLogger } = t.context
202
-
203
- // Mock yamlValidation function
204
- const mockYamlValidation = sandbox.stub()
205
-
206
- // Mock testcwd helper
207
- const mockTestcwd = sandbox.stub()
208
-
209
- // Use esmock to replace imports
210
- const ValidateCommand = await esmock('./validate.js', {
211
- '../validators/validate-yaml.js': {
212
- default: mockYamlValidation
213
- },
214
- '#lib/project/index.js': {
215
- default: { getProjectRoot: () => '/project' }
216
- },
217
- '#helpers/test-cwd.js': {
218
- default: mockTestcwd
219
- },
220
- '#lib/logger/index.js': {
221
- logger: mockLogger
222
- },
223
- 'fs-extra': fs
224
- })
225
-
226
- const command = new ValidateCommand()
227
- command.name = sandbox.stub().returns('validate')
228
-
229
- // Run action with debug option
230
- command.action({ debug: true }, command)
231
-
232
- t.true(mockYamlValidation.called, 'validation should run')
233
- // Debug output should be logged (verified through console.debug stub)
234
- })
235
-
236
- // ─────────────────────────────────────────────────────────────────────────────
237
- // JSON output tests
238
- // ─────────────────────────────────────────────────────────────────────────────
239
-
240
- test.serial('validate --json should output valid JSON when all files pass', async (t) => {
241
- const { sandbox, fs, mockLogger } = t.context
242
- const consoleLogStub = sandbox.stub(console, 'log')
243
-
244
- const mockYamlValidation = sandbox.stub()
245
- const mockTestcwd = sandbox.stub()
246
-
247
- const ValidateCommand = await esmock('./validate.js', {
248
- '../validators/validate-yaml.js': {
249
- default: mockYamlValidation
250
- },
251
- '#lib/project/index.js': {
252
- default: { getProjectRoot: () => '/project' }
253
- },
254
- '#helpers/test-cwd.js': {
255
- default: mockTestcwd
256
- },
257
- '#lib/logger/index.js': {
258
- logger: mockLogger
259
- },
260
- 'fs-extra': fs
261
- })
262
-
263
- const command = new ValidateCommand()
264
- command.name = sandbox.stub().returns('validate')
265
-
266
- command.action({ json: true }, command)
267
-
268
- // Should output via console.log, not logger.info
269
- t.true(consoleLogStub.calledOnce, 'console.log should be called once')
270
- t.false(mockLogger.info.called, 'logger.info should not be called in JSON mode')
271
-
272
- const output = JSON.parse(consoleLogStub.firstCall.args[0])
273
-
274
- // Verify JSON structure
275
- t.truthy(output.summary, 'JSON should have summary section')
276
- t.truthy(output.files, 'JSON should have files section')
277
- t.is(output.summary.files, 2, 'should report 2 YAML files')
278
- t.is(output.summary.passed, 2, 'both files should pass')
279
- t.is(output.summary.failed, 0, 'no files should fail')
280
-
281
- // Verify each file result
282
- t.true(output.files.every((f) => f.status === 'passed'), 'all files should have passed status')
283
- })
284
-
285
- test.serial('validate --json should output valid JSON with errors and throw', async (t) => {
286
- const { sandbox, fs, mockLogger } = t.context
287
- const consoleLogStub = sandbox.stub(console, 'log')
288
-
289
- const validationError = new Error('Invalid YAML')
290
- validationError.reason = 'Invalid YAML: missing required field'
291
- const mockYamlValidation = sandbox.stub().throws(validationError)
292
- const mockTestcwd = sandbox.stub()
293
-
294
- const ValidateCommand = await esmock('./validate.js', {
295
- '../validators/validate-yaml.js': {
296
- default: mockYamlValidation
297
- },
298
- '#lib/project/index.js': {
299
- default: { getProjectRoot: () => '/project' }
300
- },
301
- '#helpers/test-cwd.js': {
302
- default: mockTestcwd
303
- },
304
- '#lib/logger/index.js': {
305
- logger: mockLogger
306
- },
307
- 'fs-extra': fs
308
- })
309
-
310
- const command = new ValidateCommand()
311
- command.name = sandbox.stub().returns('validate')
312
- command.logger = mockLogger
313
-
314
- // Should still throw ValidationError for exit code
315
- const error = t.throws(() => command.action({ json: true }, command), { instanceOf: ValidationError })
316
- t.is(error.code, 'VALIDATION_FAILED')
317
-
318
- // Should output JSON before throwing
319
- t.true(consoleLogStub.calledOnce, 'console.log should be called once')
320
-
321
- const output = JSON.parse(consoleLogStub.firstCall.args[0])
322
-
323
- t.is(output.summary.files, 2)
324
- t.is(output.summary.failed, 2, 'both files should fail')
325
- t.is(output.summary.passed, 0)
326
-
327
- // Verify error details in file results
328
- t.true(output.files.every((f) => f.status === 'failed'), 'all files should have failed status')
329
- t.true(output.files.every((f) => f.error), 'all failed files should have error details')
330
-
331
- // logger.error should NOT be called in JSON mode
332
- t.false(mockLogger.error.called, 'logger.error should not be called in JSON mode')
333
- })
334
-
335
- test.serial('validate --json should output mixed results', async (t) => {
336
- const { sandbox, fs, mockLogger } = t.context
337
- const consoleLogStub = sandbox.stub(console, 'log')
338
-
339
- // First file passes, second file fails
340
- const validationError = new Error('Invalid YAML')
341
- validationError.reason = 'duplicated mapping key at line 5'
342
- const mockYamlValidation = sandbox.stub()
343
- mockYamlValidation.onFirstCall().returns(undefined)
344
- mockYamlValidation.onSecondCall().throws(validationError)
345
- const mockTestcwd = sandbox.stub()
346
-
347
- const ValidateCommand = await esmock('./validate.js', {
348
- '../validators/validate-yaml.js': {
349
- default: mockYamlValidation
350
- },
351
- '#lib/project/index.js': {
352
- default: { getProjectRoot: () => '/project' }
353
- },
354
- '#helpers/test-cwd.js': {
355
- default: mockTestcwd
356
- },
357
- '#lib/logger/index.js': {
358
- logger: mockLogger
359
- },
360
- 'fs-extra': fs
361
- })
362
-
363
- const command = new ValidateCommand()
364
- command.name = sandbox.stub().returns('validate')
365
- command.logger = mockLogger
366
-
367
- // Should throw because there are errors
368
- t.throws(() => command.action({ json: true }, command), { instanceOf: ValidationError })
369
-
370
- const output = JSON.parse(consoleLogStub.firstCall.args[0])
371
-
372
- t.is(output.summary.files, 2)
373
- t.is(output.summary.passed, 1)
374
- t.is(output.summary.failed, 1)
375
- t.is(output.files[0].status, 'passed')
376
- t.is(output.files[1].status, 'failed')
377
- t.is(output.files[1].error, 'duplicated mapping key at line 5')
378
- })
@@ -1,70 +0,0 @@
1
- import Command from '#src/Command.js'
2
- import { DOCS_BASE } from '#helpers/docs-url.js'
3
-
4
- /**
5
- * Quire CLI `workflows` Command
6
- *
7
- * Displays common workflow documentation.
8
- * Hidden from main help but accessible via `quire help workflows` or `quire workflows`.
9
- *
10
- * TODO: Refactor to an extensible `quire help <topic>` system that can load
11
- * help topics from a topics/ directory or markdown files. This would support:
12
- * - quire help workflows
13
- * - quire help debugging
14
- * - quire help publishing
15
- * - quire help configuration
16
- *
17
- * @class WorkflowsCommand
18
- * @extends {Command}
19
- */
20
- export default class WorkflowsCommand extends Command {
21
- static definition = {
22
- name: 'workflows',
23
- description: 'Display common workflow documentation',
24
- summary: 'show common workflows',
25
- hidden: true,
26
- docsLink: 'quire-commands/',
27
- helpText: `
28
- Common Workflows:
29
-
30
- Starting a New Project:
31
- quire new my-book && cd my-book && quire preview
32
-
33
- Building for Web:
34
- quire build Generate HTML site files
35
- quire clean && quire build Clean build (recommended for production)
36
-
37
- Generating PDF:
38
- quire pdf --build Build first, then generate PDF
39
- quire pdf --build --open Generate and open PDF
40
- quire pdf --engine prince Use PrinceXML instead of Paged.js
41
-
42
- Generating EPUB:
43
- quire epub --build Build first, then generate EPUB
44
- quire epub --build --open Generate and open EPUB
45
-
46
- Full Publication Build:
47
- quire clean && quire build && quire pdf && quire epub
48
-
49
- Troubleshooting:
50
- quire validate Check YAML files for errors
51
- quire info Show version information
52
- quire build --verbose Build with debug output
53
-
54
- See full documentation: ${DOCS_BASE}
55
- `,
56
- version: '1.0.0',
57
- options: [],
58
- }
59
-
60
- constructor() {
61
- super(WorkflowsCommand.definition)
62
- }
63
-
64
- async action(options, command) {
65
- this.debug('called with options %O', options)
66
- // The help text is automatically displayed via Commander's help system
67
- // If called directly (quire workflows), display help
68
- command.help()
69
- }
70
- }
@@ -1,19 +0,0 @@
1
- import QuireError from '../quire-error.js'
2
- import { docsUrl } from '#helpers/docs-url.js'
3
-
4
- /**
5
- * Error thrown when the publication build fails
6
- */
7
- export default class BuildFailedError extends QuireError {
8
- constructor(details) {
9
- super(
10
- `Publication build failed${details ? `: ${details}` : ''}`,
11
- {
12
- code: 'BUILD_FAILED',
13
- exitCode: 3,
14
- suggestion: "Run 'quire build --debug' for detailed error information",
15
- docsUrl: docsUrl('troubleshooting')
16
- }
17
- )
18
- }
19
- }
@@ -1,20 +0,0 @@
1
- import QuireError from '../quire-error.js'
2
- import { docsUrl } from '#helpers/docs-url.js'
3
-
4
- /**
5
- * Error thrown when a required field is missing from a configuration file
6
- */
7
- export default class ConfigFieldMissingError extends QuireError {
8
- constructor(fieldName, configFile) {
9
- super(
10
- `Missing required field '${fieldName}' in ${configFile}`,
11
- {
12
- code: 'CONFIG_FIELD_MISSING',
13
- exitCode: 3,
14
- filePath: `content/_data/${configFile}`,
15
- suggestion: `Add '${fieldName}' to your ${configFile}`,
16
- docsUrl: docsUrl('publication-configuration')
17
- }
18
- )
19
- }
20
- }
@@ -1,20 +0,0 @@
1
- import QuireError from '../quire-error.js'
2
- import { docsUrl } from '#helpers/docs-url.js'
3
-
4
- /**
5
- * Error thrown when a required configuration file is not found
6
- */
7
- export default class ConfigFileNotFoundError extends QuireError {
8
- constructor(configFile) {
9
- super(
10
- `Required configuration file '${configFile}' not found`,
11
- {
12
- code: 'CONFIG_FILE_NOT_FOUND',
13
- exitCode: 3,
14
- filePath: `content/_data/${configFile}`,
15
- suggestion: `Create ${configFile} in your content/_data/ folder`,
16
- docsUrl: docsUrl('publication-configuration')
17
- }
18
- )
19
- }
20
- }
@@ -1,11 +0,0 @@
1
- /**
2
- * Build-related errors (exit code: 3)
3
- *
4
- * Errors related to publication build process including
5
- * Eleventy build failures and configuration issues.
6
- *
7
- * @module errors/build
8
- */
9
- export { default as BuildFailedError } from './build-failed-error.js'
10
- export { default as ConfigFieldMissingError } from './config-field-missing-error.js'
11
- export { default as ConfigFileNotFoundError } from './config-file-not-found-error.js'
@@ -1,30 +0,0 @@
1
- import InvalidInputError from '../input/invalid-input-error.js'
2
- import { docsUrl } from '#helpers/docs-url.js'
3
- import { suggestSimilar, formatSuggestion } from '#helpers/suggest-similar.js'
4
-
5
- /**
6
- * Error thrown when a requested help topic does not exist
7
- *
8
- * @param {string} topic - The unrecognized topic name
9
- * @param {string[]} validTopics - Array of available topic names
10
- */
11
- export default class HelpTopicNotFoundError extends InvalidInputError {
12
- constructor(topic, validTopics = []) {
13
- const suggestion = formatSuggestion(suggestSimilar(topic, validTopics))
14
- || 'Run "quire help --list" to see available topics'
15
-
16
- super(
17
- `Unknown help topic: ${topic}`,
18
- {
19
- code: 'HELP_TOPIC_NOT_FOUND',
20
- exitCode: 2,
21
- inputValue: topic,
22
- inputName: 'topic',
23
- suggestion,
24
- docsUrl: docsUrl('quire-commands/'),
25
- showDebugHint: false
26
- }
27
- )
28
- this.topic = topic
29
- }
30
- }
@@ -1,8 +0,0 @@
1
- /**
2
- * Help errors (exit code: 2)
3
- *
4
- * Errors related to the help system and topic lookup.
5
- *
6
- * @module errors/help
7
- */
8
- export { default as HelpTopicNotFoundError } from './help-topic-not-found-error.js'