Files
waggle-os/scripts/third-party-notices.test.ts
shumeiko.it 35bf8e26bd feat(licenses): meet the LGPL notice and source terms for libvips and node-webpmux
The notices now carry the LGPL-3.0 and GPL-3.0 texts from
scripts/license-texts (the LGPL text byte-identical to gnu.org's, the GPL
text as the Rust toolchain ships it), whatever the dependencies ship.
The LGPL section names each component with its exact version, says it
ships unmodified as a separate library, and gives the upstream source
release of that version: sharp-libvips v1.3.2 and libvips v8.18.3 for
the libvips packages, sharp v0.35.3 for @img/sharp-win32-x64, the npm
package of node-webpmux 3.2.1. The libraries built into libvips are
listed with their versions from versions.json. Versions and repository
URLs come from the lockfile and the installed packages.

The LGPL exceptions of the license gate are no longer pending: the
project owner left these items to us. A test checks the texts, the LGPL
rows and the Apache-2.0 files against the committed notices. UF-059 is
fixed.
2026-11-04 10:34:32 +01:00

47 lines
2.5 KiB
TypeScript

/**
* THIRD_PARTY_NOTICES.md carries what the LGPL and Apache-2.0 ask for: the
* full license texts, every LGPL component with its version and source, and
* the Apache-2.0 files of @waggle/core. Regenerate the file when this fails:
* node scripts/generate-third-party-notices.mjs
*/
import fs from 'node:fs';
import path from 'node:path';
import { describe, expect, it } from 'vitest';
import { npmArtifacts, npmClosure, readLockfilePackages, uniqueVersions } from './license-inventory.mjs';
const ROOT = path.resolve(import.meta.dirname, '..');
const notices = fs.readFileSync(path.join(ROOT, 'THIRD_PARTY_NOTICES.md'), 'utf8');
const lgplSection = notices.slice(notices.indexOf('### LGPL-3.0'), notices.indexOf('### MPL-2.0'));
const readText = (file: string) => fs.readFileSync(path.join(ROOT, file), 'utf8').replace(/\r\n?/g, '\n').trim();
describe('THIRD_PARTY_NOTICES.md', () => {
it('carries the full LGPL-3.0 and GPL-3.0 texts', () => {
const lgpl = readText('scripts/license-texts/LGPL-3.0.txt');
const gpl = readText('scripts/license-texts/GPL-3.0.txt');
expect(lgpl).toContain('GNU LESSER GENERAL PUBLIC LICENSE');
expect(gpl).toContain('How to Apply These Terms to Your New Programs');
expect(notices).toContain(lgpl);
expect(notices).toContain(gpl);
});
it('names every shipped LGPL package with its version, unmodified, and its source', () => {
const packages = readLockfilePackages();
const lgplPackages = npmArtifacts().flatMap((artifact) => uniqueVersions(npmClosure(packages, artifact).packages.values()))
.filter((pkg) => /LGPL/.test(pkg.license ?? ''));
expect(lgplPackages.length).toBeGreaterThan(0);
expect(lgplSection).toContain('Each ships unmodified, as a separate library');
for (const pkg of lgplPackages) {
const row = lgplSection.split('\n').find((line) => line.startsWith(`| ${pkg.name} | ${pkg.version} |`));
expect(row, `${pkg.name}@${pkg.version} is missing from the LGPL section`).toBeDefined();
expect(row).toMatch(/https:\/\/(?:github\.com\/\S+\/releases\/tag\/v\S+|registry\.npmjs\.org\/\S+\.tgz)/);
}
});
it('lists the Apache-2.0 files of @waggle/core with the Apache-2.0 text', () => {
const listed = [...readText('packages/core/LICENSE.md').matchAll(/^\| `(src\/[^`]+)` \|/gm)].map((match) => match[1]);
expect(listed.length).toBeGreaterThan(0);
for (const file of listed) expect(notices).toContain(`| \`packages/core/${file}\` |`);
expect(notices).toContain(readText('packages/core/LICENSE-APACHE'));
});
});