@netlify/config 21.0.5 → 21.0.6
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/lib/api/site_info.js +37 -5
- package/lib/integrations.d.ts +1 -0
- package/lib/integrations.js +1 -0
- package/lib/main.js +3 -1
- package/package.json +2 -2
package/lib/api/site_info.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fetch from 'node-fetch';
|
|
2
2
|
import { getEnvelope } from '../env/envelope.js';
|
|
3
3
|
import { throwUserError } from '../error.js';
|
|
4
|
+
import { EXTENSION_API_BASE_URL, EXTENSION_API_STAGING_BASE_URL, NETLIFY_API_BASE_URL, NETLIFY_API_STAGING_BASE_URL, } from '../integrations.js';
|
|
4
5
|
import { ERROR_CALL_TO_ACTION } from '../log/messages.js';
|
|
5
6
|
/**
|
|
6
7
|
* Retrieve Netlify Site information, if available.
|
|
@@ -20,7 +21,16 @@ export const getSiteInfo = async function ({ api, siteId, accountId, mode, conte
|
|
|
20
21
|
if (accountId !== undefined)
|
|
21
22
|
siteInfo.account_id = accountId;
|
|
22
23
|
const integrations = mode === 'buildbot' && !offline
|
|
23
|
-
? await getIntegrations({
|
|
24
|
+
? await getIntegrations({
|
|
25
|
+
siteId,
|
|
26
|
+
testOpts,
|
|
27
|
+
offline,
|
|
28
|
+
accountId,
|
|
29
|
+
token,
|
|
30
|
+
featureFlags,
|
|
31
|
+
extensionApiBaseUrl,
|
|
32
|
+
mode,
|
|
33
|
+
})
|
|
24
34
|
: [];
|
|
25
35
|
return { siteInfo, accounts: [], addons: [], integrations };
|
|
26
36
|
}
|
|
@@ -28,7 +38,7 @@ export const getSiteInfo = async function ({ api, siteId, accountId, mode, conte
|
|
|
28
38
|
getSite(api, siteId, siteFeatureFlagPrefix),
|
|
29
39
|
getAccounts(api),
|
|
30
40
|
getAddons(api, siteId),
|
|
31
|
-
getIntegrations({ siteId, testOpts, offline, accountId, token, featureFlags, extensionApiBaseUrl }),
|
|
41
|
+
getIntegrations({ siteId, testOpts, offline, accountId, token, featureFlags, extensionApiBaseUrl, mode }),
|
|
32
42
|
];
|
|
33
43
|
const [siteInfo, accounts, addons, integrations] = await Promise.all(promises);
|
|
34
44
|
if (siteInfo.use_envelope) {
|
|
@@ -70,25 +80,47 @@ const getAddons = async function (api, siteId) {
|
|
|
70
80
|
throwUserError(`Failed retrieving addons for site ${siteId}: ${error.message}. ${ERROR_CALL_TO_ACTION}`);
|
|
71
81
|
}
|
|
72
82
|
};
|
|
73
|
-
const getIntegrations = async function ({ siteId, accountId, testOpts, offline, token, featureFlags, extensionApiBaseUrl, }) {
|
|
83
|
+
const getIntegrations = async function ({ siteId, accountId, testOpts, offline, token, featureFlags, extensionApiBaseUrl, mode, }) {
|
|
74
84
|
if (!siteId || offline) {
|
|
75
85
|
return [];
|
|
76
86
|
}
|
|
77
87
|
const sendBuildBotTokenToJigsaw = featureFlags?.send_build_bot_token_to_jigsaw;
|
|
78
|
-
const { host, setBaseUrl } = testOpts;
|
|
88
|
+
const { host: originalHost, setBaseUrl } = testOpts;
|
|
89
|
+
// TODO(kh): I am adding this purely for local staging development.
|
|
90
|
+
// We should remove this once we have fixed https://github.com/netlify/cli/blob/b5a5c7525edd28925c5c2e3e5f0f00c4261eaba5/src/lib/build.ts#L125
|
|
91
|
+
let host = originalHost;
|
|
92
|
+
// If there is a host, we use it to fetch the integrations
|
|
93
|
+
// we check if the host is staging or production and set the host accordingly,
|
|
94
|
+
// sadly necessary because of https://github.com/netlify/cli/blob/b5a5c7525edd28925c5c2e3e5f0f00c4261eaba5/src/lib/build.ts#L125
|
|
95
|
+
if (originalHost) {
|
|
96
|
+
if (originalHost?.includes(NETLIFY_API_STAGING_BASE_URL)) {
|
|
97
|
+
host = EXTENSION_API_STAGING_BASE_URL;
|
|
98
|
+
}
|
|
99
|
+
else if (originalHost?.includes(NETLIFY_API_BASE_URL)) {
|
|
100
|
+
host = EXTENSION_API_BASE_URL;
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
host = `http://${originalHost}`;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
const baseUrl = new URL(host ?? extensionApiBaseUrl);
|
|
79
107
|
// We only use this for testing
|
|
80
108
|
if (host && setBaseUrl) {
|
|
81
109
|
setBaseUrl(extensionApiBaseUrl);
|
|
82
110
|
}
|
|
83
|
-
const baseUrl = new URL(host ? `http://${host}` : extensionApiBaseUrl);
|
|
84
111
|
// if accountId isn't present, use safe v1 endpoint
|
|
85
112
|
const url = accountId
|
|
86
113
|
? `${baseUrl}team/${accountId}/integrations/installations/meta/${siteId}`
|
|
87
114
|
: `${baseUrl}site/${siteId}/integrations/safe`;
|
|
88
115
|
try {
|
|
89
116
|
const requestOptions = {};
|
|
117
|
+
// This is used to identify where the request is coming from
|
|
118
|
+
requestOptions.headers = {
|
|
119
|
+
'netlify-config-mode': mode,
|
|
120
|
+
};
|
|
90
121
|
if (sendBuildBotTokenToJigsaw && token) {
|
|
91
122
|
requestOptions.headers = {
|
|
123
|
+
...requestOptions.headers,
|
|
92
124
|
'netlify-sdk-build-bot-token': token,
|
|
93
125
|
};
|
|
94
126
|
}
|
package/lib/integrations.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { IntegrationResponse } from './types/api.js';
|
|
|
2
2
|
import { Integration } from './types/integrations.js';
|
|
3
3
|
import { TestOptions } from './types/options.js';
|
|
4
4
|
export declare const NETLIFY_API_STAGING_BASE_URL = "api-staging.netlify.com";
|
|
5
|
+
export declare const NETLIFY_API_BASE_URL = "api.netlify.com";
|
|
5
6
|
export declare const EXTENSION_API_BASE_URL = "https://api.netlifysdk.com";
|
|
6
7
|
export declare const EXTENSION_API_STAGING_BASE_URL = "https://api-staging.netlifysdk.com";
|
|
7
8
|
type MergeIntegrationsOpts = {
|
package/lib/integrations.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getAvailableIntegrations } from './api/integrations.js';
|
|
2
2
|
export const NETLIFY_API_STAGING_BASE_URL = 'api-staging.netlify.com';
|
|
3
|
+
export const NETLIFY_API_BASE_URL = 'api.netlify.com';
|
|
3
4
|
export const EXTENSION_API_BASE_URL = 'https://api.netlifysdk.com';
|
|
4
5
|
export const EXTENSION_API_STAGING_BASE_URL = 'https://api-staging.netlifysdk.com';
|
|
5
6
|
export const mergeIntegrations = async function ({ configIntegrations = [], apiIntegrations, context, testOpts = {}, offline, extensionApiBaseUrl, }) {
|
package/lib/main.js
CHANGED
|
@@ -35,7 +35,9 @@ export const resolveConfig = async function (opts) {
|
|
|
35
35
|
return parsedCachedConfig;
|
|
36
36
|
}
|
|
37
37
|
// TODO(kh): remove this mapping and get the extensionApiHost from the opts
|
|
38
|
-
const extensionApiBaseUrl = host
|
|
38
|
+
const extensionApiBaseUrl = host?.includes(NETLIFY_API_STAGING_BASE_URL)
|
|
39
|
+
? EXTENSION_API_STAGING_BASE_URL
|
|
40
|
+
: EXTENSION_API_BASE_URL;
|
|
39
41
|
const { config: configOpt, defaultConfig, inlineConfig, configMutations, cwd, context, repositoryRoot, base, branch, siteId, accountId, deployId, buildId, baseRelDir, mode, debug, logs, featureFlags, } = await normalizeOpts(optsA);
|
|
40
42
|
let { siteInfo, accounts, addons, integrations } = parsedCachedConfig || {};
|
|
41
43
|
// If we have cached site info, we don't need to fetch it again
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/config",
|
|
3
|
-
"version": "21.0.
|
|
3
|
+
"version": "21.0.6",
|
|
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": "
|
|
98
|
+
"gitHead": "761c1e087c92c4cf579050e686a5869da5b3ce00"
|
|
99
99
|
}
|