@thegetty/quire-cli 1.0.0-pre-release.8 → 1.0.0-pre-release.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/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.8",
4
+ "version": "1.0.0-pre-release.10",
5
5
  "author": "Getty Digital",
6
6
  "license": "J Paul Getty Trust",
7
7
  "bugs": {
@@ -1,4 +1,5 @@
1
- import { fileURLToPath } from 'node:url'
1
+ import { IS_WINDOWS } from '#helpers/os-utils.js'
2
+ import { fileURLToPath, pathToFileURL } from 'node:url'
2
3
  import fs from 'fs-extra'
3
4
  import path from 'node:path'
4
5
 
@@ -14,7 +15,10 @@ const thisfile = path.basename(__filename)
14
15
  const commands = await Promise.all(
15
16
  fs.readdirSync(__dirname)
16
17
  .filter((file) => file !== thisfile && file.match(/^.*\.js$/))
17
- .map((file) => import(path.resolve(__dirname, file)))
18
+ .map((file) => IS_WINDOWS
19
+ ? import(pathToFileURL(path.resolve(__dirname, file)))
20
+ : import(path.resolve(__dirname, file))
21
+ )
18
22
  ).then((modules) => {
19
23
  return modules.map(({ default: CommandClass }) => new CommandClass())
20
24
  })
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Determine if the process is running on Windows operating system
3
+ */
4
+ export const IS_WINDOWS =
5
+ process.platform === 'win32' || /^(cygwin|msys)$/.test(process.env.OSTYPE)
@@ -1,3 +1,5 @@
1
+ import { IS_WINDOWS } from '#helpers/os-utils.js'
2
+ import { pathToFileURL } from 'node:url'
1
3
  import path from 'node:path'
2
4
  import paths, { eleventyRoot, projectRoot } from './paths.js'
3
5
 
@@ -18,7 +20,10 @@ const factory = async (options = {}) => {
18
20
  /**
19
21
  * Dynamically import the correct version of Eleventy from `lib/quire/versions`
20
22
  */
21
- const { default: Eleventy } = await import(path.join(eleventyRoot, 'node_modules', '@11ty', 'eleventy', 'src', 'Eleventy.js'))
23
+ const modulePath = path.join(eleventyRoot, 'node_modules', '@11ty', 'eleventy', 'src', 'Eleventy.js')
24
+ const { default: Eleventy } = IS_WINDOWS
25
+ ? await import(pathToFileURL(modulePath))
26
+ : await import(modulePath)
22
27
 
23
28
  /**
24
29
  * Set Eleventy passthrough copy options
@@ -89,6 +94,7 @@ export default {
89
94
  console.info('[CLI:11ty] running eleventy build')
90
95
  console.info(`[CLI:11ty] projectRoot ${projectRoot}`)
91
96
 
97
+ process.env.ELEVENTY_ENV = 'production'
92
98
  if (options.debug) process.env.DEBUG = 'Eleventy*'
93
99
 
94
100
  const eleventy = await factory(options)
@@ -100,6 +106,7 @@ export default {
100
106
  serve: async (options = {}) => {
101
107
  console.info('[CLI:11ty] running development server')
102
108
 
109
+ process.env.ELEVENTY_ENV = 'development'
103
110
  if (options.debug) process.env.DEBUG = 'Eleventy*'
104
111
 
105
112
  const eleventy = await factory(options)
@@ -43,13 +43,15 @@ export default {
43
43
  build: async (options = {}) => {
44
44
  console.info('[CLI:11ty] running eleventy build')
45
45
 
46
- const eleventyCommand = factory()
46
+ const eleventyCommand = factory(options)
47
47
 
48
48
  /**
49
49
  * Set execa environment variables
50
50
  * @see https://github.com/sindresorhus/execa#env
51
51
  */
52
- const execaEnv = {}
52
+ const execaEnv = {
53
+ ELEVENTY_ENV: 'production'
54
+ }
53
55
 
54
56
  if (options.debug) execaEnv.DEBUG = 'Eleventy*'
55
57
 
@@ -74,7 +76,9 @@ export default {
74
76
  * Set execa environment variables
75
77
  * @see https://github.com/sindresorhus/execa#env
76
78
  */
77
- const execaEnv = {}
79
+ const execaEnv = {
80
+ ELEVENTY_ENV: 'development'
81
+ }
78
82
 
79
83
  if (options.debug) execaEnv.DEBUG = 'Eleventy*'
80
84
 
@@ -1,3 +1,4 @@
1
+ import { IS_WINDOWS } from '#helpers/os-utils.js'
1
2
  import { chdir, cwd } from 'node:process'
2
3
  import { execa, execaCommand } from 'execa'
3
4
  import { fileURLToPath } from 'node:url'
@@ -16,9 +17,6 @@ const INSTALL_PATH = path.join('src', 'lib', 'quire', 'versions')
16
17
  const PACKAGE_NAME = '@thegetty/quire-11ty'
17
18
  const VERSION_FILE = '.quire'
18
19
 
19
- const IS_WINDOWS =
20
- process.platform === 'win32' || /^(cygwin|msys)$/.test(process.env.OSTYPE)
21
-
22
20
  /**
23
21
  * Return an absolute path to an installed `quire-11ty` version
24
22
  *
@@ -30,7 +28,7 @@ function getPath(version='latest') {
30
28
  console.error(`[CLI:quire] \`quire-11ty@${version}\` is not installed`)
31
29
  return null
32
30
  }
33
- console.debug(`[CLI:quire] \%`, absolutePath)
31
+ console.debug(`[CLI:quire] %s`, absolutePath)
34
32
  return absolutePath
35
33
  }
36
34