@thegetty/quire-cli 1.0.0-pre-release.6 → 1.0.0-pre-release.8
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/helpers/is-quire.js +11 -2
- package/src/helpers/test-cwd.js +19 -0
- package/src/helpers/which.js +17 -0
- package/src/lib/quire/index.js +7 -4
- package/src/lib/telemetry/README.md +0 -0
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-pre-release.
|
|
4
|
+
"version": "1.0.0-pre-release.8",
|
|
5
5
|
"author": "Getty Digital",
|
|
6
6
|
"license": "J Paul Getty Trust",
|
|
7
7
|
"bugs": {
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"del-cli": "^5.0.0",
|
|
68
|
-
"eslint": "^8.
|
|
68
|
+
"eslint": "^8.28.0"
|
|
69
69
|
},
|
|
70
70
|
"engines": {
|
|
71
71
|
"node": ">=14.16"
|
package/src/helpers/is-quire.js
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import fs from 'node:fs'
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
const QUIRE_DOT_FILES = Object.freeze([
|
|
4
|
+
'.eleventy.js',
|
|
5
|
+
'.quire',
|
|
6
|
+
'.quire-11ty',
|
|
7
|
+
'.quire-version',
|
|
8
|
+
'eleventy.config.js',
|
|
9
|
+
])
|
|
3
10
|
|
|
4
11
|
/**
|
|
5
12
|
* Test if a directory is a Quire project root
|
|
@@ -8,11 +15,13 @@ import path from 'node:path'
|
|
|
8
15
|
* a directory is a Quire project, testing a Quire project subdirectory will
|
|
9
16
|
* return falsely negative result.
|
|
10
17
|
*
|
|
18
|
+
* @todo refactor this to throw an Error NOTQUIRE
|
|
19
|
+
*
|
|
11
20
|
* @param {String} dirpath path to a local directory
|
|
12
21
|
* @return {Promise}
|
|
13
22
|
*/
|
|
14
23
|
export function isQuire (dirpath) {
|
|
15
24
|
return fs.readdirSync(dirpath)
|
|
16
|
-
.includes((file) =>
|
|
25
|
+
.includes((file) => QUIRE_DOT_FILES.includes(file))
|
|
17
26
|
}
|
|
18
27
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import isQuire from '#helpers/is-quire.js'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Test current working directory is a Quire project directory
|
|
5
|
+
*
|
|
6
|
+
* @param {String} projectPath
|
|
7
|
+
* @return {Boolean}
|
|
8
|
+
*/
|
|
9
|
+
export default (command) => {
|
|
10
|
+
const message = `[CLI] the '${command.name}' command must be run from a Quire project directory.`
|
|
11
|
+
|
|
12
|
+
return (projectPath) => {
|
|
13
|
+
if (!isQuire(process.cwd()) && !isQuire(projectPath)) {
|
|
14
|
+
if (command) console.error(message)
|
|
15
|
+
return false
|
|
16
|
+
}
|
|
17
|
+
return true
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import which from 'which'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A simple wrapper around the `which` utility
|
|
5
|
+
* to find the first instance of an executable in the shell environment PATH
|
|
6
|
+
*
|
|
7
|
+
* @param {String} executable shell executable to find
|
|
8
|
+
*/
|
|
9
|
+
export default (executable) => {
|
|
10
|
+
const result = which.sync(executable, { nothrow: true })
|
|
11
|
+
if (!result) {
|
|
12
|
+
console.error(`Unable to locate executable '${executable}'\n
|
|
13
|
+
Ensure that the '${executable}' executable is installed and available in the shell environment PATH.
|
|
14
|
+
`)
|
|
15
|
+
}
|
|
16
|
+
return result
|
|
17
|
+
}
|
package/src/lib/quire/index.js
CHANGED
|
@@ -62,17 +62,20 @@ function getVersion(projectPath) {
|
|
|
62
62
|
* (i.e `^1.0.0-pre-release.0` => `1.0.0-pre-release.2`) so this string-trimming
|
|
63
63
|
* logic can be removed
|
|
64
64
|
*/
|
|
65
|
-
function getVersionFromStarter(projectPath) {
|
|
65
|
+
async function getVersionFromStarter(projectPath) {
|
|
66
66
|
const packageConfig = fs.readFileSync(path.join(projectPath, 'package.json'), { encoding:'utf8' })
|
|
67
67
|
const { peerDependencies } = JSON.parse(packageConfig)
|
|
68
68
|
const version = peerDependencies[PACKAGE_NAME]
|
|
69
|
-
return version
|
|
69
|
+
return version === 'latest'
|
|
70
|
+
? await latest()
|
|
71
|
+
: version.substr(version.search(/\d/))
|
|
70
72
|
}
|
|
71
73
|
|
|
72
74
|
/**
|
|
73
75
|
* Clone or copy a Quire starter project
|
|
74
76
|
*
|
|
75
|
-
* @param {String} starter A repository URL or path to local starter
|
|
77
|
+
* @param {String} starter A repository URL or an absolute path to local starter
|
|
78
|
+
* @TODO resolve both absolute and relative paths to local starter repositories
|
|
76
79
|
* @param {String} projectPath Absolute system path to the project root
|
|
77
80
|
*
|
|
78
81
|
* @return {String} quireVersion A string indicating the current version
|
|
@@ -112,7 +115,7 @@ async function initStarter (starter, projectPath) {
|
|
|
112
115
|
* Determine `quire-11ty` version required by the starter project
|
|
113
116
|
* and write a `.quire` file with the semantic version string.
|
|
114
117
|
*/
|
|
115
|
-
const quireVersion = getVersionFromStarter(projectPath)
|
|
118
|
+
const quireVersion = await getVersionFromStarter(projectPath)
|
|
116
119
|
setVersion(projectPath, quireVersion)
|
|
117
120
|
|
|
118
121
|
// Re-initialize project directory as a new git repository
|
|
File without changes
|