@netlify/config 20.12.1 → 20.12.3
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/lib/api/site_info.js +2 -2
- package/lib/env/envelope.js +2 -2
- package/lib/env/main.js +14 -7
- package/lib/main.js +1 -0
- package/package.json +3 -3
package/lib/api/site_info.js
CHANGED
|
@@ -11,7 +11,7 @@ import { ERROR_CALL_TO_ACTION } from '../log/messages.js';
|
|
|
11
11
|
* Silently ignore API errors. For example the network connection might be down,
|
|
12
12
|
* but local builds should still work regardless.
|
|
13
13
|
*/
|
|
14
|
-
export const getSiteInfo = async function ({ api, siteId, mode, siteFeatureFlagPrefix, offline = false, testOpts = {}, }) {
|
|
14
|
+
export const getSiteInfo = async function ({ api, siteId, mode, siteFeatureFlagPrefix, context, offline = false, testOpts = {}, }) {
|
|
15
15
|
const { env: testEnv = false } = testOpts;
|
|
16
16
|
if (api === undefined || mode === 'buildbot' || testEnv) {
|
|
17
17
|
const siteInfo = siteId === undefined ? {} : { id: siteId };
|
|
@@ -26,7 +26,7 @@ export const getSiteInfo = async function ({ api, siteId, mode, siteFeatureFlagP
|
|
|
26
26
|
];
|
|
27
27
|
const [siteInfo, accounts, addons, integrations] = await Promise.all(promises);
|
|
28
28
|
if (siteInfo.use_envelope) {
|
|
29
|
-
const envelope = await getEnvelope({ api, accountId: siteInfo.account_slug, siteId });
|
|
29
|
+
const envelope = await getEnvelope({ api, accountId: siteInfo.account_slug, siteId, context });
|
|
30
30
|
siteInfo.build_settings.env = envelope;
|
|
31
31
|
}
|
|
32
32
|
return { siteInfo, accounts, addons, integrations };
|
package/lib/env/envelope.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export const getEnvelope = async function ({ api, accountId, siteId }) {
|
|
1
|
+
export const getEnvelope = async function ({ api, accountId, siteId, context, }) {
|
|
2
2
|
if (accountId === undefined) {
|
|
3
3
|
return {};
|
|
4
4
|
}
|
|
5
5
|
try {
|
|
6
|
-
const environmentVariables = await api.getEnvVars({ accountId, siteId });
|
|
6
|
+
const environmentVariables = await api.getEnvVars({ accountId, siteId, context_name: context });
|
|
7
7
|
const sortedEnvVarsFromDevContext = environmentVariables
|
|
8
8
|
.sort((left, right) => (left.key.toLowerCase() < right.key.toLowerCase() ? -1 : 1))
|
|
9
9
|
.reduce((acc, cur) => {
|
package/lib/env/main.js
CHANGED
|
@@ -13,7 +13,14 @@ export const getEnv = async function ({ api, mode, config, siteInfo, accounts, a
|
|
|
13
13
|
return {};
|
|
14
14
|
}
|
|
15
15
|
const generalEnv = await getGeneralEnv({ siteInfo, buildDir, branch, deployId, buildId, context });
|
|
16
|
-
const [accountEnv, addonsEnv, uiEnv, configFileEnv] = await getUserEnv({
|
|
16
|
+
const [accountEnv, addonsEnv, uiEnv, configFileEnv] = await getUserEnv({
|
|
17
|
+
api,
|
|
18
|
+
config,
|
|
19
|
+
siteInfo,
|
|
20
|
+
accounts,
|
|
21
|
+
addons,
|
|
22
|
+
context,
|
|
23
|
+
});
|
|
17
24
|
// Sources of environment variables, in descending order of precedence.
|
|
18
25
|
const sources = [
|
|
19
26
|
{ key: 'configFile', values: configFileEnv },
|
|
@@ -59,7 +66,7 @@ const convertToString = (value) => {
|
|
|
59
66
|
// environment.
|
|
60
67
|
const getGeneralEnv = async function ({ siteInfo, siteInfo: { id, name }, buildDir, branch, deployId, buildId, context, }) {
|
|
61
68
|
const gitEnv = await getGitEnv(buildDir, branch);
|
|
62
|
-
const deployUrls = getDeployUrls({ siteInfo, branch, deployId });
|
|
69
|
+
const deployUrls = getDeployUrls({ siteInfo: siteInfo, branch, deployId });
|
|
63
70
|
return removeFalsy({
|
|
64
71
|
SITE_ID: id,
|
|
65
72
|
SITE_NAME: name,
|
|
@@ -78,7 +85,7 @@ const getGeneralEnv = async function ({ siteInfo, siteInfo: { id, name }, buildD
|
|
|
78
85
|
NEXT_TELEMETRY_DISABLED: '1',
|
|
79
86
|
});
|
|
80
87
|
};
|
|
81
|
-
const getDeployUrls = function ({ siteInfo: { name = DEFAULT_SITE_NAME, ssl_url: sslUrl, build_settings: { repo_url: REPOSITORY_URL } = {} }, branch, deployId, }) {
|
|
88
|
+
const getDeployUrls = function ({ siteInfo: { name = DEFAULT_SITE_NAME, ssl_url: sslUrl, build_settings: { repo_url: REPOSITORY_URL = undefined } = {}, }, branch, deployId, }) {
|
|
82
89
|
return {
|
|
83
90
|
URL: sslUrl,
|
|
84
91
|
REPOSITORY_URL,
|
|
@@ -90,17 +97,17 @@ const NETLIFY_DEFAULT_DOMAIN = '.netlify.app';
|
|
|
90
97
|
// `site.name` is `undefined` when there is no token or siteId
|
|
91
98
|
const DEFAULT_SITE_NAME = 'site-name';
|
|
92
99
|
// Environment variables specified by the user
|
|
93
|
-
const getUserEnv = async function ({ api, config, siteInfo, accounts, addons }) {
|
|
94
|
-
const accountEnv = await getAccountEnv({ api, siteInfo, accounts });
|
|
100
|
+
const getUserEnv = async function ({ api, config, siteInfo, accounts, addons, context }) {
|
|
101
|
+
const accountEnv = await getAccountEnv({ api, siteInfo, accounts, context });
|
|
95
102
|
const addonsEnv = getAddonsEnv(addons);
|
|
96
103
|
const uiEnv = getUiEnv({ siteInfo });
|
|
97
104
|
const configFileEnv = getConfigFileEnv({ config });
|
|
98
105
|
return [accountEnv, addonsEnv, uiEnv, configFileEnv].map(cleanUserEnv);
|
|
99
106
|
};
|
|
100
107
|
// Account-wide environment variables
|
|
101
|
-
const getAccountEnv = async function ({ api, siteInfo, accounts }) {
|
|
108
|
+
const getAccountEnv = async function ({ api, siteInfo, accounts, context, }) {
|
|
102
109
|
if (siteInfo.use_envelope) {
|
|
103
|
-
const envelope = await getEnvelope({ api, accountId: siteInfo.account_slug });
|
|
110
|
+
const envelope = await getEnvelope({ api, accountId: siteInfo.account_slug, context });
|
|
104
111
|
return envelope;
|
|
105
112
|
}
|
|
106
113
|
const { site_env: siteEnv = {} } = accounts.find(({ slug }) => slug === siteInfo.account_slug) || {};
|
package/lib/main.js
CHANGED
|
@@ -34,6 +34,7 @@ export const resolveConfig = async function (opts) {
|
|
|
34
34
|
const { config: configOpt, defaultConfig, inlineConfig, configMutations, cwd, context, repositoryRoot, base, branch, siteId, deployId, buildId, baseRelDir, mode, debug, logs, featureFlags, } = await normalizeOpts(optsA);
|
|
35
35
|
const { siteInfo, accounts, addons, integrations } = await getSiteInfo({
|
|
36
36
|
api,
|
|
37
|
+
context,
|
|
37
38
|
siteId,
|
|
38
39
|
mode,
|
|
39
40
|
offline,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/config",
|
|
3
|
-
"version": "20.12.
|
|
3
|
+
"version": "20.12.3",
|
|
4
4
|
"description": "Netlify config module",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./lib/index.js",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"is-plain-obj": "^4.0.0",
|
|
72
72
|
"js-yaml": "^4.0.0",
|
|
73
73
|
"map-obj": "^5.0.0",
|
|
74
|
-
"netlify": "^13.1.
|
|
74
|
+
"netlify": "^13.1.15",
|
|
75
75
|
"netlify-headers-parser": "^7.1.4",
|
|
76
76
|
"netlify-redirect-parser": "^14.2.2",
|
|
77
77
|
"node-fetch": "^3.3.1",
|
|
@@ -94,5 +94,5 @@
|
|
|
94
94
|
"engines": {
|
|
95
95
|
"node": "^14.16.0 || >=16.0.0"
|
|
96
96
|
},
|
|
97
|
-
"gitHead": "
|
|
97
|
+
"gitHead": "58fa495beea44671013bd5586c08dabc6d17bc20"
|
|
98
98
|
}
|