feat(licenses): list the Apache-2.0 files of @waggle/core in the notices
The generator finds the copies from hive-mind-core by their SPDX header and lists each with the file it came from, whether it changed, the copyright line and the Apache-2.0 text from packages/core/LICENSE-APACHE. The text stays in the notices even if no dependency carries it.
This commit is contained in:
@@ -159,6 +159,29 @@ const crateRows = [...crates.values()].sort(byNameAndVersion).map((crate) => ({
|
||||
),
|
||||
}));
|
||||
|
||||
// First-party files under Apache-2.0: the copies from @waggle/hive-mind-core in
|
||||
// packages/core, found by their SPDX header (packages/core/LICENSE.md).
|
||||
const CORE_DIR = path.join(ROOT, 'packages', 'core');
|
||||
const APACHE_HEADER = /^\/\/ SPDX-License-Identifier: Apache-2\.0\n\/\/ (Copyright [^\n]+)\n\/\/ (Parts copied|Copied) from @waggle\/hive-mind-core (\S+) (without changes|and changed for @waggle\/core)\.\n/;
|
||||
|
||||
function apacheCoreFiles(relative) {
|
||||
return fs.readdirSync(path.join(CORE_DIR, relative), { withFileTypes: true }).flatMap((entry) => {
|
||||
const child = `${relative}/${entry.name}`;
|
||||
if (entry.isDirectory()) return apacheCoreFiles(child);
|
||||
if (!/\.tsx?$/.test(entry.name)) return [];
|
||||
const match = APACHE_HEADER.exec(fs.readFileSync(path.join(CORE_DIR, child), 'utf8').replace(/\r\n?/g, '\n'));
|
||||
if (!match) return [];
|
||||
const changes = match[2] === 'Parts copied' ? 'parts copied' : match[4] === 'without changes' ? 'no' : 'yes';
|
||||
return [{ file: child, copyright: match[1], from: match[3], changes }];
|
||||
});
|
||||
}
|
||||
|
||||
const apacheFiles = apacheCoreFiles('src').sort((a, b) => a.file.localeCompare(b.file));
|
||||
const apacheTextNumber = registerTexts(
|
||||
[{ file: 'LICENSE-APACHE', text: fs.readFileSync(path.join(CORE_DIR, 'LICENSE-APACHE'), 'utf8').replace(/\r\n?/g, '\n').trim() }],
|
||||
'@waggle/core (its Apache-2.0 files)',
|
||||
)[0];
|
||||
|
||||
// ── Rendering ──────────────────────────────────────────────────────────────
|
||||
const nodeVersion = bundledNodeVersion();
|
||||
const out = [];
|
||||
@@ -178,9 +201,9 @@ function platformLabel(row) {
|
||||
|
||||
line('# Third-party notices');
|
||||
line();
|
||||
line('The Waggle community edition is MIT-licensed and ships the third-party components listed');
|
||||
line('below. Each entry names its license; the license and notice texts the components carry are');
|
||||
line('reproduced at the end of this file.');
|
||||
line('The Waggle community edition is MIT-licensed, except a few Apache-2.0 files listed below,');
|
||||
line('and ships the third-party components listed below. Each entry names its license; the');
|
||||
line('license and notice texts the components carry are reproduced at the end of this file.');
|
||||
line();
|
||||
line('Generated by `node scripts/generate-third-party-notices.mjs` from `package-lock.json`, the');
|
||||
line('installed npm packages and `cargo metadata --offline` for `app/src-tauri`. Do not edit by hand;');
|
||||
@@ -190,6 +213,7 @@ line();
|
||||
line('## Contents');
|
||||
line();
|
||||
line('- [What ships](#what-ships)');
|
||||
line('- [Apache-2.0 files in @waggle/core](#apache-20-files-in-wagglecore)');
|
||||
line('- [LGPL, MPL and other licenses with conditions](#lgpl-mpl-and-other-licenses-with-conditions)');
|
||||
line('- [Node.js runtime and npm](#nodejs-runtime-and-npm)');
|
||||
for (const artifact of artifacts) {
|
||||
@@ -217,6 +241,23 @@ line('tree-shaking drops may be listed. The sidecar list leaves out the packages
|
||||
line('`scripts/stage-sidecar-deps.mjs` never ships (its `SKIP` set).');
|
||||
line();
|
||||
|
||||
line('## Apache-2.0 files in @waggle/core');
|
||||
line();
|
||||
line('Waggle\'s own code is MIT-licensed except the files below, which `service.js` bundles. They');
|
||||
line('were copied from `@waggle/hive-mind-core`, a package of the commercial Waggle repository, and');
|
||||
line(`keep its license, the Apache License 2.0: [license text ${apacheTextNumber}](#license-text-${apacheTextNumber}). Each file`);
|
||||
line('starts with an `SPDX-License-Identifier: Apache-2.0` header that names the file it came');
|
||||
line('from; `packages/core/LICENSE.md` also lists the tests copied with them, which do not ship.');
|
||||
line();
|
||||
for (const copyright of new Set(apacheFiles.map((entry) => entry.copyright))) line(copyright);
|
||||
line();
|
||||
line('| File | Copied from `packages/hive-mind-core/` | Changed |');
|
||||
line('|---|---|---|');
|
||||
for (const entry of apacheFiles) {
|
||||
line(`| \`packages/core/${entry.file}\` | \`${entry.from}\` | ${entry.changes} |`);
|
||||
}
|
||||
line();
|
||||
|
||||
// Copyleft section
|
||||
const components = [...artifacts.flatMap((artifact) => artifact.rows), ...crateRows];
|
||||
const groups = { lgpl: [], mpl: [], ofl: [], none: [], other: [], dual: [] };
|
||||
|
||||
Reference in New Issue
Block a user