Files
Trilium/scripts/update-version.ts
Wael Nasreddine fb4d63b049 Add --config, --help, and --version flags to edit-docs
- Implement --config (-c) flag to allow custom configuration file paths.
- Add --help (-h) flag to display tool usage and available options.
- Add --version (-v) flag to display the current Trilium version.
- Update electron-start.mts to correctly pass command-line arguments to Electron.
- Synchronize edit-docs version with the root package.json via update-version.ts.
- Resolve config paths relative to the configuration file's directory.

This makes edit-docs more robust and easier to use from external projects
and immutable environments like Nix.
2026-01-12 22:08:27 -08:00

39 lines
1.2 KiB
TypeScript

/**
* @module
*
* This script synchronizes the `package.json` version of the monorepo (root `package.json`)
* into the apps, so that it is properly displayed.
*/
import { join } from "path";
import { readFileSync, writeFileSync } from "fs";
function patchPackageJson(packageJsonPath: string, version: string) {
// Read the version from package.json and process it.
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
// Write the adjusted version back in.
packageJson.version = version;
const formattedJson = JSON.stringify(packageJson, null, 2);
writeFileSync(packageJsonPath, formattedJson);
}
function getVersion(packageJsonPath: string) {
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
return packageJson.version;
}
function main() {
const version = getVersion(join(__dirname, "..", "package.json"));
for (const appName of ["server", "client", "desktop", "edit-docs"]) {
patchPackageJson(join(__dirname, "..", "apps", appName, "package.json"), version);
}
for (const packageName of ["commons"]) {
patchPackageJson(join(__dirname, "..", "packages", packageName, "package.json"), version);
}
}
main();