-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprepare-spa.ts
44 lines (37 loc) · 1.24 KB
/
prepare-spa.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { parseArgs } from "@std/cli";
import * as log from "@std/log";
import { zipToTs } from "./build-tools/binToTs.ts";
import { zipCompress } from "./build-tools/zip.ts";
const flags = parseArgs(Deno.args, {
string: ["action", "version"],
});
const action = flags.action;
if (action === "set-version") {
const version = flags.version || "0.0.1";
await increaseUiVersion(version);
Deno.exit(0);
}
if (action === "spa") {
await spaToTypeScript();
Deno.exit(0);
}
async function increaseUiVersion(version: string) {
const packageFile = "./q-manui/package.json";
let packageJson = await Deno.readTextFile(packageFile);
const pkg = JSON.parse(packageJson);
pkg.version = version;
pkg.description = `DenoMan ${version}`;
packageJson = JSON.stringify(pkg, null, 2);
await Deno.writeTextFile(packageFile, packageJson);
log.getLogger().info("package.json file updated.");
}
async function spaToTypeScript() {
log.getLogger().info("Compressing [q-manui/dist/spa] ...");
await zipCompress("./q-manui/dist/spa", "./q-manui/dist/ui.zip", {
overwrite: true,
flags: [],
});
log.getLogger().info("Converting [q-manui/dist/ui.zip] to [ui.ts]");
await zipToTs("./q-manui/dist", "ui");
log.getLogger().info("[ui.ts] created.");
}