2021-05-09 21:19:37 +03:00
|
|
|
#!/usr/bin/env node
|
2022-02-10 22:46:30 +03:00
|
|
|
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
2021-05-09 21:19:37 +03:00
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
|
|
|
/*
|
|
|
|
This script is solely intended to be run as part of the `covector version` step to
|
2022-02-10 22:46:30 +03:00
|
|
|
keep the `tauri-runtime`, `tauri-runtime-wry` and `tauri-driver` crates version without the `beta` or `rc` suffix.
|
2021-05-09 21:19:37 +03:00
|
|
|
*/
|
|
|
|
|
2022-02-10 22:46:30 +03:00
|
|
|
const {
|
|
|
|
readFileSync,
|
|
|
|
writeFileSync
|
|
|
|
} = require('fs')
|
2021-05-09 21:19:37 +03:00
|
|
|
|
2021-05-10 00:43:50 +03:00
|
|
|
const packageNickname = process.argv[2]
|
|
|
|
const bump = process.argv[3]
|
2021-05-09 21:19:37 +03:00
|
|
|
|
2021-05-10 00:43:50 +03:00
|
|
|
let manifestPath
|
|
|
|
let dependencyManifestPaths
|
|
|
|
let changelogPath
|
2021-05-09 21:19:37 +03:00
|
|
|
|
2021-05-10 00:43:50 +03:00
|
|
|
if (packageNickname === 'tauri-runtime') {
|
|
|
|
manifestPath = '../../core/tauri-runtime/Cargo.toml'
|
2021-07-04 01:48:04 +03:00
|
|
|
dependencyManifestPaths = [
|
|
|
|
'../../core/tauri/Cargo.toml',
|
|
|
|
'../../core/tauri-runtime-wry/Cargo.toml'
|
|
|
|
]
|
2021-05-10 00:43:50 +03:00
|
|
|
changelogPath = '../../core/tauri-runtime/CHANGELOG.md'
|
|
|
|
} else if (packageNickname === 'tauri-runtime-wry') {
|
|
|
|
manifestPath = '../../core/tauri-runtime-wry/Cargo.toml'
|
|
|
|
dependencyManifestPaths = ['../../core/tauri/Cargo.toml']
|
|
|
|
changelogPath = '../../core/tauri-runtime-wry/CHANGELOG.md'
|
2021-06-23 20:18:26 +03:00
|
|
|
} else if (packageNickname === 'tauri-driver') {
|
|
|
|
manifestPath = '../../tooling/webdriver/Cargo.toml'
|
|
|
|
dependencyManifestPaths = []
|
|
|
|
changelogPath = '../../tooling/webdriver/CHANGELOG.md'
|
2021-05-10 00:43:50 +03:00
|
|
|
} else {
|
|
|
|
throw new Error(`Unexpected package ${packageNickname}`)
|
|
|
|
}
|
|
|
|
|
2021-07-04 01:48:04 +03:00
|
|
|
let manifest = readFileSync(manifestPath, 'utf-8')
|
|
|
|
manifest = manifest.replace(
|
|
|
|
/version = "(\d+\.\d+\.\d+)-[^0-9\.]+\.0"/,
|
|
|
|
'version = "$1"'
|
|
|
|
)
|
2021-05-10 00:43:50 +03:00
|
|
|
writeFileSync(manifestPath, manifest)
|
2021-05-09 21:19:37 +03:00
|
|
|
|
2021-07-04 01:48:04 +03:00
|
|
|
let changelog = readFileSync(changelogPath, 'utf-8')
|
2021-05-09 21:19:37 +03:00
|
|
|
changelog = changelog.replace(/(\d+\.\d+\.\d+)-[^0-9\.]+\.0/, '$1')
|
|
|
|
writeFileSync(changelogPath, changelog)
|
|
|
|
|
|
|
|
for (const dependencyManifestPath of dependencyManifestPaths) {
|
2021-07-04 01:48:04 +03:00
|
|
|
let dependencyManifest = readFileSync(dependencyManifestPath, 'utf-8')
|
|
|
|
dependencyManifest = dependencyManifest.replace(
|
|
|
|
new RegExp(
|
|
|
|
packageNickname + ' = { version = "(\\d+\\.\\d+.\\d+)-[^0-9.]+.0"'
|
|
|
|
),
|
|
|
|
`${packageNickname} = { version = "$1"`
|
|
|
|
)
|
2021-05-09 21:19:37 +03:00
|
|
|
writeFileSync(dependencyManifestPath, dependencyManifest)
|
|
|
|
}
|