netlify-cli 14.0.0-rc → 14.0.0

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/src/utils/dev.mjs CHANGED
@@ -137,30 +137,40 @@ const getEnvSourceName = (source) => {
137
137
  return printFn(name)
138
138
  }
139
139
 
140
- // Takes a set of environment variables in the format provided by @netlify/config, augments it with variables from both
141
- // dot-env files and the process itself, and injects into `process.env`.
142
- export const injectEnvVariables = async ({ devConfig, env, site }) => {
143
- const environment = new Map(Object.entries(env))
140
+ /**
141
+ * @param {{devConfig: any, env: Record<string, { sources: string[], value: string}>, site: any}} param0
142
+ * @returns {Promise<Record<string, { sources: string[], value: string}>>}
143
+ */
144
+ export const getDotEnvVariables = async ({ devConfig, env, site }) => {
144
145
  const dotEnvFiles = await loadDotEnvFiles({ envFiles: devConfig.envFiles, projectDir: site.root })
145
-
146
146
  dotEnvFiles.forEach(({ env: fileEnv, file }) => {
147
+ const newSourceName = `${file} file`
148
+
147
149
  Object.keys(fileEnv).forEach((key) => {
148
- const newSourceName = `${file} file`
149
- const sources = environment.has(key) ? [newSourceName, ...environment.get(key).sources] : [newSourceName]
150
+ const sources = key in env ? [newSourceName, ...env[key].sources] : [newSourceName]
150
151
 
151
152
  if (sources.includes('internal')) {
152
153
  return
153
154
  }
154
155
 
155
- environment.set(key, {
156
+ env[key] = {
156
157
  sources,
157
158
  value: fileEnv[key],
158
- })
159
+ }
159
160
  })
160
161
  })
161
162
 
163
+ return env
164
+ }
165
+
166
+ /**
167
+ * Takes a set of environment variables in the format provided by @netlify/config and injects them into `process.env`
168
+ * @param {Record<string, { sources: string[], value: string}>} env
169
+ * @return {void}
170
+ */
171
+ export const injectEnvVariables = (env) => {
162
172
  // eslint-disable-next-line fp/no-loops
163
- for (const [key, variable] of environment) {
173
+ for (const [key, variable] of Object.entries(env)) {
164
174
  const existsInProcess = process.env[key] !== undefined
165
175
  const [usedSource, ...overriddenSources] = existsInProcess ? ['process', ...variable.sources] : variable.sources
166
176
  const usedSourceName = getEnvSourceName(usedSource)
@@ -1,7 +1,6 @@
1
1
  // @ts-check
2
2
  import { readFile } from 'fs/promises'
3
3
 
4
- import { get } from 'dot-prop'
5
4
  import { locatePath } from 'locate-path'
6
5
  import nodeVersionAlias from 'node-version-alias'
7
6
 
@@ -18,10 +17,10 @@ export const detectNodeVersion = async ({ baseDirectory, env }) => {
18
17
  try {
19
18
  const nodeVersionFile = await locatePath(['.nvmrc', '.node-version'], { cwd: baseDirectory })
20
19
  const configuredVersion =
21
- nodeVersionFile === undefined ? get(env, 'NODE_VERSION.value') : await readFile(nodeVersionFile, 'utf8')
20
+ nodeVersionFile === undefined ? env.NODE_VERSION?.value : await readFile(nodeVersionFile, 'utf8')
22
21
 
23
22
  const version =
24
- configuredVersion === undefined
23
+ configuredVersion === undefined || configuredVersion === null
25
24
  ? DEFAULT_NODE_VERSION
26
25
  : await nodeVersionAlias(normalizeConfiguredVersion(configuredVersion))
27
26
 
@@ -111,7 +111,7 @@ export const startLiveTunnel = async ({ localPort, netlifyApiToken, siteId }) =>
111
111
  return data.state === 'online'
112
112
  }
113
113
 
114
- await connectTunnel({ session, netlifyApiToken, localPort })
114
+ connectTunnel({ session, netlifyApiToken, localPort })
115
115
 
116
116
  // Waiting for the live session to have a state of `online`.
117
117
  await pWaitFor(isLiveTunnelReady, {