Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Figure out the list of all git MiniApps that have been updated (new HEAD sha)
const updatedGitMiniApps = await cauldron.getLatestShasForMiniAppsBranches(
descriptor
)
if (updatedGitMiniApps.length === 0) {
log.info('No Changes ...')
if (fullRegen) {
log.info('Performing regen anyway [--fullRegen]')
} else {
log.info('Skipping regen. To regenerate use the --fullRegen option.')
return
}
}
await syncCauldronContainer(
async () => {
for (const updatedGitMiniApp of updatedGitMiniApps) {
await cauldron.updateMiniAppVersionInContainer(
descriptor!,
updatedGitMiniApp,
{ keepBranch: true }
)
}
},
descriptor,
`Regenerate Container of ${descriptor} native application`,
{
containerVersion,
sourceMapOutput,
}
)
}
// ... and that it is a properly formatted json file
const cauldronFile = await cauldron.getFile({ cauldronFilePath: extra })
await parseJsonFromStringOrFile(cauldronFile.toString())
extraObj = extra
} else {
// Local file path to json file or json string.
// In that case, the extra property set for this publisher
// in Cauldron, will be the the json string, or the
// content of the json file, as such
// For example :
// "extra": {
// "artifactId": "app-container",
// "groupId": "com.company.app"
// }
extraObj = await parseJsonFromStringOrFile(extra)
}
}
const p: ContainerPublisher = await getPublisher(publisher)
if (descriptor && !p.platforms.includes(descriptor.platform!)) {
throw new Error(
`The ${p.name} publisher does not support ${descriptor.platform} platform`
)
}
await cauldron.addPublisher(publisher, p.platforms, descriptor, url, extraObj)
log.info(`${publisher} publisher successfully added to ${descriptor}`)
}
`${outDir} directory exists and is not empty.
Output directory should either not exist (it will be created) or should be empty.`
)
}
}
compositeDir = compositeDir || createTmpDir()
const cauldron = await getActiveCauldron({ throwIfNoActiveCauldron: false })
if (!cauldron && !miniapps) {
throw new Error(
"A Cauldron must be active, if you don't explicitly provide miniapps"
)
}
const extraObj = (extra && (await parseJsonFromStringOrFile(extra))) || {}
// Full native application selector was not provided.
// Ask the user to select a completeNapDescriptor from a list
// containing all the native applications versions in the cauldron
// Not needed if miniapps are directly provided
if (!descriptor && !miniapps) {
descriptor = await askUserToChooseANapDescriptorFromCauldron({
onlyNonReleasedVersions: true,
})
}
if (descriptor) {
await logErrorAndExitIfNotSatisfied({
napDescriptorExistInCauldron: {
descriptor,
extraErrorMessage:
//
// Cauldron file path.
// In that case, the extra property set for this publisher
// in Cauldron, will be a string, with its value being
// the path to the json extra config file stored in
// Cauldron.
// For example :
// "extra": "cauldron://config/publishers/maven.json"
// We just validate that the file exist in Cauldron ...
if (!(await cauldron.hasFile({ cauldronFilePath: extra }))) {
throw new Error(`File ${extra} does not exist in Cauldron.`)
}
// ... and that it is a properly formatted json file
const cauldronFile = await cauldron.getFile({ cauldronFilePath: extra })
await parseJsonFromStringOrFile(cauldronFile.toString())
extraObj = extra
} else {
// Local file path to json file or json string.
// In that case, the extra property set for this publisher
// in Cauldron, will be the the json string, or the
// content of the json file, as such
// For example :
// "extra": {
// "artifactId": "app-container",
// "groupId": "com.company.app"
// }
extraObj = await parseJsonFromStringOrFile(extra)
}
}
const p: ContainerPublisher = await getPublisher(publisher)
}) => {
if (process.platform !== 'darwin') {
return log.error('This command can only be used on Mac OS X')
}
deviceConfig.updateDeviceConfig('ios', usePreviousDevice)
if (!host && dev) {
try {
host = getLocalIp()
} catch (e) {
// Swallow
log.debug(e)
}
}
await runMiniApp('ios', {
baseComposite,
descriptor,
dev,
host: host || 'localhost',
mainMiniAppName,
miniapps,
port,
})
}
}: {
baseComposite?: PackagePath
extra?: string
descriptor?: AppVersionDescriptor
dev?: boolean
host?: string
mainMiniAppName?: string
miniapps?: PackagePath[]
port?: string
usePreviousDevice?: boolean
}) => {
deviceConfig.updateDeviceConfig('android', usePreviousDevice)
const miniAppPackageJson = await readPackageJson(process.cwd())
const extraObj =
(extra && (await parseJsonFromStringOrFile(extra))) ||
miniAppPackageJson.ern
? miniAppPackageJson.ern
: {}
await runMiniApp('android', {
baseComposite,
descriptor,
dev,
extra: extraObj,
host,
mainMiniAppName,
miniapps,
port,
})
process.exit(0)
}
host?: string
mainMiniAppName?: string
miniapps?: PackagePath[]
port?: string
usePreviousDevice?: boolean
}) => {
deviceConfig.updateDeviceConfig('android', usePreviousDevice)
const miniAppPackageJson = await readPackageJson(process.cwd())
const extraObj =
(extra && (await parseJsonFromStringOrFile(extra))) ||
miniAppPackageJson.ern
? miniAppPackageJson.ern
: {}
await runMiniApp('android', {
baseComposite,
descriptor,
dev,
extra: extraObj,
host,
mainMiniAppName,
miniapps,
port,
})
process.exit(0)
}
extraErrorMessage:
'This command cannot work on a non existing native application version',
},
})
const cauldronCommitMessage = [
`${
jsapiimpls.length === 1
? `Remove ${jsapiimpls[0]} JS API implementation from ${descriptor}`
: `Remove multiple JS API implementations from ${descriptor}`
}`,
]
if (!(await emptyContainerIfSingleMiniAppOrJsApiImpl(descriptor))) {
const cauldron = await getActiveCauldron()
await syncCauldronContainer(
async () => {
for (const jsApiImpl of jsapiimpls) {
await cauldron.removeJsApiImplFromContainer(descriptor!, jsApiImpl)
cauldronCommitMessage.push(
`- Remove ${jsApiImpl} JS API implementation`
)
}
},
descriptor,
cauldronCommitMessage,
{ containerVersion }
)
}
log.info(`JS API implementation(s) successfully removed from ${descriptor}`)
}
extraErrorMessage:
'You cannot provide dependency(ies) using git or file schme for this command. Only the form dependency@version is allowed.',
obj: dependencies,
},
})
const cauldronCommitMessage = [
`${
dependencies.length === 1
? `Remove ${dependencies[0]} native dependency from ${descriptor}`
: `Remove multiple native dependencies from ${descriptor}`
}`,
]
const cauldron = await getActiveCauldron()
await syncCauldronContainer(
async () => {
for (const dependency of dependencies) {
await cauldron.removeNativeDependencyFromContainer(
descriptor!,
dependency
)
cauldronCommitMessage.push(`- Remove ${dependency} native dependency`)
}
},
descriptor,
cauldronCommitMessage,
{ containerVersion }
)
log.info(`Dependency(ies) successfully removed from ${descriptor}`)
}
extraErrorMessage:
'You can only add dependencies versions that have been published to NPM',
obj: dependencies,
},
})
const cauldronCommitMessage = [
`${
dependencies.length === 1
? `Add ${dependencies[0]} native dependency to ${descriptor}`
: `Add multiple native dependencies to ${descriptor}`
}`,
]
const cauldron = await getActiveCauldron()
await syncCauldronContainer(
async () => {
for (const dependency of dependencies) {
await cauldron.addNativeDependencyToContainer(descriptor!, dependency)
cauldronCommitMessage.push(`- Add ${dependency} native dependency`)
}
},
descriptor,
cauldronCommitMessage,
{ containerVersion }
)
log.info(`Dependency(ies) successfully added to ${descriptor}`)
}