@adonisjs/core 6.0.0-0 → 6.0.1-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.
@@ -0,0 +1 @@
1
+ export * from '@adonisjs/application/factories';
@@ -0,0 +1 @@
1
+ export * from '@adonisjs/application/factories';
@@ -0,0 +1 @@
1
+ export * from '@adonisjs/bodyparser/factories';
@@ -0,0 +1 @@
1
+ export * from '@adonisjs/bodyparser/factories';
@@ -0,0 +1,8 @@
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ import { Ignitor } from '../../src/ignitor/main.js';
3
+ import type { IgnitorOptions } from '../../src/types.js';
4
+ import type { Kernel } from '../../modules/ace/kernel.js';
5
+ export declare class AceFactory {
6
+ make(ignitor: Ignitor): Promise<Kernel>;
7
+ make(appRoot: URL, options: IgnitorOptions): Promise<Kernel>;
8
+ }
@@ -0,0 +1,19 @@
1
+ import { IgnitorFactory } from './ignitor.js';
2
+ import { Ignitor } from '../../src/ignitor/main.js';
3
+ import { createAceKernel } from '../../modules/ace/create_kernel.js';
4
+ export class AceFactory {
5
+ async make(ignitorOrAppRoot, options) {
6
+ if (ignitorOrAppRoot instanceof Ignitor) {
7
+ const app = ignitorOrAppRoot.createApp('console');
8
+ await app.init();
9
+ return createAceKernel(app);
10
+ }
11
+ const app = new IgnitorFactory()
12
+ .withCoreConfig()
13
+ .withCoreProviders()
14
+ .create(ignitorOrAppRoot, options)
15
+ .createApp('console');
16
+ await app.init();
17
+ return createAceKernel(app);
18
+ }
19
+ }
@@ -0,0 +1,16 @@
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ import { Ignitor } from '../../src/ignitor/main.js';
3
+ import type { ApplicationService, IgnitorOptions } from '../../src/types.js';
4
+ type FactoryParameters = {
5
+ rcFileContents: Record<string, any>;
6
+ config: Record<string, any>;
7
+ };
8
+ export declare class IgnitorFactory {
9
+ #private;
10
+ preload(action: (app: ApplicationService) => void | Promise<void>): this;
11
+ merge(params: Partial<FactoryParameters>): this;
12
+ withCoreProviders(): this;
13
+ withCoreConfig(): this;
14
+ create(appRoot: URL, options: IgnitorOptions): Ignitor;
15
+ }
16
+ export {};
@@ -0,0 +1,76 @@
1
+ import { Ignitor } from '../../src/ignitor/main.js';
2
+ import { defineConfig as defineHttpConfig } from '../../modules/http.js';
3
+ import { defineConfig as defineLoggerConfig } from '../../modules/logger.js';
4
+ import { defineConfig as defineHashConfig } from '../../modules/hash/main.js';
5
+ import { defineConfig as defineBodyParserConfig } from '../../modules/bodyparser/main.js';
6
+ export class IgnitorFactory {
7
+ #preloadActions = [];
8
+ #parameters = {};
9
+ #loadCoreProviders = false;
10
+ preload(action) {
11
+ this.#preloadActions.push(action);
12
+ return this;
13
+ }
14
+ #mergeCoreProviders(providers) {
15
+ return [
16
+ './providers/app_provider.js',
17
+ './providers/hash_provider.js',
18
+ './providers/http_provider.js',
19
+ ].concat(providers || []);
20
+ }
21
+ merge(params) {
22
+ if (params.config) {
23
+ this.#parameters.config = Object.assign(this.#parameters.config || {}, params.config);
24
+ }
25
+ if (params.rcFileContents) {
26
+ this.#parameters.rcFileContents = Object.assign(this.#parameters.rcFileContents || {}, params.rcFileContents);
27
+ }
28
+ return this;
29
+ }
30
+ withCoreProviders() {
31
+ this.#loadCoreProviders = true;
32
+ return this;
33
+ }
34
+ withCoreConfig() {
35
+ this.merge({
36
+ config: {
37
+ app: {
38
+ appKey: 'averylongrandomsecretkey',
39
+ http: defineHttpConfig({}),
40
+ },
41
+ validator: {},
42
+ bodyparser: defineBodyParserConfig({}),
43
+ hash: defineHashConfig({
44
+ default: 'scrypt',
45
+ list: {
46
+ scrypt: {
47
+ driver: 'scrypt',
48
+ },
49
+ },
50
+ }),
51
+ logger: defineLoggerConfig({
52
+ default: 'app',
53
+ loggers: {
54
+ app: {},
55
+ },
56
+ }),
57
+ },
58
+ });
59
+ return this;
60
+ }
61
+ create(appRoot, options) {
62
+ return new Ignitor(appRoot, options).tap((app) => {
63
+ app.booted(async () => {
64
+ for (let action of this.#preloadActions) {
65
+ await action(app);
66
+ }
67
+ });
68
+ if (this.#loadCoreProviders) {
69
+ this.#parameters.rcFileContents = this.#parameters.rcFileContents || {};
70
+ this.#parameters.rcFileContents.providers = this.#mergeCoreProviders(this.#parameters.rcFileContents.providers);
71
+ }
72
+ this.#parameters.rcFileContents && app.rcContents(this.#parameters.rcFileContents);
73
+ this.#parameters.config && app.useConfig(this.#parameters.config);
74
+ });
75
+ }
76
+ }
@@ -0,0 +1,4 @@
1
+ export { AceFactory } from './ace.js';
2
+ export { StubsFactory } from '../stubs.js';
3
+ export { IgnitorFactory } from './ignitor.js';
4
+ export { TestUtilsFactory } from './test_utils.js';
@@ -0,0 +1,4 @@
1
+ export { AceFactory } from './ace.js';
2
+ export { StubsFactory } from '../stubs.js';
3
+ export { IgnitorFactory } from './ignitor.js';
4
+ export { TestUtilsFactory } from './test_utils.js';
@@ -0,0 +1,8 @@
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ import { Ignitor } from '../../index.js';
3
+ import type { IgnitorOptions } from '../../src/types.js';
4
+ import { TestUtils } from '../../src/test_utils/main.js';
5
+ export declare class TestUtilsFactory {
6
+ create(ignitor: Ignitor): TestUtils;
7
+ create(appRoot: URL, options: IgnitorOptions): TestUtils;
8
+ }
@@ -0,0 +1,15 @@
1
+ import { Ignitor } from '../../index.js';
2
+ import { IgnitorFactory } from './ignitor.js';
3
+ import { TestUtils } from '../../src/test_utils/main.js';
4
+ export class TestUtilsFactory {
5
+ create(ignitorOrAppRoot, options) {
6
+ if (ignitorOrAppRoot instanceof Ignitor) {
7
+ return new TestUtils(ignitorOrAppRoot.createApp('test'));
8
+ }
9
+ return new TestUtils(new IgnitorFactory()
10
+ .withCoreConfig()
11
+ .withCoreProviders()
12
+ .create(ignitorOrAppRoot, options)
13
+ .createApp('console'));
14
+ }
15
+ }
@@ -0,0 +1 @@
1
+ export * from '@adonisjs/encryption/factories';
@@ -0,0 +1 @@
1
+ export * from '@adonisjs/encryption/factories';
@@ -0,0 +1 @@
1
+ export * from '@adonisjs/events/factories';
@@ -0,0 +1 @@
1
+ export * from '@adonisjs/events/factories';
@@ -0,0 +1 @@
1
+ export * from '@adonisjs/hash/factories';
@@ -0,0 +1 @@
1
+ export * from '@adonisjs/hash/factories';
@@ -0,0 +1 @@
1
+ export * from '@adonisjs/http-server/factories';
@@ -0,0 +1 @@
1
+ export * from '@adonisjs/http-server/factories';
@@ -0,0 +1 @@
1
+ export * from '@adonisjs/logger/factories';
@@ -0,0 +1 @@
1
+ export * from '@adonisjs/logger/factories';
@@ -0,0 +1,15 @@
1
+ import type { ApplicationService } from '../src/types.js';
2
+ type FactoryParameters = {
3
+ app: ApplicationService;
4
+ };
5
+ export declare class StubsFactory {
6
+ #private;
7
+ merge(params: Partial<FactoryParameters>): this;
8
+ prepare(stubPath: string, data: Record<string, any>): Promise<{
9
+ contents: any;
10
+ destination: any;
11
+ force: any;
12
+ attributes: any;
13
+ }>;
14
+ }
15
+ export {};
@@ -0,0 +1,20 @@
1
+ import { AppFactory } from '@adonisjs/application/factories';
2
+ import { stubsRoot } from '../index.js';
3
+ export class StubsFactory {
4
+ #parameters = {};
5
+ #getApp() {
6
+ return this.#parameters.app || new AppFactory().create(new URL('./', import.meta.url), () => { });
7
+ }
8
+ merge(params) {
9
+ this.#parameters = Object.assign(this.#parameters, params);
10
+ return this;
11
+ }
12
+ async prepare(stubPath, data) {
13
+ const app = this.#getApp();
14
+ await app.init();
15
+ const stub = await app.stubs.build(stubPath, {
16
+ source: stubsRoot,
17
+ });
18
+ return stub.prepare(data);
19
+ }
20
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adonisjs/core",
3
- "version": "6.0.0-0",
3
+ "version": "6.0.1-0",
4
4
  "description": "Core of AdonisJS",
5
5
  "main": "build/index.js",
6
6
  "type": "module",
@@ -10,6 +10,7 @@
10
10
  "build/legacy",
11
11
  "build/providers",
12
12
  "build/services",
13
+ "build/factories",
13
14
  "build/types",
14
15
  "build/src",
15
16
  "build/stubs",
@@ -19,6 +20,14 @@
19
20
  "exports": {
20
21
  ".": "./build/index.js",
21
22
  "./commands": "./build/commands/main.js",
23
+ "./factories": "./build/factories/core/main.js",
24
+ "./factories/app": "./build/factories/app.js",
25
+ "./factories/bodyparser": "./build/factories/bodyparser.js",
26
+ "./factories/encryption": "./build/factories/encryption.js",
27
+ "./factories/events": "./build/factories/events.js",
28
+ "./factories/hash": "./build/factories/hash.js",
29
+ "./factories/http": "./build/factories/http.js",
30
+ "./factories/logger": "./build/factories/logger.js",
22
31
  "./types": "./build/src/types.js",
23
32
  "./types/ace": "./build/types/ace.js",
24
33
  "./types/app": "./build/types/app.js",
@@ -221,7 +230,7 @@
221
230
  "exclude": [
222
231
  "tests/**",
223
232
  "build/**",
224
- "test_factories/**",
233
+ "factories/**",
225
234
  ".yalc/**"
226
235
  ]
227
236
  }