@netlify/config 20.6.0 → 20.6.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.
@@ -9,7 +9,8 @@ import { ERROR_CALL_TO_ACTION } from '../log/messages.js';
9
9
  // Requires knowing the `siteId` and having the access `token`.
10
10
  // Silently ignore API errors. For example the network connection might be down,
11
11
  // but local builds should still work regardless.
12
- export const getSiteInfo = async function ({ api, siteId, mode, siteFeatureFlagPrefix, featureFlags = {}, testOpts: { env: testEnv = true } = {}, }) {
12
+ export const getSiteInfo = async function ({ api, siteId, mode, siteFeatureFlagPrefix, featureFlags = {}, testOpts = {}, }) {
13
+ const { env: testEnv = true } = testOpts;
13
14
  if (api === undefined || mode === 'buildbot' || !testEnv) {
14
15
  const siteInfo = siteId === undefined ? {} : { id: siteId };
15
16
  return { siteInfo, accounts: [], addons: [] };
@@ -17,14 +18,14 @@ export const getSiteInfo = async function ({ api, siteId, mode, siteFeatureFlagP
17
18
  const fetchIntegrations = featureFlags.buildbot_fetch_integrations;
18
19
  const promises = [getSite(api, siteId, siteFeatureFlagPrefix), getAccounts(api), getAddons(api, siteId)];
19
20
  if (fetchIntegrations) {
20
- promises.push(getIntegrations({ api, ownerType: 'site', ownerId: siteId }));
21
+ promises.push(getIntegrations({ api, ownerType: 'site', ownerId: siteId, testOpts }));
21
22
  }
22
23
  const [siteInfo, accounts, addons, integrations = []] = await Promise.all(promises);
23
24
  if (siteInfo.use_envelope) {
24
25
  const envelope = await getEnvelope({ api, accountId: siteInfo.account_slug, siteId });
25
26
  siteInfo.build_settings.env = envelope;
26
27
  }
27
- return { siteInfo, accounts, addons, integrations: integrations ?? [] };
28
+ return { siteInfo, accounts, addons, integrations: integrations };
28
29
  };
29
30
  const getSite = async function (api, siteId, siteFeatureFlagPrefix = null) {
30
31
  if (siteId === undefined) {
@@ -59,13 +60,15 @@ const getAddons = async function (api, siteId) {
59
60
  throwUserError(`Failed retrieving addons for site ${siteId}: ${error.message}. ${ERROR_CALL_TO_ACTION}`);
60
61
  }
61
62
  };
62
- const getIntegrations = async function ({ api, ownerType, ownerId }) {
63
+ const getIntegrations = async function ({ api, ownerType, ownerId, testOpts }) {
63
64
  if (ownerId === undefined) {
64
65
  return [];
65
66
  }
67
+ const { host } = testOpts;
68
+ const baseUrl = host ? `http://${host}` : `https://api.netlifysdk.com`;
66
69
  try {
67
- const token = api.accessToken();
68
- const response = await fetch(`https://api.netlifysdk.com/${ownerType}/${ownerId}/integrations`, {
70
+ const token = api.accessToken;
71
+ const response = await fetch(`${baseUrl}/${ownerType}/${ownerId}/integrations`, {
69
72
  headers: {
70
73
  Authorization: `Bearer ${token}`,
71
74
  },
@@ -18,6 +18,12 @@ export const validations = [
18
18
  message: '"path" and "pattern" are mutually exclusive.',
19
19
  example: () => ({ edge_functions: [{ path: '/hello', function: 'hello' }] }),
20
20
  },
21
+ {
22
+ property: 'edge_functions.*',
23
+ check: (edgeFunction) => !(edgeFunction.excludedPath !== undefined && edgeFunction.excludedPattern !== undefined),
24
+ message: '"excludedPath" and "excludedPattern" are mutually exclusive.',
25
+ example: () => ({ edge_functions: [{ path: '/hello/*', function: 'hello', excludedPath: '/hello/no' }] }),
26
+ },
21
27
  {
22
28
  property: 'edge_functions.*',
23
29
  check: (edgeFunction) => edgeFunction.function !== undefined,
@@ -38,14 +44,6 @@ export const validations = [
38
44
  edge_functions: [{ path: '/products/*', excludedPath: ['/products/*.jpg'], function: 'customise' }],
39
45
  }),
40
46
  },
41
- {
42
- property: 'edge_functions.*',
43
- check: (value) => value.excludedPath === undefined || value.path !== undefined,
44
- message: '"excludedPath" can only be specified together with "path".',
45
- example: () => ({
46
- edge_functions: [{ path: '/products/*', excludedPath: ['/products/*.jpg'], function: 'customise' }],
47
- }),
48
- },
49
47
  {
50
48
  property: 'edge_functions.*.pattern',
51
49
  check: isString,
@@ -57,15 +55,7 @@ export const validations = [
57
55
  check: (value) => isString(value) || (Array.isArray(value) && value.every(isString)),
58
56
  message: 'must be a string or array of strings.',
59
57
  example: () => ({
60
- edge_functions: [{ path: '/products/(.*)', excludedPath: ['/products/(.*)\\.jpg'], function: 'customise' }],
61
- }),
62
- },
63
- {
64
- property: 'edge_functions.*.excludedPattern',
65
- check: (value) => value.excludedPattern === undefined || value.pattern !== undefined,
66
- message: '"excludedPattern" can only be specified together with "pattern".',
67
- example: () => ({
68
- edge_functions: [{ path: '/products/(.*)', excludedPath: ['/products/(.*)\\.jpg'], function: 'customise' }],
58
+ edge_functions: [{ path: '/products/(.*)', excludedPattern: ['^/products/(.*)\\.jpg$'], function: 'customise' }],
69
59
  }),
70
60
  },
71
61
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/config",
3
- "version": "20.6.0",
3
+ "version": "20.6.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": "34f833bce745039add76a082f8dcfd682f9f7de0"
97
+ "gitHead": "487f1b282fed53beeb3ea17db151a741535ba8fc"
98
98
  }