ShtukbaseStandard
archivo del paquete→ .shtukbase/packages/content/checks/c02_draft.ts

checks/c02_draft.ts

21 líneas, 1.4 KB.

El archivo tal como está en el paquete: el código y sus comentarios no se traducen.

  1. // CNT-R02. A draft rests on an idea and a platform that exist; the idea is approved or drafted; the platform is not
  2. // paused (published drafts keep their platform even when it is paused later).
  3. import { FOLDERS, exists, page, phase, records, ref, report, text } from '../lib/content.ts';
  4. const out: string[] = [];
  5. const drafts = records(FOLDERS.drafts);
  6. for (const r of drafts) {
  7. const idea = ref(r.fm.idea, r.id);
  8. if (!idea) out.push(`${r.id}: no link to an idea → write idea: /content/ideas/<name> [no-idea]`);
  9. else if (!exists(idea)) out.push(`${r.id}: idea ${idea} does not exist → fix the link [missing-idea]`);
  10. else {
  11. const st = phase(page(idea).fm.status);
  12. if (!['approved', 'drafted'].includes(st)) out.push(`${r.id}: idea ${idea} is in the state "${st || '—'}", not approved → a person approves the idea, or remove the draft [idea-not-approved]`);
  13. }
  14. const pl = ref(r.fm.platform, r.id);
  15. if (!pl) out.push(`${r.id}: no platform → write platform: /content/platforms/<name> [no-platform]`);
  16. else if (!exists(pl)) out.push(`${r.id}: platform ${pl} does not exist → fix the link [missing-platform]`);
  17. else if (text(page(pl).fm.status) === 'paused' && phase(r.fm.status) !== 'published')
  18. out.push(`${r.id}: platform ${pl} is paused → take another platform or lift the pause [platform-paused]`);
  19. }
  20. report(out, `drafts (${drafts.length})`);