@netlify/config 20.6.4 → 20.7.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.
@@ -2,28 +2,26 @@ import fetch from 'node-fetch';
2
2
  import { getEnvelope } from '../env/envelope.js';
3
3
  import { throwUserError } from '../error.js';
4
4
  import { ERROR_CALL_TO_ACTION } from '../log/messages.js';
5
- // Retrieve Netlify Site information, if available.
6
- // Used to retrieve local build environment variables and UI build settings.
7
- // This is not used in production builds since the buildbot passes this
8
- // information instead.
9
- // Requires knowing the `siteId` and having the access `token`.
10
- // Silently ignore API errors. For example the network connection might be down,
11
- // but local builds should still work regardless.
12
- export const getSiteInfo = async function ({ api, siteId, mode, siteFeatureFlagPrefix, featureFlags = {}, testOpts = {}, }) {
5
+ /**
6
+ * Retrieve Netlify Site information, if available.
7
+ * Used to retrieve local build environment variables and UI build settings.
8
+ * This is not used in production builds since the buildbot passes this
9
+ * information instead.
10
+ * Requires knowing the `siteId` and having the access `token`.
11
+ * Silently ignore API errors. For example the network connection might be down,
12
+ * but local builds should still work regardless.
13
+ */
14
+ export const getSiteInfo = async function ({ api, siteId, mode, siteFeatureFlagPrefix, offline = false, featureFlags = {}, testOpts = {}, }) {
13
15
  const { env: testEnv = false } = testOpts;
14
16
  const fetchIntegrations = featureFlags.buildbot_fetch_integrations;
15
17
  if (api === undefined || mode === 'buildbot' || testEnv) {
16
18
  const siteInfo = siteId === undefined ? {} : { id: siteId };
17
- let integrations = [];
18
- if (fetchIntegrations && api !== undefined && !testEnv) {
19
- // we still want to fetch integrations within buildbot
20
- integrations = await getIntegrations({ api, ownerType: 'site', ownerId: siteId, testOpts });
21
- }
19
+ const integrations = fetchIntegrations && mode === 'buildbot' && !offline ? await getIntegrations({ siteId, testOpts }) : [];
22
20
  return { siteInfo, accounts: [], addons: [], integrations };
23
21
  }
24
22
  const promises = [getSite(api, siteId, siteFeatureFlagPrefix), getAccounts(api), getAddons(api, siteId)];
25
23
  if (fetchIntegrations) {
26
- promises.push(getIntegrations({ api, ownerType: 'site', ownerId: siteId, testOpts }));
24
+ promises.push(getIntegrations({ siteId, testOpts }));
27
25
  }
28
26
  const [siteInfo, accounts, addons, integrations = []] = await Promise.all(promises);
29
27
  if (siteInfo.use_envelope) {
@@ -65,19 +63,14 @@ const getAddons = async function (api, siteId) {
65
63
  throwUserError(`Failed retrieving addons for site ${siteId}: ${error.message}. ${ERROR_CALL_TO_ACTION}`);
66
64
  }
67
65
  };
68
- const getIntegrations = async function ({ api, ownerType, ownerId, testOpts }) {
69
- if (ownerId === undefined) {
66
+ const getIntegrations = async function ({ siteId, testOpts }) {
67
+ if (!siteId) {
70
68
  return [];
71
69
  }
72
70
  const { host } = testOpts;
73
- const baseUrl = host ? `http://${host}` : `https://api.netlifysdk.com`;
71
+ const baseUrl = new URL(host ? `http://${host}` : `https://api.netlifysdk.com`);
74
72
  try {
75
- const token = api.accessToken;
76
- const response = await fetch(`${baseUrl}/${ownerType}/${ownerId}/integrations`, {
77
- headers: {
78
- Authorization: `Bearer ${token}`,
79
- },
80
- });
73
+ const response = await fetch(`${baseUrl}site/${siteId}/integrations/safe`);
81
74
  const integrations = await response.json();
82
75
  return Array.isArray(integrations) ? integrations : [];
83
76
  }
package/lib/main.js CHANGED
@@ -33,9 +33,10 @@ export const resolveConfig = async function (opts) {
33
33
  api,
34
34
  siteId,
35
35
  mode,
36
- testOpts,
36
+ offline,
37
37
  siteFeatureFlagPrefix,
38
38
  featureFlags,
39
+ testOpts,
39
40
  });
40
41
  const { defaultConfig: defaultConfigA, baseRelDir: baseRelDirA } = parseDefaultConfig({
41
42
  defaultConfig,
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/config",
3
- "version": "20.6.4",
3
+ "version": "20.7.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": "5e684d0509bb094d0e11ff89559abf7eb2d806fc"
97
+ "gitHead": "a20207ec7cdc1101a875d9411355bd48f12733a3"
98
98
  }