grf-cli 1.0.2 → 1.0.4
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/README.md +15 -7
- package/README.zh-CN.md +15 -7
- package/dist/cli.js +2 -14
- package/dist/cli.js.map +1 -1
- package/dist/commands/add/display.d.ts +10 -0
- package/dist/commands/add/display.d.ts.map +1 -0
- package/dist/commands/add/display.js +25 -0
- package/dist/commands/add/display.js.map +1 -0
- package/dist/commands/add/helpers.d.ts +11 -0
- package/dist/commands/add/helpers.d.ts.map +1 -0
- package/dist/commands/add/helpers.js +59 -0
- package/dist/commands/add/helpers.js.map +1 -0
- package/dist/commands/add/index.d.ts +12 -0
- package/dist/commands/add/index.d.ts.map +1 -0
- package/dist/commands/add/index.js +57 -0
- package/dist/commands/add/index.js.map +1 -0
- package/dist/commands/add/types.d.ts +32 -0
- package/dist/commands/add/types.d.ts.map +1 -0
- package/dist/commands/add/types.js +6 -0
- package/dist/commands/add/types.js.map +1 -0
- package/dist/commands/add.d.ts +5 -0
- package/dist/commands/add.d.ts.map +1 -1
- package/dist/commands/add.js +21 -21
- package/dist/commands/add.js.map +1 -1
- package/dist/commands/clean/display.d.ts +30 -0
- package/dist/commands/clean/display.d.ts.map +1 -0
- package/dist/commands/clean/display.js +67 -0
- package/dist/commands/clean/display.js.map +1 -0
- package/dist/commands/clean/handlers/clean-all.d.ts +12 -0
- package/dist/commands/clean/handlers/clean-all.d.ts.map +1 -0
- package/dist/commands/clean/handlers/clean-all.js +43 -0
- package/dist/commands/clean/handlers/clean-all.js.map +1 -0
- package/dist/commands/clean/handlers/clean-single.d.ts +13 -0
- package/dist/commands/clean/handlers/clean-single.d.ts.map +1 -0
- package/dist/commands/clean/handlers/clean-single.js +78 -0
- package/dist/commands/clean/handlers/clean-single.js.map +1 -0
- package/dist/commands/clean/handlers/index.d.ts +6 -0
- package/dist/commands/clean/handlers/index.d.ts.map +1 -0
- package/dist/commands/clean/handlers/index.js +11 -0
- package/dist/commands/clean/handlers/index.js.map +1 -0
- package/dist/commands/clean/helpers.d.ts +25 -0
- package/dist/commands/clean/helpers.d.ts.map +1 -0
- package/dist/commands/clean/helpers.js +70 -0
- package/dist/commands/clean/helpers.js.map +1 -0
- package/dist/commands/clean/index.d.ts +12 -0
- package/dist/commands/clean/index.d.ts.map +1 -0
- package/dist/commands/clean/index.js +90 -0
- package/dist/commands/clean/index.js.map +1 -0
- package/dist/commands/clean/types.d.ts +21 -0
- package/dist/commands/clean/types.d.ts.map +1 -0
- package/dist/commands/clean/types.js +6 -0
- package/dist/commands/clean/types.js.map +1 -0
- package/dist/commands/clean.d.ts +5 -0
- package/dist/commands/clean.d.ts.map +1 -1
- package/dist/commands/clean.js +18 -35
- package/dist/commands/clean.js.map +1 -1
- package/dist/commands/config/display.d.ts +36 -0
- package/dist/commands/config/display.d.ts.map +1 -0
- package/dist/commands/config/display.js +86 -0
- package/dist/commands/config/display.js.map +1 -0
- package/dist/commands/config/handlers/index.d.ts +8 -0
- package/dist/commands/config/handlers/index.d.ts.map +1 -0
- package/dist/commands/config/handlers/index.js +15 -0
- package/dist/commands/config/handlers/index.js.map +1 -0
- package/dist/commands/config/handlers/set-value.d.ts +11 -0
- package/dist/commands/config/handlers/set-value.d.ts.map +1 -0
- package/dist/commands/config/handlers/set-value.js +36 -0
- package/dist/commands/config/handlers/set-value.js.map +1 -0
- package/dist/commands/config/handlers/show-all.d.ts +11 -0
- package/dist/commands/config/handlers/show-all.d.ts.map +1 -0
- package/dist/commands/config/handlers/show-all.js +24 -0
- package/dist/commands/config/handlers/show-all.js.map +1 -0
- package/dist/commands/config/handlers/show-path.d.ts +11 -0
- package/dist/commands/config/handlers/show-path.d.ts.map +1 -0
- package/dist/commands/config/handlers/show-path.js +20 -0
- package/dist/commands/config/handlers/show-path.js.map +1 -0
- package/dist/commands/config/handlers/show-value.d.ts +11 -0
- package/dist/commands/config/handlers/show-value.d.ts.map +1 -0
- package/dist/commands/config/handlers/show-value.js +31 -0
- package/dist/commands/config/handlers/show-value.js.map +1 -0
- package/dist/commands/config/helpers.d.ts +23 -0
- package/dist/commands/config/helpers.d.ts.map +1 -0
- package/dist/commands/config/helpers.js +53 -0
- package/dist/commands/config/helpers.js.map +1 -0
- package/dist/commands/config/index.d.ts +12 -0
- package/dist/commands/config/index.d.ts.map +1 -0
- package/dist/commands/config/index.js +56 -0
- package/dist/commands/config/index.js.map +1 -0
- package/dist/commands/config/types.d.ts +31 -0
- package/dist/commands/config/types.d.ts.map +1 -0
- package/dist/commands/config/types.js +13 -0
- package/dist/commands/config/types.js.map +1 -0
- package/dist/commands/config.d.ts +5 -0
- package/dist/commands/config.d.ts.map +1 -1
- package/dist/commands/config.js +22 -41
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/index.d.ts +27 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +52 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/list/display.d.ts +39 -0
- package/dist/commands/list/display.d.ts.map +1 -0
- package/dist/commands/list/display.js +144 -0
- package/dist/commands/list/display.js.map +1 -0
- package/dist/commands/list/index.d.ts +12 -0
- package/dist/commands/list/index.d.ts.map +1 -0
- package/dist/commands/list/index.js +128 -0
- package/dist/commands/list/index.js.map +1 -0
- package/dist/commands/list/types.d.ts +32 -0
- package/dist/commands/list/types.d.ts.map +1 -0
- package/dist/commands/list/types.js +6 -0
- package/dist/commands/list/types.js.map +1 -0
- package/dist/commands/list.d.ts +5 -0
- package/dist/commands/list.d.ts.map +1 -1
- package/dist/commands/list.js +29 -60
- package/dist/commands/list.js.map +1 -1
- package/dist/commands/load/display.d.ts +28 -0
- package/dist/commands/load/display.d.ts.map +1 -0
- package/dist/commands/load/display.js +53 -0
- package/dist/commands/load/display.js.map +1 -0
- package/dist/commands/load/handlers/copy-repo.d.ts +13 -0
- package/dist/commands/load/handlers/copy-repo.d.ts.map +1 -0
- package/dist/commands/load/handlers/copy-repo.js +82 -0
- package/dist/commands/load/handlers/copy-repo.js.map +1 -0
- package/dist/commands/load/handlers/index.d.ts +6 -0
- package/dist/commands/load/handlers/index.d.ts.map +1 -0
- package/dist/commands/load/handlers/index.js +11 -0
- package/dist/commands/load/handlers/index.js.map +1 -0
- package/dist/commands/load/handlers/url-add.d.ts +13 -0
- package/dist/commands/load/handlers/url-add.d.ts.map +1 -0
- package/dist/commands/load/handlers/url-add.js +50 -0
- package/dist/commands/load/handlers/url-add.js.map +1 -0
- package/dist/commands/load/helpers.d.ts +81 -0
- package/dist/commands/load/helpers.d.ts.map +1 -0
- package/dist/commands/load/helpers.js +199 -0
- package/dist/commands/load/helpers.js.map +1 -0
- package/dist/commands/load/index.d.ts +13 -0
- package/dist/commands/load/index.d.ts.map +1 -0
- package/dist/commands/load/index.js +46 -0
- package/dist/commands/load/index.js.map +1 -0
- package/dist/commands/load/types.d.ts +37 -0
- package/dist/commands/load/types.d.ts.map +1 -0
- package/dist/commands/load/types.js +6 -0
- package/dist/commands/load/types.js.map +1 -0
- package/dist/commands/load.d.ts +5 -0
- package/dist/commands/load.d.ts.map +1 -1
- package/dist/commands/load.js +27 -64
- package/dist/commands/load.js.map +1 -1
- package/dist/commands/options/all.d.ts +11 -0
- package/dist/commands/options/all.d.ts.map +1 -0
- package/dist/commands/options/all.js +14 -0
- package/dist/commands/options/all.js.map +1 -0
- package/dist/commands/options/branch.d.ts +11 -0
- package/dist/commands/options/branch.d.ts.map +1 -0
- package/dist/commands/options/branch.js +14 -0
- package/dist/commands/options/branch.js.map +1 -0
- package/dist/commands/options/check.d.ts +11 -0
- package/dist/commands/options/check.d.ts.map +1 -0
- package/dist/commands/options/check.js +14 -0
- package/dist/commands/options/check.js.map +1 -0
- package/dist/commands/options/clean-empty.d.ts +11 -0
- package/dist/commands/options/clean-empty.d.ts.map +1 -0
- package/dist/commands/options/clean-empty.js +14 -0
- package/dist/commands/options/clean-empty.js.map +1 -0
- package/dist/commands/options/depth.d.ts +11 -0
- package/dist/commands/options/depth.d.ts.map +1 -0
- package/dist/commands/options/depth.js +14 -0
- package/dist/commands/options/depth.js.map +1 -0
- package/dist/commands/options/dry-run.d.ts +11 -0
- package/dist/commands/options/dry-run.d.ts.map +1 -0
- package/dist/commands/options/dry-run.js +14 -0
- package/dist/commands/options/dry-run.js.map +1 -0
- package/dist/commands/options/force.d.ts +11 -0
- package/dist/commands/options/force.d.ts.map +1 -0
- package/dist/commands/options/force.js +14 -0
- package/dist/commands/options/force.js.map +1 -0
- package/dist/commands/options/index.d.ts +24 -0
- package/dist/commands/options/index.d.ts.map +1 -0
- package/dist/commands/options/index.js +53 -0
- package/dist/commands/options/index.js.map +1 -0
- package/dist/commands/options/json.d.ts +11 -0
- package/dist/commands/options/json.d.ts.map +1 -0
- package/dist/commands/options/json.js +14 -0
- package/dist/commands/options/json.js.map +1 -0
- package/dist/commands/options/keep-empty.d.ts +11 -0
- package/dist/commands/options/keep-empty.d.ts.map +1 -0
- package/dist/commands/options/keep-empty.js +14 -0
- package/dist/commands/options/keep-empty.js.map +1 -0
- package/dist/commands/options/list.d.ts +11 -0
- package/dist/commands/options/list.d.ts.map +1 -0
- package/dist/commands/options/list.js +14 -0
- package/dist/commands/options/list.js.map +1 -0
- package/dist/commands/options/name.d.ts +11 -0
- package/dist/commands/options/name.d.ts.map +1 -0
- package/dist/commands/options/name.js +14 -0
- package/dist/commands/options/name.js.map +1 -0
- package/dist/commands/options/no-ignore.d.ts +11 -0
- package/dist/commands/options/no-ignore.d.ts.map +1 -0
- package/dist/commands/options/no-ignore.js +14 -0
- package/dist/commands/options/no-ignore.js.map +1 -0
- package/dist/commands/options/path.d.ts +11 -0
- package/dist/commands/options/path.d.ts.map +1 -0
- package/dist/commands/options/path.js +14 -0
- package/dist/commands/options/path.js.map +1 -0
- package/dist/commands/options/shallow.d.ts +16 -0
- package/dist/commands/options/shallow.d.ts.map +1 -0
- package/dist/commands/options/shallow.js +19 -0
- package/dist/commands/options/shallow.js.map +1 -0
- package/dist/commands/options/status.d.ts +11 -0
- package/dist/commands/options/status.d.ts.map +1 -0
- package/dist/commands/options/status.js +14 -0
- package/dist/commands/options/status.js.map +1 -0
- package/dist/commands/options/subdir.d.ts +11 -0
- package/dist/commands/options/subdir.d.ts.map +1 -0
- package/dist/commands/options/subdir.js +14 -0
- package/dist/commands/options/subdir.js.map +1 -0
- package/dist/commands/options/sync-only.d.ts +11 -0
- package/dist/commands/options/sync-only.d.ts.map +1 -0
- package/dist/commands/options/sync-only.js +14 -0
- package/dist/commands/options/sync-only.js.map +1 -0
- package/dist/commands/options/sync.d.ts +11 -0
- package/dist/commands/options/sync.d.ts.map +1 -0
- package/dist/commands/options/sync.js +14 -0
- package/dist/commands/options/sync.js.map +1 -0
- package/dist/commands/options/verbose.d.ts +11 -0
- package/dist/commands/options/verbose.d.ts.map +1 -0
- package/dist/commands/options/verbose.js +14 -0
- package/dist/commands/options/verbose.js.map +1 -0
- package/dist/commands/unload/display.d.ts +29 -0
- package/dist/commands/unload/display.d.ts.map +1 -0
- package/dist/commands/unload/display.js +125 -0
- package/dist/commands/unload/display.js.map +1 -0
- package/dist/commands/unload/handlers/clean-empty.d.ts +11 -0
- package/dist/commands/unload/handlers/clean-empty.d.ts.map +1 -0
- package/dist/commands/unload/handlers/clean-empty.js +111 -0
- package/dist/commands/unload/handlers/clean-empty.js.map +1 -0
- package/dist/commands/unload/handlers/index.d.ts +8 -0
- package/dist/commands/unload/handlers/index.d.ts.map +1 -0
- package/dist/commands/unload/handlers/index.js +15 -0
- package/dist/commands/unload/handlers/index.js.map +1 -0
- package/dist/commands/unload/handlers/list.d.ts +11 -0
- package/dist/commands/unload/handlers/list.d.ts.map +1 -0
- package/dist/commands/unload/handlers/list.js +42 -0
- package/dist/commands/unload/handlers/list.js.map +1 -0
- package/dist/commands/unload/handlers/remove-all.d.ts +11 -0
- package/dist/commands/unload/handlers/remove-all.d.ts.map +1 -0
- package/dist/commands/unload/handlers/remove-all.js +184 -0
- package/dist/commands/unload/handlers/remove-all.js.map +1 -0
- package/dist/commands/unload/handlers/remove-single.d.ts +12 -0
- package/dist/commands/unload/handlers/remove-single.d.ts.map +1 -0
- package/dist/commands/unload/handlers/remove-single.js +217 -0
- package/dist/commands/unload/handlers/remove-single.js.map +1 -0
- package/dist/commands/unload/helpers.d.ts +55 -0
- package/dist/commands/unload/helpers.d.ts.map +1 -0
- package/dist/commands/unload/helpers.js +256 -0
- package/dist/commands/unload/helpers.js.map +1 -0
- package/dist/commands/unload/index.d.ts +12 -0
- package/dist/commands/unload/index.d.ts.map +1 -0
- package/dist/commands/unload/index.js +121 -0
- package/dist/commands/unload/index.js.map +1 -0
- package/dist/commands/unload/types.d.ts +53 -0
- package/dist/commands/unload/types.d.ts.map +1 -0
- package/dist/commands/unload/types.js +6 -0
- package/dist/commands/unload/types.js.map +1 -0
- package/dist/commands/unload.d.ts +6 -1
- package/dist/commands/unload.d.ts.map +1 -1
- package/dist/commands/unload.js +165 -169
- package/dist/commands/unload.js.map +1 -1
- package/dist/commands/update/display.d.ts +30 -0
- package/dist/commands/update/display.d.ts.map +1 -0
- package/dist/commands/update/display.js +161 -0
- package/dist/commands/update/display.js.map +1 -0
- package/dist/commands/update/handlers/index.d.ts +8 -0
- package/dist/commands/update/handlers/index.d.ts.map +1 -0
- package/dist/commands/update/handlers/index.js +15 -0
- package/dist/commands/update/handlers/index.js.map +1 -0
- package/dist/commands/update/handlers/status.d.ts +11 -0
- package/dist/commands/update/handlers/status.d.ts.map +1 -0
- package/dist/commands/update/handlers/status.js +20 -0
- package/dist/commands/update/handlers/status.js.map +1 -0
- package/dist/commands/update/handlers/sync-only.d.ts +11 -0
- package/dist/commands/update/handlers/sync-only.d.ts.map +1 -0
- package/dist/commands/update/handlers/sync-only.js +41 -0
- package/dist/commands/update/handlers/sync-only.js.map +1 -0
- package/dist/commands/update/handlers/update-all.d.ts +10 -0
- package/dist/commands/update/handlers/update-all.d.ts.map +1 -0
- package/dist/commands/update/handlers/update-all.js +125 -0
- package/dist/commands/update/handlers/update-all.js.map +1 -0
- package/dist/commands/update/handlers/update-single.d.ts +11 -0
- package/dist/commands/update/handlers/update-single.d.ts.map +1 -0
- package/dist/commands/update/handlers/update-single.js +154 -0
- package/dist/commands/update/handlers/update-single.js.map +1 -0
- package/dist/commands/update/helpers.d.ts +13 -0
- package/dist/commands/update/helpers.d.ts.map +1 -0
- package/dist/commands/update/helpers.js +86 -0
- package/dist/commands/update/helpers.js.map +1 -0
- package/dist/commands/update/index.d.ts +12 -0
- package/dist/commands/update/index.d.ts.map +1 -0
- package/dist/commands/update/index.js +67 -0
- package/dist/commands/update/index.js.map +1 -0
- package/dist/commands/update/types.d.ts +55 -0
- package/dist/commands/update/types.d.ts.map +1 -0
- package/dist/commands/update/types.js +6 -0
- package/dist/commands/update/types.js.map +1 -0
- package/dist/commands/update.d.ts +6 -1
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +73 -80
- package/dist/commands/update.js.map +1 -1
- package/dist/core/config-manager.d.ts +83 -0
- package/dist/core/config-manager.d.ts.map +1 -0
- package/dist/core/config-manager.js +170 -0
- package/dist/core/config-manager.js.map +1 -0
- package/dist/core/config.d.ts +22 -2
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +71 -35
- package/dist/core/config.js.map +1 -1
- package/dist/core/filesystem.js +1 -1
- package/dist/core/filesystem.js.map +1 -1
- package/dist/core/loading-state.d.ts +141 -0
- package/dist/core/loading-state.d.ts.map +1 -0
- package/dist/core/loading-state.js +237 -0
- package/dist/core/loading-state.js.map +1 -0
- package/dist/core/loading.d.ts +24 -27
- package/dist/core/loading.d.ts.map +1 -1
- package/dist/core/loading.js +127 -88
- package/dist/core/loading.js.map +1 -1
- package/dist/core/migration.d.ts +54 -0
- package/dist/core/migration.d.ts.map +1 -0
- package/dist/core/migration.js +277 -0
- package/dist/core/migration.js.map +1 -0
- package/dist/core/paths.d.ts +58 -0
- package/dist/core/paths.d.ts.map +1 -0
- package/dist/core/paths.js +103 -0
- package/dist/core/paths.js.map +1 -0
- package/dist/core/repos-index.d.ts +113 -0
- package/dist/core/repos-index.d.ts.map +1 -0
- package/dist/core/repos-index.js +206 -0
- package/dist/core/repos-index.js.map +1 -0
- package/dist/core/repository.js +2 -2
- package/dist/core/repository.js.map +1 -1
- package/dist/core/sync.d.ts.map +1 -1
- package/dist/core/sync.js +3 -3
- package/dist/core/sync.js.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/ui/format.d.ts +159 -0
- package/dist/ui/format.d.ts.map +1 -0
- package/dist/ui/format.js +300 -0
- package/dist/ui/format.js.map +1 -0
- package/dist/ui/index.d.ts +9 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +53 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ui/prompt.d.ts +94 -0
- package/dist/ui/prompt.d.ts.map +1 -0
- package/dist/ui/prompt.js +223 -0
- package/dist/ui/prompt.js.map +1 -0
- package/dist/ui/spinner.d.ts +99 -0
- package/dist/ui/spinner.d.ts.map +1 -0
- package/dist/ui/spinner.js +136 -0
- package/dist/ui/spinner.js.map +1 -0
- package/dist/ui/table.d.ts +142 -0
- package/dist/ui/table.d.ts.map +1 -0
- package/dist/ui/table.js +213 -0
- package/dist/ui/table.js.map +1 -0
- package/dist/utils/constants.d.ts +152 -0
- package/dist/utils/constants.d.ts.map +1 -0
- package/dist/utils/constants.js +160 -0
- package/dist/utils/constants.js.map +1 -0
- package/dist/utils/error.d.ts +109 -0
- package/dist/utils/error.d.ts.map +1 -0
- package/dist/utils/error.js +212 -0
- package/dist/utils/error.js.map +1 -0
- package/dist/utils/index.d.ts +8 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +44 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/validation.d.ts +122 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +248 -0
- package/dist/utils/validation.js.map +1 -0
- package/package.json +23 -3
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* 格式化输出模块
|
|
4
|
+
* 封装各种数据格式化功能
|
|
5
|
+
*/
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.StatusIcon = void 0;
|
|
11
|
+
exports.shortCommit = shortCommit;
|
|
12
|
+
exports.formatDate = formatDate;
|
|
13
|
+
exports.formatBytes = formatBytes;
|
|
14
|
+
exports.formatNumber = formatNumber;
|
|
15
|
+
exports.formatDuration = formatDuration;
|
|
16
|
+
exports.shortenPath = shortenPath;
|
|
17
|
+
exports.normalizePath = normalizePath;
|
|
18
|
+
exports.formatRepoName = formatRepoName;
|
|
19
|
+
exports.getStatusIcon = getStatusIcon;
|
|
20
|
+
exports.formatError = formatError;
|
|
21
|
+
exports.formatSuccess = formatSuccess;
|
|
22
|
+
exports.formatWarning = formatWarning;
|
|
23
|
+
exports.formatHint = formatHint;
|
|
24
|
+
exports.highlightCommand = highlightCommand;
|
|
25
|
+
exports.highlightPath = highlightPath;
|
|
26
|
+
exports.highlightName = highlightName;
|
|
27
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
28
|
+
/**
|
|
29
|
+
* 截断 commit ID(前 7 个字符)
|
|
30
|
+
* @param commitId 完整的 commit ID
|
|
31
|
+
* @param length 截断长度,默认为 7
|
|
32
|
+
* @returns 截断后的 commit ID
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* shortCommit("abc1234567890"); // "abc1234"
|
|
37
|
+
* shortCommit("abc1234567890", 10); // "abc1234567"
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
function shortCommit(commitId, length = 7) {
|
|
41
|
+
return commitId.substring(0, length);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* 格式化日期
|
|
45
|
+
* @param isoDate ISO 格式日期字符串或 Date 对象
|
|
46
|
+
* @param format 格式类型
|
|
47
|
+
* @returns 格式化后的日期字符串
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* formatDate("2024-01-15T10:30:00Z"); // "1/15/2024"
|
|
52
|
+
* formatDate("2024-01-15T10:30:00Z", "full"); // "1/15/2024, 10:30:00 AM"
|
|
53
|
+
* formatDate("2024-01-15T10:30:00Z", "relative"); // "2 days ago"
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
function formatDate(isoDate, format = "short") {
|
|
57
|
+
const date = typeof isoDate === "string" ? new Date(isoDate) : isoDate;
|
|
58
|
+
switch (format) {
|
|
59
|
+
case "short":
|
|
60
|
+
return date.toLocaleDateString();
|
|
61
|
+
case "full":
|
|
62
|
+
return date.toLocaleString();
|
|
63
|
+
case "iso":
|
|
64
|
+
return date.toISOString();
|
|
65
|
+
case "relative":
|
|
66
|
+
return formatRelativeTime(date);
|
|
67
|
+
default:
|
|
68
|
+
return date.toLocaleDateString();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* 格式化相对时间
|
|
73
|
+
* @param date 日期对象
|
|
74
|
+
* @returns 相对时间字符串
|
|
75
|
+
*/
|
|
76
|
+
function formatRelativeTime(date) {
|
|
77
|
+
const now = new Date();
|
|
78
|
+
const diffMs = now.getTime() - date.getTime();
|
|
79
|
+
const diffSeconds = Math.floor(diffMs / 1000);
|
|
80
|
+
const diffMinutes = Math.floor(diffSeconds / 60);
|
|
81
|
+
const diffHours = Math.floor(diffMinutes / 60);
|
|
82
|
+
const diffDays = Math.floor(diffHours / 24);
|
|
83
|
+
const diffWeeks = Math.floor(diffDays / 7);
|
|
84
|
+
const diffMonths = Math.floor(diffDays / 30);
|
|
85
|
+
const diffYears = Math.floor(diffDays / 365);
|
|
86
|
+
if (diffSeconds < 60) {
|
|
87
|
+
return "just now";
|
|
88
|
+
}
|
|
89
|
+
else if (diffMinutes < 60) {
|
|
90
|
+
return `${diffMinutes} minute${diffMinutes > 1 ? "s" : ""} ago`;
|
|
91
|
+
}
|
|
92
|
+
else if (diffHours < 24) {
|
|
93
|
+
return `${diffHours} hour${diffHours > 1 ? "s" : ""} ago`;
|
|
94
|
+
}
|
|
95
|
+
else if (diffDays < 7) {
|
|
96
|
+
return `${diffDays} day${diffDays > 1 ? "s" : ""} ago`;
|
|
97
|
+
}
|
|
98
|
+
else if (diffWeeks < 4) {
|
|
99
|
+
return `${diffWeeks} week${diffWeeks > 1 ? "s" : ""} ago`;
|
|
100
|
+
}
|
|
101
|
+
else if (diffMonths < 12) {
|
|
102
|
+
return `${diffMonths} month${diffMonths > 1 ? "s" : ""} ago`;
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
return `${diffYears} year${diffYears > 1 ? "s" : ""} ago`;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* 格式化字节大小
|
|
110
|
+
* @param bytes 字节数
|
|
111
|
+
* @param decimals 小数位数,默认为 2
|
|
112
|
+
* @returns 格式化后的大小字符串
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* formatBytes(1024); // "1 KB"
|
|
117
|
+
* formatBytes(1234567); // "1.18 MB"
|
|
118
|
+
* formatBytes(0); // "0 Bytes"
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
function formatBytes(bytes, decimals = 2) {
|
|
122
|
+
if (bytes === 0)
|
|
123
|
+
return "0 Bytes";
|
|
124
|
+
const k = 1024;
|
|
125
|
+
const dm = decimals < 0 ? 0 : decimals;
|
|
126
|
+
const sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB"];
|
|
127
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
128
|
+
const size = parseFloat((bytes / Math.pow(k, i)).toFixed(dm));
|
|
129
|
+
return `${size} ${sizes[i]}`;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* 格式化数字(添加千位分隔符)
|
|
133
|
+
* @param num 数字
|
|
134
|
+
* @returns 格式化后的数字字符串
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```typescript
|
|
138
|
+
* formatNumber(1234567); // "1,234,567"
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
function formatNumber(num) {
|
|
142
|
+
return num.toLocaleString();
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* 格式化持续时间(毫秒)
|
|
146
|
+
* @param ms 毫秒数
|
|
147
|
+
* @returns 格式化后的持续时间字符串
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* ```typescript
|
|
151
|
+
* formatDuration(1500); // "1.5s"
|
|
152
|
+
* formatDuration(65000); // "1m 5s"
|
|
153
|
+
* formatDuration(500); // "500ms"
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
function formatDuration(ms) {
|
|
157
|
+
if (ms < 1000) {
|
|
158
|
+
return `${ms}ms`;
|
|
159
|
+
}
|
|
160
|
+
const seconds = Math.floor(ms / 1000);
|
|
161
|
+
const minutes = Math.floor(seconds / 60);
|
|
162
|
+
const hours = Math.floor(minutes / 60);
|
|
163
|
+
if (hours > 0) {
|
|
164
|
+
const remainingMinutes = minutes % 60;
|
|
165
|
+
const remainingSeconds = seconds % 60;
|
|
166
|
+
if (remainingSeconds > 0) {
|
|
167
|
+
return `${hours}h ${remainingMinutes}m ${remainingSeconds}s`;
|
|
168
|
+
}
|
|
169
|
+
if (remainingMinutes > 0) {
|
|
170
|
+
return `${hours}h ${remainingMinutes}m`;
|
|
171
|
+
}
|
|
172
|
+
return `${hours}h`;
|
|
173
|
+
}
|
|
174
|
+
if (minutes > 0) {
|
|
175
|
+
const remainingSeconds = seconds % 60;
|
|
176
|
+
if (remainingSeconds > 0) {
|
|
177
|
+
return `${minutes}m ${remainingSeconds}s`;
|
|
178
|
+
}
|
|
179
|
+
return `${minutes}m`;
|
|
180
|
+
}
|
|
181
|
+
// 小于 1 分钟,显示小数秒
|
|
182
|
+
const decimalSeconds = ms / 1000;
|
|
183
|
+
return `${decimalSeconds.toFixed(1)}s`;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* 格式化路径(将 home 目录替换为 ~)
|
|
187
|
+
* @param filePath 文件路径
|
|
188
|
+
* @param homeDir home 目录路径
|
|
189
|
+
* @returns 格式化后的路径
|
|
190
|
+
*
|
|
191
|
+
* @example
|
|
192
|
+
* ```typescript
|
|
193
|
+
* shortenPath("/home/user/projects", "/home/user"); // "~/projects"
|
|
194
|
+
* ```
|
|
195
|
+
*/
|
|
196
|
+
function shortenPath(filePath, homeDir) {
|
|
197
|
+
const home = homeDir ?? process.env.HOME ?? process.env.USERPROFILE ?? "";
|
|
198
|
+
if (home && filePath.startsWith(home)) {
|
|
199
|
+
return "~" + filePath.slice(home.length);
|
|
200
|
+
}
|
|
201
|
+
return filePath;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* 规范化路径分隔符(统一使用正斜杠)
|
|
205
|
+
* @param filePath 文件路径
|
|
206
|
+
* @returns 规范化后的路径
|
|
207
|
+
*
|
|
208
|
+
* @example
|
|
209
|
+
* ```typescript
|
|
210
|
+
* normalizePath("path\\to\\file"); // "path/to/file"
|
|
211
|
+
* ```
|
|
212
|
+
*/
|
|
213
|
+
function normalizePath(filePath) {
|
|
214
|
+
return filePath.replace(/\\/g, "/");
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* 格式化仓库名称(用于显示)
|
|
218
|
+
* @param repoName 仓库名称
|
|
219
|
+
* @returns 格式化后的名称
|
|
220
|
+
*/
|
|
221
|
+
function formatRepoName(repoName) {
|
|
222
|
+
return normalizePath(repoName);
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* 状态图标
|
|
226
|
+
*/
|
|
227
|
+
exports.StatusIcon = {
|
|
228
|
+
success: chalk_1.default.green("✓"),
|
|
229
|
+
error: chalk_1.default.red("✗"),
|
|
230
|
+
warning: chalk_1.default.yellow("⚠"),
|
|
231
|
+
info: chalk_1.default.blue("ℹ"),
|
|
232
|
+
pending: chalk_1.default.gray("○"),
|
|
233
|
+
inProgress: chalk_1.default.cyan("◐"),
|
|
234
|
+
update: chalk_1.default.yellow("⬆"),
|
|
235
|
+
};
|
|
236
|
+
/**
|
|
237
|
+
* 获取状态图标
|
|
238
|
+
* @param status 状态类型
|
|
239
|
+
* @returns 对应的图标
|
|
240
|
+
*/
|
|
241
|
+
function getStatusIcon(status) {
|
|
242
|
+
return exports.StatusIcon[status];
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* 格式化错误消息
|
|
246
|
+
* @param message 错误消息
|
|
247
|
+
* @returns 格式化后的错误消息
|
|
248
|
+
*/
|
|
249
|
+
function formatError(message) {
|
|
250
|
+
return chalk_1.default.red(`${chalk_1.default.bold("✗")} ${message}`);
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* 格式化成功消息
|
|
254
|
+
* @param message 成功消息
|
|
255
|
+
* @returns 格式化后的成功消息
|
|
256
|
+
*/
|
|
257
|
+
function formatSuccess(message) {
|
|
258
|
+
return chalk_1.default.green(`${chalk_1.default.bold("✓")} ${message}`);
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* 格式化警告消息
|
|
262
|
+
* @param message 警告消息
|
|
263
|
+
* @returns 格式化后的警告消息
|
|
264
|
+
*/
|
|
265
|
+
function formatWarning(message) {
|
|
266
|
+
return chalk_1.default.yellow(`${chalk_1.default.bold("⚠")} ${message}`);
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* 格式化提示消息
|
|
270
|
+
* @param message 提示消息
|
|
271
|
+
* @returns 格式化后的提示消息
|
|
272
|
+
*/
|
|
273
|
+
function formatHint(message) {
|
|
274
|
+
return chalk_1.default.gray(`💡 ${message}`);
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* 高亮显示命令
|
|
278
|
+
* @param command 命令字符串
|
|
279
|
+
* @returns 高亮后的命令
|
|
280
|
+
*/
|
|
281
|
+
function highlightCommand(command) {
|
|
282
|
+
return chalk_1.default.cyan(command);
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* 高亮显示路径
|
|
286
|
+
* @param path 路径字符串
|
|
287
|
+
* @returns 高亮后的路径
|
|
288
|
+
*/
|
|
289
|
+
function highlightPath(path) {
|
|
290
|
+
return chalk_1.default.gray(path);
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* 高亮显示名称
|
|
294
|
+
* @param name 名称字符串
|
|
295
|
+
* @returns 高亮后的名称
|
|
296
|
+
*/
|
|
297
|
+
function highlightName(name) {
|
|
298
|
+
return chalk_1.default.cyan(name);
|
|
299
|
+
}
|
|
300
|
+
//# sourceMappingURL=format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../src/ui/format.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAgBH,kCAEC;AAeD,gCAkBC;AAgDD,kCAWC;AAYD,oCAEC;AAcD,wCAgCC;AAaD,kCAMC;AAYD,sCAEC;AAOD,wCAEC;AAoBD,sCAWC;AAOD,kCAEC;AAOD,sCAEC;AAOD,sCAEC;AAOD,gCAEC;AAOD,4CAEC;AAOD,sCAEC;AAOD,sCAEC;AAhTD,kDAA0B;AAE1B;;;;;;;;;;;GAWG;AACH,SAAgB,WAAW,CAAC,QAAgB,EAAE,MAAM,GAAG,CAAC;IACtD,OAAO,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AACvC,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,UAAU,CACxB,OAAsB,EACtB,SAAgD,OAAO;IAEvD,MAAM,IAAI,GAAG,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,OA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CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED;;;;GAIG;AACH,SAAgB,aAAa,CAAC,IAAY;IACxC,OAAO,eAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UI 模块统一导出
|
|
3
|
+
* 提供用户界面相关的工具函数
|
|
4
|
+
*/
|
|
5
|
+
export { createSpinner, startSpinner, withSpinner, withSpinnerMessages, type Spinner, type SpinnerOptions, } from "./spinner.js";
|
|
6
|
+
export { confirm, prompt, selectByNumber, showCancelled, showWarning, showInfo, showSuccess, type ConfirmOptions, type PromptOptions, } from "./prompt.js";
|
|
7
|
+
export { padEnd, padStart, truncate, printTable, printKeyValue, printSeparator, printEmptyLine, printTitle, printTotal, type TableColumn, type TableOptions, } from "./table.js";
|
|
8
|
+
export { shortCommit, formatDate, formatBytes, formatNumber, formatDuration, shortenPath, normalizePath, formatRepoName, StatusIcon, getStatusIcon, formatError, formatSuccess, formatWarning, formatHint, highlightCommand, highlightPath, highlightName, } from "./format.js";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACL,aAAa,EACb,YAAY,EACZ,WAAW,EACX,mBAAmB,EACnB,KAAK,OAAO,EACZ,KAAK,cAAc,GACpB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,OAAO,EACP,MAAM,EACN,cAAc,EACd,aAAa,EACb,WAAW,EACX,QAAQ,EACR,WAAW,EACX,KAAK,cAAc,EACnB,KAAK,aAAa,GACnB,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,aAAa,EACb,cAAc,EACd,cAAc,EACd,UAAU,EACV,UAAU,EACV,KAAK,WAAW,EAChB,KAAK,YAAY,GAClB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,WAAW,EACX,UAAU,EACV,WAAW,EACX,YAAY,EACZ,cAAc,EACd,WAAW,EACX,aAAa,EACb,cAAc,EACd,UAAU,EACV,aAAa,EACb,WAAW,EACX,aAAa,EACb,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,aAAa,GACd,MAAM,aAAa,CAAC"}
|
package/dist/ui/index.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* UI 模块统一导出
|
|
4
|
+
* 提供用户界面相关的工具函数
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.highlightName = exports.highlightPath = exports.highlightCommand = exports.formatHint = exports.formatWarning = exports.formatSuccess = exports.formatError = exports.getStatusIcon = exports.StatusIcon = exports.formatRepoName = exports.normalizePath = exports.shortenPath = exports.formatDuration = exports.formatNumber = exports.formatBytes = exports.formatDate = exports.shortCommit = exports.printTotal = exports.printTitle = exports.printEmptyLine = exports.printSeparator = exports.printKeyValue = exports.printTable = exports.truncate = exports.padStart = exports.padEnd = exports.showSuccess = exports.showInfo = exports.showWarning = exports.showCancelled = exports.selectByNumber = exports.prompt = exports.confirm = exports.withSpinnerMessages = exports.withSpinner = exports.startSpinner = exports.createSpinner = void 0;
|
|
8
|
+
// Spinner 相关
|
|
9
|
+
var spinner_js_1 = require("./spinner.js");
|
|
10
|
+
Object.defineProperty(exports, "createSpinner", { enumerable: true, get: function () { return spinner_js_1.createSpinner; } });
|
|
11
|
+
Object.defineProperty(exports, "startSpinner", { enumerable: true, get: function () { return spinner_js_1.startSpinner; } });
|
|
12
|
+
Object.defineProperty(exports, "withSpinner", { enumerable: true, get: function () { return spinner_js_1.withSpinner; } });
|
|
13
|
+
Object.defineProperty(exports, "withSpinnerMessages", { enumerable: true, get: function () { return spinner_js_1.withSpinnerMessages; } });
|
|
14
|
+
// 用户交互提示相关
|
|
15
|
+
var prompt_js_1 = require("./prompt.js");
|
|
16
|
+
Object.defineProperty(exports, "confirm", { enumerable: true, get: function () { return prompt_js_1.confirm; } });
|
|
17
|
+
Object.defineProperty(exports, "prompt", { enumerable: true, get: function () { return prompt_js_1.prompt; } });
|
|
18
|
+
Object.defineProperty(exports, "selectByNumber", { enumerable: true, get: function () { return prompt_js_1.selectByNumber; } });
|
|
19
|
+
Object.defineProperty(exports, "showCancelled", { enumerable: true, get: function () { return prompt_js_1.showCancelled; } });
|
|
20
|
+
Object.defineProperty(exports, "showWarning", { enumerable: true, get: function () { return prompt_js_1.showWarning; } });
|
|
21
|
+
Object.defineProperty(exports, "showInfo", { enumerable: true, get: function () { return prompt_js_1.showInfo; } });
|
|
22
|
+
Object.defineProperty(exports, "showSuccess", { enumerable: true, get: function () { return prompt_js_1.showSuccess; } });
|
|
23
|
+
// 表格输出相关
|
|
24
|
+
var table_js_1 = require("./table.js");
|
|
25
|
+
Object.defineProperty(exports, "padEnd", { enumerable: true, get: function () { return table_js_1.padEnd; } });
|
|
26
|
+
Object.defineProperty(exports, "padStart", { enumerable: true, get: function () { return table_js_1.padStart; } });
|
|
27
|
+
Object.defineProperty(exports, "truncate", { enumerable: true, get: function () { return table_js_1.truncate; } });
|
|
28
|
+
Object.defineProperty(exports, "printTable", { enumerable: true, get: function () { return table_js_1.printTable; } });
|
|
29
|
+
Object.defineProperty(exports, "printKeyValue", { enumerable: true, get: function () { return table_js_1.printKeyValue; } });
|
|
30
|
+
Object.defineProperty(exports, "printSeparator", { enumerable: true, get: function () { return table_js_1.printSeparator; } });
|
|
31
|
+
Object.defineProperty(exports, "printEmptyLine", { enumerable: true, get: function () { return table_js_1.printEmptyLine; } });
|
|
32
|
+
Object.defineProperty(exports, "printTitle", { enumerable: true, get: function () { return table_js_1.printTitle; } });
|
|
33
|
+
Object.defineProperty(exports, "printTotal", { enumerable: true, get: function () { return table_js_1.printTotal; } });
|
|
34
|
+
// 格式化输出相关
|
|
35
|
+
var format_js_1 = require("./format.js");
|
|
36
|
+
Object.defineProperty(exports, "shortCommit", { enumerable: true, get: function () { return format_js_1.shortCommit; } });
|
|
37
|
+
Object.defineProperty(exports, "formatDate", { enumerable: true, get: function () { return format_js_1.formatDate; } });
|
|
38
|
+
Object.defineProperty(exports, "formatBytes", { enumerable: true, get: function () { return format_js_1.formatBytes; } });
|
|
39
|
+
Object.defineProperty(exports, "formatNumber", { enumerable: true, get: function () { return format_js_1.formatNumber; } });
|
|
40
|
+
Object.defineProperty(exports, "formatDuration", { enumerable: true, get: function () { return format_js_1.formatDuration; } });
|
|
41
|
+
Object.defineProperty(exports, "shortenPath", { enumerable: true, get: function () { return format_js_1.shortenPath; } });
|
|
42
|
+
Object.defineProperty(exports, "normalizePath", { enumerable: true, get: function () { return format_js_1.normalizePath; } });
|
|
43
|
+
Object.defineProperty(exports, "formatRepoName", { enumerable: true, get: function () { return format_js_1.formatRepoName; } });
|
|
44
|
+
Object.defineProperty(exports, "StatusIcon", { enumerable: true, get: function () { return format_js_1.StatusIcon; } });
|
|
45
|
+
Object.defineProperty(exports, "getStatusIcon", { enumerable: true, get: function () { return format_js_1.getStatusIcon; } });
|
|
46
|
+
Object.defineProperty(exports, "formatError", { enumerable: true, get: function () { return format_js_1.formatError; } });
|
|
47
|
+
Object.defineProperty(exports, "formatSuccess", { enumerable: true, get: function () { return format_js_1.formatSuccess; } });
|
|
48
|
+
Object.defineProperty(exports, "formatWarning", { enumerable: true, get: function () { return format_js_1.formatWarning; } });
|
|
49
|
+
Object.defineProperty(exports, "formatHint", { enumerable: true, get: function () { return format_js_1.formatHint; } });
|
|
50
|
+
Object.defineProperty(exports, "highlightCommand", { enumerable: true, get: function () { return format_js_1.highlightCommand; } });
|
|
51
|
+
Object.defineProperty(exports, "highlightPath", { enumerable: true, get: function () { return format_js_1.highlightPath; } });
|
|
52
|
+
Object.defineProperty(exports, "highlightName", { enumerable: true, get: function () { return format_js_1.highlightName; } });
|
|
53
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,aAAa;AACb,2CAOsB;AANpB,2GAAA,aAAa,OAAA;AACb,0GAAA,YAAY,OAAA;AACZ,yGAAA,WAAW,OAAA;AACX,iHAAA,mBAAmB,OAAA;AAKrB,WAAW;AACX,yCAUqB;AATnB,oGAAA,OAAO,OAAA;AACP,mGAAA,MAAM,OAAA;AACN,2GAAA,cAAc,OAAA;AACd,0GAAA,aAAa,OAAA;AACb,wGAAA,WAAW,OAAA;AACX,qGAAA,QAAQ,OAAA;AACR,wGAAA,WAAW,OAAA;AAKb,SAAS;AACT,uCAYoB;AAXlB,kGAAA,MAAM,OAAA;AACN,oGAAA,QAAQ,OAAA;AACR,oGAAA,QAAQ,OAAA;AACR,sGAAA,UAAU,OAAA;AACV,yGAAA,aAAa,OAAA;AACb,0GAAA,cAAc,OAAA;AACd,0GAAA,cAAc,OAAA;AACd,sGAAA,UAAU,OAAA;AACV,sGAAA,UAAU,OAAA;AAKZ,UAAU;AACV,yCAkBqB;AAjBnB,wGAAA,WAAW,OAAA;AACX,uGAAA,UAAU,OAAA;AACV,wGAAA,WAAW,OAAA;AACX,yGAAA,YAAY,OAAA;AACZ,2GAAA,cAAc,OAAA;AACd,wGAAA,WAAW,OAAA;AACX,0GAAA,aAAa,OAAA;AACb,2GAAA,cAAc,OAAA;AACd,uGAAA,UAAU,OAAA;AACV,0GAAA,aAAa,OAAA;AACb,wGAAA,WAAW,OAAA;AACX,0GAAA,aAAa,OAAA;AACb,0GAAA,aAAa,OAAA;AACb,uGAAA,UAAU,OAAA;AACV,6GAAA,gBAAgB,OAAA;AAChB,0GAAA,aAAa,OAAA;AACb,0GAAA,aAAa,OAAA"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 用户交互提示模块
|
|
3
|
+
* 封装确认提示和用户输入功能
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* 确认提示选项
|
|
7
|
+
*/
|
|
8
|
+
export interface ConfirmOptions {
|
|
9
|
+
/** 默认值(用户直接按回车时的选择) */
|
|
10
|
+
defaultValue?: boolean;
|
|
11
|
+
/** 提示后缀,默认为 "(y/N)" 或 "(Y/n)" */
|
|
12
|
+
suffix?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* 显示确认提示,等待用户输入 y/n
|
|
16
|
+
* @param message 提示消息
|
|
17
|
+
* @param options 配置选项
|
|
18
|
+
* @returns 用户是否确认
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* // 默认为 No
|
|
23
|
+
* const confirmed = await confirm("Are you sure?");
|
|
24
|
+
*
|
|
25
|
+
* // 默认为 Yes
|
|
26
|
+
* const confirmed = await confirm("Continue?", { defaultValue: true });
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare function confirm(message: string, options?: ConfirmOptions): Promise<boolean>;
|
|
30
|
+
/**
|
|
31
|
+
* 输入提示选项
|
|
32
|
+
*/
|
|
33
|
+
export interface PromptOptions {
|
|
34
|
+
/** 默认值 */
|
|
35
|
+
defaultValue?: string;
|
|
36
|
+
/** 是否允许空输入 */
|
|
37
|
+
allowEmpty?: boolean;
|
|
38
|
+
/** 输入验证函数 */
|
|
39
|
+
validate?: (input: string) => boolean | string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* 显示输入提示,等待用户输入
|
|
43
|
+
* @param message 提示消息
|
|
44
|
+
* @param options 配置选项
|
|
45
|
+
* @returns 用户输入的内容
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* const name = await prompt("Enter repository name:");
|
|
50
|
+
*
|
|
51
|
+
* const name = await prompt("Enter name:", {
|
|
52
|
+
* defaultValue: "default-name",
|
|
53
|
+
* validate: (input) => input.length > 0 || "Name cannot be empty"
|
|
54
|
+
* });
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare function prompt(message: string, options?: PromptOptions): Promise<string>;
|
|
58
|
+
/**
|
|
59
|
+
* 显示带有选项的选择提示
|
|
60
|
+
* @param message 提示消息
|
|
61
|
+
* @param choices 选项列表
|
|
62
|
+
* @returns 用户选择的选项索引
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* const index = await select("Choose an option:", [
|
|
67
|
+
* "Option 1",
|
|
68
|
+
* "Option 2",
|
|
69
|
+
* "Option 3"
|
|
70
|
+
* ]);
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export declare function selectByNumber(message: string, choices: string[]): Promise<number>;
|
|
74
|
+
/**
|
|
75
|
+
* 显示操作取消消息
|
|
76
|
+
* @param message 可选的自定义消息
|
|
77
|
+
*/
|
|
78
|
+
export declare function showCancelled(message?: string): void;
|
|
79
|
+
/**
|
|
80
|
+
* 显示警告消息
|
|
81
|
+
* @param message 警告消息
|
|
82
|
+
*/
|
|
83
|
+
export declare function showWarning(message: string): void;
|
|
84
|
+
/**
|
|
85
|
+
* 显示信息消息
|
|
86
|
+
* @param message 信息消息
|
|
87
|
+
*/
|
|
88
|
+
export declare function showInfo(message: string): void;
|
|
89
|
+
/**
|
|
90
|
+
* 显示成功消息
|
|
91
|
+
* @param message 成功消息
|
|
92
|
+
*/
|
|
93
|
+
export declare function showSuccess(message: string): void;
|
|
94
|
+
//# sourceMappingURL=prompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../src/ui/prompt.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,uBAAuB;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,iCA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