@netlify/config 21.0.7 → 22.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/README.md +9 -20
- package/lib/api/site_info.d.ts +0 -1
- package/lib/api/site_info.js +3 -16
- package/lib/env/main.d.ts +1 -2
- package/lib/env/main.js +5 -15
- package/lib/main.d.ts +0 -1
- package/lib/main.js +3 -6
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -47,7 +47,6 @@ const exampleFunction = async function () {
|
|
|
47
47
|
// },
|
|
48
48
|
// ...
|
|
49
49
|
// ],
|
|
50
|
-
// "addons": [],
|
|
51
50
|
// "env": {
|
|
52
51
|
// "NODE_VERSION": { "sources": ["configFile"], "value": "16" },
|
|
53
52
|
// ...
|
|
@@ -117,7 +116,7 @@ Path to the `netlify.toml`. It is either an absolute path or a path relative to
|
|
|
117
116
|
If not specified, it is searched in the following directories (by highest priority order):
|
|
118
117
|
|
|
119
118
|
- `base` directory
|
|
120
|
-
- [`repositoryRoot`](#
|
|
119
|
+
- [`repositoryRoot`](#repositoryroot)
|
|
121
120
|
- current directory
|
|
122
121
|
- any parent directory
|
|
123
122
|
|
|
@@ -205,7 +204,7 @@ _Default value_: environment variable `NETLIFY_SITE_ID`
|
|
|
205
204
|
|
|
206
205
|
Netlify Site ID.
|
|
207
206
|
|
|
208
|
-
This is used to retrieve [`siteInfo`](#siteinfo)
|
|
207
|
+
This is used to retrieve [`siteInfo`](#siteinfo) and [`accounts`](#accounts).
|
|
209
208
|
|
|
210
209
|
#### env
|
|
211
210
|
|
|
@@ -227,8 +226,8 @@ What is calling `@netlify/config`. Can be:
|
|
|
227
226
|
|
|
228
227
|
This is used for the following cases:
|
|
229
228
|
|
|
230
|
-
- if `mode` is `buildbot`, [`siteInfo`](#siteinfo)
|
|
231
|
-
|
|
229
|
+
- if `mode` is `buildbot`, [`siteInfo`](#siteinfo) and [`accounts`](#accounts) are not retrieved because they are also
|
|
230
|
+
passed using another internal option.
|
|
232
231
|
|
|
233
232
|
#### defaultConfig
|
|
234
233
|
|
|
@@ -287,13 +286,13 @@ _Type_: `string`
|
|
|
287
286
|
Absolute path to the build directory.
|
|
288
287
|
|
|
289
288
|
The build directory is the current directory in which most build operations, including the build command, execute. It is
|
|
290
|
-
usually either the [`repositoryRoot`](#
|
|
289
|
+
usually either the [`repositoryRoot`](#repositoryroot) or (if specified) the `base` directory.
|
|
291
290
|
|
|
292
291
|
#### repositoryRoot
|
|
293
292
|
|
|
294
293
|
_Type_: `string`
|
|
295
294
|
|
|
296
|
-
The computed value of [`repositoryRoot`](#
|
|
295
|
+
The computed value of [`repositoryRoot`](#repositoryroot).
|
|
297
296
|
|
|
298
297
|
#### context
|
|
299
298
|
|
|
@@ -326,15 +325,6 @@ environment variables.
|
|
|
326
325
|
|
|
327
326
|
This might be empty depending on the options passed.
|
|
328
327
|
|
|
329
|
-
#### addons
|
|
330
|
-
|
|
331
|
-
_Type_: `object[]`
|
|
332
|
-
|
|
333
|
-
Netlify addons retrieved using the `listServiceInstancesForSite` Netlify API endpoint. This is used to retrieve
|
|
334
|
-
addon-specific environment variables.
|
|
335
|
-
|
|
336
|
-
This might be empty depending on the options passed.
|
|
337
|
-
|
|
338
328
|
#### token
|
|
339
329
|
|
|
340
330
|
_Type_: `string`
|
|
@@ -346,8 +336,8 @@ variables.
|
|
|
346
336
|
|
|
347
337
|
_Type_: `NetlifyClient?`
|
|
348
338
|
|
|
349
|
-
Netlify [JavaScript client instance](https://github.com/netlify/js-client) used to retrieve [`siteInfo`](#siteinfo)
|
|
350
|
-
[`accounts`](#accounts)
|
|
339
|
+
Netlify [JavaScript client instance](https://github.com/netlify/js-client) used to retrieve [`siteInfo`](#siteinfo) and
|
|
340
|
+
[`accounts`](#accounts).
|
|
351
341
|
|
|
352
342
|
#### logs
|
|
353
343
|
|
|
@@ -365,14 +355,13 @@ Site's environment variables. Each environment variable value is an object with
|
|
|
365
355
|
- `sources` `string[]` among:
|
|
366
356
|
- `general`: general environment variables set for all sites
|
|
367
357
|
- `account`: environment variables set in the Netlify UI for a specific account
|
|
368
|
-
- `addons`: addon-specific environment variables
|
|
369
358
|
- `ui`: environment variables set in the Netlify UI for a specific site
|
|
370
359
|
- `configFile`: environment variables set in `netlify.toml`
|
|
371
360
|
|
|
372
361
|
# Usage (CLI)
|
|
373
362
|
|
|
374
363
|
```bash
|
|
375
|
-
|
|
364
|
+
netlify-config
|
|
376
365
|
```
|
|
377
366
|
|
|
378
367
|
Like [`resolveConfig()`](resolveconfig), but in the CLI. The return value is printed on `stdout`.
|
package/lib/api/site_info.d.ts
CHANGED
|
@@ -26,7 +26,6 @@ type GetSiteInfoOpts = {
|
|
|
26
26
|
export declare const getSiteInfo: ({ api, siteId, accountId, mode, context, offline, testOpts, siteFeatureFlagPrefix, token, featureFlags, extensionApiBaseUrl, }: GetSiteInfoOpts) => Promise<{
|
|
27
27
|
siteInfo: any;
|
|
28
28
|
accounts: MinimalAccount[];
|
|
29
|
-
addons: any[] | undefined;
|
|
30
29
|
integrations: IntegrationResponse[];
|
|
31
30
|
}>;
|
|
32
31
|
export type MinimalAccount = {
|
package/lib/api/site_info.js
CHANGED
|
@@ -32,19 +32,18 @@ export const getSiteInfo = async function ({ api, siteId, accountId, mode, conte
|
|
|
32
32
|
mode,
|
|
33
33
|
})
|
|
34
34
|
: [];
|
|
35
|
-
return { siteInfo, accounts: [],
|
|
35
|
+
return { siteInfo, accounts: [], integrations };
|
|
36
36
|
}
|
|
37
|
-
const [siteInfo, accounts,
|
|
37
|
+
const [siteInfo, accounts, integrations] = await Promise.all([
|
|
38
38
|
getSite(api, siteId, siteFeatureFlagPrefix),
|
|
39
39
|
getAccounts(api),
|
|
40
|
-
getAddons(api, siteId),
|
|
41
40
|
getIntegrations({ siteId, testOpts, offline, accountId, token, featureFlags, extensionApiBaseUrl, mode }),
|
|
42
41
|
]);
|
|
43
42
|
if (siteInfo.use_envelope) {
|
|
44
43
|
const envelope = await getEnvelope({ api, accountId: siteInfo.account_slug, siteId, context });
|
|
45
44
|
siteInfo.build_settings.env = envelope;
|
|
46
45
|
}
|
|
47
|
-
return { siteInfo, accounts,
|
|
46
|
+
return { siteInfo, accounts, integrations };
|
|
48
47
|
};
|
|
49
48
|
const getSite = async function (api, siteId, siteFeatureFlagPrefix) {
|
|
50
49
|
if (siteId === undefined) {
|
|
@@ -69,18 +68,6 @@ const getAccounts = async function (api) {
|
|
|
69
68
|
return throwUserError(`Failed retrieving user account: ${error.message}. ${ERROR_CALL_TO_ACTION}`);
|
|
70
69
|
}
|
|
71
70
|
};
|
|
72
|
-
const getAddons = async function (api, siteId) {
|
|
73
|
-
if (siteId === undefined) {
|
|
74
|
-
return [];
|
|
75
|
-
}
|
|
76
|
-
try {
|
|
77
|
-
const addons = await api.listServiceInstancesForSite({ siteId });
|
|
78
|
-
return Array.isArray(addons) ? addons : [];
|
|
79
|
-
}
|
|
80
|
-
catch (error) {
|
|
81
|
-
throwUserError(`Failed retrieving addons for site ${siteId}: ${error.message}. ${ERROR_CALL_TO_ACTION}`);
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
71
|
const getIntegrations = async function ({ siteId, accountId, testOpts, offline, token, featureFlags, extensionApiBaseUrl, mode, }) {
|
|
85
72
|
if (!siteId || offline) {
|
|
86
73
|
return [];
|
package/lib/env/main.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
export declare const getEnv: ({ api, mode, config, siteInfo, accounts,
|
|
1
|
+
export declare const getEnv: ({ api, mode, config, siteInfo, accounts, buildDir, branch, deployId, buildId, context, cachedEnv, }: {
|
|
2
2
|
api: any;
|
|
3
3
|
mode: any;
|
|
4
4
|
config: any;
|
|
5
5
|
siteInfo: any;
|
|
6
6
|
accounts: any;
|
|
7
|
-
addons: any;
|
|
8
7
|
buildDir: any;
|
|
9
8
|
branch: any;
|
|
10
9
|
deployId: any;
|
package/lib/env/main.js
CHANGED
|
@@ -3,30 +3,28 @@ import { removeFalsy } from '../utils/remove_falsy.js';
|
|
|
3
3
|
import { getEnvelope } from './envelope.js';
|
|
4
4
|
import { getGitEnv } from './git.js';
|
|
5
5
|
// Retrieve this site's environment variable. Also take into account team-wide
|
|
6
|
-
// environment variables
|
|
6
|
+
// environment variables.
|
|
7
7
|
// The buildbot already has the right environment variables. This is mostly
|
|
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,
|
|
11
|
+
export const getEnv = async function ({ api, mode, config, siteInfo, accounts, buildDir, branch, deployId, buildId, context, cachedEnv, }) {
|
|
12
12
|
if (mode === 'buildbot') {
|
|
13
13
|
return {};
|
|
14
14
|
}
|
|
15
15
|
const internalEnv = getInternalEnv(cachedEnv);
|
|
16
16
|
const generalEnv = await getGeneralEnv({ siteInfo, buildDir, branch, deployId, buildId, context });
|
|
17
|
-
const [accountEnv,
|
|
17
|
+
const [accountEnv, uiEnv, configFileEnv] = await getUserEnv({
|
|
18
18
|
api,
|
|
19
19
|
config,
|
|
20
20
|
siteInfo,
|
|
21
21
|
accounts,
|
|
22
|
-
addons,
|
|
23
22
|
context,
|
|
24
23
|
});
|
|
25
24
|
// Sources of environment variables, in descending order of precedence.
|
|
26
25
|
const sources = [
|
|
27
26
|
{ key: 'configFile', values: configFileEnv },
|
|
28
27
|
{ key: 'ui', values: uiEnv },
|
|
29
|
-
{ key: 'addons', values: addonsEnv },
|
|
30
28
|
{ key: 'account', values: accountEnv },
|
|
31
29
|
{ key: 'general', values: generalEnv },
|
|
32
30
|
{ key: 'internal', values: internalEnv },
|
|
@@ -113,12 +111,11 @@ const NETLIFY_DEFAULT_DOMAIN = '.netlify.app';
|
|
|
113
111
|
// `site.name` is `undefined` when there is no token or siteId
|
|
114
112
|
const DEFAULT_SITE_NAME = 'site-name';
|
|
115
113
|
// Environment variables specified by the user
|
|
116
|
-
const getUserEnv = async function ({ api, config, siteInfo, accounts,
|
|
114
|
+
const getUserEnv = async function ({ api, config, siteInfo, accounts, context }) {
|
|
117
115
|
const accountEnv = await getAccountEnv({ api, siteInfo, accounts, context });
|
|
118
|
-
const addonsEnv = getAddonsEnv(addons);
|
|
119
116
|
const uiEnv = getUiEnv({ siteInfo });
|
|
120
117
|
const configFileEnv = getConfigFileEnv({ config });
|
|
121
|
-
return [accountEnv,
|
|
118
|
+
return [accountEnv, uiEnv, configFileEnv].map(cleanUserEnv);
|
|
122
119
|
};
|
|
123
120
|
// Account-wide environment variables
|
|
124
121
|
const getAccountEnv = async function ({ api, siteInfo, accounts, context, }) {
|
|
@@ -128,13 +125,6 @@ const getAccountEnv = async function ({ api, siteInfo, accounts, context, }) {
|
|
|
128
125
|
const { site_env: siteEnv = {} } = accounts.find(({ slug }) => slug === siteInfo.account_slug) || {};
|
|
129
126
|
return siteEnv;
|
|
130
127
|
};
|
|
131
|
-
// Environment variables from addons
|
|
132
|
-
const getAddonsEnv = function (addons) {
|
|
133
|
-
return Object.assign({}, ...addons.map(getAddonEnv));
|
|
134
|
-
};
|
|
135
|
-
const getAddonEnv = function ({ env }) {
|
|
136
|
-
return env;
|
|
137
|
-
};
|
|
138
128
|
// Site-specific environment variables set in the UI
|
|
139
129
|
const getUiEnv = function ({ siteInfo: { build_settings: { env = {} } = {} } }) {
|
|
140
130
|
return env;
|
package/lib/main.d.ts
CHANGED
package/lib/main.js
CHANGED
|
@@ -39,12 +39,12 @@ export const resolveConfig = async function (opts) {
|
|
|
39
39
|
? EXTENSION_API_STAGING_BASE_URL
|
|
40
40
|
: EXTENSION_API_BASE_URL;
|
|
41
41
|
const { config: configOpt, defaultConfig, inlineConfig, configMutations, cwd, context, repositoryRoot, base, branch, siteId, accountId, deployId, buildId, baseRelDir, mode, debug, logs, featureFlags, } = await normalizeOpts(optsA);
|
|
42
|
-
let { siteInfo, accounts,
|
|
42
|
+
let { siteInfo, accounts, integrations } = parsedCachedConfig || {};
|
|
43
43
|
// If we have cached site info, we don't need to fetch it again
|
|
44
|
-
const useCachedSiteInfo = Boolean(featureFlags?.use_cached_site_info && siteInfo && accounts &&
|
|
44
|
+
const useCachedSiteInfo = Boolean(featureFlags?.use_cached_site_info && siteInfo && accounts && integrations);
|
|
45
45
|
// I'm adding some debug logging to see if the logic is working as expected
|
|
46
46
|
if (featureFlags?.use_cached_site_info_logging) {
|
|
47
|
-
console.log('Checking site information', { useCachedSiteInfo, siteInfo, accounts,
|
|
47
|
+
console.log('Checking site information', { useCachedSiteInfo, siteInfo, accounts, integrations });
|
|
48
48
|
}
|
|
49
49
|
if (!useCachedSiteInfo) {
|
|
50
50
|
const updatedSiteInfo = await getSiteInfo({
|
|
@@ -62,7 +62,6 @@ export const resolveConfig = async function (opts) {
|
|
|
62
62
|
});
|
|
63
63
|
siteInfo = updatedSiteInfo.siteInfo;
|
|
64
64
|
accounts = updatedSiteInfo.accounts;
|
|
65
|
-
addons = updatedSiteInfo.addons;
|
|
66
65
|
integrations = updatedSiteInfo.integrations;
|
|
67
66
|
}
|
|
68
67
|
const { defaultConfig: defaultConfigA, baseRelDir: baseRelDirA } = parseDefaultConfig({
|
|
@@ -93,7 +92,6 @@ export const resolveConfig = async function (opts) {
|
|
|
93
92
|
config,
|
|
94
93
|
siteInfo,
|
|
95
94
|
accounts,
|
|
96
|
-
addons,
|
|
97
95
|
buildDir,
|
|
98
96
|
branch,
|
|
99
97
|
deployId,
|
|
@@ -112,7 +110,6 @@ export const resolveConfig = async function (opts) {
|
|
|
112
110
|
siteInfo,
|
|
113
111
|
integrations: mergedIntegrations,
|
|
114
112
|
accounts,
|
|
115
|
-
addons,
|
|
116
113
|
env,
|
|
117
114
|
configPath,
|
|
118
115
|
redirectsPath,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/config",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "22.0.0",
|
|
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": "6c53e667bd041a68dda336c678877dbb3b84a512"
|
|
99
99
|
}
|