@thegetty/quire-cli 1.0.0-rc.9 → 1.0.0
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 +174 -7
- package/README.md +15 -0
- package/bin/cli.js +13 -7
- package/package.json +19 -14
- package/patches/README.md +19 -0
- package/patches/install-npm-version+1.0.9.patch +12119 -0
- package/src/Command.js +14 -0
- package/src/commands/conf.js +43 -0
- package/src/commands/create.js +13 -9
- package/src/commands/epub.js +1 -2
- package/src/commands/info.js +15 -10
- package/src/commands/pdf.js +60 -10
- package/src/commands/validate.js +64 -0
- package/src/errors/validation/validation-error.js +13 -0
- package/src/errors/validation/yaml-duplicate-error.js +11 -0
- package/src/errors/validation/yaml-parse-error.js +11 -0
- package/src/errors/validation/yaml-validation-error.js +11 -0
- package/src/helpers/clean.js +5 -0
- package/src/helpers/is-empty.js +4 -0
- package/src/helpers/is-quire.js +4 -0
- package/src/helpers/os-utils.js +4 -0
- package/src/helpers/test-cwd.js +4 -0
- package/src/helpers/which.js +4 -0
- package/src/lib/11ty/api.js +1 -0
- package/src/lib/11ty/cli.js +29 -6
- package/src/lib/conf/README.md +104 -0
- package/src/lib/conf/config.js +35 -0
- package/src/lib/conf/defaults.js +37 -0
- package/src/lib/conf/migrations.js +11 -0
- package/src/lib/conf/schema.js +30 -0
- package/src/lib/pdf/README.md +11 -4
- package/src/lib/pdf/index.js +4 -4
- package/src/lib/pdf/paged.js +88 -9
- package/src/lib/pdf/pagedPlugin.js +49 -0
- package/src/lib/pdf/prince.js +79 -4
- package/src/lib/pdf/princePlugin.js +35 -0
- package/src/lib/pdf/split.js +61 -0
- package/src/lib/quire/index.js +67 -144
- package/src/main.js +21 -6
- package/src/packageConfig.js +15 -0
- package/src/validators/utils.js +98 -0
- package/src/validators/validate-yaml.js +38 -0
- package/src/lib/config/README.md +0 -3
- package/src/lib/config/index.js +0 -1
package/src/Command.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import config from '#src/lib/conf/config.js'
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Command
|
|
3
5
|
* @abstract
|
|
@@ -12,6 +14,7 @@ export default class Command {
|
|
|
12
14
|
/**
|
|
13
15
|
* @typedef CommandDefinition
|
|
14
16
|
* @property {String} name
|
|
17
|
+
* @property {String} alias
|
|
15
18
|
* @property {Array<String>} aliases
|
|
16
19
|
* @property {String} descriptions
|
|
17
20
|
* @property {Array<CommandArgument>} args
|
|
@@ -24,6 +27,8 @@ export default class Command {
|
|
|
24
27
|
/**
|
|
25
28
|
* Constructs a new instance
|
|
26
29
|
*
|
|
30
|
+
* Nota bene: Only the first command alias is displayed in the help.
|
|
31
|
+
*
|
|
27
32
|
* @param {CommandDefinition} definition The definition
|
|
28
33
|
*/
|
|
29
34
|
constructor(definition) {
|
|
@@ -31,6 +36,15 @@ export default class Command {
|
|
|
31
36
|
throw new Error('Command is an *abstract* class')
|
|
32
37
|
}
|
|
33
38
|
|
|
39
|
+
this.config = config // quire-cli configuration
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Merge and deduplicate command definition alias and aliases
|
|
43
|
+
* Nota bene: Only the first command alias is displayed in the help.
|
|
44
|
+
*/
|
|
45
|
+
// let aliases = Array.isArray(definition.aliases) ? definition.aliases || []
|
|
46
|
+
// aliases = new Set([ definition.alias, ...aliases ])
|
|
47
|
+
|
|
34
48
|
this.name = definition.name
|
|
35
49
|
this.aliases = definition.aliases
|
|
36
50
|
this.description = definition.description
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import Command from '#src/Command.js'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Quire CLI `conf` Command
|
|
5
|
+
*
|
|
6
|
+
* @class ConfCommand
|
|
7
|
+
* @extends {Command}
|
|
8
|
+
*/
|
|
9
|
+
export default class ConfCommand extends Command {
|
|
10
|
+
static definition = {
|
|
11
|
+
name: 'conf',
|
|
12
|
+
aliases: ['config', 'configure'],
|
|
13
|
+
description: 'Manage the Quire CLI configuration.',
|
|
14
|
+
summary: 'read/write quire-cli configuration options',
|
|
15
|
+
version: '1.0.0',
|
|
16
|
+
options: [
|
|
17
|
+
[ '--debug', 'run command in debug mode' ],
|
|
18
|
+
],
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
constructor() {
|
|
22
|
+
super(ConfCommand.definition)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @param {Object} options
|
|
27
|
+
* @return {Promise}
|
|
28
|
+
*/
|
|
29
|
+
async action(key, value, options = {}) {
|
|
30
|
+
if (options.debug) {
|
|
31
|
+
console.info('Command \'%s\' called with options %o', this.name(), options)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// this.outputHelp()
|
|
35
|
+
|
|
36
|
+
console.info('quire-cli configuration %s', this.config.path)
|
|
37
|
+
|
|
38
|
+
for (const [ key, value ] of Object.entries(this.config.store)) {
|
|
39
|
+
if (key.startsWith('__internal__') && !options.debug) continue
|
|
40
|
+
console.info('%s: %O', key, value)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
package/src/commands/create.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import Command from '#src/Command.js'
|
|
2
|
+
import fs from 'fs-extra'
|
|
2
3
|
import { quire } from '#src/lib/quire/index.js'
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -23,7 +24,7 @@ export default class CreateCommand extends Command {
|
|
|
23
24
|
],
|
|
24
25
|
options: [
|
|
25
26
|
[ '--quire-path <path>', 'local path to quire-11ty package' ],
|
|
26
|
-
[ '--quire-version <version>', 'quire-11ty version to install'
|
|
27
|
+
[ '--quire-version <version>', 'quire-11ty version to install' ],
|
|
27
28
|
// [ '--eject', 'install quire-11ty into the project directory', true ],
|
|
28
29
|
[ '--debug', 'debug the `quire new` command', false ],
|
|
29
30
|
],
|
|
@@ -44,6 +45,8 @@ export default class CreateCommand extends Command {
|
|
|
44
45
|
console.info('Command \'%s\' called with options %o', CreateCommand.name, options)
|
|
45
46
|
}
|
|
46
47
|
|
|
48
|
+
starter = starter || this.config.get('projectTemplate')
|
|
49
|
+
|
|
47
50
|
if (!projectPath && !starter) {
|
|
48
51
|
// @TODO implement this case of interactively selecting starter templates
|
|
49
52
|
// from available subtrees in `lib/quire` module
|
|
@@ -60,15 +63,16 @@ export default class CreateCommand extends Command {
|
|
|
60
63
|
* - interactive mode prompt to continue
|
|
61
64
|
* - non-interactive mode throw an error and exit the process
|
|
62
65
|
*/
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
await quire.install(options)
|
|
66
|
+
let quireVersion
|
|
67
|
+
try {
|
|
68
|
+
quireVersion = await quire.initStarter(starter, projectPath, options)
|
|
69
|
+
} catch (error) {
|
|
70
|
+
console.error(error.message)
|
|
71
|
+
fs.removeSync(projectPath)
|
|
72
|
+
return
|
|
71
73
|
}
|
|
74
|
+
|
|
75
|
+
await quire.installInProject(projectPath, quireVersion, options)
|
|
72
76
|
}
|
|
73
77
|
}
|
|
74
78
|
}
|
package/src/commands/epub.js
CHANGED
|
@@ -55,8 +55,7 @@ export default class EpubCommand extends Command {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
|
-
* test if build site has already be run and output can be reused
|
|
59
|
-
* @todo
|
|
58
|
+
* @todo test if build site has already be run and output can be reused
|
|
60
59
|
*/
|
|
61
60
|
preAction(command) {
|
|
62
61
|
const options = command.opts()
|
package/src/commands/info.js
CHANGED
|
@@ -2,11 +2,9 @@ import Command from '#src/Command.js'
|
|
|
2
2
|
import { execaCommand } from 'execa'
|
|
3
3
|
import fs from 'node:fs'
|
|
4
4
|
import os from 'node:os'
|
|
5
|
-
import path from 'path'
|
|
5
|
+
import path from 'node:path'
|
|
6
6
|
import testcwd from '#helpers/test-cwd.js'
|
|
7
7
|
|
|
8
|
-
const VERSION_FILE = '.quire'
|
|
9
|
-
|
|
10
8
|
/**
|
|
11
9
|
* Quire CLI `info` Command
|
|
12
10
|
*
|
|
@@ -22,7 +20,9 @@ export default class InfoCommand extends Command {
|
|
|
22
20
|
summary: 'list info',
|
|
23
21
|
version: '1.0.0',
|
|
24
22
|
args: [],
|
|
25
|
-
options: [
|
|
23
|
+
options: [
|
|
24
|
+
['--debug', 'include os versions in output']
|
|
25
|
+
],
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
constructor() {
|
|
@@ -40,15 +40,20 @@ export default class InfoCommand extends Command {
|
|
|
40
40
|
console.debug('[CLI] Command \'%s\' called', this.name())
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
// Load filename from config with a default constraint if it doesn't exist
|
|
44
|
+
const versionFileName = this.config.get('versionFile')
|
|
45
|
+
let versionInfo = { cli: '<=1.0.0.rc-7' }
|
|
46
|
+
|
|
44
47
|
try {
|
|
45
|
-
|
|
48
|
+
const versionFileData = fs.readFileSync(versionFileName, { encoding: 'utf8' })
|
|
49
|
+
|
|
50
|
+
versionInfo = JSON.parse(versionFileData)
|
|
46
51
|
} catch (error) {
|
|
47
52
|
console.warn(
|
|
48
53
|
`This project was generated with the quire-cli prior to version 1.0.0.rc-8. Updating the version file to the new format, though this project's version file will not contain specific starter version information.`
|
|
49
54
|
)
|
|
50
|
-
|
|
51
|
-
fs.writeFileSync(
|
|
55
|
+
|
|
56
|
+
fs.writeFileSync(versionFileName, JSON.stringify(versionInfo))
|
|
52
57
|
}
|
|
53
58
|
|
|
54
59
|
const { name: projectDirectory } = path.parse(process.cwd())
|
|
@@ -59,7 +64,7 @@ export default class InfoCommand extends Command {
|
|
|
59
64
|
items: [
|
|
60
65
|
{
|
|
61
66
|
name: 'quire-cli',
|
|
62
|
-
get: () =>
|
|
67
|
+
get: () => versionInfo.cli,
|
|
63
68
|
},
|
|
64
69
|
{
|
|
65
70
|
name: 'quire-11ty',
|
|
@@ -70,7 +75,7 @@ export default class InfoCommand extends Command {
|
|
|
70
75
|
},
|
|
71
76
|
{
|
|
72
77
|
name: 'starter',
|
|
73
|
-
get: () =>
|
|
78
|
+
get: () => versionInfo.starter,
|
|
74
79
|
},
|
|
75
80
|
],
|
|
76
81
|
},
|
package/src/commands/pdf.js
CHANGED
|
@@ -1,10 +1,50 @@
|
|
|
1
|
-
import Command from '#src/Command.js'
|
|
2
1
|
import { paths, projectRoot } from '#lib/11ty/index.js'
|
|
2
|
+
import Command from '#src/Command.js'
|
|
3
3
|
import fs from 'fs-extra'
|
|
4
4
|
import libPdf from '#lib/pdf/index.js'
|
|
5
5
|
import open from 'open'
|
|
6
6
|
import path from 'node:path'
|
|
7
|
-
|
|
7
|
+
import { pathToFileURL } from 'node:url'
|
|
8
|
+
import yaml from 'js-yaml'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @function loadConfig(path) - loads and validates quire config, returns an empty object if not found
|
|
12
|
+
*
|
|
13
|
+
* @param {path} string - file path to config file
|
|
14
|
+
*
|
|
15
|
+
* @return {Object|undefined} User configuration object or undefined
|
|
16
|
+
*
|
|
17
|
+
* @todo consider hardcoding a version check against .quire / project's package.json ver
|
|
18
|
+
*/
|
|
19
|
+
async function loadConfig(configPath) {
|
|
20
|
+
if (!fs.existsSync(configPath)) {
|
|
21
|
+
return undefined
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const data = fs.readFileSync(configPath)
|
|
25
|
+
let config = yaml.load(data)
|
|
26
|
+
|
|
27
|
+
// NB: Schemas and validators are specific to the 11ty version of the project being built
|
|
28
|
+
const schemaPath = path.join(projectRoot,'_plugins','schemas','config.json')
|
|
29
|
+
const validatorPath = path.join(projectRoot, '_plugins', 'globalData', 'validator.js')
|
|
30
|
+
|
|
31
|
+
if (fs.existsSync(schemaPath) && fs.existsSync(validatorPath)) {
|
|
32
|
+
|
|
33
|
+
const { validateUserConfig } = await import(pathToFileURL(validatorPath))
|
|
34
|
+
|
|
35
|
+
const schemaJSON = fs.readFileSync(schemaPath)
|
|
36
|
+
const schema = JSON.parse(schemaJSON)
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
config = validateUserConfig('config', config, { config: schema })
|
|
40
|
+
} catch (error) {
|
|
41
|
+
console.error(error)
|
|
42
|
+
process.exit(1)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return config
|
|
47
|
+
}
|
|
8
48
|
|
|
9
49
|
/**
|
|
10
50
|
* Quire CLI `pdf` Command
|
|
@@ -41,22 +81,32 @@ export default class PDFCommand extends Command {
|
|
|
41
81
|
console.debug('[CLI] Command \'%s\' called with options %o', this.name(), options)
|
|
42
82
|
}
|
|
43
83
|
|
|
44
|
-
const
|
|
84
|
+
const publicationInput = path.join(projectRoot, paths.output, 'pdf.html')
|
|
85
|
+
const coversInput = path.join(projectRoot, paths.output, 'pdf-covers.html')
|
|
45
86
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
87
|
+
const quireConfig = await loadConfig(path.join(projectRoot,'content','_data','config.yaml'))
|
|
88
|
+
|
|
89
|
+
if (quireConfig === undefined) {
|
|
90
|
+
console.error(`[quire pdf]: ERROR Unable to find a configuration file at ${path.join(projectRoot,'content','_data','config.yaml')}\nIs the command being run in a quire project?`)
|
|
91
|
+
process.exit(1)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (!fs.existsSync(publicationInput)) {
|
|
95
|
+
console.error(`[quire pdf]: ERROR Unable to find PDF input at ${publicationInput}\nPlease first run the 'quire build' command.`)
|
|
96
|
+
process.exit(1)
|
|
49
97
|
}
|
|
50
98
|
|
|
51
|
-
const output =
|
|
99
|
+
const output = quireConfig.pdf !== undefined
|
|
100
|
+
? path.join(paths.output, quireConfig.pdf.outputDir, `${quireConfig.pdf.filename}.pdf`)
|
|
101
|
+
: path.join(projectRoot, `${options.lib}.pdf`)
|
|
52
102
|
|
|
53
|
-
const pdfLib = await libPdf(options.lib, {
|
|
54
|
-
await pdfLib(
|
|
103
|
+
const pdfLib = await libPdf(options.lib, { ...options, pdfConfig: quireConfig.pdf })
|
|
104
|
+
await pdfLib(publicationInput, coversInput, output)
|
|
55
105
|
|
|
56
106
|
try {
|
|
57
107
|
if (fs.existsSync(output) && options.open) open(output)
|
|
58
108
|
} catch (error) {
|
|
59
|
-
console.error(error)
|
|
109
|
+
console.error(`[quire pdf]: ERROR`,error)
|
|
60
110
|
process.exit(1)
|
|
61
111
|
}
|
|
62
112
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import Command from '#src/Command.js'
|
|
2
|
+
import { YAMLException } from 'js-yaml'
|
|
3
|
+
import YamlValidationError from '../errors/validation/yaml-validation-error.js'
|
|
4
|
+
import fs from 'fs-extra'
|
|
5
|
+
import path from 'node:path'
|
|
6
|
+
import { projectRoot } from '#lib/11ty/index.js'
|
|
7
|
+
import testcwd from '../helpers/test-cwd.js'
|
|
8
|
+
import yamlValidation from '../validators/validate-yaml.js'
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Quire CLI `validate` Command
|
|
13
|
+
*
|
|
14
|
+
* @class ValidateCommand
|
|
15
|
+
* @extends {Command}
|
|
16
|
+
*/
|
|
17
|
+
export default class ValidateCommand extends Command {
|
|
18
|
+
static definition = {
|
|
19
|
+
name: 'validate',
|
|
20
|
+
description: 'Validate configuration files',
|
|
21
|
+
summary: 'run validation',
|
|
22
|
+
version: '1.0.0',
|
|
23
|
+
options: [
|
|
24
|
+
[ '--debug', 'run validate with debug output to console' ],
|
|
25
|
+
],
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
constructor() {
|
|
29
|
+
super(ValidateCommand.definition)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
action(options, command){
|
|
33
|
+
if(options.debug) {
|
|
34
|
+
console.debug('[CLI] Command \'%s\' called with options %o', this.name(), options)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const dataPath = path.join(projectRoot, 'content', '_data')
|
|
38
|
+
const files = fs.readdirSync(dataPath)
|
|
39
|
+
.filter(file => file.endsWith('.yaml') || file.endsWith('.yml'))
|
|
40
|
+
.map(file => path.join(dataPath, file)
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
let errorList = []
|
|
44
|
+
console.log('Validating YAML files..')
|
|
45
|
+
|
|
46
|
+
for (const file of files) {
|
|
47
|
+
try {
|
|
48
|
+
yamlValidation(file)
|
|
49
|
+
} catch (error){
|
|
50
|
+
errorList.push(error)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if(errorList.length > 0) {
|
|
55
|
+
errorList.forEach(err => { console.error(`${err.reason}`) })
|
|
56
|
+
} else {
|
|
57
|
+
console.log('Validation complete.')
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
preAction(options, command) {
|
|
62
|
+
testcwd(command)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
|
8
|
+
|
|
9
|
+
if ('captureStackTrace' in Error) {
|
|
10
|
+
Error.captureStackTrace(this, this.constructor)
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import ValidationError from './validation-error.js'
|
|
2
|
+
|
|
3
|
+
export default class YamlDuplicateIdError extends ValidationError {
|
|
4
|
+
constructor(filePath, reason) {
|
|
5
|
+
super('Duplicate ID found in YAML file', {
|
|
6
|
+
filePath,
|
|
7
|
+
reason: reason,
|
|
8
|
+
code: 'YAML_DUPLICATE_ID_ERROR',
|
|
9
|
+
})
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import ValidationError from './validation-error.js'
|
|
2
|
+
|
|
3
|
+
export default class YamlParseError extends ValidationError {
|
|
4
|
+
constructor(filePath, reason) {
|
|
5
|
+
super('Error parsing YAML file', {
|
|
6
|
+
filePath,
|
|
7
|
+
reason: reason,
|
|
8
|
+
code: 'YAML_PARSE_ERROR',
|
|
9
|
+
})
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import ValidationError from './validation-error.js'
|
|
2
|
+
|
|
3
|
+
export default class YamlValidationError extends ValidationError {
|
|
4
|
+
constructor(filePath, reason) {
|
|
5
|
+
super('Error validating YAML file', {
|
|
6
|
+
filePath,
|
|
7
|
+
reason: reason,
|
|
8
|
+
code: 'YAML_VALIDATION_ERROR',
|
|
9
|
+
})
|
|
10
|
+
}
|
|
11
|
+
}
|
package/src/helpers/clean.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A helper module for cleaning quire outputs
|
|
3
|
+
* @module clean
|
|
4
|
+
*/
|
|
1
5
|
import { deleteAsync } from 'del'
|
|
2
6
|
import path from 'node:path'
|
|
3
7
|
|
|
@@ -9,6 +13,7 @@ import path from 'node:path'
|
|
|
9
13
|
*/
|
|
10
14
|
export async function clean (projectRoot, paths, options = {}) {
|
|
11
15
|
const pathsToClean = [
|
|
16
|
+
path.join(projectRoot, '.11ty-vite'),
|
|
12
17
|
path.join(projectRoot, paths.epub),
|
|
13
18
|
path.join(projectRoot, paths.output),
|
|
14
19
|
path.join(projectRoot, '*.epub'),
|
package/src/helpers/is-empty.js
CHANGED
package/src/helpers/is-quire.js
CHANGED
package/src/helpers/os-utils.js
CHANGED
package/src/helpers/test-cwd.js
CHANGED
package/src/helpers/which.js
CHANGED
package/src/lib/11ty/api.js
CHANGED
|
@@ -42,6 +42,7 @@ const factory = async (options = {}) => {
|
|
|
42
42
|
process.env.ELEVENTY_DATA = paths.data
|
|
43
43
|
process.env.ELEVENTY_INCLUDES = paths.includes
|
|
44
44
|
process.env.ELEVENTY_LAYOUTS = paths.layouts
|
|
45
|
+
process.env.QUIRE_DEBUG_LOG = options.debug
|
|
45
46
|
|
|
46
47
|
/**
|
|
47
48
|
* Get an instance of the runtime of eleventy.
|
package/src/lib/11ty/cli.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { execa } from 'execa'
|
|
2
|
+
import fs from 'node:fs'
|
|
2
3
|
import path from 'node:path'
|
|
3
4
|
import paths, { eleventyRoot, projectRoot } from './paths.js'
|
|
4
5
|
|
|
@@ -17,9 +18,24 @@ const factory = (options = {}) => {
|
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
* Use the version of Eleventy installed to `lib/quire/versions`
|
|
21
|
+
*
|
|
22
|
+
* NB: in eleventy v3 the CLI extension (".cjs") is load-bearing but v2 is simply ".js"
|
|
23
|
+
*
|
|
20
24
|
*/
|
|
21
|
-
const
|
|
22
|
-
|
|
25
|
+
const eleventyModuleDir = path.join(eleventyRoot, 'node_modules', '@11ty', 'eleventy')
|
|
26
|
+
const packagePath = path.join(eleventyModuleDir,'package.json')
|
|
27
|
+
|
|
28
|
+
const pack = JSON.parse(fs.readFileSync(packagePath))
|
|
29
|
+
|
|
30
|
+
const { version } = pack
|
|
31
|
+
|
|
32
|
+
const eleventyMajorVer = version.split('.').at(0)
|
|
33
|
+
|
|
34
|
+
let eleventy = path.join(eleventyModuleDir,'cmd.cjs')
|
|
35
|
+
|
|
36
|
+
if ( Number(eleventyMajorVer) < 3 ) {
|
|
37
|
+
eleventy = path.join(eleventyModuleDir,'cmd.js')
|
|
38
|
+
}
|
|
23
39
|
|
|
24
40
|
const command = [
|
|
25
41
|
eleventy,
|
|
@@ -46,6 +62,7 @@ const factory = (options = {}) => {
|
|
|
46
62
|
ELEVENTY_DATA: paths.data,
|
|
47
63
|
ELEVENTY_INCLUDES: paths.includes,
|
|
48
64
|
ELEVENTY_LAYOUTS: paths.layouts,
|
|
65
|
+
QUIRE_DEBUG_LOG: options.debug
|
|
49
66
|
}
|
|
50
67
|
|
|
51
68
|
if (options.debug) env.DEBUG = 'Eleventy*'
|
|
@@ -67,12 +84,18 @@ export default {
|
|
|
67
84
|
|
|
68
85
|
env.ELEVENTY_ENV = 'production'
|
|
69
86
|
|
|
70
|
-
|
|
87
|
+
const build = execa('node', command, {
|
|
71
88
|
all: true,
|
|
72
89
|
cwd: projectRoot,
|
|
73
90
|
env,
|
|
74
|
-
|
|
75
|
-
})
|
|
91
|
+
nodePath: process.execPath
|
|
92
|
+
})
|
|
93
|
+
build.all.pipe(process.stdout)
|
|
94
|
+
await build
|
|
95
|
+
|
|
96
|
+
if (build.exitCode !== 0) {
|
|
97
|
+
process.exit(build.exitCode)
|
|
98
|
+
}
|
|
76
99
|
},
|
|
77
100
|
|
|
78
101
|
serve: async (options = {}) => {
|
|
@@ -90,7 +113,7 @@ export default {
|
|
|
90
113
|
all: true,
|
|
91
114
|
cwd: projectRoot,
|
|
92
115
|
env,
|
|
93
|
-
|
|
116
|
+
nodePath: process.execPath
|
|
94
117
|
}).all.pipe(process.stdout)
|
|
95
118
|
}
|
|
96
119
|
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
## CLI Configuration Manager
|
|
2
|
+
|
|
3
|
+
This `quire-cli/lib/config` module manages reading and writing (persisting) options for the Quire CLI using the [`conf`](https://github.com/sindresorhus/conf) package.
|
|
4
|
+
|
|
5
|
+
`conf` stores the config in the system default [user config directory](https://github.com/sindresorhus/env-paths#pathsconfig). For example, on macOS, the config file will be stored in the `~/Library/Preferences/@thegetty/quire-cli` directory.
|
|
6
|
+
|
|
7
|
+
> Changes are written to disk atomically, so if the process crashes during a write, it will not corrupt the existing config.
|
|
8
|
+
|
|
9
|
+
### Configuration
|
|
10
|
+
|
|
11
|
+
`logLevel` The default logging level for the Quire CLI output; default `'info'`.
|
|
12
|
+
|
|
13
|
+
`projectTemplate` A default project starter template to use when creating new projects; default `'quire-starter-default'`.
|
|
14
|
+
|
|
15
|
+
`quirePath` The relative path to `quire-11ty` installed in the project directory; default `./11ty`. When set to `null`, `quire-11ty` is installed to the CLI `lib/quire/versions/<version>/` directory.
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
❯ quire config quire-path '.'
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
`quireVersion` The default version of `quire-11ty` to install when creating new Quire projects; default `'latest'`.
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
❯ quire config quire-version '1.0.0'
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
`telemetry` Send anonymous data about Quire usage; default `false`.
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
❯ quire config telemetry --enabled
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
❯ quire config telemetry --disabled
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
`updateChannels` A list of distribution tags to use when checking for version updates; default `['latest']`. To show notifications for pre-releases version updates include `'pre-release'` in the array of channels. This can be set using the configuration `--pre-release` command flag.
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
❯ quire config update-channels
|
|
41
|
+
Quire configured to check for updates tagged 'latest'
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
❯ quire config update-channels --add 'pre-release'
|
|
46
|
+
Quire configured to check for updates tagged 'latest', 'pre-release'
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
```sh
|
|
50
|
+
❯ quire config update-channels --rm 'pre-release'
|
|
51
|
+
Quire configured to check for updates tagged 'latest'
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
`updateInterval` Interval at which to check for updates to the Quire CLI and project's `quire-11ty` version; default `'DAILY'`.
|
|
55
|
+
|
|
56
|
+
```sh
|
|
57
|
+
❯ quire config update-interval
|
|
58
|
+
Quire configured to check for updates DAILY
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
```sh
|
|
62
|
+
❯ quire config update-interval WEEKLY
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
`versionFile ['.quire-version']` The default file name for the `quire-11ty` version file.
|
|
66
|
+
|
|
67
|
+
```sh
|
|
68
|
+
❯ quire config version-file '.blargh'
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Quire CLI `config` Command
|
|
72
|
+
|
|
73
|
+
Running the `config` command without any arguments will start an interactive prompt to configure Quire.
|
|
74
|
+
|
|
75
|
+
To view an individual configuration value and its default value use:
|
|
76
|
+
|
|
77
|
+
```sh
|
|
78
|
+
❯ quire config [key]
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
To view the current `logLevel` setting for example:
|
|
82
|
+
|
|
83
|
+
```sh
|
|
84
|
+
❯ quire config logLevel
|
|
85
|
+
loglevel: 'debug' (default 'info')
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
To set an individual configuration value, use the `set` argument:
|
|
89
|
+
|
|
90
|
+
```sh
|
|
91
|
+
❯ quire config set <key> <value>
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
To reset *all* keys to their default values, use the `reset` argument:
|
|
95
|
+
|
|
96
|
+
```sh
|
|
97
|
+
❯ quire config reset
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
To reset an individual key to its default value:
|
|
101
|
+
|
|
102
|
+
```sh
|
|
103
|
+
❯ quire config reset [key]
|
|
104
|
+
```
|