netlify-cli 9.6.12 → 9.7.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.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "netlify-cli",
3
- "version": "9.6.12",
3
+ "version": "9.7.0",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "netlify-cli",
9
- "version": "9.6.12",
9
+ "version": "9.7.0",
10
10
  "hasInstallScript": true,
11
11
  "license": "MIT",
12
12
  "dependencies": {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "netlify-cli",
3
3
  "description": "Netlify command line tool",
4
- "version": "9.6.12",
4
+ "version": "9.7.0",
5
5
  "author": "Netlify Inc.",
6
6
  "contributors": [
7
7
  "Abraham Schilling <AbrahamSchilling@gmail.com> (https://gitlab.com/n4bb12)",
@@ -8,8 +8,8 @@ const { injectEnvVariables } = require('../../utils')
8
8
  * @param {import('../base-command').BaseCommand} command
9
9
  */
10
10
  const devExec = async (cmd, options, command) => {
11
- const { cachedConfig, site } = command.netlify
12
- await injectEnvVariables({ env: cachedConfig.env, site })
11
+ const { cachedConfig, config, site } = command.netlify
12
+ await injectEnvVariables({ devConfig: { ...config.dev }, env: cachedConfig.env, site })
13
13
 
14
14
  await execa(cmd, command.args.slice(1), {
15
15
  stdio: 'inherit',
@@ -326,7 +326,7 @@ const dev = async (options, command) => {
326
326
  )
327
327
  }
328
328
 
329
- await injectEnvVariables({ env: command.netlify.cachedConfig.env, site })
329
+ await injectEnvVariables({ devConfig, env: command.netlify.cachedConfig.env, site })
330
330
 
331
331
  const { addonsUrls, capabilities, siteUrl, timeouts } = await getSiteInformation({
332
332
  // inherited from base command --offline
@@ -477,8 +477,14 @@ const createFunctionAddon = async function ({ addonName, addons, api, siteData,
477
477
  * @param {(command: import('../base-command').BaseCommand) => any} config.onComplete
478
478
  */
479
479
  const handleOnComplete = async ({ command, onComplete }) => {
480
+ const { config } = command.netlify
481
+
480
482
  if (onComplete) {
481
- await injectEnvVariables({ env: command.netlify.cachedConfig.env, site: command.netlify.site })
483
+ await injectEnvVariables({
484
+ devConfig: { ...config.dev },
485
+ env: command.netlify.cachedConfig.env,
486
+ site: command.netlify.site,
487
+ })
482
488
  await onComplete.call(command)
483
489
  }
484
490
  }
@@ -491,6 +497,8 @@ const handleOnComplete = async ({ command, onComplete }) => {
491
497
  * @param {string} config.fnPath
492
498
  */
493
499
  const handleAddonDidInstall = async ({ addonCreated, addonDidInstall, command, fnPath }) => {
500
+ const { config } = command.netlify
501
+
494
502
  if (!addonCreated || !addonDidInstall) {
495
503
  return
496
504
  }
@@ -508,7 +516,11 @@ const handleAddonDidInstall = async ({ addonCreated, addonDidInstall, command, f
508
516
  return
509
517
  }
510
518
 
511
- await injectEnvVariables({ env: command.netlify.cachedConfig.env, site: command.netlify.site })
519
+ await injectEnvVariables({
520
+ devConfig: { ...config.dev },
521
+ env: command.netlify.cachedConfig.env,
522
+ site: command.netlify.site,
523
+ })
512
524
  addonDidInstall(fnPath)
513
525
  }
514
526
 
@@ -17,7 +17,7 @@ const functionsServe = async (options, command) => {
17
17
 
18
18
  const functionsDir = getFunctionsDir({ options, config }, join('netlify', 'functions'))
19
19
 
20
- await injectEnvVariables({ env: command.netlify.cachedConfig.env, site })
20
+ await injectEnvVariables({ devConfig: { ...config.dev }, env: command.netlify.cachedConfig.env, site })
21
21
 
22
22
  const { capabilities, siteUrl, timeouts } = await getSiteInformation({
23
23
  offline: options.offline,
package/src/utils/dev.js CHANGED
@@ -139,9 +139,9 @@ const getEnvSourceName = (source) => {
139
139
 
140
140
  // Takes a set of environment variables in the format provided by @netlify/config, augments it with variables from both
141
141
  // dot-env files and the process itself, and injects into `process.env`.
142
- const injectEnvVariables = async ({ env, site }) => {
142
+ const injectEnvVariables = async ({ devConfig, env, site }) => {
143
143
  const environment = new Map(Object.entries(env))
144
- const dotEnvFiles = await loadDotEnvFiles({ projectDir: site.root })
144
+ const dotEnvFiles = await loadDotEnvFiles({ envFiles: devConfig.envFiles, projectDir: site.root })
145
145
 
146
146
  dotEnvFiles.forEach(({ env: fileEnv, file }) => {
147
147
  Object.keys(fileEnv).forEach((key) => {
@@ -8,8 +8,8 @@ const { isFileAsync } = require('../lib/fs')
8
8
 
9
9
  const { warn } = require('./command-helpers')
10
10
 
11
- const loadDotEnvFiles = async function ({ projectDir }) {
12
- const response = await tryLoadDotEnvFiles({ projectDir })
11
+ const loadDotEnvFiles = async function ({ envFiles, projectDir }) {
12
+ const response = await tryLoadDotEnvFiles({ projectDir, dotenvFiles: envFiles })
13
13
 
14
14
  const filesWithWarning = response.filter((el) => el.warning)
15
15
  filesWithWarning.forEach((el) => {
@@ -19,8 +19,10 @@ const loadDotEnvFiles = async function ({ projectDir }) {
19
19
  return response.filter((el) => el.file && el.env)
20
20
  }
21
21
 
22
- const tryLoadDotEnvFiles = async ({ projectDir }) => {
23
- const dotenvFiles = ['.env', '.env.development']
22
+ // in the user configuration, the order is highest to lowest
23
+ const defaultEnvFiles = ['.env.development', '.env']
24
+
25
+ const tryLoadDotEnvFiles = async ({ projectDir, dotenvFiles = defaultEnvFiles }) => {
24
26
  const results = await Promise.all(
25
27
  dotenvFiles.map(async (file) => {
26
28
  const filepath = path.resolve(projectDir, file)
@@ -40,7 +42,8 @@ const tryLoadDotEnvFiles = async ({ projectDir }) => {
40
42
  }),
41
43
  )
42
44
 
43
- return results.filter(Boolean)
45
+ // we return in order of lowest to highest priority
46
+ return results.filter(Boolean).reverse()
44
47
  }
45
48
 
46
49
  module.exports = { loadDotEnvFiles, tryLoadDotEnvFiles }