@tideworthy/tidysites 0.1.16 → 0.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/tidysites.mjs +16 -2
- package/package.json +1 -1
package/bin/tidysites.mjs
CHANGED
|
@@ -356,6 +356,7 @@ async function push(ctx) {
|
|
|
356
356
|
if (removeKeys.length) { const rem = readRemoved(ctx.dir); for (const k of removeKeys) rem.delete(k); writeRemoved(ctx.dir, rem); }
|
|
357
357
|
if (r.missing?.length) say(`Not found to remove: ${r.missing.map((m) => `${m.collection}/${m.slug}`).join(', ')}`);
|
|
358
358
|
}
|
|
359
|
+
const menuProblems = [];
|
|
359
360
|
for (const name of menus) {
|
|
360
361
|
const m = s.menus[name];
|
|
361
362
|
let items;
|
|
@@ -364,9 +365,22 @@ async function push(ctx) {
|
|
|
364
365
|
} catch (e) {
|
|
365
366
|
fail(`menus/${name}.json: ${e.message}`);
|
|
366
367
|
}
|
|
367
|
-
|
|
368
|
-
|
|
368
|
+
try {
|
|
369
|
+
try {
|
|
370
|
+
await tool(ctx.cfg, 'call_website_site_tool', { site_id: ctx.cfg.site, tool: 'menu_set_items', arguments: { name, items } });
|
|
371
|
+
} catch (e) {
|
|
372
|
+
// A menu the website does not have yet (a phone drawer, a footer column) is created from the file, then filled.
|
|
373
|
+
if (!/not.?found/i.test(e.message ?? '')) throw e;
|
|
374
|
+
await tool(ctx.cfg, 'call_website_site_tool', { site_id: ctx.cfg.site, tool: 'menu_create', arguments: { name, label: m.label || name } });
|
|
375
|
+
await tool(ctx.cfg, 'call_website_site_tool', { site_id: ctx.cfg.site, tool: 'menu_set_items', arguments: { name, items } });
|
|
376
|
+
say(`Menu ${name}: created.`);
|
|
377
|
+
}
|
|
378
|
+
say(`Menu ${name}: ${items.length} item${items.length === 1 ? '' : 's'} written.`);
|
|
379
|
+
} catch (e) {
|
|
380
|
+
menuProblems.push(`menus/${name}.json: ${e.message}`);
|
|
381
|
+
}
|
|
369
382
|
}
|
|
383
|
+
if (menuProblems.length) fail(menuProblems.join('\n'));
|
|
370
384
|
// Refresh only what went, and take the website's version of exactly those entries; every other file stays as it is.
|
|
371
385
|
const pushed = new Set([...keys, ...menus.map((m) => `menus/${m}`)]);
|
|
372
386
|
if (touched.length) await pull(ctx, touched, { overwrite: pushed, menus: menus.length > 0 });
|
package/package.json
CHANGED