@netlify/config 20.22.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.
- package/lib/api/integrations.d.ts +2 -1
- package/lib/api/integrations.js +2 -2
- package/lib/api/site_info.d.ts +2 -1
- package/lib/api/site_info.js +5 -5
- package/lib/env/main.js +2 -1
- package/lib/headers.d.ts +2 -3
- package/lib/headers.js +1 -2
- package/lib/integrations.d.ts +2 -1
- package/lib/integrations.js +2 -2
- package/lib/main.js +5 -1
- package/lib/mutations/update.js +1 -1
- package/package.json +3 -3
|
@@ -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 {};
|
package/lib/api/integrations.js
CHANGED
|
@@ -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}/` :
|
|
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) {
|
package/lib/api/site_info.d.ts
CHANGED
|
@@ -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;
|
package/lib/api/site_info.js
CHANGED
|
@@ -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}` :
|
|
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}`
|
package/lib/env/main.js
CHANGED
|
@@ -66,7 +66,7 @@ const convertToString = (value) => {
|
|
|
66
66
|
};
|
|
67
67
|
// Environment variables not set by users, but meant to mimic the production
|
|
68
68
|
// environment.
|
|
69
|
-
const getGeneralEnv = async function ({ siteInfo, siteInfo: { id, name }, buildDir, branch, deployId, buildId, context, }) {
|
|
69
|
+
const getGeneralEnv = async function ({ siteInfo, siteInfo: { id, name, account_id: accountId }, buildDir, branch, deployId, buildId, context, }) {
|
|
70
70
|
const gitEnv = await getGitEnv(buildDir, branch);
|
|
71
71
|
const deployUrls = getDeployUrls({ siteInfo: siteInfo, branch, deployId });
|
|
72
72
|
return removeFalsy({
|
|
@@ -74,6 +74,7 @@ const getGeneralEnv = async function ({ siteInfo, siteInfo: { id, name }, buildD
|
|
|
74
74
|
SITE_NAME: name,
|
|
75
75
|
DEPLOY_ID: deployId,
|
|
76
76
|
BUILD_ID: buildId,
|
|
77
|
+
ACCOUNT_ID: accountId,
|
|
77
78
|
...deployUrls,
|
|
78
79
|
CONTEXT: context,
|
|
79
80
|
NETLIFY_LOCAL: 'true',
|
package/lib/headers.d.ts
CHANGED
|
@@ -3,14 +3,13 @@ export function getHeadersPath({ build: { publish } }: {
|
|
|
3
3
|
publish: any;
|
|
4
4
|
};
|
|
5
5
|
}): string;
|
|
6
|
-
export function addHeaders({ config: { headers: configHeaders, ...config }, headersPath, logs
|
|
6
|
+
export function addHeaders({ config: { headers: configHeaders, ...config }, headersPath, logs }: {
|
|
7
7
|
config: {
|
|
8
8
|
[x: string]: any;
|
|
9
9
|
headers: any;
|
|
10
10
|
};
|
|
11
11
|
headersPath: any;
|
|
12
12
|
logs: any;
|
|
13
|
-
featureFlags: any;
|
|
14
13
|
}): Promise<{
|
|
15
|
-
headers: import("
|
|
14
|
+
headers: (import("@netlify/headers-parser").MinimalHeader | import("@netlify/headers-parser").Header)[];
|
|
16
15
|
}>;
|
package/lib/headers.js
CHANGED
|
@@ -7,12 +7,11 @@ export const getHeadersPath = function ({ build: { publish } }) {
|
|
|
7
7
|
};
|
|
8
8
|
const HEADERS_FILENAME = '_headers';
|
|
9
9
|
// Add `config.headers`
|
|
10
|
-
export const addHeaders = async function ({ config: { headers: configHeaders, ...config }, headersPath, logs
|
|
10
|
+
export const addHeaders = async function ({ config: { headers: configHeaders, ...config }, headersPath, logs }) {
|
|
11
11
|
const { headers, errors } = await parseAllHeaders({
|
|
12
12
|
headersFiles: [headersPath],
|
|
13
13
|
configHeaders,
|
|
14
14
|
minimal: true,
|
|
15
|
-
featureFlags,
|
|
16
15
|
});
|
|
17
16
|
warnHeadersParsing(logs, errors);
|
|
18
17
|
warnHeadersCaseSensitivity(logs, headers);
|
package/lib/integrations.d.ts
CHANGED
|
@@ -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 {};
|
package/lib/integrations.js
CHANGED
|
@@ -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,
|
|
@@ -205,7 +209,7 @@ const getFullConfig = async function ({ configOpt, cwd, context, repositoryRoot,
|
|
|
205
209
|
});
|
|
206
210
|
const { config: configB, buildDir, base: baseA, } = await resolveFiles({ packagePath, config: configA, repositoryRoot, base, baseRelDir });
|
|
207
211
|
const headersPath = getHeadersPath(configB);
|
|
208
|
-
const configC = await addHeaders({ config: configB, headersPath, logs
|
|
212
|
+
const configC = await addHeaders({ config: configB, headersPath, logs });
|
|
209
213
|
const redirectsPath = getRedirectsPath(configC);
|
|
210
214
|
const configD = await addRedirects({ config: configC, redirectsPath, logs, featureFlags });
|
|
211
215
|
return { configPath, config: configD, buildDir, base: baseA, redirectsPath, headersPath };
|
package/lib/mutations/update.js
CHANGED
|
@@ -16,7 +16,7 @@ export const updateConfig = async function (configMutations, { buildDir, configP
|
|
|
16
16
|
const inlineConfig = applyMutations({}, configMutations);
|
|
17
17
|
const normalizedInlineConfig = ensureConfigPriority(inlineConfig, context, branch);
|
|
18
18
|
const updatedConfig = await mergeWithConfig(normalizedInlineConfig, configPath);
|
|
19
|
-
const configWithHeaders = await addHeaders({ config: updatedConfig, headersPath, logs
|
|
19
|
+
const configWithHeaders = await addHeaders({ config: updatedConfig, headersPath, logs });
|
|
20
20
|
const finalConfig = await addRedirects({ config: configWithHeaders, redirectsPath, logs, featureFlags });
|
|
21
21
|
const simplifiedConfig = simplifyConfig(finalConfig);
|
|
22
22
|
await backupConfig({ buildDir, configPath, headersPath, redirectsPath });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/config",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "21.0.1",
|
|
4
4
|
"description": "Netlify config module",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./lib/index.js",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"license": "MIT",
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"@iarna/toml": "^2.2.5",
|
|
62
|
-
"@netlify/headers-parser": "^
|
|
62
|
+
"@netlify/headers-parser": "^8.0.0",
|
|
63
63
|
"@netlify/redirect-parser": "^14.5.0",
|
|
64
64
|
"chalk": "^5.0.0",
|
|
65
65
|
"cron-parser": "^4.1.0",
|
|
@@ -95,5 +95,5 @@
|
|
|
95
95
|
"engines": {
|
|
96
96
|
"node": "^14.16.0 || >=16.0.0"
|
|
97
97
|
},
|
|
98
|
-
"gitHead": "
|
|
98
|
+
"gitHead": "8e40ace9314f5a549797f753389962ca22eab87d"
|
|
99
99
|
}
|