22 lines
755 B
TypeScript
22 lines
755 B
TypeScript
import { config } from "utils/config";
|
|
import { downloadFile } from "utils/download";
|
|
import { fs } from "utils/fs";
|
|
import { siteLog } from "utils/log";
|
|
|
|
export const downloadDeployedSite = async (site_id: string) => {
|
|
let base_url = "https://prasi.avolut.com";
|
|
const ts = Date.now();
|
|
siteLog("Downloading site deploy: ");
|
|
await downloadFile(
|
|
`${base_url}/prod-zip/${site_id}?ts=${ts}&msgpack=1`,
|
|
fs.path(`site:deploy/history/${ts}.gz`),
|
|
(rec, total) => {
|
|
if (rec % 10 === 0) process.stdout.write(".");
|
|
}
|
|
);
|
|
config.set("deploy.current", ts);
|
|
config.set("deploy.history", [...(config.current?.deploy.history || []), ts]);
|
|
await fs.copy(`site:deploy/history/${ts}.gz`, `site:deploy/current/${ts}.gz`);
|
|
return ts;
|
|
};
|