UNPKG

@bravemobile/react-native-code-push

Version:

React Native plugin for the CodePush service

26 lines (25 loc) 970 B
import fs from "fs"; import path from "path"; export async function createReleaseHistory(targetVersion, setReleaseHistory, platform, identifier) { const BINARY_RELEASE = { enabled: true, mandatory: false, downloadUrl: "", packageHash: "", }; const INITIAL_HISTORY = { [targetVersion]: BINARY_RELEASE }; try { const JSON_FILE_NAME = `${targetVersion}.json`; const JSON_FILE_PATH = path.resolve(process.cwd(), JSON_FILE_NAME); console.log(`log: creating JSON file... ("${JSON_FILE_NAME}")\n`, JSON.stringify(INITIAL_HISTORY, null, 2)); fs.writeFileSync(JSON_FILE_PATH, JSON.stringify(INITIAL_HISTORY)); await setReleaseHistory(targetVersion, JSON_FILE_PATH, INITIAL_HISTORY, platform, identifier); fs.unlinkSync(JSON_FILE_PATH); } catch (error) { console.error('Error occurred while creating new history:', error); process.exit(1); } }