@thegetty/quire-cli 1.0.0-pre-release.4 → 1.0.0-pre-release.6
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/README.md +0 -7
- package/bin/cli.js +1 -0
- package/package.json +1 -1
- package/src/commands/README.md +2 -18
- package/src/commands/create.js +10 -2
- package/src/lib/11ty/paths.js +16 -3
- package/src/lib/quire/index.js +79 -3
- package/src/main.js +0 -1
package/README.md
CHANGED
|
@@ -9,10 +9,3 @@ The `quire-cli` implements the [command pattern](https://en.wikipedia.org/wiki/C
|
|
|
9
9
|
```sh
|
|
10
10
|
npx quire-cli --help
|
|
11
11
|
```
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
#### Microsoft Windows
|
|
15
|
-
|
|
16
|
-
https://learnshareit.com/how-to-solve-nodemon-ps1-cannot-be-loaded-because-running-scripts-is-disabled-on-this-system-in-nodejs/
|
|
17
|
-
|
|
18
|
-
See [Microsoft About Execution Policies](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7.3)
|
package/bin/cli.js
CHANGED
package/package.json
CHANGED
package/src/commands/README.md
CHANGED
|
@@ -194,14 +194,6 @@ To reinstall a `quire-11ty` version run
|
|
|
194
194
|
quire version install <version> --force
|
|
195
195
|
```
|
|
196
196
|
|
|
197
|
-
#### `link`
|
|
198
|
-
|
|
199
|
-
Link to a local `quire-11ty` package for development and testing.
|
|
200
|
-
|
|
201
|
-
```sh
|
|
202
|
-
quire version link [path]
|
|
203
|
-
```
|
|
204
|
-
|
|
205
197
|
#### `list`
|
|
206
198
|
|
|
207
199
|
List installed versions of `quire-11ty`
|
|
@@ -218,20 +210,12 @@ Remove outdated versions of `quire-11ty`
|
|
|
218
210
|
quire version prune
|
|
219
211
|
```
|
|
220
212
|
|
|
221
|
-
#### `
|
|
222
|
-
|
|
223
|
-
Unlink a local `quire-11ty` package
|
|
213
|
+
#### `remove` (alias `uninstall`)
|
|
224
214
|
|
|
225
215
|
```sh
|
|
226
|
-
quire version
|
|
216
|
+
quire version remove <version>
|
|
227
217
|
```
|
|
228
218
|
|
|
229
|
-
#### `uninstall` (alias `remove`)
|
|
230
|
-
|
|
231
219
|
```sh
|
|
232
220
|
quire version uninstall <version>
|
|
233
221
|
```
|
|
234
|
-
|
|
235
|
-
```sh
|
|
236
|
-
quire version remove <version>
|
|
237
|
-
```
|
package/src/commands/create.js
CHANGED
|
@@ -23,6 +23,7 @@ export default class CreateCommand extends Command {
|
|
|
23
23
|
],
|
|
24
24
|
options: [
|
|
25
25
|
[ '--debug', 'debug the `quire new` command' ],
|
|
26
|
+
[ '--eject', 'install quire-11ty into the project directory', 'true' ],
|
|
26
27
|
],
|
|
27
28
|
}
|
|
28
29
|
|
|
@@ -38,7 +39,7 @@ export default class CreateCommand extends Command {
|
|
|
38
39
|
*/
|
|
39
40
|
async action(projectPath, starter, options = {}) {
|
|
40
41
|
if (options.debug) {
|
|
41
|
-
console.info('Command \'%s\' called with options %o',
|
|
42
|
+
console.info('Command \'%s\' called with options %o', CreateCommand.name, options)
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
if (!projectPath && !starter) {
|
|
@@ -52,7 +53,14 @@ export default class CreateCommand extends Command {
|
|
|
52
53
|
// `git clone starter path`
|
|
53
54
|
} else {
|
|
54
55
|
const version = await quire.initStarter(starter, projectPath)
|
|
55
|
-
|
|
56
|
+
// @TODO we will want to abstract the test for emptiness to prevent further install steps on error
|
|
57
|
+
if (!version) return
|
|
58
|
+
|
|
59
|
+
if (options.eject) {
|
|
60
|
+
await quire.installInProject(projectPath, version, options)
|
|
61
|
+
} else {
|
|
62
|
+
await quire.install(version, options)
|
|
63
|
+
}
|
|
56
64
|
}
|
|
57
65
|
}
|
|
58
66
|
}
|
package/src/lib/11ty/paths.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { fileURLToPath } from 'node:url'
|
|
2
|
+
import fs from 'fs-extra'
|
|
2
3
|
import path from 'node:path'
|
|
3
4
|
|
|
4
5
|
const __filename = fileURLToPath(import.meta.url)
|
|
@@ -19,13 +20,25 @@ const __dirname = path.dirname(__filename)
|
|
|
19
20
|
* and correctly resolve the path to the target of the 'latest' symlink
|
|
20
21
|
*/
|
|
21
22
|
const cliRoot = path.resolve(__dirname, path.join('..', '..'))
|
|
23
|
+
const eleventyConfig = '.eleventy.js'
|
|
22
24
|
const version = 'latest'
|
|
23
25
|
|
|
24
|
-
//
|
|
25
|
-
|
|
26
|
-
|
|
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
|
+
|
|
27
35
|
export const projectRoot = process.cwd()
|
|
28
36
|
|
|
37
|
+
// Absolute path to the current version of quire-11ty
|
|
38
|
+
export const eleventyRoot = hasEleventyConfig(projectRoot)
|
|
39
|
+
? projectRoot
|
|
40
|
+
: path.resolve(__dirname, path.join(cliRoot, 'lib', 'quire', 'versions', version))
|
|
41
|
+
|
|
29
42
|
export default {
|
|
30
43
|
config: path.join(eleventyRoot, '.eleventy.js'),
|
|
31
44
|
input: path.relative(eleventyRoot, path.join(projectRoot, 'content')),
|
package/src/lib/quire/index.js
CHANGED
|
@@ -141,9 +141,8 @@ async function initStarter (starter, projectPath) {
|
|
|
141
141
|
/**
|
|
142
142
|
* Install a specific version of `quire-11ty`
|
|
143
143
|
*
|
|
144
|
-
* If a `version` argument is not given `latest` is assumed.
|
|
145
|
-
*
|
|
146
144
|
* @param {String} version Quire-11ty semantic version
|
|
145
|
+
* @param {Object} options options passed from `quire new` command
|
|
147
146
|
* @return {Promise}
|
|
148
147
|
*/
|
|
149
148
|
async function install(version, options={}) {
|
|
@@ -157,7 +156,7 @@ async function install(version, options={}) {
|
|
|
157
156
|
* @see https://github.com/scott-lin/install-npm-version
|
|
158
157
|
*/
|
|
159
158
|
const installOptions = {
|
|
160
|
-
Destination: path.join('
|
|
159
|
+
Destination: path.join('..', version),
|
|
161
160
|
Debug: false,
|
|
162
161
|
Overwrite: options.force || options.overwrite || false,
|
|
163
162
|
Verbosity: options.debug ? 'Debug' : 'Silent',
|
|
@@ -184,6 +183,82 @@ async function install(version, options={}) {
|
|
|
184
183
|
await execaCommand('npm install --save-dev')
|
|
185
184
|
}
|
|
186
185
|
|
|
186
|
+
/**
|
|
187
|
+
* Install a specific version of `quire-11ty` directly into a quire project
|
|
188
|
+
*
|
|
189
|
+
* @param {String} projectPath Absolute system path to the project root
|
|
190
|
+
* @param {String} version Quire-11ty semantic version
|
|
191
|
+
* @param {Object} options options passed from `quire new` command
|
|
192
|
+
* @return {Promise}
|
|
193
|
+
*/
|
|
194
|
+
async function installInProject(projectPath, version, options={}) {
|
|
195
|
+
console.debug(`[CLI:quire] installing quire-11ty@${version} into ${projectPath}`)
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* delete `package.json` from starter project, as it will be replaced with
|
|
199
|
+
* `package.json` from `@thegetty/quire-11ty`
|
|
200
|
+
* @TODO If a user runs quire eject at a later date we may want to merge their
|
|
201
|
+
* package.json with the `quire-11ty` dev dependencies, scripts, etc
|
|
202
|
+
*/
|
|
203
|
+
await git
|
|
204
|
+
.cwd(projectPath)
|
|
205
|
+
.rm(['package.json'])
|
|
206
|
+
.catch((error) => console.error('[CLI:error] ', error))
|
|
207
|
+
|
|
208
|
+
const temp11tyDirectory = '.temp'
|
|
209
|
+
/**
|
|
210
|
+
* `Destination` is relative to `node_modules` of the working-directory
|
|
211
|
+
* so we have included a relative path to parent directory in order to
|
|
212
|
+
* install versions to a different local path.
|
|
213
|
+
* @see https://github.com/scott-lin/install-npm-version
|
|
214
|
+
*/
|
|
215
|
+
const installOptions = {
|
|
216
|
+
Destination: path.join('..', temp11tyDirectory),
|
|
217
|
+
Debug: false,
|
|
218
|
+
Overwrite: options.force || options.overwrite || false,
|
|
219
|
+
Verbosity: options.debug ? 'Debug' : 'Silent',
|
|
220
|
+
WorkingDirectory: projectPath
|
|
221
|
+
}
|
|
222
|
+
await inv.Install(`${PACKAGE_NAME}@${version}`, installOptions)
|
|
223
|
+
|
|
224
|
+
// delete empty `node_modules` directory that `install-npm-version` creates
|
|
225
|
+
const invNodeModulesDir = path.join(projectPath, 'node_modules')
|
|
226
|
+
if (fs.existsSync(invNodeModulesDir)) fs.rmdir(invNodeModulesDir)
|
|
227
|
+
|
|
228
|
+
// Copy all files installed in `.temp` to projectPath
|
|
229
|
+
fs.copySync(path.join(projectPath, '.temp'), projectPath)
|
|
230
|
+
|
|
231
|
+
console.debug('[CLI:quire] installing dev dependencies into quire project')
|
|
232
|
+
/**
|
|
233
|
+
* Manually install necessary dev dependencies to run 11ty;
|
|
234
|
+
* these must be `devDependencies` so that they are not bundled into
|
|
235
|
+
* the final `_site` package when running `quire build`
|
|
236
|
+
*/
|
|
237
|
+
await execaCommand('npm cache clean --force', { cwd: projectPath })
|
|
238
|
+
try {
|
|
239
|
+
await execaCommand('npm install --save-dev', { cwd: projectPath })
|
|
240
|
+
} catch(error) {
|
|
241
|
+
console.warn(`[CLI:error]`, error)
|
|
242
|
+
fs.removeSync(projectPath)
|
|
243
|
+
return
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
const eleventyFilesToCommit = fs
|
|
247
|
+
.readdirSync(path.join(projectPath, temp11tyDirectory))
|
|
248
|
+
.filter((filePath) => filePath !== 'node_modules')
|
|
249
|
+
|
|
250
|
+
eleventyFilesToCommit.push('package-lock.json')
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Create an additional commit of new `@thegetty/quire-11ty` files in repository
|
|
254
|
+
* @todo use a localized string for the commit message
|
|
255
|
+
*/
|
|
256
|
+
await git.add(eleventyFilesToCommit).commit('Adds `@thegetty/quire-11ty` files')
|
|
257
|
+
|
|
258
|
+
// remove temporary 11ty install directory
|
|
259
|
+
fs.removeSync(path.join(projectPath, temp11tyDirectory))
|
|
260
|
+
}
|
|
261
|
+
|
|
187
262
|
/**
|
|
188
263
|
* Retrieve latest published version of the `quire-11ty` package
|
|
189
264
|
* Nota bene: `npm view [<@scope>/]<name>[@<version>] version`
|
|
@@ -317,6 +392,7 @@ export const quire = {
|
|
|
317
392
|
getVersion,
|
|
318
393
|
initStarter,
|
|
319
394
|
install,
|
|
395
|
+
installInProject,
|
|
320
396
|
latest,
|
|
321
397
|
list,
|
|
322
398
|
remove,
|
package/src/main.js
CHANGED