@adonisjs/core 7.0.0-next.1 → 7.0.0-next.11

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 (145) hide show
  1. package/build/commands/add.js +40 -110
  2. package/build/commands/build.js +51 -107
  3. package/build/commands/configure.js +82 -177
  4. package/build/commands/eject.js +17 -60
  5. package/build/commands/env/add.js +55 -134
  6. package/build/commands/generate_key.js +22 -66
  7. package/build/commands/inspect_rcfile.js +27 -55
  8. package/build/commands/list/routes.js +246 -116
  9. package/build/commands/make/command.js +15 -57
  10. package/build/commands/make/controller.js +43 -120
  11. package/build/commands/make/event.js +16 -62
  12. package/build/commands/make/exception.js +16 -62
  13. package/build/commands/make/listener.js +36 -93
  14. package/build/commands/make/middleware.js +41 -101
  15. package/build/commands/make/preload.js +47 -113
  16. package/build/commands/make/provider.js +47 -112
  17. package/build/commands/make/service.js +16 -55
  18. package/build/commands/make/test.js +47 -132
  19. package/build/commands/make/transformer.js +17 -64
  20. package/build/commands/make/validator.js +20 -80
  21. package/build/commands/make/view.js +15 -56
  22. package/build/commands/repl.js +17 -50
  23. package/build/commands/serve.js +80 -156
  24. package/build/commands/test.js +92 -208
  25. package/build/factories/app.js +2 -9
  26. package/build/factories/bodyparser.js +2 -9
  27. package/build/factories/core/ace.js +15 -46
  28. package/build/factories/core/ignitor.js +12 -180
  29. package/build/factories/core/main.js +22 -11
  30. package/build/factories/core/test_utils.js +19 -43
  31. package/build/factories/encryption.js +2 -9
  32. package/build/factories/events.js +2 -9
  33. package/build/factories/hash.js +2 -9
  34. package/build/factories/http.js +2 -9
  35. package/build/factories/logger.js +2 -9
  36. package/build/factories/stubs.js +28 -91
  37. package/build/index.js +13 -46
  38. package/build/modules/ace/codemods.d.ts +109 -14
  39. package/build/modules/ace/codemods.js +222 -374
  40. package/build/modules/ace/main.d.ts +30 -0
  41. package/build/modules/ace/main.js +2 -11
  42. package/build/modules/app.d.ts +17 -0
  43. package/build/modules/app.js +4 -9
  44. package/build/modules/bodyparser/bodyparser_middleware.js +2 -14
  45. package/build/modules/bodyparser/main.js +4 -9
  46. package/build/modules/config.d.ts +17 -0
  47. package/build/modules/config.js +4 -9
  48. package/build/modules/container.js +4 -9
  49. package/build/modules/dumper/dumper.d.ts +5 -0
  50. package/build/modules/dumper/main.d.ts +21 -0
  51. package/build/modules/dumper/main.js +6 -11
  52. package/build/modules/dumper/plugins/edge.js +2 -62
  53. package/build/modules/encryption.d.ts +17 -0
  54. package/build/modules/encryption.js +4 -9
  55. package/build/modules/env/editor.js +2 -9
  56. package/build/modules/env/main.d.ts +19 -0
  57. package/build/modules/env/main.js +2 -9
  58. package/build/modules/events.js +4 -9
  59. package/build/modules/hash/drivers/argon.js +2 -9
  60. package/build/modules/hash/drivers/bcrypt.d.ts +11 -0
  61. package/build/modules/hash/drivers/bcrypt.js +2 -9
  62. package/build/modules/hash/drivers/scrypt.js +2 -9
  63. package/build/modules/hash/main.d.ts +18 -0
  64. package/build/modules/hash/main.js +6 -10
  65. package/build/modules/hash/phc_formatter.js +2 -9
  66. package/build/modules/health.js +2 -9
  67. package/build/modules/http/main.js +4 -15
  68. package/build/modules/http/url_builder_client.d.ts +1 -0
  69. package/build/modules/http/url_builder_client.js +2 -0
  70. package/build/modules/logger.d.ts +30 -0
  71. package/build/modules/logger.js +4 -9
  72. package/build/modules/repl.js +4 -9
  73. package/build/modules/transformers/main.js +4 -9
  74. package/build/providers/app_provider.d.ts +9 -21
  75. package/build/providers/app_provider.js +147 -363
  76. package/build/providers/edge_provider.js +97 -104
  77. package/build/providers/hash_provider.js +29 -91
  78. package/build/providers/repl_provider.js +61 -152
  79. package/build/providers/vinejs_provider.d.ts +1 -1
  80. package/build/providers/vinejs_provider.js +20 -66
  81. package/build/services/ace.js +2 -17
  82. package/build/services/app.js +2 -21
  83. package/build/services/config.js +2 -13
  84. package/build/services/dumper.js +5 -21
  85. package/build/services/emitter.js +2 -14
  86. package/build/services/encryption.js +2 -14
  87. package/build/services/hash.js +2 -14
  88. package/build/services/logger.js +2 -14
  89. package/build/services/repl.js +2 -14
  90. package/build/services/router.js +2 -14
  91. package/build/services/server.js +2 -14
  92. package/build/services/test_utils.js +2 -17
  93. package/build/services/url_builder.js +5 -17
  94. package/build/src/exceptions.js +2 -49
  95. package/build/src/helpers/assert.js +2 -55
  96. package/build/src/helpers/http.d.ts +20 -0
  97. package/build/src/helpers/http.js +2 -0
  98. package/build/src/helpers/is.js +3 -31
  99. package/build/src/helpers/main.d.ts +1 -5
  100. package/build/src/helpers/main.js +5 -56
  101. package/build/src/helpers/string.js +2 -60
  102. package/build/src/helpers/types.js +26 -135
  103. package/build/src/helpers/verification_token.js +2 -120
  104. package/build/src/test_utils/main.js +5 -77
  105. package/build/src/types.d.ts +1 -0
  106. package/build/src/types.js +0 -8
  107. package/build/src/utils.d.ts +1 -1
  108. package/build/src/vine.js +2 -97
  109. package/build/types/ace.js +2 -9
  110. package/build/types/app.js +2 -9
  111. package/build/types/bodyparser.js +2 -9
  112. package/build/types/common.js +2 -9
  113. package/build/types/container.js +2 -9
  114. package/build/types/encryption.js +2 -9
  115. package/build/types/events.js +2 -9
  116. package/build/types/hash.js +2 -9
  117. package/build/types/health.js +2 -9
  118. package/build/types/helpers.d.ts +20 -0
  119. package/build/types/helpers.js +0 -8
  120. package/build/types/http.js +2 -9
  121. package/build/types/logger.js +2 -9
  122. package/build/types/repl.js +2 -9
  123. package/build/types/transformers.js +2 -9
  124. package/package.json +88 -30
  125. package/build/modules/ace/commands.js +0 -157
  126. package/build/modules/ace/create_kernel.js +0 -91
  127. package/build/modules/ace/kernel.js +0 -40
  128. package/build/modules/dumper/define_config.js +0 -36
  129. package/build/modules/dumper/dumper.js +0 -256
  130. package/build/modules/dumper/errors.js +0 -119
  131. package/build/modules/hash/define_config.js +0 -125
  132. package/build/modules/http/request_validator.js +0 -100
  133. package/build/src/assembler_hooks/index_entities.js +0 -106
  134. package/build/src/cli_formatters/routes_list.js +0 -381
  135. package/build/src/config_provider.js +0 -71
  136. package/build/src/debug.js +0 -25
  137. package/build/src/ignitor/ace.js +0 -102
  138. package/build/src/ignitor/http.js +0 -146
  139. package/build/src/ignitor/main.js +0 -124
  140. package/build/src/ignitor/test.js +0 -66
  141. package/build/src/test_utils/http.js +0 -82
  142. package/build/src/utils.js +0 -104
  143. package/build/stubs/main.js +0 -9
  144. package/build/toolkit/commands/index_commands.js +0 -30
  145. package/build/toolkit/main.js +0 -27
@@ -1,63 +1,17 @@
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;
1
+ import { t as stubsRoot } from "../../main-kn40V-hF.js";
2
+ import { f as BaseCommand, o as args } from "../../main-Cn_x9YY5.js";
3
+ import { t as __decorate } from "../../decorate-DM0Sx1ye.js";
4
+ var MakeEvent = class extends BaseCommand {
5
+ static commandName = "make:event";
6
+ static description = "Create a new event class";
7
+ static options = { allowUnknownFlags: true };
8
+ stubPath = "make/event/main.stub";
9
+ async run() {
10
+ await (await this.createCodemods()).makeUsingStub(stubsRoot, this.stubPath, {
11
+ flags: this.parsed.flags,
12
+ entity: this.app.generators.createEntity(this.name)
13
+ });
14
+ }
14
15
  };
15
- import { stubsRoot } from "../../stubs/main.js";
16
- import { args, BaseCommand } from "../../modules/ace/main.js";
17
- /**
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
- * ```
28
- */
29
- export default class MakeEvent extends BaseCommand {
30
- /**
31
- * The command name
32
- */
33
- static commandName = 'make:event';
34
- /**
35
- * The command description
36
- */
37
- static description = 'Create a new event class';
38
- /**
39
- * Command options configuration.
40
- * Allows unknown flags to be passed through.
41
- */
42
- static options = {
43
- allowUnknownFlags: true,
44
- };
45
- /**
46
- * The stub template file to use for generating the event class
47
- */
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
- */
53
- async run() {
54
- const codemods = await this.createCodemods();
55
- await codemods.makeUsingStub(stubsRoot, this.stubPath, {
56
- flags: this.parsed.flags,
57
- entity: this.app.generators.createEntity(this.name),
58
- });
59
- }
60
- }
61
- __decorate([
62
- args.string({ description: 'Name of the event' })
63
- ], MakeEvent.prototype, "name", void 0);
16
+ __decorate([args.string({ description: "Name of the event" })], MakeEvent.prototype, "name", void 0);
17
+ export { MakeEvent as default };
@@ -1,63 +1,17 @@
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;
1
+ import { t as stubsRoot } from "../../main-kn40V-hF.js";
2
+ import { f as BaseCommand, o as args } from "../../main-Cn_x9YY5.js";
3
+ import { t as __decorate } from "../../decorate-DM0Sx1ye.js";
4
+ var MakeException = class extends BaseCommand {
5
+ static commandName = "make:exception";
6
+ static description = "Create a new custom exception class";
7
+ static options = { allowUnknownFlags: true };
8
+ stubPath = "make/exception/main.stub";
9
+ async run() {
10
+ await (await this.createCodemods()).makeUsingStub(stubsRoot, this.stubPath, {
11
+ flags: this.parsed.flags,
12
+ entity: this.app.generators.createEntity(this.name)
13
+ });
14
+ }
14
15
  };
15
- import { stubsRoot } from "../../stubs/main.js";
16
- import { args, BaseCommand } from "../../modules/ace/main.js";
17
- /**
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
- * ```
28
- */
29
- export default class MakeException extends BaseCommand {
30
- /**
31
- * The command name
32
- */
33
- static commandName = 'make:exception';
34
- /**
35
- * The command description
36
- */
37
- static description = 'Create a new custom exception class';
38
- /**
39
- * Command options configuration.
40
- * Allows unknown flags to be passed through.
41
- */
42
- static options = {
43
- allowUnknownFlags: true,
44
- };
45
- /**
46
- * The stub template file to use for generating the exception class
47
- */
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
- */
53
- async run() {
54
- const codemods = await this.createCodemods();
55
- await codemods.makeUsingStub(stubsRoot, this.stubPath, {
56
- flags: this.parsed.flags,
57
- entity: this.app.generators.createEntity(this.name),
58
- });
59
- }
60
- }
61
- __decorate([
62
- args.string({ description: 'Name of the exception' })
63
- ], MakeException.prototype, "name", void 0);
16
+ __decorate([args.string({ description: "Name of the exception" })], MakeException.prototype, "name", void 0);
17
+ export { MakeException as default };
@@ -1,94 +1,37 @@
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;
1
+ import { t as stubsRoot } from "../../main-kn40V-hF.js";
2
+ import { f as BaseCommand, l as flags, o as args } from "../../main-Cn_x9YY5.js";
3
+ import { t as __decorate } from "../../decorate-DM0Sx1ye.js";
4
+ var MakeListener = class extends BaseCommand {
5
+ static commandName = "make:listener";
6
+ static description = "Create a new event listener class";
7
+ static options = { allowUnknownFlags: true };
8
+ stubPath = "make/listener/main.stub";
9
+ prepare() {
10
+ if (this.event) this.stubPath = "make/listener/for_event.stub";
11
+ }
12
+ async run() {
13
+ const codemods = await this.createCodemods();
14
+ if (this.event) {
15
+ const { exitCode } = await this.kernel.exec("make:event", [this.event]);
16
+ if (exitCode === 0) {
17
+ const eventEntity = this.app.generators.createEntity(this.event);
18
+ await codemods.makeUsingStub(stubsRoot, this.stubPath, {
19
+ event: eventEntity,
20
+ flags: this.parsed.flags,
21
+ entity: this.app.generators.createEntity(this.name)
22
+ });
23
+ }
24
+ return;
25
+ }
26
+ await codemods.makeUsingStub(stubsRoot, this.stubPath, {
27
+ flags: this.parsed.flags,
28
+ entity: this.app.generators.createEntity(this.name)
29
+ });
30
+ }
14
31
  };
15
- import { stubsRoot } from "../../stubs/main.js";
16
- import { args, flags, BaseCommand } from "../../modules/ace/main.js";
17
- /**
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
- * ```
28
- */
29
- export default class MakeListener extends BaseCommand {
30
- /**
31
- * The command name
32
- */
33
- static commandName = 'make:listener';
34
- /**
35
- * The command description
36
- */
37
- static description = 'Create a new event listener class';
38
- /**
39
- * Command options configuration.
40
- * Allows unknown flags to be passed through.
41
- */
42
- static options = {
43
- allowUnknownFlags: true,
44
- };
45
- /**
46
- * The stub template file to use for generating the event listener
47
- */
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
- */
53
- prepare() {
54
- if (this.event) {
55
- this.stubPath = 'make/listener/for_event.stub';
56
- }
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
- */
63
- async run() {
64
- const codemods = await this.createCodemods();
65
- if (this.event) {
66
- const { exitCode } = await this.kernel.exec('make:event', [this.event]);
67
- /**
68
- * Create listener only when make:event is completed successfully
69
- */
70
- if (exitCode === 0) {
71
- const eventEntity = this.app.generators.createEntity(this.event);
72
- await codemods.makeUsingStub(stubsRoot, this.stubPath, {
73
- event: eventEntity,
74
- flags: this.parsed.flags,
75
- entity: this.app.generators.createEntity(this.name),
76
- });
77
- }
78
- return;
79
- }
80
- await codemods.makeUsingStub(stubsRoot, this.stubPath, {
81
- flags: this.parsed.flags,
82
- entity: this.app.generators.createEntity(this.name),
83
- });
84
- }
85
- }
86
- __decorate([
87
- args.string({ description: 'Name of the event listener' })
88
- ], MakeListener.prototype, "name", void 0);
89
- __decorate([
90
- flags.string({
91
- description: 'Generate an event class alongside the listener',
92
- alias: 'e',
93
- })
94
- ], MakeListener.prototype, "event", void 0);
32
+ __decorate([args.string({ description: "Name of the event listener" })], MakeListener.prototype, "name", void 0);
33
+ __decorate([flags.string({
34
+ description: "Generate an event class alongside the listener",
35
+ alias: "e"
36
+ })], MakeListener.prototype, "event", void 0);
37
+ export { MakeListener as default };
@@ -1,102 +1,42 @@
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;
1
+ import { t as stubsRoot } from "../../main-kn40V-hF.js";
2
+ import { t as string_default } from "../../string-CJ7ewUFq.js";
3
+ import { f as BaseCommand, l as flags, o as args } from "../../main-Cn_x9YY5.js";
4
+ import { t as __decorate } from "../../decorate-DM0Sx1ye.js";
5
+ import string from "@poppinss/utils/string";
6
+ import { basename, extname, relative } from "node:path";
7
+ var MakeMiddleware = class extends BaseCommand {
8
+ static commandName = "make:middleware";
9
+ static description = "Create a new middleware class for HTTP requests";
10
+ static options = { allowUnknownFlags: true };
11
+ stubPath = "make/middleware/main.stub";
12
+ async run() {
13
+ const stackChoices = [
14
+ "server",
15
+ "router",
16
+ "named"
17
+ ];
18
+ if (!this.stack) this.stack = await this.prompt.choice("Under which stack you want to register the middleware?", stackChoices);
19
+ if (!stackChoices.includes(this.stack)) {
20
+ this.exitCode = 1;
21
+ this.logger.error(`Invalid middleware stack "${this.stack}". Select from "${stackChoices.join(", ")}"`);
22
+ return;
23
+ }
24
+ const codemods = await this.createCodemods();
25
+ const { destination } = await codemods.makeUsingStub(stubsRoot, this.stubPath, {
26
+ flags: this.parsed.flags,
27
+ entity: this.app.generators.createEntity(this.name)
28
+ });
29
+ const middlewareRelativePath = string_default.toUnixSlash(relative(this.app.middlewarePath(), destination).replace(extname(destination), ""));
30
+ const name = string.camelCase(basename(middlewareRelativePath).replace(/_middleware$/, ""));
31
+ await codemods.registerMiddleware(this.stack, [{
32
+ name,
33
+ path: `#middleware/${middlewareRelativePath}`
34
+ }]);
35
+ }
14
36
  };
15
- import string from '@poppinss/utils/string';
16
- import { basename, extname, relative } from 'node:path';
17
- import { stubsRoot } from "../../stubs/main.js";
18
- import stringHelpers from "../../src/helpers/string.js";
19
- import { args, BaseCommand, flags } from "../../modules/ace/main.js";
20
- /**
21
- * The make middleware command to create a new middleware
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
- * ```
31
- */
32
- export default class MakeMiddleware extends BaseCommand {
33
- /**
34
- * The command name
35
- */
36
- static commandName = 'make:middleware';
37
- /**
38
- * The command description
39
- */
40
- static description = 'Create a new middleware class for HTTP requests';
41
- /**
42
- * Command options configuration
43
- */
44
- static options = {
45
- allowUnknownFlags: true,
46
- };
47
- /**
48
- * The stub to use for generating the middleware
49
- */
50
- stubPath = 'make/middleware/main.stub';
51
- async run() {
52
- const stackChoices = ['server', 'router', 'named'];
53
- /**
54
- * Prompt to select the stack under which to register
55
- * the middleware
56
- */
57
- if (!this.stack) {
58
- this.stack = await this.prompt.choice('Under which stack you want to register the middleware?', stackChoices);
59
- }
60
- /**
61
- * Error out when mentioned stack is invalid
62
- */
63
- if (!stackChoices.includes(this.stack)) {
64
- this.exitCode = 1;
65
- this.logger.error(`Invalid middleware stack "${this.stack}". Select from "${stackChoices.join(', ')}"`);
66
- return;
67
- }
68
- /**
69
- * Create middleware
70
- */
71
- const codemods = await this.createCodemods();
72
- const { destination } = await codemods.makeUsingStub(stubsRoot, this.stubPath, {
73
- flags: this.parsed.flags,
74
- entity: this.app.generators.createEntity(this.name),
75
- });
76
- /**
77
- * Creative relative path for the middleware file from
78
- * the "./app/middleware" directory
79
- */
80
- const middlewareRelativePath = stringHelpers.toUnixSlash(relative(this.app.middlewarePath(), destination).replace(extname(destination), ''));
81
- /**
82
- * Take the middleware relative path, remove `_middleware` prefix from it
83
- * and convert everything to camelcase
84
- */
85
- const name = string.camelCase(basename(middlewareRelativePath).replace(/_middleware$/, ''));
86
- /**
87
- * Register middleware
88
- */
89
- await codemods.registerMiddleware(this.stack, [
90
- {
91
- name: name,
92
- path: `#middleware/${middlewareRelativePath}`,
93
- },
94
- ]);
95
- }
96
- }
97
- __decorate([
98
- args.string({ description: 'Name of the middleware' })
99
- ], MakeMiddleware.prototype, "name", void 0);
100
- __decorate([
101
- flags.string({ description: 'The stack in which to register the middleware', alias: 's' })
102
- ], MakeMiddleware.prototype, "stack", void 0);
37
+ __decorate([args.string({ description: "Name of the middleware" })], MakeMiddleware.prototype, "name", void 0);
38
+ __decorate([flags.string({
39
+ description: "The stack in which to register the middleware",
40
+ alias: "s"
41
+ })], MakeMiddleware.prototype, "stack", void 0);
42
+ export { MakeMiddleware as default };
@@ -1,114 +1,48 @@
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;
1
+ import { t as stubsRoot } from "../../main-kn40V-hF.js";
2
+ import { t as string_default } from "../../string-CJ7ewUFq.js";
3
+ import { f as BaseCommand, l as flags, o as args } from "../../main-Cn_x9YY5.js";
4
+ import { t as __decorate } from "../../decorate-DM0Sx1ye.js";
5
+ import { extname, relative } from "node:path";
6
+ const ALLOWED_ENVIRONMENTS = [
7
+ "web",
8
+ "console",
9
+ "test",
10
+ "repl"
11
+ ];
12
+ var MakePreload = class extends BaseCommand {
13
+ static commandName = "make:preload";
14
+ static description = "Create a new preload file inside the start directory";
15
+ stubPath = "make/preload/main.stub";
16
+ #isEnvironmentsFlagValid() {
17
+ if (!this.environments || !this.environments.length) return true;
18
+ return this.environments.every((one) => ALLOWED_ENVIRONMENTS.includes(one));
19
+ }
20
+ async run() {
21
+ if (!this.#isEnvironmentsFlagValid()) {
22
+ this.logger.error(`Invalid environment(s) "${this.environments}". Only "${ALLOWED_ENVIRONMENTS}" are allowed`);
23
+ return;
24
+ }
25
+ if (this.register === void 0) this.register = await this.prompt.confirm("Do you want to register the preload file in .adonisrc.ts file?");
26
+ const codemods = await this.createCodemods();
27
+ const { destination } = await codemods.makeUsingStub(stubsRoot, this.stubPath, {
28
+ flags: this.parsed.flags,
29
+ entity: this.app.generators.createEntity(this.name)
30
+ });
31
+ if (!this.register) return;
32
+ const preloadFileRelativePath = string_default.toUnixSlash(relative(this.app.startPath(), destination).replace(extname(destination), ""));
33
+ await codemods.updateRcFile((rcFile) => {
34
+ rcFile.addPreloadFile(`#start/${preloadFileRelativePath}`, this.environments);
35
+ });
36
+ }
14
37
  };
15
- import { extname, relative } from 'node:path';
16
- import { stubsRoot } from "../../stubs/main.js";
17
- import stringHelpers from "../../src/helpers/string.js";
18
- import { args, flags, BaseCommand } from "../../modules/ace/main.js";
19
- const ALLOWED_ENVIRONMENTS = ['web', 'console', 'test', 'repl'];
20
- /**
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
- * ```
33
- */
34
- export default class MakePreload extends BaseCommand {
35
- /**
36
- * The command name
37
- */
38
- static commandName = 'make:preload';
39
- /**
40
- * The command description
41
- */
42
- static description = 'Create a new preload file inside the start directory';
43
- /**
44
- * The stub template file to use for generating the preload file
45
- */
46
- stubPath = 'make/preload/main.stub';
47
- /**
48
- * Validate that all specified environments are valid application environments.
49
- *
50
- * @returns True if all environments are valid or none specified, false otherwise
51
- */
52
- #isEnvironmentsFlagValid() {
53
- if (!this.environments || !this.environments.length) {
54
- return true;
55
- }
56
- return this.environments.every((one) => ALLOWED_ENVIRONMENTS.includes(one));
57
- }
58
- /**
59
- * Execute the command to create a new preload file.
60
- * Validates inputs, generates the preload file, and optionally registers it in .adonisrc.ts.
61
- */
62
- async run() {
63
- /**
64
- * Ensure the environments are valid when provided via flag
65
- */
66
- if (!this.#isEnvironmentsFlagValid()) {
67
- this.logger.error(`Invalid environment(s) "${this.environments}". Only "${ALLOWED_ENVIRONMENTS}" are allowed`);
68
- return;
69
- }
70
- /**
71
- * Display prompt to know if we should register the preload
72
- * file inside the ".adonisrc.ts" file.
73
- */
74
- if (this.register === undefined) {
75
- this.register = await this.prompt.confirm('Do you want to register the preload file in .adonisrc.ts file?');
76
- }
77
- const codemods = await this.createCodemods();
78
- const { destination } = await codemods.makeUsingStub(stubsRoot, this.stubPath, {
79
- flags: this.parsed.flags,
80
- entity: this.app.generators.createEntity(this.name),
81
- });
82
- /**
83
- * Do not register when prompt has been denied or "--no-register"
84
- * flag was used
85
- */
86
- if (!this.register) {
87
- return;
88
- }
89
- /**
90
- * Creative relative path for the preload file from
91
- * the "./start" directory
92
- */
93
- const preloadFileRelativePath = stringHelpers.toUnixSlash(relative(this.app.startPath(), destination).replace(extname(destination), ''));
94
- await codemods.updateRcFile((rcFile) => {
95
- rcFile.addPreloadFile(`#start/${preloadFileRelativePath}`, this.environments);
96
- });
97
- }
98
- }
99
- __decorate([
100
- args.string({ description: 'Name of the preload file' })
101
- ], MakePreload.prototype, "name", void 0);
102
- __decorate([
103
- flags.boolean({
104
- description: 'Auto register the preload file inside the .adonisrc.ts file',
105
- showNegatedVariantInHelp: true,
106
- alias: 'r',
107
- })
108
- ], MakePreload.prototype, "register", void 0);
109
- __decorate([
110
- flags.array({
111
- description: `Define the preload file's environment. Accepted values are "${ALLOWED_ENVIRONMENTS}"`,
112
- alias: 'e',
113
- })
114
- ], MakePreload.prototype, "environments", void 0);
38
+ __decorate([args.string({ description: "Name of the preload file" })], MakePreload.prototype, "name", void 0);
39
+ __decorate([flags.boolean({
40
+ description: "Auto register the preload file inside the .adonisrc.ts file",
41
+ showNegatedVariantInHelp: true,
42
+ alias: "r"
43
+ })], MakePreload.prototype, "register", void 0);
44
+ __decorate([flags.array({
45
+ description: `Define the preload file's environment. Accepted values are "${ALLOWED_ENVIRONMENTS}"`,
46
+ alias: "e"
47
+ })], MakePreload.prototype, "environments", void 0);
48
+ export { MakePreload as default };