@thegetty/quire-cli 1.0.0-rc.35 → 1.0.0-rc.36

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 (158) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +9 -0
  3. package/bin/cli.js +19 -1
  4. package/package.json +21 -8
  5. package/patches/README.md +19 -0
  6. package/patches/install-npm-version+1.0.9.patch +12119 -0
  7. package/schemas/objects.schema.json +12 -38
  8. package/schemas/publication.schema.json +0 -22
  9. package/schemas/references.schema.json +0 -1
  10. package/src/Command.js +26 -6
  11. package/src/Command.spec.js +99 -0
  12. package/src/commands/README.md +213 -122
  13. package/src/commands/build.js +46 -37
  14. package/src/commands/build.spec.js +113 -0
  15. package/src/commands/build.test.js +402 -0
  16. package/src/commands/clean.js +25 -19
  17. package/src/commands/clean.spec.js +108 -0
  18. package/src/commands/clean.test.js +260 -0
  19. package/src/commands/config.js +251 -0
  20. package/src/commands/config.spec.js +107 -0
  21. package/src/commands/config.test.js +715 -0
  22. package/src/commands/create.js +42 -14
  23. package/src/commands/create.spec.js +112 -0
  24. package/src/commands/create.test.js +415 -0
  25. package/src/commands/epub.js +59 -30
  26. package/src/commands/epub.spec.js +114 -0
  27. package/src/commands/epub.test.js +503 -0
  28. package/src/commands/index.js +9 -2
  29. package/src/commands/info.js +18 -24
  30. package/src/commands/info.spec.js +64 -0
  31. package/src/commands/info.test.js +415 -0
  32. package/src/commands/pdf.js +58 -84
  33. package/src/commands/pdf.spec.js +114 -0
  34. package/src/commands/pdf.test.js +464 -0
  35. package/src/commands/preview.js +26 -31
  36. package/src/commands/preview.spec.js +97 -0
  37. package/src/commands/preview.test.js +250 -0
  38. package/src/commands/use.js +56 -0
  39. package/src/commands/use.spec.js +61 -0
  40. package/src/commands/use.test.js +280 -0
  41. package/src/commands/validate.js +31 -19
  42. package/src/commands/validate.spec.js +82 -0
  43. package/src/commands/validate.test.js +234 -0
  44. package/src/commands/workflows.js +70 -0
  45. package/src/errors/build/build-failed-error.js +19 -0
  46. package/src/errors/build/config-field-missing-error.js +20 -0
  47. package/src/errors/build/config-file-not-found-error.js +20 -0
  48. package/src/errors/build/index.js +11 -0
  49. package/src/errors/index.js +48 -0
  50. package/src/errors/install/dependency-install-error.js +19 -0
  51. package/src/errors/install/directory-not-empty-error.js +25 -0
  52. package/src/errors/install/index.js +12 -0
  53. package/src/errors/install/invalid-path-error.js +31 -0
  54. package/src/errors/install/invalid-starter-error.js +27 -0
  55. package/src/errors/install/version-not-found-error.js +35 -0
  56. package/src/errors/output/epub-generation-error.js +19 -0
  57. package/src/errors/output/index.js +14 -0
  58. package/src/errors/output/invalid-epub-library-error.js +20 -0
  59. package/src/errors/output/invalid-pdf-library-error.js +20 -0
  60. package/src/errors/output/missing-build-output-error.js +21 -0
  61. package/src/errors/output/pdf-generation-error.js +24 -0
  62. package/src/errors/output/tool-not-found-error.js +37 -0
  63. package/src/errors/project/index.js +10 -0
  64. package/src/errors/project/not-in-project-error.js +20 -0
  65. package/src/errors/project/project-create-error.js +21 -0
  66. package/src/errors/quire-error.js +27 -0
  67. package/src/errors/validation/validation-error.js +20 -11
  68. package/src/helpers/clean.js +1 -1
  69. package/src/helpers/docs-url.js +32 -0
  70. package/src/helpers/test-cwd.js +5 -6
  71. package/src/helpers/test-cwd.test.js +192 -0
  72. package/src/helpers/which.js +10 -4
  73. package/src/lib/11ty/README.md +135 -19
  74. package/src/lib/11ty/api.js +176 -93
  75. package/src/lib/11ty/cli.js +77 -35
  76. package/src/lib/11ty/index.js +64 -5
  77. package/src/lib/11ty/index.test.js +655 -0
  78. package/src/lib/README.md +275 -0
  79. package/src/lib/commander/index.js +100 -0
  80. package/src/lib/commander/index.test.js +86 -0
  81. package/src/lib/commander/options.js +195 -0
  82. package/src/lib/commander/options.test.js +109 -0
  83. package/src/lib/conf/README.md +84 -73
  84. package/src/lib/conf/config.js +5 -3
  85. package/src/lib/conf/config.test.js +281 -0
  86. package/src/lib/conf/defaults.js +44 -0
  87. package/src/lib/conf/format.js +60 -0
  88. package/src/lib/conf/format.test.js +106 -0
  89. package/src/lib/conf/helpers.js +91 -0
  90. package/src/lib/conf/helpers.test.js +136 -0
  91. package/src/lib/conf/index.js +22 -0
  92. package/src/lib/conf/schema.js +53 -8
  93. package/src/lib/epub/README.md +133 -2
  94. package/src/lib/epub/engines.js +46 -0
  95. package/src/lib/epub/epub.js +36 -11
  96. package/src/lib/epub/index.js +111 -21
  97. package/src/lib/epub/index.test.js +518 -0
  98. package/src/lib/epub/pandoc.js +33 -4
  99. package/src/lib/epub/pandoc.test.js +122 -0
  100. package/src/lib/epub/schema.js +21 -0
  101. package/src/lib/error/README.md +170 -0
  102. package/src/lib/error/handler.js +107 -0
  103. package/src/lib/git/README.md +151 -2
  104. package/src/lib/git/index.js +217 -13
  105. package/src/lib/git/index.spec.js +80 -0
  106. package/src/lib/git/index.test.js +453 -0
  107. package/src/lib/installer/index.js +309 -0
  108. package/src/lib/installer/index.spec.js +83 -0
  109. package/src/lib/installer/index.test.js +545 -0
  110. package/src/lib/logger/README.md +424 -0
  111. package/src/lib/logger/debug.js +90 -0
  112. package/src/lib/logger/debug.spec.js +130 -0
  113. package/src/lib/logger/index.js +228 -0
  114. package/src/lib/logger/index.spec.js +131 -0
  115. package/src/lib/logger/index.test.js +477 -0
  116. package/src/lib/npm/README.md +127 -0
  117. package/src/lib/npm/index.js +198 -0
  118. package/src/lib/npm/index.spec.js +60 -0
  119. package/src/lib/npm/index.test.js +355 -0
  120. package/src/lib/pdf/README.md +131 -0
  121. package/src/lib/pdf/engines.js +46 -0
  122. package/src/lib/pdf/index.js +124 -21
  123. package/src/lib/pdf/index.test.js +708 -0
  124. package/src/lib/pdf/paged.js +100 -52
  125. package/src/lib/pdf/paged.test.js +366 -0
  126. package/src/lib/pdf/prince.js +115 -37
  127. package/src/lib/pdf/prince.test.js +202 -0
  128. package/src/lib/pdf/schema.js +21 -0
  129. package/src/lib/pdf/split.js +61 -33
  130. package/src/lib/pdf/split.test.js +445 -0
  131. package/src/lib/process/manager.js +110 -0
  132. package/src/lib/process/manager.test.js +55 -0
  133. package/src/lib/project/build.js +143 -0
  134. package/src/lib/project/build.test.js +253 -0
  135. package/src/lib/project/config.js +48 -0
  136. package/src/lib/project/config.test.js +134 -0
  137. package/src/{helpers/is-quire.js → lib/project/detect.js} +5 -3
  138. package/src/lib/project/detect.test.js +157 -0
  139. package/src/lib/project/index.js +40 -0
  140. package/src/lib/project/paths.js +224 -0
  141. package/src/lib/project/version.js +110 -0
  142. package/src/lib/project/version.test.js +350 -0
  143. package/src/lib/reporter/README.md +211 -2
  144. package/src/lib/reporter/index.js +512 -0
  145. package/src/lib/reporter/index.test.js +593 -0
  146. package/src/main.js +134 -47
  147. package/src/main.spec.js +61 -0
  148. package/src/main.test.js +347 -0
  149. package/src/validators/utils.js +2 -1
  150. package/src/commands/conf.js +0 -43
  151. package/src/commands/version.js +0 -43
  152. package/src/lib/11ty/paths.js +0 -103
  153. package/src/lib/i18n/README.md +0 -3
  154. package/src/lib/i18n/config.js +0 -53
  155. package/src/lib/i18n/index.js +0 -43
  156. package/src/lib/i18n/localeService.js +0 -58
  157. package/src/lib/quire/README.md +0 -19
  158. package/src/lib/quire/index.js +0 -350
@@ -0,0 +1,70 @@
1
+ import Command from '#src/Command.js'
2
+ import { DOCS_BASE } from '#helpers/docs-url.js'
3
+
4
+ /**
5
+ * Quire CLI `workflows` Command
6
+ *
7
+ * Displays common workflow documentation.
8
+ * Hidden from main help but accessible via `quire help workflows` or `quire workflows`.
9
+ *
10
+ * TODO: Refactor to an extensible `quire help <topic>` system that can load
11
+ * help topics from a topics/ directory or markdown files. This would support:
12
+ * - quire help workflows
13
+ * - quire help debugging
14
+ * - quire help publishing
15
+ * - quire help configuration
16
+ *
17
+ * @class WorkflowsCommand
18
+ * @extends {Command}
19
+ */
20
+ export default class WorkflowsCommand extends Command {
21
+ static definition = {
22
+ name: 'workflows',
23
+ description: 'Display common workflow documentation',
24
+ summary: 'show common workflows',
25
+ hidden: true,
26
+ docsLink: 'quire-commands/',
27
+ helpText: `
28
+ Common Workflows:
29
+
30
+ Starting a New Project:
31
+ quire new my-book && cd my-book && quire preview
32
+
33
+ Building for Web:
34
+ quire build Generate HTML site files
35
+ quire clean && quire build Clean build (recommended for production)
36
+
37
+ Generating PDF:
38
+ quire pdf --build Build first, then generate PDF
39
+ quire pdf --build --open Generate and open PDF
40
+ quire pdf --engine prince Use PrinceXML instead of Paged.js
41
+
42
+ Generating EPUB:
43
+ quire epub --build Build first, then generate EPUB
44
+ quire epub --build --open Generate and open EPUB
45
+
46
+ Full Publication Build:
47
+ quire clean && quire build && quire pdf && quire epub
48
+
49
+ Troubleshooting:
50
+ quire validate Check YAML files for errors
51
+ quire info Show version information
52
+ quire build --verbose Build with debug output
53
+
54
+ See full documentation: ${DOCS_BASE}
55
+ `,
56
+ version: '1.0.0',
57
+ options: [],
58
+ }
59
+
60
+ constructor() {
61
+ super(WorkflowsCommand.definition)
62
+ }
63
+
64
+ async action(options, command) {
65
+ this.debug('called with options %O', options)
66
+ // The help text is automatically displayed via Commander's help system
67
+ // If called directly (quire workflows), display help
68
+ command.help()
69
+ }
70
+ }
@@ -0,0 +1,19 @@
1
+ import QuireError from '../quire-error.js'
2
+ import { docsUrl } from '#helpers/docs-url.js'
3
+
4
+ /**
5
+ * Error thrown when the publication build fails
6
+ */
7
+ export default class BuildFailedError extends QuireError {
8
+ constructor(details) {
9
+ super(
10
+ `Publication build failed${details ? `: ${details}` : ''}`,
11
+ {
12
+ code: 'BUILD_FAILED',
13
+ exitCode: 3,
14
+ suggestion: "Run 'quire build --debug' for detailed error information",
15
+ docsUrl: docsUrl('troubleshooting')
16
+ }
17
+ )
18
+ }
19
+ }
@@ -0,0 +1,20 @@
1
+ import QuireError from '../quire-error.js'
2
+ import { docsUrl } from '#helpers/docs-url.js'
3
+
4
+ /**
5
+ * Error thrown when a required field is missing from a configuration file
6
+ */
7
+ export default class ConfigFieldMissingError extends QuireError {
8
+ constructor(fieldName, configFile) {
9
+ super(
10
+ `Missing required field '${fieldName}' in ${configFile}`,
11
+ {
12
+ code: 'CONFIG_FIELD_MISSING',
13
+ exitCode: 3,
14
+ filePath: `content/_data/${configFile}`,
15
+ suggestion: `Add '${fieldName}' to your ${configFile}`,
16
+ docsUrl: docsUrl('publication-configuration')
17
+ }
18
+ )
19
+ }
20
+ }
@@ -0,0 +1,20 @@
1
+ import QuireError from '../quire-error.js'
2
+ import { docsUrl } from '#helpers/docs-url.js'
3
+
4
+ /**
5
+ * Error thrown when a required configuration file is not found
6
+ */
7
+ export default class ConfigFileNotFoundError extends QuireError {
8
+ constructor(configFile) {
9
+ super(
10
+ `Required configuration file '${configFile}' not found`,
11
+ {
12
+ code: 'CONFIG_FILE_NOT_FOUND',
13
+ exitCode: 3,
14
+ filePath: `content/_data/${configFile}`,
15
+ suggestion: `Create ${configFile} in your content/_data/ folder`,
16
+ docsUrl: docsUrl('publication-configuration')
17
+ }
18
+ )
19
+ }
20
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Build-related errors (exit code: 3)
3
+ *
4
+ * Errors related to publication build process including
5
+ * Eleventy build failures and configuration issues.
6
+ *
7
+ * @module errors/build
8
+ */
9
+ export { default as BuildFailedError } from './build-failed-error.js'
10
+ export { default as ConfigFieldMissingError } from './config-field-missing-error.js'
11
+ export { default as ConfigFileNotFoundError } from './config-file-not-found-error.js'
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Centralized error exports for Quire CLI
3
+ *
4
+ * All custom error classes are exported from here for easy imports.
5
+ *
6
+ * @example
7
+ * import { NotInProjectError, BuildFailedError } from '#src/errors/index.js'
8
+ *
9
+ * @module errors
10
+ */
11
+
12
+ // Base error class
13
+ export { default as QuireError } from './quire-error.js'
14
+
15
+ // Project errors (exit code: 2)
16
+ export {
17
+ NotInProjectError,
18
+ ProjectCreateError
19
+ } from './project/index.js'
20
+
21
+ // Build errors (exit code: 3)
22
+ export {
23
+ BuildFailedError,
24
+ ConfigFieldMissingError,
25
+ ConfigFileNotFoundError
26
+ } from './build/index.js'
27
+
28
+ // Output errors (exit code: 5)
29
+ export {
30
+ EpubGenerationError,
31
+ InvalidEpubLibraryError,
32
+ InvalidPdfLibraryError,
33
+ MissingBuildOutputError,
34
+ PdfGenerationError,
35
+ ToolNotFoundError
36
+ } from './output/index.js'
37
+
38
+ // Install errors (exit code: 6)
39
+ export {
40
+ DependencyInstallError,
41
+ DirectoryNotEmptyError,
42
+ InvalidPathError,
43
+ InvalidStarterError,
44
+ VersionNotFoundError
45
+ } from './install/index.js'
46
+
47
+ // Validation errors (exit code: 4)
48
+ export { default as ValidationError } from './validation/validation-error.js'
@@ -0,0 +1,19 @@
1
+ import QuireError from '../quire-error.js'
2
+ import { docsUrl } from '#helpers/docs-url.js'
3
+
4
+ /**
5
+ * Error thrown when dependency installation fails
6
+ */
7
+ export default class DependencyInstallError extends QuireError {
8
+ constructor(details) {
9
+ super(
10
+ `Failed to install dependencies: ${details}`,
11
+ {
12
+ code: 'DEPENDENCY_INSTALL_FAILED',
13
+ exitCode: 6,
14
+ suggestion: "Try running 'npm install' manually to see detailed errors",
15
+ docsUrl: docsUrl('troubleshooting')
16
+ }
17
+ )
18
+ }
19
+ }
@@ -0,0 +1,25 @@
1
+ import QuireError from '../quire-error.js'
2
+ import { docsUrl } from '#helpers/docs-url.js'
3
+
4
+ /**
5
+ * Error thrown when attempting to create a project in a non-empty directory
6
+ *
7
+ * This error indicates the target directory contains existing files,
8
+ * which could be user content that should not be overwritten or deleted.
9
+ */
10
+ export default class DirectoryNotEmptyError extends QuireError {
11
+ constructor(path) {
12
+ const location = path === '.' ? 'the current directory' : path
13
+ super(
14
+ `Cannot create project in a non-empty directory: ${location}`,
15
+ {
16
+ code: 'DIRECTORY_NOT_EMPTY',
17
+ exitCode: 2,
18
+ filePath: path,
19
+ suggestion: 'Choose an empty directory or create a new one',
20
+ docsUrl: docsUrl('install-uninstall'),
21
+ showDebugHint: false
22
+ }
23
+ )
24
+ }
25
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Installation errors (exit code: 6)
3
+ *
4
+ * Errors related to dependency installation and version management.
5
+ *
6
+ * @module errors/install
7
+ */
8
+ export { default as DependencyInstallError } from './dependency-install-error.js'
9
+ export { default as DirectoryNotEmptyError } from './directory-not-empty-error.js'
10
+ export { default as InvalidPathError } from './invalid-path-error.js'
11
+ export { default as InvalidStarterError } from './invalid-starter-error.js'
12
+ export { default as VersionNotFoundError } from './version-not-found-error.js'
@@ -0,0 +1,31 @@
1
+ import QuireError from '../quire-error.js'
2
+ import { docsUrl } from '#helpers/docs-url.js'
3
+
4
+ /**
5
+ * Error thrown when a specified path does not exist
6
+ *
7
+ * Used when --quire-path option points to a non-existent directory.
8
+ */
9
+ export default class InvalidPathError extends QuireError {
10
+ /**
11
+ * @param {string} originalPath - The path as provided by the user
12
+ * @param {string} resolvedPath - The fully resolved absolute path
13
+ */
14
+ constructor(originalPath, resolvedPath) {
15
+ const pathDisplay = originalPath === resolvedPath
16
+ ? originalPath
17
+ : `${originalPath} (resolved to: ${resolvedPath})`
18
+
19
+ super(
20
+ `--quire-path does not exist: ${pathDisplay}`,
21
+ {
22
+ code: 'INVALID_PATH',
23
+ exitCode: 6,
24
+ filePath: resolvedPath,
25
+ suggestion: 'Verify the path exists and is accessible',
26
+ docsUrl: docsUrl('install-uninstall'),
27
+ showDebugHint: false
28
+ }
29
+ )
30
+ }
31
+ }
@@ -0,0 +1,27 @@
1
+ import QuireError from '../quire-error.js'
2
+ import { docsUrl } from '#helpers/docs-url.js'
3
+
4
+ /**
5
+ * Error thrown when a starter template is invalid
6
+ *
7
+ * Used when the starter argument points to a non-existent path
8
+ * or a path that is not a valid git repository.
9
+ */
10
+ export default class InvalidStarterError extends QuireError {
11
+ /**
12
+ * @param {string} starterPath - The starter path that is invalid
13
+ * @param {string} reason - Why the starter is invalid
14
+ */
15
+ constructor(starterPath, reason) {
16
+ super(
17
+ `Invalid starter template '${starterPath}': ${reason}`,
18
+ {
19
+ code: 'INVALID_STARTER',
20
+ exitCode: 6,
21
+ filePath: starterPath,
22
+ suggestion: 'Verify the path exists and is a git repository, or use a repository URL',
23
+ docsUrl: docsUrl('install-uninstall')
24
+ }
25
+ )
26
+ }
27
+ }
@@ -0,0 +1,35 @@
1
+ import path from 'node:path'
2
+ import QuireError from '../quire-error.js'
3
+ import { docsUrl } from '#helpers/docs-url.js'
4
+
5
+ /**
6
+ * Error thrown when a package version cannot be determined
7
+ *
8
+ * Handles both npm registry lookups and local package paths.
9
+ */
10
+ export default class VersionNotFoundError extends QuireError {
11
+ /**
12
+ * @param {string} packageName - Package name or path description
13
+ * @param {string} reason - Version string for npm, or reason for local path
14
+ * @param {Object} [options] - Override default suggestion
15
+ * @param {string} [options.suggestion] - Custom suggestion text
16
+ */
17
+ constructor(packageName, reason, options = {}) {
18
+ const isLocalPath = packageName.includes(path.sep)
19
+ const defaultSuggestion = isLocalPath
20
+ ? 'Ensure the local package has a valid package.json with a version field'
21
+ : `Run 'npm view ${packageName} versions' to see available versions`
22
+
23
+ super(
24
+ isLocalPath
25
+ ? `Cannot determine version from ${packageName}: ${reason}`
26
+ : `Version '${reason}' of ${packageName} not found`,
27
+ {
28
+ code: 'VERSION_NOT_FOUND',
29
+ exitCode: 6,
30
+ suggestion: options.suggestion || defaultSuggestion,
31
+ docsUrl: docsUrl('install-uninstall')
32
+ }
33
+ )
34
+ }
35
+ }
@@ -0,0 +1,19 @@
1
+ import QuireError from '../quire-error.js'
2
+ import { docsUrl } from '#helpers/docs-url.js'
3
+
4
+ /**
5
+ * Error thrown when EPUB generation fails
6
+ */
7
+ export default class EpubGenerationError extends QuireError {
8
+ constructor(details) {
9
+ super(
10
+ `EPUB generation failed: ${details}`,
11
+ {
12
+ code: 'EPUB_FAILED',
13
+ exitCode: 5,
14
+ suggestion: 'Check that your publication built successfully first',
15
+ docsUrl: docsUrl('epub-output')
16
+ }
17
+ )
18
+ }
19
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Output generation errors (exit code: 5)
3
+ *
4
+ * Errors related to PDF and EPUB generation including
5
+ * missing build output and external tool issues.
6
+ *
7
+ * @module errors/output
8
+ */
9
+ export { default as EpubGenerationError } from './epub-generation-error.js'
10
+ export { default as InvalidEpubLibraryError } from './invalid-epub-library-error.js'
11
+ export { default as InvalidPdfLibraryError } from './invalid-pdf-library-error.js'
12
+ export { default as MissingBuildOutputError } from './missing-build-output-error.js'
13
+ export { default as PdfGenerationError } from './pdf-generation-error.js'
14
+ export { default as ToolNotFoundError } from './tool-not-found-error.js'
@@ -0,0 +1,20 @@
1
+ import QuireError from '../quire-error.js'
2
+ import { docsUrl } from '#helpers/docs-url.js'
3
+
4
+ /**
5
+ * Error thrown when an unrecognized EPUB library is specified
6
+ */
7
+ export default class InvalidEpubLibraryError extends QuireError {
8
+ constructor(libName, validLibraries = ['epubjs', 'pandoc']) {
9
+ super(
10
+ `Unrecognized EPUB library '${libName}'`,
11
+ {
12
+ code: 'INVALID_EPUB_LIBRARY',
13
+ exitCode: 5,
14
+ suggestion: `Use one of: ${validLibraries.join(', ')}`,
15
+ docsUrl: docsUrl('epub-output'),
16
+ showDebugHint: false
17
+ }
18
+ )
19
+ }
20
+ }
@@ -0,0 +1,20 @@
1
+ import QuireError from '../quire-error.js'
2
+ import { docsUrl } from '#helpers/docs-url.js'
3
+
4
+ /**
5
+ * Error thrown when an unrecognized PDF library is specified
6
+ */
7
+ export default class InvalidPdfLibraryError extends QuireError {
8
+ constructor(libName, validLibraries = ['prince', 'pagedjs']) {
9
+ super(
10
+ `Unrecognized PDF library '${libName}'`,
11
+ {
12
+ code: 'INVALID_PDF_LIBRARY',
13
+ exitCode: 5,
14
+ suggestion: `Use one of: ${validLibraries.join(', ')}`,
15
+ docsUrl: docsUrl('pdf-output'),
16
+ showDebugHint: false
17
+ }
18
+ )
19
+ }
20
+ }
@@ -0,0 +1,21 @@
1
+ import QuireError from '../quire-error.js'
2
+ import { docsUrl } from '#helpers/docs-url.js'
3
+
4
+ /**
5
+ * Error thrown when required build output is missing
6
+ */
7
+ export default class MissingBuildOutputError extends QuireError {
8
+ constructor(outputType, expectedPath) {
9
+ super(
10
+ `Cannot generate ${outputType}: build output not found`,
11
+ {
12
+ code: 'BUILD_OUTPUT_MISSING',
13
+ exitCode: 5,
14
+ filePath: expectedPath,
15
+ suggestion: "Run 'quire build' first, then try again",
16
+ docsUrl: docsUrl('quire-commands'),
17
+ showDebugHint: false
18
+ }
19
+ )
20
+ }
21
+ }
@@ -0,0 +1,24 @@
1
+ import QuireError from '../quire-error.js'
2
+ import { docsUrl } from '#helpers/docs-url.js'
3
+
4
+ /**
5
+ * Error thrown when PDF generation fails
6
+ *
7
+ * @param {string} tool - The PDF tool that failed (e.g., 'Paged.js', 'Prince')
8
+ * @param {string} operation - The operation that failed (e.g., 'PDF rendering', 'page map extraction')
9
+ * @param {string} [details] - Additional error details from the underlying error
10
+ */
11
+ export default class PdfGenerationError extends QuireError {
12
+ constructor(tool, operation, details) {
13
+ const message = details
14
+ ? `${tool} ${operation} failed: ${details}`
15
+ : `${tool} ${operation} failed`
16
+
17
+ super(message, {
18
+ code: 'PDF_FAILED',
19
+ exitCode: 5,
20
+ suggestion: `Check that ${tool} is properly configured and the input files are valid`,
21
+ docsUrl: docsUrl('pdf-output')
22
+ })
23
+ }
24
+ }
@@ -0,0 +1,37 @@
1
+ import QuireError from '../quire-error.js'
2
+ import { docsUrl } from '#helpers/docs-url.js'
3
+
4
+ /**
5
+ * Error thrown when a required external tool is not found
6
+ *
7
+ * @param {string} toolName - The name of the tool (e.g., 'prince', 'pandoc')
8
+ * @param {Object} [toolInfo] - Tool metadata provided by the calling façade
9
+ * @param {string} [toolInfo.displayName] - Human-readable tool name
10
+ * @param {string} [toolInfo.installUrl] - URL where tool can be downloaded
11
+ * @param {string} [toolInfo.docsUrl] - Quire docs URL for this tool's usage
12
+ * @param {string} [toolInfo.fallback] - Alternative suggestion (e.g., use default engine)
13
+ */
14
+ export default class ToolNotFoundError extends QuireError {
15
+ constructor(toolName, toolInfo = {}) {
16
+ const displayName = toolInfo.displayName || toolName
17
+ const installUrl = toolInfo.installUrl || 'the tool documentation'
18
+ const toolDocsUrl = toolInfo.docsUrl || docsUrl('troubleshooting')
19
+
20
+ let suggestion = `Install ${displayName} from ${installUrl}`
21
+ if (toolInfo.fallback) {
22
+ suggestion += `\n${toolInfo.fallback}`
23
+ }
24
+
25
+ super(
26
+ `${displayName} is not installed or not in PATH`,
27
+ {
28
+ code: 'TOOL_NOT_FOUND',
29
+ exitCode: 5,
30
+ suggestion,
31
+ docsUrl: toolDocsUrl,
32
+ }
33
+ )
34
+
35
+ this.toolName = toolName
36
+ }
37
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Project-related errors (exit code: 2)
3
+ *
4
+ * Errors related to project setup and detection.
5
+ * Used when commands are run outside a Quire project or project creation fails.
6
+ *
7
+ * @module errors/project
8
+ */
9
+ export { default as NotInProjectError } from './not-in-project-error.js'
10
+ export { default as ProjectCreateError } from './project-create-error.js'
@@ -0,0 +1,20 @@
1
+ import QuireError from '../quire-error.js'
2
+ import { docsUrl } from '#helpers/docs-url.js'
3
+
4
+ /**
5
+ * Error thrown when a command is run outside a Quire project directory
6
+ */
7
+ export default class NotInProjectError extends QuireError {
8
+ constructor(commandName) {
9
+ super(
10
+ `The '${commandName}' command must be run inside a Quire project`,
11
+ {
12
+ code: 'NOT_IN_PROJECT',
13
+ exitCode: 2,
14
+ suggestion: "Navigate to your project folder with 'cd your-project-name'",
15
+ docsUrl: docsUrl('quire-commands'),
16
+ showDebugHint: false
17
+ }
18
+ )
19
+ }
20
+ }
@@ -0,0 +1,21 @@
1
+ import QuireError from '../quire-error.js'
2
+ import { docsUrl } from '#helpers/docs-url.js'
3
+
4
+ /**
5
+ * Error thrown when project creation fails
6
+ */
7
+ export default class ProjectCreateError extends QuireError {
8
+ constructor(projectPath, cause) {
9
+ super(
10
+ `Failed to create project at '${projectPath}'`,
11
+ {
12
+ code: 'PROJECT_CREATE_FAILED',
13
+ exitCode: 2,
14
+ filePath: projectPath,
15
+ suggestion: 'Check that the directory is empty and you have write permissions',
16
+ docsUrl: docsUrl('getting-started')
17
+ }
18
+ )
19
+ this.cause = cause
20
+ }
21
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Base error class for all Quire CLI errors
3
+ *
4
+ * Provides structured error data for the error handler to format.
5
+ *
6
+ * @property {string} code - Error code (e.g., 'CONFIG_FILE_NOT_FOUND')
7
+ * @property {number} exitCode - Process exit code (default: 1)
8
+ * @property {string} suggestion - Actionable fix for the user
9
+ * @property {string} docsUrl - Link to relevant documentation
10
+ * @property {string} filePath - Source file that caused the error (optional)
11
+ * @property {boolean} showDebugHint - Whether to show --debug hint (default: true)
12
+ */
13
+ export default class QuireError extends Error {
14
+ constructor(message, options = {}) {
15
+ super(message)
16
+ this.name = this.constructor.name
17
+ this.code = options.code
18
+ this.exitCode = options.exitCode ?? 1
19
+ this.suggestion = options.suggestion
20
+ this.docsUrl = options.docsUrl
21
+ this.filePath = options.filePath
22
+ this.showDebugHint = options.showDebugHint ?? true
23
+ if ('captureStackTrace' in Error) {
24
+ Error.captureStackTrace(this, this.constructor)
25
+ }
26
+ }
27
+ }
@@ -1,13 +1,22 @@
1
- export default class ValidationError extends Error {
2
- constructor(message, {filePath, reason, code} = {}) {
3
- super(message)
4
- this.name = this.constructor.name
5
- this.filePath = filePath
6
- this.reason = reason
7
- this.code = code
1
+ import QuireError from '../quire-error.js'
2
+ import { docsUrl } from '#helpers/docs-url.js'
8
3
 
9
- if ('captureStackTrace' in Error) {
10
- Error.captureStackTrace(this, this.constructor)
11
- }
4
+ /**
5
+ * Base validation error class (exit code: 4)
6
+ *
7
+ * Used for YAML validation, schema violations, and configuration errors.
8
+ * Maintains backward compatibility with existing properties (filePath, reason, code).
9
+ */
10
+ export default class ValidationError extends QuireError {
11
+ constructor(message, { filePath, reason, code, suggestion, docsUrl: docsUrlOverride } = {}) {
12
+ super(message, {
13
+ code,
14
+ exitCode: 4,
15
+ filePath,
16
+ suggestion: suggestion || (reason ? `Fix: ${reason}` : undefined),
17
+ docsUrl: docsUrlOverride || docsUrl('troubleshooting')
18
+ })
19
+ // Maintain backward compatibility
20
+ this.reason = reason
12
21
  }
13
- }
22
+ }
@@ -36,7 +36,7 @@ export async function clean (projectRoot, paths, options = {}) {
36
36
  const deletedPaths = await deleteAsync(pathsToClean, {
37
37
  dryRun: options.dryRun,
38
38
  force: true,
39
- onProgress: (options.progress || options.verbose) && progressLogger,
39
+ onProgress: options.verbose && progressLogger,
40
40
  })
41
41
 
42
42
  return deletedPaths