@adonisjs/core 7.0.1 → 7.1.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.
- package/build/ace-DBm6EcQ-.js +37 -0
- package/build/app-BCcG_oDd.js +7 -0
- package/build/app-CAuSGb2P.js +15 -0
- package/build/bodyparser_middleware-H5FArWkI.js +9 -0
- package/build/{chunk-iKc69rpz.js → chunk-Do49iUES.js} +3 -0
- package/build/commands/add.d.ts +1 -0
- package/build/commands/add.js +64 -10
- package/build/commands/build.js +41 -3
- package/build/commands/commands.json +1 -1
- package/build/commands/configure.js +70 -4
- package/build/commands/eject.js +30 -4
- package/build/commands/env/add.js +62 -4
- package/build/commands/generate_key.js +23 -3
- package/build/commands/inspect_rcfile.js +26 -2
- package/build/commands/list/routes.d.ts +5 -0
- package/build/commands/list/routes.js +242 -3
- package/build/commands/make/command.js +33 -4
- package/build/commands/make/controller.js +46 -4
- package/build/commands/make/event.js +36 -4
- package/build/commands/make/exception.js +36 -4
- package/build/commands/make/listener.js +44 -4
- package/build/commands/make/middleware.js +53 -5
- package/build/commands/make/preload.js +55 -5
- package/build/commands/make/provider.js +54 -5
- package/build/commands/make/service.js +29 -4
- package/build/commands/make/test.js +63 -4
- package/build/commands/make/transformer.js +37 -4
- package/build/commands/make/validator.js +44 -4
- package/build/commands/make/view.js +33 -4
- package/build/commands/repl.js +31 -2
- package/build/commands/serve.js +54 -4
- package/build/commands/test.js +69 -4
- package/build/config-Coti2q6R.js +7 -0
- package/build/config_provider-Do9af1ze.js +35 -0
- package/build/container-CGfEwWof.js +7 -0
- package/build/{core-IpCOCkUL.js → core-XjMm_ipu.js} +51 -2
- package/build/create_kernel-BV3swyCg.js +4 -0
- package/build/{create_kernel-B7ILNhuP.js → create_kernel-D38-0Zbt.js} +41 -1
- package/build/debug-DWofTfIX.js +20 -0
- package/build/{decorate-DmrZA614.js → decorate-B9Uz0anB.js} +2 -0
- package/build/{define_config-0oHaj43l.js → define_config--5euEdi8.js} +54 -3
- package/build/dumper-3R77st8F.js +353 -0
- package/build/edge-BG5ZYp6Z.js +57 -0
- package/build/{errors-CrCO-k44.js → errors-BScZTzBu.js} +9 -1
- package/build/events-DlKX1ZdL.js +7 -0
- package/build/exceptions-B2MzIlHY.js +2 -0
- package/build/factories/app.js +1 -0
- package/build/factories/bodyparser.js +1 -0
- package/build/factories/core/ace.js +16 -22
- package/build/factories/core/ignitor.js +13 -73
- package/build/factories/core/main.js +25 -17
- package/build/factories/core/test_utils.js +22 -19
- package/build/factories/encryption.js +1 -0
- package/build/factories/events.js +1 -0
- package/build/factories/hash.js +1 -0
- package/build/factories/http.js +1 -0
- package/build/factories/logger.js +1 -0
- package/build/factories/stubs.js +75 -7
- package/build/ignitor-Kym3gR-I.js +169 -0
- package/build/index.js +11 -8
- package/build/logger-DIdZPHCe.js +43 -0
- package/build/main-B50zECAi.js +121 -0
- package/build/main-CRnMnrH7.js +184 -0
- package/build/{main-kn40V-hF.js → main-CfTiGsiS.js} +2 -0
- package/build/main-Ck0GqLx4.js +117 -0
- package/build/main-CoZI4Ezs.js +2 -0
- package/build/main-D1MSq4Uu.js +435 -0
- package/build/{main--nXd7T-C.js → main-bRYXIHgD.js} +75 -3
- package/build/main-zxNP7iRl.js +7 -0
- package/build/modules/ace/codemods.js +301 -2
- package/build/modules/ace/commands.d.ts +5 -0
- package/build/modules/ace/main.js +2 -1
- package/build/modules/app.js +3 -5
- package/build/modules/bodyparser/bodyparser_middleware.js +2 -2
- package/build/modules/bodyparser/main.js +3 -5
- package/build/modules/config.js +3 -5
- package/build/modules/container.js +3 -5
- package/build/modules/dumper/main.js +29 -2
- package/build/modules/dumper/plugins/edge.js +2 -46
- package/build/modules/encryption/drivers/aes_256_cbc.js +1 -0
- package/build/modules/encryption/drivers/aes_256_gcm.js +1 -0
- package/build/modules/encryption/drivers/aes_siv.js +1 -0
- package/build/modules/encryption/drivers/chacha20_poly1305.js +1 -0
- package/build/modules/encryption/drivers/legacy.js +46 -1
- package/build/modules/encryption/main.js +7 -5
- package/build/modules/env/editor.js +1 -0
- package/build/modules/env/main.js +1 -0
- package/build/modules/events.js +3 -5
- package/build/modules/hash/drivers/argon.js +1 -0
- package/build/modules/hash/drivers/bcrypt.js +1 -0
- package/build/modules/hash/drivers/scrypt.js +1 -0
- package/build/modules/hash/main.js +4 -4
- package/build/modules/hash/phc_formatter.js +1 -0
- package/build/modules/health.js +1 -0
- package/build/modules/http/helpers.js +1 -0
- package/build/modules/http/main.js +2 -2
- package/build/modules/http/url_builder_client.js +1 -0
- package/build/modules/logger.js +3 -13
- package/build/modules/repl.js +3 -5
- package/build/modules/transformers/main.js +1 -0
- package/build/providers/app_provider.js +214 -15
- package/build/providers/edge_provider.js +90 -3
- package/build/providers/hash_provider.js +59 -4
- package/build/providers/repl_provider.js +64 -2
- package/build/providers/vinejs_provider.js +44 -3
- package/build/repl-C02Re0Yd.js +7 -0
- package/build/services/ace.js +11 -1
- package/build/services/app.js +2 -4
- package/build/services/config.js +7 -1
- package/build/services/dumper.js +13 -1
- package/build/services/emitter.js +8 -1
- package/build/services/encryption.js +8 -1
- package/build/services/hash.js +8 -1
- package/build/services/logger.js +8 -1
- package/build/services/repl.js +8 -1
- package/build/services/router.js +8 -1
- package/build/services/server.js +8 -1
- package/build/services/test_utils.js +11 -1
- package/build/services/url_builder.js +8 -1
- package/build/src/cli_formatters/routes_list.d.ts +7 -0
- package/build/src/exceptions.js +2 -1
- package/build/src/helpers/assert.js +1 -0
- package/build/src/helpers/http.js +1 -0
- package/build/src/helpers/is.js +24 -0
- package/build/src/helpers/main.js +2 -1
- package/build/src/helpers/string.js +2 -27
- package/build/src/helpers/types.js +18 -0
- package/build/src/helpers/verification_token.js +2 -45
- package/build/src/test_utils/main.js +9 -7
- package/build/src/types.js +1 -0
- package/build/src/vine.js +2 -32
- package/build/string-8_8He-HH.js +46 -0
- package/build/test_utils-DbJS_uEu.js +32 -0
- package/build/toolkit/main.js +13 -1
- package/build/types/ace.js +1 -0
- package/build/types/app.js +1 -0
- package/build/types/bodyparser.js +1 -0
- package/build/types/common.js +1 -0
- package/build/types/container.js +1 -0
- package/build/types/encryption.js +1 -0
- package/build/types/events.js +1 -0
- package/build/types/hash.js +1 -0
- package/build/types/health.js +1 -0
- package/build/types/helpers.js +1 -0
- package/build/types/http.js +1 -0
- package/build/types/logger.js +1 -0
- package/build/types/repl.js +1 -0
- package/build/types/transformers.js +1 -0
- package/build/utils-CKwka7OL.js +105 -0
- package/build/verification_token-WCrZtUgZ.js +108 -0
- package/build/vine-DkIupA3Z.js +97 -0
- package/package.json +12 -12
- package/build/config_provider-FIAUgvae.js +0 -13
- package/build/create_kernel-BD0Iqi8e.js +0 -3
- package/build/debug-CGQmxzGt.js +0 -3
- package/build/dumper-BBgqFX5a.js +0 -147
- package/build/main-Cxz0TyIw.js +0 -173
- package/build/main-DN2qEEg5.js +0 -41
- package/build/main-DkNgvceD.js +0 -52
- package/build/main-MBAMnmJb.js +0 -81
- package/build/utils-rRkbAPnP.js +0 -42
|
@@ -1,18 +1,59 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import "../../chunk-Do49iUES.js";
|
|
2
|
+
import { t as stubsRoot } from "../../main-CfTiGsiS.js";
|
|
3
|
+
import { f as BaseCommand, l as flags, o as args } from "../../main-CRnMnrH7.js";
|
|
4
|
+
import { t as __decorate } from "../../decorate-B9Uz0anB.js";
|
|
4
5
|
import string from "@poppinss/utils/string";
|
|
6
|
+
//#region commands/make/controller.ts
|
|
7
|
+
/**
|
|
8
|
+
* The make controller command to create an HTTP controller
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```
|
|
12
|
+
* ace make:controller User
|
|
13
|
+
* ace make:controller User store update
|
|
14
|
+
* ace make:controller User --resource
|
|
15
|
+
* ace make:controller User --api
|
|
16
|
+
* ace make:controller User --singular
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
5
19
|
var MakeController = class extends BaseCommand {
|
|
20
|
+
/**
|
|
21
|
+
* The command name
|
|
22
|
+
*/
|
|
6
23
|
static commandName = "make:controller";
|
|
7
|
-
|
|
24
|
+
/**
|
|
25
|
+
* The command description
|
|
26
|
+
*/
|
|
27
|
+
static description = "Create a new HTTP controller class in app/controllers. Use --resource for CRUD methods or --api for API-only CRUD (no create/edit)";
|
|
28
|
+
/**
|
|
29
|
+
* Command options configuration
|
|
30
|
+
*/
|
|
8
31
|
static options = { allowUnknownFlags: true };
|
|
32
|
+
/**
|
|
33
|
+
* The stub to use for generating the controller
|
|
34
|
+
*/
|
|
9
35
|
stubPath = "make/controller/main.stub";
|
|
36
|
+
/**
|
|
37
|
+
* Preparing the command state
|
|
38
|
+
*/
|
|
10
39
|
async prepare() {
|
|
40
|
+
/**
|
|
41
|
+
* Use actions stub
|
|
42
|
+
*/
|
|
11
43
|
if (this.actions) this.stubPath = "make/controller/actions.stub";
|
|
44
|
+
/**
|
|
45
|
+
* Use resource stub
|
|
46
|
+
*/
|
|
12
47
|
if (this.resource) if (this.actions) this.logger.warning("Cannot use --resource flag with actions. Ignoring --resource");
|
|
13
48
|
else this.stubPath = "make/controller/resource.stub";
|
|
49
|
+
/**
|
|
50
|
+
* Use api stub
|
|
51
|
+
*/
|
|
14
52
|
if (this.api) if (this.actions) this.logger.warning("Cannot use --api flag with actions. Ignoring --api");
|
|
15
53
|
else this.stubPath = "make/controller/api.stub";
|
|
54
|
+
/**
|
|
55
|
+
* Log warning when both flags are used together
|
|
56
|
+
*/
|
|
16
57
|
if (this.resource && this.api && !this.actions) this.logger.warning("--api and --resource flags cannot be used together. Ignoring --resource");
|
|
17
58
|
}
|
|
18
59
|
async run() {
|
|
@@ -42,4 +83,5 @@ __decorate([flags.boolean({
|
|
|
42
83
|
alias: "a"
|
|
43
84
|
})], MakeController.prototype, "api", void 0);
|
|
44
85
|
__decorate([flags.string({ description: "Use the contents of the given file as the generated output" })], MakeController.prototype, "contentsFrom", void 0);
|
|
86
|
+
//#endregion
|
|
45
87
|
export { MakeController as default };
|
|
@@ -1,11 +1,42 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import "../../chunk-Do49iUES.js";
|
|
2
|
+
import { t as stubsRoot } from "../../main-CfTiGsiS.js";
|
|
3
|
+
import { f as BaseCommand, l as flags, o as args } from "../../main-CRnMnrH7.js";
|
|
4
|
+
import { t as __decorate } from "../../decorate-B9Uz0anB.js";
|
|
5
|
+
//#region commands/make/event.ts
|
|
6
|
+
/**
|
|
7
|
+
* Command to create a new event class.
|
|
8
|
+
* Events are data objects that encapsulate information about something
|
|
9
|
+
* that happened in your application and can be dispatched to listeners.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```
|
|
13
|
+
* ace make:event UserRegistered
|
|
14
|
+
* ace make:event OrderCompleted
|
|
15
|
+
* ace make:event EmailSent
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
4
18
|
var MakeEvent = class extends BaseCommand {
|
|
19
|
+
/**
|
|
20
|
+
* The command name
|
|
21
|
+
*/
|
|
5
22
|
static commandName = "make:event";
|
|
6
|
-
|
|
23
|
+
/**
|
|
24
|
+
* The command description
|
|
25
|
+
*/
|
|
26
|
+
static description = "Create a new event class in app/events. Events are dispatched via emitter and handled by listeners";
|
|
27
|
+
/**
|
|
28
|
+
* Command options configuration.
|
|
29
|
+
* Allows unknown flags to be passed through.
|
|
30
|
+
*/
|
|
7
31
|
static options = { allowUnknownFlags: true };
|
|
32
|
+
/**
|
|
33
|
+
* The stub template file to use for generating the event class
|
|
34
|
+
*/
|
|
8
35
|
stubPath = "make/event/main.stub";
|
|
36
|
+
/**
|
|
37
|
+
* Execute the command to create a new event class.
|
|
38
|
+
* Generates the event file with proper event structure.
|
|
39
|
+
*/
|
|
9
40
|
async run() {
|
|
10
41
|
await (await this.createCodemods()).makeUsingStub(stubsRoot, this.stubPath, {
|
|
11
42
|
flags: this.parsed.flags,
|
|
@@ -15,4 +46,5 @@ var MakeEvent = class extends BaseCommand {
|
|
|
15
46
|
};
|
|
16
47
|
__decorate([args.string({ description: "Name of the event" })], MakeEvent.prototype, "name", void 0);
|
|
17
48
|
__decorate([flags.string({ description: "Use the contents of the given file as the generated output" })], MakeEvent.prototype, "contentsFrom", void 0);
|
|
49
|
+
//#endregion
|
|
18
50
|
export { MakeEvent as default };
|
|
@@ -1,11 +1,42 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import "../../chunk-Do49iUES.js";
|
|
2
|
+
import { t as stubsRoot } from "../../main-CfTiGsiS.js";
|
|
3
|
+
import { f as BaseCommand, l as flags, o as args } from "../../main-CRnMnrH7.js";
|
|
4
|
+
import { t as __decorate } from "../../decorate-B9Uz0anB.js";
|
|
5
|
+
//#region commands/make/exception.ts
|
|
6
|
+
/**
|
|
7
|
+
* Command to create a new custom exception class.
|
|
8
|
+
* Custom exceptions allow you to define specific error types for your application
|
|
9
|
+
* with custom error messages, status codes, and error handling logic.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```
|
|
13
|
+
* ace make:exception ValidationException
|
|
14
|
+
* ace make:exception UnauthorizedException
|
|
15
|
+
* ace make:exception ResourceNotFoundException
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
4
18
|
var MakeException = class extends BaseCommand {
|
|
19
|
+
/**
|
|
20
|
+
* The command name
|
|
21
|
+
*/
|
|
5
22
|
static commandName = "make:exception";
|
|
6
|
-
|
|
23
|
+
/**
|
|
24
|
+
* The command description
|
|
25
|
+
*/
|
|
26
|
+
static description = "Create a new custom exception class in app/exceptions with handle and report methods";
|
|
27
|
+
/**
|
|
28
|
+
* Command options configuration.
|
|
29
|
+
* Allows unknown flags to be passed through.
|
|
30
|
+
*/
|
|
7
31
|
static options = { allowUnknownFlags: true };
|
|
32
|
+
/**
|
|
33
|
+
* The stub template file to use for generating the exception class
|
|
34
|
+
*/
|
|
8
35
|
stubPath = "make/exception/main.stub";
|
|
36
|
+
/**
|
|
37
|
+
* Execute the command to create a new custom exception class.
|
|
38
|
+
* Generates the exception file with proper error handling structure.
|
|
39
|
+
*/
|
|
9
40
|
async run() {
|
|
10
41
|
await (await this.createCodemods()).makeUsingStub(stubsRoot, this.stubPath, {
|
|
11
42
|
flags: this.parsed.flags,
|
|
@@ -15,4 +46,5 @@ var MakeException = class extends BaseCommand {
|
|
|
15
46
|
};
|
|
16
47
|
__decorate([args.string({ description: "Name of the exception" })], MakeException.prototype, "name", void 0);
|
|
17
48
|
__decorate([flags.string({ description: "Use the contents of the given file as the generated output" })], MakeException.prototype, "contentsFrom", void 0);
|
|
49
|
+
//#endregion
|
|
18
50
|
export { MakeException as default };
|
|
@@ -1,18 +1,57 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import "../../chunk-Do49iUES.js";
|
|
2
|
+
import { t as stubsRoot } from "../../main-CfTiGsiS.js";
|
|
3
|
+
import { f as BaseCommand, l as flags, o as args } from "../../main-CRnMnrH7.js";
|
|
4
|
+
import { t as __decorate } from "../../decorate-B9Uz0anB.js";
|
|
5
|
+
//#region commands/make/listener.ts
|
|
6
|
+
/**
|
|
7
|
+
* Command to create a new event listener class.
|
|
8
|
+
* Event listeners handle events dispatched by the application and can optionally
|
|
9
|
+
* generate the corresponding event class automatically.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```
|
|
13
|
+
* ace make:listener UserRegistered
|
|
14
|
+
* ace make:listener EmailSent --event=EmailSent
|
|
15
|
+
* ace make:listener OrderCompleted --event=OrderEvent
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
4
18
|
var MakeListener = class extends BaseCommand {
|
|
19
|
+
/**
|
|
20
|
+
* The command name
|
|
21
|
+
*/
|
|
5
22
|
static commandName = "make:listener";
|
|
6
|
-
|
|
23
|
+
/**
|
|
24
|
+
* The command description
|
|
25
|
+
*/
|
|
26
|
+
static description = "Create a new event listener class in app/listeners. Use --event to also generate the event class and bind them together";
|
|
27
|
+
/**
|
|
28
|
+
* Command options configuration.
|
|
29
|
+
* Allows unknown flags to be passed through.
|
|
30
|
+
*/
|
|
7
31
|
static options = { allowUnknownFlags: true };
|
|
32
|
+
/**
|
|
33
|
+
* The stub template file to use for generating the event listener
|
|
34
|
+
*/
|
|
8
35
|
stubPath = "make/listener/main.stub";
|
|
36
|
+
/**
|
|
37
|
+
* Prepare the command by selecting the appropriate stub based on options.
|
|
38
|
+
* Uses a different stub when generating a listener for a specific event.
|
|
39
|
+
*/
|
|
9
40
|
prepare() {
|
|
10
41
|
if (this.event) this.stubPath = "make/listener/for_event.stub";
|
|
11
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Execute the command to create a new event listener.
|
|
45
|
+
* If an event is specified, creates the event class first,
|
|
46
|
+
* then generates the listener with proper event binding.
|
|
47
|
+
*/
|
|
12
48
|
async run() {
|
|
13
49
|
const codemods = await this.createCodemods();
|
|
14
50
|
if (this.event) {
|
|
15
51
|
const { exitCode } = await this.kernel.exec("make:event", [this.event]);
|
|
52
|
+
/**
|
|
53
|
+
* Create listener only when make:event is completed successfully
|
|
54
|
+
*/
|
|
16
55
|
if (exitCode === 0) {
|
|
17
56
|
const eventEntity = this.app.generators.createEntity(this.event);
|
|
18
57
|
await codemods.makeUsingStub(stubsRoot, this.stubPath, {
|
|
@@ -35,4 +74,5 @@ __decorate([flags.string({
|
|
|
35
74
|
alias: "e"
|
|
36
75
|
})], MakeListener.prototype, "event", void 0);
|
|
37
76
|
__decorate([flags.string({ description: "Use the contents of the given file as the generated output" })], MakeListener.prototype, "contentsFrom", void 0);
|
|
77
|
+
//#endregion
|
|
38
78
|
export { MakeListener as default };
|
|
@@ -1,13 +1,39 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import "../../chunk-Do49iUES.js";
|
|
2
|
+
import { t as stubsRoot } from "../../main-CfTiGsiS.js";
|
|
3
|
+
import { t as stringHelpers } from "../../string-8_8He-HH.js";
|
|
4
|
+
import { f as BaseCommand, l as flags, o as args } from "../../main-CRnMnrH7.js";
|
|
5
|
+
import { t as __decorate } from "../../decorate-B9Uz0anB.js";
|
|
5
6
|
import string from "@poppinss/utils/string";
|
|
6
7
|
import { basename, extname, relative } from "node:path";
|
|
8
|
+
//#region commands/make/middleware.ts
|
|
9
|
+
/**
|
|
10
|
+
* The make middleware command to create a new middleware
|
|
11
|
+
* class.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```
|
|
15
|
+
* ace make:middleware Auth
|
|
16
|
+
* ace make:middleware Auth --stack=server
|
|
17
|
+
* ace make:middleware Auth --stack=named
|
|
18
|
+
* ace make:middleware Auth --stack=router
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
7
21
|
var MakeMiddleware = class extends BaseCommand {
|
|
22
|
+
/**
|
|
23
|
+
* The command name
|
|
24
|
+
*/
|
|
8
25
|
static commandName = "make:middleware";
|
|
9
|
-
|
|
26
|
+
/**
|
|
27
|
+
* The command description
|
|
28
|
+
*/
|
|
29
|
+
static description = "Create a new middleware class in app/middleware and register it in start/kernel.ts under the chosen stack (server, router, or named)";
|
|
30
|
+
/**
|
|
31
|
+
* Command options configuration
|
|
32
|
+
*/
|
|
10
33
|
static options = { allowUnknownFlags: true };
|
|
34
|
+
/**
|
|
35
|
+
* The stub to use for generating the middleware
|
|
36
|
+
*/
|
|
11
37
|
stubPath = "make/middleware/main.stub";
|
|
12
38
|
async run() {
|
|
13
39
|
const stackChoices = [
|
|
@@ -15,19 +41,40 @@ var MakeMiddleware = class extends BaseCommand {
|
|
|
15
41
|
"router",
|
|
16
42
|
"named"
|
|
17
43
|
];
|
|
44
|
+
/**
|
|
45
|
+
* Prompt to select the stack under which to register
|
|
46
|
+
* the middleware
|
|
47
|
+
*/
|
|
18
48
|
if (!this.stack) this.stack = await this.prompt.choice("Under which stack you want to register the middleware?", stackChoices);
|
|
49
|
+
/**
|
|
50
|
+
* Error out when mentioned stack is invalid
|
|
51
|
+
*/
|
|
19
52
|
if (!stackChoices.includes(this.stack)) {
|
|
20
53
|
this.exitCode = 1;
|
|
21
54
|
this.logger.error(`Invalid middleware stack "${this.stack}". Select from "${stackChoices.join(", ")}"`);
|
|
22
55
|
return;
|
|
23
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Create middleware
|
|
59
|
+
*/
|
|
24
60
|
const codemods = await this.createCodemods();
|
|
25
61
|
const { destination } = await codemods.makeUsingStub(stubsRoot, this.stubPath, {
|
|
26
62
|
flags: this.parsed.flags,
|
|
27
63
|
entity: this.app.generators.createEntity(this.name)
|
|
28
64
|
}, { contentsFromFile: this.contentsFrom });
|
|
65
|
+
/**
|
|
66
|
+
* Creative relative path for the middleware file from
|
|
67
|
+
* the "./app/middleware" directory
|
|
68
|
+
*/
|
|
29
69
|
const middlewareRelativePath = stringHelpers.toUnixSlash(relative(this.app.middlewarePath(), destination).replace(extname(destination), ""));
|
|
70
|
+
/**
|
|
71
|
+
* Take the middleware relative path, remove `_middleware` prefix from it
|
|
72
|
+
* and convert everything to camelcase
|
|
73
|
+
*/
|
|
30
74
|
const name = string.camelCase(basename(middlewareRelativePath).replace(/_middleware$/, ""));
|
|
75
|
+
/**
|
|
76
|
+
* Register middleware
|
|
77
|
+
*/
|
|
31
78
|
await codemods.registerMiddleware(this.stack, [{
|
|
32
79
|
name,
|
|
33
80
|
path: `#middleware/${middlewareRelativePath}`
|
|
@@ -40,4 +87,5 @@ __decorate([flags.string({
|
|
|
40
87
|
alias: "s"
|
|
41
88
|
})], MakeMiddleware.prototype, "stack", void 0);
|
|
42
89
|
__decorate([flags.string({ description: "Use the contents of the given file as the generated output" })], MakeMiddleware.prototype, "contentsFrom", void 0);
|
|
90
|
+
//#endregion
|
|
43
91
|
export { MakeMiddleware as default };
|
|
@@ -1,34 +1,83 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import "../../chunk-Do49iUES.js";
|
|
2
|
+
import { t as stubsRoot } from "../../main-CfTiGsiS.js";
|
|
3
|
+
import { t as stringHelpers } from "../../string-8_8He-HH.js";
|
|
4
|
+
import { f as BaseCommand, l as flags, o as args } from "../../main-CRnMnrH7.js";
|
|
5
|
+
import { t as __decorate } from "../../decorate-B9Uz0anB.js";
|
|
5
6
|
import { extname, relative } from "node:path";
|
|
7
|
+
//#region commands/make/preload.ts
|
|
6
8
|
const ALLOWED_ENVIRONMENTS = [
|
|
7
9
|
"web",
|
|
8
10
|
"console",
|
|
9
11
|
"test",
|
|
10
12
|
"repl"
|
|
11
13
|
];
|
|
14
|
+
/**
|
|
15
|
+
* Command to create a new preload file in the start directory.
|
|
16
|
+
* Preload files are executed during application startup and can be used
|
|
17
|
+
* to set up global configurations, register global bindings, or perform
|
|
18
|
+
* application-wide initialization tasks.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```
|
|
22
|
+
* ace make:preload routes
|
|
23
|
+
* ace make:preload database --register
|
|
24
|
+
* ace make:preload events --no-register
|
|
25
|
+
* ace make:preload kernel --environments=web,console
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
12
28
|
var MakePreload = class extends BaseCommand {
|
|
29
|
+
/**
|
|
30
|
+
* The command name
|
|
31
|
+
*/
|
|
13
32
|
static commandName = "make:preload";
|
|
14
|
-
|
|
33
|
+
/**
|
|
34
|
+
* The command description
|
|
35
|
+
*/
|
|
36
|
+
static description = "Create a new preload file in start/ and optionally register it in adonisrc.ts. Preload files run during app boot";
|
|
37
|
+
/**
|
|
38
|
+
* The stub template file to use for generating the preload file
|
|
39
|
+
*/
|
|
15
40
|
stubPath = "make/preload/main.stub";
|
|
41
|
+
/**
|
|
42
|
+
* Validate that all specified environments are valid application environments.
|
|
43
|
+
*
|
|
44
|
+
* @returns True if all environments are valid or none specified, false otherwise
|
|
45
|
+
*/
|
|
16
46
|
#isEnvironmentsFlagValid() {
|
|
17
47
|
if (!this.environments || !this.environments.length) return true;
|
|
18
48
|
return this.environments.every((one) => ALLOWED_ENVIRONMENTS.includes(one));
|
|
19
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Execute the command to create a new preload file.
|
|
52
|
+
* Validates inputs, generates the preload file, and optionally registers it in .adonisrc.ts.
|
|
53
|
+
*/
|
|
20
54
|
async run() {
|
|
55
|
+
/**
|
|
56
|
+
* Ensure the environments are valid when provided via flag
|
|
57
|
+
*/
|
|
21
58
|
if (!this.#isEnvironmentsFlagValid()) {
|
|
22
59
|
this.logger.error(`Invalid environment(s) "${this.environments}". Only "${ALLOWED_ENVIRONMENTS}" are allowed`);
|
|
23
60
|
return;
|
|
24
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Display prompt to know if we should register the preload
|
|
64
|
+
* file inside the ".adonisrc.ts" file.
|
|
65
|
+
*/
|
|
25
66
|
if (this.register === void 0) this.register = await this.prompt.confirm("Do you want to register the preload file in .adonisrc.ts file?");
|
|
26
67
|
const codemods = await this.createCodemods();
|
|
27
68
|
const { destination } = await codemods.makeUsingStub(stubsRoot, this.stubPath, {
|
|
28
69
|
flags: this.parsed.flags,
|
|
29
70
|
entity: this.app.generators.createEntity(this.name)
|
|
30
71
|
}, { contentsFromFile: this.contentsFrom });
|
|
72
|
+
/**
|
|
73
|
+
* Do not register when prompt has been denied or "--no-register"
|
|
74
|
+
* flag was used
|
|
75
|
+
*/
|
|
31
76
|
if (!this.register) return;
|
|
77
|
+
/**
|
|
78
|
+
* Creative relative path for the preload file from
|
|
79
|
+
* the "./start" directory
|
|
80
|
+
*/
|
|
32
81
|
const preloadFileRelativePath = stringHelpers.toUnixSlash(relative(this.app.startPath(), destination).replace(extname(destination), ""));
|
|
33
82
|
await codemods.updateRcFile((rcFile) => {
|
|
34
83
|
rcFile.addPreloadFile(`#start/${preloadFileRelativePath}`, this.environments);
|
|
@@ -46,4 +95,5 @@ __decorate([flags.array({
|
|
|
46
95
|
alias: "e"
|
|
47
96
|
})], MakePreload.prototype, "environments", void 0);
|
|
48
97
|
__decorate([flags.string({ description: "Use the contents of the given file as the generated output" })], MakePreload.prototype, "contentsFrom", void 0);
|
|
98
|
+
//#endregion
|
|
49
99
|
export { MakePreload as default };
|
|
@@ -1,34 +1,82 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import "../../chunk-Do49iUES.js";
|
|
2
|
+
import { t as stubsRoot } from "../../main-CfTiGsiS.js";
|
|
3
|
+
import { t as stringHelpers } from "../../string-8_8He-HH.js";
|
|
4
|
+
import { f as BaseCommand, l as flags, o as args } from "../../main-CRnMnrH7.js";
|
|
5
|
+
import { t as __decorate } from "../../decorate-B9Uz0anB.js";
|
|
5
6
|
import { extname, relative } from "node:path";
|
|
7
|
+
//#region commands/make/provider.ts
|
|
6
8
|
const ALLOWED_ENVIRONMENTS = [
|
|
7
9
|
"web",
|
|
8
10
|
"console",
|
|
9
11
|
"test",
|
|
10
12
|
"repl"
|
|
11
13
|
];
|
|
14
|
+
/**
|
|
15
|
+
* Command to create a new service provider class.
|
|
16
|
+
* Service providers are used to register bindings, configure services,
|
|
17
|
+
* and bootstrap application components during startup.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```
|
|
21
|
+
* ace make:provider AuthProvider
|
|
22
|
+
* ace make:provider DatabaseProvider --register
|
|
23
|
+
* ace make:provider AppProvider --no-register
|
|
24
|
+
* ace make:provider CacheProvider --environments=web,console
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
12
27
|
var MakeProvider = class extends BaseCommand {
|
|
28
|
+
/**
|
|
29
|
+
* The command name
|
|
30
|
+
*/
|
|
13
31
|
static commandName = "make:provider";
|
|
14
|
-
|
|
32
|
+
/**
|
|
33
|
+
* The command description
|
|
34
|
+
*/
|
|
35
|
+
static description = "Create a new service provider in providers/ and optionally register it in adonisrc.ts. Providers register IoC container bindings";
|
|
36
|
+
/**
|
|
37
|
+
* The stub template file to use for generating the provider class
|
|
38
|
+
*/
|
|
15
39
|
stubPath = "make/provider/main.stub";
|
|
40
|
+
/**
|
|
41
|
+
* Validate that all specified environments are valid application environments.
|
|
42
|
+
*
|
|
43
|
+
* @returns True if all environments are valid or none specified, false otherwise
|
|
44
|
+
*/
|
|
16
45
|
#isEnvironmentsFlagValid() {
|
|
17
46
|
if (!this.environments || !this.environments.length) return true;
|
|
18
47
|
return this.environments.every((one) => ALLOWED_ENVIRONMENTS.includes(one));
|
|
19
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Execute the command to create a new service provider.
|
|
51
|
+
* Validates inputs, generates the provider file, and optionally registers it in .adonisrc.ts.
|
|
52
|
+
*/
|
|
20
53
|
async run() {
|
|
54
|
+
/**
|
|
55
|
+
* Ensure the environments are valid when provided via flag
|
|
56
|
+
*/
|
|
21
57
|
if (!this.#isEnvironmentsFlagValid()) {
|
|
22
58
|
this.logger.error(`Invalid environment(s) "${this.environments}". Only "${ALLOWED_ENVIRONMENTS}" are allowed`);
|
|
23
59
|
return;
|
|
24
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Display prompt to know if we should register the provider
|
|
63
|
+
* file inside the ".adonisrc.ts" file.
|
|
64
|
+
*/
|
|
25
65
|
if (this.register === void 0) this.register = await this.prompt.confirm("Do you want to register the provider in .adonisrc.ts file?");
|
|
26
66
|
const codemods = await this.createCodemods();
|
|
27
67
|
const { destination } = await codemods.makeUsingStub(stubsRoot, this.stubPath, {
|
|
28
68
|
flags: this.parsed.flags,
|
|
29
69
|
entity: this.app.generators.createEntity(this.name)
|
|
30
70
|
}, { contentsFromFile: this.contentsFrom });
|
|
71
|
+
/**
|
|
72
|
+
* Do not register when prompt has been denied or "--no-register"
|
|
73
|
+
* flag was used
|
|
74
|
+
*/
|
|
31
75
|
if (!this.register) return;
|
|
76
|
+
/**
|
|
77
|
+
* Creative relative path for the provider file from
|
|
78
|
+
* the "./start" directory
|
|
79
|
+
*/
|
|
32
80
|
const providerRelativePath = stringHelpers.toUnixSlash(relative(this.app.providersPath(), destination).replace(extname(destination), ""));
|
|
33
81
|
await codemods.updateRcFile((rcFile) => {
|
|
34
82
|
rcFile.addProvider(`#providers/${providerRelativePath}`, this.environments);
|
|
@@ -46,4 +94,5 @@ __decorate([flags.array({
|
|
|
46
94
|
alias: "e"
|
|
47
95
|
})], MakeProvider.prototype, "environments", void 0);
|
|
48
96
|
__decorate([flags.string({ description: "Use the contents of the given file as the generated output" })], MakeProvider.prototype, "contentsFrom", void 0);
|
|
97
|
+
//#endregion
|
|
49
98
|
export { MakeProvider as default };
|
|
@@ -1,10 +1,34 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import "../../chunk-Do49iUES.js";
|
|
2
|
+
import { t as stubsRoot } from "../../main-CfTiGsiS.js";
|
|
3
|
+
import { f as BaseCommand, l as flags, o as args } from "../../main-CRnMnrH7.js";
|
|
4
|
+
import { t as __decorate } from "../../decorate-B9Uz0anB.js";
|
|
5
|
+
//#region commands/make/service.ts
|
|
6
|
+
/**
|
|
7
|
+
* Make a new service class
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```
|
|
11
|
+
* ace make:service UserService
|
|
12
|
+
* ace make:service AuthService
|
|
13
|
+
* ace make:service User/ProfileService
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
4
16
|
var MakeService = class extends BaseCommand {
|
|
17
|
+
/**
|
|
18
|
+
* The command name
|
|
19
|
+
*/
|
|
5
20
|
static commandName = "make:service";
|
|
6
|
-
|
|
21
|
+
/**
|
|
22
|
+
* The command description
|
|
23
|
+
*/
|
|
24
|
+
static description = "Create a new service class in app/services. Services encapsulate reusable business logic outside of controllers";
|
|
25
|
+
/**
|
|
26
|
+
* Command options configuration
|
|
27
|
+
*/
|
|
7
28
|
static options = { allowUnknownFlags: true };
|
|
29
|
+
/**
|
|
30
|
+
* The stub to use for generating the service class
|
|
31
|
+
*/
|
|
8
32
|
stubPath = "make/service/main.stub";
|
|
9
33
|
async run() {
|
|
10
34
|
await (await this.createCodemods()).makeUsingStub(stubsRoot, this.stubPath, {
|
|
@@ -15,4 +39,5 @@ var MakeService = class extends BaseCommand {
|
|
|
15
39
|
};
|
|
16
40
|
__decorate([args.string({ description: "Name of the service" })], MakeService.prototype, "name", void 0);
|
|
17
41
|
__decorate([flags.string({ description: "Use the contents of the given file as the generated output" })], MakeService.prototype, "contentsFrom", void 0);
|
|
42
|
+
//#endregion
|
|
18
43
|
export { MakeService as default };
|
|
@@ -1,33 +1,91 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import "../../chunk-Do49iUES.js";
|
|
2
|
+
import { t as stubsRoot } from "../../main-CfTiGsiS.js";
|
|
3
|
+
import { f as BaseCommand, l as flags, o as args } from "../../main-CRnMnrH7.js";
|
|
4
|
+
import { t as __decorate } from "../../decorate-B9Uz0anB.js";
|
|
5
|
+
//#region commands/make/test.ts
|
|
6
|
+
/**
|
|
7
|
+
* Command to create a new Japa test file.
|
|
8
|
+
* Supports multiple test suites and automatically detects or prompts for
|
|
9
|
+
* the appropriate suite and directory based on application configuration.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```
|
|
13
|
+
* ace make:test UserController
|
|
14
|
+
* ace make:test UserModel --suite=unit
|
|
15
|
+
* ace make:test AuthService --suite=integration
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
4
18
|
var MakeTest = class extends BaseCommand {
|
|
19
|
+
/**
|
|
20
|
+
* The command name
|
|
21
|
+
*/
|
|
5
22
|
static commandName = "make:test";
|
|
6
|
-
|
|
23
|
+
/**
|
|
24
|
+
* The command description
|
|
25
|
+
*/
|
|
26
|
+
static description = "Create a new Japa test file in tests/. Use --suite to specify the test suite (unit, functional, etc.)";
|
|
27
|
+
/**
|
|
28
|
+
* The stub template file to use for generating the test file
|
|
29
|
+
*/
|
|
7
30
|
stubPath = "make/test/main.stub";
|
|
31
|
+
/**
|
|
32
|
+
* Determine the test suite name for creating the test file.
|
|
33
|
+
* Uses the provided suite flag, or automatically selects if only one suite exists,
|
|
34
|
+
* or prompts the user to choose from available suites.
|
|
35
|
+
*
|
|
36
|
+
* @returns The name of the selected test suite
|
|
37
|
+
*/
|
|
8
38
|
async #getSuite() {
|
|
9
39
|
if (this.suite) return this.suite;
|
|
40
|
+
/**
|
|
41
|
+
* Use the first suite from the rcFile when there is only
|
|
42
|
+
* one suite
|
|
43
|
+
*/
|
|
10
44
|
const rcFileSuites = this.app.rcFile.tests.suites;
|
|
11
45
|
if (rcFileSuites.length === 1) return rcFileSuites[0].name;
|
|
46
|
+
/**
|
|
47
|
+
* Prompt the user to select a suite manually
|
|
48
|
+
*/
|
|
12
49
|
return this.prompt.choice("Select the suite for the test file", this.app.rcFile.tests.suites.map((suite) => {
|
|
13
50
|
return suite.name;
|
|
14
51
|
}), { validate(choice) {
|
|
15
52
|
return choice ? true : "Please select a suite";
|
|
16
53
|
} });
|
|
17
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Determine the directory path for the test file within the selected suite.
|
|
57
|
+
* Automatically selects if only one directory exists, otherwise prompts the user.
|
|
58
|
+
*
|
|
59
|
+
* @param directories - Array of available directories for the suite
|
|
60
|
+
* @returns The selected directory path
|
|
61
|
+
*/
|
|
18
62
|
async #getSuiteDirectory(directories) {
|
|
19
63
|
if (directories.length === 1) return directories[0];
|
|
20
64
|
return this.prompt.choice("Select directory for the test file", directories, { validate(choice) {
|
|
21
65
|
return choice ? true : "Please select a directory";
|
|
22
66
|
} });
|
|
23
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* Find suite configuration from the RC file by name.
|
|
70
|
+
*
|
|
71
|
+
* @param suiteName - The name of the suite to find
|
|
72
|
+
* @returns The suite configuration or undefined if not found
|
|
73
|
+
*/
|
|
24
74
|
#findSuite(suiteName) {
|
|
25
75
|
return this.app.rcFile.tests.suites.find((suite) => {
|
|
26
76
|
return suite.name === suiteName;
|
|
27
77
|
});
|
|
28
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* Execute the command to create a new test file.
|
|
81
|
+
* Validates the suite exists, prompts for missing information,
|
|
82
|
+
* and generates the test file in the appropriate location.
|
|
83
|
+
*/
|
|
29
84
|
async run() {
|
|
30
85
|
const suite = this.#findSuite(await this.#getSuite());
|
|
86
|
+
/**
|
|
87
|
+
* Show error when mentioned/selected suite does not exist
|
|
88
|
+
*/
|
|
31
89
|
if (!suite) {
|
|
32
90
|
this.logger.error(`The "${this.suite}" suite is not configured inside the "adonisrc.js" file`);
|
|
33
91
|
this.exitCode = 1;
|
|
@@ -46,4 +104,5 @@ __decorate([flags.string({
|
|
|
46
104
|
alias: "s"
|
|
47
105
|
})], MakeTest.prototype, "suite", void 0);
|
|
48
106
|
__decorate([flags.string({ description: "Use the contents of the given file as the generated output" })], MakeTest.prototype, "contentsFrom", void 0);
|
|
107
|
+
//#endregion
|
|
49
108
|
export { MakeTest as default };
|