2022-10-05 20:25:50 +13:00
|
|
|
const env = require("../environment")
|
|
|
|
const { plugins: ProPlugins } = require("@budibase/pro")
|
|
|
|
const { objectStore } = require("@budibase/backend-core")
|
2022-10-05 04:28:21 +13:00
|
|
|
|
2022-10-05 20:57:26 +13:00
|
|
|
exports.enrichPluginURLs = plugins => {
|
2022-10-05 04:28:21 +13:00
|
|
|
if (!plugins || !plugins.length) {
|
|
|
|
return []
|
|
|
|
}
|
|
|
|
return plugins.map(plugin => {
|
|
|
|
const cloud = !env.SELF_HOSTED
|
2022-10-05 20:25:50 +13:00
|
|
|
const bucket = objectStore.ObjectStoreBuckets.PLUGINS
|
|
|
|
const jsFileName = "plugin.min.js"
|
|
|
|
|
|
|
|
// In self host we need to prefix the path, as the bucket name is not part
|
|
|
|
// of the bucket path. In cloud, it's already part of the bucket path.
|
|
|
|
let jsUrl = cloud ? "https://cdn.budi.live/" : `/${bucket}/`
|
2022-10-05 04:28:21 +13:00
|
|
|
jsUrl += ProPlugins.getBucketPath(plugin.name)
|
2022-10-05 20:25:50 +13:00
|
|
|
jsUrl += jsFileName
|
|
|
|
return { ...plugin, jsUrl }
|
2022-10-05 04:28:21 +13:00
|
|
|
})
|
|
|
|
}
|