@adonisjs/core 6.1.5-33 → 6.1.5-34
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/build.d.ts +3 -5
- package/build/commands/build.js +5 -9
- package/build/commands/commands.json +1 -1
- package/build/commands/configure.d.ts +20 -21
- package/build/commands/configure.js +38 -90
- package/build/commands/generate_key.js +1 -1
- package/build/commands/make/controller.js +5 -5
- package/build/commands/make/exception.js +1 -1
- package/build/commands/make/listener.js +1 -1
- package/build/commands/make/middleware.js +2 -2
- package/build/commands/make/preload.d.ts +1 -1
- package/build/commands/make/preload.js +13 -36
- package/build/commands/make/provider.d.ts +5 -0
- package/build/commands/make/provider.js +33 -5
- package/build/commands/make/test.js +1 -1
- package/build/commands/make/validator.d.ts +5 -0
- package/build/commands/make/validator.js +19 -3
- package/build/commands/serve.js +7 -4
- package/build/commands/test.js +2 -2
- package/build/modules/ace/codemods.d.ts +38 -4
- package/build/modules/ace/codemods.js +100 -2
- package/build/modules/ace/commands.js +5 -1
- package/build/providers/app_provider.js +6 -4
- package/build/providers/repl_provider.js +11 -2
- package/build/src/helpers/main.d.ts +1 -1
- package/build/src/helpers/main.js +1 -1
- package/build/src/types.d.ts +3 -4
- package/build/stubs/make/validator/resource.stub +26 -0
- package/package.json +32 -32
- /package/build/stubs/make/{preload_file → preload}/main.stub +0 -0
|
@@ -13,7 +13,8 @@ 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 { stubsRoot } from '../../stubs/main.js';
|
|
16
|
-
import { args, BaseCommand } from '../../modules/ace/main.js';
|
|
16
|
+
import { args, BaseCommand, flags } from '../../modules/ace/main.js';
|
|
17
|
+
const ALLOWED_ENVIRONMENTS = ['web', 'console', 'test', 'repl'];
|
|
17
18
|
/**
|
|
18
19
|
* Make a new provider class
|
|
19
20
|
*/
|
|
@@ -24,7 +25,23 @@ export default class MakeProvider extends BaseCommand {
|
|
|
24
25
|
* The stub to use for generating the provider class
|
|
25
26
|
*/
|
|
26
27
|
stubPath = 'make/provider/main.stub';
|
|
28
|
+
/**
|
|
29
|
+
* Validate the environments flag passed by the user
|
|
30
|
+
*/
|
|
31
|
+
#isEnvironmentsFlagValid() {
|
|
32
|
+
if (!this.environments || !this.environments.length) {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
return this.environments.every((one) => ALLOWED_ENVIRONMENTS.includes(one));
|
|
36
|
+
}
|
|
27
37
|
async run() {
|
|
38
|
+
/**
|
|
39
|
+
* Ensure the environments are valid when provided via flag
|
|
40
|
+
*/
|
|
41
|
+
if (!this.#isEnvironmentsFlagValid()) {
|
|
42
|
+
this.logger.error(`Invalid environment(s) "${this.environments}". Only "${ALLOWED_ENVIRONMENTS}" are allowed`);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
28
45
|
const codemods = await this.createCodemods();
|
|
29
46
|
const output = await codemods.makeUsingStub(stubsRoot, this.stubPath, {
|
|
30
47
|
flags: this.parsed.flags,
|
|
@@ -34,12 +51,23 @@ export default class MakeProvider extends BaseCommand {
|
|
|
34
51
|
* Registering the provider with the `adonisrc.js` file. We register
|
|
35
52
|
* the relative path, since we cannot be sure about aliases to exist.
|
|
36
53
|
*/
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
54
|
+
try {
|
|
55
|
+
const providerImportPath = `./${output.relativeFileName.replace(/(\.js|\.ts)$/, '')}.js`;
|
|
56
|
+
await codemods.updateRcFile((rcFile) => {
|
|
57
|
+
rcFile.addProvider(providerImportPath, this.environments);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
catch (_) {
|
|
61
|
+
this.logger.warning('Unable to register provider inside the adonisrc.ts file. Make sure to manually register it');
|
|
62
|
+
}
|
|
41
63
|
}
|
|
42
64
|
}
|
|
43
65
|
__decorate([
|
|
44
66
|
args.string({ description: 'Name of the provider' })
|
|
45
67
|
], MakeProvider.prototype, "name", void 0);
|
|
68
|
+
__decorate([
|
|
69
|
+
flags.array({
|
|
70
|
+
description: `Define the provider environment. Accepted values are "${ALLOWED_ENVIRONMENTS}"`,
|
|
71
|
+
alias: 'e',
|
|
72
|
+
})
|
|
73
|
+
], MakeProvider.prototype, "environments", void 0);
|
|
@@ -101,5 +101,5 @@ __decorate([
|
|
|
101
101
|
args.string({ description: 'Name of the test file' })
|
|
102
102
|
], MakeTest.prototype, "name", void 0);
|
|
103
103
|
__decorate([
|
|
104
|
-
flags.string({ description: 'The suite for which to create the test file' })
|
|
104
|
+
flags.string({ description: 'The suite for which to create the test file', alias: 's' })
|
|
105
105
|
], MakeTest.prototype, "suite", void 0);
|
|
@@ -6,9 +6,14 @@ export default class MakeValidator extends BaseCommand {
|
|
|
6
6
|
static commandName: string;
|
|
7
7
|
static description: string;
|
|
8
8
|
name: string;
|
|
9
|
+
resource: boolean;
|
|
9
10
|
/**
|
|
10
11
|
* The stub to use for generating the validator
|
|
11
12
|
*/
|
|
12
13
|
protected stubPath: string;
|
|
14
|
+
/**
|
|
15
|
+
* Preparing the command state
|
|
16
|
+
*/
|
|
17
|
+
prepare(): Promise<void>;
|
|
13
18
|
run(): Promise<void>;
|
|
14
19
|
}
|
|
@@ -13,17 +13,28 @@ 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 { stubsRoot } from '../../stubs/main.js';
|
|
16
|
-
import { args, BaseCommand } from '../../modules/ace/main.js';
|
|
16
|
+
import { args, flags, BaseCommand } from '../../modules/ace/main.js';
|
|
17
17
|
/**
|
|
18
18
|
* Make a new VineJS validator
|
|
19
19
|
*/
|
|
20
20
|
export default class MakeValidator extends BaseCommand {
|
|
21
21
|
static commandName = 'make:validator';
|
|
22
|
-
static description = 'Create a new VineJS
|
|
22
|
+
static description = 'Create a new file to define VineJS validators';
|
|
23
23
|
/**
|
|
24
24
|
* The stub to use for generating the validator
|
|
25
25
|
*/
|
|
26
26
|
stubPath = 'make/validator/main.stub';
|
|
27
|
+
/**
|
|
28
|
+
* Preparing the command state
|
|
29
|
+
*/
|
|
30
|
+
async prepare() {
|
|
31
|
+
/**
|
|
32
|
+
* Use resource stub
|
|
33
|
+
*/
|
|
34
|
+
if (this.resource) {
|
|
35
|
+
this.stubPath = 'make/validator/resource.stub';
|
|
36
|
+
}
|
|
37
|
+
}
|
|
27
38
|
async run() {
|
|
28
39
|
const codemods = await this.createCodemods();
|
|
29
40
|
await codemods.makeUsingStub(stubsRoot, this.stubPath, {
|
|
@@ -33,5 +44,10 @@ export default class MakeValidator extends BaseCommand {
|
|
|
33
44
|
}
|
|
34
45
|
}
|
|
35
46
|
__decorate([
|
|
36
|
-
args.string({ description: 'Name of the validator' })
|
|
47
|
+
args.string({ description: 'Name of the validator file' })
|
|
37
48
|
], MakeValidator.prototype, "name", void 0);
|
|
49
|
+
__decorate([
|
|
50
|
+
flags.boolean({
|
|
51
|
+
description: 'Create a file with pre-defined validators for create and update actions',
|
|
52
|
+
})
|
|
53
|
+
], MakeValidator.prototype, "resource", void 0);
|
package/build/commands/serve.js
CHANGED
|
@@ -56,13 +56,13 @@ export default class Serve extends BaseCommand {
|
|
|
56
56
|
const assetsBundler = await detectAssetsBundler(this.app);
|
|
57
57
|
return assetsBundler
|
|
58
58
|
? {
|
|
59
|
-
|
|
59
|
+
enabled: this.assets === false ? false : true,
|
|
60
60
|
driver: assetsBundler.name,
|
|
61
61
|
cmd: assetsBundler.devServer.command,
|
|
62
62
|
args: (assetsBundler.devServer.args || []).concat(this.assetsArgs || []),
|
|
63
63
|
}
|
|
64
64
|
: {
|
|
65
|
-
|
|
65
|
+
enabled: false,
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
68
|
/**
|
|
@@ -119,10 +119,13 @@ export default class Serve extends BaseCommand {
|
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
__decorate([
|
|
122
|
-
flags.boolean({
|
|
122
|
+
flags.boolean({
|
|
123
|
+
description: 'Watch filesystem and restart the HTTP server on file change',
|
|
124
|
+
alias: 'w',
|
|
125
|
+
})
|
|
123
126
|
], Serve.prototype, "watch", void 0);
|
|
124
127
|
__decorate([
|
|
125
|
-
flags.boolean({ description: 'Use polling to detect filesystem changes' })
|
|
128
|
+
flags.boolean({ description: 'Use polling to detect filesystem changes', alias: 'p' })
|
|
126
129
|
], Serve.prototype, "poll", void 0);
|
|
127
130
|
__decorate([
|
|
128
131
|
flags.boolean({
|
package/build/commands/test.js
CHANGED
|
@@ -67,13 +67,13 @@ export default class Test extends BaseCommand {
|
|
|
67
67
|
const assetsBundler = await detectAssetsBundler(this.app);
|
|
68
68
|
return assetsBundler
|
|
69
69
|
? {
|
|
70
|
-
|
|
70
|
+
enabled: this.assets === false ? false : true,
|
|
71
71
|
driver: assetsBundler.name,
|
|
72
72
|
cmd: assetsBundler.devServer.command,
|
|
73
73
|
args: (assetsBundler.devServer.args || []).concat(this.assetsArgs || []),
|
|
74
74
|
}
|
|
75
75
|
: {
|
|
76
|
-
|
|
76
|
+
enabled: false,
|
|
77
77
|
};
|
|
78
78
|
}
|
|
79
79
|
/**
|
|
@@ -1,14 +1,25 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
import { EventEmitter } from 'node:events';
|
|
1
3
|
import type { Logger } from '@poppinss/cliui';
|
|
2
4
|
import type { CodeTransformer } from '@adonisjs/assembler/code_transformer';
|
|
3
|
-
import type {
|
|
5
|
+
import type { MiddlewareNode, EnvValidationNode } from '@adonisjs/assembler/types';
|
|
4
6
|
import type { Application } from '../app.js';
|
|
5
7
|
/**
|
|
6
8
|
* Codemods to modify AdonisJS source files. The codemod APIs relies on
|
|
7
9
|
* "@adonisjs/assembler" package and it must be installed as a dependency
|
|
8
10
|
* inside user application.
|
|
9
11
|
*/
|
|
10
|
-
export declare class Codemods {
|
|
12
|
+
export declare class Codemods extends EventEmitter {
|
|
11
13
|
#private;
|
|
14
|
+
/**
|
|
15
|
+
* Overwrite existing files when generating files
|
|
16
|
+
* from stubs
|
|
17
|
+
*/
|
|
18
|
+
overwriteExisting: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Display verbose logs for package installation
|
|
21
|
+
*/
|
|
22
|
+
verboseInstallOutput: boolean;
|
|
12
23
|
constructor(app: Application<any>, cliLogger: Logger);
|
|
13
24
|
/**
|
|
14
25
|
* Define one or more environment variables
|
|
@@ -17,11 +28,11 @@ export declare class Codemods {
|
|
|
17
28
|
/**
|
|
18
29
|
* Define validations for the environment variables
|
|
19
30
|
*/
|
|
20
|
-
defineEnvValidations(validations:
|
|
31
|
+
defineEnvValidations(validations: EnvValidationNode): Promise<void>;
|
|
21
32
|
/**
|
|
22
33
|
* Define validations for the environment variables
|
|
23
34
|
*/
|
|
24
|
-
registerMiddleware(stack: 'server' | 'router' | 'named', middleware:
|
|
35
|
+
registerMiddleware(stack: 'server' | 'router' | 'named', middleware: MiddlewareNode[]): Promise<void>;
|
|
25
36
|
/**
|
|
26
37
|
* Update RCFile
|
|
27
38
|
*/
|
|
@@ -45,10 +56,33 @@ export declare class Codemods {
|
|
|
45
56
|
skipReason: null;
|
|
46
57
|
} | {
|
|
47
58
|
relativeFileName: string;
|
|
59
|
+
/**
|
|
60
|
+
* Reference to AdonisJS application
|
|
61
|
+
*/
|
|
48
62
|
contents: string;
|
|
49
63
|
destination: any;
|
|
50
64
|
attributes: Record<string, any>;
|
|
51
65
|
status: "skipped";
|
|
52
66
|
skipReason: string;
|
|
53
67
|
}>;
|
|
68
|
+
/**
|
|
69
|
+
* Install packages using the correct package manager
|
|
70
|
+
* You can specify version of each package by setting it in the
|
|
71
|
+
* name like :
|
|
72
|
+
*
|
|
73
|
+
* ```
|
|
74
|
+
* this.installPackages(['@adonisjs/lucid@next', '@adonisjs/auth@3.0.0'])
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
installPackages(packages: {
|
|
78
|
+
name: string;
|
|
79
|
+
isDevDependency: boolean;
|
|
80
|
+
}[]): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* List the packages one should install before using the packages
|
|
83
|
+
*/
|
|
84
|
+
listPackagesToInstall(packages: {
|
|
85
|
+
name: string;
|
|
86
|
+
isDevDependency: boolean;
|
|
87
|
+
}[]): Promise<void>;
|
|
54
88
|
}
|
|
@@ -7,13 +7,14 @@
|
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
9
|
import { slash } from '@poppinss/utils';
|
|
10
|
+
import { EventEmitter } from 'node:events';
|
|
10
11
|
import { EnvEditor } from '@adonisjs/env/editor';
|
|
11
12
|
/**
|
|
12
13
|
* Codemods to modify AdonisJS source files. The codemod APIs relies on
|
|
13
14
|
* "@adonisjs/assembler" package and it must be installed as a dependency
|
|
14
15
|
* inside user application.
|
|
15
16
|
*/
|
|
16
|
-
export class Codemods {
|
|
17
|
+
export class Codemods extends EventEmitter {
|
|
17
18
|
/**
|
|
18
19
|
* Flag to know if assembler is installed as a
|
|
19
20
|
* peer dependency or not.
|
|
@@ -31,7 +32,17 @@ export class Codemods {
|
|
|
31
32
|
* Reference to CLI logger to write logs
|
|
32
33
|
*/
|
|
33
34
|
#cliLogger;
|
|
35
|
+
/**
|
|
36
|
+
* Overwrite existing files when generating files
|
|
37
|
+
* from stubs
|
|
38
|
+
*/
|
|
39
|
+
overwriteExisting = false;
|
|
40
|
+
/**
|
|
41
|
+
* Display verbose logs for package installation
|
|
42
|
+
*/
|
|
43
|
+
verboseInstallOutput = false;
|
|
34
44
|
constructor(app, cliLogger) {
|
|
45
|
+
super();
|
|
35
46
|
this.#app = app;
|
|
36
47
|
this.#cliLogger = cliLogger;
|
|
37
48
|
}
|
|
@@ -44,6 +55,26 @@ export class Codemods {
|
|
|
44
55
|
this.#isAssemblerInstalled = !!this.#codeTransformer;
|
|
45
56
|
}
|
|
46
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Returns the installation command for different
|
|
60
|
+
* package managers
|
|
61
|
+
*/
|
|
62
|
+
#getInstallationCommands(packages, packageManager, isDev) {
|
|
63
|
+
if (!packages.length) {
|
|
64
|
+
return '';
|
|
65
|
+
}
|
|
66
|
+
const colors = this.#cliLogger.getColors();
|
|
67
|
+
const devFlag = isDev ? ' -D' : '';
|
|
68
|
+
switch (packageManager) {
|
|
69
|
+
case 'yarn':
|
|
70
|
+
return `${colors.yellow(`yarn add${devFlag}`)} ${packages.join(' ')}`;
|
|
71
|
+
case 'pnpm':
|
|
72
|
+
return `${colors.yellow(`pnpm add${devFlag}`)} ${packages.join(' ')}`;
|
|
73
|
+
case 'npm':
|
|
74
|
+
default:
|
|
75
|
+
return `${colors.yellow(`npm i${devFlag}`)} ${packages.join(' ')}`;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
47
78
|
/**
|
|
48
79
|
* Define one or more environment variables
|
|
49
80
|
*/
|
|
@@ -73,6 +104,7 @@ export class Codemods {
|
|
|
73
104
|
action.succeeded();
|
|
74
105
|
}
|
|
75
106
|
catch (error) {
|
|
107
|
+
this.emit('error', error);
|
|
76
108
|
action.failed(error.message);
|
|
77
109
|
}
|
|
78
110
|
}
|
|
@@ -92,6 +124,7 @@ export class Codemods {
|
|
|
92
124
|
action.succeeded();
|
|
93
125
|
}
|
|
94
126
|
catch (error) {
|
|
127
|
+
this.emit('error', error);
|
|
95
128
|
action.failed(error.message);
|
|
96
129
|
}
|
|
97
130
|
}
|
|
@@ -111,6 +144,7 @@ export class Codemods {
|
|
|
111
144
|
action.succeeded();
|
|
112
145
|
}
|
|
113
146
|
catch (error) {
|
|
147
|
+
this.emit('error', error);
|
|
114
148
|
action.failed(error.message);
|
|
115
149
|
}
|
|
116
150
|
}
|
|
@@ -120,7 +154,7 @@ export class Codemods {
|
|
|
120
154
|
async makeUsingStub(stubsRoot, stubPath, stubState) {
|
|
121
155
|
const stubs = await this.#app.stubs.create();
|
|
122
156
|
const stub = await stubs.build(stubPath, { source: stubsRoot });
|
|
123
|
-
const output = await stub.generate(stubState);
|
|
157
|
+
const output = await stub.generate({ force: this.overwriteExisting, ...stubState });
|
|
124
158
|
const entityFileName = slash(this.#app.relativePath(output.destination));
|
|
125
159
|
const result = { ...output, relativeFileName: entityFileName };
|
|
126
160
|
if (output.status === 'skipped') {
|
|
@@ -130,4 +164,68 @@ export class Codemods {
|
|
|
130
164
|
this.#cliLogger.action(`create ${entityFileName}`).succeeded();
|
|
131
165
|
return result;
|
|
132
166
|
}
|
|
167
|
+
/**
|
|
168
|
+
* Install packages using the correct package manager
|
|
169
|
+
* You can specify version of each package by setting it in the
|
|
170
|
+
* name like :
|
|
171
|
+
*
|
|
172
|
+
* ```
|
|
173
|
+
* this.installPackages(['@adonisjs/lucid@next', '@adonisjs/auth@3.0.0'])
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
async installPackages(packages) {
|
|
177
|
+
await this.#importAssembler();
|
|
178
|
+
const appPath = this.#app.makePath();
|
|
179
|
+
const colors = this.#cliLogger.getColors();
|
|
180
|
+
const devDependencies = packages.filter((pkg) => pkg.isDevDependency).map(({ name }) => name);
|
|
181
|
+
const dependencies = packages.filter((pkg) => !pkg.isDevDependency).map(({ name }) => name);
|
|
182
|
+
if (!this.#codeTransformer) {
|
|
183
|
+
this.#cliLogger.warning('Cannot install packages. Install "@adonisjs/assembler" or manually install following packages');
|
|
184
|
+
this.#cliLogger.log(`devDependencies: ${devDependencies.join(',')}`);
|
|
185
|
+
this.#cliLogger.log(`dependencies: ${dependencies.join(',')}`);
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
const transformer = new this.#codeTransformer.CodeTransformer(this.#app.appRoot);
|
|
189
|
+
const packageManager = await transformer.detectPackageManager(appPath);
|
|
190
|
+
let spinner = this.#cliLogger
|
|
191
|
+
.await(`installing dependencies using ${packageManager || 'npm'} `)
|
|
192
|
+
.start();
|
|
193
|
+
try {
|
|
194
|
+
await transformer.installPackage(dependencies, {
|
|
195
|
+
cwd: appPath,
|
|
196
|
+
silent: !this.verboseInstallOutput,
|
|
197
|
+
});
|
|
198
|
+
await transformer.installPackage(devDependencies, {
|
|
199
|
+
dev: true,
|
|
200
|
+
cwd: appPath,
|
|
201
|
+
silent: !this.verboseInstallOutput,
|
|
202
|
+
});
|
|
203
|
+
spinner.stop();
|
|
204
|
+
this.#cliLogger.success('Packages installed');
|
|
205
|
+
this.#cliLogger.log(devDependencies.map((dependency) => ` ${colors.dim('dev')} ${dependency} `).join('\n'));
|
|
206
|
+
this.#cliLogger.log(dependencies.map((dependency) => ` ${colors.dim('prod')} ${dependency} `).join('\n'));
|
|
207
|
+
}
|
|
208
|
+
catch (error) {
|
|
209
|
+
spinner.update('unable to install dependencies');
|
|
210
|
+
spinner.stop();
|
|
211
|
+
this.#cliLogger.fatal(error);
|
|
212
|
+
this.emit('error', error);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* List the packages one should install before using the packages
|
|
217
|
+
*/
|
|
218
|
+
async listPackagesToInstall(packages) {
|
|
219
|
+
const appPath = this.#app.makePath();
|
|
220
|
+
const devDependencies = packages.filter((pkg) => pkg.isDevDependency).map(({ name }) => name);
|
|
221
|
+
const dependencies = packages.filter((pkg) => !pkg.isDevDependency).map(({ name }) => name);
|
|
222
|
+
let packageManager = null;
|
|
223
|
+
if (this.#codeTransformer) {
|
|
224
|
+
const transformer = new this.#codeTransformer.CodeTransformer(this.#app.appRoot);
|
|
225
|
+
packageManager = await transformer.detectPackageManager(appPath);
|
|
226
|
+
}
|
|
227
|
+
this.#cliLogger.log('Please install following packages');
|
|
228
|
+
this.#cliLogger.log(this.#getInstallationCommands(devDependencies, packageManager || 'npm', true));
|
|
229
|
+
this.#cliLogger.log(this.#getInstallationCommands(dependencies, packageManager || 'npm', false));
|
|
230
|
+
}
|
|
133
231
|
}
|
|
@@ -31,7 +31,11 @@ export class BaseCommand extends AceBaseCommand {
|
|
|
31
31
|
*/
|
|
32
32
|
async createCodemods() {
|
|
33
33
|
const { Codemods } = await import('./codemods.js');
|
|
34
|
-
|
|
34
|
+
const codemods = new Codemods(this.app, this.logger);
|
|
35
|
+
codemods.on('error', () => {
|
|
36
|
+
this.exitCode = 1;
|
|
37
|
+
});
|
|
38
|
+
return codemods;
|
|
35
39
|
}
|
|
36
40
|
/**
|
|
37
41
|
* Executes the command
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { Config } from '../modules/config.js';
|
|
10
10
|
import { Logger } from '../modules/logger.js';
|
|
11
|
-
import {
|
|
11
|
+
import { Application } from '../modules/app.js';
|
|
12
|
+
import { BaseEvent, Emitter } from '../modules/events.js';
|
|
12
13
|
import { Encryption } from '../modules/encryption.js';
|
|
13
14
|
import { Router, Server } from '../modules/http/main.js';
|
|
14
15
|
import BodyParserMiddleware from '../modules/bodyparser/bodyparser_middleware.js';
|
|
@@ -43,7 +44,8 @@ export default class AppServiceProvider {
|
|
|
43
44
|
* Registers the application to the container
|
|
44
45
|
*/
|
|
45
46
|
registerApp() {
|
|
46
|
-
this.app.container.singleton(
|
|
47
|
+
this.app.container.singleton(Application, () => this.app);
|
|
48
|
+
this.app.container.alias('app', Application);
|
|
47
49
|
}
|
|
48
50
|
/**
|
|
49
51
|
* Registers the logger class to resolve the default logger
|
|
@@ -75,10 +77,10 @@ export default class AppServiceProvider {
|
|
|
75
77
|
* Registers emitter service to the container
|
|
76
78
|
*/
|
|
77
79
|
registerEmitter() {
|
|
78
|
-
this.app.container.singleton(
|
|
79
|
-
const { Emitter } = await import('../modules/events.js');
|
|
80
|
+
this.app.container.singleton(Emitter, async () => {
|
|
80
81
|
return new Emitter(this.app);
|
|
81
82
|
});
|
|
83
|
+
this.app.container.alias('emitter', Emitter);
|
|
82
84
|
}
|
|
83
85
|
/**
|
|
84
86
|
* Register the encryption service to the container
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { join } from 'node:path';
|
|
10
10
|
import { homedir } from 'node:os';
|
|
11
|
+
import { Repl } from '../modules/repl.js';
|
|
12
|
+
import { fsImportAll } from '@poppinss/utils';
|
|
11
13
|
/**
|
|
12
14
|
* Resolves a container binding and sets it on the REPL
|
|
13
15
|
* context
|
|
@@ -25,12 +27,12 @@ export default class ReplServiceProvider {
|
|
|
25
27
|
* Registers the REPL binding
|
|
26
28
|
*/
|
|
27
29
|
register() {
|
|
28
|
-
this.app.container.singleton(
|
|
29
|
-
const { Repl } = await import('../modules/repl.js');
|
|
30
|
+
this.app.container.singleton(Repl, async () => {
|
|
30
31
|
return new Repl({
|
|
31
32
|
historyFilePath: join(homedir(), '.adonisjs_v6_repl_history'),
|
|
32
33
|
});
|
|
33
34
|
});
|
|
35
|
+
this.app.container.alias('repl', Repl);
|
|
34
36
|
}
|
|
35
37
|
/**
|
|
36
38
|
* Registering REPL bindings during provider boot
|
|
@@ -42,6 +44,13 @@ export default class ReplServiceProvider {
|
|
|
42
44
|
}, {
|
|
43
45
|
description: 'Returns the default export for a module',
|
|
44
46
|
});
|
|
47
|
+
repl.addMethod('importAll', (_, dirPath) => {
|
|
48
|
+
return fsImportAll(this.app.makeURL(dirPath), {
|
|
49
|
+
ignoreMissingRoot: false,
|
|
50
|
+
});
|
|
51
|
+
}, {
|
|
52
|
+
description: 'Import all files from a directory and assign them to a variable',
|
|
53
|
+
});
|
|
45
54
|
repl.addMethod('make', (_, service, runtimeValues) => {
|
|
46
55
|
return this.app.container.make(service, runtimeValues);
|
|
47
56
|
}, {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { default as parseImports } from 'parse-imports';
|
|
2
|
-
export { createId as cuid } from '@paralleldrive/cuid2';
|
|
2
|
+
export { createId as cuid, isCuid } from '@paralleldrive/cuid2';
|
|
3
3
|
export { slash, base64, compose, fsReadAll, safeEqual, fsImportAll, MessageBuilder, } from '@poppinss/utils';
|
|
4
4
|
export { parseBindingReference } from './parse_binding_reference.js';
|
|
@@ -7,6 +7,6 @@
|
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
9
|
export { default as parseImports } from 'parse-imports';
|
|
10
|
-
export { createId as cuid } from '@paralleldrive/cuid2';
|
|
10
|
+
export { createId as cuid, isCuid } from '@paralleldrive/cuid2';
|
|
11
11
|
export { slash, base64, compose, fsReadAll, safeEqual, fsImportAll, MessageBuilder, } from '@poppinss/utils';
|
|
12
12
|
export { parseBindingReference } from './parse_binding_reference.js';
|
package/build/src/types.d.ts
CHANGED
|
@@ -4,12 +4,12 @@ import type { Emitter } from '../modules/events.js';
|
|
|
4
4
|
import type { Kernel } from '../modules/ace/main.js';
|
|
5
5
|
import type { Application } from '../modules/app.js';
|
|
6
6
|
import type { TestUtils } from './test_utils/main.js';
|
|
7
|
+
import type { HttpServerEvents } from '../types/http.js';
|
|
7
8
|
import type { LoggerManager } from '../modules/logger.js';
|
|
8
9
|
import type { HashManager } from '../modules/hash/main.js';
|
|
9
10
|
import type { Encryption } from '../modules/encryption.js';
|
|
10
11
|
import type { ManagerDriverFactory } from '../types/hash.js';
|
|
11
12
|
import type { Router, Server } from '../modules/http/main.js';
|
|
12
|
-
import type { HttpRequestFinishedPayload } from '../types/http.js';
|
|
13
13
|
import type { ContainerResolveEventData } from '../types/container.js';
|
|
14
14
|
import type { LoggerConfig, LoggerManagerConfig } from '../types/logger.js';
|
|
15
15
|
/**
|
|
@@ -32,9 +32,8 @@ export type IgnitorOptions = {
|
|
|
32
32
|
* user land code or packages to register events and their
|
|
33
33
|
* types.
|
|
34
34
|
*/
|
|
35
|
-
export interface EventsList {
|
|
36
|
-
'
|
|
37
|
-
'http:request_finished': HttpRequestFinishedPayload;
|
|
35
|
+
export interface EventsList extends HttpServerEvents {
|
|
36
|
+
'container_binding:resolved': ContainerResolveEventData<ContainerBindings>;
|
|
38
37
|
'http:server_ready': {
|
|
39
38
|
port: number;
|
|
40
39
|
host: string;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{{#var validatorName = string(generators.validatorName(entity.name)).noCase()}}
|
|
2
|
+
{{#var validatorFileName = generators.validatorFileName(entity.name)}}
|
|
3
|
+
{{#var createAction = generators.validatorActionName(entity.name, 'create')}}
|
|
4
|
+
{{#var updateAction = generators.validatorActionName(entity.name, 'update')}}
|
|
5
|
+
{{{
|
|
6
|
+
exports({
|
|
7
|
+
to: app.validatorsPath(entity.path, validatorFileName)
|
|
8
|
+
})
|
|
9
|
+
}}}
|
|
10
|
+
import vine from '@vinejs/vine'
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Validator to validate the payload when creating
|
|
14
|
+
* a new {{ validatorName }}.
|
|
15
|
+
*/
|
|
16
|
+
export const {{ createAction }} = vine.compile(
|
|
17
|
+
vine.object({})
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Validator to validate the payload when updating
|
|
22
|
+
* an existing {{ validatorName }}.
|
|
23
|
+
*/
|
|
24
|
+
export const {{ updateAction }} = vine.compile(
|
|
25
|
+
vine.object({})
|
|
26
|
+
)
|