@thegetty/quire-cli 1.0.0-rc.38 → 1.0.0-rc.39

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.
@@ -0,0 +1,135 @@
1
+ /**
2
+ * Help topics module
3
+ *
4
+ * Provides loading and rendering of help topics from markdown files.
5
+ * Topics are stored in the topics/ directory as markdown files with
6
+ * YAML frontmatter for metadata.
7
+ *
8
+ * @module lib/help
9
+ */
10
+ import fs from 'fs-extra'
11
+ import { marked } from 'marked'
12
+ import { markedTerminal } from 'marked-terminal'
13
+ import path from 'node:path'
14
+ import { fileURLToPath } from 'node:url'
15
+ import { HelpTopicNotFoundError } from '#src/errors/index.js'
16
+ import { extractFrontmatter, stripFrontmatter } from './frontmatter.js'
17
+
18
+ const __filename = fileURLToPath(import.meta.url)
19
+ const __dirname = path.dirname(__filename)
20
+
21
+ // Nota bene: env var override for development/testing only, not user-configurable
22
+ const TOPICS_DIR =
23
+ process.env.QUIRE_HELP_TOPICS_DIR || path.join(__dirname, 'topics');
24
+
25
+ /**
26
+ * Topic metadata extracted from markdown frontmatter
27
+ * @typedef {Object} TopicMeta
28
+ * @property {string} name - Topic identifier (filename without .md)
29
+ * @property {string} title - Display title
30
+ * @property {string} description - Brief description for listing
31
+ */
32
+
33
+ /**
34
+ * List all available help topics
35
+ * @returns {Promise<TopicMeta[]>} Array of topic metadata sorted by name
36
+ */
37
+ async function listTopics() {
38
+ if (!await fs.pathExists(TOPICS_DIR)) {
39
+ return []
40
+ }
41
+
42
+ const files = await fs.readdir(TOPICS_DIR)
43
+ const topics = []
44
+
45
+ for (const file of files) {
46
+ if (!file.endsWith('.md')) continue
47
+
48
+ const name = path.basename(file, '.md')
49
+ const content = await fs.readFile(path.join(TOPICS_DIR, file), 'utf-8')
50
+ const meta = extractFrontmatter(content)
51
+
52
+ topics.push({
53
+ name,
54
+ title: meta.title || name,
55
+ description: meta.description || ''
56
+ })
57
+ }
58
+
59
+ return topics.sort((a, b) => a.name.localeCompare(b.name))
60
+ }
61
+
62
+ /**
63
+ * Load a help topic by name
64
+ * @param {string} name - Topic name (without .md extension)
65
+ * @returns {Promise<string>} Topic content
66
+ * @throws {HelpTopicNotFoundError} If topic does not exist
67
+ */
68
+ async function loadTopic(name) {
69
+ const filePath = path.join(TOPICS_DIR, `${name}.md`)
70
+
71
+ if (!await fs.pathExists(filePath)) {
72
+ throw new HelpTopicNotFoundError(name)
73
+ }
74
+
75
+ const content = await fs.readFile(filePath, 'utf-8')
76
+ return stripFrontmatter(content)
77
+ }
78
+
79
+ /**
80
+ * Render markdown content for terminal display
81
+ * @param {string} content - Markdown content
82
+ * @returns {string} Rendered content for terminal
83
+ */
84
+ function renderTopic(content) {
85
+ marked.use(markedTerminal())
86
+ return marked.parse(content).trimEnd()
87
+ }
88
+
89
+ /**
90
+ * Format topic list for display
91
+ * @param {TopicMeta[]} topics - Array of topic metadata
92
+ * @returns {string} Formatted topic list
93
+ */
94
+ function formatTopicList(topics) {
95
+ if (topics.length === 0) {
96
+ return 'No help topics available.'
97
+ }
98
+
99
+ const lines = ['Available help topics:\n']
100
+ topics.forEach(({ name, description }) => {
101
+ lines.push(` ${name.padEnd(16)} ${description}`)
102
+ })
103
+ lines.push('\nRun "quire help <topic>" for detailed information.')
104
+ lines.push('Run "quire <command> --help" for command-specific options.')
105
+
106
+ return lines.join('\n')
107
+ }
108
+
109
+ /**
110
+ * Get formatted list of available help topics
111
+ * @returns {Promise<string>} Formatted topic list for display
112
+ */
113
+ export async function getTopicList() {
114
+ const topics = await listTopics()
115
+ return formatTopicList(topics)
116
+ }
117
+
118
+ /**
119
+ * Get formatted help content for a topic
120
+ * @param {string} name - Topic name
121
+ * @returns {Promise<string>} Rendered topic content
122
+ * @throws {HelpTopicNotFoundError} If topic does not exist
123
+ */
124
+ export async function getTopicContent(name) {
125
+ const content = await loadTopic(name)
126
+ return renderTopic(content)
127
+ }
128
+
129
+ /**
130
+ * Get the topics directory path (for testing)
131
+ * @returns {string} Path to topics directory
132
+ */
133
+ export function getTopicsDir() {
134
+ return TOPICS_DIR
135
+ }
@@ -0,0 +1,160 @@
1
+ import esmock from 'esmock'
2
+ import path from 'node:path'
3
+ import sinon from 'sinon'
4
+ import test from 'ava'
5
+
6
+ /**
7
+ * Help Topics Library Tests
8
+ *
9
+ * Tests the help topics public API.
10
+ */
11
+
12
+ test.beforeEach((t) => {
13
+ t.context.sandbox = sinon.createSandbox()
14
+ })
15
+
16
+ test.afterEach.always((t) => {
17
+ t.context.sandbox.restore()
18
+ })
19
+
20
+ test('getTopicList() returns formatted list of topics', async (t) => {
21
+ const { sandbox } = t.context
22
+
23
+ const mockFs = {
24
+ pathExists: sandbox.stub().resolves(true),
25
+ readdir: sandbox.stub().resolves(['workflows.md', 'debugging.md']),
26
+ readFile: sandbox.stub()
27
+ }
28
+
29
+ mockFs.readFile.withArgs(sinon.match(/workflows\.md/), 'utf-8').resolves(`---
30
+ title: Common Workflows
31
+ description: Step-by-step guides
32
+ ---
33
+ # Workflows`)
34
+
35
+ mockFs.readFile.withArgs(sinon.match(/debugging\.md/), 'utf-8').resolves(`---
36
+ title: Debugging
37
+ description: Troubleshooting help
38
+ ---
39
+ # Debugging`)
40
+
41
+ const { getTopicList } = await esmock('./index.js', {
42
+ 'fs-extra': mockFs
43
+ })
44
+
45
+ const output = await getTopicList()
46
+
47
+ t.true(output.includes('Available help topics:'))
48
+ t.true(output.includes('debugging'))
49
+ t.true(output.includes('Troubleshooting help'))
50
+ t.true(output.includes('workflows'))
51
+ t.true(output.includes('Step-by-step guides'))
52
+ t.true(output.includes('Run "quire help <topic>"'))
53
+ })
54
+
55
+ test('getTopicList() returns message when no topics available', async (t) => {
56
+ const { sandbox } = t.context
57
+
58
+ const mockFs = {
59
+ pathExists: sandbox.stub().resolves(false)
60
+ }
61
+
62
+ const { getTopicList } = await esmock('./index.js', {
63
+ 'fs-extra': mockFs
64
+ })
65
+
66
+ const output = await getTopicList()
67
+
68
+ t.is(output, 'No help topics available.')
69
+ })
70
+
71
+ test('getTopicList() returns message when topics directory is empty', async (t) => {
72
+ const { sandbox } = t.context
73
+
74
+ const mockFs = {
75
+ pathExists: sandbox.stub().resolves(true),
76
+ readdir: sandbox.stub().resolves([])
77
+ }
78
+
79
+ const { getTopicList } = await esmock('./index.js', {
80
+ 'fs-extra': mockFs
81
+ })
82
+
83
+ const output = await getTopicList()
84
+
85
+ t.is(output, 'No help topics available.')
86
+ })
87
+
88
+ test('getTopicContent() loads and renders topic', async (t) => {
89
+ const { sandbox } = t.context
90
+
91
+ const mockFs = {
92
+ pathExists: sandbox.stub().resolves(true),
93
+ readFile: sandbox.stub().resolves('# Test\n\nContent here.')
94
+ }
95
+
96
+ const { getTopicContent } = await esmock('./index.js', {
97
+ 'fs-extra': mockFs
98
+ })
99
+
100
+ const content = await getTopicContent('test')
101
+
102
+ t.is(typeof content, 'string')
103
+ t.true(content.includes('Test'))
104
+ t.true(content.includes('Content here'))
105
+ })
106
+
107
+ test('getTopicContent() strips frontmatter from content', async (t) => {
108
+ const { sandbox } = t.context
109
+
110
+ const mockFs = {
111
+ pathExists: sandbox.stub().resolves(true),
112
+ readFile: sandbox.stub().resolves(`---
113
+ title: Test Topic
114
+ description: A test
115
+ ---
116
+ # Test Topic
117
+
118
+ This is the content.`)
119
+ }
120
+
121
+ const { getTopicContent } = await esmock('./index.js', {
122
+ 'fs-extra': mockFs
123
+ })
124
+
125
+ const content = await getTopicContent('test')
126
+
127
+ t.true(content.includes('Test Topic'))
128
+ t.true(content.includes('This is the content'))
129
+ t.false(content.includes('---'))
130
+ t.false(content.includes('title:'))
131
+ })
132
+
133
+ test('getTopicContent() throws HelpTopicNotFoundError for missing topic', async (t) => {
134
+ const { sandbox } = t.context
135
+
136
+ const mockFs = {
137
+ pathExists: sandbox.stub().resolves(false)
138
+ }
139
+
140
+ const { getTopicContent } = await esmock('./index.js', {
141
+ 'fs-extra': mockFs
142
+ })
143
+
144
+ const error = await t.throwsAsync(
145
+ () => getTopicContent('nonexistent'),
146
+ { name: 'HelpTopicNotFoundError' }
147
+ )
148
+
149
+ t.is(error.code, 'HELP_TOPIC_NOT_FOUND')
150
+ t.is(error.topic, 'nonexistent')
151
+ })
152
+
153
+ test('getTopicsDir() returns the topics directory path', async (t) => {
154
+ const { getTopicsDir } = await import('./index.js')
155
+
156
+ const dir = getTopicsDir()
157
+
158
+ t.true(dir.endsWith('topics'))
159
+ t.true(dir.includes(`lib${path.sep}help`))
160
+ })
@@ -0,0 +1,77 @@
1
+ ---
2
+ title: Configuration
3
+ description: Project and CLI configuration options
4
+ ---
5
+
6
+ # Configuration
7
+
8
+ ## Project Configuration
9
+
10
+ The `content/_data/publication.yaml` file contains publication settings:
11
+
12
+ ```yaml
13
+ title: My Publication
14
+ subtitle: A Quire Book
15
+ contributor:
16
+ - type: primary
17
+ first_name: Jane
18
+ last_name: Doe
19
+
20
+ url: https://my-publication.example.com
21
+ ```
22
+
23
+ ## Common Settings
24
+
25
+ ### Publication Metadata
26
+
27
+ ```yaml
28
+ title: Publication Title
29
+ subtitle: Optional Subtitle
30
+ reading_line: Additional context
31
+ pub_date: 2024-01-15
32
+ ```
33
+
34
+ ### Output Configuration
35
+
36
+ ```yaml
37
+ pdf:
38
+ output: _site/downloads/publication.pdf
39
+
40
+ epub:
41
+ output: _site/downloads/publication.epub
42
+ ```
43
+
44
+ ### Build Options
45
+
46
+ ```yaml
47
+ debug: false
48
+ verbose: false
49
+ ```
50
+
51
+ ## CLI Configuration
52
+
53
+ The CLI stores user preferences separately from project settings.
54
+
55
+ ### View Configuration
56
+
57
+ ```bash
58
+ quire config # Show all settings
59
+ quire config path # Show config file location
60
+ ```
61
+
62
+ ### Configuration File Location
63
+
64
+ - **macOS:** `~/Library/Preferences/quire-cli-nodejs/config.json`
65
+ - **Linux:** `~/.config/quire-cli-nodejs/config.json`
66
+ - **Windows:** `%APPDATA%\quire-cli-nodejs\config.json`
67
+
68
+ ## Environment Variables
69
+
70
+ Override settings via environment variables:
71
+
72
+ ```bash
73
+ DEBUG=quire:* quire build # Enable debug output
74
+ QUIRE_LOG_LEVEL=debug quire preview # Set log level
75
+ ```
76
+
77
+ See full documentation: https://quire.getty.edu/docs-v1/configuration/
@@ -0,0 +1,69 @@
1
+ ---
2
+ title: Debugging
3
+ description: Troubleshooting common issues
4
+ ---
5
+
6
+ # Debugging Quire Projects
7
+
8
+ ## Debug Output
9
+
10
+ Enable debug output to see detailed information:
11
+
12
+ ```bash
13
+ quire build --debug # Enable debug mode
14
+ DEBUG=quire:* quire build # Enable all debug namespaces
15
+ DEBUG=quire:lib:pdf quire pdf # Debug PDF module only
16
+ ```
17
+
18
+ ## Common Issues
19
+
20
+ ### Build Fails with YAML Errors
21
+
22
+ Run validation to identify syntax issues:
23
+
24
+ ```bash
25
+ quire validate
26
+ ```
27
+
28
+ Common YAML problems:
29
+ - Missing colons after keys
30
+ - Incorrect indentation (use spaces, not tabs)
31
+ - Unquoted special characters
32
+ - Missing closing quotes
33
+
34
+ ### PDF Generation Fails
35
+
36
+ 1. Check that build output exists: `quire build`
37
+ 2. Run with debug: `quire pdf --debug`
38
+ 3. Verify the PDF engine is installed
39
+
40
+ ### EPUB Generation Fails
41
+
42
+ 1. Ensure the build is complete: `quire build`
43
+ 2. Check for missing images or broken links
44
+ 3. Run with debug: `quire epub --debug`
45
+
46
+ ### Preview Not Updating
47
+
48
+ Try a clean build:
49
+
50
+ ```bash
51
+ quire clean && quire preview
52
+ ```
53
+
54
+ ### "Not in a Quire project" Error
55
+
56
+ Make sure you're in a directory containing:
57
+ - `content/` directory
58
+ - An Eleventy configuration file (`.eleventy.js` or `eleventy.config.js`)
59
+
60
+ ```bash
61
+ cd your-project-name
62
+ quire preview
63
+ ```
64
+
65
+ ## Getting Help
66
+
67
+ - Documentation: https://quire.getty.edu/docs-v1/
68
+ - Community Forum: https://github.com/thegetty/quire/discussions
69
+ - Issue Tracker: https://github.com/thegetty/quire/issues
@@ -0,0 +1,74 @@
1
+ ---
2
+ title: EPUB Generation
3
+ description: Creating e-book publications
4
+ ---
5
+
6
+ # EPUB Generation
7
+
8
+ ## Quick Start
9
+
10
+ ```bash
11
+ quire epub --build # Build and generate EPUB
12
+ quire epub --build --open # Build, generate, and open EPUB
13
+ ```
14
+
15
+ ## EPUB Engines
16
+
17
+ Quire supports two EPUB engines:
18
+
19
+ ### epubjs (Default)
20
+
21
+ JavaScript-based EPUB generation.
22
+
23
+ ```bash
24
+ quire epub # Uses epubjs by default
25
+ quire epub --lib epubjs # Explicit epubjs
26
+ ```
27
+
28
+ ### Pandoc
29
+
30
+ Universal document converter with EPUB support. Requires separate installation.
31
+
32
+ ```bash
33
+ quire epub --lib pandoc # Use Pandoc
34
+ ```
35
+
36
+ ## Configuration
37
+
38
+ EPUB settings in `content/_data/config.yaml`:
39
+
40
+ ```yaml
41
+ epub:
42
+ output: _site/downloads/my-publication.epub
43
+ # Additional EPUB-specific settings
44
+ ```
45
+
46
+ ## Troubleshooting
47
+
48
+ ### EPUB fails validation
49
+
50
+ Common issues:
51
+ - Missing required metadata in `content/_data/publication.yaml`
52
+ - Invalid image formats (use JPEG or PNG)
53
+ - Broken internal links
54
+
55
+ ### Images not appearing
56
+
57
+ 1. Check image paths are relative
58
+ 2. Ensure images are in supported formats
59
+ 3. Verify images exist in the build output
60
+
61
+ ### EPUB not opening in reader
62
+
63
+ 1. Validate the EPUB file structure
64
+ 2. Check for malformed HTML in content
65
+ 3. Ensure all required files are included
66
+
67
+ ## Testing Your EPUB
68
+
69
+ Open in different readers to verify:
70
+ - Apple Books (macOS/iOS)
71
+ - Calibre (cross-platform)
72
+ - Adobe Digital Editions
73
+
74
+ See full documentation: https://quire.getty.edu/docs-v1/epub-output/
@@ -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/