forked from MapComplete/MapComplete
Chore: fix android build
This commit is contained in:
parent
07d5c85971
commit
82905fee3f
3 changed files with 23 additions and 8 deletions
|
@ -1,7 +1,5 @@
|
||||||
on:
|
on:
|
||||||
push:
|
push
|
||||||
tags:
|
|
||||||
- 'v*'
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build_android:
|
build_android:
|
||||||
|
@ -22,7 +20,7 @@ jobs:
|
||||||
run: npm ci
|
run: npm ci
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- run: mkdir -p ./assets/generated && npm run init
|
- run: npm run init
|
||||||
|
|
||||||
- name: clone submodule
|
- name: clone submodule
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
|
@ -18,7 +18,7 @@ export default class ScriptUtils {
|
||||||
* @param path
|
* @param path
|
||||||
* @param maxDepth
|
* @param maxDepth
|
||||||
*/
|
*/
|
||||||
public static readDirRecSync(path, maxDepth = 999): string[] {
|
public static readDirRecSync(path: string, maxDepth = 999): string[] {
|
||||||
const result: string[] = []
|
const result: string[] = []
|
||||||
if (maxDepth <= 0) {
|
if (maxDepth <= 0) {
|
||||||
return []
|
return []
|
||||||
|
@ -28,7 +28,6 @@ export default class ScriptUtils {
|
||||||
const stats = lstatSync(fullEntry)
|
const stats = lstatSync(fullEntry)
|
||||||
if (stats.isDirectory()) {
|
if (stats.isDirectory()) {
|
||||||
// Subdirectory
|
// Subdirectory
|
||||||
// @ts-ignore
|
|
||||||
result.push(...ScriptUtils.readDirRecSync(fullEntry, maxDepth - 1))
|
result.push(...ScriptUtils.readDirRecSync(fullEntry, maxDepth - 1))
|
||||||
} else {
|
} else {
|
||||||
result.push(fullEntry)
|
result.push(fullEntry)
|
||||||
|
@ -37,6 +36,23 @@ export default class ScriptUtils {
|
||||||
return result
|
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<void> {
|
public static DownloadFileTo(url, targetFilePath: string): Promise<void> {
|
||||||
ScriptUtils.erasableLog("Downloading", url, "to", targetFilePath)
|
ScriptUtils.erasableLog("Downloading", url, "to", targetFilePath)
|
||||||
return new Promise<void>((resolve) => {
|
return new Promise<void>((resolve) => {
|
||||||
|
@ -216,7 +232,6 @@ export default class ScriptUtils {
|
||||||
const parts: string[] = []
|
const parts: string[] = []
|
||||||
res.setEncoding("utf8")
|
res.setEncoding("utf8")
|
||||||
res.on("data", function (chunk) {
|
res.on("data", function (chunk) {
|
||||||
// @ts-ignore
|
|
||||||
parts.push(chunk)
|
parts.push(chunk)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { Utils } from "../src/Utils"
|
||||||
import { Eli, EliEntry } from "./@types/eli"
|
import { Eli, EliEntry } from "./@types/eli"
|
||||||
import fs from "fs"
|
import fs from "fs"
|
||||||
import { BingRasterLayer } from "../src/UI/Map/BingRasterLayer"
|
import { BingRasterLayer } from "../src/UI/Map/BingRasterLayer"
|
||||||
|
import ScriptUtils from "./ScriptUtils"
|
||||||
|
|
||||||
class DownloadEli extends Script {
|
class DownloadEli extends Script {
|
||||||
constructor() {
|
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
|
// 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 target = args[0] ?? "public/assets/data/editor-layer-index.json"
|
||||||
const targetGlobal = args[1] ?? "src/assets/generated/editor-layer-index-global.json"
|
const targetGlobal = args[1] ?? "src/assets/generated/editor-layer-index-global.json"
|
||||||
|
|
||||||
const targetBing = args[0] ?? "src/assets/bing.json"
|
const targetBing = args[0] ?? "src/assets/bing.json"
|
||||||
|
|
||||||
const eli: Eli = await Utils.downloadJson(url)
|
const eli: Eli = await Utils.downloadJson(url)
|
||||||
|
@ -121,8 +121,10 @@ class DownloadEli extends Script {
|
||||||
} else {
|
} else {
|
||||||
console.log("No bing entry found")
|
console.log("No bing entry found")
|
||||||
}
|
}
|
||||||
|
ScriptUtils.createParentDir(target)
|
||||||
fs.writeFileSync(target, contents, { encoding: "utf8" })
|
fs.writeFileSync(target, contents, { encoding: "utf8" })
|
||||||
console.log("Written", keptLayers.length + ", entries to the ELI")
|
console.log("Written", keptLayers.length + ", entries to the ELI")
|
||||||
|
ScriptUtils.createParentDir(targetGlobal)
|
||||||
fs.writeFileSync(targetGlobal, JSON.stringify(contentsGlobal, null, " "), {
|
fs.writeFileSync(targetGlobal, JSON.stringify(contentsGlobal, null, " "), {
|
||||||
encoding: "utf8",
|
encoding: "utf8",
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue