Skip to content

Commit 4f29432

Browse files
authored
chore(cubestore): Sync Cargo.toml version with lerna (cube-js#10487)
Add a version lifecycle script that updates cubestore/Cargo.toml version to match the npm package version whenever lerna version runs.
1 parent fbfec5e commit 4f29432

4 files changed

Lines changed: 30 additions & 2 deletions

File tree

rust/cubestore/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/cubestore/cubestore/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cubestore"
3-
version = "0.1.0"
3+
version = "1.6.22"
44
authors = ["Cube Dev, Inc."]
55
edition = "2021"
66
license = "Apache-2.0"

rust/cubestore/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"lint:fix": "eslint --fix js-wrapper/* --ext .ts,js",
1919
"unit": "jest",
2020
"unit:debug": "jest --runInBand",
21+
"version": "node scripts/sync-cargo-version.js",
2122
"postinstall": "node bin/post-install"
2223
},
2324
"files": [
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
const { execFileSync, execSync } = require('child_process');
4+
5+
const version = process.env.npm_package_version;
6+
if (!version) {
7+
console.error('npm_package_version is not set');
8+
process.exit(1);
9+
}
10+
11+
const cargoTomlPath = path.resolve(__dirname, '..', 'cubestore', 'Cargo.toml');
12+
const content = fs.readFileSync(cargoTomlPath, 'utf8');
13+
const updated = content.replace(/^(version\s*=\s*)"[^"]*"/m, `$1"${version}"`);
14+
15+
if (content === updated) {
16+
console.log(`Cargo.toml version already matches ${version}`);
17+
process.exit(0);
18+
}
19+
20+
fs.writeFileSync(cargoTomlPath, updated);
21+
console.log(`Updated Cargo.toml version to ${version}`);
22+
23+
const workspaceRoot = path.resolve(__dirname, '..');
24+
execSync('cargo update --workspace', { cwd: workspaceRoot, stdio: 'inherit' });
25+
26+
const cargoLockPath = path.resolve(workspaceRoot, 'Cargo.lock');
27+
execFileSync('git', ['add', cargoTomlPath, cargoLockPath], { stdio: 'inherit' });

0 commit comments

Comments
 (0)