@adonisjs/core 5.4.1 → 5.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +52 -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/standalone.js +5 -1
- 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 +85 -35
- 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/build/src/utils/index.js
CHANGED
|
@@ -8,16 +8,11 @@
|
|
|
8
8
|
* file that was distributed with this source code.
|
|
9
9
|
*/
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.
|
|
11
|
+
exports.loadAceCommands = exports.createHttpServer = exports.registerTsHook = void 0;
|
|
12
|
+
const path_1 = require("path");
|
|
13
|
+
const http_1 = require("http");
|
|
14
|
+
const ace_1 = require("@adonisjs/ace");
|
|
12
15
|
const helpers_1 = require("@poppinss/utils/build/helpers");
|
|
13
|
-
/**
|
|
14
|
-
* Helper to know if error belongs to a missing module
|
|
15
|
-
* error
|
|
16
|
-
*/
|
|
17
|
-
function isMissingModuleError(error) {
|
|
18
|
-
return ['MODULE_NOT_FOUND', 'ENOENT'].includes(error.code);
|
|
19
|
-
}
|
|
20
|
-
exports.isMissingModuleError = isMissingModuleError;
|
|
21
16
|
/**
|
|
22
17
|
* Registers the ts hook to compile typescript code within the memory
|
|
23
18
|
*/
|
|
@@ -26,10 +21,62 @@ function registerTsHook(appRoot) {
|
|
|
26
21
|
require((0, helpers_1.resolveFrom)(appRoot, '@adonisjs/assembler/build/src/requireHook')).default(appRoot);
|
|
27
22
|
}
|
|
28
23
|
catch (error) {
|
|
29
|
-
if (
|
|
24
|
+
if (['MODULE_NOT_FOUND', 'ENOENT'].includes(error.code)) {
|
|
30
25
|
throw new Error('AdonisJS requires "@adonisjs/assembler" in order to run typescript source directly');
|
|
31
26
|
}
|
|
32
27
|
throw error;
|
|
33
28
|
}
|
|
34
29
|
}
|
|
35
30
|
exports.registerTsHook = registerTsHook;
|
|
31
|
+
/**
|
|
32
|
+
* Creates the AdonisJS HTTP server. The method is abstracted to be used by
|
|
33
|
+
* test utils and the HTTP server process both.
|
|
34
|
+
*/
|
|
35
|
+
function createHttpServer(application, server, callback) {
|
|
36
|
+
/**
|
|
37
|
+
* Optimizing the server by pre-compiling routes and middleware
|
|
38
|
+
*/
|
|
39
|
+
application.logger.trace('optimizing http server handler');
|
|
40
|
+
server.optimize();
|
|
41
|
+
/**
|
|
42
|
+
* Bind exception handler to handle exceptions occured during HTTP requests.
|
|
43
|
+
*/
|
|
44
|
+
if (application.exceptionHandlerNamespace) {
|
|
45
|
+
application.logger.trace('binding %s exception handler', application.exceptionHandlerNamespace);
|
|
46
|
+
server.errorHandler(application.exceptionHandlerNamespace);
|
|
47
|
+
}
|
|
48
|
+
const handler = server.handle.bind(server);
|
|
49
|
+
server.instance = callback ? callback(handler) : (0, http_1.createServer)(handler);
|
|
50
|
+
}
|
|
51
|
+
exports.createHttpServer = createHttpServer;
|
|
52
|
+
/**
|
|
53
|
+
* Helper function to optionally resolve files from a given path
|
|
54
|
+
*/
|
|
55
|
+
function resolve(fromPath, resolvePath, onMatch) {
|
|
56
|
+
try {
|
|
57
|
+
onMatch((0, helpers_1.resolveFrom)(fromPath, resolvePath));
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Loads ace commands from the assembler manifest and the app manifest files
|
|
65
|
+
*/
|
|
66
|
+
function loadAceCommands(application, ace) {
|
|
67
|
+
const manifestFiles = [];
|
|
68
|
+
resolve(application.appRoot, '@adonisjs/assembler/build/ace-manifest.json', (manifestAbsPath) => {
|
|
69
|
+
const basePath = (0, path_1.join)(manifestAbsPath, '../');
|
|
70
|
+
manifestFiles.push({ manifestAbsPath, basePath });
|
|
71
|
+
});
|
|
72
|
+
resolve(application.appRoot, './ace-manifest.json', (manifestAbsPath) => {
|
|
73
|
+
const basePath = (0, path_1.join)(manifestAbsPath, '../');
|
|
74
|
+
manifestFiles.push({ manifestAbsPath, basePath });
|
|
75
|
+
});
|
|
76
|
+
/**
|
|
77
|
+
* Load commands using manifest loader
|
|
78
|
+
*/
|
|
79
|
+
ace.useManifest(new ace_1.ManifestLoader(manifestFiles));
|
|
80
|
+
return ace.preloadManifest();
|
|
81
|
+
}
|
|
82
|
+
exports.loadAceCommands = loadAceCommands;
|
package/build/standalone.js
CHANGED
|
@@ -9,7 +9,11 @@
|
|
|
9
9
|
*/
|
|
10
10
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
11
11
|
if (k2 === undefined) k2 = k;
|
|
12
|
-
Object.
|
|
12
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
13
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
14
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
15
|
+
}
|
|
16
|
+
Object.defineProperty(o, k2, desc);
|
|
13
17
|
}) : (function(o, m, k, k2) {
|
|
14
18
|
if (k2 === undefined) k2 = k;
|
|
15
19
|
o[k2] = m[k];
|
|
@@ -18,7 +18,7 @@ declare module '@ioc:Adonis/Core/Env' {
|
|
|
18
18
|
|
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
-
type CustomTypes = typeof import(
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
type CustomTypes = typeof import('../env').default
|
|
22
|
+
interface EnvTypes extends CustomTypes {
|
|
23
|
+
}
|
|
24
24
|
}
|
package/build/templates/env.txt
CHANGED
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
import Env from '@ioc:Adonis/Core/Env'
|
|
16
16
|
|
|
17
17
|
export default Env.rules({
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
PORT: Env.schema.number(),
|
|
19
|
+
HOST: Env.schema.string({ format: 'host' }),
|
|
20
|
+
APP_KEY: Env.schema.string(),
|
|
21
|
+
APP_NAME: Env.schema.string(),
|
|
22
|
+
NODE_ENV: Env.schema.enum(['development', 'production', 'testing'] as const),
|
|
23
23
|
/**
|
|
24
24
|
* Feel free to change the enum options to the actual disk names
|
|
25
25
|
* you have defined inside the "contracts/drive.ts" file.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File source: https://bit.ly/3BUZKtR
|
|
3
|
+
*
|
|
4
|
+
* Feel free to let us know via PR, if you find something broken in this contract
|
|
5
|
+
* file.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { assert } from '@japa/assert'
|
|
9
|
+
import type { Suite } from '@japa/core'
|
|
10
|
+
import { specReporter } from '@japa/spec-reporter'
|
|
11
|
+
import TestUtils from '@ioc:Adonis/Core/TestUtils'
|
|
12
|
+
import type { PluginFn, RunnerHooksHandler, TestContext, ReporterContract } from '@japa/runner'
|
|
13
|
+
|
|
14
|
+
/*
|
|
15
|
+
|--------------------------------------------------------------------------
|
|
16
|
+
| Japa Plugins
|
|
17
|
+
|--------------------------------------------------------------------------
|
|
18
|
+
|
|
|
19
|
+
| Japa plugins allows you to add additional features to Japa. By default
|
|
20
|
+
| we register the assertion plugin.
|
|
21
|
+
|
|
|
22
|
+
| Feel free to remove existing plugins or add more.
|
|
23
|
+
|
|
|
24
|
+
*/
|
|
25
|
+
export const plugins: PluginFn[] = [assert()]
|
|
26
|
+
|
|
27
|
+
/*
|
|
28
|
+
|--------------------------------------------------------------------------
|
|
29
|
+
| Japa Reporters
|
|
30
|
+
|--------------------------------------------------------------------------
|
|
31
|
+
|
|
|
32
|
+
| Japa reporters displays/saves the progress of tests as they are executed.
|
|
33
|
+
| By default, we register the spec reporter to show a detailed report
|
|
34
|
+
| of tests on the terminal.
|
|
35
|
+
|
|
|
36
|
+
*/
|
|
37
|
+
export const reporters: ReporterContract[] = [specReporter()]
|
|
38
|
+
|
|
39
|
+
/*
|
|
40
|
+
|--------------------------------------------------------------------------
|
|
41
|
+
| Runner hooks
|
|
42
|
+
|--------------------------------------------------------------------------
|
|
43
|
+
|
|
|
44
|
+
| Runner hooks are executed after booting the AdonisJS app and
|
|
45
|
+
| before the test files are imported.
|
|
46
|
+
|
|
|
47
|
+
| You can perform actions like starting the HTTP server or running migrations
|
|
48
|
+
| within the runner hooks
|
|
49
|
+
|
|
|
50
|
+
*/
|
|
51
|
+
export const runnerHooks: { setup: RunnerHooksHandler[]; teardown: RunnerHooksHandler[] } = {
|
|
52
|
+
setup: [() => TestUtils.ace().loadCommands()],
|
|
53
|
+
teardown: [],
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/*
|
|
57
|
+
|--------------------------------------------------------------------------
|
|
58
|
+
| Configure individual suites
|
|
59
|
+
|--------------------------------------------------------------------------
|
|
60
|
+
|
|
|
61
|
+
| The configureSuite method gets called for every test suite registered
|
|
62
|
+
| within ".adonisrc.json" file.
|
|
63
|
+
|
|
|
64
|
+
| You can use this method to configure suites. For example: Only start
|
|
65
|
+
| the HTTP server when it is a feature suite.
|
|
66
|
+
*/
|
|
67
|
+
export const configureSuite = (suite: Suite<TestContext>) => {
|
|
68
|
+
if (suite.name === 'feature') {
|
|
69
|
+
suite.setup(() => TestUtils.httpServer().start())
|
|
70
|
+
}
|
|
71
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adonisjs/core",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.5.1",
|
|
4
4
|
"description": "Core of AdonisJS",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -34,12 +34,12 @@
|
|
|
34
34
|
"scripts": {
|
|
35
35
|
"mrm": "mrm --preset=@adonisjs/mrm-preset",
|
|
36
36
|
"pretest": "npm run lint",
|
|
37
|
-
"test": "node
|
|
38
|
-
"clean": "del build",
|
|
37
|
+
"test": "node -r @adonisjs/require-ts/build/register bin/test.ts",
|
|
38
|
+
"clean": "del-cli build",
|
|
39
39
|
"compile": "npm run lint && npm run clean && tsc && copyfiles templates/**/* templates/* build",
|
|
40
40
|
"build": "npm run compile",
|
|
41
41
|
"commit": "git-cz",
|
|
42
|
-
"release": "np",
|
|
42
|
+
"release": "np --message=\"chore(release): %s\"",
|
|
43
43
|
"version": "npm run build",
|
|
44
44
|
"prepublishOnly": "npm run build",
|
|
45
45
|
"lint": "eslint . --ext=.ts",
|
|
@@ -63,35 +63,40 @@
|
|
|
63
63
|
},
|
|
64
64
|
"homepage": "https://github.com/adonisjs/core#readme",
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"@adonisjs/assembler": "^5.
|
|
67
|
-
"@adonisjs/mrm-preset": "^
|
|
68
|
-
"@adonisjs/repl": "^3.1.
|
|
69
|
-
"@adonisjs/require-ts": "^2.0.
|
|
70
|
-
"@adonisjs/sink": "^5.2.
|
|
71
|
-
"@
|
|
72
|
-
"@
|
|
66
|
+
"@adonisjs/assembler": "^5.4.1",
|
|
67
|
+
"@adonisjs/mrm-preset": "^5.0.2",
|
|
68
|
+
"@adonisjs/repl": "^3.1.9",
|
|
69
|
+
"@adonisjs/require-ts": "^2.0.10",
|
|
70
|
+
"@adonisjs/sink": "^5.2.2",
|
|
71
|
+
"@japa/assert": "^1.2.3",
|
|
72
|
+
"@japa/run-failed-tests": "^1.0.3",
|
|
73
|
+
"@japa/runner": "^1.2.0",
|
|
74
|
+
"@japa/spec-reporter": "^1.1.7",
|
|
75
|
+
"@poppinss/dev-utils": "^2.0.2",
|
|
76
|
+
"@types/node": "^17.0.21",
|
|
73
77
|
"@types/supertest": "^2.0.11",
|
|
74
78
|
"clear-module": "^4.1.2",
|
|
79
|
+
"commitizen": "^4.2.4",
|
|
75
80
|
"copyfiles": "^2.4.1",
|
|
81
|
+
"cz-conventional-changelog": "^3.3.0",
|
|
76
82
|
"del-cli": "^4.0.1",
|
|
77
|
-
"eslint": "^8.
|
|
78
|
-
"eslint-config-prettier": "^8.
|
|
79
|
-
"eslint-plugin-adonis": "^2.
|
|
83
|
+
"eslint": "^8.10.0",
|
|
84
|
+
"eslint-config-prettier": "^8.5.0",
|
|
85
|
+
"eslint-plugin-adonis": "^2.1.0",
|
|
80
86
|
"eslint-plugin-prettier": "^4.0.0",
|
|
81
87
|
"etag": "^1.8.1",
|
|
82
88
|
"github-label-sync": "^2.0.2",
|
|
83
89
|
"husky": "^7.0.4",
|
|
84
|
-
"japa": "^4.0.0",
|
|
85
90
|
"mrm": "^3.0.10",
|
|
86
91
|
"np": "^7.6.0",
|
|
87
|
-
"prettier": "^2.
|
|
92
|
+
"prettier": "^2.5.1",
|
|
88
93
|
"reflect-metadata": "^0.1.13",
|
|
89
94
|
"strip-ansi": "^6.0.0",
|
|
90
|
-
"supertest": "^6.
|
|
95
|
+
"supertest": "^6.2.2",
|
|
91
96
|
"test-console": "^2.0.0",
|
|
92
|
-
"typescript": "^4.
|
|
93
|
-
"youch": "^
|
|
94
|
-
"youch-terminal": "^
|
|
97
|
+
"typescript": "^4.6.2",
|
|
98
|
+
"youch": "^3.1.1",
|
|
99
|
+
"youch-terminal": "^2.1.3"
|
|
95
100
|
},
|
|
96
101
|
"nyc": {
|
|
97
102
|
"exclude": [
|
|
@@ -112,21 +117,22 @@
|
|
|
112
117
|
}
|
|
113
118
|
},
|
|
114
119
|
"dependencies": {
|
|
115
|
-
"@adonisjs/ace": "^11.0
|
|
116
|
-
"@adonisjs/application": "^5.
|
|
117
|
-
"@adonisjs/bodyparser": "^8.0
|
|
118
|
-
"@adonisjs/drive": "^2.0.
|
|
119
|
-
"@adonisjs/encryption": "^4.0.
|
|
120
|
-
"@adonisjs/events": "^7.1.
|
|
121
|
-
"@adonisjs/hash": "^7.0.
|
|
122
|
-
"@adonisjs/http-server": "^5.
|
|
123
|
-
"@adonisjs/validator": "^12.
|
|
124
|
-
"@poppinss/cliui": "^
|
|
125
|
-
"@poppinss/manager": "^
|
|
126
|
-
"@poppinss/utils": "^
|
|
127
|
-
"fs-extra": "^10.0.
|
|
128
|
-
"
|
|
129
|
-
"
|
|
120
|
+
"@adonisjs/ace": "^11.1.0",
|
|
121
|
+
"@adonisjs/application": "^5.2.0",
|
|
122
|
+
"@adonisjs/bodyparser": "^8.1.0",
|
|
123
|
+
"@adonisjs/drive": "^2.0.9",
|
|
124
|
+
"@adonisjs/encryption": "^4.0.7",
|
|
125
|
+
"@adonisjs/events": "^7.1.3",
|
|
126
|
+
"@adonisjs/hash": "^7.0.10",
|
|
127
|
+
"@adonisjs/http-server": "^5.6.1",
|
|
128
|
+
"@adonisjs/validator": "^12.2.2",
|
|
129
|
+
"@poppinss/cliui": "^3.0.1",
|
|
130
|
+
"@poppinss/manager": "^5.0.1",
|
|
131
|
+
"@poppinss/utils": "^4.0.2",
|
|
132
|
+
"fs-extra": "^10.0.1",
|
|
133
|
+
"macroable": "^6.0.1",
|
|
134
|
+
"memfs": "^3.4.1",
|
|
135
|
+
"serve-static": "^1.14.2",
|
|
130
136
|
"stringify-attributes": "^2.0.0"
|
|
131
137
|
},
|
|
132
138
|
"np": {
|
|
@@ -185,5 +191,49 @@
|
|
|
185
191
|
"publishConfig": {
|
|
186
192
|
"access": "public",
|
|
187
193
|
"tag": "latest"
|
|
194
|
+
},
|
|
195
|
+
"mrmConfig": {
|
|
196
|
+
"core": true,
|
|
197
|
+
"license": "MIT",
|
|
198
|
+
"services": [
|
|
199
|
+
"github-actions"
|
|
200
|
+
],
|
|
201
|
+
"minNodeVersion": "14.15.4",
|
|
202
|
+
"probotApps": [
|
|
203
|
+
"stale",
|
|
204
|
+
"lock"
|
|
205
|
+
],
|
|
206
|
+
"runGhActionsOnWindows": true
|
|
207
|
+
},
|
|
208
|
+
"main": "build/index.js",
|
|
209
|
+
"eslintConfig": {
|
|
210
|
+
"extends": [
|
|
211
|
+
"plugin:adonis/typescriptPackage",
|
|
212
|
+
"prettier"
|
|
213
|
+
],
|
|
214
|
+
"plugins": [
|
|
215
|
+
"prettier"
|
|
216
|
+
],
|
|
217
|
+
"rules": {
|
|
218
|
+
"prettier/prettier": [
|
|
219
|
+
"error",
|
|
220
|
+
{
|
|
221
|
+
"endOfLine": "auto"
|
|
222
|
+
}
|
|
223
|
+
]
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
"eslintIgnore": [
|
|
227
|
+
"build"
|
|
228
|
+
],
|
|
229
|
+
"prettier": {
|
|
230
|
+
"trailingComma": "es5",
|
|
231
|
+
"semi": false,
|
|
232
|
+
"singleQuote": true,
|
|
233
|
+
"useTabs": false,
|
|
234
|
+
"quoteProps": "consistent",
|
|
235
|
+
"bracketSpacing": true,
|
|
236
|
+
"arrowParens": "always",
|
|
237
|
+
"printWidth": 100
|
|
188
238
|
}
|
|
189
239
|
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { ApplicationContract } from '@ioc:Adonis/Core/Application';
|
|
2
|
-
/**
|
|
3
|
-
* Handles ignitor bootstrapping errors by pretty printing them in development
|
|
4
|
-
*/
|
|
5
|
-
export declare class ErrorHandler {
|
|
6
|
-
private application;
|
|
7
|
-
constructor(application: ApplicationContract);
|
|
8
|
-
/**
|
|
9
|
-
* Pretty prints a given error on the terminal
|
|
10
|
-
*/
|
|
11
|
-
private prettyPrintError;
|
|
12
|
-
/**
|
|
13
|
-
* Handles ignitor boot errors
|
|
14
|
-
*/
|
|
15
|
-
handleError(error: any): Promise<void>;
|
|
16
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* @adonisjs/core
|
|
4
|
-
*
|
|
5
|
-
* (c) Harminder Virk <virk@adonisjs.com>
|
|
6
|
-
*
|
|
7
|
-
* For the full copyright and license information, please view the LICENSE
|
|
8
|
-
* file that was distributed with this source code.
|
|
9
|
-
*/
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.ErrorHandler = void 0;
|
|
12
|
-
/**
|
|
13
|
-
* Handles ignitor bootstrapping errors by pretty printing them in development
|
|
14
|
-
*/
|
|
15
|
-
class ErrorHandler {
|
|
16
|
-
constructor(application) {
|
|
17
|
-
this.application = application;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Pretty prints a given error on the terminal
|
|
21
|
-
*/
|
|
22
|
-
async prettyPrintError(error) {
|
|
23
|
-
try {
|
|
24
|
-
const Youch = require('youch');
|
|
25
|
-
const output = await new Youch(error, {}).toJSON();
|
|
26
|
-
console.log(require('youch-terminal')(output));
|
|
27
|
-
}
|
|
28
|
-
catch (err) {
|
|
29
|
-
console.log(error.stack);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Handles ignitor boot errors
|
|
34
|
-
*/
|
|
35
|
-
async handleError(error) {
|
|
36
|
-
if (typeof error.handle === 'function') {
|
|
37
|
-
error.handle(error);
|
|
38
|
-
}
|
|
39
|
-
else if (this.application.inDev) {
|
|
40
|
-
await this.prettyPrintError(error);
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
console.error(error.stack);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
exports.ErrorHandler = ErrorHandler;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { ApplicationContract } from '@ioc:Adonis/Core/Application';
|
|
2
|
-
/**
|
|
3
|
-
* Handles ignitor bootstrapping errors by pretty printing them in development
|
|
4
|
-
*/
|
|
5
|
-
export declare class ErrorHandler {
|
|
6
|
-
private application;
|
|
7
|
-
constructor(application: ApplicationContract);
|
|
8
|
-
/**
|
|
9
|
-
* Pretty prints a given error on the terminal
|
|
10
|
-
*/
|
|
11
|
-
private prettyPrintError;
|
|
12
|
-
/**
|
|
13
|
-
* Handles ignitor boot errors
|
|
14
|
-
*/
|
|
15
|
-
handleError(error: any): Promise<void>;
|
|
16
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* @adonisjs/core
|
|
4
|
-
*
|
|
5
|
-
* (c) Harminder Virk <virk@adonisjs.com>
|
|
6
|
-
*
|
|
7
|
-
* For the full copyright and license information, please view the LICENSE
|
|
8
|
-
* file that was distributed with this source code.
|
|
9
|
-
*/
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.ErrorHandler = void 0;
|
|
12
|
-
/**
|
|
13
|
-
* Handles ignitor bootstrapping errors by pretty printing them in development
|
|
14
|
-
*/
|
|
15
|
-
class ErrorHandler {
|
|
16
|
-
constructor(application) {
|
|
17
|
-
this.application = application;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Pretty prints a given error on the terminal
|
|
21
|
-
*/
|
|
22
|
-
async prettyPrintError(error) {
|
|
23
|
-
try {
|
|
24
|
-
const Youch = require('youch');
|
|
25
|
-
const output = await new Youch(error, {}).toJSON();
|
|
26
|
-
console.log(require('youch-terminal')(output));
|
|
27
|
-
}
|
|
28
|
-
catch (err) {
|
|
29
|
-
console.log(error.stack);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Handles ignitor boot errors
|
|
34
|
-
*/
|
|
35
|
-
async handleError(error) {
|
|
36
|
-
if (this.application.inDev) {
|
|
37
|
-
await this.prettyPrintError(error);
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
console.error(error.stack);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
exports.ErrorHandler = ErrorHandler;
|