2020-04-17 02:37:41 +08:00
|
|
|
// This is a JS script so that the directory is created in-process on Windows.
|
2020-04-20 23:46:52 +08:00
|
|
|
// If the script isn't run in-process, there's a risk of it racing or never running
|
|
|
|
// due to file associations in Windows.
|
2020-04-17 02:37:41 +08:00
|
|
|
// Sorry.
|
|
|
|
|
2023-08-18 15:34:56 +08:00
|
|
|
import * as fs from "node:fs";
|
|
|
|
import * as path from "node:path";
|
|
|
|
import { mkdirpSync } from "mkdirp";
|
|
|
|
import fetch from "node-fetch";
|
|
|
|
import { ProxyAgent } from "proxy-agent";
|
2020-04-17 02:37:41 +08:00
|
|
|
|
|
|
|
console.log("Making webapp directory");
|
2023-04-19 00:01:10 +08:00
|
|
|
mkdirpSync("webapp");
|
2020-04-17 02:37:41 +08:00
|
|
|
|
2022-01-12 00:15:17 +08:00
|
|
|
// curl -s https://meet.element.io/libs/external_api.min.js > ./webapp/jitsi_external_api.min.js
|
2020-04-17 02:37:41 +08:00
|
|
|
console.log("Downloading Jitsi script");
|
|
|
|
const fname = path.join("webapp", "jitsi_external_api.min.js");
|
2020-10-16 20:48:28 +08:00
|
|
|
|
2023-08-18 15:34:56 +08:00
|
|
|
fetch("https://meet.element.io/libs/external_api.min.js", {
|
|
|
|
agent: new ProxyAgent(),
|
|
|
|
})
|
2022-01-12 00:15:17 +08:00
|
|
|
.then((res) => {
|
|
|
|
const stream = fs.createWriteStream(fname);
|
2023-08-18 15:34:56 +08:00
|
|
|
return new Promise<void>((resolve, reject) => {
|
2022-01-12 00:15:17 +08:00
|
|
|
res.body.pipe(stream);
|
|
|
|
res.body.on("error", (err) => reject(err));
|
|
|
|
res.body.on("finish", () => resolve());
|
|
|
|
});
|
2020-04-17 02:37:41 +08:00
|
|
|
})
|
|
|
|
.then(() => console.log("Done with Jitsi download"));
|