Skip to content

Commit 7d8ccce

Browse files
committed
Add sync-version hook, fix dataPath, bump version
Add a local pre-commit hook that runs scripts/sync-version.mjs to keep pyproject.toml in sync with package.json (uses --stage). Update sync-version.mjs to git-add pyproject.toml after updating it (spawnSync) so pre-commit yields a single staged change. Simplify GSM_Overlay/main.js dataPath logic to always use the overlay folder under APPDATA or user homedir and remove the legacy relocation checks. Bump package.json version to 2026.6.12.
1 parent 4f2e791 commit 7d8ccce

5 files changed

Lines changed: 16 additions & 13 deletions

File tree

.pre-commit-config.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,11 @@ repos:
44
hooks:
55
- id: ruff-format
66
files: ^(GameSentenceMiner|tests|scripts)/.*\.py$|^concat_proj\.py$
7+
- repo: local
8+
hooks:
9+
- id: sync-version
10+
name: sync pyproject.toml version from package.json
11+
entry: node scripts/sync-version.mjs --stage
12+
language: system
13+
files: ^(package\.json|pyproject\.toml)$
14+
pass_filenames: false

GSM_Overlay/main.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,9 @@ protocol.registerSchemesAsPrivileged([
3535
}
3636
]);
3737

38-
// Legacy overlay data location (a sibling of the default GSM data dir).
39-
const legacyOverlayDir = process.env.APPDATA
38+
let dataPath = process.env.APPDATA
4039
? path.join(process.env.APPDATA, "gsm_overlay") // Windows
4140
: path.join(os.homedir(), '.config', "gsm_overlay"); // macOS/Linux
42-
// Only relocate our data when GSM's data dir has actually been moved off the default location;
43-
// at the default location we keep reading the legacy path so existing settings are preserved.
44-
const defaultGsmDataDir = process.env.APPDATA
45-
? path.join(process.env.APPDATA, "GameSentenceMiner")
46-
: path.join(os.homedir(), '.config', "GameSentenceMiner");
47-
const gsmDataDir = (process.env.GSM_DATA_DIR || '').trim();
48-
let dataPath = gsmDataDir && path.resolve(gsmDataDir) !== path.resolve(defaultGsmDataDir)
49-
? path.join(gsmDataDir, "gsm_overlay")
50-
: legacyOverlayDir;
5141

5242
fs.mkdirSync(dataPath, { recursive: true });
5343
app.setPath('userData', dataPath);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "gamesentenceminer",
33
"productName": "GameSentenceMiner",
4-
"version": "2026.6.11",
4+
"version": "2026.6.12",
55
"description": "GameSentenceMiner",
66
"main": "dist/main/bootstrap.js",
77
"scripts": {

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
77

88
[project]
99
name = "GameSentenceMiner"
10-
version = "2026.6.11"
10+
version = "2026.6.12"
1111
description = "A tool for mining sentences from games. Update: Dependencies, replay buffer based line searching, and bug fixes."
1212
readme = "README.md"
1313
requires-python = ">=3.10, <3.14"

scripts/sync-version.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import fs from "node:fs";
22
import path from "node:path";
33
import { fileURLToPath } from "node:url";
4+
import { spawnSync } from "node:child_process";
45

56
// Single source of truth: package.json `version`. This script copies it into
67
// pyproject.toml's [project] version so the bundled Python backend always
@@ -29,6 +30,10 @@ const updated = pyproject.replace(projectVersionRe, `$1"${appVersion}"`);
2930
if (updated !== pyproject) {
3031
fs.writeFileSync(pyprojectPath, updated, "utf8");
3132
console.log(`[sync-version] pyproject.toml version set to ${appVersion}`);
33+
// `--stage` re-adds the file so a pre-commit run produces a single, in-sync commit.
34+
if (process.argv.includes("--stage")) {
35+
spawnSync("git", ["add", pyprojectPath], { stdio: "inherit" });
36+
}
3237
} else {
3338
console.log(`[sync-version] pyproject.toml already at ${appVersion}`);
3439
}

0 commit comments

Comments
 (0)