@adonisjs/core 6.0.1-0 → 6.1.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.
- 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/core/ignitor.js +3 -3
- 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 +2 -1
|
@@ -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);
|
|
@@ -13,9 +13,9 @@ export class IgnitorFactory {
|
|
|
13
13
|
}
|
|
14
14
|
#mergeCoreProviders(providers) {
|
|
15
15
|
return [
|
|
16
|
-
'
|
|
17
|
-
'
|
|
18
|
-
'
|
|
16
|
+
'@adonisjs/core/providers/app_provider',
|
|
17
|
+
'@adonisjs/core/providers/hash_provider',
|
|
18
|
+
'@adonisjs/core/providers/http_provider',
|
|
19
19
|
].concat(providers || []);
|
|
20
20
|
}
|
|
21
21
|
merge(params) {
|
|
@@ -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.1-0",
|
|
4
4
|
"description": "Core of AdonisJS",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"exports": {
|
|
21
21
|
".": "./build/index.js",
|
|
22
22
|
"./commands": "./build/commands/main.js",
|
|
23
|
+
"./commands/*": "./build/commands/*.js",
|
|
23
24
|
"./factories": "./build/factories/core/main.js",
|
|
24
25
|
"./factories/app": "./build/factories/app.js",
|
|
25
26
|
"./factories/bodyparser": "./build/factories/bodyparser.js",
|