@adonisjs/core 6.1.5-16 → 6.1.5-18
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/configure.d.ts +11 -2
- package/build/commands/configure.js +71 -10
- package/build/commands/main.d.ts +4 -0
- package/build/modules/http/request_validator.d.ts +4 -4
- package/build/providers/edge_provider.js +1 -1
- package/build/providers/vinejs_provider.d.ts +2 -7
- package/build/providers/vinejs_provider.js +2 -11
- package/build/src/bindings/vinejs.d.ts +8 -8
- package/package.json +4 -4
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { AddMiddlewareEntry, EnvValidationDefinition } from '@adonisjs/assembler/types';
|
|
2
|
+
import type { CodeTransformer } from '@adonisjs/assembler/code_transformer';
|
|
1
3
|
import { BaseCommand } from '../modules/ace/main.js';
|
|
2
|
-
import { RcFileEditor } from '@adonisjs/application/rc_file_editor';
|
|
3
4
|
/**
|
|
4
5
|
* The configure command is used to configure packages after installation
|
|
5
6
|
*/
|
|
@@ -22,10 +23,18 @@ export default class Configure extends BaseCommand {
|
|
|
22
23
|
* Define one or more environment variables
|
|
23
24
|
*/
|
|
24
25
|
defineEnvVariables(environmentVariables: Record<string, number | string | boolean>): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Define validations for the environment variables
|
|
28
|
+
*/
|
|
29
|
+
defineEnvValidations(validations: EnvValidationDefinition): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Define validations for the environment variables
|
|
32
|
+
*/
|
|
33
|
+
registerMiddleware(stack: 'server' | 'router' | 'named', middleware: AddMiddlewareEntry[]): Promise<void>;
|
|
25
34
|
/**
|
|
26
35
|
* Update rcFile
|
|
27
36
|
*/
|
|
28
|
-
updateRcFile(
|
|
37
|
+
updateRcFile(...params: Parameters<CodeTransformer['updateRcFile']>): Promise<void>;
|
|
29
38
|
/**
|
|
30
39
|
* Install packages using the correct package manager
|
|
31
40
|
* You can specify version of each package by setting it in the
|
|
@@ -13,16 +13,24 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
13
13
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
14
14
|
};
|
|
15
15
|
import { slash } from '@poppinss/utils';
|
|
16
|
-
import { installPackage, detectPackageManager } from '@antfu/install-pkg';
|
|
17
16
|
import { EnvEditor } from '@adonisjs/env/editor';
|
|
17
|
+
import { installPackage, detectPackageManager } from '@antfu/install-pkg';
|
|
18
18
|
import { args, BaseCommand, flags } from '../modules/ace/main.js';
|
|
19
|
-
import { RcFileEditor } from '@adonisjs/application/rc_file_editor';
|
|
20
19
|
/**
|
|
21
20
|
* The configure command is used to configure packages after installation
|
|
22
21
|
*/
|
|
23
22
|
export default class Configure extends BaseCommand {
|
|
24
23
|
static commandName = 'configure';
|
|
25
24
|
static description = 'Configure a package post installation';
|
|
25
|
+
/**
|
|
26
|
+
* Flag to know if assembler is installed as a
|
|
27
|
+
* peer dependency or not.
|
|
28
|
+
*/
|
|
29
|
+
#isAssemblerInstalled;
|
|
30
|
+
/**
|
|
31
|
+
* Reference to lazily imported assembler code transformer
|
|
32
|
+
*/
|
|
33
|
+
#codeTransformer;
|
|
26
34
|
/**
|
|
27
35
|
* Returns the package main exports
|
|
28
36
|
*/
|
|
@@ -47,6 +55,15 @@ export default class Configure extends BaseCommand {
|
|
|
47
55
|
return `${this.colors.yellow(`pnpm add${devFlag}`)} ${packages.join(' ')}`;
|
|
48
56
|
}
|
|
49
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Lazily installs assembler
|
|
60
|
+
*/
|
|
61
|
+
async #installAssembler() {
|
|
62
|
+
if (this.#isAssemblerInstalled === undefined) {
|
|
63
|
+
this.#codeTransformer = await import('@adonisjs/assembler/code_transformer');
|
|
64
|
+
this.#isAssemblerInstalled = !!this.#codeTransformer;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
50
67
|
/**
|
|
51
68
|
* Publish a stub file to the user project
|
|
52
69
|
*/
|
|
@@ -69,26 +86,70 @@ export default class Configure extends BaseCommand {
|
|
|
69
86
|
* Define one or more environment variables
|
|
70
87
|
*/
|
|
71
88
|
async defineEnvVariables(environmentVariables) {
|
|
72
|
-
const logs = [];
|
|
73
89
|
const editor = new EnvEditor(this.app.appRoot);
|
|
74
90
|
await editor.load();
|
|
75
91
|
Object.keys(environmentVariables).forEach((key) => {
|
|
76
92
|
const value = environmentVariables[key];
|
|
77
93
|
editor.add(key, value);
|
|
78
|
-
logs.push(` ${this.colors.dim(`${key}=${value}`)}`);
|
|
79
94
|
});
|
|
80
95
|
await editor.save();
|
|
81
96
|
this.logger.action('update .env file').succeeded();
|
|
82
|
-
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Define validations for the environment variables
|
|
100
|
+
*/
|
|
101
|
+
async defineEnvValidations(validations) {
|
|
102
|
+
await this.#installAssembler();
|
|
103
|
+
if (!this.#codeTransformer) {
|
|
104
|
+
this.logger.warning('Cannot update "start/env.ts" file. Install "@adonisjs/assembler" to modify source files');
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const transformer = new this.#codeTransformer.CodeTransformer(this.app.appRoot);
|
|
108
|
+
const action = this.logger.action('update start/env.ts file');
|
|
109
|
+
try {
|
|
110
|
+
await transformer.defineEnvValidations(validations);
|
|
111
|
+
action.succeeded();
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
action.failed(error.message);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Define validations for the environment variables
|
|
119
|
+
*/
|
|
120
|
+
async registerMiddleware(stack, middleware) {
|
|
121
|
+
await this.#installAssembler();
|
|
122
|
+
if (!this.#codeTransformer) {
|
|
123
|
+
this.logger.warning('Cannot update "start/kernel.ts" file. Install "@adonisjs/assembler" to modify source files');
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
const transformer = new this.#codeTransformer.CodeTransformer(this.app.appRoot);
|
|
127
|
+
const action = this.logger.action('update start/kernel.ts file');
|
|
128
|
+
try {
|
|
129
|
+
await transformer.addMiddlewareToStack(stack, middleware);
|
|
130
|
+
action.succeeded();
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
action.failed(error.message);
|
|
134
|
+
}
|
|
83
135
|
}
|
|
84
136
|
/**
|
|
85
137
|
* Update rcFile
|
|
86
138
|
*/
|
|
87
|
-
async updateRcFile(
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
139
|
+
async updateRcFile(...params) {
|
|
140
|
+
await this.#installAssembler();
|
|
141
|
+
if (!this.#codeTransformer) {
|
|
142
|
+
this.logger.warning('Cannot update "adonisrc.ts" file. Install "@adonisjs/assembler" to modify source files');
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
const action = this.logger.action('update adonisrc.ts file');
|
|
146
|
+
try {
|
|
147
|
+
await new this.#codeTransformer.CodeTransformer(this.app.appRoot).updateRcFile(...params);
|
|
148
|
+
action.succeeded();
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
action.failed(error.message);
|
|
152
|
+
}
|
|
92
153
|
}
|
|
93
154
|
/**
|
|
94
155
|
* Install packages using the correct package manager
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { type VineValidator } from '@vinejs/vine';
|
|
2
2
|
import type { Infer, SchemaTypes, ValidationOptions, ErrorReporterContract, MessagesProviderContact } from '@vinejs/vine/types';
|
|
3
3
|
import { type HttpContext } from '@adonisjs/http-server';
|
|
4
|
+
declare module '@adonisjs/http-server' {
|
|
5
|
+
interface Request extends RequestValidator {
|
|
6
|
+
}
|
|
7
|
+
}
|
|
4
8
|
/**
|
|
5
9
|
* Request validation options with custom data as well
|
|
6
10
|
*/
|
|
@@ -37,8 +41,4 @@ export declare class RequestValidator {
|
|
|
37
41
|
*/
|
|
38
42
|
validateUsing<Schema extends SchemaTypes, MetaData extends undefined | Record<string, any>>(validator: VineValidator<Schema, MetaData>, ...[options]: [undefined] extends MetaData ? [options?: RequestValidationOptions<MetaData> | undefined] : [options: RequestValidationOptions<MetaData>]): Promise<Infer<Schema>>;
|
|
39
43
|
}
|
|
40
|
-
declare module '@adonisjs/http-server' {
|
|
41
|
-
interface Request extends RequestValidator {
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
44
|
export {};
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* For the full copyright and license information, please view the LICENSE
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
|
+
import { bridgeEdgeAdonisJS } from '../src/bindings/edge.js';
|
|
9
10
|
export default class EdgeServiceProvider {
|
|
10
11
|
app;
|
|
11
12
|
constructor(app) {
|
|
@@ -15,7 +16,6 @@ export default class EdgeServiceProvider {
|
|
|
15
16
|
* Bridge AdonisJS and Edge
|
|
16
17
|
*/
|
|
17
18
|
async boot() {
|
|
18
|
-
const { bridgeEdgeAdonisJS } = await import('../src/bindings/edge.js');
|
|
19
19
|
bridgeEdgeAdonisJS(this.app, await this.app.container.make('router'));
|
|
20
20
|
}
|
|
21
21
|
}
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import '../src/bindings/vinejs.js';
|
|
2
|
+
import '../modules/http/request_validator.js';
|
|
2
3
|
export default class VineJSServiceProvider {
|
|
3
|
-
protected app: ApplicationService;
|
|
4
|
-
constructor(app: ApplicationService);
|
|
5
|
-
/**
|
|
6
|
-
* Registering AdonisJS specific VineJS rules
|
|
7
|
-
*/
|
|
8
|
-
boot(): Promise<void>;
|
|
9
4
|
}
|
|
@@ -6,16 +6,7 @@
|
|
|
6
6
|
* For the full copyright and license information, please view the LICENSE
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
|
+
import '../src/bindings/vinejs.js';
|
|
10
|
+
import '../modules/http/request_validator.js';
|
|
9
11
|
export default class VineJSServiceProvider {
|
|
10
|
-
app;
|
|
11
|
-
constructor(app) {
|
|
12
|
-
this.app = app;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Registering AdonisJS specific VineJS rules
|
|
16
|
-
*/
|
|
17
|
-
async boot() {
|
|
18
|
-
await import('../modules/http/request_validator.js');
|
|
19
|
-
await import('../src/bindings/vinejs.js');
|
|
20
|
-
}
|
|
21
12
|
}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { BaseLiteralType } from '@vinejs/vine';
|
|
2
2
|
import type { FieldContext, FieldOptions, Validation } from '@vinejs/vine/types';
|
|
3
3
|
import type { MultipartFile, FileValidationOptions } from '@adonisjs/bodyparser/types';
|
|
4
|
+
/**
|
|
5
|
+
* Notifying TypeScript
|
|
6
|
+
*/
|
|
7
|
+
declare module '@vinejs/vine' {
|
|
8
|
+
interface Vine {
|
|
9
|
+
file(options?: ValidationOptions): VineMultipartFile;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
4
12
|
type ValidationOptions = Partial<FileValidationOptions> | ((field: FieldContext) => Partial<FileValidationOptions>);
|
|
5
13
|
/**
|
|
6
14
|
* Represents a multipart file uploaded via multipart/form-data HTTP
|
|
@@ -11,12 +19,4 @@ declare class VineMultipartFile extends BaseLiteralType<MultipartFile, Multipart
|
|
|
11
19
|
constructor(validationOptions?: ValidationOptions, options?: FieldOptions, validations?: Validation<any>[]);
|
|
12
20
|
clone(): this;
|
|
13
21
|
}
|
|
14
|
-
/**
|
|
15
|
-
* Notifying TypeScript
|
|
16
|
-
*/
|
|
17
|
-
declare module '@vinejs/vine' {
|
|
18
|
-
interface Vine {
|
|
19
|
-
file(options?: ValidationOptions): VineMultipartFile;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
22
|
export {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adonisjs/core",
|
|
3
3
|
"description": "Core of AdonisJS",
|
|
4
|
-
"version": "6.1.5-
|
|
4
|
+
"version": "6.1.5-18",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=18.16.0"
|
|
7
7
|
},
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"index:commands": "node --loader=ts-node/esm toolkit/main.js index build/commands"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
|
-
"@adonisjs/assembler": "^6.1.3-
|
|
79
|
+
"@adonisjs/assembler": "^6.1.3-18",
|
|
80
80
|
"@adonisjs/eslint-config": "^1.1.8",
|
|
81
81
|
"@adonisjs/prettier-config": "^1.1.8",
|
|
82
82
|
"@adonisjs/tsconfig": "^1.1.8",
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
"typescript": "^5.1.6"
|
|
112
112
|
},
|
|
113
113
|
"dependencies": {
|
|
114
|
-
"@adonisjs/ace": "^12.3.1-
|
|
114
|
+
"@adonisjs/ace": "^12.3.1-10",
|
|
115
115
|
"@adonisjs/application": "^7.1.2-11",
|
|
116
116
|
"@adonisjs/bodyparser": "^9.3.2-7",
|
|
117
117
|
"@adonisjs/config": "^4.2.1-3",
|
|
@@ -138,7 +138,7 @@
|
|
|
138
138
|
"youch-terminal": "^2.2.2"
|
|
139
139
|
},
|
|
140
140
|
"peerDependencies": {
|
|
141
|
-
"@adonisjs/assembler": "^6.1.3-
|
|
141
|
+
"@adonisjs/assembler": "^6.1.3-18",
|
|
142
142
|
"@vinejs/vine": "^1.6.0",
|
|
143
143
|
"argon2": "^0.30.3",
|
|
144
144
|
"bcrypt": "^5.0.1",
|