sync-prerelease.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 `rc` suffix.
  8. */
  9. const {
  10. readFileSync,
  11. writeFileSync
  12. } = require('fs')
  13. const packageNickname = process.argv[2]
  14. const bump = process.argv[3]
  15. let manifestPath
  16. let dependencyManifestPaths
  17. let changelogPath
  18. if (packageNickname === 'tauri-runtime') {
  19. manifestPath = '../../core/tauri-runtime/Cargo.toml'
  20. dependencyManifestPaths = [
  21. '../../core/tauri/Cargo.toml',
  22. '../../core/tauri-runtime-wry/Cargo.toml'
  23. ]
  24. changelogPath = '../../core/tauri-runtime/CHANGELOG.md'
  25. } else if (packageNickname === 'tauri-runtime-wry') {
  26. manifestPath = '../../core/tauri-runtime-wry/Cargo.toml'
  27. dependencyManifestPaths = ['../../core/tauri/Cargo.toml']
  28. changelogPath = '../../core/tauri-runtime-wry/CHANGELOG.md'
  29. } else if (packageNickname === 'tauri-driver') {
  30. manifestPath = '../../tooling/webdriver/Cargo.toml'
  31. dependencyManifestPaths = []
  32. changelogPath = '../../tooling/webdriver/CHANGELOG.md'
  33. } else {
  34. throw new Error(`Unexpected package ${packageNickname}`)
  35. }
  36. let manifest = readFileSync(manifestPath, 'utf-8')
  37. manifest = manifest.replace(
  38. /version = "(\d+\.\d+\.\d+)-[^0-9\.]+\.0"/,
  39. 'version = "$1"'
  40. )
  41. writeFileSync(manifestPath, manifest)
  42. let changelog = readFileSync(changelogPath, 'utf-8')
  43. changelog = changelog.replace(/(\d+\.\d+\.\d+)-[^0-9\.]+\.0/, '$1')
  44. writeFileSync(changelogPath, changelog)
  45. for (const dependencyManifestPath of dependencyManifestPaths) {
  46. let dependencyManifest = readFileSync(dependencyManifestPath, 'utf-8')
  47. dependencyManifest = dependencyManifest.replace(
  48. new RegExp(
  49. packageNickname + ' = { version = "(\\d+\\.\\d+.\\d+)-[^0-9.]+.0"'
  50. ),
  51. `${packageNickname} = { version = "$1"`
  52. )
  53. writeFileSync(dependencyManifestPath, dependencyManifest)
  54. }