node-automator 1.4.31 → 1.4.32
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/biome.json +62 -61
- package/commands/ali_oss.js +9 -10
- package/commands/backup.js +6 -5
- package/commands/base.js +8 -3
- package/commands/border.js +179 -0
- package/commands/compress.js +30 -2
- package/commands/decrypt.js +14 -5
- package/commands/encrypt.js +11 -3
- package/commands/env_optional.js +5 -1
- package/commands/exec_from_file.js +4 -2
- package/commands/files_git.js +35 -0
- package/commands/fontmin.js +32 -0
- package/commands/ftp.js +2 -1
- package/commands/image_crop.js +2 -1
- package/commands/merge_file.js +2 -1
- package/commands/mgr.js +14 -11
- package/commands/read_only_excel.js +5 -1
- package/commands/share_data.js +11 -34
- package/commands/split_file.js +2 -1
- package/commands/stream.js +2 -1
- package/commands/tencent_cos.js +9 -9
- package/commands/tinify.js +22 -1
- package/commands/unzip.js +1 -2
- package/commands/watch.js +1 -1
- package/commands/write_cfg.js +4 -2
- package/commands/write_clipboard.js +1 -0
- package/commands/write_excel.js +2 -1
- package/commands/zip.js +1 -1
- package/commands/zip_data.js +1 -3
- package/commands/zip_folder.js +12 -11
- package/index.js +14 -14
- package/package.json +3 -1
- package/utils/file_tool.js +11 -32
- package/utils/request_tool.js +1 -1
- package/utils/scm_tool.js +2 -1
- package/utils/selection_tool.js +45 -45
- package/utils/transform_tool.js +68 -0
package/utils/selection_tool.js
CHANGED
|
@@ -48,7 +48,7 @@ async function select(content, data) {
|
|
|
48
48
|
const options = content;
|
|
49
49
|
const viewOptions = optionKeys.map((optionKey, index) => {
|
|
50
50
|
const optionValue = options[optionKey];
|
|
51
|
-
const showKey =
|
|
51
|
+
const showKey = optionKey;
|
|
52
52
|
if (data.preview_handler) {
|
|
53
53
|
return {
|
|
54
54
|
showKey,
|
|
@@ -65,13 +65,13 @@ async function select(content, data) {
|
|
|
65
65
|
key: optionKey,
|
|
66
66
|
value: data.preview
|
|
67
67
|
? toArray(data.preview)
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
.map((k, i) =>
|
|
69
|
+
i === -1 ? `${k}:${optionValue[k]}` : optionValue[k],
|
|
70
|
+
)
|
|
71
|
+
.join(" | ")
|
|
72
72
|
: typeof optionValue === "object"
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
? JSON.stringify(optionValue)
|
|
74
|
+
: optionValue,
|
|
75
75
|
};
|
|
76
76
|
});
|
|
77
77
|
let filteredViewOptions = viewOptions;
|
|
@@ -133,7 +133,7 @@ async function select(content, data) {
|
|
|
133
133
|
if (
|
|
134
134
|
(data.recommend_only_key &&
|
|
135
135
|
viewOptions[i].key ===
|
|
136
|
-
|
|
136
|
+
match_ret[match_ret.length - 1]) ||
|
|
137
137
|
(!data.recommend_only_key &&
|
|
138
138
|
viewOption.indexOf(
|
|
139
139
|
match_ret[match_ret.length - 1],
|
|
@@ -254,10 +254,10 @@ async function select(content, data) {
|
|
|
254
254
|
);
|
|
255
255
|
focusedIndex = viewOptions.indexOf(
|
|
256
256
|
filteredViewOptions[
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
257
|
+
Math.min(
|
|
258
|
+
filterIdx + 1,
|
|
259
|
+
filteredViewOptions.length - 1,
|
|
260
|
+
)
|
|
261
261
|
],
|
|
262
262
|
);
|
|
263
263
|
restrictFocusedIndex();
|
|
@@ -310,19 +310,19 @@ async function select(content, data) {
|
|
|
310
310
|
if (inputsChg) {
|
|
311
311
|
focusedIndex = -1;
|
|
312
312
|
const inputStr = inputs.join("");
|
|
313
|
-
const inputParts = inputStr?.split(/[, ]+/).filter((v) => v);
|
|
314
|
-
filteredViewOptions = !inputParts
|
|
313
|
+
const inputParts = inputStr?.split(/[, ]+/).map(v => v.trim()).filter((v) => v);
|
|
314
|
+
filteredViewOptions = !inputParts?.length
|
|
315
315
|
? viewOptions
|
|
316
316
|
: viewOptions.filter((option, i) => {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
317
|
+
const valueStr = JSON.stringify(option.value);
|
|
318
|
+
return inputParts.some((part) => {
|
|
319
|
+
return (
|
|
320
|
+
part === i ||
|
|
321
|
+
part === option.key ||
|
|
322
|
+
valueStr.indexOf(part) !== -1
|
|
323
|
+
);
|
|
324
|
+
});
|
|
325
|
+
});
|
|
326
326
|
if (filteredViewOptions.length) {
|
|
327
327
|
focusedIndex = viewOptions.indexOf(filteredViewOptions[0]);
|
|
328
328
|
}
|
|
@@ -368,7 +368,7 @@ async function multiSelect(content, data) {
|
|
|
368
368
|
const options = content;
|
|
369
369
|
const viewOptions = optionKeys.map((optionKey, index) => {
|
|
370
370
|
const optionValue = options[optionKey];
|
|
371
|
-
const showKey =
|
|
371
|
+
const showKey = optionKey;
|
|
372
372
|
if (data.preview_handler) {
|
|
373
373
|
return {
|
|
374
374
|
showKey,
|
|
@@ -385,13 +385,13 @@ async function multiSelect(content, data) {
|
|
|
385
385
|
key: optionKey,
|
|
386
386
|
value: data.preview
|
|
387
387
|
? toArray(data.preview)
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
388
|
+
.map((k, i) =>
|
|
389
|
+
i === -1 ? `${k}:${optionValue[k]}` : optionValue[k],
|
|
390
|
+
)
|
|
391
|
+
.join(" | ")
|
|
392
392
|
: typeof optionValue === "object"
|
|
393
|
-
|
|
394
|
-
|
|
393
|
+
? JSON.stringify(optionValue)
|
|
394
|
+
: optionValue,
|
|
395
395
|
};
|
|
396
396
|
});
|
|
397
397
|
let filteredViewOptions = viewOptions;
|
|
@@ -514,10 +514,10 @@ async function multiSelect(content, data) {
|
|
|
514
514
|
);
|
|
515
515
|
focusedIndex = viewOptions.indexOf(
|
|
516
516
|
filteredViewOptions[
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
517
|
+
Math.min(
|
|
518
|
+
filterIdx + 1,
|
|
519
|
+
filteredViewOptions.length - 1,
|
|
520
|
+
)
|
|
521
521
|
],
|
|
522
522
|
);
|
|
523
523
|
restrictFocusedIndex();
|
|
@@ -598,19 +598,19 @@ async function multiSelect(content, data) {
|
|
|
598
598
|
if (inputsChg) {
|
|
599
599
|
focusedIndex = 0;
|
|
600
600
|
const inputStr = inputs.join("");
|
|
601
|
-
const inputParts = inputStr?.split(/[, ]+/).filter((v) => v);
|
|
602
|
-
filteredViewOptions = !inputParts
|
|
601
|
+
const inputParts = inputStr?.split(/[, ]+/).map(v => v.trim()).filter((v) => v);
|
|
602
|
+
filteredViewOptions = !inputParts?.length
|
|
603
603
|
? viewOptions
|
|
604
604
|
: viewOptions.filter((option, i) => {
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
605
|
+
const valueStr = JSON.stringify(option.value);
|
|
606
|
+
return inputParts.some((part) => {
|
|
607
|
+
return (
|
|
608
|
+
part === i ||
|
|
609
|
+
part === option.key ||
|
|
610
|
+
valueStr.indexOf(part) !== -1
|
|
611
|
+
);
|
|
612
|
+
});
|
|
613
|
+
});
|
|
614
614
|
if (inputStr && filteredViewOptions.length) {
|
|
615
615
|
focusedIndex = viewOptions.indexOf(filteredViewOptions[0]);
|
|
616
616
|
}
|
package/utils/transform_tool.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
const { homedir } = require('node:os');
|
|
2
|
+
const path = require('node:path');
|
|
3
|
+
const fs = require("node:fs");
|
|
4
|
+
|
|
1
5
|
function toArray(value) {
|
|
2
6
|
if (Array.isArray(value)) {
|
|
3
7
|
return value;
|
|
@@ -542,6 +546,68 @@ function getDataByKeySimple(key, from) {
|
|
|
542
546
|
return val;
|
|
543
547
|
}
|
|
544
548
|
|
|
549
|
+
|
|
550
|
+
/**
|
|
551
|
+
* 获取完整真实路径
|
|
552
|
+
* @param {*} src
|
|
553
|
+
*/
|
|
554
|
+
function get_full_path(src, createIfNotExist) {
|
|
555
|
+
const dstDir = path
|
|
556
|
+
.resolve(src.replace(/^~/, homedir()))
|
|
557
|
+
.replace(/\\/g, "/");
|
|
558
|
+
let targetDir;
|
|
559
|
+
switch (createIfNotExist) {
|
|
560
|
+
case "FILE": {
|
|
561
|
+
targetDir = path.dirname(dstDir);
|
|
562
|
+
break;
|
|
563
|
+
}
|
|
564
|
+
case "FOLDER": {
|
|
565
|
+
targetDir = dstDir;
|
|
566
|
+
break;
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
if (
|
|
570
|
+
targetDir &&
|
|
571
|
+
(!fs.existsSync(targetDir) || !fs.lstatSync(targetDir).isDirectory())
|
|
572
|
+
) {
|
|
573
|
+
fs.mkdirSync(targetDir, {
|
|
574
|
+
recursive: true,
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
return dstDir;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
|
|
581
|
+
function format_bytes(size) {
|
|
582
|
+
const isNegative = size < 0;
|
|
583
|
+
size = Math.abs(size);
|
|
584
|
+
if (size < 2 ** 10) {
|
|
585
|
+
return `${isNegative ? "-" : ""}${size}B`;
|
|
586
|
+
}
|
|
587
|
+
if (size < 2 ** 20) {
|
|
588
|
+
return `${isNegative ? "-" : ""}${+(size / 2 ** 10).toFixed(2)}KB`;
|
|
589
|
+
}
|
|
590
|
+
if (size < 2 ** 30) {
|
|
591
|
+
return `${isNegative ? "-" : ""}${+(size / 2 ** 20).toFixed(2)}MB`;
|
|
592
|
+
}
|
|
593
|
+
if (size < 2 ** 40) {
|
|
594
|
+
return `${isNegative ? "-" : ""}${+(size / 2 ** 30).toFixed(2)}GB`;
|
|
595
|
+
}
|
|
596
|
+
if (size < 2 ** 50) {
|
|
597
|
+
return `${isNegative ? "-" : ""}${+(size / 2 ** 40).toFixed(2)}TB`;
|
|
598
|
+
}
|
|
599
|
+
if (size < 2 ** 60) {
|
|
600
|
+
return `${isNegative ? "-" : ""}${+(size / 2 ** 50).toFixed(2)}PB`;
|
|
601
|
+
}
|
|
602
|
+
if (size < 2 ** 70) {
|
|
603
|
+
return `${isNegative ? "-" : ""}${+(size / 2 ** 60).toFixed(2)}EB`;
|
|
604
|
+
}
|
|
605
|
+
if (size < 2 ** 80) {
|
|
606
|
+
return `${isNegative ? "-" : ""}${+(size / 2 ** 70).toFixed(2)}ZB`;
|
|
607
|
+
}
|
|
608
|
+
return `${isNegative ? "-" : ""}${+(size / 2 ** 80).toFixed(2)}YB`;
|
|
609
|
+
}
|
|
610
|
+
|
|
545
611
|
module.exports = {
|
|
546
612
|
toArray,
|
|
547
613
|
format,
|
|
@@ -562,4 +628,6 @@ module.exports = {
|
|
|
562
628
|
removeDuplicate,
|
|
563
629
|
removeDuplicateObject,
|
|
564
630
|
getByteSize,
|
|
631
|
+
get_full_path,
|
|
632
|
+
format_bytes,
|
|
565
633
|
};
|