rn-version-sync
Version:
Fast and simple utility to sync React Native version with native code
37 lines • 2.01 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getPackageVersion = exports.updateIOSVersion = exports.updateAndroidVersion = void 0;
exports.syncVersions = syncVersions;
const android_1 = require("./android");
const ios_1 = require("./ios");
const utils_1 = require("./utils");
const MAX_VERSION_CODE = 2147483647;
/**
* Main function to sync versions
*/
function syncVersions(projectRoot, options = {}) {
const { verbose = false, versionCode: manualVersionCode } = options;
const versionName = (0, utils_1.getPackageVersion)(projectRoot);
const versionCode = manualVersionCode ?? (0, utils_1.calculateVersionCode)(versionName);
// Validate manual version code override
if (manualVersionCode !== undefined && manualVersionCode > MAX_VERSION_CODE) {
throw new Error(`Version code ${manualVersionCode} exceeds maximum value ${MAX_VERSION_CODE}.\n` +
`Android and iOS use 32-bit signed integers for version codes.`);
}
if (verbose) {
console.log(`Syncing version name: ${versionName}`);
console.log(`Using version code: ${versionCode}`);
}
// Update Android with separate version name and code
(0, android_1.updateAndroidVersion)(projectRoot, versionName, versionCode, verbose);
// Update iOS with separate version name and code
(0, ios_1.updateIOSVersion)(projectRoot, versionName, versionCode.toString(), verbose);
}
// Re-export utilities for testing
var android_2 = require("./android");
Object.defineProperty(exports, "updateAndroidVersion", { enumerable: true, get: function () { return android_2.updateAndroidVersion; } });
var ios_2 = require("./ios");
Object.defineProperty(exports, "updateIOSVersion", { enumerable: true, get: function () { return ios_2.updateIOSVersion; } });
var utils_2 = require("./utils");
Object.defineProperty(exports, "getPackageVersion", { enumerable: true, get: function () { return utils_2.getPackageVersion; } });
//# sourceMappingURL=index.js.map