2020-11-24 03:11:40 +01:00
|
|
|
const editJsonFile = require('edit-json-file');
|
2020-12-04 22:20:53 +01:00
|
|
|
const replace = require('replace-in-file');
|
2020-11-24 03:11:40 +01:00
|
|
|
|
|
|
|
const WORKDIR = `${__dirname}/../..`;
|
|
|
|
|
|
|
|
const OLD_VERSION = (function(){
|
|
|
|
const file = editJsonFile(`${WORKDIR}/client/package.json`);
|
|
|
|
return file.get('version');
|
|
|
|
})();
|
|
|
|
const NEW_VERSION = process.env.VERSION;
|
|
|
|
|
|
|
|
|
|
|
|
function updateJSONVersion(filePath) {
|
|
|
|
const file = editJsonFile(filePath);
|
|
|
|
file.set('version', NEW_VERSION);
|
|
|
|
file.save();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update json versions
|
|
|
|
updateJSONVersion(`${WORKDIR}/client/package.json`);
|
|
|
|
updateJSONVersion(`${WORKDIR}/client/package-lock.json`);
|
|
|
|
updateJSONVersion(`${WORKDIR}/server/apidoc.json`);
|
|
|
|
|
|
|
|
// Replace in places
|
2020-12-04 22:20:53 +01:00
|
|
|
replace({
|
|
|
|
files: `${WORKDIR}/client/src/config.js`,
|
|
|
|
from: `opensupports_version = '${OLD_VERSION}';`,
|
|
|
|
to: `opensupports_version = '${NEW_VERSION}';`
|
|
|
|
});
|
|
|
|
replace({
|
|
|
|
files: `${WORKDIR}/client/src/index.php`,
|
|
|
|
from: `opensupports_version = '${OLD_VERSION}';`,
|
|
|
|
to: `opensupports_version = '${NEW_VERSION}';`
|
|
|
|
});
|
|
|
|
replace({
|
|
|
|
files: `${WORKDIR}/server/**/*.php`,
|
|
|
|
from: `* @apiVersion ${OLD_VERSION}`,
|
|
|
|
to: `* @apiVersion ${NEW_VERSION}`
|
|
|
|
});
|
|
|
|
replace({
|
|
|
|
files: `${WORKDIR}/client/src/config.js`,
|
|
|
|
from: `v${OLD_VERSION}`,
|
|
|
|
to: `v${NEW_VERSION}`
|
|
|
|
});
|
2021-01-08 20:31:06 +01:00
|
|
|
replace({
|
|
|
|
files: `${WORKDIR}/README.md`,
|
|
|
|
from: `v${OLD_VERSION}`,
|
|
|
|
to: `v${NEW_VERSION}`
|
|
|
|
});
|