55 * Used by local developers (after git bisect, fresh clone) and by CI jobs
66 * before building wasm-dependent packages.
77 *
8- * Package versions default to the current lerna.json version. The file
9- * packages/php-wasm/wasm-versions.json is an optional sparse overrides map
10- * used during active WASM recompiles to point specific packages at PR/SHA
11- * pre-release builds. It is reset to {} on every stable release.
8+ * The version to download for each package is read directly from its
9+ * package.json. Stable releases use the lerna version; PR/SHA recompiles
10+ * temporarily bump the package.json to a pre-release version.
1211 */
1312
1413import { execSync } from 'child_process' ;
@@ -21,20 +20,8 @@ import { createGunzip } from 'zlib';
2120
2221const __dirname = path . dirname ( fileURLToPath ( import . meta. url ) ) ;
2322const repoRoot = path . resolve ( __dirname , '../../' ) ;
24- const versionsFile = path . join (
25- repoRoot ,
26- 'packages/php-wasm/wasm-versions.json'
27- ) ;
28-
29- // Default version comes from lerna.json (the current stable release).
30- // wasm-versions.json only stores overrides for PR/SHA pre-release builds.
31- const defaultVersion = JSON . parse (
32- fs . readFileSync ( path . join ( repoRoot , 'lerna.json' ) , 'utf8' )
33- ) . version ;
34- const versions = JSON . parse ( fs . readFileSync ( versionsFile , 'utf8' ) ) ;
3523
36- // Build the full list of packages from the filesystem so wasm-versions.json
37- // only needs to contain overrides, not every entry.
24+ // Discover all WASM packages from the filesystem.
3825const allKeys = [ ] ;
3926for ( const platform of [ 'web' , 'node' ] ) {
4027 const buildsDir = path . join (
@@ -64,8 +51,14 @@ if (fs.existsSync(triggerFile)) {
6451 const stale = ( trigger . compilations ?? [ ] ) . filter (
6552 ( { platform, phpVersion } ) => {
6653 const [ major , minor ] = phpVersion . split ( '.' ) ;
67- const key = `${ platform } -${ major } -${ minor } ` ;
68- const version = versions [ key ] ?? defaultVersion ;
54+ const pkgPath = path . join (
55+ repoRoot ,
56+ `packages/php-wasm/${ platform } -builds/${ major } -${ minor } /package.json`
57+ ) ;
58+ if ( ! fs . existsSync ( pkgPath ) ) return false ;
59+ const version = JSON . parse (
60+ fs . readFileSync ( pkgPath , 'utf8' )
61+ ) . version ;
6962 return ! version . includes ( '-pr.' ) ;
7063 }
7164 ) ;
@@ -75,8 +68,8 @@ if (fs.existsSync(triggerFile)) {
7568 . map ( ( c ) => ` - ${ c . platform } PHP ${ c . phpVersion } ` )
7669 . join ( '\n' ) ;
7770 console . warn (
78- `\nWARNING: .recompile-request.json exists but wasm-versions.json still points \n` +
79- `to stable versions for the following entries (CI may not have finished yet):\n` +
71+ `\nWARNING: .recompile-request.json exists but the following packages \n` +
72+ `still have a stable version (CI may not have finished yet):\n` +
8073 `${ list } \n` +
8174 `You are downloading the previous stable binaries — not the recompiled ones.\n` +
8275 `Wait for the "Compile PHP WASM" CI job to complete and re-run prepare-wasm.\n`
@@ -88,7 +81,6 @@ let downloaded = 0;
8881let skipped = 0 ;
8982
9083for ( const key of allKeys ) {
91- const version = versions [ key ] ?? defaultVersion ;
9284 // key format: "{platform}-{major}-{minor}" e.g. "web-8-5"
9385 const parts = key . split ( '-' ) ;
9486 const platform = parts [ 0 ] ; // "web" or "node"
@@ -99,6 +91,11 @@ for (const key of allKeys) {
9991 repoRoot ,
10092 `packages/php-wasm/${ platform } -builds/${ versionDir } `
10193 ) ;
94+
95+ const version = JSON . parse (
96+ fs . readFileSync ( path . join ( buildsDir , 'package.json' ) , 'utf8' )
97+ ) . version ;
98+
10299 const jspiDir = path . join ( buildsDir , 'jspi' ) ;
103100 const asyncifyDir = path . join ( buildsDir , 'asyncify' ) ;
104101
0 commit comments