@icyfenix-dmla/cli 2026.5.2-2025 → 2026.5.2-2114
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/package.json +1 -1
- package/src/commands/data.js +94 -32
package/package.json
CHANGED
package/src/commands/data.js
CHANGED
|
@@ -49,6 +49,16 @@ const DATASETS = [
|
|
|
49
49
|
}
|
|
50
50
|
]
|
|
51
51
|
|
|
52
|
+
/**
|
|
53
|
+
* 检查是否是用户取消操作(ESC 或 Ctrl+C)
|
|
54
|
+
* enquirer 可能抛出空字符串错误或包含 'cancel' 的消息
|
|
55
|
+
*/
|
|
56
|
+
function isUserCancel(error) {
|
|
57
|
+
return !error.message ||
|
|
58
|
+
error.message === '' ||
|
|
59
|
+
error.message.includes('cancel')
|
|
60
|
+
}
|
|
61
|
+
|
|
52
62
|
/**
|
|
53
63
|
* 显示 Banner
|
|
54
64
|
*/
|
|
@@ -455,7 +465,7 @@ async function downloadDatasets() {
|
|
|
455
465
|
console.log(chalk.green('所有选中的数据集已处理完成'))
|
|
456
466
|
} catch (error) {
|
|
457
467
|
// 用户按 ESC 或 Ctrl+C 取消
|
|
458
|
-
if (error
|
|
468
|
+
if (isUserCancel(error)) {
|
|
459
469
|
console.log(chalk.gray('返回上一级'))
|
|
460
470
|
return
|
|
461
471
|
}
|
|
@@ -615,49 +625,101 @@ export async function runDataTUI() {
|
|
|
615
625
|
console.log(chalk.yellow(`数据目录不存在: ${dataPath}`))
|
|
616
626
|
console.log()
|
|
617
627
|
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
628
|
+
try {
|
|
629
|
+
const { create } = await prompt({
|
|
630
|
+
type: 'confirm',
|
|
631
|
+
name: 'create',
|
|
632
|
+
message: '是否创建数据目录?',
|
|
633
|
+
initial: true
|
|
634
|
+
})
|
|
624
635
|
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
636
|
+
if (create) {
|
|
637
|
+
ensureDataDirStructure(dataPath)
|
|
638
|
+
console.log(chalk.green(`数据目录已创建: ${dataPath}`))
|
|
639
|
+
}
|
|
640
|
+
} catch (error) {
|
|
641
|
+
if (isUserCancel(error)) {
|
|
642
|
+
console.log(chalk.gray('已退出数据管理'))
|
|
643
|
+
console.log()
|
|
644
|
+
return
|
|
645
|
+
}
|
|
646
|
+
throw error
|
|
628
647
|
}
|
|
629
648
|
}
|
|
630
649
|
|
|
631
650
|
// 主循环
|
|
632
651
|
while (true) {
|
|
633
652
|
console.log()
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
+
try {
|
|
654
|
+
const action = await showMainMenu(dataPath)
|
|
655
|
+
|
|
656
|
+
switch (action) {
|
|
657
|
+
case 1:
|
|
658
|
+
try {
|
|
659
|
+
await mountPath()
|
|
660
|
+
} catch (error) {
|
|
661
|
+
if (isUserCancel(error)) {
|
|
662
|
+
console.log(chalk.gray('返回主菜单'))
|
|
663
|
+
} else {
|
|
664
|
+
throw error
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
break
|
|
668
|
+
case 2:
|
|
669
|
+
try {
|
|
670
|
+
await downloadDatasets()
|
|
671
|
+
} catch (error) {
|
|
672
|
+
if (isUserCancel(error)) {
|
|
673
|
+
console.log(chalk.gray('返回主菜单'))
|
|
674
|
+
} else {
|
|
675
|
+
throw error
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
break
|
|
679
|
+
case 3:
|
|
680
|
+
listDatasets()
|
|
681
|
+
break
|
|
682
|
+
case 4:
|
|
683
|
+
try {
|
|
684
|
+
await clearData()
|
|
685
|
+
} catch (error) {
|
|
686
|
+
if (isUserCancel(error)) {
|
|
687
|
+
console.log(chalk.gray('返回主菜单'))
|
|
688
|
+
} else {
|
|
689
|
+
throw error
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
break
|
|
693
|
+
case 5:
|
|
694
|
+
try {
|
|
695
|
+
await removeData()
|
|
696
|
+
} catch (error) {
|
|
697
|
+
if (isUserCancel(error)) {
|
|
698
|
+
console.log(chalk.gray('返回主菜单'))
|
|
699
|
+
} else {
|
|
700
|
+
throw error
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
break
|
|
704
|
+
case 6:
|
|
705
|
+
console.log()
|
|
706
|
+
console.log(chalk.gray('已退出数据管理'))
|
|
707
|
+
console.log()
|
|
708
|
+
return
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
// 刷新路径(可能在操作中修改了)
|
|
712
|
+
dataPath = getDataVolumePath()
|
|
713
|
+
} catch (error) {
|
|
714
|
+
// 主菜单按 ESC 取消 -> 退出程序
|
|
715
|
+
if (isUserCancel(error)) {
|
|
653
716
|
console.log()
|
|
654
717
|
console.log(chalk.gray('已退出数据管理'))
|
|
655
718
|
console.log()
|
|
656
719
|
return
|
|
720
|
+
}
|
|
721
|
+
throw error
|
|
657
722
|
}
|
|
658
|
-
|
|
659
|
-
// 刷新路径(可能在操作中修改了)
|
|
660
|
-
dataPath = getDataVolumePath()
|
|
661
723
|
}
|
|
662
724
|
}
|
|
663
725
|
|