electron-version-deployer-cli 0.4.3 → 0.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/cli.cjs +37 -4
  2. package/package.json +1 -1
package/dist/cli.cjs CHANGED
@@ -19,11 +19,12 @@ const marked = require("marked");
19
19
  const jsdom = require("jsdom");
20
20
  const DOMPurify = require("dompurify");
21
21
  const archiver = require("archiver");
22
+ const fs = require("fs");
23
+ const path = require("path");
24
+ const os = require("os");
22
25
  const prompts = require("@inquirer/prompts");
23
26
  const electron = require("electron");
24
27
  const node_os = require("node:os");
25
- const fs = require("fs");
26
- const path = require("path");
27
28
  const download = require("download");
28
29
  const pkgPath = pkgUp.sync();
29
30
  function r(...paths) {
@@ -172,6 +173,32 @@ function archiveFiles(outputPath, files) {
172
173
  archive.finalize();
173
174
  });
174
175
  }
176
+ function countLineEndings(text) {
177
+ const crlf = (text.match(/\r\n/g) || []).length;
178
+ const noCRLF = text.replace(/\r\n/g, "");
179
+ const lf = (noCRLF.match(/\n/g) || []).length;
180
+ const cr = (noCRLF.match(/\r/g) || []).length;
181
+ return { crlf, lf, cr };
182
+ }
183
+ function normalizeToOSEOL(text, opts = {}) {
184
+ const { stripBOM = true, ensureFinalNewline = false } = opts;
185
+ if (stripBOM && text.charCodeAt(0) === 65279) {
186
+ text = text.slice(1);
187
+ }
188
+ const target = os.EOL;
189
+ const before = text;
190
+ let normalized = text.replace(/\r\n|\r|\n/g, target);
191
+ if (ensureFinalNewline && normalized.length > 0 && !normalized.endsWith(target)) {
192
+ normalized += target;
193
+ }
194
+ const changed = normalized !== before;
195
+ return {
196
+ text: normalized,
197
+ changed,
198
+ stats: countLineEndings(before),
199
+ target: target === "\r\n" ? "crlf" : target === "\r" ? "cr" : "lf"
200
+ };
201
+ }
175
202
  commander.program.command("prepare").description(
176
203
  "部署前的准备工作,如获取编译软件获取逻辑代码,生成 changelog 等"
177
204
  ).action(async (source, destination) => {
@@ -256,8 +283,14 @@ async function genChangelog(configs) {
256
283
  }
257
284
  const pkgContent = JSON.parse(node_fs.readFileSync(outputPackageJSONPath, "utf-8"));
258
285
  const currentVersion = pkgContent.version;
286
+ const changelogText = node_fs.readFileSync(r(configs.changelogsPath), "utf-8");
259
287
  const changes = await parseChangelog({
260
- filePath: r(configs.changelogsPath),
288
+ // 将 changelog 文件转换为 os.EOL
289
+ // https://github.com/ungoldman/changelog-parser/issues/34
290
+ text: normalizeToOSEOL(changelogText, {
291
+ stripBOM: true,
292
+ ensureFinalNewline: true
293
+ }).text,
261
294
  removeMarkdown: false
262
295
  });
263
296
  const currentChange = changes.versions.find((change) => {
@@ -726,4 +759,4 @@ async function installPrebuilt(configs) {
726
759
  }
727
760
  commander.program.description(
728
761
  "Electron 版本部署 CLI,简化你的 Electron 软件更新,让一切变得简单。"
729
- ).helpOption("-h, --help", "使用帮助").version("0.4.3", "-V, --version", "显示版本号").parse(process.argv);
762
+ ).helpOption("-h, --help", "使用帮助").version("0.4.4", "-V, --version", "显示版本号").parse(process.argv);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "electron-version-deployer-cli",
3
3
  "private": false,
4
- "version": "0.4.3",
4
+ "version": "0.4.4",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.cjs.js",
7
7
  "module": "./dist/index.es.js",