@adonisjs/core 6.0.0-0 → 6.1.0-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/build/commands/commands.json +1 -1
- package/build/commands/configure.d.ts +17 -0
- package/build/commands/configure.js +105 -0
- package/build/factories/app.d.ts +1 -0
- package/build/factories/app.js +1 -0
- package/build/factories/bodyparser.d.ts +1 -0
- package/build/factories/bodyparser.js +1 -0
- package/build/factories/core/ace.d.ts +8 -0
- package/build/factories/core/ace.js +19 -0
- package/build/factories/core/ignitor.d.ts +16 -0
- package/build/factories/core/ignitor.js +76 -0
- package/build/factories/core/main.d.ts +4 -0
- package/build/factories/core/main.js +4 -0
- package/build/factories/core/test_utils.d.ts +8 -0
- package/build/factories/core/test_utils.js +15 -0
- package/build/factories/encryption.d.ts +1 -0
- package/build/factories/encryption.js +1 -0
- package/build/factories/events.d.ts +1 -0
- package/build/factories/events.js +1 -0
- package/build/factories/hash.d.ts +1 -0
- package/build/factories/hash.js +1 -0
- package/build/factories/http.d.ts +1 -0
- package/build/factories/http.js +1 -0
- package/build/factories/logger.d.ts +1 -0
- package/build/factories/logger.js +1 -0
- package/build/factories/stubs.d.ts +15 -0
- package/build/factories/stubs.js +20 -0
- package/build/modules/ace/commands.js +2 -1
- package/build/src/helpers/main.d.ts +1 -1
- package/build/src/helpers/main.js +1 -1
- package/package.json +12 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"commands":[{"commandName":"eject","description":"Eject scaffolding stubs to your application root","help":"","namespace":null,"aliases":[],"flags":[{"name":"pkg","flagName":"pkg","required":false,"type":"string","description":"Mention package name for searching stubs","default":"@adonisjs/core"}],"args":[{"name":"stubPath","argumentName":"stub-path","required":true,"description":"Path to the stubs directory or a single stub file","type":"string"}],"options":{},"filePath":"eject.js"},{"commandName":"generate:key","description":"Generate a secure random application key","help":"","namespace":"generate","aliases":[],"flags":[{"name":"show","flagName":"show","required":false,"type":"boolean","description":"Display the key on the terminal, instead of writing it to .env file"},{"name":"force","flagName":"force","required":false,"type":"boolean","description":"Force update .env file in production environment"}],"args":[],"options":{},"filePath":"generate_key.js"},{"commandName":"make:command","description":"Create a new ace command class","help":"","namespace":"make","aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the command","type":"string"}],"options":{"allowUnknownFlags":true},"filePath":"make/command.js"},{"commandName":"make:controller","description":"Create a new HTTP controller class","help":"","namespace":"make","aliases":[],"flags":[{"name":"singular","flagName":"singular","required":false,"type":"boolean","description":"Convert controller class and file name to its singular form","alias":"r"},{"name":"resource","flagName":"resource","required":false,"type":"boolean","description":"Generate controller with resource actions","alias":"r"},{"name":"api","flagName":"api","required":false,"type":"boolean","description":"Generate controller with api resource actions","alias":"a"}],"args":[{"name":"name","argumentName":"name","required":true,"description":"The name of the controller","type":"string"}],"options":{"allowUnknownFlags":true},"filePath":"make/controller.js"},{"commandName":"make:event","description":"Create a new event class","help":"","namespace":"make","aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the event","type":"string"}],"options":{"allowUnknownFlags":true},"filePath":"make/event.js"},{"commandName":"make:listener","description":"Create a new event listener class","help":"","namespace":"make","aliases":[],"flags":[{"name":"event","flagName":"event","required":false,"type":"string","description":"Generate an event class alongside the listener","alias":"e"}],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the listener","type":"string"}],"options":{"allowUnknownFlags":true},"filePath":"make/listener.js"},{"commandName":"make:middleware","description":"Create a new middleware class","help":"","namespace":"make","aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the middleware","type":"string"}],"options":{"allowUnknownFlags":true},"filePath":"make/middleware.js"},{"commandName":"make:provider","description":"Create a new service provider class","help":"","namespace":"make","aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the provider","type":"string"}],"options":{"allowUnknownFlags":true},"filePath":"make/provider.js"}],"version":1}
|
|
1
|
+
{"commands":[{"commandName":"configure","description":"Configure a package post installation","help":"","namespace":null,"aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Package name","type":"string"}],"options":{},"filePath":"configure.js"},{"commandName":"eject","description":"Eject scaffolding stubs to your application root","help":"","namespace":null,"aliases":[],"flags":[{"name":"pkg","flagName":"pkg","required":false,"type":"string","description":"Mention package name for searching stubs","default":"@adonisjs/core"}],"args":[{"name":"stubPath","argumentName":"stub-path","required":true,"description":"Path to the stubs directory or a single stub file","type":"string"}],"options":{},"filePath":"eject.js"},{"commandName":"generate:key","description":"Generate a secure random application key","help":"","namespace":"generate","aliases":[],"flags":[{"name":"show","flagName":"show","required":false,"type":"boolean","description":"Display the key on the terminal, instead of writing it to .env file"},{"name":"force","flagName":"force","required":false,"type":"boolean","description":"Force update .env file in production environment"}],"args":[],"options":{},"filePath":"generate_key.js"},{"commandName":"make:command","description":"Create a new ace command class","help":"","namespace":"make","aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the command","type":"string"}],"options":{"allowUnknownFlags":true},"filePath":"make/command.js"},{"commandName":"make:controller","description":"Create a new HTTP controller class","help":"","namespace":"make","aliases":[],"flags":[{"name":"singular","flagName":"singular","required":false,"type":"boolean","description":"Convert controller class and file name to its singular form","alias":"r"},{"name":"resource","flagName":"resource","required":false,"type":"boolean","description":"Generate controller with resource actions","alias":"r"},{"name":"api","flagName":"api","required":false,"type":"boolean","description":"Generate controller with api resource actions","alias":"a"}],"args":[{"name":"name","argumentName":"name","required":true,"description":"The name of the controller","type":"string"}],"options":{"allowUnknownFlags":true},"filePath":"make/controller.js"},{"commandName":"make:event","description":"Create a new event class","help":"","namespace":"make","aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the event","type":"string"}],"options":{"allowUnknownFlags":true},"filePath":"make/event.js"},{"commandName":"make:listener","description":"Create a new event listener class","help":"","namespace":"make","aliases":[],"flags":[{"name":"event","flagName":"event","required":false,"type":"string","description":"Generate an event class alongside the listener","alias":"e"}],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the listener","type":"string"}],"options":{"allowUnknownFlags":true},"filePath":"make/listener.js"},{"commandName":"make:middleware","description":"Create a new middleware class","help":"","namespace":"make","aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the middleware","type":"string"}],"options":{"allowUnknownFlags":true},"filePath":"make/middleware.js"},{"commandName":"make:provider","description":"Create a new service provider class","help":"","namespace":"make","aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the provider","type":"string"}],"options":{"allowUnknownFlags":true},"filePath":"make/provider.js"}],"version":1}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ApplicationService } from '../src/types.js';
|
|
2
|
+
import { BaseCommand } from '../modules/ace/main.js';
|
|
3
|
+
export default class Configure extends BaseCommand {
|
|
4
|
+
#private;
|
|
5
|
+
static commandName: string;
|
|
6
|
+
static description: string;
|
|
7
|
+
name: string;
|
|
8
|
+
stubsRoot: string;
|
|
9
|
+
publishStub(stubPath: string, stubData?: Record<string, any>): Promise<void>;
|
|
10
|
+
defineEnvVariables(environmentVariables: Record<string, number | string | boolean>): Promise<void>;
|
|
11
|
+
updateRcFile(callback: (rcFileEditor: ApplicationService['rcFileEditor']) => Promise<void> | void): Promise<void>;
|
|
12
|
+
listPackagesToInstall(packages: {
|
|
13
|
+
name: string;
|
|
14
|
+
isDevDependency: boolean;
|
|
15
|
+
}[]): void;
|
|
16
|
+
run(): Promise<void>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { slash } from '@poppinss/utils';
|
|
11
|
+
import { EnvEditor } from '../modules/env.js';
|
|
12
|
+
import { args, BaseCommand } from '../modules/ace/main.js';
|
|
13
|
+
export default class Configure extends BaseCommand {
|
|
14
|
+
static commandName = 'configure';
|
|
15
|
+
static description = 'Configure a package post installation';
|
|
16
|
+
#getPackageSource(packageName) {
|
|
17
|
+
return this.app.import(packageName);
|
|
18
|
+
}
|
|
19
|
+
#getInstallationCommands(packages, packageManager, isDev) {
|
|
20
|
+
if (!packages.length) {
|
|
21
|
+
return '';
|
|
22
|
+
}
|
|
23
|
+
const devFlag = isDev ? ' -D' : '';
|
|
24
|
+
switch (packageManager) {
|
|
25
|
+
case 'npm':
|
|
26
|
+
return `${this.colors.yellow(`npm i${devFlag}`)} ${packages.join(' ')}`;
|
|
27
|
+
case 'yarn':
|
|
28
|
+
return `${this.colors.yellow(`yarn add${devFlag}`)} ${packages.join(' ')}`;
|
|
29
|
+
case 'pnpm':
|
|
30
|
+
return `${this.colors.yellow(`pnpm add${devFlag}`)} ${packages.join(' ')}`;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
async publishStub(stubPath, stubData) {
|
|
34
|
+
const stub = await this.app.stubs.build(stubPath, {
|
|
35
|
+
source: this.stubsRoot,
|
|
36
|
+
});
|
|
37
|
+
const output = await stub.generate(stubData || {});
|
|
38
|
+
const entityFileName = slash(this.app.relativePath(output.destination));
|
|
39
|
+
if (output.status === 'skipped') {
|
|
40
|
+
return this.logger.action(`create ${entityFileName}`).skipped(output.skipReason);
|
|
41
|
+
}
|
|
42
|
+
this.logger.action(`create ${entityFileName}`).succeeded();
|
|
43
|
+
}
|
|
44
|
+
async defineEnvVariables(environmentVariables) {
|
|
45
|
+
const logs = [];
|
|
46
|
+
const editor = new EnvEditor(this.app.appRoot);
|
|
47
|
+
await editor.load();
|
|
48
|
+
Object.keys(environmentVariables).forEach((key) => {
|
|
49
|
+
const value = environmentVariables[key];
|
|
50
|
+
editor.add(key, value);
|
|
51
|
+
logs.push(` ${this.colors.dim(`${key}=${value}`)}`);
|
|
52
|
+
});
|
|
53
|
+
await editor.save();
|
|
54
|
+
this.logger.action('update .env file').succeeded();
|
|
55
|
+
this.logger.log(logs.join('\n'));
|
|
56
|
+
}
|
|
57
|
+
async updateRcFile(callback) {
|
|
58
|
+
await callback(this.app.rcFileEditor);
|
|
59
|
+
await this.app.rcFileEditor.save();
|
|
60
|
+
this.logger.action('update .adonisrc.json file').succeeded();
|
|
61
|
+
}
|
|
62
|
+
listPackagesToInstall(packages) {
|
|
63
|
+
const devDependencies = packages.filter((pkg) => pkg.isDevDependency).map(({ name }) => name);
|
|
64
|
+
const prodDependencies = packages.filter((pkg) => !pkg.isDevDependency).map(({ name }) => name);
|
|
65
|
+
const instructions = this.ui.sticker().heading('Please install following packages');
|
|
66
|
+
[
|
|
67
|
+
this.colors.dim('# npm'),
|
|
68
|
+
this.#getInstallationCommands(devDependencies, 'npm', true),
|
|
69
|
+
this.#getInstallationCommands(prodDependencies, 'npm', false),
|
|
70
|
+
' ',
|
|
71
|
+
]
|
|
72
|
+
.concat([
|
|
73
|
+
this.colors.dim('# yarn'),
|
|
74
|
+
this.#getInstallationCommands(devDependencies, 'yarn', true),
|
|
75
|
+
this.#getInstallationCommands(prodDependencies, 'yarn', false),
|
|
76
|
+
' ',
|
|
77
|
+
])
|
|
78
|
+
.concat([
|
|
79
|
+
this.colors.dim('# pnpm'),
|
|
80
|
+
this.#getInstallationCommands(devDependencies, 'pnpm', true),
|
|
81
|
+
this.#getInstallationCommands(prodDependencies, 'pnpm', false),
|
|
82
|
+
])
|
|
83
|
+
.filter((line) => line.length)
|
|
84
|
+
.forEach((line) => instructions.add(line));
|
|
85
|
+
instructions.render();
|
|
86
|
+
}
|
|
87
|
+
async run() {
|
|
88
|
+
const packageExports = await this.#getPackageSource(this.name);
|
|
89
|
+
if (!packageExports.configure) {
|
|
90
|
+
this.logger.warning(`Cannot configure "${this.name}" package. The package does not export the configure hook`);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (!packageExports.stubsRoot) {
|
|
94
|
+
this.logger.error(`Missing "stubsRoot" export from "${this.name}" package. The stubsRoot variable is required to lookup package stubs`);
|
|
95
|
+
this.exitCode = 1;
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
this.stubsRoot = packageExports.stubsRoot;
|
|
99
|
+
await packageExports.configure(this);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
__decorate([
|
|
103
|
+
args.string({ description: 'Package name' }),
|
|
104
|
+
__metadata("design:type", String)
|
|
105
|
+
], Configure.prototype, "name", void 0);
|
|
@@ -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,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
|
+
}
|
|
@@ -19,7 +19,8 @@ export class BaseCommand extends AceBaseCommand {
|
|
|
19
19
|
try {
|
|
20
20
|
this.prepare && (await this.app.container.call(this, 'prepare'));
|
|
21
21
|
this.interact && (await this.app.container.call(this, 'interact'));
|
|
22
|
-
|
|
22
|
+
const result = await this.app.container.call(this, 'run');
|
|
23
|
+
this.result = this.result === undefined ? result : this.result;
|
|
23
24
|
this.exitCode = this.exitCode ?? 0;
|
|
24
25
|
}
|
|
25
26
|
catch (error) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { default as cuid } from 'cuid';
|
|
2
|
-
export { safeEqual, compose, base64, fsImportAll, fsReadAll } from '@poppinss/utils';
|
|
2
|
+
export { safeEqual, compose, base64, fsImportAll, fsReadAll, slash } from '@poppinss/utils';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { default as cuid } from 'cuid';
|
|
2
|
-
export { safeEqual, compose, base64, fsImportAll, fsReadAll } from '@poppinss/utils';
|
|
2
|
+
export { safeEqual, compose, base64, fsImportAll, fsReadAll, slash } from '@poppinss/utils';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adonisjs/core",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.1.0-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,15 @@
|
|
|
19
20
|
"exports": {
|
|
20
21
|
".": "./build/index.js",
|
|
21
22
|
"./commands": "./build/commands/main.js",
|
|
23
|
+
"./commands/*": "./build/commands/*.js",
|
|
24
|
+
"./factories": "./build/factories/core/main.js",
|
|
25
|
+
"./factories/app": "./build/factories/app.js",
|
|
26
|
+
"./factories/bodyparser": "./build/factories/bodyparser.js",
|
|
27
|
+
"./factories/encryption": "./build/factories/encryption.js",
|
|
28
|
+
"./factories/events": "./build/factories/events.js",
|
|
29
|
+
"./factories/hash": "./build/factories/hash.js",
|
|
30
|
+
"./factories/http": "./build/factories/http.js",
|
|
31
|
+
"./factories/logger": "./build/factories/logger.js",
|
|
22
32
|
"./types": "./build/src/types.js",
|
|
23
33
|
"./types/ace": "./build/types/ace.js",
|
|
24
34
|
"./types/app": "./build/types/app.js",
|
|
@@ -221,7 +231,7 @@
|
|
|
221
231
|
"exclude": [
|
|
222
232
|
"tests/**",
|
|
223
233
|
"build/**",
|
|
224
|
-
"
|
|
234
|
+
"factories/**",
|
|
225
235
|
".yalc/**"
|
|
226
236
|
]
|
|
227
237
|
}
|