Add tag to generated data
This commit is contained in:
rodič
6327fa27e6
revize
e9c0cd62ed
|
@ -21,11 +21,10 @@ jobs:
|
||||||
- uses: szenius/set-timezone@v1.0
|
- uses: szenius/set-timezone@v1.0
|
||||||
with:
|
with:
|
||||||
timezoneLinux: "Europe/Prague"
|
timezoneLinux: "Europe/Prague"
|
||||||
- run: make
|
|
||||||
- run: find dist
|
|
||||||
- run: "deno run --allow-run utils/tag.js >> $GITHUB_ENV"
|
- run: "deno run --allow-run utils/tag.js >> $GITHUB_ENV"
|
||||||
- run: "echo \"${{ env.TAG }}\" >> ./dist/TAG"
|
- run: "echo \"Tag: ${{ env.TAG }}\""
|
||||||
- run: "echo \"Builded Tag: ${{ env.TAG }}\""
|
- run: "make tag=${{ env.TAG }}"
|
||||||
|
- run: find dist
|
||||||
- uses: montudor/action-zip@v1
|
- uses: montudor/action-zip@v1
|
||||||
- run: "zip -qq -r release.zip dist"
|
- run: "zip -qq -r release.zip dist"
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v3
|
||||||
|
|
|
@ -3,3 +3,4 @@ dist
|
||||||
dist-mirror
|
dist-mirror
|
||||||
cache
|
cache
|
||||||
.env
|
.env
|
||||||
|
.vscode
|
2
Makefile
2
Makefile
|
@ -16,7 +16,7 @@ format:
|
||||||
fmt: format
|
fmt: format
|
||||||
|
|
||||||
build:
|
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:
|
build-mirror:
|
||||||
deno run --unstable --allow-read --allow-write utils/mirror.js
|
deno run --unstable --allow-read --allow-write utils/mirror.js
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
|
@ -16,6 +16,7 @@ let _silentMode = false;
|
||||||
export class DeConfEngine {
|
export class DeConfEngine {
|
||||||
constructor(options = {}) {
|
constructor(options = {}) {
|
||||||
this.options = options;
|
this.options = options;
|
||||||
|
this.tag = this.options.tag || "dev";
|
||||||
this.srcDir = this.options.srcDir || "./data";
|
this.srcDir = this.options.srcDir || "./data";
|
||||||
this.outputDir = this.options.outputDir || "./dist";
|
this.outputDir = this.options.outputDir || "./dist";
|
||||||
this.publicUrl = this.options.publicUrl || "https://data.prgblockweek.com";
|
this.publicUrl = this.options.publicUrl || "https://data.prgblockweek.com";
|
||||||
|
@ -39,6 +40,8 @@ export class DeConfEngine {
|
||||||
}
|
}
|
||||||
async build() {
|
async build() {
|
||||||
await emptyDir(this.outputDir);
|
await emptyDir(this.outputDir);
|
||||||
|
console.log(this.tag)
|
||||||
|
await _textWrite([this.outputDir, "TAG"], this.tag);
|
||||||
for (const pkg of this.entries) {
|
for (const pkg of this.entries) {
|
||||||
console.table(pkg.data.events.map((e) => e.data.index), ["name"]);
|
console.table(pkg.data.events.map((e) => e.data.index), ["name"]);
|
||||||
await pkg.write(this.outputDir);
|
await pkg.write(this.outputDir);
|
||||||
|
@ -103,6 +106,7 @@ class DeConf_Package {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.data = null;
|
this.data = null;
|
||||||
this.engine = engine;
|
this.engine = engine;
|
||||||
|
this.tag = engine.tag;
|
||||||
this.colMapper = {
|
this.colMapper = {
|
||||||
places: "place",
|
places: "place",
|
||||||
events: "event",
|
events: "event",
|
||||||
|
@ -170,7 +174,8 @@ class DeConf_Package {
|
||||||
return [col, this.data[col]];
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
async function _textWrite(fn, text) {
|
||||||
|
if (Array.isArray(fn)) {
|
||||||
|
fn = fn.join("/");
|
||||||
|
}
|
||||||
|
await Deno.writeTextFile(fn, text);
|
||||||
|
}
|
||||||
async function _jsonLoad(fn) {
|
async function _jsonLoad(fn) {
|
||||||
return JSON.parse(await Deno.readTextFile(fn));
|
return JSON.parse(await Deno.readTextFile(fn));
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,14 @@ await deconf.init();
|
||||||
let cmd = Deno.args[0] || "build";
|
let cmd = Deno.args[0] || "build";
|
||||||
let args = Deno.args.slice(1) || [];
|
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);
|
const output = await deconf[cmd](...args);
|
||||||
if (output) {
|
if (output) {
|
||||||
console.log(output);
|
console.log(output);
|
||||||
|
|
Načítá se…
Odkázat v novém úkolu