Skip to content

Commit f80b835

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

File tree

10 files changed

+77
-131
lines changed

10 files changed

+77
-131
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ jobs:
338338
run: git diff --exit-code lib/js lib/es6
339339

340340
- name: Version Check
341-
run: ./scripts/prebuilt.js
341+
run: yarn constraints
342342

343343
- name: Run tests
344344
run: node scripts/test.js -all

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: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,9 @@ reanalyze:
5959

6060
lib-bsb:
6161
./scripts/buildRuntime.sh
62-
./scripts/prebuilt.js
6362

6463
lib:
6564
./scripts/buildRuntimeRewatch.sh
66-
./scripts/prebuilt.js
6765

6866
artifacts: lib
6967
./scripts/npmPack.js --updateArtifactList

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,9 @@
8484
"devDependencies": {
8585
"@biomejs/biome": "1.9.4",
8686
"@types/node": "^20.14.9",
87-
"@types/semver": "^7.5.8",
87+
"@yarnpkg/types": "^4.0.1",
8888
"mocha": "10.8.2",
8989
"nyc": "15.0.0",
90-
"semver": "7.6.2",
9190
"typescript": "5.8.2"
9291
},
9392
"workspaces": [

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: 20 additions & 21 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"
@@ -747,10 +747,12 @@ __metadata:
747747
languageName: node
748748
linkType: hard
749749

750-
"@types/semver@npm:^7.5.8":
751-
version: 7.5.8
752-
resolution: "@types/semver@npm:7.5.8"
753-
checksum: 10c0/8663ff927234d1c5fcc04b33062cb2b9fcfbe0f5f351ed26c4d1e1581657deebd506b41ff7fdf89e787e3d33ce05854bc01686379b89e9c49b564c4cfa988efa
750+
"@yarnpkg/types@npm:^4.0.1":
751+
version: 4.0.1
752+
resolution: "@yarnpkg/types@npm:4.0.1"
753+
dependencies:
754+
tslib: "npm:^2.4.0"
755+
checksum: 10c0/90226789475680ba599833571dd76c0718dd5b4c5022481263ef309d6a628f6246671cd6ca86e49c966ddefa7aca6ccef82240dc1476d2cea702ea5bee2a6b72
754756
languageName: node
755757
linkType: hard
756758

@@ -2481,10 +2483,9 @@ __metadata:
24812483
"@rescript/linux-x64": "workspace:packages/@rescript/linux-x64"
24822484
"@rescript/win32-x64": "workspace:packages/@rescript/win32-x64"
24832485
"@types/node": "npm:^20.14.9"
2484-
"@types/semver": "npm:^7.5.8"
2486+
"@yarnpkg/types": "npm:^4.0.1"
24852487
mocha: "npm:10.8.2"
24862488
nyc: "npm:15.0.0"
2487-
semver: "npm:7.6.2"
24882489
typescript: "npm:5.8.2"
24892490
dependenciesMeta:
24902491
"@rescript/darwin-arm64":
@@ -2666,15 +2667,6 @@ __metadata:
26662667
languageName: node
26672668
linkType: hard
26682669

2669-
"semver@npm:7.6.2":
2670-
version: 7.6.2
2671-
resolution: "semver@npm:7.6.2"
2672-
bin:
2673-
semver: bin/semver.js
2674-
checksum: 10c0/97d3441e97ace8be4b1976433d1c32658f6afaff09f143e52c593bae7eef33de19e3e369c88bd985ce1042c6f441c80c6803078d1de2a9988080b66684cbb30c
2675-
languageName: node
2676-
linkType: hard
2677-
26782670
"semver@npm:^6.0.0, semver@npm:^6.3.0, semver@npm:^6.3.1":
26792671
version: 6.3.1
26802672
resolution: "semver@npm:6.3.1"
@@ -2924,6 +2916,13 @@ __metadata:
29242916
languageName: node
29252917
linkType: hard
29262918

2919+
"tslib@npm:^2.4.0":
2920+
version: 2.8.1
2921+
resolution: "tslib@npm:2.8.1"
2922+
checksum: 10c0/9c4759110a19c53f992d9aae23aac5ced636e99887b51b9e61def52611732872ff7668757d4e4c61f19691e36f4da981cd9485e869b4a7408d689f6bf1f14e62
2923+
languageName: node
2924+
linkType: hard
2925+
29272926
"type-fest@npm:^0.8.0":
29282927
version: 0.8.1
29292928
resolution: "type-fest@npm:0.8.1"

0 commit comments

Comments
 (0)