summaryrefslogtreecommitdiff
path: root/.github/scripts
diff options
context:
space:
mode:
Diffstat (limited to '.github/scripts')
-rw-r--r--.github/scripts/discover_bumps.py229
-rw-r--r--.github/scripts/plugin-dirs.sh10
-rw-r--r--.github/scripts/validate-frontmatter.ts283
-rw-r--r--.github/scripts/validate-plugin-folders.ts207
4 files changed, 0 insertions, 729 deletions
diff --git a/.github/scripts/discover_bumps.py b/.github/scripts/discover_bumps.py
deleted file mode 100644
index 7bc23597..00000000
--- a/.github/scripts/discover_bumps.py
+++ /dev/null
@@ -1,229 +0,0 @@
-#!/usr/bin/env python3
-"""Discover plugins in marketplace.json whose upstream repo has moved past
-their pinned SHA, update the file in place, and emit a summary.
-
-Adapted from claude-plugins-community-internal's discover_bumps.py for the
-single-file marketplace.json format used by claude-plugins-official.
-
-Usage: discover_bumps.py [--plugin NAME] [--max N] [--dry-run]
-"""
-
-import argparse
-import json
-import os
-import re
-import subprocess
-import sys
-from datetime import datetime, timezone
-from typing import Any
-
-
-MARKETPLACE_PATH = ".claude-plugin/marketplace.json"
-
-
-def gh_api(path: str) -> Any:
- """GET from the GitHub API. None on not-found; raises on other errors.
-
- "Not found" covers both 404 (resource gone) and 422 "No commit found
- for SHA" (force-pushed away). Both mean the thing we asked for isn't
- there — treating them the same lets callers handle dead refs uniformly.
- """
- r = subprocess.run(
- ["gh", "api", path], capture_output=True, text=True
- )
- if r.returncode != 0:
- combined = r.stdout + r.stderr
- if any(s in combined for s in ("404", "Not Found", "No commit found")):
- return None
- raise RuntimeError(f"gh api {path}: {r.stderr.strip() or r.stdout.strip()}")
- return json.loads(r.stdout)
-
-
-def parse_github_repo(url: str) -> tuple[str, str] | None:
- """Extract (owner, repo) from a URL or owner/repo shorthand."""
- # Full URL: https://github.com/owner/repo(.git)(/...)
- m = re.match(r"https?://github\.com/([^/]+)/([^/]+?)(?:\.git)?(?:/|$)", url)
- if m:
- return m.group(1), m.group(2)
- # Shorthand: owner/repo
- m = re.match(r"^([\w.-]+)/([\w.-]+)$", url)
- if m:
- return m.group(1), m.group(2)
- return None
-
-
-def latest_sha(owner: str, repo: str, *, ref: str | None, path: str | None) -> str | None:
- """Latest commit SHA for the repo, optionally scoped to a ref and/or path."""
- if path:
- # Scoped to a subdirectory — use the commits list endpoint with path filter.
- q = f"repos/{owner}/{repo}/commits?per_page=1&path={path}"
- if ref:
- q += f"&sha={ref}"
- commits = gh_api(q)
- if not commits:
- return None
- return commits[0]["sha"]
- # Whole repo — the single-ref endpoint is cheaper.
- if not ref:
- meta = gh_api(f"repos/{owner}/{repo}")
- if not meta:
- return None
- ref = meta["default_branch"]
- c = gh_api(f"repos/{owner}/{repo}/commits/{ref}")
- return c["sha"] if c else None
-
-
-def pinned_age_days(owner: str, repo: str, sha: str) -> int | None:
- """Days since the pinned commit was authored. Used for oldest-first rotation."""
- c = gh_api(f"repos/{owner}/{repo}/commits/{sha}")
- if not c:
- return None
- dt = datetime.fromisoformat(
- c["commit"]["committer"]["date"].replace("Z", "+00:00")
- )
- return (datetime.now(timezone.utc) - dt).days
-
-
-def main() -> int:
- ap = argparse.ArgumentParser()
- ap.add_argument("--plugin", help="only check this plugin")
- ap.add_argument("--max", type=int, default=20, help="cap bumps emitted")
- ap.add_argument("--dry-run", action="store_true", help="don't write marketplace.json")
- args = ap.parse_args()
-
- with open(MARKETPLACE_PATH) as f:
- marketplace = json.load(f)
-
- plugins = marketplace.get("plugins", [])
- bumps: list[dict] = []
- dead: list[str] = []
- skipped_non_github = 0
- checked = 0
-
- for plugin in plugins:
- name = plugin.get("name", "?")
- src = plugin.get("source")
-
- # Only process object sources with a sha field
- if not isinstance(src, dict) or "sha" not in src:
- continue
-
- # Filter to specific plugin if requested
- if args.plugin and name != args.plugin:
- continue
-
- checked += 1
- kind = src.get("source")
- url = src.get("url", "")
- path = src.get("path")
- ref = src.get("ref")
- pinned = src.get("sha")
-
- slug = parse_github_repo(url)
- if not slug:
- skipped_non_github += 1
- continue
- owner, repo = slug
-
- try:
- latest = latest_sha(owner, repo, ref=ref, path=path)
- except RuntimeError as e:
- print(f"::warning::{name}: {e}", file=sys.stderr)
- continue
-
- if latest is None:
- dead.append(f"{name} ({owner}/{repo})")
- continue
-
- if latest == pinned:
- continue # up to date
-
- # Age lookup for rotation — oldest-pinned first prevents starvation.
- try:
- age = pinned_age_days(owner, repo, pinned) if pinned else None
- except RuntimeError as e:
- print(f"::warning::{name}: age lookup failed: {e}", file=sys.stderr)
- age = None
-
- bumps.append({
- "name": name,
- "kind": kind,
- "url": url,
- "path": path or "",
- "ref": ref or "",
- "old_sha": pinned or "",
- "new_sha": latest,
- "age_days": age if age is not None else 10**6,
- })
-
- # Oldest-pinned first so nothing starves under the cap.
- bumps.sort(key=lambda b: -b["age_days"])
- emitted = bumps[: args.max]
-
- # Apply bumps to marketplace data
- if emitted and not args.dry_run:
- bump_map = {b["name"]: b["new_sha"] for b in emitted}
- for plugin in plugins:
- name = plugin.get("name")
- src = plugin.get("source")
- if isinstance(src, dict) and name in bump_map:
- src["sha"] = bump_map[name]
-
- with open(MARKETPLACE_PATH, "w") as f:
- json.dump(marketplace, f, indent=2, ensure_ascii=False)
- f.write("\n")
-
- # Write GitHub outputs
- out = os.environ.get("GITHUB_OUTPUT")
- if out:
- bumped_names = ",".join(b["name"] for b in emitted)
- with open(out, "a") as fh:
- fh.write(f"count={len(emitted)}\n")
- fh.write(f"bumped_names={bumped_names}\n")
-
- # Write GitHub step summary
- summary = os.environ.get("GITHUB_STEP_SUMMARY")
- if summary:
- with open(summary, "a") as fh:
- fh.write("## SHA Bump Discovery\n\n")
- fh.write(f"- Checked: {checked} SHA-pinned entries\n")
- fh.write(f"- Stale: {len(bumps)} (applying {len(emitted)}, cap {args.max})\n")
- if skipped_non_github:
- fh.write(f"- Skipped non-GitHub: {skipped_non_github}\n")
- if dead:
- fh.write(f"- **Dead upstream** ({len(dead)}): {', '.join(dead)}\n")
- if emitted:
- fh.write("\n| Plugin | Old | New | Age |\n|---|---|---|---|\n")
- for b in emitted:
- old = b["old_sha"][:8] if b["old_sha"] else "(unpinned)"
- fh.write(f"| {b['name']} | `{old}` | `{b['new_sha'][:8]}` | {b['age_days']}d |\n")
-
- # Write PR body for the workflow to use
- pr_body_path = os.environ.get("PR_BODY_PATH", "/tmp/bump-pr-body.md")
- if emitted:
- with open(pr_body_path, "w") as fh:
- fh.write("Upstream repos moved. Bumping pinned SHAs so plugins track latest.\n\n")
- fh.write("| Plugin | Old | New | Upstream |\n")
- fh.write("|--------|-----|-----|----------|\n")
- for b in emitted:
- old = b["old_sha"][:8] if b["old_sha"] else "(unpinned)"
- slug_str = re.sub(r"https?://github\.com/", "", b["url"])
- slug_str = re.sub(r"\.git$", "", slug_str)
- compare = f"https://github.com/{slug_str}/compare/{b['old_sha'][:12]}...{b['new_sha'][:12]}"
- fh.write(f"| `{b['name']}` | `{old}` | `{b['new_sha'][:8]}` | [diff]({compare}) |\n")
- fh.write(f"\n---\n_Auto-generated by `bump-plugin-shas.yml` on {datetime.now(timezone.utc).strftime('%Y-%m-%d')}_\n")
-
- # Console summary
- print(f"Checked {checked} SHA-pinned plugins", file=sys.stderr)
- print(f"Stale: {len(bumps)}, applying: {len(emitted)}", file=sys.stderr)
- if dead:
- print(f"Dead upstream: {', '.join(dead)}", file=sys.stderr)
- for b in emitted:
- old = b["old_sha"][:8] if b["old_sha"] else "unpinned"
- print(f" {b['name']}: {old} -> {b['new_sha'][:8]} ({b['age_days']}d)", file=sys.stderr)
-
- return 0
-
-
-if __name__ == "__main__":
- sys.exit(main())
diff --git a/.github/scripts/plugin-dirs.sh b/.github/scripts/plugin-dirs.sh
deleted file mode 100644
index 7bfa0f4b..00000000
--- a/.github/scripts/plugin-dirs.sh
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/usr/bin/env bash
-# Print the folders of the plugins that live in this repository, one per line,
-# relative to the repo root.
-set -euo pipefail
-shopt -s nullglob
-cd "$(dirname "${BASH_SOURCE[0]}")/../.."
-
-for dir in plugins/*/ external_plugins/*/; do
- printf '%s\n' "${dir%/}"
-done
diff --git a/.github/scripts/validate-frontmatter.ts b/.github/scripts/validate-frontmatter.ts
deleted file mode 100644
index 15255054..00000000
--- a/.github/scripts/validate-frontmatter.ts
+++ /dev/null
@@ -1,283 +0,0 @@
-#!/usr/bin/env bun
-/**
- * Validates YAML frontmatter in agent, skill, and command .md files.
- *
- * Usage:
- * bun validate-frontmatter.ts # scan current directory
- * bun validate-frontmatter.ts /path/to/dir # scan specific directory
- * bun validate-frontmatter.ts file1.md file2.md # validate specific files
- */
-
-import { parse as parseYaml } from "yaml";
-import { readdir, readFile } from "fs/promises";
-import { basename, join, relative, resolve } from "path";
-
-// Characters that require quoting in YAML values when unquoted:
-// {} [] flow indicators, * anchor/alias, & anchor, # comment,
-// ! tag, | > block scalars, % directive, @ ` reserved
-const YAML_SPECIAL_CHARS = /[{}[\]*&#!|>%@`]/;
-const FRONTMATTER_REGEX = /^---\s*\n([\s\S]*?)---\s*\n?/;
-
-/**
- * Pre-process frontmatter text to quote values containing special YAML
- * characters. This allows glob patterns like **\/*.{ts,tsx} to parse.
- */
-function quoteSpecialValues(text: string): string {
- const lines = text.split("\n");
- const result: string[] = [];
-
- for (const line of lines) {
- const match = line.match(/^([a-zA-Z_-]+):\s+(.+)$/);
- if (match) {
- const [, key, value] = match;
- if (!key || !value) {
- result.push(line);
- continue;
- }
- // Skip block scalar headers ("description: |"): the value is on the
- // lines below
- if (/^[|>][-+0-9]*\s*(#.*)?$/.test(value)) {
- result.push(line);
- continue;
- }
- // Skip already-quoted values
- if (
- (value.startsWith('"') && value.endsWith('"')) ||
- (value.startsWith("'") && value.endsWith("'"))
- ) {
- result.push(line);
- continue;
- }
- if (YAML_SPECIAL_CHARS.test(value)) {
- const escaped = value.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
- result.push(`${key}: "${escaped}"`);
- continue;
- }
- }
- result.push(line);
- }
-
- return result.join("\n");
-}
-
-interface ParseResult {
- frontmatter: Record<string, unknown>;
- content: string;
- error?: string;
-}
-
-function parseFrontmatter(markdown: string): ParseResult {
- const match = markdown.match(FRONTMATTER_REGEX);
-
- if (!match) {
- return {
- frontmatter: {},
- content: markdown,
- error: "No frontmatter found",
- };
- }
-
- const frontmatterText = quoteSpecialValues(match[1] || "");
- const content = markdown.slice(match[0].length);
-
- try {
- const parsed = parseYaml(frontmatterText);
- if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
- return { frontmatter: parsed as Record<string, unknown>, content };
- }
- return {
- frontmatter: {},
- content,
- error: `YAML parsed but result is not an object (got ${typeof parsed}${Array.isArray(parsed) ? " array" : ""})`,
- };
- } catch (err) {
- return {
- frontmatter: {},
- content,
- error: `YAML parse failed: ${err instanceof Error ? err.message : err}`,
- };
- }
-}
-
-// --- Validation ---
-
-type FileType = "agent" | "skill" | "command";
-
-interface ValidationIssue {
- level: "error" | "warning";
- message: string;
-}
-
-function validateAgent(
- frontmatter: Record<string, unknown>
-): ValidationIssue[] {
- const issues: ValidationIssue[] = [];
-
- if (!frontmatter["name"] || typeof frontmatter["name"] !== "string") {
- issues.push({ level: "error", message: 'Missing required "name" field' });
- }
- if (
- !frontmatter["description"] ||
- typeof frontmatter["description"] !== "string"
- ) {
- issues.push({
- level: "error",
- message: 'Missing required "description" field',
- });
- }
-
- return issues;
-}
-
-function validateSkill(
- frontmatter: Record<string, unknown>
-): ValidationIssue[] {
- const issues: ValidationIssue[] = [];
-
- if (!frontmatter["description"] && !frontmatter["when_to_use"]) {
- issues.push({
- level: "error",
- message: 'Missing required "description" field',
- });
- }
-
- return issues;
-}
-
-function validateCommand(
- frontmatter: Record<string, unknown>
-): ValidationIssue[] {
- const issues: ValidationIssue[] = [];
-
- if (
- !frontmatter["description"] ||
- typeof frontmatter["description"] !== "string"
- ) {
- issues.push({
- level: "error",
- message: 'Missing required "description" field',
- });
- }
-
- return issues;
-}
-
-// --- File type detection ---
-
-function detectFileType(filePath: string): FileType | null {
- // Only match agents/ and commands/ at the plugin root level, not nested
- // inside skill content (e.g. plugins/foo/skills/bar/agents/ is skill content,
- // not an agent definition).
- const inSkillContent = /\/skills\/[^/]+\//.test(filePath);
- if (filePath.includes("/agents/") && !inSkillContent) return "agent";
- if (filePath.includes("/skills/") && basename(filePath) === "SKILL.md")
- return "skill";
- if (filePath.includes("/commands/") && !inSkillContent) return "command";
- return null;
-}
-
-// --- File discovery ---
-
-async function findMdFiles(
- baseDir: string
-): Promise<{ path: string; type: FileType }[]> {
- const results: { path: string; type: FileType }[] = [];
-
- async function walk(dir: string) {
- const entries = await readdir(dir, { withFileTypes: true });
- for (const entry of entries) {
- const fullPath = join(dir, entry.name);
- if (entry.isDirectory()) {
- await walk(fullPath);
- } else if (entry.name.endsWith(".md")) {
- const type = detectFileType(fullPath);
- if (type) {
- results.push({ path: fullPath, type });
- }
- }
- }
- }
-
- await walk(baseDir);
- return results;
-}
-
-// --- Main ---
-
-async function main() {
- const args = process.argv.slice(2);
-
- let files: { path: string; type: FileType }[];
- let baseDir: string;
-
- if (args.length > 0 && args.every((a) => a.endsWith(".md"))) {
- baseDir = process.cwd();
- files = [];
- for (const arg of args) {
- const fullPath = resolve(arg);
- const type = detectFileType(fullPath);
- if (type) {
- files.push({ path: fullPath, type });
- }
- }
- } else {
- baseDir = args[0] || process.cwd();
- files = await findMdFiles(baseDir);
- }
-
- let totalErrors = 0;
- let totalWarnings = 0;
-
- console.log(`Validating ${files.length} frontmatter files...\n`);
-
- for (const { path: filePath, type } of files) {
- const rel = relative(baseDir, filePath);
- const content = await readFile(filePath, "utf-8");
- const result = parseFrontmatter(content);
-
- const issues: ValidationIssue[] = [];
-
- if (result.error) {
- issues.push({ level: "error", message: result.error });
- }
-
- if (!result.error) {
- switch (type) {
- case "agent":
- issues.push(...validateAgent(result.frontmatter));
- break;
- case "skill":
- issues.push(...validateSkill(result.frontmatter));
- break;
- case "command":
- issues.push(...validateCommand(result.frontmatter));
- break;
- }
- }
-
- if (issues.length > 0) {
- console.log(`${rel} (${type})`);
- for (const issue of issues) {
- const prefix = issue.level === "error" ? " ERROR" : " WARN ";
- console.log(`${prefix}: ${issue.message}`);
- if (issue.level === "error") totalErrors++;
- else totalWarnings++;
- }
- console.log();
- }
- }
-
- console.log("---");
- console.log(
- `Validated ${files.length} files: ${totalErrors} errors, ${totalWarnings} warnings`
- );
-
- if (totalErrors > 0) {
- process.exit(1);
- }
-}
-
-main().catch((err) => {
- console.error("Fatal error:", err);
- process.exit(2);
-});
diff --git a/.github/scripts/validate-plugin-folders.ts b/.github/scripts/validate-plugin-folders.ts
deleted file mode 100644
index 0b2b8a06..00000000
--- a/.github/scripts/validate-plugin-folders.ts
+++ /dev/null
@@ -1,207 +0,0 @@
-#!/usr/bin/env bun
-/**
- * Validates the plugin folders in this repository (plugin-dirs.sh) with
- * `claude plugin validate`. Needs `claude` on PATH; run from the repo root.
- *
- * Each folder is checked twice, because neither check is enough alone:
- *
- * 1. On its own, which covers the manifest and the plugin's files. This
- * rejects names such as "claude-security" as reserved for Anthropic: the
- * CLI can't tell from a bare folder that the plugin is ours. So a problem
- * with `name` is ignored here and left to check 2.
- * 2. All together, listed in a throwaway marketplace with this marketplace's
- * name. Reserved names are allowed there and other bad names are not, and
- * a plugin need not be listed in the real marketplace.json to be checked.
- */
-
-import { spawnSync } from "child_process";
-import {
- cpSync,
- existsSync,
- mkdirSync,
- mkdtempSync,
- readFileSync,
- rmSync,
- writeFileSync,
-} from "fs";
-import { tmpdir } from "os";
-import { basename, dirname, join } from "path";
-
-const MARKETPLACE_NAME = "claude-plugins-official";
-const CLI_TIMEOUT_MS = 120_000;
-// Files the plugin loader reads. The CLI doesn't report every one of these
-// when it isn't valid JSON.
-const JSON_FILES = [".mcp.json", ".lsp.json", "hooks/hooks.json"];
-
-interface Issue {
- path: string;
- message: string;
-}
-interface FileReport {
- file: string;
- errors: Issue[];
- warnings: Issue[];
-}
-interface Report {
- success: boolean;
- manifest: FileReport | null;
- contents: FileReport[];
-}
-
-function run(cmd: string, args: string[]) {
- const r = spawnSync(cmd, args, {
- encoding: "utf8",
- maxBuffer: 64 * 1024 * 1024,
- timeout: CLI_TIMEOUT_MS,
- });
- if (r.error) throw r.error;
- return r;
-}
-
-function cliValidate(path: string): Report {
- // Exits 1 with a report on stdout when the plugin is not valid.
- const r = run("claude", ["plugin", "validate", "--json", path]);
- try {
- const report = JSON.parse(r.stdout) as Report;
- if (typeof report.success !== "boolean" || !Array.isArray(report.contents))
- throw new Error("unexpected report shape");
- return report;
- } catch (err) {
- throw new Error(
- `claude plugin validate gave no usable report for ${path} (exit ${r.status}): ${err}\n${r.stdout}${r.stderr}`
- );
- }
-}
-
-function checkFolder(dir: string): { problems: string[]; name: string | null } {
- const manifestPath = join(dir, ".claude-plugin/plugin.json");
- if (!existsSync(manifestPath))
- return { problems: ["no .claude-plugin/plugin.json"], name: null };
-
- const problems: string[] = [];
- let name: string | null = null;
- try {
- const manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
- const value = manifest?.name;
- if (typeof value === "string" && value) name = value;
- } catch {
- // Not JSON: the CLI reports it below.
- }
- if (name !== null && name !== basename(dir))
- problems.push(`plugin.json name "${name}" is not the folder's name`);
-
- for (const file of JSON_FILES) {
- const path = join(dir, file);
- if (!existsSync(path)) continue;
- try {
- JSON.parse(readFileSync(path, "utf8"));
- } catch (err) {
- problems.push(`${file}: not valid JSON (${err})`);
- }
- }
-
- const report = cliValidate(dir);
- for (const w of report.manifest?.warnings ?? [])
- console.log(`warn ${dir} plugin.json ${w.path}: ${w.message}`);
- const manifestErrors = report.manifest?.errors ?? [];
- // Check 2 judges the name, and can only do so when there is one.
- const ignored = name === null ? [] : manifestErrors.filter((e) => e.path === "name");
- const reported = manifestErrors.filter((e) => !ignored.includes(e));
- for (const e of reported) problems.push(`plugin.json ${e.path}: ${e.message}`);
- let fileErrors = 0;
- for (const f of report.contents) {
- for (const e of f.errors) {
- fileErrors++;
- problems.push(`${f.file} ${e.path}: ${e.message}`);
- }
- for (const w of f.warnings ?? [])
- console.log(`warn ${f.file} ${w.path}: ${w.message}`);
- }
- // A failure with no error we can name must still fail.
- if (!report.success && !ignored.length && !reported.length && !fileErrors)
- problems.push("claude plugin validate failed without naming an error");
-
- return { problems, name };
-}
-
-function checkTogether(plugins: { dir: string; name: string }[]): string[] {
- const root = mkdtempSync(join(tmpdir(), "plugin-folders-"));
- try {
- for (const { dir } of plugins) {
- mkdirSync(join(root, dirname(dir)), { recursive: true });
- cpSync(dir, join(root, dir), { recursive: true });
- }
- const file = join(root, ".claude-plugin/marketplace.json");
- mkdirSync(dirname(file));
- writeFileSync(
- file,
- JSON.stringify({
- name: MARKETPLACE_NAME,
- owner: { name: "Anthropic", email: "support@anthropic.com" },
- plugins: plugins.map(({ dir, name }) => ({ name, source: `./${dir}` })),
- })
- );
- const report = cliValidate(file);
- const problems = [report.manifest, ...report.contents].flatMap((f) =>
- (f?.errors ?? []).map((e) => {
- // "plugins[4] plugin.json → version" or "plugins.4.name"
- const i = /^plugins[[.](\d+)/.exec(e.path)?.[1];
- const dir = i === undefined ? undefined : plugins[Number(i)]?.dir;
- return `${dir ? `${dir}: ` : ""}${e.path}: ${e.message}`;
- })
- );
- if (!report.success && problems.length === 0)
- problems.push("claude plugin validate failed without naming an error");
- return problems;
- } finally {
- rmSync(root, { recursive: true, force: true });
- }
-}
-
-// Entries of the real marketplace.json whose plugin lives in this repository.
-function checkListedFoldersExist(): string[] {
- const { plugins } = JSON.parse(
- readFileSync(".claude-plugin/marketplace.json", "utf8")
- ) as { plugins: { name: string; source: unknown }[] };
- return plugins.flatMap(({ name, source }) =>
- typeof source === "string" &&
- !existsSync(join(source, ".claude-plugin/plugin.json"))
- ? [`marketplace.json lists "${name}" at ${source}, which has no plugin`]
- : []
- );
-}
-
-const list = run("bash", [".github/scripts/plugin-dirs.sh"]);
-if (list.status !== 0) throw new Error(`plugin-dirs.sh failed: ${list.stderr}`);
-const dirs = list.stdout.split("\n").filter(Boolean);
-if (dirs.length === 0) throw new Error("found no plugin folders");
-
-const problems: string[] = [];
-const named: { dir: string; name: string }[] = [];
-for (const dir of dirs) {
- let result: ReturnType<typeof checkFolder>;
- try {
- result = checkFolder(dir);
- } catch (err) {
- result = { problems: [String(err)], name: null };
- }
- console.log(`${result.problems.length ? "FAIL" : "ok "} ${dir}`);
- for (const p of result.problems) problems.push(`${dir}: ${p}`);
- if (result.name !== null) named.push({ dir, name: result.name });
-}
-for (const check of [() => checkTogether(named), checkListedFoldersExist]) {
- try {
- problems.push(...check());
- } catch (err) {
- problems.push(String(err));
- }
-}
-
-if (problems.length > 0) {
- console.log();
- // %0A keeps a multi-line message in one annotation.
- for (const p of problems) console.log(`::error::${p.replace(/\r?\n/g, "%0A")}`);
- console.log(`\n${problems.length} problem(s) in ${dirs.length} plugin folders.`);
- process.exit(1);
-}
-console.log(`\nAll ${dirs.length} plugin folders are valid.`);