@adonisjs/core 7.0.0-next.2 → 7.0.0-next.20
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-sWl9sgM1.js +16 -0
- package/build/app-B6oge7b3.js +5 -0
- package/build/app-DNvbxVWl.js +5 -0
- package/build/bodyparser_middleware-BmARtnYe.js +3 -0
- package/build/chunk-B88MteZI.js +26 -0
- package/build/commands/add.d.ts +4 -3
- package/build/commands/add.js +76 -110
- package/build/commands/build.js +51 -107
- package/build/commands/commands.json +1 -1
- 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/config-Dd2H6-_e.js +5 -0
- package/build/config_provider-DWVFHOQX.js +15 -0
- package/build/container-uxa8LpGI.js +5 -0
- package/build/core-BuPP8K6N.js +140 -0
- package/build/create_kernel-Cn8zVtvt.js +3 -0
- package/build/create_kernel-Cpqqa931.js +38 -0
- package/build/decorate-CJcHOoD-.js +7 -0
- package/build/define_config-CoWy5lbf.js +62 -0
- package/build/dumper-BTjb8j4y.js +147 -0
- package/build/edge-BVYR-Vjr.js +47 -0
- package/build/events-C4d0OPUI.js +5 -0
- package/build/exceptions-DNMesP42.js +2 -0
- package/build/factories/app.js +2 -9
- package/build/factories/bodyparser.js +2 -9
- package/build/factories/core/ace.js +16 -46
- package/build/factories/core/ignitor.js +13 -180
- package/build/factories/core/main.js +24 -11
- package/build/factories/core/test_utils.js +21 -43
- package/build/factories/encryption.d.ts +1 -1
- 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 +27 -91
- package/build/ignitor-BrmVPN5N.js +71 -0
- package/build/index.d.ts +1 -1
- package/build/index.js +12 -46
- package/build/logger-0KKSqgPG.js +13 -0
- package/build/main-BU8NWUEG.js +73 -0
- package/build/main-Bfnr5tAw.js +2 -0
- package/build/main-BlJhxJJ2.js +81 -0
- package/build/main-C4B2SPOT.js +5 -0
- package/build/main-CZZ21eXm.js +171 -0
- package/build/main-D-WhqOOn.js +51 -0
- package/build/main-DOY5Q8Av.js +5 -0
- package/build/main-kn40V-hF.js +2 -0
- package/build/main-nojlltNo.js +30 -0
- package/build/{stubs/make → make}/health/controller.stub +5 -2
- package/build/modules/ace/codemods.d.ts +109 -14
- package/build/modules/ace/codemods.js +222 -382
- 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/define_config.d.ts +128 -0
- package/build/modules/encryption/drivers/aes_256_cbc.d.ts +20 -0
- package/build/modules/encryption/drivers/aes_256_cbc.js +2 -0
- package/build/modules/encryption/drivers/aes_256_gcm.d.ts +21 -0
- package/build/modules/encryption/drivers/aes_256_gcm.js +2 -0
- package/build/modules/encryption/drivers/chacha20_poly1305.d.ts +21 -0
- package/build/modules/encryption/drivers/chacha20_poly1305.js +2 -0
- package/build/modules/encryption/main.d.ts +85 -0
- package/build/modules/encryption/main.js +5 -0
- 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 +5 -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/request_validator.d.ts +1 -3
- 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 +14 -25
- package/build/providers/app_provider.js +155 -363
- package/build/providers/edge_provider.js +97 -114
- package/build/providers/hash_provider.js +28 -91
- package/build/providers/repl_provider.js +66 -152
- package/build/providers/vinejs_provider.d.ts +1 -1
- package/build/providers/vinejs_provider.js +19 -66
- package/build/repl-GSxgovJQ.js +5 -0
- 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.d.ts +3 -3
- package/build/services/url_builder.js +5 -17
- package/build/src/assembler_hooks/index_entities.d.ts +29 -1
- package/build/src/debug.d.ts +1 -1
- 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 +8 -77
- package/build/src/types.d.ts +53 -99
- package/build/src/types.js +0 -8
- package/build/src/utils.d.ts +1 -1
- package/build/src/vine.js +2 -97
- package/build/string-Cx6q_win.js +28 -0
- package/build/test_utils-hkQDmNpX.js +10 -0
- package/build/toolkit/main.js +19 -21
- 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.d.ts +39 -1
- package/build/types/encryption.js +1 -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/build/utils-CtGytdtt.js +42 -0
- package/build/verification_token-DrdoU4RH.js +46 -0
- package/build/vine-DGint2rk.js +32 -0
- package/package.json +113 -60
- 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/encryption.d.ts +0 -1
- package/build/modules/encryption.js +0 -9
- 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 -107
- 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/{stubs/make → make}/command/main.stub +0 -0
- /package/build/{stubs/make → make}/controller/actions.stub +0 -0
- /package/build/{stubs/make → make}/controller/api.stub +0 -0
- /package/build/{stubs/make → make}/controller/main.stub +0 -0
- /package/build/{stubs/make → make}/controller/resource.stub +0 -0
- /package/build/{stubs/make → make}/event/main.stub +0 -0
- /package/build/{stubs/make → make}/exception/main.stub +0 -0
- /package/build/{stubs/make → make}/health/main.stub +0 -0
- /package/build/{stubs/make → make}/listener/for_event.stub +0 -0
- /package/build/{stubs/make → make}/listener/main.stub +0 -0
- /package/build/{stubs/make → make}/middleware/main.stub +0 -0
- /package/build/{stubs/make → make}/preload/main.stub +0 -0
- /package/build/{stubs/make → make}/provider/main.stub +0 -0
- /package/build/{stubs/make → make}/service/main.stub +0 -0
- /package/build/{stubs/make → make}/test/main.stub +0 -0
- /package/build/{stubs/make → make}/transformer/main.stub +0 -0
- /package/build/{stubs/make → make}/validator/main.stub +0 -0
- /package/build/{stubs/make → make}/validator/resource.stub +0 -0
- /package/build/{stubs/make → make}/view/main.stub +0 -0
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @adonisjs/core
|
|
3
|
-
*
|
|
4
|
-
* (c) AdonisJS
|
|
5
|
-
*
|
|
6
|
-
* For the full copyright and license information, please view the LICENSE
|
|
7
|
-
* file that was distributed with this source code.
|
|
8
|
-
*/
|
|
9
|
-
import stringHelpers from "../helpers/string.js";
|
|
10
|
-
import { outputTransformerDataObjects } from "../utils.js";
|
|
11
|
-
/**
|
|
12
|
-
* Configures the IndexGenerator to create barrel files for "controllers", "events",
|
|
13
|
-
* and "listeners". This function is used as an assembler hook to automatically generate
|
|
14
|
-
* index files that export all modules from specified directories.
|
|
15
|
-
*
|
|
16
|
-
* @param {IndexEntitiesConfig} entities - Configuration object for entities indexing
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* // Basic usage with default configuration
|
|
20
|
-
* indexEntities({})
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* // Custom configuration for specific entities
|
|
24
|
-
* indexEntities({
|
|
25
|
-
* events: {
|
|
26
|
-
* enabled: true,
|
|
27
|
-
* source: 'app/custom-events',
|
|
28
|
-
* importAlias: '#custom-events'
|
|
29
|
-
* },
|
|
30
|
-
* controllers: {
|
|
31
|
-
* enabled: false
|
|
32
|
-
* }
|
|
33
|
-
* })
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* // Using custom glob patterns
|
|
37
|
-
* indexEntities({
|
|
38
|
-
* listeners: {
|
|
39
|
-
* source: 'app/handlers',
|
|
40
|
-
* glob: '**\/*_handler.ts'
|
|
41
|
-
* }
|
|
42
|
-
* })
|
|
43
|
-
*/
|
|
44
|
-
export function indexEntities(entities = {}) {
|
|
45
|
-
const events = Object.assign({ enabled: true, source: 'app/events', importAlias: '#events' }, entities.events);
|
|
46
|
-
const listeners = Object.assign({ enabled: true, source: 'app/listeners', importAlias: '#listeners' }, entities.listeners);
|
|
47
|
-
const controllers = Object.assign({ enabled: true, source: 'app/controllers', importAlias: '#controllers' }, entities.controllers);
|
|
48
|
-
const transformers = Object.assign({ enabled: false, source: 'app/transformers', importAlias: '#transformers' }, entities.transformers);
|
|
49
|
-
return {
|
|
50
|
-
run(_, indexGenerator) {
|
|
51
|
-
if (events.enabled) {
|
|
52
|
-
indexGenerator.add('events', {
|
|
53
|
-
source: events.source,
|
|
54
|
-
disableLazyImports: true,
|
|
55
|
-
glob: events.glob,
|
|
56
|
-
as: 'barrelFile',
|
|
57
|
-
exportName: 'events',
|
|
58
|
-
importAlias: events.importAlias,
|
|
59
|
-
output: '.adonisjs/server/events.ts',
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
if (listeners.enabled) {
|
|
63
|
-
indexGenerator.add('listeners', {
|
|
64
|
-
source: listeners.source,
|
|
65
|
-
glob: listeners.glob,
|
|
66
|
-
as: 'barrelFile',
|
|
67
|
-
exportName: 'listeners',
|
|
68
|
-
importAlias: listeners.importAlias,
|
|
69
|
-
output: '.adonisjs/server/listeners.ts',
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
if (controllers.enabled) {
|
|
73
|
-
indexGenerator.add('controllers', {
|
|
74
|
-
source: controllers.source,
|
|
75
|
-
glob: controllers.glob,
|
|
76
|
-
as: 'barrelFile',
|
|
77
|
-
exportName: 'controllers',
|
|
78
|
-
importAlias: controllers.importAlias,
|
|
79
|
-
removeSuffix: 'controller',
|
|
80
|
-
output: '.adonisjs/server/controllers.ts',
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
if (transformers.enabled) {
|
|
84
|
-
indexGenerator.add('transformers', {
|
|
85
|
-
source: transformers.source,
|
|
86
|
-
glob: transformers.glob,
|
|
87
|
-
as(vfs, buffer, __, helpers) {
|
|
88
|
-
const transformersList = vfs.asTree({
|
|
89
|
-
transformKey(key) {
|
|
90
|
-
const segments = key.split('/');
|
|
91
|
-
const baseName = segments.pop();
|
|
92
|
-
return [
|
|
93
|
-
...segments.map((segment) => stringHelpers.pascalCase(segment)),
|
|
94
|
-
stringHelpers.create(baseName).removeSuffix('transformer').pascalCase(),
|
|
95
|
-
].join('/');
|
|
96
|
-
},
|
|
97
|
-
transformValue: helpers.toImportPath,
|
|
98
|
-
});
|
|
99
|
-
outputTransformerDataObjects(transformersList, buffer);
|
|
100
|
-
},
|
|
101
|
-
importAlias: transformers.importAlias,
|
|
102
|
-
output: '.adonisjs/client/data.d.ts',
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
};
|
|
107
|
-
}
|
|
@@ -1,381 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @adonisjs/core
|
|
3
|
-
*
|
|
4
|
-
* (c) AdonisJS
|
|
5
|
-
*
|
|
6
|
-
* For the full copyright and license information, please view the LICENSE
|
|
7
|
-
* file that was distributed with this source code.
|
|
8
|
-
*/
|
|
9
|
-
import stringWidth from 'string-width';
|
|
10
|
-
import { cliHelpers } from "../../modules/ace/main.js";
|
|
11
|
-
import { middlewareInfo, routeInfo } from '@adonisjs/http-server/helpers';
|
|
12
|
-
/**
|
|
13
|
-
* Routes list formatter is used to format the routes to JSON or an ANSI string
|
|
14
|
-
* with pretty output.
|
|
15
|
-
*
|
|
16
|
-
* The decisions of colors, padding, alignment are all handled by the lists formatter
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* const formatter = new RoutesListFormatter(router, ui, {
|
|
20
|
-
* displayHeadRoutes: false,
|
|
21
|
-
* maxPrettyPrintWidth: 120
|
|
22
|
-
* }, {
|
|
23
|
-
* match: 'api',
|
|
24
|
-
* middleware: ['auth']
|
|
25
|
-
* })
|
|
26
|
-
*
|
|
27
|
-
* const ansiOutput = await formatter.formatAsAnsiList()
|
|
28
|
-
*/
|
|
29
|
-
export class RoutesListFormatter {
|
|
30
|
-
/**
|
|
31
|
-
* Router instance containing all registered routes
|
|
32
|
-
*/
|
|
33
|
-
#router;
|
|
34
|
-
/**
|
|
35
|
-
* Colors utility for ANSI formatting
|
|
36
|
-
*/
|
|
37
|
-
#colors;
|
|
38
|
-
/**
|
|
39
|
-
* Table utility for creating formatted tables
|
|
40
|
-
*/
|
|
41
|
-
#table;
|
|
42
|
-
/**
|
|
43
|
-
* Options for printing routes
|
|
44
|
-
*/
|
|
45
|
-
#options;
|
|
46
|
-
/**
|
|
47
|
-
* Filters to apply when finding routes
|
|
48
|
-
*/
|
|
49
|
-
#filters;
|
|
50
|
-
/**
|
|
51
|
-
* Creates a new instance of the routes list formatter
|
|
52
|
-
*
|
|
53
|
-
* @param router - Router instance containing routes to format
|
|
54
|
-
* @param ui - UI primitives for colors and table formatting
|
|
55
|
-
* @param options - Display options for route formatting
|
|
56
|
-
* @param filters - Filters to apply when displaying routes
|
|
57
|
-
*/
|
|
58
|
-
constructor(router, ui, options, filters) {
|
|
59
|
-
this.#router = router;
|
|
60
|
-
this.#colors = ui.colors;
|
|
61
|
-
this.#table = ui.table;
|
|
62
|
-
this.#filters = filters;
|
|
63
|
-
this.#options = options;
|
|
64
|
-
this.#router.commit();
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Test if a route clears the applied filters
|
|
68
|
-
*/
|
|
69
|
-
#isAllowedByFilters(route) {
|
|
70
|
-
let allowRoute = true;
|
|
71
|
-
/**
|
|
72
|
-
* Check if the route is allowed by applying the middleware
|
|
73
|
-
* filter
|
|
74
|
-
*/
|
|
75
|
-
if (this.#filters.middleware) {
|
|
76
|
-
allowRoute = this.#filters.middleware.every((name) => {
|
|
77
|
-
if (name === '*') {
|
|
78
|
-
return route.middleware.length > 0;
|
|
79
|
-
}
|
|
80
|
-
return route.middleware.find((middleware) => middleware.name === name);
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Check if the route has any or the ignored middleware. If yes, do not
|
|
85
|
-
* display the route
|
|
86
|
-
*/
|
|
87
|
-
if (allowRoute && this.#filters.ignoreMiddleware) {
|
|
88
|
-
allowRoute = this.#filters.ignoreMiddleware.every((name) => {
|
|
89
|
-
if (name === '*') {
|
|
90
|
-
return route.middleware.length === 0;
|
|
91
|
-
}
|
|
92
|
-
return !route.middleware.find((middleware) => middleware.name === name);
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* No more filters to be applied
|
|
97
|
-
*/
|
|
98
|
-
if (!this.#filters.match) {
|
|
99
|
-
return allowRoute;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Check if the route name has the match keyword
|
|
103
|
-
*/
|
|
104
|
-
if (route.name.includes(this.#filters.match)) {
|
|
105
|
-
return true;
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Check if the route pattern has the match keyword
|
|
109
|
-
*/
|
|
110
|
-
if (route.pattern.includes(this.#filters.match)) {
|
|
111
|
-
return true;
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Check if the route handler has the match keyword
|
|
115
|
-
*/
|
|
116
|
-
if (route.handler.type === 'controller'
|
|
117
|
-
? route.handler.moduleNameOrPath.includes(this.#filters.match)
|
|
118
|
-
: route.handler.name.includes(this.#filters.match)) {
|
|
119
|
-
return true;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Disallow route
|
|
123
|
-
*/
|
|
124
|
-
return false;
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Serializes routes JSON to an object that can be used for pretty printing
|
|
128
|
-
*/
|
|
129
|
-
async #serializeRoute(route) {
|
|
130
|
-
let methods = route.methods;
|
|
131
|
-
if (!this.#options.displayHeadRoutes) {
|
|
132
|
-
methods = methods.filter((method) => method !== 'HEAD');
|
|
133
|
-
}
|
|
134
|
-
const middlewareList = await Promise.all([...route.middleware.all()].map((middleware) => {
|
|
135
|
-
return middlewareInfo(middleware);
|
|
136
|
-
}));
|
|
137
|
-
return {
|
|
138
|
-
name: route.name || '',
|
|
139
|
-
pattern: route.pattern,
|
|
140
|
-
methods: methods,
|
|
141
|
-
handler: await routeInfo(route),
|
|
142
|
-
middleware: middlewareList.filter((info) => info.type !== 'global'),
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Formats the route method for the ansi list and table
|
|
147
|
-
*/
|
|
148
|
-
#formatRouteMethod(method) {
|
|
149
|
-
return this.#colors.dim(method);
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Formats route pattern for the ansi list and table
|
|
153
|
-
*/
|
|
154
|
-
#formatRoutePattern(route) {
|
|
155
|
-
const pattern = this.#router
|
|
156
|
-
.parsePattern(route.pattern)
|
|
157
|
-
.map((token) => {
|
|
158
|
-
if (token.type === 1) {
|
|
159
|
-
return this.#colors.yellow(`:${token.val}`);
|
|
160
|
-
}
|
|
161
|
-
if (token.type === 3) {
|
|
162
|
-
return this.#colors.yellow(`:${token.val}?`);
|
|
163
|
-
}
|
|
164
|
-
if (token.type === 2) {
|
|
165
|
-
return this.#colors.red(token.val);
|
|
166
|
-
}
|
|
167
|
-
return token.val;
|
|
168
|
-
})
|
|
169
|
-
.join('/');
|
|
170
|
-
return `${pattern === '/' ? pattern : `/${pattern}`}${route.name ? ` ${this.#colors.dim(`(${route.name})`)}` : ''} `;
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Formats controller name for the ansi list and table
|
|
174
|
-
*/
|
|
175
|
-
#formatControllerName(route) {
|
|
176
|
-
return route.handler.type === 'controller'
|
|
177
|
-
? ` ${this.#colors.cyan(route.handler.moduleNameOrPath)}.`
|
|
178
|
-
: '';
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* Formats action name for the ansi list and table
|
|
182
|
-
*/
|
|
183
|
-
#formatAction(route) {
|
|
184
|
-
if (route.handler.type === 'controller') {
|
|
185
|
-
return `${this.#colors.cyan(route.handler.method)}`;
|
|
186
|
-
}
|
|
187
|
-
const functionName = ` ${this.#colors.cyan(route.handler.name)}`;
|
|
188
|
-
if (route.handler.args) {
|
|
189
|
-
return ` ${functionName}${this.#colors.dim(`(${route.handler.args})`)}`;
|
|
190
|
-
}
|
|
191
|
-
return functionName;
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* Formats route middleware for the ansi list and table
|
|
195
|
-
*/
|
|
196
|
-
#formatMiddleware(route, mode = 'normal') {
|
|
197
|
-
if (mode === 'compact' && route.middleware.length > 3) {
|
|
198
|
-
const firstMiddleware = route.middleware[0].name;
|
|
199
|
-
const secondMiddleware = route.middleware[1].name;
|
|
200
|
-
const diff = route.middleware.length - 2;
|
|
201
|
-
return this.#colors.dim(`${firstMiddleware}, ${secondMiddleware}, and ${diff} more`);
|
|
202
|
-
}
|
|
203
|
-
return this.#colors.dim(`${route.middleware
|
|
204
|
-
.map((one) => one.name)
|
|
205
|
-
.filter((one) => one)
|
|
206
|
-
.join(', ')}`);
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* Formatting the domain headling to be in green color with
|
|
210
|
-
* dots around it
|
|
211
|
-
*/
|
|
212
|
-
#formatDomainHeadline(domain) {
|
|
213
|
-
if (domain !== 'root') {
|
|
214
|
-
return cliHelpers.justify([`${this.#colors.dim('..')} ${this.#colors.green(domain)} `], {
|
|
215
|
-
maxWidth: this.#options.maxPrettyPrintWidth || cliHelpers.TERMINAL_SIZE,
|
|
216
|
-
paddingChar: this.#colors.dim('.'),
|
|
217
|
-
})[0];
|
|
218
|
-
}
|
|
219
|
-
return '';
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
|
-
* Justify the ansi list
|
|
223
|
-
*/
|
|
224
|
-
#justifyListTables(tables) {
|
|
225
|
-
return tables.map((table) => {
|
|
226
|
-
/**
|
|
227
|
-
* Formatting methods
|
|
228
|
-
*/
|
|
229
|
-
const methods = table.rows.map((columns) => columns[0]);
|
|
230
|
-
const largestMethodsLength = Math.max(...methods.map((method) => stringWidth(method)));
|
|
231
|
-
const formattedMethods = cliHelpers.justify(methods, {
|
|
232
|
-
maxWidth: largestMethodsLength,
|
|
233
|
-
});
|
|
234
|
-
/**
|
|
235
|
-
* Formatting patterns
|
|
236
|
-
*/
|
|
237
|
-
const patterns = table.rows.map((columns) => columns[1]);
|
|
238
|
-
const largestPatternLength = Math.max(...patterns.map((pattern) => stringWidth(pattern)));
|
|
239
|
-
const formattedPatterns = cliHelpers.justify(patterns, {
|
|
240
|
-
maxWidth: largestPatternLength,
|
|
241
|
-
paddingChar: this.#colors.dim('.'),
|
|
242
|
-
});
|
|
243
|
-
/**
|
|
244
|
-
* Formatting middleware to be right aligned
|
|
245
|
-
*/
|
|
246
|
-
const middleware = table.rows.map((columns) => columns[3]);
|
|
247
|
-
const largestMiddlewareLength = Math.max(...middleware.map((one) => stringWidth(one)));
|
|
248
|
-
const formattedMiddleware = cliHelpers.justify(middleware, {
|
|
249
|
-
maxWidth: largestMiddlewareLength,
|
|
250
|
-
align: 'right',
|
|
251
|
-
paddingChar: ' ',
|
|
252
|
-
});
|
|
253
|
-
/**
|
|
254
|
-
* Formatting controllers to be right aligned and take all the remaining
|
|
255
|
-
* space after printing route method, pattern and middleware.
|
|
256
|
-
*/
|
|
257
|
-
const controllers = table.rows.map((columns) => columns[2]);
|
|
258
|
-
const largestControllerLength = (this.#options.maxPrettyPrintWidth || cliHelpers.TERMINAL_SIZE) -
|
|
259
|
-
(largestPatternLength + largestMethodsLength + largestMiddlewareLength);
|
|
260
|
-
const formattedControllers = cliHelpers.truncate(cliHelpers.justify(controllers, {
|
|
261
|
-
maxWidth: largestControllerLength,
|
|
262
|
-
align: 'right',
|
|
263
|
-
paddingChar: this.#colors.dim('.'),
|
|
264
|
-
}), {
|
|
265
|
-
maxWidth: largestControllerLength,
|
|
266
|
-
});
|
|
267
|
-
return {
|
|
268
|
-
heading: table.heading,
|
|
269
|
-
rows: formattedMethods.reduce((result, method, index) => {
|
|
270
|
-
result.push(`${method}${formattedPatterns[index]}${formattedControllers[index]}${formattedMiddleware[index]}`);
|
|
271
|
-
return result;
|
|
272
|
-
}, []),
|
|
273
|
-
};
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
/**
|
|
277
|
-
* Formats routes as an array of objects. Routes are grouped by
|
|
278
|
-
* domain.
|
|
279
|
-
*/
|
|
280
|
-
async formatAsJSON() {
|
|
281
|
-
const routes = this.#router.toJSON();
|
|
282
|
-
const domains = Object.keys(routes);
|
|
283
|
-
let routesJSON = [];
|
|
284
|
-
for (let domain of domains) {
|
|
285
|
-
const domainRoutes = await Promise.all(routes[domain].map((route) => this.#serializeRoute(route)));
|
|
286
|
-
routesJSON.push({
|
|
287
|
-
domain,
|
|
288
|
-
routes: domainRoutes.filter((route) => this.#isAllowedByFilters(route)),
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
return routesJSON;
|
|
292
|
-
}
|
|
293
|
-
/**
|
|
294
|
-
* Format routes to ansi list of tables. Each domain has its own table
|
|
295
|
-
* with heading and rows. Each row has colums with colors and spacing
|
|
296
|
-
* around them.
|
|
297
|
-
*/
|
|
298
|
-
async formatAsAnsiList() {
|
|
299
|
-
const routes = this.#router.toJSON();
|
|
300
|
-
const domains = Object.keys(routes);
|
|
301
|
-
const tables = [];
|
|
302
|
-
for (let domain of domains) {
|
|
303
|
-
const list = {
|
|
304
|
-
heading: this.#formatDomainHeadline(domain),
|
|
305
|
-
rows: [
|
|
306
|
-
[
|
|
307
|
-
this.#colors.dim('METHOD'),
|
|
308
|
-
` ${this.#colors.dim('ROUTE')} `,
|
|
309
|
-
` ${this.#colors.dim('HANDLER')}`,
|
|
310
|
-
` ${this.#colors.dim('MIDDLEWARE')}`,
|
|
311
|
-
],
|
|
312
|
-
],
|
|
313
|
-
};
|
|
314
|
-
/**
|
|
315
|
-
* Computing table rows. Each route+method will have its
|
|
316
|
-
* own row
|
|
317
|
-
*/
|
|
318
|
-
for (let route of routes[domain]) {
|
|
319
|
-
const serializedRoute = await this.#serializeRoute(route);
|
|
320
|
-
if (this.#isAllowedByFilters(serializedRoute)) {
|
|
321
|
-
serializedRoute.methods.forEach((method) => {
|
|
322
|
-
list.rows.push([
|
|
323
|
-
this.#formatRouteMethod(method),
|
|
324
|
-
` ${this.#formatRoutePattern(serializedRoute)}`,
|
|
325
|
-
`${this.#formatControllerName(serializedRoute)}${this.#formatAction(serializedRoute)}`,
|
|
326
|
-
` ${this.#formatMiddleware(serializedRoute, 'compact')}`,
|
|
327
|
-
]);
|
|
328
|
-
});
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
tables.push(list);
|
|
332
|
-
}
|
|
333
|
-
return this.#justifyListTables(tables);
|
|
334
|
-
}
|
|
335
|
-
/**
|
|
336
|
-
* Format routes to ansi tables. Each domain has its own table
|
|
337
|
-
* with heading and rows. Each row has colums with colors and spacing
|
|
338
|
-
* around them.
|
|
339
|
-
*/
|
|
340
|
-
async formatAsAnsiTable() {
|
|
341
|
-
const routes = this.#router.toJSON();
|
|
342
|
-
const domains = Object.keys(routes);
|
|
343
|
-
const tables = [];
|
|
344
|
-
for (let domain of domains) {
|
|
345
|
-
const list = {
|
|
346
|
-
heading: this.#formatDomainHeadline(domain),
|
|
347
|
-
table: this.#table()
|
|
348
|
-
.fullWidth()
|
|
349
|
-
.fluidColumnIndex(2)
|
|
350
|
-
.head([
|
|
351
|
-
this.#colors.dim('METHOD'),
|
|
352
|
-
this.#colors.dim('ROUTE'),
|
|
353
|
-
{ hAlign: 'right', content: this.#colors.dim('HANDLER') },
|
|
354
|
-
{ content: this.#colors.dim('MIDDLEWARE'), hAlign: 'right' },
|
|
355
|
-
]),
|
|
356
|
-
};
|
|
357
|
-
/**
|
|
358
|
-
* Computing table rows. Each route+method will have its
|
|
359
|
-
* own row
|
|
360
|
-
*/
|
|
361
|
-
for (let route of routes[domain]) {
|
|
362
|
-
const serializedRoute = await this.#serializeRoute(route);
|
|
363
|
-
if (this.#isAllowedByFilters(serializedRoute)) {
|
|
364
|
-
serializedRoute.methods.forEach((method) => {
|
|
365
|
-
list.table.row([
|
|
366
|
-
this.#formatRouteMethod(method),
|
|
367
|
-
this.#formatRoutePattern(serializedRoute),
|
|
368
|
-
{
|
|
369
|
-
content: `${this.#formatControllerName(serializedRoute)}${this.#formatAction(serializedRoute)}`,
|
|
370
|
-
hAlign: 'right',
|
|
371
|
-
},
|
|
372
|
-
{ content: this.#formatMiddleware(serializedRoute), hAlign: 'right' },
|
|
373
|
-
]);
|
|
374
|
-
});
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
tables.push(list);
|
|
378
|
-
}
|
|
379
|
-
return tables;
|
|
380
|
-
}
|
|
381
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @adonisjs/core
|
|
3
|
-
*
|
|
4
|
-
* (c) AdonisJS
|
|
5
|
-
*
|
|
6
|
-
* For the full copyright and license information, please view the LICENSE
|
|
7
|
-
* file that was distributed with this source code.
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Helper utilities to create and resolve config providers. Config providers
|
|
11
|
-
* are used to defer configuration resolution until the application is booted,
|
|
12
|
-
* allowing access to environment variables and other application services.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* // Creating a database config provider
|
|
16
|
-
* const databaseConfig = configProvider.create(async (app) => ({
|
|
17
|
-
* connection: app.env.get('DB_CONNECTION', 'sqlite'),
|
|
18
|
-
* host: app.env.get('DB_HOST', 'localhost'),
|
|
19
|
-
* port: app.env.get('DB_PORT', 5432)
|
|
20
|
-
* }))
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* // Resolving a config provider
|
|
24
|
-
* const config = await configProvider.resolve(app, databaseConfig)
|
|
25
|
-
* if (config) {
|
|
26
|
-
* console.log(`Database connection: ${config.connection}`)
|
|
27
|
-
* }
|
|
28
|
-
*/
|
|
29
|
-
export const configProvider = {
|
|
30
|
-
/**
|
|
31
|
-
* Creates a new config provider that will resolve configuration
|
|
32
|
-
* when the application is booted.
|
|
33
|
-
*
|
|
34
|
-
* @param resolver - Function that receives the application service and returns the configuration
|
|
35
|
-
*
|
|
36
|
-
* @example
|
|
37
|
-
* const mailConfig = configProvider.create(async (app) => ({
|
|
38
|
-
* driver: app.env.get('MAIL_DRIVER', 'smtp'),
|
|
39
|
-
* host: app.env.get('SMTP_HOST'),
|
|
40
|
-
* port: app.env.get('SMTP_PORT', 587)
|
|
41
|
-
* }))
|
|
42
|
-
*/
|
|
43
|
-
create(resolver) {
|
|
44
|
-
return {
|
|
45
|
-
type: 'provider',
|
|
46
|
-
resolver,
|
|
47
|
-
};
|
|
48
|
-
},
|
|
49
|
-
/**
|
|
50
|
-
* Resolves a config provider if the provided value is a valid config provider,
|
|
51
|
-
* otherwise returns null.
|
|
52
|
-
*
|
|
53
|
-
* @param app - The application service instance
|
|
54
|
-
* @param provider - The potential config provider to resolve
|
|
55
|
-
*
|
|
56
|
-
* @example
|
|
57
|
-
* const resolved = await configProvider.resolve(app, someProvider)
|
|
58
|
-
* if (resolved) {
|
|
59
|
-
* // Use the resolved configuration
|
|
60
|
-
* console.log('Config resolved:', resolved)
|
|
61
|
-
* } else {
|
|
62
|
-
* console.log('Not a valid config provider')
|
|
63
|
-
* }
|
|
64
|
-
*/
|
|
65
|
-
async resolve(app, provider) {
|
|
66
|
-
if (provider && typeof provider === 'object' && 'type' in provider) {
|
|
67
|
-
return provider.resolver(app);
|
|
68
|
-
}
|
|
69
|
-
return null;
|
|
70
|
-
},
|
|
71
|
-
};
|
package/build/src/debug.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @adonisjs/core
|
|
3
|
-
*
|
|
4
|
-
* (c) AdonisJS
|
|
5
|
-
*
|
|
6
|
-
* For the full copyright and license information, please view the LICENSE
|
|
7
|
-
* file that was distributed with this source code.
|
|
8
|
-
*/
|
|
9
|
-
import { debuglog } from 'node:util';
|
|
10
|
-
/**
|
|
11
|
-
* Debug utility for AdonisJS core. This uses Node.js built-in debuglog
|
|
12
|
-
* utility to provide debugging information when the NODE_DEBUG environment
|
|
13
|
-
* variable includes 'adonisjs:core'.
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* // Enable debugging by setting environment variable
|
|
17
|
-
* // NODE_DEBUG=adonisjs:core node app.js
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* // Usage in code
|
|
21
|
-
* import debug from '@adonisjs/core/debug'
|
|
22
|
-
* debug('Application started')
|
|
23
|
-
* debug('Processing request: %s', req.url)
|
|
24
|
-
*/
|
|
25
|
-
export default debuglog('adonisjs:core');
|
package/build/src/ignitor/ace.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @adonisjs/core
|
|
3
|
-
*
|
|
4
|
-
* (c) AdonisJS
|
|
5
|
-
*
|
|
6
|
-
* For the full copyright and license information, please view the LICENSE
|
|
7
|
-
* file that was distributed with this source code.
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* The Ace process is used to start the application in the
|
|
11
|
-
* console environment. It manages the Ace kernel lifecycle
|
|
12
|
-
* and command execution.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* const ignitor = new Ignitor()
|
|
16
|
-
* const aceProcess = new AceProcess(ignitor)
|
|
17
|
-
*
|
|
18
|
-
* await aceProcess
|
|
19
|
-
* .configure((app) => {
|
|
20
|
-
* // Configure ace kernel
|
|
21
|
-
* })
|
|
22
|
-
* .handle(['make:controller', 'UserController'])
|
|
23
|
-
*/
|
|
24
|
-
export class AceProcess {
|
|
25
|
-
/**
|
|
26
|
-
* Ignitor reference
|
|
27
|
-
*/
|
|
28
|
-
#ignitor;
|
|
29
|
-
/**
|
|
30
|
-
* The callback that configures the ace instance before the
|
|
31
|
-
* handle method is called
|
|
32
|
-
*/
|
|
33
|
-
#configureCallback = () => { };
|
|
34
|
-
/**
|
|
35
|
-
* Creates a new Ace process instance
|
|
36
|
-
*
|
|
37
|
-
* @param ignitor - The ignitor instance used to create and manage the app
|
|
38
|
-
*/
|
|
39
|
-
constructor(ignitor) {
|
|
40
|
-
this.#ignitor = ignitor;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Register a callback that can be used to configure the ace
|
|
44
|
-
* kernel before the handle method is called
|
|
45
|
-
*
|
|
46
|
-
* @param callback - Configuration callback function
|
|
47
|
-
*/
|
|
48
|
-
configure(callback) {
|
|
49
|
-
this.#configureCallback = callback;
|
|
50
|
-
return this;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Handles the command line arguments and executes
|
|
54
|
-
* the matching ace commands
|
|
55
|
-
*
|
|
56
|
-
* @param argv - Command line arguments array
|
|
57
|
-
*/
|
|
58
|
-
async handle(argv) {
|
|
59
|
-
const app = this.#ignitor.createApp('console');
|
|
60
|
-
await app.init();
|
|
61
|
-
const { createAceKernel } = await import('../../modules/ace/create_kernel.js');
|
|
62
|
-
const commandNameIndex = argv.findIndex((value) => !value.startsWith('-'));
|
|
63
|
-
const commandName = argv[commandNameIndex];
|
|
64
|
-
const kernel = createAceKernel(app, commandName);
|
|
65
|
-
app.container.bindValue('ace', kernel);
|
|
66
|
-
/**
|
|
67
|
-
* Hook into kernel and start the app when the
|
|
68
|
-
* command needs the app.
|
|
69
|
-
*
|
|
70
|
-
* Since multiple commands can be executed in a single process,
|
|
71
|
-
* we add a check to only start the app only once.
|
|
72
|
-
*/
|
|
73
|
-
kernel.loading(async (metaData) => {
|
|
74
|
-
if (metaData.options.startApp && !app.isReady) {
|
|
75
|
-
if (metaData.commandName === 'repl') {
|
|
76
|
-
app.setEnvironment('repl');
|
|
77
|
-
}
|
|
78
|
-
await app.boot();
|
|
79
|
-
await app.start(() => { });
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
await this.#configureCallback(app);
|
|
83
|
-
/**
|
|
84
|
-
* Handle command line args
|
|
85
|
-
*/
|
|
86
|
-
await kernel.handle(argv);
|
|
87
|
-
/**
|
|
88
|
-
* Terminate the app when the command does not want to
|
|
89
|
-
* hold a long running process
|
|
90
|
-
*/
|
|
91
|
-
const mainCommand = kernel.getMainCommand();
|
|
92
|
-
if (!mainCommand || !mainCommand.staysAlive) {
|
|
93
|
-
process.exitCode = kernel.exitCode;
|
|
94
|
-
await app.terminate();
|
|
95
|
-
}
|
|
96
|
-
else {
|
|
97
|
-
app.terminating(() => {
|
|
98
|
-
process.exitCode = mainCommand.exitCode;
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|