From 4e1fc46ff27a31eea67734ec220d644bcf201852 Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Sat, 10 Apr 2021 14:25:06 +0200 Subject: [PATCH] Add GH actions --- .../charging_stations/license_info.json | 18 +++++ scripts/generateLayerOverview.ts | 13 ++-- scripts/generateLicenseInfo.ts | 68 ++++++++----------- 3 files changed, 55 insertions(+), 44 deletions(-) diff --git a/assets/themes/charging_stations/license_info.json b/assets/themes/charging_stations/license_info.json index d407936..9c36751 100644 --- a/assets/themes/charging_stations/license_info.json +++ b/assets/themes/charging_stations/license_info.json @@ -9,5 +9,23 @@ "https://wens.be/free-antwerpenize-bicycle-font", " https://antwerpenize.be/post/634396003556081664/antwerpenize-lettertype" ] + }, + { + "authors": [], + "path": "car.svg", + "license": "CC0", + "sources": [] + }, + { + "authors": [], + "path": "logo.svg", + "license": "CC0; trivial", + "sources": [] + }, + { + "authors": [], + "path": "plug.svg", + "license": "CC0; trivial", + "sources": [] } ] \ No newline at end of file diff --git a/scripts/generateLayerOverview.ts b/scripts/generateLayerOverview.ts index f9de21c..756a3db 100644 --- a/scripts/generateLayerOverview.ts +++ b/scripts/generateLayerOverview.ts @@ -70,7 +70,7 @@ function validateLayer(layerJson: LayerConfigJson, context?: string): number { errorCount++ } } - + } catch (e) { console.error("Layer ", layerJson.id ?? JSON.stringify(layerJson).substring(0, 50), " is invalid: ", e) return 1 @@ -94,7 +94,7 @@ for (const themeFile of themeFiles) { console.error("Unknown layer id: ", layer) themeErrorCount++ } - }else if(layer.builtin === undefined){ + } else if (layer.builtin === undefined) { // layer.builtin contains layer overrides - we can skip those layerErrorCount += validateLayer(layer, themeFile.id) } @@ -104,7 +104,7 @@ for (const themeFile of themeFiles) { try { const theme = new LayoutConfig(themeFile, true, "test") - if(theme.id !== theme.id.toLowerCase()){ + if (theme.id !== theme.id.toLowerCase()) { console.error("Theme ids should be in lowercase, but it is ", theme.id) } } catch (e) { @@ -113,4 +113,9 @@ for (const themeFile of themeFiles) { } } -console.log("Found ", layerErrorCount, "errors in the layers; " + themeErrorCount + " errors in the themes") \ No newline at end of file +if (layerErrorCount + themeErrorCount == 0) { + console.log("All good!") +} else { + const msg = (`Found ${layerErrorCount} errors in the layers; ${themeErrorCount} errors in the themes`) + throw msg; +} diff --git a/scripts/generateLicenseInfo.ts b/scripts/generateLicenseInfo.ts index 73023a7..a838521 100644 --- a/scripts/generateLicenseInfo.ts +++ b/scripts/generateLicenseInfo.ts @@ -127,25 +127,6 @@ function createLicenseInfoFor(path): void { writeFileSync(path + ".license_info.json", JSON.stringify(li, null, " ")) } -function shuffle(array) { - var currentIndex = array.length, temporaryValue, randomIndex; - - // While there remain elements to shuffle... - while (0 !== currentIndex) { - - // Pick a remaining element... - randomIndex = Math.floor(Math.random() * currentIndex); - currentIndex -= 1; - - // And swap it with the current element. - temporaryValue = array[currentIndex]; - array[currentIndex] = array[randomIndex]; - array[randomIndex] = temporaryValue; - } - - return array; -} - function cleanLicenseInfo(allPaths: string[], allLicenseInfos: SmallLicense[]){ // Read the license info file from the generated assets, creates a compiled license info in every directory // Note: this removes all the old license infos @@ -172,6 +153,24 @@ function cleanLicenseInfo(allPaths: string[], allLicenseInfos: SmallLicense[]){ } +function queryMissingLicenses(missingLicenses: string[]) { + process.on('SIGINT', function () { + console.log("Aborting... Bye!"); + process.exit(); + }); + + let i = 1; + for (const missingLicens of missingLicenses) { + console.log(i + " / " + missingLicenses.length) + i++; + if (i < missingLicenses.length - 5) { + // continue + } + createLicenseInfoFor(missingLicens) + } + + console.log("You're through!") +} console.log("Checking and compiling license info") const contents = ScriptUtils.readDirRecSync("./assets") @@ -183,27 +182,16 @@ writeFileSync("./assets/generated/license_info.json", JSON.stringify(licenseInfo const artwork = contents.filter(pth => pth.match(/(.svg|.png|.jpg)$/i) != null) const missingLicenses = missingLicenseInfos(licenseInfos, artwork) -console.log(`There are ${missingLicenses.length} licenses missing.`, missingLicenses) +cleanLicenseInfo(licensePaths, licenseInfos) -// shuffle(missingLicenses) - - -// cleanLicenseInfo(licensePaths, licenseInfos) - - -process.on('SIGINT', function () { - console.log("Aborting... Bye!"); - process.exit(); -}); - -let i = 1; -for (const missingLicens of missingLicenses) { - console.log(i + " / " + missingLicenses.length) - i++; - if (i < missingLicenses.length - 5) { - // continue - } - createLicenseInfoFor(missingLicens) +if(missingLicenses.length > 0){ + const msg = `There are ${missingLicenses.length} licenses missing.` + /* + console.log(msg) + /*/ + throw msg + //*/ } -console.log("You're through!") \ No newline at end of file +// queryMissingLicenses(missingLicenses) +