@netlify/config 20.16.0 → 20.17.1
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/env/main.d.ts +2 -1
- package/lib/env/main.js +16 -1
- package/lib/main.js +5 -1
- package/package.json +2 -2
package/lib/env/main.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const getEnv: ({ api, mode, config, siteInfo, accounts, addons, buildDir, branch, deployId, buildId, context, }: {
|
|
1
|
+
export declare const getEnv: ({ api, mode, config, siteInfo, accounts, addons, buildDir, branch, deployId, buildId, context, cachedEnv, }: {
|
|
2
2
|
api: any;
|
|
3
3
|
mode: any;
|
|
4
4
|
config: any;
|
|
@@ -10,4 +10,5 @@ export declare const getEnv: ({ api, mode, config, siteInfo, accounts, addons, b
|
|
|
10
10
|
deployId: any;
|
|
11
11
|
buildId: any;
|
|
12
12
|
context: any;
|
|
13
|
+
cachedEnv: any;
|
|
13
14
|
}) => Promise<any>;
|
package/lib/env/main.js
CHANGED
|
@@ -8,10 +8,11 @@ import { getGitEnv } from './git.js';
|
|
|
8
8
|
// meant so that local builds can mimic production builds
|
|
9
9
|
// TODO: add `netlify.toml` `build.environment`, after normalization
|
|
10
10
|
// TODO: add `CONTEXT` and others
|
|
11
|
-
export const getEnv = async function ({ api, mode, config, siteInfo, accounts, addons, buildDir, branch, deployId, buildId, context, }) {
|
|
11
|
+
export const getEnv = async function ({ api, mode, config, siteInfo, accounts, addons, buildDir, branch, deployId, buildId, context, cachedEnv, }) {
|
|
12
12
|
if (mode === 'buildbot') {
|
|
13
13
|
return {};
|
|
14
14
|
}
|
|
15
|
+
const internalEnv = getInternalEnv(cachedEnv);
|
|
15
16
|
const generalEnv = await getGeneralEnv({ siteInfo, buildDir, branch, deployId, buildId, context });
|
|
16
17
|
const [accountEnv, addonsEnv, uiEnv, configFileEnv] = await getUserEnv({
|
|
17
18
|
api,
|
|
@@ -28,6 +29,7 @@ export const getEnv = async function ({ api, mode, config, siteInfo, accounts, a
|
|
|
28
29
|
{ key: 'addons', values: addonsEnv },
|
|
29
30
|
{ key: 'account', values: accountEnv },
|
|
30
31
|
{ key: 'general', values: generalEnv },
|
|
32
|
+
{ key: 'internal', values: internalEnv },
|
|
31
33
|
];
|
|
32
34
|
// A hash mapping names of environment variables to objects containing the following properties:
|
|
33
35
|
// - sources: List of sources where the environment variable was found. The first element is the source that
|
|
@@ -85,6 +87,19 @@ const getGeneralEnv = async function ({ siteInfo, siteInfo: { id, name }, buildD
|
|
|
85
87
|
NEXT_TELEMETRY_DISABLED: '1',
|
|
86
88
|
});
|
|
87
89
|
};
|
|
90
|
+
/**
|
|
91
|
+
* Retrieve internal environment variables (needed for the CLI).
|
|
92
|
+
* Based on the cached environment, it returns the internal environment variables.
|
|
93
|
+
* Internal environment variables are those that are set by the CLI and are not retrieved by Envelope or the API.
|
|
94
|
+
*/
|
|
95
|
+
const getInternalEnv = function (cachedEnv) {
|
|
96
|
+
return Object.entries(cachedEnv).reduce((prev, [key, { sources, value }]) => {
|
|
97
|
+
if (sources.includes('internal')) {
|
|
98
|
+
prev[key] = value;
|
|
99
|
+
}
|
|
100
|
+
return prev;
|
|
101
|
+
}, {});
|
|
102
|
+
};
|
|
88
103
|
const getDeployUrls = function ({ siteInfo: { name = DEFAULT_SITE_NAME, ssl_url: sslUrl, build_settings: { repo_url: REPOSITORY_URL = undefined } = {}, }, branch, deployId, }) {
|
|
89
104
|
return {
|
|
90
105
|
URL: sslUrl,
|
package/lib/main.js
CHANGED
|
@@ -28,7 +28,10 @@ export const resolveConfig = async function (opts) {
|
|
|
28
28
|
// `api` is not JSON-serializable, so we cannot cache it inside `cachedConfig`
|
|
29
29
|
const api = getApiClient({ token, offline, host, scheme, pathPrefix, testOpts });
|
|
30
30
|
const parsedCachedConfig = await getCachedConfig({ cachedConfig, cachedConfigPath, token, api });
|
|
31
|
-
|
|
31
|
+
// If there is a cached config, use it. The exception is when a default config,
|
|
32
|
+
// which consumers like the CLI can set, is present. In those cases, let the
|
|
33
|
+
// flow continue so that the default config is parsed and used.
|
|
34
|
+
if (parsedCachedConfig !== undefined && opts.defaultConfig === undefined) {
|
|
32
35
|
return parsedCachedConfig;
|
|
33
36
|
}
|
|
34
37
|
const { config: configOpt, defaultConfig, inlineConfig, configMutations, cwd, context, repositoryRoot, base, branch, siteId, accountId, deployId, buildId, baseRelDir, mode, debug, logs, featureFlags, } = await normalizeOpts(optsA);
|
|
@@ -77,6 +80,7 @@ export const resolveConfig = async function (opts) {
|
|
|
77
80
|
deployId,
|
|
78
81
|
buildId,
|
|
79
82
|
context,
|
|
83
|
+
cachedEnv: parsedCachedConfig?.env || {},
|
|
80
84
|
});
|
|
81
85
|
// @todo Remove in the next major version.
|
|
82
86
|
const configA = addLegacyFunctionsDirectory(config);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/config",
|
|
3
|
-
"version": "20.
|
|
3
|
+
"version": "20.17.1",
|
|
4
4
|
"description": "Netlify config module",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./lib/index.js",
|
|
@@ -95,5 +95,5 @@
|
|
|
95
95
|
"engines": {
|
|
96
96
|
"node": "^14.16.0 || >=16.0.0"
|
|
97
97
|
},
|
|
98
|
-
"gitHead": "
|
|
98
|
+
"gitHead": "50efbdfa49d7e84b5ca5357187a07536560b10ad"
|
|
99
99
|
}
|