@netlify/config 20.21.7 → 20.22.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/lib/api/site_info.d.ts +2 -1
- package/lib/api/site_info.js +21 -25
- package/lib/main.js +1 -0
- package/package.json +2 -2
package/lib/api/site_info.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ type GetSiteInfoOpts = {
|
|
|
10
10
|
featureFlags?: Record<string, boolean>;
|
|
11
11
|
testOpts?: TestOptions;
|
|
12
12
|
siteFeatureFlagPrefix: string;
|
|
13
|
+
token: string;
|
|
13
14
|
};
|
|
14
15
|
/**
|
|
15
16
|
* Retrieve Netlify Site information, if available.
|
|
@@ -20,7 +21,7 @@ type GetSiteInfoOpts = {
|
|
|
20
21
|
* Silently ignore API errors. For example the network connection might be down,
|
|
21
22
|
* but local builds should still work regardless.
|
|
22
23
|
*/
|
|
23
|
-
export declare const getSiteInfo: ({ api, siteId, accountId, mode, context, offline, testOpts, siteFeatureFlagPrefix, featureFlags, }: GetSiteInfoOpts) => Promise<{
|
|
24
|
+
export declare const getSiteInfo: ({ api, siteId, accountId, mode, context, offline, testOpts, siteFeatureFlagPrefix, token, featureFlags, }: GetSiteInfoOpts) => Promise<{
|
|
24
25
|
siteInfo: any;
|
|
25
26
|
accounts: any;
|
|
26
27
|
addons: any;
|
package/lib/api/site_info.js
CHANGED
|
@@ -11,9 +11,8 @@ 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, accountId, mode, context, offline = false, testOpts = {}, siteFeatureFlagPrefix, featureFlags = {}, }) {
|
|
14
|
+
export const getSiteInfo = async function ({ api, siteId, accountId, mode, context, offline = false, testOpts = {}, siteFeatureFlagPrefix, token, featureFlags = {}, }) {
|
|
15
15
|
const { env: testEnv = false } = testOpts;
|
|
16
|
-
const errorOnExtensionFetchFail = featureFlags.error_builds_on_extension_fetch_fail;
|
|
17
16
|
if (api === undefined || mode === 'buildbot' || testEnv) {
|
|
18
17
|
const siteInfo = {};
|
|
19
18
|
if (siteId !== undefined)
|
|
@@ -21,7 +20,7 @@ export const getSiteInfo = async function ({ api, siteId, accountId, mode, conte
|
|
|
21
20
|
if (accountId !== undefined)
|
|
22
21
|
siteInfo.account_id = accountId;
|
|
23
22
|
const integrations = mode === 'buildbot' && !offline
|
|
24
|
-
? await getIntegrations({ siteId, testOpts, offline, accountId,
|
|
23
|
+
? await getIntegrations({ siteId, testOpts, offline, accountId, token, featureFlags })
|
|
25
24
|
: [];
|
|
26
25
|
return { siteInfo, accounts: [], addons: [], integrations };
|
|
27
26
|
}
|
|
@@ -29,7 +28,7 @@ export const getSiteInfo = async function ({ api, siteId, accountId, mode, conte
|
|
|
29
28
|
getSite(api, siteId, siteFeatureFlagPrefix),
|
|
30
29
|
getAccounts(api),
|
|
31
30
|
getAddons(api, siteId),
|
|
32
|
-
getIntegrations({ siteId, testOpts, offline, accountId,
|
|
31
|
+
getIntegrations({ siteId, testOpts, offline, accountId, token, featureFlags }),
|
|
33
32
|
];
|
|
34
33
|
const [siteInfo, accounts, addons, integrations] = await Promise.all(promises);
|
|
35
34
|
if (siteInfo.use_envelope) {
|
|
@@ -71,39 +70,36 @@ const getAddons = async function (api, siteId) {
|
|
|
71
70
|
throwUserError(`Failed retrieving addons for site ${siteId}: ${error.message}. ${ERROR_CALL_TO_ACTION}`);
|
|
72
71
|
}
|
|
73
72
|
};
|
|
74
|
-
const getIntegrations = async function ({ siteId, accountId, testOpts, offline,
|
|
73
|
+
const getIntegrations = async function ({ siteId, accountId, testOpts, offline, token, featureFlags, }) {
|
|
75
74
|
if (!siteId || offline) {
|
|
76
75
|
return [];
|
|
77
76
|
}
|
|
77
|
+
const sendBuildBotTokenToJigsaw = featureFlags?.send_build_bot_token_to_jigsaw;
|
|
78
78
|
const { host } = testOpts;
|
|
79
79
|
const baseUrl = new URL(host ? `http://${host}` : `https://api.netlifysdk.com`);
|
|
80
80
|
// if accountId isn't present, use safe v1 endpoint
|
|
81
81
|
const url = accountId
|
|
82
82
|
? `${baseUrl}team/${accountId}/integrations/installations/meta/${siteId}`
|
|
83
83
|
: `${baseUrl}site/${siteId}/integrations/safe`;
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
const bodyText = await response.text();
|
|
91
|
-
if (bodyText === '') {
|
|
92
|
-
return [];
|
|
93
|
-
}
|
|
94
|
-
const integrations = await JSON.parse(bodyText);
|
|
95
|
-
return Array.isArray(integrations) ? integrations : [];
|
|
84
|
+
try {
|
|
85
|
+
const requestOptions = {};
|
|
86
|
+
if (sendBuildBotTokenToJigsaw && token) {
|
|
87
|
+
requestOptions.headers = {
|
|
88
|
+
'netlify-sdk-build-bot-token': token,
|
|
89
|
+
};
|
|
96
90
|
}
|
|
97
|
-
|
|
98
|
-
|
|
91
|
+
const response = await fetch(url, requestOptions);
|
|
92
|
+
if (!response.ok) {
|
|
93
|
+
throw new Error(`Unexpected status code ${response.status} from fetching extensions`);
|
|
99
94
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
95
|
+
const bodyText = await response.text();
|
|
96
|
+
if (bodyText === '') {
|
|
97
|
+
return [];
|
|
98
|
+
}
|
|
99
|
+
const integrations = await JSON.parse(bodyText);
|
|
104
100
|
return Array.isArray(integrations) ? integrations : [];
|
|
105
101
|
}
|
|
106
|
-
catch {
|
|
107
|
-
return
|
|
102
|
+
catch (error) {
|
|
103
|
+
return throwUserError(`Failed retrieving extensions for site ${siteId}: ${error.message}. ${ERROR_CALL_TO_ACTION}`);
|
|
108
104
|
}
|
|
109
105
|
};
|
package/lib/main.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/config",
|
|
3
|
-
"version": "20.
|
|
3
|
+
"version": "20.22.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": "b1de419113daee962ab37b1e75bcfc0d32f778e7"
|
|
99
99
|
}
|