@adonisjs/core 5.6.2 → 5.7.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.
@@ -1,3 +1,4 @@
1
+ /// <reference types="@adonisjs/http-server/build/adonis-typings" />
1
2
  declare module '@ioc:Adonis/Core/Cors' {
2
3
  import { RequestContract } from '@ioc:Adonis/Core/Request';
3
4
  import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext';
@@ -1,4 +1,5 @@
1
1
  /// <reference types="@adonisjs/logger/build/adonis-typings/logger" />
2
+ /// <reference types="@adonisjs/http-server/build/adonis-typings" />
2
3
  /**
3
4
  * The binding for the given module is defined inside `providers/AppProvider.ts`
4
5
  * file.
@@ -1,3 +1,4 @@
1
+ /// <reference types="@adonisjs/http-server/build/adonis-typings" />
1
2
  import { BaseCommand } from '@adonisjs/ace';
2
3
  import type { RouteNode } from '@ioc:Adonis/Core/Route';
3
4
  /**
@@ -69,6 +69,7 @@ async function instructions(projectRoot, _, { logger, files }) {
69
69
  * Create env.ts file for performing environment variable validations
70
70
  */
71
71
  const envTsFile = new files.MustacheFile(projectRoot, 'env.ts', ENV_VALIDATIONS_TEMPLATE_STUB);
72
+ envTsFile.apply({ assetsManager });
72
73
  if (envTsFile.exists()) {
73
74
  logger.action('create').skipped('env.ts');
74
75
  }
@@ -0,0 +1,37 @@
1
+ import { ApplicationContract } from '@ioc:Adonis/Core/Application';
2
+ import { AssetsDriverContract } from '@ioc:Adonis/Core/AssetsManager';
3
+ /**
4
+ * Fake driver stubs out the implementation of the Assets
5
+ * manager with empty return data.
6
+ *
7
+ * The main use case is to make assets manager work during
8
+ * testing without compiling the real assets
9
+ */
10
+ export declare class FakeDriver implements AssetsDriverContract {
11
+ private application;
12
+ name: string;
13
+ hasEntrypoints: boolean;
14
+ publicPath: string;
15
+ get version(): string;
16
+ constructor(application: ApplicationContract);
17
+ /**
18
+ * Returns the manifest contents as object
19
+ */
20
+ manifest(): {};
21
+ /**
22
+ * Returns path to a given asset file
23
+ */
24
+ assetPath(name: string): string;
25
+ /**
26
+ * Returns the entrypoints contents as object
27
+ */
28
+ entryPoints(): {};
29
+ /**
30
+ * Returns list for all the javascript files for a given entry point
31
+ */
32
+ entryPointJsFiles(_: string): string[];
33
+ /**
34
+ * Returns list for all the css files for a given entry point
35
+ */
36
+ entryPointCssFiles(_: string): string[];
37
+ }
@@ -0,0 +1,60 @@
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.FakeDriver = void 0;
12
+ /**
13
+ * Fake driver stubs out the implementation of the Assets
14
+ * manager with empty return data.
15
+ *
16
+ * The main use case is to make assets manager work during
17
+ * testing without compiling the real assets
18
+ */
19
+ class FakeDriver {
20
+ constructor(application) {
21
+ this.application = application;
22
+ this.name = 'fake';
23
+ this.hasEntrypoints = true;
24
+ this.publicPath = this.application.publicPath('assets');
25
+ }
26
+ get version() {
27
+ return '';
28
+ }
29
+ /**
30
+ * Returns the manifest contents as object
31
+ */
32
+ manifest() {
33
+ return {};
34
+ }
35
+ /**
36
+ * Returns path to a given asset file
37
+ */
38
+ assetPath(name) {
39
+ return `__fake('${name}')`;
40
+ }
41
+ /**
42
+ * Returns the entrypoints contents as object
43
+ */
44
+ entryPoints() {
45
+ return {};
46
+ }
47
+ /**
48
+ * Returns list for all the javascript files for a given entry point
49
+ */
50
+ entryPointJsFiles(_) {
51
+ return [];
52
+ }
53
+ /**
54
+ * Returns list for all the css files for a given entry point
55
+ */
56
+ entryPointCssFiles(_) {
57
+ return [];
58
+ }
59
+ }
60
+ exports.FakeDriver = FakeDriver;
@@ -14,6 +14,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.AssetsManager = void 0;
15
15
  const utils_1 = require("@poppinss/utils");
16
16
  const stringify_attributes_1 = __importDefault(require("stringify-attributes"));
17
+ const Fake_1 = require("./Drivers/Fake");
17
18
  const Encore_1 = require("./Drivers/Encore");
18
19
  /**
19
20
  * Assets manager exposes the API to make link and HTML fragments
@@ -28,6 +29,7 @@ class AssetsManager {
28
29
  this.application = application;
29
30
  this.drivers = {
30
31
  encore: () => new Encore_1.EncoreDriver(this.application),
32
+ fake: () => new Fake_1.FakeDriver(this.application),
31
33
  };
32
34
  this.booted = false;
33
35
  }
@@ -1,3 +1,4 @@
1
+ /// <reference types="@adonisjs/http-server/build/adonis-typings" />
1
2
  import { ContainerBindings } from '@ioc:Adonis/Core/Application';
2
3
  import { CookieClientContract } from '@ioc:Adonis/Core/CookieClient';
3
4
  /**
@@ -1,3 +1,4 @@
1
+ /// <reference types="@adonisjs/http-server/build/adonis-typings" />
1
2
  import { CorsConfig } from '@ioc:Adonis/Core/Cors';
2
3
  import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext';
3
4
  /**
@@ -1,3 +1,4 @@
1
+ /// <reference types="@adonisjs/http-server/build/adonis-typings" />
1
2
  import { AssetsConfig } from '@ioc:Adonis/Core/Static';
2
3
  import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext';
3
4
  /**
@@ -1,4 +1,5 @@
1
1
  /// <reference types="@adonisjs/logger/build/adonis-typings/logger" />
2
+ /// <reference types="@adonisjs/http-server/build/adonis-typings" />
2
3
  import { LoggerContract } from '@ioc:Adonis/Core/Logger';
3
4
  import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext';
4
5
  /**
@@ -163,6 +163,13 @@ class HttpExceptionHandler {
163
163
  if (typeof error.handle === 'function') {
164
164
  return error.handle(error, ctx);
165
165
  }
166
+ /**
167
+ * Send stack in the response when in test environment and
168
+ * there is a fatal error.
169
+ */
170
+ if (error.status >= 500 && error.stack && process.env.NODE_ENV === 'test') {
171
+ return ctx.response.status(error.status).send(error.stack);
172
+ }
166
173
  /**
167
174
  * Attempt to find the best error reporter for validation
168
175
  */
@@ -1,3 +1,4 @@
1
+ /// <reference types="@adonisjs/http-server/build/adonis-typings" />
1
2
  import { Kernel } from '@adonisjs/ace';
2
3
  import { ServerContract } from '@ioc:Adonis/Core/Server';
3
4
  import { CustomServerCallback } from '@ioc:Adonis/Core/TestUtils';
@@ -261,7 +261,7 @@ export const assets: AssetsManagerConfig = {
261
261
  | in the future
262
262
  |
263
263
  */
264
- driver: 'encore',
264
+ driver: Env.get('ASSETS_DRIVER'),
265
265
 
266
266
  /*
267
267
  |--------------------------------------------------------------------------
@@ -25,4 +25,7 @@ export default Env.rules({
25
25
  * you have defined inside the "contracts/drive.ts" file.
26
26
  */
27
27
  DRIVE_DISK: Env.schema.enum(['local', 's3', 'gcs'] as const),
28
+ {{#assetsManager}}
29
+ ASSETS_DRIVER: Env.schema.enum(['fake', 'encore'] as const),
30
+ {{/assetsManager}}
28
31
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adonisjs/core",
3
- "version": "5.6.2",
3
+ "version": "5.7.0",
4
4
  "description": "Core of AdonisJS",
5
5
  "exports": {
6
6
  ".": {
@@ -65,15 +65,15 @@
65
65
  "devDependencies": {
66
66
  "@adonisjs/assembler": "^5.4.2",
67
67
  "@adonisjs/mrm-preset": "^5.0.3",
68
- "@adonisjs/repl": "^3.1.9",
69
- "@adonisjs/require-ts": "^2.0.10",
68
+ "@adonisjs/repl": "^3.1.10",
69
+ "@adonisjs/require-ts": "^2.0.11",
70
70
  "@adonisjs/sink": "^5.2.2",
71
- "@japa/assert": "^1.3.2",
72
- "@japa/preset-adonis": "^1.0.8",
73
- "@japa/run-failed-tests": "^1.0.6",
74
- "@japa/runner": "^2.0.5",
75
- "@japa/spec-reporter": "^1.1.11",
76
- "@poppinss/dev-utils": "^2.0.2",
71
+ "@japa/assert": "^1.3.3",
72
+ "@japa/preset-adonis": "^1.0.12",
73
+ "@japa/run-failed-tests": "^1.0.7",
74
+ "@japa/runner": "^2.0.6",
75
+ "@japa/spec-reporter": "^1.1.12",
76
+ "@poppinss/dev-utils": "^2.0.3",
77
77
  "@types/node": "^17.0.23",
78
78
  "@types/supertest": "^2.0.12",
79
79
  "clear-module": "^4.1.2",
@@ -86,11 +86,11 @@
86
86
  "eslint-plugin-adonis": "^2.1.0",
87
87
  "eslint-plugin-prettier": "^4.0.0",
88
88
  "etag": "^1.8.1",
89
- "github-label-sync": "^2.0.2",
89
+ "github-label-sync": "^2.2.0",
90
90
  "husky": "^7.0.4",
91
91
  "mrm": "^4.0.0",
92
92
  "np": "^7.6.1",
93
- "prettier": "^2.6.1",
93
+ "prettier": "^2.6.2",
94
94
  "reflect-metadata": "^0.1.13",
95
95
  "strip-ansi": "^6.0.1",
96
96
  "supertest": "^6.2.2",
@@ -118,20 +118,20 @@
118
118
  }
119
119
  },
120
120
  "dependencies": {
121
- "@adonisjs/ace": "^11.2.2",
122
- "@adonisjs/application": "^5.2.0",
123
- "@adonisjs/bodyparser": "^8.1.1",
124
- "@adonisjs/drive": "^2.0.10",
125
- "@adonisjs/encryption": "^4.0.7",
126
- "@adonisjs/events": "^7.1.3",
127
- "@adonisjs/hash": "^7.0.10",
128
- "@adonisjs/http-server": "^5.7.3",
129
- "@adonisjs/validator": "^12.2.3",
130
- "@poppinss/cliui": "^3.0.1",
131
- "@poppinss/manager": "^5.0.1",
132
- "@poppinss/utils": "^4.0.2",
121
+ "@adonisjs/ace": "^11.2.3",
122
+ "@adonisjs/application": "^5.2.1",
123
+ "@adonisjs/bodyparser": "^8.1.2",
124
+ "@adonisjs/drive": "^2.1.0",
125
+ "@adonisjs/encryption": "^4.0.8",
126
+ "@adonisjs/events": "^7.2.0",
127
+ "@adonisjs/hash": "^7.0.11",
128
+ "@adonisjs/http-server": "^5.7.4",
129
+ "@adonisjs/validator": "^12.3.0",
130
+ "@poppinss/cliui": "^3.0.2",
131
+ "@poppinss/manager": "^5.0.2",
132
+ "@poppinss/utils": "^4.0.3",
133
133
  "fs-extra": "^10.0.1",
134
- "macroable": "^7.0.0",
134
+ "macroable": "^7.0.1",
135
135
  "memfs": "^3.4.1",
136
136
  "serve-static": "^1.15.0",
137
137
  "stringify-attributes": "^2.0.0"
@@ -1,16 +0,0 @@
1
- /**
2
- * Contract source: https://github.com/adonisjs/core/blob/master/templates/contracts/tests.txt
3
- *
4
- * Feel free to let us know via PR, if you find something broken in this contract
5
- * file.
6
- */
7
-
8
- import '@japa/runner'
9
-
10
- declare module '@japa/runner' {
11
- interface TestContext {
12
- }
13
-
14
- interface Test<DataSet> {
15
- }
16
- }
@@ -1,69 +0,0 @@
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 type { Config } from '@japa/runner'
9
- import TestUtils from '@ioc:Adonis/Core/TestUtils'
10
- import { assert, runFailedTests, specReporter } from '@japa/preset-adonis'
11
-
12
- /*
13
- |--------------------------------------------------------------------------
14
- | Japa Plugins
15
- |--------------------------------------------------------------------------
16
- |
17
- | Japa plugins allows you to add additional features to Japa. By default
18
- | we register the assertion plugin.
19
- |
20
- | Feel free to remove existing plugins or add more.
21
- |
22
- */
23
- export const plugins: Config['plugins'] = [assert(), runFailedTests()]
24
-
25
- /*
26
- |--------------------------------------------------------------------------
27
- | Japa Reporters
28
- |--------------------------------------------------------------------------
29
- |
30
- | Japa reporters displays/saves the progress of tests as they are executed.
31
- | By default, we register the spec reporter to show a detailed report
32
- | of tests on the terminal.
33
- |
34
- */
35
- export const reporters: Config['reporters'] = [specReporter()]
36
-
37
- /*
38
- |--------------------------------------------------------------------------
39
- | Runner hooks
40
- |--------------------------------------------------------------------------
41
- |
42
- | Runner hooks are executed after booting the AdonisJS app and
43
- | before the test files are imported.
44
- |
45
- | You can perform actions like starting the HTTP server or running migrations
46
- | within the runner hooks
47
- |
48
- */
49
- export const runnerHooks: Required<Pick<Config, 'setup' | 'teardown'>> = {
50
- setup: [() => TestUtils.ace().loadCommands(), () => TestUtils.db().migrate()],
51
- teardown: [],
52
- }
53
-
54
- /*
55
- |--------------------------------------------------------------------------
56
- | Configure individual suites
57
- |--------------------------------------------------------------------------
58
- |
59
- | The configureSuite method gets called for every test suite registered
60
- | within ".adonisrc.json" file.
61
- |
62
- | You can use this method to configure suites. For example: Only start
63
- | the HTTP server when it is a functional suite.
64
- */
65
- export const configureSuite: Config['configureSuite'] = (suite) => {
66
- if (suite.name === 'functional') {
67
- suite.setup(() => TestUtils.httpServer().start())
68
- }
69
- }
@@ -1,44 +0,0 @@
1
- /*
2
- |--------------------------------------------------------------------------
3
- | Tests
4
- |--------------------------------------------------------------------------
5
- |
6
- | The contents in this file boots the AdonisJS application and configures
7
- | the Japa tests runner.
8
- |
9
- | For the most part you will never edit this file. The configuration
10
- | for the tests can be controlled via ".adonisrc.json" and
11
- | "tests/bootstrap.ts" files.
12
- |
13
- */
14
-
15
- process.env.NODE_ENV = 'testing'
16
-
17
- import 'reflect-metadata'
18
- import sourceMapSupport from 'source-map-support'
19
- import { Ignitor } from '@adonisjs/core/build/standalone'
20
- import { configure, processCliArgs, run, RunnerHooksHandler } from '@japa/runner'
21
-
22
- sourceMapSupport.install({ handleUncaughtExceptions: false })
23
-
24
- const kernel = new Ignitor(__dirname).kernel('test')
25
-
26
- kernel
27
- .boot()
28
- .then(() => import('./tests/bootstrap'))
29
- .then(({ runnerHooks, ...config }) => {
30
- const app: RunnerHooksHandler[] = [() => kernel.start()]
31
-
32
- configure({
33
- ...kernel.application.rcFile.tests,
34
- ...processCliArgs(process.argv.slice(2)),
35
- ...config,
36
- ...{
37
- importer: (filePath) => import(filePath),
38
- setup: app.concat(runnerHooks.setup),
39
- teardown: runnerHooks.teardown,
40
- },
41
- })
42
-
43
- run()
44
- })