feat: base config

This commit is contained in:
Nicolas Meienberger 2025-04-23 21:06:48 +02:00
parent 631177e3b2
commit 65a5a418e8
11 changed files with 250 additions and 0 deletions

35
scripts/update-config.ts Normal file
View file

@ -0,0 +1,35 @@
import path from "node:path";
import fs from "fs/promises";
const packageFile = process.argv[2];
const newVersion = process.argv[3];
type AppConfig = {
tipi_version: string;
version: string;
updated_at: number;
};
const updateAppConfig = async (packageFile: string, newVersion: string) => {
try {
const packageRoot = path.dirname(packageFile);
const configPath = path.join(packageRoot, "config.json");
const config = await fs.readFile(configPath, "utf-8");
const configParsed = JSON.parse(config) as AppConfig;
configParsed.tipi_version = configParsed.tipi_version + 1;
configParsed.version = newVersion;
configParsed.updated_at = new Date().getTime();
await fs.writeFile(configPath, JSON.stringify(configParsed, null, 2));
} catch (e) {
console.error(`Failed to update app config, error: ${e}`);
}
};
if (!packageFile || !newVersion) {
console.error("Usage: node update-config.js <packageFile> <newVersion>");
process.exit(1);
}
updateAppConfig(packageFile, newVersion);