@@ -10,6 +10,7 @@ import * as fs from "node:fs";
1010import * as path from "node:path" ;
1111import * as readline from "node:readline/promises" ;
1212import { createRequire } from "node:module" ;
13+ import semver from "semver" ;
1314
1415import {
1516 exec ,
@@ -98,3 +99,30 @@ exec(`rclone copyto ${rcloneOpts} \\
9899 "${ archivePath } " \\
99100 "${ remote } :${ bucket } /playground-bundles/${ tag } .tar.zst"
100101` ) ;
102+
103+ console . log ( "Update versions.json" ) ;
104+ {
105+ const bundles = exec (
106+ `rclone lsf --include="*.tar.zst" rescript:cdn-assets/playground-bundles` ,
107+ { stdio : [ 'ignore' , 'pipe' , 'pipe' ] } ,
108+ ) . trimEnd ( ) . split ( "\n" ) ;
109+
110+ /** @type {string[] } */
111+ let playgroundVersions = [ ] ;
112+ for ( const bundle of bundles ) {
113+ playgroundVersions . push ( bundle . replace ( ".tar.zst" , "" ) ) ;
114+ }
115+ playgroundVersions = semver . sort ( playgroundVersions ) ;
116+
117+ console . log ( 'Versions: ' , playgroundVersions ) ;
118+
119+ const versionsPath = path . join ( tmpDir , "versions.json" ) ;
120+ fs . writeFileSync (
121+ versionsPath ,
122+ JSON . stringify ( playgroundVersions ) ,
123+ ) ;
124+ exec ( `rclone copyto ${ rcloneOpts } \\
125+ "${ versionsPath } " \\
126+ "${ remote } :${ bucket } /playground-bundles/versions.json"
127+ ` ) ;
128+ }
0 commit comments