@flowscripter/dynamic-cli-framework 6.0.1 → 7.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.
- package/README.md +2 -0
- package/dist/index.d.ts +10 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -2
- package/dist/src/cli/BaseCLI.d.ts +8 -0
- package/dist/src/cli/BaseCLI.d.ts.map +1 -1
- package/dist/src/cli/BaseCLI.js +37 -4
- package/dist/src/launcher.d.ts +3 -3
- package/dist/src/launcher.d.ts.map +1 -1
- package/dist/src/launcher.js +6 -4
- package/dist/src/runtime/lifecycle/PriorityTaskList.d.ts +22 -0
- package/dist/src/runtime/lifecycle/PriorityTaskList.d.ts.map +1 -0
- package/dist/src/runtime/lifecycle/PriorityTaskList.js +23 -0
- package/dist/src/runtime/runner.d.ts +15 -7
- package/dist/src/runtime/runner.d.ts.map +1 -1
- package/dist/src/runtime/runner.js +82 -53
- package/dist/src/service/configuration/ConfigurationServiceProvider.d.ts +26 -82
- package/dist/src/service/configuration/ConfigurationServiceProvider.d.ts.map +1 -1
- package/dist/src/service/configuration/ConfigurationServiceProvider.js +68 -163
- package/dist/src/service/configuration/DefaultKeyValueService.d.ts +6 -3
- package/dist/src/service/configuration/DefaultKeyValueService.d.ts.map +1 -1
- package/dist/src/service/configuration/DefaultKeyValueService.js +7 -24
- package/dist/src/service/configuration/DefaultSecretService.d.ts +1 -3
- package/dist/src/service/configuration/DefaultSecretService.d.ts.map +1 -1
- package/dist/src/service/configuration/DefaultSecretService.js +2 -10
- package/dist/src/service/configuration/KeyValueServiceProvider.d.ts +105 -0
- package/dist/src/service/configuration/KeyValueServiceProvider.d.ts.map +1 -0
- package/dist/src/service/configuration/KeyValueServiceProvider.js +201 -0
- package/dist/src/service/configuration/command/ConfigCommand.d.ts +4 -5
- package/dist/src/service/configuration/command/ConfigCommand.d.ts.map +1 -1
- package/dist/src/service/configuration/command/ConfigCommand.js +7 -6
- package/dist/src/service/configuration/command/DumpConfigCommand.d.ts +7 -3
- package/dist/src/service/configuration/command/DumpConfigCommand.d.ts.map +1 -1
- package/dist/src/service/configuration/command/DumpConfigCommand.js +10 -5
- package/dist/src/service/fetch/DefaultFetchService.d.ts +2 -2
- package/dist/src/service/fetch/DefaultFetchService.d.ts.map +1 -1
- package/dist/src/service/fetch/DefaultFetchService.js +17 -12
- package/dist/src/service/fetch/FetchServiceProvider.d.ts.map +1 -1
- package/dist/src/service/fetch/FetchServiceProvider.js +2 -3
- package/dist/src/service/printer/PrinterServiceProvider.d.ts.map +1 -1
- package/dist/src/service/printer/PrinterServiceProvider.js +11 -7
- package/dist/src/service/printer/command/DarkModeCommand.d.ts +3 -5
- package/dist/src/service/printer/command/DarkModeCommand.d.ts.map +1 -1
- package/dist/src/service/printer/command/DarkModeCommand.js +6 -6
- package/dist/src/service/printer/command/LogLevelCommand.d.ts +3 -5
- package/dist/src/service/printer/command/LogLevelCommand.d.ts.map +1 -1
- package/dist/src/service/printer/command/LogLevelCommand.js +9 -9
- package/dist/src/service/printer/command/NoColorCommand.d.ts +3 -5
- package/dist/src/service/printer/command/NoColorCommand.d.ts.map +1 -1
- package/dist/src/service/printer/command/NoColorCommand.js +6 -6
- package/dist/src/service/printer/command/NoHyperlinksCommand.d.ts +2 -4
- package/dist/src/service/printer/command/NoHyperlinksCommand.d.ts.map +1 -1
- package/dist/src/service/printer/command/NoHyperlinksCommand.js +5 -5
- package/dist/src/service/prompter/PrompterServiceProvider.js +1 -1
- package/dist/src/service/prompter/command/NoPromptCommand.d.ts +2 -4
- package/dist/src/service/prompter/command/NoPromptCommand.d.ts.map +1 -1
- package/dist/src/service/prompter/command/NoPromptCommand.js +5 -5
- package/dist/src/service/shutdown/DefaultShutdownService.d.ts +4 -3
- package/dist/src/service/shutdown/DefaultShutdownService.d.ts.map +1 -1
- package/dist/src/service/shutdown/DefaultShutdownService.js +4 -3
- package/dist/src/service/shutdown/ShutdownServiceProvider.js +2 -2
- package/dist/src/service/spawn/DefaultSpawnService.d.ts +2 -2
- package/dist/src/service/spawn/DefaultSpawnService.d.ts.map +1 -1
- package/dist/src/service/spawn/DefaultSpawnService.js +17 -14
- package/dist/src/service/spawn/SpawnServiceProvider.d.ts.map +1 -1
- package/dist/src/service/spawn/SpawnServiceProvider.js +1 -4
- package/dist/src/service/startup/DefaultStartupService.d.ts +10 -0
- package/dist/src/service/startup/DefaultStartupService.d.ts.map +1 -0
- package/dist/src/service/startup/DefaultStartupService.js +13 -0
- package/dist/src/service/startup/StartupServiceProvider.d.ts +17 -0
- package/dist/src/service/startup/StartupServiceProvider.d.ts.map +1 -0
- package/dist/src/service/startup/StartupServiceProvider.js +26 -0
- package/dist/src/service/upgrade/DefaultUpgradeService.d.ts +10 -4
- package/dist/src/service/upgrade/DefaultUpgradeService.d.ts.map +1 -1
- package/dist/src/service/upgrade/DefaultUpgradeService.js +156 -37
- package/dist/src/service/upgrade/UpgradeServiceProvider.d.ts +10 -0
- package/dist/src/service/upgrade/UpgradeServiceProvider.d.ts.map +1 -1
- package/dist/src/service/upgrade/UpgradeServiceProvider.js +25 -6
- package/dist/src/service/upgrade/command/UpgradeSubCommand.d.ts +0 -3
- package/dist/src/service/upgrade/command/UpgradeSubCommand.d.ts.map +1 -1
- package/dist/src/service/upgrade/command/UpgradeSubCommand.js +5 -13
- package/dist/src/startup/banner/bannerStartupTask.d.ts +17 -0
- package/dist/src/startup/banner/bannerStartupTask.d.ts.map +1 -0
- package/dist/src/startup/banner/bannerStartupTask.js +66 -0
- package/dist/src/{service → startup}/banner/command/NoBannerCommand.d.ts +8 -2
- package/dist/src/startup/banner/command/NoBannerCommand.d.ts.map +1 -0
- package/dist/src/{service → startup}/banner/command/NoBannerCommand.js +4 -4
- package/index.ts +19 -3
- package/package.json +2 -2
- package/src/cli/BaseCLI.ts +49 -3
- package/src/launcher.ts +7 -2
- package/src/runtime/lifecycle/PriorityTaskList.ts +34 -0
- package/src/runtime/runner.ts +106 -67
- package/src/service/configuration/ConfigurationServiceProvider.ts +80 -180
- package/src/service/configuration/DefaultKeyValueService.ts +8 -27
- package/src/service/configuration/DefaultSecretService.ts +3 -13
- package/src/service/configuration/KeyValueServiceProvider.ts +246 -0
- package/src/service/configuration/command/ConfigCommand.ts +12 -11
- package/src/service/configuration/command/DumpConfigCommand.ts +10 -9
- package/src/service/fetch/DefaultFetchService.ts +18 -12
- package/src/service/fetch/FetchServiceProvider.ts +2 -4
- package/src/service/printer/PrinterServiceProvider.ts +11 -7
- package/src/service/printer/command/DarkModeCommand.ts +7 -8
- package/src/service/printer/command/LogLevelCommand.ts +10 -11
- package/src/service/printer/command/NoColorCommand.ts +7 -8
- package/src/service/printer/command/NoHyperlinksCommand.ts +6 -7
- package/src/service/prompter/PrompterServiceProvider.ts +1 -1
- package/src/service/prompter/command/NoPromptCommand.ts +6 -7
- package/src/service/shutdown/DefaultShutdownService.ts +5 -4
- package/src/service/shutdown/ShutdownServiceProvider.ts +2 -2
- package/src/service/spawn/DefaultSpawnService.ts +18 -14
- package/src/service/spawn/SpawnServiceProvider.ts +1 -5
- package/src/service/startup/DefaultStartupService.ts +17 -0
- package/src/service/startup/StartupServiceProvider.ts +36 -0
- package/src/service/upgrade/DefaultUpgradeService.ts +202 -42
- package/src/service/upgrade/UpgradeServiceProvider.ts +31 -8
- package/src/service/upgrade/command/UpgradeSubCommand.ts +5 -15
- package/src/startup/banner/bannerStartupTask.ts +96 -0
- package/src/{service → startup}/banner/command/NoBannerCommand.ts +12 -5
- package/dist/src/service/banner/BannerServiceProvider.d.ts +0 -29
- package/dist/src/service/banner/BannerServiceProvider.d.ts.map +0 -1
- package/dist/src/service/banner/BannerServiceProvider.js +0 -69
- package/dist/src/service/banner/command/NoBannerCommand.d.ts.map +0 -1
- package/src/service/banner/BannerServiceProvider.ts +0 -89
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { KEY_VALUE_SERVICE_ID, SHUTDOWN_SERVICE_ID } from "@flowscripter/dynamic-cli-framework-api";
|
|
2
|
+
import DefaultKeyValueService from "./DefaultKeyValueService.js";
|
|
3
|
+
import DefaultSecretService from "./DefaultSecretService.js";
|
|
4
|
+
/**
|
|
5
|
+
* Registered under {@link KEY_VALUE_SERVICE_ID} in the plain, undecorated {@link Context} purely
|
|
6
|
+
* so {@link Context.doesServiceExist} reports correctly - every real access goes through a
|
|
7
|
+
* per-scope instance from {@link KeyValueServiceProvider.getScopedKeyValueService}, applied
|
|
8
|
+
* via a per-call decorated {@link Context} (see `runner.ts`). Reaching any of these methods
|
|
9
|
+
* directly means that decoration was somehow bypassed.
|
|
10
|
+
*/
|
|
11
|
+
class UnreachableKeyValueService {
|
|
12
|
+
get() {
|
|
13
|
+
return Promise.reject(new Error(UnreachableKeyValueService.#message));
|
|
14
|
+
}
|
|
15
|
+
has() {
|
|
16
|
+
return Promise.reject(new Error(UnreachableKeyValueService.#message));
|
|
17
|
+
}
|
|
18
|
+
set() {
|
|
19
|
+
return Promise.reject(new Error(UnreachableKeyValueService.#message));
|
|
20
|
+
}
|
|
21
|
+
delete() {
|
|
22
|
+
return Promise.reject(new Error(UnreachableKeyValueService.#message));
|
|
23
|
+
}
|
|
24
|
+
static #message = "KeyValueService accessed without a resolved scope - this should be unreachable";
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Provides a generic, per-scope key-value store for commands and services ({@link KeyValueService}).
|
|
28
|
+
*
|
|
29
|
+
* The underlying data is read from/written to the same configuration file managed by
|
|
30
|
+
* {@link ConfigurationServiceProvider} - see {@link ConfigurationServiceProvider.getKeyValueData} and
|
|
31
|
+
* {@link ConfigurationServiceProvider.flushIfDirty}, reached via a direct constructor reference wired
|
|
32
|
+
* up by `BaseCLI` (never via {@link Context}, since that would expose config-file read/write access
|
|
33
|
+
* more broadly than intended).
|
|
34
|
+
*
|
|
35
|
+
* Its `serviceId` is {@link KEY_VALUE_SERVICE_ID} and its {@link ServiceInfo.service} is a
|
|
36
|
+
* placeholder ({@link UnreachableKeyValueService}) - real access always goes through a per-consumer
|
|
37
|
+
* decorated {@link Context} from {@link getContextForScope}, applied by `runner.ts`.
|
|
38
|
+
*
|
|
39
|
+
* Any node within a value passed to {@link KeyValueService.set} can be wrapped in {@link Secret} -
|
|
40
|
+
* at any depth - to have that node, and only that node, stored as an OS-native secret. When a node
|
|
41
|
+
* is wrapped in {@link Secret}, its value (of any shape) is JSON-serialized and stored as a single
|
|
42
|
+
* OS-native secret via Bun.secrets, with a sentinel value of the format `__SECRET__:<bun_secret_name>`
|
|
43
|
+
* substituted in its place in the structure that gets stored in the config file. Everything else in
|
|
44
|
+
* the value is stored as plain (unencrypted) config data. The sentinel prefix `__SECRET__:` is
|
|
45
|
+
* reserved and must not be used for regular key-value data.
|
|
46
|
+
*
|
|
47
|
+
* Independently of how a value was written, {@link KeyValueService.get} recursively resolves any
|
|
48
|
+
* string leaf - at any depth within the retrieved value - which starts with the sentinel prefix,
|
|
49
|
+
* via the OS secret store. This means a secret reference may also be hand-embedded (nested
|
|
50
|
+
* arbitrarily deep) directly within a plain, non-secret value in the config file.
|
|
51
|
+
*
|
|
52
|
+
* Secret support requires `secretServiceEnabled=true` in the constructor (which also requires
|
|
53
|
+
* `keyValueServiceEnabled=true` on the {@link ConfigurationServiceProvider} to have config enabled).
|
|
54
|
+
*
|
|
55
|
+
* As an example of the underlying config file structure:
|
|
56
|
+
* ```
|
|
57
|
+
* {
|
|
58
|
+
* "defaults": {
|
|
59
|
+
* ...
|
|
60
|
+
* },
|
|
61
|
+
* "key-values": {
|
|
62
|
+
* "commands": {
|
|
63
|
+
* "command1": {
|
|
64
|
+
* "foo1": "bar1",
|
|
65
|
+
* "foo2": "__SECRET__:command_command1_foo2",
|
|
66
|
+
* "foo3": {
|
|
67
|
+
* "nested": ["a", "__SECRET__:command_command1_foo3_nested"]
|
|
68
|
+
* }
|
|
69
|
+
* },
|
|
70
|
+
* "command2": {
|
|
71
|
+
* "foo1": "bar3"
|
|
72
|
+
* }
|
|
73
|
+
* },
|
|
74
|
+
* "services": {
|
|
75
|
+
* "service-id-1": {
|
|
76
|
+
* "foo1": "bar"
|
|
77
|
+
* }
|
|
78
|
+
* }
|
|
79
|
+
* }
|
|
80
|
+
* }
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
export default class KeyValueServiceProvider {
|
|
84
|
+
serviceId = KEY_VALUE_SERVICE_ID;
|
|
85
|
+
servicePriority;
|
|
86
|
+
#configurationServiceProvider;
|
|
87
|
+
keyValueServiceEnabled;
|
|
88
|
+
secretServiceEnabled;
|
|
89
|
+
// per-scope KeyValueService instances, created on first request and cached thereafter - each is
|
|
90
|
+
// bound permanently to one scope's Map (and one scope-prefixed DefaultSecretService), never
|
|
91
|
+
// re-pointed. See getScopedKeyValueService().
|
|
92
|
+
#commandScopedKeyValueServices = new Map();
|
|
93
|
+
#serviceScopedKeyValueServices = new Map();
|
|
94
|
+
// used to construct scoped DefaultSecretService instances on demand.
|
|
95
|
+
#cliConfigName;
|
|
96
|
+
/**
|
|
97
|
+
* Create an instance of the service provider with the specified details.
|
|
98
|
+
*
|
|
99
|
+
* @param servicePriority the priority of the service.
|
|
100
|
+
* @param configurationServiceProvider the {@link ConfigurationServiceProvider} whose config file
|
|
101
|
+
* backs this provider's data - an internal wiring reference, never exposed further.
|
|
102
|
+
* @param keyValueServiceEnabled optionally provide a {@link KeyValueService} implementation: `configurationServiceProvider.configEnabled` must be true in this case
|
|
103
|
+
* @param secretServiceEnabled optionally enable OS-native secret storage via Bun.secrets: `configurationServiceProvider.configEnabled` must be true in this case
|
|
104
|
+
*/
|
|
105
|
+
constructor(servicePriority, configurationServiceProvider, keyValueServiceEnabled = false, secretServiceEnabled = false) {
|
|
106
|
+
if (!configurationServiceProvider.configEnabled && keyValueServiceEnabled) {
|
|
107
|
+
throw new Error("configEnabled must be true if keyValueServiceEnabled is true");
|
|
108
|
+
}
|
|
109
|
+
if (!configurationServiceProvider.configEnabled && secretServiceEnabled) {
|
|
110
|
+
throw new Error("configEnabled must be true if secretServiceEnabled is true");
|
|
111
|
+
}
|
|
112
|
+
this.servicePriority = servicePriority;
|
|
113
|
+
this.#configurationServiceProvider = configurationServiceProvider;
|
|
114
|
+
this.keyValueServiceEnabled = keyValueServiceEnabled;
|
|
115
|
+
this.secretServiceEnabled = secretServiceEnabled;
|
|
116
|
+
}
|
|
117
|
+
getServiceInfo(cliConfig) {
|
|
118
|
+
this.#cliConfigName = cliConfig.name;
|
|
119
|
+
return Promise.resolve({
|
|
120
|
+
// this is a placeholder - see UnreachableKeyValueService - unless neither is enabled
|
|
121
|
+
service: this.keyValueServiceEnabled || this.secretServiceEnabled
|
|
122
|
+
? new UnreachableKeyValueService()
|
|
123
|
+
: undefined,
|
|
124
|
+
commands: [],
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Return the {@link KeyValueService} bound to the given scope, creating (and caching) it on
|
|
129
|
+
* first request. The returned instance is permanently bound to that scope's data and secret
|
|
130
|
+
* prefix - it is never re-pointed, so it may be held and used for as long as its owning
|
|
131
|
+
* command/service/task is alive without racing any other scope's window.
|
|
132
|
+
*
|
|
133
|
+
* @param scopeType whether `scopeKey` is a command name or a service/task ID.
|
|
134
|
+
* @param scopeKey the command name or service/task ID to scope the key-value data to.
|
|
135
|
+
*
|
|
136
|
+
* @throws {Error} if neither `keyValueServiceEnabled` nor `secretServiceEnabled` is set.
|
|
137
|
+
*/
|
|
138
|
+
getScopedKeyValueService(scopeType, scopeKey) {
|
|
139
|
+
if (!this.keyValueServiceEnabled && !this.secretServiceEnabled) {
|
|
140
|
+
throw new Error(`Attempt to use KeyValueService/SecretService which is not enabled`);
|
|
141
|
+
}
|
|
142
|
+
const scopedServices = scopeType === "command"
|
|
143
|
+
? this.#commandScopedKeyValueServices
|
|
144
|
+
: this.#serviceScopedKeyValueServices;
|
|
145
|
+
const cached = scopedServices.get(scopeKey);
|
|
146
|
+
if (cached) {
|
|
147
|
+
return cached;
|
|
148
|
+
}
|
|
149
|
+
const keyValueData = this.#configurationServiceProvider.getKeyValueData(scopeType, scopeKey);
|
|
150
|
+
const secretService = this.secretServiceEnabled
|
|
151
|
+
? new DefaultSecretService(this.#cliConfigName, `${scopeType}_${scopeKey}`)
|
|
152
|
+
: undefined;
|
|
153
|
+
const scopedService = new DefaultKeyValueService(keyValueData, secretService);
|
|
154
|
+
scopedServices.set(scopeKey, scopedService);
|
|
155
|
+
return scopedService;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Return a {@link Context} which delegates every lookup to `context` unchanged, except
|
|
159
|
+
* `getServiceById(KEY_VALUE_SERVICE_ID)`, which resolves to the scope-bound instance from
|
|
160
|
+
* {@link getScopedKeyValueService} for the given scope. Used by `runner.ts` to give each
|
|
161
|
+
* command/service/task a KeyValueService isolated to its own scope, invisibly at the call site.
|
|
162
|
+
*
|
|
163
|
+
* Returns `context` itself, unchanged, if neither `keyValueServiceEnabled` nor
|
|
164
|
+
* `secretServiceEnabled` is set.
|
|
165
|
+
*/
|
|
166
|
+
getContextForScope(context, scopeType, scopeKey) {
|
|
167
|
+
if (!this.keyValueServiceEnabled && !this.secretServiceEnabled) {
|
|
168
|
+
return context;
|
|
169
|
+
}
|
|
170
|
+
const scopedKeyValueService = this.getScopedKeyValueService(scopeType, scopeKey);
|
|
171
|
+
return {
|
|
172
|
+
cliConfig: context.cliConfig,
|
|
173
|
+
getServiceById: (id) => id === KEY_VALUE_SERVICE_ID ? scopedKeyValueService : context.getServiceById(id),
|
|
174
|
+
doesServiceExist: (id) => context.doesServiceExist(id),
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Flush every scoped KeyValueService's data to the configuration file, if any of them report
|
|
179
|
+
* themselves dirty. Registered as a low-priority ShutdownTask (see {@link initService}) so it
|
|
180
|
+
* runs once, after other shutdown cleanup, regardless of how long any scope was written to.
|
|
181
|
+
*/
|
|
182
|
+
async #flushDirtyScopes() {
|
|
183
|
+
const anyDirty = [
|
|
184
|
+
...this.#commandScopedKeyValueServices.values(),
|
|
185
|
+
...this.#serviceScopedKeyValueServices.values(),
|
|
186
|
+
].some((service) => service.isDirty());
|
|
187
|
+
await this.#configurationServiceProvider.flushIfDirty(anyDirty);
|
|
188
|
+
}
|
|
189
|
+
async initService(context) {
|
|
190
|
+
if (this.keyValueServiceEnabled || this.secretServiceEnabled) {
|
|
191
|
+
const shutdownService = context.getServiceById(SHUTDOWN_SERVICE_ID);
|
|
192
|
+
shutdownService.registerTask({
|
|
193
|
+
id: `${KEY_VALUE_SERVICE_ID}-flush`,
|
|
194
|
+
// low priority - shutdown tasks run in descending priority order, so this runs after
|
|
195
|
+
// other shutdown cleanup (which defaults to priority 0).
|
|
196
|
+
priority: -100,
|
|
197
|
+
run: () => this.#flushDirtyScopes(),
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
@@ -2,18 +2,17 @@ import type { GlobalModifierCommand } from "@flowscripter/dynamic-cli-framework-
|
|
|
2
2
|
import type { GlobalCommandArgument } from "@flowscripter/dynamic-cli-framework-api";
|
|
3
3
|
import { type SingleValueType } from "@flowscripter/dynamic-cli-framework-api";
|
|
4
4
|
import type { Context } from "@flowscripter/dynamic-cli-framework-api";
|
|
5
|
-
import type ConfigurationServiceProvider from "../ConfigurationServiceProvider.ts";
|
|
6
5
|
/**
|
|
7
|
-
* Command allowing the specification of the configuration file location used by
|
|
6
|
+
* Command allowing the specification of the configuration file location used by
|
|
7
|
+
* {@link ConfigurationServiceProvider}.
|
|
8
8
|
*/
|
|
9
9
|
export default class ConfigCommand implements GlobalModifierCommand {
|
|
10
|
-
#private;
|
|
11
10
|
readonly name = "config";
|
|
12
11
|
readonly description = "Set the configuration file location";
|
|
13
12
|
readonly enableConfiguration = true;
|
|
14
13
|
readonly argument: GlobalCommandArgument;
|
|
15
14
|
readonly executePriority: number;
|
|
16
|
-
constructor(
|
|
17
|
-
execute(
|
|
15
|
+
constructor(executePriority: number);
|
|
16
|
+
execute(context: Context, argumentValue: SingleValueType): Promise<void>;
|
|
18
17
|
}
|
|
19
18
|
//# sourceMappingURL=ConfigCommand.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigCommand.d.ts","sourceRoot":"","sources":["../../../../../src/service/configuration/command/ConfigCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,KAAK,eAAe,EAAiB,MAAM,yCAAyC,CAAC;AAC9F,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"ConfigCommand.d.ts","sourceRoot":"","sources":["../../../../../src/service/configuration/command/ConfigCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,KAAK,eAAe,EAAiB,MAAM,yCAAyC,CAAC;AAC9F,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yCAAyC,CAAC;AAMvE;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,aAAc,YAAW,qBAAqB;IACjE,QAAQ,CAAC,IAAI,YAAY;IACzB,QAAQ,CAAC,WAAW,yCAAyC;IAC7D,QAAQ,CAAC,mBAAmB,QAAQ;IACpC,QAAQ,CAAC,QAAQ,EAAE,qBAAqB,CAGtC;IACF,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IAEjC,YAAmB,eAAe,EAAE,MAAM,EAEzC;IAEM,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAS9E;CACF"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ValueTypeName } from "@flowscripter/dynamic-cli-framework-api";
|
|
2
|
+
import { CONFIGURATION_SERVICE_ID, } from "@flowscripter/dynamic-cli-framework-api";
|
|
2
3
|
/**
|
|
3
|
-
* Command allowing the specification of the configuration file location used by
|
|
4
|
+
* Command allowing the specification of the configuration file location used by
|
|
5
|
+
* {@link ConfigurationServiceProvider}.
|
|
4
6
|
*/
|
|
5
7
|
export default class ConfigCommand {
|
|
6
8
|
name = "config";
|
|
@@ -11,14 +13,13 @@ export default class ConfigCommand {
|
|
|
11
13
|
configurationKey: "CONFIG",
|
|
12
14
|
};
|
|
13
15
|
executePriority;
|
|
14
|
-
|
|
15
|
-
constructor(configurationServiceProvider, executePriority) {
|
|
16
|
-
this.#configurationServiceProvider = configurationServiceProvider;
|
|
16
|
+
constructor(executePriority) {
|
|
17
17
|
this.executePriority = executePriority;
|
|
18
18
|
}
|
|
19
|
-
execute(
|
|
19
|
+
execute(context, argumentValue) {
|
|
20
20
|
const configLocation = argumentValue;
|
|
21
|
-
|
|
21
|
+
const configurationService = context.getServiceById(CONFIGURATION_SERVICE_ID);
|
|
22
|
+
configurationService.setConfigLocation(configLocation);
|
|
22
23
|
return Promise.resolve();
|
|
23
24
|
}
|
|
24
25
|
}
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import type { Context } from "@flowscripter/dynamic-cli-framework-api";
|
|
2
2
|
import type { GlobalCommand } from "@flowscripter/dynamic-cli-framework-api";
|
|
3
|
-
import type ConfigurationServiceProvider from "../ConfigurationServiceProvider.ts";
|
|
4
3
|
/**
|
|
5
|
-
* Command which dumps the configuration loaded by
|
|
4
|
+
* Command which dumps the configuration loaded by {@link ConfigurationServiceProvider}.
|
|
5
|
+
*
|
|
6
|
+
* Takes a direct reference to {@link ConfigurationServiceProvider.getConfigString}, wired by the
|
|
7
|
+
* provider that constructs this command, rather than looking it up via {@link Context} -
|
|
8
|
+
* deliberately, since a full config dump is not something every command/task should be able to
|
|
9
|
+
* reach through a general lookup (see {@link ConfigurationService}'s doc comment).
|
|
6
10
|
*/
|
|
7
11
|
export default class DumpConfigCommand implements GlobalCommand {
|
|
8
12
|
#private;
|
|
9
13
|
readonly name = "dump-config";
|
|
10
14
|
readonly description = "Dump configuration values";
|
|
11
|
-
constructor(
|
|
15
|
+
constructor(getConfigString: () => string);
|
|
12
16
|
execute(context: Context): Promise<void>;
|
|
13
17
|
}
|
|
14
18
|
//# sourceMappingURL=DumpConfigCommand.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DumpConfigCommand.d.ts","sourceRoot":"","sources":["../../../../../src/service/configuration/command/DumpConfigCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yCAAyC,CAAC;AACvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"DumpConfigCommand.d.ts","sourceRoot":"","sources":["../../../../../src/service/configuration/command/DumpConfigCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yCAAyC,CAAC;AACvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AAM7E;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAkB,YAAW,aAAa;;IAC7D,QAAQ,CAAC,IAAI,iBAAiB;IAC9B,QAAQ,CAAC,WAAW,+BAA+B;IAInD,YAAmB,eAAe,EAAE,MAAM,MAAM,EAE/C;IAEY,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CASpD;CACF"}
|
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
import { PRINTER_SERVICE_ID } from "@flowscripter/dynamic-cli-framework-api";
|
|
2
2
|
import { SYNTAX_HIGHLIGHTER_SERVICE_ID } from "@flowscripter/dynamic-cli-framework-api";
|
|
3
3
|
/**
|
|
4
|
-
* Command which dumps the configuration loaded by
|
|
4
|
+
* Command which dumps the configuration loaded by {@link ConfigurationServiceProvider}.
|
|
5
|
+
*
|
|
6
|
+
* Takes a direct reference to {@link ConfigurationServiceProvider.getConfigString}, wired by the
|
|
7
|
+
* provider that constructs this command, rather than looking it up via {@link Context} -
|
|
8
|
+
* deliberately, since a full config dump is not something every command/task should be able to
|
|
9
|
+
* reach through a general lookup (see {@link ConfigurationService}'s doc comment).
|
|
5
10
|
*/
|
|
6
11
|
export default class DumpConfigCommand {
|
|
7
12
|
name = "dump-config";
|
|
8
13
|
description = "Dump configuration values";
|
|
9
|
-
#
|
|
10
|
-
constructor(
|
|
11
|
-
this.#
|
|
14
|
+
#getConfigString;
|
|
15
|
+
constructor(getConfigString) {
|
|
16
|
+
this.#getConfigString = getConfigString;
|
|
12
17
|
}
|
|
13
18
|
async execute(context) {
|
|
14
19
|
const printerService = context.getServiceById(PRINTER_SERVICE_ID);
|
|
15
20
|
const syntaxHighlighterService = context.getServiceById(SYNTAX_HIGHLIGHTER_SERVICE_ID);
|
|
16
|
-
await printerService.print(`${syntaxHighlighterService.highlight(this.#
|
|
21
|
+
await printerService.print(`${syntaxHighlighterService.highlight(this.#getConfigString(), "json")}\n`);
|
|
17
22
|
}
|
|
18
23
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { FetchOptions, FetchService
|
|
1
|
+
import type { Context, FetchOptions, FetchService } from "@flowscripter/dynamic-cli-framework-api";
|
|
2
2
|
export default class DefaultFetchService implements FetchService {
|
|
3
3
|
#private;
|
|
4
|
-
|
|
4
|
+
setContext(context: Context): void;
|
|
5
5
|
fetch(input: string | URL, options?: FetchOptions): Promise<Response>;
|
|
6
6
|
}
|
|
7
7
|
//# sourceMappingURL=DefaultFetchService.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultFetchService.d.ts","sourceRoot":"","sources":["../../../../src/service/fetch/DefaultFetchService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,
|
|
1
|
+
{"version":3,"file":"DefaultFetchService.d.ts","sourceRoot":"","sources":["../../../../src/service/fetch/DefaultFetchService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,YAAY,EACZ,YAAY,EAEb,MAAM,yCAAyC,CAAC;AAMjD,MAAM,CAAC,OAAO,OAAO,mBAAoB,YAAW,YAAY;;IAGvD,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAExC;IAEY,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,EAAE,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAyCrF;CACF"}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
+
import { SHUTDOWN_SERVICE_ID } from "@flowscripter/dynamic-cli-framework-api";
|
|
1
2
|
import getLogger from "../../util/logger.js";
|
|
2
3
|
const logger = getLogger("DefaultFetchService");
|
|
3
4
|
export default class DefaultFetchService {
|
|
4
|
-
#
|
|
5
|
-
|
|
6
|
-
this.#
|
|
5
|
+
#context;
|
|
6
|
+
setContext(context) {
|
|
7
|
+
this.#context = context;
|
|
7
8
|
}
|
|
8
9
|
async fetch(input, options = {}) {
|
|
9
|
-
if (this.#
|
|
10
|
-
throw new Error("DefaultFetchService.fetch() called before
|
|
10
|
+
if (this.#context === undefined) {
|
|
11
|
+
throw new Error("DefaultFetchService.fetch() called before setContext()");
|
|
11
12
|
}
|
|
12
|
-
const shutdownService = this.#
|
|
13
|
+
const shutdownService = this.#context.getServiceById(SHUTDOWN_SERVICE_ID);
|
|
13
14
|
const { timeoutMs, longRunning = false, signal: callerSignal, ...requestInit } = options;
|
|
14
15
|
const controller = new AbortController();
|
|
15
16
|
const signals = [controller.signal];
|
|
@@ -23,12 +24,16 @@ export default class DefaultFetchService {
|
|
|
23
24
|
let settled = false;
|
|
24
25
|
if (longRunning) {
|
|
25
26
|
shutdownService.enterLongRunningMode();
|
|
26
|
-
shutdownService.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
shutdownService.registerTask({
|
|
28
|
+
id: `fetch:${input.toString()}`,
|
|
29
|
+
priority: 0,
|
|
30
|
+
run: async () => {
|
|
31
|
+
if (settled) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
logger.debug(() => `Aborting fetch of '${input.toString()}' due to shutdown`);
|
|
35
|
+
controller.abort();
|
|
36
|
+
},
|
|
32
37
|
});
|
|
33
38
|
}
|
|
34
39
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FetchServiceProvider.d.ts","sourceRoot":"","sources":["../../../../src/service/fetch/FetchServiceProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,OAAO,EACP,WAAW,EACX,eAAe,
|
|
1
|
+
{"version":3,"file":"FetchServiceProvider.d.ts","sourceRoot":"","sources":["../../../../src/service/fetch/FetchServiceProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,OAAO,EACP,WAAW,EACX,eAAe,EAChB,MAAM,yCAAyC,CAAC;AAIjD,MAAM,CAAC,OAAO,OAAO,oBAAqB,YAAW,eAAe;;IAClE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAoB;IAC9C,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IAGjC,YAAmB,eAAe,EAAE,MAAM,EAEzC;IAEM,cAAc,CAAC,UAAU,EAAE,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,CAMjE;IAEM,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAGlD;CACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FETCH_SERVICE_ID
|
|
1
|
+
import { FETCH_SERVICE_ID } from "@flowscripter/dynamic-cli-framework-api";
|
|
2
2
|
import DefaultFetchService from "./DefaultFetchService.js";
|
|
3
3
|
export default class FetchServiceProvider {
|
|
4
4
|
serviceId = FETCH_SERVICE_ID;
|
|
@@ -15,8 +15,7 @@ export default class FetchServiceProvider {
|
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
17
|
initService(context) {
|
|
18
|
-
|
|
19
|
-
this.#fetchService.setDependencies(shutdownService);
|
|
18
|
+
this.#fetchService.setContext(context);
|
|
20
19
|
return Promise.resolve();
|
|
21
20
|
}
|
|
22
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrinterServiceProvider.d.ts","sourceRoot":"","sources":["../../../../src/service/printer/PrinterServiceProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yCAAyC,CAAC;AAEvE,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAC5F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AAK9E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAIzE;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,sBAAuB,YAAW,eAAe;IACpE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAsB;IAChD,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IAExC;;;;;OAKG;IACH,YAAmB,eAAe,EAAE,MAAM,EAAE,cAAc,EAAE,cAAc,EAGzE;IAEM,cAAc,CAAC,UAAU,EAAE,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,CAUjE;IAED,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"PrinterServiceProvider.d.ts","sourceRoot":"","sources":["../../../../src/service/printer/PrinterServiceProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yCAAyC,CAAC;AAEvE,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAC5F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AAK9E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAIzE;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,sBAAuB,YAAW,eAAe;IACpE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAsB;IAChD,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IAExC;;;;;OAKG;IACH,YAAmB,eAAe,EAAE,MAAM,EAAE,cAAc,EAAE,cAAc,EAGzE;IAEM,cAAc,CAAC,UAAU,EAAE,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,CAUjE;IAED,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAY3C;CACF"}
|
|
@@ -25,18 +25,22 @@ export default class PrinterServiceProvider {
|
|
|
25
25
|
return Promise.resolve({
|
|
26
26
|
service: this.printerService,
|
|
27
27
|
commands: [
|
|
28
|
-
new NoHyperlinksCommand(this
|
|
29
|
-
new DarkModeCommand(this
|
|
30
|
-
new NoColorCommand(this
|
|
31
|
-
new LogLevelCommand(this
|
|
28
|
+
new NoHyperlinksCommand(this.servicePriority + 3),
|
|
29
|
+
new DarkModeCommand(this.servicePriority + 2),
|
|
30
|
+
new NoColorCommand(this.servicePriority + 1),
|
|
31
|
+
new LogLevelCommand(this.servicePriority),
|
|
32
32
|
],
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
35
|
initService(context) {
|
|
36
36
|
const shutdownService = context.getServiceById(SHUTDOWN_SERVICE_ID);
|
|
37
|
-
shutdownService.
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
shutdownService.registerTask({
|
|
38
|
+
id: PRINTER_SERVICE_ID,
|
|
39
|
+
priority: 0,
|
|
40
|
+
run: async () => {
|
|
41
|
+
await this.printerService.hideSpinner();
|
|
42
|
+
await this.printerService.hideAllProgressBars();
|
|
43
|
+
},
|
|
40
44
|
});
|
|
41
45
|
return Promise.resolve();
|
|
42
46
|
}
|
|
@@ -2,18 +2,16 @@ import type { GlobalModifierCommand } from "@flowscripter/dynamic-cli-framework-
|
|
|
2
2
|
import type { GlobalCommandArgument } from "@flowscripter/dynamic-cli-framework-api";
|
|
3
3
|
import { type SingleValueType } from "@flowscripter/dynamic-cli-framework-api";
|
|
4
4
|
import type { Context } from "@flowscripter/dynamic-cli-framework-api";
|
|
5
|
-
import type PrinterServiceProvider from "../PrinterServiceProvider.ts";
|
|
6
5
|
/**
|
|
7
|
-
* Command allowing the specification of dark/light mode for {@link
|
|
6
|
+
* Command allowing the specification of dark/light mode for the {@link PrinterService}.
|
|
8
7
|
*/
|
|
9
8
|
export default class DarkModeCommand implements GlobalModifierCommand {
|
|
10
|
-
#private;
|
|
11
9
|
readonly name = "dark-mode";
|
|
12
10
|
readonly description = "Enable dark mode for output";
|
|
13
11
|
readonly enableConfiguration = true;
|
|
14
12
|
readonly argument: GlobalCommandArgument;
|
|
15
13
|
readonly executePriority: number;
|
|
16
|
-
constructor(
|
|
17
|
-
execute(
|
|
14
|
+
constructor(executePriority: number);
|
|
15
|
+
execute(context: Context, argumentValue: SingleValueType): Promise<void>;
|
|
18
16
|
}
|
|
19
17
|
//# sourceMappingURL=DarkModeCommand.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DarkModeCommand.d.ts","sourceRoot":"","sources":["../../../../../src/service/printer/command/DarkModeCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,KAAK,eAAe,EAAiB,MAAM,yCAAyC,CAAC;AAC9F,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"DarkModeCommand.d.ts","sourceRoot":"","sources":["../../../../../src/service/printer/command/DarkModeCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,KAAK,eAAe,EAAiB,MAAM,yCAAyC,CAAC;AAC9F,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yCAAyC,CAAC;AAIvE;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,eAAgB,YAAW,qBAAqB;IACnE,QAAQ,CAAC,IAAI,eAAe;IAC5B,QAAQ,CAAC,WAAW,iCAAiC;IACrD,QAAQ,CAAC,mBAAmB,QAAQ;IACpC,QAAQ,CAAC,QAAQ,EAAE,qBAAqB,CAItC;IACF,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IAEjC,YAAmB,eAAe,EAAE,MAAM,EAEzC;IAEM,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAK9E;CACF"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ValueTypeName } from "@flowscripter/dynamic-cli-framework-api";
|
|
2
|
+
import { PRINTER_SERVICE_ID } from "@flowscripter/dynamic-cli-framework-api";
|
|
2
3
|
/**
|
|
3
|
-
* Command allowing the specification of dark/light mode for {@link
|
|
4
|
+
* Command allowing the specification of dark/light mode for the {@link PrinterService}.
|
|
4
5
|
*/
|
|
5
6
|
export default class DarkModeCommand {
|
|
6
7
|
name = "dark-mode";
|
|
@@ -12,13 +13,12 @@ export default class DarkModeCommand {
|
|
|
12
13
|
configurationKey: "DARK_MODE",
|
|
13
14
|
};
|
|
14
15
|
executePriority;
|
|
15
|
-
|
|
16
|
-
constructor(printerServiceProvider, executePriority) {
|
|
17
|
-
this.#printerServiceProvider = printerServiceProvider;
|
|
16
|
+
constructor(executePriority) {
|
|
18
17
|
this.executePriority = executePriority;
|
|
19
18
|
}
|
|
20
|
-
execute(
|
|
21
|
-
|
|
19
|
+
execute(context, argumentValue) {
|
|
20
|
+
const printerService = context.getServiceById(PRINTER_SERVICE_ID);
|
|
21
|
+
printerService.darkMode = argumentValue;
|
|
22
22
|
return Promise.resolve();
|
|
23
23
|
}
|
|
24
24
|
}
|
|
@@ -2,18 +2,16 @@ import type { GlobalCommandArgument } from "@flowscripter/dynamic-cli-framework-
|
|
|
2
2
|
import { type SingleValueType } from "@flowscripter/dynamic-cli-framework-api";
|
|
3
3
|
import type { GlobalModifierCommand } from "@flowscripter/dynamic-cli-framework-api";
|
|
4
4
|
import type { Context } from "@flowscripter/dynamic-cli-framework-api";
|
|
5
|
-
import type PrinterServiceProvider from "../PrinterServiceProvider.ts";
|
|
6
5
|
/**
|
|
7
|
-
* Command allowing the setting of the log level for {@link
|
|
6
|
+
* Command allowing the setting of the log level for the {@link PrinterService}.
|
|
8
7
|
*/
|
|
9
8
|
export default class LogLevelCommand implements GlobalModifierCommand {
|
|
10
|
-
#private;
|
|
11
9
|
readonly name = "log-level";
|
|
12
10
|
readonly description = "Set the logging threshold";
|
|
13
11
|
readonly enableConfiguration = true;
|
|
14
12
|
readonly argument: GlobalCommandArgument;
|
|
15
13
|
readonly executePriority: number;
|
|
16
|
-
constructor(
|
|
17
|
-
execute(
|
|
14
|
+
constructor(executePriority: number);
|
|
15
|
+
execute(context: Context, argumentValue: SingleValueType): Promise<void>;
|
|
18
16
|
}
|
|
19
17
|
//# sourceMappingURL=LogLevelCommand.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LogLevelCommand.d.ts","sourceRoot":"","sources":["../../../../../src/service/printer/command/LogLevelCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,KAAK,eAAe,EAAiB,MAAM,yCAAyC,CAAC;AAC9F,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"LogLevelCommand.d.ts","sourceRoot":"","sources":["../../../../../src/service/printer/command/LogLevelCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,KAAK,eAAe,EAAiB,MAAM,yCAAyC,CAAC;AAC9F,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yCAAyC,CAAC;AAKvE;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,eAAgB,YAAW,qBAAqB;IACnE,QAAQ,CAAC,IAAI,eAAe;IAC5B,QAAQ,CAAC,WAAW,+BAA+B;IACnD,QAAQ,CAAC,mBAAmB,QAAQ;IACpC,QAAQ,CAAC,QAAQ,EAAE,qBAAqB,CAMtC;IACF,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IAEjC,YAAmB,eAAe,EAAE,MAAM,EAEzC;IAEM,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAoB9E;CACF"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ValueTypeName } from "@flowscripter/dynamic-cli-framework-api";
|
|
2
|
+
import { PRINTER_SERVICE_ID } from "@flowscripter/dynamic-cli-framework-api";
|
|
2
3
|
import { Level } from "@flowscripter/dynamic-cli-framework-api";
|
|
3
4
|
/**
|
|
4
|
-
* Command allowing the setting of the log level for {@link
|
|
5
|
+
* Command allowing the setting of the log level for the {@link PrinterService}.
|
|
5
6
|
*/
|
|
6
7
|
export default class LogLevelCommand {
|
|
7
8
|
name = "log-level";
|
|
@@ -15,25 +16,24 @@ export default class LogLevelCommand {
|
|
|
15
16
|
configurationKey: "LOG_LEVEL",
|
|
16
17
|
};
|
|
17
18
|
executePriority;
|
|
18
|
-
|
|
19
|
-
constructor(printerServiceProvider, executePriority) {
|
|
20
|
-
this.#printerServiceProvider = printerServiceProvider;
|
|
19
|
+
constructor(executePriority) {
|
|
21
20
|
this.executePriority = executePriority;
|
|
22
21
|
}
|
|
23
|
-
execute(
|
|
22
|
+
execute(context, argumentValue) {
|
|
23
|
+
const printerService = context.getServiceById(PRINTER_SERVICE_ID);
|
|
24
24
|
const logLevel = argumentValue;
|
|
25
25
|
switch (logLevel.toUpperCase()) {
|
|
26
26
|
case "DEBUG":
|
|
27
|
-
|
|
27
|
+
printerService.setLevel(Level.DEBUG);
|
|
28
28
|
break;
|
|
29
29
|
case "INFO":
|
|
30
|
-
|
|
30
|
+
printerService.setLevel(Level.INFO);
|
|
31
31
|
break;
|
|
32
32
|
case "WARN":
|
|
33
|
-
|
|
33
|
+
printerService.setLevel(Level.WARN);
|
|
34
34
|
break;
|
|
35
35
|
case "ERROR":
|
|
36
|
-
|
|
36
|
+
printerService.setLevel(Level.ERROR);
|
|
37
37
|
break;
|
|
38
38
|
}
|
|
39
39
|
return Promise.resolve();
|
|
@@ -2,18 +2,16 @@ import type { GlobalModifierCommand } from "@flowscripter/dynamic-cli-framework-
|
|
|
2
2
|
import type { GlobalCommandArgument } from "@flowscripter/dynamic-cli-framework-api";
|
|
3
3
|
import { type SingleValueType } from "@flowscripter/dynamic-cli-framework-api";
|
|
4
4
|
import type { Context } from "@flowscripter/dynamic-cli-framework-api";
|
|
5
|
-
import type PrinterServiceProvider from "../PrinterServiceProvider.ts";
|
|
6
5
|
/**
|
|
7
|
-
* Command allowing the disabling of color for {@link
|
|
6
|
+
* Command allowing the disabling of color for the {@link PrinterService}.
|
|
8
7
|
*/
|
|
9
8
|
export default class NoColorCommand implements GlobalModifierCommand {
|
|
10
|
-
#private;
|
|
11
9
|
readonly name = "no-color";
|
|
12
10
|
readonly description = "Disable color for output";
|
|
13
11
|
readonly enableConfiguration = true;
|
|
14
12
|
readonly argument: GlobalCommandArgument;
|
|
15
13
|
readonly executePriority: number;
|
|
16
|
-
constructor(
|
|
17
|
-
execute(
|
|
14
|
+
constructor(executePriority: number);
|
|
15
|
+
execute(context: Context, argumentValue: SingleValueType): Promise<void>;
|
|
18
16
|
}
|
|
19
17
|
//# sourceMappingURL=NoColorCommand.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NoColorCommand.d.ts","sourceRoot":"","sources":["../../../../../src/service/printer/command/NoColorCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,KAAK,eAAe,EAAiB,MAAM,yCAAyC,CAAC;AAC9F,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"NoColorCommand.d.ts","sourceRoot":"","sources":["../../../../../src/service/printer/command/NoColorCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,KAAK,eAAe,EAAiB,MAAM,yCAAyC,CAAC;AAC9F,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yCAAyC,CAAC;AAIvE;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,cAAe,YAAW,qBAAqB;IAClE,QAAQ,CAAC,IAAI,cAAc;IAC3B,QAAQ,CAAC,WAAW,8BAA8B;IAClD,QAAQ,CAAC,mBAAmB,QAAQ;IACpC,QAAQ,CAAC,QAAQ,EAAE,qBAAqB,CAItC;IACF,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IAEjC,YAAmB,eAAe,EAAE,MAAM,EAEzC;IAEM,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAK9E;CACF"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ValueTypeName } from "@flowscripter/dynamic-cli-framework-api";
|
|
2
|
+
import { PRINTER_SERVICE_ID } from "@flowscripter/dynamic-cli-framework-api";
|
|
2
3
|
/**
|
|
3
|
-
* Command allowing the disabling of color for {@link
|
|
4
|
+
* Command allowing the disabling of color for the {@link PrinterService}.
|
|
4
5
|
*/
|
|
5
6
|
export default class NoColorCommand {
|
|
6
7
|
name = "no-color";
|
|
@@ -12,13 +13,12 @@ export default class NoColorCommand {
|
|
|
12
13
|
configurationKey: "NO_COLOR",
|
|
13
14
|
};
|
|
14
15
|
executePriority;
|
|
15
|
-
|
|
16
|
-
constructor(printerServiceProvider, executePriority) {
|
|
17
|
-
this.#printerServiceProvider = printerServiceProvider;
|
|
16
|
+
constructor(executePriority) {
|
|
18
17
|
this.executePriority = executePriority;
|
|
19
18
|
}
|
|
20
|
-
execute(
|
|
21
|
-
|
|
19
|
+
execute(context, argumentValue) {
|
|
20
|
+
const printerService = context.getServiceById(PRINTER_SERVICE_ID);
|
|
21
|
+
printerService.colorEnabled = !argumentValue;
|
|
22
22
|
return Promise.resolve();
|
|
23
23
|
}
|
|
24
24
|
}
|