From 1f9f9f88bb3bc42908266aac1f7753d69856c44e Mon Sep 17 00:00:00 2001 From: Oliver Akins Date: Fri, 27 May 2022 00:41:43 -0600 Subject: [PATCH] Change to a Python file for version bumping --- version-bump.mjs | 14 -------------- version-bump.py | 30 ++++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 14 deletions(-) delete mode 100644 version-bump.mjs create mode 100644 version-bump.py diff --git a/version-bump.mjs b/version-bump.mjs deleted file mode 100644 index d409fa0..0000000 --- a/version-bump.mjs +++ /dev/null @@ -1,14 +0,0 @@ -import { readFileSync, writeFileSync } from "fs"; - -const targetVersion = process.env.npm_package_version; - -// read minAppVersion from manifest.json and bump version to target version -let manifest = JSON.parse(readFileSync("manifest.json", "utf8")); -const { minAppVersion } = manifest; -manifest.version = targetVersion; -writeFileSync("manifest.json", JSON.stringify(manifest, null, "\t")); - -// update versions.json with target version and minAppVersion from manifest.json -let versions = JSON.parse(readFileSync("versions.json", "utf8")); -versions[targetVersion] = minAppVersion; -writeFileSync("versions.json", JSON.stringify(versions, null, "\t")); diff --git a/version-bump.py b/version-bump.py new file mode 100644 index 0000000..68d3ac5 --- /dev/null +++ b/version-bump.py @@ -0,0 +1,30 @@ +import json + +plugin_version = None +obsidian_version = None + + +# Load the versions from the manifest +with open("manifest.json", "r") as file: + data = json.load(file) + obsidian_version = data["minAppVersion"] + plugin_version = data["version"] + + +# Update the package.json +with open("package.json", "r") as file: + package = json.load(file) + if plugin_version: + package["version"] = plugin_version + +with open("versions.json", "r") as file: + versions = json.load(file) + if plugin_version and obsidian_version: + versions[plugin_version] = obsidian_version + + +with open("package.json", "w") as file: + json.dump(package, file, indent=2) + +with open("versions.json", "w") as file: + json.dump(versions, file, indent=2) \ No newline at end of file