@netlify/config 20.13.1 → 20.13.2

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.
@@ -13,37 +13,18 @@ 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 || testEnv || offline) {
16
+ if (api === undefined || mode === 'buildbot' || testEnv) {
17
17
  const siteInfo = siteId === undefined ? {} : { id: siteId };
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 });
18
+ const integrations = mode === 'buildbot' && !offline ? await getIntegrations({ siteId, testOpts, offline }) : [];
39
19
  return { siteInfo, accounts: [], addons: [], integrations };
40
20
  }
41
21
  const promises = [
22
+ getSite(api, siteId, siteFeatureFlagPrefix),
42
23
  getAccounts(api),
43
24
  getAddons(api, siteId),
44
- getIntegrations({ siteId, testOpts, offline, featureFlags }),
25
+ getIntegrations({ siteId, testOpts, offline }),
45
26
  ];
46
- const [accounts, addons, integrations] = await Promise.all(promises);
27
+ const [siteInfo, accounts, addons, integrations] = await Promise.all(promises);
47
28
  if (siteInfo.use_envelope) {
48
29
  const envelope = await getEnvelope({ api, accountId: siteInfo.account_slug, siteId, context });
49
30
  siteInfo.build_settings.env = envelope;
@@ -59,7 +40,7 @@ const getSite = async function (api, siteId, siteFeatureFlagPrefix = null) {
59
40
  return { ...site, id: siteId };
60
41
  }
61
42
  catch (error) {
62
- return throwUserError(`Failed retrieving site data for site ${siteId}: ${error.message}. ${ERROR_CALL_TO_ACTION}`);
43
+ throwUserError(`Failed retrieving site data for site ${siteId}: ${error.message}. ${ERROR_CALL_TO_ACTION}`);
63
44
  }
64
45
  };
65
46
  const getAccounts = async function (api) {
@@ -68,7 +49,7 @@ const getAccounts = async function (api) {
68
49
  return Array.isArray(accounts) ? accounts : [];
69
50
  }
70
51
  catch (error) {
71
- return throwUserError(`Failed retrieving user account: ${error.message}. ${ERROR_CALL_TO_ACTION}`);
52
+ throwUserError(`Failed retrieving user account: ${error.message}. ${ERROR_CALL_TO_ACTION}`);
72
53
  }
73
54
  };
74
55
  const getAddons = async function (api, siteId) {
@@ -80,28 +61,22 @@ const getAddons = async function (api, siteId) {
80
61
  return Array.isArray(addons) ? addons : [];
81
62
  }
82
63
  catch (error) {
83
- return throwUserError(`Failed retrieving addons for site ${siteId}: ${error.message}. ${ERROR_CALL_TO_ACTION}`);
64
+ throwUserError(`Failed retrieving addons for site ${siteId}: ${error.message}. ${ERROR_CALL_TO_ACTION}`);
84
65
  }
85
66
  };
86
- const getIntegrations = async function ({ siteId, accountId, testOpts, offline, featureFlags, }) {
67
+ const getIntegrations = async function ({ siteId, testOpts, offline, }) {
87
68
  if (!siteId || offline) {
88
69
  return [];
89
70
  }
90
71
  const { host } = testOpts;
91
72
  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`;
96
73
  try {
97
- const response = await fetch(url);
74
+ const response = await fetch(`${baseUrl}site/${siteId}/integrations/safe`);
98
75
  const integrations = await response.json();
99
76
  return Array.isArray(integrations) ? integrations : [];
100
77
  }
101
78
  catch (error) {
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
79
+ // for now, we'll just ignore errors, as this is early days
105
80
  return [];
106
81
  }
107
82
  };
package/lib/main.js CHANGED
@@ -39,6 +39,7 @@ export const resolveConfig = async function (opts) {
39
39
  mode,
40
40
  offline,
41
41
  siteFeatureFlagPrefix,
42
+ featureFlags,
42
43
  testOpts,
43
44
  });
44
45
  const { defaultConfig: defaultConfigA, baseRelDir: baseRelDirA } = parseDefaultConfig({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/config",
3
- "version": "20.13.1",
3
+ "version": "20.13.2",
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": "600d5f1a934b57f39746083cce925ecfe9025fad"
97
+ "gitHead": "6573e4d27bb60c0b1438ace279791389330286ad"
98
98
  }