From 51df5a4999402cc790e5221846be9a2bb65bc3b3 Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Mon, 30 Jun 2025 20:50:19 +0200 Subject: [PATCH] Make rewatch version number same as rescript version number --- rewatch/Cargo.lock | 2 +- rewatch/Cargo.toml | 2 +- yarn.config.cjs | 26 ++++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/rewatch/Cargo.lock b/rewatch/Cargo.lock index 4b313f505c..9ce6fc0242 100644 --- a/rewatch/Cargo.lock +++ b/rewatch/Cargo.lock @@ -749,7 +749,7 @@ checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "rewatch" -version = "1.2.0" +version = "12.0.0-alpha.15" dependencies = [ "ahash", "anyhow", diff --git a/rewatch/Cargo.toml b/rewatch/Cargo.toml index 5a5d192d0d..87d23df89c 100644 --- a/rewatch/Cargo.toml +++ b/rewatch/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rewatch" -version = "1.2.0" +version = "12.0.0-alpha.15" edition = "2021" [dependencies] diff --git a/yarn.config.cjs b/yarn.config.cjs index 42e6c4ac34..21b399d1cd 100644 --- a/yarn.config.cjs +++ b/yarn.config.cjs @@ -6,6 +6,9 @@ const fs = require("node:fs/promises"); const { defineConfig } = require("@yarnpkg/types"); +const { exec } = require("node:child_process"); +const util = require("node:util"); +const execPromise = util.promisify(exec); /** * @param {Yarn.Constraints.Context} ctx @@ -65,6 +68,29 @@ async function enforceCompilerMeta({ Yarn }) { ); } } + + const rewatchCargoFile = "rewatch/Cargo.toml"; + const rewatchCargoContent = await fs.readFile(rewatchCargoFile, "utf8"); + const rewatchVersionPattern = /^version = "(?[^"]+)"$/m; + + if (process.argv.includes("--fix")) { + await fs.writeFile( + rewatchCargoFile, + rewatchCargoContent.replace( + rewatchVersionPattern, + `version = "${EXPECTED_VERSION}"`, + ), + ); + await execPromise("cargo check", { cwd: "rewatch" }); + } else { + const rewatchVersionMatch = rewatchCargoContent.match(rewatchVersionPattern); + const foundRewatchVersion = rewatchVersionMatch?.groups?.version; + if (foundRewatchVersion !== EXPECTED_VERSION) { + Yarn.workspace().error( + `rewatch/Cargo.toml file need to be fixed; expected ${EXPECTED_VERSION}, found ${foundRewatchVersion}.`, + ); + } + } } module.exports = defineConfig({