@netlify/config 20.19.0 → 20.20.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/base.d.ts CHANGED
@@ -4,9 +4,7 @@
4
4
  export declare const getInitialBase: ({ repositoryRoot, defaultConfig: { build: { base: defaultBase } }, inlineConfig: { build: { base: initialBase } }, }: {
5
5
  repositoryRoot: any;
6
6
  defaultConfig: {
7
- build?: {
8
- base: any;
9
- } | undefined;
7
+ build?: {} | undefined;
10
8
  };
11
9
  inlineConfig: {
12
10
  build?: {
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,
@@ -4,10 +4,10 @@ export const getEnvelope = async function ({ api, accountId, siteId, context, })
4
4
  }
5
5
  try {
6
6
  const environmentVariables = await api.getEnvVars({ accountId, siteId, context_name: context });
7
- const sortedEnvVarsFromDevContext = environmentVariables
7
+ const sortedEnvVarsFromContext = environmentVariables
8
8
  .sort((left, right) => (left.key.toLowerCase() < right.key.toLowerCase() ? -1 : 1))
9
9
  .reduce((acc, cur) => {
10
- const envVar = cur.values.find((val) => ['dev', 'all'].includes(val.context));
10
+ const envVar = cur.values.find((val) => ['all', context].includes(val.context));
11
11
  if (envVar && envVar.value) {
12
12
  return {
13
13
  ...acc,
@@ -16,7 +16,7 @@ export const getEnvelope = async function ({ api, accountId, siteId, context, })
16
16
  }
17
17
  return acc;
18
18
  }, {});
19
- return sortedEnvVarsFromDevContext;
19
+ return sortedEnvVarsFromContext;
20
20
  }
21
21
  catch {
22
22
  return {};
package/lib/env/main.js CHANGED
@@ -122,7 +122,7 @@ const getUserEnv = async function ({ api, config, siteInfo, accounts, addons, co
122
122
  // Account-wide environment variables
123
123
  const getAccountEnv = async function ({ api, siteInfo, accounts, context, }) {
124
124
  if (siteInfo.use_envelope) {
125
- const envelope = await getEnvelope({ api, accountId: siteInfo.account_slug, context });
125
+ const envelope = await getEnvelope({ api, accountId: siteInfo.account_slug, siteId: siteInfo.site_id, context });
126
126
  return envelope;
127
127
  }
128
128
  const { site_env: siteEnv = {} } = accounts.find(({ slug }) => slug === siteInfo.account_slug) || {};
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 } }) {
@@ -1,18 +1,10 @@
1
1
  export function cleanupConfig({ build: { base, command, commandOrigin, environment, edge_functions: edgeFunctions, ignore, processing, publish, publishOrigin, }, headers, headersOrigin, plugins, redirects, redirectsOrigin, baseRelDir, functions, functionsDirectory, }: {
2
2
  build?: {
3
- base: any;
4
- command: any;
5
- commandOrigin: any;
6
3
  environment?: {} | undefined;
7
- edge_functions: any;
8
- ignore: any;
9
- processing: any;
10
- publish: any;
11
- publishOrigin: any;
12
4
  } | undefined;
13
5
  headers: any;
14
6
  headersOrigin: any;
15
- plugins?: any[] | undefined;
7
+ plugins?: never[] | undefined;
16
8
  redirects: any;
17
9
  redirectsOrigin: any;
18
10
  baseRelDir: any;
@@ -5,9 +5,7 @@ export function getBufferLogs({ buffer }: {
5
5
  stdout: never[];
6
6
  stderr: never[];
7
7
  } | undefined;
8
- export function log(logs: any, string: any, { color }?: {
9
- color: any;
10
- }): void;
8
+ export function log(logs: any, string: any, { color }?: {}): void;
11
9
  export function logWarning(logs: any, string: any, opts: any): void;
12
10
  export function logObject(logs: any, object: any, opts: any): void;
13
11
  export function logSubHeader(logs: any, string: any, opts: any): void;
package/lib/merge.d.ts CHANGED
@@ -1,3 +1 @@
1
- export function mergeConfigs(configs: any, { concatenateArrays }?: {
2
- concatenateArrays: any;
3
- }): object;
1
+ export function mergeConfigs(configs: any, { concatenateArrays }?: {}): object;
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 } }) {
package/lib/simplify.d.ts CHANGED
@@ -1,14 +1,7 @@
1
1
  export function simplifyConfig({ build: { environment, processing: { css, html, images, js, ...processing }, services, ...build }, functions, plugins, headers, redirects, context, ...config }: {
2
2
  [x: string]: any;
3
3
  build?: {
4
- environment: any;
5
- processing?: {
6
- css: any;
7
- html: any;
8
- images: any;
9
- js: any;
10
- } | undefined;
11
- services: any;
4
+ processing?: {} | undefined;
12
5
  } | undefined;
13
6
  functions: any;
14
7
  plugins: any;
@@ -5,4 +5,5 @@ export type Integration = {
5
5
  dev?: {
6
6
  path: string;
7
7
  };
8
+ author?: string;
8
9
  };
@@ -6,9 +6,7 @@ export function validProperties(propNames: any, legacyPropNames: any): {
6
6
  message: string;
7
7
  };
8
8
  export namespace functionsDirectoryCheck {
9
- function formatInvalid({ functionsDirectory }?: {
10
- functionsDirectory: any;
11
- }): {
9
+ function formatInvalid({ functionsDirectory }?: {}): {
12
10
  functions: {
13
11
  directory: any;
14
12
  };
@@ -1,3 +1,3 @@
1
1
  export function validateIdenticalPlugins({ plugins }: {
2
- plugins?: any[] | undefined;
2
+ plugins?: never[] | undefined;
3
3
  }): void;
@@ -276,9 +276,7 @@ export const POST_NORMALIZE_VALIDATIONS: ({
276
276
  directory: string;
277
277
  };
278
278
  };
279
- formatInvalid: ({ functionsDirectory }?: {
280
- functionsDirectory: any;
281
- }) => {
279
+ formatInvalid: ({ functionsDirectory }?: {}) => {
282
280
  functions: {
283
281
  directory: any;
284
282
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/config",
3
- "version": "20.19.0",
3
+ "version": "20.20.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.2.0",
63
+ "@netlify/redirect-parser": "^14.4.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": "4ae7f95ca7b31f392956894d5cd6ecf781349b55"
98
+ "gitHead": "131a644bfde5205f730f3369b778d8914c7c0382"
99
99
  }