bob-core 1.0.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/dist/{Cli.d.ts → cjs/Cli.d.ts} +4 -4
  2. package/dist/{Cli.js → cjs/Cli.js} +6 -6
  3. package/dist/{Command.d.ts → cjs/Command.d.ts} +2 -2
  4. package/dist/{Command.js → cjs/Command.js} +4 -4
  5. package/dist/{Command.test.js → cjs/Command.test.js} +4 -4
  6. package/dist/{CommandParser.d.ts → cjs/CommandParser.d.ts} +1 -1
  7. package/dist/{CommandParser.js → cjs/CommandParser.js} +13 -13
  8. package/dist/{CommandParser.test.js → cjs/CommandParser.test.js} +5 -5
  9. package/dist/{CommandRegistry.d.ts → cjs/CommandRegistry.d.ts} +1 -1
  10. package/dist/{CommandRegistry.js → cjs/CommandRegistry.js} +21 -11
  11. package/dist/{ExceptionHandler.d.ts → cjs/ExceptionHandler.d.ts} +1 -1
  12. package/dist/{ExceptionHandler.js → cjs/ExceptionHandler.js} +2 -2
  13. package/dist/{commands → cjs/commands}/HelpCommand.d.ts +2 -2
  14. package/dist/{commands → cjs/commands}/HelpCommand.js +4 -4
  15. package/dist/cjs/contracts/index.d.ts +1 -0
  16. package/dist/{contracts → cjs/contracts}/index.js +1 -1
  17. package/dist/{errors → cjs/errors}/BadCommandOption.d.ts +1 -1
  18. package/dist/{errors → cjs/errors}/BadCommandOption.js +2 -2
  19. package/dist/{errors → cjs/errors}/BadCommandParameter.d.ts +1 -1
  20. package/dist/{errors → cjs/errors}/BadCommandParameter.js +2 -2
  21. package/dist/{errors → cjs/errors}/CommandNotFoundError.d.ts +1 -1
  22. package/dist/{errors → cjs/errors}/CommandNotFoundError.js +2 -2
  23. package/dist/{errors → cjs/errors}/InvalidOption.d.ts +2 -2
  24. package/dist/{errors → cjs/errors}/InvalidOption.js +2 -2
  25. package/dist/{errors → cjs/errors}/MissingRequiredArgumentValue.d.ts +2 -2
  26. package/dist/{errors → cjs/errors}/MissingRequiredArgumentValue.js +2 -2
  27. package/dist/{errors → cjs/errors}/MissingSignatureArgument.d.ts +2 -2
  28. package/dist/{errors → cjs/errors}/MissingSignatureArgument.js +2 -2
  29. package/dist/{errors → cjs/errors}/MissingSignatureOption.d.ts +2 -2
  30. package/dist/{errors → cjs/errors}/MissingSignatureOption.js +2 -2
  31. package/dist/cjs/errors/index.d.ts +3 -0
  32. package/dist/{errors → cjs/errors}/index.js +3 -3
  33. package/dist/cjs/index.d.ts +5 -0
  34. package/dist/{index.js → cjs/index.js} +5 -5
  35. package/dist/{lib → cjs/lib}/string.js +1 -2
  36. package/dist/{options → cjs/options}/HelpOption.d.ts +2 -2
  37. package/dist/{options → cjs/options}/HelpOption.js +3 -3
  38. package/dist/cjs/options/index.d.ts +1 -0
  39. package/dist/{options → cjs/options}/index.js +1 -1
  40. package/dist/cjs/package.json +1 -0
  41. package/dist/esm/Cli.d.ts +26 -0
  42. package/dist/esm/Cli.js +59 -0
  43. package/dist/esm/Command.d.ts +34 -0
  44. package/dist/esm/Command.js +93 -0
  45. package/dist/esm/Command.test.d.ts +1 -0
  46. package/dist/esm/Command.test.js +50 -0
  47. package/dist/esm/CommandParser.d.ts +46 -0
  48. package/dist/esm/CommandParser.js +232 -0
  49. package/dist/esm/CommandParser.test.d.ts +1 -0
  50. package/dist/esm/CommandParser.test.js +175 -0
  51. package/dist/esm/CommandRegistry.d.ts +17 -0
  52. package/dist/esm/CommandRegistry.js +109 -0
  53. package/dist/esm/ExceptionHandler.d.ts +4 -0
  54. package/dist/esm/ExceptionHandler.js +10 -0
  55. package/dist/esm/commands/HelpCommand.d.ts +14 -0
  56. package/dist/esm/commands/HelpCommand.js +50 -0
  57. package/dist/esm/contracts/CommandOption.d.ts +7 -0
  58. package/dist/esm/contracts/CommandOption.js +1 -0
  59. package/dist/esm/contracts/index.d.ts +1 -0
  60. package/dist/esm/contracts/index.js +1 -0
  61. package/dist/esm/errors/BadCommandOption.d.ts +11 -0
  62. package/dist/esm/errors/BadCommandOption.js +29 -0
  63. package/dist/esm/errors/BadCommandParameter.d.ts +11 -0
  64. package/dist/esm/errors/BadCommandParameter.js +29 -0
  65. package/dist/esm/errors/BobError.d.ts +3 -0
  66. package/dist/esm/errors/BobError.js +2 -0
  67. package/dist/esm/errors/CommandNotFoundError.d.ts +7 -0
  68. package/dist/esm/errors/CommandNotFoundError.js +23 -0
  69. package/dist/esm/errors/InvalidOption.d.ts +8 -0
  70. package/dist/esm/errors/InvalidOption.js +25 -0
  71. package/dist/esm/errors/MissingRequiredArgumentValue.d.ts +7 -0
  72. package/dist/esm/errors/MissingRequiredArgumentValue.js +16 -0
  73. package/dist/esm/errors/MissingSignatureArgument.d.ts +8 -0
  74. package/dist/esm/errors/MissingSignatureArgument.js +24 -0
  75. package/dist/esm/errors/MissingSignatureOption.d.ts +8 -0
  76. package/dist/esm/errors/MissingSignatureOption.js +24 -0
  77. package/dist/esm/errors/index.d.ts +3 -0
  78. package/dist/esm/errors/index.js +3 -0
  79. package/dist/esm/index.d.ts +5 -0
  80. package/dist/esm/index.js +5 -0
  81. package/dist/esm/lib/string.d.ts +1 -0
  82. package/dist/esm/lib/string.js +3 -0
  83. package/dist/esm/options/HelpOption.d.ts +9 -0
  84. package/dist/esm/options/HelpOption.js +71 -0
  85. package/dist/esm/options/index.d.ts +1 -0
  86. package/dist/esm/options/index.js +1 -0
  87. package/package.json +20 -5
  88. package/dist/CommandHelper.d.ts +0 -4
  89. package/dist/CommandHelper.js +0 -74
  90. package/dist/contracts/index.d.ts +0 -1
  91. package/dist/errors/index.d.ts +0 -3
  92. package/dist/index.d.ts +0 -5
  93. package/dist/options/index.d.ts +0 -1
  94. /package/dist/{Command.test.d.ts → cjs/Command.test.d.ts} +0 -0
  95. /package/dist/{CommandParser.test.d.ts → cjs/CommandParser.test.d.ts} +0 -0
  96. /package/dist/{contracts → cjs/contracts}/CommandOption.d.ts +0 -0
  97. /package/dist/{contracts → cjs/contracts}/CommandOption.js +0 -0
  98. /package/dist/{errors → cjs/errors}/BobError.d.ts +0 -0
  99. /package/dist/{errors → cjs/errors}/BobError.js +0 -0
  100. /package/dist/{lib → cjs/lib}/string.d.ts +0 -0
@@ -1,7 +1,7 @@
1
- import { CommandRegistry } from "./CommandRegistry";
2
- import { Command } from "./Command";
3
- import HelpCommand from "./commands/HelpCommand";
4
- import { ExceptionHandler } from "./ExceptionHandler";
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";
5
5
  export type CliOptions<C> = {
6
6
  ctx?: C;
7
7
  name?: string;
@@ -4,22 +4,22 @@ 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_1 = require("./CommandRegistry");
8
- const HelpCommand_1 = __importDefault(require("./commands/HelpCommand"));
9
- const ExceptionHandler_1 = require("./ExceptionHandler");
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");
10
10
  class Cli {
11
11
  commandRegistry;
12
12
  exceptionHandler;
13
13
  ctx;
14
14
  helpCommand;
15
15
  get CommandRegistryClass() {
16
- return CommandRegistry_1.CommandRegistry;
16
+ return CommandRegistry_js_1.CommandRegistry;
17
17
  }
18
18
  get HelpCommandClass() {
19
- return HelpCommand_1.default;
19
+ return HelpCommand_js_1.default;
20
20
  }
21
21
  get ExceptionHandlerClass() {
22
- return ExceptionHandler_1.ExceptionHandler;
22
+ return ExceptionHandler_js_1.ExceptionHandler;
23
23
  }
24
24
  constructor(opts = {}) {
25
25
  this.ctx = opts.ctx;
@@ -1,5 +1,5 @@
1
- import { CommandParser } from "./CommandParser";
2
- import { CommandOption } from "./contracts/CommandOption";
1
+ import { CommandParser } from "@/src/CommandParser.js";
2
+ import { CommandOption } from "@/src/contracts/index.js";
3
3
  export type CommandExample = {
4
4
  description: string;
5
5
  command: string;
@@ -1,18 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Command = void 0;
4
- const CommandParser_1 = require("./CommandParser");
5
- const HelpOption_1 = require("./options/HelpOption");
4
+ const CommandParser_js_1 = require("@/src/CommandParser.js");
5
+ const index_js_1 = require("@/src/options/index.js");
6
6
  class Command {
7
7
  ctx;
8
8
  helperDefinitions = {};
9
9
  commandsExamples = [];
10
10
  parser;
11
11
  get CommandParserClass() {
12
- return CommandParser_1.CommandParser;
12
+ return CommandParser_js_1.CommandParser;
13
13
  }
14
14
  defaultOptions() {
15
- return [new HelpOption_1.HelpOption];
15
+ return [new index_js_1.HelpOption];
16
16
  }
17
17
  get command() {
18
18
  if (this.parser) {
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const Command_1 = require("./Command");
4
- const MissingRequiredArgumentValue_1 = require("./errors/MissingRequiredArgumentValue");
5
- class MockCommand extends Command_1.Command {
3
+ const Command_js_1 = require("@/src/Command.js");
4
+ const MissingRequiredArgumentValue_js_1 = require("@/src/errors/MissingRequiredArgumentValue.js");
5
+ class MockCommand extends Command_js_1.Command {
6
6
  signature = 'mockCommand {argument} {--option}';
7
7
  description = 'This is a mock command for testing';
8
8
  handle() {
@@ -43,7 +43,7 @@ describe('Command', () => {
43
43
  expect(result).toBe(-1);
44
44
  });
45
45
  it('should throw error if argument is missing', async () => {
46
- await expect(command.run(undefined)).rejects.toThrowError(MissingRequiredArgumentValue_1.MissingRequiredArgumentValue);
46
+ await expect(command.run(undefined)).rejects.toThrowError(MissingRequiredArgumentValue_js_1.MissingRequiredArgumentValue);
47
47
  });
48
48
  it('should handle command with option', async () => {
49
49
  const result = await command.run(undefined, 'value', '--option');
@@ -1,4 +1,4 @@
1
- import { CommandOption } from "./contracts/CommandOption";
1
+ import { CommandOption } from "@/src/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_1 = require("./errors/MissingRequiredArgumentValue");
9
- const MissingSignatureOption_1 = require("./errors/MissingSignatureOption");
10
- const MissingSignatureArgument_1 = require("./errors/MissingSignatureArgument");
11
- const InvalidOption_1 = require("./errors/InvalidOption");
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");
12
12
  class CommandParser {
13
13
  signature;
14
14
  helperDefinitions;
@@ -33,39 +33,39 @@ class CommandParser {
33
33
  }
34
34
  option(name) {
35
35
  if (!this.optionSignatures[name]) {
36
- throw new MissingSignatureOption_1.MissingSignatureOption(name, Object.values(this.optionSignatures));
36
+ throw new MissingSignatureOption_js_1.MissingSignatureOption(name, Object.values(this.optionSignatures));
37
37
  }
38
38
  return this.options[name];
39
39
  }
40
40
  setOption(name, value) {
41
41
  if (!this.optionSignatures[name]) {
42
- throw new MissingSignatureOption_1.MissingSignatureOption(name, Object.values(this.optionSignatures));
42
+ throw new MissingSignatureOption_js_1.MissingSignatureOption(name, Object.values(this.optionSignatures));
43
43
  }
44
44
  this.options[name] = value;
45
45
  }
46
46
  optionHelp(name) {
47
47
  const optionSignature = this.optionSignatures[name];
48
48
  if (!optionSignature) {
49
- throw new MissingSignatureOption_1.MissingSignatureOption(name, Object.values(this.optionSignatures));
49
+ throw new MissingSignatureOption_js_1.MissingSignatureOption(name, Object.values(this.optionSignatures));
50
50
  }
51
51
  return this.optionSignatures[name].help;
52
52
  }
53
53
  argument(name) {
54
54
  if (!this.argumentsSignature[name]) {
55
- throw new MissingSignatureArgument_1.MissingSignatureArgument(name, Object.values(this.argumentsSignature));
55
+ throw new MissingSignatureArgument_js_1.MissingSignatureArgument(name, Object.values(this.argumentsSignature));
56
56
  }
57
57
  return this.arguments[name];
58
58
  }
59
59
  setArgument(name, value) {
60
60
  if (!this.argumentsSignature[name]) {
61
- throw new MissingSignatureArgument_1.MissingSignatureArgument(name, Object.values(this.argumentsSignature));
61
+ throw new MissingSignatureArgument_js_1.MissingSignatureArgument(name, Object.values(this.argumentsSignature));
62
62
  }
63
63
  this.arguments[name] = value;
64
64
  }
65
65
  argumentHelp(name) {
66
66
  const argumentSignature = this.argumentsSignature[name];
67
67
  if (!argumentSignature) {
68
- throw new MissingSignatureArgument_1.MissingSignatureArgument(name, Object.values(this.argumentsSignature));
68
+ throw new MissingSignatureArgument_js_1.MissingSignatureArgument(name, Object.values(this.argumentsSignature));
69
69
  }
70
70
  return this.argumentsSignature[name].help;
71
71
  }
@@ -110,7 +110,7 @@ class CommandParser {
110
110
  const optionAlias = this.optionAliases[option];
111
111
  const optionSignature = this.optionSignatures[option] ?? this.optionSignatures[optionAlias];
112
112
  if (!optionSignature) {
113
- throw new InvalidOption_1.InvalidOption(option, Object.values(this.optionSignatures));
113
+ throw new InvalidOption_js_1.InvalidOption(option, Object.values(this.optionSignatures));
114
114
  }
115
115
  this.options[option] = this.getParamValue(value, optionSignature);
116
116
  for (const alias of optionSignature.alias ?? []) {
@@ -228,10 +228,10 @@ class CommandParser {
228
228
  for (const [argument, value] of Object.entries(this.arguments)) {
229
229
  const argSignature = this.argumentsSignature[argument];
230
230
  if (!value && !argSignature.optional) {
231
- throw new MissingRequiredArgumentValue_1.MissingRequiredArgumentValue(argSignature);
231
+ throw new MissingRequiredArgumentValue_js_1.MissingRequiredArgumentValue(argSignature);
232
232
  }
233
233
  if (!value?.length && argSignature.variadic && !argSignature.optional) {
234
- throw new MissingRequiredArgumentValue_1.MissingRequiredArgumentValue(argSignature);
234
+ throw new MissingRequiredArgumentValue_js_1.MissingRequiredArgumentValue(argSignature);
235
235
  }
236
236
  }
237
237
  }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const CommandParser_1 = require("./CommandParser");
4
- const MissingRequiredArgumentValue_1 = require("./errors/MissingRequiredArgumentValue");
3
+ const CommandParser_js_1 = require("@/src/CommandParser.js");
4
+ const MissingRequiredArgumentValue_js_1 = require("@/src/errors/MissingRequiredArgumentValue.js");
5
5
  class TestCommandOptions {
6
6
  option = 'testOption';
7
7
  description = 'Test option';
@@ -14,7 +14,7 @@ class TestCommandOptions {
14
14
  describe('CommandParser', () => {
15
15
  let commandParser;
16
16
  const parseCommand = (signature, args, helperDefinition = {}, defaultCommandOptions = []) => {
17
- return new CommandParser_1.CommandParser(signature, helperDefinition, defaultCommandOptions, ...args);
17
+ return new CommandParser_js_1.CommandParser(signature, helperDefinition, defaultCommandOptions, ...args);
18
18
  };
19
19
  it('should parse signature without arguments & options', () => {
20
20
  commandParser = parseCommand('test', []);
@@ -59,11 +59,11 @@ describe('CommandParser', () => {
59
59
  });
60
60
  it('calling validate method should throw error when argument is missing', () => {
61
61
  commandParser = parseCommand('test {arg1}', []);
62
- expect(() => commandParser.validate()).toThrowError(MissingRequiredArgumentValue_1.MissingRequiredArgumentValue);
62
+ expect(() => commandParser.validate()).toThrowError(MissingRequiredArgumentValue_js_1.MissingRequiredArgumentValue);
63
63
  });
64
64
  it('calling validate should throw with variadic argument is missing', () => {
65
65
  commandParser = parseCommand('test {arg1*}', []);
66
- expect(() => commandParser.validate()).toThrowError(MissingRequiredArgumentValue_1.MissingRequiredArgumentValue);
66
+ expect(() => commandParser.validate()).toThrowError(MissingRequiredArgumentValue_js_1.MissingRequiredArgumentValue);
67
67
  });
68
68
  });
69
69
  describe('Options', () => {
@@ -1,4 +1,4 @@
1
- import { Command } from "./Command";
1
+ import { Command } from "@/src/Command.js";
2
2
  export type CommandResolver = (path: string) => Promise<Command>;
3
3
  export declare class CommandRegistry {
4
4
  private readonly commands;
@@ -15,23 +15,33 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
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
+ })();
25
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
37
  };
28
38
  Object.defineProperty(exports, "__esModule", { value: true });
29
39
  exports.CommandRegistry = void 0;
30
- const path_1 = __importDefault(require("path"));
31
40
  const fs = __importStar(require("node:fs"));
32
- const CommandNotFoundError_1 = require("./errors/CommandNotFoundError");
41
+ const path_1 = __importDefault(require("path"));
33
42
  const SS = __importStar(require("string-similarity"));
34
43
  const chalk_1 = __importDefault(require("chalk"));
44
+ const CommandNotFoundError_js_1 = require("@/src/errors/CommandNotFoundError.js");
35
45
  class CommandRegistry {
36
46
  commands = {};
37
47
  get commandSuffix() {
@@ -45,7 +55,7 @@ class CommandRegistry {
45
55
  return Object.values(this.commands);
46
56
  }
47
57
  commandResolver = async (path) => {
48
- const CommandClass = (await import(path)).default;
58
+ const CommandClass = (await Promise.resolve(`${path}`).then(s => __importStar(require(s)))).default;
49
59
  let command;
50
60
  if (CommandClass?.default) {
51
61
  command = new CommandClass.default();
@@ -105,7 +115,7 @@ class CommandRegistry {
105
115
  return null;
106
116
  }
107
117
  }
108
- throw new CommandNotFoundError_1.CommandNotFoundError(command, similarCommands);
118
+ throw new CommandNotFoundError_js_1.CommandNotFoundError(command, similarCommands);
109
119
  }
110
120
  async askRunSimilarCommand(command, commandToAsk) {
111
121
  const readline = require('readline').createInterface({
@@ -1,4 +1,4 @@
1
- import { BobError } from "./errors/BobError";
1
+ import { BobError } from "@/src/errors/index.js";
2
2
  export declare class ExceptionHandler {
3
3
  handle(err: Error | BobError): number;
4
4
  }
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ExceptionHandler = void 0;
4
- const BobError_1 = require("./errors/BobError");
4
+ const index_js_1 = require("@/src/errors/index.js");
5
5
  class ExceptionHandler {
6
6
  handle(err) {
7
- if (err instanceof BobError_1.BobError) {
7
+ if (err instanceof index_js_1.BobError) {
8
8
  err.pretty();
9
9
  return -1;
10
10
  }
@@ -1,5 +1,5 @@
1
- import { Command } from "../Command";
2
- import { CommandRegistry } from "../CommandRegistry";
1
+ import { Command } from "@/src/Command.js";
2
+ import { CommandRegistry } from "@/src/CommandRegistry.js";
3
3
  export type HelpCommandOptions = {
4
4
  commandRegistry: CommandRegistry;
5
5
  cliName?: string;
@@ -3,11 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const Command_1 = require("../Command");
7
6
  const chalk_1 = __importDefault(require("chalk"));
8
7
  const lodash_1 = require("lodash");
9
- const string_1 = require("../lib/string");
10
- class HelpCommand extends Command_1.Command {
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
11
  opts;
12
12
  signature = 'help';
13
13
  description = 'Show help';
@@ -44,7 +44,7 @@ class HelpCommand extends Command_1.Command {
44
44
  }
45
45
  const sortedGroupCommands = (0, lodash_1.orderBy)(groupCommands, [command => command.command.toLowerCase()], ['asc']);
46
46
  for (const command of sortedGroupCommands) {
47
- let spaces = (0, string_1.generateSpace)(maxCommandLength - command.command.length);
47
+ let spaces = (0, string_js_1.generateSpace)(maxCommandLength - command.command.length);
48
48
  if (isGrouped) {
49
49
  spaces = spaces.slice(2);
50
50
  }
@@ -0,0 +1 @@
1
+ export * from './CommandOption.js';
@@ -14,4 +14,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./CommandOption"), exports);
17
+ __exportStar(require("./CommandOption.js"), exports);
@@ -1,4 +1,4 @@
1
- import { BobError } from "./BobError";
1
+ import { BobError } from "@/src/errors/BobError.js";
2
2
  export type OptionProps = {
3
3
  option: string;
4
4
  value?: 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.BadCommandOption = void 0;
7
- const BobError_1 = require("./BobError");
8
7
  const chalk_1 = __importDefault(require("chalk"));
9
- class BadCommandOption extends BobError_1.BobError {
8
+ const BobError_js_1 = require("@/src/errors/BobError.js");
9
+ class BadCommandOption extends BobError_js_1.BobError {
10
10
  param;
11
11
  constructor(param) {
12
12
  let message = `Option "${param.option}" value is invalid.`;
@@ -1,4 +1,4 @@
1
- import { BobError } from "./BobError";
1
+ import { BobError } from "@/src/errors/BobError.js";
2
2
  export type ParameterProps = {
3
3
  param: string;
4
4
  value?: 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.BadCommandParameter = void 0;
7
- const BobError_1 = require("./BobError");
8
7
  const chalk_1 = __importDefault(require("chalk"));
9
- class BadCommandParameter extends BobError_1.BobError {
8
+ const BobError_js_1 = require("@/src/errors/BobError.js");
9
+ class BadCommandParameter extends BobError_js_1.BobError {
10
10
  param;
11
11
  constructor(param) {
12
12
  let message = `Argument "${param.param}" value is invalid.`;
@@ -1,4 +1,4 @@
1
- import { BobError } from "./BobError";
1
+ import { BobError } from "@/src/errors/BobError.js";
2
2
  export declare class CommandNotFoundError extends BobError {
3
3
  readonly command: string;
4
4
  readonly similarCommands: 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.CommandNotFoundError = void 0;
7
- const BobError_1 = require("./BobError");
8
7
  const chalk_1 = __importDefault(require("chalk"));
9
- class CommandNotFoundError extends BobError_1.BobError {
8
+ const BobError_js_1 = require("@/src/errors/BobError.js");
9
+ class CommandNotFoundError extends BobError_js_1.BobError {
10
10
  command;
11
11
  similarCommands;
12
12
  constructor(command, similarCommands) {
@@ -1,5 +1,5 @@
1
- import { BobError } from "./BobError";
2
- import { ArgSignature } from "../CommandParser";
1
+ import { BobError } from "@/src/errors/BobError.js";
2
+ import { ArgSignature } from "@/src/CommandParser.js";
3
3
  export declare class InvalidOption extends BobError {
4
4
  private option;
5
5
  private optionsSignature;
@@ -4,9 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.InvalidOption = void 0;
7
- const BobError_1 = require("./BobError");
8
7
  const chalk_1 = __importDefault(require("chalk"));
9
- class InvalidOption extends BobError_1.BobError {
8
+ const BobError_js_1 = require("@/src/errors/BobError.js");
9
+ class InvalidOption extends BobError_js_1.BobError {
10
10
  option;
11
11
  optionsSignature;
12
12
  constructor(option, optionsSignature) {
@@ -1,5 +1,5 @@
1
- import { BobError } from "./BobError";
2
- import { ArgSignature } from "../CommandParser";
1
+ import { BobError } from "@/src/errors/BobError.js";
2
+ import { ArgSignature } from "@/src/CommandParser.js";
3
3
  export declare class MissingRequiredArgumentValue extends BobError {
4
4
  readonly paramSignature: ArgSignature;
5
5
  constructor(paramSignature: ArgSignature);
@@ -4,9 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.MissingRequiredArgumentValue = void 0;
7
- const BobError_1 = require("./BobError");
8
7
  const chalk_1 = __importDefault(require("chalk"));
9
- class MissingRequiredArgumentValue extends BobError_1.BobError {
8
+ const BobError_js_1 = require("@/src/errors/BobError.js");
9
+ class MissingRequiredArgumentValue extends BobError_js_1.BobError {
10
10
  paramSignature;
11
11
  constructor(paramSignature) {
12
12
  super(`Argument "${paramSignature.name}" is required.`);
@@ -1,5 +1,5 @@
1
- import { BobError } from "./BobError";
2
- import { ArgSignature } from "../CommandParser";
1
+ import { BobError } from "@/src/errors/BobError.js";
2
+ import { ArgSignature } from "@/src/CommandParser.js";
3
3
  export declare class MissingSignatureArgument extends BobError {
4
4
  private argument;
5
5
  private argumentSignatures;
@@ -4,9 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.MissingSignatureArgument = void 0;
7
- const BobError_1 = require("./BobError");
8
7
  const chalk_1 = __importDefault(require("chalk"));
9
- class MissingSignatureArgument extends BobError_1.BobError {
8
+ const BobError_js_1 = require("@/src/errors/BobError.js");
9
+ class MissingSignatureArgument extends BobError_js_1.BobError {
10
10
  argument;
11
11
  argumentSignatures;
12
12
  constructor(argument, argumentSignatures) {
@@ -1,5 +1,5 @@
1
- import { BobError } from "./BobError";
2
- import { ArgSignature } from "../CommandParser";
1
+ import { BobError } from "@/src/errors/BobError.js";
2
+ import { ArgSignature } from "@/src/CommandParser.js";
3
3
  export declare class MissingSignatureOption extends BobError {
4
4
  private option;
5
5
  private optionsSignature;
@@ -4,9 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.MissingSignatureOption = void 0;
7
- const BobError_1 = require("./BobError");
8
7
  const chalk_1 = __importDefault(require("chalk"));
9
- class MissingSignatureOption extends BobError_1.BobError {
8
+ const BobError_js_1 = require("@/src/errors/BobError.js");
9
+ class MissingSignatureOption extends BobError_js_1.BobError {
10
10
  option;
11
11
  optionsSignature;
12
12
  constructor(option, optionsSignature) {
@@ -0,0 +1,3 @@
1
+ export * from './BobError.js';
2
+ export * from './BadCommandParameter.js';
3
+ export * from './BadCommandOption.js';
@@ -14,6 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./BobError"), exports);
18
- __exportStar(require("./BadCommandParameter"), exports);
19
- __exportStar(require("./BadCommandOption"), exports);
17
+ __exportStar(require("./BobError.js"), exports);
18
+ __exportStar(require("./BadCommandParameter.js"), exports);
19
+ __exportStar(require("./BadCommandOption.js"), exports);
@@ -0,0 +1,5 @@
1
+ export * from './Command.js';
2
+ export * from './Cli.js';
3
+ export * from './errors/index.js';
4
+ export * from './contracts/index.js';
5
+ export * from './options/index.js';
@@ -14,8 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./Command"), exports);
18
- __exportStar(require("./Cli"), exports);
19
- __exportStar(require("./errors"), exports);
20
- __exportStar(require("./contracts"), exports);
21
- __exportStar(require("./options"), exports);
17
+ __exportStar(require("./Command.js"), exports);
18
+ __exportStar(require("./Cli.js"), exports);
19
+ __exportStar(require("./errors/index.js"), exports);
20
+ __exportStar(require("./contracts/index.js"), exports);
21
+ __exportStar(require("./options/index.js"), exports);
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateSpace = void 0;
3
+ exports.generateSpace = generateSpace;
4
4
  function generateSpace(nb) {
5
5
  return new Array(nb + 5).join(' ');
6
6
  }
7
- exports.generateSpace = generateSpace;
@@ -1,5 +1,5 @@
1
- import { Command } from "../Command";
2
- import { CommandOption } from "../contracts/CommandOption";
1
+ import { Command } from "@/src/Command.js";
2
+ import { CommandOption } from "@/src/contracts/index.js";
3
3
  export declare class HelpOption implements CommandOption<Command> {
4
4
  option: string;
5
5
  alias: string[];
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.HelpOption = void 0;
7
7
  const chalk_1 = __importDefault(require("chalk"));
8
8
  const lodash_1 = require("lodash");
9
- const string_1 = require("../lib/string");
9
+ const string_js_1 = require("@/src/lib/string.js");
10
10
  class HelpOption {
11
11
  option = 'help';
12
12
  alias = ['h'];
@@ -31,7 +31,7 @@ class HelpOption {
31
31
  if (availableArguments.length > 0) {
32
32
  log((0, chalk_1.default) `\n{yellow Arguments}:`);
33
33
  for (const signature of availableArguments) {
34
- const spaces = (0, string_1.generateSpace)(maxLength - signature.name.length);
34
+ const spaces = (0, string_js_1.generateSpace)(maxLength - signature.name.length);
35
35
  let message = (0, chalk_1.default) ` {green ${signature.name}} ${spaces} ${signature.help ?? '\b'}`;
36
36
  if (signature.defaultValue !== undefined && signature.optional) {
37
37
  const defaultValue = signature.type === 'array' ? JSON.stringify(signature.defaultValue) : signature.defaultValue;
@@ -46,7 +46,7 @@ class HelpOption {
46
46
  if (availableOptions.length > 0) {
47
47
  log((0, chalk_1.default) `\n{yellow Options}:`);
48
48
  for (const signature of availableOptions) {
49
- const spaces = (0, string_1.generateSpace)(maxLength - signature.optionWithAlias.length);
49
+ const spaces = (0, string_js_1.generateSpace)(maxLength - signature.optionWithAlias.length);
50
50
  let message = (0, chalk_1.default) `{green ${signature.optionWithAlias}} ${spaces} ${signature.help ?? '\b'}`;
51
51
  if (signature.type) {
52
52
  message += (0, chalk_1.default) ` {white (${signature.type})}`;
@@ -0,0 +1 @@
1
+ export * from './HelpOption.js';
@@ -14,4 +14,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./HelpOption"), exports);
17
+ __exportStar(require("./HelpOption.js"), exports);
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}