forked from lullabyX/sone
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsync-version.mjs
More file actions
52 lines (46 loc) · 1.54 KB
/
Copy pathsync-version.mjs
File metadata and controls
52 lines (46 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Syncs the version from package.json → tauri.conf.json + Cargo.toml.
// Runs automatically via the npm "version" lifecycle hook.
import { readFileSync, writeFileSync } from "fs";
const { version } = JSON.parse(readFileSync("package.json", "utf8"));
// tauri.conf.json
const tauri = readFileSync("src-tauri/tauri.conf.json", "utf8");
writeFileSync(
"src-tauri/tauri.conf.json",
tauri.replace(/"version": "[^"]+"/, `"version": "${version}"`)
);
// Cargo.toml (only the package version, not dependency versions)
const cargo = readFileSync("src-tauri/Cargo.toml", "utf8");
writeFileSync(
"src-tauri/Cargo.toml",
cargo.replace(/^version = "[^"]+"/m, `version = "${version}"`)
);
// metainfo.xml (release version + date)
const metainfo = readFileSync(
"data/io.github.lullabyX.sone.metainfo.xml",
"utf8"
);
const today = new Date().toISOString().slice(0, 10);
writeFileSync(
"data/io.github.lullabyX.sone.metainfo.xml",
metainfo.replace(
/<release version="[^"]+" date="[^"]+">/,
`<release version="${version}" date="${today}">`
)
);
// PKGBUILD
try {
const pkgbuild = readFileSync("build-scripts/build/PKGBUILD", "utf8");
writeFileSync(
"build-scripts/build/PKGBUILD",
pkgbuild.replace(/^pkgver=.+$/m, `pkgver=${version}`)
);
console.log(
`Synced version ${version} → tauri.conf.json, Cargo.toml, metainfo.xml, PKGBUILD`
);
} catch (e) {
if (e.code !== "ENOENT") throw e;
console.log(
`Synced version ${version} → tauri.conf.json, Cargo.toml, metainfo.xml`
);
console.warn("PKGBUILD not found, skipping");
}