Skip to content

Commit 857592b

Browse files
committed
Ensure version bump using Yarn constraints
1 parent 3317b11 commit 857592b

File tree

9 files changed

+81
-113
lines changed

9 files changed

+81
-113
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,8 @@ To build a new version and release it on NPM, follow these steps:
388388
- `npm dist-tag add @rescript/std@<version> <tag>`
389389
1. Create a release entry for the version tag on the [Github Releases page](https://github.com/rescript-lang/rescript-compiler/releases), copying the changes from `CHANGELOG.md`.
390390
1. Create a PR with the following changes to prepare for development of the next version:
391-
- Increment the version number in `package.json` for the next version.
392-
- Run `node scripts/setVersion.js` to take that version number over into other files.
391+
- Increment the `EXPECTED_VERSION` number in `yarn.config.cjs` for the next version.
392+
- Run `yarn constraints --fix` to take that version number over into other files.
393393
- Update `CHANGELOG.md` and add an entry for the next version, e.g., "10.0.0-beta.2 (Unreleased)"
394394
1. Coordinate any forum/blog posts with [@ryyppy](https://github.com/ryyppy).
395395

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ reanalyze:
5959

6060
lib-bsb:
6161
./scripts/buildRuntime.sh
62-
./scripts/prebuilt.js
62+
yarn constraints
6363

6464
lib:
6565
./scripts/buildRuntimeRewatch.sh
66-
./scripts/prebuilt.js
66+
yarn constraints
6767

6868
artifacts: lib
6969
./scripts/npmPack.js --updateArtifactList

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
"@biomejs/biome": "1.9.4",
8686
"@types/node": "^20.14.9",
8787
"@types/semver": "^7.5.8",
88+
"@yarnpkg/types": "^4.0.1",
8889
"mocha": "10.8.2",
8990
"nyc": "15.0.0",
9091
"semver": "7.6.2",

scripts/prebuilt.js

Lines changed: 0 additions & 41 deletions
This file was deleted.

scripts/setVersion.js

Lines changed: 0 additions & 61 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"name": "@rescript/react",
2+
"name": "@tests/rescript-react",
33
"private": true
44
}

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"packages/**",
2020
"tests/**/input.js",
2121
".github/workflows/*.js",
22+
"yarn.config.cjs",
2223
"package.json"
2324
],
2425
"exclude": ["*.res.js", "*.res.mjs"]

yarn.config.cjs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// @ts-check
2+
3+
/**
4+
* @import { Yarn } from "@yarnpkg/types"
5+
*/
6+
7+
const fs = require("node:fs/promises");
8+
const { defineConfig } = require("@yarnpkg/types");
9+
10+
const { compilerVersionFile } = require("#dev/paths");
11+
12+
/**
13+
* @param {Yarn.Constraints.Context} ctx
14+
*/
15+
async function enforceCompilerVersion({ Yarn }) {
16+
const EXPECTED_VERSION = "12.0.0-alpha.13";
17+
18+
for (const workspace of Yarn.workspaces()) {
19+
const { ident } = workspace.pkg;
20+
if (ident === "rescript" || ident.startsWith("@rescript/")) {
21+
workspace.set("version", EXPECTED_VERSION);
22+
}
23+
}
24+
25+
const versionFile = await fs.readFile(compilerVersionFile, "utf8");
26+
const versionPattern = /^let version = "(?<version>[^"]+)"$/m;
27+
28+
if (process.argv.includes("--fix")) {
29+
await fs.writeFile(
30+
compilerVersionFile,
31+
versionFile.replace(
32+
versionPattern,
33+
`let version = "${EXPECTED_VERSION}"`,
34+
),
35+
);
36+
} else {
37+
const versionMatch = versionFile.match(versionPattern);
38+
const foundVersion = versionMatch?.groups?.version;
39+
if (foundVersion !== EXPECTED_VERSION) {
40+
Yarn.workspace().error(
41+
`compiler/common/bs_version.ml file need to be fiexed; expected ${EXPECTED_VERSION}, found ${foundVersion}.`,
42+
);
43+
}
44+
}
45+
}
46+
47+
module.exports = defineConfig({
48+
async constraints(ctx) {
49+
await enforceCompilerVersion(ctx);
50+
},
51+
});

yarn.lock

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -440,12 +440,6 @@ __metadata:
440440
languageName: node
441441
linkType: hard
442442

443-
"@rescript/react@workspace:tests/dependencies/rescript-react":
444-
version: 0.0.0-use.local
445-
resolution: "@rescript/react@workspace:tests/dependencies/rescript-react"
446-
languageName: unknown
447-
linkType: soft
448-
449443
"@rescript/std@workspace:packages/std":
450444
version: 0.0.0-use.local
451445
resolution: "@rescript/std@workspace:packages/std"
@@ -689,6 +683,12 @@ __metadata:
689683
languageName: unknown
690684
linkType: soft
691685

686+
"@tests/rescript-react@workspace:tests/dependencies/rescript-react":
687+
version: 0.0.0-use.local
688+
resolution: "@tests/rescript-react@workspace:tests/dependencies/rescript-react"
689+
languageName: unknown
690+
linkType: soft
691+
692692
"@tests/tools@workspace:tests/tools_tests":
693693
version: 0.0.0-use.local
694694
resolution: "@tests/tools@workspace:tests/tools_tests"
@@ -754,6 +754,15 @@ __metadata:
754754
languageName: node
755755
linkType: hard
756756

757+
"@yarnpkg/types@npm:^4.0.1":
758+
version: 4.0.1
759+
resolution: "@yarnpkg/types@npm:4.0.1"
760+
dependencies:
761+
tslib: "npm:^2.4.0"
762+
checksum: 10c0/90226789475680ba599833571dd76c0718dd5b4c5022481263ef309d6a628f6246671cd6ca86e49c966ddefa7aca6ccef82240dc1476d2cea702ea5bee2a6b72
763+
languageName: node
764+
linkType: hard
765+
757766
"abbrev@npm:^3.0.0":
758767
version: 3.0.0
759768
resolution: "abbrev@npm:3.0.0"
@@ -2482,6 +2491,7 @@ __metadata:
24822491
"@rescript/win32-x64": "workspace:packages/@rescript/win32-x64"
24832492
"@types/node": "npm:^20.14.9"
24842493
"@types/semver": "npm:^7.5.8"
2494+
"@yarnpkg/types": "npm:^4.0.1"
24852495
mocha: "npm:10.8.2"
24862496
nyc: "npm:15.0.0"
24872497
semver: "npm:7.6.2"
@@ -2924,6 +2934,13 @@ __metadata:
29242934
languageName: node
29252935
linkType: hard
29262936

2937+
"tslib@npm:^2.4.0":
2938+
version: 2.8.1
2939+
resolution: "tslib@npm:2.8.1"
2940+
checksum: 10c0/9c4759110a19c53f992d9aae23aac5ced636e99887b51b9e61def52611732872ff7668757d4e4c61f19691e36f4da981cd9485e869b4a7408d689f6bf1f14e62
2941+
languageName: node
2942+
linkType: hard
2943+
29272944
"type-fest@npm:^0.8.0":
29282945
version: 0.8.1
29292946
resolution: "type-fest@npm:0.8.1"

0 commit comments

Comments
 (0)