@thegetty/quire-cli 1.0.0-rc.44 → 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 (243) 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 +9 -25
  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/schemas/config.schema.json +0 -194
  56. package/schemas/figures.schema.json +0 -56
  57. package/schemas/layout.schema.json +0 -5
  58. package/schemas/objects.schema.json +0 -62
  59. package/schemas/publication.schema.json +0 -140
  60. package/schemas/references.schema.json +0 -29
  61. package/src/Command.spec.js +0 -99
  62. package/src/commands/build.spec.js +0 -113
  63. package/src/commands/build.test.js +0 -397
  64. package/src/commands/clean.spec.js +0 -118
  65. package/src/commands/clean.test.js +0 -382
  66. package/src/commands/config.js +0 -238
  67. package/src/commands/config.spec.js +0 -107
  68. package/src/commands/config.test.js +0 -845
  69. package/src/commands/create.spec.js +0 -112
  70. package/src/commands/create.test.js +0 -415
  71. package/src/commands/doctor.js +0 -251
  72. package/src/commands/doctor.spec.js +0 -115
  73. package/src/commands/doctor.test.js +0 -1409
  74. package/src/commands/epub.spec.js +0 -114
  75. package/src/commands/epub.test.js +0 -503
  76. package/src/commands/help.js +0 -60
  77. package/src/commands/help.test.js +0 -132
  78. package/src/commands/info.spec.js +0 -72
  79. package/src/commands/info.test.js +0 -512
  80. package/src/commands/pdf.spec.js +0 -114
  81. package/src/commands/pdf.test.js +0 -464
  82. package/src/commands/preview.spec.js +0 -97
  83. package/src/commands/preview.test.js +0 -250
  84. package/src/commands/use.js +0 -56
  85. package/src/commands/use.spec.js +0 -61
  86. package/src/commands/use.test.js +0 -280
  87. package/src/commands/validate.spec.js +0 -90
  88. package/src/commands/validate.test.js +0 -378
  89. package/src/commands/workflows.js +0 -70
  90. package/src/errors/build/build-failed-error.js +0 -19
  91. package/src/errors/build/config-field-missing-error.js +0 -20
  92. package/src/errors/build/config-file-not-found-error.js +0 -20
  93. package/src/errors/build/index.js +0 -11
  94. package/src/errors/help/help-topic-not-found-error.js +0 -30
  95. package/src/errors/help/index.js +0 -8
  96. package/src/errors/index.js +0 -58
  97. package/src/errors/input/index.js +0 -8
  98. package/src/errors/input/invalid-input-error.js +0 -21
  99. package/src/errors/install/dependency-install-error.js +0 -19
  100. package/src/errors/install/directory-not-empty-error.js +0 -25
  101. package/src/errors/install/index.js +0 -12
  102. package/src/errors/install/invalid-path-error.js +0 -31
  103. package/src/errors/install/invalid-starter-error.js +0 -27
  104. package/src/errors/install/version-not-found-error.js +0 -35
  105. package/src/errors/output/epub-generation-error.js +0 -19
  106. package/src/errors/output/index.js +0 -14
  107. package/src/errors/output/invalid-epub-library-error.js +0 -20
  108. package/src/errors/output/invalid-pdf-library-error.js +0 -20
  109. package/src/errors/output/missing-build-output-error.js +0 -21
  110. package/src/errors/output/pdf-generation-error.js +0 -24
  111. package/src/errors/output/tool-not-found-error.js +0 -37
  112. package/src/errors/project/index.js +0 -10
  113. package/src/errors/project/not-in-project-error.js +0 -20
  114. package/src/errors/project/project-create-error.js +0 -21
  115. package/src/errors/quire-error.js +0 -27
  116. package/src/errors/validation/index.js +0 -3
  117. package/src/errors/validation/unknown-config-key-error.js +0 -27
  118. package/src/errors/validation/unknown-config-operation-error.js +0 -24
  119. package/src/helpers/docs-url.js +0 -32
  120. package/src/helpers/pager.js +0 -59
  121. package/src/helpers/pager.test.js +0 -85
  122. package/src/helpers/suggest-similar.js +0 -124
  123. package/src/helpers/suggest-similar.test.js +0 -108
  124. package/src/helpers/test-cwd.test.js +0 -192
  125. package/src/lib/11ty/index.test.js +0 -655
  126. package/src/lib/commander/index.js +0 -103
  127. package/src/lib/commander/index.test.js +0 -86
  128. package/src/lib/commander/options.js +0 -237
  129. package/src/lib/commander/options.test.js +0 -205
  130. package/src/lib/conf/build-status.js +0 -103
  131. package/src/lib/conf/build-status.test.js +0 -247
  132. package/src/lib/conf/config.test.js +0 -281
  133. package/src/lib/conf/format.js +0 -60
  134. package/src/lib/conf/format.test.js +0 -106
  135. package/src/lib/conf/helpers.js +0 -91
  136. package/src/lib/conf/helpers.test.js +0 -136
  137. package/src/lib/conf/index.js +0 -22
  138. package/src/lib/constants.js +0 -28
  139. package/src/lib/doctor/README.md +0 -667
  140. package/src/lib/doctor/checks/environment/cli-version.js +0 -62
  141. package/src/lib/doctor/checks/environment/cli-version.test.js +0 -132
  142. package/src/lib/doctor/checks/environment/git-available.js +0 -77
  143. package/src/lib/doctor/checks/environment/git-available.test.js +0 -52
  144. package/src/lib/doctor/checks/environment/index.js +0 -13
  145. package/src/lib/doctor/checks/environment/node-version.js +0 -66
  146. package/src/lib/doctor/checks/environment/node-version.test.js +0 -17
  147. package/src/lib/doctor/checks/environment/npm-available.js +0 -66
  148. package/src/lib/doctor/checks/environment/npm-available.test.js +0 -52
  149. package/src/lib/doctor/checks/environment/os-info.js +0 -48
  150. package/src/lib/doctor/checks/environment/os-info.test.js +0 -81
  151. package/src/lib/doctor/checks/environment/runtime-info.js +0 -51
  152. package/src/lib/doctor/checks/environment/runtime-info.test.js +0 -132
  153. package/src/lib/doctor/checks/outputs/epub-output.js +0 -119
  154. package/src/lib/doctor/checks/outputs/epub-output.test.js +0 -277
  155. package/src/lib/doctor/checks/outputs/index.js +0 -10
  156. package/src/lib/doctor/checks/outputs/pdf-output.js +0 -144
  157. package/src/lib/doctor/checks/outputs/pdf-output.test.js +0 -377
  158. package/src/lib/doctor/checks/outputs/stale-build.js +0 -122
  159. package/src/lib/doctor/checks/outputs/stale-build.test.js +0 -282
  160. package/src/lib/doctor/checks/project/data-files.js +0 -56
  161. package/src/lib/doctor/checks/project/data-files.test.js +0 -125
  162. package/src/lib/doctor/checks/project/dependencies.js +0 -53
  163. package/src/lib/doctor/checks/project/dependencies.test.js +0 -71
  164. package/src/lib/doctor/checks/project/index.js +0 -11
  165. package/src/lib/doctor/checks/project/quire-11ty.js +0 -98
  166. package/src/lib/doctor/checks/project/quire-11ty.test.js +0 -170
  167. package/src/lib/doctor/checks/project/quire-project.js +0 -38
  168. package/src/lib/doctor/checks/project/quire-project.test.js +0 -47
  169. package/src/lib/doctor/checks/tools/index.js +0 -10
  170. package/src/lib/doctor/checks/tools/pandoc-available.js +0 -82
  171. package/src/lib/doctor/checks/tools/pandoc-available.test.js +0 -73
  172. package/src/lib/doctor/checks/tools/prince-available.js +0 -81
  173. package/src/lib/doctor/checks/tools/prince-available.test.js +0 -73
  174. package/src/lib/doctor/constants.js +0 -39
  175. package/src/lib/doctor/formatDuration.js +0 -108
  176. package/src/lib/doctor/formatDuration.test.js +0 -76
  177. package/src/lib/doctor/formatters/human.js +0 -257
  178. package/src/lib/doctor/formatters/human.test.js +0 -463
  179. package/src/lib/doctor/formatters/index.js +0 -8
  180. package/src/lib/doctor/formatters/json.js +0 -78
  181. package/src/lib/doctor/formatters/json.test.js +0 -174
  182. package/src/lib/doctor/formatters/shared.js +0 -129
  183. package/src/lib/doctor/formatters/shared.test.js +0 -194
  184. package/src/lib/doctor/index.js +0 -271
  185. package/src/lib/doctor/index.test.js +0 -797
  186. package/src/lib/epub/engines.js +0 -46
  187. package/src/lib/epub/index.test.js +0 -518
  188. package/src/lib/epub/pandoc.test.js +0 -122
  189. package/src/lib/epub/schema.js +0 -21
  190. package/src/lib/error/README.md +0 -170
  191. package/src/lib/error/handler.js +0 -107
  192. package/src/lib/git/index.spec.js +0 -80
  193. package/src/lib/git/index.test.js +0 -453
  194. package/src/lib/help/frontmatter.js +0 -77
  195. package/src/lib/help/frontmatter.test.js +0 -139
  196. package/src/lib/help/index.js +0 -146
  197. package/src/lib/help/index.test.js +0 -188
  198. package/src/lib/help/topics/configuration.md +0 -77
  199. package/src/lib/help/topics/debugging.md +0 -69
  200. package/src/lib/help/topics/epub.md +0 -74
  201. package/src/lib/help/topics/pdf.md +0 -74
  202. package/src/lib/help/topics/publishing.md +0 -80
  203. package/src/lib/help/topics/workflows.md +0 -50
  204. package/src/lib/installer/index.js +0 -309
  205. package/src/lib/installer/index.spec.js +0 -83
  206. package/src/lib/installer/index.test.js +0 -545
  207. package/src/lib/logger/README.md +0 -424
  208. package/src/lib/logger/debug.js +0 -132
  209. package/src/lib/logger/debug.spec.js +0 -130
  210. package/src/lib/logger/debug.test.js +0 -128
  211. package/src/lib/logger/index.js +0 -228
  212. package/src/lib/logger/index.spec.js +0 -131
  213. package/src/lib/logger/index.test.js +0 -578
  214. package/src/lib/npm/README.md +0 -127
  215. package/src/lib/npm/index.js +0 -198
  216. package/src/lib/npm/index.spec.js +0 -60
  217. package/src/lib/npm/index.test.js +0 -355
  218. package/src/lib/pdf/engines.js +0 -46
  219. package/src/lib/pdf/index.test.js +0 -708
  220. package/src/lib/pdf/paged.test.js +0 -366
  221. package/src/lib/pdf/prince.test.js +0 -202
  222. package/src/lib/pdf/schema.js +0 -21
  223. package/src/lib/pdf/split.test.js +0 -445
  224. package/src/lib/platform.js +0 -95
  225. package/src/lib/process/manager.js +0 -110
  226. package/src/lib/process/manager.test.js +0 -55
  227. package/src/lib/project/build.js +0 -162
  228. package/src/lib/project/build.test.js +0 -275
  229. package/src/lib/project/config.js +0 -48
  230. package/src/lib/project/config.test.js +0 -134
  231. package/src/lib/project/detect.js +0 -47
  232. package/src/lib/project/detect.test.js +0 -157
  233. package/src/lib/project/index.js +0 -56
  234. package/src/lib/project/output-paths.js +0 -87
  235. package/src/lib/project/output-paths.test.js +0 -66
  236. package/src/lib/project/paths.js +0 -272
  237. package/src/lib/project/version.js +0 -110
  238. package/src/lib/project/version.test.js +0 -350
  239. package/src/lib/reporter/index.test.js +0 -862
  240. package/src/main.spec.js +0 -61
  241. package/src/main.test.js +0 -347
  242. package/src/validators/validate-data-files.js +0 -154
  243. package/src/validators/validate-data-files.test.js +0 -217
package/src/main.js CHANGED
@@ -1,87 +1,14 @@
1
- import { Command, Argument, Option } from 'commander'
2
- import {
3
- arrayToArgument,
4
- arrayToOption,
5
- colorOption,
6
- noColorOption,
7
- quietOption,
8
- verboseOption,
9
- debugOption,
10
- reducedMotionOption,
11
- } from '#lib/commander/index.js'
1
+ import { Argument, Command, Option } from 'commander'
12
2
  import commands from '#src/commands/index.js'
13
3
  import config from '#lib/conf/config.js'
14
- import { handleError } from '#lib/error/handler.js'
15
- import reporter from '#lib/reporter/index.js'
16
- import { docsUrl, DOCS_BASE } from '#helpers/docs-url.js'
17
4
  import packageConfig from '#src/packageConfig.js'
18
- import { enableDebug } from '#lib/logger/debug.js'
19
- import { formatPrefix } from '#lib/logger/index.js'
20
5
 
21
6
  const { version } = packageConfig
22
7
 
23
- const mainHelpText = `
24
- Docs: ${DOCS_BASE}
25
-
26
- Common Workflows:
27
- New project quire new my-book && cd my-book && quire preview
28
- Build for web quire build
29
- Generate PDF quire pdf --build
30
- Generate EPUB quire epub --build
31
-
32
- Run 'quire help workflows' for detailed workflow documentation.
33
-
34
- Output Modes:
35
- -q, --quiet Suppress progress output (for CI/scripts)
36
- -v, --verbose Show detailed progress (paths, timing, steps)
37
- --debug Enable debug output for developers/troubleshooting
38
- --reduced-motion Disable spinner animation and line overwriting
39
-
40
- Set defaults: quire settings set verbose true
41
-
42
- Accessibility:
43
- --reduced-motion disables animated spinners and line overwriting.
44
- Each stage prints on a new line as static text, making output
45
- compatible with screen readers and reduced-motion preferences.
46
-
47
- Set default: quire settings set reducedMotion true
48
-
49
- Color Output:
50
- --no-color Disable colored output
51
- --color Force colored output (overrides NO_COLOR env var)
52
-
53
- Respects NO_COLOR environment variable (https://no-color.org/)
54
- Set default: quire settings set logUseColor false
55
-
56
- Paging:
57
- --no-pager Disable paging for long output
58
- NO_PAGER=1 Disable paging via environment variable
59
- PAGER=cat Traditional Unix alternative (passes output through)
60
-
61
- Environment Variables:
62
- REDUCED_MOTION Disable spinner animation and line overwriting
63
- NO_COLOR Disable colored output (https://no-color.org/)
64
- NO_PAGER=1 Disable paging for long output
65
- PAGER=<program> Set pager program (default: less). Use PAGER=cat to disable
66
- DEBUG=quire:* Enable debug output for all modules
67
- DEBUG=quire:lib:pdf Enable debug output for PDF module only
68
- DEBUG=quire:lib:* Enable debug output for all lib modules
69
-
70
- Examples:
71
- $ quire build Build the publication
72
- $ quire build --verbose Build with detailed progress
73
- $ quire build --debug Build with debug output
74
- $ quire build --reduced-motion Build without animated spinners
75
- $ REDUCED_MOTION=1 quire build Build without animated spinners
76
- $ quire build --no-color Build without colored output
77
- $ NO_COLOR=1 quire build Build without colored output
78
- $ DEBUG=quire:* quire pdf Generate PDF with debug output
79
- `
80
-
81
8
  /**
82
9
  * Quire CLI implements the command pattern.
83
10
  *
84
- * The \`main\` module acts as the _receiver_, parsing input from the client,
11
+ * The `main` module acts as the _receiver_, parsing input from the client,
85
12
  * calling the appropriate command module(s), managing messages between modules,
86
13
  * and sending formatted messages to the client for display.
87
14
  */
@@ -90,107 +17,29 @@ const program = new Command()
90
17
  program
91
18
  .name('quire')
92
19
  .description('Quire command-line interface')
93
- .version(version, '-V, --version', 'output quire version number')
94
- .addOption(arrayToOption(colorOption))
95
- .addOption(arrayToOption(noColorOption))
96
- .addOption(arrayToOption(quietOption))
97
- .addOption(arrayToOption(verboseOption))
98
- .addOption(arrayToOption(debugOption))
99
- .addOption(arrayToOption(reducedMotionOption))
100
- .option('--no-pager', 'disable paging for long output')
101
- .addHelpText('after', mainHelpText)
20
+ .version(version, '-v, --version', 'output quire version number')
102
21
  .configureHelp({
103
22
  helpWidth: 80,
104
23
  sortOptions: false,
105
24
  sortSubcommands: false,
106
- styleOptionTerm: (term) => {
107
- // Add spacing to long-only options to align with short-flag options
108
- return /^-\w/.test(term) ? term : term.padStart(term.length + 4)
109
- },
110
25
  })
111
26
 
112
- /**
113
- * Handle global options before any command runs
114
- *
115
- * Output mode semantics:
116
- * - --quiet: Suppress progress spinners (for CI/scripts)
117
- * - --verbose: Show detailed progress (paths, timing, steps)
118
- * - --debug: Enable DEBUG namespace + tool debug modes (for developers)
119
- * - --reduced-motion: Disable animated spinners, use static text on new lines
120
- * - --no-color: Disable colored output (sets NO_COLOR env var)
121
- * - --color: Force colored output (overrides NO_COLOR env var)
122
- *
123
- * These global options are passed through to commands via opts()
124
- * and should be merged with command-level options.
125
- */
126
- program.hook('preAction', (thisCommand) => {
127
- const opts = thisCommand.opts()
128
-
129
- // Handle --no-color / --color flag
130
- // Sets NO_COLOR env var for chalk, ora, and logger to read
131
- if (opts.color === false) {
132
- process.env.NO_COLOR = '1'
133
- delete process.env.FORCE_COLOR
134
- } else if (opts.color === true) {
135
- delete process.env.NO_COLOR
136
- process.env.FORCE_COLOR = '1'
137
- }
138
-
139
- // --debug or config.debug enables the quire:* DEBUG namespace for internal logging
140
- // CLI flag takes precedence, then config setting
141
- if (opts.debug ?? config.get('debug')) {
142
- enableDebug('quire:*')
143
- }
144
-
145
- // --reduced-motion sets REDUCED_MOTION env var for reporter to read
146
- // CLI flag takes precedence over env var and config setting
147
- if (opts.reducedMotion) {
148
- process.env.REDUCED_MOTION = '1'
149
- }
150
-
151
- // --no-pager sets pager to false; propagate via env var for pager utility
152
- if (opts.pager === false) {
153
- process.env.NO_PAGER = '1'
154
- }
155
-
156
- // Log prefix and level label visibility for quire-11ty's chalk logger
157
- process.env.QUIRE_LOG_PREFIX = formatPrefix(config.get('logPrefixStyle'), config.get('logPrefix'))
158
- process.env.QUIRE_LOG_SHOW_LEVEL = String(config.get('logShowLevel'))
159
- })
160
-
161
- /**
162
- * Stop the reporter after every command to clear any active setInterval timers
163
- * (e.g. elapsed time display) that would otherwise keep the event loop alive.
164
- */
165
- program.hook('postAction', () => {
166
- reporter.stop()
167
- })
168
-
169
27
  /**
170
28
  * Register each command as a subcommand of this program
29
+ *
30
+ * @todo refactor command definition to allow for per-command custom help text
171
31
  * @see https://github.com/tj/commander.js?tab=readme-ov-file#automated-help
172
32
  */
173
33
  commands.forEach((command) => {
174
- const { action, alias, aliases, args, description, docsLink, helpText, hidden, name, options, summary } = command
34
+ const { action, alias, aliases, args, description, name, options } = command
175
35
 
176
36
  const subCommand = program
177
- .command(name, { hidden })
37
+ .command(name)
178
38
  .description(description)
179
- .summary(summary || description)
180
39
  .addHelpCommand()
181
40
  .showHelpAfterError()
182
41
 
183
- // Append docs link and/or custom help text after built-in help
184
- const customHelpText = [
185
- docsLink && `Docs: ${docsUrl(docsLink)}`,
186
- helpText?.trim()
187
- ].filter(Boolean).join('\n\n')
188
-
189
- if (customHelpText) {
190
- subCommand.addHelpText('after', '\n' + customHelpText)
191
- }
192
-
193
- if (typeof alias === 'string') {
42
+ if (alias instanceof String) {
194
43
  subCommand.alias(alias)
195
44
  }
196
45
 
@@ -199,93 +48,71 @@ commands.forEach((command) => {
199
48
  }
200
49
 
201
50
  /**
202
- * Register arguments with the subcommand
51
+ * @see https://github.com/tj/commander.js#more-configuration-1
203
52
  */
204
53
  if (Array.isArray(args)) {
205
- args.forEach((entry) => {
206
- const argument = entry instanceof Argument ? entry : arrayToArgument(entry)
54
+ args.forEach(([ name, description, configuration = {} ]) => {
55
+ const argument = new Argument(name, description)
56
+ if (configuration.choices) argument.choices(configuration.choices)
57
+ if (configuration.default) argument.default(configuration.default)
207
58
  subCommand.addArgument(argument)
208
59
  })
209
60
  }
210
61
 
211
62
  /**
212
- * Register options with the subcommand
63
+ * @see https://github.com/tj/commander.js/#options
213
64
  */
214
65
  if (Array.isArray(options)) {
215
66
  options.forEach((entry) => {
216
- const option = entry instanceof Option ? entry : arrayToOption(entry)
217
- subCommand.addOption(option)
67
+ if (Array.isArray(entry)) {
68
+ // ensure we can join the first two attributes as the option name
69
+ // when only the short or the long flag is defined in the array
70
+ if (entry[0].startsWith('--')) entry.unshift('\u0020'.repeat(4))
71
+ if (entry[0].startsWith('-') && !entry[1].startsWith('--')) {
72
+ entry.splice(1, 0, '')
73
+ }
74
+ // assign attribute names to the array of option attributes
75
+ const [ short, long, description, defaultValue ] = entry
76
+ // join short and long flags as the option name attribute
77
+ const name = /^-\w/.test(short) && /^--\w/.test(long)
78
+ ? [short, long].join(', ')
79
+ : [short, long].join('')
80
+ subCommand.option(name, description, defaultValue)
81
+ } else {
82
+ /**
83
+ * @todo allow options to be defined by a configuration object
84
+ * @see https://github.com/tj/commander.js/#more-configuration
85
+ */
86
+ // const option = new Option(name, description)
87
+ // for (const property of configuration) {
88
+ // option[property](configuration[property])
89
+ // }
90
+ // subCommand.addOption(option)
91
+ console.error('@TODO please use an array to define option attributes')
92
+ }
218
93
  })
219
94
  }
220
95
 
221
- /**
222
- * Command lifecycle hook: called after action handler and nested subcommands
223
- * @see https://github.com/tj/commander.js?tab=readme-ov-file#life-cycle-hooks
224
- */
225
96
  if (command.postAction) {
226
- subCommand.hook('postAction', async (thisCommand, actionCommand) => {
227
- try {
228
- await command.postAction.call(command, thisCommand, actionCommand)
229
- } catch (error) {
230
- const { debug } = program.opts()
231
- handleError(error, { debug })
232
- }
97
+ subCommand.hook('postAction', (thisCommand, actionCommand) => {
98
+ command.postAction.call(command, thisCommand, actionCommand)
233
99
  })
234
100
  }
235
101
 
236
- /**
237
- * Command lifecycle hook: called before action handler and nested subcommands
238
- * @see https://github.com/tj/commander.js?tab=readme-ov-file#life-cycle-hooks
239
- */
240
102
  if (command.preAction) {
241
- subCommand.hook('preAction', async (thisCommand, actionCommand) => {
242
- try {
243
- await command.preAction.call(command, thisCommand, actionCommand)
244
- } catch (error) {
245
- const { debug } = program.opts()
246
- handleError(error, { debug })
247
- }
103
+ subCommand.hook('preAction', (thisCommand, actionCommand) => {
104
+ command.preAction.call(command, thisCommand, actionCommand)
248
105
  })
249
106
  }
250
107
 
251
- /**
252
- * Subcommand lifecyle hook: called before parsing direct subcommand
253
- * @see https://github.com/tj/commander.js?tab=readme-ov-file#life-cycle-hooks
254
- */
255
108
  if (command.preSubcommand) {
256
- subCommand.hook('preSubcommand', async (thisCommand, theSubcommand) => {
257
- try {
258
- await command.preSubcommand.call(command, thisCommand, theSubcommand)
259
- } catch (error) {
260
- const { debug } = program.opts()
261
- handleError(error, { debug })
262
- }
109
+ subCommand.hook('preSubcommand', (thisCommand, theSubcommand) => {
110
+ command.preSubcommand.call(command, thisCommand, theSubcommand)
263
111
  })
264
112
  }
265
113
 
266
- /**
267
- * Wrap action in centralized error handler.
268
- * Using apply() preserves `this` context for `this.debug` and `this.logger`.
269
- *
270
- * Nota bene: Commander passes subcommand-local opts as the options argument,
271
- * but global options (--verbose, --quiet, --debug) defined on the parent
272
- * program are only available via optsWithGlobals(). We replace the options
273
- * argument with the merged set so action handlers see all options uniformly.
274
- */
275
- subCommand.action(async (...args) => {
276
- try {
277
- // Commander Command instance is the last element in args array
278
- // @see https://github.com/tj/commander.js#action-handler
279
- const cmd = args[args.length - 1]
280
- const mergedOpts = cmd.optsWithGlobals()
281
- args[args.length - 2] = mergedOpts
282
- await action.apply(command, args)
283
- } catch (error) {
284
- reporter.stop()
285
- const { debug } = program.opts()
286
- handleError(error, { debug })
287
- }
288
- })
114
+ // subCommand.action((args) => action.apply(command, args))
115
+ subCommand.action(action)
289
116
 
290
117
  /**
291
118
  * Inject the CLI configuration into commands
@@ -1,7 +1,6 @@
1
1
  import { dirname } from 'node:path'
2
2
  import { fileURLToPath } from 'node:url'
3
3
  import { readPackageUpSync } from 'read-package-up'
4
- import which from '#helpers/which.js'
5
4
 
6
5
  const __filename = fileURLToPath(import.meta.url)
7
6
  const __dirname = dirname(__filename)
@@ -13,20 +12,4 @@ const __dirname = dirname(__filename)
13
12
  */
14
13
  const { packageJson } = readPackageUpSync({ cwd: __dirname, normalize: true })
15
14
 
16
- /**
17
- * Resolve the full filesystem path to the quire CLI executable
18
- *
19
- * Uses the `which` helper to find the first `quire` executable in PATH.
20
- * Returns null if the executable is not found.
21
- *
22
- * @returns {string|null} Absolute path to the quire executable, or null
23
- */
24
- export function binPath() {
25
- try {
26
- return which('quire')
27
- } catch {
28
- return null
29
- }
30
- }
31
-
32
15
  export default packageJson
@@ -2,7 +2,7 @@ import YamlDuplicateIdError from '../errors/validation/yaml-duplicate-error.js'
2
2
  import { fileURLToPath } from 'url'
3
3
  import fs from 'node:fs'
4
4
  import path from 'path'
5
- import { paths as eleventyPaths } from '#lib/11ty/index.js'
5
+ import { projectRoot } from '#lib/11ty/index.js'
6
6
 
7
7
  const IMAGE_KEYS = new Set(['src', 'image', 'logo'])
8
8
 
@@ -37,7 +37,6 @@ function collectImagePaths(node, paths=[]) {
37
37
  function validateImage(label, src) {
38
38
  if(!src) return
39
39
 
40
- const projectRoot = eleventyPaths.getProjectRoot()
41
40
  let assetPath = ''
42
41
  if(src.endsWith('.html')) {
43
42
  assetPath = path.join(projectRoot, 'content', '_assets', src)
@@ -1,194 +0,0 @@
1
- {
2
- "$schema": "http://json-schema.org/draft-07/schema#",
3
- "title": "Quire Config Schema",
4
- "type": "object",
5
- "properties": {
6
- "accordion": {
7
- "type": "object",
8
- "properties": {
9
- "controls": {
10
- "type": "string",
11
- "enum": ["arrow", "plus-minus"]
12
- },
13
- "copyButton": {
14
- "type": "object",
15
- "properties": {
16
- "ariaLabel": { "type": "string" },
17
- "successText": { "type": "string" },
18
- "symbol": { "type": "string" }
19
- },
20
- "required": ["ariaLabel", "successText", "symbol"]
21
- },
22
- "globalControls": {
23
- "type": "object",
24
- "properties": {
25
- "collapseText": { "type": "string" },
26
- "expandText": { "type": "string" }
27
- },
28
- "required": ["collapseText", "expandText"]
29
- }
30
- },
31
- "required": ["controls", "copyButton", "globalControls"]
32
- },
33
- "analytics": {
34
- "type": "object",
35
- "properties": {
36
- "googleId": { "type": "string" }
37
- },
38
- "required": ["googleId"]
39
- },
40
- "bylineFormat": {
41
- "oneOf": [
42
- { "type": "string", "enum": ["name", "name-title"] },
43
- { "type": "boolean", "enum": [false] }
44
- ]
45
- },
46
- "bibliography": {
47
- "type": "object",
48
- "properties": {
49
- "displayOnPage": { "type": "boolean" },
50
- "displayShort": { "type": "boolean" },
51
- "heading": { "type": "string" }
52
- },
53
- "required": ["displayOnPage", "displayShort", "heading"]
54
- },
55
- "citations": {
56
- "type": "object",
57
- "properties": {
58
- "divider": { "type": "string" },
59
- "popupStyle": {
60
- "type": "string",
61
- "enum": ["text", "icon"]
62
- }
63
- },
64
- "required": ["divider", "popupStyle"]
65
- },
66
- "entryPage": {
67
- "type": "object",
68
- "properties": {
69
- "sideBySide": { "type": "boolean" },
70
- "objectLinkText": { "type": "string" }
71
- },
72
- "required": ["sideBySide", "objectLinkText"]
73
- },
74
- "epub": {
75
- "type": "object",
76
- "properties": {
77
- "defaultCoverImage": { "type": "string" },
78
- "outputDir": { "type": "string" }
79
- },
80
- "required": ["defaultCoverImage", "outputDir"]
81
- },
82
- "footnotes": {
83
- "type": "object",
84
- "properties": {
85
- "backlinkSymbol": { "type": "string" }
86
- },
87
- "required": ["backlinkSymbol"]
88
- },
89
- "figures": {
90
- "type": "object",
91
- "properties": {
92
- "assetDir": { "type": "string" },
93
- "enableModal": { "type": "boolean" },
94
- "imageDir": { "type": "string" }
95
- },
96
- "required": ["assetDir", "enableModal", "imageDir"]
97
- },
98
- "licenseIcons": { "type": "boolean" },
99
- "localization": {
100
- "type": "object",
101
- "properties": {
102
- "defaultLocale": { "type": "string" }
103
- },
104
- "required": ["defaultLocale"]
105
- },
106
- "menuType": {
107
- "type": "string",
108
- "enum": ["full", "brief"]
109
- },
110
- "navigation": {
111
- "type": "object",
112
- "properties": {
113
- "nextButtonText": { "type": "string" },
114
- "prevButtonText": { "type": "string" }
115
- },
116
- "required": ["nextButtonText", "prevButtonText"]
117
- },
118
- "pageTitle": {
119
- "type": "object",
120
- "properties": {
121
- "labelDivider": { "type": "string" }
122
- },
123
- "required": ["labelDivider"]
124
- },
125
- "pdf": {
126
- "type": "object",
127
- "properties": {
128
- "filename": { "type": "string" },
129
- "outputDir": { "type": "string" },
130
- "pagePDF": {
131
- "type": "object",
132
- "properties": {
133
- "accessLinks": {
134
- "type": "array",
135
- "items": {
136
- "type": "object",
137
- "properties": {
138
- "header": { "type": "boolean" },
139
- "footer": { "type": "boolean" },
140
- "label": { "type": "string" }
141
- }
142
- }
143
- },
144
- "coverPage": { "type": "boolean" },
145
- "output": { "type": "boolean" }
146
- },
147
- "required": ["accessLinks", "coverPage", "output"]
148
- },
149
- "publicationPDF": {
150
- "type": "object",
151
- "properties": {
152
- "output": { "type": "boolean" }
153
- },
154
- "required": ["output"]
155
- }
156
- },
157
- "required": ["filename", "outputDir", "pagePDF", "publicationPDF"]
158
- },
159
- "ref": {
160
- "type": "object",
161
- "properties": {
162
- "sequenceTransition": { "type": "number" }
163
- },
164
- "required": ["sequenceTransition"]
165
- },
166
- "searchEnabled": { "type": "boolean" },
167
- "tableOfContents": {
168
- "type": "object",
169
- "properties": {
170
- "contributorDivider": { "type": "string" }
171
- },
172
- "required": ["contributorDivider"]
173
- }
174
- },
175
- "required": [
176
- "accordion",
177
- "bylineFormat",
178
- "bibliography",
179
- "citations",
180
- "entryPage",
181
- "epub",
182
- "footnotes",
183
- "figures",
184
- "licenseIcons",
185
- "localization",
186
- "menuType",
187
- "navigation",
188
- "pageTitle",
189
- "pdf",
190
- "ref",
191
- "searchEnabled",
192
- "tableOfContents"
193
- ]
194
- }
@@ -1,56 +0,0 @@
1
- {
2
- "$schema": "http://json-schema.org/draft-07/schema#",
3
- "title": "Figures YAML Schema",
4
- "type": "object",
5
- "properties": {
6
- "figure_list": {
7
- "type": "array",
8
- "items": {
9
- "type": "object",
10
- "required": ["id"],
11
- "properties": {
12
- "id": { "type": "string" },
13
- "label": { "type": "string" },
14
- "src": { "type": "string" },
15
- "caption": { "type": "string" },
16
- "credit": { "type": ["string", "null"] },
17
- "alt": { "type": ["string", "null"] },
18
- "poster": { "type": "string" },
19
- "download": { "type": "boolean" },
20
- "zoom": { "type": "boolean" },
21
- "media_id": { "type": "string" },
22
- "media_type": {
23
- "type": "string",
24
- "enum": ["youtube", "soundcloud", "table"]
25
- },
26
- "annotations": {
27
- "type": "array",
28
- "items": {
29
- "type": "object",
30
- "required": ["input", "items"],
31
- "properties": {
32
- "input": {
33
- "type": "string",
34
- "enum": ["radio", "checkbox"]
35
- },
36
- "items": {
37
- "type": "array",
38
- "items": {
39
- "type": "object",
40
- "properties": {
41
- "src": { "type": "string" },
42
- "label": { "type": "string" },
43
- "selected": { "type": "boolean" }
44
- },
45
- "required": ["src"]
46
- }
47
- }
48
- }
49
- }
50
- }
51
- }
52
- }
53
- }
54
- },
55
- "required": ["figure_list"]
56
- }
@@ -1,5 +0,0 @@
1
- {
2
- "$schema": "http://json-schema.org/draft-07/schema#",
3
- "title": "Layout Schema",
4
- "type": "string"
5
- }