@flowscripter/dynamic-cli-framework 1.1.6 → 1.2.0
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/.github/workflows/release-bun-library.yml +1 -0
- package/README/core-commands.md +40 -0
- package/README/core-service-providers.md +198 -0
- package/README/development.md +60 -0
- package/README/implementation-details.md +474 -0
- package/README/key-concepts.md +751 -0
- package/README.md +12 -1413
- package/bun.lock +20 -18
- package/index.ts +97 -1
- package/package.json +8 -7
- package/src/api/BaseCLIFeatureOptions.ts +10 -0
- package/src/api/CLIConfig.ts +5 -0
- package/src/api/RunResult.ts +16 -0
- package/src/api/argument/Argument.ts +24 -0
- package/src/api/service/ServiceProvider.ts +3 -3
- package/src/api/service/core/ArgumentPrompterService.ts +10 -0
- package/src/api/service/core/AsciiBannerGeneratorService.ts +44 -7
- package/src/api/service/core/CompletionService.ts +36 -0
- package/src/api/service/core/DataDumpGeneratorService.ts +27 -0
- package/src/api/service/core/ImagePrinterService.ts +26 -0
- package/src/api/service/core/KeyValueService.ts +22 -5
- package/src/api/service/core/PrinterService.ts +127 -1
- package/src/api/service/core/PrompterService.ts +49 -0
- package/src/api/service/core/SecretService.ts +27 -0
- package/src/api/service/core/ShutdownService.ts +17 -1
- package/src/api/service/core/Table.ts +85 -0
- package/src/api/service/core/TableGeneratorService.ts +38 -0
- package/src/api/service/core/TreePrinterService.ts +11 -0
- package/src/cli/BaseCLI.ts +116 -44
- package/src/cli/DefaultRuntimeCLI.ts +10 -18
- package/src/command/CompletionCommand.ts +179 -0
- package/src/command/MultiCommandCliHelpCommand.ts +18 -2
- package/src/command/SingleCommandCliHelpCommand.ts +10 -1
- package/src/launcher.ts +16 -58
- package/src/runtime/command/CommandValidator.ts +3 -3
- package/src/runtime/runner.ts +102 -30
- package/src/runtime/scanner.ts +18 -15
- package/src/runtime/values/argumentValueValidation.ts +49 -5
- package/src/runtime/values/globalCommandValuePopulation.ts +1 -1
- package/src/runtime/values/subCommandValuePopulation.ts +9 -8
- package/src/service/argumentPrompter/ArgumentPrompterServiceProvider.ts +34 -0
- package/src/service/argumentPrompter/DefaultArgumentPrompterService.ts +330 -0
- package/src/service/asciiBannerGenerator/AsciiBannerGeneratorServiceProvider.ts +1 -1
- package/src/service/asciiBannerGenerator/DefaultAsciiBannerGeneratorService.ts +254 -17
- package/src/service/banner/BannerServiceProvider.ts +2 -2
- package/src/service/chiselAsciiBannerGenerator/ChiselFontAsciiBannerGeneratorService.ts +85 -0
- package/src/service/chiselAsciiBannerGenerator/chisel.flf.json +3 -0
- package/src/service/completion/CompletionServiceProvider.ts +212 -0
- package/src/service/completion/DefaultCompletionService.ts +364 -0
- package/src/service/completion/shell/ShellHandler.ts +16 -0
- package/src/service/completion/shell/bash.ts +47 -0
- package/src/service/completion/shell/fish.ts +43 -0
- package/src/service/completion/shell/powershell.ts +66 -0
- package/src/service/completion/shell/zsh.ts +50 -0
- package/src/service/configuration/ConfigurationServiceProvider.ts +138 -42
- package/src/service/configuration/DefaultKeyValueService.ts +53 -7
- package/src/service/configuration/DefaultSecretService.ts +85 -0
- package/src/service/dataDumpGenerator/DataDumpGeneratorServiceProvider.ts +41 -0
- package/src/service/dataDumpGenerator/DefaultDataDumpGeneratorService.ts +80 -0
- package/src/service/imagePrinter/DefaultImagePrinterService.ts +23 -0
- package/src/service/imagePrinter/ImagePrinterServiceProvider.ts +32 -0
- package/src/service/prettyPrinter/PrettyPrinterServiceProvider.ts +1 -1
- package/src/service/printer/DefaultPrinterService.ts +147 -27
- package/src/service/printer/PrinterServiceProvider.ts +7 -7
- package/src/service/printer/command/NoHyperlinksCommand.ts +40 -0
- package/src/service/printer/terminal/Progress.ts +21 -4
- package/src/service/printer/terminal/Spinner.ts +32 -8
- package/src/service/printer/terminal/Theme.ts +1 -1
- package/src/service/prompter/DefaultPrompterService.ts +87 -0
- package/src/service/prompter/PrompterServiceProvider.ts +36 -0
- package/src/service/prompter/command/NoPromptCommand.ts +40 -0
- package/src/service/prompter/prompt/PromptContext.ts +47 -0
- package/src/service/prompter/prompt/promptAcknowledge.ts +28 -0
- package/src/service/prompter/prompt/promptMultiSelect.ts +99 -0
- package/src/service/prompter/prompt/promptOpenUrl.ts +97 -0
- package/src/service/prompter/prompt/promptSingleSelect.ts +102 -0
- package/src/service/prompter/prompt/promptText.ts +107 -0
- package/src/service/prompter/prompt/promptToggle.ts +28 -0
- package/src/service/shutdown/DefaultShutdownService.ts +13 -0
- package/src/service/shutdown/ShutdownServiceProvider.ts +28 -9
- package/src/service/shutdown/ShutdownState.ts +5 -0
- package/src/service/syntaxHighlighter/SyntaxHighlighterServiceProvider.ts +1 -1
- package/src/service/tableGenerator/DefaultTableGeneratorService.ts +415 -0
- package/src/service/tableGenerator/TableGeneratorServiceProvider.ts +43 -0
- package/src/service/treePrinter/DefaultTreePrinterService.ts +49 -0
- package/src/service/treePrinter/TreePrinterServiceProvider.ts +40 -0
- package/src/terminal/Ansi.ts +27 -0
- package/src/terminal/ImageRenderer.ts +199 -0
- package/src/terminal/KeyReader.ts +23 -0
- package/src/terminal/PngDecoder.ts +143 -0
- package/src/{service/printer/terminal → terminal}/Styler.ts +3 -0
- package/src/{service/printer/terminal → terminal}/Terminal.ts +1 -0
- package/src/terminal/TtyKeyReader.ts +83 -0
- package/src/terminal/TtyStyler.ts +78 -0
- package/src/{service/printer/terminal → terminal}/TtyTerminal.ts +9 -1
- package/src/terminal/supportsHyperlinks.ts +110 -0
- package/src/util/configHelper.ts +2 -2
- package/src/util/envVarHelper.ts +2 -2
- package/src/util/helpHelper.ts +66 -122
- package/src/util/logger.ts +16 -14
- package/src/util/runnerHelper.ts +1 -1
- package/tests/cli/BaseCLI.test.ts +50 -54
- package/tests/command/CompletionCommand.test.ts +68 -0
- package/tests/command/UsageCommand.test.ts +3 -2
- package/tests/command/VersionCommand.test.ts +3 -2
- package/tests/fixtures/Context.ts +9 -2
- package/tests/fixtures/util.ts +1 -1
- package/tests/runtime/parser.test.ts +9 -7
- package/tests/runtime/registry/DefaultServiceProviderRegistry.test.ts +3 -3
- package/tests/runtime/values/argumentValueValidation.test.ts +193 -0
- package/tests/service/argumentPrompter/ArgumentPrompterServiceProvider.test.ts +47 -0
- package/tests/service/argumentPrompter/DefaultArgumentPrompterService.test.ts +754 -0
- package/tests/service/asciiBannerGenerator/AsciiBannerGeneratorServiceProvider.test.ts +5 -4
- package/tests/service/asciiBannerGenerator/DefaultAsciiBannerGeneratorService.test.ts +163 -3
- package/tests/service/asciiBannerGenerator/__snapshots__/DefaultAsciiBannerGeneratorService.test.ts.snap +1 -1
- package/tests/service/banner/BannerServiceProvider.test.ts +8 -4
- package/tests/service/chiselAsciiBannerGenerator/ChiselFontAsciiBannerGeneratorService.test.ts +52 -0
- package/tests/service/completion/CompletionServiceProvider.test.ts +404 -0
- package/tests/service/completion/DefaultCompletionService.test.ts +278 -0
- package/tests/service/completion/shell/bash.test.ts +73 -0
- package/tests/service/completion/shell/fish.test.ts +62 -0
- package/tests/service/completion/shell/powershell.test.ts +59 -0
- package/tests/service/completion/shell/zsh.test.ts +60 -0
- package/tests/service/configuration/ConfigurationServiceProvider.test.ts +24 -12
- package/tests/service/configuration/DefaultKeyValueService.test.ts +118 -16
- package/tests/service/configuration/DefaultSecretService.test.ts +148 -0
- package/tests/service/configuration/command/ConfigCommand.test.ts +29 -0
- package/tests/service/configuration/command/DumpConfigCommand.test.ts +60 -0
- package/tests/service/dataDumpGenerator/DataDumpGeneratorServiceProvider.test.ts +57 -0
- package/tests/service/dataDumpGenerator/DefaultDataDumpGeneratorService.test.ts +217 -0
- package/tests/service/imagePrinter/DefaultImagePrinterService.test.ts +96 -0
- package/tests/service/imagePrinter/ImagePrinterServiceProvider.test.ts +17 -0
- package/tests/service/prettyPrinter/DefaultPrettyPrinterService.test.ts +2 -2
- package/tests/service/prettyPrinter/PrettyPrinterServiceProvider.test.ts +5 -4
- package/tests/service/printer/DefaultPrinterService.test.ts +233 -2
- package/tests/service/printer/PrinterServiceProvider.test.ts +6 -5
- package/tests/service/printer/command/DarkModeCommand.test.ts +83 -0
- package/tests/service/printer/command/LogLevelCommand.test.ts +7 -5
- package/tests/service/printer/command/NoColorCommand.test.ts +83 -0
- package/tests/service/printer/command/NoHyperlinksCommand.test.ts +89 -0
- package/tests/service/printer/terminal/Progress.test.ts +64 -4
- package/tests/service/printer/terminal/Spinner.test.ts +44 -3
- package/tests/service/prompter/DefaultPrompterService.test.ts +615 -0
- package/tests/service/prompter/PrompterServiceProvider.test.ts +47 -0
- package/tests/service/prompter/command/NoPromptCommand.test.ts +58 -0
- package/tests/service/shutdown/ShutdownServiceProvider.test.ts +4 -2
- package/tests/service/syntaxHighlighter/DefaultSyntaxHighlighterService.test.ts +3 -2
- package/tests/service/syntaxHighlighter/SyntaxHighlighterServiceProvider.test.ts +5 -4
- package/tests/service/tableGenerator/DefaultTableGeneratorService.test.ts +363 -0
- package/tests/service/tableGenerator/TableGeneratorServiceProvider.test.ts +47 -0
- package/tests/service/treePrinter/DefaultTreePrinterService.test.ts +144 -0
- package/tests/service/treePrinter/TreePrinterServiceProvider.test.ts +55 -0
- package/tests/terminal/ImageRenderer.test.ts +161 -0
- package/tests/terminal/PngDecoder.test.ts +223 -0
- package/tests/terminal/supportsHyperlinks.test.ts +149 -0
- package/tests/util/configHelper.test.ts +4 -4
- package/tests/util/logger.test.ts +23 -1
- package/tsconfig.json +31 -0
- package/src/service/printer/terminal/Ansi.ts +0 -10
- package/src/service/printer/terminal/TtyStyler.ts +0 -39
package/bun.lock
CHANGED
|
@@ -1,39 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"lockfileVersion": 1,
|
|
3
|
+
"configVersion": 1,
|
|
3
4
|
"workspaces": {
|
|
4
5
|
"": {
|
|
5
|
-
"name": "@flowscripter/dynamic-
|
|
6
|
+
"name": "@flowscripter/dynamic-cli-framework",
|
|
6
7
|
"dependencies": {
|
|
7
8
|
"emphasize": "^7.0.0",
|
|
8
9
|
"fastest-levenshtein": "^1.0.16",
|
|
9
|
-
"figlet": "^1.
|
|
10
|
+
"figlet": "^1.11.0",
|
|
10
11
|
"highlight.js": "^11.11.1",
|
|
11
|
-
"prettier": "^3.
|
|
12
|
-
"supports-color": "^10.
|
|
13
|
-
"
|
|
12
|
+
"prettier": "^3.8.3",
|
|
13
|
+
"supports-color": "^10.2.2",
|
|
14
|
+
"supports-terminal-graphics": "^0.1.0",
|
|
14
15
|
},
|
|
15
16
|
"devDependencies": {
|
|
16
|
-
"@types/bun": "^1.
|
|
17
|
+
"@types/bun": "^1.3.14",
|
|
18
|
+
"@types/node": "^25.9.1",
|
|
17
19
|
},
|
|
18
20
|
"peerDependencies": {
|
|
19
|
-
"typescript": "^
|
|
21
|
+
"typescript": "^6.0.3",
|
|
20
22
|
},
|
|
21
23
|
},
|
|
22
24
|
},
|
|
23
25
|
"packages": {
|
|
24
|
-
"@types/bun": ["@types/bun@1.
|
|
26
|
+
"@types/bun": ["@types/bun@1.3.14", "", { "dependencies": { "bun-types": "1.3.14" } }, "sha512-h1hFqFVcvAvD9j9K7ZW7vd82aSA+rTdznZa+5bwvCwqSB1jmmfLcbIWhOLx1/+boy/xmjgCs/OMUL8hRJSmnPw=="],
|
|
25
27
|
|
|
26
28
|
"@types/hast": ["@types/hast@3.0.4", "", { "dependencies": { "@types/unist": "*" } }, "sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ=="],
|
|
27
29
|
|
|
28
|
-
"@types/node": ["@types/node@
|
|
30
|
+
"@types/node": ["@types/node@25.9.1", "", { "dependencies": { "undici-types": ">=7.24.0 <7.24.7" } }, "sha512-xfrlY7UD5rMJk3ZVJP8BNzS28J36YJg+xp+LPXV1TdWxr8uMH5A860QNxYDGQe/ylDSgjxE52Q9VnO7p75tJxg=="],
|
|
29
31
|
|
|
30
32
|
"@types/unist": ["@types/unist@3.0.3", "", {}, "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q=="],
|
|
31
33
|
|
|
32
|
-
"
|
|
34
|
+
"bun-types": ["bun-types@1.3.14", "", { "dependencies": { "@types/node": "*" } }, "sha512-4N0ig0fEomHt5R0KCFWjovxow98rIoRwKolrYdCcknNwMekCXRnWEUvgu5soYV8QXtVsrUD8B95MBOZGPvr6KQ=="],
|
|
33
35
|
|
|
34
|
-
"
|
|
36
|
+
"chalk": ["chalk@5.6.2", "", {}, "sha512-7NzBL0rN6fMUW+f7A6Io4h40qQlG+xGmtMxfbnH/K7TAtt8JQWVQK+6g0UXKMeVJoyV5EkkNsErQ8pVD3bLHbA=="],
|
|
35
37
|
|
|
36
|
-
"
|
|
38
|
+
"commander": ["commander@14.0.3", "", {}, "sha512-H+y0Jo/T1RZ9qPP4Eh1pkcQcLRglraJaSLoyOtHxu6AapkjWVCy2Sit1QQ4x3Dng8qDlSsZEet7g5Pq06MvTgw=="],
|
|
37
39
|
|
|
38
40
|
"dequal": ["dequal@2.0.3", "", {}, "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA=="],
|
|
39
41
|
|
|
@@ -43,21 +45,21 @@
|
|
|
43
45
|
|
|
44
46
|
"fastest-levenshtein": ["fastest-levenshtein@1.0.16", "", {}, "sha512-eRnCtTTtGZFpQCwhJiUOuxPQWRXVKYDn0b2PeHfXL6/Zi53SLAzAHfVhVWK2AryC/WH05kGfxhFIPvTF0SXQzg=="],
|
|
45
47
|
|
|
46
|
-
"figlet": ["figlet@1.
|
|
48
|
+
"figlet": ["figlet@1.11.0", "", { "dependencies": { "commander": "^14.0.0" }, "bin": { "figlet": "bin/index.js" } }, "sha512-EEx3OS/l2bFqcUNN2NM9FPJp8vAMrgbCxsbl2hbcJNNxOEwVe3mEzrhan7TbJQViZa8mMqhihlbCaqD+LyYKTQ=="],
|
|
47
49
|
|
|
48
50
|
"highlight.js": ["highlight.js@11.11.1", "", {}, "sha512-Xwwo44whKBVCYoliBQwaPvtd/2tYFkRQtXDWj1nackaV2JPXx3L0+Jvd8/qCJ2p+ML0/XVkJ2q+Mr+UVdpJK5w=="],
|
|
49
51
|
|
|
50
52
|
"lowlight": ["lowlight@3.1.0", "", { "dependencies": { "@types/hast": "^3.0.0", "devlop": "^1.0.0", "highlight.js": "~11.9.0" } }, "sha512-CEbNVoSikAxwDMDPjXlqlFYiZLkDJHwyGu/MfOsJnF3d7f3tds5J3z8s/l9TMXhzfsJCCJEAsD78842mwmg0PQ=="],
|
|
51
53
|
|
|
52
|
-
"prettier": ["prettier@3.
|
|
54
|
+
"prettier": ["prettier@3.8.3", "", { "bin": { "prettier": "bin/prettier.cjs" } }, "sha512-7igPTM53cGHMW8xWuVTydi2KO233VFiTNyF5hLJqpilHfmn8C8gPf+PS7dUT64YcXFbiMGZxS9pCSxL/Dxm/Jw=="],
|
|
53
55
|
|
|
54
|
-
"supports-color": ["supports-color@10.
|
|
56
|
+
"supports-color": ["supports-color@10.2.2", "", {}, "sha512-SS+jx45GF1QjgEXQx4NJZV9ImqmO2NPz5FNsIHrsDjh2YsHnawpan7SNQ1o8NuhrbHZy9AZhIoCUiCeaW/C80g=="],
|
|
55
57
|
|
|
56
|
-
"
|
|
58
|
+
"supports-terminal-graphics": ["supports-terminal-graphics@0.1.0", "", {}, "sha512-+KdfozhS0Fw8y5Sghw8kkZNGT8nWYzJ1EzcoIvVjxhl+26TJTs26y02yfBgvc1jh5AS/c8jcI3xtahhR95KRyQ=="],
|
|
57
59
|
|
|
58
|
-
"typescript": ["typescript@
|
|
60
|
+
"typescript": ["typescript@6.0.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw=="],
|
|
59
61
|
|
|
60
|
-
"undici-types": ["undici-types@
|
|
62
|
+
"undici-types": ["undici-types@7.24.6", "", {}, "sha512-WRNW+sJgj5OBN4/0JpHFqtqzhpbnV0GuB+OozA9gCL7a993SmU+1JBZCzLNxYsbMfIeDL+lTsphD5jN5N+n0zg=="],
|
|
61
63
|
|
|
62
64
|
"emphasize/highlight.js": ["highlight.js@11.9.0", "", {}, "sha512-fJ7cW7fQGCYAkgv4CPfwFHrfd/cLS4Hau96JuJ+ZTOWhjnhoeN1ub1tFmALm/+lW5z4WCAuAV9bm05AP0mS6Gw=="],
|
|
63
65
|
|
package/index.ts
CHANGED
|
@@ -39,21 +39,43 @@ export type { default as ServiceProviderRegistry } from "./src/runtime/registry/
|
|
|
39
39
|
// Core Services
|
|
40
40
|
export { ASCII_BANNER_GENERATOR_SERVICE_ID } from "./src/api/service/core/AsciiBannerGeneratorService.ts";
|
|
41
41
|
export type { default as AsciiBannerGeneratorService } from "./src/api/service/core/AsciiBannerGeneratorService.ts";
|
|
42
|
+
export type {
|
|
43
|
+
BannerColorEffects,
|
|
44
|
+
BannerGenerateOptions,
|
|
45
|
+
ColorEffect,
|
|
46
|
+
ColorEffectDirection,
|
|
47
|
+
FixedColorEffect,
|
|
48
|
+
GradientColorEffect,
|
|
49
|
+
RainbowColorEffect,
|
|
50
|
+
} from "./src/api/service/core/AsciiBannerGeneratorService.ts";
|
|
42
51
|
export { default as DefaultAsciiBannerGeneratorService } from "./src/service/asciiBannerGenerator/DefaultAsciiBannerGeneratorService.ts";
|
|
43
52
|
export { default as AsciiBannerGeneratorServiceProvider } from "./src/service/asciiBannerGenerator/AsciiBannerGeneratorServiceProvider.ts";
|
|
53
|
+
export { default as ChiselFontAsciiBannerGeneratorService } from "./src/service/chiselAsciiBannerGenerator/ChiselFontAsciiBannerGeneratorService.ts";
|
|
54
|
+
export type {
|
|
55
|
+
ChiselBannerColors,
|
|
56
|
+
ChiselBannerGenerateOptions,
|
|
57
|
+
} from "./src/service/chiselAsciiBannerGenerator/ChiselFontAsciiBannerGeneratorService.ts";
|
|
44
58
|
|
|
45
59
|
export { default as BannerServiceProvider } from "./src/service/banner/BannerServiceProvider.ts";
|
|
46
60
|
|
|
47
61
|
export { KEY_VALUE_SERVICE_ID } from "./src/api/service/core/KeyValueService.ts";
|
|
62
|
+
export { SECRET_SENTINEL_PREFIX } from "./src/api/service/core/KeyValueService.ts";
|
|
48
63
|
export type { default as KeyValueService } from "./src/api/service/core/KeyValueService.ts";
|
|
64
|
+
export type { default as SecretService } from "./src/api/service/core/SecretService.ts";
|
|
49
65
|
export { default as DefaultKeyValueService } from "./src/service/configuration/DefaultKeyValueService.ts";
|
|
66
|
+
export { default as DefaultSecretService } from "./src/service/configuration/DefaultSecretService.ts";
|
|
50
67
|
export { default as ConfigurationServiceProvider } from "./src/service/configuration/ConfigurationServiceProvider.ts";
|
|
51
68
|
|
|
52
69
|
export { PRINTER_SERVICE_ID } from "./src/api/service/core/PrinterService.ts";
|
|
53
70
|
export type {
|
|
54
71
|
default as PrinterService,
|
|
55
72
|
} from "./src/api/service/core/PrinterService.ts";
|
|
56
|
-
export {
|
|
73
|
+
export {
|
|
74
|
+
Icon,
|
|
75
|
+
Level,
|
|
76
|
+
ProgressStyle,
|
|
77
|
+
SpinnerStyle,
|
|
78
|
+
} from "./src/api/service/core/PrinterService.ts";
|
|
57
79
|
export { default as DefaultPrinterService } from "./src/service/printer/DefaultPrinterService.ts";
|
|
58
80
|
export { default as PrinterServiceProvider } from "./src/service/printer/PrinterServiceProvider.ts";
|
|
59
81
|
|
|
@@ -73,6 +95,69 @@ export type { default as PrettyPrinterService } from "./src/api/service/core/Pre
|
|
|
73
95
|
export { default as DefaultPrettyPrinterService } from "./src/service/prettyPrinter/DefaultPrettyPrinterService.ts";
|
|
74
96
|
export { default as PrettyPrinterServiceProvider } from "./src/service/prettyPrinter/PrettyPrinterServiceProvider.ts";
|
|
75
97
|
|
|
98
|
+
export { IMAGE_PRINTER_SERVICE_ID } from "./src/api/service/core/ImagePrinterService.ts";
|
|
99
|
+
export type { default as ImagePrinterService } from "./src/api/service/core/ImagePrinterService.ts";
|
|
100
|
+
export { default as DefaultImagePrinterService } from "./src/service/imagePrinter/DefaultImagePrinterService.ts";
|
|
101
|
+
export { default as ImagePrinterServiceProvider } from "./src/service/imagePrinter/ImagePrinterServiceProvider.ts";
|
|
102
|
+
|
|
103
|
+
export { TREE_PRINTER_SERVICE_ID } from "./src/api/service/core/TreePrinterService.ts";
|
|
104
|
+
export type { default as TreePrinterService } from "./src/api/service/core/TreePrinterService.ts";
|
|
105
|
+
export type { TreeNode } from "./src/api/service/core/TreePrinterService.ts";
|
|
106
|
+
export { default as DefaultTreePrinterService } from "./src/service/treePrinter/DefaultTreePrinterService.ts";
|
|
107
|
+
export { default as TreePrinterServiceProvider } from "./src/service/treePrinter/TreePrinterServiceProvider.ts";
|
|
108
|
+
|
|
109
|
+
export { TABLE_GENERATOR_SERVICE_ID } from "./src/api/service/core/TableGeneratorService.ts";
|
|
110
|
+
export type { default as TableGeneratorService } from "./src/api/service/core/TableGeneratorService.ts";
|
|
111
|
+
export {
|
|
112
|
+
Align,
|
|
113
|
+
type CellOptions,
|
|
114
|
+
type ColumnOptions,
|
|
115
|
+
type RowOptions,
|
|
116
|
+
type TableOptions,
|
|
117
|
+
} from "./src/api/service/core/TableGeneratorService.ts";
|
|
118
|
+
export { default as Table } from "./src/api/service/core/Table.ts";
|
|
119
|
+
export { default as DefaultTableGeneratorService } from "./src/service/tableGenerator/DefaultTableGeneratorService.ts";
|
|
120
|
+
export { default as TableGeneratorServiceProvider } from "./src/service/tableGenerator/TableGeneratorServiceProvider.ts";
|
|
121
|
+
|
|
122
|
+
export { DATA_DUMP_GENERATOR_SERVICE_ID } from "./src/api/service/core/DataDumpGeneratorService.ts";
|
|
123
|
+
export type { default as DataDumpGeneratorService } from "./src/api/service/core/DataDumpGeneratorService.ts";
|
|
124
|
+
export {
|
|
125
|
+
type ByteRangeColor,
|
|
126
|
+
DumpFormat,
|
|
127
|
+
type HexDumpGenerateOptions,
|
|
128
|
+
} from "./src/api/service/core/DataDumpGeneratorService.ts";
|
|
129
|
+
export { default as DefaultDataDumpGeneratorService } from "./src/service/dataDumpGenerator/DefaultDataDumpGeneratorService.ts";
|
|
130
|
+
export { default as DataDumpGeneratorServiceProvider } from "./src/service/dataDumpGenerator/DataDumpGeneratorServiceProvider.ts";
|
|
131
|
+
|
|
132
|
+
export { COMPLETION_SERVICE_ID } from "./src/api/service/core/CompletionService.ts";
|
|
133
|
+
export type { default as CompletionService } from "./src/api/service/core/CompletionService.ts";
|
|
134
|
+
export {
|
|
135
|
+
type CompletionItem,
|
|
136
|
+
ShellType,
|
|
137
|
+
} from "./src/api/service/core/CompletionService.ts";
|
|
138
|
+
export { default as DefaultCompletionService } from "./src/service/completion/DefaultCompletionService.ts";
|
|
139
|
+
export { default as CompletionServiceProvider } from "./src/service/completion/CompletionServiceProvider.ts";
|
|
140
|
+
|
|
141
|
+
export { PROMPTER_SERVICE_ID } from "./src/api/service/core/PrompterService.ts";
|
|
142
|
+
export type { default as PrompterService } from "./src/api/service/core/PrompterService.ts";
|
|
143
|
+
export {
|
|
144
|
+
type Prompt,
|
|
145
|
+
type PromptOption,
|
|
146
|
+
type PromptResult,
|
|
147
|
+
PromptType,
|
|
148
|
+
} from "./src/api/service/core/PrompterService.ts";
|
|
149
|
+
export { default as DefaultPrompterService } from "./src/service/prompter/DefaultPrompterService.ts";
|
|
150
|
+
export {
|
|
151
|
+
DEFAULT_PROMPTER_CONFIG,
|
|
152
|
+
type PrompterServiceConfig,
|
|
153
|
+
} from "./src/service/prompter/DefaultPrompterService.ts";
|
|
154
|
+
export { default as PrompterServiceProvider } from "./src/service/prompter/PrompterServiceProvider.ts";
|
|
155
|
+
|
|
156
|
+
export { ARGUMENT_PROMPTER_SERVICE_ID } from "./src/api/service/core/ArgumentPrompterService.ts";
|
|
157
|
+
export type { default as ArgumentPrompterService } from "./src/api/service/core/ArgumentPrompterService.ts";
|
|
158
|
+
export { default as DefaultArgumentPrompterService } from "./src/service/argumentPrompter/DefaultArgumentPrompterService.ts";
|
|
159
|
+
export { default as ArgumentPrompterServiceProvider } from "./src/service/argumentPrompter/ArgumentPrompterServiceProvider.ts";
|
|
160
|
+
|
|
76
161
|
// CLI API
|
|
77
162
|
export type { InvalidArgument } from "./src/api/RunResult.ts";
|
|
78
163
|
export type { default as Context } from "./src/api/Context.ts";
|
|
@@ -81,6 +166,7 @@ export type {
|
|
|
81
166
|
InvalidArgumentReason,
|
|
82
167
|
RunState,
|
|
83
168
|
} from "./src/api/RunResult.ts";
|
|
169
|
+
export type { default as BaseCLIFeatureOptions } from "./src/api/BaseCLIFeatureOptions.ts";
|
|
84
170
|
export type { default as CLIConfig } from "./src/api/CLIConfig.ts";
|
|
85
171
|
export type { default as CLI } from "./src/api/CLI.ts";
|
|
86
172
|
|
|
@@ -88,6 +174,16 @@ export type { default as CLI } from "./src/api/CLI.ts";
|
|
|
88
174
|
export { default as BaseCLI } from "./src/cli/BaseCLI.ts";
|
|
89
175
|
export { default as DefaultRuntimeCLI } from "./src/cli/DefaultRuntimeCLI.ts";
|
|
90
176
|
|
|
177
|
+
// Terminal API
|
|
178
|
+
export type { default as Terminal } from "./src/terminal/Terminal.ts";
|
|
179
|
+
export type { default as Styler } from "./src/terminal/Styler.ts";
|
|
180
|
+
export type {
|
|
181
|
+
default as KeyReader,
|
|
182
|
+
KeyEvent,
|
|
183
|
+
} from "./src/terminal/KeyReader.ts";
|
|
184
|
+
export { SpecialKey } from "./src/terminal/KeyReader.ts";
|
|
185
|
+
export { default as TtyKeyReader } from "./src/terminal/TtyKeyReader.ts";
|
|
186
|
+
|
|
91
187
|
// Convenience functions
|
|
92
188
|
export {
|
|
93
189
|
launchMultiCommandCLI,
|
package/package.json
CHANGED
|
@@ -18,23 +18,24 @@
|
|
|
18
18
|
],
|
|
19
19
|
"module": "index.ts",
|
|
20
20
|
"type": "module",
|
|
21
|
-
"version": "1.
|
|
21
|
+
"version": "1.2.0",
|
|
22
22
|
"publishConfig": {
|
|
23
23
|
"access": "public"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@types/bun": "^1.
|
|
26
|
+
"@types/bun": "^1.3.14",
|
|
27
|
+
"@types/node": "^25.9.1"
|
|
27
28
|
},
|
|
28
29
|
"peerDependencies": {
|
|
29
|
-
"typescript": "^
|
|
30
|
+
"typescript": "^6.0.3"
|
|
30
31
|
},
|
|
31
32
|
"dependencies": {
|
|
32
33
|
"emphasize": "^7.0.0",
|
|
33
34
|
"fastest-levenshtein": "^1.0.16",
|
|
34
|
-
"figlet": "^1.
|
|
35
|
+
"figlet": "^1.11.0",
|
|
35
36
|
"highlight.js": "^11.11.1",
|
|
36
|
-
"prettier": "^3.
|
|
37
|
-
"supports-color": "^10.
|
|
38
|
-
"
|
|
37
|
+
"prettier": "^3.8.3",
|
|
38
|
+
"supports-color": "^10.2.2",
|
|
39
|
+
"supports-terminal-graphics": "^0.1.0"
|
|
39
40
|
}
|
|
40
41
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export default interface BaseCLIFeatureOptions {
|
|
2
|
+
readonly configFileSupportEnabled?: boolean;
|
|
3
|
+
readonly envVarsSupportEnabled?: boolean;
|
|
4
|
+
readonly keyValueServiceEnabled?: boolean;
|
|
5
|
+
readonly secretServiceEnabled?: boolean;
|
|
6
|
+
readonly argumentPrompterServiceEnabled?: boolean;
|
|
7
|
+
readonly completionServiceEnabled?: boolean;
|
|
8
|
+
readonly imagePrinterServiceEnabled?: boolean;
|
|
9
|
+
readonly validateAllCommands?: boolean;
|
|
10
|
+
}
|
package/src/api/CLIConfig.ts
CHANGED
package/src/api/RunResult.ts
CHANGED
|
@@ -34,6 +34,11 @@ export enum RunState {
|
|
|
34
34
|
* General runtime error related to the framework.
|
|
35
35
|
*/
|
|
36
36
|
RUNTIME_ERROR = 4,
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Execution was interrupted by a signal (e.g. Ctrl-C or SIGTERM).
|
|
40
|
+
*/
|
|
41
|
+
INTERRUPTED = 130,
|
|
37
42
|
}
|
|
38
43
|
|
|
39
44
|
/**
|
|
@@ -84,6 +89,11 @@ export enum InvalidArgumentReason {
|
|
|
84
89
|
* Attempt to set a primitive value on a complex object object.
|
|
85
90
|
*/
|
|
86
91
|
OPTION_IS_COMPLEX = 8,
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* The value failed a custom validation function defined on the argument.
|
|
95
|
+
*/
|
|
96
|
+
CUSTOM_VALIDATION = 9,
|
|
87
97
|
}
|
|
88
98
|
|
|
89
99
|
/**
|
|
@@ -114,6 +124,12 @@ export interface InvalidArgument {
|
|
|
114
124
|
| PopulatedArgumentValues
|
|
115
125
|
| PopulatedArgumentValueType
|
|
116
126
|
| Array<PopulatedArgumentValues | PopulatedArgumentValueType>;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* An optional message providing detail about the validation failure.
|
|
130
|
+
* Populated when {@link reason} is {@link InvalidArgumentReason.CUSTOM_VALIDATION}.
|
|
131
|
+
*/
|
|
132
|
+
readonly message?: string;
|
|
117
133
|
}
|
|
118
134
|
|
|
119
135
|
/**
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
ArgumentSingleValueType,
|
|
3
|
+
ArgumentValues,
|
|
4
|
+
ArgumentValueType,
|
|
3
5
|
ArgumentValueTypeName,
|
|
4
6
|
} from "./ArgumentValueTypes.ts";
|
|
5
7
|
|
|
@@ -48,4 +50,26 @@ export default interface Argument {
|
|
|
48
50
|
* it will only be used if the parent {@link Command} has specified {@link Command.enableConfiguration} as `true`.
|
|
49
51
|
*/
|
|
50
52
|
readonly configurationKey?: string;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Optional custom validation function invoked after all built-in validation
|
|
56
|
+
* has passed. Receives the validated and type-converted value.
|
|
57
|
+
*
|
|
58
|
+
* Return `undefined` if the value is valid, or a string describing the
|
|
59
|
+
* validation error. The error string is associated with
|
|
60
|
+
* {@link InvalidArgumentReason.CUSTOM_VALIDATION}.
|
|
61
|
+
*
|
|
62
|
+
* Example: ensure array values are unique:
|
|
63
|
+
* ```typescript
|
|
64
|
+
* validate: (value) => {
|
|
65
|
+
* const arr = value as string[];
|
|
66
|
+
* return new Set(arr).size !== arr.length
|
|
67
|
+
* ? "values must be unique"
|
|
68
|
+
* : undefined;
|
|
69
|
+
* }
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
readonly validate?: (
|
|
73
|
+
value: ArgumentValueType | ArgumentValues | Array<ArgumentValues>,
|
|
74
|
+
) => string | undefined;
|
|
51
75
|
}
|
|
@@ -18,7 +18,7 @@ export interface ServiceInfo {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
|
-
* Interface allowing
|
|
21
|
+
* Interface allowing a service to be provided to the CLI.
|
|
22
22
|
*/
|
|
23
23
|
export interface ServiceProvider {
|
|
24
24
|
/**
|
|
@@ -33,11 +33,11 @@ export interface ServiceProvider {
|
|
|
33
33
|
readonly servicePriority: number;
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
|
-
* Return {@link ServiceInfo} containing the service and any commands which should be registered in the CLI.
|
|
36
|
+
* Return {@link ServiceInfo} containing the service and any commands it provides which should be registered in the CLI.
|
|
37
37
|
*
|
|
38
38
|
* @param cliConfig the {@link CLIConfig} for the CLI.
|
|
39
39
|
*/
|
|
40
|
-
|
|
40
|
+
getServiceInfo(cliConfig: CLIConfig): Promise<ServiceInfo>;
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
43
|
* Initialise the service. This will be invoked AFTER any {@link GlobalModifierCommand} provided in the
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ParseResult } from "../../../runtime/parser.ts";
|
|
2
|
+
|
|
3
|
+
export const ARGUMENT_PROMPTER_SERVICE_ID =
|
|
4
|
+
"@flowscripter/dynamic-cli-framework/argument-prompter-service";
|
|
5
|
+
|
|
6
|
+
export default interface ArgumentPrompterService {
|
|
7
|
+
promptForMissingArguments(
|
|
8
|
+
parseResult: ParseResult,
|
|
9
|
+
): Promise<ParseResult>;
|
|
10
|
+
}
|
|
@@ -1,8 +1,46 @@
|
|
|
1
1
|
export const ASCII_BANNER_GENERATOR_SERVICE_ID =
|
|
2
2
|
"@flowscripter/dynamic-cli-framework/ascii-banner-generator-service";
|
|
3
3
|
|
|
4
|
+
export type ColorEffectDirection = "horizontal" | "vertical";
|
|
5
|
+
|
|
6
|
+
export interface FixedColorEffect {
|
|
7
|
+
type: "fixed";
|
|
8
|
+
color: string; // hex "#rrggbb"
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface GradientColorEffect {
|
|
12
|
+
type: "gradient";
|
|
13
|
+
colors: string[]; // 2+ hex color stops
|
|
14
|
+
direction: ColorEffectDirection;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface RainbowColorEffect {
|
|
18
|
+
type: "rainbow";
|
|
19
|
+
spread?: number; // default 8.0
|
|
20
|
+
frequency?: number; // default 0.3
|
|
21
|
+
seed?: number; // default 0 = random seed
|
|
22
|
+
direction: ColorEffectDirection;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type ColorEffect =
|
|
26
|
+
| FixedColorEffect
|
|
27
|
+
| GradientColorEffect
|
|
28
|
+
| RainbowColorEffect;
|
|
29
|
+
|
|
30
|
+
export interface BannerColorEffects {
|
|
31
|
+
background?: ColorEffect;
|
|
32
|
+
messageForeground?: ColorEffect;
|
|
33
|
+
subMessageForeground?: ColorEffect;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface BannerGenerateOptions {
|
|
37
|
+
fontName?: string;
|
|
38
|
+
subMessage?: string;
|
|
39
|
+
colorEffects?: BannerColorEffects;
|
|
40
|
+
}
|
|
41
|
+
|
|
4
42
|
/**
|
|
5
|
-
* Service allowing a text string to be rendered using an ASCII banner
|
|
43
|
+
* Service allowing a text string to be rendered using an ASCII banner font.
|
|
6
44
|
*/
|
|
7
45
|
export default interface AsciiBannerGeneratorService {
|
|
8
46
|
/**
|
|
@@ -12,11 +50,10 @@ export default interface AsciiBannerGeneratorService {
|
|
|
12
50
|
* (replacing newlines with `\n`) and placing in a simple JSON file: `{ "font": "<figlet font definition>" }`.
|
|
13
51
|
* This can then be imported as follows:
|
|
14
52
|
*
|
|
15
|
-
* `import { font as myFont } from "./myfont.json" with { type: "json" }
|
|
53
|
+
* `import { font as myFont } from "./myfont.json" with { type: "json" };`
|
|
16
54
|
*
|
|
17
55
|
* @param fontName the name used to refer to the font.
|
|
18
|
-
* @param fontDefinition the definition for the syntax conforming to the
|
|
19
|
-
* [FIGfont format](http://www.jave.de/figlet/figfont.html#creating).
|
|
56
|
+
* @param fontDefinition the definition for the syntax conforming to the FIGfont format.
|
|
20
57
|
*/
|
|
21
58
|
registerFont(fontName: string, fontDefinition: string): void;
|
|
22
59
|
|
|
@@ -26,10 +63,10 @@ export default interface AsciiBannerGeneratorService {
|
|
|
26
63
|
getRegisteredFonts(): ReadonlyArray<string>;
|
|
27
64
|
|
|
28
65
|
/**
|
|
29
|
-
* Generate an ASCII banner text for the message using the specified
|
|
66
|
+
* Generate an ASCII banner text for the message using the specified options.
|
|
30
67
|
*
|
|
31
68
|
* @param message the message to output.
|
|
32
|
-
* @param
|
|
69
|
+
* @param options optional generation options.
|
|
33
70
|
*/
|
|
34
|
-
generate(message: string,
|
|
71
|
+
generate(message: string, options?: BannerGenerateOptions): Promise<string>;
|
|
35
72
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export const COMPLETION_SERVICE_ID =
|
|
2
|
+
"@flowscripter/dynamic-cli-framework/completion-service";
|
|
3
|
+
|
|
4
|
+
export enum ShellType {
|
|
5
|
+
BASH = "bash",
|
|
6
|
+
ZSH = "zsh",
|
|
7
|
+
FISH = "fish",
|
|
8
|
+
POWERSHELL = "powershell",
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface CompletionItem {
|
|
12
|
+
readonly value: string;
|
|
13
|
+
readonly description?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Interface for a service providing shell auto-completion support.
|
|
18
|
+
*/
|
|
19
|
+
export default interface CompletionService {
|
|
20
|
+
generateCompletions(
|
|
21
|
+
shellType: ShellType,
|
|
22
|
+
line: string,
|
|
23
|
+
cursorPosition: number,
|
|
24
|
+
): Promise<ReadonlyArray<CompletionItem>>;
|
|
25
|
+
|
|
26
|
+
getBootstrapScript(shellType: ShellType, cliName: string): string;
|
|
27
|
+
|
|
28
|
+
getDefaultConfigPath(shellType: ShellType): string;
|
|
29
|
+
|
|
30
|
+
validateShellEnvironment(shellType: ShellType): Promise<boolean>;
|
|
31
|
+
|
|
32
|
+
formatCompletions(
|
|
33
|
+
shellType: ShellType,
|
|
34
|
+
completions: ReadonlyArray<CompletionItem>,
|
|
35
|
+
): string;
|
|
36
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Buffer } from "node:buffer";
|
|
2
|
+
|
|
3
|
+
export const DATA_DUMP_GENERATOR_SERVICE_ID =
|
|
4
|
+
"@flowscripter/dynamic-cli-framework/data-dump-generator-service";
|
|
5
|
+
|
|
6
|
+
export enum DumpFormat {
|
|
7
|
+
HEX = "HEX",
|
|
8
|
+
ASCII = "ASCII",
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface ByteRangeColor {
|
|
12
|
+
start: number;
|
|
13
|
+
end: number;
|
|
14
|
+
color: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface HexDumpGenerateOptions {
|
|
18
|
+
format?: DumpFormat;
|
|
19
|
+
bytesPerGroup?: number;
|
|
20
|
+
groupsPerRow?: number;
|
|
21
|
+
spacesBetweenGroups?: number;
|
|
22
|
+
colorScheme?: ByteRangeColor[];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default interface DataDumpGeneratorService {
|
|
26
|
+
generate(data: Buffer, options?: HexDumpGenerateOptions): string;
|
|
27
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export const IMAGE_PRINTER_SERVICE_ID =
|
|
2
|
+
"@flowscripter/dynamic-cli-framework/image-printer-service";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Service for rendering images in the terminal.
|
|
6
|
+
*
|
|
7
|
+
* Uses the Kitty or iTerm2 graphics protocol when supported, otherwise falls back
|
|
8
|
+
* to ANSI half-block character rendering. Terminal multiplexers (tmux, screen) always
|
|
9
|
+
* use the ANSI fallback as they do not pass through graphics protocol escape sequences.
|
|
10
|
+
*/
|
|
11
|
+
export default interface ImagePrinterService {
|
|
12
|
+
/**
|
|
13
|
+
* Render an image as a string suitable for terminal output.
|
|
14
|
+
*
|
|
15
|
+
* @param imageBuffer the raw image data (e.g. PNG file contents).
|
|
16
|
+
* @param widthPercentage the percentage of terminal width to use for rendering. Defaults to 100.
|
|
17
|
+
* @param hexFormattedBackgroundColor optional background color for transparent pixels.
|
|
18
|
+
* This should be a valid hex formatted string e.g. "#rrggbb". If not specified,
|
|
19
|
+
* transparent pixels show through to the terminal background.
|
|
20
|
+
*/
|
|
21
|
+
image(
|
|
22
|
+
imageBuffer: Uint8Array,
|
|
23
|
+
widthPercentage?: number,
|
|
24
|
+
hexFormattedBackgroundColor?: string,
|
|
25
|
+
): Promise<string>;
|
|
26
|
+
}
|
|
@@ -1,28 +1,45 @@
|
|
|
1
1
|
export const KEY_VALUE_SERVICE_ID =
|
|
2
2
|
"@flowscripter/dynamic-cli-framework/key-value-service";
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* The sentinel prefix used to indicate a value is stored as an OS-native secret.
|
|
6
|
+
* Values starting with this prefix are resolved via the {@link SecretService}.
|
|
7
|
+
* This prefix is reserved and must not be used for regular key-value data.
|
|
8
|
+
*/
|
|
9
|
+
export const SECRET_SENTINEL_PREFIX = "__SECRET__:";
|
|
10
|
+
|
|
4
11
|
/**
|
|
5
12
|
* Service providing keystore functionality for the CLI. The keystore data is scoped to the
|
|
6
|
-
* service or {@link Command} instances accessing this service via {@link Context.getServiceById}
|
|
13
|
+
* service or {@link Command} instances accessing this service via {@link Context.getServiceById}.
|
|
14
|
+
*
|
|
15
|
+
* Values can optionally be stored as OS-native secrets using the `isSecret` parameter on
|
|
16
|
+
* {@link setKey}. Secret values are stored via {@link SecretService} and only a sentinel
|
|
17
|
+
* reference is kept in the key-value Map. The sentinel prefix `__SECRET__:` is reserved.
|
|
7
18
|
*/
|
|
8
19
|
export default interface KeyValueService {
|
|
9
20
|
/**
|
|
10
21
|
* Get a value for a specified key in the keystore.
|
|
22
|
+
* If the stored value is a secret sentinel, the actual value is retrieved from the OS secret store.
|
|
11
23
|
*/
|
|
12
|
-
getKey(key: string): string
|
|
24
|
+
getKey(key: string): Promise<string>;
|
|
13
25
|
|
|
14
26
|
/**
|
|
15
27
|
* Set a value for a specified key in the keystore.
|
|
28
|
+
*
|
|
29
|
+
* @param isSecret if true, the value is stored in the OS-native secret store and a sentinel
|
|
30
|
+
* reference is kept in the key-value Map. Requires that the service was constructed with
|
|
31
|
+
* secret support enabled.
|
|
16
32
|
*/
|
|
17
|
-
setKey(key: string, value: string): void
|
|
33
|
+
setKey(key: string, value: string, isSecret?: boolean): Promise<void>;
|
|
18
34
|
|
|
19
35
|
/**
|
|
20
36
|
* Check if a value for a specified key exists in the keystore.
|
|
21
37
|
*/
|
|
22
|
-
hasKey(key: string): boolean
|
|
38
|
+
hasKey(key: string): Promise<boolean>;
|
|
23
39
|
|
|
24
40
|
/**
|
|
25
41
|
* Delete the value for a specified key in the keystore.
|
|
42
|
+
* If the stored value is a secret sentinel, the secret is also deleted from the OS secret store.
|
|
26
43
|
*/
|
|
27
|
-
deleteKey(key: string): void
|
|
44
|
+
deleteKey(key: string): Promise<void>;
|
|
28
45
|
}
|