@thegetty/quire-cli 1.0.0-rc.23 → 1.0.0-rc.25

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 CHANGED
@@ -12,16 +12,30 @@ Changelog entries are classified using the following labels:
12
12
  - `Fixed`: for any bug fixes
13
13
  - `Removed`: for deprecated features removed in this release
14
14
 
15
- ## [1.0.0-rc.23]
15
+ ## [1.0.0-rc.25]
16
+
17
+ ### Changed
18
+
19
+ - Use quire-cli config values for quire-11ty version and version file name
20
+
21
+ ### Fixed
22
+
23
+ - Install path for quire-11ty versions
24
+
25
+ ## [1.0.0-rc.24]
16
26
 
17
27
  ### Changed
18
28
 
19
- - Replace Node `import` assertions (deprecated) with file operations
29
+ - Replace Node `import` assertions (deprecated) with a packageConfig module
20
30
 
21
31
  ### Fixed
22
32
 
23
33
  - Quire new command fails with newer version of Node #968
24
34
 
35
+ ## [1.0.0-rc.23]
36
+
37
+ :warning: broken release candidate
38
+
25
39
  ## [1.0.0-rc.22]
26
40
 
27
41
  :warning: broken release candidate
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-rc.23",
4
+ "version": "1.0.0-rc.25",
5
5
  "author": "Getty Digital",
6
6
  "license": "SEE LICENSE IN https://github.com/thegetty/quire/blob/main/LICENSE",
7
7
  "bugs": {
@@ -64,6 +64,7 @@
64
64
  "install-npm-version": "^1.0.9",
65
65
  "js-yaml": "^4.1.0",
66
66
  "loglevel": "^1.8.1",
67
+ "node-fetch": "^3.3.2",
67
68
  "open": "^8.4.0",
68
69
  "ora": "^6.1.2",
69
70
  "pagedjs-cli": "^0.4.3",
package/src/PLUGIN.md ADDED
@@ -0,0 +1,57 @@
1
+ ## Quire Plugins
2
+
3
+ ### Defining Plugins
4
+
5
+ ```javascript
6
+ import { definePlugin } from 'quire-cli/plugins'
7
+
8
+ definePlugin({
9
+ commands: [],
10
+ compatability: {
11
+ // quire-cli version
12
+ },
13
+ name: 'plugin-name',
14
+ version: 'semantic-version',
15
+ install: () => {},
16
+ prepare: () => {},
17
+ })
18
+ ```
19
+
20
+ ### Adding Quire Commands
21
+
22
+
23
+
24
+ ### Modifying Quire Commands
25
+
26
+ ```javascript
27
+ import { modifyCommand } from 'quire-cli/plugins'
28
+
29
+ /**
30
+ * Extend an existing quire-cli command with additional aliases or options
31
+ *
32
+ * @todo how should the version be updated when a command is extended?
33
+ *
34
+ * @typedef {CommandDefinition}
35
+ * @property {String} alias
36
+ * @property {Array<String>} aliases
37
+ * @property {Array<CommandOption>} options
38
+ *
39
+ * @returns {Command} instance of the extended command object
40
+ */
41
+ modifyCommand(commandName, {})
42
+ ```
43
+
44
+ ### Overriding Quire Commands
45
+
46
+ ```javascript
47
+ import { replaceCommand } from 'quire-cli/plugins'
48
+
49
+ /**
50
+ * Override an existing quire-cli command
51
+ *
52
+ * @params {CommandDefinition} A complete Command definition
53
+ *
54
+ * @returns {Command} instance of the extended command object
55
+ */
56
+ replaceCommand({})
57
+ ```
@@ -1,30 +1,36 @@
1
1
  import { IS_WINDOWS } from '#helpers/os-utils.js'
2
2
  import { chdir, cwd } from 'node:process'
3
3
  import { execa, execaCommand } from 'execa'
4
+ import { fileURLToPath } from 'node:url'
4
5
  import { isEmpty } from '#helpers/is-empty.js'
6
+ import config from '#lib/conf/config.js'
5
7
  import fetch from 'node-fetch'
6
8
  import fs from 'fs-extra'
7
- import git from '#src/lib/git/index.js'
9
+ import git from '#lib/git/index.js'
8
10
  import inv from 'install-npm-version'
9
11
  import packageConfig from '#src/packageConfig.js'
10
12
  import path from 'node:path'
11
13
  import semver from 'semver'
12
14
 
13
- const { name: PACKAGE_NAME } = packageConfig
15
+ const __filename = fileURLToPath(import.meta.url)
16
+ const __dirname = path.dirname(__filename)
14
17
 
15
18
  // Version install path is relative to process working directory
16
19
  const INSTALL_PATH = path.join('src', 'lib', 'quire', 'versions')
17
- const VERSION_FILE = '.quire'
20
+ const PACKAGE_NAME = '@thegetty/quire-11ty'
21
+
22
+ const QUIRE_VERSION = config.get('quireVersion')
23
+ const VERSION_FILE = config.get('versionFile')
18
24
 
19
25
  /**
20
- * Return an absolute path to an installed `quire-11ty` version
26
+ * Return an absolute path to an installed quire-11ty version
21
27
  *
22
- * @return {String} path to installed `quire-11ty` version
28
+ * @return {String} path to installed quire-11ty version
23
29
  */
24
- function getPath(version='latest') {
25
- const absolutePath = path.relative('/', `${INSTALL_PATH}/${version}`)
30
+ function getPath(version=QUIRE_VERSION) {
31
+ const absolutePath = path.relative('/', path.join(INSTALL_PATH, version))
26
32
  if (!fs.existsSync(absolutePath)) {
27
- console.error(`[CLI:quire] \`quire-11ty@${version}\` is not installed`)
33
+ console.error(`[CLI:quire] quire-11ty@${version} is not installed`)
28
34
  return null
29
35
  }
30
36
  console.debug(`[CLI:quire] %s`, absolutePath)
@@ -32,7 +38,7 @@ function getPath(version='latest') {
32
38
  }
33
39
 
34
40
  /**
35
- * Read the required `quire-11ty` version for the project `.quire` file
41
+ * Read the required quire-11ty version for the quire version file
36
42
  *
37
43
  * @param {String} projectPath Absolute system path to the project root
38
44
  *
@@ -47,7 +53,7 @@ function getVersion(projectPath) {
47
53
  }
48
54
 
49
55
  /**
50
- * Read the required `quire-11ty` and starter versions from starter `package.json` `peerDependencies`
56
+ * Read required quire-11ty and starter versions from starter peerDependencies
51
57
  *
52
58
  * @param {String} projectPath Absolute system path to the project root
53
59
  *
@@ -87,8 +93,8 @@ async function initStarter (starter, projectPath, options) {
87
93
  }
88
94
 
89
95
  console.debug('[CLI:quire] init-starter',
90
- `\n project root: "${projectPath}"`,
91
- `\n starter: "${starter}"`
96
+ `\n project: ${path.join(__dirname, projectPath)}`,
97
+ `\n starter: ${starter}`
92
98
  )
93
99
 
94
100
  /**
@@ -101,19 +107,19 @@ async function initStarter (starter, projectPath, options) {
101
107
  .catch((error) => console.error('[CLI:error] ', error))
102
108
 
103
109
  /**
104
- * Determine the `quire-11ty` version to use in the new project,
105
- * from the `quireVersion` option or as required by the starter project.
110
+ * Determine the quire-11ty version to use in the new project,
111
+ * from the quireVersion option or as required by the starter project.
106
112
  *
107
- * Uses `latest` to get the latest semantic version compatible with version ranges
113
+ * Uses 'latest' to get the latest semantic version compatible with version ranges
108
114
  */
109
115
  const { quire11tyVersion, starterVersion } = await getVersionsFromStarter(projectPath)
110
116
  const quireVersion = await latest(options.quireVersion || quire11tyVersion)
111
117
  setVersion(projectPath, quireVersion)
112
118
 
113
119
  /**
114
- * Write quire-11ty, cli, starter name and version to VERSION_FILE
120
+ * Write quire-11ty, quire-cli, starter versions to the version file
115
121
  */
116
- const versionInfo = {
122
+ const versionInfo = {
117
123
  cli: packageConfig.version,
118
124
  starter: `${starter}@${starterVersion}`,
119
125
  }
@@ -142,7 +148,7 @@ async function initStarter (starter, projectPath, options) {
142
148
  }
143
149
 
144
150
  /**
145
- * Install `quire-11ty`, default to 'latest' version
151
+ * Install quire-11ty (default to 'latest' version)
146
152
  *
147
153
  * @TODO refactor this to be callable by the installInProject method
148
154
  *
@@ -150,7 +156,7 @@ async function initStarter (starter, projectPath, options) {
150
156
  * @return {Promise}
151
157
  */
152
158
  async function install(options = {}) {
153
- const version = options.quireVersion || 'latest'
159
+ const version = options.quireVersion || QUIRE_VERSION
154
160
  console.debug(`[CLI:quire] installing quire-11ty@${version}`)
155
161
  const absoluteInstallPath = path.join(__dirname, 'versions')
156
162
  fs.ensureDirSync(absoluteInstallPath)
@@ -181,9 +187,7 @@ async function install(options = {}) {
181
187
  * these must be `devDependencies` so that they are not bundled into
182
188
  * the final `_site` package when running `quire build`
183
189
  */
184
- const currentWorkingDirectory = cwd()
185
- const versionDir = path.join(absoluteInstallPath, version)
186
- chdir(versionDir)
190
+ chdir(path.join(absoluteInstallPath, version))
187
191
  await execaCommand('npm cache clean --force')
188
192
  await execaCommand('npm install --save-dev')
189
193
  }
@@ -6,10 +6,9 @@ const __filename = fileURLToPath(import.meta.url)
6
6
  const __dirname = dirname(__filename)
7
7
 
8
8
  /**
9
- * Nota bene:
10
- * working directory will be the path from which quire-cli commands are run;
11
- * readPackageUpSync must be called with the change working directory option
12
- * set to the path of this module to find the quire-cli package config file.
9
+ * Nota bene: current working directory will be that from which cli commands
10
+ * are being, readPackageUpSync is passed the directory of this module as the
11
+ * starting path to search for the quire-cli package config file.
13
12
  */
14
13
  const { packageJson } = readPackageUpSync({ cwd: __dirname, normalize: true })
15
14