Skip to content

Commit 23b453d

Browse files
committed
Sync available version list
1 parent 6929cd0 commit 23b453d

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed

packages/playground/scripts/common.mjs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// @ts-check
22

33
import * as child_process from "node:child_process";
4-
import * as fs from "node:fs";
54
import * as path from "node:path";
65

76
export const compilerRootDir = path.join(
@@ -19,13 +18,16 @@ export const playgroundPackagesDir = path.join(playgroundDir, "packages");
1918

2019
/**
2120
* @param {string} cmd
21+
* @param {child_process.ExecSyncOptions} [opts={}]
2222
*/
23-
export function exec(cmd) {
23+
export function exec(cmd, opts = {}) {
2424
console.log(`>>>>>> running command: ${cmd}`);
25-
child_process.execSync(cmd, {
25+
const result = child_process.execSync(cmd, {
2626
cwd: playgroundDir,
27-
encoding: "utf8",
2827
stdio: "inherit",
28+
...opts,
29+
encoding: "utf8",
2930
});
3031
console.log("<<<<<<");
32+
return result || "";
3133
}

packages/playground/scripts/upload_bundle.mjs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import * as fs from "node:fs";
1010
import * as path from "node:path";
1111
import * as readline from "node:readline/promises";
1212
import { createRequire } from "node:module";
13+
import semver from "semver";
1314

1415
import {
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

Comments
 (0)