fix(release): generate licenses without mutating committed inputs

This commit is contained in:
Agent Workbench Dev
2026-11-11 03:06:59 +08:00
parent e306f40cae
commit 35a6d6d9b2
5 changed files with 46 additions and 5 deletions
+8 -5
View File
@@ -77,7 +77,10 @@ const notices = ['Agent Workbench third-party notices', '',
'Original product code is supplied for the project owner. Its redistribution terms are determined by the project owner.',
'Third-party components remain governed by their own licenses. Full available license texts are reproduced below and in licenses/.', '',
'The release does not contain Claude Code or Cursor client binaries or recovered application source.', ''];
const licenseRoot = path.join(root, 'licenses'); fs.mkdirSync(licenseRoot, { recursive: true });
// License generation belongs to the release output. Packaging must not mutate
// committed inputs after freezing sourceCommit.
const licenseRoot = path.join(portableRoot, 'licenses');
fs.cpSync(path.join(root, 'licenses'), licenseRoot, { recursive: true });
let licenseCount = 0;
for (const [location, entry] of Object.entries(lock.packages).sort(([a], [b]) => a.localeCompare(b))) {
if (!location.startsWith('node_modules/')) continue;
@@ -105,10 +108,10 @@ notices.push('='.repeat(72), 'REA (rea-agents) ' + reaRuntime.version, 'License:
fs.writeFileSync(path.join(licenseRoot, 'Node-' + nodeVersion + '-LICENSE.txt'), nodeLicenseText);
notices.push('='.repeat(72), 'Node.js ' + nodeVersion, '', nodeLicenseText);
notices.push('='.repeat(72), 'npm bundled with Node.js', 'Complete package and dependency licenses are retained under runtime/node_modules/npm/.', '', fs.readFileSync(path.join(npmRoot, 'LICENSE'), 'utf8'));
fs.writeFileSync(path.join(root, 'THIRD_PARTY_NOTICES.txt'), notices.join('\n'));
for (const output of [portableRoot, sourceRoot].filter(Boolean)) {
fs.cpSync(licenseRoot, path.join(output, 'licenses'), { recursive: true });
fs.copyFileSync(path.join(root, 'THIRD_PARTY_NOTICES.txt'), path.join(output, 'THIRD_PARTY_NOTICES.txt'));
fs.writeFileSync(path.join(portableRoot, 'THIRD_PARTY_NOTICES.txt'), notices.join('\n'));
if (sourceRoot) {
fs.cpSync(licenseRoot, path.join(sourceRoot, 'licenses'), { recursive: true });
fs.copyFileSync(path.join(portableRoot, 'THIRD_PARTY_NOTICES.txt'), path.join(sourceRoot, 'THIRD_PARTY_NOTICES.txt'));
}
function filesIn(directory, relative = '') {