@adonisjs/core 7.0.0-next.0 → 7.0.0-next.10

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 (96) hide show
  1. package/build/commands/add.d.ts +32 -0
  2. package/build/commands/add.js +17 -0
  3. package/build/commands/build.d.ts +22 -0
  4. package/build/commands/build.js +18 -0
  5. package/build/commands/commands.json +1 -1
  6. package/build/commands/configure.d.ts +32 -9
  7. package/build/commands/configure.js +36 -9
  8. package/build/commands/eject.d.ts +27 -2
  9. package/build/commands/eject.js +21 -2
  10. package/build/commands/env/add.d.ts +39 -2
  11. package/build/commands/env/add.js +30 -3
  12. package/build/commands/generate_key.d.ts +19 -0
  13. package/build/commands/generate_key.js +13 -0
  14. package/build/commands/inspect_rcfile.d.ts +19 -1
  15. package/build/commands/inspect_rcfile.js +19 -1
  16. package/build/commands/list/routes.d.ts +31 -9
  17. package/build/commands/list/routes.js +26 -3
  18. package/build/commands/make/command.d.ts +25 -2
  19. package/build/commands/make/command.js +22 -2
  20. package/build/commands/make/controller.d.ts +33 -0
  21. package/build/commands/make/controller.js +18 -0
  22. package/build/commands/make/event.d.ts +28 -2
  23. package/build/commands/make/event.js +25 -2
  24. package/build/commands/make/exception.d.ts +28 -2
  25. package/build/commands/make/exception.js +25 -2
  26. package/build/commands/make/listener.d.ts +36 -3
  27. package/build/commands/make/listener.js +30 -3
  28. package/build/commands/make/middleware.d.ts +23 -0
  29. package/build/commands/make/middleware.js +17 -0
  30. package/build/commands/make/preload.d.ts +30 -3
  31. package/build/commands/make/preload.js +24 -4
  32. package/build/commands/make/provider.d.ts +31 -2
  33. package/build/commands/make/provider.js +25 -3
  34. package/build/commands/make/service.d.ts +19 -0
  35. package/build/commands/make/service.js +16 -0
  36. package/build/commands/make/test.d.ts +26 -3
  37. package/build/commands/make/test.js +34 -6
  38. package/build/commands/make/transformer.d.ts +43 -0
  39. package/build/commands/make/transformer.js +65 -0
  40. package/build/commands/make/validator.d.ts +34 -3
  41. package/build/commands/make/validator.js +28 -3
  42. package/build/commands/make/view.d.ts +25 -2
  43. package/build/commands/make/view.js +22 -2
  44. package/build/commands/repl.d.ts +22 -2
  45. package/build/commands/repl.js +22 -2
  46. package/build/commands/serve.d.ts +36 -0
  47. package/build/commands/serve.js +26 -9
  48. package/build/commands/test.d.ts +66 -3
  49. package/build/commands/test.js +37 -13
  50. package/build/modules/ace/codemods.d.ts +109 -14
  51. package/build/modules/ace/codemods.js +119 -16
  52. package/build/modules/ace/commands.d.ts +0 -1
  53. package/build/modules/ace/commands.js +0 -3
  54. package/build/modules/ace/main.d.ts +30 -0
  55. package/build/modules/ace/main.js +30 -0
  56. package/build/modules/app.d.ts +17 -0
  57. package/build/modules/app.js +17 -0
  58. package/build/modules/config.d.ts +17 -0
  59. package/build/modules/config.js +17 -0
  60. package/build/modules/dumper/dumper.d.ts +5 -0
  61. package/build/modules/dumper/dumper.js +11 -1
  62. package/build/modules/dumper/main.d.ts +21 -0
  63. package/build/modules/dumper/main.js +21 -0
  64. package/build/modules/encryption.d.ts +17 -0
  65. package/build/modules/encryption.js +17 -0
  66. package/build/modules/env/main.d.ts +19 -0
  67. package/build/modules/env/main.js +19 -0
  68. package/build/modules/hash/drivers/bcrypt.d.ts +11 -0
  69. package/build/modules/hash/drivers/bcrypt.js +11 -0
  70. package/build/modules/hash/main.d.ts +18 -0
  71. package/build/modules/hash/main.js +18 -0
  72. package/build/modules/http/url_builder_client.d.ts +1 -0
  73. package/build/modules/http/url_builder_client.js +9 -0
  74. package/build/providers/app_provider.d.ts +11 -23
  75. package/build/providers/app_provider.js +41 -45
  76. package/build/providers/edge_provider.js +62 -1
  77. package/build/src/assembler_hooks/index_entities.d.ts +3 -17
  78. package/build/src/assembler_hooks/index_entities.js +31 -15
  79. package/build/src/cli_formatters/routes_list.js +23 -7
  80. package/build/src/helpers/http.d.ts +20 -0
  81. package/build/src/helpers/http.js +28 -0
  82. package/build/src/helpers/main.d.ts +1 -5
  83. package/build/src/helpers/main.js +1 -5
  84. package/build/src/helpers/string.js +24 -0
  85. package/build/src/helpers/types.d.ts +1 -0
  86. package/build/src/ignitor/http.js +18 -5
  87. package/build/src/types.d.ts +7 -0
  88. package/build/src/utils.d.ts +26 -0
  89. package/build/src/utils.js +65 -0
  90. package/build/src/vine.js +14 -6
  91. package/build/stubs/make/transformer/main.stub +18 -0
  92. package/build/types/common.d.ts +1 -0
  93. package/build/types/common.js +9 -0
  94. package/build/types/helpers.d.ts +20 -0
  95. package/build/types/http.d.ts +1 -0
  96. package/package.json +26 -23
@@ -18,9 +18,22 @@ import { BaseCommand, flags } from "../modules/ace/main.js";
18
18
  /**
19
19
  * The generate key command is used to generate the app key
20
20
  * and write it inside the .env file.
21
+ *
22
+ * @example
23
+ * ```
24
+ * ace generate:key
25
+ * ace generate:key --show
26
+ * ace generate:key --force
27
+ * ```
21
28
  */
22
29
  export default class GenerateKey extends BaseCommand {
30
+ /**
31
+ * The command name
32
+ */
23
33
  static commandName = 'generate:key';
34
+ /**
35
+ * The command description
36
+ */
24
37
  static description = 'Generate a cryptographically secure random application key';
25
38
  async run() {
26
39
  let writeToFile = process.env.NODE_ENV !== 'production';
@@ -1,9 +1,27 @@
1
1
  import { BaseCommand } from '../modules/ace/main.ts';
2
2
  /**
3
- * Prints the RcFile file contents to the terminal
3
+ * Command to inspect and display the AdonisJS RC file contents with default values.
4
+ * The RC file contains configuration for providers, preloads, commands, and other
5
+ * application settings. This command formats and displays the contents in a readable JSON format.
6
+ *
7
+ * @example
8
+ * ```
9
+ * ace inspect:rcfile
10
+ * ```
4
11
  */
5
12
  export default class InspectRCFile extends BaseCommand {
13
+ /**
14
+ * The command name
15
+ */
6
16
  static commandName: string;
17
+ /**
18
+ * The command description
19
+ */
7
20
  static description: string;
21
+ /**
22
+ * Execute the command to display RC file contents.
23
+ * Transforms provider, preload, and command entries to display their file paths
24
+ * as strings and formats the output as readable JSON.
25
+ */
8
26
  run(): Promise<void>;
9
27
  }
@@ -8,11 +8,29 @@
8
8
  */
9
9
  import { BaseCommand } from "../modules/ace/main.js";
10
10
  /**
11
- * Prints the RcFile file contents to the terminal
11
+ * Command to inspect and display the AdonisJS RC file contents with default values.
12
+ * The RC file contains configuration for providers, preloads, commands, and other
13
+ * application settings. This command formats and displays the contents in a readable JSON format.
14
+ *
15
+ * @example
16
+ * ```
17
+ * ace inspect:rcfile
18
+ * ```
12
19
  */
13
20
  export default class InspectRCFile extends BaseCommand {
21
+ /**
22
+ * The command name
23
+ */
14
24
  static commandName = 'inspect:rcfile';
25
+ /**
26
+ * The command description
27
+ */
15
28
  static description = 'Inspect the RC file with its default values';
29
+ /**
30
+ * Execute the command to display RC file contents.
31
+ * Transforms provider, preload, and command entries to display their file paths
32
+ * as strings and formats the output as readable JSON.
33
+ */
16
34
  async run() {
17
35
  const { raw, providers, preloads, commands, ...rest } = this.app.rcFile;
18
36
  this.logger.log(JSON.stringify({
@@ -1,36 +1,58 @@
1
1
  import type { CommandOptions } from '../../types/ace.ts';
2
2
  import { BaseCommand } from '../../modules/ace/main.ts';
3
3
  /**
4
- * The list routes command is used to view the list of registered routes
4
+ * Command to display a list of all registered routes in the application.
5
+ * Supports filtering by keywords, middleware, and output formatting options.
6
+ * Routes can be displayed as a formatted list, table, or JSON.
7
+ *
8
+ * @example
9
+ * ```
10
+ * ace list:routes
11
+ * ace list:routes user
12
+ * ace list:routes --middleware=auth
13
+ * ace list:routes --ignore-middleware=guest
14
+ * ace list:routes --json
15
+ * ace list:routes --table
16
+ * ```
5
17
  */
6
18
  export default class ListRoutes extends BaseCommand {
19
+ /**
20
+ * The command name
21
+ */
7
22
  static commandName: string;
23
+ /**
24
+ * The command description
25
+ */
8
26
  static description: string;
9
27
  /**
10
- * Making sure to start the application so that the routes are
11
- * imported
28
+ * Command options configuration.
29
+ * Requires the application to be started so routes are loaded.
12
30
  */
13
31
  static options: CommandOptions;
14
32
  /**
15
- * The match filter is used to find route by name, pattern and controller name that
16
- * includes the match keyword
33
+ * Keyword to match against route names, patterns, and controller names
17
34
  */
18
35
  match: string;
19
36
  /**
20
- * The middleware flag searches for the routes using all the mentioned middleware
37
+ * Filter routes that include all specified middleware names
21
38
  */
22
39
  middleware: string[];
23
40
  /**
24
- * The ignoreMiddleware flag searches for the routes not using all the mentioned middleware
41
+ * Filter routes that do not include all specified middleware names
25
42
  */
26
43
  ignoreMiddleware: string[];
27
44
  /**
28
- * The json flag is used to view list of routes as a JSON string.
45
+ * Output routes as JSON format
29
46
  */
30
47
  json: boolean;
31
48
  /**
32
- * The table flag is used to view list of routes as a classic CLI table
49
+ * Output routes as a CLI table format
33
50
  */
34
51
  table: boolean;
52
+ /**
53
+ * Execute the command to list application routes.
54
+ * Creates a formatter with the specified filters and outputs routes
55
+ * in the requested format (JSON, table, or formatted list).
56
+ */
35
57
  run(): Promise<void>;
36
58
  }
@@ -15,18 +15,41 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
15
15
  import { args, BaseCommand, flags } from "../../modules/ace/main.js";
16
16
  import { RoutesListFormatter } from "../../src/cli_formatters/routes_list.js";
17
17
  /**
18
- * The list routes command is used to view the list of registered routes
18
+ * Command to display a list of all registered routes in the application.
19
+ * Supports filtering by keywords, middleware, and output formatting options.
20
+ * Routes can be displayed as a formatted list, table, or JSON.
21
+ *
22
+ * @example
23
+ * ```
24
+ * ace list:routes
25
+ * ace list:routes user
26
+ * ace list:routes --middleware=auth
27
+ * ace list:routes --ignore-middleware=guest
28
+ * ace list:routes --json
29
+ * ace list:routes --table
30
+ * ```
19
31
  */
20
32
  export default class ListRoutes extends BaseCommand {
33
+ /**
34
+ * The command name
35
+ */
21
36
  static commandName = 'list:routes';
37
+ /**
38
+ * The command description
39
+ */
22
40
  static description = 'List application routes. This command will boot the application in the console environment';
23
41
  /**
24
- * Making sure to start the application so that the routes are
25
- * imported
42
+ * Command options configuration.
43
+ * Requires the application to be started so routes are loaded.
26
44
  */
27
45
  static options = {
28
46
  startApp: true,
29
47
  };
48
+ /**
49
+ * Execute the command to list application routes.
50
+ * Creates a formatter with the specified filters and outputs routes
51
+ * in the requested format (JSON, table, or formatted list).
52
+ */
30
53
  async run() {
31
54
  const router = await this.app.container.make('router');
32
55
  const formatter = new RoutesListFormatter(router, this.ui, {}, {
@@ -1,14 +1,37 @@
1
1
  import { BaseCommand } from '../../modules/ace/main.ts';
2
2
  /**
3
- * Make a new ace command
3
+ * Command to create a new Ace command class.
4
+ * Ace commands are CLI commands that can be executed via the `ace` binary,
5
+ * allowing you to create custom functionality for your application's command line interface.
6
+ *
7
+ * @example
8
+ * ```
9
+ * ace make:command SendEmails
10
+ * ace make:command ProcessPayments
11
+ * ace make:command GenerateReports
12
+ * ace make:command CleanupFiles
13
+ * ```
4
14
  */
5
15
  export default class MakeCommand extends BaseCommand {
16
+ /**
17
+ * The command name
18
+ */
6
19
  static commandName: string;
20
+ /**
21
+ * The command description
22
+ */
7
23
  static description: string;
24
+ /**
25
+ * Name of the command class to create
26
+ */
8
27
  name: string;
9
28
  /**
10
- * The stub to use for generating the command class
29
+ * The stub template file to use for generating the command class
11
30
  */
12
31
  protected stubPath: string;
32
+ /**
33
+ * Execute the command to create a new Ace command class.
34
+ * Generates the command file with proper CLI command structure.
35
+ */
13
36
  run(): Promise<void>;
14
37
  }
@@ -16,15 +16,35 @@ import { stubsRoot } from "../../stubs/main.js";
16
16
  import { args } from "../../modules/ace/main.js";
17
17
  import { BaseCommand } from "../../modules/ace/main.js";
18
18
  /**
19
- * Make a new ace command
19
+ * Command to create a new Ace command class.
20
+ * Ace commands are CLI commands that can be executed via the `ace` binary,
21
+ * allowing you to create custom functionality for your application's command line interface.
22
+ *
23
+ * @example
24
+ * ```
25
+ * ace make:command SendEmails
26
+ * ace make:command ProcessPayments
27
+ * ace make:command GenerateReports
28
+ * ace make:command CleanupFiles
29
+ * ```
20
30
  */
21
31
  export default class MakeCommand extends BaseCommand {
32
+ /**
33
+ * The command name
34
+ */
22
35
  static commandName = 'make:command';
36
+ /**
37
+ * The command description
38
+ */
23
39
  static description = 'Create a new ace command class';
24
40
  /**
25
- * The stub to use for generating the command class
41
+ * The stub template file to use for generating the command class
26
42
  */
27
43
  stubPath = 'make/command/main.stub';
44
+ /**
45
+ * Execute the command to create a new Ace command class.
46
+ * Generates the command file with proper CLI command structure.
47
+ */
28
48
  async run() {
29
49
  const codemods = await this.createCodemods();
30
50
  await codemods.makeUsingStub(stubsRoot, this.stubPath, {
@@ -2,15 +2,48 @@ import { BaseCommand } from '../../modules/ace/main.ts';
2
2
  import { type CommandOptions } from '../../types/ace.ts';
3
3
  /**
4
4
  * The make controller command to create an HTTP controller
5
+ *
6
+ * @example
7
+ * ```
8
+ * ace make:controller User
9
+ * ace make:controller User store update
10
+ * ace make:controller User --resource
11
+ * ace make:controller User --api
12
+ * ace make:controller User --singular
13
+ * ```
5
14
  */
6
15
  export default class MakeController extends BaseCommand {
16
+ /**
17
+ * The command name
18
+ */
7
19
  static commandName: string;
20
+ /**
21
+ * The command description
22
+ */
8
23
  static description: string;
24
+ /**
25
+ * Command options configuration
26
+ */
9
27
  static options: CommandOptions;
28
+ /**
29
+ * The name of the controller
30
+ */
10
31
  name: string;
32
+ /**
33
+ * Create controller with custom method names
34
+ */
11
35
  actions?: string[];
36
+ /**
37
+ * Generate controller in singular form
38
+ */
12
39
  singular: boolean;
40
+ /**
41
+ * Generate resourceful controller with methods to perform CRUD actions on a resource
42
+ */
13
43
  resource: boolean;
44
+ /**
45
+ * Generate resourceful controller without the "edit" and the "create" methods
46
+ */
14
47
  api: boolean;
15
48
  /**
16
49
  * The stub to use for generating the controller
@@ -17,10 +17,28 @@ import { stubsRoot } from "../../stubs/main.js";
17
17
  import { args, flags, BaseCommand } from "../../modules/ace/main.js";
18
18
  /**
19
19
  * The make controller command to create an HTTP controller
20
+ *
21
+ * @example
22
+ * ```
23
+ * ace make:controller User
24
+ * ace make:controller User store update
25
+ * ace make:controller User --resource
26
+ * ace make:controller User --api
27
+ * ace make:controller User --singular
28
+ * ```
20
29
  */
21
30
  export default class MakeController extends BaseCommand {
31
+ /**
32
+ * The command name
33
+ */
22
34
  static commandName = 'make:controller';
35
+ /**
36
+ * The command description
37
+ */
23
38
  static description = 'Create a new HTTP controller class';
39
+ /**
40
+ * Command options configuration
41
+ */
24
42
  static options = {
25
43
  allowUnknownFlags: true,
26
44
  };
@@ -1,16 +1,42 @@
1
1
  import { BaseCommand } from '../../modules/ace/main.ts';
2
2
  import { type CommandOptions } from '../../types/ace.ts';
3
3
  /**
4
- * The make event command to create a class based event
4
+ * Command to create a new event class.
5
+ * Events are data objects that encapsulate information about something
6
+ * that happened in your application and can be dispatched to listeners.
7
+ *
8
+ * @example
9
+ * ```
10
+ * ace make:event UserRegistered
11
+ * ace make:event OrderCompleted
12
+ * ace make:event EmailSent
13
+ * ```
5
14
  */
6
15
  export default class MakeEvent extends BaseCommand {
16
+ /**
17
+ * The command name
18
+ */
7
19
  static commandName: string;
20
+ /**
21
+ * The command description
22
+ */
8
23
  static description: string;
24
+ /**
25
+ * Command options configuration.
26
+ * Allows unknown flags to be passed through.
27
+ */
9
28
  static options: CommandOptions;
29
+ /**
30
+ * Name of the event class to create
31
+ */
10
32
  name: string;
11
33
  /**
12
- * The stub to use for generating the event
34
+ * The stub template file to use for generating the event class
13
35
  */
14
36
  protected stubPath: string;
37
+ /**
38
+ * Execute the command to create a new event class.
39
+ * Generates the event file with proper event structure.
40
+ */
15
41
  run(): Promise<void>;
16
42
  }
@@ -15,18 +15,41 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
15
15
  import { stubsRoot } from "../../stubs/main.js";
16
16
  import { args, BaseCommand } from "../../modules/ace/main.js";
17
17
  /**
18
- * The make event command to create a class based event
18
+ * Command to create a new event class.
19
+ * Events are data objects that encapsulate information about something
20
+ * that happened in your application and can be dispatched to listeners.
21
+ *
22
+ * @example
23
+ * ```
24
+ * ace make:event UserRegistered
25
+ * ace make:event OrderCompleted
26
+ * ace make:event EmailSent
27
+ * ```
19
28
  */
20
29
  export default class MakeEvent extends BaseCommand {
30
+ /**
31
+ * The command name
32
+ */
21
33
  static commandName = 'make:event';
34
+ /**
35
+ * The command description
36
+ */
22
37
  static description = 'Create a new event class';
38
+ /**
39
+ * Command options configuration.
40
+ * Allows unknown flags to be passed through.
41
+ */
23
42
  static options = {
24
43
  allowUnknownFlags: true,
25
44
  };
26
45
  /**
27
- * The stub to use for generating the event
46
+ * The stub template file to use for generating the event class
28
47
  */
29
48
  stubPath = 'make/event/main.stub';
49
+ /**
50
+ * Execute the command to create a new event class.
51
+ * Generates the event file with proper event structure.
52
+ */
30
53
  async run() {
31
54
  const codemods = await this.createCodemods();
32
55
  await codemods.makeUsingStub(stubsRoot, this.stubPath, {
@@ -1,16 +1,42 @@
1
1
  import { BaseCommand } from '../../modules/ace/main.ts';
2
2
  import { type CommandOptions } from '../../types/ace.ts';
3
3
  /**
4
- * Make a new exception class
4
+ * Command to create a new custom exception class.
5
+ * Custom exceptions allow you to define specific error types for your application
6
+ * with custom error messages, status codes, and error handling logic.
7
+ *
8
+ * @example
9
+ * ```
10
+ * ace make:exception ValidationException
11
+ * ace make:exception UnauthorizedException
12
+ * ace make:exception ResourceNotFoundException
13
+ * ```
5
14
  */
6
15
  export default class MakeException extends BaseCommand {
16
+ /**
17
+ * The command name
18
+ */
7
19
  static commandName: string;
20
+ /**
21
+ * The command description
22
+ */
8
23
  static description: string;
24
+ /**
25
+ * Command options configuration.
26
+ * Allows unknown flags to be passed through.
27
+ */
9
28
  static options: CommandOptions;
29
+ /**
30
+ * Name of the exception class to create
31
+ */
10
32
  name: string;
11
33
  /**
12
- * The stub to use for generating the command class
34
+ * The stub template file to use for generating the exception class
13
35
  */
14
36
  protected stubPath: string;
37
+ /**
38
+ * Execute the command to create a new custom exception class.
39
+ * Generates the exception file with proper error handling structure.
40
+ */
15
41
  run(): Promise<void>;
16
42
  }
@@ -15,18 +15,41 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
15
15
  import { stubsRoot } from "../../stubs/main.js";
16
16
  import { args, BaseCommand } from "../../modules/ace/main.js";
17
17
  /**
18
- * Make a new exception class
18
+ * Command to create a new custom exception class.
19
+ * Custom exceptions allow you to define specific error types for your application
20
+ * with custom error messages, status codes, and error handling logic.
21
+ *
22
+ * @example
23
+ * ```
24
+ * ace make:exception ValidationException
25
+ * ace make:exception UnauthorizedException
26
+ * ace make:exception ResourceNotFoundException
27
+ * ```
19
28
  */
20
29
  export default class MakeException extends BaseCommand {
30
+ /**
31
+ * The command name
32
+ */
21
33
  static commandName = 'make:exception';
34
+ /**
35
+ * The command description
36
+ */
22
37
  static description = 'Create a new custom exception class';
38
+ /**
39
+ * Command options configuration.
40
+ * Allows unknown flags to be passed through.
41
+ */
23
42
  static options = {
24
43
  allowUnknownFlags: true,
25
44
  };
26
45
  /**
27
- * The stub to use for generating the command class
46
+ * The stub template file to use for generating the exception class
28
47
  */
29
48
  stubPath = 'make/exception/main.stub';
49
+ /**
50
+ * Execute the command to create a new custom exception class.
51
+ * Generates the exception file with proper error handling structure.
52
+ */
30
53
  async run() {
31
54
  const codemods = await this.createCodemods();
32
55
  await codemods.makeUsingStub(stubsRoot, this.stubPath, {
@@ -1,19 +1,52 @@
1
1
  import { BaseCommand } from '../../modules/ace/main.ts';
2
2
  import { type CommandOptions } from '../../types/ace.ts';
3
3
  /**
4
- * The make listener command to create a class based event
5
- * listener
4
+ * Command to create a new event listener class.
5
+ * Event listeners handle events dispatched by the application and can optionally
6
+ * generate the corresponding event class automatically.
7
+ *
8
+ * @example
9
+ * ```
10
+ * ace make:listener UserRegistered
11
+ * ace make:listener EmailSent --event=EmailSent
12
+ * ace make:listener OrderCompleted --event=OrderEvent
13
+ * ```
6
14
  */
7
15
  export default class MakeListener extends BaseCommand {
16
+ /**
17
+ * The command name
18
+ */
8
19
  static commandName: string;
20
+ /**
21
+ * The command description
22
+ */
9
23
  static description: string;
24
+ /**
25
+ * Command options configuration.
26
+ * Allows unknown flags to be passed through.
27
+ */
10
28
  static options: CommandOptions;
29
+ /**
30
+ * Name of the event listener class to create
31
+ */
11
32
  name: string;
33
+ /**
34
+ * Generate an event class alongside the listener and bind them together
35
+ */
12
36
  event: string;
13
37
  /**
14
- * The stub to use for generating the event listener
38
+ * The stub template file to use for generating the event listener
15
39
  */
16
40
  protected stubPath: string;
41
+ /**
42
+ * Prepare the command by selecting the appropriate stub based on options.
43
+ * Uses a different stub when generating a listener for a specific event.
44
+ */
17
45
  prepare(): void;
46
+ /**
47
+ * Execute the command to create a new event listener.
48
+ * If an event is specified, creates the event class first,
49
+ * then generates the listener with proper event binding.
50
+ */
18
51
  run(): Promise<void>;
19
52
  }
@@ -15,24 +15,51 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
15
15
  import { stubsRoot } from "../../stubs/main.js";
16
16
  import { args, flags, BaseCommand } from "../../modules/ace/main.js";
17
17
  /**
18
- * The make listener command to create a class based event
19
- * listener
18
+ * Command to create a new event listener class.
19
+ * Event listeners handle events dispatched by the application and can optionally
20
+ * generate the corresponding event class automatically.
21
+ *
22
+ * @example
23
+ * ```
24
+ * ace make:listener UserRegistered
25
+ * ace make:listener EmailSent --event=EmailSent
26
+ * ace make:listener OrderCompleted --event=OrderEvent
27
+ * ```
20
28
  */
21
29
  export default class MakeListener extends BaseCommand {
30
+ /**
31
+ * The command name
32
+ */
22
33
  static commandName = 'make:listener';
34
+ /**
35
+ * The command description
36
+ */
23
37
  static description = 'Create a new event listener class';
38
+ /**
39
+ * Command options configuration.
40
+ * Allows unknown flags to be passed through.
41
+ */
24
42
  static options = {
25
43
  allowUnknownFlags: true,
26
44
  };
27
45
  /**
28
- * The stub to use for generating the event listener
46
+ * The stub template file to use for generating the event listener
29
47
  */
30
48
  stubPath = 'make/listener/main.stub';
49
+ /**
50
+ * Prepare the command by selecting the appropriate stub based on options.
51
+ * Uses a different stub when generating a listener for a specific event.
52
+ */
31
53
  prepare() {
32
54
  if (this.event) {
33
55
  this.stubPath = 'make/listener/for_event.stub';
34
56
  }
35
57
  }
58
+ /**
59
+ * Execute the command to create a new event listener.
60
+ * If an event is specified, creates the event class first,
61
+ * then generates the listener with proper event binding.
62
+ */
36
63
  async run() {
37
64
  const codemods = await this.createCodemods();
38
65
  if (this.event) {