filecat 5.23.2 → 5.23.3
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 +1 -1
- package/build/dist/{523.e773ebf3ccfcf3d84c73.js → 523.f4a220b54c0c5c4c6202.js} +2 -2
- package/build/dist/{943.6360059826b561a14949.js → 943.3092a7e42ef0b65f31e1.js} +2 -2
- package/build/dist/index.html +1 -1
- package/build/dist/{main.b2c4cedb05c5a34a2565.js → main.59b54e721f7588304840.js} +2 -2
- package/build/main.js +1 -1
- package/build/threads.work.filecat.js +1 -1
- package/package.json +1 -1
- package/shell/build.js +12 -7
- package/shell/pkg.ts +2 -1
- package/shell/start/windows-install.js +58 -11
- package/shell/start/windows-uninstall.js +44 -5
- package/shell/util/file.js +46 -0
- package/shell/config/webpack.worker.get.js +0 -42
- /package/build/dist/{523.e773ebf3ccfcf3d84c73.js.LICENSE.txt → 523.f4a220b54c0c5c4c6202.js.LICENSE.txt} +0 -0
- /package/build/dist/{943.6360059826b561a14949.js.LICENSE.txt → 943.3092a7e42ef0b65f31e1.js.LICENSE.txt} +0 -0
- /package/build/dist/{main.b2c4cedb05c5a34a2565.js.LICENSE.txt → main.59b54e721f7588304840.js.LICENSE.txt} +0 -0
package/package.json
CHANGED
package/shell/build.js
CHANGED
|
@@ -8,7 +8,9 @@ const is_exe = args[0]==="exe"
|
|
|
8
8
|
const is_npm = args[0]==="npm"
|
|
9
9
|
if (args.length ===0 || is_npm) {
|
|
10
10
|
serverConfig = require('./config/webpack.npm.config.js');
|
|
11
|
+
console.log('npm打包')
|
|
11
12
|
} else if (is_exe) {
|
|
13
|
+
console.log('二进制打包')
|
|
12
14
|
serverConfig = require('./config/webpack.exe.config.js');
|
|
13
15
|
} else {
|
|
14
16
|
console.error('无法识别打包环境')
|
|
@@ -18,9 +20,12 @@ const fs = require("fs");
|
|
|
18
20
|
const path = require("path");
|
|
19
21
|
const {rimraf} = require("rimraf");
|
|
20
22
|
const fse = require("fs-extra");
|
|
21
|
-
const {get_webpack_work_config} = require('./config/webpack.worker.get.js');
|
|
22
23
|
const {copy_wintun_dll} = require("./config/common-bin.config");
|
|
23
24
|
|
|
25
|
+
// const test_p = path.join(process.cwd(), "node_modules","node-process-watcher");
|
|
26
|
+
// const test_p2 = path.join(process.cwd(), "node_modules","better-sqlite3");
|
|
27
|
+
// console.log(`存在node-process-watcher ${fs.existsSync(test_p)}`);
|
|
28
|
+
// console.log(`存在better-sqlite3 ${fs.existsSync(test_p2)}`);
|
|
24
29
|
|
|
25
30
|
function ensure_copyFileSync(sourcePath, destPath) {
|
|
26
31
|
fse.ensureDirSync(path.dirname(destPath))
|
|
@@ -54,12 +59,12 @@ const tasksLister = new Listr(
|
|
|
54
59
|
title:"子线程构建",
|
|
55
60
|
task:async ()=>{
|
|
56
61
|
return Promise.all([new Promise((res, rej) => {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
const config = {...serverConfig};
|
|
63
|
+
config['entry'] = path.join(__dirname, "..", "build", "server", "main","threads","filecat","threads.work.filecat.js")
|
|
64
|
+
config['output'] = {...config['output']}
|
|
65
|
+
config['output']['filename'] = 'threads.work.filecat.js'
|
|
66
|
+
// 第一个
|
|
67
|
+
webpack(config, (err, stats) => {
|
|
63
68
|
if (err || stats.hasErrors()) {
|
|
64
69
|
console.error(err || stats.toString());
|
|
65
70
|
rej(false);
|
package/shell/pkg.ts
CHANGED
|
@@ -4,6 +4,7 @@ import {FileService} from "../src/main/domain/file/file.service";
|
|
|
4
4
|
|
|
5
5
|
const fs = require('fs');
|
|
6
6
|
const path = require('path');
|
|
7
|
+
const {copy_auto} = require('./util/file');
|
|
7
8
|
|
|
8
9
|
// 复制 node
|
|
9
10
|
fs.copyFileSync(process.execPath, path.join(__dirname, "..", "build", path.basename(process.execPath)));
|
|
@@ -17,7 +18,7 @@ if(args[0].includes("win")) {
|
|
|
17
18
|
fs.copyFileSync(path.join(__dirname,"start","filecat-uninstall.cmd"), path.join(__dirname, "..", "build", "filecat-uninstall.cmd"));
|
|
18
19
|
fs.copyFileSync(path.join(__dirname,"start","windows-install.js"), path.join(__dirname, "..", "build", "windows-install.js"));
|
|
19
20
|
fs.copyFileSync(path.join(__dirname,"start","windows-uninstall.js"), path.join(__dirname, "..", "build", "windows-uninstall.js"));
|
|
20
|
-
|
|
21
|
+
copy_auto(path.join(process.cwd(),"node_modules","windows-shortcuts"), path.join(__dirname, "..", "build", "node_modules","windows-shortcuts"))
|
|
21
22
|
} else {
|
|
22
23
|
fs.copyFileSync(path.join(__dirname,"start","filecat-run.sh"), path.join(__dirname, "..", "build", "filecat-run.sh"));
|
|
23
24
|
}
|
|
@@ -3,15 +3,13 @@ const path = require("path");
|
|
|
3
3
|
const fs = require("fs");
|
|
4
4
|
const readline = require("readline");
|
|
5
5
|
|
|
6
|
-
//
|
|
7
|
-
// const currentDir = process.cwd();
|
|
6
|
+
// 当前脚本目录
|
|
8
7
|
const currentDir = __dirname;
|
|
9
8
|
|
|
10
|
-
|
|
11
9
|
// 默认安装目录
|
|
12
|
-
const defaultInstallDir = "C:\\
|
|
10
|
+
const defaultInstallDir = "C:\\Filecat";
|
|
13
11
|
|
|
14
|
-
//
|
|
12
|
+
// 启动脚本
|
|
15
13
|
const CMD_NAME = "filecat-run.cmd";
|
|
16
14
|
|
|
17
15
|
// 开始菜单目录
|
|
@@ -24,6 +22,16 @@ const startMenuDir = path.join(
|
|
|
24
22
|
"Filecat"
|
|
25
23
|
);
|
|
26
24
|
|
|
25
|
+
// 当前用户开机启动目录
|
|
26
|
+
const startupDir = path.join(
|
|
27
|
+
process.env.APPDATA,
|
|
28
|
+
"Microsoft",
|
|
29
|
+
"Windows",
|
|
30
|
+
"Start Menu",
|
|
31
|
+
"Programs",
|
|
32
|
+
"Startup"
|
|
33
|
+
);
|
|
34
|
+
|
|
27
35
|
// =====================
|
|
28
36
|
// 递归复制目录
|
|
29
37
|
// =====================
|
|
@@ -47,9 +55,9 @@ function copyDir(src, dest) {
|
|
|
47
55
|
}
|
|
48
56
|
|
|
49
57
|
// =====================
|
|
50
|
-
//
|
|
58
|
+
// 创建开始菜单快捷方式
|
|
51
59
|
// =====================
|
|
52
|
-
function
|
|
60
|
+
function createStartMenuShortcut(installDir) {
|
|
53
61
|
const cmdPath = path.join(installDir, CMD_NAME);
|
|
54
62
|
const shortcutPath = path.join(startMenuDir, "Filecat.lnk");
|
|
55
63
|
|
|
@@ -61,22 +69,42 @@ function createShortcut(installDir) {
|
|
|
61
69
|
desc: "Filecat 启动程序"
|
|
62
70
|
}, (err) => {
|
|
63
71
|
if (err) {
|
|
64
|
-
console.error("
|
|
72
|
+
console.error("创建开始菜单快捷方式失败:", err);
|
|
65
73
|
} else {
|
|
66
74
|
console.log("开始菜单快捷方式创建成功!");
|
|
67
75
|
}
|
|
68
76
|
});
|
|
69
77
|
}
|
|
70
78
|
|
|
79
|
+
// =====================
|
|
80
|
+
// 创建开机启动快捷方式
|
|
81
|
+
// =====================
|
|
82
|
+
function createStartupShortcut(installDir) {
|
|
83
|
+
const cmdPath = path.join(installDir, CMD_NAME);
|
|
84
|
+
const shortcutPath = path.join(startupDir, "Filecat.lnk");
|
|
85
|
+
|
|
86
|
+
ws.create(shortcutPath, {
|
|
87
|
+
target: cmdPath,
|
|
88
|
+
workingDir: installDir,
|
|
89
|
+
desc: "Filecat 开机自启"
|
|
90
|
+
}, (err) => {
|
|
91
|
+
if (err) {
|
|
92
|
+
console.error("创建开机自启失败:", err);
|
|
93
|
+
} else {
|
|
94
|
+
console.log("已加入当前用户开机自启!");
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
71
99
|
// =====================
|
|
72
100
|
// 安装主流程
|
|
73
101
|
// =====================
|
|
74
|
-
function install(installDir) {
|
|
102
|
+
function install(installDir, askStartup = true) {
|
|
75
103
|
|
|
76
104
|
const cmdSrc = path.join(currentDir, CMD_NAME);
|
|
77
105
|
|
|
78
106
|
if (!fs.existsSync(cmdSrc)) {
|
|
79
|
-
console.error("找不到 filecat-
|
|
107
|
+
console.error("找不到 filecat-run.cmd");
|
|
80
108
|
return;
|
|
81
109
|
}
|
|
82
110
|
|
|
@@ -87,11 +115,30 @@ function install(installDir) {
|
|
|
87
115
|
|
|
88
116
|
console.log("文件复制完成");
|
|
89
117
|
|
|
90
|
-
|
|
118
|
+
createStartMenuShortcut(installDir);
|
|
91
119
|
|
|
92
120
|
console.log("安装成功!");
|
|
93
121
|
console.log("Win 键搜索 Filecat 即可启动");
|
|
94
122
|
|
|
123
|
+
// ===== 询问是否开机自启 =====
|
|
124
|
+
if (askStartup) {
|
|
125
|
+
const rl2 = readline.createInterface({
|
|
126
|
+
input: process.stdin,
|
|
127
|
+
output: process.stdout
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
rl2.question("是否加入当前用户开机自启?(y/n): ", (answer) => {
|
|
131
|
+
|
|
132
|
+
if (answer.toLowerCase() === "y") {
|
|
133
|
+
createStartupShortcut(installDir);
|
|
134
|
+
} else {
|
|
135
|
+
console.log("未启用开机自启");
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
rl2.close();
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
95
142
|
} catch (e) {
|
|
96
143
|
console.error("安装失败:", e.message);
|
|
97
144
|
}
|
|
@@ -2,7 +2,9 @@ const ws = require("windows-shortcuts");
|
|
|
2
2
|
const path = require("path");
|
|
3
3
|
const fs = require("fs");
|
|
4
4
|
|
|
5
|
-
//
|
|
5
|
+
// =====================
|
|
6
|
+
// 开始菜单快捷方式
|
|
7
|
+
// =====================
|
|
6
8
|
const shortcutPath = path.join(
|
|
7
9
|
process.env.APPDATA,
|
|
8
10
|
"Microsoft",
|
|
@@ -13,6 +15,22 @@ const shortcutPath = path.join(
|
|
|
13
15
|
"Filecat.lnk"
|
|
14
16
|
);
|
|
15
17
|
|
|
18
|
+
// =====================
|
|
19
|
+
// 开机自启快捷方式
|
|
20
|
+
// =====================
|
|
21
|
+
const startupShortcutPath = path.join(
|
|
22
|
+
process.env.APPDATA,
|
|
23
|
+
"Microsoft",
|
|
24
|
+
"Windows",
|
|
25
|
+
"Start Menu",
|
|
26
|
+
"Programs",
|
|
27
|
+
"Startup",
|
|
28
|
+
"Filecat.lnk"
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
// =====================
|
|
32
|
+
// 安全删除目录
|
|
33
|
+
// =====================
|
|
16
34
|
function removeDirSafe(dir) {
|
|
17
35
|
if (fs.existsSync(dir)) {
|
|
18
36
|
fs.rmSync(dir, { recursive: true, force: true });
|
|
@@ -20,6 +38,9 @@ function removeDirSafe(dir) {
|
|
|
20
38
|
}
|
|
21
39
|
}
|
|
22
40
|
|
|
41
|
+
// =====================
|
|
42
|
+
// 安全删除文件
|
|
43
|
+
// =====================
|
|
23
44
|
function removeFileSafe(file) {
|
|
24
45
|
if (fs.existsSync(file)) {
|
|
25
46
|
fs.rmSync(file, { force: true });
|
|
@@ -27,14 +48,29 @@ function removeFileSafe(file) {
|
|
|
27
48
|
}
|
|
28
49
|
}
|
|
29
50
|
|
|
51
|
+
// =====================
|
|
52
|
+
// 删除开机自启
|
|
53
|
+
// =====================
|
|
54
|
+
function removeStartupShortcut() {
|
|
55
|
+
if (fs.existsSync(startupShortcutPath)) {
|
|
56
|
+
removeFileSafe(startupShortcutPath);
|
|
57
|
+
console.log("已移除开机自启");
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
30
61
|
// =====================
|
|
31
62
|
// 主逻辑
|
|
32
63
|
// =====================
|
|
33
64
|
if (!fs.existsSync(shortcutPath)) {
|
|
34
|
-
console.log("
|
|
65
|
+
console.log("找不到开始菜单快捷方式,尝试仅删除开机自启...");
|
|
66
|
+
|
|
67
|
+
removeStartupShortcut();
|
|
68
|
+
|
|
69
|
+
console.log("卸载完成(仅移除自启)");
|
|
35
70
|
process.exit(0);
|
|
36
71
|
}
|
|
37
72
|
|
|
73
|
+
// 读取快捷方式
|
|
38
74
|
ws.query(shortcutPath, (err, options) => {
|
|
39
75
|
|
|
40
76
|
if (err) {
|
|
@@ -47,10 +83,10 @@ ws.query(shortcutPath, (err, options) => {
|
|
|
47
83
|
process.exit(1);
|
|
48
84
|
}
|
|
49
85
|
|
|
50
|
-
//
|
|
86
|
+
// 获取真实文件路径
|
|
51
87
|
const targetFile = options.target;
|
|
52
88
|
|
|
53
|
-
//
|
|
89
|
+
// 获取安装目录
|
|
54
90
|
const installDir = path.dirname(targetFile);
|
|
55
91
|
|
|
56
92
|
console.log("检测到安装目录:", installDir);
|
|
@@ -60,12 +96,15 @@ ws.query(shortcutPath, (err, options) => {
|
|
|
60
96
|
// 删除安装目录
|
|
61
97
|
removeDirSafe(installDir);
|
|
62
98
|
|
|
63
|
-
//
|
|
99
|
+
// 删除开始菜单快捷方式
|
|
64
100
|
removeFileSafe(shortcutPath);
|
|
65
101
|
|
|
66
102
|
// 删除开始菜单文件夹
|
|
67
103
|
removeDirSafe(path.dirname(shortcutPath));
|
|
68
104
|
|
|
105
|
+
// 删除开机自启
|
|
106
|
+
removeStartupShortcut();
|
|
107
|
+
|
|
69
108
|
console.log("卸载完成");
|
|
70
109
|
|
|
71
110
|
} catch (e) {
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const fse = require("fs-extra");
|
|
2
|
+
const fs = require("fs");
|
|
3
|
+
const path = require("path");
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 自动复制文件或目录
|
|
7
|
+
* @param {string} src 源路径
|
|
8
|
+
* @param {string} dest 目标路径
|
|
9
|
+
*/
|
|
10
|
+
function copy_auto(src, dest) {
|
|
11
|
+
|
|
12
|
+
if (!fs.existsSync(src)) {
|
|
13
|
+
throw new Error(`源路径不存在: ${src}`);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const stat = fs.statSync(src);
|
|
17
|
+
|
|
18
|
+
// ===== 如果是文件 =====
|
|
19
|
+
if (stat.isFile()) {
|
|
20
|
+
|
|
21
|
+
// 确保目标目录存在
|
|
22
|
+
fse.ensureDirSync(path.dirname(dest));
|
|
23
|
+
|
|
24
|
+
fs.copyFileSync(src, dest);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// ===== 如果是目录 =====
|
|
29
|
+
if (stat.isDirectory()) {
|
|
30
|
+
|
|
31
|
+
fse.copySync(src, dest, {
|
|
32
|
+
overwrite: true,
|
|
33
|
+
recursive: true,
|
|
34
|
+
errorOnExist: false
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
throw new Error("未知文件类型");
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
module.exports.copy_auto = copy_auto;
|
|
44
|
+
|
|
45
|
+
// copy_auto(path.join(process.cwd(),"node_modules","windows-shortcuts"), path.join(process.cwd(),"build","windows-shortcuts"))
|
|
46
|
+
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
const path = require("path");
|
|
2
|
-
const package_data = require("../../package.json")
|
|
3
|
-
const webpack = require('webpack');
|
|
4
|
-
const TerserPlugin = require("terser-webpack-plugin");
|
|
5
|
-
const {base_url} = require("./env");
|
|
6
|
-
const {plugins, pkg_externals, npm_externals, _node_rules} = require("./base.webpack.config");
|
|
7
|
-
|
|
8
|
-
function get_webpack_work_config({entry_path,output_name,is_exe}) {
|
|
9
|
-
const config = {
|
|
10
|
-
target: 'node', // 指定打包结果运行在node环境下
|
|
11
|
-
mode: 'production', // 或者 'production'
|
|
12
|
-
entry: entry_path, // 你的TypeScript入口文件路径
|
|
13
|
-
output: {
|
|
14
|
-
path: path.resolve(__dirname, "..",'..', "build"), // 输出目录
|
|
15
|
-
filename: output_name, // 输出文件名
|
|
16
|
-
},
|
|
17
|
-
resolve: {
|
|
18
|
-
extensions: ['.ts', '.js', '.node'] // 解析文件时自动补全的文件扩展名
|
|
19
|
-
},
|
|
20
|
-
externalsPresets: { node: true },
|
|
21
|
-
optimization: {
|
|
22
|
-
minimize: true, // 压缩Js代码
|
|
23
|
-
minimizer: [
|
|
24
|
-
new TerserPlugin({
|
|
25
|
-
// extractComments: true,//不将注释提取到单独的文件中
|
|
26
|
-
}),
|
|
27
|
-
],
|
|
28
|
-
},
|
|
29
|
-
plugins,
|
|
30
|
-
externals: npm_externals
|
|
31
|
-
}
|
|
32
|
-
if(is_exe) {
|
|
33
|
-
// 整体打包需要二进制也进去
|
|
34
|
-
config['module'] = {
|
|
35
|
-
rules: _node_rules
|
|
36
|
-
}
|
|
37
|
-
config['externals'] = pkg_externals;
|
|
38
|
-
}
|
|
39
|
-
return config;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
module.exports.get_webpack_work_config = get_webpack_work_config;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|