mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 18:12:29 +08:00
refactor(scripts): fix type errors
This commit is contained in:
parent
7d29a6279e
commit
8e4b3711d4
@ -5,35 +5,33 @@
|
|||||||
* into the apps, so that it is properly displayed.
|
* into the apps, so that it is properly displayed.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { fileURLToPath } from "url";
|
import { join } from "path";
|
||||||
import { dirname, join } from "path";
|
import { readFileSync, writeFileSync } from "fs";
|
||||||
import fs from "fs";
|
|
||||||
|
|
||||||
function patchPackageJson(packageJsonPath: string, version: string) {
|
function patchPackageJson(packageJsonPath: string, version: string) {
|
||||||
// Read the version from package.json and process it.
|
// Read the version from package.json and process it.
|
||||||
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
|
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
||||||
|
|
||||||
// Write the adjusted version back in.
|
// Write the adjusted version back in.
|
||||||
packageJson.version = version;
|
packageJson.version = version;
|
||||||
const formattedJson = JSON.stringify(packageJson, null, 2);
|
const formattedJson = JSON.stringify(packageJson, null, 2);
|
||||||
fs.writeFileSync(packageJsonPath, formattedJson);
|
writeFileSync(packageJsonPath, formattedJson);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getVersion(packageJsonPath: string) {
|
function getVersion(packageJsonPath: string) {
|
||||||
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
|
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
||||||
return packageJson.version;
|
return packageJson.version;
|
||||||
}
|
}
|
||||||
|
|
||||||
function main() {
|
function main() {
|
||||||
const scriptDir = dirname(fileURLToPath(import.meta.url));
|
const version = getVersion(join(__dirname, "..", "package.json"));
|
||||||
const version = getVersion(join(scriptDir, "..", "package.json"));
|
|
||||||
|
|
||||||
for (const appName of ["server", "client"]) {
|
for (const appName of ["server", "client"]) {
|
||||||
patchPackageJson(join(scriptDir, "..", "apps", appName, "package.json"), version);
|
patchPackageJson(join(__dirname, "..", "apps", appName, "package.json"), version);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const packageName of ["commons"]) {
|
for (const packageName of ["commons"]) {
|
||||||
patchPackageJson(join(scriptDir, "..", "packages", packageName, "package.json"), version);
|
patchPackageJson(join(__dirname, "..", "packages", packageName, "package.json"), version);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user