52 lines
2.1 KiB
JavaScript
52 lines
2.1 KiB
JavaScript
"use strict";
|
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
if (mod && mod.__esModule) return mod;
|
|
var result = {};
|
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
result["default"] = mod;
|
|
return result;
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const android_plugins_1 = require("../plugins/android-plugins");
|
|
const WarningAggregator = __importStar(require("../utils/warnings"));
|
|
exports.withVersion = config => {
|
|
return android_plugins_1.withAppBuildGradle(config, config => {
|
|
if (config.modResults.language === 'groovy') {
|
|
config.modResults.contents = setVersionCode(config, config.modResults.contents);
|
|
config.modResults.contents = setVersionName(config, config.modResults.contents);
|
|
}
|
|
else {
|
|
WarningAggregator.addWarningAndroid('android-version', `Cannot automatically configure app build.gradle if it's not groovy`);
|
|
}
|
|
return config;
|
|
});
|
|
};
|
|
function getVersionName(config) {
|
|
var _a;
|
|
return (_a = config.version) !== null && _a !== void 0 ? _a : null;
|
|
}
|
|
exports.getVersionName = getVersionName;
|
|
function setVersionName(config, buildGradle) {
|
|
const versionName = getVersionName(config);
|
|
if (versionName === null) {
|
|
return buildGradle;
|
|
}
|
|
const pattern = new RegExp(`versionName ".*"`);
|
|
return buildGradle.replace(pattern, `versionName "${versionName}"`);
|
|
}
|
|
exports.setVersionName = setVersionName;
|
|
function getVersionCode(config) {
|
|
var _a, _b;
|
|
return (_b = (_a = config.android) === null || _a === void 0 ? void 0 : _a.versionCode) !== null && _b !== void 0 ? _b : null;
|
|
}
|
|
exports.getVersionCode = getVersionCode;
|
|
function setVersionCode(config, buildGradle) {
|
|
const versionCode = getVersionCode(config);
|
|
if (versionCode === null) {
|
|
return buildGradle;
|
|
}
|
|
const pattern = new RegExp(`versionCode.*`);
|
|
return buildGradle.replace(pattern, `versionCode ${versionCode}`);
|
|
}
|
|
exports.setVersionCode = setVersionCode;
|
|
//# sourceMappingURL=Version.js.map
|