@netlify/config 20.19.1 → 20.21.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.
@@ -20,7 +20,7 @@ type GetSiteInfoOpts = {
20
20
  * Silently ignore API errors. For example the network connection might be down,
21
21
  * but local builds should still work regardless.
22
22
  */
23
- export declare const getSiteInfo: ({ api, siteId, accountId, mode, context, offline, testOpts, featureFlags, siteFeatureFlagPrefix, }: GetSiteInfoOpts) => Promise<{
23
+ export declare const getSiteInfo: ({ api, siteId, accountId, mode, context, offline, testOpts, siteFeatureFlagPrefix, }: GetSiteInfoOpts) => Promise<{
24
24
  siteInfo: any;
25
25
  accounts: any;
26
26
  addons: any;
@@ -11,48 +11,22 @@ 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 = {}, featureFlags = {}, siteFeatureFlagPrefix, }) {
14
+ export const getSiteInfo = async function ({ api, siteId, accountId, mode, context, offline = false, testOpts = {}, siteFeatureFlagPrefix, }) {
15
15
  const { env: testEnv = false } = testOpts;
16
- const useV2Endpoint = !!accountId && featureFlags.cli_integration_installations_meta;
17
- if (useV2Endpoint) {
18
- if (api === undefined || mode === 'buildbot' || testEnv) {
19
- const siteInfo = {};
20
- if (siteId !== undefined)
21
- siteInfo.id = siteId;
22
- if (accountId !== undefined)
23
- siteInfo.account_id = accountId;
24
- const integrations = mode === 'buildbot' && !offline
25
- ? await getIntegrations({ siteId, testOpts, offline, useV2Endpoint, accountId })
26
- : [];
27
- return { siteInfo, accounts: [], addons: [], integrations };
28
- }
29
- const promises = [
30
- getSite(api, siteId, siteFeatureFlagPrefix),
31
- getAccounts(api),
32
- getAddons(api, siteId),
33
- getIntegrations({ siteId, testOpts, offline, useV2Endpoint, accountId }),
34
- ];
35
- const [siteInfo, accounts, addons, integrations] = await Promise.all(promises);
36
- if (siteInfo.use_envelope) {
37
- const envelope = await getEnvelope({ api, accountId: siteInfo.account_slug, siteId, context });
38
- siteInfo.build_settings.env = envelope;
39
- }
40
- return { siteInfo, accounts, addons, integrations };
41
- }
42
16
  if (api === undefined || mode === 'buildbot' || testEnv) {
43
17
  const siteInfo = {};
44
18
  if (siteId !== undefined)
45
19
  siteInfo.id = siteId;
46
20
  if (accountId !== undefined)
47
21
  siteInfo.account_id = accountId;
48
- const integrations = mode === 'buildbot' && !offline ? await getIntegrations({ siteId, testOpts, offline }) : [];
22
+ const integrations = mode === 'buildbot' && !offline ? await getIntegrations({ siteId, testOpts, offline, accountId }) : [];
49
23
  return { siteInfo, accounts: [], addons: [], integrations };
50
24
  }
51
25
  const promises = [
52
26
  getSite(api, siteId, siteFeatureFlagPrefix),
53
27
  getAccounts(api),
54
28
  getAddons(api, siteId),
55
- getIntegrations({ siteId, testOpts, offline }),
29
+ getIntegrations({ siteId, testOpts, offline, accountId }),
56
30
  ];
57
31
  const [siteInfo, accounts, addons, integrations] = await Promise.all(promises);
58
32
  if (siteInfo.use_envelope) {
@@ -94,25 +68,33 @@ const getAddons = async function (api, siteId) {
94
68
  throwUserError(`Failed retrieving addons for site ${siteId}: ${error.message}. ${ERROR_CALL_TO_ACTION}`);
95
69
  }
96
70
  };
97
- const getIntegrations = async function ({ siteId, accountId, testOpts, offline, useV2Endpoint, }) {
71
+ const getIntegrations = async function ({ siteId, accountId, testOpts, offline, }) {
98
72
  if (!siteId || offline) {
99
73
  return [];
100
74
  }
101
75
  const { host } = testOpts;
102
76
  const baseUrl = new URL(host ? `http://${host}` : `https://api.netlifysdk.com`);
103
- // use future state feature flag
104
- const url = useV2Endpoint
77
+ // if accountId isn't present, use safe v1 endpoint
78
+ const url = accountId
105
79
  ? `${baseUrl}team/${accountId}/integrations/installations/meta/${siteId}`
106
80
  : `${baseUrl}site/${siteId}/integrations/safe`;
81
+ let response;
107
82
  try {
108
- const response = await fetch(url);
109
- const integrations = await response.json();
110
- return Array.isArray(integrations) ? integrations : [];
83
+ response = await fetch(url);
84
+ if (response.status !== 200) {
85
+ throw new Error(`Unexpected status code ${response.status} from fetching extensions`);
86
+ }
111
87
  }
112
88
  catch (error) {
113
- // Integrations should not block the build if they fail to load
114
- // TODO: We should consider blocking the build as integrations are a critical part of the build process
115
- // https://linear.app/netlify/issue/CT-1214/implement-strategy-in-builds-to-deal-with-integrations-that-we-fail-to
116
- return [];
89
+ throwUserError(`Failed retrieving extensions for site ${siteId}: ${error.message}. ${ERROR_CALL_TO_ACTION}`);
90
+ }
91
+ try {
92
+ if (Number(response.headers.get(`content-length`)) === 0)
93
+ return [];
94
+ const responseBody = await response.json();
95
+ return Array.isArray(responseBody) ? responseBody : [];
96
+ }
97
+ catch (error) {
98
+ throwUserError(`Failed to parse extensions for site ${siteId}: ${error.message}. ${ERROR_CALL_TO_ACTION}`);
117
99
  }
118
100
  };
package/lib/case.d.ts CHANGED
@@ -1,16 +1,5 @@
1
- export function normalizeConfigCase({ Build, build, ...config }: {
2
- [x: string]: any;
3
- Build: any;
4
- build?: any;
5
- }): {
6
- build: {
7
- base: any;
8
- command: any;
9
- edge_functions: any;
10
- environment: any;
11
- functions: any;
12
- ignore: any;
13
- processing: any;
14
- publish: any;
15
- };
16
- };
1
+ export declare const normalizeConfigCase: ({ Build, build, ...config }: {
2
+ Build: Record<string, unknown>;
3
+ build: Record<string, unknown>;
4
+ [key: string]: unknown;
5
+ }) => Record<string, unknown>;
package/lib/case.js CHANGED
@@ -3,7 +3,7 @@ export const normalizeConfigCase = function ({ Build, build = Build, ...config }
3
3
  const buildA = normalizeBuildCase(build);
4
4
  return { ...config, build: buildA };
5
5
  };
6
- const normalizeBuildCase = function ({ Base, base = Base, Command, command = Command, Edge_functions: EdgeFunctions, edge_functions: edgeFunctions = EdgeFunctions, Environment, environment = Environment, Functions, functions = Functions, Ignore, ignore = Ignore, Processing, processing = Processing, Publish, publish = Publish, ...build } = {}) {
6
+ const normalizeBuildCase = ({ Base, base = Base, Command, command = Command, Edge_functions: EdgeFunctions, edge_functions: edgeFunctions = EdgeFunctions, Environment, environment = Environment, Functions, functions = Functions, Ignore, ignore = Ignore, Processing, processing = Processing, Publish, publish = Publish, ...build } = {}) => {
7
7
  return {
8
8
  ...build,
9
9
  base,
package/lib/headers.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { resolve } from 'path';
2
- import { parseAllHeaders } from 'netlify-headers-parser';
2
+ import { parseAllHeaders } from '@netlify/headers-parser';
3
3
  import { warnHeadersParsing, warnHeadersCaseSensitivity } from './log/messages.js';
4
4
  // Retrieve path to `_headers` file (even if it does not exist yet)
5
5
  export const getHeadersPath = function ({ build: { publish } }) {
package/lib/redirects.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { resolve } from 'path';
2
- import { parseAllRedirects } from 'netlify-redirect-parser';
2
+ import { parseAllRedirects } from '@netlify/redirect-parser';
3
3
  import { warnRedirectsParsing } from './log/messages.js';
4
4
  // Retrieve path to `_redirects` file (even if it does not exist yet)
5
5
  export const getRedirectsPath = function ({ build: { publish } }) {
@@ -5,4 +5,5 @@ export type Integration = {
5
5
  dev?: {
6
6
  path: string;
7
7
  };
8
+ author?: string;
8
9
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/config",
3
- "version": "20.19.1",
3
+ "version": "20.21.0",
4
4
  "description": "Netlify config module",
5
5
  "type": "module",
6
6
  "exports": "./lib/index.js",
@@ -59,6 +59,8 @@
59
59
  "license": "MIT",
60
60
  "dependencies": {
61
61
  "@iarna/toml": "^2.2.5",
62
+ "@netlify/headers-parser": "^7.3.0",
63
+ "@netlify/redirect-parser": "^14.5.0",
62
64
  "chalk": "^5.0.0",
63
65
  "cron-parser": "^4.1.0",
64
66
  "deepmerge": "^4.2.2",
@@ -72,9 +74,7 @@
72
74
  "is-plain-obj": "^4.0.0",
73
75
  "js-yaml": "^4.0.0",
74
76
  "map-obj": "^5.0.0",
75
- "netlify": "^13.1.21",
76
- "netlify-headers-parser": "^7.1.4",
77
- "netlify-redirect-parser": "^14.3.0",
77
+ "netlify": "^13.2.0",
78
78
  "node-fetch": "^3.3.1",
79
79
  "omit.js": "^2.0.2",
80
80
  "p-locate": "^6.0.0",
@@ -95,5 +95,5 @@
95
95
  "engines": {
96
96
  "node": "^14.16.0 || >=16.0.0"
97
97
  },
98
- "gitHead": "319d6b39f8382f114b1f7d138b3ea3a312a7b55c"
98
+ "gitHead": "214d1726e1f87eedf1aeb3b62ba5b3e87b84bfab"
99
99
  }