@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.
- package/CHANGELOG.md +0 -36
- package/README.md +0 -9
- package/bin/cli.js +1 -46
- package/package.json +10 -27
- package/src/Command.js +6 -26
- package/src/commands/README.md +122 -213
- package/src/commands/build.js +37 -45
- package/src/commands/clean.js +19 -33
- package/src/commands/conf.js +43 -0
- package/src/commands/create.js +14 -42
- package/src/commands/epub.js +31 -67
- package/src/commands/index.js +2 -9
- package/src/commands/info.js +86 -88
- package/src/commands/pdf.js +82 -63
- package/src/commands/preview.js +31 -32
- package/src/commands/validate.js +20 -64
- package/src/commands/version.js +43 -0
- package/src/errors/validation/validation-error.js +11 -20
- package/src/helpers/clean.js +1 -1
- package/src/helpers/is-quire.js +31 -0
- package/src/helpers/test-cwd.js +6 -5
- package/src/helpers/which.js +4 -10
- package/src/lib/11ty/README.md +19 -135
- package/src/lib/11ty/api.js +93 -235
- package/src/lib/11ty/cli.js +37 -112
- package/src/lib/11ty/index.js +5 -64
- package/src/lib/11ty/paths.js +103 -0
- package/src/lib/README.md +0 -330
- package/src/lib/conf/README.md +69 -86
- package/src/lib/conf/config.js +3 -5
- package/src/lib/conf/defaults.js +0 -65
- package/src/lib/conf/schema.js +9 -103
- package/src/lib/epub/README.md +2 -133
- package/src/lib/epub/epub.js +11 -36
- package/src/lib/epub/index.js +21 -111
- package/src/lib/epub/pandoc.js +4 -33
- package/src/lib/git/README.md +2 -151
- package/src/lib/git/index.js +13 -217
- package/src/lib/i18n/README.md +3 -0
- package/src/lib/i18n/config.js +53 -0
- package/src/lib/i18n/index.js +43 -0
- package/src/lib/i18n/localeService.js +58 -0
- package/src/lib/pdf/README.md +0 -131
- package/src/lib/pdf/index.js +21 -124
- package/src/lib/pdf/paged.js +52 -100
- package/src/lib/pdf/prince.js +37 -115
- package/src/lib/pdf/split.js +33 -61
- package/src/lib/quire/README.md +19 -0
- package/src/lib/quire/index.js +353 -0
- package/src/lib/reporter/README.md +2 -211
- package/src/lib/reporter/index.js +0 -607
- package/src/main.js +48 -221
- package/src/packageConfig.js +0 -17
- package/src/validators/utils.js +1 -2
- package/man/quire.1 +0 -341
- package/man/quire.1.md +0 -232
- package/schemas/config.schema.json +0 -194
- package/schemas/figures.schema.json +0 -56
- package/schemas/layout.schema.json +0 -5
- package/schemas/objects.schema.json +0 -62
- package/schemas/publication.schema.json +0 -140
- package/schemas/references.schema.json +0 -29
- package/src/Command.spec.js +0 -99
- package/src/commands/build.spec.js +0 -113
- package/src/commands/build.test.js +0 -397
- package/src/commands/clean.spec.js +0 -118
- package/src/commands/clean.test.js +0 -382
- package/src/commands/config.js +0 -238
- package/src/commands/config.spec.js +0 -107
- package/src/commands/config.test.js +0 -845
- package/src/commands/create.spec.js +0 -112
- package/src/commands/create.test.js +0 -415
- package/src/commands/doctor.js +0 -251
- package/src/commands/doctor.spec.js +0 -115
- package/src/commands/doctor.test.js +0 -1409
- package/src/commands/epub.spec.js +0 -114
- package/src/commands/epub.test.js +0 -503
- package/src/commands/help.js +0 -60
- package/src/commands/help.test.js +0 -132
- package/src/commands/info.spec.js +0 -72
- package/src/commands/info.test.js +0 -512
- package/src/commands/pdf.spec.js +0 -114
- package/src/commands/pdf.test.js +0 -464
- package/src/commands/preview.spec.js +0 -97
- package/src/commands/preview.test.js +0 -250
- package/src/commands/use.js +0 -56
- package/src/commands/use.spec.js +0 -61
- package/src/commands/use.test.js +0 -280
- package/src/commands/validate.spec.js +0 -90
- package/src/commands/validate.test.js +0 -378
- package/src/commands/workflows.js +0 -70
- package/src/errors/build/build-failed-error.js +0 -19
- package/src/errors/build/config-field-missing-error.js +0 -20
- package/src/errors/build/config-file-not-found-error.js +0 -20
- package/src/errors/build/index.js +0 -11
- package/src/errors/help/help-topic-not-found-error.js +0 -30
- package/src/errors/help/index.js +0 -8
- package/src/errors/index.js +0 -58
- package/src/errors/input/index.js +0 -8
- package/src/errors/input/invalid-input-error.js +0 -21
- package/src/errors/install/dependency-install-error.js +0 -19
- package/src/errors/install/directory-not-empty-error.js +0 -25
- package/src/errors/install/index.js +0 -12
- package/src/errors/install/invalid-path-error.js +0 -31
- package/src/errors/install/invalid-starter-error.js +0 -27
- package/src/errors/install/version-not-found-error.js +0 -35
- package/src/errors/output/epub-generation-error.js +0 -19
- package/src/errors/output/index.js +0 -14
- package/src/errors/output/invalid-epub-library-error.js +0 -20
- package/src/errors/output/invalid-pdf-library-error.js +0 -20
- package/src/errors/output/missing-build-output-error.js +0 -21
- package/src/errors/output/pdf-generation-error.js +0 -24
- package/src/errors/output/tool-not-found-error.js +0 -37
- package/src/errors/project/index.js +0 -10
- package/src/errors/project/not-in-project-error.js +0 -20
- package/src/errors/project/project-create-error.js +0 -21
- package/src/errors/quire-error.js +0 -27
- package/src/errors/validation/index.js +0 -3
- package/src/errors/validation/unknown-config-key-error.js +0 -27
- package/src/errors/validation/unknown-config-operation-error.js +0 -24
- package/src/helpers/docs-url.js +0 -32
- package/src/helpers/pager.js +0 -59
- package/src/helpers/pager.test.js +0 -85
- package/src/helpers/suggest-similar.js +0 -124
- package/src/helpers/suggest-similar.test.js +0 -108
- package/src/helpers/test-cwd.test.js +0 -192
- package/src/lib/11ty/index.test.js +0 -655
- package/src/lib/commander/index.js +0 -103
- package/src/lib/commander/index.test.js +0 -86
- package/src/lib/commander/options.js +0 -237
- package/src/lib/commander/options.test.js +0 -205
- package/src/lib/conf/build-status.js +0 -103
- package/src/lib/conf/build-status.test.js +0 -247
- package/src/lib/conf/config.test.js +0 -281
- package/src/lib/conf/format.js +0 -60
- package/src/lib/conf/format.test.js +0 -106
- package/src/lib/conf/helpers.js +0 -91
- package/src/lib/conf/helpers.test.js +0 -136
- package/src/lib/conf/index.js +0 -22
- package/src/lib/constants.js +0 -28
- package/src/lib/doctor/README.md +0 -667
- package/src/lib/doctor/checks/environment/cli-version.js +0 -62
- package/src/lib/doctor/checks/environment/cli-version.test.js +0 -132
- package/src/lib/doctor/checks/environment/git-available.js +0 -77
- package/src/lib/doctor/checks/environment/git-available.test.js +0 -52
- package/src/lib/doctor/checks/environment/index.js +0 -13
- package/src/lib/doctor/checks/environment/node-version.js +0 -66
- package/src/lib/doctor/checks/environment/node-version.test.js +0 -17
- package/src/lib/doctor/checks/environment/npm-available.js +0 -66
- package/src/lib/doctor/checks/environment/npm-available.test.js +0 -52
- package/src/lib/doctor/checks/environment/os-info.js +0 -48
- package/src/lib/doctor/checks/environment/os-info.test.js +0 -81
- package/src/lib/doctor/checks/environment/runtime-info.js +0 -51
- package/src/lib/doctor/checks/environment/runtime-info.test.js +0 -132
- package/src/lib/doctor/checks/outputs/epub-output.js +0 -119
- package/src/lib/doctor/checks/outputs/epub-output.test.js +0 -277
- package/src/lib/doctor/checks/outputs/index.js +0 -10
- package/src/lib/doctor/checks/outputs/pdf-output.js +0 -144
- package/src/lib/doctor/checks/outputs/pdf-output.test.js +0 -377
- package/src/lib/doctor/checks/outputs/stale-build.js +0 -122
- package/src/lib/doctor/checks/outputs/stale-build.test.js +0 -282
- package/src/lib/doctor/checks/project/data-files.js +0 -56
- package/src/lib/doctor/checks/project/data-files.test.js +0 -125
- package/src/lib/doctor/checks/project/dependencies.js +0 -53
- package/src/lib/doctor/checks/project/dependencies.test.js +0 -71
- package/src/lib/doctor/checks/project/index.js +0 -11
- package/src/lib/doctor/checks/project/quire-11ty.js +0 -98
- package/src/lib/doctor/checks/project/quire-11ty.test.js +0 -170
- package/src/lib/doctor/checks/project/quire-project.js +0 -38
- package/src/lib/doctor/checks/project/quire-project.test.js +0 -47
- package/src/lib/doctor/checks/tools/index.js +0 -10
- package/src/lib/doctor/checks/tools/pandoc-available.js +0 -82
- package/src/lib/doctor/checks/tools/pandoc-available.test.js +0 -73
- package/src/lib/doctor/checks/tools/prince-available.js +0 -81
- package/src/lib/doctor/checks/tools/prince-available.test.js +0 -73
- package/src/lib/doctor/constants.js +0 -39
- package/src/lib/doctor/formatDuration.js +0 -108
- package/src/lib/doctor/formatDuration.test.js +0 -76
- package/src/lib/doctor/formatters/human.js +0 -257
- package/src/lib/doctor/formatters/human.test.js +0 -463
- package/src/lib/doctor/formatters/index.js +0 -8
- package/src/lib/doctor/formatters/json.js +0 -78
- package/src/lib/doctor/formatters/json.test.js +0 -174
- package/src/lib/doctor/formatters/shared.js +0 -129
- package/src/lib/doctor/formatters/shared.test.js +0 -194
- package/src/lib/doctor/index.js +0 -271
- package/src/lib/doctor/index.test.js +0 -797
- package/src/lib/epub/engines.js +0 -46
- package/src/lib/epub/index.test.js +0 -518
- package/src/lib/epub/pandoc.test.js +0 -122
- package/src/lib/epub/schema.js +0 -21
- package/src/lib/error/README.md +0 -170
- package/src/lib/error/handler.js +0 -107
- package/src/lib/git/index.spec.js +0 -80
- package/src/lib/git/index.test.js +0 -453
- package/src/lib/help/frontmatter.js +0 -77
- package/src/lib/help/frontmatter.test.js +0 -139
- package/src/lib/help/index.js +0 -146
- package/src/lib/help/index.test.js +0 -188
- package/src/lib/help/topics/configuration.md +0 -77
- package/src/lib/help/topics/debugging.md +0 -69
- package/src/lib/help/topics/epub.md +0 -74
- package/src/lib/help/topics/pdf.md +0 -74
- package/src/lib/help/topics/publishing.md +0 -80
- package/src/lib/help/topics/workflows.md +0 -50
- package/src/lib/installer/index.js +0 -309
- package/src/lib/installer/index.spec.js +0 -83
- package/src/lib/installer/index.test.js +0 -545
- package/src/lib/logger/README.md +0 -424
- package/src/lib/logger/debug.js +0 -132
- package/src/lib/logger/debug.spec.js +0 -130
- package/src/lib/logger/debug.test.js +0 -128
- package/src/lib/logger/index.js +0 -228
- package/src/lib/logger/index.spec.js +0 -131
- package/src/lib/logger/index.test.js +0 -578
- package/src/lib/npm/README.md +0 -127
- package/src/lib/npm/index.js +0 -198
- package/src/lib/npm/index.spec.js +0 -60
- package/src/lib/npm/index.test.js +0 -355
- package/src/lib/pdf/engines.js +0 -46
- package/src/lib/pdf/index.test.js +0 -708
- package/src/lib/pdf/paged.test.js +0 -366
- package/src/lib/pdf/prince.test.js +0 -202
- package/src/lib/pdf/schema.js +0 -21
- package/src/lib/pdf/split.test.js +0 -445
- package/src/lib/platform.js +0 -95
- package/src/lib/process/manager.js +0 -110
- package/src/lib/process/manager.test.js +0 -55
- package/src/lib/project/build.js +0 -162
- package/src/lib/project/build.test.js +0 -275
- package/src/lib/project/config.js +0 -48
- package/src/lib/project/config.test.js +0 -134
- package/src/lib/project/detect.js +0 -47
- package/src/lib/project/detect.test.js +0 -157
- package/src/lib/project/index.js +0 -56
- package/src/lib/project/output-paths.js +0 -87
- package/src/lib/project/output-paths.test.js +0 -66
- package/src/lib/project/paths.js +0 -272
- package/src/lib/project/version.js +0 -110
- package/src/lib/project/version.test.js +0 -350
- package/src/lib/reporter/index.test.js +0 -862
- package/src/main.spec.js +0 -61
- package/src/main.test.js +0 -347
- package/src/validators/validate-data-files.js +0 -154
- package/src/validators/validate-data-files.test.js +0 -217
package/src/lib/epub/engines.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* EPUB Engine Registry
|
|
3
|
-
*
|
|
4
|
-
* Centralized metadata for EPUB engines. Each engine module re-exports
|
|
5
|
-
* its metadata from here, ensuring single source of truth.
|
|
6
|
-
*
|
|
7
|
-
* The façade imports this registry to:
|
|
8
|
-
* 1. Resolve engine names to implementations
|
|
9
|
-
* 2. Check binary availability before loading heavy modules
|
|
10
|
-
* 3. Provide helpful error messages with install URLs
|
|
11
|
-
*/
|
|
12
|
-
import QuireError from '#src/errors/quire-error.js'
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @typedef {Object} EngineMetadata
|
|
16
|
-
* @property {string} name - Human-readable display name
|
|
17
|
-
* @property {string} module - Module filename (e.g., 'epub.js')
|
|
18
|
-
* @property {string|null} requiresBinary - CLI binary name, or null if built-in
|
|
19
|
-
* @property {Object} [toolInfo] - Error metadata (only for engines requiring binaries)
|
|
20
|
-
* @property {string} [toolInfo.displayName] - Display name for error messages
|
|
21
|
-
* @property {string} [toolInfo.installUrl] - URL to download the tool
|
|
22
|
-
* @property {string} [toolInfo.docsUrl] - Quire docs URL
|
|
23
|
-
* @property {string} [toolInfo.fallback] - Alternative suggestion
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
/** @type {Record<string, EngineMetadata>} */
|
|
27
|
-
const ENGINES = {
|
|
28
|
-
epubjs: {
|
|
29
|
-
name: 'Epub.js',
|
|
30
|
-
module: 'epub.js',
|
|
31
|
-
requiresBinary: null, // Built-in Node.js library
|
|
32
|
-
},
|
|
33
|
-
pandoc: {
|
|
34
|
-
name: 'Pandoc',
|
|
35
|
-
module: 'pandoc.js',
|
|
36
|
-
requiresBinary: 'pandoc',
|
|
37
|
-
toolInfo: {
|
|
38
|
-
displayName: 'Pandoc',
|
|
39
|
-
installUrl: 'https://pandoc.org/installing.html',
|
|
40
|
-
docsUrl: `${QuireError.DOCS_BASE}/epub-output/`,
|
|
41
|
-
fallback: 'Or use the default EPUB engine: quire epub --engine epubjs',
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export default ENGINES
|
|
@@ -1,518 +0,0 @@
|
|
|
1
|
-
import esmock from 'esmock'
|
|
2
|
-
import path from 'node:path'
|
|
3
|
-
import sinon from 'sinon'
|
|
4
|
-
import test from 'ava'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* EPUB Module Integration Tests
|
|
8
|
-
*
|
|
9
|
-
* Tests the EPUB generation façade module behavior with mocked dependencies.
|
|
10
|
-
* Uses esmock to isolate the module from file system and external EPUB tools.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Create a cross-platform absolute path for testing
|
|
15
|
-
* @param {...string} segments - Path segments to join
|
|
16
|
-
* @returns {string} Platform-appropriate absolute path
|
|
17
|
-
*/
|
|
18
|
-
function testPath(...segments) {
|
|
19
|
-
const root = process.platform === 'win32' ? 'C:\\' : '/'
|
|
20
|
-
return path.join(root, ...segments)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
test.beforeEach((t) => {
|
|
24
|
-
t.context.sandbox = sinon.createSandbox()
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
test.afterEach.always((t) => {
|
|
28
|
-
t.context.sandbox.restore()
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
32
|
-
// Library resolution tests
|
|
33
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
34
|
-
|
|
35
|
-
test('generateEpub resolves epubjs library correctly', async (t) => {
|
|
36
|
-
const { sandbox } = t.context
|
|
37
|
-
|
|
38
|
-
const mockEpubLib = sandbox.stub().resolves()
|
|
39
|
-
const mockDynamicImport = sandbox.stub().resolves({ default: mockEpubLib })
|
|
40
|
-
|
|
41
|
-
const mockPaths = {
|
|
42
|
-
getProjectRoot: () => testPath('project'),
|
|
43
|
-
getEpubDir: () => '_epub'
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const mockFs = {
|
|
47
|
-
existsSync: sandbox.stub().returns(true),
|
|
48
|
-
mkdirSync: sandbox.stub()
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const mockReporter = {
|
|
52
|
-
start: sandbox.stub(),
|
|
53
|
-
detail: sandbox.stub(),
|
|
54
|
-
succeed: sandbox.stub(),
|
|
55
|
-
fail: sandbox.stub()
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const generateEpub = await esmock('./index.js', {
|
|
59
|
-
'#helpers/os-utils.js': { dynamicImport: mockDynamicImport },
|
|
60
|
-
'#lib/project/index.js': mockPaths,
|
|
61
|
-
'fs-extra': mockFs,
|
|
62
|
-
'#lib/reporter/index.js': { default: mockReporter }
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
await generateEpub.default({ lib: 'epubjs' })
|
|
66
|
-
|
|
67
|
-
t.true(mockDynamicImport.calledOnce)
|
|
68
|
-
t.true(mockDynamicImport.firstCall.args[0].includes('epub.js'))
|
|
69
|
-
t.true(mockReporter.start.calledWith(sinon.match(/Epub\.js/)))
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
test('generateEpub resolves pandoc library correctly', async (t) => {
|
|
73
|
-
const { sandbox } = t.context
|
|
74
|
-
|
|
75
|
-
const mockEpubLib = sandbox.stub().resolves()
|
|
76
|
-
const mockDynamicImport = sandbox.stub().resolves({ default: mockEpubLib })
|
|
77
|
-
const mockWhich = sandbox.stub().returns('/usr/local/bin/pandoc')
|
|
78
|
-
|
|
79
|
-
const mockPaths = {
|
|
80
|
-
getProjectRoot: () => testPath('project'),
|
|
81
|
-
getEpubDir: () => '_epub'
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const mockFs = {
|
|
85
|
-
existsSync: sandbox.stub().returns(true),
|
|
86
|
-
mkdirSync: sandbox.stub()
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const mockReporter = {
|
|
90
|
-
start: sandbox.stub(),
|
|
91
|
-
detail: sandbox.stub(),
|
|
92
|
-
succeed: sandbox.stub(),
|
|
93
|
-
fail: sandbox.stub()
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const generateEpub = await esmock('./index.js', {
|
|
97
|
-
'#helpers/os-utils.js': { dynamicImport: mockDynamicImport },
|
|
98
|
-
'#helpers/which.js': { default: mockWhich },
|
|
99
|
-
'#lib/project/index.js': mockPaths,
|
|
100
|
-
'fs-extra': mockFs,
|
|
101
|
-
'#lib/reporter/index.js': { default: mockReporter }
|
|
102
|
-
})
|
|
103
|
-
|
|
104
|
-
await generateEpub.default({ lib: 'pandoc' })
|
|
105
|
-
|
|
106
|
-
t.true(mockDynamicImport.firstCall.args[0].includes('pandoc.js'))
|
|
107
|
-
t.true(mockReporter.start.calledWith(sinon.match(/Pandoc/)))
|
|
108
|
-
})
|
|
109
|
-
|
|
110
|
-
test('generateEpub normalizes library name variations', async (t) => {
|
|
111
|
-
const { sandbox } = t.context
|
|
112
|
-
|
|
113
|
-
const mockEpubLib = sandbox.stub().resolves()
|
|
114
|
-
const mockDynamicImport = sandbox.stub().resolves({ default: mockEpubLib })
|
|
115
|
-
const mockWhich = sandbox.stub().returns('/usr/local/bin/pandoc')
|
|
116
|
-
|
|
117
|
-
const mockPaths = {
|
|
118
|
-
getProjectRoot: () => testPath('project'),
|
|
119
|
-
getEpubDir: () => '_epub'
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
const mockFs = {
|
|
123
|
-
existsSync: sandbox.stub().returns(true),
|
|
124
|
-
mkdirSync: sandbox.stub()
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
const mockReporter = {
|
|
128
|
-
start: sandbox.stub(),
|
|
129
|
-
detail: sandbox.stub(),
|
|
130
|
-
succeed: sandbox.stub(),
|
|
131
|
-
fail: sandbox.stub()
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
const generateEpub = await esmock('./index.js', {
|
|
135
|
-
'#helpers/os-utils.js': { dynamicImport: mockDynamicImport },
|
|
136
|
-
'#helpers/which.js': { default: mockWhich },
|
|
137
|
-
'#lib/project/index.js': mockPaths,
|
|
138
|
-
'fs-extra': mockFs,
|
|
139
|
-
'#lib/reporter/index.js': { default: mockReporter }
|
|
140
|
-
})
|
|
141
|
-
|
|
142
|
-
// Test "epub-js" variant (with hyphen)
|
|
143
|
-
await generateEpub.default({ lib: 'epub-js' })
|
|
144
|
-
t.true(mockDynamicImport.firstCall.args[0].includes('epub.js'))
|
|
145
|
-
|
|
146
|
-
// Test "PANDOC" variant (uppercase)
|
|
147
|
-
mockDynamicImport.resetHistory()
|
|
148
|
-
await generateEpub.default({ lib: 'PANDOC' })
|
|
149
|
-
t.true(mockDynamicImport.firstCall.args[0].includes('pandoc.js'))
|
|
150
|
-
})
|
|
151
|
-
|
|
152
|
-
test('generateEpub defaults to epubjs when no library specified', async (t) => {
|
|
153
|
-
const { sandbox } = t.context
|
|
154
|
-
|
|
155
|
-
const mockEpubLib = sandbox.stub().resolves()
|
|
156
|
-
const mockDynamicImport = sandbox.stub().resolves({ default: mockEpubLib })
|
|
157
|
-
|
|
158
|
-
const mockPaths = {
|
|
159
|
-
getProjectRoot: () => testPath('project'),
|
|
160
|
-
getEpubDir: () => '_epub'
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
const mockFs = {
|
|
164
|
-
existsSync: sandbox.stub().returns(true),
|
|
165
|
-
mkdirSync: sandbox.stub()
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
const mockReporter = {
|
|
169
|
-
start: sandbox.stub(),
|
|
170
|
-
detail: sandbox.stub(),
|
|
171
|
-
succeed: sandbox.stub(),
|
|
172
|
-
fail: sandbox.stub()
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
const generateEpub = await esmock('./index.js', {
|
|
176
|
-
'#helpers/os-utils.js': { dynamicImport: mockDynamicImport },
|
|
177
|
-
'#lib/project/index.js': mockPaths,
|
|
178
|
-
'fs-extra': mockFs,
|
|
179
|
-
'#lib/reporter/index.js': { default: mockReporter }
|
|
180
|
-
})
|
|
181
|
-
|
|
182
|
-
await generateEpub.default({})
|
|
183
|
-
|
|
184
|
-
t.true(mockDynamicImport.firstCall.args[0].includes('epub.js'))
|
|
185
|
-
})
|
|
186
|
-
|
|
187
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
188
|
-
// Error handling tests
|
|
189
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
190
|
-
|
|
191
|
-
test('generateEpub throws InvalidEpubLibraryError for unrecognized library', async (t) => {
|
|
192
|
-
const { sandbox } = t.context
|
|
193
|
-
|
|
194
|
-
const mockPaths = {
|
|
195
|
-
getProjectRoot: () => testPath('project'),
|
|
196
|
-
getEpubDir: () => '_epub'
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
const mockReporter = {
|
|
200
|
-
start: sandbox.stub(),
|
|
201
|
-
detail: sandbox.stub(),
|
|
202
|
-
succeed: sandbox.stub(),
|
|
203
|
-
fail: sandbox.stub()
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
const generateEpub = await esmock('./index.js', {
|
|
207
|
-
'#helpers/os-utils.js': { dynamicImport: sandbox.stub() },
|
|
208
|
-
'#lib/project/index.js': mockPaths,
|
|
209
|
-
'fs-extra': { existsSync: sandbox.stub(), mkdirSync: sandbox.stub() },
|
|
210
|
-
'#lib/reporter/index.js': { default: mockReporter }
|
|
211
|
-
})
|
|
212
|
-
|
|
213
|
-
const error = await t.throwsAsync(() => generateEpub.default({ lib: 'unknown-library' }))
|
|
214
|
-
|
|
215
|
-
t.is(error.code, 'INVALID_EPUB_LIBRARY')
|
|
216
|
-
t.true(error.message.includes('unknown-library'))
|
|
217
|
-
})
|
|
218
|
-
|
|
219
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
220
|
-
// Output path tests
|
|
221
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
222
|
-
|
|
223
|
-
test('generateEpub uses default output path based on library name', async (t) => {
|
|
224
|
-
const { sandbox } = t.context
|
|
225
|
-
|
|
226
|
-
const mockEpubLib = sandbox.stub().resolves()
|
|
227
|
-
const mockDynamicImport = sandbox.stub().resolves({ default: mockEpubLib })
|
|
228
|
-
|
|
229
|
-
const mockPaths = {
|
|
230
|
-
getProjectRoot: () => testPath('project'),
|
|
231
|
-
getEpubDir: () => '_epub'
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
const mockFs = {
|
|
235
|
-
existsSync: sandbox.stub().returns(true),
|
|
236
|
-
mkdirSync: sandbox.stub()
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
const mockReporter = {
|
|
240
|
-
start: sandbox.stub(),
|
|
241
|
-
detail: sandbox.stub(),
|
|
242
|
-
succeed: sandbox.stub(),
|
|
243
|
-
fail: sandbox.stub()
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
const generateEpub = await esmock('./index.js', {
|
|
247
|
-
'#helpers/os-utils.js': { dynamicImport: mockDynamicImport },
|
|
248
|
-
'#lib/project/index.js': mockPaths,
|
|
249
|
-
'fs-extra': mockFs,
|
|
250
|
-
'#lib/reporter/index.js': { default: mockReporter }
|
|
251
|
-
})
|
|
252
|
-
|
|
253
|
-
const output = await generateEpub.default({ lib: 'epubjs' })
|
|
254
|
-
|
|
255
|
-
t.is(output, path.join(testPath('project'), 'epubjs.epub'))
|
|
256
|
-
})
|
|
257
|
-
|
|
258
|
-
test('generateEpub uses custom output path when provided', async (t) => {
|
|
259
|
-
const { sandbox } = t.context
|
|
260
|
-
|
|
261
|
-
const mockEpubLib = sandbox.stub().resolves()
|
|
262
|
-
const mockDynamicImport = sandbox.stub().resolves({ default: mockEpubLib })
|
|
263
|
-
|
|
264
|
-
const mockPaths = {
|
|
265
|
-
getProjectRoot: () => testPath('project'),
|
|
266
|
-
getEpubDir: () => '_epub'
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
const mockFs = {
|
|
270
|
-
existsSync: sandbox.stub().returns(true),
|
|
271
|
-
mkdirSync: sandbox.stub()
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
const mockReporter = {
|
|
275
|
-
start: sandbox.stub(),
|
|
276
|
-
detail: sandbox.stub(),
|
|
277
|
-
succeed: sandbox.stub(),
|
|
278
|
-
fail: sandbox.stub()
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
const generateEpub = await esmock('./index.js', {
|
|
282
|
-
'#helpers/os-utils.js': { dynamicImport: mockDynamicImport },
|
|
283
|
-
'#lib/project/index.js': mockPaths,
|
|
284
|
-
'fs-extra': mockFs,
|
|
285
|
-
'#lib/reporter/index.js': { default: mockReporter }
|
|
286
|
-
})
|
|
287
|
-
|
|
288
|
-
const output = await generateEpub.default({ lib: 'epubjs', output: 'my-book.epub' })
|
|
289
|
-
|
|
290
|
-
t.is(output, path.join(testPath('project'), 'my-book.epub'))
|
|
291
|
-
})
|
|
292
|
-
|
|
293
|
-
test('generateEpub resolves relative output path against project root', async (t) => {
|
|
294
|
-
const { sandbox } = t.context
|
|
295
|
-
|
|
296
|
-
const mockEpubLib = sandbox.stub().resolves()
|
|
297
|
-
const mockDynamicImport = sandbox.stub().resolves({ default: mockEpubLib })
|
|
298
|
-
|
|
299
|
-
const mockPaths = {
|
|
300
|
-
getProjectRoot: () => testPath('project'),
|
|
301
|
-
getEpubDir: () => '_epub'
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
const mockFs = {
|
|
305
|
-
existsSync: sandbox.stub().returns(true),
|
|
306
|
-
mkdirSync: sandbox.stub()
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
const mockReporter = {
|
|
310
|
-
start: sandbox.stub(),
|
|
311
|
-
detail: sandbox.stub(),
|
|
312
|
-
succeed: sandbox.stub(),
|
|
313
|
-
fail: sandbox.stub()
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
const generateEpub = await esmock('./index.js', {
|
|
317
|
-
'#helpers/os-utils.js': { dynamicImport: mockDynamicImport },
|
|
318
|
-
'#lib/project/index.js': mockPaths,
|
|
319
|
-
'fs-extra': mockFs,
|
|
320
|
-
'#lib/reporter/index.js': { default: mockReporter }
|
|
321
|
-
})
|
|
322
|
-
|
|
323
|
-
const output = await generateEpub.default({ lib: 'epubjs', output: '_downloads/book' })
|
|
324
|
-
|
|
325
|
-
t.is(output, path.join(testPath('project'), '_downloads', 'book.epub'))
|
|
326
|
-
})
|
|
327
|
-
|
|
328
|
-
test('generateEpub uses absolute output path directly', async (t) => {
|
|
329
|
-
const { sandbox } = t.context
|
|
330
|
-
|
|
331
|
-
const mockEpubLib = sandbox.stub().resolves()
|
|
332
|
-
const mockDynamicImport = sandbox.stub().resolves({ default: mockEpubLib })
|
|
333
|
-
|
|
334
|
-
const mockPaths = {
|
|
335
|
-
getProjectRoot: () => testPath('project'),
|
|
336
|
-
getEpubDir: () => '_epub'
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
const mockFs = {
|
|
340
|
-
existsSync: sandbox.stub().returns(true),
|
|
341
|
-
mkdirSync: sandbox.stub()
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
const mockReporter = {
|
|
345
|
-
start: sandbox.stub(),
|
|
346
|
-
detail: sandbox.stub(),
|
|
347
|
-
succeed: sandbox.stub(),
|
|
348
|
-
fail: sandbox.stub()
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
const generateEpub = await esmock('./index.js', {
|
|
352
|
-
'#helpers/os-utils.js': { dynamicImport: mockDynamicImport },
|
|
353
|
-
'#lib/project/index.js': mockPaths,
|
|
354
|
-
'fs-extra': mockFs,
|
|
355
|
-
'#lib/reporter/index.js': { default: mockReporter }
|
|
356
|
-
})
|
|
357
|
-
|
|
358
|
-
const customPath = testPath('custom', 'path', 'book.epub')
|
|
359
|
-
const output = await generateEpub.default({ lib: 'epubjs', output: customPath })
|
|
360
|
-
|
|
361
|
-
t.is(output, customPath)
|
|
362
|
-
})
|
|
363
|
-
|
|
364
|
-
test('generateEpub adds .epub extension if missing', async (t) => {
|
|
365
|
-
const { sandbox } = t.context
|
|
366
|
-
|
|
367
|
-
const mockEpubLib = sandbox.stub().resolves()
|
|
368
|
-
const mockDynamicImport = sandbox.stub().resolves({ default: mockEpubLib })
|
|
369
|
-
|
|
370
|
-
const mockPaths = {
|
|
371
|
-
getProjectRoot: () => testPath('project'),
|
|
372
|
-
getEpubDir: () => '_epub'
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
const mockFs = {
|
|
376
|
-
existsSync: sandbox.stub().returns(true),
|
|
377
|
-
mkdirSync: sandbox.stub()
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
const mockReporter = {
|
|
381
|
-
start: sandbox.stub(),
|
|
382
|
-
detail: sandbox.stub(),
|
|
383
|
-
succeed: sandbox.stub(),
|
|
384
|
-
fail: sandbox.stub()
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
const generateEpub = await esmock('./index.js', {
|
|
388
|
-
'#helpers/os-utils.js': { dynamicImport: mockDynamicImport },
|
|
389
|
-
'#lib/project/index.js': mockPaths,
|
|
390
|
-
'fs-extra': mockFs,
|
|
391
|
-
'#lib/reporter/index.js': { default: mockReporter }
|
|
392
|
-
})
|
|
393
|
-
|
|
394
|
-
const output = await generateEpub.default({ lib: 'epubjs', output: 'my-book' })
|
|
395
|
-
|
|
396
|
-
t.is(output, path.join(testPath('project'), 'my-book.epub'))
|
|
397
|
-
})
|
|
398
|
-
|
|
399
|
-
test('generateEpub creates output directory if missing', async (t) => {
|
|
400
|
-
const { sandbox } = t.context
|
|
401
|
-
|
|
402
|
-
const mockEpubLib = sandbox.stub().resolves()
|
|
403
|
-
const mockDynamicImport = sandbox.stub().resolves({ default: mockEpubLib })
|
|
404
|
-
|
|
405
|
-
const mockPaths = {
|
|
406
|
-
getProjectRoot: () => testPath('project'),
|
|
407
|
-
getEpubDir: () => '_epub'
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
const mockFs = {
|
|
411
|
-
existsSync: sandbox.stub().returns(false),
|
|
412
|
-
mkdirSync: sandbox.stub()
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
const mockReporter = {
|
|
416
|
-
start: sandbox.stub(),
|
|
417
|
-
detail: sandbox.stub(),
|
|
418
|
-
succeed: sandbox.stub(),
|
|
419
|
-
fail: sandbox.stub()
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
const generateEpub = await esmock('./index.js', {
|
|
423
|
-
'#helpers/os-utils.js': { dynamicImport: mockDynamicImport },
|
|
424
|
-
'#lib/project/index.js': mockPaths,
|
|
425
|
-
'fs-extra': mockFs,
|
|
426
|
-
'#lib/reporter/index.js': { default: mockReporter }
|
|
427
|
-
})
|
|
428
|
-
|
|
429
|
-
await generateEpub.default({ lib: 'epubjs', output: '_downloads/book.epub' })
|
|
430
|
-
|
|
431
|
-
t.true(mockFs.mkdirSync.calledOnce)
|
|
432
|
-
t.is(mockFs.mkdirSync.firstCall.args[0], path.join(testPath('project'), '_downloads'))
|
|
433
|
-
t.deepEqual(mockFs.mkdirSync.firstCall.args[1], { recursive: true })
|
|
434
|
-
})
|
|
435
|
-
|
|
436
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
437
|
-
// EPUB library invocation tests
|
|
438
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
439
|
-
|
|
440
|
-
test('generateEpub passes correct arguments to EPUB library', async (t) => {
|
|
441
|
-
const { sandbox } = t.context
|
|
442
|
-
|
|
443
|
-
const mockEpubLib = sandbox.stub().resolves()
|
|
444
|
-
const mockDynamicImport = sandbox.stub().resolves({ default: mockEpubLib })
|
|
445
|
-
|
|
446
|
-
const mockPaths = {
|
|
447
|
-
getProjectRoot: () => testPath('project'),
|
|
448
|
-
getEpubDir: () => '_epub'
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
const mockFs = {
|
|
452
|
-
existsSync: sandbox.stub().returns(true),
|
|
453
|
-
mkdirSync: sandbox.stub()
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
const mockReporter = {
|
|
457
|
-
start: sandbox.stub(),
|
|
458
|
-
detail: sandbox.stub(),
|
|
459
|
-
succeed: sandbox.stub(),
|
|
460
|
-
fail: sandbox.stub()
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
const generateEpub = await esmock('./index.js', {
|
|
464
|
-
'#helpers/os-utils.js': { dynamicImport: mockDynamicImport },
|
|
465
|
-
'#lib/project/index.js': mockPaths,
|
|
466
|
-
'fs-extra': mockFs,
|
|
467
|
-
'#lib/reporter/index.js': { default: mockReporter }
|
|
468
|
-
})
|
|
469
|
-
|
|
470
|
-
await generateEpub.default({ lib: 'epubjs', debug: true })
|
|
471
|
-
|
|
472
|
-
t.true(mockEpubLib.calledOnce)
|
|
473
|
-
const [input, output, options] = mockEpubLib.firstCall.args
|
|
474
|
-
t.is(input, path.join(testPath('project'), '_epub'))
|
|
475
|
-
t.is(output, path.join(testPath('project'), 'epubjs.epub'))
|
|
476
|
-
t.true(options.debug)
|
|
477
|
-
})
|
|
478
|
-
|
|
479
|
-
test('generateEpub passes options through to EPUB library', async (t) => {
|
|
480
|
-
const { sandbox } = t.context
|
|
481
|
-
|
|
482
|
-
const mockEpubLib = sandbox.stub().resolves()
|
|
483
|
-
const mockDynamicImport = sandbox.stub().resolves({ default: mockEpubLib })
|
|
484
|
-
|
|
485
|
-
const mockPaths = {
|
|
486
|
-
getProjectRoot: () => testPath('project'),
|
|
487
|
-
getEpubDir: () => '_epub'
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
const mockFs = {
|
|
491
|
-
existsSync: sandbox.stub().returns(true),
|
|
492
|
-
mkdirSync: sandbox.stub()
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
const mockReporter = {
|
|
496
|
-
start: sandbox.stub(),
|
|
497
|
-
detail: sandbox.stub(),
|
|
498
|
-
succeed: sandbox.stub(),
|
|
499
|
-
fail: sandbox.stub()
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
const generateEpub = await esmock('./index.js', {
|
|
503
|
-
'#helpers/os-utils.js': { dynamicImport: mockDynamicImport },
|
|
504
|
-
'#lib/project/index.js': mockPaths,
|
|
505
|
-
'fs-extra': mockFs,
|
|
506
|
-
'#lib/reporter/index.js': { default: mockReporter }
|
|
507
|
-
})
|
|
508
|
-
|
|
509
|
-
await generateEpub.default({
|
|
510
|
-
lib: 'epubjs',
|
|
511
|
-
debug: true,
|
|
512
|
-
customOption: 'value'
|
|
513
|
-
})
|
|
514
|
-
|
|
515
|
-
const [, , options] = mockEpubLib.firstCall.args
|
|
516
|
-
t.true(options.debug)
|
|
517
|
-
t.is(options.customOption, 'value')
|
|
518
|
-
})
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import esmock from 'esmock'
|
|
2
|
-
import path from 'node:path'
|
|
3
|
-
import sinon from 'sinon'
|
|
4
|
-
import test from 'ava'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Pandoc EPUB Engine Integration Tests
|
|
8
|
-
*
|
|
9
|
-
* Tests error handling and logging paths that are difficult to trigger in E2E tests.
|
|
10
|
-
* The happy path is covered by E2E tests with real Pandoc installation.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Create a cross-platform absolute path for testing
|
|
15
|
-
* @param {...string} segments - Path segments to join
|
|
16
|
-
* @returns {string} Platform-appropriate absolute path
|
|
17
|
-
*/
|
|
18
|
-
function testPath(...segments) {
|
|
19
|
-
const root = process.platform === 'win32' ? 'C:\\' : '/'
|
|
20
|
-
return path.join(root, ...segments)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
test.beforeEach((t) => {
|
|
24
|
-
t.context.sandbox = sinon.createSandbox()
|
|
25
|
-
|
|
26
|
-
// Mock fs-extra
|
|
27
|
-
t.context.mockFs = {
|
|
28
|
-
readdirSync: t.context.sandbox.stub().returns(['chapter1.xhtml', 'chapter2.xhtml']),
|
|
29
|
-
lstatSync: t.context.sandbox.stub().returns({ isFile: () => true })
|
|
30
|
-
}
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
test.afterEach.always((t) => {
|
|
34
|
-
t.context.sandbox.restore()
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
test('pandoc logs stderr via debug when present', async (t) => {
|
|
38
|
-
const { sandbox, mockFs } = t.context
|
|
39
|
-
|
|
40
|
-
const mockExeca = sandbox.stub().resolves({ stderr: 'warning: deprecated option used' })
|
|
41
|
-
const mockDebug = sandbox.stub()
|
|
42
|
-
const mockCreateDebug = sandbox.stub().returns(mockDebug)
|
|
43
|
-
|
|
44
|
-
const pandoc = await esmock('./pandoc.js', {
|
|
45
|
-
execa: { execa: mockExeca },
|
|
46
|
-
'fs-extra': mockFs,
|
|
47
|
-
'#debug': { default: mockCreateDebug }
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
await pandoc.default(testPath('input'), testPath('output.epub'), {})
|
|
51
|
-
|
|
52
|
-
t.true(mockDebug.calledWith('pandoc stderr: %s', 'warning: deprecated option used'))
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
test('pandoc does not log stderr when empty', async (t) => {
|
|
56
|
-
const { sandbox, mockFs } = t.context
|
|
57
|
-
|
|
58
|
-
const mockExeca = sandbox.stub().resolves({ stderr: '' })
|
|
59
|
-
const mockDebug = sandbox.stub()
|
|
60
|
-
const mockCreateDebug = sandbox.stub().returns(mockDebug)
|
|
61
|
-
|
|
62
|
-
const pandoc = await esmock('./pandoc.js', {
|
|
63
|
-
execa: { execa: mockExeca },
|
|
64
|
-
'fs-extra': mockFs,
|
|
65
|
-
'#debug': { default: mockCreateDebug }
|
|
66
|
-
})
|
|
67
|
-
|
|
68
|
-
await pandoc.default(testPath('input'), testPath('output.epub'), {})
|
|
69
|
-
|
|
70
|
-
t.false(mockDebug.calledWith(sinon.match('pandoc stderr')))
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
test('pandoc throws EpubGenerationError when execa fails', async (t) => {
|
|
74
|
-
const { sandbox, mockFs } = t.context
|
|
75
|
-
|
|
76
|
-
const execaError = new Error('Pandoc failed')
|
|
77
|
-
execaError.stderr = 'error: unknown input format'
|
|
78
|
-
|
|
79
|
-
const mockExeca = sandbox.stub().rejects(execaError)
|
|
80
|
-
|
|
81
|
-
const pandoc = await esmock('./pandoc.js', {
|
|
82
|
-
execa: { execa: mockExeca },
|
|
83
|
-
'fs-extra': mockFs
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
const error = await t.throwsAsync(() =>
|
|
87
|
-
pandoc.default(testPath('input'), testPath('output.epub'), {})
|
|
88
|
-
)
|
|
89
|
-
|
|
90
|
-
t.is(error.code, 'EPUB_FAILED')
|
|
91
|
-
// EpubGenerationError formats message as: "EPUB generation failed: <details>"
|
|
92
|
-
// where <details> includes tool name, operation, and stderr/message
|
|
93
|
-
t.true(error.message.includes('EPUB generation failed'))
|
|
94
|
-
t.true(error.message.includes('Pandoc'))
|
|
95
|
-
t.true(error.message.includes('unknown input format'))
|
|
96
|
-
})
|
|
97
|
-
|
|
98
|
-
test('pandoc filters only XHTML files from input directory', async (t) => {
|
|
99
|
-
const { sandbox } = t.context
|
|
100
|
-
|
|
101
|
-
const mockExeca = sandbox.stub().resolves({ stderr: '' })
|
|
102
|
-
|
|
103
|
-
// Mock readdirSync to return mixed files
|
|
104
|
-
const mockFs = {
|
|
105
|
-
readdirSync: sandbox.stub().returns(['chapter1.xhtml', 'image.png', 'chapter2.xhtml', 'style.css']),
|
|
106
|
-
lstatSync: sandbox.stub().returns({ isFile: () => true })
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
const pandoc = await esmock('./pandoc.js', {
|
|
110
|
-
execa: { execa: mockExeca },
|
|
111
|
-
'fs-extra': mockFs
|
|
112
|
-
})
|
|
113
|
-
|
|
114
|
-
await pandoc.default(testPath('input'), testPath('output.epub'), {})
|
|
115
|
-
|
|
116
|
-
// Verify only XHTML files were passed to pandoc
|
|
117
|
-
const [, args] = mockExeca.firstCall.args
|
|
118
|
-
const inputFiles = args.filter(arg => arg.endsWith('.xhtml'))
|
|
119
|
-
t.is(inputFiles.length, 2)
|
|
120
|
-
t.true(inputFiles[0].endsWith('chapter1.xhtml'))
|
|
121
|
-
t.true(inputFiles[1].endsWith('chapter2.xhtml'))
|
|
122
|
-
})
|
package/src/lib/epub/schema.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* EPUB engine schema definition
|
|
3
|
-
*
|
|
4
|
-
* This module has NO imports to avoid circular dependencies.
|
|
5
|
-
* It serves as the single source of truth for EPUB engine options.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Supported EPUB engines
|
|
10
|
-
* @type {string[]}
|
|
11
|
-
*/
|
|
12
|
-
export const ENGINES = ['epubjs', 'pandoc']
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Schema definition for epubEngine config property
|
|
16
|
-
*/
|
|
17
|
-
export const schema = {
|
|
18
|
-
type: 'string',
|
|
19
|
-
enum: ENGINES,
|
|
20
|
-
description: 'Default EPUB engine to use (epubjs, pandoc)'
|
|
21
|
-
}
|