@thegetty/quire-cli 1.0.0-rc.35 → 1.0.0-rc.37

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.
Files changed (159) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +9 -0
  3. package/bin/cli.js +19 -1
  4. package/package.json +21 -8
  5. package/patches/README.md +19 -0
  6. package/patches/install-npm-version+1.0.9.patch +12119 -0
  7. package/schemas/objects.schema.json +12 -38
  8. package/schemas/publication.schema.json +0 -22
  9. package/schemas/references.schema.json +0 -1
  10. package/src/Command.js +26 -6
  11. package/src/Command.spec.js +99 -0
  12. package/src/commands/README.md +213 -122
  13. package/src/commands/build.js +37 -36
  14. package/src/commands/build.spec.js +113 -0
  15. package/src/commands/build.test.js +397 -0
  16. package/src/commands/clean.js +25 -19
  17. package/src/commands/clean.spec.js +108 -0
  18. package/src/commands/clean.test.js +260 -0
  19. package/src/commands/config.js +251 -0
  20. package/src/commands/config.spec.js +107 -0
  21. package/src/commands/config.test.js +715 -0
  22. package/src/commands/create.js +42 -14
  23. package/src/commands/create.spec.js +112 -0
  24. package/src/commands/create.test.js +415 -0
  25. package/src/commands/epub.js +59 -30
  26. package/src/commands/epub.spec.js +114 -0
  27. package/src/commands/epub.test.js +503 -0
  28. package/src/commands/index.js +9 -2
  29. package/src/commands/info.js +18 -24
  30. package/src/commands/info.spec.js +64 -0
  31. package/src/commands/info.test.js +415 -0
  32. package/src/commands/pdf.js +58 -84
  33. package/src/commands/pdf.spec.js +114 -0
  34. package/src/commands/pdf.test.js +464 -0
  35. package/src/commands/preview.js +32 -31
  36. package/src/commands/preview.spec.js +97 -0
  37. package/src/commands/preview.test.js +250 -0
  38. package/src/commands/use.js +56 -0
  39. package/src/commands/use.spec.js +61 -0
  40. package/src/commands/use.test.js +280 -0
  41. package/src/commands/validate.js +31 -19
  42. package/src/commands/validate.spec.js +82 -0
  43. package/src/commands/validate.test.js +234 -0
  44. package/src/commands/workflows.js +70 -0
  45. package/src/errors/build/build-failed-error.js +19 -0
  46. package/src/errors/build/config-field-missing-error.js +20 -0
  47. package/src/errors/build/config-file-not-found-error.js +20 -0
  48. package/src/errors/build/index.js +11 -0
  49. package/src/errors/index.js +48 -0
  50. package/src/errors/install/dependency-install-error.js +19 -0
  51. package/src/errors/install/directory-not-empty-error.js +25 -0
  52. package/src/errors/install/index.js +12 -0
  53. package/src/errors/install/invalid-path-error.js +31 -0
  54. package/src/errors/install/invalid-starter-error.js +27 -0
  55. package/src/errors/install/version-not-found-error.js +35 -0
  56. package/src/errors/output/epub-generation-error.js +19 -0
  57. package/src/errors/output/index.js +14 -0
  58. package/src/errors/output/invalid-epub-library-error.js +20 -0
  59. package/src/errors/output/invalid-pdf-library-error.js +20 -0
  60. package/src/errors/output/missing-build-output-error.js +21 -0
  61. package/src/errors/output/pdf-generation-error.js +24 -0
  62. package/src/errors/output/tool-not-found-error.js +37 -0
  63. package/src/errors/project/index.js +10 -0
  64. package/src/errors/project/not-in-project-error.js +20 -0
  65. package/src/errors/project/project-create-error.js +21 -0
  66. package/src/errors/quire-error.js +27 -0
  67. package/src/errors/validation/validation-error.js +20 -11
  68. package/src/helpers/clean.js +1 -1
  69. package/src/helpers/docs-url.js +32 -0
  70. package/src/helpers/test-cwd.js +5 -6
  71. package/src/helpers/test-cwd.test.js +192 -0
  72. package/src/helpers/which.js +10 -4
  73. package/src/lib/11ty/README.md +135 -19
  74. package/src/lib/11ty/api.js +196 -94
  75. package/src/lib/11ty/cli.js +91 -37
  76. package/src/lib/11ty/index.js +64 -5
  77. package/src/lib/11ty/index.test.js +655 -0
  78. package/src/lib/README.md +275 -0
  79. package/src/lib/commander/index.js +100 -0
  80. package/src/lib/commander/index.test.js +86 -0
  81. package/src/lib/commander/options.js +195 -0
  82. package/src/lib/commander/options.test.js +109 -0
  83. package/src/lib/conf/README.md +84 -73
  84. package/src/lib/conf/config.js +5 -3
  85. package/src/lib/conf/config.test.js +281 -0
  86. package/src/lib/conf/defaults.js +44 -0
  87. package/src/lib/conf/format.js +60 -0
  88. package/src/lib/conf/format.test.js +106 -0
  89. package/src/lib/conf/helpers.js +91 -0
  90. package/src/lib/conf/helpers.test.js +136 -0
  91. package/src/lib/conf/index.js +22 -0
  92. package/src/lib/conf/schema.js +53 -8
  93. package/src/lib/epub/README.md +133 -2
  94. package/src/lib/epub/engines.js +46 -0
  95. package/src/lib/epub/epub.js +36 -11
  96. package/src/lib/epub/index.js +111 -21
  97. package/src/lib/epub/index.test.js +518 -0
  98. package/src/lib/epub/pandoc.js +33 -4
  99. package/src/lib/epub/pandoc.test.js +122 -0
  100. package/src/lib/epub/schema.js +21 -0
  101. package/src/lib/error/README.md +170 -0
  102. package/src/lib/error/handler.js +107 -0
  103. package/src/lib/git/README.md +151 -2
  104. package/src/lib/git/index.js +217 -13
  105. package/src/lib/git/index.spec.js +80 -0
  106. package/src/lib/git/index.test.js +453 -0
  107. package/src/lib/installer/index.js +309 -0
  108. package/src/lib/installer/index.spec.js +83 -0
  109. package/src/lib/installer/index.test.js +545 -0
  110. package/src/lib/logger/README.md +424 -0
  111. package/src/lib/logger/debug.js +132 -0
  112. package/src/lib/logger/debug.spec.js +130 -0
  113. package/src/lib/logger/debug.test.js +128 -0
  114. package/src/lib/logger/index.js +228 -0
  115. package/src/lib/logger/index.spec.js +131 -0
  116. package/src/lib/logger/index.test.js +477 -0
  117. package/src/lib/npm/README.md +127 -0
  118. package/src/lib/npm/index.js +198 -0
  119. package/src/lib/npm/index.spec.js +60 -0
  120. package/src/lib/npm/index.test.js +355 -0
  121. package/src/lib/pdf/README.md +131 -0
  122. package/src/lib/pdf/engines.js +46 -0
  123. package/src/lib/pdf/index.js +124 -21
  124. package/src/lib/pdf/index.test.js +708 -0
  125. package/src/lib/pdf/paged.js +100 -52
  126. package/src/lib/pdf/paged.test.js +366 -0
  127. package/src/lib/pdf/prince.js +115 -37
  128. package/src/lib/pdf/prince.test.js +202 -0
  129. package/src/lib/pdf/schema.js +21 -0
  130. package/src/lib/pdf/split.js +61 -33
  131. package/src/lib/pdf/split.test.js +445 -0
  132. package/src/lib/process/manager.js +110 -0
  133. package/src/lib/process/manager.test.js +55 -0
  134. package/src/lib/project/build.js +143 -0
  135. package/src/lib/project/build.test.js +253 -0
  136. package/src/lib/project/config.js +48 -0
  137. package/src/lib/project/config.test.js +134 -0
  138. package/src/{helpers/is-quire.js → lib/project/detect.js} +5 -3
  139. package/src/lib/project/detect.test.js +157 -0
  140. package/src/lib/project/index.js +40 -0
  141. package/src/lib/project/paths.js +224 -0
  142. package/src/lib/project/version.js +110 -0
  143. package/src/lib/project/version.test.js +350 -0
  144. package/src/lib/reporter/README.md +211 -2
  145. package/src/lib/reporter/index.js +512 -0
  146. package/src/lib/reporter/index.test.js +593 -0
  147. package/src/main.js +134 -47
  148. package/src/main.spec.js +61 -0
  149. package/src/main.test.js +347 -0
  150. package/src/validators/utils.js +2 -1
  151. package/src/commands/conf.js +0 -43
  152. package/src/commands/version.js +0 -43
  153. package/src/lib/11ty/paths.js +0 -103
  154. package/src/lib/i18n/README.md +0 -3
  155. package/src/lib/i18n/config.js +0 -53
  156. package/src/lib/i18n/index.js +0 -43
  157. package/src/lib/i18n/localeService.js +0 -58
  158. package/src/lib/quire/README.md +0 -19
  159. package/src/lib/quire/index.js +0 -350
@@ -1,43 +0,0 @@
1
- import Command from '#src/Command.js'
2
-
3
- /**
4
- * Quire CLI `conf` Command
5
- *
6
- * @class ConfCommand
7
- * @extends {Command}
8
- */
9
- export default class ConfCommand extends Command {
10
- static definition = {
11
- name: 'conf',
12
- aliases: ['config', 'configure'],
13
- description: 'Manage the Quire CLI configuration.',
14
- summary: 'read/write quire-cli configuration options',
15
- version: '1.0.0',
16
- options: [
17
- [ '--debug', 'run command in debug mode' ],
18
- ],
19
- }
20
-
21
- constructor() {
22
- super(ConfCommand.definition)
23
- }
24
-
25
- /**
26
- * @param {Object} options
27
- * @return {Promise}
28
- */
29
- async action(key, value, options = {}) {
30
- if (options.debug) {
31
- console.info('Command \'%s\' called with options %o', this.name(), options)
32
- }
33
-
34
- // this.outputHelp()
35
-
36
- console.info('quire-cli configuration %s', this.config.path)
37
-
38
- for (const [ key, value ] of Object.entries(this.config.store)) {
39
- if (key.startsWith('__internal__') && !options.debug) continue
40
- console.info('%s: %O', key, value)
41
- }
42
- }
43
- }
@@ -1,43 +0,0 @@
1
- import Command from '#src/Command.js'
2
- import { paths, projectRoot } from '#lib/11ty/index.js'
3
- import * as quire from '#lib/quire/index.js'
4
- import testcwd from '#helpers/test-cwd.js'
5
-
6
- /**
7
- * Quire CLI `version` Command
8
- *
9
- * Running `quire version` sets the `quire-11ty` version for a project.
10
- * The version is written to a `.quire` file in the project directory
11
- * or to the `quire-cli` package `.quire` when the `global` flag is used.
12
- *
13
- * @class VersionCommand
14
- * @extends {Command}
15
- */
16
- export default class VersionCommand extends Command {
17
- static definition = {
18
- name: 'version',
19
- description: 'Sets the Quire version to use when running commands on the project.',
20
- summary: 'set the @thegetty/quire-11ty version',
21
- version: '1.0.0',
22
- args: [
23
- [ '<version>', 'the local quire version to use' ],
24
- ],
25
- options: [
26
- // [ '-g', '--global', 'set the quire version globally' ],
27
- ],
28
- }
29
-
30
- constructor() {
31
- super(VersionCommand.definition)
32
- }
33
-
34
- action(args, options = {}) {
35
- if (options.debug) {
36
- console.info('Command \'%s\' called with options %o', this.name, options)
37
- }
38
- }
39
-
40
- preAction(command) {
41
- testcwd(command)
42
- }
43
- }
@@ -1,103 +0,0 @@
1
- import { fileURLToPath } from 'node:url'
2
- import fs from 'fs-extra'
3
- import path from 'node:path'
4
-
5
- const __filename = fileURLToPath(import.meta.url)
6
- const __dirname = path.dirname(__filename)
7
-
8
- /**
9
- * Eleventy configuration paths
10
- * @see https://www.11ty.dev/docs/config/#configuration-options
11
- *
12
- * Resolve the absolute path to the Eleventy configuration module,
13
- * `eleventyRoot` is _relative_ to `main.js`, the CLI entry point.
14
- * Both `input` and `output` are _relative_ to the `config` module.
15
- *
16
- * @todo
17
- * - refactor the paths module as a concern of the `lib/quire` module
18
- * - refactor resolving an absolute path to the correct eleventy version root;
19
- * this needs to use the correct `quire-11ty` version for the project
20
- * and correctly resolve the path to the target of the 'latest' symlink
21
- */
22
- const cliRoot = path.resolve(__dirname, path.join('..', '..'))
23
- const eleventyConfig = '.eleventy.js'
24
- const version = 'latest'
25
-
26
- export const projectRoot = process.cwd()
27
-
28
- /**
29
- * Absolute path to the latest installed version of `quire-11ty`
30
- * @todo use version read from the project `.quire-version` file
31
- */
32
- const libQuirePath = path.resolve(__dirname, path.join(cliRoot, 'lib', 'quire', 'versions', version))
33
-
34
- /**
35
- * Absolute path to the current version of `quire-11ty`
36
- * Nota bene: to get a relative path to the `eleventyRoot`,
37
- * for example when the version is specified is 'latest',
38
- * it must be set to the real path to the symlink target.
39
- *
40
- * @todo refactor how and *when* the eleventyRoot is determined:
41
- * - we only need eleventyRoot for cli commands that run 11ty
42
- * - paths module is a concern of the `quire` module
43
- * - global quire-cli installation
44
- * - local quire-cli installation
45
- *
46
- * For an excellent developer experience, the quire-11ty code should be
47
- * installed into an `11ty` or `quire-11ty` directory in the `projectRoot`
48
- * this will allow us to more easily manage symlinks for local development
49
- * using unpublished `quire-11ty` code.
50
- * @example
51
- * ```sh
52
- * blargh/
53
- * .git/
54
- * .gitignore
55
- * .node-version
56
- * .quire-version
57
- * 11ty@ --> /Users/mph/Code/Getty/quire/packages/11ty
58
- * content/
59
- * CHANGELOG.md
60
- * LICENSE
61
- * README.md
62
- * package.json
63
- * package-lock.json
64
- * ```
65
- * Installing to a directory will allow more cleanly `eject` and `uneject`
66
- * using a symlink or single directory `rm -rf`.
67
- * Should the `11ty` directory be a dot directory to hide the complexity from
68
- * users or should it be visible to be more explicit when project is ejected?
69
- */
70
- const getEleventyRoot = () => {
71
- // try {
72
- // return fs.readdirSync(projectRoot).includes(eleventyConfig)
73
- // ? projectRoot
74
- // : fs.realpathSync(libQuirePath)
75
- // } catch (error) {
76
- // throw new Error(`[CLI:11ty] Unable to read project directory for eleventy config ${error}`)
77
- // }
78
- return projectRoot
79
- }
80
-
81
- export const eleventyRoot = getEleventyRoot()
82
-
83
- const inputDir = path.join(projectRoot, 'content')
84
-
85
- export default {
86
- /**
87
- * An abolsute path to eleventy config module
88
- */
89
- config: path.join(eleventyRoot, '.eleventy.js'),
90
- /**
91
- * Paths _relative to_ the eleventy config module
92
- */
93
- input: path.relative(eleventyRoot, inputDir),
94
- output: path.relative(eleventyRoot, path.join(projectRoot, '_site')),
95
- epub: path.relative(eleventyRoot, path.join(projectRoot, '_epub')),
96
- /**
97
- * Paths _relative to_ the `input` directory
98
- */
99
- data: '_computed',
100
- includes: path.relative(inputDir, path.join(eleventyRoot, '_includes')),
101
- layouts: path.relative(inputDir, path.join(eleventyRoot, '_layouts')),
102
- public: './public',
103
- }
@@ -1,3 +0,0 @@
1
- ## CLI Internationalization (i18n) & Localization Module
2
-
3
- This `quire-cli/lib/i18n` module manages localized message strings for the `quire-cli` and implements a façade for a separate i18n service.
@@ -1,53 +0,0 @@
1
- /**
2
- * i18next configuration
3
- * @see https://www.i18next.com/overview/configuration-options
4
- *
5
- * @todo
6
- * set debug using cli `--debug` option
7
- * set resources by loading data files
8
- */
9
- const configuration = {
10
- debug: true,
11
- /**
12
- * Languages
13
- */
14
- fallbackLng: 'en',
15
- lng: 'en',
16
- supportedLngs: ['en'],
17
- /**
18
- * Namespaces
19
- */
20
- defaultNS: 'translation',
21
- fallbackNS: false,
22
- ns: 'translation',
23
- /**
24
- * Resources
25
- */
26
- partialBundledLanguages: false,
27
- resources: {
28
- en: {
29
- translation: {
30
- 'gradoo': 'blargh',
31
- }
32
- },
33
- },
34
- /**
35
- * Missing Keys
36
- * @ https://www.i18next.com/overview/configuration-options#missing-keys
37
- */
38
- saveMissing: false,
39
- /**
40
- * Translation defaults
41
- * @ https://www.i18next.com/overview/configuration-options#translation-defaults
42
- */
43
-
44
- /**
45
- * Plugin options
46
- * @see https://www.i18next.com/overview/configuration-options#plugin-options
47
- */
48
-
49
- /**
50
- * Other
51
- * @see https://www.i18next.com/overview/configuration-options#others
52
- */
53
- }
@@ -1,43 +0,0 @@
1
- import { LocaleService } from './LocaleService.js'
2
- import I18nextCLILanguageDetector from 'i18next-cli-language-detector'
3
- import i18next from 'i18next'
4
-
5
- /**
6
- * i18next configuration
7
- * @see https://www.i18next.com/overview/configuration-options
8
- *
9
- * @todo
10
- * set debug using cli `--debug` option
11
- * set resources by loading data files
12
- */
13
- const configuration = {
14
- debug: true,
15
- /**
16
- * Languages
17
- */
18
- fallbackLng: 'en',
19
- lng: 'en',
20
- supportedLngs: ['en'],
21
- /**
22
- * Namespaces
23
- */
24
- defaultNS: 'translation',
25
- fallbackNS: false,
26
- ns: 'translation',
27
- /**
28
- * Resources
29
- */
30
- resources: {
31
- en: {
32
- translation: {
33
- 'gradoo': 'blargh',
34
- }
35
- },
36
- },
37
- }
38
-
39
- await i18next
40
- .use(I18nextCLILanguageDetector)
41
- .init(configuration)
42
-
43
- export default new LocaleService(i18next)
@@ -1,58 +0,0 @@
1
- /**
2
- * Localization service
3
- *
4
- * @class LocaleService
5
- */
6
- export class LocaleService {
7
- /**
8
- * @param {Object} i18nProvider
9
- */
10
- constructor(i18nProvider) {
11
- this.i18nProvider = i18nProvider
12
- }
13
-
14
- /**
15
- * Gets the current locale
16
- *
17
- * @return {String} current locale code
18
- */
19
- getCurrentLocale() {
20
- return this.i18nProvider.getLocale()
21
- }
22
-
23
- /**
24
- * Get a list of supported locales
25
- *
26
- * @return {Array} List of supported locale codes
27
- */
28
- getLocales() {
29
- return this.i18nProvider.getLocales()
30
- }
31
-
32
- /**
33
- * Sets the current locale
34
- *
35
- * @param {String} locale i18n locale code
36
- * @return {String} the current locale code
37
- */
38
- setLocale(locale) {
39
- const locales = this.getLocales()
40
- if (!locales.includes(locale)) {
41
- throw new Error(`
42
- Unknown locale code ${locale} Unable to set current locale;
43
- supported locales: ${locales}
44
- `)
45
- }
46
- return this.i18nProvider.setLocale(locale)
47
- }
48
-
49
- /**
50
- * Translate a string
51
- *
52
- * @param {String} string string to translate
53
- * @param {Object} options translation options
54
- */
55
- translate(string, options) {
56
- return this.i18nProvider.t(string)
57
- }
58
- }
@@ -1,19 +0,0 @@
1
- ## CLI Quire Module
2
-
3
- The primary concern of the Quire CLI `quire` module is to decouple the `11ty` package from the publication content templates and manage the version of the [Quire/11ty package](packages/11ty) that is used to build a Quire project.
4
-
5
- The [Quire/11ty package](packages/11ty) contains the Eleventy [configuration](packages/11ty/.eleventy.js), [includes](packages/11ty/_includes), [layouts](packages/11ty/_layouts), and [plugins](packages/11ty/_plugins) for [universal template shortcodes](packages/11ty/_plugins/shortcodes) and [components](packages/11ty/_includes/components) to build Quire publications.
6
-
7
- When the Quire CLI is installed the latest version of the [11ty package](packages/11ty) is installed in in the `cli/quire/versions/` directory.
8
-
9
- ```sh
10
- cli/
11
- quire/
12
- versions/
13
- 1.0.0/
14
- _includes/
15
- _layouts/
16
- _plugins/
17
- .eleventy.js
18
- package.json
19
- ```