@thegetty/quire-cli 1.0.0-rc.38 → 1.0.0-rc.40
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.
- package/bin/cli.js +14 -1
- package/package.json +3 -1
- package/src/commands/config.js +1 -1
- package/src/commands/help.js +60 -0
- package/src/commands/help.test.js +132 -0
- package/src/errors/help/help-topic-not-found-error.js +22 -0
- package/src/errors/help/index.js +8 -0
- package/src/errors/index.js +6 -0
- package/src/errors/input/index.js +8 -0
- package/src/errors/input/invalid-input-error.js +21 -0
- package/src/helpers/pager.js +59 -0
- package/src/helpers/pager.test.js +85 -0
- package/src/lib/commander/index.js +2 -0
- package/src/lib/commander/options.js +24 -0
- package/src/lib/commander/options.test.js +46 -1
- package/src/lib/help/frontmatter.js +77 -0
- package/src/lib/help/frontmatter.test.js +139 -0
- package/src/lib/help/index.js +135 -0
- package/src/lib/help/index.test.js +160 -0
- package/src/lib/help/topics/configuration.md +77 -0
- package/src/lib/help/topics/debugging.md +69 -0
- package/src/lib/help/topics/epub.md +74 -0
- package/src/lib/help/topics/pdf.md +74 -0
- package/src/lib/help/topics/publishing.md +80 -0
- package/src/lib/help/topics/workflows.md +50 -0
- package/src/lib/logger/index.js +1 -1
- package/src/lib/logger/index.test.js +101 -0
- package/src/main.js +40 -1
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: PDF Generation
|
|
3
|
+
description: Creating print-ready PDF publications
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# PDF Generation
|
|
7
|
+
|
|
8
|
+
## Quick Start
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
quire pdf --build # Build and generate PDF
|
|
12
|
+
quire pdf --build --open # Build, generate, and open PDF
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## PDF Engines
|
|
16
|
+
|
|
17
|
+
Quire supports two PDF engines:
|
|
18
|
+
|
|
19
|
+
### Paged.js (Default)
|
|
20
|
+
|
|
21
|
+
Open-source, browser-based PDF generation. No additional installation required.
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
quire pdf # Uses Paged.js by default
|
|
25
|
+
quire pdf --lib pagedjs # Explicit Paged.js
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### PrinceXML
|
|
29
|
+
|
|
30
|
+
Commercial PDF engine with advanced typography features. Requires separate installation.
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
quire pdf --lib prince # Use PrinceXML
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**When to use PrinceXML:**
|
|
37
|
+
- Complex typography requirements
|
|
38
|
+
- Specific print production needs
|
|
39
|
+
- Advanced CSS paged media features
|
|
40
|
+
|
|
41
|
+
## Configuration
|
|
42
|
+
|
|
43
|
+
PDF settings in `content/_data/config.yaml`:
|
|
44
|
+
|
|
45
|
+
```yaml
|
|
46
|
+
pdf:
|
|
47
|
+
output: _site/downloads/my-publication.pdf
|
|
48
|
+
# Additional PDF-specific settings
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Troubleshooting
|
|
52
|
+
|
|
53
|
+
### PDF is blank or missing content
|
|
54
|
+
|
|
55
|
+
1. Ensure build completed successfully: `quire build`
|
|
56
|
+
2. Check that `_site/pdf.html` exists
|
|
57
|
+
3. Run with debug: `quire pdf --debug`
|
|
58
|
+
|
|
59
|
+
### Fonts not rendering correctly
|
|
60
|
+
|
|
61
|
+
- Ensure fonts are properly installed or embedded
|
|
62
|
+
- Check font paths in your CSS
|
|
63
|
+
|
|
64
|
+
### Page breaks in wrong places
|
|
65
|
+
|
|
66
|
+
Use CSS page break properties:
|
|
67
|
+
|
|
68
|
+
```css
|
|
69
|
+
.chapter {
|
|
70
|
+
page-break-before: always;
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
See full documentation: https://quire.getty.edu/docs-v1/pdf-output/
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Publishing
|
|
3
|
+
description: Deploying your Quire publication
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Publishing Your Publication
|
|
7
|
+
|
|
8
|
+
## Build for Production
|
|
9
|
+
|
|
10
|
+
Always use a clean build for production:
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
quire clean && quire build
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
This ensures all files are freshly generated without stale artifacts.
|
|
17
|
+
|
|
18
|
+
## Output Formats
|
|
19
|
+
|
|
20
|
+
### Web (HTML)
|
|
21
|
+
|
|
22
|
+
The default `quire build` generates a static HTML site in `_site/`:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
quire build
|
|
26
|
+
# Output: _site/
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Deploy the `_site/` directory to any static hosting service.
|
|
30
|
+
|
|
31
|
+
### PDF
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
quire pdf --build
|
|
35
|
+
# Output: _site/downloads/*.pdf
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### EPUB
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
quire epub --build
|
|
42
|
+
# Output: _site/downloads/*.epub
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Complete Publication Workflow
|
|
46
|
+
|
|
47
|
+
Generate all formats in one sequence:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
quire clean && quire build && quire pdf && quire epub
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Deployment Options
|
|
54
|
+
|
|
55
|
+
### GitHub Pages
|
|
56
|
+
|
|
57
|
+
1. Push `_site/` to a `gh-pages` branch
|
|
58
|
+
2. Configure GitHub Pages in repository settings
|
|
59
|
+
3. Access at `https://username.github.io/repo-name/`
|
|
60
|
+
|
|
61
|
+
### Netlify / Vercel
|
|
62
|
+
|
|
63
|
+
1. Connect your repository
|
|
64
|
+
2. Set build command: `quire build`
|
|
65
|
+
3. Set publish directory: `_site`
|
|
66
|
+
|
|
67
|
+
### Traditional Hosting
|
|
68
|
+
|
|
69
|
+
Upload the contents of `_site/` to your web server via FTP/SFTP.
|
|
70
|
+
|
|
71
|
+
## Pre-Publication Checklist
|
|
72
|
+
|
|
73
|
+
- [ ] Run `quire validate` to check for errors
|
|
74
|
+
- [ ] Review all content for accuracy
|
|
75
|
+
- [ ] Test links and navigation
|
|
76
|
+
- [ ] Verify images display correctly
|
|
77
|
+
- [ ] Check PDF and EPUB in multiple readers
|
|
78
|
+
- [ ] Test on different devices and browsers
|
|
79
|
+
|
|
80
|
+
See full documentation: https://quire.getty.edu/docs-v1/site-deploy/
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Common Workflows
|
|
3
|
+
description: Step-by-step guides for common Quire tasks
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Common Workflows
|
|
7
|
+
|
|
8
|
+
## Starting a New Project
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
quire new my-book && cd my-book && quire preview
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Building for Web
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
quire build # Generate HTML site files
|
|
18
|
+
quire clean && quire build # Clean build (recommended for production)
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Generating PDF
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
quire pdf --build # Build first, then generate PDF
|
|
25
|
+
quire pdf --build --open # Generate and open PDF
|
|
26
|
+
quire pdf --lib prince # Use PrinceXML instead of Paged.js
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Generating EPUB
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
quire epub --build # Build first, then generate EPUB
|
|
33
|
+
quire epub --build --open # Generate and open EPUB
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Full Publication Build
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
quire clean && quire build && quire pdf && quire epub
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Troubleshooting
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
quire validate # Check YAML files for errors
|
|
46
|
+
quire info # Show version information
|
|
47
|
+
quire build --verbose # Build with detailed output
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
See full documentation: https://quire.getty.edu/docs-v1/
|
package/src/lib/logger/index.js
CHANGED
|
@@ -162,7 +162,7 @@ export default function createLogger(name = 'quire', level) {
|
|
|
162
162
|
const prefix = config.get('logPrefix')
|
|
163
163
|
const prefixStyle = config.get('logPrefixStyle')
|
|
164
164
|
const showLevel = config.get('logShowLevel')
|
|
165
|
-
const useColor = config.get('logUseColor')
|
|
165
|
+
const useColor = config.get('logUseColor') && !process.env.NO_COLOR
|
|
166
166
|
const colorMessages = config.get('logColorMessages')
|
|
167
167
|
|
|
168
168
|
const parts = []
|
|
@@ -475,3 +475,104 @@ test.serial('invalid env var value falls back to info', async (t) => {
|
|
|
475
475
|
}
|
|
476
476
|
}
|
|
477
477
|
})
|
|
478
|
+
|
|
479
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
480
|
+
// NO_COLOR environment variable tests
|
|
481
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
482
|
+
|
|
483
|
+
test.serial('logger disables color when NO_COLOR env var is set', async (t) => {
|
|
484
|
+
const { sandbox } = t.context
|
|
485
|
+
const consoleErrorStub = sandbox.stub(console, 'error')
|
|
486
|
+
const originalNoColor = process.env.NO_COLOR
|
|
487
|
+
|
|
488
|
+
try {
|
|
489
|
+
process.env.NO_COLOR = '1'
|
|
490
|
+
|
|
491
|
+
const mockConfig = {
|
|
492
|
+
get: sandbox.stub().callsFake((key) => ({
|
|
493
|
+
logPrefix: 'quire',
|
|
494
|
+
logPrefixStyle: 'bracket',
|
|
495
|
+
logShowLevel: true,
|
|
496
|
+
logUseColor: true, // Config says use color, but NO_COLOR overrides
|
|
497
|
+
logColorMessages: true,
|
|
498
|
+
})[key])
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
const { default: createLoggerMocked } = await esmock('./index.js', {
|
|
502
|
+
'#lib/conf/config.js': { default: mockConfig }
|
|
503
|
+
})
|
|
504
|
+
|
|
505
|
+
const log = createLoggerMocked('test:nocolor', 'error')
|
|
506
|
+
log.error('Error message')
|
|
507
|
+
|
|
508
|
+
t.true(consoleErrorStub.calledOnce)
|
|
509
|
+
const output = consoleErrorStub.firstCall.args.join(' ')
|
|
510
|
+
// Should not contain ANSI escape sequences when NO_COLOR is set
|
|
511
|
+
t.false(/\u001b\[/.test(output), 'output should not contain ANSI escape codes')
|
|
512
|
+
// Should still contain the actual text
|
|
513
|
+
t.true(output.includes('[quire]'))
|
|
514
|
+
t.true(output.includes('ERROR'))
|
|
515
|
+
t.true(output.includes('Error message'))
|
|
516
|
+
} finally {
|
|
517
|
+
if (originalNoColor === undefined) {
|
|
518
|
+
delete process.env.NO_COLOR
|
|
519
|
+
} else {
|
|
520
|
+
process.env.NO_COLOR = originalNoColor
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
})
|
|
524
|
+
|
|
525
|
+
test.serial('logger uses color when NO_COLOR env var is not set and config enables color', async (t) => {
|
|
526
|
+
const { sandbox } = t.context
|
|
527
|
+
const consoleErrorStub = sandbox.stub(console, 'error')
|
|
528
|
+
const originalNoColor = process.env.NO_COLOR
|
|
529
|
+
|
|
530
|
+
try {
|
|
531
|
+
delete process.env.NO_COLOR
|
|
532
|
+
|
|
533
|
+
const mockConfig = {
|
|
534
|
+
get: sandbox.stub().callsFake((key) => ({
|
|
535
|
+
logPrefix: 'quire',
|
|
536
|
+
logPrefixStyle: 'bracket',
|
|
537
|
+
logShowLevel: true,
|
|
538
|
+
logUseColor: true,
|
|
539
|
+
logColorMessages: true,
|
|
540
|
+
})[key])
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
// Create a mock chalk that always applies ANSI styling regardless of TTY/env
|
|
544
|
+
const ansiRed = (s) => `\u001b[91m${s}\u001b[39m`
|
|
545
|
+
const ansiRedInverse = (s) => `\u001b[91m\u001b[7m${s}\u001b[27m\u001b[39m`
|
|
546
|
+
const ansiBold = (s) => `\u001b[1m${s}\u001b[22m`
|
|
547
|
+
const mockChalk = {
|
|
548
|
+
bold: ansiBold,
|
|
549
|
+
gray: (s) => s,
|
|
550
|
+
yellow: (s) => s,
|
|
551
|
+
magenta: (s) => s,
|
|
552
|
+
red: ansiRed,
|
|
553
|
+
redBright: { inverse: ansiRedInverse },
|
|
554
|
+
'yellow.inverse': (s) => s,
|
|
555
|
+
}
|
|
556
|
+
// Support chained properties
|
|
557
|
+
mockChalk.yellow.inverse = (s) => s
|
|
558
|
+
|
|
559
|
+
const { default: createLoggerMocked } = await esmock('./index.js', {
|
|
560
|
+
'#lib/conf/config.js': { default: mockConfig },
|
|
561
|
+
'chalk': { default: mockChalk }
|
|
562
|
+
})
|
|
563
|
+
|
|
564
|
+
const log = createLoggerMocked('test:withcolor', 'error')
|
|
565
|
+
log.error('Error message')
|
|
566
|
+
|
|
567
|
+
t.true(consoleErrorStub.calledOnce)
|
|
568
|
+
const output = consoleErrorStub.firstCall.args.join(' ')
|
|
569
|
+
// Should contain ANSI escape sequences when color is enabled and NO_COLOR not set
|
|
570
|
+
t.true(/\u001b\[/.test(output), 'output should contain ANSI escape codes')
|
|
571
|
+
} finally {
|
|
572
|
+
if (originalNoColor === undefined) {
|
|
573
|
+
delete process.env.NO_COLOR
|
|
574
|
+
} else {
|
|
575
|
+
process.env.NO_COLOR = originalNoColor
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
})
|
package/src/main.js
CHANGED
|
@@ -2,6 +2,8 @@ import { Command, Argument, Option } from 'commander'
|
|
|
2
2
|
import {
|
|
3
3
|
arrayToArgument,
|
|
4
4
|
arrayToOption,
|
|
5
|
+
colorOption,
|
|
6
|
+
noColorOption,
|
|
5
7
|
quietOption,
|
|
6
8
|
verboseOption,
|
|
7
9
|
debugOption
|
|
@@ -34,7 +36,22 @@ Output Modes:
|
|
|
34
36
|
|
|
35
37
|
Set defaults: quire settings set verbose true
|
|
36
38
|
|
|
39
|
+
Color Output:
|
|
40
|
+
--no-color Disable colored output
|
|
41
|
+
--color Force colored output (overrides NO_COLOR env var)
|
|
42
|
+
|
|
43
|
+
Respects NO_COLOR environment variable (https://no-color.org/)
|
|
44
|
+
Set default: quire settings set logUseColor false
|
|
45
|
+
|
|
46
|
+
Paging:
|
|
47
|
+
--no-pager Disable paging for long output
|
|
48
|
+
NO_PAGER=1 Disable paging via environment variable
|
|
49
|
+
PAGER=cat Traditional Unix alternative (passes output through)
|
|
50
|
+
|
|
37
51
|
Environment Variables:
|
|
52
|
+
NO_COLOR Disable colored output (https://no-color.org/)
|
|
53
|
+
NO_PAGER=1 Disable paging for long output
|
|
54
|
+
PAGER=<program> Set pager program (default: less). Use PAGER=cat to disable
|
|
38
55
|
DEBUG=quire:* Enable debug output for all modules
|
|
39
56
|
DEBUG=quire:lib:pdf Enable debug output for PDF module only
|
|
40
57
|
DEBUG=quire:lib:* Enable debug output for all lib modules
|
|
@@ -43,13 +60,15 @@ Examples:
|
|
|
43
60
|
$ quire build Build the publication
|
|
44
61
|
$ quire build --verbose Build with detailed progress
|
|
45
62
|
$ quire build --debug Build with debug output
|
|
63
|
+
$ quire build --no-color Build without colored output
|
|
64
|
+
$ NO_COLOR=1 quire build Build without colored output
|
|
46
65
|
$ DEBUG=quire:* quire pdf Generate PDF with debug output
|
|
47
66
|
`
|
|
48
67
|
|
|
49
68
|
/**
|
|
50
69
|
* Quire CLI implements the command pattern.
|
|
51
70
|
*
|
|
52
|
-
* The
|
|
71
|
+
* The \`main\` module acts as the _receiver_, parsing input from the client,
|
|
53
72
|
* calling the appropriate command module(s), managing messages between modules,
|
|
54
73
|
* and sending formatted messages to the client for display.
|
|
55
74
|
*/
|
|
@@ -59,9 +78,12 @@ program
|
|
|
59
78
|
.name('quire')
|
|
60
79
|
.description('Quire command-line interface')
|
|
61
80
|
.version(version, '-V, --version', 'output quire version number')
|
|
81
|
+
.addOption(arrayToOption(colorOption))
|
|
82
|
+
.addOption(arrayToOption(noColorOption))
|
|
62
83
|
.addOption(arrayToOption(quietOption))
|
|
63
84
|
.addOption(arrayToOption(verboseOption))
|
|
64
85
|
.addOption(arrayToOption(debugOption))
|
|
86
|
+
.option('--no-pager', 'disable paging for long output')
|
|
65
87
|
.addHelpText('after', mainHelpText)
|
|
66
88
|
.configureHelp({
|
|
67
89
|
helpWidth: 80,
|
|
@@ -80,6 +102,8 @@ program
|
|
|
80
102
|
* - --quiet: Suppress progress spinners (for CI/scripts)
|
|
81
103
|
* - --verbose: Show detailed progress (paths, timing, steps)
|
|
82
104
|
* - --debug: Enable DEBUG namespace + tool debug modes (for developers)
|
|
105
|
+
* - --no-color: Disable colored output (sets NO_COLOR env var)
|
|
106
|
+
* - --color: Force colored output (overrides NO_COLOR env var)
|
|
83
107
|
*
|
|
84
108
|
* These global options are passed through to commands via opts()
|
|
85
109
|
* and should be merged with command-level options.
|
|
@@ -87,11 +111,26 @@ program
|
|
|
87
111
|
program.hook('preAction', (thisCommand) => {
|
|
88
112
|
const opts = thisCommand.opts()
|
|
89
113
|
|
|
114
|
+
// Handle --no-color / --color flag
|
|
115
|
+
// Sets NO_COLOR env var for chalk, ora, and logger to read
|
|
116
|
+
if (opts.color === false) {
|
|
117
|
+
process.env.NO_COLOR = '1'
|
|
118
|
+
delete process.env.FORCE_COLOR
|
|
119
|
+
} else if (opts.color === true) {
|
|
120
|
+
delete process.env.NO_COLOR
|
|
121
|
+
process.env.FORCE_COLOR = '1'
|
|
122
|
+
}
|
|
123
|
+
|
|
90
124
|
// --debug or config.debug enables the quire:* DEBUG namespace for internal logging
|
|
91
125
|
// CLI flag takes precedence, then config setting
|
|
92
126
|
if (opts.debug ?? config.get('debug')) {
|
|
93
127
|
enableDebug('quire:*')
|
|
94
128
|
}
|
|
129
|
+
|
|
130
|
+
// --no-pager sets pager to false; propagate via env var for pager utility
|
|
131
|
+
if (opts.pager === false) {
|
|
132
|
+
process.env.NO_PAGER = '1'
|
|
133
|
+
}
|
|
95
134
|
})
|
|
96
135
|
|
|
97
136
|
/**
|