@netlify/config 20.14.1 → 20.15.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/api/site_info.d.ts +2 -2
- package/lib/api/site_info.js +34 -7
- package/lib/bin/flags.d.ts +1 -0
- package/lib/bin/flags.js +4 -0
- package/lib/main.js +3 -3
- package/package.json +3 -3
package/lib/api/site_info.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { NetlifyAPI } from 'netlify';
|
|
|
2
2
|
import { ModeOption, TestOptions } from '../types/options.js';
|
|
3
3
|
type GetSiteInfoOpts = {
|
|
4
4
|
siteId: string;
|
|
5
|
+
accountId?: string;
|
|
5
6
|
mode: ModeOption;
|
|
6
|
-
siteFeatureFlagPrefix: string;
|
|
7
7
|
offline?: boolean;
|
|
8
8
|
api?: NetlifyAPI;
|
|
9
9
|
context?: string;
|
|
@@ -19,7 +19,7 @@ type GetSiteInfoOpts = {
|
|
|
19
19
|
* Silently ignore API errors. For example the network connection might be down,
|
|
20
20
|
* but local builds should still work regardless.
|
|
21
21
|
*/
|
|
22
|
-
export declare const getSiteInfo: ({ api, siteId,
|
|
22
|
+
export declare const getSiteInfo: ({ api, siteId, accountId, mode, context, offline, testOpts, featureFlags, }: GetSiteInfoOpts) => Promise<{
|
|
23
23
|
siteInfo: any;
|
|
24
24
|
accounts: any;
|
|
25
25
|
addons: any;
|
package/lib/api/site_info.js
CHANGED
|
@@ -11,15 +11,37 @@ 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,
|
|
14
|
+
export const getSiteInfo = async function ({ api, siteId, accountId, mode, context, offline = false, testOpts = {}, featureFlags = {}, }) {
|
|
15
15
|
const { env: testEnv = false } = testOpts;
|
|
16
|
+
const useV2Endpoint = !!accountId && featureFlags.cli_integration_installations_meta;
|
|
17
|
+
if (useV2Endpoint) {
|
|
18
|
+
if (api === undefined || mode === 'buildbot' || testEnv) {
|
|
19
|
+
const siteInfo = siteId === undefined ? {} : { id: siteId };
|
|
20
|
+
const integrations = mode === 'buildbot' && !offline
|
|
21
|
+
? await getIntegrations({ siteId, testOpts, offline, useV2Endpoint, accountId })
|
|
22
|
+
: [];
|
|
23
|
+
return { siteInfo, accounts: [], addons: [], integrations };
|
|
24
|
+
}
|
|
25
|
+
const promises = [
|
|
26
|
+
getSite(api, siteId),
|
|
27
|
+
getAccounts(api),
|
|
28
|
+
getAddons(api, siteId),
|
|
29
|
+
getIntegrations({ siteId, testOpts, offline, useV2Endpoint, accountId }),
|
|
30
|
+
];
|
|
31
|
+
const [siteInfo, accounts, addons, integrations] = await Promise.all(promises);
|
|
32
|
+
if (siteInfo.use_envelope) {
|
|
33
|
+
const envelope = await getEnvelope({ api, accountId: siteInfo.account_slug, siteId, context });
|
|
34
|
+
siteInfo.build_settings.env = envelope;
|
|
35
|
+
}
|
|
36
|
+
return { siteInfo, accounts, addons, integrations };
|
|
37
|
+
}
|
|
16
38
|
if (api === undefined || mode === 'buildbot' || testEnv) {
|
|
17
39
|
const siteInfo = siteId === undefined ? {} : { id: siteId };
|
|
18
40
|
const integrations = mode === 'buildbot' && !offline ? await getIntegrations({ siteId, testOpts, offline }) : [];
|
|
19
41
|
return { siteInfo, accounts: [], addons: [], integrations };
|
|
20
42
|
}
|
|
21
43
|
const promises = [
|
|
22
|
-
getSite(api, siteId
|
|
44
|
+
getSite(api, siteId),
|
|
23
45
|
getAccounts(api),
|
|
24
46
|
getAddons(api, siteId),
|
|
25
47
|
getIntegrations({ siteId, testOpts, offline }),
|
|
@@ -31,12 +53,12 @@ export const getSiteInfo = async function ({ api, siteId, mode, siteFeatureFlagP
|
|
|
31
53
|
}
|
|
32
54
|
return { siteInfo, accounts, addons, integrations };
|
|
33
55
|
};
|
|
34
|
-
const getSite = async function (api, siteId
|
|
56
|
+
const getSite = async function (api, siteId) {
|
|
35
57
|
if (siteId === undefined) {
|
|
36
58
|
return {};
|
|
37
59
|
}
|
|
38
60
|
try {
|
|
39
|
-
const site = await api.getSite({ siteId
|
|
61
|
+
const site = await api.getSite({ siteId });
|
|
40
62
|
return { ...site, id: siteId };
|
|
41
63
|
}
|
|
42
64
|
catch (error) {
|
|
@@ -64,19 +86,24 @@ const getAddons = async function (api, siteId) {
|
|
|
64
86
|
throwUserError(`Failed retrieving addons for site ${siteId}: ${error.message}. ${ERROR_CALL_TO_ACTION}`);
|
|
65
87
|
}
|
|
66
88
|
};
|
|
67
|
-
const getIntegrations = async function ({ siteId, testOpts, offline, }) {
|
|
89
|
+
const getIntegrations = async function ({ siteId, accountId, testOpts, offline, useV2Endpoint, }) {
|
|
68
90
|
if (!siteId || offline) {
|
|
69
91
|
return [];
|
|
70
92
|
}
|
|
71
93
|
const { host } = testOpts;
|
|
72
94
|
const baseUrl = new URL(host ? `http://${host}` : `https://api.netlifysdk.com`);
|
|
95
|
+
const url = useV2Endpoint
|
|
96
|
+
? `${baseUrl}team/${accountId}/integrations/installations/meta`
|
|
97
|
+
: `${baseUrl}site/${siteId}/integrations/safe`;
|
|
73
98
|
try {
|
|
74
|
-
const response = await fetch(
|
|
99
|
+
const response = await fetch(url);
|
|
75
100
|
const integrations = await response.json();
|
|
76
101
|
return Array.isArray(integrations) ? integrations : [];
|
|
77
102
|
}
|
|
78
103
|
catch (error) {
|
|
79
|
-
//
|
|
104
|
+
// Integrations should not block the build if they fail to load
|
|
105
|
+
// TODO: We should consider blocking the build as integrations are a critical part of the build process
|
|
106
|
+
// https://linear.app/netlify/issue/CT-1214/implement-strategy-in-builds-to-deal-with-integrations-that-we-fail-to
|
|
80
107
|
return [];
|
|
81
108
|
}
|
|
82
109
|
};
|
package/lib/bin/flags.d.ts
CHANGED
package/lib/bin/flags.js
CHANGED
|
@@ -118,6 +118,10 @@ The NETLIFY_AUTH_TOKEN environment variable can be used as well.`,
|
|
|
118
118
|
string: true,
|
|
119
119
|
describe: `Netlify Site ID.`,
|
|
120
120
|
},
|
|
121
|
+
accountId: {
|
|
122
|
+
string: true,
|
|
123
|
+
describe: 'Netlify Account ID. This will only be available in buildbot mode.',
|
|
124
|
+
},
|
|
121
125
|
context: {
|
|
122
126
|
string: true,
|
|
123
127
|
describe: `Build context.
|
package/lib/main.js
CHANGED
|
@@ -24,21 +24,21 @@ import { getRedirectsPath, addRedirects } from './redirects.js';
|
|
|
24
24
|
* `config` together with related properties such as the `configPath`.
|
|
25
25
|
*/
|
|
26
26
|
export const resolveConfig = async function (opts) {
|
|
27
|
-
const { cachedConfig, cachedConfigPath, host, scheme, packagePath, pathPrefix, testOpts, token, offline,
|
|
27
|
+
const { cachedConfig, cachedConfigPath, host, scheme, packagePath, pathPrefix, testOpts, token, offline, ...optsA } = addDefaultOpts(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 (parsedCachedConfig !== undefined) {
|
|
32
32
|
return parsedCachedConfig;
|
|
33
33
|
}
|
|
34
|
-
const { config: configOpt, defaultConfig, inlineConfig, configMutations, cwd, context, repositoryRoot, base, branch, siteId, deployId, buildId, baseRelDir, mode, debug, logs, featureFlags, } = await normalizeOpts(optsA);
|
|
34
|
+
const { config: configOpt, defaultConfig, inlineConfig, configMutations, cwd, context, repositoryRoot, base, branch, siteId, accountId, deployId, buildId, baseRelDir, mode, debug, logs, featureFlags, } = await normalizeOpts(optsA);
|
|
35
35
|
const { siteInfo, accounts, addons, integrations } = await getSiteInfo({
|
|
36
36
|
api,
|
|
37
37
|
context,
|
|
38
38
|
siteId,
|
|
39
|
+
accountId,
|
|
39
40
|
mode,
|
|
40
41
|
offline,
|
|
41
|
-
siteFeatureFlagPrefix,
|
|
42
42
|
featureFlags,
|
|
43
43
|
testOpts,
|
|
44
44
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/config",
|
|
3
|
-
"version": "20.
|
|
3
|
+
"version": "20.15.1",
|
|
4
4
|
"description": "Netlify config module",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./lib/index.js",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"is-plain-obj": "^4.0.0",
|
|
73
73
|
"js-yaml": "^4.0.0",
|
|
74
74
|
"map-obj": "^5.0.0",
|
|
75
|
-
"netlify": "^13.1.
|
|
75
|
+
"netlify": "^13.1.18",
|
|
76
76
|
"netlify-headers-parser": "^7.1.4",
|
|
77
77
|
"netlify-redirect-parser": "^14.3.0",
|
|
78
78
|
"node-fetch": "^3.3.1",
|
|
@@ -95,5 +95,5 @@
|
|
|
95
95
|
"engines": {
|
|
96
96
|
"node": "^14.16.0 || >=16.0.0"
|
|
97
97
|
},
|
|
98
|
-
"gitHead": "
|
|
98
|
+
"gitHead": "aa96e910e165bde1a46101bcf73702818d008214"
|
|
99
99
|
}
|