@flowscripter/dynamic-cli-framework 1.6.2 → 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 +12 -1
- package/dist/cli-plugin.d.ts +4 -1
- package/dist/cli-plugin.d.ts.map +1 -1
- package/dist/cli-plugin.js +24 -0
- 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/package.json +2 -2
- package/src/api/plugin/CLIPlugin.ts +35 -0
- package/src/api/plugin/createCLIPlugin.ts +47 -0
package/cli-plugin.ts
CHANGED
|
@@ -13,7 +13,18 @@ export type { ArgumentValues } from "./src/api/argument/ArgumentValueTypes.ts";
|
|
|
13
13
|
export { ArgumentValueTypeName } from "./src/api/argument/ArgumentValueTypes.ts";
|
|
14
14
|
export type { default as Option } from "./src/api/argument/Option.ts";
|
|
15
15
|
export type { default as Positional } from "./src/api/argument/Positional.ts";
|
|
16
|
-
export type {
|
|
16
|
+
export type {
|
|
17
|
+
Plugin,
|
|
18
|
+
ExtensionDescriptor,
|
|
19
|
+
ExtensionFactory,
|
|
20
|
+
} from "@flowscripter/dynamic-plugin-framework";
|
|
21
|
+
export type {
|
|
22
|
+
default as CLIPlugin,
|
|
23
|
+
CommandFactoryExtensionDescriptor,
|
|
24
|
+
ServiceProviderFactoryExtensionDescriptor,
|
|
25
|
+
} from "./src/api/plugin/CLIPlugin.ts";
|
|
26
|
+
export { default as createCLIPlugin } from "./src/api/plugin/createCLIPlugin.ts";
|
|
27
|
+
export type { CLIPluginOptions } from "./src/api/plugin/createCLIPlugin.ts";
|
|
17
28
|
|
|
18
29
|
// Core Service IDs and types
|
|
19
30
|
export { ASCII_BANNER_GENERATOR_SERVICE_ID } from "./src/api/service/core/AsciiBannerGeneratorService.ts";
|
package/dist/cli-plugin.d.ts
CHANGED
|
@@ -13,7 +13,10 @@ export type { ArgumentValues } from "./src/api/argument/ArgumentValueTypes.ts";
|
|
|
13
13
|
export { ArgumentValueTypeName } from "./src/api/argument/ArgumentValueTypes.ts";
|
|
14
14
|
export type { default as Option } from "./src/api/argument/Option.ts";
|
|
15
15
|
export type { default as Positional } from "./src/api/argument/Positional.ts";
|
|
16
|
-
export type { ExtensionDescriptor, ExtensionFactory } from "@flowscripter/dynamic-plugin-framework";
|
|
16
|
+
export type { Plugin, ExtensionDescriptor, ExtensionFactory, } from "@flowscripter/dynamic-plugin-framework";
|
|
17
|
+
export type { default as CLIPlugin, CommandFactoryExtensionDescriptor, ServiceProviderFactoryExtensionDescriptor, } from "./src/api/plugin/CLIPlugin.ts";
|
|
18
|
+
export { default as createCLIPlugin } from "./src/api/plugin/createCLIPlugin.ts";
|
|
19
|
+
export type { CLIPluginOptions } from "./src/api/plugin/createCLIPlugin.ts";
|
|
17
20
|
export { ASCII_BANNER_GENERATOR_SERVICE_ID } from "./src/api/service/core/AsciiBannerGeneratorService.ts";
|
|
18
21
|
export type { default as AsciiBannerGeneratorService } from "./src/api/service/core/AsciiBannerGeneratorService.ts";
|
|
19
22
|
export type { BannerColorEffects, BannerGenerateOptions, ColorEffect, ColorEffectDirection, FixedColorEffect, GradientColorEffect, RainbowColorEffect, } from "./src/api/service/core/AsciiBannerGeneratorService.ts";
|
package/dist/cli-plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-plugin.d.ts","sourceRoot":"","sources":["../cli-plugin.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpF,OAAO,EAAE,qDAAqD,EAAE,MAAM,oCAAoC,CAAC;AAC3G,YAAY,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AACpG,OAAO,EAAE,8DAA8D,EAAE,MAAM,4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E,MAAM,oDAAoD,CAAC;AACpG,YAAY,EAAE,OAAO,IAAI,wBAAwB,EAAE,MAAM,oDAAoD,CAAC;AAC9G,OAAO,EACL,KAAK,cAAc,EACnB,UAAU,EACV,KAAK,sBAAsB,GAC5B,MAAM,oDAAoD,CAAC;AAE5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AACpF,YAAY,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,6CAA6C,CAAC;AAChG,OAAO,EAAE,KAAK,cAAc,EAAE,SAAS,EAAE,MAAM,6CAA6C,CAAC;AAE7F,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,YAAY,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,2CAA2C,CAAC;AAC5F,OAAO,EACL,KAAK,MAAM,EACX,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,UAAU,GACX,MAAM,2CAA2C,CAAC;AAEnD,OAAO,EAAE,4BAA4B,EAAE,MAAM,mDAAmD,CAAC;AACjG,YAAY,EAAE,OAAO,IAAI,uBAAuB,EAAE,MAAM,mDAAmD,CAAC;AAE5G,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAC5E,YAAY,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,yCAAyC,CAAC"}
|
package/dist/cli-plugin.js
CHANGED
|
@@ -62,6 +62,29 @@ var ComplexValueTypeName;
|
|
|
62
62
|
((ComplexValueTypeName2) => {
|
|
63
63
|
ComplexValueTypeName2[ComplexValueTypeName2["COMPLEX"] = 5] = "COMPLEX";
|
|
64
64
|
})(ComplexValueTypeName ||= {});
|
|
65
|
+
// src/api/plugin/createCLIPlugin.ts
|
|
66
|
+
function createCLIPlugin(options) {
|
|
67
|
+
const extensionDescriptors = [];
|
|
68
|
+
if (options.commandFactory) {
|
|
69
|
+
const commandFactory = options.commandFactory;
|
|
70
|
+
extensionDescriptors.push({
|
|
71
|
+
extensionPoint: DYNAMIC_CLI_FRAMEWORK_COMMAND_FACTORY_EXTENSION_POINT,
|
|
72
|
+
factory: {
|
|
73
|
+
create: async () => typeof commandFactory === "function" ? commandFactory() : commandFactory
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
if (options.serviceProviderFactory) {
|
|
78
|
+
const serviceProviderFactory = options.serviceProviderFactory;
|
|
79
|
+
extensionDescriptors.push({
|
|
80
|
+
extensionPoint: DYNAMIC_CLI_FRAMEWORK_SERVICE_PROVIDER_FACTORY_EXTENSION_POINT,
|
|
81
|
+
factory: {
|
|
82
|
+
create: async () => typeof serviceProviderFactory === "function" ? serviceProviderFactory() : serviceProviderFactory
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
return { extensionDescriptors, pluginData: options.pluginData };
|
|
87
|
+
}
|
|
65
88
|
// src/api/service/core/AsciiBannerGeneratorService.ts
|
|
66
89
|
var ASCII_BANNER_GENERATOR_SERVICE_ID = "@flowscripter/dynamic-cli-framework/ascii-banner-generator-service";
|
|
67
90
|
// src/api/service/core/KeyValueService.ts
|
|
@@ -193,6 +216,7 @@ var ARGUMENT_PROMPTER_SERVICE_ID = "@flowscripter/dynamic-cli-framework/argument
|
|
|
193
216
|
// src/api/service/core/PluginService.ts
|
|
194
217
|
var PLUGIN_SERVICE_ID = "PLUGIN_SERVICE";
|
|
195
218
|
export {
|
|
219
|
+
createCLIPlugin,
|
|
196
220
|
Table,
|
|
197
221
|
TREE_PRINTER_SERVICE_ID,
|
|
198
222
|
TABLE_GENERATOR_SERVICE_ID,
|
|
@@ -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"}
|
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,7 +48,7 @@
|
|
|
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",
|
|
@@ -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
|
+
}
|