package file→ .shtukbase/packages/live/checks/l03_run.ts
checks/l03_run.ts
21 lines, 1.1 KB.
- // LIVE-R03. A page runs only the actions the project allowed by name: `run:` of /base/live.md is a list of
- // "package action" (empty by default); no patterns, and every entry is an action of an installed package
- // (or `shtuk check`, all checks of the project).
- import { type Project, type Result } from '../../collections/checks/lib/speclib.ts';
- import { actionsOf } from '../server/run.ts';
- import { CHECK_ALL, PAGE } from '../server/settings.ts';
- import { main, settingsFindings } from './lib.ts';
- export const RULE = { id: 'live03', title: 'A page runs only actions from the project allowlist', scope: 'page /base/live.md, run list' };
- export function check(p: Project, res: Result): void {
- const s = settingsFindings(p, res, 'LIVE-R03', 'run: [] or lines "package action"');
- for (const entry of s.run) {
- if (entry === CHECK_ALL) continue;
- const [pkg, action] = entry.split(' ');
- if (!actionsOf(p.root, pkg).some((a) => a.name === action))
- res.hole(PAGE, `run: "${entry}" - the project has no such action`, 'remove the line or install the package', 'live-r03');
- }
- }
- if (import.meta.main) main({ RULE, check });