additional logging around component definitions
This commit is contained in:
parent
e77e6b070f
commit
d5c2f32df3
|
@ -3,32 +3,36 @@ const { getComponentLibraryManifest } = require("../../utilities/fileSystem")
|
||||||
const { getAppDB } = require("@budibase/backend-core/context")
|
const { getAppDB } = require("@budibase/backend-core/context")
|
||||||
|
|
||||||
exports.fetchAppComponentDefinitions = async function (ctx) {
|
exports.fetchAppComponentDefinitions = async function (ctx) {
|
||||||
const db = getAppDB()
|
try {
|
||||||
const app = await db.get(DocumentType.APP_METADATA)
|
const db = getAppDB()
|
||||||
|
const app = await db.get(DocumentType.APP_METADATA)
|
||||||
|
|
||||||
let componentManifests = await Promise.all(
|
let componentManifests = await Promise.all(
|
||||||
app.componentLibraries.map(async library => {
|
app.componentLibraries.map(async library => {
|
||||||
let manifest = await getComponentLibraryManifest(library)
|
let manifest = await getComponentLibraryManifest(library)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
manifest,
|
manifest,
|
||||||
library,
|
library,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
const definitions = {}
|
const definitions = {}
|
||||||
for (let { manifest, library } of componentManifests) {
|
for (let { manifest, library } of componentManifests) {
|
||||||
for (let key of Object.keys(manifest)) {
|
for (let key of Object.keys(manifest)) {
|
||||||
if (key === "features") {
|
if (key === "features") {
|
||||||
definitions[key] = manifest[key]
|
definitions[key] = manifest[key]
|
||||||
} else {
|
} else {
|
||||||
const fullComponentName = `${library}/${key}`.toLowerCase()
|
const fullComponentName = `${library}/${key}`.toLowerCase()
|
||||||
definitions[fullComponentName] = {
|
definitions[fullComponentName] = {
|
||||||
component: fullComponentName,
|
component: fullComponentName,
|
||||||
...manifest[key],
|
...manifest[key],
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ctx.body = definitions
|
||||||
|
} catch (err) {
|
||||||
|
console.error(`component-definitions=failed`, err)
|
||||||
}
|
}
|
||||||
ctx.body = definitions
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -291,6 +291,7 @@ exports.getComponentLibraryManifest = async library => {
|
||||||
const path = join(appId, filename)
|
const path = join(appId, filename)
|
||||||
resp = await retrieve(ObjectStoreBuckets.APPS, path)
|
resp = await retrieve(ObjectStoreBuckets.APPS, path)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
console.error(`component-manifest-objectstore=failed appId=${appId}`, error)
|
||||||
// Fallback to loading it from the old location for old apps
|
// Fallback to loading it from the old location for old apps
|
||||||
const path = join(appId, "node_modules", library, "package", filename)
|
const path = join(appId, "node_modules", library, "package", filename)
|
||||||
resp = await retrieve(ObjectStoreBuckets.APPS, path)
|
resp = await retrieve(ObjectStoreBuckets.APPS, path)
|
||||||
|
|
Loading…
Reference in New Issue