@thegetty/quire-cli 1.0.0-rc.5 → 1.0.0-rc.7
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 +1 -1
- package/src/commands/README.md +20 -0
- package/src/commands/create.js +15 -7
- package/src/lib/epub/index.js +3 -1
- package/src/lib/pdf/index.js +3 -1
- package/src/lib/quire/index.js +25 -17
package/package.json
CHANGED
package/src/commands/README.md
CHANGED
|
@@ -80,6 +80,26 @@ To create a new project from a starter template
|
|
|
80
80
|
quire new <path> <starter>
|
|
81
81
|
```
|
|
82
82
|
|
|
83
|
+
#### Specifying the `quire-11ty` version
|
|
84
|
+
|
|
85
|
+
When the `--quire` flag is used the new project will be started using the specified version of `quire-11ty`
|
|
86
|
+
|
|
87
|
+
```sh
|
|
88
|
+
quire new <path> <starter> --quire <version>
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
##### Version identifiers
|
|
92
|
+
|
|
93
|
+
The `--quire` flag must be either a semantic version identifier or a npm distribution tag. For example:
|
|
94
|
+
|
|
95
|
+
```sh
|
|
96
|
+
quire new ./blargh --quire 1.0.0-rc.5
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
```sh
|
|
100
|
+
quire new ./blargh --quire latest
|
|
101
|
+
```
|
|
102
|
+
|
|
83
103
|
### `preview`
|
|
84
104
|
|
|
85
105
|
Build and server the Quire site in development mode.
|
package/src/commands/create.js
CHANGED
|
@@ -22,8 +22,10 @@ export default class CreateCommand extends Command {
|
|
|
22
22
|
[ '[starter]', 'repository url or local path for a starter project' ],
|
|
23
23
|
],
|
|
24
24
|
options: [
|
|
25
|
-
[ '--
|
|
26
|
-
[ '--
|
|
25
|
+
[ '--quire-path <path>', 'local path to quire-11ty package' ],
|
|
26
|
+
[ '--quire-version <version>', 'quire-11ty version to install', 'latest' ],
|
|
27
|
+
// [ '--eject', 'install quire-11ty into the project directory', true ],
|
|
28
|
+
[ '--debug', 'debug the `quire new` command', false ],
|
|
27
29
|
],
|
|
28
30
|
}
|
|
29
31
|
|
|
@@ -52,14 +54,20 @@ export default class CreateCommand extends Command {
|
|
|
52
54
|
// const starter = starters['default']
|
|
53
55
|
// `git clone starter path`
|
|
54
56
|
} else {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
/**
|
|
58
|
+
* @TODO test that `version` is compatible with the `requiredVersion`
|
|
59
|
+
* if version is incompatible or unknown
|
|
60
|
+
* - interactive mode prompt to continue
|
|
61
|
+
* - non-interactive mode throw an error and exit the process
|
|
62
|
+
*/
|
|
63
|
+
await quire.initStarter(starter, projectPath, options)
|
|
64
|
+
|
|
65
|
+
options.eject = true
|
|
58
66
|
|
|
59
67
|
if (options.eject) {
|
|
60
|
-
await quire.installInProject(projectPath,
|
|
68
|
+
await quire.installInProject(projectPath, options)
|
|
61
69
|
} else {
|
|
62
|
-
await quire.install(
|
|
70
|
+
await quire.install(options)
|
|
63
71
|
}
|
|
64
72
|
}
|
|
65
73
|
}
|
package/src/lib/epub/index.js
CHANGED
|
@@ -11,7 +11,9 @@ const __dirname = path.dirname(__filename)
|
|
|
11
11
|
export default async (name = 'epubjs', options = {}) => {
|
|
12
12
|
const lib = { name, options, path }
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
const normalizedName = name.replace(/[-_.\s]/g, '').toLowerCase()
|
|
15
|
+
|
|
16
|
+
switch (normalizedName) {
|
|
15
17
|
case 'epubjs': {
|
|
16
18
|
lib.name = 'Epub.js'
|
|
17
19
|
lib.options = {}
|
package/src/lib/pdf/index.js
CHANGED
|
@@ -11,7 +11,9 @@ const __dirname = path.dirname(__filename)
|
|
|
11
11
|
export default async (name = 'pagedjs', options = {}) => {
|
|
12
12
|
const lib = { name, options, path }
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
const normalizedName = name.replace(/[-_.\s]/g, '').toLowerCase()
|
|
15
|
+
|
|
16
|
+
switch (normalizedName) {
|
|
15
17
|
case 'paged':
|
|
16
18
|
case 'pagedjs': {
|
|
17
19
|
lib.name = 'Paged.js'
|
package/src/lib/quire/index.js
CHANGED
|
@@ -79,7 +79,7 @@ async function getVersionFromStarter(projectPath) {
|
|
|
79
79
|
* @return {String} quireVersion A string indicating the current version
|
|
80
80
|
* of quire being used with a new project
|
|
81
81
|
*/
|
|
82
|
-
async function initStarter (starter, projectPath) {
|
|
82
|
+
async function initStarter (starter, projectPath, options) {
|
|
83
83
|
projectPath = projectPath || cwd()
|
|
84
84
|
|
|
85
85
|
// ensure that the target path exists
|
|
@@ -110,10 +110,12 @@ async function initStarter (starter, projectPath) {
|
|
|
110
110
|
.catch((error) => console.error('[CLI:error] ', error))
|
|
111
111
|
|
|
112
112
|
/**
|
|
113
|
-
* Determine `quire-11ty` version required by the starter project
|
|
114
|
-
*
|
|
113
|
+
* Determine `quire-11ty` version required by the starter project.
|
|
114
|
+
*
|
|
115
|
+
* A version specified in `options.quireVersion` overrides the version in starter
|
|
116
|
+
* project `package.json`.
|
|
115
117
|
*/
|
|
116
|
-
const quireVersion = await getVersionFromStarter(projectPath)
|
|
118
|
+
const quireVersion = options.quireVersion || await getVersionFromStarter(projectPath)
|
|
117
119
|
setVersion(projectPath, quireVersion)
|
|
118
120
|
|
|
119
121
|
// Re-initialize project directory as a new git repository
|
|
@@ -140,13 +142,15 @@ async function initStarter (starter, projectPath) {
|
|
|
140
142
|
}
|
|
141
143
|
|
|
142
144
|
/**
|
|
143
|
-
* Install
|
|
145
|
+
* Install `quire-11ty`, default to 'latest' version
|
|
146
|
+
*
|
|
147
|
+
* @TODO refactor this to be callable by the installInProject method
|
|
144
148
|
*
|
|
145
|
-
* @param {String} version Quire-11ty semantic version
|
|
146
149
|
* @param {Object} options options passed from `quire new` command
|
|
147
150
|
* @return {Promise}
|
|
148
151
|
*/
|
|
149
|
-
async function install(
|
|
152
|
+
async function install(options = {}) {
|
|
153
|
+
const version = options.quireVersion || 'latest'
|
|
150
154
|
console.debug(`[CLI:quire] installing quire-11ty@${version}`)
|
|
151
155
|
const absoluteInstallPath = path.join(__dirname, 'versions')
|
|
152
156
|
fs.ensureDirSync(absoluteInstallPath)
|
|
@@ -185,19 +189,23 @@ async function install(version, options={}) {
|
|
|
185
189
|
}
|
|
186
190
|
|
|
187
191
|
/**
|
|
188
|
-
* Install
|
|
192
|
+
* Install `quire-11ty` directly into a quire project
|
|
193
|
+
*
|
|
194
|
+
* @TODO refactor this to use the install method with pre and post-install hooks
|
|
195
|
+
* or steps to prepare the working directory and cleanup on error and completion
|
|
189
196
|
*
|
|
190
197
|
* @param {String} projectPath Absolute system path to the project root
|
|
191
|
-
* @param {String} version Quire-11ty semantic version
|
|
192
198
|
* @param {Object} options options passed from `quire new` command
|
|
193
199
|
* @return {Promise}
|
|
194
200
|
*/
|
|
195
|
-
async function installInProject(projectPath,
|
|
196
|
-
|
|
201
|
+
async function installInProject(projectPath, options = {}) {
|
|
202
|
+
const { quirePath, quireVersion } = options
|
|
203
|
+
const quire11tyPackage = fs.existsSync(quirePath) ? quirePath : `${PACKAGE_NAME}@${quireVersion}`
|
|
204
|
+
console.debug(`[CLI:quire] installing ${quire11tyPackage} into ${projectPath}`)
|
|
197
205
|
|
|
198
206
|
/**
|
|
199
|
-
*
|
|
200
|
-
*
|
|
207
|
+
* Delete the starter project package configuration so that it can be replaced
|
|
208
|
+
* with the `@thegetty/quire-11ty` configuration
|
|
201
209
|
* @TODO If a user runs quire eject at a later date we may want to merge their
|
|
202
210
|
* package.json with the `quire-11ty` dev dependencies, scripts, etc
|
|
203
211
|
*/
|
|
@@ -220,7 +228,7 @@ async function installInProject(projectPath, version, options={}) {
|
|
|
220
228
|
Verbosity: options.debug ? 'Debug' : 'Silent',
|
|
221
229
|
WorkingDirectory: projectPath
|
|
222
230
|
}
|
|
223
|
-
await inv.Install(
|
|
231
|
+
await inv.Install(quire11tyPackage, installOptions)
|
|
224
232
|
|
|
225
233
|
// delete empty `node_modules` directory that `install-npm-version` creates
|
|
226
234
|
const invNodeModulesDir = path.join(projectPath, 'node_modules')
|
|
@@ -314,16 +322,16 @@ async function remove(version) {
|
|
|
314
322
|
/**
|
|
315
323
|
* Sets the quire-11ty version for a project
|
|
316
324
|
*
|
|
317
|
-
* @param {String} version
|
|
325
|
+
* @param {String} version a version identifier or distribution tag
|
|
318
326
|
*/
|
|
319
327
|
function setVersion(projectPath, version) {
|
|
320
328
|
if (!version) {
|
|
321
329
|
console.error('[CLI] no version specified')
|
|
330
|
+
return
|
|
322
331
|
}
|
|
332
|
+
fs.writeFileSync(path.join(projectPath, VERSION_FILE), version)
|
|
323
333
|
const projectName = path.basename(projectPath)
|
|
324
334
|
console.info(`${projectName} set to use quire-11ty@${version}`)
|
|
325
|
-
const versionFilePath = path.join(projectPath, VERSION_FILE)
|
|
326
|
-
fs.writeFileSync(versionFilePath, version)
|
|
327
335
|
}
|
|
328
336
|
|
|
329
337
|
/**
|