@flowscripter/dynamic-cli-framework 1.6.1 → 1.7.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/cli-plugin.ts +89 -1
- package/dist/cli-plugin.d.ts +43 -1
- package/dist/cli-plugin.d.ts.map +1 -1
- package/dist/cli-plugin.js +179 -1
- package/dist/index.js +178 -164
- package/dist/src/api/plugin/CLIPlugin.d.ts +31 -0
- package/dist/src/api/plugin/CLIPlugin.d.ts.map +1 -0
- package/dist/src/api/plugin/createCLIPlugin.d.ts +14 -0
- package/dist/src/api/plugin/createCLIPlugin.d.ts.map +1 -0
- package/dist/src/api/service/core/CompletionService.d.ts +1 -1
- package/dist/src/api/service/core/CompletionService.d.ts.map +1 -1
- package/dist/src/command/CompletionCommand.d.ts.map +1 -1
- package/dist/src/command/PluginCommand.d.ts.map +1 -1
- package/dist/src/service/completion/CompletionServiceProvider.d.ts.map +1 -1
- package/dist/src/service/completion/DefaultCompletionService.d.ts +1 -1
- package/dist/src/service/completion/DefaultCompletionService.d.ts.map +1 -1
- package/dist/src/service/completion/shell/ShellHandler.d.ts +1 -1
- package/dist/src/service/completion/shell/ShellHandler.d.ts.map +1 -1
- package/dist/src/service/completion/shell/bash.d.ts +1 -1
- package/dist/src/service/completion/shell/bash.d.ts.map +1 -1
- package/dist/src/service/completion/shell/fish.d.ts +1 -1
- package/dist/src/service/completion/shell/fish.d.ts.map +1 -1
- package/dist/src/service/completion/shell/powershell.d.ts +1 -1
- package/dist/src/service/completion/shell/powershell.d.ts.map +1 -1
- package/dist/src/service/completion/shell/zsh.d.ts +1 -1
- package/dist/src/service/completion/shell/zsh.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/api/plugin/CLIPlugin.ts +35 -0
- package/src/api/plugin/createCLIPlugin.ts +47 -0
- package/src/api/service/core/CompletionService.ts +1 -1
- package/src/command/CompletionCommand.ts +6 -1
- package/src/command/PluginCommand.ts +20 -7
- package/src/service/completion/CompletionServiceProvider.ts +6 -1
- package/src/service/completion/DefaultCompletionService.ts +2 -2
- package/src/service/completion/shell/ShellHandler.ts +1 -1
- package/src/service/completion/shell/bash.ts +2 -2
- package/src/service/completion/shell/fish.ts +2 -2
- package/src/service/completion/shell/powershell.ts +5 -3
- package/src/service/completion/shell/zsh.ts +2 -2
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Plugin, ExtensionDescriptor } from "@flowscripter/dynamic-plugin-framework";
|
|
2
|
+
import type CommandFactory from "./CommandFactory.ts";
|
|
3
|
+
import { DYNAMIC_CLI_FRAMEWORK_COMMAND_FACTORY_EXTENSION_POINT } from "./CommandFactory.ts";
|
|
4
|
+
import type ServiceProviderFactory from "./ServiceProviderFactory.ts";
|
|
5
|
+
import { DYNAMIC_CLI_FRAMEWORK_SERVICE_PROVIDER_FACTORY_EXTENSION_POINT } from "./ServiceProviderFactory.ts";
|
|
6
|
+
/**
|
|
7
|
+
* {@link ExtensionDescriptor} for a {@link CommandFactory} extension.
|
|
8
|
+
*/
|
|
9
|
+
export interface CommandFactoryExtensionDescriptor extends ExtensionDescriptor {
|
|
10
|
+
readonly extensionPoint: typeof DYNAMIC_CLI_FRAMEWORK_COMMAND_FACTORY_EXTENSION_POINT;
|
|
11
|
+
readonly factory: {
|
|
12
|
+
create(hostData?: Map<string, string>): Promise<CommandFactory>;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* {@link ExtensionDescriptor} for a {@link ServiceProviderFactory} extension.
|
|
17
|
+
*/
|
|
18
|
+
export interface ServiceProviderFactoryExtensionDescriptor extends ExtensionDescriptor {
|
|
19
|
+
readonly extensionPoint: typeof DYNAMIC_CLI_FRAMEWORK_SERVICE_PROVIDER_FACTORY_EXTENSION_POINT;
|
|
20
|
+
readonly factory: {
|
|
21
|
+
create(hostData?: Map<string, string>): Promise<ServiceProviderFactory>;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* A {@link Plugin} for {@link DynamicPluginRuntimeCLI} whose {@link extensionDescriptors} are
|
|
26
|
+
* limited to the {@link CommandFactory} and {@link ServiceProviderFactory} extension points.
|
|
27
|
+
*/
|
|
28
|
+
export default interface CLIPlugin extends Plugin {
|
|
29
|
+
readonly extensionDescriptors: ReadonlyArray<CommandFactoryExtensionDescriptor | ServiceProviderFactoryExtensionDescriptor>;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=CLIPlugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CLIPlugin.d.ts","sourceRoot":"","sources":["../../../../src/api/plugin/CLIPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC1F,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,qDAAqD,EAAE,MAAM,qBAAqB,CAAC;AAC5F,OAAO,KAAK,sBAAsB,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAE,8DAA8D,EAAE,MAAM,6BAA6B,CAAC;AAE7G;;GAEG;AACH,MAAM,WAAW,iCAAkC,SAAQ,mBAAmB;IAC5E,QAAQ,CAAC,cAAc,EAAE,OAAO,qDAAqD,CAAC;IACtF,QAAQ,CAAC,OAAO,EAAE;QAChB,MAAM,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;KACjE,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,yCAA0C,SAAQ,mBAAmB;IACpF,QAAQ,CAAC,cAAc,EAAE,OAAO,8DAA8D,CAAC;IAC/F,QAAQ,CAAC,OAAO,EAAE;QAChB,MAAM,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;KACzE,CAAC;CACH;AAED;;;GAGG;AACH,MAAM,CAAC,OAAO,WAAW,SAAU,SAAQ,MAAM;IAC/C,QAAQ,CAAC,oBAAoB,EAAE,aAAa,CAC1C,iCAAiC,GAAG,yCAAyC,CAC9E,CAAC;CACH"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type CommandFactory from "./CommandFactory.ts";
|
|
2
|
+
import type ServiceProviderFactory from "./ServiceProviderFactory.ts";
|
|
3
|
+
import type CLIPlugin from "./CLIPlugin.ts";
|
|
4
|
+
export interface CLIPluginOptions {
|
|
5
|
+
readonly commandFactory?: CommandFactory | (() => Promise<CommandFactory>);
|
|
6
|
+
readonly serviceProviderFactory?: ServiceProviderFactory | (() => Promise<ServiceProviderFactory>);
|
|
7
|
+
readonly pluginData?: ReadonlyMap<string, string>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Build a {@link CLIPlugin} from optional {@link CommandFactory} and {@link ServiceProviderFactory}
|
|
11
|
+
* instances (or factory functions), without needing to hand-construct extension descriptors.
|
|
12
|
+
*/
|
|
13
|
+
export default function createCLIPlugin(options: CLIPluginOptions): CLIPlugin;
|
|
14
|
+
//# sourceMappingURL=createCLIPlugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createCLIPlugin.d.ts","sourceRoot":"","sources":["../../../../src/api/plugin/createCLIPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAC;AAEtD,OAAO,KAAK,sBAAsB,MAAM,6BAA6B,CAAC;AAEtE,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAE5C,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,cAAc,CAAC,EAAE,cAAc,GAAG,CAAC,MAAM,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC;IAC3E,QAAQ,CAAC,sBAAsB,CAAC,EAC5B,sBAAsB,GACtB,CAAC,MAAM,OAAO,CAAC,sBAAsB,CAAC,CAAC,CAAC;IAC5C,QAAQ,CAAC,UAAU,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnD;AAED;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,OAAO,EAAE,gBAAgB,GAAG,SAAS,CA4B5E"}
|
|
@@ -14,7 +14,7 @@ export interface CompletionItem {
|
|
|
14
14
|
*/
|
|
15
15
|
export default interface CompletionService {
|
|
16
16
|
generateCompletions(shellType: ShellType, line: string, cursorPosition: number): Promise<ReadonlyArray<CompletionItem>>;
|
|
17
|
-
getBootstrapScript(shellType: ShellType, cliName: string): string;
|
|
17
|
+
getBootstrapScript(shellType: ShellType, cliName: string, executablePath: string): string;
|
|
18
18
|
getDefaultConfigPath(shellType: ShellType): string;
|
|
19
19
|
validateShellEnvironment(shellType: ShellType): Promise<boolean>;
|
|
20
20
|
formatCompletions(shellType: ShellType, completions: ReadonlyArray<CompletionItem>): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompletionService.d.ts","sourceRoot":"","sources":["../../../../../src/api/service/core/CompletionService.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,2DAA2D,CAAC;AAE9F,oBAAY,SAAS;IACnB,IAAI,SAAS;IACb,GAAG,QAAQ;IACX,IAAI,SAAS;IACb,UAAU,eAAe;CAC1B;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,CAAC,OAAO,WAAW,iBAAiB;IACxC,mBAAmB,CACjB,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,MAAM,EACZ,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC,CAAC;IAE1C,kBAAkB,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"CompletionService.d.ts","sourceRoot":"","sources":["../../../../../src/api/service/core/CompletionService.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,2DAA2D,CAAC;AAE9F,oBAAY,SAAS;IACnB,IAAI,SAAS;IACb,GAAG,QAAQ;IACX,IAAI,SAAS;IACb,UAAU,eAAe;CAC1B;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,CAAC,OAAO,WAAW,iBAAiB;IACxC,mBAAmB,CACjB,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,MAAM,EACZ,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC,CAAC;IAE1C,kBAAkB,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,MAAM,CAAC;IAE1F,oBAAoB,CAAC,SAAS,EAAE,SAAS,GAAG,MAAM,CAAC;IAEnD,wBAAwB,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAEjE,iBAAiB,CAAC,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,aAAa,CAAC,cAAc,CAAC,GAAG,MAAM,CAAC;CAC7F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompletionCommand.d.ts","sourceRoot":"","sources":["../../../src/command/CompletionCommand.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CompletionCommand.d.ts","sourceRoot":"","sources":["../../../src/command/CompletionCommand.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,YAAY,MAAM,gCAAgC,CAAC;AAC/D,OAAO,KAAK,UAAU,MAAM,8BAA8B,CAAC;AAC3D,OAAO,KAAK,MAAM,MAAM,2BAA2B,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AAuB,YAAW,UAAU;IACvD,QAAQ,CAAC,IAAI,YAAY;IACzB,QAAQ,CAAC,WAAW,uCAAuC;IAC3D,QAAQ,CAAC,mBAAmB,SAAS;IACrC,QAAQ,CAAC,OAAO,UAAM;IACtB,QAAQ,CAAC,WAAW;;;;QAMlB;IAEI,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CAS/E;AAED,qBAAa,uBAAwB,YAAW,UAAU;IACxD,QAAQ,CAAC,IAAI,aAAa;IAC1B,QAAQ,CAAC,WAAW,uCAAuC;IAC3D,QAAQ,CAAC,mBAAmB,SAAS;IACrC,QAAQ,CAAC,OAAO,UAAM;IACtB,QAAQ,CAAC,WAAW,UAAM;IAEpB,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CAmBhF;AAED,qBAAa,kBAAmB,YAAW,YAAY;IACrD,QAAQ,CAAC,IAAI,YAAY;IACzB,QAAQ,CAAC,WAAW,wBAAwB;IAC5C,QAAQ,CAAC,mBAAmB,SAAS;IACrC,QAAQ,CAAC,iBAAiB,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;;IAYhD,OAAO,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAChD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompletionServiceProvider.d.ts","sourceRoot":"","sources":["../../../../src/service/completion/CompletionServiceProvider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CompletionServiceProvider.d.ts","sourceRoot":"","sources":["../../../../src/service/completion/CompletionServiceProvider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,KAAK,SAAS,MAAM,wBAAwB,CAAC;AACpD,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAGhD,OAAO,KAAK,wBAAwB,MAAM,+BAA+B,CAAC;AAY1E,MAAM,CAAC,OAAO,OAAO,yBAA0B,YAAW,eAAe;;IACvE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAyB;IACnD,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;gBAId,eAAe,EAAE,MAAM,EAAE,iBAAiB,EAAE,wBAAwB;IAKhF,cAAc,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC;IAQpD,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAsJ1D"}
|
|
@@ -4,7 +4,7 @@ import type CommandRegistry from "../../runtime/registry/CommandRegistry.ts";
|
|
|
4
4
|
export default class DefaultCompletionService implements CompletionService {
|
|
5
5
|
#private;
|
|
6
6
|
setCommandRegistry(registry: CommandRegistry): void;
|
|
7
|
-
getBootstrapScript(shellType: ShellType, cliName: string): string;
|
|
7
|
+
getBootstrapScript(shellType: ShellType, cliName: string, executablePath: string): string;
|
|
8
8
|
getDefaultConfigPath(shellType: ShellType): string;
|
|
9
9
|
validateShellEnvironment(shellType: ShellType): Promise<boolean>;
|
|
10
10
|
formatCompletions(shellType: ShellType, completions: ReadonlyArray<CompletionItem>): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultCompletionService.d.ts","sourceRoot":"","sources":["../../../../src/service/completion/DefaultCompletionService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,iBAAiB,MAAM,6CAA6C,CAAC;AACjF,OAAO,EAAE,KAAK,cAAc,EAAE,SAAS,EAAE,MAAM,6CAA6C,CAAC;AAC7F,OAAO,KAAK,eAAe,MAAM,2CAA2C,CAAC;AAS7E,MAAM,CAAC,OAAO,OAAO,wBAAyB,YAAW,iBAAiB;;IAUxE,kBAAkB,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI;IAInD,kBAAkB,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM;
|
|
1
|
+
{"version":3,"file":"DefaultCompletionService.d.ts","sourceRoot":"","sources":["../../../../src/service/completion/DefaultCompletionService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,iBAAiB,MAAM,6CAA6C,CAAC;AACjF,OAAO,EAAE,KAAK,cAAc,EAAE,SAAS,EAAE,MAAM,6CAA6C,CAAC;AAC7F,OAAO,KAAK,eAAe,MAAM,2CAA2C,CAAC;AAS7E,MAAM,CAAC,OAAO,OAAO,wBAAyB,YAAW,iBAAiB;;IAUxE,kBAAkB,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI;IAInD,kBAAkB,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,MAAM;IAIzF,oBAAoB,CAAC,SAAS,EAAE,SAAS,GAAG,MAAM;IAIlD,wBAAwB,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC;IAIhE,iBAAiB,CAAC,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,aAAa,CAAC,cAAc,CAAC,GAAG,MAAM;IAI3F,sBAAsB,CACpB,KAAK,EAAE,SAAS,EAChB,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,GAC1B;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,MAAM,CAAA;KAAE;IAI3C,mBAAmB,CACjB,UAAU,EAAE,SAAS,EACrB,IAAI,EAAE,MAAM,EACZ,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;CAgR1C"}
|
|
@@ -5,7 +5,7 @@ export interface CompletionContext {
|
|
|
5
5
|
}
|
|
6
6
|
export default interface ShellHandler {
|
|
7
7
|
getDefaultConfigPath(): string;
|
|
8
|
-
getBootstrapScript(cliName: string): string;
|
|
8
|
+
getBootstrapScript(cliName: string, executablePath: string): string;
|
|
9
9
|
validateEnvironment(): Promise<boolean>;
|
|
10
10
|
formatCompletions(completions: ReadonlyArray<CompletionItem>): string;
|
|
11
11
|
parseCompletionContext(args: ReadonlyArray<string>): CompletionContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShellHandler.d.ts","sourceRoot":"","sources":["../../../../../src/service/completion/shell/ShellHandler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gDAAgD,CAAC;AAErF,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;CACjC;AAED,MAAM,CAAC,OAAO,WAAW,YAAY;IACnC,oBAAoB,IAAI,MAAM,CAAC;IAC/B,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"ShellHandler.d.ts","sourceRoot":"","sources":["../../../../../src/service/completion/shell/ShellHandler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gDAAgD,CAAC;AAErF,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;CACjC;AAED,MAAM,CAAC,OAAO,WAAW,YAAY;IACnC,oBAAoB,IAAI,MAAM,CAAC;IAC/B,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,MAAM,CAAC;IACpE,mBAAmB,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IACxC,iBAAiB,CAAC,WAAW,EAAE,aAAa,CAAC,cAAc,CAAC,GAAG,MAAM,CAAC;IACtE,sBAAsB,CAAC,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,iBAAiB,CAAC;CACxE"}
|
|
@@ -3,7 +3,7 @@ import type ShellHandler from "./ShellHandler.ts";
|
|
|
3
3
|
import type { CompletionContext } from "./ShellHandler.ts";
|
|
4
4
|
export default class BashShellHandler implements ShellHandler {
|
|
5
5
|
getDefaultConfigPath(): string;
|
|
6
|
-
getBootstrapScript(cliName: string): string;
|
|
6
|
+
getBootstrapScript(cliName: string, executablePath: string): string;
|
|
7
7
|
validateEnvironment(): Promise<boolean>;
|
|
8
8
|
formatCompletions(completions: ReadonlyArray<CompletionItem>): string;
|
|
9
9
|
parseCompletionContext(args: ReadonlyArray<string>): CompletionContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bash.d.ts","sourceRoot":"","sources":["../../../../../src/service/completion/shell/bash.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gDAAgD,CAAC;AACrF,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAI3D,MAAM,CAAC,OAAO,OAAO,gBAAiB,YAAW,YAAY;IAC3D,oBAAoB,IAAI,MAAM;IAI9B,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;
|
|
1
|
+
{"version":3,"file":"bash.d.ts","sourceRoot":"","sources":["../../../../../src/service/completion/shell/bash.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gDAAgD,CAAC;AACrF,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAI3D,MAAM,CAAC,OAAO,OAAO,gBAAiB,YAAW,YAAY;IAC3D,oBAAoB,IAAI,MAAM;IAI9B,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,MAAM;IAUnE,mBAAmB,IAAI,OAAO,CAAC,OAAO,CAAC;IAavC,iBAAiB,CAAC,WAAW,EAAE,aAAa,CAAC,cAAc,CAAC,GAAG,MAAM;IAIrE,sBAAsB,CAAC,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,iBAAiB;CAKvE"}
|
|
@@ -3,7 +3,7 @@ import type ShellHandler from "./ShellHandler.ts";
|
|
|
3
3
|
import type { CompletionContext } from "./ShellHandler.ts";
|
|
4
4
|
export default class FishShellHandler implements ShellHandler {
|
|
5
5
|
getDefaultConfigPath(): string;
|
|
6
|
-
getBootstrapScript(cliName: string): string;
|
|
6
|
+
getBootstrapScript(cliName: string, executablePath: string): string;
|
|
7
7
|
validateEnvironment(): Promise<boolean>;
|
|
8
8
|
formatCompletions(completions: ReadonlyArray<CompletionItem>): string;
|
|
9
9
|
parseCompletionContext(args: ReadonlyArray<string>): CompletionContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fish.d.ts","sourceRoot":"","sources":["../../../../../src/service/completion/shell/fish.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gDAAgD,CAAC;AACrF,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAI3D,MAAM,CAAC,OAAO,OAAO,gBAAiB,YAAW,YAAY;IAC3D,oBAAoB,IAAI,MAAM;IAI9B,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;
|
|
1
|
+
{"version":3,"file":"fish.d.ts","sourceRoot":"","sources":["../../../../../src/service/completion/shell/fish.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gDAAgD,CAAC;AACrF,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAI3D,MAAM,CAAC,OAAO,OAAO,gBAAiB,YAAW,YAAY;IAC3D,oBAAoB,IAAI,MAAM;IAI9B,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,MAAM;IAInE,mBAAmB,IAAI,OAAO,CAAC,OAAO,CAAC;IAavC,iBAAiB,CAAC,WAAW,EAAE,aAAa,CAAC,cAAc,CAAC,GAAG,MAAM;IAMrE,sBAAsB,CAAC,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,iBAAiB;CAKvE"}
|
|
@@ -3,7 +3,7 @@ import type ShellHandler from "./ShellHandler.ts";
|
|
|
3
3
|
import type { CompletionContext } from "./ShellHandler.ts";
|
|
4
4
|
export default class PowerShellShellHandler implements ShellHandler {
|
|
5
5
|
getDefaultConfigPath(): string;
|
|
6
|
-
getBootstrapScript(cliName: string): string;
|
|
6
|
+
getBootstrapScript(cliName: string, executablePath: string): string;
|
|
7
7
|
validateEnvironment(): Promise<boolean>;
|
|
8
8
|
formatCompletions(completions: ReadonlyArray<CompletionItem>): string;
|
|
9
9
|
parseCompletionContext(args: ReadonlyArray<string>): CompletionContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"powershell.d.ts","sourceRoot":"","sources":["../../../../../src/service/completion/shell/powershell.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gDAAgD,CAAC;AACrF,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAI3D,MAAM,CAAC,OAAO,OAAO,sBAAuB,YAAW,YAAY;IACjE,oBAAoB,IAAI,MAAM;IAO9B,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;
|
|
1
|
+
{"version":3,"file":"powershell.d.ts","sourceRoot":"","sources":["../../../../../src/service/completion/shell/powershell.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gDAAgD,CAAC;AACrF,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAI3D,MAAM,CAAC,OAAO,OAAO,sBAAuB,YAAW,YAAY;IACjE,oBAAoB,IAAI,MAAM;IAO9B,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,MAAM;IAYnE,mBAAmB,IAAI,OAAO,CAAC,OAAO,CAAC;IAmBvC,iBAAiB,CAAC,WAAW,EAAE,aAAa,CAAC,cAAc,CAAC,GAAG,MAAM;IAIrE,sBAAsB,CAAC,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,iBAAiB;CAKvE"}
|
|
@@ -3,7 +3,7 @@ import type ShellHandler from "./ShellHandler.ts";
|
|
|
3
3
|
import type { CompletionContext } from "./ShellHandler.ts";
|
|
4
4
|
export default class ZshShellHandler implements ShellHandler {
|
|
5
5
|
getDefaultConfigPath(): string;
|
|
6
|
-
getBootstrapScript(cliName: string): string;
|
|
6
|
+
getBootstrapScript(cliName: string, executablePath: string): string;
|
|
7
7
|
validateEnvironment(): Promise<boolean>;
|
|
8
8
|
formatCompletions(completions: ReadonlyArray<CompletionItem>): string;
|
|
9
9
|
parseCompletionContext(args: ReadonlyArray<string>): CompletionContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zsh.d.ts","sourceRoot":"","sources":["../../../../../src/service/completion/shell/zsh.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gDAAgD,CAAC;AACrF,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAI3D,MAAM,CAAC,OAAO,OAAO,eAAgB,YAAW,YAAY;IAC1D,oBAAoB,IAAI,MAAM;IAI9B,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;
|
|
1
|
+
{"version":3,"file":"zsh.d.ts","sourceRoot":"","sources":["../../../../../src/service/completion/shell/zsh.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gDAAgD,CAAC;AACrF,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAI3D,MAAM,CAAC,OAAO,OAAO,eAAgB,YAAW,YAAY;IAC1D,oBAAoB,IAAI,MAAM;IAI9B,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,MAAM;IAWnE,mBAAmB,IAAI,OAAO,CAAC,OAAO,CAAC;IAavC,iBAAiB,CAAC,WAAW,EAAE,aAAa,CAAC,cAAc,CAAC,GAAG,MAAM;IAMrE,sBAAsB,CAAC,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,iBAAiB;CAKvE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flowscripter/dynamic-cli-framework",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "A framework for developing CLI applications which supports dynamic discovery and installation of new commands",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bun",
|
|
@@ -48,20 +48,20 @@
|
|
|
48
48
|
"build": "bun build index.ts cli-plugin.ts --outdir dist --target bun && tsc -p tsconfig.build.json"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@flowscripter/dynamic-plugin-framework": "1.
|
|
51
|
+
"@flowscripter/dynamic-plugin-framework": "1.10.0",
|
|
52
52
|
"emphasize": "^7.0.0",
|
|
53
53
|
"fastest-levenshtein": "^1.0.16",
|
|
54
54
|
"figlet": "^1.11.0",
|
|
55
55
|
"highlight.js": "^11.11.1",
|
|
56
|
-
"prettier": "^3.
|
|
56
|
+
"prettier": "^3.9.4",
|
|
57
57
|
"supports-color": "^10.2.2",
|
|
58
58
|
"supports-terminal-graphics": "^0.1.0"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@types/bun": "^1.3.14",
|
|
62
|
-
"@types/node": "^26.0
|
|
63
|
-
"oxfmt": "0.
|
|
64
|
-
"oxlint": "1.
|
|
62
|
+
"@types/node": "^26.1.0",
|
|
63
|
+
"oxfmt": "0.57.0",
|
|
64
|
+
"oxlint": "1.72.0"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
67
|
"typescript": "^6.0.3"
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Plugin, ExtensionDescriptor } from "@flowscripter/dynamic-plugin-framework";
|
|
2
|
+
import type CommandFactory from "./CommandFactory.ts";
|
|
3
|
+
import { DYNAMIC_CLI_FRAMEWORK_COMMAND_FACTORY_EXTENSION_POINT } from "./CommandFactory.ts";
|
|
4
|
+
import type ServiceProviderFactory from "./ServiceProviderFactory.ts";
|
|
5
|
+
import { DYNAMIC_CLI_FRAMEWORK_SERVICE_PROVIDER_FACTORY_EXTENSION_POINT } from "./ServiceProviderFactory.ts";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* {@link ExtensionDescriptor} for a {@link CommandFactory} extension.
|
|
9
|
+
*/
|
|
10
|
+
export interface CommandFactoryExtensionDescriptor extends ExtensionDescriptor {
|
|
11
|
+
readonly extensionPoint: typeof DYNAMIC_CLI_FRAMEWORK_COMMAND_FACTORY_EXTENSION_POINT;
|
|
12
|
+
readonly factory: {
|
|
13
|
+
create(hostData?: Map<string, string>): Promise<CommandFactory>;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* {@link ExtensionDescriptor} for a {@link ServiceProviderFactory} extension.
|
|
19
|
+
*/
|
|
20
|
+
export interface ServiceProviderFactoryExtensionDescriptor extends ExtensionDescriptor {
|
|
21
|
+
readonly extensionPoint: typeof DYNAMIC_CLI_FRAMEWORK_SERVICE_PROVIDER_FACTORY_EXTENSION_POINT;
|
|
22
|
+
readonly factory: {
|
|
23
|
+
create(hostData?: Map<string, string>): Promise<ServiceProviderFactory>;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* A {@link Plugin} for {@link DynamicPluginRuntimeCLI} whose {@link extensionDescriptors} are
|
|
29
|
+
* limited to the {@link CommandFactory} and {@link ServiceProviderFactory} extension points.
|
|
30
|
+
*/
|
|
31
|
+
export default interface CLIPlugin extends Plugin {
|
|
32
|
+
readonly extensionDescriptors: ReadonlyArray<
|
|
33
|
+
CommandFactoryExtensionDescriptor | ServiceProviderFactoryExtensionDescriptor
|
|
34
|
+
>;
|
|
35
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type CommandFactory from "./CommandFactory.ts";
|
|
2
|
+
import { DYNAMIC_CLI_FRAMEWORK_COMMAND_FACTORY_EXTENSION_POINT } from "./CommandFactory.ts";
|
|
3
|
+
import type ServiceProviderFactory from "./ServiceProviderFactory.ts";
|
|
4
|
+
import { DYNAMIC_CLI_FRAMEWORK_SERVICE_PROVIDER_FACTORY_EXTENSION_POINT } from "./ServiceProviderFactory.ts";
|
|
5
|
+
import type CLIPlugin from "./CLIPlugin.ts";
|
|
6
|
+
|
|
7
|
+
export interface CLIPluginOptions {
|
|
8
|
+
readonly commandFactory?: CommandFactory | (() => Promise<CommandFactory>);
|
|
9
|
+
readonly serviceProviderFactory?:
|
|
10
|
+
| ServiceProviderFactory
|
|
11
|
+
| (() => Promise<ServiceProviderFactory>);
|
|
12
|
+
readonly pluginData?: ReadonlyMap<string, string>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Build a {@link CLIPlugin} from optional {@link CommandFactory} and {@link ServiceProviderFactory}
|
|
17
|
+
* instances (or factory functions), without needing to hand-construct extension descriptors.
|
|
18
|
+
*/
|
|
19
|
+
export default function createCLIPlugin(options: CLIPluginOptions): CLIPlugin {
|
|
20
|
+
const extensionDescriptors: CLIPlugin["extensionDescriptors"][number][] = [];
|
|
21
|
+
|
|
22
|
+
if (options.commandFactory) {
|
|
23
|
+
const commandFactory = options.commandFactory;
|
|
24
|
+
extensionDescriptors.push({
|
|
25
|
+
extensionPoint: DYNAMIC_CLI_FRAMEWORK_COMMAND_FACTORY_EXTENSION_POINT,
|
|
26
|
+
factory: {
|
|
27
|
+
create: async () =>
|
|
28
|
+
typeof commandFactory === "function" ? commandFactory() : commandFactory,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (options.serviceProviderFactory) {
|
|
34
|
+
const serviceProviderFactory = options.serviceProviderFactory;
|
|
35
|
+
extensionDescriptors.push({
|
|
36
|
+
extensionPoint: DYNAMIC_CLI_FRAMEWORK_SERVICE_PROVIDER_FACTORY_EXTENSION_POINT,
|
|
37
|
+
factory: {
|
|
38
|
+
create: async () =>
|
|
39
|
+
typeof serviceProviderFactory === "function"
|
|
40
|
+
? serviceProviderFactory()
|
|
41
|
+
: serviceProviderFactory,
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return { extensionDescriptors, pluginData: options.pluginData };
|
|
47
|
+
}
|
|
@@ -22,7 +22,7 @@ export default interface CompletionService {
|
|
|
22
22
|
cursorPosition: number,
|
|
23
23
|
): Promise<ReadonlyArray<CompletionItem>>;
|
|
24
24
|
|
|
25
|
-
getBootstrapScript(shellType: ShellType, cliName: string): string;
|
|
25
|
+
getBootstrapScript(shellType: ShellType, cliName: string, executablePath: string): string;
|
|
26
26
|
|
|
27
27
|
getDefaultConfigPath(shellType: ShellType): string;
|
|
28
28
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import process from "node:process";
|
|
1
2
|
import type GroupCommand from "../api/command/GroupCommand.ts";
|
|
2
3
|
import type SubCommand from "../api/command/SubCommand.ts";
|
|
3
4
|
import type Option from "../api/argument/Option.ts";
|
|
@@ -51,7 +52,11 @@ export class CompletionIntegrationSubCommand implements SubCommand {
|
|
|
51
52
|
|
|
52
53
|
const configPath = configPathArg || completionService.getDefaultConfigPath(shellType);
|
|
53
54
|
const cliName = context.cliConfig.name;
|
|
54
|
-
const bootstrapScript = completionService.getBootstrapScript(
|
|
55
|
+
const bootstrapScript = completionService.getBootstrapScript(
|
|
56
|
+
shellType,
|
|
57
|
+
cliName,
|
|
58
|
+
process.execPath,
|
|
59
|
+
);
|
|
55
60
|
|
|
56
61
|
const beginMarker = `# BEGIN ${cliName} completion`;
|
|
57
62
|
const endMarker = `# END ${cliName} completion`;
|
|
@@ -98,17 +98,30 @@ export class PluginAddSubCommand implements SubCommand {
|
|
|
98
98
|
break;
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
|
+
|
|
101
102
|
if (!descriptor) {
|
|
102
|
-
|
|
103
|
-
|
|
103
|
+
// Search did not find an exact match - attempt direct install by plugin ID.
|
|
104
|
+
// This handles cases where the package exists on the registry but is not
|
|
105
|
+
// returned by search (e.g. recently published or low search ranking).
|
|
106
|
+
await printerService.info(
|
|
107
|
+
`Plugin not found via search, attempting direct install of ${pluginId}...`,
|
|
108
|
+
Icon.INFORMATION,
|
|
109
|
+
);
|
|
110
|
+
const parts = pluginId.startsWith("@") ? pluginId.slice(1).split("/") : [undefined, pluginId];
|
|
111
|
+
const scope = pluginId.startsWith("@") ? `@${parts[0]}` : undefined;
|
|
112
|
+
const name = pluginId.startsWith("@") ? parts[1]! : pluginId;
|
|
113
|
+
descriptor = {
|
|
114
|
+
pluginId,
|
|
115
|
+
scope,
|
|
116
|
+
name,
|
|
117
|
+
version: "latest",
|
|
118
|
+
extensionPoints: [],
|
|
119
|
+
};
|
|
104
120
|
}
|
|
105
121
|
|
|
106
|
-
await printerService.info(
|
|
107
|
-
`Installing ${getPluginId(descriptor)}@${descriptor.version}...`,
|
|
108
|
-
Icon.INFORMATION,
|
|
109
|
-
);
|
|
122
|
+
await printerService.info(`Installing ${descriptor.pluginId}...`, Icon.INFORMATION);
|
|
110
123
|
await pluginService.install(descriptor);
|
|
111
|
-
await printerService.print(`Plugin ${
|
|
124
|
+
await printerService.print(`Plugin ${descriptor.pluginId} installed.\n`, Icon.SUCCESS);
|
|
112
125
|
}
|
|
113
126
|
}
|
|
114
127
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import process from "node:process";
|
|
1
2
|
import type { ServiceProvider } from "../../api/service/ServiceProvider.ts";
|
|
2
3
|
import type { ServiceInfo } from "../../api/service/ServiceProvider.ts";
|
|
3
4
|
import type CLIConfig from "../../api/CLIConfig.ts";
|
|
@@ -141,7 +142,11 @@ export default class CompletionServiceProvider implements ServiceProvider {
|
|
|
141
142
|
|
|
142
143
|
async #installCompletion(context: Context, shellType: ShellType): Promise<void> {
|
|
143
144
|
const configPath = this.#completionService.getDefaultConfigPath(shellType);
|
|
144
|
-
const bootstrapScript = this.#completionService.getBootstrapScript(
|
|
145
|
+
const bootstrapScript = this.#completionService.getBootstrapScript(
|
|
146
|
+
shellType,
|
|
147
|
+
this.#cliName,
|
|
148
|
+
process.execPath,
|
|
149
|
+
);
|
|
145
150
|
const beginMarker = `# BEGIN ${this.#cliName} completion`;
|
|
146
151
|
const endMarker = `# END ${this.#cliName} completion`;
|
|
147
152
|
const block = `${beginMarker}\n${bootstrapScript}\n${endMarker}`;
|
|
@@ -23,8 +23,8 @@ export default class DefaultCompletionService implements CompletionService {
|
|
|
23
23
|
this.#commandRegistry = registry;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
getBootstrapScript(shellType: ShellType, cliName: string): string {
|
|
27
|
-
return this.#getHandler(shellType).getBootstrapScript(cliName);
|
|
26
|
+
getBootstrapScript(shellType: ShellType, cliName: string, executablePath: string): string {
|
|
27
|
+
return this.#getHandler(shellType).getBootstrapScript(cliName, executablePath);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
getDefaultConfigPath(shellType: ShellType): string {
|
|
@@ -7,7 +7,7 @@ export interface CompletionContext {
|
|
|
7
7
|
|
|
8
8
|
export default interface ShellHandler {
|
|
9
9
|
getDefaultConfigPath(): string;
|
|
10
|
-
getBootstrapScript(cliName: string): string;
|
|
10
|
+
getBootstrapScript(cliName: string, executablePath: string): string;
|
|
11
11
|
validateEnvironment(): Promise<boolean>;
|
|
12
12
|
formatCompletions(completions: ReadonlyArray<CompletionItem>): string;
|
|
13
13
|
parseCompletionContext(args: ReadonlyArray<string>): CompletionContext;
|
|
@@ -12,11 +12,11 @@ export default class BashShellHandler implements ShellHandler {
|
|
|
12
12
|
return join(homedir(), ".bashrc");
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
getBootstrapScript(cliName: string): string {
|
|
15
|
+
getBootstrapScript(cliName: string, executablePath: string): string {
|
|
16
16
|
return [
|
|
17
17
|
`_${cliName}_completions() {`,
|
|
18
18
|
` local IFS=$'\\n'`,
|
|
19
|
-
` COMPREPLY=( $(${
|
|
19
|
+
` COMPREPLY=( $("${executablePath}" completions:complete bash "\${COMP_LINE}" "\${COMP_POINT}") )`,
|
|
20
20
|
`}`,
|
|
21
21
|
`complete -F _${cliName}_completions ${cliName}`,
|
|
22
22
|
].join("\n");
|
|
@@ -12,8 +12,8 @@ export default class FishShellHandler implements ShellHandler {
|
|
|
12
12
|
return join(homedir(), ".config", "fish", "config.fish");
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
getBootstrapScript(cliName: string): string {
|
|
16
|
-
return `complete -c ${cliName} -f -a '(${
|
|
15
|
+
getBootstrapScript(cliName: string, executablePath: string): string {
|
|
16
|
+
return `complete -c ${cliName} -f -a '("${executablePath}" completions:complete fish (commandline -cp) (commandline -C))'`;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
validateEnvironment(): Promise<boolean> {
|
|
@@ -15,11 +15,11 @@ export default class PowerShellShellHandler implements ShellHandler {
|
|
|
15
15
|
return join(homedir(), ".config", "powershell", "Microsoft.PowerShell_profile.ps1");
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
getBootstrapScript(cliName: string): string {
|
|
18
|
+
getBootstrapScript(cliName: string, executablePath: string): string {
|
|
19
19
|
return [
|
|
20
20
|
`Register-ArgumentCompleter -Native -CommandName ${cliName} -ScriptBlock {`,
|
|
21
21
|
` param($wordToComplete, $commandAst, $cursorPosition)`,
|
|
22
|
-
` $completions = & ${
|
|
22
|
+
` $completions = & "${executablePath}" completions:complete powershell "$commandAst" "$cursorPosition"`,
|
|
23
23
|
` $completions -split '\\n' | ForEach-Object {`,
|
|
24
24
|
` [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)`,
|
|
25
25
|
` }`,
|
|
@@ -37,7 +37,9 @@ export default class PowerShellShellHandler implements ShellHandler {
|
|
|
37
37
|
// try powershell fallback
|
|
38
38
|
}
|
|
39
39
|
try {
|
|
40
|
-
const result = Bun.spawnSync(["powershell", "-Command", "echo ok"], {
|
|
40
|
+
const result = Bun.spawnSync(["powershell", "-Command", "echo ok"], {
|
|
41
|
+
timeout: 2000,
|
|
42
|
+
});
|
|
41
43
|
return Promise.resolve(result.exitCode === 0);
|
|
42
44
|
} catch {
|
|
43
45
|
return Promise.resolve(false);
|
|
@@ -12,11 +12,11 @@ export default class ZshShellHandler implements ShellHandler {
|
|
|
12
12
|
return join(homedir(), ".zshrc");
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
getBootstrapScript(cliName: string): string {
|
|
15
|
+
getBootstrapScript(cliName: string, executablePath: string): string {
|
|
16
16
|
return [
|
|
17
17
|
`_${cliName}_completions() {`,
|
|
18
18
|
` local -a completions`,
|
|
19
|
-
` completions=("\${(@f)$(${
|
|
19
|
+
` completions=("\${(@f)$("${executablePath}" completions:complete zsh "\${words}" "\${CURSOR}")}")`,
|
|
20
20
|
` _describe '${cliName}' completions`,
|
|
21
21
|
`}`,
|
|
22
22
|
`compdef _${cliName}_completions ${cliName}`,
|