64 lines
1.5 KiB
JavaScript
64 lines
1.5 KiB
JavaScript
import { existsSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
import { join } from "node:path";
|
|
|
|
const version = "0.4.0";
|
|
|
|
const dependencyGroups = [
|
|
"dependencies",
|
|
"devDependencies",
|
|
"peerDependencies",
|
|
"optionalDependencies",
|
|
];
|
|
|
|
for (const entry of readdirSync("packages", {
|
|
withFileTypes: true,
|
|
})) {
|
|
if (!entry.isDirectory()) {
|
|
continue;
|
|
}
|
|
|
|
const packageFile = join("packages", entry.name, "package.json");
|
|
|
|
if (!existsSync(packageFile)) {
|
|
continue;
|
|
}
|
|
|
|
const packageJson = JSON.parse(readFileSync(packageFile, "utf8"));
|
|
|
|
packageJson.version = version;
|
|
|
|
for (const group of dependencyGroups) {
|
|
const dependencies = packageJson[group];
|
|
|
|
if (!dependencies || typeof dependencies !== "object") {
|
|
continue;
|
|
}
|
|
|
|
for (const dependencyName of Object.keys(dependencies)) {
|
|
if (!dependencyName.startsWith("@wrnexus/")) {
|
|
continue;
|
|
}
|
|
|
|
const currentVersion = dependencies[dependencyName];
|
|
|
|
if (typeof currentVersion !== "string") {
|
|
continue;
|
|
}
|
|
|
|
if (currentVersion.startsWith("workspace:")) {
|
|
continue;
|
|
}
|
|
|
|
if (currentVersion.startsWith("^")) {
|
|
dependencies[dependencyName] = `^${version}`;
|
|
} else if (currentVersion.startsWith("~")) {
|
|
dependencies[dependencyName] = `~${version}`;
|
|
} else {
|
|
dependencies[dependencyName] = version;
|
|
}
|
|
}
|
|
}
|
|
|
|
writeFileSync(packageFile, `${JSON.stringify(packageJson, null, 2)}\n`);
|
|
}
|