Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
)
log.info('Regenerating JS bundle only')
await runCaudronBundleGen(napDescriptor, {
compositeMiniAppDir,
outDir,
})
// Update container metadata
const metadata = await fileUtils.readJSON(
getContainerMetadataPath(outDir)
)
const miniapps = await cauldron.getContainerMiniApps(napDescriptor)
const jsApiImpls = await cauldron.getContainerJsApiImpls(napDescriptor)
metadata.miniApps = miniapps.map(m => m.fullPath)
metadata.jsApiImpls = jsApiImpls.map(j => j.fullPath)
metadata.ernVersion = Platform.currentVersion
await fileUtils.writeJSON(getContainerMetadataPath(outDir), metadata)
} catch (e) {
log.error(`Something went wrong trying to regenerate JS bundle only`)
log.error(e)
log.error(`Falling back to full Container generation`)
jsBundleOnly = false
}
} else if (publishOnly) {
log.info(`No changes from ${currentContainerVersion}`)
log.info('Only publishing')
// Update container metadata
const metadata = await fileUtils.readJSON(
getContainerMetadataPath(outDir)
)
metadata.ernVersion = Platform.currentVersion
await fileUtils.writeJSON(getContainerMetadataPath(outDir), metadata)
}
const compositeMiniAppDir = createTmpDir()
// Only regenerate bundle if possible
if (jsBundleOnly) {
try {
log.info(
`No native dependencies changes from ${currentContainerVersion}`
)
log.info('Regenerating JS bundle only')
await runCaudronBundleGen(napDescriptor, {
compositeMiniAppDir,
outDir,
})
// Update container metadata
const metadata = await fileUtils.readJSON(
getContainerMetadataPath(outDir)
)
const miniapps = await cauldron.getContainerMiniApps(napDescriptor)
const jsApiImpls = await cauldron.getContainerJsApiImpls(napDescriptor)
metadata.miniApps = miniapps.map(m => m.fullPath)
metadata.jsApiImpls = jsApiImpls.map(j => j.fullPath)
metadata.ernVersion = Platform.currentVersion
await fileUtils.writeJSON(getContainerMetadataPath(outDir), metadata)
} catch (e) {
log.error(`Something went wrong trying to regenerate JS bundle only`)
log.error(e)
log.error(`Falling back to full Container generation`)
jsBundleOnly = false
}
} else if (publishOnly) {
log.info(`No changes from ${currentContainerVersion}`)
log.info('Only publishing')
public static isContainerPath(path: string, extraErrorMessage: string = '') {
if (!fs.existsSync(getContainerMetadataPath(path))) {
throw new Error(
`${path} is not a path to a Container\n${extraErrorMessage}`
)
}
}