ShtukbaseStandard
包文件→ .shtukbase/packages/live/checks/l03_run.ts

checks/l03_run.ts

21 行, 1.1 KB.

文件按包中的原样显示:代码及其注释不做翻译。

  1. // LIVE-R03. A page runs only the actions the project allowed by name: `run:` of /base/live.md is a list of
  2. // "package action" (empty by default); no patterns, and every entry is an action of an installed package
  3. // (or `shtuk check`, all checks of the project).
  4. import { type Project, type Result } from '../../collections/checks/lib/speclib.ts';
  5. import { actionsOf } from '../server/run.ts';
  6. import { CHECK_ALL, PAGE } from '../server/settings.ts';
  7. import { main, settingsFindings } from './lib.ts';
  8. export const RULE = { id: 'live03', title: 'A page runs only actions from the project allowlist', scope: 'page /base/live.md, run list' };
  9. export function check(p: Project, res: Result): void {
  10. const s = settingsFindings(p, res, 'LIVE-R03', 'run: [] or lines "package action"');
  11. for (const entry of s.run) {
  12. if (entry === CHECK_ALL) continue;
  13. const [pkg, action] = entry.split(' ');
  14. if (!actionsOf(p.root, pkg).some((a) => a.name === action))
  15. res.hole(PAGE, `run: "${entry}" - the project has no such action`, 'remove the line or install the package', 'live-r03');
  16. }
  17. }
  18. if (import.meta.main) main({ RULE, check });