@thegetty/quire-cli 1.0.0-rc.3 → 1.0.0-rc.5
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/bin/cli.js +2 -2
- package/package.json +1 -1
- package/src/lib/11ty/plugins/before.js +0 -16
- package/src/lib/quire/constants.js +0 -6
- package/src/lib/quire/project.js +0 -104
package/bin/cli.js
CHANGED
|
@@ -20,12 +20,12 @@ const INTERVAL = Object.freeze({
|
|
|
20
20
|
* @todo user configuration of choosen update interval
|
|
21
21
|
*/
|
|
22
22
|
const notifier = updateNotifier({
|
|
23
|
-
distTag: '
|
|
23
|
+
distTag: 'latest',
|
|
24
24
|
pkg: packageConfig,
|
|
25
25
|
updateCheckInterval: INTERVAL.DAILY,
|
|
26
26
|
})
|
|
27
27
|
|
|
28
|
-
notifier.notify()
|
|
28
|
+
notifier.notify({ defer: false })
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* Run the cli program
|
package/package.json
CHANGED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* { item_description }
|
|
3
|
-
*/
|
|
4
|
-
module.export = (eleventyConfig) => {
|
|
5
|
-
/**
|
|
6
|
-
* The `eleventy.before` event runs every time Eleventy starts building,
|
|
7
|
-
* it will run before the start of each stand-alone build, as well as
|
|
8
|
-
* each time building starts as either part of `--watch` or `--serve`.
|
|
9
|
-
* @see https://www.11ty.dev/docs/events/#eleventy.before
|
|
10
|
-
*/
|
|
11
|
-
eleventyConfig.on('eleventy.before', async () => {
|
|
12
|
-
console.debug('[11ty] before build')
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
return eleventyConfig
|
|
16
|
-
}
|
package/src/lib/quire/project.js
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { CONSTANT } from 'constants.js'
|
|
2
|
-
import fs from 'fs-extra'
|
|
3
|
-
import path from 'node:path'
|
|
4
|
-
|
|
5
|
-
const { PACKAGE_NAME } = CONSTANT
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Read the required `quire-11ty` version from starter `package.json` `peerDependencies`
|
|
9
|
-
*
|
|
10
|
-
* @param {String} projectPath Absolute system path to the project root
|
|
11
|
-
*
|
|
12
|
-
* @return {String} version Quire-11ty semantic version with caret or other
|
|
13
|
-
* comparators trimmed off the beginning
|
|
14
|
-
*
|
|
15
|
-
* @TODO refactor `latest()` function to programmatically return a specific
|
|
16
|
-
* version of `@thegetty/quire-11ty` from a semantic version string
|
|
17
|
-
* (i.e `^1.0.0-pre-release.0` => `1.0.0-pre-release.2`) so this string-trimming
|
|
18
|
-
* logic can be removed
|
|
19
|
-
*/
|
|
20
|
-
async function getVersion(projectPath) {
|
|
21
|
-
const packageConfig = fs.readFileSync(path.join(projectPath, 'package.json'), { encoding:'utf8' })
|
|
22
|
-
const { peerDependencies } = JSON.parse(packageConfig)
|
|
23
|
-
const version = peerDependencies[PACKAGE_NAME]
|
|
24
|
-
return version === 'latest'
|
|
25
|
-
? await latest()
|
|
26
|
-
: version.substr(version.search(/\d/))
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Clone or copy a Quire starter project
|
|
31
|
-
*
|
|
32
|
-
* @param {String} starter A repository URL or an absolute path to local starter
|
|
33
|
-
* @TODO resolve both absolute and relative paths to local starter repositories
|
|
34
|
-
* @param {String} projectPath Absolute system path to the project root
|
|
35
|
-
*
|
|
36
|
-
* @return {String} quireVersion A string indicating the current version
|
|
37
|
-
* of quire being used with a new project
|
|
38
|
-
*/
|
|
39
|
-
async function init (starter, projectPath) {
|
|
40
|
-
projectPath = projectPath || cwd()
|
|
41
|
-
|
|
42
|
-
// ensure that the target path exists
|
|
43
|
-
fs.ensureDirSync(projectPath)
|
|
44
|
-
|
|
45
|
-
// if the target directory exists it must be empty
|
|
46
|
-
if (!isEmpty(projectPath)) {
|
|
47
|
-
const location = projectPath === '.' ? 'the current directory' : projectPath
|
|
48
|
-
console.error(`[CLI] cannot create a starter project in ${location} because it is not empty`)
|
|
49
|
-
// @TODO cleanup directories from failed new command
|
|
50
|
-
return
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
starter = starter || 'https://github.com/thegetty/quire-starter-default'
|
|
54
|
-
|
|
55
|
-
console.debug('[CLI:quire] init-starter',
|
|
56
|
-
`\n project root: "${projectPath}"`,
|
|
57
|
-
`\n starter: "${starter}"`
|
|
58
|
-
)
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Clone starter project repository
|
|
62
|
-
* @todo pipe `git clone` status to stdout for better UX
|
|
63
|
-
*/
|
|
64
|
-
await git
|
|
65
|
-
.cwd(projectPath)
|
|
66
|
-
.clone(starter, '.')
|
|
67
|
-
.catch((error) => console.error('[CLI:error] ', error))
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Determine `quire-11ty` version required by the starter project
|
|
71
|
-
* and write a `.quire` file with the semantic version string.
|
|
72
|
-
*/
|
|
73
|
-
const quireVersion = await getVersion(projectPath)
|
|
74
|
-
setVersion(projectPath, quireVersion)
|
|
75
|
-
|
|
76
|
-
// Re-initialize project directory as a new git repository
|
|
77
|
-
await fs.remove(path.join(projectPath, '.git'))
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Remove the starter repository package config file
|
|
81
|
-
* and create a new package config for the project
|
|
82
|
-
* (this is necessary for Eleventy to resolve project paths)
|
|
83
|
-
* @todo allow interactive init using a custom questionnaire
|
|
84
|
-
* @see https://docs.npmjs.com/creating-a-package-json-file#customizing-the-packagejson-questionnaire
|
|
85
|
-
*/
|
|
86
|
-
await fs.remove(path.join(projectPath, 'package.json'))
|
|
87
|
-
await execaCommand('npm init --yes', { cwd: projectPath })
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Create an initial commit of files in new repository
|
|
91
|
-
* @todo use a localized string for the commit message
|
|
92
|
-
*/
|
|
93
|
-
const projectFiles = fs.readdirSync(projectPath)
|
|
94
|
-
await git.init().add(projectFiles).commit('Initial Commit')
|
|
95
|
-
|
|
96
|
-
return quireVersion
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Update quire-11ty
|
|
101
|
-
*
|
|
102
|
-
* @return {Promise} { description_of_the_return_value }
|
|
103
|
-
*/
|
|
104
|
-
async function update () {}
|