bob-core 1.2.0 → 1.2.1

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 (95) hide show
  1. package/dist/cjs/{Cli.d.ts → src/Cli.d.ts} +4 -4
  2. package/dist/cjs/{Cli.js → src/Cli.js} +3 -3
  3. package/dist/{esm → cjs/src}/Command.d.ts +2 -2
  4. package/dist/cjs/{Command.js → src/Command.js} +2 -2
  5. package/dist/cjs/{Command.test.js → src/Command.test.js} +2 -2
  6. package/dist/{esm → cjs/src}/CommandParser.d.ts +1 -1
  7. package/dist/cjs/{CommandParser.js → src/CommandParser.js} +4 -4
  8. package/dist/cjs/{CommandParser.test.js → src/CommandParser.test.js} +2 -2
  9. package/dist/cjs/{CommandRegistry.d.ts → src/CommandRegistry.d.ts} +1 -1
  10. package/dist/cjs/{CommandRegistry.js → src/CommandRegistry.js} +1 -1
  11. package/dist/cjs/{ExceptionHandler.d.ts → src/ExceptionHandler.d.ts} +1 -1
  12. package/dist/cjs/{ExceptionHandler.js → src/ExceptionHandler.js} +1 -1
  13. package/dist/{esm → cjs/src}/commands/HelpCommand.d.ts +2 -2
  14. package/dist/cjs/src/commands/HelpCommand.js +90 -0
  15. package/dist/{esm → cjs/src}/errors/BadCommandOption.d.ts +1 -1
  16. package/dist/cjs/{errors → src/errors}/BadCommandOption.js +1 -1
  17. package/dist/cjs/{errors → src/errors}/BadCommandParameter.d.ts +1 -1
  18. package/dist/cjs/{errors → src/errors}/BadCommandParameter.js +1 -1
  19. package/dist/cjs/{errors → src/errors}/CommandNotFoundError.d.ts +1 -1
  20. package/dist/cjs/{errors → src/errors}/CommandNotFoundError.js +1 -1
  21. package/dist/{esm → cjs/src}/errors/InvalidOption.d.ts +2 -2
  22. package/dist/cjs/{errors → src/errors}/InvalidOption.js +1 -1
  23. package/dist/cjs/{errors → src/errors}/MissingRequiredArgumentValue.d.ts +2 -2
  24. package/dist/cjs/{errors → src/errors}/MissingRequiredArgumentValue.js +1 -1
  25. package/dist/cjs/{errors → src/errors}/MissingSignatureArgument.d.ts +2 -2
  26. package/dist/cjs/{errors → src/errors}/MissingSignatureArgument.js +1 -1
  27. package/dist/cjs/{errors → src/errors}/MissingSignatureOption.d.ts +2 -2
  28. package/dist/cjs/{errors → src/errors}/MissingSignatureOption.js +1 -1
  29. package/dist/cjs/{options → src/options}/HelpOption.d.ts +2 -2
  30. package/dist/cjs/{options → src/options}/HelpOption.js +3 -4
  31. package/dist/esm/package.json +50 -0
  32. package/dist/esm/{Cli.d.ts → src/Cli.d.ts} +4 -4
  33. package/dist/esm/{Cli.js → src/Cli.js} +3 -3
  34. package/dist/{cjs → esm/src}/Command.d.ts +2 -2
  35. package/dist/esm/{Command.js → src/Command.js} +2 -2
  36. package/dist/esm/{Command.test.js → src/Command.test.js} +2 -2
  37. package/dist/{cjs → esm/src}/CommandParser.d.ts +1 -1
  38. package/dist/esm/{CommandParser.js → src/CommandParser.js} +4 -4
  39. package/dist/esm/{CommandParser.test.js → src/CommandParser.test.js} +2 -2
  40. package/dist/esm/{CommandRegistry.d.ts → src/CommandRegistry.d.ts} +1 -1
  41. package/dist/esm/{CommandRegistry.js → src/CommandRegistry.js} +1 -1
  42. package/dist/esm/{ExceptionHandler.d.ts → src/ExceptionHandler.d.ts} +1 -1
  43. package/dist/esm/{ExceptionHandler.js → src/ExceptionHandler.js} +1 -1
  44. package/dist/{cjs → esm/src}/commands/HelpCommand.d.ts +2 -2
  45. package/dist/esm/{commands → src/commands}/HelpCommand.js +8 -7
  46. package/dist/{cjs → esm/src}/errors/BadCommandOption.d.ts +1 -1
  47. package/dist/esm/{errors → src/errors}/BadCommandOption.js +1 -1
  48. package/dist/esm/{errors → src/errors}/BadCommandParameter.d.ts +1 -1
  49. package/dist/esm/{errors → src/errors}/BadCommandParameter.js +1 -1
  50. package/dist/esm/{errors → src/errors}/CommandNotFoundError.d.ts +1 -1
  51. package/dist/esm/{errors → src/errors}/CommandNotFoundError.js +1 -1
  52. package/dist/{cjs → esm/src}/errors/InvalidOption.d.ts +2 -2
  53. package/dist/esm/{errors → src/errors}/InvalidOption.js +1 -1
  54. package/dist/esm/{errors → src/errors}/MissingRequiredArgumentValue.d.ts +2 -2
  55. package/dist/esm/{errors → src/errors}/MissingRequiredArgumentValue.js +1 -1
  56. package/dist/esm/{errors → src/errors}/MissingSignatureArgument.d.ts +2 -2
  57. package/dist/esm/{errors → src/errors}/MissingSignatureArgument.js +1 -1
  58. package/dist/esm/{errors → src/errors}/MissingSignatureOption.d.ts +2 -2
  59. package/dist/esm/{errors → src/errors}/MissingSignatureOption.js +1 -1
  60. package/dist/esm/{options → src/options}/HelpOption.d.ts +2 -2
  61. package/dist/esm/{options → src/options}/HelpOption.js +3 -4
  62. package/package.json +7 -7
  63. package/dist/cjs/commands/HelpCommand.js +0 -56
  64. /package/dist/cjs/{Command.test.d.ts → src/Command.test.d.ts} +0 -0
  65. /package/dist/cjs/{CommandParser.test.d.ts → src/CommandParser.test.d.ts} +0 -0
  66. /package/dist/cjs/{contracts → src/contracts}/CommandOption.d.ts +0 -0
  67. /package/dist/cjs/{contracts → src/contracts}/CommandOption.js +0 -0
  68. /package/dist/cjs/{contracts → src/contracts}/index.d.ts +0 -0
  69. /package/dist/cjs/{contracts → src/contracts}/index.js +0 -0
  70. /package/dist/cjs/{errors → src/errors}/BobError.d.ts +0 -0
  71. /package/dist/cjs/{errors → src/errors}/BobError.js +0 -0
  72. /package/dist/cjs/{errors → src/errors}/index.d.ts +0 -0
  73. /package/dist/cjs/{errors → src/errors}/index.js +0 -0
  74. /package/dist/cjs/{index.d.ts → src/index.d.ts} +0 -0
  75. /package/dist/cjs/{index.js → src/index.js} +0 -0
  76. /package/dist/cjs/{lib → src/lib}/string.d.ts +0 -0
  77. /package/dist/cjs/{lib → src/lib}/string.js +0 -0
  78. /package/dist/cjs/{options → src/options}/index.d.ts +0 -0
  79. /package/dist/cjs/{options → src/options}/index.js +0 -0
  80. /package/dist/esm/{Command.test.d.ts → src/Command.test.d.ts} +0 -0
  81. /package/dist/esm/{CommandParser.test.d.ts → src/CommandParser.test.d.ts} +0 -0
  82. /package/dist/esm/{contracts → src/contracts}/CommandOption.d.ts +0 -0
  83. /package/dist/esm/{contracts → src/contracts}/CommandOption.js +0 -0
  84. /package/dist/esm/{contracts → src/contracts}/index.d.ts +0 -0
  85. /package/dist/esm/{contracts → src/contracts}/index.js +0 -0
  86. /package/dist/esm/{errors → src/errors}/BobError.d.ts +0 -0
  87. /package/dist/esm/{errors → src/errors}/BobError.js +0 -0
  88. /package/dist/esm/{errors → src/errors}/index.d.ts +0 -0
  89. /package/dist/esm/{errors → src/errors}/index.js +0 -0
  90. /package/dist/esm/{index.d.ts → src/index.d.ts} +0 -0
  91. /package/dist/esm/{index.js → src/index.js} +0 -0
  92. /package/dist/esm/{lib → src/lib}/string.d.ts +0 -0
  93. /package/dist/esm/{lib → src/lib}/string.js +0 -0
  94. /package/dist/esm/{options → src/options}/index.d.ts +0 -0
  95. /package/dist/esm/{options → src/options}/index.js +0 -0
@@ -1,7 +1,7 @@
1
- import { CommandRegistry } from "@/src/CommandRegistry.js";
2
- import { Command } from "@/src/Command.js";
3
- import HelpCommand from "@/src/commands/HelpCommand.js";
4
- import { ExceptionHandler } from "@/src/ExceptionHandler.js";
1
+ import { CommandRegistry } from "./CommandRegistry.js";
2
+ import { Command } from "./Command.js";
3
+ import HelpCommand from "./commands/HelpCommand.js";
4
+ import { ExceptionHandler } from "./ExceptionHandler.js";
5
5
  export type CliOptions<C> = {
6
6
  ctx?: C;
7
7
  name?: string;
@@ -4,9 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Cli = void 0;
7
- const CommandRegistry_js_1 = require("@/src/CommandRegistry.js");
8
- const HelpCommand_js_1 = __importDefault(require("@/src/commands/HelpCommand.js"));
9
- const ExceptionHandler_js_1 = require("@/src/ExceptionHandler.js");
7
+ const CommandRegistry_js_1 = require("./CommandRegistry.js");
8
+ const HelpCommand_js_1 = __importDefault(require("./commands/HelpCommand.js"));
9
+ const ExceptionHandler_js_1 = require("./ExceptionHandler.js");
10
10
  class Cli {
11
11
  commandRegistry;
12
12
  exceptionHandler;
@@ -1,5 +1,5 @@
1
- import { CommandParser } from "@/src/CommandParser.js";
2
- import { CommandOption } from "@/src/contracts/index.js";
1
+ import { CommandParser } from "./CommandParser.js";
2
+ import { CommandOption } from "./contracts/index.js";
3
3
  export type CommandExample = {
4
4
  description: string;
5
5
  command: string;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Command = void 0;
4
- const CommandParser_js_1 = require("@/src/CommandParser.js");
5
- const index_js_1 = require("@/src/options/index.js");
4
+ const CommandParser_js_1 = require("./CommandParser.js");
5
+ const index_js_1 = require("./options/index.js");
6
6
  class Command {
7
7
  ctx;
8
8
  helperDefinitions = {};
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const Command_js_1 = require("@/src/Command.js");
4
- const MissingRequiredArgumentValue_js_1 = require("@/src/errors/MissingRequiredArgumentValue.js");
3
+ const Command_js_1 = require("./Command.js");
4
+ const MissingRequiredArgumentValue_js_1 = require("./errors/MissingRequiredArgumentValue.js");
5
5
  class MockCommand extends Command_js_1.Command {
6
6
  signature = 'mockCommand {argument} {--option}';
7
7
  description = 'This is a mock command for testing';
@@ -1,4 +1,4 @@
1
- import { CommandOption } from "@/src/contracts/index.js";
1
+ import { CommandOption } from "./contracts/index.js";
2
2
  export type ArgSignature = {
3
3
  name: string;
4
4
  type: string;
@@ -5,10 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.CommandParser = void 0;
7
7
  const minimist_1 = __importDefault(require("minimist"));
8
- const MissingRequiredArgumentValue_js_1 = require("@/src/errors/MissingRequiredArgumentValue.js");
9
- const MissingSignatureOption_js_1 = require("@/src/errors/MissingSignatureOption.js");
10
- const MissingSignatureArgument_js_1 = require("@/src/errors/MissingSignatureArgument.js");
11
- const InvalidOption_js_1 = require("@/src/errors/InvalidOption.js");
8
+ const MissingRequiredArgumentValue_js_1 = require("./errors/MissingRequiredArgumentValue.js");
9
+ const MissingSignatureOption_js_1 = require("./errors/MissingSignatureOption.js");
10
+ const MissingSignatureArgument_js_1 = require("./errors/MissingSignatureArgument.js");
11
+ const InvalidOption_js_1 = require("./errors/InvalidOption.js");
12
12
  class CommandParser {
13
13
  signature;
14
14
  helperDefinitions;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const CommandParser_js_1 = require("@/src/CommandParser.js");
4
- const MissingRequiredArgumentValue_js_1 = require("@/src/errors/MissingRequiredArgumentValue.js");
3
+ const CommandParser_js_1 = require("./CommandParser.js");
4
+ const MissingRequiredArgumentValue_js_1 = require("./errors/MissingRequiredArgumentValue.js");
5
5
  class TestCommandOptions {
6
6
  option = 'testOption';
7
7
  description = 'Test option';
@@ -1,4 +1,4 @@
1
- import { Command } from "@/src/Command.js";
1
+ import { Command } from "./Command.js";
2
2
  export type CommandResolver = (path: string) => Promise<Command>;
3
3
  export declare class CommandRegistry {
4
4
  private readonly commands;
@@ -41,7 +41,7 @@ const fs = __importStar(require("node:fs"));
41
41
  const path_1 = __importDefault(require("path"));
42
42
  const SS = __importStar(require("string-similarity"));
43
43
  const chalk_1 = __importDefault(require("chalk"));
44
- const CommandNotFoundError_js_1 = require("@/src/errors/CommandNotFoundError.js");
44
+ const CommandNotFoundError_js_1 = require("./errors/CommandNotFoundError.js");
45
45
  class CommandRegistry {
46
46
  commands = {};
47
47
  get commandSuffix() {
@@ -1,4 +1,4 @@
1
- import { BobError } from "@/src/errors/index.js";
1
+ import { BobError } from "./errors/index.js";
2
2
  export declare class ExceptionHandler {
3
3
  handle(err: Error | BobError): number;
4
4
  }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ExceptionHandler = void 0;
4
- const index_js_1 = require("@/src/errors/index.js");
4
+ const index_js_1 = require("./errors/index.js");
5
5
  class ExceptionHandler {
6
6
  handle(err) {
7
7
  if (err instanceof index_js_1.BobError) {
@@ -1,5 +1,5 @@
1
- import { Command } from "@/src/Command.js";
2
- import { CommandRegistry } from "@/src/CommandRegistry.js";
1
+ import { Command } from "../Command.js";
2
+ import { CommandRegistry } from "../CommandRegistry.js";
3
3
  export type HelpCommandOptions = {
4
4
  commandRegistry: CommandRegistry;
5
5
  cliName?: string;
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ const chalk_1 = __importDefault(require("chalk"));
40
+ const Command_js_1 = require("../Command.js");
41
+ const string_js_1 = require("../lib/string.js");
42
+ class HelpCommand extends Command_js_1.Command {
43
+ opts;
44
+ signature = 'help';
45
+ description = 'Show help';
46
+ constructor(opts) {
47
+ super();
48
+ this.opts = opts;
49
+ }
50
+ async handle() {
51
+ const commands = this.opts.commandRegistry.getCommands();
52
+ const cliName = this.opts.cliName ?? 'Bob CLI';
53
+ const version = this.opts.cliVersion ?? '0.0.0';
54
+ const coreVersion = (await Promise.resolve().then(() => __importStar(require('../../package.json'))))?.default?.version ?? '0.0.0';
55
+ console.log((0, chalk_1.default) `${cliName} {green ${version}} (core: {yellow ${coreVersion}})
56
+
57
+ {yellow Usage}:
58
+ command [options] [arguments]
59
+
60
+ {yellow Available commands}:
61
+ `);
62
+ const maxCommandLength = Math.max(...commands.map(command => command.command.length)) ?? 0;
63
+ const commandByGroups = {};
64
+ for (const command of commands) {
65
+ const commandGroup = command.command.split(':')[0];
66
+ if (!commandByGroups[commandGroup]) {
67
+ commandByGroups[commandGroup] = [];
68
+ }
69
+ commandByGroups[commandGroup].push(command);
70
+ }
71
+ const sortedCommandsByGroups = Object.entries(commandByGroups)
72
+ .sort(([groupA], [groupB]) => groupA.toLowerCase().localeCompare(groupB.toLowerCase()))
73
+ .sort(([, commandsA], [, commandsB]) => commandsA.length - commandsB.length);
74
+ for (const [group, groupCommands] of sortedCommandsByGroups) {
75
+ const isGrouped = groupCommands.length > 1;
76
+ if (isGrouped) {
77
+ console.log((0, chalk_1.default) `{yellow ${group}}:`);
78
+ }
79
+ const sortedGroupCommands = groupCommands.sort((a, b) => a.command.toLowerCase().localeCompare(b.command.toLowerCase()));
80
+ for (const command of sortedGroupCommands) {
81
+ let spaces = (0, string_js_1.generateSpace)(maxCommandLength - command.command.length);
82
+ if (isGrouped) {
83
+ spaces = spaces.slice(2);
84
+ }
85
+ console.log((0, chalk_1.default) `${isGrouped ? ' ' : ''}{green ${command.command}} ${spaces} ${command.description}`);
86
+ }
87
+ }
88
+ }
89
+ }
90
+ exports.default = HelpCommand;
@@ -1,4 +1,4 @@
1
- import { BobError } from "@/src/errors/BobError.js";
1
+ import { BobError } from "../errors/BobError.js";
2
2
  export type OptionProps = {
3
3
  option: string;
4
4
  value?: string;
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.BadCommandOption = void 0;
7
7
  const chalk_1 = __importDefault(require("chalk"));
8
- const BobError_js_1 = require("@/src/errors/BobError.js");
8
+ const BobError_js_1 = require("../errors/BobError.js");
9
9
  class BadCommandOption extends BobError_js_1.BobError {
10
10
  param;
11
11
  constructor(param) {
@@ -1,4 +1,4 @@
1
- import { BobError } from "@/src/errors/BobError.js";
1
+ import { BobError } from "../errors/BobError.js";
2
2
  export type ParameterProps = {
3
3
  param: string;
4
4
  value?: string;
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.BadCommandParameter = void 0;
7
7
  const chalk_1 = __importDefault(require("chalk"));
8
- const BobError_js_1 = require("@/src/errors/BobError.js");
8
+ const BobError_js_1 = require("../errors/BobError.js");
9
9
  class BadCommandParameter extends BobError_js_1.BobError {
10
10
  param;
11
11
  constructor(param) {
@@ -1,4 +1,4 @@
1
- import { BobError } from "@/src/errors/BobError.js";
1
+ import { BobError } from "../errors/BobError.js";
2
2
  export declare class CommandNotFoundError extends BobError {
3
3
  readonly command: string;
4
4
  readonly similarCommands: string[];
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.CommandNotFoundError = void 0;
7
7
  const chalk_1 = __importDefault(require("chalk"));
8
- const BobError_js_1 = require("@/src/errors/BobError.js");
8
+ const BobError_js_1 = require("../errors/BobError.js");
9
9
  class CommandNotFoundError extends BobError_js_1.BobError {
10
10
  command;
11
11
  similarCommands;
@@ -1,5 +1,5 @@
1
- import { BobError } from "@/src/errors/BobError.js";
2
- import { ArgSignature } from "@/src/CommandParser.js";
1
+ import { BobError } from "../errors/BobError.js";
2
+ import { ArgSignature } from "../CommandParser.js";
3
3
  export declare class InvalidOption extends BobError {
4
4
  private option;
5
5
  private optionsSignature;
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.InvalidOption = void 0;
7
7
  const chalk_1 = __importDefault(require("chalk"));
8
- const BobError_js_1 = require("@/src/errors/BobError.js");
8
+ const BobError_js_1 = require("../errors/BobError.js");
9
9
  class InvalidOption extends BobError_js_1.BobError {
10
10
  option;
11
11
  optionsSignature;
@@ -1,5 +1,5 @@
1
- import { BobError } from "@/src/errors/BobError.js";
2
- import { ArgSignature } from "@/src/CommandParser.js";
1
+ import { BobError } from "../errors/BobError.js";
2
+ import { ArgSignature } from "../CommandParser.js";
3
3
  export declare class MissingRequiredArgumentValue extends BobError {
4
4
  readonly paramSignature: ArgSignature;
5
5
  constructor(paramSignature: ArgSignature);
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.MissingRequiredArgumentValue = void 0;
7
7
  const chalk_1 = __importDefault(require("chalk"));
8
- const BobError_js_1 = require("@/src/errors/BobError.js");
8
+ const BobError_js_1 = require("../errors/BobError.js");
9
9
  class MissingRequiredArgumentValue extends BobError_js_1.BobError {
10
10
  paramSignature;
11
11
  constructor(paramSignature) {
@@ -1,5 +1,5 @@
1
- import { BobError } from "@/src/errors/BobError.js";
2
- import { ArgSignature } from "@/src/CommandParser.js";
1
+ import { BobError } from "../errors/BobError.js";
2
+ import { ArgSignature } from "../CommandParser.js";
3
3
  export declare class MissingSignatureArgument extends BobError {
4
4
  private argument;
5
5
  private argumentSignatures;
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.MissingSignatureArgument = void 0;
7
7
  const chalk_1 = __importDefault(require("chalk"));
8
- const BobError_js_1 = require("@/src/errors/BobError.js");
8
+ const BobError_js_1 = require("../errors/BobError.js");
9
9
  class MissingSignatureArgument extends BobError_js_1.BobError {
10
10
  argument;
11
11
  argumentSignatures;
@@ -1,5 +1,5 @@
1
- import { BobError } from "@/src/errors/BobError.js";
2
- import { ArgSignature } from "@/src/CommandParser.js";
1
+ import { BobError } from "../errors/BobError.js";
2
+ import { ArgSignature } from "../CommandParser.js";
3
3
  export declare class MissingSignatureOption extends BobError {
4
4
  private option;
5
5
  private optionsSignature;
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.MissingSignatureOption = void 0;
7
7
  const chalk_1 = __importDefault(require("chalk"));
8
- const BobError_js_1 = require("@/src/errors/BobError.js");
8
+ const BobError_js_1 = require("../errors/BobError.js");
9
9
  class MissingSignatureOption extends BobError_js_1.BobError {
10
10
  option;
11
11
  optionsSignature;
@@ -1,5 +1,5 @@
1
- import { Command } from "@/src/Command.js";
2
- import { CommandOption } from "@/src/contracts/index.js";
1
+ import { Command } from "../Command.js";
2
+ import { CommandOption } from "../contracts/index.js";
3
3
  export declare class HelpOption implements CommandOption<Command> {
4
4
  option: string;
5
5
  alias: string[];
@@ -5,8 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.HelpOption = void 0;
7
7
  const chalk_1 = __importDefault(require("chalk"));
8
- const lodash_1 = require("lodash");
9
- const string_js_1 = require("@/src/lib/string.js");
8
+ const string_js_1 = require("../lib/string.js");
10
9
  class HelpOption {
11
10
  option = 'help';
12
11
  alias = ['h'];
@@ -25,8 +24,8 @@ class HelpOption {
25
24
  log((0, chalk_1.default) ` ${this.description}\n`);
26
25
  log((0, chalk_1.default) `{yellow Usage}:`);
27
26
  log((0, chalk_1.default) ` ${this.command} ${requiredArguments.length > 0 ? requiredArguments.map((signature) => `<${signature.name}>`).join(' ') : '\b'} [options]`);
28
- const maxOptionLength = (0, lodash_1.max)(availableOptions.map((signature) => signature.optionWithAlias.length)) ?? 0;
29
- const maxArgumentLength = (0, lodash_1.max)(availableArguments.map((arg) => arg.name.length)) ?? 0;
27
+ const maxOptionLength = Math.max(...availableOptions.map((signature) => signature.optionWithAlias.length)) ?? 0;
28
+ const maxArgumentLength = Math.max(...availableArguments.map((arg) => arg.name.length)) ?? 0;
30
29
  const maxLength = maxArgumentLength > maxOptionLength ? maxArgumentLength : maxOptionLength;
31
30
  if (availableArguments.length > 0) {
32
31
  log((0, chalk_1.default) `\n{yellow Arguments}:`);
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "bob-core",
3
+ "version": "1.2.1",
4
+ "description": "BOB Core",
5
+ "type": "module",
6
+ "files": [
7
+ "/dist"
8
+ ],
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/esm/index.js",
12
+ "require": "./dist/cjs/index.js"
13
+ }
14
+ },
15
+ "typesVersions": {
16
+ "*": {
17
+ "*": [
18
+ "./dist/cjs/index.d.ts"
19
+ ]
20
+ }
21
+ },
22
+ "scripts": {
23
+ "start": "node -r @swc-node/register debug/main.ts",
24
+ "build": "rimraf ./dist && npm run build:cjs && npm run build:esm",
25
+ "build:cjs": "tsc --project tsconfig.json --module commonjs --verbatimModuleSyntax false --moduleResolution node10 --outDir ./dist/cjs && tsc-alias -p tsconfig.json --outDir ./dist/cjs && echo >./dist/cjs/package.json '{\"type\":\"commonjs\"}'",
26
+ "build:esm": "tsc --project tsconfig.json --outDir ./dist/esm && tsc-alias -p tsconfig.json --outDir ./dist/esm",
27
+ "prepare": "npm run build",
28
+ "test": "jest"
29
+ },
30
+ "author": "Léo Hubert",
31
+ "license": "ISC",
32
+ "devDependencies": {
33
+ "@swc-node/register": "^1.11.1",
34
+ "@types/jest": "^29.5.12",
35
+ "@types/lodash": "^4.17.5",
36
+ "@types/minimist": "^1.2.5",
37
+ "@types/node": "^20.14.5",
38
+ "@types/string-similarity": "^4.0.2",
39
+ "jest": "^29.7.0",
40
+ "rimraf": "^6.0.1",
41
+ "ts-jest": "^29.1.5",
42
+ "tsc-alias": "^1.8.16",
43
+ "typescript": "^5.7.3"
44
+ },
45
+ "dependencies": {
46
+ "chalk": "^4.1.2",
47
+ "minimist": "^1.2.8",
48
+ "string-similarity": "^4.0.4"
49
+ }
50
+ }
@@ -1,7 +1,7 @@
1
- import { CommandRegistry } from "@/src/CommandRegistry.js";
2
- import { Command } from "@/src/Command.js";
3
- import HelpCommand from "@/src/commands/HelpCommand.js";
4
- import { ExceptionHandler } from "@/src/ExceptionHandler.js";
1
+ import { CommandRegistry } from "./CommandRegistry.js";
2
+ import { Command } from "./Command.js";
3
+ import HelpCommand from "./commands/HelpCommand.js";
4
+ import { ExceptionHandler } from "./ExceptionHandler.js";
5
5
  export type CliOptions<C> = {
6
6
  ctx?: C;
7
7
  name?: string;
@@ -1,6 +1,6 @@
1
- import { CommandRegistry } from "@/src/CommandRegistry.js";
2
- import HelpCommand from "@/src/commands/HelpCommand.js";
3
- import { ExceptionHandler } from "@/src/ExceptionHandler.js";
1
+ import { CommandRegistry } from "./CommandRegistry.js";
2
+ import HelpCommand from "./commands/HelpCommand.js";
3
+ import { ExceptionHandler } from "./ExceptionHandler.js";
4
4
  export class Cli {
5
5
  commandRegistry;
6
6
  exceptionHandler;
@@ -1,5 +1,5 @@
1
- import { CommandParser } from "@/src/CommandParser.js";
2
- import { CommandOption } from "@/src/contracts/index.js";
1
+ import { CommandParser } from "./CommandParser.js";
2
+ import { CommandOption } from "./contracts/index.js";
3
3
  export type CommandExample = {
4
4
  description: string;
5
5
  command: string;
@@ -1,5 +1,5 @@
1
- import { CommandParser } from "@/src/CommandParser.js";
2
- import { HelpOption } from "@/src/options/index.js";
1
+ import { CommandParser } from "./CommandParser.js";
2
+ import { HelpOption } from "./options/index.js";
3
3
  export class Command {
4
4
  ctx;
5
5
  helperDefinitions = {};
@@ -1,5 +1,5 @@
1
- import { Command } from '@/src/Command.js';
2
- import { MissingRequiredArgumentValue } from "@/src/errors/MissingRequiredArgumentValue.js";
1
+ import { Command } from './Command.js';
2
+ import { MissingRequiredArgumentValue } from "./errors/MissingRequiredArgumentValue.js";
3
3
  class MockCommand extends Command {
4
4
  signature = 'mockCommand {argument} {--option}';
5
5
  description = 'This is a mock command for testing';
@@ -1,4 +1,4 @@
1
- import { CommandOption } from "@/src/contracts/index.js";
1
+ import { CommandOption } from "./contracts/index.js";
2
2
  export type ArgSignature = {
3
3
  name: string;
4
4
  type: string;
@@ -1,8 +1,8 @@
1
1
  import minimist from 'minimist';
2
- import { MissingRequiredArgumentValue } from "@/src/errors/MissingRequiredArgumentValue.js";
3
- import { MissingSignatureOption } from "@/src/errors/MissingSignatureOption.js";
4
- import { MissingSignatureArgument } from "@/src/errors/MissingSignatureArgument.js";
5
- import { InvalidOption } from "@/src/errors/InvalidOption.js";
2
+ import { MissingRequiredArgumentValue } from "./errors/MissingRequiredArgumentValue.js";
3
+ import { MissingSignatureOption } from "./errors/MissingSignatureOption.js";
4
+ import { MissingSignatureArgument } from "./errors/MissingSignatureArgument.js";
5
+ import { InvalidOption } from "./errors/InvalidOption.js";
6
6
  export class CommandParser {
7
7
  signature;
8
8
  helperDefinitions;
@@ -1,5 +1,5 @@
1
- import { CommandParser } from '@/src/CommandParser.js';
2
- import { MissingRequiredArgumentValue } from "@/src/errors/MissingRequiredArgumentValue.js";
1
+ import { CommandParser } from './CommandParser.js';
2
+ import { MissingRequiredArgumentValue } from "./errors/MissingRequiredArgumentValue.js";
3
3
  class TestCommandOptions {
4
4
  option = 'testOption';
5
5
  description = 'Test option';
@@ -1,4 +1,4 @@
1
- import { Command } from "@/src/Command.js";
1
+ import { Command } from "./Command.js";
2
2
  export type CommandResolver = (path: string) => Promise<Command>;
3
3
  export declare class CommandRegistry {
4
4
  private readonly commands;
@@ -2,7 +2,7 @@ import * as fs from "node:fs";
2
2
  import path from "path";
3
3
  import * as SS from "string-similarity";
4
4
  import chalk from "chalk";
5
- import { CommandNotFoundError } from "@/src/errors/CommandNotFoundError.js";
5
+ import { CommandNotFoundError } from "./errors/CommandNotFoundError.js";
6
6
  export class CommandRegistry {
7
7
  commands = {};
8
8
  get commandSuffix() {
@@ -1,4 +1,4 @@
1
- import { BobError } from "@/src/errors/index.js";
1
+ import { BobError } from "./errors/index.js";
2
2
  export declare class ExceptionHandler {
3
3
  handle(err: Error | BobError): number;
4
4
  }
@@ -1,4 +1,4 @@
1
- import { BobError } from "@/src/errors/index.js";
1
+ import { BobError } from "./errors/index.js";
2
2
  export class ExceptionHandler {
3
3
  handle(err) {
4
4
  if (err instanceof BobError) {
@@ -1,5 +1,5 @@
1
- import { Command } from "@/src/Command.js";
2
- import { CommandRegistry } from "@/src/CommandRegistry.js";
1
+ import { Command } from "../Command.js";
2
+ import { CommandRegistry } from "../CommandRegistry.js";
3
3
  export type HelpCommandOptions = {
4
4
  commandRegistry: CommandRegistry;
5
5
  cliName?: string;
@@ -1,7 +1,6 @@
1
1
  import chalk from "chalk";
2
- import { max, orderBy } from "lodash";
3
- import { Command } from "@/src/Command.js";
4
- import { generateSpace } from "@/src/lib/string.js";
2
+ import { Command } from "../Command.js";
3
+ import { generateSpace } from "../lib/string.js";
5
4
  export default class HelpCommand extends Command {
6
5
  opts;
7
6
  signature = 'help';
@@ -14,7 +13,7 @@ export default class HelpCommand extends Command {
14
13
  const commands = this.opts.commandRegistry.getCommands();
15
14
  const cliName = this.opts.cliName ?? 'Bob CLI';
16
15
  const version = this.opts.cliVersion ?? '0.0.0';
17
- const coreVersion = require('../../package.json').version;
16
+ const coreVersion = (await import('../../package.json'))?.default?.version ?? '0.0.0';
18
17
  console.log(chalk `${cliName} {green ${version}} (core: {yellow ${coreVersion}})
19
18
 
20
19
  {yellow Usage}:
@@ -22,7 +21,7 @@ export default class HelpCommand extends Command {
22
21
 
23
22
  {yellow Available commands}:
24
23
  `);
25
- const maxCommandLength = max(commands.map(command => command.command.length)) ?? 0;
24
+ const maxCommandLength = Math.max(...commands.map(command => command.command.length)) ?? 0;
26
25
  const commandByGroups = {};
27
26
  for (const command of commands) {
28
27
  const commandGroup = command.command.split(':')[0];
@@ -31,13 +30,15 @@ export default class HelpCommand extends Command {
31
30
  }
32
31
  commandByGroups[commandGroup].push(command);
33
32
  }
34
- const sortedCommandsByGroups = orderBy(orderBy(Object.entries(commandByGroups), [([group]) => group.toLowerCase()], ['asc']), [([_, commands]) => commands.length], ['asc']);
33
+ const sortedCommandsByGroups = Object.entries(commandByGroups)
34
+ .sort(([groupA], [groupB]) => groupA.toLowerCase().localeCompare(groupB.toLowerCase()))
35
+ .sort(([, commandsA], [, commandsB]) => commandsA.length - commandsB.length);
35
36
  for (const [group, groupCommands] of sortedCommandsByGroups) {
36
37
  const isGrouped = groupCommands.length > 1;
37
38
  if (isGrouped) {
38
39
  console.log(chalk `{yellow ${group}}:`);
39
40
  }
40
- const sortedGroupCommands = orderBy(groupCommands, [command => command.command.toLowerCase()], ['asc']);
41
+ const sortedGroupCommands = groupCommands.sort((a, b) => a.command.toLowerCase().localeCompare(b.command.toLowerCase()));
41
42
  for (const command of sortedGroupCommands) {
42
43
  let spaces = generateSpace(maxCommandLength - command.command.length);
43
44
  if (isGrouped) {
@@ -1,4 +1,4 @@
1
- import { BobError } from "@/src/errors/BobError.js";
1
+ import { BobError } from "../errors/BobError.js";
2
2
  export type OptionProps = {
3
3
  option: string;
4
4
  value?: string;
@@ -1,5 +1,5 @@
1
1
  import chalk from "chalk";
2
- import { BobError } from "@/src/errors/BobError.js";
2
+ import { BobError } from "../errors/BobError.js";
3
3
  export class BadCommandOption extends BobError {
4
4
  param;
5
5
  constructor(param) {
@@ -1,4 +1,4 @@
1
- import { BobError } from "@/src/errors/BobError.js";
1
+ import { BobError } from "../errors/BobError.js";
2
2
  export type ParameterProps = {
3
3
  param: string;
4
4
  value?: string;
@@ -1,5 +1,5 @@
1
1
  import chalk from "chalk";
2
- import { BobError } from "@/src/errors/BobError.js";
2
+ import { BobError } from "../errors/BobError.js";
3
3
  export class BadCommandParameter extends BobError {
4
4
  param;
5
5
  constructor(param) {
@@ -1,4 +1,4 @@
1
- import { BobError } from "@/src/errors/BobError.js";
1
+ import { BobError } from "../errors/BobError.js";
2
2
  export declare class CommandNotFoundError extends BobError {
3
3
  readonly command: string;
4
4
  readonly similarCommands: string[];
@@ -1,5 +1,5 @@
1
1
  import chalk from "chalk";
2
- import { BobError } from "@/src/errors/BobError.js";
2
+ import { BobError } from "../errors/BobError.js";
3
3
  export class CommandNotFoundError extends BobError {
4
4
  command;
5
5
  similarCommands;
@@ -1,5 +1,5 @@
1
- import { BobError } from "@/src/errors/BobError.js";
2
- import { ArgSignature } from "@/src/CommandParser.js";
1
+ import { BobError } from "../errors/BobError.js";
2
+ import { ArgSignature } from "../CommandParser.js";
3
3
  export declare class InvalidOption extends BobError {
4
4
  private option;
5
5
  private optionsSignature;
@@ -1,5 +1,5 @@
1
1
  import chalk from "chalk";
2
- import { BobError } from "@/src/errors/BobError.js";
2
+ import { BobError } from "../errors/BobError.js";
3
3
  export class InvalidOption extends BobError {
4
4
  option;
5
5
  optionsSignature;
@@ -1,5 +1,5 @@
1
- import { BobError } from "@/src/errors/BobError.js";
2
- import { ArgSignature } from "@/src/CommandParser.js";
1
+ import { BobError } from "../errors/BobError.js";
2
+ import { ArgSignature } from "../CommandParser.js";
3
3
  export declare class MissingRequiredArgumentValue extends BobError {
4
4
  readonly paramSignature: ArgSignature;
5
5
  constructor(paramSignature: ArgSignature);
@@ -1,5 +1,5 @@
1
1
  import chalk from "chalk";
2
- import { BobError } from "@/src/errors/BobError.js";
2
+ import { BobError } from "../errors/BobError.js";
3
3
  export class MissingRequiredArgumentValue extends BobError {
4
4
  paramSignature;
5
5
  constructor(paramSignature) {
@@ -1,5 +1,5 @@
1
- import { BobError } from "@/src/errors/BobError.js";
2
- import { ArgSignature } from "@/src/CommandParser.js";
1
+ import { BobError } from "../errors/BobError.js";
2
+ import { ArgSignature } from "../CommandParser.js";
3
3
  export declare class MissingSignatureArgument extends BobError {
4
4
  private argument;
5
5
  private argumentSignatures;
@@ -1,5 +1,5 @@
1
1
  import chalk from "chalk";
2
- import { BobError } from "@/src/errors/BobError.js";
2
+ import { BobError } from "../errors/BobError.js";
3
3
  export class MissingSignatureArgument extends BobError {
4
4
  argument;
5
5
  argumentSignatures;
@@ -1,5 +1,5 @@
1
- import { BobError } from "@/src/errors/BobError.js";
2
- import { ArgSignature } from "@/src/CommandParser.js";
1
+ import { BobError } from "../errors/BobError.js";
2
+ import { ArgSignature } from "../CommandParser.js";
3
3
  export declare class MissingSignatureOption extends BobError {
4
4
  private option;
5
5
  private optionsSignature;
@@ -1,5 +1,5 @@
1
1
  import chalk from "chalk";
2
- import { BobError } from "@/src/errors/BobError.js";
2
+ import { BobError } from "../errors/BobError.js";
3
3
  export class MissingSignatureOption extends BobError {
4
4
  option;
5
5
  optionsSignature;
@@ -1,5 +1,5 @@
1
- import { Command } from "@/src/Command.js";
2
- import { CommandOption } from "@/src/contracts/index.js";
1
+ import { Command } from "../Command.js";
2
+ import { CommandOption } from "../contracts/index.js";
3
3
  export declare class HelpOption implements CommandOption<Command> {
4
4
  option: string;
5
5
  alias: string[];
@@ -1,6 +1,5 @@
1
1
  import chalk from "chalk";
2
- import { max } from "lodash";
3
- import { generateSpace } from "@/src/lib/string.js";
2
+ import { generateSpace } from "../lib/string.js";
4
3
  export class HelpOption {
5
4
  option = 'help';
6
5
  alias = ['h'];
@@ -19,8 +18,8 @@ export class HelpOption {
19
18
  log(chalk ` ${this.description}\n`);
20
19
  log(chalk `{yellow Usage}:`);
21
20
  log(chalk ` ${this.command} ${requiredArguments.length > 0 ? requiredArguments.map((signature) => `<${signature.name}>`).join(' ') : '\b'} [options]`);
22
- const maxOptionLength = max(availableOptions.map((signature) => signature.optionWithAlias.length)) ?? 0;
23
- const maxArgumentLength = max(availableArguments.map((arg) => arg.name.length)) ?? 0;
21
+ const maxOptionLength = Math.max(...availableOptions.map((signature) => signature.optionWithAlias.length)) ?? 0;
22
+ const maxArgumentLength = Math.max(...availableArguments.map((arg) => arg.name.length)) ?? 0;
24
23
  const maxLength = maxArgumentLength > maxOptionLength ? maxArgumentLength : maxOptionLength;
25
24
  if (availableArguments.length > 0) {
26
25
  log(chalk `\n{yellow Arguments}:`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bob-core",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "BOB Core",
5
5
  "type": "module",
6
6
  "files": [
@@ -22,28 +22,28 @@
22
22
  "scripts": {
23
23
  "start": "node -r @swc-node/register debug/main.ts",
24
24
  "build": "rimraf ./dist && npm run build:cjs && npm run build:esm",
25
- "build:cjs": "tsc --project tsconfig.json --module commonjs --verbatimModuleSyntax false --moduleResolution node10 --outDir ./dist/cjs && echo >./dist/cjs/package.json '{\"type\":\"commonjs\"}'",
26
- "build:esm": "tsc --project tsconfig.json --outDir ./dist/esm",
25
+ "build:cjs": "tsc --project tsconfig.json --module commonjs --verbatimModuleSyntax false --moduleResolution node10 --outDir ./dist/cjs && tsc-alias -p tsconfig.json --outDir ./dist/cjs && echo >./dist/cjs/package.json '{\"type\":\"commonjs\"}'",
26
+ "build:esm": "tsc --project tsconfig.json --outDir ./dist/esm && tsc-alias -p tsconfig.json --outDir ./dist/esm",
27
27
  "prepare": "npm run build",
28
28
  "test": "jest"
29
29
  },
30
30
  "author": "Léo Hubert",
31
31
  "license": "ISC",
32
32
  "devDependencies": {
33
- "@swc-node/register": "^1.9.2",
33
+ "@swc-node/register": "^1.11.1",
34
34
  "@types/jest": "^29.5.12",
35
35
  "@types/lodash": "^4.17.5",
36
36
  "@types/minimist": "^1.2.5",
37
37
  "@types/node": "^20.14.5",
38
38
  "@types/string-similarity": "^4.0.2",
39
39
  "jest": "^29.7.0",
40
+ "rimraf": "^6.0.1",
40
41
  "ts-jest": "^29.1.5",
41
- "typescript": "^5.7.3",
42
- "rimraf": "^6.0.1"
42
+ "tsc-alias": "^1.8.16",
43
+ "typescript": "^5.7.3"
43
44
  },
44
45
  "dependencies": {
45
46
  "chalk": "^4.1.2",
46
- "lodash": "^4.17.21",
47
47
  "minimist": "^1.2.8",
48
48
  "string-similarity": "^4.0.4"
49
49
  }
@@ -1,56 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const chalk_1 = __importDefault(require("chalk"));
7
- const lodash_1 = require("lodash");
8
- const Command_js_1 = require("@/src/Command.js");
9
- const string_js_1 = require("@/src/lib/string.js");
10
- class HelpCommand extends Command_js_1.Command {
11
- opts;
12
- signature = 'help';
13
- description = 'Show help';
14
- constructor(opts) {
15
- super();
16
- this.opts = opts;
17
- }
18
- async handle() {
19
- const commands = this.opts.commandRegistry.getCommands();
20
- const cliName = this.opts.cliName ?? 'Bob CLI';
21
- const version = this.opts.cliVersion ?? '0.0.0';
22
- const coreVersion = require('../../package.json').version;
23
- console.log((0, chalk_1.default) `${cliName} {green ${version}} (core: {yellow ${coreVersion}})
24
-
25
- {yellow Usage}:
26
- command [options] [arguments]
27
-
28
- {yellow Available commands}:
29
- `);
30
- const maxCommandLength = (0, lodash_1.max)(commands.map(command => command.command.length)) ?? 0;
31
- const commandByGroups = {};
32
- for (const command of commands) {
33
- const commandGroup = command.command.split(':')[0];
34
- if (!commandByGroups[commandGroup]) {
35
- commandByGroups[commandGroup] = [];
36
- }
37
- commandByGroups[commandGroup].push(command);
38
- }
39
- const sortedCommandsByGroups = (0, lodash_1.orderBy)((0, lodash_1.orderBy)(Object.entries(commandByGroups), [([group]) => group.toLowerCase()], ['asc']), [([_, commands]) => commands.length], ['asc']);
40
- for (const [group, groupCommands] of sortedCommandsByGroups) {
41
- const isGrouped = groupCommands.length > 1;
42
- if (isGrouped) {
43
- console.log((0, chalk_1.default) `{yellow ${group}}:`);
44
- }
45
- const sortedGroupCommands = (0, lodash_1.orderBy)(groupCommands, [command => command.command.toLowerCase()], ['asc']);
46
- for (const command of sortedGroupCommands) {
47
- let spaces = (0, string_js_1.generateSpace)(maxCommandLength - command.command.length);
48
- if (isGrouped) {
49
- spaces = spaces.slice(2);
50
- }
51
- console.log((0, chalk_1.default) `${isGrouped ? ' ' : ''}{green ${command.command}} ${spaces} ${command.description}`);
52
- }
53
- }
54
- }
55
- }
56
- exports.default = HelpCommand;
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes