@flowscripter/dynamic-cli-framework 1.0.6 → 1.0.8

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 (46) hide show
  1. package/bun.lock +3 -3
  2. package/package.json +2 -2
  3. package/src/cli/DefaultRuntimeCLI.ts +2 -2
  4. package/src/launcher.ts +4 -20
  5. package/src/runtime/parser.ts +4 -4
  6. package/src/runtime/registry/DefaultServiceProviderRegistry.ts +7 -0
  7. package/src/runtime/runner.ts +1 -1
  8. package/src/runtime/scanner.ts +2 -2
  9. package/src/util/logger.ts +17 -17
  10. package/tests/cli/BaseCLI.test.ts +1 -1
  11. package/tests/command/MultiCommandCliHelpCommand.test.ts +1 -1
  12. package/tests/command/SingleCommandCliHelpCommand.test.ts +1 -1
  13. package/tests/command/UsageCommand.test.ts +1 -1
  14. package/tests/command/VersionCommand.test.ts +1 -1
  15. package/tests/runtime/DefaultContext.test.ts +1 -1
  16. package/tests/runtime/argument/ArgumentTypeGuards.test.ts +1 -1
  17. package/tests/runtime/command/CommandTypeGuards.test.ts +1 -1
  18. package/tests/runtime/command/CommandValidator.test.ts +1 -1
  19. package/tests/runtime/parser.test.ts +1 -1
  20. package/tests/runtime/registry/DefaultCommandRegistry.test.ts +1 -1
  21. package/tests/runtime/registry/DefaultServiceProviderRegistry.test.ts +1 -1
  22. package/tests/runtime/runner.test.ts +1 -1
  23. package/tests/runtime/scanner.test.ts +1 -1
  24. package/tests/runtime/values/argumentValueMerge.test.ts +1 -1
  25. package/tests/runtime/values/argumentValueValidation.test.ts +1 -1
  26. package/tests/runtime/values/globalCommandValuePopulation.test.ts +1 -1
  27. package/tests/runtime/values/subCommandValuePopulation.test.ts +1 -1
  28. package/tests/service/asciiBannerGenerator/AsciiBannerGeneratorServiceProvider.test.ts +1 -1
  29. package/tests/service/asciiBannerGenerator/DefaultAsciiBannerGeneratorService.test.ts +1 -1
  30. package/tests/service/asciiBannerGenerator/__snapshots__/DefaultAsciiBannerGeneratorService.test.ts.snap +21 -0
  31. package/tests/service/configuration/ConfigurationServiceProvider.test.ts +1 -1
  32. package/tests/service/configuration/DefaultKeyValueService.test.ts +1 -1
  33. package/tests/service/launchBanner/BannerServiceProvider.test.ts +1 -1
  34. package/tests/service/launchBanner/__snapshots__/BannerServiceProvider.test.ts.snap +2 -0
  35. package/tests/service/launchBanner/command/NoBannerCommand.test.ts +1 -1
  36. package/tests/service/printer/DefaultPrinterService.test.ts +1 -1
  37. package/tests/service/printer/PrinterServiceProvider.test.ts +1 -1
  38. package/tests/service/printer/command/LogLevelCommand.test.ts +1 -1
  39. package/tests/service/printer/terminal/Progress.test.ts +1 -1
  40. package/tests/service/printer/terminal/Spinner.test.ts +1 -1
  41. package/tests/service/shutdown/ShutdownServiceProvider.test.ts +1 -1
  42. package/tests/service/syntaxHighlighter/DefaultSyntaxHighlighterService.test.ts +1 -1
  43. package/tests/service/syntaxHighlighter/SyntaxHighlighterServiceProvider.test.ts +1 -1
  44. package/tests/util/configHelper.test.ts +1 -1
  45. package/tests/util/envVarHelper.test.ts +1 -1
  46. package/tests/util/logger.test.ts +25 -1
package/bun.lock CHANGED
@@ -12,7 +12,7 @@
12
12
  "ts-log": "^2.2.7",
13
13
  },
14
14
  "devDependencies": {
15
- "@types/bun": "^1.2.4",
15
+ "@types/bun": "^1.2.5",
16
16
  },
17
17
  "peerDependencies": {
18
18
  "typescript": "^5.8.2",
@@ -20,7 +20,7 @@
20
20
  },
21
21
  },
22
22
  "packages": {
23
- "@types/bun": ["@types/bun@1.2.4", "", { "dependencies": { "bun-types": "1.2.4" } }, "sha512-QtuV5OMR8/rdKJs213iwXDpfVvnskPXY/S0ZiFbsTjQZycuqPbMW8Gf/XhLfwE5njW8sxI2WjISURXPlHypMFA=="],
23
+ "@types/bun": ["@types/bun@1.2.5", "", { "dependencies": { "bun-types": "1.2.5" } }, "sha512-w2OZTzrZTVtbnJew1pdFmgV99H0/L+Pvw+z1P67HaR18MHOzYnTYOi6qzErhK8HyT+DB782ADVPPE92Xu2/Opg=="],
24
24
 
25
25
  "@types/hast": ["@types/hast@3.0.4", "", { "dependencies": { "@types/unist": "*" } }, "sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ=="],
26
26
 
@@ -30,7 +30,7 @@
30
30
 
31
31
  "@types/ws": ["@types/ws@8.5.14", "", { "dependencies": { "@types/node": "*" } }, "sha512-bd/YFLW+URhBzMXurx7lWByOu+xzU9+kb3RboOteXYDfW+tr+JZa99OyNmPINEGB/ahzKrEuc8rcv4gnpJmxTw=="],
32
32
 
33
- "bun-types": ["bun-types@1.2.4", "", { "dependencies": { "@types/node": "*", "@types/ws": "~8.5.10" } }, "sha512-nDPymR207ZZEoWD4AavvEaa/KZe/qlrbMSchqpQwovPZCKc7pwMoENjEtHgMKaAjJhy+x6vfqSBA1QU3bJgs0Q=="],
33
+ "bun-types": ["bun-types@1.2.5", "", { "dependencies": { "@types/node": "*", "@types/ws": "~8.5.10" } }, "sha512-3oO6LVGGRRKI4kHINx5PIdIgnLRb7l/SprhzqXapmoYkFl5m4j6EvALvbDVuuBFaamB46Ap6HCUxIXNLCGy+tg=="],
34
34
 
35
35
  "chalk": ["chalk@5.4.1", "", {}, "sha512-zgVZuo2WcZgfUEmsn6eO3kINexW8RAE4maiQ8QNs8CtpPCSyMiYsULR3HQYkm3w8FIA3SberyMJMSldGsW+U3w=="],
36
36
 
package/package.json CHANGED
@@ -2,12 +2,12 @@
2
2
  "name": "@flowscripter/dynamic-cli-framework",
3
3
  "module": "index.ts",
4
4
  "type": "module",
5
- "version": "1.0.6",
5
+ "version": "1.0.8",
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },
9
9
  "devDependencies": {
10
- "@types/bun": "^1.2.4"
10
+ "@types/bun": "^1.2.5"
11
11
  },
12
12
  "peerDependencies": {
13
13
  "typescript": "^5.8.2"
@@ -9,7 +9,7 @@ import TtyStyler from "../service/printer/terminal/TtyStyler.ts";
9
9
  import supportsColor from "supports-color";
10
10
 
11
11
  /**
12
- * Default Bun and NodeJS implementation of a {@link CLI} using `process.stdout`, `process.stderr` and `process.argv`.
12
+ * Default Bun implementation of a {@link CLI} using `process.stdout`, `process.stderr` and `process.argv`.
13
13
  */
14
14
  export default class DefaultRuntimeCLI extends BaseCLI {
15
15
  /**
@@ -45,7 +45,7 @@ export default class DefaultRuntimeCLI extends BaseCLI {
45
45
  * {@link RunState} value resulting from the invocation.
46
46
  */
47
47
  override async run(): Promise<RunResult> {
48
- const runResult = await super.run(process.argv);
48
+ const runResult = await super.run(process.argv.slice(2));
49
49
  if (runResult.runState === RunState.RUNTIME_ERROR) {
50
50
  console.error(runResult.error);
51
51
  }
package/src/launcher.ts CHANGED
@@ -7,29 +7,16 @@ import type Command from "./api/command/Command.ts";
7
7
  import type RunResult from "./api/RunResult.ts";
8
8
  import type { ServiceProvider } from "./api/service/ServiceProvider.ts";
9
9
 
10
- function parseVersion(moduleUrl?: string): string | undefined {
11
- if (moduleUrl === undefined) {
12
- return undefined;
13
- }
14
-
15
- const v = moduleUrl.match(/@([^\/]+)[\/$]?/);
16
- if (v === null) {
17
- return undefined;
18
- }
19
- return v[1];
20
- }
21
-
22
10
  /**
23
11
  * Launch a {@link DefaultRuntimeCLI} with a single specified {@link SubCommand} instance.
24
12
  *
25
13
  * @param command the {@link SubCommand} to add to the CLI.
26
14
  * @param description optional description of the CLI.
27
15
  * @param name optional name of the CLI. If not provided, `process.execPath` will be used in an attempt to derive the name.
28
- * @param version optional version of the CLI. If not provided the optionally provided {@link callingModuleUrl} will be used in an attempt to derive the version. If not possible the default is `N/A`.
16
+ * @param version optional version of the CLI.
29
17
  * @param envVarsEnabled optionally support checking env variables for default argument values.
30
18
  * @param configEnabled optionally enable configuration file support for default argument values.
31
19
  * @param keyValueServiceEnabled optionally provide a {@link KeyValueService} implementation: `configEnabled` must be true in this case
32
- * @param callingModuleUrl optional URL of the calling module, can be used in an attempt to derive the version of the CLI if {@link version} is not provided. If not possible the default is `N/A`.
33
20
  * @param serviceProviders optional array of {@link ServiceProvider} instances to add to the CLI.
34
21
  */
35
22
  export async function launchSingleCommandCLI(
@@ -40,7 +27,6 @@ export async function launchSingleCommandCLI(
40
27
  envVarsEnabled = false,
41
28
  configEnabled = false,
42
29
  keyValueServiceEnabled = false,
43
- callingModuleUrl?: string,
44
30
  serviceProviders?: ReadonlyArray<ServiceProvider>,
45
31
  ): Promise<RunResult> {
46
32
  if (!name) {
@@ -49,7 +35,7 @@ export async function launchSingleCommandCLI(
49
35
  const cliConfig: CLIConfig = {
50
36
  description,
51
37
  name,
52
- version: version || parseVersion(callingModuleUrl) || "N/A",
38
+ version: version || "N/A",
53
39
  };
54
40
 
55
41
  if (!configEnabled && keyValueServiceEnabled) {
@@ -79,11 +65,10 @@ export async function launchSingleCommandCLI(
79
65
  * @param commands the {@link Command} instances to add to the CLI.
80
66
  * @param description optional description of the CLI.
81
67
  * @param name optional name of the CLI. If not provided, `process.execPath` will be used in an attempt to derive the name.
82
- * @param version optional version of the CLI. If not provided the optionally provided {@link callingModuleUrl} will be used in an attempt to derive the version. If not possible the default is `N/A`.
68
+ * @param version optional version of the CLI.
83
69
  * @param envVarsEnabled optionally support checking env variables for default argument values.
84
70
  * @param configEnabled optionally enable configuration file support for default argument values.
85
71
  * @param keyValueServiceEnabled optionally provide a {@link KeyValueService} implementation: `configEnabled` must be true in this case
86
- * @param callingModuleUrl optional URL of the calling module, can be used in an attempt to derive the version of the CLI if {@link version} is not provided. If not possible the default is `N/A`.
87
72
  * @param serviceProviders optional array of {@link ServiceProvider} instances to add to the CLI.
88
73
  */
89
74
  export async function launchMultiCommandCLI(
@@ -94,7 +79,6 @@ export async function launchMultiCommandCLI(
94
79
  envVarsEnabled = false,
95
80
  configEnabled = false,
96
81
  keyValueServiceEnabled = false,
97
- callingModuleUrl?: string,
98
82
  serviceProviders?: ReadonlyArray<ServiceProvider>,
99
83
  ): Promise<RunResult> {
100
84
  if (!name) {
@@ -103,7 +87,7 @@ export async function launchMultiCommandCLI(
103
87
  const cliConfig: CLIConfig = {
104
88
  description,
105
89
  name,
106
- version: version || parseVersion(callingModuleUrl) || "N/A",
90
+ version: version || "N/A",
107
91
  };
108
92
  if (!configEnabled && keyValueServiceEnabled) {
109
93
  throw new Error(
@@ -107,7 +107,7 @@ export function parseSubCommandClause(
107
107
  });
108
108
 
109
109
  logger.debug(
110
- "Command arguments after options validated: %j with invalid args: %j",
110
+ "Command arguments after options validated: %O with invalid args: %O",
111
111
  populatedArgumentValues,
112
112
  invalidArguments,
113
113
  );
@@ -125,7 +125,7 @@ export function parseSubCommandClause(
125
125
  }
126
126
  });
127
127
  logger.debug(
128
- "Command arguments after positionals validated: %j with invalid args: %j",
128
+ "Command arguments after positionals validated: %O with invalid args: %O",
129
129
  populatedArgumentValues,
130
130
  invalidArguments,
131
131
  );
@@ -184,7 +184,7 @@ export function parseGlobalCommandClause(
184
184
  }
185
185
 
186
186
  logger.debug(
187
- "Command arguments for command: %s after value population: %j with invalid args: %j and unused args: %j",
187
+ "Command arguments for command: %s after value population: %O with invalid args: %O and unused args: %O",
188
188
  command.name,
189
189
  populatedArgumentValue,
190
190
  invalidArguments,
@@ -204,7 +204,7 @@ export function parseGlobalCommandClause(
204
204
  }
205
205
 
206
206
  logger.debug(
207
- "Command arguments for command: %s after value validation: %j with invalid args: %j",
207
+ "Command arguments for command: %s after value validation: %O with invalid args: %O",
208
208
  command.name,
209
209
  populatedArgumentValue,
210
210
  invalidArguments,
@@ -1,5 +1,8 @@
1
1
  import type ServiceProviderRegistry from "./ServiceProviderRegistry.ts";
2
2
  import type { ServiceProvider } from "../../api/service/ServiceProvider.ts";
3
+ import getLogger from "../../util/logger.ts";
4
+
5
+ const logger = getLogger("DefaultServiceProviderRegistry");
3
6
 
4
7
  /**
5
8
  * Default implementation of a {@link ServiceProviderRegistry}.
@@ -15,6 +18,10 @@ export default class DefaultServiceProviderRegistry
15
18
  }
16
19
 
17
20
  public addServiceProvider(serviceProvider: ServiceProvider): void {
21
+ logger.debug(
22
+ "Adding service provider for service ID: %s",
23
+ serviceProvider.serviceId,
24
+ );
18
25
  this.#serviceProviders.push(serviceProvider);
19
26
  }
20
27
 
@@ -67,7 +67,7 @@ async function executeParsedCommand(
67
67
  }
68
68
 
69
69
  logger.debug(
70
- "Executing command with name: %s and args: %j",
70
+ "Executing command with name: %s and args: %O",
71
71
  parseResult!.command.name,
72
72
  parseResult!.populatedArgumentValues,
73
73
  );
@@ -349,7 +349,7 @@ export function scanForGlobalModifierCommandClauses(
349
349
  scanResult.globalModifierCommandClauses = commandClauses;
350
350
  }
351
351
 
352
- logger.debug("scan result: %j", scanResult);
352
+ logger.debug("scan result: %O", scanResult);
353
353
 
354
354
  return scanResult;
355
355
  }
@@ -411,7 +411,7 @@ export function scanForNonModifierCommandClause(
411
411
  }
412
412
  }
413
413
 
414
- logger.debug("scan result: %j", scanResult);
414
+ logger.debug("scan result: %O", scanResult);
415
415
 
416
416
  return scanResult;
417
417
  }
@@ -19,16 +19,16 @@ function getDefaultLogger(): Logger {
19
19
  return {
20
20
  trace: () => {},
21
21
  debug: (message, ...optionalParams) => {
22
- console.debug(message, optionalParams);
22
+ console.debug(message, ...optionalParams);
23
23
  },
24
24
  info: (message, ...optionalParams) => {
25
- console.info(message, optionalParams);
25
+ console.info(message, ...optionalParams);
26
26
  },
27
27
  warn: (message, ...optionalParams) => {
28
- console.warn(message, optionalParams);
28
+ console.warn(message, ...optionalParams);
29
29
  },
30
30
  error: (message, ...optionalParams) => {
31
- console.error(message, optionalParams);
31
+ console.error(message, ...optionalParams);
32
32
  },
33
33
  };
34
34
  }
@@ -38,26 +38,26 @@ function getDefaultLogger(): Logger {
38
38
  info: () => {},
39
39
  warn: () => {},
40
40
  error: (message, ...optionalParams) => {
41
- console.error(message, optionalParams);
41
+ console.error(message, ...optionalParams);
42
42
  },
43
43
  };
44
44
  }
45
45
 
46
- function wrapWithLoggerName(
46
+ function wrapDefaultLogger(
47
47
  loggerName: string,
48
48
  loggerFunction: LoggerFunction,
49
49
  ): LoggerFunction {
50
50
  return (message, ...optionalParams) => {
51
- if (message instanceof Object) {
52
- message.loggerName = loggerName;
53
- loggerFunction(message, optionalParams);
51
+ if (message instanceof Function) {
52
+ loggerFunction(`${loggerName} : ${message()}`, ...optionalParams);
54
53
  return;
55
54
  }
56
- if (message instanceof Function) {
57
- loggerFunction(`${loggerName} ${message()}`, optionalParams);
55
+ if (message instanceof Object) {
56
+ (message as { loggerName?: string }).loggerName = loggerName;
57
+ loggerFunction(message, ...optionalParams);
58
58
  return;
59
59
  }
60
- loggerFunction(`${loggerName} ${message}`, optionalParams);
60
+ loggerFunction(`${loggerName} : ${message}`, ...optionalParams);
61
61
  };
62
62
  }
63
63
 
@@ -68,10 +68,10 @@ export default function getLogger(loggerName: string): Logger {
68
68
  if (debugEnabled) {
69
69
  return {
70
70
  trace: () => {},
71
- debug: wrapWithLoggerName(loggerName, globalThis.defaultLogger.debug),
72
- info: wrapWithLoggerName(loggerName, globalThis.defaultLogger.info),
73
- warn: wrapWithLoggerName(loggerName, globalThis.defaultLogger.warn),
74
- error: wrapWithLoggerName(loggerName, globalThis.defaultLogger.error),
71
+ debug: wrapDefaultLogger(loggerName, globalThis.defaultLogger.debug),
72
+ info: wrapDefaultLogger(loggerName, globalThis.defaultLogger.info),
73
+ warn: wrapDefaultLogger(loggerName, globalThis.defaultLogger.warn),
74
+ error: wrapDefaultLogger(loggerName, globalThis.defaultLogger.error),
75
75
  };
76
76
  }
77
77
  return {
@@ -79,6 +79,6 @@ export default function getLogger(loggerName: string): Logger {
79
79
  debug: () => {},
80
80
  info: () => {},
81
81
  warn: () => {},
82
- error: wrapWithLoggerName(loggerName, globalThis.defaultLogger.error),
82
+ error: wrapDefaultLogger(loggerName, globalThis.defaultLogger.error),
83
83
  };
84
84
  }
@@ -26,7 +26,7 @@ import { expectStringEquals, expectStringIncludes } from "../fixtures/util.ts";
26
26
  import TtyTerminal from "../../src/service/printer/terminal/TtyTerminal.ts";
27
27
  import TtyStyler from "../../src/service/printer/terminal/TtyStyler.ts";
28
28
 
29
- describe("BaseCLI Tests", () => {
29
+ describe("BaseCLI tests", () => {
30
30
  test("BaseCLI no command specified works", async () => {
31
31
  const config = getCLIConfig();
32
32
  const dummyStdout = new StreamString();
@@ -19,7 +19,7 @@ import type GroupCommand from "../../src/api/command/GroupCommand.ts";
19
19
  import { ArgumentValueTypeName } from "../../src/api/argument/ArgumentValueTypes.ts";
20
20
  import StreamString from "../fixtures/StreamString.ts";
21
21
 
22
- describe("MultiCommandCliHelpCommand Tests", () => {
22
+ describe("MultiCommandCliHelpCommand tests", () => {
23
23
  test("MultiCommandCliHelpGlobalCommand works", async () => {
24
24
  const streamString = new StreamString();
25
25
  const context = getContext(streamString);
@@ -16,7 +16,7 @@ import { SingleCommandCliHelpGlobalCommand } from "../../src/command/SingleComma
16
16
  import type SubCommand from "../../src/api/command/SubCommand.ts";
17
17
  import StreamString from "../fixtures/StreamString.ts";
18
18
 
19
- describe("SingleCommandCliHelpCommand Tests", () => {
19
+ describe("SingleCommandCliHelpCommand tests", () => {
20
20
  test("Ensure single command CLI with simple default command help is rendered correctly: simple default command", async () => {
21
21
  const streamString = new StreamString();
22
22
  const context = getContext(streamString);
@@ -12,7 +12,7 @@ import { expectStringEquals } from "../fixtures/util.ts";
12
12
  import TtyTerminal from "../../src/service/printer/terminal/TtyTerminal.ts";
13
13
  import TtyStyler from "../../src/service/printer/terminal/TtyStyler.ts";
14
14
 
15
- describe("UsageCommand Tests", () => {
15
+ describe("UsageCommand tests", () => {
16
16
  test("Usage works", async () => {
17
17
  const dummyStdout = new StreamString();
18
18
  const dummyStderr = new StreamString();
@@ -9,7 +9,7 @@ import { expectStringEquals } from "../fixtures/util.ts";
9
9
  import TtyTerminal from "../../src/service/printer/terminal/TtyTerminal.ts";
10
10
  import TtyStyler from "../../src/service/printer/terminal/TtyStyler.ts";
11
11
 
12
- describe("VersionCommand Tests", () => {
12
+ describe("VersionCommand tests", () => {
13
13
  test("Version works", async () => {
14
14
  const dummyStdout = new StreamString();
15
15
  const dummyStderr = new StreamString();
@@ -2,7 +2,7 @@ import { describe, expect, test } from "bun:test";
2
2
  import DefaultContext from "../../src/runtime/DefaultContext.ts";
3
3
  import { getCLIConfig } from "../fixtures/CLIConfig.ts";
4
4
 
5
- describe("DefaultContext Tests", () => {
5
+ describe("DefaultContext tests", () => {
6
6
  test("Check for duplicate service ID", () => {
7
7
  const context = new DefaultContext(getCLIConfig());
8
8
 
@@ -39,7 +39,7 @@ function getGlobalCommandArgument(): GlobalCommandArgument {
39
39
  };
40
40
  }
41
41
 
42
- describe("ArgumentTypeGuards Tests", () => {
42
+ describe("ArgumentTypeGuards tests", () => {
43
43
  test("isComplexOption works", () => {
44
44
  expect(isComplexOption(getComplexOption())).toBeTrue();
45
45
  expect(isComplexOption(getOption())).toBeFalse();
@@ -12,7 +12,7 @@ import {
12
12
  isSubCommand,
13
13
  } from "../../../src/runtime/command/CommandTypeGuards.ts";
14
14
 
15
- describe("CommandTypeGuards Tests", () => {
15
+ describe("CommandTypeGuards tests", () => {
16
16
  test("isSubCommand works", () => {
17
17
  expect(isSubCommand(getSubCommandWithOption())).toBeTrue();
18
18
  expect(isSubCommand(getGroupCommand())).toBeFalse();
@@ -29,7 +29,7 @@ function getSubCommand(
29
29
  execute: async (): Promise<void> => {},
30
30
  };
31
31
  }
32
- describe("CommandValidator Tests", () => {
32
+ describe("CommandValidator tests", () => {
33
33
  test("SubCommand validation fails due to duplicate argument names", () => {
34
34
  let command = getSubCommand("command", [{
35
35
  name: "foo",
@@ -30,7 +30,7 @@ function expectParseResult(result: ParseResult, expected: ParseResult) {
30
30
  expect(result.invalidArguments).toEqual(expected.invalidArguments);
31
31
  }
32
32
 
33
- describe("parser Tests", () => {
33
+ describe("parser tests", () => {
34
34
  test("Arguments parsed for sub-command", () => {
35
35
  const subCommand = getSubCommandWithOptionAndPositional();
36
36
 
@@ -22,7 +22,7 @@ function getSubCommand(
22
22
  execute: async (): Promise<void> => {},
23
23
  };
24
24
  }
25
- describe("DefaultCommandRegistry Tests", () => {
25
+ describe("DefaultCommandRegistry tests", () => {
26
26
  test("Check for duplicate non-global command name", () => {
27
27
  const command1 = getSubCommand("c1", [], []);
28
28
  const command2 = getSubCommand("c1", [], []);
@@ -26,7 +26,7 @@ function getServiceProvider(
26
26
  };
27
27
  }
28
28
 
29
- describe("DefaultServiceProviderRegistry Tests", () => {
29
+ describe("DefaultServiceProviderRegistry tests", () => {
30
30
  test("Check for ordering of service providers", () => {
31
31
  const serviceProvider1 = getServiceProvider("foo1", 1);
32
32
  const serviceProvider2 = getServiceProvider("foo2", 2);
@@ -22,7 +22,7 @@ import {
22
22
  } from "../../src/api/argument/ArgumentValueTypes.ts";
23
23
  import WritableStreamString from "../fixtures/StreamString.ts";
24
24
  import StreamString from "../fixtures/StreamString.ts";
25
- describe("runner Tests", () => {
25
+ describe("runner tests", () => {
26
26
  test("Sub-Command run", async () => {
27
27
  let hasRun = false;
28
28
 
@@ -30,7 +30,7 @@ function expectScanResult(result: ScanResult, expected: ScanResult) {
30
30
  expected.globalModifierCommandClauses!,
31
31
  );
32
32
  }
33
- describe("scanner Tests", () => {
33
+ describe("scanner tests", () => {
34
34
  test("Global modifier command scanned", () => {
35
35
  const globalModifierCommand = getGlobalModifierCommand(
36
36
  "modifier",
@@ -2,7 +2,7 @@ import { describe, expect, test } from "bun:test";
2
2
  import argumentValueMerge from "../../../src/runtime/values/argumentValueMerge.ts";
3
3
  import { MAXIMUM_ARGUMENT_ARRAY_SIZE } from "../../../src/api/argument/SubCommandArgument.ts";
4
4
 
5
- describe("argumentValueMerge Tests", () => {
5
+ describe("argumentValueMerge tests", () => {
6
6
  test("One layer merge", () => {
7
7
  let result = argumentValueMerge({ a: 1 }, { b: 2 });
8
8
  expect(result).toEqual({ a: 1, b: 2 });
@@ -19,7 +19,7 @@ import type Positional from "../../../src/api/argument/Positional.ts";
19
19
  import type GlobalCommandArgument from "../../../src/api/argument/GlobalCommandArgument.ts";
20
20
  import type Option from "../../../src/api/argument/Option.ts";
21
21
 
22
- describe("argumentValueValidation Tests", () => {
22
+ describe("argumentValueValidation tests", () => {
23
23
  test("Option types", () => {
24
24
  let option: Option = {
25
25
  name: "foo",
@@ -17,7 +17,7 @@ function expectExtractResult(
17
17
  expect(result.unusedArgs).toEqual(unusedArgs);
18
18
  }
19
19
 
20
- describe("globalCommandValuePopulation Tests", () => {
20
+ describe("globalCommandValuePopulation tests", () => {
21
21
  test("Global command argument", () => {
22
22
  const command: GlobalCommand = {
23
23
  name: "foo",
@@ -18,7 +18,7 @@ function expectExtractResult(
18
18
  expect(result.populatedArgumentValues).toEqual(values);
19
19
  expect(result.unusedArgs).toEqual(unusedArgs);
20
20
  }
21
- describe("subCommandValuePopulation Tests", () => {
21
+ describe("subCommandValuePopulation tests", () => {
22
22
  test("Option argument", () => {
23
23
  const command: SubCommand = {
24
24
  name: "command",
@@ -3,7 +3,7 @@ import DefaultContext from "../../../src/runtime/DefaultContext.ts";
3
3
  import { getCLIConfig } from "../../fixtures/CLIConfig.ts";
4
4
  import AsciiBannerGeneratorServiceProvider from "../../../src/service/asciiBannerGenerator/AsciiBannerGeneratorServiceProvider.ts";
5
5
 
6
- describe("AsciiBannerGeneratorServiceProvider Tests", () => {
6
+ describe("AsciiBannerGeneratorServiceProvider tests", () => {
7
7
  test("AsciiBannerGeneratorServiceProvider provide and initService works", async () => {
8
8
  const asciiBannerGeneratorServiceProvider =
9
9
  new AsciiBannerGeneratorServiceProvider(
@@ -3,7 +3,7 @@ import DefaultAsciiBannerGeneratorService from "../../../src/service/asciiBanner
3
3
 
4
4
  // FIGlet font is converted to a JSON string and embedded in a simple JSON file: `{ "font": "<figlet font definition>" }`
5
5
  import smallFont from "./small.flf.json" with { type: "json" };
6
- describe("DefaultAsciiBannerGeneratorService Tests", () => {
6
+ describe("DefaultAsciiBannerGeneratorService tests", () => {
7
7
  test("standard font registered by default", () => {
8
8
  const asciiBannerGeneratorService =
9
9
  new DefaultAsciiBannerGeneratorService();
@@ -20,3 +20,24 @@ exports[`DefaultAsciiBannerGeneratorService Tests Can generate with newly regist
20
20
 
21
21
  "
22
22
  `;
23
+
24
+ exports[`DefaultAsciiBannerGeneratorService tests Can generate with standard font 1`] = `
25
+ "
26
+ __
27
+ / _| ___ ___
28
+ | |_ / _ \\ / _ \\
29
+ | _| (_) | (_) |
30
+ |_| \\___/ \\___/
31
+
32
+ "
33
+ `;
34
+
35
+ exports[`DefaultAsciiBannerGeneratorService tests Can generate with newly registered font 1`] = `
36
+ "
37
+ __
38
+ / _|___ ___
39
+ | _/ _ \\/ _ \\
40
+ |_| \\___/\\___/
41
+
42
+ "
43
+ `;
@@ -60,7 +60,7 @@ function getSubCommand(): SubCommand {
60
60
  execute: async (): Promise<void> => {},
61
61
  };
62
62
  }
63
- describe("ConfigurationServiceProvider Tests", () => {
63
+ describe("ConfigurationServiceProvider tests", () => {
64
64
  test("ConfigurationServiceProvider provide works", async () => {
65
65
  const configurationServiceProvider = new ConfigurationServiceProvider(
66
66
  100,
@@ -1,7 +1,7 @@
1
1
  import { describe, expect, test } from "bun:test";
2
2
  import DefaultKeyValueService from "../../../src/service/configuration/DefaultKeyValueService.ts";
3
3
 
4
- describe("DefaultKeyValueService Tests", () => {
4
+ describe("DefaultKeyValueService tests", () => {
5
5
  test("Setting data works", () => {
6
6
  const keyValueService = new DefaultKeyValueService();
7
7
 
@@ -10,7 +10,7 @@ import TtyTerminal from "../../../src/service/printer/terminal/TtyTerminal.ts";
10
10
  import StreamString from "../../fixtures/StreamString.ts";
11
11
  import TtyStyler from "../../../src/service/printer/terminal/TtyStyler.ts";
12
12
 
13
- describe("BannerServiceProvider Tests", () => {
13
+ describe("BannerServiceProvider tests", () => {
14
14
  test("BannerServiceProvider provide works", async () => {
15
15
  const bannerServiceProvider = new BannerServiceProvider(100);
16
16
  const serviceInfo = await bannerServiceProvider.provide(getCLIConfig());
@@ -1,3 +1,5 @@
1
1
  // Bun Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`BannerServiceProvider Tests BannerServiceProvider initService works 1`] = `""`;
4
+
5
+ exports[`BannerServiceProvider tests BannerServiceProvider initService works 1`] = `""`;
@@ -4,7 +4,7 @@ import DefaultContext from "../../../../src/runtime/DefaultContext.ts";
4
4
  import { getCLIConfig } from "../../../fixtures/CLIConfig.ts";
5
5
  import BannerServiceProvider from "../../../../src/service/banner/BannerServiceProvider.ts";
6
6
 
7
- describe("NoBannerCommand Tests", () => {
7
+ describe("NoBannerCommand tests", () => {
8
8
  test("No banner works", async () => {
9
9
  const bannerServiceProvider = new BannerServiceProvider(100);
10
10
  const noBannerCommand = new NoBannerCommand(bannerServiceProvider, 110);
@@ -12,7 +12,7 @@ import TtyTerminal from "../../../src/service/printer/terminal/TtyTerminal.ts";
12
12
  import TtyStyler from "../../../src/service/printer/terminal/TtyStyler.ts";
13
13
  import StreamString from "../../fixtures/StreamString.ts";
14
14
 
15
- describe("DefaultPrinterService Tests", () => {
15
+ describe("DefaultPrinterService tests", () => {
16
16
  test("Color disabled works", async () => {
17
17
  const dummyStdout = new StreamString();
18
18
  const dummyStderr = new StreamString();
@@ -7,7 +7,7 @@ import DefaultShutdownService from "../../../src/service/shutdown/DefaultShutdow
7
7
  import TtyTerminal from "../../../src/service/printer/terminal/TtyTerminal.ts";
8
8
  import StreamString from "../../fixtures/StreamString.ts";
9
9
 
10
- describe("PrinterServiceProvider Tests", () => {
10
+ describe("PrinterServiceProvider tests", () => {
11
11
  test("PrinterServiceProvider provide works", async () => {
12
12
  const streamString = new StreamString();
13
13
  const printerServiceProvider = new PrinterServiceProvider(
@@ -11,7 +11,7 @@ import StreamString from "../../../fixtures/StreamString.ts";
11
11
  import DefaultPrinterService from "../../../../src/service/printer/DefaultPrinterService.ts";
12
12
  import TtyStyler from "../../../../src/service/printer/terminal/TtyStyler.ts";
13
13
 
14
- describe("LogLevelCommand Tests", () => {
14
+ describe("LogLevelCommand tests", () => {
15
15
  test("LogLevelCommand works", async () => {
16
16
  const streamString = new StreamString();
17
17
  const printerService = new DefaultPrinterService(
@@ -5,7 +5,7 @@ import TtyTerminal from "../../../../src/service/printer/terminal/TtyTerminal.ts
5
5
  import StreamString from "../../../fixtures/StreamString.ts";
6
6
  import TtyStyler from "../../../../src/service/printer/terminal/TtyStyler.ts";
7
7
 
8
- describe("Progress Tests", () => {
8
+ describe("Progress tests", () => {
9
9
  test("Progress works", async () => {
10
10
  const streamString = new StreamString();
11
11
  const terminal = new TtyTerminal(streamString.writeStream);
@@ -9,7 +9,7 @@ import TtyTerminal from "../../../../src/service/printer/terminal/TtyTerminal.ts
9
9
  import StreamString from "../../../fixtures/StreamString.ts";
10
10
  import TtyStyler from "../../../../src/service/printer/terminal/TtyStyler.ts";
11
11
 
12
- describe("Spinner Tests", () => {
12
+ describe("Spinner tests", () => {
13
13
  test("Spinner works", async () => {
14
14
  const streamString = new StreamString();
15
15
  const terminal = new TtyTerminal(streamString.writeStream);
@@ -2,7 +2,7 @@ import { describe, expect, test } from "bun:test";
2
2
  import ShutdownServiceProvider from "../../../src/service/shutdown/ShutdownServiceProvider.ts";
3
3
  import { getCLIConfig } from "../../fixtures/CLIConfig.ts";
4
4
 
5
- describe("ShutdownServiceProvider Tests", () => {
5
+ describe("ShutdownServiceProvider tests", () => {
6
6
  test("ShutdownServiceProvider provide works", async () => {
7
7
  const shutdownServiceProvider = new ShutdownServiceProvider(100);
8
8
  const serviceInfo = await shutdownServiceProvider.provide(getCLIConfig());
@@ -3,7 +3,7 @@ import { expectBytesEquals } from "../../fixtures/util.ts";
3
3
  import DefaultSyntaxHighlighterService from "../../../src/service/syntaxHighlighter/DefaultSyntaxHighlighterService.ts";
4
4
  import yaml from "highlight.js/lib/languages/yaml";
5
5
 
6
- describe("DefaultSyntaxHighlighterService Tests", () => {
6
+ describe("DefaultSyntaxHighlighterService tests", () => {
7
7
  test("JSON registered by default", () => {
8
8
  const syntaxHighlighterService = new DefaultSyntaxHighlighterService();
9
9
 
@@ -8,7 +8,7 @@ import StreamString from "../../fixtures/StreamString.ts";
8
8
  import TtyTerminal from "../../../src/service/printer/terminal/TtyTerminal.ts";
9
9
  import TtyStyler from "../../../src/service/printer/terminal/TtyStyler.ts";
10
10
 
11
- describe("SyntaxHighlighterServiceProvider Tests", () => {
11
+ describe("SyntaxHighlighterServiceProvider tests", () => {
12
12
  test("SyntaxHighlighterServiceProvider provide and initService works", async () => {
13
13
  const dummyStdout = new StreamString();
14
14
  const dummyStderr = new StreamString();
@@ -15,7 +15,7 @@ import type ComplexOption from "../../src/api/argument/ComplexOption.ts";
15
15
  import type Option from "../../src/api/argument/Option.ts";
16
16
  import type SubCommandArgument from "../../src/api/argument/SubCommandArgument.ts";
17
17
 
18
- describe("configHelper Tests", () => {
18
+ describe("configHelper tests", () => {
19
19
  test("getConfigurationKey works for global argument", () => {
20
20
  let command = getGlobalCommand("blah", true);
21
21
 
@@ -14,7 +14,7 @@ import {
14
14
  } from "../../src/util/envVarHelper.ts";
15
15
  import { ArgumentValueTypeName } from "../../src/api/argument/ArgumentValueTypes.ts";
16
16
 
17
- describe("envVarHelper Tests", () => {
17
+ describe("envVarHelper tests", () => {
18
18
  test("getGlobalCommandValuesFromEnvVars works", () => {
19
19
  try {
20
20
  let command = getGlobalCommand("blah", true);
@@ -1,10 +1,34 @@
1
1
  import { describe, test } from "bun:test";
2
2
  import getLogger from "../../src/util/logger.ts";
3
3
 
4
- describe("logger Tests", () => {
4
+ describe("logger tests", () => {
5
5
  test("Can acquire a logger", () => {
6
6
  const logger = getLogger("logger test");
7
7
 
8
8
  logger.debug("foobar");
9
9
  });
10
+
11
+ test("Log a string at error level", () => {
12
+ const logger = getLogger("logger test");
13
+
14
+ logger.error("foobar");
15
+ });
16
+
17
+ test("Log an object at error level", () => {
18
+ const logger = getLogger("logger test");
19
+
20
+ logger.error({ foo: "bar" });
21
+ });
22
+
23
+ test("Log result of a function at error level", () => {
24
+ const logger = getLogger("logger test");
25
+
26
+ logger.error(() => "foobar");
27
+ });
28
+
29
+ test("Log a string with formatted args at error level", () => {
30
+ const logger = getLogger("logger test");
31
+
32
+ logger.error("foo: %s %O", "bar", { foo1: "bar1", func: () => "foobar" });
33
+ });
10
34
  });