@adonisjs/core 5.4.0 → 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.
Files changed (39) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +10 -2
  3. package/build/adonis-typings/ace.d.ts +5 -0
  4. package/build/adonis-typings/ace.js +8 -0
  5. package/build/adonis-typings/container.d.ts +4 -0
  6. package/build/adonis-typings/index.d.ts +2 -0
  7. package/build/adonis-typings/index.js +2 -0
  8. package/build/adonis-typings/test-utils.d.ts +23 -0
  9. package/build/adonis-typings/test-utils.js +8 -0
  10. package/build/providers/AppProvider.d.ts +10 -0
  11. package/build/providers/AppProvider.js +24 -0
  12. package/build/src/Ignitor/Ace/App/index.d.ts +8 -29
  13. package/build/src/Ignitor/Ace/App/index.js +49 -112
  14. package/build/src/Ignitor/Ace/GenerateManifest/index.d.ts +1 -1
  15. package/build/src/Ignitor/Ace/GenerateManifest/index.js +8 -15
  16. package/build/src/Ignitor/HttpServer/index.d.ts +11 -33
  17. package/build/src/Ignitor/HttpServer/index.js +20 -84
  18. package/build/src/Ignitor/Kernel/index.d.ts +56 -0
  19. package/build/src/Ignitor/Kernel/index.js +123 -0
  20. package/build/src/Ignitor/SignalsListener/index.js +14 -11
  21. package/build/src/Ignitor/index.d.ts +6 -0
  22. package/build/src/Ignitor/index.js +12 -1
  23. package/build/src/TestUtils/Ace/index.d.ts +0 -0
  24. package/build/src/TestUtils/Ace/index.js +8 -0
  25. package/build/src/TestUtils/HttpServer/index.d.ts +27 -0
  26. package/build/src/TestUtils/HttpServer/index.js +56 -0
  27. package/build/src/TestUtils/index.d.ts +24 -0
  28. package/build/src/TestUtils/index.js +43 -0
  29. package/build/src/utils/index.d.ts +13 -6
  30. package/build/src/utils/index.js +57 -10
  31. package/build/templates/contracts/env.txt +3 -3
  32. package/build/templates/env.txt +5 -5
  33. package/build/templates/tests/bootstrap.txt +71 -0
  34. package/package.json +89 -39
  35. package/README.html +0 -1160
  36. package/build/src/Ignitor/Ace/ErrorHandler/index.d.ts +0 -16
  37. package/build/src/Ignitor/Ace/ErrorHandler/index.js +0 -47
  38. package/build/src/Ignitor/HttpServer/ErrorHandler/index.d.ts +0 -16
  39. package/build/src/Ignitor/HttpServer/ErrorHandler/index.js +0 -44
@@ -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.registerTsHook = exports.isMissingModuleError = void 0;
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 (isMissingModuleError(error)) {
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;
@@ -18,7 +18,7 @@ declare module '@ioc:Adonis/Core/Env' {
18
18
  |
19
19
  */
20
20
 
21
- type CustomTypes = typeof import("../env").default;
22
- interface EnvTypes extends CustomTypes {
23
- }
21
+ type CustomTypes = typeof import('../env').default
22
+ interface EnvTypes extends CustomTypes {
23
+ }
24
24
  }
@@ -15,11 +15,11 @@
15
15
  import Env from '@ioc:Adonis/Core/Env'
16
16
 
17
17
  export default Env.rules({
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),
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,9 +1,12 @@
1
1
  {
2
2
  "name": "@adonisjs/core",
3
- "version": "5.4.0",
3
+ "version": "5.5.0",
4
4
  "description": "Core of AdonisJS",
5
5
  "exports": {
6
- ".": "./build/providers/AppProvider.js",
6
+ ".": {
7
+ "types": "./build/adonis-typings/index.d.ts",
8
+ "require": "./build/providers/AppProvider.js"
9
+ },
7
10
  "./standalone": "./build/standalone.js",
8
11
  "./Ignitor": "./build/src/Ignitor/index.js",
9
12
  "./commands": "./build/commands/index.js",
@@ -31,12 +34,12 @@
31
34
  "scripts": {
32
35
  "mrm": "mrm --preset=@adonisjs/mrm-preset",
33
36
  "pretest": "npm run lint",
34
- "test": "node japaFile.js",
37
+ "test": "node .bin/test.js",
35
38
  "clean": "del build",
36
39
  "compile": "npm run lint && npm run clean && tsc && copyfiles templates/**/* templates/* build",
37
40
  "build": "npm run compile",
38
41
  "commit": "git-cz",
39
- "release": "np",
42
+ "release": "np --message=\"chore(release): %s\"",
40
43
  "version": "npm run build",
41
44
  "prepublishOnly": "npm run build",
42
45
  "lint": "eslint . --ext=.ts",
@@ -60,35 +63,37 @@
60
63
  },
61
64
  "homepage": "https://github.com/adonisjs/core#readme",
62
65
  "devDependencies": {
63
- "@adonisjs/assembler": "^5.3.7",
64
- "@adonisjs/mrm-preset": "^4.1.2",
65
- "@adonisjs/repl": "^3.1.6",
66
- "@adonisjs/require-ts": "^2.0.8",
67
- "@adonisjs/sink": "^5.1.6",
68
- "@poppinss/dev-utils": "^1.1.5",
69
- "@types/node": "^16.10.3",
66
+ "@adonisjs/assembler": "^5.4.1",
67
+ "@adonisjs/mrm-preset": "^5.0.2",
68
+ "@adonisjs/repl": "^3.1.8",
69
+ "@adonisjs/require-ts": "^2.0.10",
70
+ "@adonisjs/sink": "^5.2.1",
71
+ "@poppinss/dev-utils": "^2.0.2",
72
+ "@types/node": "^17.0.21",
70
73
  "@types/supertest": "^2.0.11",
71
- "clear-module": "^4.1.1",
74
+ "clear-module": "^4.1.2",
75
+ "commitizen": "^4.2.4",
72
76
  "copyfiles": "^2.4.1",
77
+ "cz-conventional-changelog": "^3.3.0",
73
78
  "del-cli": "^4.0.1",
74
- "eslint": "^7.31.0",
75
- "eslint-config-prettier": "^8.3.0",
76
- "eslint-plugin-adonis": "^1.3.3",
79
+ "eslint": "^8.10.0",
80
+ "eslint-config-prettier": "^8.4.0",
81
+ "eslint-plugin-adonis": "^2.1.0",
77
82
  "eslint-plugin-prettier": "^4.0.0",
78
83
  "etag": "^1.8.1",
79
84
  "github-label-sync": "^2.0.2",
80
- "husky": "^7.0.2",
81
- "japa": "^3.1.1",
82
- "mrm": "^3.0.9",
83
- "np": "^7.5.0",
84
- "prettier": "^2.4.1",
85
+ "husky": "^7.0.4",
86
+ "japa": "^4.0.0",
87
+ "mrm": "^3.0.10",
88
+ "np": "^7.6.0",
89
+ "prettier": "^2.5.1",
85
90
  "reflect-metadata": "^0.1.13",
86
91
  "strip-ansi": "^6.0.0",
87
- "supertest": "^6.1.6",
92
+ "supertest": "^6.2.2",
88
93
  "test-console": "^2.0.0",
89
- "typescript": "^4.4.3",
90
- "youch": "^2.2.2",
91
- "youch-terminal": "^1.1.1"
94
+ "typescript": "^4.5.5",
95
+ "youch": "^3.1.1",
96
+ "youch-terminal": "^2.1.3"
92
97
  },
93
98
  "nyc": {
94
99
  "exclude": [
@@ -109,21 +114,22 @@
109
114
  }
110
115
  },
111
116
  "dependencies": {
112
- "@adonisjs/ace": "^11.0.4",
113
- "@adonisjs/application": "^5.1.7",
114
- "@adonisjs/bodyparser": "^8.0.1",
115
- "@adonisjs/drive": "^2.0.7",
116
- "@adonisjs/encryption": "^4.0.5",
117
- "@adonisjs/events": "^7.1.2",
118
- "@adonisjs/hash": "^7.0.8",
119
- "@adonisjs/http-server": "^5.5.7",
120
- "@adonisjs/validator": "^12.1.1",
121
- "@poppinss/cliui": "^2.2.5",
122
- "@poppinss/manager": "^4.0.4",
123
- "@poppinss/utils": "^3.3.0",
124
- "fs-extra": "^10.0.0",
125
- "memfs": "^3.3.0",
126
- "serve-static": "^1.14.1",
117
+ "@adonisjs/ace": "^11.0.6",
118
+ "@adonisjs/application": "^5.2.0",
119
+ "@adonisjs/bodyparser": "^8.1.0",
120
+ "@adonisjs/drive": "^2.0.9",
121
+ "@adonisjs/encryption": "^4.0.7",
122
+ "@adonisjs/events": "^7.1.3",
123
+ "@adonisjs/hash": "^7.0.10",
124
+ "@adonisjs/http-server": "^5.6.1",
125
+ "@adonisjs/validator": "^12.2.2",
126
+ "@poppinss/cliui": "^3.0.1",
127
+ "@poppinss/manager": "^5.0.1",
128
+ "@poppinss/utils": "^4.0.2",
129
+ "fs-extra": "^10.0.1",
130
+ "macroable": "^6.0.1",
131
+ "memfs": "^3.4.1",
132
+ "serve-static": "^1.14.2",
127
133
  "stringify-attributes": "^2.0.0"
128
134
  },
129
135
  "np": {
@@ -182,5 +188,49 @@
182
188
  "publishConfig": {
183
189
  "access": "public",
184
190
  "tag": "latest"
191
+ },
192
+ "mrmConfig": {
193
+ "core": true,
194
+ "license": "MIT",
195
+ "services": [
196
+ "github-actions"
197
+ ],
198
+ "minNodeVersion": "14.15.4",
199
+ "probotApps": [
200
+ "stale",
201
+ "lock"
202
+ ],
203
+ "runGhActionsOnWindows": true
204
+ },
205
+ "main": "build/index.js",
206
+ "eslintConfig": {
207
+ "extends": [
208
+ "plugin:adonis/typescriptPackage",
209
+ "prettier"
210
+ ],
211
+ "plugins": [
212
+ "prettier"
213
+ ],
214
+ "rules": {
215
+ "prettier/prettier": [
216
+ "error",
217
+ {
218
+ "endOfLine": "auto"
219
+ }
220
+ ]
221
+ }
222
+ },
223
+ "eslintIgnore": [
224
+ "build"
225
+ ],
226
+ "prettier": {
227
+ "trailingComma": "es5",
228
+ "semi": false,
229
+ "singleQuote": true,
230
+ "useTabs": false,
231
+ "quoteProps": "consistent",
232
+ "bracketSpacing": true,
233
+ "arrowParens": "always",
234
+ "printWidth": 100
185
235
  }
186
236
  }