@adonisjs/core 7.0.1 → 7.1.1
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-aRg0soJX.js} +52 -3
- 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,34 +1,91 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import "../../chunk-Do49iUES.js";
|
|
2
|
+
import { t as stringHelpers } from "../../string-8_8He-HH.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/env/add.ts
|
|
4
6
|
const ALLOWED_TYPES = [
|
|
5
7
|
"string",
|
|
6
8
|
"boolean",
|
|
7
9
|
"number",
|
|
8
10
|
"enum"
|
|
9
11
|
];
|
|
12
|
+
/**
|
|
13
|
+
* Command to add a new environment variable to the application.
|
|
14
|
+
* Updates .env, .env.example, and start/env.ts files with the new variable,
|
|
15
|
+
* including appropriate validation schema based on the variable type.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```
|
|
19
|
+
* ace env:add
|
|
20
|
+
* ace env:add DATABASE_URL postgres://localhost:5432/mydb
|
|
21
|
+
* ace env:add API_KEY secret --type=string
|
|
22
|
+
* ace env:add PORT 3333 --type=number
|
|
23
|
+
* ace env:add DEBUG true --type=boolean
|
|
24
|
+
* ace env:add LOG_LEVEL info --type=enum --enum-values=debug,info,warn,error
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
10
27
|
var EnvAdd = class extends BaseCommand {
|
|
28
|
+
/**
|
|
29
|
+
* The command name
|
|
30
|
+
*/
|
|
11
31
|
static commandName = "env:add";
|
|
12
|
-
|
|
32
|
+
/**
|
|
33
|
+
* The command description
|
|
34
|
+
*/
|
|
35
|
+
static description = "Add a new environment variable to .env, .env.example, and its validation rule to start/env.ts";
|
|
36
|
+
/**
|
|
37
|
+
* Command options configuration.
|
|
38
|
+
* Allows unknown flags to be passed through.
|
|
39
|
+
*/
|
|
13
40
|
static options = { allowUnknownFlags: true };
|
|
41
|
+
/**
|
|
42
|
+
* Validate that the provided type is one of the allowed types.
|
|
43
|
+
*
|
|
44
|
+
* @returns True if the type is valid, false otherwise
|
|
45
|
+
*/
|
|
14
46
|
#isTypeFlagValid() {
|
|
15
47
|
return ALLOWED_TYPES.includes(this.type);
|
|
16
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Execute the command to add a new environment variable.
|
|
51
|
+
* Prompts for missing values, validates inputs, and updates all relevant files.
|
|
52
|
+
*/
|
|
17
53
|
async run() {
|
|
54
|
+
/**
|
|
55
|
+
* Prompt for missing name
|
|
56
|
+
*/
|
|
18
57
|
if (!this.name) this.name = await this.prompt.ask("Enter the variable name", {
|
|
19
58
|
validate: (value) => !!value,
|
|
20
59
|
format: (value) => stringHelpers.snakeCase(value).toUpperCase()
|
|
21
60
|
});
|
|
61
|
+
/**
|
|
62
|
+
* Prompt for missing value
|
|
63
|
+
*/
|
|
22
64
|
if (!this.value) this.value = await this.prompt.ask("Enter the variable value");
|
|
65
|
+
/**
|
|
66
|
+
* Prompt for missing type
|
|
67
|
+
*/
|
|
23
68
|
if (!this.type) this.type = await this.prompt.choice("Select the variable type", ALLOWED_TYPES);
|
|
69
|
+
/**
|
|
70
|
+
* Prompt for missing enum values if the selected env type is `enum`
|
|
71
|
+
*/
|
|
24
72
|
if (this.type === "enum" && !this.enumValues) this.enumValues = await this.prompt.ask("Enter the enum values separated by a comma", { result: (value) => value.split(",").map((one) => one.trim()) });
|
|
73
|
+
/**
|
|
74
|
+
* Validate inputs
|
|
75
|
+
*/
|
|
25
76
|
if (!this.#isTypeFlagValid()) {
|
|
26
77
|
this.logger.error(`Invalid type "${this.type}". Must be one of ${ALLOWED_TYPES.join(", ")}`);
|
|
27
78
|
return;
|
|
28
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* Add the environment variable to the `.env` and `.env.example` files
|
|
82
|
+
*/
|
|
29
83
|
const codemods = await this.createCodemods();
|
|
30
84
|
const transformedName = stringHelpers.snakeCase(this.name).toUpperCase();
|
|
31
85
|
await codemods.defineEnvVariables({ [transformedName]: this.value }, { omitFromExample: [transformedName] });
|
|
86
|
+
/**
|
|
87
|
+
* Add the environment variable to the `start/env.ts` file
|
|
88
|
+
*/
|
|
32
89
|
const validation = {
|
|
33
90
|
string: "Env.schema.string()",
|
|
34
91
|
number: "Env.schema.number()",
|
|
@@ -53,4 +110,5 @@ __decorate([flags.array({
|
|
|
53
110
|
default: [""],
|
|
54
111
|
required: false
|
|
55
112
|
})], EnvAdd.prototype, "enumValues", void 0);
|
|
113
|
+
//#endregion
|
|
56
114
|
export { EnvAdd as default };
|
|
@@ -1,10 +1,29 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import "../chunk-Do49iUES.js";
|
|
2
|
+
import { f as BaseCommand, l as flags } from "../main-CRnMnrH7.js";
|
|
3
|
+
import { t as __decorate } from "../decorate-B9Uz0anB.js";
|
|
3
4
|
import string from "@poppinss/utils/string";
|
|
4
5
|
import { EnvEditor } from "@adonisjs/env/editor";
|
|
6
|
+
//#region commands/generate_key.ts
|
|
7
|
+
/**
|
|
8
|
+
* The generate key command is used to generate the app key
|
|
9
|
+
* and write it inside the .env file.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```
|
|
13
|
+
* ace generate:key
|
|
14
|
+
* ace generate:key --show
|
|
15
|
+
* ace generate:key --force
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
5
18
|
var GenerateKey = class extends BaseCommand {
|
|
19
|
+
/**
|
|
20
|
+
* The command name
|
|
21
|
+
*/
|
|
6
22
|
static commandName = "generate:key";
|
|
7
|
-
|
|
23
|
+
/**
|
|
24
|
+
* The command description
|
|
25
|
+
*/
|
|
26
|
+
static description = "Generate a cryptographically secure APP_KEY and write it to the .env file. Use --show to print without writing";
|
|
8
27
|
async run() {
|
|
9
28
|
let writeToFile = process.env.NODE_ENV !== "production";
|
|
10
29
|
if (this.force) writeToFile = true;
|
|
@@ -20,4 +39,5 @@ var GenerateKey = class extends BaseCommand {
|
|
|
20
39
|
};
|
|
21
40
|
__decorate([flags.boolean({ description: "Display the key on the terminal, instead of writing it to .env file" })], GenerateKey.prototype, "show", void 0);
|
|
22
41
|
__decorate([flags.boolean({ description: "Force update .env file in production environment" })], GenerateKey.prototype, "force", void 0);
|
|
42
|
+
//#endregion
|
|
23
43
|
export { GenerateKey as default };
|
|
@@ -1,7 +1,30 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "../chunk-Do49iUES.js";
|
|
2
|
+
import { f as BaseCommand } from "../main-CRnMnrH7.js";
|
|
3
|
+
//#region commands/inspect_rcfile.ts
|
|
4
|
+
/**
|
|
5
|
+
* Command to inspect and display the AdonisJS RC file contents with default values.
|
|
6
|
+
* The RC file contains configuration for providers, preloads, commands, and other
|
|
7
|
+
* application settings. This command formats and displays the contents in a readable JSON format.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```
|
|
11
|
+
* ace inspect:rcfile
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
2
14
|
var InspectRCFile = class extends BaseCommand {
|
|
15
|
+
/**
|
|
16
|
+
* The command name
|
|
17
|
+
*/
|
|
3
18
|
static commandName = "inspect:rcfile";
|
|
4
|
-
|
|
19
|
+
/**
|
|
20
|
+
* The command description
|
|
21
|
+
*/
|
|
22
|
+
static description = "Display the resolved adonisrc.ts configuration as JSON, including providers, preloads, commands, and meta files";
|
|
23
|
+
/**
|
|
24
|
+
* Execute the command to display RC file contents.
|
|
25
|
+
* Transforms provider, preload, and command entries to display their file paths
|
|
26
|
+
* as strings and formats the output as readable JSON.
|
|
27
|
+
*/
|
|
5
28
|
async run() {
|
|
6
29
|
const { raw, providers, preloads, commands, ...rest } = this.app.rcFile;
|
|
7
30
|
this.logger.log(JSON.stringify({
|
|
@@ -24,4 +47,5 @@ var InspectRCFile = class extends BaseCommand {
|
|
|
24
47
|
}, null, 2));
|
|
25
48
|
}
|
|
26
49
|
};
|
|
50
|
+
//#endregion
|
|
27
51
|
export { InspectRCFile as default };
|
|
@@ -49,6 +49,11 @@ export default class ListRoutes extends BaseCommand {
|
|
|
49
49
|
* Output routes as a CLI table format
|
|
50
50
|
*/
|
|
51
51
|
table: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Output routes as JSONL (one JSON object per line), optimized for
|
|
54
|
+
* machine consumption by AI agents and CLI tools
|
|
55
|
+
*/
|
|
56
|
+
jsonl: boolean;
|
|
52
57
|
/**
|
|
53
58
|
* Execute the command to list application routes.
|
|
54
59
|
* Creates a formatter with the specified filters and outputs routes
|
|
@@ -1,13 +1,55 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import "../../chunk-Do49iUES.js";
|
|
2
|
+
import { f as BaseCommand, l as flags, o as args, s as cliHelpers } from "../../main-CRnMnrH7.js";
|
|
3
|
+
import { t as __decorate } from "../../decorate-B9Uz0anB.js";
|
|
3
4
|
import stringWidth from "string-width";
|
|
4
5
|
import { middlewareInfo, routeInfo } from "@adonisjs/http-server/helpers";
|
|
6
|
+
//#region src/cli_formatters/routes_list.ts
|
|
7
|
+
/**
|
|
8
|
+
* Routes list formatter is used to format the routes to JSON or an ANSI string
|
|
9
|
+
* with pretty output.
|
|
10
|
+
*
|
|
11
|
+
* The decisions of colors, padding, alignment are all handled by the lists formatter
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* const formatter = new RoutesListFormatter(router, ui, {
|
|
15
|
+
* displayHeadRoutes: false,
|
|
16
|
+
* maxPrettyPrintWidth: 120
|
|
17
|
+
* }, {
|
|
18
|
+
* match: 'api',
|
|
19
|
+
* middleware: ['auth']
|
|
20
|
+
* })
|
|
21
|
+
*
|
|
22
|
+
* const ansiOutput = await formatter.formatAsAnsiList()
|
|
23
|
+
*/
|
|
5
24
|
var RoutesListFormatter = class {
|
|
25
|
+
/**
|
|
26
|
+
* Router instance containing all registered routes
|
|
27
|
+
*/
|
|
6
28
|
#router;
|
|
29
|
+
/**
|
|
30
|
+
* Colors utility for ANSI formatting
|
|
31
|
+
*/
|
|
7
32
|
#colors;
|
|
33
|
+
/**
|
|
34
|
+
* Table utility for creating formatted tables
|
|
35
|
+
*/
|
|
8
36
|
#table;
|
|
37
|
+
/**
|
|
38
|
+
* Options for printing routes
|
|
39
|
+
*/
|
|
9
40
|
#options;
|
|
41
|
+
/**
|
|
42
|
+
* Filters to apply when finding routes
|
|
43
|
+
*/
|
|
10
44
|
#filters;
|
|
45
|
+
/**
|
|
46
|
+
* Creates a new instance of the routes list formatter
|
|
47
|
+
*
|
|
48
|
+
* @param router - Router instance containing routes to format
|
|
49
|
+
* @param ui - UI primitives for colors and table formatting
|
|
50
|
+
* @param options - Display options for route formatting
|
|
51
|
+
* @param filters - Filters to apply when displaying routes
|
|
52
|
+
*/
|
|
11
53
|
constructor(router, ui, options, filters) {
|
|
12
54
|
this.#router = router;
|
|
13
55
|
this.#colors = ui.colors;
|
|
@@ -16,22 +58,56 @@ var RoutesListFormatter = class {
|
|
|
16
58
|
this.#options = options;
|
|
17
59
|
this.#router.commit();
|
|
18
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Test if a route clears the applied filters based on middleware, name, pattern, and handler.
|
|
63
|
+
*
|
|
64
|
+
* @param route - The serialized route to test against filters
|
|
65
|
+
*/
|
|
19
66
|
#isAllowedByFilters(route) {
|
|
20
67
|
let allowRoute = true;
|
|
68
|
+
/**
|
|
69
|
+
* Check if the route is allowed by applying the middleware
|
|
70
|
+
* filter
|
|
71
|
+
*/
|
|
21
72
|
if (this.#filters.middleware) allowRoute = this.#filters.middleware.every((name) => {
|
|
22
73
|
if (name === "*") return route.middleware.length > 0;
|
|
23
74
|
return route.middleware.find((middleware) => middleware.name === name);
|
|
24
75
|
});
|
|
76
|
+
/**
|
|
77
|
+
* Check if the route has any or the ignored middleware. If yes, do not
|
|
78
|
+
* display the route
|
|
79
|
+
*/
|
|
25
80
|
if (allowRoute && this.#filters.ignoreMiddleware) allowRoute = this.#filters.ignoreMiddleware.every((name) => {
|
|
26
81
|
if (name === "*") return route.middleware.length === 0;
|
|
27
82
|
return !route.middleware.find((middleware) => middleware.name === name);
|
|
28
83
|
});
|
|
84
|
+
/**
|
|
85
|
+
* No more filters to be applied
|
|
86
|
+
*/
|
|
29
87
|
if (!this.#filters.match) return allowRoute;
|
|
88
|
+
/**
|
|
89
|
+
* Check if the route name has the match keyword
|
|
90
|
+
*/
|
|
30
91
|
if (route.name.includes(this.#filters.match)) return true;
|
|
92
|
+
/**
|
|
93
|
+
* Check if the route pattern has the match keyword
|
|
94
|
+
*/
|
|
31
95
|
if (route.pattern.includes(this.#filters.match)) return true;
|
|
96
|
+
/**
|
|
97
|
+
* Check if the route handler has the match keyword
|
|
98
|
+
*/
|
|
32
99
|
if (route.handler.type === "controller" ? route.handler.moduleNameOrPath.includes(this.#filters.match) : route.handler.name.includes(this.#filters.match)) return true;
|
|
100
|
+
/**
|
|
101
|
+
* Disallow route
|
|
102
|
+
*/
|
|
33
103
|
return false;
|
|
34
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* Serializes routes JSON to an object that can be used for pretty printing.
|
|
107
|
+
* Converts RouteJSON into a format suitable for display and filtering.
|
|
108
|
+
*
|
|
109
|
+
* @param route - The route JSON object to serialize
|
|
110
|
+
*/
|
|
35
111
|
async #serializeRoute(route) {
|
|
36
112
|
let methods = route.methods;
|
|
37
113
|
if (!this.#options.displayHeadRoutes) methods = methods.filter((method) => method !== "HEAD");
|
|
@@ -46,9 +122,19 @@ var RoutesListFormatter = class {
|
|
|
46
122
|
middleware: middlewareList.filter((info) => info.type !== "global")
|
|
47
123
|
};
|
|
48
124
|
}
|
|
125
|
+
/**
|
|
126
|
+
* Formats the route method for the ansi list and table with dim styling.
|
|
127
|
+
*
|
|
128
|
+
* @param method - The HTTP method to format (GET, POST, etc.)
|
|
129
|
+
*/
|
|
49
130
|
#formatRouteMethod(method) {
|
|
50
131
|
return this.#colors.dim(method);
|
|
51
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* Formats route pattern for the ansi list and table with colored parameters and route name.
|
|
135
|
+
*
|
|
136
|
+
* @param route - The serialized route containing pattern and name information
|
|
137
|
+
*/
|
|
52
138
|
#formatRoutePattern(route) {
|
|
53
139
|
const pattern = this.#router.parsePattern(route.pattern).map((token) => {
|
|
54
140
|
if (token.type === 1) return this.#colors.yellow(`:${token.val}`);
|
|
@@ -58,15 +144,31 @@ var RoutesListFormatter = class {
|
|
|
58
144
|
}).join("/");
|
|
59
145
|
return `${pattern === "/" ? pattern : `/${pattern}`}${route.name ? ` ${this.#colors.dim(`(${route.name})`)}` : ""} `;
|
|
60
146
|
}
|
|
147
|
+
/**
|
|
148
|
+
* Formats controller name for the ansi list and table with cyan coloring.
|
|
149
|
+
*
|
|
150
|
+
* @param route - The serialized route containing handler information
|
|
151
|
+
*/
|
|
61
152
|
#formatControllerName(route) {
|
|
62
153
|
return route.handler.type === "controller" ? ` ${this.#colors.cyan(route.handler.moduleNameOrPath)}.` : "";
|
|
63
154
|
}
|
|
155
|
+
/**
|
|
156
|
+
* Formats action name for the ansi list and table with cyan coloring and arguments.
|
|
157
|
+
*
|
|
158
|
+
* @param route - The serialized route containing handler information
|
|
159
|
+
*/
|
|
64
160
|
#formatAction(route) {
|
|
65
161
|
if (route.handler.type === "controller") return `${this.#colors.cyan(route.handler.method)}`;
|
|
66
162
|
const functionName = ` ${this.#colors.cyan(route.handler.name)}`;
|
|
67
163
|
if (route.handler.args) return ` ${functionName}${this.#colors.dim(`(${route.handler.args})`)}`;
|
|
68
164
|
return functionName;
|
|
69
165
|
}
|
|
166
|
+
/**
|
|
167
|
+
* Formats route middleware for the ansi list and table with optional compacting.
|
|
168
|
+
*
|
|
169
|
+
* @param route - The serialized route containing middleware information
|
|
170
|
+
* @param mode - Display mode: 'normal' shows all middleware, 'compact' truncates long lists
|
|
171
|
+
*/
|
|
70
172
|
#formatMiddleware(route, mode = "normal") {
|
|
71
173
|
if (mode === "compact" && route.middleware.length > 3) {
|
|
72
174
|
const firstMiddleware = route.middleware[0].name;
|
|
@@ -76,6 +178,10 @@ var RoutesListFormatter = class {
|
|
|
76
178
|
}
|
|
77
179
|
return this.#colors.dim(`${route.middleware.map((one) => one.name).filter((one) => one).join(", ")}`);
|
|
78
180
|
}
|
|
181
|
+
/**
|
|
182
|
+
* Formatting the domain headling to be in green color with
|
|
183
|
+
* dots around it
|
|
184
|
+
*/
|
|
79
185
|
#formatDomainHeadline(domain) {
|
|
80
186
|
if (domain !== "root") return cliHelpers.justify([`${this.#colors.dim("..")} ${this.#colors.green(domain)} `], {
|
|
81
187
|
maxWidth: this.#options.maxPrettyPrintWidth || cliHelpers.TERMINAL_SIZE,
|
|
@@ -83,17 +189,29 @@ var RoutesListFormatter = class {
|
|
|
83
189
|
})[0];
|
|
84
190
|
return "";
|
|
85
191
|
}
|
|
192
|
+
/**
|
|
193
|
+
* Justify the ansi list
|
|
194
|
+
*/
|
|
86
195
|
#justifyListTables(tables) {
|
|
87
196
|
return tables.map((table) => {
|
|
197
|
+
/**
|
|
198
|
+
* Formatting methods
|
|
199
|
+
*/
|
|
88
200
|
const methods = table.rows.map((columns) => columns[0]);
|
|
89
201
|
const largestMethodsLength = Math.max(...methods.map((method) => stringWidth(method)));
|
|
90
202
|
const formattedMethods = cliHelpers.justify(methods, { maxWidth: largestMethodsLength });
|
|
203
|
+
/**
|
|
204
|
+
* Formatting patterns
|
|
205
|
+
*/
|
|
91
206
|
const patterns = table.rows.map((columns) => columns[1]);
|
|
92
207
|
const largestPatternLength = Math.max(...patterns.map((pattern) => stringWidth(pattern)));
|
|
93
208
|
const formattedPatterns = cliHelpers.justify(patterns, {
|
|
94
209
|
maxWidth: largestPatternLength,
|
|
95
210
|
paddingChar: this.#colors.dim(".")
|
|
96
211
|
});
|
|
212
|
+
/**
|
|
213
|
+
* Formatting middleware to be right aligned
|
|
214
|
+
*/
|
|
97
215
|
const middleware = table.rows.map((columns) => columns[3]);
|
|
98
216
|
const largestMiddlewareLength = Math.max(...middleware.map((one) => stringWidth(one)));
|
|
99
217
|
const formattedMiddleware = cliHelpers.justify(middleware, {
|
|
@@ -101,6 +219,10 @@ var RoutesListFormatter = class {
|
|
|
101
219
|
align: "right",
|
|
102
220
|
paddingChar: " "
|
|
103
221
|
});
|
|
222
|
+
/**
|
|
223
|
+
* Formatting controllers to be right aligned and take all the remaining
|
|
224
|
+
* space after printing route method, pattern and middleware.
|
|
225
|
+
*/
|
|
104
226
|
const controllers = table.rows.map((columns) => columns[2]);
|
|
105
227
|
const largestControllerLength = (this.#options.maxPrettyPrintWidth || cliHelpers.TERMINAL_SIZE) - (largestPatternLength + largestMethodsLength + largestMiddlewareLength);
|
|
106
228
|
const formattedControllers = cliHelpers.truncate(cliHelpers.justify(controllers, {
|
|
@@ -117,6 +239,55 @@ var RoutesListFormatter = class {
|
|
|
117
239
|
};
|
|
118
240
|
});
|
|
119
241
|
}
|
|
242
|
+
/**
|
|
243
|
+
* Formats middleware info into a compact string representation.
|
|
244
|
+
* Named middleware with args becomes "name:args", closures use their name as-is.
|
|
245
|
+
*/
|
|
246
|
+
#formatMiddlewareAsString(middleware) {
|
|
247
|
+
if (middleware.type === "named" && middleware.args) return `${middleware.name}:${middleware.args}`;
|
|
248
|
+
return middleware.name;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Formats routes as JSONL (one JSON object per line). Each line is a
|
|
252
|
+
* self-contained route object with flattened domain, simplified handler,
|
|
253
|
+
* and middleware as a string array. Optimized for machine consumption
|
|
254
|
+
* by AI agents and CLI tools.
|
|
255
|
+
*/
|
|
256
|
+
async formatAsJSONL() {
|
|
257
|
+
const routes = this.#router.toJSON();
|
|
258
|
+
const domains = Object.keys(routes);
|
|
259
|
+
const lines = [];
|
|
260
|
+
for (let domain of domains) for (let route of routes[domain]) {
|
|
261
|
+
const serializedRoute = await this.#serializeRoute(route);
|
|
262
|
+
if (!this.#isAllowedByFilters(serializedRoute)) continue;
|
|
263
|
+
const handler = serializedRoute.handler.type === "controller" ? {
|
|
264
|
+
type: "controller",
|
|
265
|
+
module: serializedRoute.handler.moduleNameOrPath,
|
|
266
|
+
method: serializedRoute.handler.method
|
|
267
|
+
} : {
|
|
268
|
+
type: serializedRoute.handler.name === "redirectsToRoute" ? "redirect" : "closure",
|
|
269
|
+
name: serializedRoute.handler.name,
|
|
270
|
+
...serializedRoute.handler.args ? { args: serializedRoute.handler.args } : {}
|
|
271
|
+
};
|
|
272
|
+
const middleware = serializedRoute.middleware.map((m) => this.#formatMiddlewareAsString(m)).filter((m) => !!m);
|
|
273
|
+
for (let method of serializedRoute.methods) {
|
|
274
|
+
const entry = {
|
|
275
|
+
method,
|
|
276
|
+
pattern: serializedRoute.pattern,
|
|
277
|
+
handler
|
|
278
|
+
};
|
|
279
|
+
if (serializedRoute.name) entry.name = serializedRoute.name;
|
|
280
|
+
if (domain !== "root") entry.domain = domain;
|
|
281
|
+
if (middleware.length > 0) entry.middleware = middleware;
|
|
282
|
+
lines.push(JSON.stringify(entry));
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
return lines;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Formats routes as an array of objects. Routes are grouped by
|
|
289
|
+
* domain.
|
|
290
|
+
*/
|
|
120
291
|
async formatAsJSON() {
|
|
121
292
|
const routes = this.#router.toJSON();
|
|
122
293
|
const domains = Object.keys(routes);
|
|
@@ -130,6 +301,11 @@ var RoutesListFormatter = class {
|
|
|
130
301
|
}
|
|
131
302
|
return routesJSON;
|
|
132
303
|
}
|
|
304
|
+
/**
|
|
305
|
+
* Format routes to ansi list of tables. Each domain has its own table
|
|
306
|
+
* with heading and rows. Each row has colums with colors and spacing
|
|
307
|
+
* around them.
|
|
308
|
+
*/
|
|
133
309
|
async formatAsAnsiList() {
|
|
134
310
|
const routes = this.#router.toJSON();
|
|
135
311
|
const domains = Object.keys(routes);
|
|
@@ -144,6 +320,10 @@ var RoutesListFormatter = class {
|
|
|
144
320
|
` ${this.#colors.dim("MIDDLEWARE")}`
|
|
145
321
|
]]
|
|
146
322
|
};
|
|
323
|
+
/**
|
|
324
|
+
* Computing table rows. Each route+method will have its
|
|
325
|
+
* own row
|
|
326
|
+
*/
|
|
147
327
|
for (let route of routes[domain]) {
|
|
148
328
|
const serializedRoute = await this.#serializeRoute(route);
|
|
149
329
|
if (this.#isAllowedByFilters(serializedRoute)) serializedRoute.methods.forEach((method) => {
|
|
@@ -159,6 +339,11 @@ var RoutesListFormatter = class {
|
|
|
159
339
|
}
|
|
160
340
|
return this.#justifyListTables(tables);
|
|
161
341
|
}
|
|
342
|
+
/**
|
|
343
|
+
* Format routes to ansi tables. Each domain has its own table
|
|
344
|
+
* with heading and rows. Each row has colums with colors and spacing
|
|
345
|
+
* around them.
|
|
346
|
+
*/
|
|
162
347
|
async formatAsAnsiTable() {
|
|
163
348
|
const routes = this.#router.toJSON();
|
|
164
349
|
const domains = Object.keys(routes);
|
|
@@ -179,6 +364,10 @@ var RoutesListFormatter = class {
|
|
|
179
364
|
}
|
|
180
365
|
])
|
|
181
366
|
};
|
|
367
|
+
/**
|
|
368
|
+
* Computing table rows. Each route+method will have its
|
|
369
|
+
* own row
|
|
370
|
+
*/
|
|
182
371
|
for (let route of routes[domain]) {
|
|
183
372
|
const serializedRoute = await this.#serializeRoute(route);
|
|
184
373
|
if (this.#isAllowedByFilters(serializedRoute)) serializedRoute.methods.forEach((method) => {
|
|
@@ -201,20 +390,68 @@ var RoutesListFormatter = class {
|
|
|
201
390
|
return tables;
|
|
202
391
|
}
|
|
203
392
|
};
|
|
393
|
+
//#endregion
|
|
394
|
+
//#region commands/list/routes.ts
|
|
395
|
+
/**
|
|
396
|
+
* Command to display a list of all registered routes in the application.
|
|
397
|
+
* Supports filtering by keywords, middleware, and output formatting options.
|
|
398
|
+
* Routes can be displayed as a formatted list, table, or JSON.
|
|
399
|
+
*
|
|
400
|
+
* @example
|
|
401
|
+
* ```
|
|
402
|
+
* ace list:routes
|
|
403
|
+
* ace list:routes user
|
|
404
|
+
* ace list:routes --middleware=auth
|
|
405
|
+
* ace list:routes --ignore-middleware=guest
|
|
406
|
+
* ace list:routes --json
|
|
407
|
+
* ace list:routes --table
|
|
408
|
+
* ```
|
|
409
|
+
*/
|
|
204
410
|
var ListRoutes = class extends BaseCommand {
|
|
411
|
+
/**
|
|
412
|
+
* The command name
|
|
413
|
+
*/
|
|
205
414
|
static commandName = "list:routes";
|
|
206
|
-
|
|
415
|
+
/**
|
|
416
|
+
* The command description
|
|
417
|
+
*/
|
|
418
|
+
static description = "List all registered routes with their HTTP methods, URL patterns, handlers, and middleware";
|
|
419
|
+
/**
|
|
420
|
+
* Command options configuration.
|
|
421
|
+
* Requires the application to be started so routes are loaded.
|
|
422
|
+
*/
|
|
207
423
|
static options = { startApp: true };
|
|
424
|
+
/**
|
|
425
|
+
* Execute the command to list application routes.
|
|
426
|
+
* Creates a formatter with the specified filters and outputs routes
|
|
427
|
+
* in the requested format (JSON, table, or formatted list).
|
|
428
|
+
*/
|
|
208
429
|
async run() {
|
|
209
430
|
const formatter = new RoutesListFormatter(await this.app.container.make("router"), this.ui, {}, {
|
|
210
431
|
ignoreMiddleware: this.ignoreMiddleware,
|
|
211
432
|
middleware: this.middleware,
|
|
212
433
|
match: this.match
|
|
213
434
|
});
|
|
435
|
+
/**
|
|
436
|
+
* Display as JSONL (one JSON object per line).
|
|
437
|
+
* Auto-selected when running inside an AI agent and no
|
|
438
|
+
* explicit format flag is provided.
|
|
439
|
+
*/
|
|
440
|
+
if (this.jsonl || !this.json && !this.table && this.app.runningInAIAgent) {
|
|
441
|
+
const lines = await formatter.formatAsJSONL();
|
|
442
|
+
for (const line of lines) this.logger.log(line);
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* Display as JSON
|
|
447
|
+
*/
|
|
214
448
|
if (this.json) {
|
|
215
449
|
this.logger.log(JSON.stringify(await formatter.formatAsJSON(), null, 2));
|
|
216
450
|
return;
|
|
217
451
|
}
|
|
452
|
+
/**
|
|
453
|
+
* Display as a standard table
|
|
454
|
+
*/
|
|
218
455
|
if (this.table) {
|
|
219
456
|
(await formatter.formatAsAnsiTable()).forEach((table) => {
|
|
220
457
|
this.logger.log("");
|
|
@@ -244,4 +481,6 @@ __decorate([flags.array({ description: "View routes that includes all the mentio
|
|
|
244
481
|
__decorate([flags.array({ description: "View routes that does not include all the mentioned middleware names. Use * to see routes that are using zero middleware" })], ListRoutes.prototype, "ignoreMiddleware", void 0);
|
|
245
482
|
__decorate([flags.boolean({ description: "Get routes list as a JSON string" })], ListRoutes.prototype, "json", void 0);
|
|
246
483
|
__decorate([flags.boolean({ description: "View list of routes as a table" })], ListRoutes.prototype, "table", void 0);
|
|
484
|
+
__decorate([flags.boolean({ description: "Get routes as JSONL, one JSON object per line (optimized for AI agents)" })], ListRoutes.prototype, "jsonl", void 0);
|
|
485
|
+
//#endregion
|
|
247
486
|
export { ListRoutes as default };
|
|
@@ -1,10 +1,38 @@
|
|
|
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/command.ts
|
|
6
|
+
/**
|
|
7
|
+
* Command to create a new Ace command class.
|
|
8
|
+
* Ace commands are CLI commands that can be executed via the `ace` binary,
|
|
9
|
+
* allowing you to create custom functionality for your application's command line interface.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```
|
|
13
|
+
* ace make:command SendEmails
|
|
14
|
+
* ace make:command ProcessPayments
|
|
15
|
+
* ace make:command GenerateReports
|
|
16
|
+
* ace make:command CleanupFiles
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
4
19
|
var MakeCommand = class extends BaseCommand {
|
|
20
|
+
/**
|
|
21
|
+
* The command name
|
|
22
|
+
*/
|
|
5
23
|
static commandName = "make:command";
|
|
6
|
-
|
|
24
|
+
/**
|
|
25
|
+
* The command description
|
|
26
|
+
*/
|
|
27
|
+
static description = "Create a new Ace CLI command class in commands/";
|
|
28
|
+
/**
|
|
29
|
+
* The stub template file to use for generating the command class
|
|
30
|
+
*/
|
|
7
31
|
stubPath = "make/command/main.stub";
|
|
32
|
+
/**
|
|
33
|
+
* Execute the command to create a new Ace command class.
|
|
34
|
+
* Generates the command file with proper CLI command structure.
|
|
35
|
+
*/
|
|
8
36
|
async run() {
|
|
9
37
|
await (await this.createCodemods()).makeUsingStub(stubsRoot, this.stubPath, {
|
|
10
38
|
flags: this.parsed.flags,
|
|
@@ -14,4 +42,5 @@ var MakeCommand = class extends BaseCommand {
|
|
|
14
42
|
};
|
|
15
43
|
__decorate([args.string({ description: "Name of the command" })], MakeCommand.prototype, "name", void 0);
|
|
16
44
|
__decorate([flags.string({ description: "Use the contents of the given file as the generated output" })], MakeCommand.prototype, "contentsFrom", void 0);
|
|
45
|
+
//#endregion
|
|
17
46
|
export { MakeCommand as default };
|