sync-prerelease.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/usr/bin/env node
  2. // Copyright 2019-2021 Tauri Programme within The Commons Conservancy
  3. // SPDX-License-Identifier: Apache-2.0
  4. // SPDX-License-Identifier: MIT
  5. /*
  6. This script is solely intended to be run as part of the `covector version` step to
  7. keep the `tauri-runtime`, `tauri-runtime-wry` and `tauri-driver` crates version without the `beta` or `beta-rc` suffix.
  8. */
  9. const { readFileSync, writeFileSync } = require('fs')
  10. const packageNickname = process.argv[2]
  11. const bump = process.argv[3]
  12. let manifestPath
  13. let dependencyManifestPaths
  14. let changelogPath
  15. if (packageNickname === 'tauri-runtime') {
  16. manifestPath = '../../core/tauri-runtime/Cargo.toml'
  17. dependencyManifestPaths = [
  18. '../../core/tauri/Cargo.toml',
  19. '../../core/tauri-runtime-wry/Cargo.toml'
  20. ]
  21. changelogPath = '../../core/tauri-runtime/CHANGELOG.md'
  22. } else if (packageNickname === 'tauri-runtime-wry') {
  23. manifestPath = '../../core/tauri-runtime-wry/Cargo.toml'
  24. dependencyManifestPaths = ['../../core/tauri/Cargo.toml']
  25. changelogPath = '../../core/tauri-runtime-wry/CHANGELOG.md'
  26. } else if (packageNickname === 'tauri-driver') {
  27. manifestPath = '../../tooling/webdriver/Cargo.toml'
  28. dependencyManifestPaths = []
  29. changelogPath = '../../tooling/webdriver/CHANGELOG.md'
  30. } else {
  31. throw new Error(`Unexpected package ${packageNickname}`)
  32. }
  33. let manifest = readFileSync(manifestPath, 'utf-8')
  34. manifest = manifest.replace(
  35. /version = "(\d+\.\d+\.\d+)-[^0-9\.]+\.0"/,
  36. 'version = "$1"'
  37. )
  38. writeFileSync(manifestPath, manifest)
  39. let changelog = readFileSync(changelogPath, 'utf-8')
  40. changelog = changelog.replace(/(\d+\.\d+\.\d+)-[^0-9\.]+\.0/, '$1')
  41. writeFileSync(changelogPath, changelog)
  42. for (const dependencyManifestPath of dependencyManifestPaths) {
  43. let dependencyManifest = readFileSync(dependencyManifestPath, 'utf-8')
  44. dependencyManifest = dependencyManifest.replace(
  45. new RegExp(
  46. packageNickname + ' = { version = "(\\d+\\.\\d+.\\d+)-[^0-9.]+.0"'
  47. ),
  48. `${packageNickname} = { version = "$1"`
  49. )
  50. writeFileSync(dependencyManifestPath, dependencyManifest)
  51. }