#!/usr/bin/env node /** * Write THIRD_PARTY_NOTICES.md: the third-party components that ship in the * community edition, their licenses and the license texts they carry. * * Offline. npm packages come from package-lock.json (closures in * scripts/license-inventory.mjs) and their texts from the installed packages; * Rust crates come from `cargo metadata --offline` and their texts from the * cargo registry cache. Targets whose crates are not cached are reported in the * file and on stderr. Platform packages (npm installs them on some of the v1 * platforms only) are listed without their texts, because a machine has only * its own platform's variants installed; that keeps the output the same on * every platform. * * Usage: node scripts/generate-third-party-notices.mjs */ import fs from 'node:fs'; import path from 'node:path'; import { ROOT, RUST_TARGETS, bundledNodeVersion, manifestLicense, npmArtifacts, npmClosure, readInstalledManifest, readLicenseFiles, readLockfilePackages, rustCrates, uniqueVersions, } from './license-inventory.mjs'; import { ALLOWED_LICENSES, EXCEPTIONS, evaluateLicense, findException } from './check-licenses.mjs'; const OUTPUT = path.join(ROOT, 'THIRD_PARTY_NOTICES.md'); const TARGET_LABELS = { 'x86_64-pc-windows-msvc': 'Windows x64', 'aarch64-apple-darwin': 'macOS arm64', 'x86_64-apple-darwin': 'macOS x64', 'x86_64-unknown-linux-gnu': 'Linux x64', }; // Licenses that impose no conditions beyond keeping the notice. MPL-2.0 is on // the allowlist but is file-level copyleft, so it is reported with LGPL. const PERMISSIVE = new Set(ALLOWED_LICENSES.filter((id) => id !== 'MPL-2.0')); const COPYLEFT_LEAF = /^(?:A?GPL|LGPL|MPL|EPL|EUPL|CDDL|OFL)/; // ── License texts, deduplicated by content ───────────────────────────────── const texts = []; const textIndex = new Map(); function registerTexts(files, owner) { return files.map(({ file, text }) => { const key = text.replace(/\s+/g, ' '); if (!textIndex.has(key)) { texts.push({ number: texts.length + 1, text, source: `${file} of ${owner}`, users: [] }); textIndex.set(key, texts.length - 1); } const entry = texts[textIndex.get(key)]; entry.users.push(owner); return entry.number; }); } function textLinks(numbers) { return numbers.length > 0 ? numbers.map((n) => `[${n}](#license-text-${n})`).join(', ') : ''; } function fence(text) { const longest = Math.max(0, ...[...text.matchAll(/`+/g)].map((match) => match[0].length)); return '`'.repeat(Math.max(3, longest + 1)); } function cell(value) { return String(value ?? '').replace(/\|/g, '\\|').replace(/\n/g, ' '); } function byNameAndVersion(a, b) { return a.name.localeCompare(b.name) || a.version.localeCompare(b.version, undefined, { numeric: true }); } function findText(pattern) { return texts.find((entry) => pattern.test(entry.text.slice(0, 400))); } // ── Classification for the copyleft section ──────────────────────────────── function leafIds(expression) { return expression.replace(/[()]/g, ' ').split(/\s+/).filter((token) => token && !/^(?:AND|OR|WITH)$/i.test(token)); } /** Cargo still accepts "MIT/Apache-2.0"; read the slash as OR. */ function normalizeCargoLicense(license) { return license ? license.replace(/\s*\/\s*/g, ' OR ') : license; } function classify(component) { const declared = component.license; const result = evaluateLicense(declared, PERMISSIVE); if (result.status === 'allowed') { const copyleftOptions = leafIds(declared).filter((id) => COPYLEFT_LEAF.test(id)); return copyleftOptions.length > 0 ? 'dual' : null; } if (result.status === 'denied') { const ids = leafIds(declared); if (ids.some((id) => /^LGPL/.test(id))) return 'lgpl'; if (ids.some((id) => /^MPL/.test(id))) return 'mpl'; if (ids.some((id) => /^OFL/.test(id))) return 'ofl'; } const exception = component.ecosystem === 'npm' ? findException({ name: component.name, license: component.lockLicense }) : undefined; if (exception && !exception.pending) return null; if (!declared) return 'none'; return 'other'; } function permissiveChoice(expression) { const options = expression.replace(/^\((.*)\)$/, '$1').split(/\s+OR\s+/i); return options.find((option) => evaluateLicense(option, PERMISSIVE).status === 'allowed') ?? ''; } // ── Inventory ────────────────────────────────────────────────────────────── const lockPackages = readLockfilePackages(); const artifacts = npmArtifacts().map((artifact) => { const { packages, unresolved } = npmClosure(lockPackages, artifact); for (const missing of unresolved) console.warn(`[notices] not in package-lock.json: ${missing}`); const rows = uniqueVersions(packages.values()).map((pkg) => { const manifest = pkg.platformSpecific ? null : readInstalledManifest(ROOT, pkg.key); const license = pkg.license ?? manifestLicense(manifest); const files = pkg.platformSpecific ? [] : readLicenseFiles(path.join(ROOT, pkg.key)); if (!pkg.platformSpecific && !manifest) { console.warn(`[notices] ${pkg.name}@${pkg.version} is not installed; run npm ci first`); } return { ...pkg, ecosystem: 'npm', artifact: artifact.title, license, lockLicense: pkg.license, textNumbers: registerTexts(files, `${pkg.name} ${pkg.version}`), installed: Boolean(manifest), }; }); return { ...artifact, rows }; }); const { crates, unresolvedTargets } = rustCrates(); const resolvedTargets = RUST_TARGETS.filter((target) => !unresolvedTargets.some((entry) => entry.target === target)); for (const { target, reason } of unresolvedTargets) { console.warn(`[notices] Rust target ${target} not resolved offline: ${reason}`); } const crateRows = [...crates.values()].sort(byNameAndVersion).map((crate) => ({ ...crate, ecosystem: 'cargo', artifact: 'Desktop shell', license: normalizeCargoLicense(crate.license), declaredLicense: crate.license ?? (crate.licenseFile ? `see ${crate.licenseFile}` : null), textNumbers: registerTexts( readLicenseFiles(crate.dir, crate.licenseFile ? [crate.licenseFile] : []), `${crate.name} ${crate.version}`, ), })); // 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 = []; const line = (text = '') => out.push(text); function npmSource(row) { if (row.resolved) return row.resolved; return row.key.startsWith('node_modules/') || row.key.includes('/node_modules/') ? '' : `vendored at \`${row.key}\``; } function platformLabel(row) { if (!row.platformSpecific) return 'all'; return [row.os?.join('/'), row.cpu?.join('/')].filter(Boolean).join(' '); } line('# Third-party notices'); line(); 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;'); line('regenerate after changing dependencies. `npm run check:licenses` checks the same npm packages'); line('against the license policy, and cargo-deny checks the crates (`app/src-tauri/deny.toml`).'); 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) { const anchor = `${artifact.title} npm packages`.toLowerCase().replace(/[^a-z0-9 -]/g, '').replace(/ /g, '-'); line(`- [${artifact.title} npm packages](#${anchor})`); } line('- [Rust crates](#rust-crates)'); line('- [License texts](#license-texts)'); line(); line('## What ships'); line(); line('| Artifact | Contents | Third-party components |'); line('|---|---|---|'); for (const artifact of artifacts) { line(`| ${artifact.title} | ${artifact.ships} | ${artifact.rows.length} npm packages |`); } line(`| Node.js runtime | Node.js ${nodeVersion} and npm, staged by \`scripts/bundle-node.mjs\` for the desktop sidecar | 2 components with their own notices |`); line(`| Desktop shell | the Tauri executable built from \`app/src-tauri\` | ${crateRows.length} Rust crates |`); line(); line('The npm lists are the production dependency closures of `packages/server` and `apps/web`'); line('from `package-lock.json`, restricted to the v1 platforms (Windows x64, macOS arm64 and x64,'); line('Linux x64). They include everything the bundlers could pull in, so a few packages that'); line('tree-shaking drops may be listed. The sidecar list leaves out the packages that'); 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: [] }; for (const component of components) { const group = classify(component); if (group) groups[group].push(component); } const textLink = (number) => `[license text ${number}](#license-text-${number})`; const textRef = (entry, name) => (entry ? textLink(entry.number) : `the ${name} text (not found in any shipped package; add it before distribution)`); // The LGPL-3.0 and the GPL-3.0 it incorporates live in scripts/license-texts, // so the notices carry them whatever the dependencies happen to ship. function canonicalText(file) { const text = fs.readFileSync(path.join(ROOT, 'scripts', 'license-texts', file), 'utf8').replace(/\r\n?/g, '\n').trim(); return registerTexts([{ file: `scripts/license-texts/${file}`, text }], 'Waggle, for its LGPL-3.0 components')[0]; } // Upstream repositories as the installed packages name them: sharp and its // platform packages (package.json of sharp), the libvips packages (package.json // of @img/sharp-libvips-*) and libvips itself (README of sharp). const SHARP_REPOSITORY = 'https://github.com/lovell/sharp'; const SHARP_LIBVIPS_REPOSITORY = 'https://github.com/lovell/sharp-libvips'; const LIBVIPS_REPOSITORY = 'https://github.com/libvips/libvips'; const sharpManifest = readInstalledManifest(ROOT, 'node_modules/sharp') ?? {}; const libvipsDir = ['darwin-arm64', 'darwin-x64', 'linux-x64', 'linuxmusl-x64'] .map((suffix) => path.join(ROOT, 'node_modules', '@img', `sharp-libvips-${suffix}`)) .find((dir) => fs.existsSync(path.join(dir, 'versions.json'))); const libvipsVersions = libvipsDir ? JSON.parse(fs.readFileSync(path.join(libvipsDir, 'versions.json'), 'utf8')) : {}; const vipsVersion = libvipsVersions.vips ?? String(sharpManifest.config?.libvips ?? '').replace(/^>=/, ''); function repositoryUrl(manifest) { const url = typeof manifest?.repository === 'string' ? manifest.repository : manifest?.repository?.url; return url ? url.replace(/^git\+/, '').replace(/\.git$/, '') : null; } /** Where the corresponding source of an LGPL component of this exact version is published. */ function lgplSource(row) { const sharpLibvipsRelease = (version) => `${SHARP_LIBVIPS_REPOSITORY}/releases/tag/v${version}`; if (row.name.startsWith('@img/sharp-libvips-')) { return `${sharpLibvipsRelease(row.version)} (build scripts and \`versions.json\`); libvips ${vipsVersion}: ${LIBVIPS_REPOSITORY}/releases/tag/v${vipsVersion}`; } if (row.name.startsWith('@img/sharp-')) { const libvipsPackage = `@img/sharp-libvips-${row.name.slice('@img/sharp-'.length)}`; const libvipsVersion = sharpManifest.devDependencies?.[libvipsPackage] ?? sharpManifest.optionalDependencies?.[libvipsPackage]; const dlls = libvipsVersion ? `; its libvips DLLs are ${libvipsPackage} ${libvipsVersion}: ${sharpLibvipsRelease(libvipsVersion)}` : ''; return `${SHARP_REPOSITORY}/releases/tag/v${row.version}${dlls}`; } const repository = repositoryUrl(readInstalledManifest(ROOT, row.key)); return `${row.resolved ?? npmSource(row)} (the published package of this version)${repository ? `; repository: ${repository}` : ''}`; } /** A version from versions.json of the libvips packages, by the library name their README uses. */ function bundledVersion(name) { const version = libvipsVersions[name] ?? libvipsVersions[name.replace(/^lib/, '')] ?? libvipsVersions[{ libultrahdr: 'uhdr' }[name]]; if (!version) return 'not in `versions.json`'; return /^[0-9a-f]{7,40}$/.test(version) ? `commit ${version}` : version; } function componentTable(rows) { line('| Component | Version | Artifact | License | Source |'); line('|---|---|---|---|---|'); for (const row of rows) { const source = row.ecosystem === 'cargo' ? `https://crates.io/crates/${row.name}/${row.version}${row.repository ? ` (repository: ${row.repository})` : ''}` : npmSource(row); line(`| ${cell(row.name)} | ${cell(row.version)} | ${row.artifact} | ${cell(row.declaredLicense ?? row.license ?? 'none declared')} | ${cell(source)} |`); } line(); } line('## LGPL, MPL and other licenses with conditions'); line(); line('Most components are under permissive licenses that only ask for their notice to be kept,'); line('which this file does. The components below carry further conditions. The summaries say what'); line('the licenses ask of whoever distributes Waggle and how this distribution meets it; they are'); line('engineering notes, not legal advice.'); line(); line('### LGPL-3.0'); line(); if (groups.lgpl.length === 0) { line('No shipped component is under the LGPL.'); line(); } else { const lgplRows = groups.lgpl.sort(byNameAndVersion); const lgplNumber = canonicalText('LGPL-3.0.txt'); const gplNumber = canonicalText('GPL-3.0.txt'); line('Waggle uses the libraries below under the GNU Lesser General Public License, version 3 or'); line('(at your option) any later version. Each ships unmodified, as a separate library that Waggle'); line('loads at runtime.'); line(); line(`- LGPL-3.0: ${textLink(lgplNumber)}`); line(`- GPL-3.0, which the LGPL-3.0 incorporates: ${textLink(gplNumber)}`); line(); line('| Component | Version | Artifact | License | Corresponding source |'); line('|---|---|---|---|---|'); for (const row of lgplRows) { line(`| ${cell(row.name)} | ${cell(row.version)} | ${row.artifact} | ${cell(row.declaredLicense ?? row.license)} | ${cell(lgplSource(row))} |`); } line(); line('How they ship: `build-sidecar.mjs` keeps `@huggingface/transformers`, `sharp` and'); line('`whatsapp-web.js` external to `service.js`, and `stage-sidecar-deps.mjs` copies these'); line('packages as published into `resources/node_modules` of the desktop app; the server archive'); line('packs that folder as `node_modules`. The libvips packages (and, on Windows,'); line('`@img/sharp-win32-x64`) hold prebuilt shared libraries that sharp loads at runtime;'); line('node-webpmux is a JavaScript package that whatsapp-web.js loads at startup. None of them is'); line('compiled into Waggle code.'); if (lgplRows.some((row) => row.name === 'node-webpmux')) { line('The npm package of node-webpmux holds its JavaScript source and `libwebp/binding.cpp`, the'); line('C++ binding compiled into its WebAssembly module.'); } line(); line('What LGPL-3.0 asks, and how this distribution meets it:'); line(); line('1. Say prominently that the libraries are used and are covered by the LGPL, and ship the'); line(' LGPL-3.0 and GPL-3.0 texts with them (sections 4(a) and 4(b)): this section and the two'); line(' texts. This file ships next to `service.js` in every desktop installer and in the server'); line(' archive, and Settings > General > Third-party licenses opens it.'); line('2. Keep each library a separate file that the user can replace with a modified,'); line(' interface-compatible version (section 4(d)(1)): the files above are separate and are'); line(' loaded at runtime. Replacing a file inside a signed macOS or Windows bundle breaks the'); line(' bundle signature; the server archive has no signature.'); line('3. Tell recipients where the corresponding source of each exact version is published'); line(' (section 4(d)(0) and section 6 of the GPL): the Corresponding source column above.'); line('4. Do not forbid users to modify the combined work or to reverse engineer it to debug such'); line(' modifications (section 4). Waggle\'s licenses, MIT and Apache-2.0, do not.'); line(); const readme = libvipsDir ? fs.readFileSync(path.join(libvipsDir, 'README.md'), 'utf8') : ''; const table = /## Licensing[\s\S]*?(\|[\s\S]*?\n)(?:\n[^|]|$)/.exec(readme); if (table) { const libraries = table[1].trim().split('\n').slice(2) .map((row) => row.split('|').slice(1, -1).map((value) => value.trim())) .map(([name, terms]) => ({ name, terms, version: bundledVersion(name) })); const lgplLibraries = libraries.filter((library) => /LGPL/.test(library.terms)); line('The libvips packages bundle further libraries, which the sharp-libvips release above'); line('builds into the prebuilt libvips library at the versions in its `versions.json`. Their'); line('README lists their licenses as follows (for cairo under MPL-2.0, see below):'); line(); line('| Library | Version | Used under the terms of |'); line('|---|---|---|'); for (const library of libraries) line(`| ${library.name} | ${library.version} | ${library.terms} |`); line(); line('The LGPLv3 libraries among them ship on the same terms as the libvips packages:'); line(); line(lgplLibraries.map((library) => `${library.name} ${library.version}`).join(', ')); line(); line('As the README notes, they are used under the LGPLv3 through the "any later version"'); line('clause of the LGPLv2 or LGPLv2.1. Each upstream project publishes its source at the'); line('version above; the build scripts of the sharp-libvips release download and build exactly'); line('those versions, so the release records which source went into the libvips packages.'); line(); } } line('### MPL-2.0'); line(); if (groups.mpl.length === 0) { line('No shipped component is under the MPL alone.'); line(); } else { componentTable(groups.mpl.sort(byNameAndVersion)); } const mplText = findText(/Mozilla Public License,? Version 2\.0/); line(`MPL-2.0 is a per-file copyleft; its text is ${textRef(mplText, 'MPL-2.0')}. What it asks:`); line(); line('1. MPL-covered files stay under MPL-2.0, and a modified MPL file must be published under'); line(' MPL-2.0. Waggle uses these components unmodified.'); line('2. With the executable, tell recipients where the source of the MPL-covered files is'); line(' available (section 3.2(a)). The Source column links the exact published versions; cairo'); line(' inside libvips is published by the sharp-libvips release named above.'); line('3. Keep the MPL notices intact. The executable may be distributed under other terms (MIT)'); line(' as long as they do not restrict access to that source (section 3.2(b)).'); line(); if (groups.ofl.length > 0) { line('### OFL-1.1 (fonts)'); line(); componentTable(groups.ofl.sort(byNameAndVersion)); line('The SIL Open Font License allows bundling the fonts with software. The license text and'); line('copyright notice must ship with the fonts (they are reproduced in this file), the fonts'); line('may not be sold on their own, and modified fonts may not use the reserved font names.'); line(); } if (groups.none.length > 0 || groups.other.length > 0) { line('### No license or an unrecognised license'); line(); componentTable([...groups.none, ...groups.other].sort(byNameAndVersion)); line('Without a license grant the code cannot be redistributed. These need a license from their'); line('authors or a dependency change before release.'); line(); } if (groups.dual.length > 0) { line('### Dual-licensed components used under the permissive option'); line(); line('| Component | Version | Artifact | License | Used under |'); line('|---|---|---|---|---|'); for (const row of groups.dual.sort(byNameAndVersion)) { line(`| ${cell(row.name)} | ${cell(row.version)} | ${row.artifact} | ${cell(row.declaredLicense ?? row.license)} | ${cell(permissiveChoice(row.license))} |`); } line(); } // Runtime const lockEntry = (key) => lockPackages[key] ?? {}; const braceExpansion = lockEntry('node_modules/archiver-utils/node_modules/brace-expansion'); const ipAddress = lockEntry('node_modules/ip-address'); line('## Node.js runtime and npm'); line(); line(`The desktop sidecar runs on Node.js ${nodeVersion}, which \`scripts/bundle-node.mjs\` downloads from`); line('nodejs.org and verifies against the official SHA-256 sums. It is not an npm dependency of'); line('Waggle and is not part of the npm lists below.'); line(); line('| Component | Version | License | Where its notices ship |'); line('|---|---|---|---|'); line(`| Node.js | ${nodeVersion} | MIT, plus the licenses of the libraries Node.js includes (OpenSSL, ICU, libuv, V8 and others) | Node's LICENSE file, which reproduces all of them, as \`resources/node_modules/waggle-node-runtime/NODE-LICENSE\` |`); line(`| npm | the release bundled with Node.js ${nodeVersion} | Artistic-2.0; its bundled dependencies carry their own licenses | with its LICENSE and its bundled \`node_modules\` in \`resources/node_modules/waggle-node-runtime/node_modules/npm\`; two bundled dependencies are replaced (next row) |`); line(`| brace-expansion, ip-address | ${braceExpansion.version ?? '?'}, ${ipAddress.version ?? '?'} | ${braceExpansion.license ?? '?'}, ${ipAddress.license ?? '?'} | copied from \`package-lock.json\` over npm's bundled copies by \`bundle-node.mjs\` |`); line(); // npm tables for (const artifact of artifacts) { line(`## ${artifact.title} npm packages`); line(); line(`${artifact.rows.length} packages from the production dependencies of \`${artifact.workspace}\`; they ship in ${artifact.ships}.`); line(); line('| Package | Version | License | Platforms | License texts |'); line('|---|---|---|---|---|'); for (const row of artifact.rows) { let note = textLinks(row.textNumbers); if (row.platformSpecific) note = 'platform package; ships its own files'; else if (!row.installed) note = 'not installed when generated'; else if (!note) note = 'no license file in the package'; const vendored = npmSource(row).startsWith('vendored') ? ` (${npmSource(row)}, modified)` : ''; line(`| ${cell(row.name)}${vendored} | ${cell(row.version)} | ${cell(row.license ?? 'none declared')} | ${platformLabel(row)} | ${note} |`); } line(); } // Rust line('## Rust crates'); line(); line(`${crateRows.length} crates that the desktop shell (\`app/src-tauri\`) links, following normal dependencies`); line('(build and dev dependencies do not ship).'); line(); line(`Resolved offline for: ${resolvedTargets.map((target) => TARGET_LABELS[target]).join(', ') || 'none'}.`); if (unresolvedTargets.length > 0) { line(); const labels = unresolvedTargets.map(({ target }) => TARGET_LABELS[target]); const named = labels.length > 1 ? `${labels.slice(0, -1).join(', ')} and ${labels.at(-1)}` : labels[0]; line(`**Incomplete:** the crates for ${named} were`); line('not in the local cargo cache when this file was generated, so crates used only on those'); line('platforms are missing below. Fetch them (`cargo fetch --locked --manifest-path'); line('app/src-tauri/Cargo.toml`, which needs network access) and regenerate before a release.'); } line(); const targetSets = new Set(crateRows.map((row) => [...row.targets].sort().join(','))); const showTargets = targetSets.size > 1; line(`| Crate | Version | License |${showTargets ? ' Targets |' : ''} License texts |`); line(`|---|---|---|${showTargets ? '---|' : ''}---|`); for (const row of crateRows) { const targets = showTargets ? ` ${[...row.targets].map((target) => TARGET_LABELS[target]).join(', ')} |` : ''; const note = textLinks(row.textNumbers) || 'no license file in the crate'; line(`| ${cell(row.name)} | ${cell(row.version)} | ${cell(row.declaredLicense ?? 'none declared')} |${targets} ${note} |`); } line(); // Texts line('## License texts'); line(); line('Each text appears once, followed by the components that carry it.'); line(); for (const entry of texts) { const marker = fence(entry.text); line(`### License text ${entry.number}`); line(); line(`From ${entry.source}. Carried by: ${entry.users.join(', ')}.`); line(); line(`${marker}text`); line(entry.text); line(marker); line(); } fs.writeFileSync(OUTPUT, `${out.join('\n').trimEnd()}\n`, 'utf8'); const pendingExceptions = EXCEPTIONS.filter((exception) => exception.pending).length; console.log( `[notices] Wrote ${path.relative(ROOT, OUTPUT)}: ${artifacts.map((a) => `${a.rows.length} ${a.id}`).join(', ')} npm packages, ` + `${crateRows.length} crates, ${texts.length} distinct license texts` + ` (${pendingExceptions} npm exceptions pending review)`, );