@thegetty/quire-cli 1.0.0-rc.6 → 1.0.0-rc.9
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 +14 -1
- package/package.json +2 -2
- package/src/commands/README.md +8 -8
- package/src/commands/create.js +2 -1
- package/src/commands/info.js +125 -0
- package/src/lib/quire/index.js +27 -13
package/CHANGELOG.md
CHANGED
|
@@ -18,6 +18,19 @@ Changelog entries are classified using the following labels:
|
|
|
18
18
|
|
|
19
19
|
- `Removed`: for deprecated features removed in this release
|
|
20
20
|
|
|
21
|
+
## [1.0.0-rc.9]
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
### Added
|
|
24
|
+
- Update old `.quire` files when running `info` command on versions prior to `1.0.0-rc.8`
|
|
25
|
+
- Include `quire-cli` version used to generate project in `info` output
|
|
26
|
+
- Adds headings to `info` output
|
|
23
27
|
|
|
28
|
+
## [1.0.0-rc.8]
|
|
29
|
+
|
|
30
|
+
### Added
|
|
31
|
+
- Added `info` command to output package versions
|
|
32
|
+
|
|
33
|
+
## [1.0.0-rc.7]
|
|
34
|
+
|
|
35
|
+
### Added
|
|
36
|
+
- Added `new` command `--quire-path` option to support development with local version of `quire-11ty`
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thegetty/quire-cli",
|
|
3
3
|
"description": "Quire command-line interface",
|
|
4
|
-
"version": "1.0.0-rc.
|
|
4
|
+
"version": "1.0.0-rc.9",
|
|
5
5
|
"author": "Getty Digital",
|
|
6
6
|
"license": "SEE LICENSE IN https://github.com/thegetty/quire/blob/main/LICENSE",
|
|
7
7
|
"bugs": {
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"conf": "^11.0.1",
|
|
52
52
|
"cross-env": "^7.0.3",
|
|
53
53
|
"del": "^7.0.0",
|
|
54
|
-
"epubjs-cli": "^0.1.
|
|
54
|
+
"epubjs-cli": "^0.1.3",
|
|
55
55
|
"execa": "^6.1.0",
|
|
56
56
|
"fs-extra": "^11.1.0",
|
|
57
57
|
"hosted-git-info": "^6.1.1",
|
package/src/commands/README.md
CHANGED
|
@@ -16,6 +16,14 @@ Build Quire publication EPUB format.
|
|
|
16
16
|
quire build epub
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
+
#### `info`
|
|
20
|
+
|
|
21
|
+
List `quire-11ty`, `quire-cli`, and starter package versions; use the `--debug` option to include node, npm, and os versions.
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
quire build info
|
|
25
|
+
```
|
|
26
|
+
|
|
19
27
|
#### `pdf`
|
|
20
28
|
|
|
21
29
|
Build Quire publication PDF format.
|
|
@@ -154,14 +162,6 @@ To set the quire version globally use the `--global` command flag.
|
|
|
154
162
|
quire version 1.0.0 --global
|
|
155
163
|
```
|
|
156
164
|
|
|
157
|
-
#### `info`
|
|
158
|
-
|
|
159
|
-
Display the local and global `quire-11ty` version; this is the *default* subcommand (running `quire version` invokes the `info` subcommand).
|
|
160
|
-
|
|
161
|
-
```sh
|
|
162
|
-
quire version info
|
|
163
|
-
```
|
|
164
|
-
|
|
165
165
|
#### `install`
|
|
166
166
|
|
|
167
167
|
```sh
|
package/src/commands/create.js
CHANGED
|
@@ -22,7 +22,8 @@ export default class CreateCommand extends Command {
|
|
|
22
22
|
[ '[starter]', 'repository url or local path for a starter project' ],
|
|
23
23
|
],
|
|
24
24
|
options: [
|
|
25
|
-
[ '--quire <
|
|
25
|
+
[ '--quire-path <path>', 'local path to quire-11ty package' ],
|
|
26
|
+
[ '--quire-version <version>', 'quire-11ty version to install', 'latest' ],
|
|
26
27
|
// [ '--eject', 'install quire-11ty into the project directory', true ],
|
|
27
28
|
[ '--debug', 'debug the `quire new` command', false ],
|
|
28
29
|
],
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import Command from '#src/Command.js'
|
|
2
|
+
import { execaCommand } from 'execa'
|
|
3
|
+
import fs from 'node:fs'
|
|
4
|
+
import os from 'node:os'
|
|
5
|
+
import path from 'path'
|
|
6
|
+
import testcwd from '#helpers/test-cwd.js'
|
|
7
|
+
|
|
8
|
+
const VERSION_FILE = '.quire'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Quire CLI `info` Command
|
|
12
|
+
*
|
|
13
|
+
* Runs the Eleventy `info` command to list the quire-cli, quire-11ty, node, and npm versions.
|
|
14
|
+
*
|
|
15
|
+
* @class InfoCommand
|
|
16
|
+
* @extends {Command}
|
|
17
|
+
*/
|
|
18
|
+
export default class InfoCommand extends Command {
|
|
19
|
+
static definition = {
|
|
20
|
+
name: 'info',
|
|
21
|
+
description: 'List Quire cli, quire-11ty, and node versions',
|
|
22
|
+
summary: 'list info',
|
|
23
|
+
version: '1.0.0',
|
|
24
|
+
args: [],
|
|
25
|
+
options: [['--debug', 'include os versions in output']],
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
constructor() {
|
|
29
|
+
super(InfoCommand.definition)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async action(options, command) {
|
|
33
|
+
if (options.debug) {
|
|
34
|
+
console.debug(
|
|
35
|
+
'[CLI] Command \'%s\' called with options %o',
|
|
36
|
+
this.name(),
|
|
37
|
+
options
|
|
38
|
+
)
|
|
39
|
+
} else {
|
|
40
|
+
console.debug('[CLI] Command \'%s\' called', this.name())
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
let versionFile = fs.readFileSync(VERSION_FILE, { encoding: 'utf8' })
|
|
44
|
+
try {
|
|
45
|
+
versionFile = JSON.parse(versionFile)
|
|
46
|
+
} catch (error) {
|
|
47
|
+
console.warn(
|
|
48
|
+
`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
|
+
)
|
|
50
|
+
versionFile = { cli: '<=1.0.0.rc-7' }
|
|
51
|
+
fs.writeFileSync(VERSION_FILE, JSON.stringify(versionFile))
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const { name: projectDirectory } = path.parse(process.cwd())
|
|
55
|
+
|
|
56
|
+
const versions = [
|
|
57
|
+
{
|
|
58
|
+
title: `[${projectDirectory}]`,
|
|
59
|
+
items: [
|
|
60
|
+
{
|
|
61
|
+
name: 'quire-cli',
|
|
62
|
+
get: () => versionFile.cli,
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: 'quire-11ty',
|
|
66
|
+
get: () => {
|
|
67
|
+
const { version } = JSON.parse(fs.readFileSync('./package.json'))
|
|
68
|
+
return version
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: 'starter',
|
|
73
|
+
get: () => versionFile.starter,
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
title: '[System]',
|
|
79
|
+
items: [
|
|
80
|
+
{
|
|
81
|
+
name: 'quire-cli',
|
|
82
|
+
get: async () => {
|
|
83
|
+
const { stdout } = await execaCommand('quire --version')
|
|
84
|
+
return stdout
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
debug: true,
|
|
89
|
+
name: 'node',
|
|
90
|
+
get: () => process.version,
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
debug: true,
|
|
94
|
+
name: 'npm',
|
|
95
|
+
get: async () => {
|
|
96
|
+
const { stdout } = await execaCommand('npm --version')
|
|
97
|
+
return stdout
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
debug: true,
|
|
102
|
+
name: 'os',
|
|
103
|
+
get: () => `${os.type()} ${os.release()}`,
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
},
|
|
107
|
+
]
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Filter the command output based on `debug` settings
|
|
111
|
+
*/
|
|
112
|
+
versions.forEach(async ({ items, title }) => {
|
|
113
|
+
const versions = await Promise.all(
|
|
114
|
+
items
|
|
115
|
+
.filter(({ debug }) => !debug || (options.debug && debug))
|
|
116
|
+
.map(async ({ name, get }) => `${name} ${await get()}`)
|
|
117
|
+
)
|
|
118
|
+
console.info(`${title}\n ${versions.join('\n ')}`)
|
|
119
|
+
})
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
preAction(command) {
|
|
123
|
+
testcwd(command)
|
|
124
|
+
}
|
|
125
|
+
}
|
package/src/lib/quire/index.js
CHANGED
|
@@ -6,6 +6,7 @@ import { isEmpty } from '#helpers/is-empty.js'
|
|
|
6
6
|
import fs from 'fs-extra'
|
|
7
7
|
import git from '#src/lib/git/index.js'
|
|
8
8
|
import inv from 'install-npm-version'
|
|
9
|
+
import packageConfig from '#root/package.json' assert { type: 'json' }
|
|
9
10
|
import path from 'node:path'
|
|
10
11
|
import semver from 'semver'
|
|
11
12
|
|
|
@@ -60,13 +61,14 @@ function getVersion(projectPath) {
|
|
|
60
61
|
* (i.e `^1.0.0-pre-release.0` => `1.0.0-pre-release.2`) so this string-trimming
|
|
61
62
|
* logic can be removed
|
|
62
63
|
*/
|
|
63
|
-
async function
|
|
64
|
-
const
|
|
65
|
-
const { peerDependencies } = JSON.parse(
|
|
66
|
-
const
|
|
67
|
-
|
|
64
|
+
async function getVersionsFromStarter(projectPath) {
|
|
65
|
+
const projectPackageConfig = fs.readFileSync(path.join(projectPath, 'package.json'), { encoding:'utf8' })
|
|
66
|
+
const { peerDependencies, version: starterVersion } = JSON.parse(projectPackageConfig)
|
|
67
|
+
const quire11ty = peerDependencies[PACKAGE_NAME]
|
|
68
|
+
const quire11tyVersion = quire11ty === 'latest'
|
|
68
69
|
? await latest()
|
|
69
|
-
:
|
|
70
|
+
: quire11ty.substr(quire11ty.search(/\d/))
|
|
71
|
+
return { quire11tyVersion, starterVersion }
|
|
70
72
|
}
|
|
71
73
|
|
|
72
74
|
/**
|
|
@@ -112,12 +114,23 @@ async function initStarter (starter, projectPath, options) {
|
|
|
112
114
|
/**
|
|
113
115
|
* Determine `quire-11ty` version required by the starter project.
|
|
114
116
|
*
|
|
115
|
-
* A version specified in `options.
|
|
117
|
+
* A version specified in `options.quireVersion` overrides the version in starter
|
|
116
118
|
* project `package.json`.
|
|
117
119
|
*/
|
|
118
|
-
const
|
|
120
|
+
const { quire11tyVersion, starterVersion } = await getVersionsFromStarter(projectPath)
|
|
121
|
+
const quireVersion = options.quireVersion || quire11tyVersion
|
|
122
|
+
|
|
119
123
|
setVersion(projectPath, quireVersion)
|
|
120
124
|
|
|
125
|
+
/**
|
|
126
|
+
* Write quire-11ty, cli, starter name and version to VERSION_FILE
|
|
127
|
+
*/
|
|
128
|
+
const versionInfo = {
|
|
129
|
+
cli: packageConfig.version,
|
|
130
|
+
starter: `${starter}@${starterVersion}`,
|
|
131
|
+
}
|
|
132
|
+
fs.writeFileSync(path.join(projectPath, VERSION_FILE), JSON.stringify(versionInfo))
|
|
133
|
+
|
|
121
134
|
// Re-initialize project directory as a new git repository
|
|
122
135
|
await fs.remove(path.join(projectPath, '.git'))
|
|
123
136
|
|
|
@@ -150,7 +163,7 @@ async function initStarter (starter, projectPath, options) {
|
|
|
150
163
|
* @return {Promise}
|
|
151
164
|
*/
|
|
152
165
|
async function install(options = {}) {
|
|
153
|
-
const version = options.
|
|
166
|
+
const version = options.quireVersion || 'latest'
|
|
154
167
|
console.debug(`[CLI:quire] installing quire-11ty@${version}`)
|
|
155
168
|
const absoluteInstallPath = path.join(__dirname, 'versions')
|
|
156
169
|
fs.ensureDirSync(absoluteInstallPath)
|
|
@@ -199,8 +212,9 @@ async function install(options = {}) {
|
|
|
199
212
|
* @return {Promise}
|
|
200
213
|
*/
|
|
201
214
|
async function installInProject(projectPath, options = {}) {
|
|
202
|
-
const
|
|
203
|
-
|
|
215
|
+
const { quirePath, quireVersion } = options
|
|
216
|
+
const quire11tyPackage = fs.existsSync(quirePath) ? quirePath : `${PACKAGE_NAME}@${quireVersion}`
|
|
217
|
+
console.debug(`[CLI:quire] installing ${quire11tyPackage} into ${projectPath}`)
|
|
204
218
|
|
|
205
219
|
/**
|
|
206
220
|
* Delete the starter project package configuration so that it can be replaced
|
|
@@ -227,7 +241,7 @@ async function installInProject(projectPath, options = {}) {
|
|
|
227
241
|
Verbosity: options.debug ? 'Debug' : 'Silent',
|
|
228
242
|
WorkingDirectory: projectPath
|
|
229
243
|
}
|
|
230
|
-
await inv.Install(
|
|
244
|
+
await inv.Install(quire11tyPackage, installOptions)
|
|
231
245
|
|
|
232
246
|
// delete empty `node_modules` directory that `install-npm-version` creates
|
|
233
247
|
const invNodeModulesDir = path.join(projectPath, 'node_modules')
|
|
@@ -328,7 +342,7 @@ function setVersion(projectPath, version) {
|
|
|
328
342
|
console.error('[CLI] no version specified')
|
|
329
343
|
return
|
|
330
344
|
}
|
|
331
|
-
|
|
345
|
+
|
|
332
346
|
const projectName = path.basename(projectPath)
|
|
333
347
|
console.info(`${projectName} set to use quire-11ty@${version}`)
|
|
334
348
|
}
|