electron-version-deployer-cli 0.4.1 → 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.
- package/README.md +3 -2
- package/dist/cli.cjs +40 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -153,9 +153,10 @@ export type EVDConfigType = {
|
|
|
153
153
|
// 额外需要打包的文件夹
|
|
154
154
|
// 这将会在部署时将文件夹里面的内容,一同部署到服务器上
|
|
155
155
|
// 文件会被放在根目录的 basename 文件中,比如
|
|
156
|
-
// 传入 ['/
|
|
156
|
+
// 传入 ['public/test'] 这样一个文件夹,那么最终会被放到根目录的
|
|
157
157
|
// /test 中
|
|
158
|
-
//
|
|
158
|
+
// 注意:当个文件不能超过 25mb 这是 cloudflare 的限制
|
|
159
|
+
// 注意:必须使用相对路径,相对路径谁相对于 evd.config.ts 文件
|
|
159
160
|
extraFolders: string[] | (() => Promise<string[]>) | (() => string[]);
|
|
160
161
|
// netlify 部署设置
|
|
161
162
|
netlify?: {
|
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
|
-
|
|
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) => {
|
|
@@ -608,10 +641,10 @@ async function deployExtraFolders(configs) {
|
|
|
608
641
|
folders = extraFolders;
|
|
609
642
|
}
|
|
610
643
|
for (const folder of folders) {
|
|
611
|
-
if (!node_fs.existsSync(folder)) {
|
|
644
|
+
if (!node_fs.existsSync(r(folder))) {
|
|
612
645
|
throw new Error(`未找到文件夹 ${folder}`);
|
|
613
646
|
}
|
|
614
|
-
const stat = node_fs.statSync(folder);
|
|
647
|
+
const stat = node_fs.statSync(r(folder));
|
|
615
648
|
if (!stat.isDirectory()) {
|
|
616
649
|
throw new Error(`${folder} 不是一个文件夹`);
|
|
617
650
|
}
|
|
@@ -619,7 +652,7 @@ async function deployExtraFolders(configs) {
|
|
|
619
652
|
if (node_fs.existsSync(destFolder)) {
|
|
620
653
|
node_fs.rmSync(destFolder, { recursive: true });
|
|
621
654
|
}
|
|
622
|
-
node_fs.cpSync(folder, r(`node_modules/.evd/${node_path.basename(folder)}`), {
|
|
655
|
+
node_fs.cpSync(r(folder), r(`node_modules/.evd/${node_path.basename(folder)}`), {
|
|
623
656
|
recursive: true
|
|
624
657
|
});
|
|
625
658
|
}
|
|
@@ -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.
|
|
762
|
+
).helpOption("-h, --help", "使用帮助").version("0.4.4", "-V, --version", "显示版本号").parse(process.argv);
|