Add tag to generated data

This commit is contained in:
tree 2023-02-05 16:21:19 +01:00
rodič 6327fa27e6
revize e9c0cd62ed
6 změnil soubory, kde provedl 44 přidání a 6 odebrání

Zobrazit soubor

@ -21,11 +21,10 @@ jobs:
- uses: szenius/set-timezone@v1.0
with:
timezoneLinux: "Europe/Prague"
- run: make
- run: find dist
- run: "deno run --allow-run utils/tag.js >> $GITHUB_ENV"
- run: "echo \"${{ env.TAG }}\" >> ./dist/TAG"
- run: "echo \"Builded Tag: ${{ env.TAG }}\""
- run: "echo \"Tag: ${{ env.TAG }}\""
- run: "make tag=${{ env.TAG }}"
- run: find dist
- uses: montudor/action-zip@v1
- run: "zip -qq -r release.zip dist"
- uses: actions/upload-artifact@v3

1
.gitignore vendorováno
Zobrazit soubor

@ -3,3 +3,4 @@ dist
dist-mirror
cache
.env
.vscode

Zobrazit soubor

@ -16,7 +16,7 @@ format:
fmt: format
build:
deno run --unstable --allow-read --allow-write utils/exec.js build
deno run --unstable --allow-read --allow-write utils/build.js tag=$(tag)
build-mirror:
deno run --unstable --allow-read --allow-write utils/mirror.js

19
utils/build.js Normal file
Zobrazit soubor

@ -0,0 +1,19 @@
import { DeConfEngine } from "./engine.js";
const args = Deno.args || [];
const options = Object.fromEntries(
args.map((x) => {
const [key, value] = x.split("=");
if (!value) return null;
return [key, value];
}).filter((x) => x),
);
const deconf = new DeConfEngine();
console.log(options)
await deconf.init(options);
const output = await deconf.build();
if (output) {
console.log(output);
}

Zobrazit soubor

@ -16,6 +16,7 @@ let _silentMode = false;
export class DeConfEngine {
constructor(options = {}) {
this.options = options;
this.tag = this.options.tag || "dev";
this.srcDir = this.options.srcDir || "./data";
this.outputDir = this.options.outputDir || "./dist";
this.publicUrl = this.options.publicUrl || "https://data.prgblockweek.com";
@ -39,6 +40,8 @@ export class DeConfEngine {
}
async build() {
await emptyDir(this.outputDir);
console.log(this.tag)
await _textWrite([this.outputDir, "TAG"], this.tag);
for (const pkg of this.entries) {
console.table(pkg.data.events.map((e) => e.data.index), ["name"]);
await pkg.write(this.outputDir);
@ -103,6 +106,7 @@ class DeConf_Package {
this.id = id;
this.data = null;
this.engine = engine;
this.tag = engine.tag;
this.colMapper = {
places: "place",
events: "event",
@ -170,7 +174,8 @@ class DeConf_Package {
return [col, this.data[col]];
}),
),
time: new Date(),
__time: new Date(),
__tag: this.tag,
});
}
}
@ -338,6 +343,12 @@ async function _jsonWrite(fn, data) {
}
return true;
}
async function _textWrite(fn, text) {
if (Array.isArray(fn)) {
fn = fn.join("/");
}
await Deno.writeTextFile(fn, text);
}
async function _jsonLoad(fn) {
return JSON.parse(await Deno.readTextFile(fn));
}

Zobrazit soubor

@ -6,6 +6,14 @@ await deconf.init();
let cmd = Deno.args[0] || "build";
let args = Deno.args.slice(1) || [];
const options = Object.fromEntries(
args.map((x) => {
const [key, value] = x.split("=");
if (!value) return null;
return [key, value];
}).filter((x) => x),
);
const output = await deconf[cmd](...args);
if (output) {
console.log(output);