sync-prerelease.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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-release` crate 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 = ['../../core/tauri/Cargo.toml', '../../core/tauri-runtime-wry/Cargo.toml']
  18. changelogPath = '../../core/tauri-runtime/CHANGELOG.md'
  19. } else if (packageNickname === 'tauri-runtime-wry') {
  20. manifestPath = '../../core/tauri-runtime-wry/Cargo.toml'
  21. dependencyManifestPaths = ['../../core/tauri/Cargo.toml']
  22. changelogPath = '../../core/tauri-runtime-wry/CHANGELOG.md'
  23. } else {
  24. throw new Error(`Unexpected package ${packageNickname}`)
  25. }
  26. let manifest = readFileSync(manifestPath, "utf-8")
  27. manifest = manifest.replace(/version = "(\d+\.\d+\.\d+)-[^0-9\.]+\.0"/, 'version = "$1"')
  28. writeFileSync(manifestPath, manifest)
  29. let changelog = readFileSync(changelogPath, "utf-8")
  30. changelog = changelog.replace(/(\d+\.\d+\.\d+)-[^0-9\.]+\.0/, '$1')
  31. writeFileSync(changelogPath, changelog)
  32. for (const dependencyManifestPath of dependencyManifestPaths) {
  33. let dependencyManifest = readFileSync(dependencyManifestPath, "utf-8")
  34. dependencyManifest = dependencyManifest.replace(/tauri-runtime = { version = "(\d+\.\d+\.\d+)-[^0-9\.]+\.0"/, 'tauri-runtime = { version = "$1"')
  35. writeFileSync(dependencyManifestPath, dependencyManifest)
  36. }