@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,424 +0,0 @@
1
- # Logger Module
2
-
3
- A logging façade for the Quire CLI that provides colored output, log level filtering, and module-specific prefixes. Aligned with the 11ty package logging format for a consistent user experience.
4
-
5
- ## Features
6
-
7
- - **Log level filtering** via [loglevel](https://github.com/pimterry/loglevel)
8
- - **Colored output** via [chalk](https://github.com/chalk/chalk)
9
- - **Module-specific prefixes** for traceable log messages
10
- - **Configuration integration** reads level from `QUIRE_LOG_LEVEL` environment variable
11
- - **11ty format alignment** consistent `[quire] LEVEL prefix message` output
12
- - **Namespace debugging** via [debug](https://github.com/debug-js/debug) for surgical internal debugging
13
-
14
- ## Two Logging Systems
15
-
16
- The logger module provides two complementary systems:
17
-
18
- | System | Purpose | Environment Variable | Use Case |
19
- |--------|---------|---------------------|----------|
20
- | **Logger** (loglevel) | User-facing output | `QUIRE_LOG_LEVEL` | Status messages, warnings, errors |
21
- | **Debug** (debug) | Developer debugging | `DEBUG` | Internal tracing, troubleshooting |
22
-
23
- ### When to Use Each
24
-
25
- ```javascript
26
- // User-facing output - use logger
27
- import { logger } from '#lib/logger/index.js'
28
- logger.info('Building PDF...') // Always relevant to users
29
- logger.error('Build failed') // User needs to see this
30
-
31
- // Internal debugging - use debug
32
- import createDebug from '#lib/logger/debug.js'
33
- const debug = createDebug('lib:pdf')
34
- debug('printer options: %O', opts) // Only developers care about this
35
- ```
36
-
37
- ## Command Integration
38
-
39
- The base `Command` class provides inherited `logger` and `debug` properties to all commands:
40
-
41
- ```javascript
42
- // In a command class - use inherited properties
43
- export default class BuildCommand extends Command {
44
- async action(options, command) {
45
- // Debug output (via DEBUG env var)
46
- this.debug('called with options %O', options)
47
-
48
- // User-facing logger
49
- this.logger.info('Building publication...')
50
- this.logger.warn('Deprecated option used')
51
- this.logger.error('Build failed')
52
- }
53
- }
54
- ```
55
-
56
- Each command automatically gets:
57
- - `this.logger` - A logger with prefix `commands:{name}` (e.g., `commands:build`)
58
- - `this.debug` - A debug instance with namespace `quire:commands:{name}`
59
-
60
- This ensures consistent prefixes and makes it easy to filter debug output:
61
-
62
- ```bash
63
- # Debug all commands
64
- DEBUG=quire:commands:* quire build
65
-
66
- # Debug specific command
67
- DEBUG=quire:commands:build quire build
68
- ```
69
-
70
- ## Usage
71
-
72
- ### Simple Usage (Singleton)
73
-
74
- ```javascript
75
- import { logger } from '#lib/logger/index.js'
76
-
77
- logger.info('Starting build...')
78
- logger.debug('Processing file:', filename)
79
- logger.warn('Deprecated option used')
80
- logger.error('Build failed:', error.message)
81
- ```
82
-
83
- ### Module-Specific Logger
84
-
85
- ```javascript
86
- import createLogger from '#lib/logger/index.js'
87
-
88
- const logger = createLogger('lib:pdf')
89
-
90
- logger.info('Generating PDF...')
91
- // Output: [quire] INFO lib:pdf Generating PDF...
92
- ```
93
-
94
- ### With Explicit Level
95
-
96
- ```javascript
97
- import createLogger from '#lib/logger/index.js'
98
-
99
- // Create a debug-level logger regardless of config
100
- const logger = createLogger('debug:module', 'debug')
101
- ```
102
-
103
- ## Log Levels
104
-
105
- | Level | Value | Description |
106
- |-------|-------|-------------|
107
- | `trace` | 0 | Most verbose, for detailed debugging |
108
- | `debug` | 1 | Debug information |
109
- | `info` | 2 | General information (default) |
110
- | `warn` | 3 | Warnings |
111
- | `error` | 4 | Errors only |
112
- | `silent` | 5 | No output |
113
-
114
- ## Configuration
115
-
116
- The logger reads its default level from the `QUIRE_LOG_LEVEL` environment variable, which is set by the CLI entry point from the user's configuration.
117
-
118
- ### Priority Order
119
-
120
- 1. **Explicit level parameter** - `createLogger('prefix', 'debug')`
121
- 2. **Environment variable** - `QUIRE_LOG_LEVEL=debug`
122
- 3. **Default** - `info`
123
-
124
- ### Setting Log Level
125
-
126
- ```javascript
127
- // At runtime
128
- logger.setLevel('debug')
129
-
130
- // Check current level
131
- const level = logger.getLevel() // Returns numeric level (0-5)
132
- ```
133
-
134
- ### Via Configuration
135
-
136
- The CLI reads `logLevel` from the user's config file (`~/.config/quire-cli/config.json`):
137
-
138
- ```json
139
- {
140
- "logLevel": "debug"
141
- }
142
- ```
143
-
144
- This is set as `QUIRE_LOG_LEVEL` environment variable before logger modules are loaded.
145
-
146
- ## Output Format
147
-
148
- ```
149
- [quire] LEVEL prefix message
150
- ```
151
-
152
- Example output:
153
-
154
- ```
155
- [quire] INFO quire Starting build...
156
- [quire] DEBUG lib:pdf Resolving library: prince
157
- [quire] WARN lib:epub Missing cover image
158
- [quire] ERROR lib:git Failed to clone repository
159
- ```
160
-
161
- The format matches the 11ty package's logging for visual consistency.
162
-
163
- ## Testing
164
-
165
- ### Mocking in Tests
166
-
167
- ```javascript
168
- import test from 'ava'
169
- import esmock from 'esmock'
170
-
171
- test('example test', async (t) => {
172
- const mockLogger = {
173
- info: t.context.sandbox.stub(),
174
- error: t.context.sandbox.stub(),
175
- debug: t.context.sandbox.stub(),
176
- warn: t.context.sandbox.stub(),
177
- trace: t.context.sandbox.stub(),
178
- setLevel: t.context.sandbox.stub(),
179
- getLevel: t.context.sandbox.stub().returns(2)
180
- }
181
-
182
- const MyModule = await esmock('./my-module.js', {
183
- '#lib/logger/index.js': { logger: mockLogger }
184
- })
185
-
186
- // Test code...
187
-
188
- t.true(mockLogger.info.calledWith('expected message'))
189
- })
190
- ```
191
-
192
- ### Testing with Environment Variable
193
-
194
- ```javascript
195
- test.serial('logger respects QUIRE_LOG_LEVEL', async (t) => {
196
- const original = process.env.QUIRE_LOG_LEVEL
197
-
198
- try {
199
- process.env.QUIRE_LOG_LEVEL = 'debug'
200
-
201
- // Import fresh module
202
- const { default: createLogger } = await import('./index.js?test-env')
203
- const log = createLogger('test:prefix')
204
-
205
- t.is(log.getLevel(), 1) // debug = 1
206
- } finally {
207
- process.env.QUIRE_LOG_LEVEL = original
208
- }
209
- })
210
- ```
211
-
212
- ## API Reference
213
-
214
- ### `createLogger(prefix?, level?)`
215
-
216
- Creates a new logger instance.
217
-
218
- **Parameters:**
219
- - `prefix` (string, default: `'quire'`) - Module prefix for log messages
220
- - `level` (string|number, optional) - Log level override
221
-
222
- **Returns:** Logger instance with methods:
223
- - `trace(...args)` - Log at trace level
224
- - `debug(...args)` - Log at debug level
225
- - `info(...args)` - Log at info level
226
- - `warn(...args)` - Log at warn level
227
- - `error(...args)` - Log at error level
228
- - `setLevel(level)` - Change log level at runtime
229
- - `getLevel()` - Get current numeric log level
230
-
231
- ### `logger`
232
-
233
- Default singleton logger instance with prefix `'quire'`.
234
-
235
- ### `LOG_LEVELS`
236
-
237
- Exported constants for log level values:
238
-
239
- ```javascript
240
- import { LOG_LEVELS } from '#lib/logger/index.js'
241
-
242
- LOG_LEVELS.trace // 0
243
- LOG_LEVELS.debug // 1
244
- LOG_LEVELS.info // 2
245
- LOG_LEVELS.warn // 3
246
- LOG_LEVELS.error // 4
247
- LOG_LEVELS.silent // 5
248
- ```
249
-
250
- ### `LOG_LEVEL_ENV_VAR`
251
-
252
- The environment variable name used for configuration: `'QUIRE_LOG_LEVEL'`
253
-
254
- ## Architecture
255
-
256
- ```
257
- bin/cli.js
258
-
259
- ├── Reads config.get('logLevel')
260
- ├── Sets process.env.QUIRE_LOG_LEVEL
261
-
262
- └── Dynamic import main.js
263
-
264
- └── Imports commands
265
-
266
- └── Import logger
267
-
268
- └── resolveLevel() reads QUIRE_LOG_LEVEL
269
- ```
270
-
271
- This architecture ensures:
272
- 1. Config is read before any logger modules are loaded
273
- 2. All loggers (including module-level ones) use the configured level
274
- 3. Tests can set the env var before importing to control levels
275
-
276
- ## Debug Module
277
-
278
- The debug module provides namespace-based debugging using the industry-standard [debug](https://github.com/debug-js/debug) package. This aligns with Eleventy core, which uses the same system.
279
-
280
- ### Basic Usage
281
-
282
- ```javascript
283
- // Short import alias
284
- import createDebug from '#debug'
285
-
286
- // Or full path
287
- // import createDebug from '#lib/logger/debug.js'
288
-
289
- const debug = createDebug('lib:pdf')
290
-
291
- debug('starting PDF generation')
292
- debug('options: %O', options)
293
- debug('processing file: %s', filename)
294
- ```
295
-
296
- ### Enabling Debug Output
297
-
298
- Debug output is controlled via the `DEBUG` environment variable:
299
-
300
- ```bash
301
- # Single namespace
302
- DEBUG=quire:lib:pdf quire pdf
303
-
304
- # Wildcard matching
305
- DEBUG=quire:lib:* quire build
306
-
307
- # All Quire debug output
308
- DEBUG=quire:* quire build
309
-
310
- # Combined with Eleventy debugging
311
- DEBUG=quire:*,Eleventy:* quire build
312
-
313
- # Exclude specific namespaces
314
- DEBUG=quire:*,-quire:lib:git quire create my-project
315
- ```
316
-
317
- ### Namespace Conventions
318
-
319
- Use colon-separated namespaces that mirror the module path:
320
-
321
- | Module Path | Namespace |
322
- |-------------|-----------|
323
- | `lib/pdf/index.js` | `lib:pdf` |
324
- | `lib/pdf/paged.js` | `lib:pdf:paged` |
325
- | `commands/build.js` | `commands:build` |
326
- | `helpers/test-cwd.js` | `helpers:cwd` |
327
-
328
- ### Debug API Reference
329
-
330
- #### `createDebug(namespace)`
331
-
332
- Creates a debug instance with the `quire:` prefix.
333
-
334
- ```javascript
335
- import createDebug from '#lib/logger/debug.js'
336
- const debug = createDebug('lib:pdf')
337
- // Creates debugger with namespace: quire:lib:pdf
338
- ```
339
-
340
- #### `createRawDebug(namespace)`
341
-
342
- Creates a debug instance without the `quire:` prefix.
343
-
344
- ```javascript
345
- import { createRawDebug } from '#lib/logger/debug.js'
346
- const debug = createRawDebug('my:custom:namespace')
347
- ```
348
-
349
- #### `isDebugEnabled(namespace)`
350
-
351
- Check if debug output is enabled for a namespace.
352
-
353
- ```javascript
354
- import { isDebugEnabled } from '#lib/logger/debug.js'
355
-
356
- if (isDebugEnabled('lib:pdf')) {
357
- // Expensive debug-only computation
358
- const details = computeExpensiveDebugInfo()
359
- debug('details: %O', details)
360
- }
361
- ```
362
-
363
- #### `enableDebug(namespaces)` / `disableDebug()`
364
-
365
- Programmatically enable/disable debug output.
366
-
367
- ```javascript
368
- import { enableDebug, disableDebug } from '#lib/logger/debug.js'
369
-
370
- enableDebug('quire:lib:*')
371
- // ... debugging code ...
372
- disableDebug()
373
- ```
374
-
375
- ### Debug Formatters
376
-
377
- The `debug` package supports printf-style formatters:
378
-
379
- | Formatter | Description |
380
- |-----------|-------------|
381
- | `%s` | String |
382
- | `%d` | Number |
383
- | `%j` | JSON |
384
- | `%O` | Pretty-print object (multi-line) |
385
- | `%o` | Pretty-print object (single-line) |
386
- | `%%` | Literal `%` |
387
-
388
- ```javascript
389
- debug('user: %s, count: %d', username, count)
390
- debug('config: %O', config) // Pretty printed
391
- debug('inline: %o', { a: 1 }) // Single line
392
- ```
393
-
394
- ### Extending Debug Instances
395
-
396
- Debug instances can be extended for sub-modules:
397
-
398
- ```javascript
399
- const debug = createDebug('lib:pdf')
400
- const debugPaged = debug.extend('paged')
401
- // debugPaged.namespace === 'quire:lib:pdf:paged'
402
- ```
403
-
404
- ### Testing with Debug
405
-
406
- ```javascript
407
- import test from 'ava'
408
- import { enableDebug, disableDebug } from '#lib/logger/debug.js'
409
-
410
- test.serial('debug output test', (t) => {
411
- enableDebug('quire:test:*')
412
-
413
- // Test code that uses debug...
414
-
415
- disableDebug()
416
- })
417
- ```
418
-
419
- ## Related
420
-
421
- - [11ty chalk factory](../../../11ty/_lib/chalk/index.js) - 11ty's equivalent logger
422
- - [debug package](https://github.com/debug-js/debug) - Underlying debug library
423
- - [conf module](../conf/) - Configuration management
424
- - [cli-architecture.md](../../docs/cli-architecture.md) - Architecture documentation
@@ -1,132 +0,0 @@
1
- import util from 'node:util'
2
- import debug from 'debug'
3
-
4
- /**
5
- * Debug utility for internal developer debugging
6
- *
7
- * Creates debug instances with the `quire:` namespace prefix.
8
- * Uses the standard `debug` package for namespace-based filtering.
9
- *
10
- * Object formatting:
11
- * %O Pretty-printed, indented on a new line (multi-line)
12
- * %o Compact single-line output (built-in default)
13
- *
14
- * @example
15
- * // In a module (short alias)
16
- * import createDebug from '#debug'
17
- * const debug = createDebug('lib:pdf')
18
- * debug('processing file: %s', filename)
19
- *
20
- * @example
21
- * // Enable via DEBUG environment variable
22
- * DEBUG=quire:lib:pdf quire pdf # Single namespace
23
- * DEBUG=quire:lib:* quire build # Wildcard matching
24
- * DEBUG=quire:* quire build # All quire debug output
25
- * DEBUG=quire:*,Eleventy:* quire build # Combined with Eleventy
26
- *
27
- * @see https://www.npmjs.com/package/debug
28
- */
29
-
30
- /**
31
- * Override %O formatter to produce indented multi-line output
32
- *
33
- * Pretty-prints objects with each line indented by 2 spaces,
34
- * starting on a new line after the label.
35
- *
36
- * Use %o (lowercase) for compact single-line output.
37
- */
38
- debug.formatters.O = function (value) {
39
- this.inspectOpts.colors = this.useColors
40
- const string = util.inspect(value, this.inspectOpts)
41
- return '\n' + string.split('\n').map((line) => ' ' + line).join('\n')
42
- }
43
-
44
- /**
45
- * Override formatArgs to prevent per-line namespace prefixing
46
- *
47
- * The default debug formatArgs (in color mode) splits the formatted
48
- * message on newlines and inserts the namespace prefix before every
49
- * line. This makes multi-line %O output noisy. This override only
50
- * prefixes the first line, letting continuation lines flow cleanly.
51
- */
52
- const originalFormatArgs = debug.formatArgs
53
- debug.formatArgs = function (args) {
54
- if (this.useColors) {
55
- const c = this.color
56
- const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c)
57
- const prefix = ` ${colorCode};1m${this.namespace} \u001B[0m`
58
-
59
- args[0] = prefix + args[0]
60
- args.push(colorCode + 'm+' + debug.humanize(this.diff) + '\u001B[0m')
61
- } else {
62
- originalFormatArgs.call(this, args)
63
- }
64
- }
65
-
66
- /**
67
- * Root namespace for all Quire CLI debug output
68
- */
69
- export const DEBUG_NAMESPACE = 'quire'
70
-
71
- /**
72
- * Create a debug instance with the quire namespace prefix
73
- *
74
- * @param {string} namespace - Module namespace (e.g., 'lib:pdf', 'commands:build')
75
- * @returns {debug.Debugger} Debug instance
76
- *
77
- * @example
78
- * const debug = createDebug('lib:pdf:paged')
79
- * debug('printer options: %O', options)
80
- * // Output (when DEBUG=quire:lib:pdf:paged):
81
- * // quire:lib:pdf:paged printer options:
82
- * // { format: 'A4', landscape: false } +0ms
83
- */
84
- export default function createDebug(namespace) {
85
- return debug(`${DEBUG_NAMESPACE}:${namespace}`)
86
- }
87
-
88
- /**
89
- * Create a debug instance without the quire prefix
90
- * Useful for debugging external libraries or special cases
91
- *
92
- * @param {string} namespace - Full namespace
93
- * @returns {debug.Debugger} Debug instance
94
- */
95
- export function createRawDebug(namespace) {
96
- return debug(namespace)
97
- }
98
-
99
- /**
100
- * Enable debug output for specific namespaces programmatically
101
- *
102
- * @param {string} namespaces - Comma-separated namespaces (supports wildcards)
103
- *
104
- * @example
105
- * enableDebug('quire:lib:*')
106
- * enableDebug('quire:*,Eleventy:*')
107
- */
108
- export function enableDebug(namespaces) {
109
- debug.enable(namespaces)
110
- }
111
-
112
- /**
113
- * Disable all debug output
114
- */
115
- export function disableDebug() {
116
- debug.disable()
117
- }
118
-
119
- /**
120
- * Check if debug output is enabled for a namespace
121
- *
122
- * @param {string} namespace - Namespace to check (without quire: prefix)
123
- * @returns {boolean} True if debug output would be shown
124
- *
125
- * @example
126
- * if (isDebugEnabled('lib:pdf')) {
127
- * // Expensive debug-only computation
128
- * }
129
- */
130
- export function isDebugEnabled(namespace) {
131
- return debug.enabled(`${DEBUG_NAMESPACE}:${namespace}`)
132
- }
@@ -1,130 +0,0 @@
1
- import test from 'ava'
2
- import createDebug, {
3
- DEBUG_NAMESPACE,
4
- createRawDebug,
5
- disableDebug,
6
- enableDebug,
7
- isDebugEnabled
8
- } from './debug.js'
9
-
10
- /**
11
- * Debug Module Unit Tests
12
- *
13
- * Tests the debug factory exports and API surface.
14
- */
15
-
16
- // ─────────────────────────────────────────────────────────────────────────────
17
- // Export tests
18
- // ─────────────────────────────────────────────────────────────────────────────
19
-
20
- test('createDebug is exported as default', (t) => {
21
- t.is(typeof createDebug, 'function')
22
- })
23
-
24
- test('DEBUG_NAMESPACE constant is exported', (t) => {
25
- t.is(DEBUG_NAMESPACE, 'quire')
26
- })
27
-
28
- test('createRawDebug is exported', (t) => {
29
- t.is(typeof createRawDebug, 'function')
30
- })
31
-
32
- test('disableDebug is exported', (t) => {
33
- t.is(typeof disableDebug, 'function')
34
- })
35
-
36
- test('enableDebug is exported', (t) => {
37
- t.is(typeof enableDebug, 'function')
38
- })
39
-
40
- test('isDebugEnabled is exported', (t) => {
41
- t.is(typeof isDebugEnabled, 'function')
42
- })
43
-
44
- // ─────────────────────────────────────────────────────────────────────────────
45
- // Factory function tests
46
- // ─────────────────────────────────────────────────────────────────────────────
47
-
48
- test('createDebug returns a function', (t) => {
49
- const debug = createDebug('test')
50
- t.is(typeof debug, 'function')
51
- })
52
-
53
- test('createDebug creates debug instance with quire prefix', (t) => {
54
- const debug = createDebug('lib:pdf')
55
- // Debug instances have a namespace property
56
- t.is(debug.namespace, 'quire:lib:pdf')
57
- })
58
-
59
- test('createDebug supports nested namespaces', (t) => {
60
- const debug = createDebug('lib:pdf:paged')
61
- t.is(debug.namespace, 'quire:lib:pdf:paged')
62
- })
63
-
64
- test('createRawDebug creates debug instance without prefix', (t) => {
65
- const debug = createRawDebug('custom:namespace')
66
- t.is(debug.namespace, 'custom:namespace')
67
- })
68
-
69
- // ─────────────────────────────────────────────────────────────────────────────
70
- // Enable/disable tests
71
- // ─────────────────────────────────────────────────────────────────────────────
72
-
73
- test.serial('enableDebug enables debug output for namespace', (t) => {
74
- // Clean state
75
- disableDebug()
76
- t.false(isDebugEnabled('lib:pdf'))
77
-
78
- enableDebug('quire:lib:pdf')
79
- t.true(isDebugEnabled('lib:pdf'))
80
-
81
- // Cleanup
82
- disableDebug()
83
- })
84
-
85
- test.serial('enableDebug supports wildcards', (t) => {
86
- disableDebug()
87
- t.false(isDebugEnabled('lib:pdf'))
88
- t.false(isDebugEnabled('lib:epub'))
89
-
90
- enableDebug('quire:lib:*')
91
- t.true(isDebugEnabled('lib:pdf'))
92
- t.true(isDebugEnabled('lib:epub'))
93
-
94
- // Cleanup
95
- disableDebug()
96
- })
97
-
98
- test.serial('disableDebug disables all debug output', (t) => {
99
- enableDebug('quire:*')
100
- t.true(isDebugEnabled('lib:pdf'))
101
-
102
- disableDebug()
103
- t.false(isDebugEnabled('lib:pdf'))
104
- })
105
-
106
- test.serial('isDebugEnabled returns false when not enabled', (t) => {
107
- disableDebug()
108
- t.false(isDebugEnabled('lib:pdf'))
109
- t.false(isDebugEnabled('commands:build'))
110
- })
111
-
112
- // ─────────────────────────────────────────────────────────────────────────────
113
- // Debug instance behavior tests
114
- // ─────────────────────────────────────────────────────────────────────────────
115
-
116
- test('debug instance has extend method', (t) => {
117
- const debug = createDebug('lib:pdf')
118
- t.is(typeof debug.extend, 'function')
119
- })
120
-
121
- test('debug instance can be extended', (t) => {
122
- const debug = createDebug('lib:pdf')
123
- const extended = debug.extend('paged')
124
- t.is(extended.namespace, 'quire:lib:pdf:paged')
125
- })
126
-
127
- test('debug instance has enabled property', (t) => {
128
- const debug = createDebug('test:namespace')
129
- t.is(typeof debug.enabled, 'boolean')
130
- })