Skip to content

Commit 97cd743

Browse files
committed
update build script to fetch latest version of regex-scanner
1 parent be252b0 commit 97cd743

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

scripts/build-flow-scanner.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,35 @@ function setupRemoteRepo(tempDir) {
9292
}
9393

9494
copyDirSync(coreSource, tempDir);
95+
96+
// Resolve workspace:* dependencies before deleting the clone
97+
const pkgJsonPath = path.join(tempDir, "package.json");
98+
const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, "utf8"));
99+
100+
for (const depType of ["dependencies", "devDependencies", "peerDependencies"]) {
101+
if (pkgJson[depType]) {
102+
for (const [name, version] of Object.entries(pkgJson[depType])) {
103+
if (typeof version === "string" && version.startsWith("workspace:")) {
104+
// Find matching package in monorepo
105+
const packagesDirPath = path.join(cloneDir, "packages");
106+
for (const dir of fs.readdirSync(packagesDirPath)) {
107+
const depPkgPath = path.join(packagesDirPath, dir, "package.json");
108+
if (fs.existsSync(depPkgPath)) {
109+
const depPkg = JSON.parse(fs.readFileSync(depPkgPath, "utf8"));
110+
if (depPkg.name === name) {
111+
const spec = version.replace("workspace:", "");
112+
pkgJson[depType][name] = (spec === "^" || spec === "~") ? spec + depPkg.version : depPkg.version;
113+
console.log(`Resolved ${name}: ${version} -> ${pkgJson[depType][name]}`);
114+
break;
115+
}
116+
}
117+
}
118+
}
119+
}
120+
}
121+
}
122+
123+
fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2), "utf8");
95124
fs.rmSync(cloneDir, {recursive: true, force: true});
96125
}
97126

0 commit comments

Comments
 (0)