(feat): update android version stuff to better fit obtainium's needs
This commit is contained in:
parent
167036533c
commit
ebd2a364a7
8 changed files with 90 additions and 9 deletions
|
|
@ -25,7 +25,7 @@
|
|||
"dev:mobile:raw": "tauri android dev",
|
||||
"build:mobile:raw": "tauri android build",
|
||||
"dev:mobile": "if command -v nix >/dev/null 2>&1; then nix develop --command bun dev:mobile:raw; else bun dev:mobile:raw; fi",
|
||||
"build:mobile": "if command -v nix >/dev/null 2>&1; then nix develop --command bun build:mobile:raw; else bun build:mobile:raw; fi",
|
||||
"build:mobile": "bun run render-version.ts && if command -v nix >/dev/null 2>&1; then nix develop --command bun build:mobile:raw; else bun build:mobile:raw; fi && bun run render-version.ts --unrender",
|
||||
"dev:desktop:raw": "tauri dev",
|
||||
"build:desktop:raw": "tauri build",
|
||||
"dev:desktop": "if command -v nix >/dev/null 2>&1; then nix develop --command bun dev:desktop:raw; else bun dev:desktop:raw; fi",
|
||||
|
|
@ -46,6 +46,7 @@
|
|||
"react-dom": "^19.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tauri-apps/cli": "^2"
|
||||
"@tauri-apps/cli": "^2",
|
||||
"@types/node": "^25.9.1"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
75
apps/tauri/render-version.ts
Normal file
75
apps/tauri/render-version.ts
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
import fs from "fs";
|
||||
import path from "path";
|
||||
|
||||
// Config
|
||||
const PLACEHOLDER_VERSION = "0.0.0";
|
||||
|
||||
const rootPackageJsonPath = path.resolve(__dirname, "../../package.json");
|
||||
const cargoTomlPath = path.resolve(__dirname, "./src-tauri/Cargo.toml");
|
||||
const tauriConfigPath = path.resolve(__dirname, "./src-tauri/tauri.conf.json");
|
||||
|
||||
// Args
|
||||
const isUnrender = process.argv.includes("--unrender");
|
||||
|
||||
// Version Source
|
||||
const packageJson = JSON.parse(
|
||||
fs.readFileSync(rootPackageJsonPath, "utf8")
|
||||
);
|
||||
|
||||
const packageVersion: string = packageJson.version;
|
||||
|
||||
if (!packageVersion && !isUnrender) {
|
||||
throw new Error("No version found in package.json");
|
||||
}
|
||||
|
||||
const targetVersion = isUnrender
|
||||
? PLACEHOLDER_VERSION
|
||||
: packageVersion;
|
||||
|
||||
// Helpers
|
||||
function updateCargoToml(content: string): string {
|
||||
const regex = /^version\s*=\s*".*"$/m;
|
||||
|
||||
if (!regex.test(content)) {
|
||||
throw new Error("Could not find version field in Cargo.toml");
|
||||
}
|
||||
|
||||
return content.replace(
|
||||
regex,
|
||||
`version = "${targetVersion}"`
|
||||
);
|
||||
}
|
||||
|
||||
function updateTauriConfig(content: string): string {
|
||||
const regex = /"version"\s*:\s*".*"/;
|
||||
|
||||
if (!regex.test(content)) {
|
||||
throw new Error("Could not find version field in tauri.conf.json");
|
||||
}
|
||||
|
||||
return content.replace(
|
||||
regex,
|
||||
`"version": "${targetVersion}"`
|
||||
);
|
||||
}
|
||||
|
||||
// Update Cargo.toml
|
||||
const cargoToml = fs.readFileSync(cargoTomlPath, "utf8");
|
||||
|
||||
const updatedCargoToml = updateCargoToml(cargoToml);
|
||||
|
||||
fs.writeFileSync(cargoTomlPath, updatedCargoToml, "utf8");
|
||||
|
||||
// Update tauri.conf.json
|
||||
const tauriConfig = fs.readFileSync(tauriConfigPath, "utf8");
|
||||
|
||||
const updatedTauriConfig = updateTauriConfig(tauriConfig);
|
||||
|
||||
fs.writeFileSync(tauriConfigPath, updatedTauriConfig, "utf8");
|
||||
|
||||
// Finished
|
||||
if (isUnrender) {
|
||||
console.log(`Unrendered versions back to ${PLACEHOLDER_VERSION}`);
|
||||
} else {
|
||||
console.log(`Rendered version ${targetVersion}`);
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "tensamin"
|
||||
version = "0.1.0"
|
||||
name = "Tensamin"
|
||||
version = "0.0.0"
|
||||
description = "Privacy focused messanger"
|
||||
authors = ["methanium"]
|
||||
edition = "2021"
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"$schema": "https://schema.tauri.app/config/2",
|
||||
"productName": "Tensamin",
|
||||
"version": "0.1.0",
|
||||
"version": "0.0.0",
|
||||
"mainBinaryName": "tensamin",
|
||||
"identifier": "net.tensamin.client",
|
||||
"build": {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"types": ["node"],
|
||||
"target": "ES2022",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "bundler",
|
||||
|
|
@ -8,5 +9,5 @@
|
|||
"skipLibCheck": true,
|
||||
"noEmit": true
|
||||
},
|
||||
"include": ["src"]
|
||||
"include": ["src", "./render-version.ts"]
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue