@thegetty/quire-cli 1.0.0-pre-release.7 → 1.0.0-pre-release.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 +1 -1
- package/package.json +2 -2
- package/src/commands/index.js +6 -2
- package/src/helpers/is-quire.js +11 -2
- package/src/helpers/os-utils.js +5 -0
- package/src/helpers/test-cwd.js +19 -0
- package/src/lib/11ty/api.js +6 -1
- package/src/lib/quire/index.js +9 -8
- package/src/lib/pdf/paged.js +0 -21
- package/src/lib/pdf/prince.js +0 -7
package/CHANGELOG.md
CHANGED
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.9",
|
|
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/commands/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IS_WINDOWS } from '#helpers/os-utils.js'
|
|
2
|
+
import { fileURLToPath, pathToFileURL } from 'node:url'
|
|
2
3
|
import fs from 'fs-extra'
|
|
3
4
|
import path from 'node:path'
|
|
4
5
|
|
|
@@ -14,7 +15,10 @@ const thisfile = path.basename(__filename)
|
|
|
14
15
|
const commands = await Promise.all(
|
|
15
16
|
fs.readdirSync(__dirname)
|
|
16
17
|
.filter((file) => file !== thisfile && file.match(/^.*\.js$/))
|
|
17
|
-
.map((file) =>
|
|
18
|
+
.map((file) => IS_WINDOWS
|
|
19
|
+
? import(pathToFileURL(path.resolve(__dirname, file)))
|
|
20
|
+
: import(path.resolve(__dirname, file))
|
|
21
|
+
)
|
|
18
22
|
).then((modules) => {
|
|
19
23
|
return modules.map(({ default: CommandClass }) => new CommandClass())
|
|
20
24
|
})
|
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
|
+
}
|
package/src/lib/11ty/api.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { IS_WINDOWS } from '#helpers/os-utils.js'
|
|
2
|
+
import { pathToFileURL } from 'node:url'
|
|
1
3
|
import path from 'node:path'
|
|
2
4
|
import paths, { eleventyRoot, projectRoot } from './paths.js'
|
|
3
5
|
|
|
@@ -18,7 +20,10 @@ const factory = async (options = {}) => {
|
|
|
18
20
|
/**
|
|
19
21
|
* Dynamically import the correct version of Eleventy from `lib/quire/versions`
|
|
20
22
|
*/
|
|
21
|
-
const
|
|
23
|
+
const modulePath = path.join(eleventyRoot, 'node_modules', '@11ty', 'eleventy', 'src', 'Eleventy.js')
|
|
24
|
+
const { default: Eleventy } = IS_WINDOWS
|
|
25
|
+
? await import(pathToFileURL(modulePath))
|
|
26
|
+
: await import(modulePath)
|
|
22
27
|
|
|
23
28
|
/**
|
|
24
29
|
* Set Eleventy passthrough copy options
|
package/src/lib/quire/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IS_WINDOWS } from '#helpers/os-utils.js'
|
|
1
2
|
import { chdir, cwd } from 'node:process'
|
|
2
3
|
import { execa, execaCommand } from 'execa'
|
|
3
4
|
import { fileURLToPath } from 'node:url'
|
|
@@ -16,9 +17,6 @@ const INSTALL_PATH = path.join('src', 'lib', 'quire', 'versions')
|
|
|
16
17
|
const PACKAGE_NAME = '@thegetty/quire-11ty'
|
|
17
18
|
const VERSION_FILE = '.quire'
|
|
18
19
|
|
|
19
|
-
const IS_WINDOWS =
|
|
20
|
-
process.platform === 'win32' || /^(cygwin|msys)$/.test(process.env.OSTYPE)
|
|
21
|
-
|
|
22
20
|
/**
|
|
23
21
|
* Return an absolute path to an installed `quire-11ty` version
|
|
24
22
|
*
|
|
@@ -30,7 +28,7 @@ function getPath(version='latest') {
|
|
|
30
28
|
console.error(`[CLI:quire] \`quire-11ty@${version}\` is not installed`)
|
|
31
29
|
return null
|
|
32
30
|
}
|
|
33
|
-
console.debug(`[CLI:quire]
|
|
31
|
+
console.debug(`[CLI:quire] %s`, absolutePath)
|
|
34
32
|
return absolutePath
|
|
35
33
|
}
|
|
36
34
|
|
|
@@ -62,17 +60,20 @@ function getVersion(projectPath) {
|
|
|
62
60
|
* (i.e `^1.0.0-pre-release.0` => `1.0.0-pre-release.2`) so this string-trimming
|
|
63
61
|
* logic can be removed
|
|
64
62
|
*/
|
|
65
|
-
function getVersionFromStarter(projectPath) {
|
|
63
|
+
async function getVersionFromStarter(projectPath) {
|
|
66
64
|
const packageConfig = fs.readFileSync(path.join(projectPath, 'package.json'), { encoding:'utf8' })
|
|
67
65
|
const { peerDependencies } = JSON.parse(packageConfig)
|
|
68
66
|
const version = peerDependencies[PACKAGE_NAME]
|
|
69
|
-
return version
|
|
67
|
+
return version === 'latest'
|
|
68
|
+
? await latest()
|
|
69
|
+
: version.substr(version.search(/\d/))
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
73
|
* Clone or copy a Quire starter project
|
|
74
74
|
*
|
|
75
|
-
* @param {String} starter A repository URL or path to local starter
|
|
75
|
+
* @param {String} starter A repository URL or an absolute path to local starter
|
|
76
|
+
* @TODO resolve both absolute and relative paths to local starter repositories
|
|
76
77
|
* @param {String} projectPath Absolute system path to the project root
|
|
77
78
|
*
|
|
78
79
|
* @return {String} quireVersion A string indicating the current version
|
|
@@ -112,7 +113,7 @@ async function initStarter (starter, projectPath) {
|
|
|
112
113
|
* Determine `quire-11ty` version required by the starter project
|
|
113
114
|
* and write a `.quire` file with the semantic version string.
|
|
114
115
|
*/
|
|
115
|
-
const quireVersion = getVersionFromStarter(projectPath)
|
|
116
|
+
const quireVersion = await getVersionFromStarter(projectPath)
|
|
116
117
|
setVersion(projectPath, quireVersion)
|
|
117
118
|
|
|
118
119
|
// Re-initialize project directory as a new git repository
|
package/src/lib/pdf/paged.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// if (!commandExists('pagedjs-cli')) return
|
|
2
|
-
// const opts = [
|
|
3
|
-
// `--outline-tags 'h1'`,
|
|
4
|
-
// `--output ${output}`,
|
|
5
|
-
// ]
|
|
6
|
-
// const { stderror, stdout } = execa('pagedjs-cli', [...opts, input])
|
|
7
|
-
|
|
8
|
-
// console.info(`[CLI:lib/pdf] generating PDF using ${lib}`)
|
|
9
|
-
// const Printer = await import('pagedjs-cli')
|
|
10
|
-
/**
|
|
11
|
-
* Configure the Paged.js Printer options
|
|
12
|
-
* @see https://gitlab.coko.foundation/pagedjs/pagedjs-cli/-/blob/main/src/cli.js
|
|
13
|
-
*/
|
|
14
|
-
// const printerOptions = { debug: options.debug || false }
|
|
15
|
-
// const printer = new Printer(printerOptions)
|
|
16
|
-
/**
|
|
17
|
-
* Configure the Paged.js PDF options
|
|
18
|
-
* @see
|
|
19
|
-
*/
|
|
20
|
-
// const pdfOptions = {}
|
|
21
|
-
// const pdfFile = await printer.pdf(input, pdfOptions)
|
package/src/lib/pdf/prince.js
DELETED