mirror of
https://github.com/tutao/tutanota.git
synced 2025-12-08 06:09:50 +00:00
41 lines
1.2 KiB
JavaScript
41 lines
1.2 KiB
JavaScript
import fs from "node:fs"
|
|
import { program } from "commander"
|
|
import { glob } from "glob"
|
|
import { fileURLToPath } from "node:url"
|
|
import "zx/globals"
|
|
|
|
if (process.argv[1] === fileURLToPath(import.meta.url)) {
|
|
program.usage("make|dist").arguments("<target>").action(prepareMobileBuild).parse(process.argv)
|
|
}
|
|
|
|
/**
|
|
* Removes source maps, icons, HTML files which are not needed for mobile apps.
|
|
*/
|
|
export async function prepareMobileBuild(buildType, app) {
|
|
console.log("prepare mobile build for build type", buildType)
|
|
let prefix
|
|
if (["dist", "make"].includes(buildType)) {
|
|
prefix = app === "mail" ? "build/" : "build-calendar-app/"
|
|
} else {
|
|
throw new Error("Unknown build type " + buildType)
|
|
}
|
|
|
|
const wasmpath = prefix + "wasm"
|
|
if (fs.existsSync(wasmpath)) {
|
|
console.log("unlinking ", wasmpath)
|
|
fs.rmSync(wasmpath, { force: true, recursive: true })
|
|
}
|
|
|
|
const maps = glob.sync(prefix + "*.js.map")
|
|
for (let file of maps) {
|
|
console.log("unlinking ", file)
|
|
fs.unlinkSync(file)
|
|
}
|
|
const indexHtmlPath = prefix + "index.html"
|
|
if (fs.existsSync(indexHtmlPath)) {
|
|
fs.unlinkSync(indexHtmlPath)
|
|
console.log("rm ", indexHtmlPath)
|
|
} else {
|
|
console.log("no file at", indexHtmlPath)
|
|
}
|
|
}
|