2021-03-04 17:49:52 +03:00
|
|
|
import { command } from 'execa'
|
2019-02-10 15:26:50 +03:00
|
|
|
|
2022-09-26 16:29:56 +03:00
|
|
|
import { LogHelper } from '@/helpers/log-helper'
|
2019-02-10 15:26:50 +03:00
|
|
|
|
|
|
|
/**
|
2019-03-02 07:54:25 +03:00
|
|
|
* Update version number in files which need version number
|
2019-02-10 15:26:50 +03:00
|
|
|
*/
|
2022-09-03 14:12:41 +03:00
|
|
|
export default (version) =>
|
|
|
|
new Promise(async (resolve, reject) => {
|
2022-09-26 16:29:56 +03:00
|
|
|
LogHelper.info('Updating version...')
|
2019-02-10 15:26:50 +03:00
|
|
|
|
2022-09-03 14:12:41 +03:00
|
|
|
const promises = []
|
2023-05-01 05:09:29 +03:00
|
|
|
// const files = ['package.json', 'package-lock.json']
|
|
|
|
const files = ['package.json']
|
2019-02-10 15:26:50 +03:00
|
|
|
|
2022-09-03 14:12:41 +03:00
|
|
|
for (let i = 0; i < files.length; i += 1) {
|
|
|
|
promises.push(
|
|
|
|
command(`json -I -f ${files[i]} -e 'this.version="${version}"'`, {
|
|
|
|
shell: true
|
|
|
|
})
|
|
|
|
)
|
|
|
|
}
|
2019-02-10 15:26:50 +03:00
|
|
|
|
2022-09-03 14:12:41 +03:00
|
|
|
try {
|
|
|
|
await Promise.all(promises)
|
2019-02-10 15:26:50 +03:00
|
|
|
|
2022-09-26 16:29:56 +03:00
|
|
|
LogHelper.success(`Version updated to ${version}`)
|
2022-09-03 14:12:41 +03:00
|
|
|
resolve()
|
|
|
|
} catch (e) {
|
2022-09-26 16:29:56 +03:00
|
|
|
LogHelper.error(`Error while updating version: ${e.stderr}`)
|
2022-09-03 14:12:41 +03:00
|
|
|
reject(e)
|
|
|
|
}
|
|
|
|
})
|