@thegetty/quire-cli 1.0.0-pre-release.12 → 1.0.0-pre-release.14
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/package.json +2 -2
- package/src/commands/build.js +3 -0
- package/src/commands/clean.js +5 -0
- package/src/commands/preview.js +5 -0
- package/src/commands/version.js +8 -2
- package/src/helpers/is-quire.js +2 -2
- package/src/helpers/test-cwd.js +5 -9
- package/src/lib/11ty/paths.js +42 -12
- package/src/lib/quire/index.js +9 -5
- package/LICENSE +0 -1
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thegetty/quire-cli",
|
|
3
3
|
"description": "Quire command-line interface",
|
|
4
|
-
"version": "1.0.0-pre-release.
|
|
4
|
+
"version": "1.0.0-pre-release.14",
|
|
5
5
|
"author": "Getty Digital",
|
|
6
|
-
"license": "
|
|
6
|
+
"license": "SEE LICENSE IN https://github.com/thegetty/quire/blob/main/LICENSE",
|
|
7
7
|
"bugs": {
|
|
8
8
|
"url": "https://github.com/thegetty/quire/issues"
|
|
9
9
|
},
|
package/src/commands/build.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import Command from '#src/Command.js'
|
|
2
2
|
import { api, cli, paths, projectRoot } from '#lib/11ty/index.js'
|
|
3
3
|
import { clean } from '#helpers/clean.js'
|
|
4
|
+
import testcwd from '#helpers/test-cwd.js'
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Quire CLI `build` Command
|
|
@@ -56,6 +57,8 @@ export default class BuildCommand extends Command {
|
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
preAction(command) {
|
|
60
|
+
testcwd(command)
|
|
61
|
+
|
|
59
62
|
const options = command.opts()
|
|
60
63
|
if (options.debug) {
|
|
61
64
|
console.debug('[CLI] Calling \'build\' command pre-action with options', options)
|
package/src/commands/clean.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import Command from '#src/Command.js'
|
|
2
2
|
import { clean } from '#helpers/clean.js'
|
|
3
3
|
import { paths, projectRoot } from '#lib/11ty/index.js'
|
|
4
|
+
import testcwd from '#helpers/test-cwd.js'
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Quire CLI `clean` Command
|
|
@@ -53,4 +54,8 @@ export default class CleanCommand extends Command {
|
|
|
53
54
|
|
|
54
55
|
console.debug(`[CLI] ${message} ${deletedPaths}`)
|
|
55
56
|
}
|
|
57
|
+
|
|
58
|
+
preAction(command) {
|
|
59
|
+
testcwd(command)
|
|
60
|
+
}
|
|
56
61
|
}
|
package/src/commands/preview.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Command from '#src/Command.js'
|
|
2
2
|
import { api, cli, paths, projectRoot } from '#lib/11ty/index.js'
|
|
3
|
+
import testcwd from '#helpers/test-cwd.js'
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Quire CLI `preview` Command
|
|
@@ -53,4 +54,8 @@ export default class PreviewCommand extends Command {
|
|
|
53
54
|
api.serve(options)
|
|
54
55
|
}
|
|
55
56
|
}
|
|
57
|
+
|
|
58
|
+
preAction(command) {
|
|
59
|
+
testcwd(command)
|
|
60
|
+
}
|
|
56
61
|
}
|
package/src/commands/version.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import Command from '#src/Command.js'
|
|
2
|
+
import { paths, projectRoot } from '#lib/11ty/index.js'
|
|
2
3
|
import * as quire from '#lib/quire/index.js'
|
|
4
|
+
import testcwd from '#helpers/test-cwd.js'
|
|
3
5
|
|
|
4
6
|
/**
|
|
5
7
|
* Quire CLI `version` Command
|
|
@@ -21,7 +23,7 @@ export default class VersionCommand extends Command {
|
|
|
21
23
|
[ '<version>', 'the local quire version to use' ],
|
|
22
24
|
],
|
|
23
25
|
options: [
|
|
24
|
-
[ '-g', '--global', 'set the quire version globally' ],
|
|
26
|
+
// [ '-g', '--global', 'set the quire version globally' ],
|
|
25
27
|
],
|
|
26
28
|
}
|
|
27
29
|
|
|
@@ -29,9 +31,13 @@ export default class VersionCommand extends Command {
|
|
|
29
31
|
super(VersionCommand.definition)
|
|
30
32
|
}
|
|
31
33
|
|
|
32
|
-
|
|
34
|
+
action(args, options = {}) {
|
|
33
35
|
if (options.debug) {
|
|
34
36
|
console.info('Command \'%s\' called with options %o', this.name, options)
|
|
35
37
|
}
|
|
36
38
|
}
|
|
39
|
+
|
|
40
|
+
preAction(command) {
|
|
41
|
+
testcwd(command)
|
|
42
|
+
}
|
|
37
43
|
}
|
package/src/helpers/is-quire.js
CHANGED
|
@@ -20,8 +20,8 @@ const QUIRE_DOT_FILES = Object.freeze([
|
|
|
20
20
|
* @param {String} dirpath path to a local directory
|
|
21
21
|
* @return {Promise}
|
|
22
22
|
*/
|
|
23
|
-
export function
|
|
23
|
+
export default function (dirpath) {
|
|
24
24
|
return fs.readdirSync(dirpath)
|
|
25
|
-
.
|
|
25
|
+
.find((entry) => QUIRE_DOT_FILES.includes(entry))
|
|
26
26
|
}
|
|
27
27
|
|
package/src/helpers/test-cwd.js
CHANGED
|
@@ -3,17 +3,13 @@ import isQuire from '#helpers/is-quire.js'
|
|
|
3
3
|
/**
|
|
4
4
|
* Test current working directory is a Quire project directory
|
|
5
5
|
*
|
|
6
|
-
* @param {
|
|
7
|
-
* @return {Boolean}
|
|
6
|
+
* @param {Command} command the command from which testcwd was called
|
|
8
7
|
*/
|
|
9
8
|
export default (command) => {
|
|
10
|
-
const message = `[CLI]
|
|
9
|
+
const message = `[CLI] ${ command ? command.name() : '' } command must be run while in a Quire project directory. Use 'cd' to navigate to your project directory and re-run the 'quire ${ command ? command.name() : '' }' command.`
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return false
|
|
16
|
-
}
|
|
17
|
-
return true
|
|
11
|
+
if (!isQuire(process.cwd())) {
|
|
12
|
+
console.error(message)
|
|
13
|
+
process.exit(1)
|
|
18
14
|
}
|
|
19
15
|
}
|
package/src/lib/11ty/paths.js
CHANGED
|
@@ -23,15 +23,6 @@ const cliRoot = path.resolve(__dirname, path.join('..', '..'))
|
|
|
23
23
|
const eleventyConfig = '.eleventy.js'
|
|
24
24
|
const version = 'latest'
|
|
25
25
|
|
|
26
|
-
// Test project directory for an eleventy configuration file
|
|
27
|
-
const hasEleventyConfig = (dir) => {
|
|
28
|
-
try {
|
|
29
|
-
return fs.readdirSync(dir).includes(eleventyConfig)
|
|
30
|
-
} catch (error) {
|
|
31
|
-
throw new Error(`[CLI:11ty] Unable to read project directory for eleventy config ${error}`)
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
26
|
export const projectRoot = process.cwd()
|
|
36
27
|
|
|
37
28
|
const inputDir = path.join(projectRoot, 'content')
|
|
@@ -47,10 +38,49 @@ const libQuirePath = path.resolve(__dirname, path.join(cliRoot, 'lib', 'quire',
|
|
|
47
38
|
* Nota bene: to get a relative path to the `eleventyRoot`,
|
|
48
39
|
* for example when the version is specified is 'latest',
|
|
49
40
|
* it must be set to the real path to the symlink target.
|
|
41
|
+
*
|
|
42
|
+
* @todo refactor how and *when* the eleventyRoot is determined:
|
|
43
|
+
* - we only need eleventyRoot for cli commands that run 11ty
|
|
44
|
+
* - paths module is a concern of the `quire` module
|
|
45
|
+
* - global quire-cli installation
|
|
46
|
+
* - local quire-cli installation
|
|
47
|
+
*
|
|
48
|
+
* For an excellent developer experience, the quire-11ty code should be
|
|
49
|
+
* installed into an `11ty` or `quire-11ty` directory in the `projectRoot`
|
|
50
|
+
* this will allow us to more easily manage symlinks for local development
|
|
51
|
+
* using unpublished `quire-11ty` code.
|
|
52
|
+
* @example
|
|
53
|
+
* ```sh
|
|
54
|
+
* blargh/
|
|
55
|
+
* .git/
|
|
56
|
+
* .gitignore
|
|
57
|
+
* .node-version
|
|
58
|
+
* .quire-version
|
|
59
|
+
* 11ty@ --> /Users/mph/Code/Getty/quire/packages/11ty
|
|
60
|
+
* content/
|
|
61
|
+
* CHANGELOG.md
|
|
62
|
+
* LICENSE
|
|
63
|
+
* README.md
|
|
64
|
+
* package.json
|
|
65
|
+
* package-lock.json
|
|
66
|
+
* ```
|
|
67
|
+
* Installing to a directory will allow more cleanly `eject` and `uneject`
|
|
68
|
+
* using a symlink or single directory `rm -rf`.
|
|
69
|
+
* Should the `11ty` directory be a dot directory to hide the complexity from
|
|
70
|
+
* users or should it be visible to be more explicit when project is ejected?
|
|
50
71
|
*/
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
72
|
+
const getEleventyRoot = () => {
|
|
73
|
+
// try {
|
|
74
|
+
// return fs.readdirSync(projectRoot).includes(eleventyConfig)
|
|
75
|
+
// ? projectRoot
|
|
76
|
+
// : fs.realpathSync(libQuirePath)
|
|
77
|
+
// } catch (error) {
|
|
78
|
+
// throw new Error(`[CLI:11ty] Unable to read project directory for eleventy config ${error}`)
|
|
79
|
+
// }
|
|
80
|
+
return projectRoot
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export const eleventyRoot = getEleventyRoot()
|
|
54
84
|
|
|
55
85
|
export default {
|
|
56
86
|
config: path.join(eleventyRoot, '.eleventy.js'),
|
package/src/lib/quire/index.js
CHANGED
|
@@ -262,17 +262,21 @@ async function installInProject(projectPath, version, options={}) {
|
|
|
262
262
|
|
|
263
263
|
/**
|
|
264
264
|
* Retrieve latest published version of the `quire-11ty` package
|
|
265
|
+
|
|
266
|
+
* @todo refactor to programmatically return a specific version
|
|
267
|
+
* of `@thegetty/quire-11ty` from a semantic version string
|
|
268
|
+
* (i.e `^1.0.0-pre-release.0` => `1.0.0-pre-release.2`)
|
|
269
|
+
* so that the latest function may be used like:
|
|
270
|
+
* await latest('^1.0.0-pre-release.0') => '1.0.0-pre-release.2'
|
|
271
|
+
*
|
|
265
272
|
* Nota bene: `npm view [<@scope>/]<name>[@<version>] version`
|
|
266
273
|
* @see https://docs.npmjs.com/cli/v7/commands/npm-view
|
|
267
274
|
* returns a list of versions that satisfy the `<version>` range specifier,
|
|
268
275
|
* piping this to execa `stdout` we get only the last line of output.
|
|
276
|
+
* @todo use [`parse-columns`](https://github.com/sindresorhus/parse-columns)
|
|
277
|
+
* to parse the column formated list of versions returned by `npm view`
|
|
269
278
|
*
|
|
270
279
|
* @return {String} `quire-11ty@latest` semantic version string
|
|
271
|
-
*
|
|
272
|
-
* @TODO refactor `latest()` function to programmatically return a specific
|
|
273
|
-
* version of `@thegetty/quire-11ty` from a semantic version string
|
|
274
|
-
* (i.e `^1.0.0-pre-release.0` => `1.0.0-pre-release.2`) so it may be used like:
|
|
275
|
-
* await latest('^1.0.0-pre-release.0') => '1.0.0-pre-release.2'
|
|
276
280
|
*/
|
|
277
281
|
async function latest() {
|
|
278
282
|
const { stdout: quireVersion } =
|
package/LICENSE
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Copyright (c) 2022, J Paul Getty Trust.
|