@thegetty/quire-cli 1.0.0-rc.0 → 1.0.0-rc.10

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
@@ -18,6 +18,24 @@ Changelog entries are classified using the following labels:
18
18
 
19
19
  - `Removed`: for deprecated features removed in this release
20
20
 
21
+ ## [1.0.0-rc.10]
21
22
 
22
- ## [Unreleased]
23
+ ### Added
24
+ - Support semantic version ranges for `quire-11ty` in quire starter projects and the `--quire-version` option of the `quire new` command, and use the latest compatible `quire-11ty` version when creating and installing a new project.
23
25
 
26
+ ## [1.0.0-rc.9]
27
+
28
+ ### Added
29
+ - Update old `.quire` files when running `info` command on versions prior to `1.0.0-rc.8`
30
+ - Include `quire-cli` version used to generate project in `info` output
31
+ - Adds headings to `info` output
32
+
33
+ ## [1.0.0-rc.8]
34
+
35
+ ### Added
36
+ - Added `info` command to output package versions
37
+
38
+ ## [1.0.0-rc.7]
39
+
40
+ ### Added
41
+ - Added `new` command `--quire-path` option to support development with local version of `quire-11ty`
package/bin/cli.js CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node --no-warnings
1
+ #!/usr/bin/env -S node --no-warnings
2
2
 
3
3
  import cli from '#src/main.js'
4
4
  import packageConfig from '#root/package.json' assert { type: 'json' }
@@ -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: 'rc',
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,7 +1,7 @@
1
1
  {
2
2
  "name": "@thegetty/quire-cli",
3
3
  "description": "Quire command-line interface",
4
- "version": "1.0.0-rc.0",
4
+ "version": "1.0.0-rc.10",
5
5
  "author": "Getty Digital",
6
6
  "license": "SEE LICENSE IN https://github.com/thegetty/quire/blob/main/LICENSE",
7
7
  "bugs": {
@@ -45,30 +45,29 @@
45
45
  "#lib/*.js": "./src/lib/*.js"
46
46
  },
47
47
  "dependencies": {
48
- "boxen": "^7.0.0",
49
- "chalk": "^5.1.2",
50
- "commander": "^9.4.1",
51
- "conf": "^10.2.0",
48
+ "boxen": "^7.0.1",
49
+ "chalk": "^5.2.0",
50
+ "commander": "^10.0.0",
51
+ "conf": "^11.0.1",
52
52
  "cross-env": "^7.0.3",
53
53
  "del": "^7.0.0",
54
- "epubjs": "^0.4.2",
54
+ "epubjs-cli": "^0.1.3",
55
55
  "execa": "^6.1.0",
56
- "fs-extra": "^11.0.0",
56
+ "fs-extra": "^11.1.0",
57
57
  "hosted-git-info": "^6.1.1",
58
- "i18next": "^22.0.4",
58
+ "i18next": "^22.4.9",
59
59
  "inquirer": "^9.1.4",
60
60
  "install-npm-version": "^1.0.8",
61
- "loglevel": "^1.8.0",
61
+ "loglevel": "^1.8.1",
62
62
  "open": "^8.4.0",
63
63
  "ora": "^6.1.2",
64
- "pagedjs-cli": "^0.3.1",
64
+ "pagedjs-cli": "^0.3.3",
65
65
  "semver": "^7.3.8",
66
- "simple-git": "^3.15.0",
66
+ "simple-git": "^3.16.0",
67
67
  "update-notifier": "^6.0.2"
68
68
  },
69
69
  "devDependencies": {
70
- "del-cli": "^5.0.0",
71
- "eslint": "^8.28.0"
70
+ "eslint": "^8.32.0"
72
71
  },
73
72
  "engines": {
74
73
  "node": ">=14.16"
@@ -16,6 +16,14 @@ Build Quire publication EPUB format.
16
16
  quire build epub
17
17
  ```
18
18
 
19
+ #### `info`
20
+
21
+ List `quire-11ty`, `quire-cli`, and starter package versions; use the `--debug` option to include node, npm, and os versions.
22
+
23
+ ```sh
24
+ quire build info
25
+ ```
26
+
19
27
  #### `pdf`
20
28
 
21
29
  Build Quire publication PDF format.
@@ -42,41 +50,17 @@ Note that this command is distinct from the [quire/11ty package](https://github.
42
50
  quire clean --dry-run
43
51
  ```
44
52
 
45
- ### `configure`
53
+ ### `configure` **not yet implemented**
46
54
 
47
- Edit a Quire project configuration.
55
+ Edit the Quire CLI configuration.
48
56
 
49
57
  ```sh
50
58
  quire configure
51
59
  ```
52
60
 
53
- ### `debug`
54
-
55
- Display Quire debugging information in the console.
56
-
57
- ```sh
58
- quire debug
59
- ```
60
-
61
- ### `dev`
62
-
63
- Clone `quire/packages/11ty` into the local project.
64
-
65
- ```sh
66
- quire dev
67
- ```
68
-
69
- ### `edit`
70
-
71
- Open or create a new content file in the default editor.
72
-
73
- ```sh
74
- quire edit
75
- ```
76
-
77
- ### `install`
61
+ ### `install` **not yet implemented**
78
62
 
79
- Clone an existing project from a git repository.
63
+ Clone an existing Quire project from a git repository.
80
64
 
81
65
  ```sh
82
66
  quire install <repository>
@@ -104,47 +88,51 @@ To create a new project from a starter template
104
88
  quire new <path> <starter>
105
89
  ```
106
90
 
107
- ### `preview`
91
+ #### Specifying the `quire-11ty` version
108
92
 
109
- Build and server the Quire site in development mode.
93
+ When the `--quire` flag is used the new project will be started using the specified version of `quire-11ty`
110
94
 
111
95
  ```sh
112
- quire preview --port 8080
96
+ quire new <path> <starter> --quire <version>
113
97
  ```
114
98
 
115
- #### `epub`
99
+ ##### Version identifiers
116
100
 
117
- Preview the Quire publication epub in the default application.
101
+ The `--quire` flag must be either a semantic version identifier or a npm distribution tag. For example:
118
102
 
119
103
  ```sh
120
- quire preview epub --open
104
+ quire new ./blargh --quire 1.0.0-rc.5
121
105
  ```
122
106
 
123
- To preview the epub in Apple iBooks or Kindle Previewer
124
-
125
107
  ```sh
126
- quire preview epub --open iBooks
108
+ quire new ./blargh --quire latest
127
109
  ```
128
110
 
111
+ ### `preview`
112
+
113
+ Build and server the Quire site in development mode.
114
+
129
115
  ```sh
130
- quire preview epub --open Kindle
116
+ quire preview --port 8080
131
117
  ```
132
118
 
133
- #### `pdf`
119
+ #### `epub` **not yet implemented**
134
120
 
135
- Preview the Quire publication PDF in the default application.
121
+ Preview the Quire publication epub in the default application.
136
122
 
137
123
  ```sh
138
- quire preview pdf --open
124
+ quire preview epub --open
139
125
  ```
140
126
 
141
- Preview the Quire publication PDF in an application.
127
+ #### `pdf` **not yet implemented**
128
+
129
+ Preview the Quire publication PDF in the default application.
142
130
 
143
131
  ```sh
144
- quire preview pdf --open <Application>
132
+ quire preview pdf --open
145
133
  ```
146
134
 
147
- #### `site`
135
+ #### `site` **default subcommand**
148
136
 
149
137
  Build and serve the Quire site in development mode.
150
138
 
@@ -152,7 +140,7 @@ Build and serve the Quire site in development mode.
152
140
  quire preview site
153
141
  ```
154
142
 
155
- #### `server`
143
+ ### `server` **not yet implemented**
156
144
 
157
145
  Start a local web server to serve a previously built Quire site.
158
146
 
@@ -160,7 +148,7 @@ Start a local web server to serve a previously built Quire site.
160
148
  quire server --port 8080
161
149
  ```
162
150
 
163
- ### `version`
151
+ ### `version` **partial implementation**
164
152
 
165
153
  Sets the Quire version to use when running commands on the project.
166
154
 
@@ -174,14 +162,6 @@ To set the quire version globally use the `--global` command flag.
174
162
  quire version 1.0.0 --global
175
163
  ```
176
164
 
177
- #### `info`
178
-
179
- Display the local and global `quire-11ty` version; this is the *default* subcommand (running `quire version` invokes the `info` subcommand).
180
-
181
- ```sh
182
- quire version info
183
- ```
184
-
185
165
  #### `install`
186
166
 
187
167
  ```sh
@@ -1,4 +1,5 @@
1
1
  import Command from '#src/Command.js'
2
+ import fs from 'fs-extra'
2
3
  import { quire } from '#src/lib/quire/index.js'
3
4
 
4
5
  /**
@@ -22,8 +23,10 @@ export default class CreateCommand extends Command {
22
23
  [ '[starter]', 'repository url or local path for a starter project' ],
23
24
  ],
24
25
  options: [
25
- [ '--debug', 'debug the `quire new` command' ],
26
- [ '--eject', 'install quire-11ty into the project directory', 'true' ],
26
+ [ '--quire-path <path>', 'local path to quire-11ty package' ],
27
+ [ '--quire-version <version>', 'quire-11ty version to install' ],
28
+ // [ '--eject', 'install quire-11ty into the project directory', true ],
29
+ [ '--debug', 'debug the `quire new` command', false ],
27
30
  ],
28
31
  }
29
32
 
@@ -52,14 +55,27 @@ export default class CreateCommand extends Command {
52
55
  // const starter = starters['default']
53
56
  // `git clone starter path`
54
57
  } else {
55
- const version = await quire.initStarter(starter, projectPath)
56
- // @TODO we will want to abstract the test for emptiness to prevent further install steps on error
57
- if (!version) return
58
+ /**
59
+ * @TODO test that `version` is compatible with the `requiredVersion`
60
+ * if version is incompatible or unknown
61
+ * - interactive mode prompt to continue
62
+ * - non-interactive mode throw an error and exit the process
63
+ */
64
+ let quireVersion
65
+ try {
66
+ quireVersion = await quire.initStarter(starter, projectPath, options)
67
+ } catch (error) {
68
+ console.error(error.message)
69
+ fs.removeSync(projectPath)
70
+ return
71
+ }
72
+
73
+ options.eject = true
58
74
 
59
75
  if (options.eject) {
60
- await quire.installInProject(projectPath, version, options)
76
+ await quire.installInProject(projectPath, quireVersion, options)
61
77
  } else {
62
- await quire.install(version, options)
78
+ await quire.install(options)
63
79
  }
64
80
  }
65
81
  }
@@ -48,8 +48,8 @@ export default class EpubCommand extends Command {
48
48
 
49
49
  const output = path.join(projectRoot, `${options.lib}.epub`)
50
50
 
51
- const epubLib = await libEpub(options.lib, { ...options.debug })
52
- await epubLib(input, output, { ...options.debug })
51
+ const epubLib = await libEpub(options.lib, { debug: options.debug })
52
+ await epubLib(input, output)
53
53
 
54
54
  if (fs.existsSync(output) && options.open) open(output)
55
55
  }
@@ -0,0 +1,125 @@
1
+ import Command from '#src/Command.js'
2
+ import { execaCommand } from 'execa'
3
+ import fs from 'node:fs'
4
+ import os from 'node:os'
5
+ import path from 'path'
6
+ import testcwd from '#helpers/test-cwd.js'
7
+
8
+ const VERSION_FILE = '.quire'
9
+
10
+ /**
11
+ * Quire CLI `info` Command
12
+ *
13
+ * Runs the Eleventy `info` command to list the quire-cli, quire-11ty, node, and npm versions.
14
+ *
15
+ * @class InfoCommand
16
+ * @extends {Command}
17
+ */
18
+ export default class InfoCommand extends Command {
19
+ static definition = {
20
+ name: 'info',
21
+ description: 'List Quire cli, quire-11ty, and node versions',
22
+ summary: 'list info',
23
+ version: '1.0.0',
24
+ args: [],
25
+ options: [['--debug', 'include os versions in output']],
26
+ }
27
+
28
+ constructor() {
29
+ super(InfoCommand.definition)
30
+ }
31
+
32
+ async action(options, command) {
33
+ if (options.debug) {
34
+ console.debug(
35
+ '[CLI] Command \'%s\' called with options %o',
36
+ this.name(),
37
+ options
38
+ )
39
+ } else {
40
+ console.debug('[CLI] Command \'%s\' called', this.name())
41
+ }
42
+
43
+ let versionFile = fs.readFileSync(VERSION_FILE, { encoding: 'utf8' })
44
+ try {
45
+ versionFile = JSON.parse(versionFile)
46
+ } catch (error) {
47
+ console.warn(
48
+ `This project was generated with the quire-cli prior to version 1.0.0.rc-8. Updating the version file to the new format, though this project's version file will not contain specific starter version information.`
49
+ )
50
+ versionFile = { cli: '<=1.0.0.rc-7' }
51
+ fs.writeFileSync(VERSION_FILE, JSON.stringify(versionFile))
52
+ }
53
+
54
+ const { name: projectDirectory } = path.parse(process.cwd())
55
+
56
+ const versions = [
57
+ {
58
+ title: `[${projectDirectory}]`,
59
+ items: [
60
+ {
61
+ name: 'quire-cli',
62
+ get: () => versionFile.cli,
63
+ },
64
+ {
65
+ name: 'quire-11ty',
66
+ get: () => {
67
+ const { version } = JSON.parse(fs.readFileSync('./package.json'))
68
+ return version
69
+ },
70
+ },
71
+ {
72
+ name: 'starter',
73
+ get: () => versionFile.starter,
74
+ },
75
+ ],
76
+ },
77
+ {
78
+ title: '[System]',
79
+ items: [
80
+ {
81
+ name: 'quire-cli',
82
+ get: async () => {
83
+ const { stdout } = await execaCommand('quire --version')
84
+ return stdout
85
+ },
86
+ },
87
+ {
88
+ debug: true,
89
+ name: 'node',
90
+ get: () => process.version,
91
+ },
92
+ {
93
+ debug: true,
94
+ name: 'npm',
95
+ get: async () => {
96
+ const { stdout } = await execaCommand('npm --version')
97
+ return stdout
98
+ },
99
+ },
100
+ {
101
+ debug: true,
102
+ name: 'os',
103
+ get: () => `${os.type()} ${os.release()}`,
104
+ },
105
+ ],
106
+ },
107
+ ]
108
+
109
+ /**
110
+ * Filter the command output based on `debug` settings
111
+ */
112
+ versions.forEach(async ({ items, title }) => {
113
+ const versions = await Promise.all(
114
+ items
115
+ .filter(({ debug }) => !debug || (options.debug && debug))
116
+ .map(async ({ name, get }) => `${name} ${await get()}`)
117
+ )
118
+ console.info(`${title}\n ${versions.join('\n ')}`)
119
+ })
120
+ }
121
+
122
+ preAction(command) {
123
+ testcwd(command)
124
+ }
125
+ }
@@ -50,8 +50,8 @@ export default class PDFCommand extends Command {
50
50
 
51
51
  const output = path.join(projectRoot, `${options.lib}.pdf`)
52
52
 
53
- const pdfLib = await libPdf(options.lib, { ...options.debug })
54
- await pdfLib(input, output, { ...options.debug })
53
+ const pdfLib = await libPdf(options.lib, { debug: options.debug })
54
+ await pdfLib(input, output)
55
55
 
56
56
  try {
57
57
  if (fs.existsSync(output) && options.open) open(output)
@@ -40,7 +40,7 @@ export default class PreviewCommand extends Command {
40
40
  super(PreviewCommand.definition)
41
41
  }
42
42
 
43
- action(options, command) {
43
+ async action(options, command) {
44
44
  if (options.debug) {
45
45
  console.debug('[CLI] Command \'%s\' called with arguments [%o] and options %o', this.name(), options)
46
46
  }
@@ -13,9 +13,9 @@ import paths, { eleventyRoot, projectRoot } from './paths.js'
13
13
  const factory = async (options = {}) => {
14
14
  const { config, input, output } = paths
15
15
 
16
- console.info(`[CLI:11ty] projectRoot ${projectRoot}`)
17
-
18
- console.debug('[CLI:11ty] %o', paths)
16
+ if (options.debug) {
17
+ console.debug('[CLI:11ty] projectRoot %s\n%o', projectRoot, paths)
18
+ }
19
19
 
20
20
  /**
21
21
  * Dynamically import the correct version of Eleventy
@@ -113,8 +113,8 @@ export default {
113
113
  if (options.debug) process.env.DEBUG = 'Eleventy*'
114
114
 
115
115
  const eleventy = await factory(options)
116
+
116
117
  eleventy.setDryRun(options.dryrun)
117
- eleventy.setIncrementalBuild(true)
118
118
 
119
119
  await eleventy.write()
120
120
  },
@@ -127,7 +127,6 @@ export default {
127
127
  if (options.debug) process.env.DEBUG = 'Eleventy*'
128
128
 
129
129
  const eleventy = await factory(options)
130
- eleventy.setIncrementalBuild(true)
131
130
 
132
131
  await eleventy.serve(options.port)
133
132
  }
@@ -11,9 +11,9 @@ import paths, { eleventyRoot, projectRoot } from './paths.js'
11
11
  const factory = (options = {}) => {
12
12
  const { config, input, output } = paths
13
13
 
14
- console.info(`[CLI:11ty] projectRoot ${projectRoot}`)
15
-
16
- console.debug('[CLI:11ty] %o', paths)
14
+ if (options.debug) {
15
+ console.debug('[CLI:11ty] projectRoot %s\n%o', projectRoot, paths)
16
+ }
17
17
 
18
18
  /**
19
19
  * Use the version of Eleventy installed to `lib/quire/versions`
@@ -1,9 +1,27 @@
1
- // import epub from 'epubjs'
1
+ import { ManifestToEpub } from 'epubjs-cli'
2
+ import fs from 'fs-extra'
3
+ import { pathToFileURL } from 'node:url'
2
4
 
3
5
  /**
4
6
  * A façade module for the EPUB.js library
5
- * @see https://github.com/futurepress/epub.js
7
+ * @see https://github.com/futurepress/epubjs-cli
6
8
  */
7
- export default async (input, output, options) => {
8
- console.info('[CLI:lib/epubjs] integration with epub.js is not yet implemented.')
9
+ export default async (input, output, options = {}) => {
10
+ try {
11
+ console.info(`[CLI:lib/epub/epubjs] Generating ePub from ${input}`)
12
+
13
+ const url = pathToFileURL(`${input}/manifest.json`).toString()
14
+
15
+ const epub = await new ManifestToEpub(url)
16
+ .catch((error) => console.error(error))
17
+
18
+ const file = await epub.save()
19
+ .catch((error) => console.error(error))
20
+
21
+ if (file && output) {
22
+ fs.writeFile(output, file, (error) => { if (error) throw error })
23
+ }
24
+ } catch (ERR_FILE_NOT_FOUND) {
25
+ console.error(`[CLI:lib/epub/epubjs] file not found ${input}`)
26
+ }
9
27
  }
@@ -8,29 +8,33 @@ const __dirname = path.dirname(__filename)
8
8
  /**
9
9
  * A façade delegation module for EPUB libraries
10
10
  */
11
- export default async (lib = 'epubjs', options = {}) => {
12
- let libName, libPath
11
+ export default async (name = 'epubjs', options = {}) => {
12
+ const lib = { name, options, path }
13
13
 
14
- switch (lib.toLowerCase()) {
14
+ const normalizedName = name.replace(/[-_.\s]/g, '').toLowerCase()
15
+
16
+ switch (normalizedName) {
15
17
  case 'epubjs': {
16
- libName = 'Epub.js'
17
- libPath = path.join(__dirname, 'epub.js')
18
+ lib.name = 'Epub.js'
19
+ lib.options = {}
20
+ lib.path = path.join(__dirname, 'epub.js')
18
21
  break
19
22
  }
20
23
  case 'pandoc': {
21
- libName = 'Pandoc'
22
- libPath = path.join(__dirname, 'pandoc.js')
24
+ lib.name = 'Pandoc'
25
+ lib.options = {}
26
+ lib.path = path.join(__dirname, 'pandoc.js')
23
27
  break
24
28
  }
25
29
  default:
26
- console.error(`[CLI:lib/pdf] Unrecognized EPUB library '${lib}'`)
30
+ console.error(`[CLI:lib/pdf] Unrecognized EPUB library '${name}'`)
27
31
  return
28
32
  }
29
33
 
30
- const { default: epubLib } = await dynamicImport(libPath)
34
+ const { default: epubLib } = await dynamicImport(lib.path)
31
35
 
32
- return async (input, output, options = {}) => {
33
- console.info(`[CLI:lib/epub] generating EPUB using ${libName}`)
34
- return await epubLib(input, output, options)
36
+ return async (input, output) => {
37
+ console.info(`[CLI:lib/epub] generating EPUB using ${lib.name}`)
38
+ return await epubLib(input, output, lib.options)
35
39
  }
36
40
  }
@@ -20,7 +20,7 @@ const xhtmlFiles = (dirent) => {
20
20
  * A façade module for interacting with Pandoc CLI.
21
21
  * @see https://pandoc.org/MANUAL.html#general-options
22
22
  */
23
- export default async (input, output, options) => {
23
+ export default async (input, output, options = {}) => {
24
24
  which('pandoc')
25
25
 
26
26
  const inputs = fs.readdirSync(input)
@@ -8,31 +8,35 @@ const __dirname = path.dirname(__filename)
8
8
  /**
9
9
  * A façade delegation module for PDF generation libraries
10
10
  */
11
- export default async (lib = 'pagedjs', options = {}) => {
12
- let libName, libPath
11
+ export default async (name = 'pagedjs', options = {}) => {
12
+ const lib = { name, options, path }
13
13
 
14
- switch (lib.toLowerCase()) {
14
+ const normalizedName = name.replace(/[-_.\s]/g, '').toLowerCase()
15
+
16
+ switch (normalizedName) {
15
17
  case 'paged':
16
18
  case 'pagedjs': {
17
- libName = 'Paged.js'
18
- libPath = path.join(__dirname, 'paged.js')
19
+ lib.name = 'Paged.js'
20
+ lib.options = { debug: options.debug }
21
+ lib.path = path.join(__dirname, 'paged.js')
19
22
  break
20
23
  }
21
24
  case 'prince':
22
25
  case 'princexml': {
23
- libName = 'Prince'
24
- libPath = path.join(__dirname, 'prince.js')
26
+ lib.name = 'Prince'
27
+ lib.options = { debug: options.debug, verbose: options.verbose }
28
+ lib.path = path.join(__dirname, 'prince.js')
25
29
  break
26
30
  }
27
31
  default:
28
- console.error(`[CLI:lib/pdf] Unrecognized PDF library '${lib}'`)
32
+ console.error(`[CLI:lib/pdf] Unrecognized PDF library '${name}'`)
29
33
  return
30
34
  }
31
35
 
32
- const { default: pdfLib } = await dynamicImport(libPath)
36
+ const { default: pdfLib } = await dynamicImport(lib.path)
33
37
 
34
- return async (input, output, options = {}) => {
35
- console.info(`[CLI:lib/pdf] generating PDF using ${libName}`)
36
- return await pdfLib(input, output, options)
38
+ return async (input, output) => {
39
+ console.info(`[CLI:lib/pdf] generating PDF using ${lib.name}`)
40
+ return await pdfLib(input, output, lib.options)
37
41
  }
38
42
  }