Skip to content

Commit c7a8e8e

Browse files
committed
Postversion script
1 parent ee269c4 commit c7a8e8e

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"format:check": "yarn format:all --list-different",
1414
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
1515
"lint:fix": "yarn lint --fix && yarn prettier:fix",
16+
"postversion": "node --experimental-strip-types scripts/postversion.mts",
1617
"prepack": "rm -Rf dist && npm run build",
1718
"test": "jest -i",
1819
"typecheck": "tsc --noEmit"
@@ -72,5 +73,6 @@
7273
},
7374
"files": [
7475
"dist"
75-
]
76+
],
77+
"packageManager": "yarn@1.22.22"
7678
}

scripts/postversion.mts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import * as fs from "node:fs/promises";
2+
3+
const __dirname = import.meta.dirname;
4+
5+
const ROOT = `${__dirname}/..`;
6+
const versionTsPath = `${ROOT}/src/version.ts`;
7+
const packageJsonPath = `${ROOT}/package.json`;
8+
9+
const packageJson = JSON.parse(await fs.readFile(packageJsonPath, "utf8"));
10+
11+
await fs.writeFile(
12+
versionTsPath,
13+
`\
14+
// This file is autogenerated by /scripts/postversion.mjs
15+
export const version = ${JSON.stringify(packageJson.version)};
16+
`
17+
);

src/version.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// This file is autogenerated by /scripts/postversion.mjs
2+
export const version = "3.0.0-rc.1";

0 commit comments

Comments
 (0)