@thegetty/quire-cli 1.0.0-pre-release.3 → 1.0.0-pre-release.4

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/README.md CHANGED
@@ -9,3 +9,10 @@ The `quire-cli` implements the [command pattern](https://en.wikipedia.org/wiki/C
9
9
  ```sh
10
10
  npx quire-cli --help
11
11
  ```
12
+
13
+
14
+ #### Microsoft Windows
15
+
16
+ https://learnshareit.com/how-to-solve-nodemon-ps1-cannot-be-loaded-because-running-scripts-is-disabled-on-this-system-in-nodejs/
17
+
18
+ See [Microsoft About Execution Policies](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7.3)
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.3",
4
+ "version": "1.0.0-pre-release.4",
5
5
  "author": "Getty Digital",
6
6
  "license": "J Paul Getty Trust",
7
7
  "bugs": {
@@ -8,7 +8,7 @@ import paths, { eleventyRoot, projectRoot } from './paths.js'
8
8
  * @param {Object} options Eleventy configuration options
9
9
  * @return {Eleventy} A configured instance of Eleventy
10
10
  */
11
- const factory = async (options) => {
11
+ const factory = async (options = {}) => {
12
12
  const { config, input, output } = paths
13
13
 
14
14
  console.info(`[CLI:11ty] projectRoot ${projectRoot}`)
@@ -20,13 +20,61 @@ const factory = async (options) => {
20
20
  */
21
21
  const { default: Eleventy } = await import(path.join(eleventyRoot, 'node_modules', '@11ty', 'eleventy', 'src', 'Eleventy.js'))
22
22
 
23
- return new Eleventy(input, output, {
23
+ /**
24
+ * Set Eleventy passthrough copy options
25
+ * @see https://www.11ty.dev/docs/copy/#advanced-options
26
+ * @see https://github.com/timkendrick/recursive-copy
27
+ */
28
+ const copyOptions = {
29
+ debug: options.debug || false,
30
+ expand: true,
31
+ }
32
+
33
+ /**
34
+ * Get an instance of the runtime of eleventy.
35
+ * @see https://github.com/11ty/eleventy/blob/src/Eleventy.js
36
+ *
37
+ * @param {String} input Path from which to read content templates
38
+ * @param {String} output Path where rendered files will be written
39
+ * @param {Object} options Options are merged with the Eleventy UserConfig
40
+ * @param {Object} config An eleventy configurtion object
41
+ *
42
+ * @returns {module:11ty/eleventy/Eleventy~Eleventy}
43
+ */
44
+ const eleventy = new Eleventy(input, output, {
24
45
  config: (eleventyConfig) => {
25
- // custom configuration
46
+ /**
47
+ * Override addPassthroughCopy to use _absolute_ system paths.
48
+ * @see https://www.11ty.dev/docs/copy/#passthrough-file-copy
49
+ * Nota bene: Eleventy addPassthroughCopy assumes paths are _relative_
50
+ * to the `config` file however the quire-cli separates 11ty from the
51
+ * project directory (`input`) and needs to use absolute system paths.
52
+ */
53
+ const addPassthroughCopy = eleventyConfig.addPassthroughCopy.bind(eleventyConfig)
54
+ eleventyConfig.addPassthroughCopy = (entry) => {
55
+ if (typeof entry === 'string') {
56
+ const filePath = path.resolve(entry) //path.join(projectRoot, file)
57
+ // console.debug('[11ty:API] passthrough copy %s', filePath)
58
+ return addPassthroughCopy(filePath, copyOptions)
59
+ } else {
60
+ // console.debug('[11ty:API] passthrough copy %o', entry)
61
+ entry = Object.fromEntries(
62
+ Object.entries(entry).map(([ src, dest ]) => {
63
+ return [ path.join(eleventyRoot, src), path.resolve(dest) ]
64
+ })
65
+ )
66
+ // console.debug('[11ty:API] passthrough copy %o', entry)
67
+ return addPassthroughCopy(entry, copyOptions)
68
+ }
69
+ }
70
+ return eleventyConfig
26
71
  },
27
72
  configPath: options.config || config,
28
73
  quietMode: options.quiet || false,
74
+ // source: 'script',
29
75
  })
76
+
77
+ return eleventy
30
78
  }
31
79
 
32
80
  /**
@@ -44,6 +92,9 @@ export default {
44
92
  if (options.debug) process.env.DEBUG = 'Eleventy*'
45
93
 
46
94
  const eleventy = await factory(options)
95
+
96
+ eleventy.setDryRun(options.dryrun)
97
+
47
98
  await eleventy.executeBuild()
48
99
  },
49
100
  serve: async (options = {}) => {
@@ -52,6 +103,7 @@ export default {
52
103
  if (options.debug) process.env.DEBUG = 'Eleventy*'
53
104
 
54
105
  const eleventy = await factory(options)
55
- await eleventy.serve()
106
+
107
+ await eleventy.serve(options.port)
56
108
  }
57
109
  }
@@ -1,7 +1,6 @@
1
1
  import { execa } from 'execa'
2
- import { fileURLToPath } from 'node:url'
3
2
  import path from 'node:path'
4
- import paths, { projectRoot } from './paths.js'
3
+ import paths, { eleventyRoot, projectRoot } from './paths.js'
5
4
 
6
5
  /**
7
6
  * A factory function to configure an Eleventy CLI command
@@ -9,20 +8,31 @@ import paths, { projectRoot } from './paths.js'
9
8
  * @param {Object} options Eleventy configuration options
10
9
  * @return {Array} Eleventy CLI options
11
10
  */
12
- const factory = () => {
11
+ const factory = (options = {}) => {
13
12
  const { config, input, output } = paths
14
13
 
15
14
  console.info(`[CLI:11ty] projectRoot ${projectRoot}`)
16
15
 
17
16
  console.debug('[CLI:11ty] %o', paths)
18
17
 
19
- return [
20
- `@11ty/eleventy`,
18
+ /**
19
+ * Use the version of Eleventy installed to `lib/quire/versions`
20
+ */
21
+ const eleventy =
22
+ path.join(eleventyRoot, 'node_modules', '@11ty', 'eleventy', 'cmd.js')
23
+
24
+ const command = [
25
+ eleventy,
21
26
  `--config=${config}`,
22
27
  `--input=${input}`,
23
28
  `--output=${output}`,
24
29
  `--incremental`,
25
30
  ]
31
+
32
+ if (options.quiet) command.push('--quiet')
33
+ if (options.verbose) command.push('--verbose')
34
+
35
+ return command
26
36
  }
27
37
 
28
38
  /**
@@ -33,7 +43,7 @@ export default {
33
43
  build: async (options = {}) => {
34
44
  console.info('[CLI:11ty] running eleventy build')
35
45
 
36
- const eleventyOptions = factory()
46
+ const eleventyCommand = factory()
37
47
 
38
48
  /**
39
49
  * Set execa environment variables
@@ -42,10 +52,10 @@ export default {
42
52
  const execaEnv = {}
43
53
 
44
54
  if (options.debug) execaEnv.DEBUG = 'Eleventy*'
45
- if (options.dryRun) eleventyOptions.push('--dryrun')
46
- if (options.quiet) eleventyOptions.push('--quiet')
47
55
 
48
- await execa('npx', eleventyOptions, {
56
+ if (options.dryRun) eleventyCommand.push('--dryrun')
57
+
58
+ await execa('node', eleventyCommand, {
49
59
  all: true,
50
60
  cwd: projectRoot,
51
61
  env: execaEnv,
@@ -56,9 +66,9 @@ export default {
56
66
  serve: async (options = {}) => {
57
67
  console.info(`[CLI:11ty] running eleventy serve`)
58
68
 
59
- const eleventyOptions = factory()
69
+ const eleventyCommand = factory(options)
60
70
 
61
- eleventyOptions.push('--serve')
71
+ eleventyCommand.push('--serve')
62
72
 
63
73
  /**
64
74
  * Set execa environment variables
@@ -67,11 +77,10 @@ export default {
67
77
  const execaEnv = {}
68
78
 
69
79
  if (options.debug) execaEnv.DEBUG = 'Eleventy*'
70
- if (options.port) eleventyOptions.push(`--port=${options.port}`)
71
- if (options.quiet) eleventyOptions.push('--quiet')
72
- if (options.verbose) eleventyOptions.push('--verbose')
73
80
 
74
- await execa('npx', eleventyOptions, {
81
+ if (options.port) eleventyCommand.push(`--port=${options.port}`)
82
+
83
+ await execa('node', eleventyCommand, {
75
84
  all: true,
76
85
  cwd: projectRoot,
77
86
  env: execaEnv,