Skip to content

Commit 2354286

Browse files
committed
chore: update scripts
1 parent 456937e commit 2354286

File tree

2 files changed

+22
-23
lines changed

2 files changed

+22
-23
lines changed

scripts/update-version.ts

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import pc from "picocolors";
12
import { isMatching, match, P } from "ts-pattern";
23

34
import { ignores } from "./ignores";
@@ -6,32 +7,30 @@ import { version } from "./version";
67

78
const GLOB_PACKAGE_JSON = ["package.json", "packages/*/package.json", "packages/*/*/package.json"];
89

9-
const mkTask = (path: string) => {
10-
return async () => {
11-
const packageJson = await readJsonFile(path);
12-
if (!isMatching({ version: P.string }, packageJson)) {
13-
throw new Error(`Invalid package.json at ${path}`);
14-
}
15-
const newVersion = version;
16-
const oldVersion = match(packageJson)
17-
.with({ version: P.select(P.string) }, v => v)
18-
.otherwise(() => "0.0.0");
19-
if (oldVersion === newVersion) {
20-
console.info(`Skipping ${path} as it's already on version ${newVersion}`);
21-
return;
22-
}
23-
const packageJsonUpdated = {
24-
...packageJson,
25-
version: newVersion,
26-
};
27-
await writeJsonFile(path, packageJsonUpdated);
28-
console.info(`Updated ${path} to version ${packageJsonUpdated.version}`);
10+
async function update(path: string) {
11+
const packageJson = await readJsonFile(path);
12+
if (!isMatching({ version: P.string }, packageJson)) {
13+
throw new Error(`Invalid package.json at ${path}`);
14+
}
15+
const newVersion = version;
16+
const oldVersion = match(packageJson)
17+
.with({ version: P.select(P.string) }, v => v)
18+
.otherwise(() => "0.0.0");
19+
if (oldVersion === newVersion) {
20+
console.info(pc.greenBright(`Skipping ${path} as it's already on version ${newVersion}`));
21+
return;
22+
}
23+
const packageJsonUpdated = {
24+
...packageJson,
25+
version: newVersion,
2926
};
30-
};
27+
await writeJsonFile(path, packageJsonUpdated);
28+
console.info(pc.green(`Updated ${path} to version ${packageJsonUpdated.version}`));
29+
}
3130

3231
async function main() {
3332
const tasks = glob(GLOB_PACKAGE_JSON, ignores);
34-
await Promise.all(tasks.map(mkTask));
33+
await Promise.all(tasks.map(path => update(path)));
3534
}
3635

3736
await main();

scripts/verify-lockfile.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ import { x } from "tinyexec";
44
const { stdout } = await x("git", ["diff", "HEAD@{1}", "--stat", "--", "./pnpm-lock.yaml"]);
55
if (stdout.split("\n").length > 0) {
66
console.log("");
7-
console.info(pc.greenBright("Detected changes in pnpm-lock.yaml!"));
7+
console.info(pc.green("Detected changes in pnpm-lock.yaml!"));
88
console.info(pc.greenBright("Please run `pnpm install` to update local dependencies."));
99
}

0 commit comments

Comments
 (0)