add: meal ingestion CLI for images and metadata
All checks were successful
Deploy on push / deploy (push) Has been skipped
All checks were successful
Deploy on push / deploy (push) Has been skipped
This commit is contained in:
@@ -182,6 +182,18 @@ function writeManifest(manifest) {
|
||||
|
||||
async function main() {
|
||||
const options = parseArgs(process.argv.slice(2));
|
||||
const summary = await buildThumbnails(options);
|
||||
|
||||
console.log(
|
||||
`Thumbnail build complete: ${summary.generated} generated, ${summary.skipped} skipped, ${summary.removed} removed`
|
||||
);
|
||||
}
|
||||
|
||||
async function buildThumbnails(options = {}) {
|
||||
const settings = {
|
||||
force: false,
|
||||
...options,
|
||||
};
|
||||
const meals = loadMeals();
|
||||
const manifest = loadManifest();
|
||||
const nextManifest = {};
|
||||
@@ -194,7 +206,7 @@ async function main() {
|
||||
let skipped = 0;
|
||||
|
||||
for (const meal of meals) {
|
||||
const result = await generateThumbnail(meal, manifest, options);
|
||||
const result = await generateThumbnail(meal, manifest, settings);
|
||||
nextManifest[getManifestKey(meal.id)] = result.manifestEntry;
|
||||
|
||||
if (result.changed) {
|
||||
@@ -206,12 +218,21 @@ async function main() {
|
||||
|
||||
writeManifest(nextManifest);
|
||||
|
||||
console.log(
|
||||
`Thumbnail build complete: ${generated} generated, ${skipped} skipped, ${removed} removed`
|
||||
);
|
||||
return {
|
||||
generated,
|
||||
removed,
|
||||
skipped,
|
||||
total: meals.length,
|
||||
};
|
||||
}
|
||||
|
||||
main().catch((error) => {
|
||||
console.error(error.message);
|
||||
process.exitCode = 1;
|
||||
});
|
||||
if (require.main === module) {
|
||||
main().catch((error) => {
|
||||
console.error(error.message);
|
||||
process.exitCode = 1;
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
buildThumbnails,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user