@netlify/config 22.0.0-rc → 22.0.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.
package/README.md CHANGED
@@ -47,7 +47,6 @@ const exampleFunction = async function () {
47
47
  // },
48
48
  // ...
49
49
  // ],
50
- // "addons": [],
51
50
  // "env": {
52
51
  // "NODE_VERSION": { "sources": ["configFile"], "value": "16" },
53
52
  // ...
@@ -117,7 +116,7 @@ Path to the `netlify.toml`. It is either an absolute path or a path relative to
117
116
  If not specified, it is searched in the following directories (by highest priority order):
118
117
 
119
118
  - `base` directory
120
- - [`repositoryRoot`](#repositoryRoot)
119
+ - [`repositoryRoot`](#repositoryroot)
121
120
  - current directory
122
121
  - any parent directory
123
122
 
@@ -205,7 +204,7 @@ _Default value_: environment variable `NETLIFY_SITE_ID`
205
204
 
206
205
  Netlify Site ID.
207
206
 
208
- This is used to retrieve [`siteInfo`](#siteinfo), [`accounts`](#accounts) and [`addons`](#addons).
207
+ This is used to retrieve [`siteInfo`](#siteinfo) and [`accounts`](#accounts).
209
208
 
210
209
  #### env
211
210
 
@@ -227,8 +226,8 @@ What is calling `@netlify/config`. Can be:
227
226
 
228
227
  This is used for the following cases:
229
228
 
230
- - if `mode` is `buildbot`, [`siteInfo`](#siteinfo), [`accounts`](#accounts) and [`addons`](#addons) are not retrieved
231
- because they are also passed using another internal option.
229
+ - if `mode` is `buildbot`, [`siteInfo`](#siteinfo) and [`accounts`](#accounts) are not retrieved because they are also
230
+ passed using another internal option.
232
231
 
233
232
  #### defaultConfig
234
233
 
@@ -287,13 +286,13 @@ _Type_: `string`
287
286
  Absolute path to the build directory.
288
287
 
289
288
  The build directory is the current directory in which most build operations, including the build command, execute. It is
290
- usually either the [`repositoryRoot`](#repositoryRoot) or (if specified) the `base` directory.
289
+ usually either the [`repositoryRoot`](#repositoryroot) or (if specified) the `base` directory.
291
290
 
292
291
  #### repositoryRoot
293
292
 
294
293
  _Type_: `string`
295
294
 
296
- The computed value of [`repositoryRoot`](#repositoryRoot).
295
+ The computed value of [`repositoryRoot`](#repositoryroot).
297
296
 
298
297
  #### context
299
298
 
@@ -326,15 +325,6 @@ environment variables.
326
325
 
327
326
  This might be empty depending on the options passed.
328
327
 
329
- #### addons
330
-
331
- _Type_: `object[]`
332
-
333
- Netlify addons retrieved using the `listServiceInstancesForSite` Netlify API endpoint. This is used to retrieve
334
- addon-specific environment variables.
335
-
336
- This might be empty depending on the options passed.
337
-
338
328
  #### token
339
329
 
340
330
  _Type_: `string`
@@ -346,8 +336,8 @@ variables.
346
336
 
347
337
  _Type_: `NetlifyClient?`
348
338
 
349
- Netlify [JavaScript client instance](https://github.com/netlify/js-client) used to retrieve [`siteInfo`](#siteinfo),
350
- [`accounts`](#accounts) and [`addons`](#addons).
339
+ Netlify [JavaScript client instance](https://github.com/netlify/js-client) used to retrieve [`siteInfo`](#siteinfo) and
340
+ [`accounts`](#accounts).
351
341
 
352
342
  #### logs
353
343
 
@@ -365,14 +355,13 @@ Site's environment variables. Each environment variable value is an object with
365
355
  - `sources` `string[]` among:
366
356
  - `general`: general environment variables set for all sites
367
357
  - `account`: environment variables set in the Netlify UI for a specific account
368
- - `addons`: addon-specific environment variables
369
358
  - `ui`: environment variables set in the Netlify UI for a specific site
370
359
  - `configFile`: environment variables set in `netlify.toml`
371
360
 
372
361
  # Usage (CLI)
373
362
 
374
363
  ```bash
375
- $ netlify-config
364
+ netlify-config
376
365
  ```
377
366
 
378
367
  Like [`resolveConfig()`](resolveconfig), but in the CLI. The return value is printed on `stdout`.
@@ -26,7 +26,6 @@ type GetSiteInfoOpts = {
26
26
  export declare const getSiteInfo: ({ api, siteId, accountId, mode, context, offline, testOpts, siteFeatureFlagPrefix, token, featureFlags, extensionApiBaseUrl, }: GetSiteInfoOpts) => Promise<{
27
27
  siteInfo: any;
28
28
  accounts: MinimalAccount[];
29
- addons: any[] | undefined;
30
29
  integrations: IntegrationResponse[];
31
30
  }>;
32
31
  export type MinimalAccount = {
@@ -32,19 +32,18 @@ export const getSiteInfo = async function ({ api, siteId, accountId, mode, conte
32
32
  mode,
33
33
  })
34
34
  : [];
35
- return { siteInfo, accounts: [], addons: [], integrations };
35
+ return { siteInfo, accounts: [], integrations };
36
36
  }
37
- const [siteInfo, accounts, addons, integrations] = await Promise.all([
37
+ const [siteInfo, accounts, integrations] = await Promise.all([
38
38
  getSite(api, siteId, siteFeatureFlagPrefix),
39
39
  getAccounts(api),
40
- getAddons(api, siteId),
41
40
  getIntegrations({ siteId, testOpts, offline, accountId, token, featureFlags, extensionApiBaseUrl, mode }),
42
41
  ]);
43
42
  if (siteInfo.use_envelope) {
44
43
  const envelope = await getEnvelope({ api, accountId: siteInfo.account_slug, siteId, context });
45
44
  siteInfo.build_settings.env = envelope;
46
45
  }
47
- return { siteInfo, accounts, addons, integrations };
46
+ return { siteInfo, accounts, integrations };
48
47
  };
49
48
  const getSite = async function (api, siteId, siteFeatureFlagPrefix) {
50
49
  if (siteId === undefined) {
@@ -69,18 +68,6 @@ const getAccounts = async function (api) {
69
68
  return throwUserError(`Failed retrieving user account: ${error.message}. ${ERROR_CALL_TO_ACTION}`);
70
69
  }
71
70
  };
72
- const getAddons = async function (api, siteId) {
73
- if (siteId === undefined) {
74
- return [];
75
- }
76
- try {
77
- const addons = await api.listServiceInstancesForSite({ siteId });
78
- return Array.isArray(addons) ? addons : [];
79
- }
80
- catch (error) {
81
- throwUserError(`Failed retrieving addons for site ${siteId}: ${error.message}. ${ERROR_CALL_TO_ACTION}`);
82
- }
83
- };
84
71
  const getIntegrations = async function ({ siteId, accountId, testOpts, offline, token, featureFlags, extensionApiBaseUrl, mode, }) {
85
72
  if (!siteId || offline) {
86
73
  return [];
package/lib/env/main.d.ts CHANGED
@@ -1,10 +1,9 @@
1
- export declare const getEnv: ({ api, mode, config, siteInfo, accounts, addons, buildDir, branch, deployId, buildId, context, cachedEnv, }: {
1
+ export declare const getEnv: ({ api, mode, config, siteInfo, accounts, buildDir, branch, deployId, buildId, context, cachedEnv, }: {
2
2
  api: any;
3
3
  mode: any;
4
4
  config: any;
5
5
  siteInfo: any;
6
6
  accounts: any;
7
- addons: any;
8
7
  buildDir: any;
9
8
  branch: any;
10
9
  deployId: any;
package/lib/env/main.js CHANGED
@@ -3,30 +3,28 @@ import { removeFalsy } from '../utils/remove_falsy.js';
3
3
  import { getEnvelope } from './envelope.js';
4
4
  import { getGitEnv } from './git.js';
5
5
  // Retrieve this site's environment variable. Also take into account team-wide
6
- // environment variables and addons.
6
+ // environment variables.
7
7
  // The buildbot already has the right environment variables. This is mostly
8
8
  // meant so that local builds can mimic production builds
9
9
  // TODO: add `netlify.toml` `build.environment`, after normalization
10
10
  // TODO: add `CONTEXT` and others
11
- export const getEnv = async function ({ api, mode, config, siteInfo, accounts, addons, buildDir, branch, deployId, buildId, context, cachedEnv, }) {
11
+ export const getEnv = async function ({ api, mode, config, siteInfo, accounts, buildDir, branch, deployId, buildId, context, cachedEnv, }) {
12
12
  if (mode === 'buildbot') {
13
13
  return {};
14
14
  }
15
15
  const internalEnv = getInternalEnv(cachedEnv);
16
16
  const generalEnv = await getGeneralEnv({ siteInfo, buildDir, branch, deployId, buildId, context });
17
- const [accountEnv, addonsEnv, uiEnv, configFileEnv] = await getUserEnv({
17
+ const [accountEnv, uiEnv, configFileEnv] = await getUserEnv({
18
18
  api,
19
19
  config,
20
20
  siteInfo,
21
21
  accounts,
22
- addons,
23
22
  context,
24
23
  });
25
24
  // Sources of environment variables, in descending order of precedence.
26
25
  const sources = [
27
26
  { key: 'configFile', values: configFileEnv },
28
27
  { key: 'ui', values: uiEnv },
29
- { key: 'addons', values: addonsEnv },
30
28
  { key: 'account', values: accountEnv },
31
29
  { key: 'general', values: generalEnv },
32
30
  { key: 'internal', values: internalEnv },
@@ -113,12 +111,11 @@ const NETLIFY_DEFAULT_DOMAIN = '.netlify.app';
113
111
  // `site.name` is `undefined` when there is no token or siteId
114
112
  const DEFAULT_SITE_NAME = 'site-name';
115
113
  // Environment variables specified by the user
116
- const getUserEnv = async function ({ api, config, siteInfo, accounts, addons, context }) {
114
+ const getUserEnv = async function ({ api, config, siteInfo, accounts, context }) {
117
115
  const accountEnv = await getAccountEnv({ api, siteInfo, accounts, context });
118
- const addonsEnv = getAddonsEnv(addons);
119
116
  const uiEnv = getUiEnv({ siteInfo });
120
117
  const configFileEnv = getConfigFileEnv({ config });
121
- return [accountEnv, addonsEnv, uiEnv, configFileEnv].map(cleanUserEnv);
118
+ return [accountEnv, uiEnv, configFileEnv].map(cleanUserEnv);
122
119
  };
123
120
  // Account-wide environment variables
124
121
  const getAccountEnv = async function ({ api, siteInfo, accounts, context, }) {
@@ -128,13 +125,6 @@ const getAccountEnv = async function ({ api, siteInfo, accounts, context, }) {
128
125
  const { site_env: siteEnv = {} } = accounts.find(({ slug }) => slug === siteInfo.account_slug) || {};
129
126
  return siteEnv;
130
127
  };
131
- // Environment variables from addons
132
- const getAddonsEnv = function (addons) {
133
- return Object.assign({}, ...addons.map(getAddonEnv));
134
- };
135
- const getAddonEnv = function ({ env }) {
136
- return env;
137
- };
138
128
  // Site-specific environment variables set in the UI
139
129
  const getUiEnv = function ({ siteInfo: { build_settings: { env = {} } = {} } }) {
140
130
  return env;
@@ -1,6 +1,5 @@
1
1
  import { IntegrationResponse } from './types/api.js';
2
2
  import { Integration } from './types/integrations.js';
3
- import { TestOptions } from './types/options.js';
4
3
  export declare const NETLIFY_API_STAGING_BASE_URL = "api-staging.netlify.com";
5
4
  export declare const NETLIFY_API_BASE_URL = "api.netlify.com";
6
5
  export declare const EXTENSION_API_BASE_URL = "https://api.netlifysdk.com";
@@ -15,9 +14,6 @@ type MergeIntegrationsOpts = {
15
14
  }[];
16
15
  apiIntegrations: IntegrationResponse[];
17
16
  context: string;
18
- testOpts?: TestOptions;
19
- offline: boolean;
20
- extensionApiBaseUrl: string;
21
17
  };
22
- export declare const mergeIntegrations: ({ configIntegrations, apiIntegrations, context, testOpts, offline, extensionApiBaseUrl, }: MergeIntegrationsOpts) => Promise<Integration[]>;
18
+ export declare const mergeIntegrations: ({ configIntegrations, apiIntegrations, context, }: MergeIntegrationsOpts) => Promise<Integration[]>;
23
19
  export {};
@@ -1,10 +1,8 @@
1
- import { getAvailableIntegrations } from './api/integrations.js';
2
1
  export const NETLIFY_API_STAGING_BASE_URL = 'api-staging.netlify.com';
3
2
  export const NETLIFY_API_BASE_URL = 'api.netlify.com';
4
3
  export const EXTENSION_API_BASE_URL = 'https://api.netlifysdk.com';
5
4
  export const EXTENSION_API_STAGING_BASE_URL = 'https://api-staging.netlifysdk.com';
6
- export const mergeIntegrations = async function ({ configIntegrations = [], apiIntegrations, context, testOpts = {}, offline, extensionApiBaseUrl, }) {
7
- const availableIntegrations = await getAvailableIntegrations({ testOpts, offline, extensionApiBaseUrl });
5
+ export const mergeIntegrations = async function ({ configIntegrations = [], apiIntegrations, context, }) {
8
6
  // Include all API integrations, unless they have a `dev` property and we are in the `dev` context
9
7
  const resolvedApiIntegrations = apiIntegrations.filter((integration) => !configIntegrations.some((configIntegration) => configIntegration.name === integration.slug &&
10
8
  typeof configIntegration.dev !== 'undefined' &&
@@ -15,19 +13,20 @@ export const mergeIntegrations = async function ({ configIntegrations = [], apiI
15
13
  .filter((configIntegration) => apiIntegrations.every((apiIntegration) => apiIntegration.slug !== configIntegration.name) ||
16
14
  ('dev' in configIntegration && context === 'dev'))
17
15
  .map((configIntegration) => {
16
+ const apiIntegration = apiIntegrations.find((apiIntegration) => apiIntegration.slug === configIntegration.name);
18
17
  if (configIntegration.dev && context === 'dev') {
19
- const integrationInstance = apiIntegrations.find((apiIntegration) => apiIntegration.slug === configIntegration.name);
20
18
  return {
21
19
  slug: configIntegration.name,
22
20
  dev: configIntegration.dev,
23
- has_build: integrationInstance?.has_build ?? configIntegration.dev?.force_run_in_build ?? false,
21
+ // TODO(kh): has_build should become irrelevant soon as we are only returning extensions that have a build event handler.
22
+ has_build: apiIntegration?.has_build ?? configIntegration.dev?.force_run_in_build ?? false,
23
+ ...apiIntegration,
24
24
  };
25
25
  }
26
- const integration = availableIntegrations.find((availableIntegration) => availableIntegration.slug === configIntegration.name);
27
- if (!integration) {
26
+ if (!apiIntegration) {
28
27
  return undefined;
29
28
  }
30
- return { slug: integration.slug, version: integration.hostSiteUrl, has_build: !!integration.hasBuild };
29
+ return apiIntegration;
31
30
  })
32
31
  .filter((i) => typeof i !== 'undefined');
33
32
  return [...resolvedApiIntegrations, ...resolvedConfigIntegrations];
package/lib/main.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { type MinimalAccount } from './api/site_info.js';
2
2
  export type Config = {
3
3
  accounts: MinimalAccount[] | undefined;
4
- addons: any;
5
4
  api: any;
6
5
  branch: any;
7
6
  buildDir: any;
package/lib/main.js CHANGED
@@ -39,12 +39,12 @@ export const resolveConfig = async function (opts) {
39
39
  ? EXTENSION_API_STAGING_BASE_URL
40
40
  : EXTENSION_API_BASE_URL;
41
41
  const { config: configOpt, defaultConfig, inlineConfig, configMutations, cwd, context, repositoryRoot, base, branch, siteId, accountId, deployId, buildId, baseRelDir, mode, debug, logs, featureFlags, } = await normalizeOpts(optsA);
42
- let { siteInfo, accounts, addons, integrations } = parsedCachedConfig || {};
42
+ let { siteInfo, accounts, integrations } = parsedCachedConfig || {};
43
43
  // If we have cached site info, we don't need to fetch it again
44
- const useCachedSiteInfo = Boolean(featureFlags?.use_cached_site_info && siteInfo && accounts && addons && integrations);
44
+ const useCachedSiteInfo = Boolean(featureFlags?.use_cached_site_info && siteInfo && accounts && integrations);
45
45
  // I'm adding some debug logging to see if the logic is working as expected
46
46
  if (featureFlags?.use_cached_site_info_logging) {
47
- console.log('Checking site information', { useCachedSiteInfo, siteInfo, accounts, addons, integrations });
47
+ console.log('Checking site information', { useCachedSiteInfo, siteInfo, accounts, integrations });
48
48
  }
49
49
  if (!useCachedSiteInfo) {
50
50
  const updatedSiteInfo = await getSiteInfo({
@@ -62,7 +62,6 @@ export const resolveConfig = async function (opts) {
62
62
  });
63
63
  siteInfo = updatedSiteInfo.siteInfo;
64
64
  accounts = updatedSiteInfo.accounts;
65
- addons = updatedSiteInfo.addons;
66
65
  integrations = updatedSiteInfo.integrations;
67
66
  }
68
67
  const { defaultConfig: defaultConfigA, baseRelDir: baseRelDirA } = parseDefaultConfig({
@@ -93,7 +92,6 @@ export const resolveConfig = async function (opts) {
93
92
  config,
94
93
  siteInfo,
95
94
  accounts,
96
- addons,
97
95
  buildDir,
98
96
  branch,
99
97
  deployId,
@@ -107,15 +105,11 @@ export const resolveConfig = async function (opts) {
107
105
  apiIntegrations: integrations,
108
106
  configIntegrations: configA.integrations,
109
107
  context: context,
110
- testOpts,
111
- offline,
112
- extensionApiBaseUrl,
113
108
  });
114
109
  const result = {
115
110
  siteInfo,
116
111
  integrations: mergedIntegrations,
117
112
  accounts,
118
- addons,
119
113
  env,
120
114
  configPath,
121
115
  redirectsPath,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/config",
3
- "version": "22.0.0-rc",
3
+ "version": "22.0.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": "^8.0.0",
63
+ "@netlify/redirect-parser": "^14.5.1",
62
64
  "chalk": "^5.0.0",
63
65
  "cron-parser": "^4.1.0",
64
66
  "deepmerge": "^4.2.2",
@@ -73,8 +75,6 @@
73
75
  "js-yaml": "^4.0.0",
74
76
  "map-obj": "^5.0.0",
75
77
  "netlify": "^13.3.4",
76
- "@netlify/headers-parser": "^8.0.0",
77
- "@netlify/redirect-parser": "^14.5.1",
78
78
  "node-fetch": "^3.3.1",
79
79
  "omit.js": "^2.0.2",
80
80
  "p-locate": "^6.0.0",
@@ -94,5 +94,6 @@
94
94
  },
95
95
  "engines": {
96
96
  "node": "^14.16.0 || >=16.0.0"
97
- }
97
+ },
98
+ "gitHead": "6c53e667bd041a68dda336c678877dbb3b84a512"
98
99
  }
@@ -1,13 +0,0 @@
1
- import { TestOptions } from '../types/options.js';
2
- type AvailableIntegration = {
3
- slug: string;
4
- hostSiteUrl: string;
5
- hasBuild?: boolean;
6
- };
7
- type GetAvailableIntegrationsOpts = {
8
- testOpts: TestOptions;
9
- offline: boolean;
10
- extensionApiBaseUrl: string;
11
- };
12
- export declare const getAvailableIntegrations: ({ testOpts, offline, extensionApiBaseUrl, }: GetAvailableIntegrationsOpts) => Promise<AvailableIntegration[]>;
13
- export {};
@@ -1,19 +0,0 @@
1
- import fetch from 'node-fetch';
2
- export const getAvailableIntegrations = async function ({ testOpts, offline, extensionApiBaseUrl, }) {
3
- if (offline) {
4
- return [];
5
- }
6
- const { host } = testOpts;
7
- const baseUrl = new URL(host ? `http://${host}/` : extensionApiBaseUrl);
8
- try {
9
- const response = await fetch(`${baseUrl}integrations`);
10
- if (response.ok) {
11
- const integrations = (await response.json());
12
- return Array.isArray(integrations) ? integrations : [];
13
- }
14
- return [];
15
- }
16
- catch {
17
- return [];
18
- }
19
- };