@thegetty/quire-cli 1.0.0-pre-release.11 → 1.0.0-pre-release.13
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/README.html +1089 -0
- package/src/lib/11ty/README.md +23 -3
- package/src/lib/11ty/api.js +11 -1
- package/src/lib/11ty/cli.js +30 -28
- package/src/lib/11ty/paths.js +19 -3
- package/src/lib/quire/index.js +9 -5
- package/LICENSE +0 -1
package/src/lib/11ty/README.md
CHANGED
|
@@ -2,14 +2,34 @@
|
|
|
2
2
|
|
|
3
3
|
The `quire-cli/lib/11ty` module is a façade for interacting with Eleventy, the static site generator for Quire projects.
|
|
4
4
|
|
|
5
|
+
### 11ty/API module
|
|
6
|
+
|
|
7
|
+
The `api` module allows the Quire CLI to programmatical configure an instance of Eleventy on which it can call methods.
|
|
8
|
+
|
|
9
|
+
See [Eleventy Documentation: Programmatic API](https://www.11ty.dev/docs/programmatic/)
|
|
10
|
+
|
|
5
11
|
### 11ty/CLI module
|
|
6
12
|
|
|
7
13
|
The `cli` module is a wrapper around the Eleventy CLI to run `@11ty/eleventy` commands.
|
|
8
14
|
|
|
9
15
|
See [Eleventy Documentation: Command Line Usage](https://www.11ty.dev/docs/usage/#command-line-usage)
|
|
10
16
|
|
|
11
|
-
###
|
|
17
|
+
### Paths module
|
|
12
18
|
|
|
13
|
-
The `
|
|
19
|
+
The `paths` module returns paths for a Quire project to configure the Eleventy instance:
|
|
14
20
|
|
|
15
|
-
|
|
21
|
+
- _absolute_ path to the [Eleventy configuration](https://www.11ty.dev/docs/config/) file
|
|
22
|
+
- _relative_ path *from* the `quire-11ty` source *to* the `input` and `output` directories for the project
|
|
23
|
+
- _relative_ path *from* the project `input` *to* the Eleventy `includes` and `layouts` directories
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
Set environment variables for paths relative to eleventy `input` dir,
|
|
27
|
+
* allowing a project agnostic `quire-11ty` eleventy configuration file.
|
|
28
|
+
* Nota bene: environment variables read into the eleventy configuration
|
|
29
|
+
* file _must_ be set before the eleventy configuration file is parsed.
|
|
30
|
+
|
|
31
|
+
`Eleventy` does not expose an API to set the relative `includes` and `layouts` paths on the instance. In order to decouple the Eleventy configuration file from a specific project and its path on the system the exported `paths` are used by the `api` and `cli` modules to set environment variables that can be used in the `.eleventy.js` configuration.
|
|
32
|
+
|
|
33
|
+
These environment variables **must be set before** the `Eleventy` instance is created and the `.eleventy.js` configuration is parsed.
|
|
34
|
+
|
|
35
|
+
**Nota bene** The current implementation of the `Eleventy` `TemplatePathResolver` assumes that the `layouts` directory is a child of the `input` directory and prevents decoupling the Quire project content from the `quire-11ty` code; see [eleventy#2655](https://github.com/11ty/eleventy/issues/2655).
|
package/src/lib/11ty/api.js
CHANGED
|
@@ -35,6 +35,17 @@ const factory = async (options = {}) => {
|
|
|
35
35
|
expand: true,
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
/**
|
|
39
|
+
* Set environment variables for paths relative to eleventy `input` dir,
|
|
40
|
+
* to allow `quire-11ty` to be decouple from the project input directory.
|
|
41
|
+
* Nota bene: environment variables read into the eleventy configuration
|
|
42
|
+
* file _must_ be set before the eleventy configuration file is parsed.
|
|
43
|
+
* @see https://github.com/11ty/eleventy/issues/2655
|
|
44
|
+
*/
|
|
45
|
+
process.env.ELEVENTY_DATA = paths.data
|
|
46
|
+
process.env.ELEVENTY_INCLUDES = paths.includes
|
|
47
|
+
process.env.ELEVENTY_LAYOUTS = paths.layouts
|
|
48
|
+
|
|
38
49
|
/**
|
|
39
50
|
* Get an instance of the runtime of eleventy.
|
|
40
51
|
* @see https://github.com/11ty/eleventy/blob/src/Eleventy.js
|
|
@@ -92,7 +103,6 @@ export default {
|
|
|
92
103
|
process.cwd(projectRoot)
|
|
93
104
|
|
|
94
105
|
console.info('[CLI:11ty] running eleventy build')
|
|
95
|
-
console.info(`[CLI:11ty] projectRoot ${projectRoot}`)
|
|
96
106
|
|
|
97
107
|
process.env.ELEVENTY_ENV = 'production'
|
|
98
108
|
if (options.debug) process.env.DEBUG = 'Eleventy*'
|
package/src/lib/11ty/cli.js
CHANGED
|
@@ -32,7 +32,25 @@ const factory = (options = {}) => {
|
|
|
32
32
|
if (options.quiet) command.push('--quiet')
|
|
33
33
|
if (options.verbose) command.push('--verbose')
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Set execa environment variables
|
|
37
|
+
* @see https://github.com/sindresorhus/execa#env
|
|
38
|
+
*
|
|
39
|
+
* Set environment variables for paths relative to eleventy `input` dir,
|
|
40
|
+
* to allow `quire-11ty` to be decouple from the project input directory.
|
|
41
|
+
* Nota bene: environment variables read into the eleventy configuration
|
|
42
|
+
* file _must_ be set before the eleventy configuration file is parsed.
|
|
43
|
+
* @see https://github.com/11ty/eleventy/issues/2655
|
|
44
|
+
*/
|
|
45
|
+
const env = {
|
|
46
|
+
ELEVENTY_DATA: paths.data,
|
|
47
|
+
ELEVENTY_INCLUDES: paths.includes,
|
|
48
|
+
ELEVENTY_LAYOUTS: paths.layouts,
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (options.debug) env.DEBUG = 'Eleventy*'
|
|
52
|
+
|
|
53
|
+
return { command, env }
|
|
36
54
|
}
|
|
37
55
|
|
|
38
56
|
/**
|
|
@@ -43,24 +61,16 @@ export default {
|
|
|
43
61
|
build: async (options = {}) => {
|
|
44
62
|
console.info('[CLI:11ty] running eleventy build')
|
|
45
63
|
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Set execa environment variables
|
|
50
|
-
* @see https://github.com/sindresorhus/execa#env
|
|
51
|
-
*/
|
|
52
|
-
const execaEnv = {
|
|
53
|
-
ELEVENTY_ENV: 'production'
|
|
54
|
-
}
|
|
64
|
+
const { command, env } = factory(options)
|
|
55
65
|
|
|
56
|
-
if (options.
|
|
66
|
+
if (options.dryRun) command.push('--dryrun')
|
|
57
67
|
|
|
58
|
-
|
|
68
|
+
env.ELEVENTY_ENV = 'production'
|
|
59
69
|
|
|
60
|
-
await execa('node',
|
|
70
|
+
await execa('node', command, {
|
|
61
71
|
all: true,
|
|
62
72
|
cwd: projectRoot,
|
|
63
|
-
env
|
|
73
|
+
env,
|
|
64
74
|
execPath: process.execPath
|
|
65
75
|
}).all.pipe(process.stdout)
|
|
66
76
|
},
|
|
@@ -68,26 +78,18 @@ export default {
|
|
|
68
78
|
serve: async (options = {}) => {
|
|
69
79
|
console.info(`[CLI:11ty] running eleventy serve`)
|
|
70
80
|
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
eleventyCommand.push('--serve')
|
|
81
|
+
const { command, env } = factory(options)
|
|
74
82
|
|
|
75
|
-
|
|
76
|
-
* Set execa environment variables
|
|
77
|
-
* @see https://github.com/sindresorhus/execa#env
|
|
78
|
-
*/
|
|
79
|
-
const execaEnv = {
|
|
80
|
-
ELEVENTY_ENV: 'development'
|
|
81
|
-
}
|
|
83
|
+
command.push('--serve')
|
|
82
84
|
|
|
83
|
-
|
|
85
|
+
env.ELEVENTY_ENV = 'development'
|
|
84
86
|
|
|
85
|
-
if (options.port)
|
|
87
|
+
if (options.port) command.push(`--port=${options.port}`)
|
|
86
88
|
|
|
87
|
-
await execa('node',
|
|
89
|
+
await execa('node', command, {
|
|
88
90
|
all: true,
|
|
89
91
|
cwd: projectRoot,
|
|
90
|
-
env
|
|
92
|
+
env,
|
|
91
93
|
execPath: process.execPath
|
|
92
94
|
}).all.pipe(process.stdout)
|
|
93
95
|
}
|
package/src/lib/11ty/paths.js
CHANGED
|
@@ -34,14 +34,30 @@ const hasEleventyConfig = (dir) => {
|
|
|
34
34
|
|
|
35
35
|
export const projectRoot = process.cwd()
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
const inputDir = path.join(projectRoot, 'content')
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Absolute path to the latest installed version of `quire-11ty`
|
|
41
|
+
* @todo use version read from the project `.quire-version` file
|
|
42
|
+
*/
|
|
43
|
+
const libQuirePath = path.resolve(__dirname, path.join(cliRoot, 'lib', 'quire', 'versions', version))
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Absolute path to the current version of `quire-11ty`
|
|
47
|
+
* Nota bene: to get a relative path to the `eleventyRoot`,
|
|
48
|
+
* for example when the version is specified is 'latest',
|
|
49
|
+
* it must be set to the real path to the symlink target.
|
|
50
|
+
*/
|
|
38
51
|
export const eleventyRoot = hasEleventyConfig(projectRoot)
|
|
39
52
|
? projectRoot
|
|
40
|
-
:
|
|
53
|
+
: fs.realpathSync(libQuirePath)
|
|
41
54
|
|
|
42
55
|
export default {
|
|
43
56
|
config: path.join(eleventyRoot, '.eleventy.js'),
|
|
44
|
-
input: path.relative(eleventyRoot,
|
|
57
|
+
input: path.relative(eleventyRoot, inputDir),
|
|
45
58
|
output: path.relative(eleventyRoot, path.join(projectRoot, '_site')),
|
|
59
|
+
data: path.relative(inputDir, path.join(eleventyRoot, '_computed')),
|
|
60
|
+
includes: path.relative(inputDir, path.join(eleventyRoot, '_includes')),
|
|
61
|
+
layouts: path.relative(inputDir, path.join(eleventyRoot, '_layouts')),
|
|
46
62
|
public: './public',
|
|
47
63
|
}
|
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.
|