@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,146 +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 { createServer, } from 'node:http';
|
|
10
|
-
import debug from "../debug.js";
|
|
11
|
-
/**
|
|
12
|
-
* The HTTP server process is used to start the application in the
|
|
13
|
-
* web environment. It creates and manages the Node.js HTTP server
|
|
14
|
-
* instance, handling lifecycle events and monitoring.
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* const ignitor = new Ignitor()
|
|
18
|
-
* const httpProcess = new HttpServerProcess(ignitor)
|
|
19
|
-
* await httpProcess.start()
|
|
20
|
-
*/
|
|
21
|
-
export class HttpServerProcess {
|
|
22
|
-
/**
|
|
23
|
-
* Ignitor reference
|
|
24
|
-
*/
|
|
25
|
-
#ignitor;
|
|
26
|
-
/**
|
|
27
|
-
* Creates a new HTTP server process instance
|
|
28
|
-
*
|
|
29
|
-
* @param ignitor - The ignitor instance used to create and manage the app
|
|
30
|
-
*/
|
|
31
|
-
constructor(ignitor) {
|
|
32
|
-
this.#ignitor = ignitor;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Calling this method closes the underlying HTTP server
|
|
36
|
-
*/
|
|
37
|
-
#close(nodeHttpServer) {
|
|
38
|
-
return new Promise((resolve) => {
|
|
39
|
-
debug('closing http server process');
|
|
40
|
-
nodeHttpServer.close(() => resolve());
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Monitors the app and the server to close the HTTP server when
|
|
45
|
-
* either one of them goes down
|
|
46
|
-
*/
|
|
47
|
-
#monitorAppAndServer(nodeHttpServer, app, logger) {
|
|
48
|
-
/**
|
|
49
|
-
* Close the HTTP server when the application begins to
|
|
50
|
-
* terminate
|
|
51
|
-
*/
|
|
52
|
-
app.terminating(async () => {
|
|
53
|
-
debug('terminating signal received');
|
|
54
|
-
await this.#close(nodeHttpServer);
|
|
55
|
-
});
|
|
56
|
-
/**
|
|
57
|
-
* Terminate the app when the HTTP server crashes
|
|
58
|
-
*/
|
|
59
|
-
nodeHttpServer.once('error', (error) => {
|
|
60
|
-
debug('http server crashed with error "%O"', error);
|
|
61
|
-
logger.fatal({ err: error }, error.message);
|
|
62
|
-
process.exitCode = 1;
|
|
63
|
-
app.terminate();
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Starts the http server a given host and port
|
|
68
|
-
*/
|
|
69
|
-
#listen(nodeHttpServer) {
|
|
70
|
-
return new Promise((resolve, reject) => {
|
|
71
|
-
const host = process.env.HOST || '0.0.0.0';
|
|
72
|
-
const port = Number(process.env.PORT || '3333');
|
|
73
|
-
nodeHttpServer.listen(port, host);
|
|
74
|
-
nodeHttpServer.once('listening', () => {
|
|
75
|
-
debug('listening to http server, host :%s, port: %s', host, port);
|
|
76
|
-
resolve({ port, host });
|
|
77
|
-
});
|
|
78
|
-
nodeHttpServer.once('error', (error) => {
|
|
79
|
-
reject(error);
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Notifies the app and the parent process that the
|
|
85
|
-
* HTTP server is ready
|
|
86
|
-
*/
|
|
87
|
-
#notifyServerHasStarted(app, logger, emitter, payload) {
|
|
88
|
-
/**
|
|
89
|
-
* Notify parent process
|
|
90
|
-
*/
|
|
91
|
-
app.notify({ isAdonisJS: true, environment: 'web', ...payload });
|
|
92
|
-
/**
|
|
93
|
-
* Visual notification
|
|
94
|
-
*/
|
|
95
|
-
logger.info('started HTTP server on %s:%s', payload.host, payload.port);
|
|
96
|
-
/**
|
|
97
|
-
* Notify app
|
|
98
|
-
*/
|
|
99
|
-
emitter.emit('http:server_ready', payload);
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Start the HTTP server by wiring up the application
|
|
103
|
-
*
|
|
104
|
-
* @param serverCallback - Optional callback to create custom HTTP server instance
|
|
105
|
-
*/
|
|
106
|
-
async start(serverCallback) {
|
|
107
|
-
const startTime = process.hrtime();
|
|
108
|
-
/**
|
|
109
|
-
* Method to create the HTTP server
|
|
110
|
-
*/
|
|
111
|
-
const createHTTPServer = serverCallback || createServer;
|
|
112
|
-
const app = this.#ignitor.createApp('web');
|
|
113
|
-
await app.init();
|
|
114
|
-
await app.boot();
|
|
115
|
-
await app.start(async () => {
|
|
116
|
-
/**
|
|
117
|
-
* Resolve and boot the AdonisJS HTTP server
|
|
118
|
-
*/
|
|
119
|
-
const server = await app.container.make('server');
|
|
120
|
-
await server.boot();
|
|
121
|
-
/**
|
|
122
|
-
* Create Node.js HTTP server instance and share it with the
|
|
123
|
-
* AdonisJS HTTP server
|
|
124
|
-
*/
|
|
125
|
-
const httpServer = createHTTPServer(server.handle.bind(server));
|
|
126
|
-
server.setNodeServer(httpServer);
|
|
127
|
-
const logger = await app.container.make('logger');
|
|
128
|
-
const emitter = await app.container.make('emitter');
|
|
129
|
-
/**
|
|
130
|
-
* Start the server by listening on a port of host
|
|
131
|
-
*/
|
|
132
|
-
const payload = await this.#listen(httpServer);
|
|
133
|
-
/**
|
|
134
|
-
* Notify
|
|
135
|
-
*/
|
|
136
|
-
this.#notifyServerHasStarted(app, logger, emitter, {
|
|
137
|
-
...payload,
|
|
138
|
-
duration: process.hrtime(startTime),
|
|
139
|
-
});
|
|
140
|
-
/**
|
|
141
|
-
* Monitor app and the server (after the server is listening)
|
|
142
|
-
*/
|
|
143
|
-
this.#monitorAppAndServer(httpServer, app, logger);
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
}
|
|
@@ -1,124 +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 debug from "../debug.js";
|
|
10
|
-
import { AceProcess } from "./ace.js";
|
|
11
|
-
import { TestRunnerProcess } from "./test.js";
|
|
12
|
-
import { HttpServerProcess } from "./http.js";
|
|
13
|
-
import { setApp } from "../../services/app.js";
|
|
14
|
-
import { Application } from "../../modules/app.js";
|
|
15
|
-
/**
|
|
16
|
-
* Ignitor is used to instantiate an AdonisJS application in different
|
|
17
|
-
* known environments. It serves as the main entry point for creating
|
|
18
|
-
* and managing application processes.
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* const ignitor = new Ignitor(new URL(import.meta.url))
|
|
22
|
-
*
|
|
23
|
-
* // For HTTP server
|
|
24
|
-
* await ignitor.httpServer().start()
|
|
25
|
-
*
|
|
26
|
-
* // For CLI commands
|
|
27
|
-
* await ignitor.ace().handle(process.argv.slice(2))
|
|
28
|
-
*
|
|
29
|
-
* // For tests
|
|
30
|
-
* await ignitor.testRunner().run(() => {})
|
|
31
|
-
*/
|
|
32
|
-
export class Ignitor {
|
|
33
|
-
/**
|
|
34
|
-
* Ignitor options
|
|
35
|
-
*/
|
|
36
|
-
#options;
|
|
37
|
-
/**
|
|
38
|
-
* Application root URL
|
|
39
|
-
*/
|
|
40
|
-
#appRoot;
|
|
41
|
-
/**
|
|
42
|
-
* Reference to the application instance created using
|
|
43
|
-
* the "createApp" method.
|
|
44
|
-
*
|
|
45
|
-
* We store the output of the last call made to "createApp" method
|
|
46
|
-
* and assume that in one process only one entrypoint will
|
|
47
|
-
* call this method.
|
|
48
|
-
*/
|
|
49
|
-
#app;
|
|
50
|
-
/**
|
|
51
|
-
* Reference to the created application
|
|
52
|
-
*/
|
|
53
|
-
#tapCallbacks = new Set();
|
|
54
|
-
/**
|
|
55
|
-
* Creates a new Ignitor instance
|
|
56
|
-
*
|
|
57
|
-
* @param appRoot - The root URL of the application
|
|
58
|
-
* @param options - Configuration options for the ignitor
|
|
59
|
-
*/
|
|
60
|
-
constructor(appRoot, options = {}) {
|
|
61
|
-
this.#appRoot = appRoot;
|
|
62
|
-
this.#options = options;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Runs all the tap callbacks
|
|
66
|
-
*/
|
|
67
|
-
#runTapCallbacks(app) {
|
|
68
|
-
this.#tapCallbacks.forEach((tapCallback) => tapCallback(app));
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Get access to the application instance created
|
|
72
|
-
* by either the http server process or the ace
|
|
73
|
-
* process
|
|
74
|
-
*/
|
|
75
|
-
getApp() {
|
|
76
|
-
return this.#app;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Create an instance of AdonisJS application
|
|
80
|
-
*
|
|
81
|
-
* @param environment - The environment in which to create the app (web, console, test, repl)
|
|
82
|
-
*/
|
|
83
|
-
createApp(environment) {
|
|
84
|
-
debug('creating application instance');
|
|
85
|
-
this.#app = new Application(this.#appRoot, { environment, importer: this.#options.importer });
|
|
86
|
-
setApp(this.#app);
|
|
87
|
-
this.#runTapCallbacks(this.#app);
|
|
88
|
-
return this.#app;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Tap to access the application class instance.
|
|
92
|
-
*
|
|
93
|
-
* @param callback - Callback function to execute when app is created
|
|
94
|
-
*/
|
|
95
|
-
tap(callback) {
|
|
96
|
-
this.#tapCallbacks.add(callback);
|
|
97
|
-
return this;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Get instance of the HTTPServerProcess
|
|
101
|
-
*/
|
|
102
|
-
httpServer() {
|
|
103
|
-
return new HttpServerProcess(this);
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Get an instance of the AceProcess class
|
|
107
|
-
*/
|
|
108
|
-
ace() {
|
|
109
|
-
return new AceProcess(this);
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Get an instance of the TestRunnerProcess class
|
|
113
|
-
*/
|
|
114
|
-
testRunner() {
|
|
115
|
-
return new TestRunnerProcess(this);
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Terminates the app by calling the "app.terminate"
|
|
119
|
-
* method
|
|
120
|
-
*/
|
|
121
|
-
async terminate() {
|
|
122
|
-
await this.#app?.terminate();
|
|
123
|
-
}
|
|
124
|
-
}
|
|
@@ -1,66 +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 Test runner process is used to start the tests runner process.
|
|
11
|
-
* It provides lifecycle hooks for configuring the test environment
|
|
12
|
-
* and running tests within the AdonisJS application context.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* const ignitor = new Ignitor()
|
|
16
|
-
* const testProcess = new TestRunnerProcess(ignitor)
|
|
17
|
-
*
|
|
18
|
-
* await testProcess
|
|
19
|
-
* .configure((app) => {
|
|
20
|
-
* // Configure test environment
|
|
21
|
-
* })
|
|
22
|
-
* .run(async (app) => {
|
|
23
|
-
* // Run your tests
|
|
24
|
-
* })
|
|
25
|
-
*/
|
|
26
|
-
export class TestRunnerProcess {
|
|
27
|
-
/**
|
|
28
|
-
* Ignitor reference
|
|
29
|
-
*/
|
|
30
|
-
#ignitor;
|
|
31
|
-
/**
|
|
32
|
-
* The callback that configures the tests runner. This callback
|
|
33
|
-
* runs at the time of starting the app.
|
|
34
|
-
*/
|
|
35
|
-
#configureCallback = () => { };
|
|
36
|
-
/**
|
|
37
|
-
* Creates a new test runner process instance
|
|
38
|
-
*
|
|
39
|
-
* @param ignitor - The ignitor instance used to create and manage the app
|
|
40
|
-
*/
|
|
41
|
-
constructor(ignitor) {
|
|
42
|
-
this.#ignitor = ignitor;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Register a callback that runs after booting the AdonisJS app
|
|
46
|
-
* and just before the provider's ready hook
|
|
47
|
-
*
|
|
48
|
-
* @param callback - Configuration callback function
|
|
49
|
-
*/
|
|
50
|
-
configure(callback) {
|
|
51
|
-
this.#configureCallback = callback;
|
|
52
|
-
return this;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Runs a callback after starting the app
|
|
56
|
-
*
|
|
57
|
-
* @param callback - Test execution callback function
|
|
58
|
-
*/
|
|
59
|
-
async run(callback) {
|
|
60
|
-
const app = this.#ignitor.createApp('test');
|
|
61
|
-
await app.init();
|
|
62
|
-
await app.boot();
|
|
63
|
-
await app.start(this.#configureCallback);
|
|
64
|
-
await callback(app);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
@@ -1,82 +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 debug from "../debug.js";
|
|
10
|
-
import { createServer, } from 'node:http';
|
|
11
|
-
/**
|
|
12
|
-
* Http server utils are used to start the AdonisJS HTTP server
|
|
13
|
-
* during testing. It provides methods to start and stop the server
|
|
14
|
-
* for integration testing.
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* const testUtils = new TestUtils(app)
|
|
18
|
-
* const httpUtils = testUtils.httpServer()
|
|
19
|
-
*
|
|
20
|
-
* const closeServer = await httpUtils.start()
|
|
21
|
-
* // Make HTTP requests to test endpoints
|
|
22
|
-
* await closeServer() // Clean up
|
|
23
|
-
*/
|
|
24
|
-
export class HttpServerUtils {
|
|
25
|
-
/**
|
|
26
|
-
* Reference to the test utils instance
|
|
27
|
-
*/
|
|
28
|
-
#utils;
|
|
29
|
-
/**
|
|
30
|
-
* Creates a new HttpServerUtils instance
|
|
31
|
-
*
|
|
32
|
-
* @param utils - The test utils instance
|
|
33
|
-
*/
|
|
34
|
-
constructor(utils) {
|
|
35
|
-
this.#utils = utils;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Starts the http server a given host and port
|
|
39
|
-
*
|
|
40
|
-
* @param nodeHttpServer - The Node.js HTTP server instance
|
|
41
|
-
*/
|
|
42
|
-
#listen(nodeHttpServer) {
|
|
43
|
-
return new Promise((resolve, reject) => {
|
|
44
|
-
const host = process.env.HOST || '0.0.0.0';
|
|
45
|
-
const port = Number(process.env.PORT || '3333');
|
|
46
|
-
nodeHttpServer.listen(port, host);
|
|
47
|
-
nodeHttpServer.once('listening', () => {
|
|
48
|
-
debug('listening to utils http server, host :%s, port: %s', host, port);
|
|
49
|
-
resolve({ port, host });
|
|
50
|
-
});
|
|
51
|
-
nodeHttpServer.once('error', (error) => {
|
|
52
|
-
reject(error);
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Testing hook to start the HTTP server to listen for new request.
|
|
58
|
-
* The return value is a function to close the HTTP server.
|
|
59
|
-
*
|
|
60
|
-
* @param serverCallback - Optional callback to create custom HTTP server instance
|
|
61
|
-
*/
|
|
62
|
-
async start(serverCallback) {
|
|
63
|
-
const createHTTPServer = serverCallback || createServer;
|
|
64
|
-
const server = await this.#utils.app.container.make('server');
|
|
65
|
-
await server.boot();
|
|
66
|
-
const httpServer = createHTTPServer(server.handle.bind(server));
|
|
67
|
-
server.setNodeServer(httpServer);
|
|
68
|
-
await this.#listen(httpServer);
|
|
69
|
-
return () => {
|
|
70
|
-
return new Promise((resolve, reject) => {
|
|
71
|
-
httpServer.close((error) => {
|
|
72
|
-
if (error) {
|
|
73
|
-
reject(error);
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
resolve();
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
}
|
package/build/src/utils.js
DELETED
|
@@ -1,104 +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
|
-
* Imports the AdonisJS assembler package optionally. This function attempts
|
|
11
|
-
* to import the assembler and returns undefined if it's not available,
|
|
12
|
-
* making it safe to use in environments where the assembler might not be installed.
|
|
13
|
-
*
|
|
14
|
-
* @param app - The application service instance used for importing the assembler
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* const assembler = await importAssembler(app)
|
|
18
|
-
* if (assembler) {
|
|
19
|
-
* // Use assembler functionality
|
|
20
|
-
* const generator = new assembler.IndexGenerator()
|
|
21
|
-
* }
|
|
22
|
-
*/
|
|
23
|
-
export async function importAssembler(app) {
|
|
24
|
-
try {
|
|
25
|
-
return await app.import('@adonisjs/assembler');
|
|
26
|
-
}
|
|
27
|
-
catch { }
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Imports the TypeScript compiler package optionally. This function attempts
|
|
31
|
-
* to import TypeScript and returns undefined if it's not available,
|
|
32
|
-
* making it safe to use in environments where TypeScript might not be installed.
|
|
33
|
-
*
|
|
34
|
-
* @param app - The application service instance used for importing TypeScript
|
|
35
|
-
*
|
|
36
|
-
* @example
|
|
37
|
-
* const ts = await importTypeScript(app)
|
|
38
|
-
* if (ts) {
|
|
39
|
-
* // Use TypeScript compiler API
|
|
40
|
-
* const program = ts.createProgram(['file.ts'], {})
|
|
41
|
-
* const sourceFile = program.getSourceFile('file.ts')
|
|
42
|
-
* }
|
|
43
|
-
*/
|
|
44
|
-
export async function importTypeScript(app) {
|
|
45
|
-
try {
|
|
46
|
-
return await app.importDefault('typescript');
|
|
47
|
-
}
|
|
48
|
-
catch { }
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Outputs transformer data objects by generating TypeScript type definitions
|
|
52
|
-
* for all transformers in the provided file tree. This function creates
|
|
53
|
-
* InferData types for each transformer and organizes them in namespaces.
|
|
54
|
-
*
|
|
55
|
-
* @param transformersList - A recursive file tree containing transformer file paths
|
|
56
|
-
* @param buffer - The file buffer to write the generated types to
|
|
57
|
-
*
|
|
58
|
-
* @example
|
|
59
|
-
* const transformersList = {
|
|
60
|
-
* User: '#app/transformers/user_transformer',
|
|
61
|
-
* Auth: {
|
|
62
|
-
* Login: '#app/transformers/auth/login_transformer'
|
|
63
|
-
* }
|
|
64
|
-
* }
|
|
65
|
-
* await outputTransformerDataObjects(transformersList, buffer)
|
|
66
|
-
* // Generates:
|
|
67
|
-
* // export namespace Data {
|
|
68
|
-
* // export type User = InferData<UserTransformer>
|
|
69
|
-
* // export namespace Auth {
|
|
70
|
-
* // export type Login = InferData<AuthLoginTransformer>
|
|
71
|
-
* // }
|
|
72
|
-
* // }
|
|
73
|
-
*/
|
|
74
|
-
export async function outputTransformerDataObjects(transformersList, buffer) {
|
|
75
|
-
const importsBuffer = buffer.create();
|
|
76
|
-
importsBuffer.write(`import { InferData } from '@adonisjs/core/types/transformers'`);
|
|
77
|
-
buffer.writeLine(importsBuffer);
|
|
78
|
-
buffer.write('export namespace Data {').indent();
|
|
79
|
-
/**
|
|
80
|
-
* Recursively generates namespace tree structure for transformers.
|
|
81
|
-
* Creates nested namespaces for directory structures and type exports
|
|
82
|
-
* for individual transformer files.
|
|
83
|
-
*
|
|
84
|
-
* @param input - The current level of the file tree to process
|
|
85
|
-
* @param parents - Array of parent namespace names for import naming
|
|
86
|
-
*/
|
|
87
|
-
function generateNamespaceTree(input, parents) {
|
|
88
|
-
Object.keys(input).forEach((key) => {
|
|
89
|
-
const value = input[key];
|
|
90
|
-
if (typeof value === 'string') {
|
|
91
|
-
const importName = `${parents.join()}${key}Transformer`;
|
|
92
|
-
importsBuffer.write(`import ${importName} from '${value}'`);
|
|
93
|
-
buffer.write(`export type ${key} = InferData<${importName}>`);
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
buffer.write(`export namespace ${key} {`).indent();
|
|
97
|
-
generateNamespaceTree(value, [...parents, key]);
|
|
98
|
-
buffer.dedent().write(`}`);
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
generateNamespaceTree(transformersList, []);
|
|
103
|
-
buffer.dedent().write('}');
|
|
104
|
-
}
|
package/build/stubs/main.js
DELETED
|
@@ -1,30 +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
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
10
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
11
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
12
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
13
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
14
|
-
};
|
|
15
|
-
import { join } from 'node:path';
|
|
16
|
-
import { args, BaseCommand, IndexGenerator } from '@adonisjs/ace';
|
|
17
|
-
/**
|
|
18
|
-
* Generates index of commands with a loader. Must be called against
|
|
19
|
-
* the TypeScript compiled output.
|
|
20
|
-
*/
|
|
21
|
-
export default class IndexCommand extends BaseCommand {
|
|
22
|
-
static commandName = 'index';
|
|
23
|
-
static description = 'Create an index of commands along with a lazy loader';
|
|
24
|
-
async run() {
|
|
25
|
-
await new IndexGenerator(join(process.cwd(), this.commandsDir)).generate();
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
__decorate([
|
|
29
|
-
args.string({ description: 'Relative path from cwd to the commands directory' })
|
|
30
|
-
], IndexCommand.prototype, "commandsDir", void 0);
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|