@itera-web/cli 1.1.54
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 +56 -0
- package/bin/index.js +18 -0
- package/dist/commands/app/app-obs.d.ts +14 -0
- package/dist/commands/app/app-obs.js +243 -0
- package/dist/commands/app/up.d.ts +11 -0
- package/dist/commands/app/up.js +103 -0
- package/dist/commands/web/buildapp.d.ts +10 -0
- package/dist/commands/web/buildapp.js +106 -0
- package/dist/commands/web/git.d.ts +3 -0
- package/dist/commands/web/git.js +57 -0
- package/dist/commands/web/init.d.ts +4 -0
- package/dist/commands/web/init.js +129 -0
- package/dist/commands/web/packageapp.d.ts +5 -0
- package/dist/commands/web/packageapp.js +98 -0
- package/dist/commands/web/publish.d.ts +10 -0
- package/dist/commands/web/publish.js +104 -0
- package/dist/commands/web/pullprojects.d.ts +5 -0
- package/dist/commands/web/pullprojects.js +108 -0
- package/dist/commands/web/startapp.d.ts +5 -0
- package/dist/commands/web/startapp.js +98 -0
- package/dist/commands/web/updateprojects.d.ts +17 -0
- package/dist/commands/web/updateprojects.js +220 -0
- package/dist/config/util.d.ts +14 -0
- package/dist/config/util.js +88 -0
- package/dist/config/webpack.buildpackage.d.ts +1 -0
- package/dist/config/webpack.buildpackage.js +63 -0
- package/dist/config/webpack.common.d.ts +1 -0
- package/dist/config/webpack.common.js +178 -0
- package/dist/config/webpack.dev.d.ts +1 -0
- package/dist/config/webpack.dev.js +27 -0
- package/dist/config/webpack.pro.d.ts +1 -0
- package/dist/config/webpack.pro.js +43 -0
- package/dist/plugins/app.exe +0 -0
- package/dist/plugins/sortSrciptTag.d.ts +1 -0
- package/dist/plugins/sortSrciptTag.js +75 -0
- package/dist/plugins/webSocketServer.d.ts +4 -0
- package/dist/plugins/webSocketServer.js +53 -0
- package/dist/public/git.d.ts +1 -0
- package/dist/public/git.js +375 -0
- package/dist/public/hook.d.ts +18 -0
- package/dist/public/hook.js +93 -0
- package/dist/public/log.d.ts +8 -0
- package/dist/public/log.js +58 -0
- package/dist/public/public.d.ts +19 -0
- package/dist/public/public.js +425 -0
- package/dist/public/sign.d.ts +2 -0
- package/dist/public/sign.js +148 -0
- package/dist/public/smartMerge.d.ts +3 -0
- package/dist/public/smartMerge.js +31 -0
- package/dist/public/update-version.d.ts +2 -0
- package/dist/public/update-version.js +130 -0
- package/dist/public/upload-obs.d.ts +1 -0
- package/dist/public/upload-obs.js +242 -0
- package/dist/public/upload-web.d.ts +1 -0
- package/dist/public/upload-web.js +154 -0
- package/dist/store/index.d.ts +2 -0
- package/dist/store/index.js +65 -0
- package/dist/store/types.d.ts +53 -0
- package/dist/store/types.js +2 -0
- package/package.json +110 -0
- package/tsconfig.json +30 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Console = void 0;
|
|
7
|
+
var chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
var moment_1 = __importDefault(require("moment"));
|
|
9
|
+
exports.Console = {
|
|
10
|
+
log: function () {
|
|
11
|
+
var args = [];
|
|
12
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
13
|
+
args[_i] = arguments[_i];
|
|
14
|
+
}
|
|
15
|
+
var params = chalk_1.default.whiteBright(args.join(' '));
|
|
16
|
+
console.log("".concat((0, moment_1.default)().format('HH:mm:ss'), " | ").concat(params));
|
|
17
|
+
},
|
|
18
|
+
warn: function () {
|
|
19
|
+
var args = [];
|
|
20
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
21
|
+
args[_i] = arguments[_i];
|
|
22
|
+
}
|
|
23
|
+
var params = chalk_1.default.yellowBright(args.join(' '));
|
|
24
|
+
console.log("".concat((0, moment_1.default)().format('HH:mm:ss'), " | ").concat(params));
|
|
25
|
+
},
|
|
26
|
+
cyan: function () {
|
|
27
|
+
var args = [];
|
|
28
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
29
|
+
args[_i] = arguments[_i];
|
|
30
|
+
}
|
|
31
|
+
var params = chalk_1.default.cyanBright(args.join(' '));
|
|
32
|
+
console.log("".concat((0, moment_1.default)().format('HH:mm:ss'), " | ").concat(params));
|
|
33
|
+
},
|
|
34
|
+
success: function () {
|
|
35
|
+
var args = [];
|
|
36
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
37
|
+
args[_i] = arguments[_i];
|
|
38
|
+
}
|
|
39
|
+
var params = chalk_1.default.greenBright(args.join(' '));
|
|
40
|
+
console.log("".concat((0, moment_1.default)().format('HH:mm:ss'), " | ").concat(params));
|
|
41
|
+
},
|
|
42
|
+
error: function () {
|
|
43
|
+
var args = [];
|
|
44
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
45
|
+
args[_i] = arguments[_i];
|
|
46
|
+
}
|
|
47
|
+
var params = chalk_1.default.redBright(args.join(' '));
|
|
48
|
+
console.log("".concat((0, moment_1.default)().format('HH:mm:ss'), " | ").concat(params));
|
|
49
|
+
},
|
|
50
|
+
info: function () {
|
|
51
|
+
var args = [];
|
|
52
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
53
|
+
args[_i] = arguments[_i];
|
|
54
|
+
}
|
|
55
|
+
var params = chalk_1.default.magentaBright(args.join(' '));
|
|
56
|
+
console.log("".concat((0, moment_1.default)().format('HH:mm:ss'), " | ").concat(params));
|
|
57
|
+
},
|
|
58
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Hook } from '../public/hook';
|
|
2
|
+
interface AppObsArgs {
|
|
3
|
+
autoupdate?: boolean;
|
|
4
|
+
web?: boolean;
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
}
|
|
7
|
+
export declare function zipMainJS(coreAppPath: string): boolean;
|
|
8
|
+
export declare function onSetLatest(isRemote: boolean): void;
|
|
9
|
+
export declare function onUpdateZip(destPatchZipFile: string, destPatchFile: string): Promise<boolean>;
|
|
10
|
+
export declare function onKillProcess(processNameList?: string[], callback?: (success?: boolean) => void): void;
|
|
11
|
+
export declare function fsUnLinkSync(list?: string[]): void;
|
|
12
|
+
export declare function ensurePathsExist(paths: Record<string, string>, options?: {
|
|
13
|
+
create: boolean;
|
|
14
|
+
}): void;
|
|
15
|
+
export declare function onSetElectronDir(argv: AppObsArgs): Promise<void>;
|
|
16
|
+
export declare function onSeePackage(item: any, sign: boolean): Promise<void>;
|
|
17
|
+
export declare function onCheckIteraCliVersion(): Promise<void>;
|
|
18
|
+
export declare function loadUserConfig(hook: Hook): Promise<void>;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
24
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
+
};
|
|
52
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
53
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
+
exports.zipMainJS = zipMainJS;
|
|
55
|
+
exports.onSetLatest = onSetLatest;
|
|
56
|
+
exports.onUpdateZip = onUpdateZip;
|
|
57
|
+
exports.onKillProcess = onKillProcess;
|
|
58
|
+
exports.fsUnLinkSync = fsUnLinkSync;
|
|
59
|
+
exports.ensurePathsExist = ensurePathsExist;
|
|
60
|
+
exports.onSetElectronDir = onSetElectronDir;
|
|
61
|
+
exports.onSeePackage = onSeePackage;
|
|
62
|
+
exports.onCheckIteraCliVersion = onCheckIteraCliVersion;
|
|
63
|
+
exports.loadUserConfig = loadUserConfig;
|
|
64
|
+
var child_process_1 = require("child_process");
|
|
65
|
+
var fs_1 = __importDefault(require("fs"));
|
|
66
|
+
var fs_extra_1 = __importDefault(require("fs-extra"));
|
|
67
|
+
var javascript_obfuscator_1 = __importDefault(require("javascript-obfuscator"));
|
|
68
|
+
var moment_1 = __importDefault(require("moment"));
|
|
69
|
+
var node_fetch_1 = __importDefault(require("node-fetch"));
|
|
70
|
+
var path_1 = __importDefault(require("path"));
|
|
71
|
+
var uglify_js_1 = __importDefault(require("uglify-js"));
|
|
72
|
+
var store_1 = require("../store");
|
|
73
|
+
var log_1 = require("./log");
|
|
74
|
+
var sign_1 = require("./sign");
|
|
75
|
+
var upload_obs_1 = require("./upload-obs");
|
|
76
|
+
var startTime = (0, moment_1.default)().unix();
|
|
77
|
+
var rootPath = (_a = store_1.mainData.runtimePath) !== null && _a !== void 0 ? _a : '';
|
|
78
|
+
var finallyProPath = (_d = (_c = (_b = store_1.mainData.updateConfig) === null || _b === void 0 ? void 0 : _b.configPath) === null || _c === void 0 ? void 0 : _c.finallyProPath) !== null && _d !== void 0 ? _d : '';
|
|
79
|
+
var OutputPath = (_g = (_f = (_e = store_1.mainData.updateConfig) === null || _e === void 0 ? void 0 : _e.configPath) === null || _f === void 0 ? void 0 : _f.OutputPath) !== null && _g !== void 0 ? _g : '';
|
|
80
|
+
var FilesToInstallPath = (_k = (_j = (_h = store_1.mainData.updateConfig) === null || _h === void 0 ? void 0 : _h.configPath) === null || _j === void 0 ? void 0 : _j.FilesToInstallPath) !== null && _k !== void 0 ? _k : '';
|
|
81
|
+
var destPatchZipFile = (_o = (_m = (_l = store_1.mainData.updateConfig) === null || _l === void 0 ? void 0 : _l.configPath) === null || _m === void 0 ? void 0 : _m.destPatchZipFile) !== null && _o !== void 0 ? _o : '';
|
|
82
|
+
var destPatchFile = (_r = (_q = (_p = store_1.mainData.updateConfig) === null || _p === void 0 ? void 0 : _p.configPath) === null || _q === void 0 ? void 0 : _q.destPatchFile) !== null && _r !== void 0 ? _r : '';
|
|
83
|
+
var newDir = (_u = (_t = (_s = store_1.mainData.updateConfig) === null || _s === void 0 ? void 0 : _s.configPath) === null || _t === void 0 ? void 0 : _t.newDir) !== null && _u !== void 0 ? _u : '';
|
|
84
|
+
var env = __assign(__assign({}, process.env), { PATH: rootPath + ';' + process.env.PATH, npm_config_prefix: 'C:\\Program Files\\nodejs\\npm' });
|
|
85
|
+
function zipMainJS(coreAppPath) {
|
|
86
|
+
if (!coreAppPath || !fs_1.default.existsSync(coreAppPath))
|
|
87
|
+
return false;
|
|
88
|
+
try {
|
|
89
|
+
var files = fs_1.default.readdirSync(coreAppPath);
|
|
90
|
+
files.forEach(function (file) {
|
|
91
|
+
var filePath = path_1.default.join(coreAppPath, file);
|
|
92
|
+
if (!fs_1.default.existsSync(filePath))
|
|
93
|
+
return;
|
|
94
|
+
var stat = fs_1.default.statSync(filePath);
|
|
95
|
+
if (stat.isDirectory()) {
|
|
96
|
+
zipMainJS(filePath);
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
var dirJs = fs_1.default.readFileSync(filePath, 'utf8');
|
|
100
|
+
var filePathPro = filePath.replace('core', 'pro-node');
|
|
101
|
+
var dirPath = path_1.default.dirname(filePathPro);
|
|
102
|
+
if (!fs_1.default.existsSync(dirPath))
|
|
103
|
+
fs_1.default.mkdirSync(dirPath, { recursive: true });
|
|
104
|
+
if (filePath.endsWith('.html') || filePath.endsWith('.node') || filePath.endsWith('.dll')) {
|
|
105
|
+
if (!fs_1.default.existsSync(filePathPro))
|
|
106
|
+
fs_1.default.copyFileSync(filePath, filePathPro);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
var result = uglify_js_1.default.minify(dirJs);
|
|
110
|
+
if (!result.code)
|
|
111
|
+
return;
|
|
112
|
+
var obfuscationResult = javascript_obfuscator_1.default.obfuscate(result.code, {
|
|
113
|
+
compact: true,
|
|
114
|
+
controlFlowFlattening: true,
|
|
115
|
+
controlFlowFlatteningThreshold: 0.75,
|
|
116
|
+
numbersToExpressions: true,
|
|
117
|
+
simplify: true,
|
|
118
|
+
shuffleStringArray: true,
|
|
119
|
+
splitStrings: true,
|
|
120
|
+
stringArrayThreshold: 0.75,
|
|
121
|
+
});
|
|
122
|
+
if (!fs_1.default.existsSync(filePathPro)) {
|
|
123
|
+
fs_1.default.writeFileSync(filePathPro, obfuscationResult.getObfuscatedCode());
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
catch (err) {
|
|
131
|
+
log_1.Console.error(err);
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
function onSetLatest(isRemote) {
|
|
136
|
+
var _a, _b, _c, _d, _e, _f;
|
|
137
|
+
var latest = (_a = store_1.mainData.updateConfig) === null || _a === void 0 ? void 0 : _a.latest;
|
|
138
|
+
var obs = (_b = store_1.mainData.updateConfig) === null || _b === void 0 ? void 0 : _b.obs;
|
|
139
|
+
if (!latest || !obs)
|
|
140
|
+
return;
|
|
141
|
+
var version = (_c = latest.version) === null || _c === void 0 ? void 0 : _c.split('.').join('_');
|
|
142
|
+
if (!version) {
|
|
143
|
+
log_1.Console.error('生成 latest: version 信息未发现');
|
|
144
|
+
process.exit(1);
|
|
145
|
+
}
|
|
146
|
+
log_1.Console.cyan('生成 latest');
|
|
147
|
+
if (!isRemote) {
|
|
148
|
+
var latestLocalPath = (_e = (_d = store_1.mainData.updateConfig) === null || _d === void 0 ? void 0 : _d.configPath) === null || _e === void 0 ? void 0 : _e.latestLocalPath;
|
|
149
|
+
if (latestLocalPath) {
|
|
150
|
+
fs_1.default.writeFileSync(latestLocalPath, JSON.stringify({ version: latest.version }));
|
|
151
|
+
log_1.Console.cyan('latest 已写入[latestLocalPath]文件内', JSON.stringify({ version: latest.version }));
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
if (latest.patchFilePath) {
|
|
156
|
+
latest.patchFilePath = "".concat((_f = obs.remoteURL) !== null && _f !== void 0 ? _f : '').concat(version, "/").concat(latest.patchFilePath);
|
|
157
|
+
}
|
|
158
|
+
if (latest.installerPath) {
|
|
159
|
+
latest.installerPath = latest.installerPath.map(function (item) {
|
|
160
|
+
var _a;
|
|
161
|
+
return ({
|
|
162
|
+
agent_id: item.agent_id,
|
|
163
|
+
stepLink: "".concat((_a = obs.remoteURL) !== null && _a !== void 0 ? _a : '').concat(version, "/").concat(item.stepLink),
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
if (newDir) {
|
|
168
|
+
fs_1.default.writeFileSync(path_1.default.join(newDir, 'latest'), JSON.stringify(latest));
|
|
169
|
+
log_1.Console.cyan('latest 已写入更新文件夹');
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
function onUpdateZip(destPatchZipFile, destPatchFile) {
|
|
174
|
+
return new Promise(function (resolve) {
|
|
175
|
+
var _a, _b;
|
|
176
|
+
try {
|
|
177
|
+
if (!destPatchZipFile || !destPatchFile)
|
|
178
|
+
return resolve(false);
|
|
179
|
+
log_1.Console.cyan('正在压缩 [update] 文件夹到项目根目录');
|
|
180
|
+
var zipPath = (_b = (_a = store_1.mainData.updateConfig) === null || _a === void 0 ? void 0 : _a.configPath) === null || _b === void 0 ? void 0 : _b.zipPath;
|
|
181
|
+
if (!zipPath || !fs_1.default.existsSync(zipPath))
|
|
182
|
+
return resolve(false);
|
|
183
|
+
var command = "\"".concat(zipPath, "\" a -t7z \"").concat(destPatchZipFile, "\" \"").concat(destPatchFile, "/*\" -mx=9");
|
|
184
|
+
(0, child_process_1.execSync)(command, { env: env });
|
|
185
|
+
log_1.Console.success("\u589E\u91CF\u66F4\u65B0\u5305\u538B\u7F29\u5B8C\u6BD5\uFF0C\u538B\u7F29\u5305\u8DEF\u5F84\uFF1A\u3010".concat(path_1.default.resolve(destPatchZipFile), "\u3011"));
|
|
186
|
+
resolve(true);
|
|
187
|
+
}
|
|
188
|
+
catch (e) {
|
|
189
|
+
log_1.Console.error('源码压缩失败');
|
|
190
|
+
resolve(false);
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
function onKillProcess(processNameList, callback) {
|
|
195
|
+
if (processNameList === void 0) { processNameList = []; }
|
|
196
|
+
if (callback === void 0) { callback = function () { }; }
|
|
197
|
+
try {
|
|
198
|
+
processNameList === null || processNameList === void 0 ? void 0 : processNameList.forEach(function (processName) {
|
|
199
|
+
if (!processName)
|
|
200
|
+
return;
|
|
201
|
+
(0, child_process_1.execSync)("chcp 65001 && cmd.exe /C taskkill /F /IM ".concat(processName));
|
|
202
|
+
callback(true);
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
catch (_a) {
|
|
206
|
+
callback(false);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
function fsUnLinkSync(list) {
|
|
210
|
+
if (list === void 0) { list = []; }
|
|
211
|
+
list === null || list === void 0 ? void 0 : list.forEach(function (item) {
|
|
212
|
+
if (!item)
|
|
213
|
+
return;
|
|
214
|
+
fs_extra_1.default.removeSync(item);
|
|
215
|
+
log_1.Console.cyan("\u5DF2\u5220\u9664 ".concat(item));
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
function ensurePathsExist(paths, options) {
|
|
219
|
+
if (options === void 0) { options = { create: false }; }
|
|
220
|
+
var hasMissing = false;
|
|
221
|
+
Object.entries(paths).forEach(function (_a) {
|
|
222
|
+
var _b, _c;
|
|
223
|
+
var key = _a[0], value = _a[1];
|
|
224
|
+
if (!value) {
|
|
225
|
+
log_1.Console.warn("".concat(key, " \u8DEF\u5F84\u672A\u5B9A\u4E49"));
|
|
226
|
+
hasMissing = true;
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
if ((_c = (_b = store_1.mainData.updateConfig) === null || _b === void 0 ? void 0 : _b.noCheckPath) === null || _c === void 0 ? void 0 : _c.includes(key))
|
|
230
|
+
return;
|
|
231
|
+
if (!fs_1.default.existsSync(value)) {
|
|
232
|
+
hasMissing = true;
|
|
233
|
+
if (options.create) {
|
|
234
|
+
fs_1.default.mkdirSync(value, { recursive: true });
|
|
235
|
+
log_1.Console.log("[create] \u5DF2\u521B\u5EFA\u7F3A\u5931\u76EE\u5F55: ".concat(value));
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
log_1.Console.warn("[missing] ".concat(key, " \u8DEF\u5F84\u4E0D\u5B58\u5728: ").concat(value));
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
if (hasMissing)
|
|
243
|
+
process.exit(1);
|
|
244
|
+
}
|
|
245
|
+
function onSetElectronDir(argv) {
|
|
246
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
247
|
+
var updateConfig, res;
|
|
248
|
+
var _a;
|
|
249
|
+
return __generator(this, function (_b) {
|
|
250
|
+
switch (_b.label) {
|
|
251
|
+
case 0:
|
|
252
|
+
updateConfig = store_1.mainData.updateConfig;
|
|
253
|
+
if (!updateConfig)
|
|
254
|
+
return [2];
|
|
255
|
+
(_a = updateConfig.updateCoolFiles) === null || _a === void 0 ? void 0 : _a.forEach(function (item) {
|
|
256
|
+
if ((item === null || item === void 0 ? void 0 : item.sourceDir) && (item === null || item === void 0 ? void 0 : item.finallyDir))
|
|
257
|
+
fs_extra_1.default.copySync(item.sourceDir, item.finallyDir);
|
|
258
|
+
});
|
|
259
|
+
return [4, onUpdateZip(destPatchZipFile, destPatchFile)];
|
|
260
|
+
case 1:
|
|
261
|
+
res = _b.sent();
|
|
262
|
+
if (!res) {
|
|
263
|
+
log_1.Console.error('压缩增量更新文件失败');
|
|
264
|
+
process.exit(1);
|
|
265
|
+
}
|
|
266
|
+
if (destPatchZipFile && newDir) {
|
|
267
|
+
fs_extra_1.default.copySync(destPatchZipFile, path_1.default.resolve(newDir, 'update.7z'));
|
|
268
|
+
log_1.Console.cyan('将冷更新文件复制到桌面');
|
|
269
|
+
}
|
|
270
|
+
onSetLatest(true);
|
|
271
|
+
log_1.Console.cyan('更新所需文件已复制到桌面文件夹:Output');
|
|
272
|
+
log_1.Console.success('共用时:' + ((0, moment_1.default)().unix() - startTime) + '秒');
|
|
273
|
+
if (!(typeof upload_obs_1.upload === 'function')) return [3, 3];
|
|
274
|
+
return [4, (0, upload_obs_1.upload)(argv, true)];
|
|
275
|
+
case 2:
|
|
276
|
+
_b.sent();
|
|
277
|
+
_b.label = 3;
|
|
278
|
+
case 3: return [2];
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
function onSeePackage(item, sign) {
|
|
284
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
285
|
+
var updateConfig, uninstSrc, uninstDest, boxPath, currVersion, desktopProPath, setupConfig, data, regex, regep, regeh, reexe, match, text, updatedData, buildNoZip, stepLink;
|
|
286
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1;
|
|
287
|
+
return __generator(this, function (_2) {
|
|
288
|
+
switch (_2.label) {
|
|
289
|
+
case 0:
|
|
290
|
+
updateConfig = store_1.mainData.updateConfig;
|
|
291
|
+
if (!item || !updateConfig)
|
|
292
|
+
return [2];
|
|
293
|
+
fsUnLinkSync([OutputPath, FilesToInstallPath]);
|
|
294
|
+
if (!fs_1.default.existsSync(OutputPath))
|
|
295
|
+
fs_1.default.mkdirSync(OutputPath, { recursive: true });
|
|
296
|
+
if (!fs_1.default.existsSync(FilesToInstallPath))
|
|
297
|
+
fs_1.default.mkdirSync(FilesToInstallPath, { recursive: true });
|
|
298
|
+
uninstSrc = path_1.default.join((_c = (_b = (_a = store_1.mainData.updateConfig) === null || _a === void 0 ? void 0 : _a.configPath) === null || _b === void 0 ? void 0 : _b.uninstPath) !== null && _c !== void 0 ? _c : '', (_d = item.uninst) !== null && _d !== void 0 ? _d : '');
|
|
299
|
+
uninstDest = path_1.default.join((_g = (_f = (_e = store_1.mainData.updateConfig) === null || _e === void 0 ? void 0 : _e.configPath) === null || _f === void 0 ? void 0 : _f.buildPath) !== null && _g !== void 0 ? _g : '', "".concat(item.path, "-win32-ia32"), 'uninst.exe');
|
|
300
|
+
if (fs_1.default.existsSync(uninstSrc))
|
|
301
|
+
fs_extra_1.default.copySync(uninstSrc, uninstDest);
|
|
302
|
+
boxPath = path_1.default.join((_k = (_j = (_h = store_1.mainData.updateConfig) === null || _h === void 0 ? void 0 : _h.configPath) === null || _j === void 0 ? void 0 : _j.buildPath) !== null && _k !== void 0 ? _k : '', "".concat(item.path, "-win32-ia32"));
|
|
303
|
+
if (fs_1.default.existsSync(boxPath))
|
|
304
|
+
fs_extra_1.default.copySync(boxPath, FilesToInstallPath);
|
|
305
|
+
log_1.Console.cyan("\u5F00\u59CBNSIS\u6253\u5305 - ".concat((_l = item.name) !== null && _l !== void 0 ? _l : '未命名'));
|
|
306
|
+
currVersion = (_p = (_o = (_m = updateConfig.latest) === null || _m === void 0 ? void 0 : _m.version) === null || _o === void 0 ? void 0 : _o.split('.').join('')) !== null && _p !== void 0 ? _p : '';
|
|
307
|
+
desktopProPath = path_1.default.join((_q = store_1.mainData.desktopDir) !== null && _q !== void 0 ? _q : '', "".concat(item.path).concat(currVersion, ".exe"));
|
|
308
|
+
setupConfig = (_t = (_s = (_r = store_1.mainData.updateConfig) === null || _r === void 0 ? void 0 : _r.configPath) === null || _s === void 0 ? void 0 : _s.setupConfigPath) !== null && _t !== void 0 ? _t : '';
|
|
309
|
+
if (!fs_1.default.existsSync(setupConfig))
|
|
310
|
+
return [2, log_1.Console.error('setupConfig 文件不存在')];
|
|
311
|
+
data = fs_1.default.readFileSync(setupConfig, 'utf16le');
|
|
312
|
+
regex = /(!define|ifndef)\s+PRODUCT_NAME\s+"(.*?)"/g;
|
|
313
|
+
regep = /(!define|ifndef)\s+PRODUCT_PATHNAME\s+"(.*?)"/g;
|
|
314
|
+
regeh = /(!define|ifndef)\s+INSTALL_APPEND_PATH\s+"(.*?)"/g;
|
|
315
|
+
reexe = /(!define|ifndef)\s+EXE_NAME\s+"(.*?)"/g;
|
|
316
|
+
text = '';
|
|
317
|
+
while ((match = regex.exec(data)) !== null)
|
|
318
|
+
text = (_u = match[2]) !== null && _u !== void 0 ? _u : '';
|
|
319
|
+
if (!text)
|
|
320
|
+
return [2, log_1.Console.error('引号内的项目名为空')];
|
|
321
|
+
log_1.Console.cyan("\u914D\u7F6E\u9879\u76EE\u540D: [".concat(text, "] => [").concat(item.name, "]"));
|
|
322
|
+
updatedData = data.replace(new RegExp("(PRODUCT_NAME\\s+)\"".concat(text, "\"")), "$1\"".concat(item.name, "\""));
|
|
323
|
+
while ((match = regep.exec(data)) !== null)
|
|
324
|
+
text = (_v = match[2]) !== null && _v !== void 0 ? _v : '';
|
|
325
|
+
if (!text)
|
|
326
|
+
return [2, log_1.Console.error('引号内的Appid为空')];
|
|
327
|
+
log_1.Console.cyan("\u914D\u7F6EAPPID: [".concat(text, "] => [").concat(item.appid, "]"));
|
|
328
|
+
updatedData = updatedData.replace(new RegExp("(PRODUCT_PATHNAME\\s+)\"".concat(text, "\"")), "$1\"".concat(item.appid, "\""));
|
|
329
|
+
while ((match = regeh.exec(data)) !== null)
|
|
330
|
+
text = (_w = match[2]) !== null && _w !== void 0 ? _w : '';
|
|
331
|
+
if (!text)
|
|
332
|
+
return [2, log_1.Console.error('引号内的安装路径为空')];
|
|
333
|
+
log_1.Console.cyan("\u914D\u7F6E\u5B89\u88C5\u8DEF\u5F84: [".concat(text, "] => [").concat(item.path, "]"));
|
|
334
|
+
updatedData = updatedData.replace(new RegExp("(INSTALL_APPEND_PATH\\s+)\"".concat(text, "\"")), "$1\"".concat(item.path, "\""));
|
|
335
|
+
while ((match = reexe.exec(data)) !== null)
|
|
336
|
+
text = (_x = match[2]) !== null && _x !== void 0 ? _x : '';
|
|
337
|
+
if (!text)
|
|
338
|
+
return [2, log_1.Console.error('引号内的启动程序名为空')];
|
|
339
|
+
log_1.Console.cyan("\u914D\u7F6E\u542F\u52A8\u7A0B\u5E8F: [".concat(text, "] => [").concat(item.startApp, "]"));
|
|
340
|
+
updatedData = updatedData.replace(new RegExp("(EXE_NAME\\s+)\"".concat(text, "\"")), "$1\"".concat(item.startApp, "\""));
|
|
341
|
+
fs_1.default.writeFileSync(setupConfig, updatedData, 'utf16le');
|
|
342
|
+
log_1.Console.success('打包信息已成功更新');
|
|
343
|
+
buildNoZip = (_z = (_y = store_1.mainData.updateConfig) === null || _y === void 0 ? void 0 : _y.configPath) === null || _z === void 0 ? void 0 : _z.buildNoZip;
|
|
344
|
+
if (buildNoZip && fs_1.default.existsSync(buildNoZip)) {
|
|
345
|
+
(0, child_process_1.spawnSync)(buildNoZip, [], { cwd: path_1.default.join(buildNoZip, '..'), shell: true });
|
|
346
|
+
}
|
|
347
|
+
if (!sign) return [3, 2];
|
|
348
|
+
return [4, (0, sign_1.InstallBackSign)()];
|
|
349
|
+
case 1:
|
|
350
|
+
_2.sent();
|
|
351
|
+
return [3, 3];
|
|
352
|
+
case 2:
|
|
353
|
+
log_1.Console.warn('已跳过安装包签名');
|
|
354
|
+
_2.label = 3;
|
|
355
|
+
case 3:
|
|
356
|
+
log_1.Console.success("".concat(item.name, "\u6253\u5305\u5B8C\u6BD5"));
|
|
357
|
+
if (finallyProPath && fs_1.default.existsSync(finallyProPath) && desktopProPath) {
|
|
358
|
+
fs_extra_1.default.copySync(finallyProPath, desktopProPath);
|
|
359
|
+
}
|
|
360
|
+
if (finallyProPath && fs_1.default.existsSync(finallyProPath) && newDir) {
|
|
361
|
+
stepLink = (_1 = (_0 = store_1.mainData.updateConfig.latest.installerPath) === null || _0 === void 0 ? void 0 : _0.find(function (el) { return el.agent_id === item.agent_id; })) === null || _1 === void 0 ? void 0 : _1.stepLink;
|
|
362
|
+
if (!stepLink) {
|
|
363
|
+
throw "\u8BF7\u914D\u7F6E [".concat(item.name, "] installerPath.stepLink");
|
|
364
|
+
}
|
|
365
|
+
fs_extra_1.default.copySync(finallyProPath, path_1.default.resolve(newDir, stepLink));
|
|
366
|
+
}
|
|
367
|
+
return [2];
|
|
368
|
+
}
|
|
369
|
+
});
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
function onCheckIteraCliVersion() {
|
|
373
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
374
|
+
var response, data, latestVersion, err_1;
|
|
375
|
+
return __generator(this, function (_a) {
|
|
376
|
+
switch (_a.label) {
|
|
377
|
+
case 0:
|
|
378
|
+
_a.trys.push([0, 3, , 4]);
|
|
379
|
+
return [4, (0, node_fetch_1.default)("https://registry.npmjs.org/".concat(encodeURIComponent('@npmqg/itera-cli'), "/latest"))];
|
|
380
|
+
case 1:
|
|
381
|
+
response = _a.sent();
|
|
382
|
+
if (!response.ok)
|
|
383
|
+
throw new Error("\u8BF7\u6C42\u5931\u8D25\uFF1A".concat(response.status));
|
|
384
|
+
return [4, response.json()];
|
|
385
|
+
case 2:
|
|
386
|
+
data = _a.sent();
|
|
387
|
+
latestVersion = data.version;
|
|
388
|
+
log_1.Console.cyan("\n\u6B22\u8FCE\u4F7F\u7528 itera-cli \u811A\u624B\u67B6\n\u5F53\u524D\u7248\u672C\uFF1A".concat(store_1.mainData.pkg.version, "\n\u6700\u65B0\u7248\u672C\uFF1A").concat(latestVersion, "\n"));
|
|
389
|
+
if (store_1.mainData.pkg.version !== latestVersion) {
|
|
390
|
+
log_1.Console.warn("\u68C0\u6D4B\u5230\u65B0\u7248\u672C ".concat(latestVersion, "\uFF0C\u8BF7\u4F7F\u7528 npm install -g itera-cli \u66F4\u65B0"));
|
|
391
|
+
}
|
|
392
|
+
return [3, 4];
|
|
393
|
+
case 3:
|
|
394
|
+
err_1 = _a.sent();
|
|
395
|
+
log_1.Console.error('版本检测失败:', err_1.message);
|
|
396
|
+
return [3, 4];
|
|
397
|
+
case 4: return [2];
|
|
398
|
+
}
|
|
399
|
+
});
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
function loadUserConfig(hook) {
|
|
403
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
404
|
+
var configPath, module_1;
|
|
405
|
+
return __generator(this, function (_a) {
|
|
406
|
+
configPath = path_1.default.resolve(process.cwd(), 'scaffold.config.js');
|
|
407
|
+
if (!fs_1.default.existsSync(configPath)) {
|
|
408
|
+
return [2];
|
|
409
|
+
}
|
|
410
|
+
try {
|
|
411
|
+
module_1 = require(configPath);
|
|
412
|
+
if (module_1.registerHooks && typeof module_1.registerHooks === 'function') {
|
|
413
|
+
module_1.registerHooks(hook, log_1.Console);
|
|
414
|
+
}
|
|
415
|
+
else {
|
|
416
|
+
log_1.Console.warn('用户配置文件中没有导出 registerHooks 函数: module.exports.registerHooks');
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
catch (err) {
|
|
420
|
+
log_1.Console.error('加载用户Hooks配置失败:', err);
|
|
421
|
+
}
|
|
422
|
+
return [2];
|
|
423
|
+
});
|
|
424
|
+
});
|
|
425
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
exports.BatchSign = BatchSign;
|
|
44
|
+
exports.InstallBackSign = InstallBackSign;
|
|
45
|
+
var child_process_1 = require("child_process");
|
|
46
|
+
var fs_1 = __importDefault(require("fs"));
|
|
47
|
+
var fs_extra_1 = __importDefault(require("fs-extra"));
|
|
48
|
+
var path_1 = __importDefault(require("path"));
|
|
49
|
+
var store_1 = require("../store");
|
|
50
|
+
var log_1 = require("../public/log");
|
|
51
|
+
var signAllFiles = (_c = (_b = (_a = store_1.mainData.updateConfig) === null || _a === void 0 ? void 0 : _a.configPath) === null || _b === void 0 ? void 0 : _b.signAllFilesPath) !== null && _c !== void 0 ? _c : '';
|
|
52
|
+
var finallyProPath = (_f = (_e = (_d = store_1.mainData.updateConfig) === null || _d === void 0 ? void 0 : _d.configPath) === null || _e === void 0 ? void 0 : _e.finallyProPath) !== null && _f !== void 0 ? _f : '';
|
|
53
|
+
var signToolsPath = (_j = (_h = (_g = store_1.mainData.updateConfig) === null || _g === void 0 ? void 0 : _g.configPath) === null || _h === void 0 ? void 0 : _h.signToolsPath) !== null && _j !== void 0 ? _j : '';
|
|
54
|
+
var buildPath = (_m = (_l = (_k = store_1.mainData.updateConfig) === null || _k === void 0 ? void 0 : _k.configPath) === null || _l === void 0 ? void 0 : _l.buildPath) !== null && _m !== void 0 ? _m : '';
|
|
55
|
+
var agentPath = (_q = (_p = (_o = store_1.mainData.updateConfig) === null || _o === void 0 ? void 0 : _o.configPath) === null || _p === void 0 ? void 0 : _p.batAgentPath) !== null && _q !== void 0 ? _q : '';
|
|
56
|
+
function BatchSign() {
|
|
57
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
58
|
+
var agentsInfo, agentValue, agentIndex, agentName, appid, signExePath, signFiles;
|
|
59
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
60
|
+
return __generator(this, function (_h) {
|
|
61
|
+
if (!signAllFiles || !buildPath || !signToolsPath || !agentPath) {
|
|
62
|
+
log_1.Console.error('批量签名路径配置缺失');
|
|
63
|
+
return [2, false];
|
|
64
|
+
}
|
|
65
|
+
log_1.Console.cyan('开始批量签名');
|
|
66
|
+
fs_extra_1.default.removeSync(signAllFiles);
|
|
67
|
+
fs_1.default.mkdirSync(signAllFiles, { recursive: true });
|
|
68
|
+
log_1.Console.cyan('已初始化文件');
|
|
69
|
+
agentsInfo = (_a = store_1.mainData.updateConfig) === null || _a === void 0 ? void 0 : _a.agentsInfo;
|
|
70
|
+
if (!agentsInfo || !Array.isArray(agentsInfo)) {
|
|
71
|
+
log_1.Console.error('agentsInfo 配置为空');
|
|
72
|
+
return [2, false];
|
|
73
|
+
}
|
|
74
|
+
if (!fs_1.default.existsSync(agentPath)) {
|
|
75
|
+
log_1.Console.error('代理标识文件不存在');
|
|
76
|
+
return [2, false];
|
|
77
|
+
}
|
|
78
|
+
agentValue = (_b = fs_1.default.readFileSync(agentPath, 'utf8')) !== null && _b !== void 0 ? _b : '';
|
|
79
|
+
agentIndex = agentsInfo.findIndex(function (item) { return String(item.value) === agentValue; });
|
|
80
|
+
if (agentIndex === -1) {
|
|
81
|
+
log_1.Console.error("\u672A\u627E\u5230\u5339\u914D\u7684\u4EE3\u7406\u4FE1\u606F: ".concat(agentValue));
|
|
82
|
+
return [2, false];
|
|
83
|
+
}
|
|
84
|
+
agentName = (_d = (_c = agentsInfo[agentIndex]) === null || _c === void 0 ? void 0 : _c.path) !== null && _d !== void 0 ? _d : '';
|
|
85
|
+
appid = (_f = (_e = agentsInfo[agentIndex]) === null || _e === void 0 ? void 0 : _e.appid) !== null && _f !== void 0 ? _f : '';
|
|
86
|
+
if (!agentName || !appid) {
|
|
87
|
+
log_1.Console.error('代理名称或 appid 缺失');
|
|
88
|
+
return [2, false];
|
|
89
|
+
}
|
|
90
|
+
signExePath = path_1.default.join(buildPath, "".concat(agentName, "-win32-ia32/").concat(appid, ".exe"));
|
|
91
|
+
if (!fs_1.default.existsSync(signExePath)) {
|
|
92
|
+
log_1.Console.error("\u9700\u8981\u7B7E\u540D\u7684exe\u4E0D\u5B58\u5728: ".concat(signExePath));
|
|
93
|
+
return [2, false];
|
|
94
|
+
}
|
|
95
|
+
log_1.Console.cyan("\u6B63\u5728\u6279\u91CF\u7B7E\u540D ".concat(agentName));
|
|
96
|
+
fs_extra_1.default.copySync(signExePath, path_1.default.join(signAllFiles, path_1.default.basename(signExePath)));
|
|
97
|
+
signFiles = (_g = store_1.mainData.updateConfig) === null || _g === void 0 ? void 0 : _g.signFiles;
|
|
98
|
+
if (Array.isArray(signFiles)) {
|
|
99
|
+
signFiles.forEach(function (item) {
|
|
100
|
+
if (item && fs_1.default.existsSync(item)) {
|
|
101
|
+
fs_extra_1.default.copySync(item, path_1.default.join(signAllFiles, path_1.default.basename(item)));
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
if (signToolsPath && fs_1.default.existsSync(signToolsPath)) {
|
|
106
|
+
(0, child_process_1.spawnSync)(signToolsPath, [], {
|
|
107
|
+
cwd: path_1.default.join(signToolsPath, '..'),
|
|
108
|
+
shell: true,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
fs_extra_1.default.copySync(path_1.default.join(signAllFiles, path_1.default.basename(signExePath)), signExePath, { overwrite: true });
|
|
112
|
+
if (Array.isArray(signFiles)) {
|
|
113
|
+
signFiles.forEach(function (item) {
|
|
114
|
+
if (item) {
|
|
115
|
+
fs_extra_1.default.copySync(path_1.default.join(signAllFiles, path_1.default.basename(item)), item, { overwrite: true });
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
return [2, true];
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
function InstallBackSign() {
|
|
124
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
125
|
+
return __generator(this, function (_a) {
|
|
126
|
+
if (!signAllFiles || !finallyProPath || !signToolsPath) {
|
|
127
|
+
log_1.Console.error('安装包签名路径配置缺失');
|
|
128
|
+
return [2, false];
|
|
129
|
+
}
|
|
130
|
+
log_1.Console.cyan('开始安装包签名');
|
|
131
|
+
fs_extra_1.default.removeSync(signAllFiles);
|
|
132
|
+
fs_1.default.mkdirSync(signAllFiles, { recursive: true });
|
|
133
|
+
if (!fs_1.default.existsSync(finallyProPath)) {
|
|
134
|
+
log_1.Console.error("\u5B89\u88C5\u5305\u6587\u4EF6\u4E0D\u5B58\u5728: ".concat(finallyProPath));
|
|
135
|
+
return [2, false];
|
|
136
|
+
}
|
|
137
|
+
fs_extra_1.default.copySync(finallyProPath, path_1.default.join(signAllFiles, path_1.default.basename(finallyProPath)));
|
|
138
|
+
if (signToolsPath && fs_1.default.existsSync(signToolsPath)) {
|
|
139
|
+
(0, child_process_1.spawnSync)(signToolsPath, [], {
|
|
140
|
+
cwd: path_1.default.join(signToolsPath, '..'),
|
|
141
|
+
shell: true,
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
fs_extra_1.default.copySync(path_1.default.join(signAllFiles, path_1.default.basename(finallyProPath)), finallyProPath, { overwrite: true });
|
|
145
|
+
return [2, true];
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
}
|