@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.
- package/build/commands/add.js +40 -110
- package/build/commands/build.js +51 -107
- package/build/commands/configure.js +82 -177
- package/build/commands/eject.js +17 -60
- package/build/commands/env/add.js +55 -134
- package/build/commands/generate_key.js +22 -66
- package/build/commands/inspect_rcfile.js +27 -55
- package/build/commands/list/routes.js +246 -116
- package/build/commands/make/command.js +15 -57
- package/build/commands/make/controller.js +43 -120
- package/build/commands/make/event.js +16 -62
- package/build/commands/make/exception.js +16 -62
- package/build/commands/make/listener.js +36 -93
- package/build/commands/make/middleware.js +41 -101
- package/build/commands/make/preload.js +47 -113
- package/build/commands/make/provider.js +47 -112
- package/build/commands/make/service.js +16 -55
- package/build/commands/make/test.js +47 -132
- package/build/commands/make/transformer.js +17 -64
- package/build/commands/make/validator.js +20 -80
- package/build/commands/make/view.js +15 -56
- package/build/commands/repl.js +17 -50
- package/build/commands/serve.js +80 -156
- package/build/commands/test.js +92 -208
- package/build/factories/app.js +2 -9
- package/build/factories/bodyparser.js +2 -9
- package/build/factories/core/ace.js +15 -46
- package/build/factories/core/ignitor.js +12 -180
- package/build/factories/core/main.js +22 -11
- package/build/factories/core/test_utils.js +19 -43
- package/build/factories/encryption.js +2 -9
- package/build/factories/events.js +2 -9
- package/build/factories/hash.js +2 -9
- package/build/factories/http.js +2 -9
- package/build/factories/logger.js +2 -9
- package/build/factories/stubs.js +28 -91
- package/build/index.js +13 -46
- package/build/modules/ace/codemods.d.ts +109 -14
- package/build/modules/ace/codemods.js +222 -374
- package/build/modules/ace/main.d.ts +30 -0
- package/build/modules/ace/main.js +2 -11
- package/build/modules/app.d.ts +17 -0
- package/build/modules/app.js +4 -9
- package/build/modules/bodyparser/bodyparser_middleware.js +2 -14
- package/build/modules/bodyparser/main.js +4 -9
- package/build/modules/config.d.ts +17 -0
- package/build/modules/config.js +4 -9
- package/build/modules/container.js +4 -9
- package/build/modules/dumper/dumper.d.ts +5 -0
- package/build/modules/dumper/main.d.ts +21 -0
- package/build/modules/dumper/main.js +6 -11
- package/build/modules/dumper/plugins/edge.js +2 -62
- package/build/modules/encryption.d.ts +17 -0
- package/build/modules/encryption.js +4 -9
- package/build/modules/env/editor.js +2 -9
- package/build/modules/env/main.d.ts +19 -0
- package/build/modules/env/main.js +2 -9
- package/build/modules/events.js +4 -9
- package/build/modules/hash/drivers/argon.js +2 -9
- package/build/modules/hash/drivers/bcrypt.d.ts +11 -0
- package/build/modules/hash/drivers/bcrypt.js +2 -9
- package/build/modules/hash/drivers/scrypt.js +2 -9
- package/build/modules/hash/main.d.ts +18 -0
- package/build/modules/hash/main.js +6 -10
- package/build/modules/hash/phc_formatter.js +2 -9
- package/build/modules/health.js +2 -9
- package/build/modules/http/main.js +4 -15
- package/build/modules/http/url_builder_client.d.ts +1 -0
- package/build/modules/http/url_builder_client.js +2 -0
- package/build/modules/logger.d.ts +30 -0
- package/build/modules/logger.js +4 -9
- package/build/modules/repl.js +4 -9
- package/build/modules/transformers/main.js +4 -9
- package/build/providers/app_provider.d.ts +9 -21
- package/build/providers/app_provider.js +147 -363
- package/build/providers/edge_provider.js +97 -104
- package/build/providers/hash_provider.js +29 -91
- package/build/providers/repl_provider.js +61 -152
- package/build/providers/vinejs_provider.d.ts +1 -1
- package/build/providers/vinejs_provider.js +20 -66
- package/build/services/ace.js +2 -17
- package/build/services/app.js +2 -21
- package/build/services/config.js +2 -13
- package/build/services/dumper.js +5 -21
- package/build/services/emitter.js +2 -14
- package/build/services/encryption.js +2 -14
- package/build/services/hash.js +2 -14
- package/build/services/logger.js +2 -14
- package/build/services/repl.js +2 -14
- package/build/services/router.js +2 -14
- package/build/services/server.js +2 -14
- package/build/services/test_utils.js +2 -17
- package/build/services/url_builder.js +5 -17
- package/build/src/exceptions.js +2 -49
- package/build/src/helpers/assert.js +2 -55
- package/build/src/helpers/http.d.ts +20 -0
- package/build/src/helpers/http.js +2 -0
- package/build/src/helpers/is.js +3 -31
- package/build/src/helpers/main.d.ts +1 -5
- package/build/src/helpers/main.js +5 -56
- package/build/src/helpers/string.js +2 -60
- package/build/src/helpers/types.js +26 -135
- package/build/src/helpers/verification_token.js +2 -120
- package/build/src/test_utils/main.js +5 -77
- package/build/src/types.d.ts +1 -0
- package/build/src/types.js +0 -8
- package/build/src/utils.d.ts +1 -1
- package/build/src/vine.js +2 -97
- package/build/types/ace.js +2 -9
- package/build/types/app.js +2 -9
- package/build/types/bodyparser.js +2 -9
- package/build/types/common.js +2 -9
- package/build/types/container.js +2 -9
- package/build/types/encryption.js +2 -9
- package/build/types/events.js +2 -9
- package/build/types/hash.js +2 -9
- package/build/types/health.js +2 -9
- package/build/types/helpers.d.ts +20 -0
- package/build/types/helpers.js +0 -8
- package/build/types/http.js +2 -9
- package/build/types/logger.js +2 -9
- package/build/types/repl.js +2 -9
- package/build/types/transformers.js +2 -9
- package/package.json +88 -30
- package/build/modules/ace/commands.js +0 -157
- package/build/modules/ace/create_kernel.js +0 -91
- package/build/modules/ace/kernel.js +0 -40
- package/build/modules/dumper/define_config.js +0 -36
- package/build/modules/dumper/dumper.js +0 -256
- package/build/modules/dumper/errors.js +0 -119
- package/build/modules/hash/define_config.js +0 -125
- package/build/modules/http/request_validator.js +0 -100
- package/build/src/assembler_hooks/index_entities.js +0 -106
- package/build/src/cli_formatters/routes_list.js +0 -381
- package/build/src/config_provider.js +0 -71
- package/build/src/debug.js +0 -25
- package/build/src/ignitor/ace.js +0 -102
- package/build/src/ignitor/http.js +0 -146
- package/build/src/ignitor/main.js +0 -124
- package/build/src/ignitor/test.js +0 -66
- package/build/src/test_utils/http.js +0 -82
- package/build/src/utils.js +0 -104
- package/build/stubs/main.js +0 -9
- package/build/toolkit/commands/index_commands.js +0 -30
- package/build/toolkit/main.js +0 -27
|
@@ -1,117 +1,247 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { f as BaseCommand, l as flags, o as args, s as cliHelpers } from "../../main-Cn_x9YY5.js";
|
|
2
|
+
import { t as __decorate } from "../../decorate-DM0Sx1ye.js";
|
|
3
|
+
import stringWidth from "string-width";
|
|
4
|
+
import { middlewareInfo, routeInfo } from "@adonisjs/http-server/helpers";
|
|
5
|
+
var RoutesListFormatter = class {
|
|
6
|
+
#router;
|
|
7
|
+
#colors;
|
|
8
|
+
#table;
|
|
9
|
+
#options;
|
|
10
|
+
#filters;
|
|
11
|
+
constructor(router, ui, options, filters) {
|
|
12
|
+
this.#router = router;
|
|
13
|
+
this.#colors = ui.colors;
|
|
14
|
+
this.#table = ui.table;
|
|
15
|
+
this.#filters = filters;
|
|
16
|
+
this.#options = options;
|
|
17
|
+
this.#router.commit();
|
|
18
|
+
}
|
|
19
|
+
#isAllowedByFilters(route) {
|
|
20
|
+
let allowRoute = true;
|
|
21
|
+
if (this.#filters.middleware) allowRoute = this.#filters.middleware.every((name) => {
|
|
22
|
+
if (name === "*") return route.middleware.length > 0;
|
|
23
|
+
return route.middleware.find((middleware) => middleware.name === name);
|
|
24
|
+
});
|
|
25
|
+
if (allowRoute && this.#filters.ignoreMiddleware) allowRoute = this.#filters.ignoreMiddleware.every((name) => {
|
|
26
|
+
if (name === "*") return route.middleware.length === 0;
|
|
27
|
+
return !route.middleware.find((middleware) => middleware.name === name);
|
|
28
|
+
});
|
|
29
|
+
if (!this.#filters.match) return allowRoute;
|
|
30
|
+
if (route.name.includes(this.#filters.match)) return true;
|
|
31
|
+
if (route.pattern.includes(this.#filters.match)) return true;
|
|
32
|
+
if (route.handler.type === "controller" ? route.handler.moduleNameOrPath.includes(this.#filters.match) : route.handler.name.includes(this.#filters.match)) return true;
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
async #serializeRoute(route) {
|
|
36
|
+
let methods = route.methods;
|
|
37
|
+
if (!this.#options.displayHeadRoutes) methods = methods.filter((method) => method !== "HEAD");
|
|
38
|
+
const middlewareList = await Promise.all([...route.middleware.all()].map((middleware) => {
|
|
39
|
+
return middlewareInfo(middleware);
|
|
40
|
+
}));
|
|
41
|
+
return {
|
|
42
|
+
name: route.name || "",
|
|
43
|
+
pattern: route.pattern,
|
|
44
|
+
methods,
|
|
45
|
+
handler: await routeInfo(route),
|
|
46
|
+
middleware: middlewareList.filter((info) => info.type !== "global")
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
#formatRouteMethod(method) {
|
|
50
|
+
return this.#colors.dim(method);
|
|
51
|
+
}
|
|
52
|
+
#formatRoutePattern(route) {
|
|
53
|
+
const pattern = this.#router.parsePattern(route.pattern).map((token) => {
|
|
54
|
+
if (token.type === 1) return this.#colors.yellow(`:${token.val}`);
|
|
55
|
+
if (token.type === 3) return this.#colors.yellow(`:${token.val}?`);
|
|
56
|
+
if (token.type === 2) return this.#colors.red(token.val);
|
|
57
|
+
return token.val;
|
|
58
|
+
}).join("/");
|
|
59
|
+
return `${pattern === "/" ? pattern : `/${pattern}`}${route.name ? ` ${this.#colors.dim(`(${route.name})`)}` : ""} `;
|
|
60
|
+
}
|
|
61
|
+
#formatControllerName(route) {
|
|
62
|
+
return route.handler.type === "controller" ? ` ${this.#colors.cyan(route.handler.moduleNameOrPath)}.` : "";
|
|
63
|
+
}
|
|
64
|
+
#formatAction(route) {
|
|
65
|
+
if (route.handler.type === "controller") return `${this.#colors.cyan(route.handler.method)}`;
|
|
66
|
+
const functionName = ` ${this.#colors.cyan(route.handler.name)}`;
|
|
67
|
+
if (route.handler.args) return ` ${functionName}${this.#colors.dim(`(${route.handler.args})`)}`;
|
|
68
|
+
return functionName;
|
|
69
|
+
}
|
|
70
|
+
#formatMiddleware(route, mode = "normal") {
|
|
71
|
+
if (mode === "compact" && route.middleware.length > 3) {
|
|
72
|
+
const firstMiddleware = route.middleware[0].name;
|
|
73
|
+
const secondMiddleware = route.middleware[1].name;
|
|
74
|
+
const diff = route.middleware.length - 2;
|
|
75
|
+
return this.#colors.dim(`${firstMiddleware}, ${secondMiddleware}, and ${diff} more`);
|
|
76
|
+
}
|
|
77
|
+
return this.#colors.dim(`${route.middleware.map((one) => one.name).filter((one) => one).join(", ")}`);
|
|
78
|
+
}
|
|
79
|
+
#formatDomainHeadline(domain) {
|
|
80
|
+
if (domain !== "root") return cliHelpers.justify([`${this.#colors.dim("..")} ${this.#colors.green(domain)} `], {
|
|
81
|
+
maxWidth: this.#options.maxPrettyPrintWidth || cliHelpers.TERMINAL_SIZE,
|
|
82
|
+
paddingChar: this.#colors.dim(".")
|
|
83
|
+
})[0];
|
|
84
|
+
return "";
|
|
85
|
+
}
|
|
86
|
+
#justifyListTables(tables) {
|
|
87
|
+
return tables.map((table) => {
|
|
88
|
+
const methods = table.rows.map((columns) => columns[0]);
|
|
89
|
+
const largestMethodsLength = Math.max(...methods.map((method) => stringWidth(method)));
|
|
90
|
+
const formattedMethods = cliHelpers.justify(methods, { maxWidth: largestMethodsLength });
|
|
91
|
+
const patterns = table.rows.map((columns) => columns[1]);
|
|
92
|
+
const largestPatternLength = Math.max(...patterns.map((pattern) => stringWidth(pattern)));
|
|
93
|
+
const formattedPatterns = cliHelpers.justify(patterns, {
|
|
94
|
+
maxWidth: largestPatternLength,
|
|
95
|
+
paddingChar: this.#colors.dim(".")
|
|
96
|
+
});
|
|
97
|
+
const middleware = table.rows.map((columns) => columns[3]);
|
|
98
|
+
const largestMiddlewareLength = Math.max(...middleware.map((one) => stringWidth(one)));
|
|
99
|
+
const formattedMiddleware = cliHelpers.justify(middleware, {
|
|
100
|
+
maxWidth: largestMiddlewareLength,
|
|
101
|
+
align: "right",
|
|
102
|
+
paddingChar: " "
|
|
103
|
+
});
|
|
104
|
+
const controllers = table.rows.map((columns) => columns[2]);
|
|
105
|
+
const largestControllerLength = (this.#options.maxPrettyPrintWidth || cliHelpers.TERMINAL_SIZE) - (largestPatternLength + largestMethodsLength + largestMiddlewareLength);
|
|
106
|
+
const formattedControllers = cliHelpers.truncate(cliHelpers.justify(controllers, {
|
|
107
|
+
maxWidth: largestControllerLength,
|
|
108
|
+
align: "right",
|
|
109
|
+
paddingChar: this.#colors.dim(".")
|
|
110
|
+
}), { maxWidth: largestControllerLength });
|
|
111
|
+
return {
|
|
112
|
+
heading: table.heading,
|
|
113
|
+
rows: formattedMethods.reduce((result, method, index) => {
|
|
114
|
+
result.push(`${method}${formattedPatterns[index]}${formattedControllers[index]}${formattedMiddleware[index]}`);
|
|
115
|
+
return result;
|
|
116
|
+
}, [])
|
|
117
|
+
};
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
async formatAsJSON() {
|
|
121
|
+
const routes = this.#router.toJSON();
|
|
122
|
+
const domains = Object.keys(routes);
|
|
123
|
+
let routesJSON = [];
|
|
124
|
+
for (let domain of domains) {
|
|
125
|
+
const domainRoutes = await Promise.all(routes[domain].map((route) => this.#serializeRoute(route)));
|
|
126
|
+
routesJSON.push({
|
|
127
|
+
domain,
|
|
128
|
+
routes: domainRoutes.filter((route) => this.#isAllowedByFilters(route))
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
return routesJSON;
|
|
132
|
+
}
|
|
133
|
+
async formatAsAnsiList() {
|
|
134
|
+
const routes = this.#router.toJSON();
|
|
135
|
+
const domains = Object.keys(routes);
|
|
136
|
+
const tables = [];
|
|
137
|
+
for (let domain of domains) {
|
|
138
|
+
const list = {
|
|
139
|
+
heading: this.#formatDomainHeadline(domain),
|
|
140
|
+
rows: [[
|
|
141
|
+
this.#colors.dim("METHOD"),
|
|
142
|
+
` ${this.#colors.dim("ROUTE")} `,
|
|
143
|
+
` ${this.#colors.dim("HANDLER")}`,
|
|
144
|
+
` ${this.#colors.dim("MIDDLEWARE")}`
|
|
145
|
+
]]
|
|
146
|
+
};
|
|
147
|
+
for (let route of routes[domain]) {
|
|
148
|
+
const serializedRoute = await this.#serializeRoute(route);
|
|
149
|
+
if (this.#isAllowedByFilters(serializedRoute)) serializedRoute.methods.forEach((method) => {
|
|
150
|
+
list.rows.push([
|
|
151
|
+
this.#formatRouteMethod(method),
|
|
152
|
+
` ${this.#formatRoutePattern(serializedRoute)}`,
|
|
153
|
+
`${this.#formatControllerName(serializedRoute)}${this.#formatAction(serializedRoute)}`,
|
|
154
|
+
` ${this.#formatMiddleware(serializedRoute, "compact")}`
|
|
155
|
+
]);
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
tables.push(list);
|
|
159
|
+
}
|
|
160
|
+
return this.#justifyListTables(tables);
|
|
161
|
+
}
|
|
162
|
+
async formatAsAnsiTable() {
|
|
163
|
+
const routes = this.#router.toJSON();
|
|
164
|
+
const domains = Object.keys(routes);
|
|
165
|
+
const tables = [];
|
|
166
|
+
for (let domain of domains) {
|
|
167
|
+
const list = {
|
|
168
|
+
heading: this.#formatDomainHeadline(domain),
|
|
169
|
+
table: this.#table().fullWidth().fluidColumnIndex(2).head([
|
|
170
|
+
this.#colors.dim("METHOD"),
|
|
171
|
+
this.#colors.dim("ROUTE"),
|
|
172
|
+
{
|
|
173
|
+
hAlign: "right",
|
|
174
|
+
content: this.#colors.dim("HANDLER")
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
content: this.#colors.dim("MIDDLEWARE"),
|
|
178
|
+
hAlign: "right"
|
|
179
|
+
}
|
|
180
|
+
])
|
|
181
|
+
};
|
|
182
|
+
for (let route of routes[domain]) {
|
|
183
|
+
const serializedRoute = await this.#serializeRoute(route);
|
|
184
|
+
if (this.#isAllowedByFilters(serializedRoute)) serializedRoute.methods.forEach((method) => {
|
|
185
|
+
list.table.row([
|
|
186
|
+
this.#formatRouteMethod(method),
|
|
187
|
+
this.#formatRoutePattern(serializedRoute),
|
|
188
|
+
{
|
|
189
|
+
content: `${this.#formatControllerName(serializedRoute)}${this.#formatAction(serializedRoute)}`,
|
|
190
|
+
hAlign: "right"
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
content: this.#formatMiddleware(serializedRoute),
|
|
194
|
+
hAlign: "right"
|
|
195
|
+
}
|
|
196
|
+
]);
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
tables.push(list);
|
|
200
|
+
}
|
|
201
|
+
return tables;
|
|
202
|
+
}
|
|
14
203
|
};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
});
|
|
60
|
-
/**
|
|
61
|
-
* Display as JSON
|
|
62
|
-
*/
|
|
63
|
-
if (this.json) {
|
|
64
|
-
this.logger.log(JSON.stringify(await formatter.formatAsJSON(), null, 2));
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Display as a standard table
|
|
69
|
-
*/
|
|
70
|
-
if (this.table) {
|
|
71
|
-
const tables = await formatter.formatAsAnsiTable();
|
|
72
|
-
tables.forEach((table) => {
|
|
73
|
-
this.logger.log('');
|
|
74
|
-
if (table.heading) {
|
|
75
|
-
this.logger.log(table.heading);
|
|
76
|
-
this.logger.log('');
|
|
77
|
-
}
|
|
78
|
-
table.table.render();
|
|
79
|
-
});
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Display as a list
|
|
84
|
-
*/
|
|
85
|
-
const list = await formatter.formatAsAnsiList();
|
|
86
|
-
list.forEach((item) => {
|
|
87
|
-
this.logger.log('');
|
|
88
|
-
if (item.heading) {
|
|
89
|
-
this.logger.log(item.heading);
|
|
90
|
-
this.logger.log('');
|
|
91
|
-
}
|
|
92
|
-
this.logger.log(item.rows.join('\n'));
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
__decorate([
|
|
97
|
-
args.string({
|
|
98
|
-
description: 'Find routes matching the given keyword. Route name, pattern and controller name will be searched against the keyword',
|
|
99
|
-
required: false,
|
|
100
|
-
})
|
|
101
|
-
], ListRoutes.prototype, "match", void 0);
|
|
102
|
-
__decorate([
|
|
103
|
-
flags.array({
|
|
104
|
-
description: 'View routes that includes all the mentioned middleware names. Use * to see routes that are using one or more middleware',
|
|
105
|
-
})
|
|
106
|
-
], ListRoutes.prototype, "middleware", void 0);
|
|
107
|
-
__decorate([
|
|
108
|
-
flags.array({
|
|
109
|
-
description: 'View routes that does not include all the mentioned middleware names. Use * to see routes that are using zero middleware',
|
|
110
|
-
})
|
|
111
|
-
], ListRoutes.prototype, "ignoreMiddleware", void 0);
|
|
112
|
-
__decorate([
|
|
113
|
-
flags.boolean({ description: 'Get routes list as a JSON string' })
|
|
114
|
-
], ListRoutes.prototype, "json", void 0);
|
|
115
|
-
__decorate([
|
|
116
|
-
flags.boolean({ description: 'View list of routes as a table' })
|
|
117
|
-
], ListRoutes.prototype, "table", void 0);
|
|
204
|
+
var ListRoutes = class extends BaseCommand {
|
|
205
|
+
static commandName = "list:routes";
|
|
206
|
+
static description = "List application routes. This command will boot the application in the console environment";
|
|
207
|
+
static options = { startApp: true };
|
|
208
|
+
async run() {
|
|
209
|
+
const formatter = new RoutesListFormatter(await this.app.container.make("router"), this.ui, {}, {
|
|
210
|
+
ignoreMiddleware: this.ignoreMiddleware,
|
|
211
|
+
middleware: this.middleware,
|
|
212
|
+
match: this.match
|
|
213
|
+
});
|
|
214
|
+
if (this.json) {
|
|
215
|
+
this.logger.log(JSON.stringify(await formatter.formatAsJSON(), null, 2));
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
if (this.table) {
|
|
219
|
+
(await formatter.formatAsAnsiTable()).forEach((table) => {
|
|
220
|
+
this.logger.log("");
|
|
221
|
+
if (table.heading) {
|
|
222
|
+
this.logger.log(table.heading);
|
|
223
|
+
this.logger.log("");
|
|
224
|
+
}
|
|
225
|
+
table.table.render();
|
|
226
|
+
});
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
(await formatter.formatAsAnsiList()).forEach((item) => {
|
|
230
|
+
this.logger.log("");
|
|
231
|
+
if (item.heading) {
|
|
232
|
+
this.logger.log(item.heading);
|
|
233
|
+
this.logger.log("");
|
|
234
|
+
}
|
|
235
|
+
this.logger.log(item.rows.join("\n"));
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
__decorate([args.string({
|
|
240
|
+
description: "Find routes matching the given keyword. Route name, pattern and controller name will be searched against the keyword",
|
|
241
|
+
required: false
|
|
242
|
+
})], ListRoutes.prototype, "match", void 0);
|
|
243
|
+
__decorate([flags.array({ description: "View routes that includes all the mentioned middleware names. Use * to see routes that are using one or more middleware" })], ListRoutes.prototype, "middleware", void 0);
|
|
244
|
+
__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
|
+
__decorate([flags.boolean({ description: "Get routes list as a JSON string" })], ListRoutes.prototype, "json", void 0);
|
|
246
|
+
__decorate([flags.boolean({ description: "View list of routes as a table" })], ListRoutes.prototype, "table", void 0);
|
|
247
|
+
export { ListRoutes as default };
|
|
@@ -1,58 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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 MakeCommand = class extends BaseCommand {
|
|
5
|
+
static commandName = "make:command";
|
|
6
|
+
static description = "Create a new ace command class";
|
|
7
|
+
stubPath = "make/command/main.stub";
|
|
8
|
+
async run() {
|
|
9
|
+
await (await this.createCodemods()).makeUsingStub(stubsRoot, this.stubPath, {
|
|
10
|
+
flags: this.parsed.flags,
|
|
11
|
+
entity: this.app.generators.createEntity(this.name)
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
14
|
};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
import { BaseCommand } from "../../modules/ace/main.js";
|
|
18
|
-
/**
|
|
19
|
-
* Command to create a new Ace command class.
|
|
20
|
-
* Ace commands are CLI commands that can be executed via the `ace` binary,
|
|
21
|
-
* allowing you to create custom functionality for your application's command line interface.
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* ```
|
|
25
|
-
* ace make:command SendEmails
|
|
26
|
-
* ace make:command ProcessPayments
|
|
27
|
-
* ace make:command GenerateReports
|
|
28
|
-
* ace make:command CleanupFiles
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
export default class MakeCommand extends BaseCommand {
|
|
32
|
-
/**
|
|
33
|
-
* The command name
|
|
34
|
-
*/
|
|
35
|
-
static commandName = 'make:command';
|
|
36
|
-
/**
|
|
37
|
-
* The command description
|
|
38
|
-
*/
|
|
39
|
-
static description = 'Create a new ace command class';
|
|
40
|
-
/**
|
|
41
|
-
* The stub template file to use for generating the command class
|
|
42
|
-
*/
|
|
43
|
-
stubPath = 'make/command/main.stub';
|
|
44
|
-
/**
|
|
45
|
-
* Execute the command to create a new Ace command class.
|
|
46
|
-
* Generates the command file with proper CLI command structure.
|
|
47
|
-
*/
|
|
48
|
-
async run() {
|
|
49
|
-
const codemods = await this.createCodemods();
|
|
50
|
-
await codemods.makeUsingStub(stubsRoot, this.stubPath, {
|
|
51
|
-
flags: this.parsed.flags,
|
|
52
|
-
entity: this.app.generators.createEntity(this.name),
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
__decorate([
|
|
57
|
-
args.string({ description: 'Name of the command' })
|
|
58
|
-
], MakeCommand.prototype, "name", void 0);
|
|
15
|
+
__decorate([args.string({ description: "Name of the command" })], MakeCommand.prototype, "name", void 0);
|
|
16
|
+
export { MakeCommand as default };
|
|
@@ -1,121 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
+
import string from "@poppinss/utils/string";
|
|
5
|
+
var MakeController = class extends BaseCommand {
|
|
6
|
+
static commandName = "make:controller";
|
|
7
|
+
static description = "Create a new HTTP controller class";
|
|
8
|
+
static options = { allowUnknownFlags: true };
|
|
9
|
+
stubPath = "make/controller/main.stub";
|
|
10
|
+
async prepare() {
|
|
11
|
+
if (this.actions) this.stubPath = "make/controller/actions.stub";
|
|
12
|
+
if (this.resource) if (this.actions) this.logger.warning("Cannot use --resource flag with actions. Ignoring --resource");
|
|
13
|
+
else this.stubPath = "make/controller/resource.stub";
|
|
14
|
+
if (this.api) if (this.actions) this.logger.warning("Cannot use --api flag with actions. Ignoring --api");
|
|
15
|
+
else this.stubPath = "make/controller/api.stub";
|
|
16
|
+
if (this.resource && this.api && !this.actions) this.logger.warning("--api and --resource flags cannot be used together. Ignoring --resource");
|
|
17
|
+
}
|
|
18
|
+
async run() {
|
|
19
|
+
await (await this.createCodemods()).makeUsingStub(stubsRoot, this.stubPath, {
|
|
20
|
+
flags: this.parsed.flags,
|
|
21
|
+
actions: this.actions?.map((action) => string.camelCase(action)),
|
|
22
|
+
entity: this.app.generators.createEntity(this.name),
|
|
23
|
+
singular: this.singular
|
|
24
|
+
});
|
|
25
|
+
}
|
|
14
26
|
};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
*/
|
|
34
|
-
static commandName = 'make:controller';
|
|
35
|
-
/**
|
|
36
|
-
* The command description
|
|
37
|
-
*/
|
|
38
|
-
static description = 'Create a new HTTP controller class';
|
|
39
|
-
/**
|
|
40
|
-
* Command options configuration
|
|
41
|
-
*/
|
|
42
|
-
static options = {
|
|
43
|
-
allowUnknownFlags: true,
|
|
44
|
-
};
|
|
45
|
-
/**
|
|
46
|
-
* The stub to use for generating the controller
|
|
47
|
-
*/
|
|
48
|
-
stubPath = 'make/controller/main.stub';
|
|
49
|
-
/**
|
|
50
|
-
* Preparing the command state
|
|
51
|
-
*/
|
|
52
|
-
async prepare() {
|
|
53
|
-
/**
|
|
54
|
-
* Use actions stub
|
|
55
|
-
*/
|
|
56
|
-
if (this.actions) {
|
|
57
|
-
this.stubPath = 'make/controller/actions.stub';
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Use resource stub
|
|
61
|
-
*/
|
|
62
|
-
if (this.resource) {
|
|
63
|
-
if (this.actions) {
|
|
64
|
-
this.logger.warning('Cannot use --resource flag with actions. Ignoring --resource');
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
this.stubPath = 'make/controller/resource.stub';
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Use api stub
|
|
72
|
-
*/
|
|
73
|
-
if (this.api) {
|
|
74
|
-
if (this.actions) {
|
|
75
|
-
this.logger.warning('Cannot use --api flag with actions. Ignoring --api');
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
this.stubPath = 'make/controller/api.stub';
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Log warning when both flags are used together
|
|
83
|
-
*/
|
|
84
|
-
if (this.resource && this.api && !this.actions) {
|
|
85
|
-
this.logger.warning('--api and --resource flags cannot be used together. Ignoring --resource');
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
async run() {
|
|
89
|
-
const codemods = await this.createCodemods();
|
|
90
|
-
await codemods.makeUsingStub(stubsRoot, this.stubPath, {
|
|
91
|
-
flags: this.parsed.flags,
|
|
92
|
-
actions: this.actions?.map((action) => string.camelCase(action)),
|
|
93
|
-
entity: this.app.generators.createEntity(this.name),
|
|
94
|
-
singular: this.singular,
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
__decorate([
|
|
99
|
-
args.string({ description: 'The name of the controller' })
|
|
100
|
-
], MakeController.prototype, "name", void 0);
|
|
101
|
-
__decorate([
|
|
102
|
-
args.spread({ description: 'Create controller with custom method names', required: false })
|
|
103
|
-
], MakeController.prototype, "actions", void 0);
|
|
104
|
-
__decorate([
|
|
105
|
-
flags.boolean({
|
|
106
|
-
description: 'Generate controller in singular form',
|
|
107
|
-
alias: 's',
|
|
108
|
-
})
|
|
109
|
-
], MakeController.prototype, "singular", void 0);
|
|
110
|
-
__decorate([
|
|
111
|
-
flags.boolean({
|
|
112
|
-
description: 'Generate resourceful controller with methods to perform CRUD actions on a resource',
|
|
113
|
-
alias: 'r',
|
|
114
|
-
})
|
|
115
|
-
], MakeController.prototype, "resource", void 0);
|
|
116
|
-
__decorate([
|
|
117
|
-
flags.boolean({
|
|
118
|
-
description: 'Generate resourceful controller without the "edit" and the "create" methods',
|
|
119
|
-
alias: 'a',
|
|
120
|
-
})
|
|
121
|
-
], MakeController.prototype, "api", void 0);
|
|
27
|
+
__decorate([args.string({ description: "The name of the controller" })], MakeController.prototype, "name", void 0);
|
|
28
|
+
__decorate([args.spread({
|
|
29
|
+
description: "Create controller with custom method names",
|
|
30
|
+
required: false
|
|
31
|
+
})], MakeController.prototype, "actions", void 0);
|
|
32
|
+
__decorate([flags.boolean({
|
|
33
|
+
description: "Generate controller in singular form",
|
|
34
|
+
alias: "s"
|
|
35
|
+
})], MakeController.prototype, "singular", void 0);
|
|
36
|
+
__decorate([flags.boolean({
|
|
37
|
+
description: "Generate resourceful controller with methods to perform CRUD actions on a resource",
|
|
38
|
+
alias: "r"
|
|
39
|
+
})], MakeController.prototype, "resource", void 0);
|
|
40
|
+
__decorate([flags.boolean({
|
|
41
|
+
description: "Generate resourceful controller without the \"edit\" and the \"create\" methods",
|
|
42
|
+
alias: "a"
|
|
43
|
+
})], MakeController.prototype, "api", void 0);
|
|
44
|
+
export { MakeController as default };
|