TagSpaces is an offline, open source, document manager with tagging support
fix: showing the license in nsis
Ilian Sapundshievf6c4505ec1f3
diff --git a/.gitignore b/.gitignoreindex bb58acf52..cfd3265d4 100644--- a/.gitignore+++ b/.gitignore@@ -84,10 +84,6 @@ web/third-party.txtweb/sw-config.jsweb/EULA.txt-# Generated by scripts/build-licenses.js on every prebuild-assets/license_en.rtf-tagspacespro/EULA.rtf-.envsrc/.envsrc/main/configdiff --git a/assets/license_en.txt b/assets/license_en.txtindex 177328168..dba13ed2d 100644--- a/assets/license_en.txt+++ b/assets/license_en.txt@@ -1,4 +1,4 @@- GNU AFFERO GENERAL PUBLIC LICENSE+ GNU AFFERO GENERAL PUBLIC LICENSEVersion 3, 19 November 2007Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>diff --git a/resources/builder.json b/resources/builder.jsonindex 6b94a3b38..86d3771f5 100644--- a/resources/builder.json+++ b/resources/builder.json@@ -61,7 +61,7 @@"oneClick": false,"allowToChangeInstallationDirectory": true,"include": "resources/installer.nsh",- "license": "assets/license_en.rtf"+ "license": "assets/license_en.txt"},"mac": {"target": ["pkg", "dmg"],diff --git a/scripts/build-licenses.js b/scripts/build-licenses.jsindex 747e878e0..7ba27e55c 100644--- a/scripts/build-licenses.js+++ b/scripts/build-licenses.js@@ -1,64 +1,58 @@-/* Regenerate .rtf license files from the .txt sources.+/* Normalize .txt license files for cross-installer compatibility.*- * Why: NSIS (Windows installer) truncates UTF-8-with-BOM .txt files and- * can't handle very long lines. RTF sidesteps both. macOS pkg also- * renders RTF natively. Runs as part of `prebuild` so every packaging- * run picks up the latest source text.+ * Why: electron-builder's NSIS target auto-picks `assets/license*.{txt,rtf}`+ * from buildResources and feeds it to Windows RichEdit, which truncates+ * UTF-8-with-BOM files and prefers CRLF line endings. We rewrite the source+ * .txt files in place (BOM stripped, CRLF line endings, lines >120 chars+ * soft-wrapped) so the auto-detected NSIS license renders fully. macOS pkg+ * and the AppImage license viewer are happy with the same normalized .txt.+ * Runs from `prebuild`, so every packaging run produces clean output.*/const fs = require('fs');const path = require('path');const root = path.resolve(__dirname, '..');-const jobs = [- { src: 'assets/license_en.txt', dst: 'assets/license_en.rtf' },- { src: 'tagspacespro/EULA.txt', dst: 'tagspacespro/EULA.rtf' },-];+const sources = ['assets/license_en.txt', 'tagspacespro/EULA.txt'];-function escapeRtfLine(line) {- let out = '';- for (let i = 0; i < line.length; i++) {- const ch = line[i];- const code = line.charCodeAt(i);- if (ch === '\\') out += '\\\\';- else if (ch === '{') out += '\\{';- else if (ch === '}') out += '\\}';- else if (ch === '\t') out += '\\tab ';- else if (code > 127) {- // NSIS ships older RichEdit; \'xx for Windows-1252 chars is safer than \uN?.- // Everything outside Latin-1 becomes "?" — license files are almost always ASCII anyway.- if (code <= 0xff) out += "\\'" + code.toString(16).padStart(2, '0');- else out += '?';- } else out += ch;+const MAX_LINE = 120;++function softWrap(line) {+ if (line.length <= MAX_LINE) return [line];+ const out = [];+ let rest = line;+ while (rest.length > MAX_LINE) {+ let cut = rest.lastIndexOf(' ', MAX_LINE);+ if (cut <= 0) cut = MAX_LINE;+ out.push(rest.slice(0, cut));+ rest = rest.slice(cut + (rest[cut] === ' ' ? 1 : 0));}+ if (rest.length) out.push(rest);return out;}-function txtToRtf(text) {+function normalize(text) {if (text.charCodeAt(0) === 0xfeff) text = text.slice(1);text = text.replace(/\r\n/g, '\n').replace(/\r/g, '\n');- const lines = text.split('\n');- const body = lines.map((l) => escapeRtfLine(l) + '\\par').join('\n');- return (- '{\\rtf1\\ansi\\ansicpg1252\\deff0\n' +- '{\\fonttbl{\\f0\\fswiss\\fcharset0 Arial;}}\n' +- '\\pard\\f0\\fs20\n' +- body +- '\n}\n'- );+ return text.split('\n').flatMap(softWrap).join('\r\n');}-let generated = 0;-for (const job of jobs) {- const src = path.join(root, job.src);- const dst = path.join(root, job.dst);- if (!fs.existsSync(src)) {- console.log(`[build-licenses] skipping (missing source): ${job.src}`);+let processed = 0;+for (const rel of sources) {+ const abs = path.join(root, rel);+ if (!fs.existsSync(abs)) {+ console.log(`[build-licenses] skipping (missing): ${rel}`);continue;}- fs.writeFileSync(dst, txtToRtf(fs.readFileSync(src, 'utf8')), 'utf8');- console.log(`[build-licenses] ${job.src} -> ${job.dst}`);- generated++;+ const raw = fs.readFileSync(abs, 'utf8');+ const normalized = normalize(raw);+ if (normalized !== raw) {+ fs.writeFileSync(abs, normalized, 'utf8');+ console.log(`[build-licenses] normalized: ${rel}`);+ } else {+ console.log(`[build-licenses] already clean: ${rel}`);+ }+ processed++;}-if (generated === 0) console.log('[build-licenses] no licenses generated');+if (processed === 0) console.log('[build-licenses] no sources processed');