Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/config/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ export const resolveConfig = async function (opts): Promise<Config> {
testOpts,
offline,
mode,
debug,
})

const mergedIntegrations = await mergeIntegrations({
Expand Down
70 changes: 22 additions & 48 deletions packages/config/src/utils/extensions/auto-install-extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ interface AutoInstallOptions {
testOpts: any
mode: ModeOption
extensionApiBaseUrl: string
debug?: boolean
}

export async function handleAutoInstallExtensions({
Expand All @@ -41,58 +42,31 @@ export async function handleAutoInstallExtensions({
testOpts = {},
mode,
extensionApiBaseUrl,
debug = false,
}: AutoInstallOptions) {
if (!featureFlags?.auto_install_required_extensions) {
return integrations
}
if (!accountId) {
console.error("Failed to auto install extension(s): Missing 'accountId'", {
accountId,
siteId,
buildDir,
offline,
mode,
})
return integrations
}
if (!siteId) {
console.error("Failed to auto install extension(s): Missing 'siteId'", {
accountId,
siteId,
buildDir,
offline,
mode,
})
return integrations
}
if (!token) {
console.error("Failed to auto install extension(s): Missing 'token'", {
accountId,
siteId,
buildDir,
offline,
mode,
})
return integrations
}
if (!buildDir) {
console.error("Failed to auto install extension(s): Missing 'buildDir'", {
accountId,
siteId,
buildDir,
offline,
mode,
})
return integrations
}
if (offline) {
console.error("Failed to auto install extension(s): Running as 'offline'", {
accountId,
siteId,
buildDir,
offline,
mode,
})
if (!accountId || !siteId || !token || !buildDir || offline) {
const reason = !accountId
? 'Missing accountId'
: !siteId
? 'Missing siteId'
: !token
? 'Missing token'
: !buildDir
? 'Missing buildDir'
: 'Running as offline'

if (debug) {
console.error(`Failed to auto install extension(s): ${reason}`, {
accountId,
siteId,
buildDir,
offline,
mode,
})
}
return integrations
}

Expand Down
17 changes: 11 additions & 6 deletions packages/config/src/utils/extensions/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,16 @@ type AutoInstallableExtensionMeta = {
* @returns Array of extensions with their associated packages
*/
export async function fetchAutoInstallableExtensionsMeta(): Promise<AutoInstallableExtensionMeta[]> {
const url = new URL(`/meta/auto-installable`, process.env.EXTENSION_API_BASE_URL ?? EXTENSION_API_BASE_URL)
const response = await fetch(url.toString())
if (!response.ok) {
throw new Error(`Failed to fetch extensions meta`)
try {
const url = new URL(`/meta/auto-installable`, process.env.EXTENSION_API_BASE_URL ?? EXTENSION_API_BASE_URL)
const response = await fetch(url.toString())
if (!response.ok) {
throw new Error(`Failed to fetch extensions meta`)
}
const data = await response.json()
return data as AutoInstallableExtensionMeta[]
} catch (error) {
console.error(`Failed to fetch auto-installable extensions meta: ${error.message}`, error)
return []
}
const data = await response.json()
return data as AutoInstallableExtensionMeta[]
}
Loading