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

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 (67) 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 +23 -0
  48. package/build/commands/test.d.ts +66 -3
  49. package/build/commands/test.js +35 -5
  50. package/build/modules/ace/codemods.js +10 -2
  51. package/build/modules/ace/commands.d.ts +0 -1
  52. package/build/modules/ace/commands.js +0 -3
  53. package/build/providers/app_provider.d.ts +2 -2
  54. package/build/providers/app_provider.js +3 -3
  55. package/build/providers/edge_provider.js +10 -0
  56. package/build/src/assembler_hooks/index_entities.d.ts +3 -17
  57. package/build/src/assembler_hooks/index_entities.js +26 -15
  58. package/build/src/helpers/string.js +6 -0
  59. package/build/src/helpers/types.d.ts +1 -0
  60. package/build/src/types.d.ts +6 -0
  61. package/build/src/utils.d.ts +26 -0
  62. package/build/src/utils.js +55 -0
  63. package/build/stubs/make/transformer/main.stub +18 -0
  64. package/build/types/common.d.ts +1 -0
  65. package/build/types/common.js +9 -0
  66. package/build/types/http.d.ts +1 -0
  67. package/package.json +14 -12
@@ -3,12 +3,35 @@ import { BaseCommand } from '../../modules/ace/main.ts';
3
3
  /**
4
4
  * The make middleware command to create a new middleware
5
5
  * class.
6
+ *
7
+ * @example
8
+ * ```
9
+ * ace make:middleware Auth
10
+ * ace make:middleware Auth --stack=server
11
+ * ace make:middleware Auth --stack=named
12
+ * ace make:middleware Auth --stack=router
13
+ * ```
6
14
  */
7
15
  export default class MakeMiddleware 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
+ */
10
27
  static options: CommandOptions;
28
+ /**
29
+ * Name of the middleware
30
+ */
11
31
  name: string;
32
+ /**
33
+ * The stack in which to register the middleware
34
+ */
12
35
  stack?: 'server' | 'named' | 'router';
13
36
  /**
14
37
  * The stub to use for generating the middleware
@@ -20,10 +20,27 @@ import { args, BaseCommand, flags } from "../../modules/ace/main.js";
20
20
  /**
21
21
  * The make middleware command to create a new middleware
22
22
  * class.
23
+ *
24
+ * @example
25
+ * ```
26
+ * ace make:middleware Auth
27
+ * ace make:middleware Auth --stack=server
28
+ * ace make:middleware Auth --stack=named
29
+ * ace make:middleware Auth --stack=router
30
+ * ```
23
31
  */
24
32
  export default class MakeMiddleware extends BaseCommand {
33
+ /**
34
+ * The command name
35
+ */
25
36
  static commandName = 'make:middleware';
37
+ /**
38
+ * The command description
39
+ */
26
40
  static description = 'Create a new middleware class for HTTP requests';
41
+ /**
42
+ * Command options configuration
43
+ */
27
44
  static options = {
28
45
  allowUnknownFlags: true,
29
46
  };
@@ -2,21 +2,48 @@ import { BaseCommand } from '../../modules/ace/main.ts';
2
2
  declare const ALLOWED_ENVIRONMENTS: ("web" | "console" | "test" | "repl")[];
3
3
  type AllowedAppEnvironments = typeof ALLOWED_ENVIRONMENTS;
4
4
  /**
5
- * Make a new preload file
5
+ * Command to create a new preload file in the start directory.
6
+ * Preload files are executed during application startup and can be used
7
+ * to set up global configurations, register global bindings, or perform
8
+ * application-wide initialization tasks.
9
+ *
10
+ * @example
11
+ * ```
12
+ * ace make:preload routes
13
+ * ace make:preload database --register
14
+ * ace make:preload events --no-register
15
+ * ace make:preload kernel --environments=web,console
16
+ * ```
6
17
  */
7
18
  export default class MakePreload extends BaseCommand {
8
19
  #private;
20
+ /**
21
+ * The command name
22
+ */
9
23
  static commandName: string;
24
+ /**
25
+ * The command description
26
+ */
10
27
  static description: string;
28
+ /**
29
+ * Name of the preload file to create
30
+ */
11
31
  name: string;
32
+ /**
33
+ * Automatically register the preload file in the .adonisrc.ts file
34
+ */
12
35
  register?: boolean;
36
+ /**
37
+ * Application environments where the preload file should be loaded
38
+ */
13
39
  environments?: AllowedAppEnvironments;
14
40
  /**
15
- * The stub to use for generating the preload file
41
+ * The stub template file to use for generating the preload file
16
42
  */
17
43
  protected stubPath: string;
18
44
  /**
19
- * Run command
45
+ * Execute the command to create a new preload file.
46
+ * Validates inputs, generates the preload file, and optionally registers it in .adonisrc.ts.
20
47
  */
21
48
  run(): Promise<void>;
22
49
  }
@@ -18,17 +18,36 @@ import stringHelpers from "../../src/helpers/string.js";
18
18
  import { args, flags, BaseCommand } from "../../modules/ace/main.js";
19
19
  const ALLOWED_ENVIRONMENTS = ['web', 'console', 'test', 'repl'];
20
20
  /**
21
- * Make a new preload file
21
+ * Command to create a new preload file in the start directory.
22
+ * Preload files are executed during application startup and can be used
23
+ * to set up global configurations, register global bindings, or perform
24
+ * application-wide initialization tasks.
25
+ *
26
+ * @example
27
+ * ```
28
+ * ace make:preload routes
29
+ * ace make:preload database --register
30
+ * ace make:preload events --no-register
31
+ * ace make:preload kernel --environments=web,console
32
+ * ```
22
33
  */
23
34
  export default class MakePreload extends BaseCommand {
35
+ /**
36
+ * The command name
37
+ */
24
38
  static commandName = 'make:preload';
39
+ /**
40
+ * The command description
41
+ */
25
42
  static description = 'Create a new preload file inside the start directory';
26
43
  /**
27
- * The stub to use for generating the preload file
44
+ * The stub template file to use for generating the preload file
28
45
  */
29
46
  stubPath = 'make/preload/main.stub';
30
47
  /**
31
- * Validate the environments flag passed by the user
48
+ * Validate that all specified environments are valid application environments.
49
+ *
50
+ * @returns True if all environments are valid or none specified, false otherwise
32
51
  */
33
52
  #isEnvironmentsFlagValid() {
34
53
  if (!this.environments || !this.environments.length) {
@@ -37,7 +56,8 @@ export default class MakePreload extends BaseCommand {
37
56
  return this.environments.every((one) => ALLOWED_ENVIRONMENTS.includes(one));
38
57
  }
39
58
  /**
40
- * Run command
59
+ * Execute the command to create a new preload file.
60
+ * Validates inputs, generates the preload file, and optionally registers it in .adonisrc.ts.
41
61
  */
42
62
  async run() {
43
63
  /**
@@ -2,19 +2,48 @@ import { BaseCommand } from '../../modules/ace/main.ts';
2
2
  declare const ALLOWED_ENVIRONMENTS: ("web" | "console" | "test" | "repl")[];
3
3
  type AllowedAppEnvironments = typeof ALLOWED_ENVIRONMENTS;
4
4
  /**
5
- * Make a new provider class
5
+ * Command to create a new service provider class.
6
+ * Service providers are used to register bindings, configure services,
7
+ * and bootstrap application components during startup.
8
+ *
9
+ * @example
10
+ * ```
11
+ * ace make:provider AuthProvider
12
+ * ace make:provider DatabaseProvider --register
13
+ * ace make:provider AppProvider --no-register
14
+ * ace make:provider CacheProvider --environments=web,console
15
+ * ```
6
16
  */
7
17
  export default class MakeProvider extends BaseCommand {
8
18
  #private;
19
+ /**
20
+ * The command name
21
+ */
9
22
  static commandName: string;
23
+ /**
24
+ * The command description
25
+ */
10
26
  static description: string;
27
+ /**
28
+ * Name of the service provider to create
29
+ */
11
30
  name: string;
31
+ /**
32
+ * Automatically register the provider in the .adonisrc.ts file
33
+ */
12
34
  register?: boolean;
35
+ /**
36
+ * Application environments where the provider should be loaded
37
+ */
13
38
  environments?: AllowedAppEnvironments;
14
39
  /**
15
- * The stub to use for generating the provider class
40
+ * The stub template file to use for generating the provider class
16
41
  */
17
42
  protected stubPath: string;
43
+ /**
44
+ * Execute the command to create a new service provider.
45
+ * Validates inputs, generates the provider file, and optionally registers it in .adonisrc.ts.
46
+ */
18
47
  run(): Promise<void>;
19
48
  }
20
49
  export {};
@@ -18,17 +18,35 @@ import stringHelpers from "../../src/helpers/string.js";
18
18
  import { args, BaseCommand, flags } from "../../modules/ace/main.js";
19
19
  const ALLOWED_ENVIRONMENTS = ['web', 'console', 'test', 'repl'];
20
20
  /**
21
- * Make a new provider class
21
+ * Command to create a new service provider class.
22
+ * Service providers are used to register bindings, configure services,
23
+ * and bootstrap application components during startup.
24
+ *
25
+ * @example
26
+ * ```
27
+ * ace make:provider AuthProvider
28
+ * ace make:provider DatabaseProvider --register
29
+ * ace make:provider AppProvider --no-register
30
+ * ace make:provider CacheProvider --environments=web,console
31
+ * ```
22
32
  */
23
33
  export default class MakeProvider extends BaseCommand {
34
+ /**
35
+ * The command name
36
+ */
24
37
  static commandName = 'make:provider';
38
+ /**
39
+ * The command description
40
+ */
25
41
  static description = 'Create a new service provider class';
26
42
  /**
27
- * The stub to use for generating the provider class
43
+ * The stub template file to use for generating the provider class
28
44
  */
29
45
  stubPath = 'make/provider/main.stub';
30
46
  /**
31
- * Validate the environments flag passed by the user
47
+ * Validate that all specified environments are valid application environments.
48
+ *
49
+ * @returns True if all environments are valid or none specified, false otherwise
32
50
  */
33
51
  #isEnvironmentsFlagValid() {
34
52
  if (!this.environments || !this.environments.length) {
@@ -36,6 +54,10 @@ export default class MakeProvider extends BaseCommand {
36
54
  }
37
55
  return this.environments.every((one) => ALLOWED_ENVIRONMENTS.includes(one));
38
56
  }
57
+ /**
58
+ * Execute the command to create a new service provider.
59
+ * Validates inputs, generates the provider file, and optionally registers it in .adonisrc.ts.
60
+ */
39
61
  async run() {
40
62
  /**
41
63
  * Ensure the environments are valid when provided via flag
@@ -2,11 +2,30 @@ import { BaseCommand } from '../../modules/ace/main.ts';
2
2
  import { type CommandOptions } from '../../types/ace.ts';
3
3
  /**
4
4
  * Make a new service class
5
+ *
6
+ * @example
7
+ * ```
8
+ * ace make:service UserService
9
+ * ace make:service AuthService
10
+ * ace make:service User/ProfileService
11
+ * ```
5
12
  */
6
13
  export default class MakeService extends BaseCommand {
14
+ /**
15
+ * The command name
16
+ */
7
17
  static commandName: string;
18
+ /**
19
+ * The command description
20
+ */
8
21
  static description: string;
22
+ /**
23
+ * Command options configuration
24
+ */
9
25
  static options: CommandOptions;
26
+ /**
27
+ * Name of the service
28
+ */
10
29
  name: string;
11
30
  /**
12
31
  * The stub to use for generating the service class
@@ -16,10 +16,26 @@ import { stubsRoot } from "../../stubs/main.js";
16
16
  import { args, BaseCommand } from "../../modules/ace/main.js";
17
17
  /**
18
18
  * Make a new service class
19
+ *
20
+ * @example
21
+ * ```
22
+ * ace make:service UserService
23
+ * ace make:service AuthService
24
+ * ace make:service User/ProfileService
25
+ * ```
19
26
  */
20
27
  export default class MakeService extends BaseCommand {
28
+ /**
29
+ * The command name
30
+ */
21
31
  static commandName = 'make:service';
32
+ /**
33
+ * The command description
34
+ */
22
35
  static description = 'Create a new service class';
36
+ /**
37
+ * Command options configuration
38
+ */
23
39
  static options = {
24
40
  allowUnknownFlags: true,
25
41
  };
@@ -1,19 +1,42 @@
1
1
  import { BaseCommand } from '../../modules/ace/main.ts';
2
2
  /**
3
- * Make a new test file
3
+ * Command to create a new Japa test file.
4
+ * Supports multiple test suites and automatically detects or prompts for
5
+ * the appropriate suite and directory based on application configuration.
6
+ *
7
+ * @example
8
+ * ```
9
+ * ace make:test UserController
10
+ * ace make:test UserModel --suite=unit
11
+ * ace make:test AuthService --suite=integration
12
+ * ```
4
13
  */
5
14
  export default class MakeTest extends BaseCommand {
6
15
  #private;
16
+ /**
17
+ * The command name
18
+ */
7
19
  static commandName: string;
20
+ /**
21
+ * The command description
22
+ */
8
23
  static description: string;
24
+ /**
25
+ * Name of the test file to create
26
+ */
9
27
  name: string;
28
+ /**
29
+ * Test suite name where the test file should be created
30
+ */
10
31
  suite?: string;
11
32
  /**
12
- * The stub to use for generating the test file
33
+ * The stub template file to use for generating the test file
13
34
  */
14
35
  protected stubPath: string;
15
36
  /**
16
- * Executed by ace
37
+ * Execute the command to create a new test file.
38
+ * Validates the suite exists, prompts for missing information,
39
+ * and generates the test file in the appropriate location.
17
40
  */
18
41
  run(): Promise<void>;
19
42
  }
@@ -15,17 +15,36 @@ 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
- * Make a new test file
18
+ * Command to create a new Japa test file.
19
+ * Supports multiple test suites and automatically detects or prompts for
20
+ * the appropriate suite and directory based on application configuration.
21
+ *
22
+ * @example
23
+ * ```
24
+ * ace make:test UserController
25
+ * ace make:test UserModel --suite=unit
26
+ * ace make:test AuthService --suite=integration
27
+ * ```
19
28
  */
20
29
  export default class MakeTest extends BaseCommand {
30
+ /**
31
+ * The command name
32
+ */
21
33
  static commandName = 'make:test';
34
+ /**
35
+ * The command description
36
+ */
22
37
  static description = 'Create a new Japa test file';
23
38
  /**
24
- * The stub to use for generating the test file
39
+ * The stub template file to use for generating the test file
25
40
  */
26
41
  stubPath = 'make/test/main.stub';
27
42
  /**
28
- * Returns the suite name for creating the test file
43
+ * Determine the test suite name for creating the test file.
44
+ * Uses the provided suite flag, or automatically selects if only one suite exists,
45
+ * or prompts the user to choose from available suites.
46
+ *
47
+ * @returns The name of the selected test suite
29
48
  */
30
49
  async #getSuite() {
31
50
  if (this.suite) {
@@ -51,7 +70,11 @@ export default class MakeTest extends BaseCommand {
51
70
  });
52
71
  }
53
72
  /**
54
- * Returns the directory path for the selected suite.
73
+ * Determine the directory path for the test file within the selected suite.
74
+ * Automatically selects if only one directory exists, otherwise prompts the user.
75
+ *
76
+ * @param directories - Array of available directories for the suite
77
+ * @returns The selected directory path
55
78
  */
56
79
  async #getSuiteDirectory(directories) {
57
80
  if (directories.length === 1) {
@@ -64,7 +87,10 @@ export default class MakeTest extends BaseCommand {
64
87
  });
65
88
  }
66
89
  /**
67
- * Find suite info from the rcFile file
90
+ * Find suite configuration from the RC file by name.
91
+ *
92
+ * @param suiteName - The name of the suite to find
93
+ * @returns The suite configuration or undefined if not found
68
94
  */
69
95
  #findSuite(suiteName) {
70
96
  return this.app.rcFile.tests.suites.find((suite) => {
@@ -72,7 +98,9 @@ export default class MakeTest extends BaseCommand {
72
98
  });
73
99
  }
74
100
  /**
75
- * Executed by ace
101
+ * Execute the command to create a new test file.
102
+ * Validates the suite exists, prompts for missing information,
103
+ * and generates the test file in the appropriate location.
76
104
  */
77
105
  async run() {
78
106
  const suite = this.#findSuite(await this.#getSuite());
@@ -0,0 +1,43 @@
1
+ import { BaseCommand } from '../../modules/ace/main.ts';
2
+ import { type CommandOptions } from '../../types/ace.ts';
3
+ /**
4
+ * Command to create a new transformer class.
5
+ * Transformers are used to serialize data objects (like models) into specific
6
+ * formats for API responses, allowing you to control which fields are exposed
7
+ * and how data is structured for clients.
8
+ *
9
+ * @example
10
+ * ```
11
+ * ace make:transformer User
12
+ * ace make:transformer Post
13
+ * ace make:transformer ProductTransformer
14
+ * ```
15
+ */
16
+ export default class MakeTransformer extends BaseCommand {
17
+ /**
18
+ * The command name
19
+ */
20
+ static commandName: string;
21
+ /**
22
+ * The command description
23
+ */
24
+ static description: string;
25
+ /**
26
+ * Command options configuration.
27
+ * Allows unknown flags to be passed through.
28
+ */
29
+ static options: CommandOptions;
30
+ /**
31
+ * Name of the entity for which to generate the transformer
32
+ */
33
+ name: string;
34
+ /**
35
+ * The stub template file to use for generating the transformer class
36
+ */
37
+ protected stubPath: string;
38
+ /**
39
+ * Execute the command to create a new transformer class.
40
+ * Generates the transformer file with proper data serialization structure.
41
+ */
42
+ run(): Promise<void>;
43
+ }
@@ -0,0 +1,65 @@
1
+ /*
2
+ * @adonisjs/core
3
+ *
4
+ * (c) AdonisJS
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ */
9
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
10
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
11
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
12
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
13
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
14
+ };
15
+ import { stubsRoot } from "../../stubs/main.js";
16
+ import { args, BaseCommand } from "../../modules/ace/main.js";
17
+ /**
18
+ * Command to create a new transformer class.
19
+ * Transformers are used to serialize data objects (like models) into specific
20
+ * formats for API responses, allowing you to control which fields are exposed
21
+ * and how data is structured for clients.
22
+ *
23
+ * @example
24
+ * ```
25
+ * ace make:transformer User
26
+ * ace make:transformer Post
27
+ * ace make:transformer ProductTransformer
28
+ * ```
29
+ */
30
+ export default class MakeTransformer extends BaseCommand {
31
+ /**
32
+ * The command name
33
+ */
34
+ static commandName = 'make:transformer';
35
+ /**
36
+ * The command description
37
+ */
38
+ static description = 'Create a new transformer class';
39
+ /**
40
+ * Command options configuration.
41
+ * Allows unknown flags to be passed through.
42
+ */
43
+ static options = {
44
+ allowUnknownFlags: true,
45
+ };
46
+ /**
47
+ * The stub template file to use for generating the transformer class
48
+ */
49
+ stubPath = 'make/transformer/main.stub';
50
+ /**
51
+ * Execute the command to create a new transformer class.
52
+ * Generates the transformer file with proper data serialization structure.
53
+ */
54
+ async run() {
55
+ const codemods = await this.createCodemods();
56
+ await codemods.makeUsingStub(stubsRoot, this.stubPath, {
57
+ flags: this.parsed.flags,
58
+ entity: this.app.generators.createEntity(this.name),
59
+ model: this.app.generators.createEntity(this.name),
60
+ });
61
+ }
62
+ }
63
+ __decorate([
64
+ args.string({ description: 'Entity name for which to generate the transformer' })
65
+ ], MakeTransformer.prototype, "name", void 0);
@@ -1,21 +1,52 @@
1
1
  import { BaseCommand } from '../../modules/ace/main.ts';
2
2
  import { type CommandOptions } from '../../types/ace.ts';
3
3
  /**
4
- * Make a new VineJS validator
4
+ * Command to create a new VineJS validator file.
5
+ * Validators define reusable validation schemas for request validation,
6
+ * and can be generated as simple validators or resource-based validators
7
+ * with create and update schemas.
8
+ *
9
+ * @example
10
+ * ```
11
+ * ace make:validator UserValidator
12
+ * ace make:validator PostValidator --resource
13
+ * ace make:validator ContactValidator
14
+ * ```
5
15
  */
6
16
  export default class MakeValidator extends BaseCommand {
17
+ /**
18
+ * The command name
19
+ */
7
20
  static commandName: string;
21
+ /**
22
+ * The command description
23
+ */
8
24
  static description: string;
25
+ /**
26
+ * Command options configuration.
27
+ * Allows unknown flags to be passed through.
28
+ */
9
29
  static options: CommandOptions;
30
+ /**
31
+ * Name of the validator file to create
32
+ */
10
33
  name: string;
34
+ /**
35
+ * Generate a resource validator with create and update schemas
36
+ */
11
37
  resource: boolean;
12
38
  /**
13
- * The stub to use for generating the validator
39
+ * The stub template file to use for generating the validator
14
40
  */
15
41
  protected stubPath: string;
16
42
  /**
17
- * Preparing the command state
43
+ * Prepare the command by selecting the appropriate stub based on options.
44
+ * Uses a resource stub when generating validators for CRUD operations.
18
45
  */
19
46
  prepare(): Promise<void>;
47
+ /**
48
+ * Execute the command to create a new VineJS validator file.
49
+ * Generates the validator with the appropriate stub template.
50
+ */
20
51
  run(): Promise<void>;
21
52
  }
@@ -15,20 +15,41 @@ 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
- * Make a new VineJS validator
18
+ * Command to create a new VineJS validator file.
19
+ * Validators define reusable validation schemas for request validation,
20
+ * and can be generated as simple validators or resource-based validators
21
+ * with create and update schemas.
22
+ *
23
+ * @example
24
+ * ```
25
+ * ace make:validator UserValidator
26
+ * ace make:validator PostValidator --resource
27
+ * ace make:validator ContactValidator
28
+ * ```
19
29
  */
20
30
  export default class MakeValidator extends BaseCommand {
31
+ /**
32
+ * The command name
33
+ */
21
34
  static commandName = 'make:validator';
35
+ /**
36
+ * The command description
37
+ */
22
38
  static description = 'Create a new file to define VineJS validators';
39
+ /**
40
+ * Command options configuration.
41
+ * Allows unknown flags to be passed through.
42
+ */
23
43
  static options = {
24
44
  allowUnknownFlags: true,
25
45
  };
26
46
  /**
27
- * The stub to use for generating the validator
47
+ * The stub template file to use for generating the validator
28
48
  */
29
49
  stubPath = 'make/validator/main.stub';
30
50
  /**
31
- * Preparing the command state
51
+ * Prepare the command by selecting the appropriate stub based on options.
52
+ * Uses a resource stub when generating validators for CRUD operations.
32
53
  */
33
54
  async prepare() {
34
55
  /**
@@ -38,6 +59,10 @@ export default class MakeValidator extends BaseCommand {
38
59
  this.stubPath = 'make/validator/resource.stub';
39
60
  }
40
61
  }
62
+ /**
63
+ * Execute the command to create a new VineJS validator file.
64
+ * Generates the validator with the appropriate stub template.
65
+ */
41
66
  async run() {
42
67
  const codemods = await this.createCodemods();
43
68
  await codemods.makeUsingStub(stubsRoot, this.stubPath, {