scripts/check-licenses.mjs (npm run check:licenses) reads the production dependency closures of the sidecar (@waggle/server minus the packages stage-sidecar-deps.mjs never ships) and the web UI (apps/web) from package-lock.json and fails on GPL, AGPL, SSPL, missing and unknown licenses. It allows permissive licenses plus MPL-2.0 and lists named exceptions with reasons; LGPL libvips and node-webpmux, the OFL fonts and the unlicensed buffers package are marked as pending the licensing review. app/src-tauri/deny.toml applies the same allowlist to the Tauri crates with cargo-deny; the npm check fails when the two lists drift apart. A new CI job runs both, with cargo-deny 0.18.3 installed and cached in CI. scripts/license-inventory.mjs holds the shared closure logic.
59 lines
2.5 KiB
TypeScript
59 lines
2.5 KiB
TypeScript
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
import { describe, expect, it } from 'vitest';
|
|
import {
|
|
ALLOWED_LICENSES,
|
|
evaluateLicense,
|
|
findException,
|
|
readDenyAllowList,
|
|
} from './check-licenses.mjs';
|
|
|
|
describe('evaluateLicense', () => {
|
|
it('allows listed licenses and expressions the allowlist satisfies', () => {
|
|
expect(evaluateLicense('MIT').status).toBe('allowed');
|
|
expect(evaluateLicense('(MIT AND Zlib)').status).toBe('allowed');
|
|
expect(evaluateLicense('(MIT OR Apache-2.0) AND Unicode-3.0').status).toBe('allowed');
|
|
expect(evaluateLicense('Apache-2.0 WITH LLVM-exception').status).toBe('allowed');
|
|
});
|
|
|
|
it('passes dual-licensed packages on their permissive option and reports the other one', () => {
|
|
const result = evaluateLicense('(MIT OR GPL-3.0-or-later)');
|
|
expect(result.status).toBe('allowed');
|
|
expect(result.alternatives).toEqual(['GPL-3.0-or-later']);
|
|
});
|
|
|
|
it('denies copyleft licenses, alone or in a conjunction', () => {
|
|
for (const expression of ['GPL-3.0-only', 'AGPL-3.0-or-later', 'SSPL-1.0', 'MIT AND LGPL-3.0-or-later']) {
|
|
const result = evaluateLicense(expression);
|
|
expect(result.status, expression).toBe('denied');
|
|
expect(result.copyleft, expression).toBe(true);
|
|
}
|
|
expect(evaluateLicense('GPL-2.0-only WITH Classpath-exception-2.0').status).toBe('denied');
|
|
});
|
|
|
|
it('flags missing and non-SPDX licenses', () => {
|
|
expect(evaluateLicense(null).status).toBe('missing');
|
|
expect(evaluateLicense(' ').status).toBe('missing');
|
|
for (const expression of ['SEE LICENSE IN LICENSE', 'MIT/X11', 'Apache 2.0', '(MIT', 'MIT OR']) {
|
|
expect(evaluateLicense(expression).status, expression).toBe('invalid');
|
|
}
|
|
expect(evaluateLicense('BSD').status).toBe('denied');
|
|
});
|
|
});
|
|
|
|
describe('findException', () => {
|
|
it('matches by name pattern and the exact declared license', () => {
|
|
expect(findException({ name: '@img/sharp-libvips-linux-x64', license: 'LGPL-3.0-or-later' })).toBeDefined();
|
|
expect(findException({ name: '@img/sharp-libvips-linux-x64', license: 'GPL-3.0-only' })).toBeUndefined();
|
|
expect(findException({ name: 'async', license: null })).toBeDefined();
|
|
expect(findException({ name: 'async', license: 'GPL-3.0-only' })).toBeUndefined();
|
|
});
|
|
});
|
|
|
|
describe('deny.toml', () => {
|
|
it('uses the same allowlist as the npm check', () => {
|
|
const denyToml = fs.readFileSync(path.join(__dirname, '..', 'app', 'src-tauri', 'deny.toml'), 'utf8');
|
|
expect([...readDenyAllowList(denyToml)].sort()).toEqual([...ALLOWED_LICENSES].sort());
|
|
});
|
|
});
|