diff --git a/.forgejo/workflows/on_release.yml b/.forgejo/workflows/on_release.yml index 666b82f07..65528a288 100644 --- a/.forgejo/workflows/on_release.yml +++ b/.forgejo/workflows/on_release.yml @@ -1,7 +1,5 @@ on: - push: - tags: - - 'v*' + push jobs: build_android: @@ -22,7 +20,7 @@ jobs: run: npm ci shell: bash - - run: mkdir -p ./assets/generated && npm run init + - run: npm run init - name: clone submodule shell: bash diff --git a/scripts/ScriptUtils.ts b/scripts/ScriptUtils.ts index 66ca1e815..0389a2c16 100644 --- a/scripts/ScriptUtils.ts +++ b/scripts/ScriptUtils.ts @@ -18,7 +18,7 @@ export default class ScriptUtils { * @param path * @param maxDepth */ - public static readDirRecSync(path, maxDepth = 999): string[] { + public static readDirRecSync(path: string, maxDepth = 999): string[] { const result: string[] = [] if (maxDepth <= 0) { return [] @@ -28,7 +28,6 @@ export default class ScriptUtils { const stats = lstatSync(fullEntry) if (stats.isDirectory()) { // Subdirectory - // @ts-ignore result.push(...ScriptUtils.readDirRecSync(fullEntry, maxDepth - 1)) } else { result.push(fullEntry) @@ -37,6 +36,23 @@ export default class ScriptUtils { return result } + public static createParentDir(path: string) { + const index = path.lastIndexOf("/") + if (index < 0) { + return + } + const parent = path.substring(0, index) + if (parent.length === 0) { + return + } + if (fs.existsSync(parent)) { + return + } + fs.mkdirSync(parent, { + recursive: true + }) + } + public static DownloadFileTo(url, targetFilePath: string): Promise { ScriptUtils.erasableLog("Downloading", url, "to", targetFilePath) return new Promise((resolve) => { @@ -216,7 +232,6 @@ export default class ScriptUtils { const parts: string[] = [] res.setEncoding("utf8") res.on("data", function (chunk) { - // @ts-ignore parts.push(chunk) }) diff --git a/scripts/downloadEli.ts b/scripts/downloadEli.ts index 5686fdccf..07b77757b 100644 --- a/scripts/downloadEli.ts +++ b/scripts/downloadEli.ts @@ -3,6 +3,7 @@ import { Utils } from "../src/Utils" import { Eli, EliEntry } from "./@types/eli" import fs from "fs" import { BingRasterLayer } from "../src/UI/Map/BingRasterLayer" +import ScriptUtils from "./ScriptUtils" class DownloadEli extends Script { constructor() { @@ -14,7 +15,6 @@ class DownloadEli extends Script { // Target should use '.json' instead of '.geojson', as the latter cannot be imported by the build systems const target = args[0] ?? "public/assets/data/editor-layer-index.json" const targetGlobal = args[1] ?? "src/assets/generated/editor-layer-index-global.json" - const targetBing = args[0] ?? "src/assets/bing.json" const eli: Eli = await Utils.downloadJson(url) @@ -121,8 +121,10 @@ class DownloadEli extends Script { } else { console.log("No bing entry found") } + ScriptUtils.createParentDir(target) fs.writeFileSync(target, contents, { encoding: "utf8" }) console.log("Written", keptLayers.length + ", entries to the ELI") + ScriptUtils.createParentDir(targetGlobal) fs.writeFileSync(targetGlobal, JSON.stringify(contentsGlobal, null, " "), { encoding: "utf8", })