@netlify/config
Advanced tools
Comparing version 20.12.1 to 20.12.2
@@ -14,3 +14,3 @@ import fetch from 'node-fetch'; | ||
*/ | ||
export const getSiteInfo = async function ({ api, siteId, mode, siteFeatureFlagPrefix, offline = false, testOpts = {}, }) { | ||
export const getSiteInfo = async function ({ api, siteId, mode, siteFeatureFlagPrefix, context, offline = false, testOpts = {}, }) { | ||
const { env: testEnv = false } = testOpts; | ||
@@ -30,3 +30,3 @@ if (api === undefined || mode === 'buildbot' || testEnv) { | ||
if (siteInfo.use_envelope) { | ||
const envelope = await getEnvelope({ api, accountId: siteInfo.account_slug, siteId }); | ||
const envelope = await getEnvelope({ api, accountId: siteInfo.account_slug, siteId, context }); | ||
siteInfo.build_settings.env = envelope; | ||
@@ -33,0 +33,0 @@ } |
@@ -1,2 +0,2 @@ | ||
export const getEnvelope = async function ({ api, accountId, siteId }) { | ||
export const getEnvelope = async function ({ api, accountId, siteId, context, }) { | ||
if (accountId === undefined) { | ||
@@ -6,3 +6,3 @@ return {}; | ||
try { | ||
const environmentVariables = await api.getEnvVars({ accountId, siteId }); | ||
const environmentVariables = await api.getEnvVars({ accountId, siteId, context_name: context }); | ||
const sortedEnvVarsFromDevContext = environmentVariables | ||
@@ -9,0 +9,0 @@ .sort((left, right) => (left.key.toLowerCase() < right.key.toLowerCase() ? -1 : 1)) |
@@ -16,3 +16,10 @@ import omit from 'omit.js'; | ||
const generalEnv = await getGeneralEnv({ siteInfo, buildDir, branch, deployId, buildId, context }); | ||
const [accountEnv, addonsEnv, uiEnv, configFileEnv] = await getUserEnv({ api, config, siteInfo, accounts, addons }); | ||
const [accountEnv, addonsEnv, uiEnv, configFileEnv] = await getUserEnv({ | ||
api, | ||
config, | ||
siteInfo, | ||
accounts, | ||
addons, | ||
context, | ||
}); | ||
// Sources of environment variables, in descending order of precedence. | ||
@@ -63,3 +70,3 @@ const sources = [ | ||
const gitEnv = await getGitEnv(buildDir, branch); | ||
const deployUrls = getDeployUrls({ siteInfo, branch, deployId }); | ||
const deployUrls = getDeployUrls({ siteInfo: siteInfo, branch, deployId }); | ||
return removeFalsy({ | ||
@@ -83,3 +90,3 @@ SITE_ID: id, | ||
}; | ||
const getDeployUrls = function ({ siteInfo: { name = DEFAULT_SITE_NAME, ssl_url: sslUrl, build_settings: { repo_url: REPOSITORY_URL } = {} }, branch, deployId, }) { | ||
const getDeployUrls = function ({ siteInfo: { name = DEFAULT_SITE_NAME, ssl_url: sslUrl, build_settings: { repo_url: REPOSITORY_URL = undefined } = {}, }, branch, deployId, }) { | ||
return { | ||
@@ -96,4 +103,4 @@ URL: sslUrl, | ||
// Environment variables specified by the user | ||
const getUserEnv = async function ({ api, config, siteInfo, accounts, addons }) { | ||
const accountEnv = await getAccountEnv({ api, siteInfo, accounts }); | ||
const getUserEnv = async function ({ api, config, siteInfo, accounts, addons, context }) { | ||
const accountEnv = await getAccountEnv({ api, siteInfo, accounts, context }); | ||
const addonsEnv = getAddonsEnv(addons); | ||
@@ -105,5 +112,5 @@ const uiEnv = getUiEnv({ siteInfo }); | ||
// Account-wide environment variables | ||
const getAccountEnv = async function ({ api, siteInfo, accounts }) { | ||
const getAccountEnv = async function ({ api, siteInfo, accounts, context, }) { | ||
if (siteInfo.use_envelope) { | ||
const envelope = await getEnvelope({ api, accountId: siteInfo.account_slug }); | ||
const envelope = await getEnvelope({ api, accountId: siteInfo.account_slug, context }); | ||
return envelope; | ||
@@ -110,0 +117,0 @@ } |
@@ -37,2 +37,3 @@ import { getApiClient } from './api/client.js'; | ||
api, | ||
context, | ||
siteId, | ||
@@ -39,0 +40,0 @@ mode, |
{ | ||
"name": "@netlify/config", | ||
"version": "20.12.1", | ||
"version": "20.12.2", | ||
"description": "Netlify config module", | ||
@@ -97,3 +97,3 @@ "type": "module", | ||
}, | ||
"gitHead": "b967616d77aa5a926c798f0296bfd01d2628543d" | ||
"gitHead": "cf765526c7970810cc1812ac0b2b3d9bb11ea926" | ||
} |
134556
2957