@flowscripter/dynamic-cli-framework 3.0.1 → 4.0.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.
Files changed (51) hide show
  1. package/dist/index.d.ts +2 -3
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +2 -3
  4. package/dist/src/cli/BaseCLI.d.ts +1 -0
  5. package/dist/src/cli/BaseCLI.d.ts.map +1 -1
  6. package/dist/src/cli/BaseCLI.js +8 -0
  7. package/dist/src/cli/BaseCLIFeatureOptions.d.ts +4 -0
  8. package/dist/src/cli/BaseCLIFeatureOptions.d.ts.map +1 -1
  9. package/dist/src/launcher.d.ts +0 -2
  10. package/dist/src/launcher.d.ts.map +1 -1
  11. package/dist/src/launcher.js +0 -20
  12. package/dist/src/service/completion/CompletionServiceProvider.js +4 -4
  13. package/dist/src/service/configuration/ConfigurationServiceProvider.d.ts +19 -8
  14. package/dist/src/service/configuration/ConfigurationServiceProvider.d.ts.map +1 -1
  15. package/dist/src/service/configuration/ConfigurationServiceProvider.js +26 -33
  16. package/dist/src/service/configuration/DefaultKeyValueService.d.ts +6 -6
  17. package/dist/src/service/configuration/DefaultKeyValueService.d.ts.map +1 -1
  18. package/dist/src/service/configuration/DefaultKeyValueService.js +60 -19
  19. package/dist/src/service/configuration/resolveSecrets.d.ts +11 -0
  20. package/dist/src/service/configuration/resolveSecrets.d.ts.map +1 -0
  21. package/dist/src/service/configuration/resolveSecrets.js +31 -0
  22. package/dist/src/service/plugin/DefaultPluginService.d.ts +5 -2
  23. package/dist/src/service/plugin/DefaultPluginService.d.ts.map +1 -1
  24. package/dist/src/service/plugin/DefaultPluginService.js +21 -2
  25. package/dist/src/service/plugin/PluginServiceProvider.d.ts +17 -0
  26. package/dist/src/service/plugin/PluginServiceProvider.d.ts.map +1 -0
  27. package/dist/src/service/plugin/PluginServiceProvider.js +95 -0
  28. package/dist/src/service/upgrade/DefaultUpgradeService.d.ts.map +1 -1
  29. package/dist/src/service/upgrade/DefaultUpgradeService.js +12 -10
  30. package/dist/src/service/upgrade/UpgradeServiceProvider.js +4 -4
  31. package/index.ts +2 -7
  32. package/package.json +3 -3
  33. package/src/cli/BaseCLI.ts +17 -0
  34. package/src/cli/BaseCLIFeatureOptions.ts +7 -0
  35. package/src/launcher.ts +0 -35
  36. package/src/service/completion/CompletionServiceProvider.ts +4 -4
  37. package/src/service/configuration/ConfigurationServiceProvider.ts +36 -40
  38. package/src/service/configuration/DefaultKeyValueService.ts +76 -22
  39. package/src/service/configuration/resolveSecrets.ts +35 -0
  40. package/src/service/plugin/DefaultPluginService.ts +41 -3
  41. package/src/service/plugin/PluginServiceProvider.ts +142 -0
  42. package/src/service/upgrade/DefaultUpgradeService.ts +10 -10
  43. package/src/service/upgrade/UpgradeServiceProvider.ts +4 -4
  44. package/dist/src/cli/DynamicPluginRuntimeCLI.d.ts +0 -20
  45. package/dist/src/cli/DynamicPluginRuntimeCLI.d.ts.map +0 -1
  46. package/dist/src/cli/DynamicPluginRuntimeCLI.js +0 -50
  47. package/dist/src/service/plugin/DefaultPluginServiceProvider.d.ts +0 -15
  48. package/dist/src/service/plugin/DefaultPluginServiceProvider.d.ts.map +0 -1
  49. package/dist/src/service/plugin/DefaultPluginServiceProvider.js +0 -56
  50. package/src/cli/DynamicPluginRuntimeCLI.ts +0 -77
  51. package/src/service/plugin/DefaultPluginServiceProvider.ts +0 -82
@@ -1,77 +0,0 @@
1
- import type { MarketplacePluginManager } from "@flowscripter/dynamic-plugin-framework";
2
- import type { CLIConfig } from "@flowscripter/dynamic-cli-framework-api";
3
- import type BaseCLIFeatureOptions from "./BaseCLIFeatureOptions.ts";
4
- import type { RunResult } from "@flowscripter/dynamic-cli-framework-api";
5
- import { RunState } from "@flowscripter/dynamic-cli-framework-api";
6
- import DefaultRuntimeCLI from "./DefaultRuntimeCLI.ts";
7
- import DefaultPluginServiceProvider from "../service/plugin/DefaultPluginServiceProvider.ts";
8
- import { DYNAMIC_CLI_FRAMEWORK_COMMAND_FACTORY_EXTENSION_POINT } from "@flowscripter/dynamic-cli-framework-api";
9
- import { DYNAMIC_CLI_FRAMEWORK_SERVICE_PROVIDER_FACTORY_EXTENSION_POINT } from "@flowscripter/dynamic-cli-framework-api";
10
- import type { CommandFactory } from "@flowscripter/dynamic-cli-framework-api";
11
- import type { ServiceProviderFactory } from "@flowscripter/dynamic-cli-framework-api";
12
- import process from "node:process";
13
-
14
- /**
15
- * Extension of {@link DefaultRuntimeCLI} that discovers and loads installed plugins before running.
16
- *
17
- * On each invocation of {@link run}, all locally installed plugins are discovered via the
18
- * {@link MarketplacePluginManager}. Commands provided by {@link CommandFactory} extensions and
19
- * service providers provided by {@link ServiceProviderFactory} extensions are registered before
20
- * the runner starts, so they participate in the full initialization lifecycle.
21
- */
22
- export default class DynamicPluginRuntimeCLI extends DefaultRuntimeCLI {
23
- readonly #pluginManager: MarketplacePluginManager;
24
-
25
- constructor(
26
- cliConfig: CLIConfig,
27
- pluginManager: MarketplacePluginManager,
28
- options?: BaseCLIFeatureOptions,
29
- ) {
30
- super(cliConfig, options);
31
- this.#pluginManager = pluginManager;
32
- this.addServiceProvider(new DefaultPluginServiceProvider(pluginManager));
33
- }
34
-
35
- override async run(): Promise<RunResult> {
36
- try {
37
- await this.loadPlugins();
38
- } catch (err) {
39
- console.error(err);
40
- process.exit(RunState.RUNTIME_ERROR);
41
- }
42
- return super.run();
43
- }
44
-
45
- async loadPlugins(): Promise<void> {
46
- await this.#pluginManager.registerExtensions(
47
- DYNAMIC_CLI_FRAMEWORK_COMMAND_FACTORY_EXTENSION_POINT,
48
- );
49
- await this.#pluginManager.registerExtensions(
50
- DYNAMIC_CLI_FRAMEWORK_SERVICE_PROVIDER_FACTORY_EXTENSION_POINT,
51
- );
52
-
53
- const commandFactoryExtensions = await this.#pluginManager.getRegisteredExtensions(
54
- DYNAMIC_CLI_FRAMEWORK_COMMAND_FACTORY_EXTENSION_POINT,
55
- );
56
- for (const ext of commandFactoryExtensions) {
57
- const factory = (await this.#pluginManager.instantiate(
58
- ext.extensionHandle,
59
- )) as CommandFactory;
60
- for (const command of factory.getCommands()) {
61
- this.addCommand(command);
62
- }
63
- }
64
-
65
- const spFactoryExtensions = await this.#pluginManager.getRegisteredExtensions(
66
- DYNAMIC_CLI_FRAMEWORK_SERVICE_PROVIDER_FACTORY_EXTENSION_POINT,
67
- );
68
- for (const ext of spFactoryExtensions) {
69
- const factory = (await this.#pluginManager.instantiate(
70
- ext.extensionHandle,
71
- )) as ServiceProviderFactory;
72
- for (const sp of factory.getServiceProviders()) {
73
- this.addServiceProvider(sp);
74
- }
75
- }
76
- }
77
- }
@@ -1,82 +0,0 @@
1
- import type { ServiceInfo, ServiceProvider } from "@flowscripter/dynamic-cli-framework-api";
2
- import type { Context } from "@flowscripter/dynamic-cli-framework-api";
3
- import type { CLIConfig } from "@flowscripter/dynamic-cli-framework-api";
4
- import type { PrinterService, SpawnService } from "@flowscripter/dynamic-cli-framework-api";
5
- import { PRINTER_SERVICE_ID, SPAWN_SERVICE_ID } from "@flowscripter/dynamic-cli-framework-api";
6
- import type { FetchService } from "@flowscripter/dynamic-cli-framework-api";
7
- import { FETCH_SERVICE_ID } from "@flowscripter/dynamic-cli-framework-api";
8
- import type {
9
- FetchCapable,
10
- MarketplacePluginManager,
11
- SpawnCapable,
12
- } from "@flowscripter/dynamic-plugin-framework";
13
- import { PLUGIN_SERVICE_ID } from "@flowscripter/dynamic-cli-framework-api";
14
- import DefaultPluginService from "./DefaultPluginService.ts";
15
- import { PluginGroupCommand } from "./command/PluginGroupCommand.ts";
16
- import SpawnInterfaceAdapter, {
17
- type SpawnInterfaceAdapterOptions,
18
- } from "./SpawnInterfaceAdapter.ts";
19
- import FetchInterfaceAdapter, {
20
- type FetchInterfaceAdapterOptions,
21
- } from "./FetchInterfaceAdapter.ts";
22
- import getLogger from "../../util/logger.ts";
23
-
24
- const logger = getLogger("DefaultPluginServiceProvider");
25
-
26
- export default class DefaultPluginServiceProvider implements ServiceProvider {
27
- readonly serviceId = PLUGIN_SERVICE_ID;
28
- readonly servicePriority: number;
29
- readonly #pluginManager: MarketplacePluginManager;
30
- readonly #spawnInterfaceAdapterOptions: SpawnInterfaceAdapterOptions;
31
- readonly #fetchInterfaceAdapterOptions: FetchInterfaceAdapterOptions;
32
- #pluginService: DefaultPluginService | undefined;
33
-
34
- constructor(
35
- pluginManager: MarketplacePluginManager,
36
- servicePriority = 50,
37
- spawnInterfaceAdapterOptions: SpawnInterfaceAdapterOptions = {},
38
- fetchInterfaceAdapterOptions: FetchInterfaceAdapterOptions = {},
39
- ) {
40
- this.#pluginManager = pluginManager;
41
- this.servicePriority = servicePriority;
42
- this.#spawnInterfaceAdapterOptions = spawnInterfaceAdapterOptions;
43
- this.#fetchInterfaceAdapterOptions = fetchInterfaceAdapterOptions;
44
- }
45
-
46
- async getServiceInfo(_cliConfig: CLIConfig): Promise<ServiceInfo> {
47
- this.#pluginService = new DefaultPluginService(this.#pluginManager);
48
- return {
49
- service: this.#pluginService,
50
- commands: [new PluginGroupCommand()],
51
- };
52
- }
53
-
54
- initService(context: Context): Promise<void> {
55
- if (!context.doesServiceExist(SPAWN_SERVICE_ID)) {
56
- logger.debug("SpawnService not available, plugin manager will spawn processes directly");
57
- } else if (!("setSpawn" in this.#pluginManager)) {
58
- logger.debug("Plugin manager does not support SpawnCapable, skipping spawn injection");
59
- } else {
60
- const spawnService = context.getServiceById(SPAWN_SERVICE_ID) as SpawnService;
61
- const printerService = context.getServiceById(PRINTER_SERVICE_ID) as PrinterService;
62
- const adapter = new SpawnInterfaceAdapter(
63
- spawnService,
64
- printerService,
65
- this.#spawnInterfaceAdapterOptions,
66
- );
67
- (this.#pluginManager as unknown as SpawnCapable).setSpawn(adapter);
68
- }
69
-
70
- if (!context.doesServiceExist(FETCH_SERVICE_ID)) {
71
- logger.debug("FetchService not available, plugin manager will fetch directly");
72
- } else if (!("setFetch" in this.#pluginManager)) {
73
- logger.debug("Plugin manager does not support FetchCapable, skipping fetch injection");
74
- } else {
75
- const fetchService = context.getServiceById(FETCH_SERVICE_ID) as FetchService;
76
- const adapter = new FetchInterfaceAdapter(fetchService, this.#fetchInterfaceAdapterOptions);
77
- (this.#pluginManager as unknown as FetchCapable).setFetch(adapter);
78
- }
79
-
80
- return Promise.resolve();
81
- }
82
- }