@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
@@ -1,170 +0,0 @@
1
- # Error Handler
2
-
3
- Centralized error handling for the Quire CLI. All command errors flow through this handler for consistent formatting and exit code management.
4
-
5
- ## Usage
6
-
7
- ```javascript
8
- import { handleError, handleErrors, formatError } from '#lib/error/handler.js'
9
-
10
- try {
11
- await someOperation()
12
- } catch (error) {
13
- handleError(error, { debug: options.debug })
14
- }
15
- ```
16
-
17
- ## API
18
-
19
- ### `formatError(error, options)`
20
-
21
- Formats a QuireError for user display.
22
-
23
- **Parameters:**
24
- - `error` - The error to format (QuireError or Error)
25
- - `options.debug` - Include error code in output (default: `false`)
26
-
27
- **Returns:** Formatted string with error message and metadata.
28
-
29
- **Output format:**
30
- ```
31
- [ERROR_CODE] Message # Code shown only in debug mode
32
- File: /path/to/file # If error.filePath is set
33
- Suggestion: Actionable fix # If error.suggestion is set
34
- Learn more: https://docs.url # If error.docsUrl is set
35
- Tip: Run with --debug for more details # If not in debug mode and showDebugHint !== false
36
- ```
37
-
38
- ### `handleError(error, options)`
39
-
40
- Handles a single error: formats it, logs it, and exits.
41
-
42
- **Parameters:**
43
- - `error` - The error to handle
44
- - `options.exit` - Whether to exit process (default: `true`)
45
- - `options.exitFn` - Exit function for testing (default: `process.exit`)
46
- - `options.debug` - Show stack traces (default: `false`)
47
-
48
- **Returns:** Exit code (number)
49
-
50
- **Behavior:**
51
- - QuireError: Uses structured properties (code, exitCode, suggestion, docsUrl)
52
- - Other errors: Shows as "Unexpected error" with issue report link
53
-
54
- ### `handleErrors(errors, options)`
55
-
56
- Handles multiple errors (for batch validation scenarios).
57
-
58
- **Parameters:** Same as `handleError`, but takes array of errors.
59
-
60
- **Returns:** Highest exit code from all errors.
61
-
62
- ## Debug Mode
63
-
64
- When `--debug` is enabled:
65
- - Error codes are shown in the header (e.g., `[TOOL_NOT_FOUND]`)
66
- - Stack traces are printed after the error message
67
- - The "Tip: Run with --debug" hint is suppressed
68
-
69
- ## Debug Hint Control
70
-
71
- By default, errors display a tip suggesting the user run with `--debug` for more details. This can be disabled for errors where the fix is obvious and debug info wouldn't help.
72
-
73
- ### Disabling the hint
74
-
75
- Set `showDebugHint: false` in the error options:
76
-
77
- ```javascript
78
- class NotInProjectError extends QuireError {
79
- constructor(commandName) {
80
- super(`Must run inside a Quire project`, {
81
- code: 'NOT_IN_PROJECT',
82
- suggestion: "Navigate to your project folder with 'cd your-project-name'",
83
- showDebugHint: false // Fix is obvious, debug won't help
84
- })
85
- }
86
- }
87
- ```
88
-
89
- ### When to disable
90
-
91
- Disable the hint for "simple user errors" where:
92
- - The fix is immediately obvious from the message
93
- - Debug output wouldn't provide additional useful information
94
- - The user just needs to take a simple corrective action
95
-
96
- **Examples of errors with hint disabled:**
97
- - `NotInProjectError` - just cd to project folder
98
- - `DirectoryNotEmptyError` - choose empty directory
99
- - `InvalidPathError` - verify path exists
100
- - `MissingBuildOutputError` - run `quire build` first
101
- - `InvalidPdfLibraryError` - use valid library name
102
- - `InvalidEpubLibraryError` - use valid library name
103
-
104
- ### When to keep the hint
105
-
106
- Keep the hint (default) for errors where:
107
- - The issue may be complex or environmental
108
- - Stack traces or debug logging would help diagnosis
109
- - The user may need to report a bug
110
-
111
- **Examples of errors with hint enabled (default):**
112
- - `BuildFailedError` - complex build issues
113
- - `PdfGenerationError` - tool/process issues
114
- - `EpubGenerationError` - tool/process issues
115
- - `ToolNotFoundError` - PATH/environment issues
116
- - `DependencyInstallError` - npm issues
117
- - Configuration and YAML validation errors
118
-
119
- ## QuireError Properties
120
-
121
- The handler understands these QuireError properties:
122
-
123
- | Property | Type | Description |
124
- |----------|------|-------------|
125
- | `message` | string | Main error message |
126
- | `code` | string | Error code (e.g., `'TOOL_NOT_FOUND'`) |
127
- | `exitCode` | number | Process exit code (default: 1) |
128
- | `suggestion` | string | Actionable fix for the user |
129
- | `docsUrl` | string | Link to relevant documentation |
130
- | `filePath` | string | Source file that caused the error |
131
- | `showDebugHint` | boolean | Whether to show --debug hint (default: true) |
132
-
133
- ## Exit Codes
134
-
135
- | Code | Category | Examples |
136
- |------|----------|----------|
137
- | 1 | General error | Unexpected errors |
138
- | 2 | Project error | Not in project, directory not empty |
139
- | 3 | Build error | Config not found, build failed |
140
- | 4 | Validation error | YAML parse error, validation failed |
141
- | 5 | Output error | PDF/EPUB generation failed |
142
- | 6 | Install error | Invalid path, dependency install failed |
143
-
144
- ## Testing
145
-
146
- Use the `exit` and `exitFn` options to prevent actual process exit:
147
-
148
- ```javascript
149
- import { handleError } from '#lib/error/handler.js'
150
-
151
- const exitCode = handleError(error, {
152
- exit: false, // Don't call process.exit
153
- debug: true
154
- })
155
-
156
- t.is(exitCode, 5)
157
- ```
158
-
159
- Or provide a mock exit function:
160
-
161
- ```javascript
162
- const mockExit = sinon.stub()
163
-
164
- handleError(error, {
165
- exitFn: mockExit,
166
- debug: false
167
- })
168
-
169
- t.true(mockExit.calledWith(5))
170
- ```
@@ -1,107 +0,0 @@
1
- /**
2
- * Centralized error handler for the Quire CLI
3
- *
4
- * Provides consistent error formatting and exit code management.
5
- * All command errors should flow through this handler.
6
- *
7
- * @module lib/error/handler
8
- */
9
- import { logger } from '#lib/logger/index.js'
10
- import QuireError from '#src/errors/quire-error.js'
11
-
12
- /**
13
- * Format a QuireError for user display
14
- *
15
- * @param {QuireError} error - The error to format
16
- * @param {Object} options - Formatting options
17
- * @param {boolean} options.debug - Include error code in output (default: false)
18
- * @returns {string} Formatted error message
19
- */
20
- export function formatError(error, options = {}) {
21
- const { debug = false } = options
22
- // Only show error code (e.g., INVALID_PATH) in debug mode
23
- const header = (debug && error.code) ? `${error.code} ${error.message}` : error.message
24
- const lines = [header]
25
- if (error.filePath) lines.push(` File: ${error.filePath}`)
26
- if (error.suggestion) lines.push(` Suggestion: ${error.suggestion}`)
27
- if (error.docsUrl) lines.push(` Learn more: ${error.docsUrl}`)
28
- // Show debug hint when not in debug mode and error opts in
29
- if (!debug && error.showDebugHint !== false) {
30
- lines.push(' Tip: Run with --debug for more details')
31
- }
32
- return lines.join('\n')
33
- }
34
-
35
- /**
36
- * Handle a single error
37
- *
38
- * @param {Error} error - The error to handle
39
- * @param {Object} options
40
- * @param {boolean} options.exit - Whether to exit process (default: true)
41
- * @param {Function} options.exitFn - Exit function for testing (default: process.exit)
42
- * @param {boolean} options.debug - Show stack traces (default: false)
43
- * @returns {number} Exit code
44
- */
45
- export function handleError(error, options = {}) {
46
- const { exit = true, exitFn = process.exit, debug = false } = options
47
-
48
- if (error instanceof QuireError) {
49
- logger.error(formatError(error, { debug }))
50
-
51
- if (debug && error.stack) {
52
- logger.debug('Stack trace:')
53
- logger.debug(error.stack)
54
- }
55
-
56
- if (exit) exitFn(error.exitCode)
57
- return error.exitCode
58
- }
59
-
60
- // Non-Quire errors (unexpected)
61
- logger.error(`Unexpected error: ${error.message}`)
62
- logger.info('Please report this issue: https://github.com/thegetty/quire/issues')
63
-
64
- if (debug && error.stack) {
65
- logger.debug('Stack trace:')
66
- logger.debug(error.stack)
67
- }
68
-
69
- if (exit) exitFn(1)
70
- return 1
71
- }
72
-
73
- /**
74
- * Handle multiple errors (for batch validation)
75
- *
76
- * @param {Error[]} errors - Array of errors
77
- * @param {Object} options - Same as handleError
78
- * @returns {number} Highest exit code
79
- */
80
- export function handleErrors(errors, options = {}) {
81
- if (!errors.length) return 0
82
-
83
- const { exit = true, exitFn = process.exit, debug = false } = options
84
-
85
- logger.error(`${errors.length} error(s) occurred:\n`)
86
-
87
- let maxExitCode = 1
88
- errors.forEach((error, i) => {
89
- const formatted = error instanceof QuireError ? formatError(error, { debug }) : error.message
90
- logger.error(`${i + 1}. ${formatted}`)
91
- if (error instanceof QuireError && error.exitCode > maxExitCode) {
92
- maxExitCode = error.exitCode
93
- }
94
- })
95
-
96
- if (debug) {
97
- errors.forEach((error) => {
98
- if (error.stack) {
99
- logger.debug(`Stack trace for ${error.message}:`)
100
- logger.debug(error.stack)
101
- }
102
- })
103
- }
104
-
105
- if (exit) exitFn(maxExitCode)
106
- return maxExitCode
107
- }
@@ -1,80 +0,0 @@
1
- import test from 'ava'
2
- import git, { Git } from './index.js'
3
-
4
- /**
5
- * Git Façade Unit Tests
6
- *
7
- * Tests the git façade module interface and API contract.
8
- * These tests verify the module exports and method signatures
9
- * without actually executing git commands.
10
- */
11
-
12
- // Default singleton export tests
13
- test('git façade exports a singleton object', (t) => {
14
- t.truthy(git, 'git should be exported')
15
- t.is(typeof git, 'object', 'git should be an object')
16
- })
17
-
18
- test('git façade singleton has no cwd by default', (t) => {
19
- t.is(git.cwd, undefined, 'singleton cwd should be undefined')
20
- })
21
-
22
- test('git façade has add method', (t) => {
23
- t.is(typeof git.add, 'function', 'add should be a function')
24
- })
25
-
26
- test('git façade has clone method', (t) => {
27
- t.is(typeof git.clone, 'function', 'clone should be a function')
28
- })
29
-
30
- test('git façade has commit method', (t) => {
31
- t.is(typeof git.commit, 'function', 'commit should be a function')
32
- })
33
-
34
- test('git façade has init method', (t) => {
35
- t.is(typeof git.init, 'function', 'init should be a function')
36
- })
37
-
38
- test('git façade has isAvailable method', (t) => {
39
- t.is(typeof git.isAvailable, 'function', 'isAvailable should be a function')
40
- })
41
-
42
- test('git façade has rm method', (t) => {
43
- t.is(typeof git.rm, 'function', 'rm should be a function')
44
- })
45
-
46
- test('git façade has version method', (t) => {
47
- t.is(typeof git.version, 'function', 'version should be a function')
48
- })
49
-
50
- test('isAvailable returns a boolean', (t) => {
51
- const result = git.isAvailable()
52
- t.is(typeof result, 'boolean', 'isAvailable should return a boolean')
53
- })
54
-
55
- // Git class export tests
56
- test('Git class is exported', (t) => {
57
- t.truthy(Git, 'Git class should be exported')
58
- t.is(typeof Git, 'function', 'Git should be a constructor')
59
- })
60
-
61
- test('Git class can be instantiated with cwd', (t) => {
62
- const repo = new Git('/path/to/project')
63
- t.is(repo.cwd, '/path/to/project', 'cwd should be set from constructor')
64
- })
65
-
66
- test('Git class can be instantiated without cwd', (t) => {
67
- const repo = new Git()
68
- t.is(repo.cwd, undefined, 'cwd should be undefined when not provided')
69
- })
70
-
71
- test('Git instance has all methods', (t) => {
72
- const repo = new Git('/path/to/project')
73
- t.is(typeof repo.add, 'function', 'add should be a function')
74
- t.is(typeof repo.clone, 'function', 'clone should be a function')
75
- t.is(typeof repo.commit, 'function', 'commit should be a function')
76
- t.is(typeof repo.init, 'function', 'init should be a function')
77
- t.is(typeof repo.isAvailable, 'function', 'isAvailable should be a function')
78
- t.is(typeof repo.rm, 'function', 'rm should be a function')
79
- t.is(typeof repo.version, 'function', 'version should be a function')
80
- })