Remove deactivated sources from generated metadata source files

This commit is contained in:
Bionus 2022-03-12 11:13:23 +01:00
parent 7c8890c521
commit a17e7c072e
No known key found for this signature in database
GPG Key ID: 54B0B2DE713AE915
2 changed files with 12 additions and 4 deletions

View File

@ -3,6 +3,7 @@ const crypto = require("crypto");
const cp = require("child_process");
const SITES_DIR = "src/sites";
const DISABLED_SOURCES = ["Sankaku", "Tumblr", "Reddit"];
function mkPath(source, filename) {
return SITES_DIR + "/" + source + "/" + filename;
@ -35,11 +36,12 @@ function getLastCommit(path) {
}
const args = process.argv.slice(2);
const isNightly = args.length > 0 && args[0] == "develop";
const branch = args.length > 0 ? args[0] : "master";
const isNightly = branch == "develop";
const output = {
name: "Official Grabber sources" + (isNightly ? " (nightly)" : ""),
home: "https://github.com/Bionus/imgbrd-grabber",
url: "https://raw.githubusercontent.com/Bionus/imgbrd-grabber/" + (isNightly ? "develop" : "master") + "/src/sites/",
url: "https://github.com/Bionus/imgbrd-grabber/releases/download/sources-" + branch + "/source-",
sources: [],
};
@ -47,6 +49,12 @@ const sources = fs
.readdirSync(SITES_DIR)
.filter((f) => fs.statSync(SITES_DIR + "/" + f).isDirectory());
for (const source of sources) {
// Skip disabled sources
if (DISABLED_SOURCES.includes(source)) {
continue;
}
// Skip directories without a "model.ts" file
const modelFile = mkPath(source, "model.ts");
if (!fs.existsSync(modelFile)) {
continue;

View File

@ -7,10 +7,10 @@ mkdir -p $OUTPUT_DIR
for DIR in src/sites/*/; do
NAME=$(basename "$DIR")
[[ $NAME =~ ^(node_modules|Sankaku|Tumblr|Reddit)$ ]] && continue
[[ $NAME =~ ^(Sankaku|Tumblr|Reddit)$ ]] && continue
[[ ! -f "$DIR/model.js" ]] && continue
pushd "$DIR"
zip "$OUTPUT_DIR/$NAME.zip" model.js icon.png sites.txt */defaults.ini */tag-types.txt
zip "$OUTPUT_DIR/source-$NAME.zip" model.js icon.png sites.txt */defaults.ini */tag-types.txt
popd
done