@netlify/config 21.0.6 → 21.0.7
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.d.ts +16 -3
- package/lib/api/site_info.js +6 -5
- package/lib/integrations.d.ts +1 -5
- package/lib/integrations.js +7 -8
- package/lib/main.d.ts +20 -1
- package/lib/main.js +0 -3
- package/package.json +2 -2
- package/lib/api/integrations.d.ts +0 -13
- package/lib/api/integrations.js +0 -19
package/lib/api/site_info.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { NetlifyAPI } from 'netlify';
|
|
2
|
+
import { IntegrationResponse } from '../types/api.js';
|
|
2
3
|
import { ModeOption, TestOptions } from '../types/options.js';
|
|
3
4
|
type GetSiteInfoOpts = {
|
|
4
5
|
siteId: string;
|
|
@@ -24,8 +25,20 @@ type GetSiteInfoOpts = {
|
|
|
24
25
|
*/
|
|
25
26
|
export declare const getSiteInfo: ({ api, siteId, accountId, mode, context, offline, testOpts, siteFeatureFlagPrefix, token, featureFlags, extensionApiBaseUrl, }: GetSiteInfoOpts) => Promise<{
|
|
26
27
|
siteInfo: any;
|
|
27
|
-
accounts:
|
|
28
|
-
addons: any;
|
|
29
|
-
integrations:
|
|
28
|
+
accounts: MinimalAccount[];
|
|
29
|
+
addons: any[] | undefined;
|
|
30
|
+
integrations: IntegrationResponse[];
|
|
30
31
|
}>;
|
|
32
|
+
export type MinimalAccount = {
|
|
33
|
+
id: string;
|
|
34
|
+
name: string;
|
|
35
|
+
slug: string;
|
|
36
|
+
default: boolean;
|
|
37
|
+
team_logo_url: string | null;
|
|
38
|
+
on_pro_trial: boolean;
|
|
39
|
+
organization_id: string | null;
|
|
40
|
+
type_name: string;
|
|
41
|
+
type_slug: string;
|
|
42
|
+
members_count: number;
|
|
43
|
+
};
|
|
31
44
|
export {};
|
package/lib/api/site_info.js
CHANGED
|
@@ -34,13 +34,12 @@ export const getSiteInfo = async function ({ api, siteId, accountId, mode, conte
|
|
|
34
34
|
: [];
|
|
35
35
|
return { siteInfo, accounts: [], addons: [], integrations };
|
|
36
36
|
}
|
|
37
|
-
const
|
|
37
|
+
const [siteInfo, accounts, addons, integrations] = await Promise.all([
|
|
38
38
|
getSite(api, siteId, siteFeatureFlagPrefix),
|
|
39
39
|
getAccounts(api),
|
|
40
40
|
getAddons(api, siteId),
|
|
41
41
|
getIntegrations({ siteId, testOpts, offline, accountId, token, featureFlags, extensionApiBaseUrl, mode }),
|
|
42
|
-
];
|
|
43
|
-
const [siteInfo, accounts, addons, integrations] = await Promise.all(promises);
|
|
42
|
+
]);
|
|
44
43
|
if (siteInfo.use_envelope) {
|
|
45
44
|
const envelope = await getEnvelope({ api, accountId: siteInfo.account_slug, siteId, context });
|
|
46
45
|
siteInfo.build_settings.env = envelope;
|
|
@@ -61,11 +60,13 @@ const getSite = async function (api, siteId, siteFeatureFlagPrefix) {
|
|
|
61
60
|
};
|
|
62
61
|
const getAccounts = async function (api) {
|
|
63
62
|
try {
|
|
64
|
-
const accounts = await api.listAccountsForUser(
|
|
63
|
+
const accounts = (await api.listAccountsForUser(
|
|
64
|
+
// @ts-expect-error(ndhoule): This is an unpublished, internal querystring parameter
|
|
65
|
+
{ minimal: 'true' }));
|
|
65
66
|
return Array.isArray(accounts) ? accounts : [];
|
|
66
67
|
}
|
|
67
68
|
catch (error) {
|
|
68
|
-
throwUserError(`Failed retrieving user account: ${error.message}. ${ERROR_CALL_TO_ACTION}`);
|
|
69
|
+
return throwUserError(`Failed retrieving user account: ${error.message}. ${ERROR_CALL_TO_ACTION}`);
|
|
69
70
|
}
|
|
70
71
|
};
|
|
71
72
|
const getAddons = async function (api, siteId) {
|
package/lib/integrations.d.ts
CHANGED
|
@@ -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,
|
|
18
|
+
export declare const mergeIntegrations: ({ configIntegrations, apiIntegrations, context, }: MergeIntegrationsOpts) => Promise<Integration[]>;
|
|
23
19
|
export {};
|
package/lib/integrations.js
CHANGED
|
@@ -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,
|
|
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
|
-
|
|
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
|
-
|
|
27
|
-
if (!integration) {
|
|
26
|
+
if (!apiIntegration) {
|
|
28
27
|
return undefined;
|
|
29
28
|
}
|
|
30
|
-
return
|
|
29
|
+
return apiIntegration;
|
|
31
30
|
})
|
|
32
31
|
.filter((i) => typeof i !== 'undefined');
|
|
33
32
|
return [...resolvedApiIntegrations, ...resolvedConfigIntegrations];
|
package/lib/main.d.ts
CHANGED
|
@@ -1,6 +1,25 @@
|
|
|
1
|
+
import { type MinimalAccount } from './api/site_info.js';
|
|
2
|
+
export type Config = {
|
|
3
|
+
accounts: MinimalAccount[] | undefined;
|
|
4
|
+
addons: any;
|
|
5
|
+
api: any;
|
|
6
|
+
branch: any;
|
|
7
|
+
buildDir: any;
|
|
8
|
+
config: any;
|
|
9
|
+
configPath: any;
|
|
10
|
+
context: any;
|
|
11
|
+
env: any;
|
|
12
|
+
headersPath: any;
|
|
13
|
+
integrations: any;
|
|
14
|
+
logs: any;
|
|
15
|
+
redirectsPath: any;
|
|
16
|
+
repositoryRoot: any;
|
|
17
|
+
siteInfo: any;
|
|
18
|
+
token: any;
|
|
19
|
+
};
|
|
1
20
|
/**
|
|
2
21
|
* Load the configuration file.
|
|
3
22
|
* Takes an optional configuration file path as input and return the resolved
|
|
4
23
|
* `config` together with related properties such as the `configPath`.
|
|
5
24
|
*/
|
|
6
|
-
export declare const resolveConfig: (opts: any) => Promise<
|
|
25
|
+
export declare const resolveConfig: (opts: any) => Promise<Config>;
|
package/lib/main.js
CHANGED
|
@@ -107,9 +107,6 @@ export const resolveConfig = async function (opts) {
|
|
|
107
107
|
apiIntegrations: integrations,
|
|
108
108
|
configIntegrations: configA.integrations,
|
|
109
109
|
context: context,
|
|
110
|
-
testOpts,
|
|
111
|
-
offline,
|
|
112
|
-
extensionApiBaseUrl,
|
|
113
110
|
});
|
|
114
111
|
const result = {
|
|
115
112
|
siteInfo,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/config",
|
|
3
|
-
"version": "21.0.
|
|
3
|
+
"version": "21.0.7",
|
|
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": "8d10878db3be9cfefe3162fd155c76595aba045e"
|
|
99
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 {};
|
package/lib/api/integrations.js
DELETED
|
@@ -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
|
-
};
|