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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (245) hide show
  1. package/CHANGELOG.md +0 -36
  2. package/README.md +0 -9
  3. package/bin/cli.js +1 -46
  4. package/package.json +10 -27
  5. package/src/Command.js +6 -26
  6. package/src/commands/README.md +122 -213
  7. package/src/commands/build.js +37 -45
  8. package/src/commands/clean.js +19 -33
  9. package/src/commands/conf.js +43 -0
  10. package/src/commands/create.js +14 -42
  11. package/src/commands/epub.js +31 -67
  12. package/src/commands/index.js +2 -9
  13. package/src/commands/info.js +86 -88
  14. package/src/commands/pdf.js +82 -63
  15. package/src/commands/preview.js +31 -32
  16. package/src/commands/validate.js +20 -64
  17. package/src/commands/version.js +43 -0
  18. package/src/errors/validation/validation-error.js +11 -20
  19. package/src/helpers/clean.js +1 -1
  20. package/src/helpers/is-quire.js +31 -0
  21. package/src/helpers/test-cwd.js +6 -5
  22. package/src/helpers/which.js +4 -10
  23. package/src/lib/11ty/README.md +19 -135
  24. package/src/lib/11ty/api.js +93 -235
  25. package/src/lib/11ty/cli.js +37 -112
  26. package/src/lib/11ty/index.js +5 -64
  27. package/src/lib/11ty/paths.js +103 -0
  28. package/src/lib/README.md +0 -330
  29. package/src/lib/conf/README.md +69 -86
  30. package/src/lib/conf/config.js +3 -5
  31. package/src/lib/conf/defaults.js +0 -65
  32. package/src/lib/conf/schema.js +9 -103
  33. package/src/lib/epub/README.md +2 -133
  34. package/src/lib/epub/epub.js +11 -36
  35. package/src/lib/epub/index.js +21 -111
  36. package/src/lib/epub/pandoc.js +4 -33
  37. package/src/lib/git/README.md +2 -151
  38. package/src/lib/git/index.js +13 -217
  39. package/src/lib/i18n/README.md +3 -0
  40. package/src/lib/i18n/config.js +53 -0
  41. package/src/lib/i18n/index.js +43 -0
  42. package/src/lib/i18n/localeService.js +58 -0
  43. package/src/lib/pdf/README.md +0 -131
  44. package/src/lib/pdf/index.js +21 -124
  45. package/src/lib/pdf/paged.js +52 -100
  46. package/src/lib/pdf/prince.js +37 -115
  47. package/src/lib/pdf/split.js +33 -61
  48. package/src/lib/quire/README.md +19 -0
  49. package/src/lib/quire/index.js +353 -0
  50. package/src/lib/reporter/README.md +2 -211
  51. package/src/lib/reporter/index.js +0 -607
  52. package/src/main.js +48 -221
  53. package/src/packageConfig.js +0 -17
  54. package/src/validators/utils.js +1 -2
  55. package/man/quire.1 +0 -341
  56. package/man/quire.1.md +0 -232
  57. package/schemas/config.schema.json +0 -194
  58. package/schemas/figures.schema.json +0 -56
  59. package/schemas/layout.schema.json +0 -5
  60. package/schemas/objects.schema.json +0 -62
  61. package/schemas/publication.schema.json +0 -140
  62. package/schemas/references.schema.json +0 -29
  63. package/src/Command.spec.js +0 -99
  64. package/src/commands/build.spec.js +0 -113
  65. package/src/commands/build.test.js +0 -397
  66. package/src/commands/clean.spec.js +0 -118
  67. package/src/commands/clean.test.js +0 -382
  68. package/src/commands/config.js +0 -238
  69. package/src/commands/config.spec.js +0 -107
  70. package/src/commands/config.test.js +0 -845
  71. package/src/commands/create.spec.js +0 -112
  72. package/src/commands/create.test.js +0 -415
  73. package/src/commands/doctor.js +0 -251
  74. package/src/commands/doctor.spec.js +0 -115
  75. package/src/commands/doctor.test.js +0 -1409
  76. package/src/commands/epub.spec.js +0 -114
  77. package/src/commands/epub.test.js +0 -503
  78. package/src/commands/help.js +0 -60
  79. package/src/commands/help.test.js +0 -132
  80. package/src/commands/info.spec.js +0 -72
  81. package/src/commands/info.test.js +0 -512
  82. package/src/commands/pdf.spec.js +0 -114
  83. package/src/commands/pdf.test.js +0 -464
  84. package/src/commands/preview.spec.js +0 -97
  85. package/src/commands/preview.test.js +0 -250
  86. package/src/commands/use.js +0 -56
  87. package/src/commands/use.spec.js +0 -61
  88. package/src/commands/use.test.js +0 -280
  89. package/src/commands/validate.spec.js +0 -90
  90. package/src/commands/validate.test.js +0 -378
  91. package/src/commands/workflows.js +0 -70
  92. package/src/errors/build/build-failed-error.js +0 -19
  93. package/src/errors/build/config-field-missing-error.js +0 -20
  94. package/src/errors/build/config-file-not-found-error.js +0 -20
  95. package/src/errors/build/index.js +0 -11
  96. package/src/errors/help/help-topic-not-found-error.js +0 -30
  97. package/src/errors/help/index.js +0 -8
  98. package/src/errors/index.js +0 -58
  99. package/src/errors/input/index.js +0 -8
  100. package/src/errors/input/invalid-input-error.js +0 -21
  101. package/src/errors/install/dependency-install-error.js +0 -19
  102. package/src/errors/install/directory-not-empty-error.js +0 -25
  103. package/src/errors/install/index.js +0 -12
  104. package/src/errors/install/invalid-path-error.js +0 -31
  105. package/src/errors/install/invalid-starter-error.js +0 -27
  106. package/src/errors/install/version-not-found-error.js +0 -35
  107. package/src/errors/output/epub-generation-error.js +0 -19
  108. package/src/errors/output/index.js +0 -14
  109. package/src/errors/output/invalid-epub-library-error.js +0 -20
  110. package/src/errors/output/invalid-pdf-library-error.js +0 -20
  111. package/src/errors/output/missing-build-output-error.js +0 -21
  112. package/src/errors/output/pdf-generation-error.js +0 -24
  113. package/src/errors/output/tool-not-found-error.js +0 -37
  114. package/src/errors/project/index.js +0 -10
  115. package/src/errors/project/not-in-project-error.js +0 -20
  116. package/src/errors/project/project-create-error.js +0 -21
  117. package/src/errors/quire-error.js +0 -27
  118. package/src/errors/validation/index.js +0 -3
  119. package/src/errors/validation/unknown-config-key-error.js +0 -27
  120. package/src/errors/validation/unknown-config-operation-error.js +0 -24
  121. package/src/helpers/docs-url.js +0 -32
  122. package/src/helpers/pager.js +0 -59
  123. package/src/helpers/pager.test.js +0 -85
  124. package/src/helpers/suggest-similar.js +0 -124
  125. package/src/helpers/suggest-similar.test.js +0 -108
  126. package/src/helpers/test-cwd.test.js +0 -192
  127. package/src/lib/11ty/index.test.js +0 -655
  128. package/src/lib/commander/index.js +0 -103
  129. package/src/lib/commander/index.test.js +0 -86
  130. package/src/lib/commander/options.js +0 -237
  131. package/src/lib/commander/options.test.js +0 -205
  132. package/src/lib/conf/build-status.js +0 -103
  133. package/src/lib/conf/build-status.test.js +0 -247
  134. package/src/lib/conf/config.test.js +0 -281
  135. package/src/lib/conf/format.js +0 -60
  136. package/src/lib/conf/format.test.js +0 -106
  137. package/src/lib/conf/helpers.js +0 -91
  138. package/src/lib/conf/helpers.test.js +0 -136
  139. package/src/lib/conf/index.js +0 -22
  140. package/src/lib/constants.js +0 -28
  141. package/src/lib/doctor/README.md +0 -667
  142. package/src/lib/doctor/checks/environment/cli-version.js +0 -62
  143. package/src/lib/doctor/checks/environment/cli-version.test.js +0 -132
  144. package/src/lib/doctor/checks/environment/git-available.js +0 -77
  145. package/src/lib/doctor/checks/environment/git-available.test.js +0 -52
  146. package/src/lib/doctor/checks/environment/index.js +0 -13
  147. package/src/lib/doctor/checks/environment/node-version.js +0 -66
  148. package/src/lib/doctor/checks/environment/node-version.test.js +0 -17
  149. package/src/lib/doctor/checks/environment/npm-available.js +0 -66
  150. package/src/lib/doctor/checks/environment/npm-available.test.js +0 -52
  151. package/src/lib/doctor/checks/environment/os-info.js +0 -48
  152. package/src/lib/doctor/checks/environment/os-info.test.js +0 -81
  153. package/src/lib/doctor/checks/environment/runtime-info.js +0 -51
  154. package/src/lib/doctor/checks/environment/runtime-info.test.js +0 -132
  155. package/src/lib/doctor/checks/outputs/epub-output.js +0 -119
  156. package/src/lib/doctor/checks/outputs/epub-output.test.js +0 -277
  157. package/src/lib/doctor/checks/outputs/index.js +0 -10
  158. package/src/lib/doctor/checks/outputs/pdf-output.js +0 -144
  159. package/src/lib/doctor/checks/outputs/pdf-output.test.js +0 -377
  160. package/src/lib/doctor/checks/outputs/stale-build.js +0 -122
  161. package/src/lib/doctor/checks/outputs/stale-build.test.js +0 -282
  162. package/src/lib/doctor/checks/project/data-files.js +0 -56
  163. package/src/lib/doctor/checks/project/data-files.test.js +0 -125
  164. package/src/lib/doctor/checks/project/dependencies.js +0 -53
  165. package/src/lib/doctor/checks/project/dependencies.test.js +0 -71
  166. package/src/lib/doctor/checks/project/index.js +0 -11
  167. package/src/lib/doctor/checks/project/quire-11ty.js +0 -98
  168. package/src/lib/doctor/checks/project/quire-11ty.test.js +0 -170
  169. package/src/lib/doctor/checks/project/quire-project.js +0 -38
  170. package/src/lib/doctor/checks/project/quire-project.test.js +0 -47
  171. package/src/lib/doctor/checks/tools/index.js +0 -10
  172. package/src/lib/doctor/checks/tools/pandoc-available.js +0 -82
  173. package/src/lib/doctor/checks/tools/pandoc-available.test.js +0 -73
  174. package/src/lib/doctor/checks/tools/prince-available.js +0 -81
  175. package/src/lib/doctor/checks/tools/prince-available.test.js +0 -73
  176. package/src/lib/doctor/constants.js +0 -39
  177. package/src/lib/doctor/formatDuration.js +0 -108
  178. package/src/lib/doctor/formatDuration.test.js +0 -76
  179. package/src/lib/doctor/formatters/human.js +0 -257
  180. package/src/lib/doctor/formatters/human.test.js +0 -463
  181. package/src/lib/doctor/formatters/index.js +0 -8
  182. package/src/lib/doctor/formatters/json.js +0 -78
  183. package/src/lib/doctor/formatters/json.test.js +0 -174
  184. package/src/lib/doctor/formatters/shared.js +0 -129
  185. package/src/lib/doctor/formatters/shared.test.js +0 -194
  186. package/src/lib/doctor/index.js +0 -271
  187. package/src/lib/doctor/index.test.js +0 -797
  188. package/src/lib/epub/engines.js +0 -46
  189. package/src/lib/epub/index.test.js +0 -518
  190. package/src/lib/epub/pandoc.test.js +0 -122
  191. package/src/lib/epub/schema.js +0 -21
  192. package/src/lib/error/README.md +0 -170
  193. package/src/lib/error/handler.js +0 -107
  194. package/src/lib/git/index.spec.js +0 -80
  195. package/src/lib/git/index.test.js +0 -453
  196. package/src/lib/help/frontmatter.js +0 -77
  197. package/src/lib/help/frontmatter.test.js +0 -139
  198. package/src/lib/help/index.js +0 -146
  199. package/src/lib/help/index.test.js +0 -188
  200. package/src/lib/help/topics/configuration.md +0 -77
  201. package/src/lib/help/topics/debugging.md +0 -69
  202. package/src/lib/help/topics/epub.md +0 -74
  203. package/src/lib/help/topics/pdf.md +0 -74
  204. package/src/lib/help/topics/publishing.md +0 -80
  205. package/src/lib/help/topics/workflows.md +0 -50
  206. package/src/lib/installer/index.js +0 -309
  207. package/src/lib/installer/index.spec.js +0 -83
  208. package/src/lib/installer/index.test.js +0 -545
  209. package/src/lib/logger/README.md +0 -424
  210. package/src/lib/logger/debug.js +0 -132
  211. package/src/lib/logger/debug.spec.js +0 -130
  212. package/src/lib/logger/debug.test.js +0 -128
  213. package/src/lib/logger/index.js +0 -228
  214. package/src/lib/logger/index.spec.js +0 -131
  215. package/src/lib/logger/index.test.js +0 -578
  216. package/src/lib/npm/README.md +0 -127
  217. package/src/lib/npm/index.js +0 -198
  218. package/src/lib/npm/index.spec.js +0 -60
  219. package/src/lib/npm/index.test.js +0 -355
  220. package/src/lib/pdf/engines.js +0 -46
  221. package/src/lib/pdf/index.test.js +0 -708
  222. package/src/lib/pdf/paged.test.js +0 -366
  223. package/src/lib/pdf/prince.test.js +0 -202
  224. package/src/lib/pdf/schema.js +0 -21
  225. package/src/lib/pdf/split.test.js +0 -445
  226. package/src/lib/platform.js +0 -95
  227. package/src/lib/process/manager.js +0 -110
  228. package/src/lib/process/manager.test.js +0 -55
  229. package/src/lib/project/build.js +0 -162
  230. package/src/lib/project/build.test.js +0 -275
  231. package/src/lib/project/config.js +0 -48
  232. package/src/lib/project/config.test.js +0 -134
  233. package/src/lib/project/detect.js +0 -47
  234. package/src/lib/project/detect.test.js +0 -157
  235. package/src/lib/project/index.js +0 -56
  236. package/src/lib/project/output-paths.js +0 -87
  237. package/src/lib/project/output-paths.test.js +0 -66
  238. package/src/lib/project/paths.js +0 -272
  239. package/src/lib/project/version.js +0 -110
  240. package/src/lib/project/version.test.js +0 -350
  241. package/src/lib/reporter/index.test.js +0 -862
  242. package/src/main.spec.js +0 -61
  243. package/src/main.test.js +0 -347
  244. package/src/validators/validate-data-files.js +0 -154
  245. package/src/validators/validate-data-files.test.js +0 -217
@@ -0,0 +1,103 @@
1
+ import { fileURLToPath } from 'node:url'
2
+ import fs from 'fs-extra'
3
+ import path from 'node:path'
4
+
5
+ const __filename = fileURLToPath(import.meta.url)
6
+ const __dirname = path.dirname(__filename)
7
+
8
+ /**
9
+ * Eleventy configuration paths
10
+ * @see https://www.11ty.dev/docs/config/#configuration-options
11
+ *
12
+ * Resolve the absolute path to the Eleventy configuration module,
13
+ * `eleventyRoot` is _relative_ to `main.js`, the CLI entry point.
14
+ * Both `input` and `output` are _relative_ to the `config` module.
15
+ *
16
+ * @todo
17
+ * - refactor the paths module as a concern of the `lib/quire` module
18
+ * - refactor resolving an absolute path to the correct eleventy version root;
19
+ * this needs to use the correct `quire-11ty` version for the project
20
+ * and correctly resolve the path to the target of the 'latest' symlink
21
+ */
22
+ const cliRoot = path.resolve(__dirname, path.join('..', '..'))
23
+ const eleventyConfig = '.eleventy.js'
24
+ const version = 'latest'
25
+
26
+ export const projectRoot = process.cwd()
27
+
28
+ /**
29
+ * Absolute path to the latest installed version of `quire-11ty`
30
+ * @todo use version read from the project `.quire-version` file
31
+ */
32
+ const libQuirePath = path.resolve(__dirname, path.join(cliRoot, 'lib', 'quire', 'versions', version))
33
+
34
+ /**
35
+ * Absolute path to the current version of `quire-11ty`
36
+ * Nota bene: to get a relative path to the `eleventyRoot`,
37
+ * for example when the version is specified is 'latest',
38
+ * it must be set to the real path to the symlink target.
39
+ *
40
+ * @todo refactor how and *when* the eleventyRoot is determined:
41
+ * - we only need eleventyRoot for cli commands that run 11ty
42
+ * - paths module is a concern of the `quire` module
43
+ * - global quire-cli installation
44
+ * - local quire-cli installation
45
+ *
46
+ * For an excellent developer experience, the quire-11ty code should be
47
+ * installed into an `11ty` or `quire-11ty` directory in the `projectRoot`
48
+ * this will allow us to more easily manage symlinks for local development
49
+ * using unpublished `quire-11ty` code.
50
+ * @example
51
+ * ```sh
52
+ * blargh/
53
+ * .git/
54
+ * .gitignore
55
+ * .node-version
56
+ * .quire-version
57
+ * 11ty@ --> /Users/mph/Code/Getty/quire/packages/11ty
58
+ * content/
59
+ * CHANGELOG.md
60
+ * LICENSE
61
+ * README.md
62
+ * package.json
63
+ * package-lock.json
64
+ * ```
65
+ * Installing to a directory will allow more cleanly `eject` and `uneject`
66
+ * using a symlink or single directory `rm -rf`.
67
+ * Should the `11ty` directory be a dot directory to hide the complexity from
68
+ * users or should it be visible to be more explicit when project is ejected?
69
+ */
70
+ const getEleventyRoot = () => {
71
+ // try {
72
+ // return fs.readdirSync(projectRoot).includes(eleventyConfig)
73
+ // ? projectRoot
74
+ // : fs.realpathSync(libQuirePath)
75
+ // } catch (error) {
76
+ // throw new Error(`[CLI:11ty] Unable to read project directory for eleventy config ${error}`)
77
+ // }
78
+ return projectRoot
79
+ }
80
+
81
+ export const eleventyRoot = getEleventyRoot()
82
+
83
+ const inputDir = path.join(projectRoot, 'content')
84
+
85
+ export default {
86
+ /**
87
+ * An abolsute path to eleventy config module
88
+ */
89
+ config: path.join(eleventyRoot, '.eleventy.js'),
90
+ /**
91
+ * Paths _relative to_ the eleventy config module
92
+ */
93
+ input: path.relative(eleventyRoot, inputDir),
94
+ output: path.relative(eleventyRoot, path.join(projectRoot, '_site')),
95
+ epub: path.relative(eleventyRoot, path.join(projectRoot, '_epub')),
96
+ /**
97
+ * Paths _relative to_ the `input` directory
98
+ */
99
+ data: '_computed',
100
+ includes: path.relative(inputDir, path.join(eleventyRoot, '_includes')),
101
+ layouts: path.relative(inputDir, path.join(eleventyRoot, '_layouts')),
102
+ public: './public',
103
+ }
package/src/lib/README.md CHANGED
@@ -1,330 +0,0 @@
1
- # CLI Library Modules
2
-
3
- This directory contains domain-specific modules that encapsulate the core functionality of the Quire CLI. Each module is designed around a single responsibility and provides a façade for its domain.
4
-
5
- ## Architecture Overview
6
-
7
- ```
8
- Commands Layer
9
- ┌───────────────────────────────────────────────────┐
10
- │ build preview new pdf epub info doctor │
11
- └────────────────────────┬──────────────────────────┘
12
-
13
- ┌────────────────────────┴──────────────────────────┐
14
- │ lib/ modules │
15
- └───────────────────────────────────────────────────┘
16
-
17
- ┌─────────────────────────────────────────────────────────────────────────┐
18
- │ Domain Modules │
19
- │ ┌────────────┐ ┌──────────┐ ┌────────────┐ ┌──────────┐ ┌────────┐ │
20
- │ │ project/ │ │ 11ty/ │ │ pdf/ │ │ epub/ │ │doctor/ │ │
21
- │ │ │ │ │ │ │ │ │ │ │ │
22
- │ │ - paths │ │ - api │ │ - pagedjs │ │ - epubjs │ │-checks │ │
23
- │ │ - config │ │ - cli │ │ - prince │ │ - pandoc │ │-format │ │
24
- │ │ - detect │ │ │ │ │ │ │ │ │ │
25
- │ │ - version │ │ │ │ │ │ │ │ │ │
26
- │ └────┬───────┘ └────┬─────┘ └────┬───────┘ └────┬─────┘ └───┬────┘ │
27
- └───────┼───────────────┼─────────────┼───────────────┼─────────────┼──────┘
28
- │ │ │ │ │
29
- │ ┌────────┴─────────────┴───────────────┴─────────────┘
30
- │ │
31
- ┌───────┴──────┴──────────────────────────────────────────────────┐
32
- │ Installation Module │
33
- │ ┌──────────────────────────────────────────────────────────┐ │
34
- │ │ installer/ │ │
35
- │ │ - initStarter (clone starter, setup project) │ │
36
- │ │ - installInProject (install @thegetty/quire-11ty) │ │
37
- │ │ - latest (resolve version from npm) │ │
38
- │ │ - versions (list published versions) │ │
39
- │ └──────────────────────────────────────────────────────────┘ │
40
- └───────────────────────────────┬─────────────────────────────────┘
41
-
42
- ┌───────────────────────────────┴─────────────────────────────────┐
43
- │ Infrastructure Modules │
44
- │ ┌────────┐ ┌────────┐ ┌────────┐ ┌─────────┐ ┌──────────┐ │
45
- │ │ npm/ │ │ git/ │ │ conf/ │ │ error/ │ │ logger/ │ │
46
- │ │ │ │ │ │ │ │ │ │ │ │
47
- │ └────────┘ └────────┘ └────────┘ └─────────┘ └──────────┘ │
48
- │ ┌───────────┐ ┌───────────┐ │
49
- │ │ reporter/ │ │ ui/ │ │
50
- │ │ │ │ (prompt) │ │
51
- │ └───────────┘ └───────────┘ │
52
- └─────────────────────────────────────────────────────────────────┘
53
- ```
54
-
55
- ## Module Reference
56
-
57
- ### Domain Modules
58
-
59
- These modules encapsulate specific business domains of Quire.
60
-
61
- #### `project/`
62
- **Purpose:** Project-level concerns including paths, detection, configuration, and version management.
63
-
64
- | Export | Description |
65
- |--------|-------------|
66
- | `paths` (default) | Singleton for path resolution |
67
- | `Paths` | Class for custom path instances |
68
- | `DATA_DIR` | Path to data files directory (`content/_data`) |
69
- | `PROJECT_MARKERS` | Files that identify a Quire project |
70
- | `REQUIRED_DATA_FILES` | Required data files (`publication.yaml`) |
71
- | `SOURCE_DIRECTORIES` | Directories monitored for changes |
72
- | `detect(dirpath)` | Check if directory is a Quire project |
73
- | `loadProjectConfig(projectRoot?)` | Load and validate project config |
74
- | `getVersion(projectPath?)` | Read `quire-11ty` version from project |
75
- | `setVersion(version, projectPath?)` | Write `quire-11ty` version to project |
76
- | `getVersionsFromStarter(projectPath)` | Read versions from starter package.json |
77
- | `readVersionFile(projectPath)` | Read raw version file contents |
78
- | `writeVersionFile(projectPath, info)` | Write version file contents |
79
-
80
- **Dependencies:** `conf/`, `fs-extra`
81
-
82
- #### `11ty/`
83
- **Purpose:** Eleventy build system integration via API or CLI.
84
-
85
- | Export | Description |
86
- |--------|-------------|
87
- | `api` | Programmatic Eleventy control |
88
- | `cli` | CLI-based Eleventy execution |
89
- | `paths` | Re-exported from `project/` |
90
- | `Paths` | Re-exported from `project/` |
91
-
92
- **Dependencies:** `project/`
93
-
94
- #### `pdf/`
95
- **Purpose:** PDF generation using Prince or Paged.js.
96
-
97
- | Export | Description |
98
- |--------|-------------|
99
- | `default` | Factory returning configured PDF generator |
100
-
101
- **Implementations:** `prince.js`, `paged.js`
102
-
103
- **Dependencies:** `project/`
104
-
105
- #### `epub/`
106
- **Purpose:** EPUB generation using Pandoc.
107
-
108
- | Export | Description |
109
- |--------|-------------|
110
- | `default` | EPUB generator façade |
111
-
112
- **Dependencies:** `project/`
113
-
114
- #### `doctor/`
115
- **Purpose:** Diagnostic checks for Quire environment and project health.
116
-
117
- | Export | Description |
118
- |--------|-------------|
119
- | `default` | Object with all check functions and arrays |
120
- | `checks` | Flat array of all diagnostic checks |
121
- | `checkSections` | Checks organized by section (Environment, Project) |
122
- | `runAllChecks()` | Run all checks, return flat results array |
123
- | `runAllChecksWithSections()` | Run all checks, return results by section |
124
- | `checkNodeVersion()` | Verify Node.js >= 22 |
125
- | `checkNpmAvailable()` | Verify npm in PATH |
126
- | `checkGitAvailable()` | Verify git in PATH |
127
- | `checkQuireProject()` | Detect project marker files |
128
- | `checkDependencies()` | Verify node_modules exists |
129
- | `checkDataFiles()` | Validate YAML files in content/_data/ |
130
- | `checkStaleBuild()` | Compare source vs build timestamps |
131
-
132
- **Sub-modules:**
133
-
134
- | File | Description |
135
- |------|-------------|
136
- | `formatDuration.js` | Human-readable time duration formatting |
137
-
138
- **Duration Formatting:**
139
-
140
- The `formatDuration` function converts milliseconds to the most appropriate time unit:
141
-
142
- | Duration | Example Output |
143
- |----------------|-----------------|
144
- | < 1 minute | "45 seconds" |
145
- | < 1 hour | "30 minutes" |
146
- | < 1 day | "5 hours" |
147
- | < 1 week | "3 days" |
148
- | < 1 month | "2 weeks" |
149
- | < 1 year | "3 months" |
150
- | >= 1 year | "2 years" |
151
-
152
- **Data Files Validation:**
153
-
154
- The `checkDataFiles` function validates YAML files in `content/_data/`:
155
-
156
- | Validation | Description |
157
- |------------|-------------|
158
- | Required files | Checks `publication.yaml` exists |
159
- | YAML syntax | Parses each file and reports syntax errors |
160
- | Schema validation | Validates against JSON schemas in `schemas/` |
161
- | Duplicate IDs | Detects duplicate `id` values in arrays |
162
-
163
- **Dependencies:** `project/`, `npm/`, `git/`, `validators/validate-data-files`
164
-
165
- #### `installer/`
166
- **Purpose:** Installation of `@thegetty/quire-11ty` into Quire projects.
167
-
168
- | Export | Description |
169
- |--------|-------------|
170
- | `installer` | Object with all installer methods |
171
- | `initStarter(starter, projectPath, options)` | Clone and setup starter project |
172
- | `installInProject(projectPath, version, options)` | Install `@thegetty/quire-11ty` package |
173
- | `latest(version?)` | Resolve version from npm registry |
174
- | `versions()` | List all published `@thegetty/quire-11ty` versions |
175
-
176
- **Dependencies:** `project/`, `npm/`, `git/`
177
-
178
- ### Infrastructure Modules
179
-
180
- These modules provide cross-cutting concerns and external tool integrations.
181
-
182
- #### `npm/`
183
- **Purpose:** NPM operations façade.
184
-
185
- | Export | Description |
186
- |--------|-------------|
187
- | `default` | Singleton npm façade |
188
- | `init(cwd, options?)` | Run `npm init` |
189
- | `install(cwd, options?)` | Run `npm install` |
190
- | `pack(spec, dest, options?)` | Run `npm pack` |
191
- | `cacheClean(cwd?)` | Run `npm cache clean` |
192
- | `view(pkg, field?)` | Query package info |
193
- | `show(pkg, field?)` | Query package versions |
194
- | `version()` | Get npm version |
195
- | `isAvailable()` | Check npm in PATH |
196
- | `fetchFromRegistry(pkg)` | Direct registry API call |
197
- | `getCompatibleVersion(pkg, range)` | Resolve semver range |
198
-
199
- **Dependencies:** `execa`, `node-fetch`
200
-
201
- #### `git/`
202
- **Purpose:** Git operations via simple-git.
203
-
204
- | Export | Description |
205
- |--------|-------------|
206
- | `default` | Configured simple-git instance |
207
-
208
- **Dependencies:** `simple-git`
209
-
210
- #### `conf/`
211
- **Purpose:** CLI configuration persistence and schema-aware helpers.
212
-
213
- | Export | Source | Description |
214
- |--------|--------|-------------|
215
- | `default` | `config.js` | `Conf` singleton instance |
216
- | `isValidKey(key)` | `helpers.js` | Check if key exists in schema |
217
- | `getValidKeys()` | `helpers.js` | Sorted array of all schema keys |
218
- | `coerceValue(key, value)` | `helpers.js` | Coerce CLI string to schema type |
219
- | `formatValidationError(key, value)` | `helpers.js` | Format error with enum/description hints |
220
- | `getDefault(key)` | `helpers.js` | Get default value for a key |
221
- | `getKeyDescription(key)` | `helpers.js` | Get schema description for a key |
222
- | `formatSettings(store, options)` | `helpers.js` | Format all settings for display |
223
-
224
- Uses a barrel export (`index.js`) rather than a wrapper class to keep pure helper functions separate from the stateful `Conf` singleton. This avoids circular dependencies with the logger module and keeps helpers directly testable without mocking.
225
-
226
- **Dependencies:** `conf`
227
-
228
- #### `logger.js`
229
- **Purpose:** Logging abstraction.
230
-
231
- | Export | Description |
232
- |--------|-------------|
233
- | `default` | Logger instance (loglevel) |
234
-
235
- **Dependencies:** `loglevel`
236
-
237
- #### `reporter/`
238
- **Purpose:** Progress reporting for long-running operations.
239
-
240
- | Export | Description |
241
- |--------|-------------|
242
- | `default` | Reporter façade |
243
-
244
- #### `error/`
245
- **Purpose:** Centralized error handling and formatting.
246
-
247
- | Export | Description |
248
- |--------|-------------|
249
- | `formatError(error, options)` | Format error for display |
250
- | `handleError(error, options)` | Handle single error (format, log, exit) |
251
- | `handleErrors(errors, options)` | Handle multiple errors (batch validation) |
252
-
253
- **Features:**
254
- - Consistent error formatting with suggestion, docs URL, file path
255
- - Debug mode shows error codes and stack traces
256
- - Conditional `--debug` hint (controlled by `showDebugHint` property)
257
- - Exit code management per error category
258
-
259
- **Dependencies:** `logger/`
260
-
261
- #### `ui/`
262
- **Purpose:** Display and interactive prompt
263
-
264
- _Future feature: Not yet impemented._
265
-
266
- ## Design Patterns
267
-
268
- ### Singleton façade
269
- Most modules export a singleton instance as the default export:
270
- ```javascript
271
- import npm from '#lib/npm/index.js'
272
- await npm.install('/path/to/project')
273
- ```
274
-
275
- ### Optional Parameters with Defaults
276
- Functions that operate on projects default to `cwd` when path not provided:
277
- ```javascript
278
- // Uses current working directory
279
- setVersion('1.0.0')
280
-
281
- // Uses explicit path
282
- setVersion('1.0.0', '/path/to/project')
283
- ```
284
-
285
- ### Re-exports for Convenience
286
- Modules re-export commonly used dependencies:
287
- ```javascript
288
- // 11ty/ re-exports paths from project/
289
- import { paths } from '#lib/11ty/index.js'
290
- ```
291
-
292
- ## Import Aliases
293
-
294
- Use these aliases for imports:
295
-
296
- | Alias | Path |
297
- |-------|------|
298
- | `#lib/` | `src/lib/` |
299
- | `#src/` | `src/` |
300
- | `#helpers/` | `src/helpers/` |
301
-
302
- Example:
303
- ```javascript
304
- import npm from '#lib/npm/index.js'
305
- import { installer } from '#lib/installer/index.js'
306
- import paths, { loadProjectConfig } from '#lib/project/index.js'
307
- ```
308
-
309
- ## Testing
310
-
311
- Each module has associated test files:
312
-
313
- | Pattern | Purpose |
314
- |---------|---------|
315
- | `*.spec.js` | Unit tests (interface contracts) |
316
- | `*.test.js` | Integration tests (with mocked dependencies) |
317
-
318
- Tests use:
319
- - **AVA** for test runner
320
- - **esmock** for ESM module mocking
321
- - **sinon** for stubs and spies
322
- - **memfs** for in-memory filesystem
323
-
324
- ## Adding a New Module
325
-
326
- 1. Create directory: `lib/<module-name>/`
327
- 2. Create entry point: `index.js` with façade pattern
328
- 3. Export singleton or factory as default
329
- 4. Add tests: `index.spec.js` and/or `index.test.js`
330
- 5. Update this README with module documentation
@@ -1,121 +1,104 @@
1
- ## CLI Configuration Module
1
+ ## CLI Configuration Manager
2
2
 
3
- The `conf/` module manages reading and writing (persisting) settings for the Quire CLI using the [`conf`](https://github.com/sindresorhus/conf) package.
3
+ This `quire-cli/lib/config` module manages reading and writing (persisting) options for the Quire CLI using the [`conf`](https://github.com/sindresorhus/conf) package.
4
4
 
5
5
  `conf` stores the config in the system default [user config directory](https://github.com/sindresorhus/env-paths#pathsconfig). For example, on macOS, the config file will be stored in the `~/Library/Preferences/@thegetty/quire-cli` directory.
6
6
 
7
7
  > Changes are written to disk atomically, so if the process crashes during a write, it will not corrupt the existing config.
8
8
 
9
- ### Module Structure
9
+ ### Configuration
10
10
 
11
+ `logLevel` The default logging level for the Quire CLI output; default `'info'`.
12
+
13
+ `projectTemplate` A default project starter template to use when creating new projects; default `'quire-starter-default'`.
14
+
15
+ `quirePath` The relative path to `quire-11ty` installed in the project directory; default `./11ty`. When set to `null`, `quire-11ty` is installed to the CLI `lib/quire/versions/<version>/` directory.
16
+
17
+ ```sh
18
+ ❯ quire config quire-path '.'
11
19
  ```
12
- conf/
13
- ├── index.js Barrel export (config singleton + helpers + format)
14
- ├── config.js Conf singleton instance
15
- ├── helpers.js Pure schema-aware validation and coercion
16
- ├── format.js Display formatting with optional chalk styling
17
- ├── defaults.js Default configuration values
18
- ├── schema.js JSON Schema definitions
19
- ├── migrations.js Version migration functions
20
- ├── config.test.js Integration tests for Conf instance
21
- ├── helpers.test.js Unit tests for validation/coercion helpers
22
- └── format.test.js Unit tests for display formatting
20
+
21
+ `quireVersion` The default version of `quire-11ty` to install when creating new Quire projects; default `'latest'`.
22
+
23
+ ```sh
24
+ quire config quire-version '1.0.0'
23
25
  ```
24
26
 
25
- ### Architecture: Barrel Export vs Singleton Wrapper
27
+ `telemetry` Send anonymous data about Quire usage; default `false`.
26
28
 
27
- The module uses a **barrel export** pattern (`index.js`) rather than wrapping the `Conf` singleton in a class. This is a deliberate design choice:
29
+ ```sh
30
+ ❯ quire config telemetry --enabled
31
+ ```
28
32
 
29
- - **`config.js`** exports the `Conf` singleton that owns mutable state (the on-disk JSON store, file watching, schema validation, migrations). This is a thin wrapper around the `conf` package.
30
- - **`helpers.js`** exports pure functions (`isValidKey`, `coerceValue`, `formatValidationError`, etc.) for schema-aware validation and coercion. These import only `schema.js` and `defaults.js` (pure data), keeping them free of transitive dependencies.
31
- - **`format.js`** exports display formatting functions (`formatSettings`, `getKeyDescription`) that depend on `chalk` for optional coloured output. Separated from `helpers.js` to isolate the chalk dependency from the pure validation/coercion functions.
32
- - **`index.js`** re-exports all three, providing a single import path for consumers.
33
+ ```sh
34
+ quire config telemetry --disabled
35
+ ```
33
36
 
34
- A wrapper class was considered but rejected for three reasons:
37
+ `updateChannels` A list of distribution tags to use when checking for version updates; default `['latest']`. To show notifications for pre-releases version updates include `'pre-release'` in the array of channels. This can be set using the configuration `--pre-release` command flag.
35
38
 
36
- 1. **No shared state.** The helpers operate on schema/defaults (static data), not the config store (runtime state). Binding them to the singleton would create a false coupling.
37
- 2. **Circular dependency avoidance.** The logger imports `config.js`. If helpers were methods on the config singleton, importing them would trigger the full `Conf` instantiation chain. By depending only on `schema.js` and `defaults.js` (pure data modules), `helpers.js` stays free of transitive dependencies.
38
- 3. **Testability.** Pure functions are directly testable with simple import + assert — no esmock, no sinon, no constructor stubbing. Compare `helpers.test.js` (pure function tests) with `config.test.js` (integration tests requiring esmock to mock the `Conf` constructor).
39
+ ```sh
40
+ quire config update-channels
41
+ Quire configured to check for updates tagged 'latest'
42
+ ```
39
43
 
40
- ### Exports
44
+ ```sh
45
+ ❯ quire config update-channels --add 'pre-release'
46
+ Quire configured to check for updates tagged 'latest', 'pre-release'
47
+ ```
41
48
 
42
- ```javascript
43
- // Barrel import — config singleton + named helpers
44
- import config, { isValidKey, coerceValue } from '#lib/conf/index.js'
49
+ ```sh
50
+ quire config update-channels --rm 'pre-release'
51
+ Quire configured to check for updates tagged 'latest'
52
+ ```
53
+
54
+ `updateInterval` Interval at which to check for updates to the Quire CLI and project's `quire-11ty` version; default `'DAILY'`.
45
55
 
46
- // Direct import — config singleton only (used by logger, etc.)
47
- import config from '#lib/conf/config.js'
56
+ ```sh
57
+ quire config update-interval
58
+ Quire configured to check for updates DAILY
48
59
  ```
49
60
 
50
- | Export | Source | Description |
51
- |--------|--------|-------------|
52
- | `default` | `config.js` | `Conf` singleton instance |
53
- | `isValidKey(key)` | `helpers.js` | Check if key exists in schema |
54
- | `getValidKeys()` | `helpers.js` | Sorted array of all schema keys |
55
- | `coerceValue(key, value)` | `helpers.js` | Coerce CLI string to schema type |
56
- | `formatValidationError(key, value)` | `helpers.js` | Format error with enum/description hints |
57
- | `getDefault(key)` | `helpers.js` | Get default value for a key |
58
- | `getKeyDescription(key)` | `format.js` | Get schema description for a key |
59
- | `formatSettings(store, options)` | `format.js` | Format all settings for display (with optional chalk styling) |
61
+ ```sh
62
+ ❯ quire config update-interval WEEKLY
63
+ ```
60
64
 
61
- ### Display Formatting
65
+ `versionFile ['.quire-version']` The default file name for the `quire-11ty` version file.
62
66
 
63
- `formatSettings` accepts an options object controlling output:
67
+ ```sh
68
+ ❯ quire config version-file '.blargh'
69
+ ```
64
70
 
65
- | Option | Type | Default | Description |
66
- |--------|------|---------|-------------|
67
- | `configPath` | string | — | Path shown in header (e.g. `quire-cli configuration /path/to/config`) |
68
- | `showInternal` | boolean | `false` | Include `__internal__`-prefixed keys |
69
- | `useColor` | boolean | `false` | Apply chalk styling (bold header, cyan keys, dim descriptions) |
71
+ ### Quire CLI `config` Command
70
72
 
71
- When `useColor` is `true`, output uses:
72
- - **Bold** for the header line
73
- - **Cyan** for key names
74
- - **Dim** for descriptions and the help hint
73
+ Running the `config` command without any arguments will start an interactive prompt to configure Quire.
75
74
 
76
- When `useColor` is `false` (default), no ANSI escape codes are emitted.
75
+ To view an individual configuration value and its default value use:
77
76
 
78
- The settings command reads `logUseColor` from the config to determine whether to pass `useColor: true`.
77
+ ```sh
78
+ ❯ quire config [key]
79
+ ```
80
+
81
+ To view the current `logLevel` setting for example:
79
82
 
80
- ### Settings Reference
83
+ ```sh
84
+ ❯ quire config logLevel
85
+ loglevel: 'debug' (default 'info')
86
+ ```
81
87
 
82
- Use `quire settings` to view all settings with descriptions, or manage individual values:
88
+ To set an individual configuration value, use the `set` argument:
83
89
 
84
90
  ```sh
85
- quire settings # Show all settings (coloured if logUseColor is true)
86
- quire settings get <key> # Get a single value
87
- quire settings set <key> <value> # Set a value
88
- quire settings delete <key> # Delete (reset to default)
89
- quire settings reset [key] # Reset all or single key
90
- quire settings path # Show settings file path
91
- quire settings --json # Output all settings as JSON
92
- quire settings get <key> --json # Output single value as JSON
93
- quire settings --json --debug # Include __internal__ keys in JSON output
91
+ quire config set <key> <value>
94
92
  ```
95
93
 
96
- `staleThreshold` How stale an output must be before `quire doctor` warns; default `'HOURLY'`. Options: `'ZERO'` (0 min), `'SHORT'` (5 min), `'HOURLY'` (60 min), `'DAILY'` (12 hours), `'NEVER'` (disabled).
94
+ To reset *all* keys to their default values, use the `reset` argument:
97
95
 
98
96
  ```sh
99
- ❯ quire config set staleThreshold DAILY
97
+ ❯ quire config reset
100
98
  ```
101
99
 
102
- The `--json` flag outputs raw JSON to stdout (bypassing the logger), suitable for piping to `jq` or other tools. `__internal__` keys are excluded from JSON output unless `--debug` is also passed, consistent with the plain-text display.
103
-
104
- | Key | Type | Default | Description |
105
- |-----|------|---------|-------------|
106
- | `debug` | boolean | `false` | Enable debug output by default |
107
- | `epubEngine` | string | `'epubjs'` | EPUB engine (`epubjs`, `pandoc`) |
108
- | `logLevel` | string | `'info'` | Log level (`trace`, `debug`, `info`, `warn`, `error`, `silent`) |
109
- | `logPrefix` | string | `'quire'` | Prefix text for log messages |
110
- | `logPrefixStyle` | string | `'bracket'` | Prefix style (`bracket`, `emoji`, `plain`, `none`) |
111
- | `logShowLevel` | boolean | `false` | Show level label in output |
112
- | `logUseColor` | boolean | `true` | Use colored output |
113
- | `logColorMessages` | boolean | `true` | Color message text by level |
114
- | `pdfEngine` | string | `'pagedjs'` | PDF engine (`pagedjs`, `prince`) |
115
- | `projectTemplate` | string | (GitHub URL) | Default starter template |
116
- | `quire11tyPath` | string | `'.'` | Path to quire-11ty package |
117
- | `quireVersion` | string | `'latest'` | Version of quire-11ty to install |
118
- | `updateChannel` | string | `'rc'` | Release channel (`stable`, `rc`, `beta`, `alpha`) |
119
- | `updateInterval` | string | `'DAILY'` | Update check frequency (`DAILY`, `WEEKLY`, `MONTHLY`, `NEVER`) |
120
- | `verbose` | boolean | `false` | Enable verbose output by default |
121
- | `versionFile` | string | `'.quire'` | Filename to identify Quire projects |
100
+ To reset an individual key to its default value:
101
+
102
+ ```sh
103
+ ❯ quire config reset [key]
104
+ ```
@@ -1,16 +1,14 @@
1
1
  import Conf from 'conf'
2
- import packageConfig from '#src/packageConfig.js'
3
2
  import defaults from './defaults.js'
4
3
  import migrations from './migrations.js'
4
+ import packageConfig from '#src/packageConfig.js'
5
5
  import schema from './schema.js'
6
6
 
7
7
  const { name, version } = packageConfig
8
8
 
9
- const beforeEachMigration = (_store, context) => {
9
+ const beforeEachMigration = (store, context) => {
10
10
  const { fromVersion, toVersion } = context
11
- // Call console directly to avoid circular dependency (logger imports config)
12
- // Migration messages are rare, so the simpler formatting is acceptable
13
- console.info(`[quire] Migrating config from ${fromVersion} → ${toVersion}`)
11
+ console.info(`quire-cli migrating config from ${fromVersion} ${toVersion}`)
14
12
  }
15
13
 
16
14
  /**