Some checks are pending
build-images / api (push) Waiting to run
build-images / worker-gpu (push) Waiting to run
build-images / web (push) Waiting to run
codeql / Analyze (javascript-typescript) (push) Waiting to run
codeql / Analyze (python) (push) Waiting to run
perf / API hot-path micro-smoke (budgeted) (push) Waiting to run
perf / Desktop engine crates (release build check) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Waiting to run
vision2026-ci / API phase modules (ruff + pytest) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Waiting to run
vision2026-ci / Python SDK resource tests (push) Waiting to run
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Waiting to run
vision2026-ci / Alembic upgrade + drift check (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Waiting to run
Paid, hosted product at menivor.com, now retired as a company project. Fresh squashed history of the cleaned working tree (secret-scanned, no .env, no customer data, no outreach logs). Built on MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
78 lines
3.0 KiB
JavaScript
78 lines
3.0 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* Licence check for the watch app (CI, after `npm ci`): no GPL-family licence
|
|
* (GPL, LGPL, AGPL) may ship in the mobile or TV apps. A dual licence that
|
|
* offers a permissive choice ("MIT OR GPL-3.0") passes. Unknown licences are
|
|
* listed so a person can look at them; they do not fail the build.
|
|
*
|
|
* Usage: node scripts/licence-check.mjs [node_modules dir]
|
|
*/
|
|
|
|
import { readdirSync, readFileSync, existsSync } from "node:fs";
|
|
import { join } from "node:path";
|
|
import { pathToFileURL } from "node:url";
|
|
|
|
const PERMISSIVE = /\b(MIT|ISC|0BSD|BSD-[23]-Clause|Apache-2\.0|CC0-1\.0|Unlicense|BlueOak-1\.0\.0|Python-2\.0|MPL-2\.0|CC-BY-[34]\.0|Zlib|WTFPL)\b/i;
|
|
const COPYLEFT = /\b(A?GPL|LGPL)(-[0-9.]+)?(-only|-or-later|\+)?\b/i;
|
|
|
|
export function licenceOf(pkg) {
|
|
const raw = pkg.license ?? pkg.licenses ?? "";
|
|
if (Array.isArray(raw)) return raw.map((l) => (typeof l === "string" ? l : l?.type ?? "")).join(" OR ");
|
|
if (typeof raw === "object" && raw) return raw.type ?? "";
|
|
return String(raw);
|
|
}
|
|
|
|
/** "ok" | "copyleft" | "unknown" for one licence expression. */
|
|
export function classify(expression) {
|
|
const text = String(expression || "").trim();
|
|
if (!text) return "unknown";
|
|
const alternatives = text.replace(/[()]/g, " ").split(/\s+OR\s+/i);
|
|
if (alternatives.some((alt) => PERMISSIVE.test(alt) && !COPYLEFT.test(alt))) return "ok";
|
|
if (COPYLEFT.test(text)) return "copyleft";
|
|
return "unknown";
|
|
}
|
|
|
|
function* packages(dir) {
|
|
if (!existsSync(dir)) return;
|
|
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
if (!entry.isDirectory() || entry.name.startsWith(".")) continue;
|
|
const full = join(dir, entry.name);
|
|
if (entry.name.startsWith("@")) {
|
|
yield* packages(full);
|
|
continue;
|
|
}
|
|
const manifest = join(full, "package.json");
|
|
if (existsSync(manifest)) {
|
|
try {
|
|
const pkg = JSON.parse(readFileSync(manifest, "utf8"));
|
|
yield { name: pkg.name ?? entry.name, version: pkg.version ?? "", licence: licenceOf(pkg) };
|
|
} catch {
|
|
yield { name: entry.name, version: "", licence: "" };
|
|
}
|
|
}
|
|
yield* packages(join(full, "node_modules"));
|
|
}
|
|
}
|
|
|
|
export function check(dir) {
|
|
const copyleft = [];
|
|
const unknown = [];
|
|
let count = 0;
|
|
for (const pkg of packages(dir)) {
|
|
count += 1;
|
|
const verdict = classify(pkg.licence);
|
|
if (verdict === "copyleft") copyleft.push(pkg);
|
|
if (verdict === "unknown") unknown.push(pkg);
|
|
}
|
|
return { count, copyleft, unknown };
|
|
}
|
|
|
|
if (import.meta.url === pathToFileURL(process.argv[1] ?? "").href) {
|
|
const dir = process.argv[2] ?? "node_modules";
|
|
const result = check(dir);
|
|
for (const pkg of result.unknown) console.warn(`look at: ${pkg.name}@${pkg.version} (${pkg.licence || "no licence field"})`);
|
|
for (const pkg of result.copyleft) console.error(`not allowed: ${pkg.name}@${pkg.version} (${pkg.licence})`);
|
|
console.log(`${result.count} packages, ${result.copyleft.length} copyleft, ${result.unknown.length} to look at`);
|
|
process.exit(result.copyleft.length ? 1 : 0);
|
|
}
|