@netlify/config 20.12.5 → 20.13.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.js +36 -11
- package/lib/bin/flags.js +2 -0
- package/lib/log/logger.js +7 -1
- package/lib/main.js +0 -1
- package/package.json +2 -2
package/lib/api/site_info.js
CHANGED
|
@@ -13,18 +13,37 @@ import { ERROR_CALL_TO_ACTION } from '../log/messages.js';
|
|
|
13
13
|
*/
|
|
14
14
|
export const getSiteInfo = async function ({ api, siteId, mode, siteFeatureFlagPrefix, context, offline = false, testOpts = {}, }) {
|
|
15
15
|
const { env: testEnv = false } = testOpts;
|
|
16
|
-
if (api === undefined ||
|
|
16
|
+
if (api === undefined || testEnv || offline) {
|
|
17
17
|
const siteInfo = siteId === undefined ? {} : { id: siteId };
|
|
18
|
-
|
|
18
|
+
return { siteInfo, accounts: [], addons: [], integrations: [] };
|
|
19
|
+
}
|
|
20
|
+
const siteInfo = await getSite(api, siteId, siteFeatureFlagPrefix);
|
|
21
|
+
const featureFlags = siteInfo.feature_flags;
|
|
22
|
+
const useV2Endpoint = featureFlags?.cli_integration_installations_meta;
|
|
23
|
+
if (useV2Endpoint) {
|
|
24
|
+
const promises = [
|
|
25
|
+
getAccounts(api),
|
|
26
|
+
getAddons(api, siteId),
|
|
27
|
+
getIntegrations({ siteId, testOpts, offline, accountId: siteInfo.account_id, featureFlags }),
|
|
28
|
+
];
|
|
29
|
+
const [accounts, addons, integrations] = await Promise.all(promises);
|
|
30
|
+
if (siteInfo.use_envelope) {
|
|
31
|
+
const envelope = await getEnvelope({ api, accountId: siteInfo.account_slug, siteId, context });
|
|
32
|
+
siteInfo.build_settings.env = envelope;
|
|
33
|
+
}
|
|
34
|
+
return { siteInfo, accounts, addons, integrations };
|
|
35
|
+
}
|
|
36
|
+
if (mode === 'buildbot') {
|
|
37
|
+
const siteInfo = siteId === undefined ? {} : { id: siteId };
|
|
38
|
+
const integrations = await getIntegrations({ siteId, testOpts, offline, featureFlags });
|
|
19
39
|
return { siteInfo, accounts: [], addons: [], integrations };
|
|
20
40
|
}
|
|
21
41
|
const promises = [
|
|
22
|
-
getSite(api, siteId, siteFeatureFlagPrefix),
|
|
23
42
|
getAccounts(api),
|
|
24
43
|
getAddons(api, siteId),
|
|
25
|
-
getIntegrations({ siteId, testOpts, offline }),
|
|
44
|
+
getIntegrations({ siteId, testOpts, offline, featureFlags }),
|
|
26
45
|
];
|
|
27
|
-
const [
|
|
46
|
+
const [accounts, addons, integrations] = await Promise.all(promises);
|
|
28
47
|
if (siteInfo.use_envelope) {
|
|
29
48
|
const envelope = await getEnvelope({ api, accountId: siteInfo.account_slug, siteId, context });
|
|
30
49
|
siteInfo.build_settings.env = envelope;
|
|
@@ -40,7 +59,7 @@ const getSite = async function (api, siteId, siteFeatureFlagPrefix = null) {
|
|
|
40
59
|
return { ...site, id: siteId };
|
|
41
60
|
}
|
|
42
61
|
catch (error) {
|
|
43
|
-
throwUserError(`Failed retrieving site data for site ${siteId}: ${error.message}. ${ERROR_CALL_TO_ACTION}`);
|
|
62
|
+
return throwUserError(`Failed retrieving site data for site ${siteId}: ${error.message}. ${ERROR_CALL_TO_ACTION}`);
|
|
44
63
|
}
|
|
45
64
|
};
|
|
46
65
|
const getAccounts = async function (api) {
|
|
@@ -49,7 +68,7 @@ const getAccounts = async function (api) {
|
|
|
49
68
|
return Array.isArray(accounts) ? accounts : [];
|
|
50
69
|
}
|
|
51
70
|
catch (error) {
|
|
52
|
-
throwUserError(`Failed retrieving user account: ${error.message}. ${ERROR_CALL_TO_ACTION}`);
|
|
71
|
+
return throwUserError(`Failed retrieving user account: ${error.message}. ${ERROR_CALL_TO_ACTION}`);
|
|
53
72
|
}
|
|
54
73
|
};
|
|
55
74
|
const getAddons = async function (api, siteId) {
|
|
@@ -61,22 +80,28 @@ const getAddons = async function (api, siteId) {
|
|
|
61
80
|
return Array.isArray(addons) ? addons : [];
|
|
62
81
|
}
|
|
63
82
|
catch (error) {
|
|
64
|
-
throwUserError(`Failed retrieving addons for site ${siteId}: ${error.message}. ${ERROR_CALL_TO_ACTION}`);
|
|
83
|
+
return throwUserError(`Failed retrieving addons for site ${siteId}: ${error.message}. ${ERROR_CALL_TO_ACTION}`);
|
|
65
84
|
}
|
|
66
85
|
};
|
|
67
|
-
const getIntegrations = async function ({ siteId, testOpts, offline, }) {
|
|
86
|
+
const getIntegrations = async function ({ siteId, accountId, testOpts, offline, featureFlags, }) {
|
|
68
87
|
if (!siteId || offline) {
|
|
69
88
|
return [];
|
|
70
89
|
}
|
|
71
90
|
const { host } = testOpts;
|
|
72
91
|
const baseUrl = new URL(host ? `http://${host}` : `https://api.netlifysdk.com`);
|
|
92
|
+
const useV2Endpoint = featureFlags?.cli_integration_installations_meta;
|
|
93
|
+
const url = useV2Endpoint
|
|
94
|
+
? `${baseUrl}team/${accountId}/integrations/installations/meta`
|
|
95
|
+
: `${baseUrl}site/${siteId}/integrations/safe`;
|
|
73
96
|
try {
|
|
74
|
-
const response = await fetch(
|
|
97
|
+
const response = await fetch(url);
|
|
75
98
|
const integrations = await response.json();
|
|
76
99
|
return Array.isArray(integrations) ? integrations : [];
|
|
77
100
|
}
|
|
78
101
|
catch (error) {
|
|
79
|
-
//
|
|
102
|
+
// Integrations should not block the build if they fail to load
|
|
103
|
+
// TODO: We should consider blocking the build as integrations are a critical part of the build process
|
|
104
|
+
// https://linear.app/netlify/issue/CT-1214/implement-strategy-in-builds-to-deal-with-integrations-that-we-fail-to
|
|
80
105
|
return [];
|
|
81
106
|
}
|
|
82
107
|
};
|
package/lib/bin/flags.js
CHANGED
|
@@ -5,6 +5,8 @@ import { hideBin } from 'yargs/helpers';
|
|
|
5
5
|
import { normalizeCliFeatureFlags } from '../options/feature_flags.js';
|
|
6
6
|
// Parse CLI flags
|
|
7
7
|
export const parseFlags = function () {
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
9
|
+
// @ts-ignore: `yargs` types are incorrect
|
|
8
10
|
const { featureFlags: cliFeatureFlags = '', ...flags } = yargs(hideBin(process.argv))
|
|
9
11
|
.options(FLAGS)
|
|
10
12
|
.usage(USAGE)
|
package/lib/log/logger.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import figures from 'figures';
|
|
2
2
|
import { serializeObject } from './serialize.js';
|
|
3
3
|
import { THEME } from './theme.js';
|
|
4
|
+
export const logsAreBuffered = (logs) => {
|
|
5
|
+
return logs !== undefined && 'stdout' in logs;
|
|
6
|
+
};
|
|
4
7
|
// When the `buffer` option is true, we return logs instead of printing them
|
|
5
8
|
// on the console. The logs are accumulated in a `logs` array variable.
|
|
6
9
|
export const getBufferLogs = function ({ buffer }) {
|
|
@@ -14,7 +17,10 @@ export const getBufferLogs = function ({ buffer }) {
|
|
|
14
17
|
export const log = function (logs, string, { color } = {}) {
|
|
15
18
|
const stringA = String(string).replace(EMPTY_LINES_REGEXP, EMPTY_LINE);
|
|
16
19
|
const stringB = color === undefined ? stringA : color(stringA);
|
|
17
|
-
if (logs
|
|
20
|
+
if (logs && logs.outputFlusher) {
|
|
21
|
+
logs.outputFlusher.flush();
|
|
22
|
+
}
|
|
23
|
+
if (logsAreBuffered(logs)) {
|
|
18
24
|
// `logs` is a stateful variable
|
|
19
25
|
logs.stderr.push(stringB);
|
|
20
26
|
return;
|
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.13.0",
|
|
4
4
|
"description": "Netlify config module",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./lib/index.js",
|
|
@@ -94,5 +94,5 @@
|
|
|
94
94
|
"engines": {
|
|
95
95
|
"node": "^14.16.0 || >=16.0.0"
|
|
96
96
|
},
|
|
97
|
-
"gitHead": "
|
|
97
|
+
"gitHead": "14419e3fd6fdeaba6d8f4460e5c13871db7f26ef"
|
|
98
98
|
}
|