@netlify/config 21.0.0 → 21.0.1

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.
@@ -7,6 +7,7 @@ type AvailableIntegration = {
7
7
  type GetAvailableIntegrationsOpts = {
8
8
  testOpts: TestOptions;
9
9
  offline: boolean;
10
+ extensionApiBaseUrl: string;
10
11
  };
11
- export declare const getAvailableIntegrations: ({ testOpts, offline, }: GetAvailableIntegrationsOpts) => Promise<AvailableIntegration[]>;
12
+ export declare const getAvailableIntegrations: ({ testOpts, offline, extensionApiBaseUrl, }: GetAvailableIntegrationsOpts) => Promise<AvailableIntegration[]>;
12
13
  export {};
@@ -1,10 +1,10 @@
1
1
  import fetch from 'node-fetch';
2
- export const getAvailableIntegrations = async function ({ testOpts, offline, }) {
2
+ export const getAvailableIntegrations = async function ({ testOpts, offline, extensionApiBaseUrl, }) {
3
3
  if (offline) {
4
4
  return [];
5
5
  }
6
6
  const { host } = testOpts;
7
- const baseUrl = new URL(host ? `http://${host}/` : `https://api.netlifysdk.com/`);
7
+ const baseUrl = new URL(host ? `http://${host}/` : extensionApiBaseUrl);
8
8
  try {
9
9
  const response = await fetch(`${baseUrl}integrations`);
10
10
  if (response.ok) {
@@ -11,6 +11,7 @@ type GetSiteInfoOpts = {
11
11
  testOpts?: TestOptions;
12
12
  siteFeatureFlagPrefix: string;
13
13
  token: string;
14
+ extensionApiBaseUrl: string;
14
15
  };
15
16
  /**
16
17
  * Retrieve Netlify Site information, if available.
@@ -21,7 +22,7 @@ type GetSiteInfoOpts = {
21
22
  * Silently ignore API errors. For example the network connection might be down,
22
23
  * but local builds should still work regardless.
23
24
  */
24
- export declare const getSiteInfo: ({ api, siteId, accountId, mode, context, offline, testOpts, siteFeatureFlagPrefix, token, featureFlags, }: GetSiteInfoOpts) => Promise<{
25
+ export declare const getSiteInfo: ({ api, siteId, accountId, mode, context, offline, testOpts, siteFeatureFlagPrefix, token, featureFlags, extensionApiBaseUrl, }: GetSiteInfoOpts) => Promise<{
25
26
  siteInfo: any;
26
27
  accounts: any;
27
28
  addons: any;
@@ -11,7 +11,7 @@ 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 = {}, siteFeatureFlagPrefix, token, featureFlags = {}, }) {
14
+ export const getSiteInfo = async function ({ api, siteId, accountId, mode, context, offline = false, testOpts = {}, siteFeatureFlagPrefix, token, featureFlags = {}, extensionApiBaseUrl, }) {
15
15
  const { env: testEnv = false } = testOpts;
16
16
  if (api === undefined || mode === 'buildbot' || testEnv) {
17
17
  const siteInfo = {};
@@ -20,7 +20,7 @@ export const getSiteInfo = async function ({ api, siteId, accountId, mode, conte
20
20
  if (accountId !== undefined)
21
21
  siteInfo.account_id = accountId;
22
22
  const integrations = mode === 'buildbot' && !offline
23
- ? await getIntegrations({ siteId, testOpts, offline, accountId, token, featureFlags })
23
+ ? await getIntegrations({ siteId, testOpts, offline, accountId, token, featureFlags, extensionApiBaseUrl })
24
24
  : [];
25
25
  return { siteInfo, accounts: [], addons: [], integrations };
26
26
  }
@@ -28,7 +28,7 @@ export const getSiteInfo = async function ({ api, siteId, accountId, mode, conte
28
28
  getSite(api, siteId, siteFeatureFlagPrefix),
29
29
  getAccounts(api),
30
30
  getAddons(api, siteId),
31
- getIntegrations({ siteId, testOpts, offline, accountId, token, featureFlags }),
31
+ getIntegrations({ siteId, testOpts, offline, accountId, token, featureFlags, extensionApiBaseUrl }),
32
32
  ];
33
33
  const [siteInfo, accounts, addons, integrations] = await Promise.all(promises);
34
34
  if (siteInfo.use_envelope) {
@@ -70,13 +70,13 @@ const getAddons = async function (api, siteId) {
70
70
  throwUserError(`Failed retrieving addons for site ${siteId}: ${error.message}. ${ERROR_CALL_TO_ACTION}`);
71
71
  }
72
72
  };
73
- const getIntegrations = async function ({ siteId, accountId, testOpts, offline, token, featureFlags, }) {
73
+ const getIntegrations = async function ({ siteId, accountId, testOpts, offline, token, featureFlags, extensionApiBaseUrl, }) {
74
74
  if (!siteId || offline) {
75
75
  return [];
76
76
  }
77
77
  const sendBuildBotTokenToJigsaw = featureFlags?.send_build_bot_token_to_jigsaw;
78
78
  const { host } = testOpts;
79
- const baseUrl = new URL(host ? `http://${host}` : `https://api.netlifysdk.com`);
79
+ const baseUrl = new URL(host ? `http://${host}` : extensionApiBaseUrl);
80
80
  // if accountId isn't present, use safe v1 endpoint
81
81
  const url = accountId
82
82
  ? `${baseUrl}team/${accountId}/integrations/installations/meta/${siteId}`
@@ -13,6 +13,7 @@ type MergeIntegrationsOpts = {
13
13
  context: string;
14
14
  testOpts?: TestOptions;
15
15
  offline: boolean;
16
+ extensionApiBaseUrl: string;
16
17
  };
17
- export declare const mergeIntegrations: ({ configIntegrations, apiIntegrations, context, testOpts, offline, }: MergeIntegrationsOpts) => Promise<Integration[]>;
18
+ export declare const mergeIntegrations: ({ configIntegrations, apiIntegrations, context, testOpts, offline, extensionApiBaseUrl, }: MergeIntegrationsOpts) => Promise<Integration[]>;
18
19
  export {};
@@ -1,6 +1,6 @@
1
1
  import { getAvailableIntegrations } from './api/integrations.js';
2
- export const mergeIntegrations = async function ({ configIntegrations = [], apiIntegrations, context, testOpts = {}, offline, }) {
3
- const availableIntegrations = await getAvailableIntegrations({ testOpts, offline });
2
+ export const mergeIntegrations = async function ({ configIntegrations = [], apiIntegrations, context, testOpts = {}, offline, extensionApiBaseUrl, }) {
3
+ const availableIntegrations = await getAvailableIntegrations({ testOpts, offline, extensionApiBaseUrl });
4
4
  // Include all API integrations, unless they have a `dev` property and we are in the `dev` context
5
5
  const resolvedApiIntegrations = apiIntegrations.filter((integration) => !configIntegrations.some((configIntegration) => configIntegration.name === integration.slug &&
6
6
  typeof configIntegration.dev !== 'undefined' &&
package/lib/main.js CHANGED
@@ -34,6 +34,8 @@ export const resolveConfig = async function (opts) {
34
34
  if (parsedCachedConfig !== undefined && opts.defaultConfig === undefined) {
35
35
  return parsedCachedConfig;
36
36
  }
37
+ // TODO(kh): remove this mapping and get the extensionApiHost from the opts
38
+ const extensionApiBaseUrl = host === 'api-staging.netlify.com' ? 'https://api-staging.netlifysdk.com' : 'https://api.netlifysdk.com';
37
39
  const { config: configOpt, defaultConfig, inlineConfig, configMutations, cwd, context, repositoryRoot, base, branch, siteId, accountId, deployId, buildId, baseRelDir, mode, debug, logs, featureFlags, } = await normalizeOpts(optsA);
38
40
  const { siteInfo, accounts, addons, integrations } = await getSiteInfo({
39
41
  api,
@@ -46,6 +48,7 @@ export const resolveConfig = async function (opts) {
46
48
  featureFlags,
47
49
  testOpts,
48
50
  token,
51
+ extensionApiBaseUrl,
49
52
  });
50
53
  const { defaultConfig: defaultConfigA, baseRelDir: baseRelDirA } = parseDefaultConfig({
51
54
  defaultConfig,
@@ -91,6 +94,7 @@ export const resolveConfig = async function (opts) {
91
94
  context: context,
92
95
  testOpts,
93
96
  offline,
97
+ extensionApiBaseUrl,
94
98
  });
95
99
  const result = {
96
100
  siteInfo,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/config",
3
- "version": "21.0.0",
3
+ "version": "21.0.1",
4
4
  "description": "Netlify config module",
5
5
  "type": "module",
6
6
  "exports": "./lib/index.js",
@@ -95,5 +95,5 @@
95
95
  "engines": {
96
96
  "node": "^14.16.0 || >=16.0.0"
97
97
  },
98
- "gitHead": "65206cf82369d2e0412c707c763590690cc1819a"
98
+ "gitHead": "8e40ace9314f5a549797f753389962ca22eab87d"
99
99
  }