@pixui-dev/pxw 0.1.24 → 0.1.26
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/bin/pxw.js +8 -144
- package/config/daemon.js +157 -0
- package/config/devops.js +235 -51
- package/config/h5es.js +4 -0
- package/config/index.html +2 -2
- package/config/util.js +11 -7
- package/config/webpack.js +4 -3
- package/lib/h5es-types/v3.5.6/h5es.d.ts +1837 -0
- package/lib/types/preact/jsx.d.ts +49 -0
- package/package.json +16 -3
package/config/devops.js
CHANGED
|
@@ -7,17 +7,21 @@ let pr = path.resolve;
|
|
|
7
7
|
|
|
8
8
|
let multer = require('multer');
|
|
9
9
|
let express = require('express');
|
|
10
|
+
let util = require('./util');
|
|
10
11
|
|
|
11
12
|
let rootDir = pr(__dirname, '../');
|
|
13
|
+
let runInWindows = process.platform == 'win32';
|
|
12
14
|
|
|
13
15
|
let dirConfig = {
|
|
14
16
|
pxkit: '',
|
|
15
17
|
pxembed: '',
|
|
16
18
|
pxapp: '',
|
|
19
|
+
unreal: '',
|
|
17
20
|
};
|
|
18
21
|
|
|
19
22
|
function updateFile(file, targetLine) {
|
|
20
23
|
targetLine = '\n' + targetLine;
|
|
24
|
+
console.log('updateFile', file, targetLine);
|
|
21
25
|
fs.existsSync(file) ? fs.readFileSync(file, 'utf8').includes(targetLine) || fs.appendFileSync(file, targetLine) : fs.writeFileSync(file, targetLine);
|
|
22
26
|
}
|
|
23
27
|
|
|
@@ -31,10 +35,10 @@ module.exports.setupDevops = async function (server, app) {
|
|
|
31
35
|
|
|
32
36
|
if (!runInVM) {
|
|
33
37
|
let chokidar = require('chokidar');
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
);
|
|
38
|
+
let watchPatterns = [];
|
|
39
|
+
watchPatterns = ['/pxtest/html/**/*.html', '/pxtest/**/*.js'].map((v) => pr('.') + v);
|
|
40
|
+
console.log('watchPatterns', watchPatterns);
|
|
41
|
+
watcher = chokidar.watch(watchPatterns, { persistent: true });
|
|
38
42
|
|
|
39
43
|
watcher
|
|
40
44
|
.on('change', function (path) {
|
|
@@ -55,14 +59,21 @@ module.exports.setupDevops = async function (server, app) {
|
|
|
55
59
|
watcher.emit('change', htmlPath);
|
|
56
60
|
}
|
|
57
61
|
|
|
62
|
+
let testImages = [];
|
|
58
63
|
let subProcesses = {};
|
|
59
64
|
let devopsConn;
|
|
65
|
+
let symbolConn;
|
|
60
66
|
let websocketServer = new ws.Server({ server });
|
|
61
67
|
websocketServer.on('connection', (conn, req) => {
|
|
62
68
|
let url = new URL(req.url, 'http://localhost');
|
|
63
69
|
//去掉第1个字符/,否则在windows上与path比较时会因为\而不一样
|
|
64
70
|
let referrer = url.searchParams.get('referrer')?.substring(1);
|
|
65
71
|
console.log('ws connection', url.pathname, referrer);
|
|
72
|
+
conn.send(JSON.stringify({ type: 'ipList', data: util.getLocalIP() }));
|
|
73
|
+
{
|
|
74
|
+
let br = cp.execSync('git branch --show-current', { stdio: 'pipe', cwd: rootDir, windowsHide: true });
|
|
75
|
+
conn.send(JSON.stringify({ type: 'setDirResult', id: 'pxw', value: rootDir, result: br.toString() }));
|
|
76
|
+
}
|
|
66
77
|
// console.log(url.pathname, url.searchParams);
|
|
67
78
|
if (url.pathname == '/notify') {
|
|
68
79
|
conn.on('message', (message) => {
|
|
@@ -87,7 +98,8 @@ module.exports.setupDevops = async function (server, app) {
|
|
|
87
98
|
watcher?.removeListener('change', changeHandler);
|
|
88
99
|
console.log('ws connection closed', url.pathname, url.searchParams);
|
|
89
100
|
});
|
|
90
|
-
}
|
|
101
|
+
}
|
|
102
|
+
else if (url.pathname == '/devops') {
|
|
91
103
|
devopsConn = conn;
|
|
92
104
|
let notifySubProcesses = () => {
|
|
93
105
|
conn.send(
|
|
@@ -108,32 +120,108 @@ module.exports.setupDevops = async function (server, app) {
|
|
|
108
120
|
devopsConn = null;
|
|
109
121
|
});
|
|
110
122
|
conn.on('message', (data) => {
|
|
111
|
-
let { command, options } = JSON.parse(data);
|
|
123
|
+
let { seqId, command, options } = JSON.parse(data);
|
|
112
124
|
console.log('devops cmd', command, options);
|
|
113
125
|
|
|
114
126
|
let subprocess;
|
|
115
|
-
if (command == '
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
|
|
127
|
+
if (command == '') {
|
|
128
|
+
}
|
|
129
|
+
else if (command == 'setEntryUrl') {
|
|
130
|
+
let iniFile = `${dirConfig.pxkit}/.cache/pixui.ini`;
|
|
131
|
+
let lines = fs.readFileSync(iniFile).toString().split('\n');
|
|
132
|
+
// console.log(lines);
|
|
133
|
+
lines[0] = `entry_url=${options.url}`;
|
|
134
|
+
fs.writeFileSync(iniFile, lines.join('\n'));
|
|
135
|
+
}
|
|
136
|
+
else if (command == 'useNewImage') {
|
|
137
|
+
let newFile = options.new;
|
|
138
|
+
let dstFile = `${rootDir}/pxtest/capture/` + newFile.split('/caps/')[1];
|
|
139
|
+
try {
|
|
140
|
+
fs.copyFileSync(newFile, dstFile);
|
|
141
|
+
console.log('copy new image', newFile, 'to', dstFile);
|
|
142
|
+
}
|
|
143
|
+
catch (e) {
|
|
144
|
+
console.log('useNewImage error', e);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
else if (command == 'killProcessById') {
|
|
148
|
+
try {
|
|
149
|
+
let output;
|
|
150
|
+
if (process.platform == 'win32') {
|
|
151
|
+
output = cp.execSync('taskkill /F /PID ' + options.pid, { windowsHide: true });
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
output = cp.execSync(`kill ${options.pid}`, { stdio: 'pipe', cwd: rootDir, windowsHide: true });
|
|
155
|
+
}
|
|
156
|
+
devopsConn?.send(JSON.stringify({ type: 'stdout', data: `kill ${options.pid} 完成\n` }));
|
|
157
|
+
}
|
|
158
|
+
catch (e) {
|
|
159
|
+
devopsConn?.send(JSON.stringify({ type: 'stdout', data: e.message }));
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
else if (command == 'queryTestImage') {
|
|
163
|
+
devopsConn?.send(JSON.stringify({ seqId, testImages }));
|
|
164
|
+
}
|
|
165
|
+
else if (command == 'queryServerProcess') {
|
|
166
|
+
let output;
|
|
167
|
+
if (process.platform == 'win32') {
|
|
168
|
+
cmd = 'wmic /OUTPUT:STDOUT process get processid,commandline';
|
|
169
|
+
output = cp.execSync(cmd, { maxBuffer: 1024 * 1024 * 10, cwd: rootDir, windowsHide: true });
|
|
170
|
+
let psl = output.toString().trim().split('\n');
|
|
171
|
+
let psl2 = psl
|
|
172
|
+
.map((line) => {
|
|
173
|
+
if (line.indexOf('pixui_') < 0) return;
|
|
174
|
+
let info = line.trim().replace(/\s+/g, ' ').split(' ');
|
|
175
|
+
let pid = info[info.length - 1];
|
|
176
|
+
// console.log(info);
|
|
177
|
+
return `0 ${pid} ${info.slice(0, info.length - 1).join(' ')}`;
|
|
178
|
+
})
|
|
179
|
+
.filter((x) => !!x);
|
|
180
|
+
console.log('psl', psl.length, 'psl2', psl2.length);
|
|
181
|
+
output = psl2.join('\n');
|
|
121
182
|
}
|
|
122
|
-
|
|
183
|
+
else {
|
|
184
|
+
cmd = 'ps -ef|grep pixui_';
|
|
185
|
+
output = cp.execSync(cmd, { stdio: 'pipe', cwd: rootDir, windowsHide: true });
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
devopsConn?.send(JSON.stringify({ seqId, data: output.toString() }));
|
|
189
|
+
}
|
|
190
|
+
else if (command == 'killBuildProcess') {
|
|
191
|
+
let { name } = options;
|
|
192
|
+
if (name in subProcesses) {
|
|
193
|
+
let { subprocess } = subProcesses[name];
|
|
194
|
+
subprocess.kill();
|
|
195
|
+
delete subProcesses[name];
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
console.log('process not found', name);
|
|
199
|
+
}
|
|
200
|
+
notifySubProcesses();
|
|
201
|
+
}
|
|
202
|
+
else if (command == 'buildIOS') {
|
|
203
|
+
testImages = [];
|
|
204
|
+
(options.withPxKitSource = dirConfig.pxkit.replace(/\\/g, '/')),
|
|
205
|
+
(subprocess = cp.spawn('node', [dirConfig.pxembed + '/src/script/itest.js'], {
|
|
123
206
|
cwd: dirConfig.pxembed,
|
|
124
207
|
detached: true,
|
|
125
|
-
env: { ...process.env, ...
|
|
126
|
-
});
|
|
127
|
-
}
|
|
208
|
+
env: { ...process.env, ...options, IPHONEOS_DEPLOYMENT_TARGET: '12.0' },
|
|
209
|
+
}));
|
|
210
|
+
}
|
|
211
|
+
else if (command == 'buildAndroid') {
|
|
212
|
+
testImages = [];
|
|
128
213
|
let withEnv = { redirectLogcat: 1 };
|
|
129
214
|
let tasks = [];
|
|
130
215
|
if (options.java) withEnv['JAVA_HOME'] = options.java;
|
|
131
216
|
if (options.rebuild) {
|
|
132
217
|
tasks.push('clean');
|
|
133
218
|
}
|
|
134
|
-
tasks.push('test');
|
|
219
|
+
tasks.push(options.test ? 'test' : 'assembleRelease');
|
|
220
|
+
if (1) {
|
|
221
|
+
tasks.push('-PskipLargeTest=true'); //跳过大文件测试
|
|
222
|
+
}
|
|
135
223
|
let clfile = dirConfig.pxembed + '/project/android_app/settings.local';
|
|
136
|
-
let targetLine = `gradle.ext.withPxKitSource = '${
|
|
224
|
+
let targetLine = `gradle.ext.withPxKitSource = '${dirConfig.pxkit.replace(/\\/g, '/')}';`;
|
|
137
225
|
updateFile(clfile, targetLine);
|
|
138
226
|
subprocess = cp.spawn('gradlew' + (runInWindows ? '.bat' : ''), tasks, {
|
|
139
227
|
cwd: dirConfig.pxembed + '/project/android_app',
|
|
@@ -142,7 +230,9 @@ module.exports.setupDevops = async function (server, app) {
|
|
|
142
230
|
shell: true,
|
|
143
231
|
env: { ...process.env, ...withEnv },
|
|
144
232
|
});
|
|
145
|
-
}
|
|
233
|
+
}
|
|
234
|
+
else if (command == 'buildHarmony') {
|
|
235
|
+
testImages = [];
|
|
146
236
|
let withEnv = {};
|
|
147
237
|
if (options.java) {
|
|
148
238
|
withEnv['JAVA_HOME'] = options.java;
|
|
@@ -152,31 +242,35 @@ module.exports.setupDevops = async function (server, app) {
|
|
|
152
242
|
withEnv['rebuild'] = 1;
|
|
153
243
|
}
|
|
154
244
|
let clfile = dirConfig.pxembed + '/project/hm_app/hvigorlocal.ts';
|
|
155
|
-
let targetLine = `export let withPxKit = '${
|
|
245
|
+
let targetLine = `export let withPxKit = '${dirConfig.pxkit.replace(/\\/g, '/')}';`;
|
|
156
246
|
updateFile(clfile, targetLine);
|
|
157
|
-
subprocess = cp.spawn('node', [dirConfig.pxembed + '/src/script/htest.js', '-b', '-i', '-t'], {
|
|
247
|
+
subprocess = cp.spawn('node', [dirConfig.pxembed + '/src/script/htest.js', '-b', '-i', options.test ? '-t' : ''], {
|
|
158
248
|
cwd: dirConfig.pxembed,
|
|
159
249
|
detached: !runInWindows,
|
|
160
250
|
shell: true,
|
|
161
251
|
windowsHide: true,
|
|
162
252
|
env: { ...process.env, ...withEnv },
|
|
163
253
|
});
|
|
164
|
-
}
|
|
254
|
+
}
|
|
255
|
+
else if (command == 'buildMac') {
|
|
256
|
+
testImages = [];
|
|
165
257
|
let cfg = `--CFG=${options.debug ? 'Debug' : 'Release'}`;
|
|
166
258
|
let clean = `${options.rebuild ? '--clean' : ''}`;
|
|
167
259
|
let clfile = dirConfig.pxapp + '/cmake.local';
|
|
168
|
-
let targetLine = `set(WITH_PX_SOURCE ${
|
|
260
|
+
let targetLine = `set(WITH_PX_SOURCE ${dirConfig.pxkit.replace(/\\/g, '/')})`;
|
|
169
261
|
updateFile(clfile, targetLine);
|
|
170
262
|
subprocess = cp.spawn('jtx', `pxide-build --mac --build ${cfg} ${clean} --test-pxkit`.split(' '), {
|
|
171
263
|
cwd: dirConfig.pxapp,
|
|
172
264
|
detached: true,
|
|
173
265
|
env: { ...process.env, echo: 1, xPX_TEST_FORCE_ALL: 1 },
|
|
174
266
|
});
|
|
175
|
-
}
|
|
267
|
+
}
|
|
268
|
+
else if (command == 'buildWin') {
|
|
269
|
+
testImages = [];
|
|
176
270
|
let cfg = `--CFG=${options.debug ? 'Debug' : 'Release'}`;
|
|
177
|
-
let clean = `${options.rebuild ? '--
|
|
271
|
+
let clean = `${options.rebuild ? '--rebuild' : ''}`;
|
|
178
272
|
let clfile = dirConfig.pxapp + '/cmake.local';
|
|
179
|
-
let targetLine = `set(WITH_PX_SOURCE ${
|
|
273
|
+
let targetLine = `set(WITH_PX_SOURCE ${dirConfig.pxkit.replace(/\\/g, '/')})`;
|
|
180
274
|
updateFile(clfile, targetLine);
|
|
181
275
|
subprocess = cp.spawn('jtx' + (runInWindows ? '.cmd' : ''), `pxide-build --win --build ${cfg} ${clean} --test-pxkit`.split(' '), {
|
|
182
276
|
cwd: dirConfig.pxapp,
|
|
@@ -185,29 +279,54 @@ module.exports.setupDevops = async function (server, app) {
|
|
|
185
279
|
windowsHide: true,
|
|
186
280
|
shell: true,
|
|
187
281
|
});
|
|
188
|
-
}
|
|
282
|
+
}
|
|
283
|
+
else if (command == 'buildWinMinGW') {
|
|
284
|
+
testImages = [];
|
|
189
285
|
subprocess = cp.spawn('jtx', `build --mingw --build ${options.debug ? '--debug' : '--release'}`.split(' '), {
|
|
190
286
|
detached: !runInWindows,
|
|
191
287
|
env: { ...process.env, xPX_TEST_FORCE_ALL: 1 },
|
|
192
288
|
windowsHide: true,
|
|
193
289
|
shell: true,
|
|
194
290
|
});
|
|
195
|
-
}
|
|
291
|
+
}
|
|
292
|
+
else if (command == 'buildUE') {
|
|
293
|
+
testImages = [];
|
|
294
|
+
let testReportDir = pr(__dirname, './ue_test_report');
|
|
295
|
+
let args = [
|
|
296
|
+
'-game',
|
|
297
|
+
// '-log', // 是否开启日志窗口
|
|
298
|
+
'-RenderOffScreen', // 是否开启离屏渲染
|
|
299
|
+
'-unattended',
|
|
300
|
+
'-ExecCmds=Automation RunTests PixTest.UI;Quit',
|
|
301
|
+
'-TestServerUrl=http://localhost:8001/pxtest/auto',
|
|
302
|
+
'-ReportExportPath=' + testReportDir,
|
|
303
|
+
'-Tests=' + 'test_border.html;' + 'test_issue_446.html;' + 'test_stack_overflow.html;' + 'test_onscroll_get_value.html;' + 'test_xhr.html?test=basic&loadInPxAndroid=1;' + 'samples/project-wxcommunity/index.html',
|
|
304
|
+
];
|
|
305
|
+
subprocess = cp.spawn(dirConfig.unreal + '/PixUI_UE', args, {
|
|
306
|
+
cwd: '',
|
|
307
|
+
detached: !runInWindows,
|
|
308
|
+
env: { ...process.env, xPX_TEST_FORCE_ALL: 1 },
|
|
309
|
+
windowsHide: true,
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
else if (command == 'setDir') {
|
|
196
313
|
let { id, value } = options;
|
|
197
314
|
try {
|
|
198
|
-
if (id == '
|
|
315
|
+
if (id == 'pxw') {
|
|
199
316
|
value = rootDir;
|
|
200
317
|
}
|
|
201
|
-
if (value && id in { pxkit: 1, pxembed: 1, pxapp: 1 }) {
|
|
318
|
+
if (value && id in { pxw: 1, pxkit: 1, pxembed: 1, pxapp: 1, unreal: 1 }) {
|
|
202
319
|
let br = cp.execSync('git branch --show-current', { stdio: 'pipe', cwd: value, windowsHide: true });
|
|
203
320
|
devopsConn?.send(JSON.stringify({ type: 'setDirResult', id, value, result: br.toString() }));
|
|
204
|
-
}
|
|
321
|
+
}
|
|
322
|
+
else if (id in { java: 1 }) {
|
|
205
323
|
// let ver = cp.spawnSync('java', ['-version'], { stdio: 'pipe' }).stderr.toString().split('\n')[0];
|
|
206
324
|
// console.log(value, ver);
|
|
207
325
|
// devopsConn?.send(JSON.stringify({ type: 'setDirResult', id, value, result: ver }));
|
|
208
326
|
}
|
|
209
327
|
dirConfig[id] = value;
|
|
210
|
-
}
|
|
328
|
+
}
|
|
329
|
+
catch (e) {
|
|
211
330
|
devopsConn?.send(JSON.stringify({ type: 'setDirResult', id, result: e.message }));
|
|
212
331
|
}
|
|
213
332
|
}
|
|
@@ -231,27 +350,77 @@ module.exports.setupDevops = async function (server, app) {
|
|
|
231
350
|
devopsConn?.send(JSON.stringify({ type: 'stderr', data: data.toString() }));
|
|
232
351
|
});
|
|
233
352
|
notifySubProcesses();
|
|
234
|
-
}
|
|
353
|
+
}
|
|
354
|
+
else {
|
|
355
|
+
// devopsConn?.send(JSON.stringify({ type: 'return', name: command, value: -1, err: 'unknown command' }));
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
else if (url.pathname == '/symbol') {
|
|
360
|
+
symbolConn = conn;
|
|
361
|
+
conn.on('close', () => {
|
|
362
|
+
symbolConn = null;
|
|
363
|
+
});
|
|
364
|
+
conn.on('message', (data) => {
|
|
365
|
+
let { add2linePath, soPath, stacks } = JSON.parse(data);
|
|
366
|
+
|
|
367
|
+
let subprocess;
|
|
368
|
+
subprocess = cp.spawn(add2linePath, ['-C', '-f', '-e', soPath].concat(stacks), {
|
|
369
|
+
cwd: dirConfig.pxembed,
|
|
370
|
+
detached: true,
|
|
371
|
+
env: { ...process.env },
|
|
372
|
+
});
|
|
373
|
+
if (subprocess) {
|
|
374
|
+
let output = '';
|
|
375
|
+
let errorOutput = '';
|
|
376
|
+
subprocess.stdout.on('data', (data) => {
|
|
377
|
+
output += data.toString();
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
subprocess.stderr.on('data', (data) => {
|
|
381
|
+
errorOutput += data.toString();
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
subprocess.on('error', (err) => {
|
|
385
|
+
symbolConn?.send(JSON.stringify({ type: 'return', value: -1, err: err.message }));
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
subprocess.on('close', (code, signal) => {
|
|
389
|
+
// 这里保证所有数据都收集完了
|
|
390
|
+
symbolConn?.send(JSON.stringify({ status: 'success', data: output }));
|
|
391
|
+
if (errorOutput) {
|
|
392
|
+
symbolConn?.send(JSON.stringify({ type: 'stderr', data: errorOutput }));
|
|
393
|
+
}
|
|
394
|
+
symbolConn?.send(JSON.stringify({ type: 'return', value: code }));
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
else {
|
|
235
398
|
// devopsConn?.send(JSON.stringify({ type: 'return', name: command, value: -1, err: 'unknown command' }));
|
|
236
399
|
}
|
|
237
400
|
});
|
|
238
401
|
}
|
|
239
402
|
});
|
|
240
403
|
|
|
241
|
-
let
|
|
404
|
+
let pxTestDir = pr(__dirname, '../pxtest');
|
|
405
|
+
let serveIndex = require('serve-index');
|
|
406
|
+
let express = require('express');
|
|
407
|
+
app.use('/pxtest', serveIndex(pxTestDir, { view: 'details' }), express.static(pxTestDir));
|
|
408
|
+
|
|
409
|
+
let tCapDir = rootDir + '/.cache/caps';
|
|
242
410
|
if (!fs.existsSync(tCapDir)) fs.mkdirSync(tCapDir, { recursive: true });
|
|
243
411
|
var storage = multer.diskStorage({
|
|
244
412
|
destination: (req, file, cb) => {
|
|
413
|
+
console.log('body2:', req.body, req.body.platform);
|
|
245
414
|
let dir = tCapDir + '/' + req.body.platform;
|
|
246
415
|
if (!fs.existsSync(dir)) fs.mkdirSync(dir);
|
|
247
416
|
cb(null, dir);
|
|
248
417
|
},
|
|
249
418
|
filename: (req, file, cb) => cb(null, file.originalname),
|
|
250
419
|
});
|
|
420
|
+
app.use('/caps', serveIndex(tCapDir, { view: 'details' }), express.static(tCapDir));
|
|
251
421
|
app.use(express.urlencoded({ extended: true }));
|
|
252
422
|
app.post('/compareImage', multer({ storage }).single('file'), (req, res) => {
|
|
253
|
-
console.log('
|
|
254
|
-
console.log('body:', req.body);
|
|
423
|
+
console.log('upload file:', req.file, 'body:', req.body, req.body.platform);
|
|
255
424
|
|
|
256
425
|
if (!req.file) {
|
|
257
426
|
return res.status(400).send('No files were uploaded.');
|
|
@@ -267,24 +436,38 @@ module.exports.setupDevops = async function (server, app) {
|
|
|
267
436
|
const pixelmatch = require('pixelmatch');
|
|
268
437
|
|
|
269
438
|
let baseFile = `${req.file.path}`.replace('.png', '.base.png');
|
|
270
|
-
|
|
439
|
+
let srcFile = `${rootDir}/pxtest/capture/${platform}/${req.file.originalname}`;
|
|
440
|
+
let ret = {};
|
|
441
|
+
if (fs.existsSync(srcFile)) {
|
|
442
|
+
fs.copyFileSync(srcFile, baseFile);
|
|
271
443
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
444
|
+
const img1 = PNG.sync.read(fs.readFileSync(req.file.path));
|
|
445
|
+
const img2 = PNG.sync.read(fs.readFileSync(baseFile));
|
|
446
|
+
const { width, height } = img1;
|
|
447
|
+
const diff = new PNG({ width, height });
|
|
276
448
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
449
|
+
let num = pixelmatch(img1.data, img2.data, diff.data, width, height, { threshold, includeAA });
|
|
450
|
+
let diffFile = `${req.file.path}`.replace('.png', '.diff.png');
|
|
451
|
+
console.log('compareImage', 'diffNum', num, 'threshold', threshold, req.file.path, baseFile);
|
|
452
|
+
if (num) {
|
|
453
|
+
fs.writeFileSync(diffFile, PNG.sync.write(diff));
|
|
454
|
+
testImages.push({
|
|
455
|
+
base: baseFile,
|
|
456
|
+
new: req.file.path,
|
|
457
|
+
time: fs.statSync(req.file.path).mtime.getTime(),
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
else {
|
|
461
|
+
if (fs.existsSync(diffFile)) fs.unlinkSync(diffFile);
|
|
462
|
+
if (fs.existsSync(baseFile)) fs.unlinkSync(baseFile);
|
|
463
|
+
}
|
|
464
|
+
ret.diff = num;
|
|
465
|
+
}
|
|
466
|
+
else {
|
|
467
|
+
ret.diff = -1;
|
|
285
468
|
}
|
|
286
469
|
res.setHeader('Content-Type', 'application/json');
|
|
287
|
-
res.send(JSON.stringify(
|
|
470
|
+
res.send(JSON.stringify(ret));
|
|
288
471
|
});
|
|
289
472
|
|
|
290
473
|
app.use('/proxy/', async (req, res, next) => {
|
|
@@ -300,7 +483,8 @@ module.exports.setupDevops = async function (server, app) {
|
|
|
300
483
|
console.log('req proxy', url, data.byteLength);
|
|
301
484
|
// res.setHeader('Content-Type', response.headers['Content-Type']);
|
|
302
485
|
res.send(data);
|
|
303
|
-
}
|
|
486
|
+
}
|
|
487
|
+
catch (error) {
|
|
304
488
|
console.log('req proxy failed', url, error);
|
|
305
489
|
res.sendStatus(500);
|
|
306
490
|
}
|
package/config/h5es.js
CHANGED
package/config/index.html
CHANGED
|
@@ -166,13 +166,13 @@
|
|
|
166
166
|
</div>
|
|
167
167
|
</div>
|
|
168
168
|
<div style="height: 20px"></div>
|
|
169
|
-
<div>
|
|
169
|
+
<!-- <div>
|
|
170
170
|
<div style="font-size: 36">测试:</div>
|
|
171
171
|
<div id="entry" style="margin-left: 20px; align-items: start">
|
|
172
172
|
<a style="font-size: 36px" href="/pxtest/auto">pxtest</a>
|
|
173
173
|
<a style="font-size: 36px" href="/pxtest/devops.html">devops</a>
|
|
174
174
|
</div>
|
|
175
|
-
</div>
|
|
175
|
+
</div> -->
|
|
176
176
|
<div class="custom-dd">
|
|
177
177
|
<div class="dd-header" onclick="toggleDD()" id="ddHeader">▼ 选择声明文件对应版本</div>
|
|
178
178
|
<div class="dd-list" id="ddList">
|
package/config/util.js
CHANGED
|
@@ -22,7 +22,7 @@ module.exports.getLocalIP = function () {
|
|
|
22
22
|
ipList.push(iface.address);
|
|
23
23
|
});
|
|
24
24
|
});
|
|
25
|
-
console.log('iplist', ipList);
|
|
25
|
+
// console.log('iplist', ipList);
|
|
26
26
|
return ipList;
|
|
27
27
|
};
|
|
28
28
|
|
|
@@ -49,7 +49,8 @@ module.exports.readRegKey = function (path, key) {
|
|
|
49
49
|
windowsHide: true,
|
|
50
50
|
});
|
|
51
51
|
return out.toString();
|
|
52
|
-
}
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
53
54
|
console.error('Error executing PowerShell script:', error.message);
|
|
54
55
|
return '';
|
|
55
56
|
}
|
|
@@ -68,7 +69,7 @@ module.exports.loadProjectConfig = function () {
|
|
|
68
69
|
try {
|
|
69
70
|
let cwd = process.cwd();
|
|
70
71
|
let ep = cwd + '/entry';
|
|
71
|
-
console.log('read entry.js', ep);
|
|
72
|
+
// console.log('read entry.js', ep);
|
|
72
73
|
projectConfig = require(ep);
|
|
73
74
|
// projectConfig.pages.forEach((p) => {
|
|
74
75
|
// p.entry = `${cwd}/${p.entry}`;
|
|
@@ -81,13 +82,15 @@ module.exports.loadProjectConfig = function () {
|
|
|
81
82
|
Object.entries(env || {}).forEach(([k, v]) => {
|
|
82
83
|
pienv['process.env.' + k] = JSON.stringify(v);
|
|
83
84
|
});
|
|
84
|
-
}
|
|
85
|
-
|
|
85
|
+
}
|
|
86
|
+
catch (e) {
|
|
87
|
+
// console.warn('read entry.js failed');
|
|
86
88
|
if (!/Cannot find module/.test(e.message)) {
|
|
87
89
|
console.error(e);
|
|
88
90
|
}
|
|
89
91
|
projectConfig = { pages: [] };
|
|
90
|
-
}
|
|
92
|
+
}
|
|
93
|
+
finally {
|
|
91
94
|
}
|
|
92
95
|
return projectConfig;
|
|
93
96
|
};
|
|
@@ -124,7 +127,8 @@ module.exports.setH5esType = function (newType) {
|
|
|
124
127
|
fs.writeFileSync(tsconfigPath, stringify(tsconfig, null, 2));
|
|
125
128
|
try {
|
|
126
129
|
cp.execSync('npx prettier-eslint --write tsconfig.json', {});
|
|
127
|
-
}
|
|
130
|
+
}
|
|
131
|
+
catch (e) {
|
|
128
132
|
console.error('prettier-eslint failed:', e.message);
|
|
129
133
|
}
|
|
130
134
|
}
|
package/config/webpack.js
CHANGED
|
@@ -20,8 +20,8 @@ const pr = path.resolve;
|
|
|
20
20
|
let cwd = process.cwd();
|
|
21
21
|
let isPxwSelf = cwd == pr(__dirname + '/..');
|
|
22
22
|
let isShipping = argv.mode == 'production';
|
|
23
|
-
console.log('isPxwSelf:', isPxwSelf);
|
|
24
|
-
console.log('isShipping:', isShipping);
|
|
23
|
+
// console.log('isPxwSelf:', isPxwSelf);
|
|
24
|
+
// console.log('isShipping:', isShipping);
|
|
25
25
|
let rootDir = pr(__dirname + '/../');
|
|
26
26
|
let buildOutputPath = pr(cwd, 'dist', 'html' + (isShipping ? '-pro' : '-dev'));
|
|
27
27
|
|
|
@@ -292,7 +292,8 @@ var getMiddleware = function (appPort, notifyAppReload) {
|
|
|
292
292
|
restartRecommended: true,
|
|
293
293
|
newConfig: h5esType,
|
|
294
294
|
});
|
|
295
|
-
}
|
|
295
|
+
}
|
|
296
|
+
catch (error) {
|
|
296
297
|
console.log(error);
|
|
297
298
|
res.status(500).json({
|
|
298
299
|
error: `更新配置失败: ${error.message}`,
|