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:
 | 
			
		||||
  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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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<void> {
 | 
			
		||||
        ScriptUtils.erasableLog("Downloading", url, "to", targetFilePath)
 | 
			
		||||
        return new Promise<void>((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)
 | 
			
		||||
                        })
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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",
 | 
			
		||||
        })
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue