UNPKG

@applicaster/zapplicaster-cli

Version:

CLI Tool for the zapp app and Quick Brick project

66 lines (53 loc) 1.79 kB
const { existsSync } = require("fs"); const { writeJsonToFile, readJsonFile } = require("../../file"); const { getPodspecFilePath } = require("./iOSTasks/helper"); const logger = require("../../logger"); async function updateJazzyTemplate({ appleFolder, version }) { const jazzyPath = `${appleFolder}/.jazzy.json`; if (existsSync(jazzyPath)) { logger.log(`Generating template: ${jazzyPath}`); const jazzyJson = await readJsonFile(jazzyPath); jazzyJson.module_version = version; return await writeJsonToFile(jazzyPath, jazzyJson); } else { logger.log(`Template in path: ${jazzyPath}, not exist. Skipping`); } } async function updatePodspecVersion({ pluginPackageJson, appleFolder, version, }) { const podspecPath = await getPodspecFilePath({ pluginAppleFolder: appleFolder, }); if (existsSync(podspecPath)) { logger.log(`Generating template for path: ${podspecPath}`); const podspecJson = await readJsonFile(podspecPath); const pluginName = pluginPackageJson.name; podspecJson.version = version; podspecJson.source.tag = `@${pluginName}/${version}`; return await writeJsonToFile(podspecPath, podspecJson); } else { logger.log(`Podspec: ${podspecPath}, not exist. Skipping`); } } async function generateAppleTemplates(configuration) { const { pluginPath, version, pluginPackageJson } = configuration; try { await updateJazzyTemplate({ appleFolder: `${pluginPath}/apple`, version, }); return await updatePodspecVersion({ pluginPackageJson, appleFolder: `${pluginPath}/apple`, version, }); } catch (e) { throw new Error( "An error occured when generating the templates: " + e.message ); } } module.exports = { generateAppleTemplates };