@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
@@ -1,8 +1,5 @@
1
1
  import Command from '#src/Command.js'
2
- import { Option } from 'commander'
3
- import { withOutputModes } from '#lib/commander/index.js'
4
- import { api, cli } from '#lib/11ty/index.js'
5
- import reporter from '#lib/reporter/index.js'
2
+ import { api, cli, paths, projectRoot } from '#lib/11ty/index.js'
6
3
  import testcwd from '#helpers/test-cwd.js'
7
4
 
8
5
  /**
@@ -14,48 +11,50 @@ import testcwd from '#helpers/test-cwd.js'
14
11
  * @extends {Command}
15
12
  */
16
13
  export default class PreviewCommand extends Command {
17
- static definition = withOutputModes({
14
+ static definition = {
18
15
  name: 'preview',
19
16
  description: 'Run the development server and watch on file changes',
20
- summary: 'start local preview server',
21
- docsLink: 'quire-commands/#start-and-preview-projects',
22
- helpText: `
23
- Examples:
24
- quire preview Start preview server on default port
25
- quire preview --port 3000 Run on custom port
26
- quire preview --open Start server and open in browser
27
- quire preview --verbose Start with detailed progress
28
- `,
29
- version: '1.1.0',
17
+ summary: 'run the development server',
18
+ version: '1.0.0',
19
+ args: [
20
+ // [
21
+ // '[formats...]', 'output formats',
22
+ // {
23
+ // choices: ['pdf', 'epub'],
24
+ // }
25
+ // ],
26
+ ],
30
27
  options: [
31
- [ '-p, --port <port>', 'configure development server port', 8080 ],
32
- [ '--open', 'open in default browser when server starts' ],
33
- // Use Option object syntax to configure this as a hidden option
34
- new Option('--11ty <module>', 'use the specified 11ty module')
35
- .choices(['api', 'cli']).default('api').hideHelp(),
28
+ [ '-p', '--port <port>', 'configure development server port', 8080 ],
29
+ [ '-q', '--quiet', 'run preview in silent mode' ],
30
+ [ '-v', '--verbose', 'run preview with verbose console messages' ],
31
+ [
32
+ '--11ty <module>', 'use the specified 11ty module', 'cli',
33
+ // { choices: ['api', 'cli'], default: 'cli' }
34
+ ],
35
+ [ '--debug', 'run preview with debug output to console' ],
36
36
  ],
37
- })
37
+ }
38
38
 
39
39
  constructor() {
40
40
  super(PreviewCommand.definition)
41
41
  }
42
42
 
43
43
  async action(options, command) {
44
- this.debug('called with options %O', options)
45
-
46
- // Configure reporter for this command
47
- reporter.configure({ quiet: options.quiet, verbose: options.verbose })
44
+ if (options.debug) {
45
+ console.debug('[CLI] Command \'%s\' called with arguments [%o] and options %o', this.name(), options)
46
+ }
48
47
 
49
- if (options['11ty'] === 'api') {
50
- this.debug('running eleventy using lib/11ty api')
51
- await api.serve(options)
48
+ if (options['11ty'] === 'cli') {
49
+ console.debug('[CLI] running eleventy using lib/11ty cli')
50
+ cli.serve(options)
52
51
  } else {
53
- this.debug('running eleventy using lib/11ty cli')
54
- await cli.serve(options)
52
+ console.debug('[CLI] running eleventy using lib/11ty api')
53
+ api.serve(options)
55
54
  }
56
55
  }
57
56
 
58
- preAction(thisCommand, actionCommand) {
59
- testcwd(thisCommand)
57
+ preAction(command) {
58
+ testcwd(command)
60
59
  }
61
60
  }
@@ -1,108 +1,64 @@
1
1
  import Command from '#src/Command.js'
2
- import { withOutputModes } from '#lib/commander/index.js'
3
2
  import { YAMLException } from 'js-yaml'
4
3
  import YamlValidationError from '../errors/validation/yaml-validation-error.js'
5
4
  import fs from 'fs-extra'
6
5
  import path from 'node:path'
7
- import paths from '#lib/project/index.js'
6
+ import { projectRoot } from '#lib/11ty/index.js'
8
7
  import testcwd from '../helpers/test-cwd.js'
9
8
  import yamlValidation from '../validators/validate-yaml.js'
10
- import { ValidationError } from '#src/errors/index.js'
9
+
11
10
 
12
11
  /**
13
12
  * Quire CLI `validate` Command
14
- *
13
+ *
15
14
  * @class ValidateCommand
16
15
  * @extends {Command}
17
16
  */
18
17
  export default class ValidateCommand extends Command {
19
- static definition = withOutputModes({
18
+ static definition = {
20
19
  name: 'validate',
21
20
  description: 'Validate configuration files',
22
- summary: 'check YAML files for errors',
23
- docsLink: 'quire-commands/#get-help',
24
- helpText: `
25
- Examples:
26
- quire validate Check YAML syntax in content/_data/
27
- quire validate --verbose Validate with detailed file listing
28
- quire validate --json Output validation results as JSON
29
-
30
- Validates YAML files in content/_data/ directory.
31
- `,
21
+ summary: 'run validation',
32
22
  version: '1.0.0',
33
23
  options: [
34
- ['--json', 'output validation results as JSON'],
24
+ [ '--debug', 'run validate with debug output to console' ],
35
25
  ],
36
- })
26
+ }
37
27
 
38
28
  constructor() {
39
29
  super(ValidateCommand.definition)
40
30
  }
41
31
 
42
32
  action(options, command){
43
- this.debug('called with options %O', options)
44
-
45
- const dataPath = path.join(paths.getProjectRoot(), 'content', '_data')
33
+ if(options.debug) {
34
+ console.debug('[CLI] Command \'%s\' called with options %o', this.name(), options)
35
+ }
36
+
37
+ const dataPath = path.join(projectRoot, 'content', '_data')
46
38
  const files = fs.readdirSync(dataPath)
47
39
  .filter(file => file.endsWith('.yaml') || file.endsWith('.yml'))
48
40
  .map(file => path.join(dataPath, file)
49
41
  )
50
42
 
51
- const results = []
52
- if (!options.json) {
53
- this.logger.info('Validating YAML files..')
54
- }
43
+ let errorList = []
44
+ console.log('Validating YAML files..')
55
45
 
56
46
  for (const file of files) {
57
47
  try {
58
48
  yamlValidation(file)
59
- results.push({ file, status: 'passed' })
60
49
  } catch (error){
61
- results.push({ file, status: 'failed', error: error.reason })
50
+ errorList.push(error)
62
51
  }
63
52
  }
64
53
 
65
- const errors = results.filter((r) => r.status === 'failed')
66
-
67
- if (options.json) {
68
- const output = {
69
- summary: {
70
- files: results.length,
71
- passed: results.length - errors.length,
72
- failed: errors.length,
73
- },
74
- files: results,
75
- }
76
- console.log(JSON.stringify(output, null, 2))
77
-
78
- // Still throw so exit code reflects failure
79
- if (errors.length > 0) {
80
- throw new ValidationError(
81
- `Validation failed with ${errors.length} error(s)`,
82
- {
83
- code: 'VALIDATION_FAILED',
84
- suggestion: 'Fix the errors listed above and run validation again'
85
- }
86
- )
87
- }
88
- return
89
- }
90
-
91
- if (errors.length > 0) {
92
- errors.forEach((r) => { this.logger.error(`${r.error}`) })
93
- throw new ValidationError(
94
- `Validation failed with ${errors.length} error(s)`,
95
- {
96
- code: 'VALIDATION_FAILED',
97
- suggestion: 'Fix the errors listed above and run validation again'
98
- }
99
- )
54
+ if(errorList.length > 0) {
55
+ errorList.forEach(err => { console.error(`${err.reason}`) })
100
56
  } else {
101
- this.logger.info('Validation complete.')
57
+ console.log('Validation complete.')
102
58
  }
103
59
  }
104
60
 
105
- preAction(thisCommand, actionCommand) {
106
- testcwd(thisCommand)
61
+ preAction(options, command) {
62
+ testcwd(command)
107
63
  }
108
64
  }
@@ -0,0 +1,43 @@
1
+ import Command from '#src/Command.js'
2
+ import { paths, projectRoot } from '#lib/11ty/index.js'
3
+ import * as quire from '#lib/quire/index.js'
4
+ import testcwd from '#helpers/test-cwd.js'
5
+
6
+ /**
7
+ * Quire CLI `version` Command
8
+ *
9
+ * Running `quire version` sets the `quire-11ty` version for a project.
10
+ * The version is written to a `.quire` file in the project directory
11
+ * or to the `quire-cli` package `.quire` when the `global` flag is used.
12
+ *
13
+ * @class VersionCommand
14
+ * @extends {Command}
15
+ */
16
+ export default class VersionCommand extends Command {
17
+ static definition = {
18
+ name: 'version',
19
+ description: 'Sets the Quire version to use when running commands on the project.',
20
+ summary: 'set the @thegetty/quire-11ty version',
21
+ version: '1.0.0',
22
+ args: [
23
+ [ '<version>', 'the local quire version to use' ],
24
+ ],
25
+ options: [
26
+ // [ '-g', '--global', 'set the quire version globally' ],
27
+ ],
28
+ }
29
+
30
+ constructor() {
31
+ super(VersionCommand.definition)
32
+ }
33
+
34
+ action(args, options = {}) {
35
+ if (options.debug) {
36
+ console.info('Command \'%s\' called with options %o', this.name, options)
37
+ }
38
+ }
39
+
40
+ preAction(command) {
41
+ testcwd(command)
42
+ }
43
+ }
@@ -1,22 +1,13 @@
1
- import QuireError from '../quire-error.js'
2
- import { docsUrl } from '#helpers/docs-url.js'
3
-
4
- /**
5
- * Base validation error class (exit code: 4)
6
- *
7
- * Used for YAML validation, schema violations, and configuration errors.
8
- * Maintains backward compatibility with existing properties (filePath, reason, code).
9
- */
10
- export default class ValidationError extends QuireError {
11
- constructor(message, { filePath, reason, code, suggestion, docsUrl: docsUrlOverride } = {}) {
12
- super(message, {
13
- code,
14
- exitCode: 4,
15
- filePath,
16
- suggestion: suggestion || (reason ? `Fix: ${reason}` : undefined),
17
- docsUrl: docsUrlOverride || docsUrl('troubleshooting')
18
- })
19
- // Maintain backward compatibility
1
+ export default class ValidationError extends Error {
2
+ constructor(message, {filePath, reason, code} = {}) {
3
+ super(message)
4
+ this.name = this.constructor.name
5
+ this.filePath = filePath
20
6
  this.reason = reason
7
+ this.code = code
8
+
9
+ if ('captureStackTrace' in Error) {
10
+ Error.captureStackTrace(this, this.constructor)
11
+ }
21
12
  }
22
- }
13
+ }
@@ -36,7 +36,7 @@ export async function clean (projectRoot, paths, options = {}) {
36
36
  const deletedPaths = await deleteAsync(pathsToClean, {
37
37
  dryRun: options.dryRun,
38
38
  force: true,
39
- onProgress: options.verbose && progressLogger,
39
+ onProgress: (options.progress || options.verbose) && progressLogger,
40
40
  })
41
41
 
42
42
  return deletedPaths
@@ -0,0 +1,31 @@
1
+ /**
2
+ * A helper module to test if a directory is a Quire project root
3
+ * @module is-quire
4
+ */
5
+ import fs from 'node:fs'
6
+
7
+ const QUIRE_DOT_FILES = Object.freeze([
8
+ '.eleventy.js',
9
+ '.quire',
10
+ '.quire-11ty',
11
+ '.quire-version',
12
+ 'eleventy.config.js',
13
+ ])
14
+
15
+ /**
16
+ * Test if a directory is a Quire project root
17
+ *
18
+ * Nota bene: `dirpath` must be to the Quire project root to positively confirm
19
+ * a directory is a Quire project, testing a Quire project subdirectory will
20
+ * return falsely negative result.
21
+ *
22
+ * @todo refactor this to throw an Error NOTQUIRE
23
+ *
24
+ * @param {String} dirpath path to a local directory
25
+ * @return {Promise}
26
+ */
27
+ export default function (dirpath) {
28
+ return fs.readdirSync(dirpath)
29
+ .find((entry) => QUIRE_DOT_FILES.includes(entry))
30
+ }
31
+
@@ -1,18 +1,19 @@
1
1
  /**
2
2
  * A helper module to test the current working directory
3
- * @module test-cwd
3
+ * @module test-csd
4
4
  */
5
- import { detect as isQuire } from '#lib/project/index.js'
6
- import { NotInProjectError } from '#src/errors/index.js'
5
+ import isQuire from '#helpers/is-quire.js'
7
6
 
8
7
  /**
9
8
  * Test current working directory is a Quire project directory
10
9
  *
11
10
  * @param {Command} command the command from which testcwd was called
12
- * @throws {NotInProjectError} if not in a Quire project directory
13
11
  */
14
12
  export default (command) => {
13
+ const message = `[CLI] ${ command ? command.name() : '' } command must be run while in a Quire project directory. Use 'cd' to navigate to your project directory and re-run the 'quire ${ command ? command.name() : '' }' command.`
14
+
15
15
  if (!isQuire(process.cwd())) {
16
- throw new NotInProjectError(command?.name() || '')
16
+ console.error(message)
17
+ process.exit(1)
17
18
  }
18
19
  }
@@ -3,25 +3,19 @@
3
3
  * @module which
4
4
  */
5
5
  import which from 'which'
6
- import { ToolNotFoundError } from '#src/errors/index.js'
7
6
 
8
7
  /**
9
8
  * A simple wrapper around the `which` utility
10
9
  * to find the first instance of an executable in the shell environment PATH
11
10
  *
12
11
  * @param {String} executable shell executable to find
13
- * @param {Object} [toolInfo] optional metadata for error messages
14
- * @param {String} [toolInfo.displayName] human-readable tool name
15
- * @param {String} [toolInfo.installUrl] URL where tool can be downloaded
16
- * @param {String} [toolInfo.docsUrl] Quire docs URL for this tool
17
- * @param {String} [toolInfo.fallback] alternative suggestion
18
- * @throws {ToolNotFoundError} When executable is not found in PATH
19
- * @returns {String} Path to the executable
20
12
  */
21
- export default (executable, toolInfo) => {
13
+ export default (executable) => {
22
14
  const result = which.sync(executable, { nothrow: true })
23
15
  if (!result) {
24
- throw new ToolNotFoundError(executable, toolInfo)
16
+ console.error(`Unable to locate executable '${executable}'\n
17
+ Ensure that the '${executable}' executable is installed and available in the shell environment PATH.
18
+ `)
25
19
  }
26
20
  return result
27
21
  }
@@ -1,151 +1,35 @@
1
1
  ## CLI 11ty Module
2
2
 
3
- The `lib/11ty` module is a façade for interacting with Eleventy, the static site generator for Quire projects. It follows the singleton pattern established by `lib/npm` and `lib/git`.
3
+ The `quire-cli/lib/11ty` module is a façade for interacting with Eleventy, the static site generator for Quire projects.
4
4
 
5
- ### Usage
5
+ ### 11ty/API module
6
6
 
7
- **Recommended: Default export**
7
+ The `api` module allows the Quire CLI to programmatical configure an instance of Eleventy on which it can call methods.
8
8
 
9
- ```javascript
10
- import eleventy from '#lib/11ty/index.js'
9
+ See [Eleventy Documentation: Programmatic API](https://www.11ty.dev/docs/programmatic/)
11
10
 
12
- // Run production build
13
- await eleventy.build({ debug: true })
11
+ ### 11ty/CLI module
14
12
 
15
- // Run development server
16
- await eleventy.serve({ port: 8080 })
13
+ The `cli` module is a wrapper around the Eleventy CLI to run `@11ty/eleventy` commands.
17
14
 
18
- // Access paths through the façade
19
- const outputDir = eleventy.paths.getOutputDir()
20
- ```
15
+ See [Eleventy Documentation: Command Line Usage](https://www.11ty.dev/docs/usage/#command-line-usage)
21
16
 
22
- **Path-only consumers**
17
+ ### Paths module
23
18
 
24
- ```javascript
25
- import { paths } from '#lib/11ty/index.js'
19
+ The `paths` module returns paths for a Quire project to configure the Eleventy instance:
26
20
 
27
- const projectRoot = paths.getProjectRoot()
28
- const outputDir = paths.getOutputDir()
29
- ```
21
+ - _absolute_ path to the [Eleventy configuration](https://www.11ty.dev/docs/config/) file
22
+ - _relative_ path *from* the `quire-11ty` source *to* the `input` and `output` directories for the project
23
+ - _relative_ path *from* the project `input` *to* the Eleventy `includes` and `layouts` directories
30
24
 
31
- **Legacy usage (deprecated)**
32
25
 
33
- ```javascript
34
- // Deprecated - use default export instead
35
- import { api, cli, paths } from '#lib/11ty/index.js'
36
- await api.build(options)
37
- ```
26
+ Set environment variables for paths relative to eleventy `input` dir,
27
+ * allowing a project agnostic `quire-11ty` eleventy configuration file.
28
+ * Nota bene: environment variables read into the eleventy configuration
29
+ * file _must_ be set before the eleventy configuration file is parsed.
38
30
 
39
- ### Test Mocking
31
+ `Eleventy` does not expose an API to set the relative `includes` and `layouts` paths on the instance. In order to decouple the Eleventy configuration file from a specific project and its path on the system the exported `paths` are used by the `api` and `cli` modules to set environment variables that can be used in the `.eleventy.js` configuration.
40
32
 
41
- ```javascript
42
- const mockEleventy = {
43
- build: sandbox.stub().resolves(),
44
- serve: sandbox.stub().resolves(),
45
- paths: {
46
- getProjectRoot: () => '/project',
47
- getOutputDir: () => '_site'
48
- }
49
- }
50
- const MyCommand = await esmock('./mycommand.js', {
51
- '#lib/11ty/index.js': { default: mockEleventy }
52
- })
53
- ```
33
+ These environment variables **must be set before** the `Eleventy` instance is created and the `.eleventy.js` configuration is parsed.
54
34
 
55
- ### Quire11ty Façade
56
-
57
- The `Quire11ty` class provides abstracted Eleventy operations:
58
-
59
- | Method | Description |
60
- |--------|-------------|
61
- | `build(options)` | Run Eleventy production build |
62
- | `serve(options)` | Run Eleventy development server |
63
- | `paths` | Access to `Paths` instance for path resolution |
64
-
65
- **Build options:**
66
- - `debug` - Enable debug output
67
- - `dryRun` - Perform dry run without writing files
68
- - `quiet` - Suppress output
69
-
70
- **Serve options:**
71
- - `debug` - Enable debug output
72
- - `port` - Server port
73
- - `quiet` - Suppress output
74
-
75
- ### Paths Module
76
-
77
- The `paths` property provides a `Paths` instance with accessor methods for Eleventy path configuration. Values are computed on access to reflect the current working directory state.
78
-
79
- #### Naming Convention
80
-
81
- Method names encode the return type:
82
-
83
- | Suffix | Returns |
84
- |--------|---------|
85
- | `Path` or `Root` | Absolute filesystem path |
86
- | `Dir` | Relative directory name |
87
-
88
- #### API Reference
89
-
90
- **Absolute paths:**
91
-
92
- | Method | Description |
93
- |--------|-------------|
94
- | `getConfigPath()` | Absolute path to `.eleventy.js` config |
95
- | `getEleventyRoot()` | Absolute path to Eleventy root directory |
96
- | `getInputPath()` | Absolute path to content input directory |
97
- | `getLibQuirePath()` | Absolute path to quire-11ty installation |
98
- | `getProjectRoot()` | Absolute path to project root (`process.cwd()`) |
99
-
100
- **Relative directories:**
101
-
102
- | Method | Description |
103
- |--------|-------------|
104
- | `getDataDir()` | Data directory relative to input (`_computed`) |
105
- | `getEpubDir()` | EPUB output directory relative to Eleventy root |
106
- | `getIncludesDir()` | Includes directory relative to input |
107
- | `getInputDir()` | Input directory relative to Eleventy root |
108
- | `getLayoutsDir()` | Layouts directory relative to input |
109
- | `getOutputDir()` | Output directory relative to Eleventy root (`_site`) |
110
- | `getPublicDir()` | Public assets directory (`./public`) |
111
-
112
- **Utility:**
113
-
114
- | Method | Description |
115
- |--------|-------------|
116
- | `toObject()` | Returns all paths as an object (for logging/debugging) |
117
-
118
- ### Environment Variables
119
-
120
- The façade sets environment variables before creating the Eleventy instance:
121
-
122
- | Variable | Source |
123
- |----------|--------|
124
- | `ELEVENTY_DATA` | `paths.getDataDir()` |
125
- | `ELEVENTY_ENV` | `'production'` or `'development'` |
126
- | `ELEVENTY_INCLUDES` | `paths.getIncludesDir()` |
127
- | `ELEVENTY_LAYOUTS` | `paths.getLayoutsDir()` |
128
-
129
- These environment variables **must be set before** the Eleventy instance is created and the `.eleventy.js` configuration is parsed.
130
-
131
- ### Design Notes
132
-
133
- **Why a unified façade?**
134
-
135
- The façade pattern provides:
136
- 1. **Single point of control** - Eleventy configuration in one place
137
- 2. **Consistent logging** - All operations use `[CLI:lib/11ty]` prefix
138
- 3. **Easy mocking** - Single object to mock in tests
139
- 4. **Implementation hiding** - Consumers don't need to know if we use API or CLI
140
-
141
- **Why programmatic API instead of CLI subprocess?**
142
-
143
- The façade uses Eleventy's programmatic API internally rather than spawning a subprocess:
144
- 1. **Event access** - Direct access to `eleventy.after` and other hooks
145
- 2. **Better error handling** - Native try/catch with full stack traces
146
- 3. **No spawn overhead** - Eliminates ~100-200ms process startup time
147
- 4. **Debugging** - Easier to trace issues in-process
148
-
149
- The `cli.js` module is retained for backwards compatibility but is deprecated.
150
-
151
- **Known limitation:** The Eleventy `TemplatePathResolver` requires layouts and includes directories to be within the input directory, which prevents fully decoupling Quire project content from `quire-11ty` code. See [eleventy#2655](https://github.com/11ty/eleventy/issues/2655) (still open).
35
+ **Nota bene** The current implementation of the `Eleventy` `TemplatePathResolver` assumes that the `layouts` directory is a child of the `input` directory and prevents decoupling the Quire project content from the `quire-11ty` code; see [eleventy#2655](https://github.com/11ty/eleventy/issues/2655).