jsir 2.3.0 → 2.3.1
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/cmd/oaa.js +11 -20
- package/deps/util.js +22 -17
- package/package.json +1 -1
package/cmd/oaa.js
CHANGED
|
@@ -367,7 +367,7 @@ function getTipStr(showKey = false) {
|
|
|
367
367
|
}
|
|
368
368
|
}
|
|
369
369
|
let tips = items.join(',')
|
|
370
|
-
if (!showKey && !_isTipsDoneShowKey && tips.length >
|
|
370
|
+
if (!showKey && !_isTipsDoneShowKey && tips.length > 64) {
|
|
371
371
|
return '...'
|
|
372
372
|
}
|
|
373
373
|
return tips;
|
|
@@ -578,30 +578,18 @@ async function wrapperInput(str) {
|
|
|
578
578
|
}
|
|
579
579
|
|
|
580
580
|
function wrapperAlias(str) {
|
|
581
|
-
let aliasMap =
|
|
581
|
+
let aliasMap = {};
|
|
582
582
|
try {
|
|
583
583
|
aliasMap = getConfig("alias");
|
|
584
584
|
} catch (e) {
|
|
585
|
-
console.$error(e);
|
|
585
|
+
console.$error("getAlias failed ", e);
|
|
586
586
|
}
|
|
587
|
-
if (
|
|
587
|
+
if (Object.keys(aliasMap).length <= 0) {
|
|
588
588
|
return str;
|
|
589
589
|
}
|
|
590
|
-
let
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
if (arg.endsWith(" ")) {
|
|
594
|
-
arg = `\`${arg}\``
|
|
595
|
-
} else if (arg.endsWith(" ")) {
|
|
596
|
-
arg = `"${arg}"`
|
|
597
|
-
} else if (arg.endsWith(" ")) {
|
|
598
|
-
arg = `'${arg}'`
|
|
599
|
-
} else {
|
|
600
|
-
arg = getAlias(aliasMap, arg)
|
|
601
|
-
}
|
|
602
|
-
args[i] = arg;
|
|
603
|
-
}
|
|
604
|
-
return args.join(' ')
|
|
590
|
+
let fstr = str.split(/\s+/)[0];
|
|
591
|
+
fstr = getAlias(aliasMap, fstr);
|
|
592
|
+
return [fstr, str.substring(fstr.length)].map(trim).filter(i => i).join(' ')
|
|
605
593
|
}
|
|
606
594
|
|
|
607
595
|
async function _wrapperInput(str) {
|
|
@@ -1462,7 +1450,7 @@ async function preLoad(text, fnNameMatch, fn, packages = [], space) {
|
|
|
1462
1450
|
};
|
|
1463
1451
|
await fn(packageName, space)
|
|
1464
1452
|
} catch (e) {
|
|
1465
|
-
console.$error(e)
|
|
1453
|
+
console.$error('preLoad failed', e)
|
|
1466
1454
|
}
|
|
1467
1455
|
}
|
|
1468
1456
|
return packages;
|
|
@@ -1501,14 +1489,17 @@ async function _dealKeyword(keyword, args) {
|
|
|
1501
1489
|
if (item.short === shortKey) {
|
|
1502
1490
|
unMatched = false;
|
|
1503
1491
|
if (item === keywordDef.run) {
|
|
1492
|
+
console.$log('execute', key)
|
|
1504
1493
|
await item.exeFn(args);
|
|
1505
1494
|
} else {
|
|
1495
|
+
console.$log('execute', key)
|
|
1506
1496
|
await item.exeFn(args.map(trim));
|
|
1507
1497
|
}
|
|
1508
1498
|
break;
|
|
1509
1499
|
}
|
|
1510
1500
|
}
|
|
1511
1501
|
if (unMatched) {
|
|
1502
|
+
console.$log('execute run', keyword)
|
|
1512
1503
|
await keywordDef.run.exeFn([keyword, ...args])
|
|
1513
1504
|
}
|
|
1514
1505
|
}
|
package/deps/util.js
CHANGED
|
@@ -71,7 +71,8 @@ const $log = createLimitLogger(`${setting.name}.log`, {
|
|
|
71
71
|
});
|
|
72
72
|
const $error = createLimitLogger(`${setting.name}.error`, {
|
|
73
73
|
logInfo: false,
|
|
74
|
-
error: true
|
|
74
|
+
error: true,
|
|
75
|
+
syncLogs: [$log]
|
|
75
76
|
});
|
|
76
77
|
let _globalDraft= createLimitLogger(`draft.log`, {
|
|
77
78
|
logInfo: false,
|
|
@@ -209,7 +210,8 @@ function createConsole(uniqueName) {
|
|
|
209
210
|
});
|
|
210
211
|
result.$error = createLimitLogger(fileName + '.error', {
|
|
211
212
|
logInfo: false,
|
|
212
|
-
error: true
|
|
213
|
+
error: true,
|
|
214
|
+
syncLogs: [result.$log]
|
|
213
215
|
});
|
|
214
216
|
}
|
|
215
217
|
let quite = false
|
|
@@ -230,7 +232,6 @@ function createConsole(uniqueName) {
|
|
|
230
232
|
}
|
|
231
233
|
let _args = _consoleFns[key].args(args);
|
|
232
234
|
if ("error" === key) {
|
|
233
|
-
result.$log(..._args)
|
|
234
235
|
result.$error(..._args)
|
|
235
236
|
} else {
|
|
236
237
|
result.$log(..._args)
|
|
@@ -502,7 +503,7 @@ function getEditor() {
|
|
|
502
503
|
try {
|
|
503
504
|
defaultEditor = getConfig("defaultEditor", "vi");
|
|
504
505
|
} catch (e) {
|
|
505
|
-
console.$error('
|
|
506
|
+
console.$error('getEditor failed', e);
|
|
506
507
|
}
|
|
507
508
|
return defaultEditor
|
|
508
509
|
}
|
|
@@ -640,7 +641,8 @@ function createLimitLogger(fileName, {
|
|
|
640
641
|
maxChars = 49 * 1024 * 1024,
|
|
641
642
|
logInfo = true,
|
|
642
643
|
time = true,
|
|
643
|
-
error = false
|
|
644
|
+
error = false,
|
|
645
|
+
syncLogs = []
|
|
644
646
|
} = {}) {
|
|
645
647
|
fileName = trim(fileName)
|
|
646
648
|
if (!fileName) {
|
|
@@ -657,10 +659,16 @@ function createLimitLogger(fileName, {
|
|
|
657
659
|
}
|
|
658
660
|
let minNum = (Date.now()/(1000 * 60 * 10)).toFixed(0)
|
|
659
661
|
return (...args) => {
|
|
660
|
-
|
|
661
|
-
if (!text) {
|
|
662
|
+
if (args.length <= 0) {
|
|
662
663
|
return
|
|
663
664
|
}
|
|
665
|
+
// 处理参数
|
|
666
|
+
args = args.map(i => isError(i) ? errorStack(i):i);
|
|
667
|
+
|
|
668
|
+
// 处理同步函数
|
|
669
|
+
syncLogs.forEach(i => i(...args));
|
|
670
|
+
|
|
671
|
+
let text = args.join(" ")
|
|
664
672
|
if (error) {
|
|
665
673
|
global.$newError = true;
|
|
666
674
|
}
|
|
@@ -862,7 +870,7 @@ function aesCipher(str, key){
|
|
|
862
870
|
const cipher = crypto.createCipheriv('aes-128-ecb', pad(key, 16, '0'), null);
|
|
863
871
|
return cipher.update(str, 'utf8', 'hex') + cipher.final('hex');
|
|
864
872
|
} catch(err) {
|
|
865
|
-
$
|
|
873
|
+
$error(err)
|
|
866
874
|
throw 'aesCipher failed: ' + String(err)
|
|
867
875
|
}
|
|
868
876
|
}
|
|
@@ -879,7 +887,7 @@ function aesDecipher(str, key){
|
|
|
879
887
|
const decipher = crypto.createDecipheriv('aes-128-ecb', pad(key, 16, '0'), null);
|
|
880
888
|
return decipher.update(str, 'hex', 'utf8') + decipher.final('utf8');
|
|
881
889
|
} catch(err) {
|
|
882
|
-
$
|
|
890
|
+
$error(err)
|
|
883
891
|
throw 'aesDecipher failed: ' + String(err)
|
|
884
892
|
}
|
|
885
893
|
}
|
|
@@ -1139,8 +1147,7 @@ function tipsOnRmCallback(key) {
|
|
|
1139
1147
|
try {
|
|
1140
1148
|
callback()
|
|
1141
1149
|
} catch (e) {
|
|
1142
|
-
$
|
|
1143
|
-
console.error(`[${key}] OnRmCallback: ${String(e)}`)
|
|
1150
|
+
$error(`[${key}] OnRmCallback`, e)
|
|
1144
1151
|
}
|
|
1145
1152
|
}
|
|
1146
1153
|
}
|
|
@@ -1211,7 +1218,7 @@ function cleanFile(path, maxChars = 9 * 1024 * 1024) {
|
|
|
1211
1218
|
try {
|
|
1212
1219
|
stats = await fp.stat(path);
|
|
1213
1220
|
} catch (e) {
|
|
1214
|
-
console.$error('cleanFile stat failed',
|
|
1221
|
+
console.$error('cleanFile stat failed', e);
|
|
1215
1222
|
return;
|
|
1216
1223
|
}
|
|
1217
1224
|
const fileSize = stats.size;
|
|
@@ -1292,8 +1299,7 @@ function timeLoop(fn, timestamp, lastIds = []){
|
|
|
1292
1299
|
try {
|
|
1293
1300
|
val = fn()
|
|
1294
1301
|
} catch (e) {
|
|
1295
|
-
|
|
1296
|
-
$log(new Error(errorStack(e)).stack)
|
|
1302
|
+
$error(e)
|
|
1297
1303
|
}
|
|
1298
1304
|
if (vl(val) && getType(val) === 'Promise') {
|
|
1299
1305
|
return val.then(result => {
|
|
@@ -1302,8 +1308,7 @@ function timeLoop(fn, timestamp, lastIds = []){
|
|
|
1302
1308
|
}
|
|
1303
1309
|
return lastIds
|
|
1304
1310
|
}).catch(e => {
|
|
1305
|
-
|
|
1306
|
-
$log(new Error(errorStack(e)).stack)
|
|
1311
|
+
$error(e)
|
|
1307
1312
|
|
|
1308
1313
|
if (lastIds[0] !== false) {
|
|
1309
1314
|
lastIds[0] = setTimeout(() => timeLoop(fn, timestamp, lastIds), timestamp)
|
|
@@ -1348,7 +1353,7 @@ function mkdir(dir) {
|
|
|
1348
1353
|
try {
|
|
1349
1354
|
fs.mkdirSync(dir)
|
|
1350
1355
|
} catch (e) {
|
|
1351
|
-
console.$error(
|
|
1356
|
+
console.$error(e)
|
|
1352
1357
|
}
|
|
1353
1358
|
}
|
|
1354
1359
|
|