@king-3/file-kit 1.4.0 → 1.4.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/dist/cli.js +21 -13
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -165,8 +165,16 @@ const base64ToBuffer = (data) => Buffer.from(data, "base64");
|
|
|
165
165
|
//#endregion
|
|
166
166
|
//#region src/utils/time.ts
|
|
167
167
|
function nowUTC8() {
|
|
168
|
-
|
|
169
|
-
|
|
168
|
+
return (/* @__PURE__ */ new Date()).toLocaleString("zh-CN", {
|
|
169
|
+
timeZone: "Asia/Shanghai",
|
|
170
|
+
year: "numeric",
|
|
171
|
+
month: "2-digit",
|
|
172
|
+
day: "2-digit",
|
|
173
|
+
hour: "2-digit",
|
|
174
|
+
minute: "2-digit",
|
|
175
|
+
second: "2-digit",
|
|
176
|
+
hour12: false
|
|
177
|
+
}).replace(/\//g, "-");
|
|
170
178
|
}
|
|
171
179
|
|
|
172
180
|
//#endregion
|
|
@@ -226,7 +234,7 @@ async function base64ToFile(archiveData, outputDir = ".") {
|
|
|
226
234
|
//#endregion
|
|
227
235
|
//#region src/config/defaults.ts
|
|
228
236
|
const CLI_NAME = "File Kit";
|
|
229
|
-
const CLI_VERSION = "1.4.
|
|
237
|
+
const CLI_VERSION = "1.4.1";
|
|
230
238
|
const CLI_ALIAS = "fkt";
|
|
231
239
|
/**
|
|
232
240
|
* 默认配置
|
|
@@ -350,7 +358,7 @@ async function getInputPath(providedPath, options) {
|
|
|
350
358
|
}
|
|
351
359
|
return inputPath;
|
|
352
360
|
}
|
|
353
|
-
async function getPassword(providedPwd) {
|
|
361
|
+
async function getPassword(providedPwd, options) {
|
|
354
362
|
let userPwd = providedPwd;
|
|
355
363
|
if (!userPwd) {
|
|
356
364
|
userPwd = await password$1({
|
|
@@ -360,14 +368,14 @@ async function getPassword(providedPwd) {
|
|
|
360
368
|
if (value.length < 6) return "密码长度至少 6 位";
|
|
361
369
|
}
|
|
362
370
|
});
|
|
363
|
-
await password$1({
|
|
371
|
+
if (options?.confirm) await password$1({
|
|
364
372
|
message: "请再次输入密码:",
|
|
365
373
|
validate: (value) => {
|
|
366
374
|
if (value !== userPwd) return "两次密码不一致";
|
|
367
375
|
}
|
|
368
376
|
});
|
|
369
377
|
} else if (typeof userPwd === "string" && userPwd.length < 6) {
|
|
370
|
-
logger.error(
|
|
378
|
+
logger.error("密码长度至少 6 位");
|
|
371
379
|
process.exit(1);
|
|
372
380
|
}
|
|
373
381
|
return userPwd;
|
|
@@ -442,7 +450,7 @@ var base64_default = defineCommand({
|
|
|
442
450
|
const typedArgs = args;
|
|
443
451
|
const ctx = createCommandContext(rawArgs);
|
|
444
452
|
ctx.showIntro();
|
|
445
|
-
tryCatch(async () => {
|
|
453
|
+
await tryCatch(async () => {
|
|
446
454
|
const inputPath = await ctx.getInput(typedArgs.input, {
|
|
447
455
|
message: "请输入文件路径",
|
|
448
456
|
placeholder: "file.txt"
|
|
@@ -589,14 +597,14 @@ var decrypt_default = defineCommand({
|
|
|
589
597
|
const typedArgs = args;
|
|
590
598
|
const ctx = createCommandContext(rawArgs);
|
|
591
599
|
ctx.showIntro();
|
|
592
|
-
tryCatch(async () => {
|
|
600
|
+
await tryCatch(async () => {
|
|
593
601
|
const inputPath = await ctx.getInput(typedArgs.input, {
|
|
594
602
|
message: "请输入文件路径",
|
|
595
603
|
placeholder: "*.crypto.txt",
|
|
596
604
|
validateExtension: ".crypto.txt"
|
|
597
605
|
});
|
|
598
606
|
const outputDir = await ctx.getOutput(typedArgs.output, { defaultDir: path.dirname(inputPath) });
|
|
599
|
-
const password$2 = await getPassword(typedArgs.password);
|
|
607
|
+
const password$2 = await getPassword(typedArgs.password, { confirm: false });
|
|
600
608
|
const loading$1 = ctx.loading("正在解密");
|
|
601
609
|
const outputPath = await decrypt(await loadArchive(inputPath, "crypto"), outputDir, { password: password$2 });
|
|
602
610
|
loading$1.close(`文件已解密到: ${cyan(outputPath)}`);
|
|
@@ -633,13 +641,13 @@ var encrypt_default = defineCommand({
|
|
|
633
641
|
const typedArgs = args;
|
|
634
642
|
const ctx = createCommandContext(rawArgs);
|
|
635
643
|
ctx.showIntro();
|
|
636
|
-
tryCatch(async () => {
|
|
644
|
+
await tryCatch(async () => {
|
|
637
645
|
const inputPath = await ctx.getInput(typedArgs.input, {
|
|
638
646
|
message: "请输入文件路径",
|
|
639
647
|
placeholder: "file.txt"
|
|
640
648
|
});
|
|
641
649
|
const outputDir = await ctx.getOutput(typedArgs.output, { defaultDir: path$1.dirname(inputPath) });
|
|
642
|
-
const password$2 = await getPassword(typedArgs.password);
|
|
650
|
+
const password$2 = await getPassword(typedArgs.password, { confirm: true });
|
|
643
651
|
console.log(gray("│"));
|
|
644
652
|
logger.warn(yellow("请妥善保管密码,丢失后无法恢复文件!"));
|
|
645
653
|
const outputPath = buildOutputPath(inputPath, outputDir, "crypto.txt");
|
|
@@ -673,7 +681,7 @@ var restore_default = defineCommand({
|
|
|
673
681
|
const typedArgs = args;
|
|
674
682
|
const ctx = createCommandContext(rawArgs);
|
|
675
683
|
ctx.showIntro();
|
|
676
|
-
tryCatch(async () => {
|
|
684
|
+
await tryCatch(async () => {
|
|
677
685
|
const inputPath = await ctx.getInput(typedArgs.input, {
|
|
678
686
|
message: "请输入文件路径",
|
|
679
687
|
placeholder: "*.base64.txt",
|
|
@@ -915,7 +923,7 @@ var video_to_audio_default = defineCommand({
|
|
|
915
923
|
const typedArgs = args;
|
|
916
924
|
const ctx = createCommandContext(rawArgs);
|
|
917
925
|
ctx.showIntro();
|
|
918
|
-
tryCatch(async () => {
|
|
926
|
+
await tryCatch(async () => {
|
|
919
927
|
const inputPath = await ctx.getInput(typedArgs.input, {
|
|
920
928
|
message: "请输入视频文件路径",
|
|
921
929
|
placeholder: "video.mp4"
|