@adonisjs/core 5.4.2 → 5.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -1
- package/README.md +1 -1
- package/build/adonis-typings/ace.d.ts +5 -0
- package/build/adonis-typings/ace.js +8 -0
- package/build/adonis-typings/container.d.ts +4 -0
- package/build/adonis-typings/index.d.ts +2 -0
- package/build/adonis-typings/index.js +2 -0
- package/build/adonis-typings/test-utils.d.ts +23 -0
- package/build/adonis-typings/test-utils.js +8 -0
- package/build/providers/AppProvider.d.ts +10 -0
- package/build/providers/AppProvider.js +24 -0
- package/build/src/Ignitor/Ace/App/index.d.ts +8 -29
- package/build/src/Ignitor/Ace/App/index.js +49 -112
- package/build/src/Ignitor/Ace/GenerateManifest/index.d.ts +1 -1
- package/build/src/Ignitor/Ace/GenerateManifest/index.js +8 -15
- package/build/src/Ignitor/HttpServer/index.d.ts +11 -33
- package/build/src/Ignitor/HttpServer/index.js +20 -84
- package/build/src/Ignitor/Kernel/index.d.ts +56 -0
- package/build/src/Ignitor/Kernel/index.js +123 -0
- package/build/src/Ignitor/SignalsListener/index.js +14 -11
- package/build/src/Ignitor/index.d.ts +6 -0
- package/build/src/Ignitor/index.js +12 -1
- package/build/src/TestUtils/Ace/index.d.ts +0 -0
- package/build/src/TestUtils/Ace/index.js +8 -0
- package/build/src/TestUtils/HttpServer/index.d.ts +27 -0
- package/build/src/TestUtils/HttpServer/index.js +56 -0
- package/build/src/TestUtils/index.d.ts +24 -0
- package/build/src/TestUtils/index.js +43 -0
- package/build/src/utils/index.d.ts +13 -6
- package/build/src/utils/index.js +57 -10
- package/build/templates/contracts/env.txt +3 -3
- package/build/templates/env.txt +5 -5
- package/build/templates/tests/bootstrap.txt +71 -0
- package/package.json +78 -31
- package/build/src/Ignitor/Ace/ErrorHandler/index.d.ts +0 -16
- package/build/src/Ignitor/Ace/ErrorHandler/index.js +0 -47
- package/build/src/Ignitor/HttpServer/ErrorHandler/index.d.ts +0 -16
- package/build/src/Ignitor/HttpServer/ErrorHandler/index.js +0 -44
package/LICENSE.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# The MIT License
|
|
2
2
|
|
|
3
|
-
Copyright
|
|
3
|
+
Copyright 2022 Harminder Virk, contributors
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
6
|
|
package/README.md
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
declare module '@ioc:Adonis/Core/Application' {
|
|
2
|
+
import Ace from '@ioc:Adonis/Core/Ace';
|
|
3
|
+
import { TestUtilsContract } from '@ioc:Adonis/Core/TestUtils';
|
|
2
4
|
import { HealthCheckContract } from '@ioc:Adonis/Core/HealthCheck';
|
|
3
5
|
import { AssetsManagerContract } from '@ioc:Adonis/Core/AssetsManager';
|
|
4
6
|
import HttpExceptionHandler from '@ioc:Adonis/Core/HttpExceptionHandler';
|
|
@@ -6,5 +8,7 @@ declare module '@ioc:Adonis/Core/Application' {
|
|
|
6
8
|
'Adonis/Core/HealthCheck': HealthCheckContract;
|
|
7
9
|
'Adonis/Core/AssetsManager': AssetsManagerContract;
|
|
8
10
|
'Adonis/Core/HttpExceptionHandler': typeof HttpExceptionHandler;
|
|
11
|
+
'Adonis/Core/Ace': typeof Ace;
|
|
12
|
+
'Adonis/Core/TestUtils': TestUtilsContract;
|
|
9
13
|
}
|
|
10
14
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
/// <reference path="ace.d.ts" />
|
|
1
2
|
/// <reference path="cors.d.ts" />
|
|
2
3
|
/// <reference path="health-check.d.ts" />
|
|
3
4
|
/// <reference path="exception-handler.d.ts" />
|
|
4
5
|
/// <reference path="static.d.ts" />
|
|
5
6
|
/// <reference path="assets-manager.d.ts" />
|
|
6
7
|
/// <reference path="container.d.ts" />
|
|
8
|
+
/// <reference path="test-utils.d.ts" />
|
|
7
9
|
/// <reference types="@adonisjs/application/build/adonis-typings" />
|
|
8
10
|
/// <reference types="@adonisjs/events/build/adonis-typings" />
|
|
9
11
|
/// <reference types="@adonisjs/hash/build/adonis-typings" />
|
|
@@ -14,9 +14,11 @@
|
|
|
14
14
|
/// <reference path="../node_modules/@adonisjs/bodyparser/build/adonis-typings/index.d.ts" />
|
|
15
15
|
/// <reference path="../node_modules/@adonisjs/validator/build/adonis-typings/index.d.ts" />
|
|
16
16
|
/// <reference path="../node_modules/@adonisjs/drive/build/adonis-typings/index.d.ts" />
|
|
17
|
+
/// <reference path="./ace.ts" />
|
|
17
18
|
/// <reference path="./cors.ts" />
|
|
18
19
|
/// <reference path="./health-check.ts" />
|
|
19
20
|
/// <reference path="./exception-handler.ts" />
|
|
20
21
|
/// <reference path="./static.ts" />
|
|
21
22
|
/// <reference path="./assets-manager.ts" />
|
|
22
23
|
/// <reference path="./container.ts" />
|
|
24
|
+
/// <reference path="./test-utils.ts" />
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
declare module '@ioc:Adonis/Core/TestUtils' {
|
|
3
|
+
import type { Server as HttpsServer } from 'https';
|
|
4
|
+
import type { MacroableConstructorContract } from 'macroable';
|
|
5
|
+
import type { IncomingMessage, ServerResponse, Server } from 'http';
|
|
6
|
+
export type ServerHandler = (req: IncomingMessage, res: ServerResponse) => any;
|
|
7
|
+
export type CustomServerCallback = (handler: ServerHandler) => Server | HttpsServer;
|
|
8
|
+
export interface TestUtilsContract {
|
|
9
|
+
constructor: MacroableConstructorContract<TestUtilsContract>;
|
|
10
|
+
ace(): {
|
|
11
|
+
loadCommands(): Promise<void>;
|
|
12
|
+
};
|
|
13
|
+
httpServer(): {
|
|
14
|
+
start(serverCallback?: CustomServerCallback): Promise<() => Promise<void>>;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Test utils module is meant to be extended to add custom
|
|
19
|
+
* utilities required for testing AdonisJS applications.
|
|
20
|
+
*/
|
|
21
|
+
const TestUtils: TestUtilsContract;
|
|
22
|
+
export default TestUtils;
|
|
23
|
+
}
|
|
@@ -39,6 +39,16 @@ export default class AppProvider {
|
|
|
39
39
|
* Registers base health checkers
|
|
40
40
|
*/
|
|
41
41
|
protected registerHealthCheckers(): void;
|
|
42
|
+
/**
|
|
43
|
+
* Register ace kernel to the container. When the process is started
|
|
44
|
+
* by running an ace command, then the "Adonis/Core/Ace" binding
|
|
45
|
+
* will already be in place and hence we do not overwrite it.
|
|
46
|
+
*/
|
|
47
|
+
protected registerAceKernel(): void;
|
|
48
|
+
/**
|
|
49
|
+
* Register utilities object required during testing
|
|
50
|
+
*/
|
|
51
|
+
protected registerTestUtils(): void;
|
|
42
52
|
/**
|
|
43
53
|
* Define repl bindings
|
|
44
54
|
*/
|
|
@@ -124,6 +124,28 @@ class AppProvider {
|
|
|
124
124
|
require('../src/HealthCheck/Checkers/AppKey').default(healthCheck);
|
|
125
125
|
});
|
|
126
126
|
}
|
|
127
|
+
/**
|
|
128
|
+
* Register ace kernel to the container. When the process is started
|
|
129
|
+
* by running an ace command, then the "Adonis/Core/Ace" binding
|
|
130
|
+
* will already be in place and hence we do not overwrite it.
|
|
131
|
+
*/
|
|
132
|
+
registerAceKernel() {
|
|
133
|
+
if (!this.app.container.hasBinding('Adonis/Core/Ace')) {
|
|
134
|
+
this.app.container.singleton('Adonis/Core/Ace', () => {
|
|
135
|
+
const { Kernel } = require('@adonisjs/ace');
|
|
136
|
+
return new Kernel(this.app);
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Register utilities object required during testing
|
|
142
|
+
*/
|
|
143
|
+
registerTestUtils() {
|
|
144
|
+
this.app.container.singleton('Adonis/Core/TestUtils', () => {
|
|
145
|
+
const { TestUtils } = require('../src/TestUtils');
|
|
146
|
+
return new TestUtils(this.app);
|
|
147
|
+
});
|
|
148
|
+
}
|
|
127
149
|
/**
|
|
128
150
|
* Define repl bindings
|
|
129
151
|
*/
|
|
@@ -150,6 +172,8 @@ class AppProvider {
|
|
|
150
172
|
this.registerHttpExceptionHandler();
|
|
151
173
|
this.registerHealthCheck();
|
|
152
174
|
this.registerAssetsManager();
|
|
175
|
+
this.registerAceKernel();
|
|
176
|
+
this.registerTestUtils();
|
|
153
177
|
}
|
|
154
178
|
/**
|
|
155
179
|
* Register hooks and health checkers on boot
|
|
@@ -11,26 +11,13 @@ export declare class App {
|
|
|
11
11
|
*/
|
|
12
12
|
private get isAssemblerCommand();
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
15
|
-
* loadApp inside the command setting is true.
|
|
16
|
-
*/
|
|
17
|
-
private wired;
|
|
18
|
-
/**
|
|
19
|
-
* Reference to the application
|
|
20
|
-
*/
|
|
21
|
-
private application;
|
|
22
|
-
/**
|
|
23
|
-
* Reference to the ace kernel
|
|
14
|
+
* Reference to the app kernel
|
|
24
15
|
*/
|
|
25
16
|
private kernel;
|
|
26
17
|
/**
|
|
27
|
-
*
|
|
28
|
-
*/
|
|
29
|
-
private signalsListener;
|
|
30
|
-
/**
|
|
31
|
-
* Find if TS hook has been registered or not
|
|
18
|
+
* Reference to the ace kernel
|
|
32
19
|
*/
|
|
33
|
-
private
|
|
20
|
+
private ace;
|
|
34
21
|
/**
|
|
35
22
|
* Source root always points to the compiled source
|
|
36
23
|
* code.
|
|
@@ -54,26 +41,18 @@ export declare class App {
|
|
|
54
41
|
*/
|
|
55
42
|
private onRun;
|
|
56
43
|
/**
|
|
57
|
-
* Hooks into
|
|
44
|
+
* Hooks into ace lifecycle events to conditionally
|
|
58
45
|
* load the app.
|
|
59
46
|
*/
|
|
60
|
-
private
|
|
47
|
+
private registerAceHooks;
|
|
61
48
|
/**
|
|
62
49
|
* Adding flags
|
|
63
50
|
*/
|
|
64
|
-
private
|
|
65
|
-
/**
|
|
66
|
-
* Boot the application.
|
|
67
|
-
*/
|
|
68
|
-
private wire;
|
|
69
|
-
/**
|
|
70
|
-
* Returns manifest details for assembler
|
|
71
|
-
*/
|
|
72
|
-
private getAssemblerManifest;
|
|
51
|
+
private registerAceFlags;
|
|
73
52
|
/**
|
|
74
|
-
*
|
|
53
|
+
* Load commands using manifest loader
|
|
75
54
|
*/
|
|
76
|
-
|
|
55
|
+
loadCommands(): Promise<void>;
|
|
77
56
|
/**
|
|
78
57
|
* Handle application command
|
|
79
58
|
*/
|
|
@@ -9,14 +9,11 @@
|
|
|
9
9
|
*/
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
11
|
exports.App = void 0;
|
|
12
|
-
const path_1 = require("path");
|
|
13
|
-
const cliui_1 = require("@poppinss/cliui");
|
|
14
|
-
const application_1 = require("@adonisjs/application");
|
|
15
12
|
const ace_1 = require("@adonisjs/ace");
|
|
13
|
+
const cliui_1 = require("@poppinss/cliui");
|
|
16
14
|
const helpers_1 = require("@poppinss/utils/build/helpers");
|
|
17
|
-
const
|
|
15
|
+
const Kernel_1 = require("../../Kernel");
|
|
18
16
|
const utils_1 = require("../../../utils");
|
|
19
|
-
const SignalsListener_1 = require("../../SignalsListener");
|
|
20
17
|
const GenerateManifest_1 = require("../GenerateManifest");
|
|
21
18
|
/**
|
|
22
19
|
* A local list of assembler commands. We need this, so that when assembler
|
|
@@ -53,26 +50,13 @@ class App {
|
|
|
53
50
|
constructor(appRoot) {
|
|
54
51
|
this.appRoot = appRoot;
|
|
55
52
|
/**
|
|
56
|
-
*
|
|
57
|
-
* loadApp inside the command setting is true.
|
|
53
|
+
* Reference to the app kernel
|
|
58
54
|
*/
|
|
59
|
-
this.
|
|
60
|
-
/**
|
|
61
|
-
* Reference to the application
|
|
62
|
-
*/
|
|
63
|
-
this.application = new application_1.Application(this.appRoot, 'console');
|
|
55
|
+
this.kernel = new Kernel_1.AppKernel(this.appRoot, 'console');
|
|
64
56
|
/**
|
|
65
57
|
* Reference to the ace kernel
|
|
66
58
|
*/
|
|
67
|
-
this.
|
|
68
|
-
/**
|
|
69
|
-
* Signals listener to listen for exit signals and kill command
|
|
70
|
-
*/
|
|
71
|
-
this.signalsListener = new SignalsListener_1.SignalsListener(this.application);
|
|
72
|
-
/**
|
|
73
|
-
* Find if TS hook has been registered or not
|
|
74
|
-
*/
|
|
75
|
-
this.registeredTsHook = false;
|
|
59
|
+
this.ace = new ace_1.Kernel(this.kernel.application);
|
|
76
60
|
}
|
|
77
61
|
/**
|
|
78
62
|
* Returns a boolean if mentioned command is an assembler
|
|
@@ -88,7 +72,7 @@ class App {
|
|
|
88
72
|
if (!value) {
|
|
89
73
|
return;
|
|
90
74
|
}
|
|
91
|
-
this.
|
|
75
|
+
this.ace.printHelp(command, [GenerateManifest_1.GenerateManifest.getManifestJSON()]);
|
|
92
76
|
process.exit(0);
|
|
93
77
|
}
|
|
94
78
|
/**
|
|
@@ -98,8 +82,8 @@ class App {
|
|
|
98
82
|
if (!value) {
|
|
99
83
|
return;
|
|
100
84
|
}
|
|
101
|
-
const appVersion = this.application.version;
|
|
102
|
-
const adonisVersion = this.application.adonisVersion;
|
|
85
|
+
const appVersion = this.kernel.application.version;
|
|
86
|
+
const adonisVersion = this.kernel.application.adonisVersion;
|
|
103
87
|
let assemblerVersion = 'Not Installed';
|
|
104
88
|
try {
|
|
105
89
|
assemblerVersion = require((0, helpers_1.resolveFrom)(this.appRoot, '@adonisjs/assembler/package.json')).version;
|
|
@@ -128,105 +112,69 @@ class App {
|
|
|
128
112
|
* - Is a typescript project
|
|
129
113
|
* - Is not an assembler command
|
|
130
114
|
*/
|
|
131
|
-
if (!this.
|
|
132
|
-
|
|
133
|
-
this.registeredTsHook = true;
|
|
115
|
+
if (!this.isAssemblerCommand) {
|
|
116
|
+
this.kernel.registerTsCompilerHook();
|
|
134
117
|
}
|
|
135
118
|
/**
|
|
136
|
-
*
|
|
119
|
+
* Only main command can load the application or switch
|
|
120
|
+
* the environment.
|
|
121
|
+
*
|
|
122
|
+
* If a sub-command needs application, then the main command
|
|
123
|
+
* should set "loadApp" to true as well.
|
|
137
124
|
*/
|
|
138
|
-
if (
|
|
125
|
+
if (command.commandName === this.commandName) {
|
|
139
126
|
/**
|
|
140
127
|
* Switch environment before wiring the app
|
|
141
128
|
*/
|
|
142
129
|
if (command.settings.environment) {
|
|
143
|
-
this.application.switchEnvironment(command.settings.environment);
|
|
130
|
+
this.kernel.application.switchEnvironment(command.settings.environment);
|
|
131
|
+
}
|
|
132
|
+
if (command.settings.loadApp) {
|
|
133
|
+
/**
|
|
134
|
+
* Set ace instance within the container, so that the underlying
|
|
135
|
+
* commands or the app can access it from the container
|
|
136
|
+
*/
|
|
137
|
+
this.kernel.application.container.singleton('Adonis/Core/Ace', () => this.ace);
|
|
138
|
+
await this.kernel.boot();
|
|
144
139
|
}
|
|
145
|
-
await this.wire();
|
|
146
140
|
}
|
|
147
141
|
}
|
|
148
142
|
/**
|
|
149
143
|
* Invoked before command is about to run.
|
|
150
144
|
*/
|
|
151
145
|
async onRun() {
|
|
152
|
-
if (this.
|
|
153
|
-
await this.
|
|
146
|
+
if (this.kernel.hasBooted) {
|
|
147
|
+
await this.kernel.start();
|
|
154
148
|
}
|
|
155
149
|
}
|
|
156
150
|
/**
|
|
157
|
-
* Hooks into
|
|
151
|
+
* Hooks into ace lifecycle events to conditionally
|
|
158
152
|
* load the app.
|
|
159
153
|
*/
|
|
160
|
-
|
|
161
|
-
this.
|
|
162
|
-
this.
|
|
154
|
+
registerAceHooks() {
|
|
155
|
+
this.ace.before('find', async (command) => this.onFind(command));
|
|
156
|
+
this.ace.before('run', async () => this.onRun());
|
|
163
157
|
}
|
|
164
158
|
/**
|
|
165
159
|
* Adding flags
|
|
166
160
|
*/
|
|
167
|
-
|
|
161
|
+
registerAceFlags() {
|
|
168
162
|
/**
|
|
169
163
|
* Showing help including core commands
|
|
170
164
|
*/
|
|
171
|
-
this.
|
|
165
|
+
this.ace.flag('help', async (value, _, command) => this.printHelp(value, command), {
|
|
172
166
|
alias: 'h',
|
|
173
167
|
});
|
|
174
168
|
/**
|
|
175
169
|
* Showing app and AdonisJs version
|
|
176
170
|
*/
|
|
177
|
-
this.
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Boot the application.
|
|
181
|
-
*/
|
|
182
|
-
async wire() {
|
|
183
|
-
if (this.wired) {
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
this.wired = true;
|
|
187
|
-
/**
|
|
188
|
-
* Do not change sequence
|
|
189
|
-
*/
|
|
190
|
-
await this.application.setup();
|
|
191
|
-
await this.application.registerProviders();
|
|
192
|
-
await this.application.bootProviders();
|
|
193
|
-
await this.application.requirePreloads();
|
|
171
|
+
this.ace.flag('version', async (value) => this.printVersion(value), { alias: 'v' });
|
|
194
172
|
}
|
|
195
173
|
/**
|
|
196
|
-
*
|
|
174
|
+
* Load commands using manifest loader
|
|
197
175
|
*/
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
const manifestAbsPath = (0, helpers_1.resolveFrom)(this.application.appRoot, '@adonisjs/assembler/build/ace-manifest.json');
|
|
201
|
-
const basePath = (0, path_1.join)(manifestAbsPath, '../');
|
|
202
|
-
return [
|
|
203
|
-
{
|
|
204
|
-
manifestAbsPath,
|
|
205
|
-
basePath,
|
|
206
|
-
},
|
|
207
|
-
];
|
|
208
|
-
}
|
|
209
|
-
catch (error) {
|
|
210
|
-
return [];
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Returns manifest details for app
|
|
215
|
-
*/
|
|
216
|
-
getAppManifest() {
|
|
217
|
-
try {
|
|
218
|
-
const manifestAbsPath = (0, helpers_1.resolveFrom)(this.application.appRoot, './ace-manifest.json');
|
|
219
|
-
const basePath = this.application.appRoot;
|
|
220
|
-
return [
|
|
221
|
-
{
|
|
222
|
-
manifestAbsPath,
|
|
223
|
-
basePath,
|
|
224
|
-
},
|
|
225
|
-
];
|
|
226
|
-
}
|
|
227
|
-
catch (error) {
|
|
228
|
-
return [];
|
|
229
|
-
}
|
|
176
|
+
async loadCommands() {
|
|
177
|
+
await (0, utils_1.loadAceCommands)(this.kernel.application, this.ace);
|
|
230
178
|
}
|
|
231
179
|
/**
|
|
232
180
|
* Handle application command
|
|
@@ -236,20 +184,15 @@ class App {
|
|
|
236
184
|
/**
|
|
237
185
|
* Manifest files to load
|
|
238
186
|
*/
|
|
239
|
-
|
|
187
|
+
await this.loadCommands();
|
|
240
188
|
/**
|
|
241
|
-
* Define
|
|
189
|
+
* Define ace hooks to wire the application (if required)
|
|
242
190
|
*/
|
|
243
|
-
this.
|
|
191
|
+
this.registerAceHooks();
|
|
244
192
|
/**
|
|
245
193
|
* Define global flags
|
|
246
194
|
*/
|
|
247
|
-
this.
|
|
248
|
-
/**
|
|
249
|
-
* Preload manifest in advance. This way we can show the help
|
|
250
|
-
* when no args are defined
|
|
251
|
-
*/
|
|
252
|
-
await this.kernel.preloadManifest();
|
|
195
|
+
this.registerAceFlags();
|
|
253
196
|
/**
|
|
254
197
|
* Print help when no arguments have been passed
|
|
255
198
|
*/
|
|
@@ -263,33 +206,27 @@ class App {
|
|
|
263
206
|
* executed
|
|
264
207
|
*/
|
|
265
208
|
this.commandName = argv[0];
|
|
266
|
-
/**
|
|
267
|
-
* Listen for exit events and shutdown app
|
|
268
|
-
*/
|
|
269
|
-
this.signalsListener.listen(async () => {
|
|
270
|
-
if (this.wired) {
|
|
271
|
-
await this.application.shutdown();
|
|
272
|
-
}
|
|
273
|
-
});
|
|
274
209
|
/**
|
|
275
210
|
* Listen for the exit signal on ace kernel
|
|
276
211
|
*/
|
|
277
|
-
this.
|
|
278
|
-
if (this.
|
|
279
|
-
|
|
212
|
+
this.ace.onExit(async () => {
|
|
213
|
+
if (!this.ace.error) {
|
|
214
|
+
process.exit(this.ace.exitCode);
|
|
280
215
|
}
|
|
281
|
-
|
|
216
|
+
return this.kernel
|
|
217
|
+
.handleError(this.ace.error)
|
|
218
|
+
.finally(() => process.exit(this.ace.exitCode));
|
|
282
219
|
});
|
|
283
220
|
/**
|
|
284
221
|
* Handle command
|
|
285
222
|
*/
|
|
286
|
-
await this.
|
|
223
|
+
await this.ace.handle(argv);
|
|
287
224
|
}
|
|
288
225
|
catch (error) {
|
|
289
226
|
if (!error) {
|
|
290
227
|
process.exit(1);
|
|
291
228
|
}
|
|
292
|
-
|
|
229
|
+
this.kernel.handleError(error).finally(() => process.exit(1));
|
|
293
230
|
}
|
|
294
231
|
}
|
|
295
232
|
}
|
|
@@ -11,9 +11,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
11
11
|
exports.GenerateManifest = void 0;
|
|
12
12
|
const cliui_1 = require("@poppinss/cliui");
|
|
13
13
|
const ace_1 = require("@adonisjs/ace");
|
|
14
|
-
const
|
|
15
|
-
const ErrorHandler_1 = require("../ErrorHandler");
|
|
16
|
-
const utils_1 = require("../../../utils");
|
|
14
|
+
const Kernel_1 = require("../../Kernel");
|
|
17
15
|
const Exceptions_1 = require("../Exceptions");
|
|
18
16
|
/**
|
|
19
17
|
* Exposes the API to generate the manifest file
|
|
@@ -25,7 +23,7 @@ class GenerateManifest {
|
|
|
25
23
|
*/
|
|
26
24
|
constructor(appRoot) {
|
|
27
25
|
this.appRoot = appRoot;
|
|
28
|
-
this.
|
|
26
|
+
this.kernel = new Kernel_1.AppKernel(this.appRoot, 'console');
|
|
29
27
|
}
|
|
30
28
|
/**
|
|
31
29
|
* Returns manifest object for showing help
|
|
@@ -46,27 +44,22 @@ class GenerateManifest {
|
|
|
46
44
|
*/
|
|
47
45
|
async handle() {
|
|
48
46
|
try {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
*/
|
|
52
|
-
if (this.application.rcFile.typescript) {
|
|
53
|
-
(0, utils_1.registerTsHook)(this.application.appRoot);
|
|
54
|
-
}
|
|
55
|
-
const commands = this.application.rcFile.commands;
|
|
47
|
+
this.kernel.registerTsCompilerHook();
|
|
48
|
+
const commands = this.kernel.application.rcFile.commands;
|
|
56
49
|
/**
|
|
57
50
|
* Generating manifest requires us to import the command files to read their
|
|
58
51
|
* meta data defined as class static properties. However, at this stage
|
|
59
52
|
* the application is not booted and hence top level IoC container
|
|
60
53
|
* imports will break
|
|
61
54
|
*/
|
|
62
|
-
this.application.container.trap((namespace) => {
|
|
55
|
+
this.kernel.application.container.trap((namespace) => {
|
|
63
56
|
if (namespace === 'Adonis/Core/Application') {
|
|
64
|
-
return this.application;
|
|
57
|
+
return this.kernel.application;
|
|
65
58
|
}
|
|
66
59
|
return {
|
|
67
60
|
__esModule: new Proxy({ namespace }, {
|
|
68
61
|
get(target) {
|
|
69
|
-
throw new Exceptions_1.AceRuntimeException(`Top level import for module "${target.namespace}" is not allowed in commands. Learn more https://
|
|
62
|
+
throw new Exceptions_1.AceRuntimeException(`Top level import for module "${target.namespace}" is not allowed in commands. Learn more https://docs.adonisjs.com/guides/ace-commandline#top-level-imports-are-not-allowed`);
|
|
70
63
|
},
|
|
71
64
|
}),
|
|
72
65
|
};
|
|
@@ -75,7 +68,7 @@ class GenerateManifest {
|
|
|
75
68
|
cliui_1.logger.action('create').succeeded('ace-manifest.json file');
|
|
76
69
|
}
|
|
77
70
|
catch (error) {
|
|
78
|
-
await
|
|
71
|
+
await this.kernel.handleError(error).finally(() => process.exit(1));
|
|
79
72
|
}
|
|
80
73
|
}
|
|
81
74
|
}
|
|
@@ -1,55 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import { Application } from '@adonisjs/application';
|
|
4
|
-
import { IncomingMessage, ServerResponse, Server } from 'http';
|
|
5
|
-
declare type ServerHandler = (req: IncomingMessage, res: ServerResponse) => any;
|
|
6
|
-
declare type CustomServerCallback = (handler: ServerHandler) => Server | HttpsServer;
|
|
1
|
+
import { CustomServerCallback } from '@ioc:Adonis/Core/TestUtils';
|
|
2
|
+
import { AppKernel } from '../Kernel';
|
|
7
3
|
/**
|
|
8
4
|
* Exposes the API to setup the application for starting the HTTP
|
|
9
5
|
* server.
|
|
6
|
+
*
|
|
7
|
+
* - Calling "kill" explicitly exists the process.
|
|
8
|
+
* - The "error" event emitted on the server instance explicitly exists the process.
|
|
9
|
+
* - SIGINT and in some case SIGTERM explicitly exists the process.
|
|
10
10
|
*/
|
|
11
11
|
export declare class HttpServer {
|
|
12
12
|
private appRoot;
|
|
13
13
|
/**
|
|
14
|
-
* Reference to
|
|
14
|
+
* Reference to the HTTP server.
|
|
15
15
|
*/
|
|
16
16
|
private server;
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
18
|
+
* Reference to the app kernel
|
|
19
19
|
*/
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
* Reference to the application.
|
|
23
|
-
*/
|
|
24
|
-
application: Application;
|
|
25
|
-
/**
|
|
26
|
-
* Listens for unix signals to kill long running
|
|
27
|
-
* processes.
|
|
28
|
-
*/
|
|
29
|
-
private signalsListener;
|
|
20
|
+
kernel: AppKernel;
|
|
21
|
+
application: import("@adonisjs/application").Application;
|
|
30
22
|
constructor(appRoot: string);
|
|
31
|
-
/**
|
|
32
|
-
* Wires up everything, so that we are ready to kick start
|
|
33
|
-
* the HTTP server.
|
|
34
|
-
*/
|
|
35
|
-
private wire;
|
|
36
|
-
/**
|
|
37
|
-
* Sets the server reference
|
|
38
|
-
*/
|
|
39
|
-
private setServer;
|
|
40
23
|
/**
|
|
41
24
|
* Closes the underlying HTTP server
|
|
42
25
|
*/
|
|
43
26
|
private closeHttpServer;
|
|
44
27
|
/**
|
|
45
28
|
* Monitors the HTTP server for close and error events, so that
|
|
46
|
-
* we can perform a graceful shutdown
|
|
29
|
+
* we can perform a graceful shutdown.
|
|
47
30
|
*/
|
|
48
31
|
private monitorHttpServer;
|
|
49
|
-
/**
|
|
50
|
-
* Notify server is ready
|
|
51
|
-
*/
|
|
52
|
-
private notifyServerReady;
|
|
53
32
|
/**
|
|
54
33
|
* Creates the HTTP server to handle incoming requests. The server is just
|
|
55
34
|
* created but not listening on any port.
|
|
@@ -75,4 +54,3 @@ export declare class HttpServer {
|
|
|
75
54
|
*/
|
|
76
55
|
kill(waitTimeout?: number): Promise<void>;
|
|
77
56
|
}
|
|
78
|
-
export {};
|