@@ -14,6 +14,7 @@ type GetSiteInfoOpts = {
14
14
offline ?: boolean
15
15
api ?: NetlifyAPI
16
16
context ?: string
17
+ featureFlags ?: Record < string , boolean >
17
18
testOpts ?: TestOptions
18
19
}
19
20
/**
@@ -36,49 +37,22 @@ export const getSiteInfo = async function ({
36
37
} : GetSiteInfoOpts ) {
37
38
const { env : testEnv = false } = testOpts
38
39
39
- if ( api === undefined || testEnv || offline ) {
40
+ if ( api === undefined || mode === 'buildbot' || testEnv ) {
40
41
const siteInfo = siteId === undefined ? { } : { id : siteId }
41
42
42
- return { siteInfo, accounts : [ ] , addons : [ ] , integrations : [ ] }
43
- }
44
-
45
- const siteInfo = await getSite ( api , siteId , siteFeatureFlagPrefix )
46
- const featureFlags = siteInfo . feature_flags
47
-
48
- const useV2Endpoint = featureFlags ?. cli_integration_installations_meta
49
-
50
- if ( useV2Endpoint ) {
51
- const promises = [
52
- getAccounts ( api ) ,
53
- getAddons ( api , siteId ) ,
54
- getIntegrations ( { siteId, testOpts, offline, accountId : siteInfo . account_id , featureFlags } ) ,
55
- ]
56
-
57
- const [ accounts , addons , integrations ] = await Promise . all < any [ ] > ( promises )
58
-
59
- if ( siteInfo . use_envelope ) {
60
- const envelope = await getEnvelope ( { api, accountId : siteInfo . account_slug , siteId, context } )
61
-
62
- siteInfo . build_settings . env = envelope
63
- }
64
-
65
- return { siteInfo, accounts, addons, integrations }
66
- }
67
- if ( mode === 'buildbot' ) {
68
- const siteInfo = siteId === undefined ? { } : { id : siteId }
69
-
70
- const integrations = await getIntegrations ( { siteId, testOpts, offline, featureFlags } )
43
+ const integrations = mode === 'buildbot' && ! offline ? await getIntegrations ( { siteId, testOpts, offline } ) : [ ]
71
44
72
45
return { siteInfo, accounts : [ ] , addons : [ ] , integrations }
73
46
}
74
47
75
48
const promises = [
49
+ getSite ( api , siteId , siteFeatureFlagPrefix ) ,
76
50
getAccounts ( api ) ,
77
51
getAddons ( api , siteId ) ,
78
- getIntegrations ( { siteId, testOpts, offline, featureFlags } ) ,
52
+ getIntegrations ( { siteId, testOpts, offline } ) ,
79
53
]
80
54
81
- const [ accounts , addons , integrations ] = await Promise . all ( promises )
55
+ const [ siteInfo , accounts , addons , integrations ] = await Promise . all ( promises )
82
56
83
57
if ( siteInfo . use_envelope ) {
84
58
const envelope = await getEnvelope ( { api, accountId : siteInfo . account_slug , siteId, context } )
@@ -98,7 +72,7 @@ const getSite = async function (api: NetlifyAPI, siteId: string, siteFeatureFlag
98
72
const site = await ( api as any ) . getSite ( { siteId, feature_flags : siteFeatureFlagPrefix } )
99
73
return { ...site , id : siteId }
100
74
} catch ( error ) {
101
- return throwUserError ( `Failed retrieving site data for site ${ siteId } : ${ error . message } . ${ ERROR_CALL_TO_ACTION } ` )
75
+ throwUserError ( `Failed retrieving site data for site ${ siteId } : ${ error . message } . ${ ERROR_CALL_TO_ACTION } ` )
102
76
}
103
77
}
104
78
@@ -107,7 +81,7 @@ const getAccounts = async function (api: NetlifyAPI) {
107
81
const accounts = await ( api as any ) . listAccountsForUser ( )
108
82
return Array . isArray ( accounts ) ? accounts : [ ]
109
83
} catch ( error ) {
110
- return throwUserError ( `Failed retrieving user account: ${ error . message } . ${ ERROR_CALL_TO_ACTION } ` )
84
+ throwUserError ( `Failed retrieving user account: ${ error . message } . ${ ERROR_CALL_TO_ACTION } ` )
111
85
}
112
86
}
113
87
@@ -120,24 +94,20 @@ const getAddons = async function (api: NetlifyAPI, siteId: string) {
120
94
const addons = await ( api as any ) . listServiceInstancesForSite ( { siteId } )
121
95
return Array . isArray ( addons ) ? addons : [ ]
122
96
} catch ( error ) {
123
- return throwUserError ( `Failed retrieving addons for site ${ siteId } : ${ error . message } . ${ ERROR_CALL_TO_ACTION } ` )
97
+ throwUserError ( `Failed retrieving addons for site ${ siteId } : ${ error . message } . ${ ERROR_CALL_TO_ACTION } ` )
124
98
}
125
99
}
126
100
127
101
type GetIntegrationsOpts = {
128
102
siteId ?: string
129
- accountId ?: string
130
103
testOpts : TestOptions
131
104
offline : boolean
132
- featureFlags ?: Record < string , boolean >
133
105
}
134
106
135
107
const getIntegrations = async function ( {
136
108
siteId,
137
- accountId,
138
109
testOpts,
139
110
offline,
140
- featureFlags,
141
111
} : GetIntegrationsOpts ) : Promise < IntegrationResponse [ ] > {
142
112
if ( ! siteId || offline ) {
143
113
return [ ]
@@ -147,21 +117,13 @@ const getIntegrations = async function ({
147
117
148
118
const baseUrl = new URL ( host ? `http://${ host } ` : `https://api.netlifysdk.com` )
149
119
150
- const useV2Endpoint = featureFlags ?. cli_integration_installations_meta
151
-
152
- const url = useV2Endpoint
153
- ? `${ baseUrl } team/${ accountId } /integrations/installations/meta`
154
- : `${ baseUrl } site/${ siteId } /integrations/safe`
155
-
156
120
try {
157
- const response = await fetch ( url )
121
+ const response = await fetch ( ` ${ baseUrl } site/ ${ siteId } /integrations/safe` )
158
122
159
123
const integrations = await response . json ( )
160
124
return Array . isArray ( integrations ) ? integrations : [ ]
161
125
} catch ( error ) {
162
- // Integrations should not block the build if they fail to load
163
- // TODO: We should consider blocking the build as integrations are a critical part of the build process
164
- // https://linear.app/netlify/issue/CT-1214/implement-strategy-in-builds-to-deal-with-integrations-that-we-fail-to
126
+ // for now, we'll just ignore errors, as this is early days
165
127
return [ ]
166
128
}
167
129
}
0 commit comments