CH-J Server Managergestione server su SSH
Menu
Sorgente pubblicata

CH-J Server Manager

Sfoglia directory e file per una specifica release di applicazioni.

Scarica sorgente ZIP
CH-J / Server Manager 196 file
core-20261013T133631Z-faa4ab45100e Aggiunto: Data non registrata · Costruito:
File
generateThirdPartyNotices.js Aggiunto: Data non registrata 7,2 KB · 132 righe
Scarica file
1"use strict";
3const fs = require("node:fs");
4const path = require("node:path");
5const crypto = require("node:crypto");
6const AdmZip = require("adm-zip");
8const projectRoot = path.resolve(__dirname, "..");
9const lock = JSON.parse(fs.readFileSync(path.join(projectRoot, "package-lock.json"), "utf8"));
10const outputPath = path.join(projectRoot, "THIRD_PARTY_NOTICES.txt");
11const packages = new Map();
13// Electron 43 downloads its runtime lazily. The build copies license files from
14// that runtime, so make the documented `npm ci` -> `npm run build:*` flow
15// deterministic on every supported OS without a platform-specific shell step.
16const electronExecutable = require("electron");
17if (!fs.statSync(electronExecutable, { throwIfNoEntry: false })?.isFile()) {
18 throw new Error("Electron runtime is unavailable after dependency installation.");
21function declaredLicense(value) {
22 if (typeof value === "string") return value;
23 if (Array.isArray(value)) return value.map(declaredLicense).filter(Boolean).join(" OR ");
24 if (value && typeof value === "object") return String(value.type || value.name || "See included text");
25 return "See included text";
28function readLicense(directory) {
29 const entries = fs.readdirSync(directory, { withFileTypes: true });
30 const candidates = entries
31 .filter((entry) => entry.isFile() && /^(licen[cs]e|copying|notice)(\..*)?$/i.test(entry.name))
32 .sort((left, right) => left.name.localeCompare(right.name));
33 if (candidates.length) {
34 return candidates.map((entry) => ({ source: entry.name, text: fs.readFileSync(path.join(directory, entry.name), "utf8").trim() }));
35 }
36 const readme = entries.find((entry) => entry.isFile() && /^readme(?:\..*)?$/i.test(entry.name));
37 if (readme) {
38 const text = fs.readFileSync(path.join(directory, readme.name), "utf8");
39 const match = text.match(/^#{1,3}\s+licen[cs]e\s*$[\s\S]*/im);
40 if (match) return [{ source: `${readme.name} (License section)`, text: match[0].trim() }];
41 }
42 return [];
45for (const [relative, metadata] of Object.entries(lock.packages || {})) {
46 if (!relative.startsWith("node_modules/") || metadata.dev === true) continue;
47 const directory = path.join(projectRoot, relative);
48 const packagePath = path.join(directory, "package.json");
49 if (!fs.statSync(packagePath, { throwIfNoEntry: false })?.isFile()) continue;
50 const manifest = JSON.parse(fs.readFileSync(packagePath, "utf8"));
51 const key = `${manifest.name}@${manifest.version}`;
52 if (packages.has(key)) continue;
53 const texts = readLicense(directory);
54 if (!texts.length) throw new Error(`No distributable license text found for ${key}.`);
55 packages.set(key, { key, license: declaredLicense(manifest.license || metadata.license), texts });
57const bundledTigerLicense = path.join(projectRoot, "src", "main", "hashing", "vendor", "fbTiger", "LICENSE.txt");
58packages.set("fb-tiger-hash@1.0.0 (bundled source)", {
59 key: "fb-tiger-hash@1.0.0 (bundled source)",
60 license: "MIT",
61 texts: [{ source: "src/main/hashing/vendor/fbTiger/LICENSE.txt", text: fs.readFileSync(bundledTigerLicense, "utf8").trim() }]
62});
63const bundledCityHashLicense = path.join(projectRoot, "src", "main", "hashing", "vendor", "cityHash", "LICENSE.txt");
64packages.set("google-cityhash (ported source)", {
65 key: "google-cityhash (ported source)",
66 license: "MIT",
67 texts: [{ source: "src/main/hashing/vendor/cityHash/LICENSE.txt", text: fs.readFileSync(bundledCityHashLicense, "utf8").trim() }]
68});
70const separator = "=".repeat(78);
71const sections = [...packages.values()]
72 .sort((left, right) => left.key.localeCompare(right.key))
73 .map((entry) => {
74 const body = entry.texts.map((item) => `Source: ${item.source}\n\n${item.text}`).join("\n\n");
75 return `${separator}\n${entry.key}\nDeclared license: ${entry.license}\n${separator}\n\n${body}`;
76 });
77const header = [
78 "CH-J Server Manager — Third-Party Notices",
79 "",
80 "This file lists license texts for production Node.js dependencies bundled",
81 "with the application. Electron and Chromium license files are distributed",
82 "separately in the application's resources/licenses directory.",
83 ""
84].join("\n");
85fs.writeFileSync(outputPath, `${header}\n${sections.join("\n\n")}\n`, "utf8");
87const bundleDocuments = [
88 { name: "THIRD_PARTY_NOTICES.txt", path: outputPath, description: "Production Node.js dependency licenses" },
89 { name: "ELECTRON_LICENSE.txt", path: path.join(projectRoot, "node_modules", "electron", "dist", "LICENSE"), description: "Electron license" },
90 { name: "CHROMIUM_LICENSES.html", path: path.join(projectRoot, "node_modules", "electron", "dist", "LICENSES.chromium.html"), description: "Chromium and embedded component licenses" },
91 { name: "MONACO_LICENSE.txt", path: path.join(projectRoot, "node_modules", "monaco-editor", "LICENSE"), description: "Monaco Editor license" },
92 { name: "MONACO_THIRD_PARTY_NOTICES.txt", path: path.join(projectRoot, "node_modules", "monaco-editor", "ThirdPartyNotices.txt"), description: "Monaco Editor third-party notices" },
93 { name: "GOOGLE_CITYHASH_LICENSE.txt", path: bundledCityHashLicense, description: "Ported CityHash implementation license" },
94 { name: "FB_TIGER_HASH_LICENSE.txt", path: bundledTigerLicense, description: "Bundled Tiger/Tiger2 implementation license" }
95];
96const nativeLicenseRoot = path.join(projectRoot, "scripts", "native", "licenses");
97if (fs.existsSync(nativeLicenseRoot)) {
98 for (const platform of fs.readdirSync(nativeLicenseRoot)) {
99 const dir = path.join(nativeLicenseRoot, platform);
100 for (const name of fs.readdirSync(dir)) bundleDocuments.push({ name: `native/${platform}/${name}`, path: path.join(dir, name), description: "Bundled native HTTP transport license/provenance" });
101 }
103for (const document of bundleDocuments) {
104 if (!fs.statSync(document.path, { throwIfNoEntry: false })?.isFile()) throw new Error(`Missing third-party license document: ${document.path}`);
105 document.data = fs.readFileSync(document.path);
106 document.sha512 = crypto.createHash("sha512").update(document.data).digest("hex");
108const bundleReadme = [
109 "CH-J Server Manager — Complete Third-Party License Package",
110 "",
111 "This archive contains the license texts and notices for third-party software",
112 "distributed by CH-J Server Manager Core and its bundled source components.",
113 "This application edition is licensed separately under the CH-J Proprietary Software License, version 1.14.",
114 "",
115 "Contents:",
116 ...bundleDocuments.map((document) => `- ${document.name}: ${document.description}`),
117 ""
118].join("\n");
119const checksums = bundleDocuments.map((document) => `${document.sha512} ${document.name}`).join("\n") + "\n";
120const zip = new AdmZip();
121for (const document of [
122 { name: "README.txt", data: Buffer.from(bundleReadme, "utf8") },
123 { name: "SHA512SUMS.txt", data: Buffer.from(checksums, "utf8") },
124 ...bundleDocuments
125]) {
126 zip.addFile(document.name, document.data, "", 0o644);
127 const entry = zip.getEntry(document.name);
128 if (entry) entry.header.time = new Date("2000-01-01T00:00:00Z");
130const bundlePath = path.join(projectRoot, "THIRD_PARTY_LICENSES.zip");
131zip.writeZip(bundlePath);
132console.log(`Generated ${path.basename(outputPath)} for ${sections.length} package versions and ${path.basename(bundlePath)} with ${bundleDocuments.length} complete license documents.`);
SHA-256fec2969e7825c062367818ee175dd8d11d888e6c2b311d61e35442ec3a4f92f6

CH-J Proprietary Software License 1.14 · La sorgente è fornita sotto CH-J Proprietary Software License 1.14. La sua disponibilità non modifica i termini di licenza o concede diritti aggiuntivi.

Archivio SHA-256de757268dbc4f0226549f8b4f41f9b7e585c856ee97fa0d43b17a0e95c281449