@adonisjs/core 6.19.0 → 7.0.0-next.1
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/add.d.ts +36 -5
- package/build/commands/add.js +24 -60
- package/build/commands/build.d.ts +23 -3
- package/build/commands/build.js +22 -36
- package/build/commands/commands.json +1 -1
- package/build/commands/configure.d.ts +35 -12
- package/build/commands/configure.js +39 -12
- package/build/commands/eject.d.ts +28 -3
- package/build/commands/eject.js +24 -5
- package/build/commands/env/add.d.ts +41 -4
- package/build/commands/env/add.js +32 -5
- package/build/commands/generate_key.d.ts +20 -1
- package/build/commands/generate_key.js +14 -1
- package/build/commands/inspect_rcfile.d.ts +20 -2
- package/build/commands/inspect_rcfile.js +20 -2
- package/build/commands/list/routes.d.ts +33 -11
- package/build/commands/list/routes.js +28 -5
- package/build/commands/make/command.d.ts +26 -3
- package/build/commands/make/command.js +25 -5
- package/build/commands/make/controller.d.ts +35 -2
- package/build/commands/make/controller.js +20 -2
- package/build/commands/make/event.d.ts +30 -4
- package/build/commands/make/event.js +27 -4
- package/build/commands/make/exception.d.ts +30 -4
- package/build/commands/make/exception.js +27 -4
- package/build/commands/make/listener.d.ts +38 -5
- package/build/commands/make/listener.js +32 -5
- package/build/commands/make/middleware.d.ts +25 -2
- package/build/commands/make/middleware.js +21 -4
- package/build/commands/make/preload.d.ts +31 -4
- package/build/commands/make/preload.js +28 -8
- package/build/commands/make/provider.d.ts +32 -3
- package/build/commands/make/provider.js +29 -7
- package/build/commands/make/service.d.ts +21 -2
- package/build/commands/make/service.js +18 -2
- package/build/commands/make/test.d.ts +27 -4
- package/build/commands/make/test.js +36 -8
- package/build/commands/make/transformer.d.ts +43 -0
- package/build/commands/make/transformer.js +65 -0
- package/build/commands/make/validator.d.ts +36 -5
- package/build/commands/make/validator.js +30 -5
- package/build/commands/make/view.d.ts +26 -3
- package/build/commands/make/view.js +24 -4
- package/build/commands/repl.d.ts +24 -4
- package/build/commands/repl.js +23 -3
- package/build/commands/serve.d.ts +38 -4
- package/build/commands/serve.js +34 -43
- package/build/commands/test.d.ts +68 -7
- package/build/commands/test.js +39 -37
- package/build/factories/core/ace.d.ts +31 -4
- package/build/factories/core/ace.js +20 -4
- package/build/factories/core/ignitor.d.ts +80 -9
- package/build/factories/core/ignitor.js +84 -13
- package/build/factories/core/main.d.ts +3 -3
- package/build/factories/core/main.js +3 -3
- package/build/factories/core/test_utils.d.ts +32 -4
- package/build/factories/core/test_utils.js +21 -4
- package/build/factories/stubs.d.ts +54 -5
- package/build/factories/stubs.js +55 -6
- package/build/index.d.ts +5 -4
- package/build/index.js +13 -9
- package/build/modules/ace/codemods.d.ts +71 -11
- package/build/modules/ace/codemods.js +90 -22
- package/build/modules/ace/commands.d.ts +48 -13
- package/build/modules/ace/commands.js +45 -10
- package/build/modules/ace/create_kernel.d.ts +19 -8
- package/build/modules/ace/create_kernel.js +19 -8
- package/build/modules/ace/kernel.d.ts +18 -4
- package/build/modules/ace/kernel.js +17 -3
- package/build/modules/ace/main.d.ts +3 -3
- package/build/modules/ace/main.js +3 -3
- package/build/modules/dumper/define_config.d.ts +25 -4
- package/build/modules/dumper/define_config.js +23 -2
- package/build/modules/dumper/dumper.d.ts +82 -12
- package/build/modules/dumper/dumper.js +82 -12
- package/build/modules/dumper/errors.d.ts +31 -10
- package/build/modules/dumper/errors.js +28 -7
- package/build/modules/dumper/main.d.ts +3 -3
- package/build/modules/dumper/main.js +3 -3
- package/build/modules/dumper/plugins/edge.d.ts +1 -1
- package/build/modules/hash/define_config.d.ts +53 -8
- package/build/modules/hash/define_config.js +51 -6
- package/build/modules/hash/main.d.ts +1 -1
- package/build/modules/hash/main.js +1 -1
- package/build/modules/http/main.d.ts +1 -1
- package/build/modules/http/main.js +1 -1
- package/build/modules/http/request_validator.d.ts +36 -9
- package/build/modules/http/request_validator.js +32 -5
- package/build/modules/transformers/main.d.ts +1 -0
- package/build/modules/transformers/main.js +9 -0
- package/build/providers/app_provider.d.ts +173 -1
- package/build/providers/app_provider.js +204 -8
- package/build/providers/edge_provider.d.ts +31 -2
- package/build/providers/edge_provider.js +31 -2
- package/build/providers/hash_provider.d.ts +38 -1
- package/build/providers/hash_provider.js +40 -3
- package/build/providers/repl_provider.d.ts +40 -1
- package/build/providers/repl_provider.js +52 -2
- package/build/providers/vinejs_provider.d.ts +32 -5
- package/build/providers/vinejs_provider.js +31 -4
- package/build/services/ace.d.ts +1 -1
- package/build/services/ace.js +1 -1
- package/build/services/app.d.ts +1 -1
- package/build/services/config.d.ts +1 -1
- package/build/services/config.js +1 -1
- package/build/services/dumper.js +1 -1
- package/build/services/emitter.d.ts +1 -1
- package/build/services/emitter.js +1 -1
- package/build/services/encryption.d.ts +1 -1
- package/build/services/encryption.js +1 -1
- package/build/services/hash.d.ts +1 -1
- package/build/services/hash.js +1 -1
- package/build/services/logger.d.ts +1 -1
- package/build/services/logger.js +1 -1
- package/build/services/repl.d.ts +1 -1
- package/build/services/repl.js +1 -1
- package/build/services/router.d.ts +1 -1
- package/build/services/router.js +1 -1
- package/build/services/server.d.ts +1 -1
- package/build/services/server.js +1 -1
- package/build/services/test_utils.d.ts +1 -1
- package/build/services/test_utils.js +1 -1
- package/build/services/url_builder.d.ts +4 -0
- package/build/services/url_builder.js +21 -0
- package/build/src/assembler_hooks/index_entities.d.ts +37 -0
- package/build/src/assembler_hooks/index_entities.js +106 -0
- package/build/src/cli_formatters/routes_list.d.ts +24 -12
- package/build/src/cli_formatters/routes_list.js +43 -46
- package/build/src/config_provider.d.ts +48 -3
- package/build/src/config_provider.js +47 -2
- package/build/src/debug.d.ts +15 -0
- package/build/src/debug.js +15 -0
- package/build/src/exceptions.d.ts +41 -1
- package/build/src/exceptions.js +41 -1
- package/build/src/helpers/assert.d.ts +47 -1
- package/build/src/helpers/assert.js +47 -1
- package/build/src/helpers/is.d.ts +21 -0
- package/build/src/helpers/is.js +21 -0
- package/build/src/helpers/main.d.ts +48 -5
- package/build/src/helpers/main.js +48 -5
- package/build/src/helpers/string.d.ts +89 -9
- package/build/src/helpers/string.js +21 -2
- package/build/src/helpers/types.d.ts +97 -2
- package/build/src/helpers/types.js +96 -2
- package/build/src/helpers/verification_token.d.ts +22 -1
- package/build/src/helpers/verification_token.js +24 -2
- package/build/src/ignitor/ace.d.ts +23 -3
- package/build/src/ignitor/ace.js +21 -1
- package/build/src/ignitor/http.d.ts +16 -3
- package/build/src/ignitor/http.js +16 -3
- package/build/src/ignitor/main.d.ts +29 -6
- package/build/src/ignitor/main.js +30 -7
- package/build/src/ignitor/test.d.ts +26 -3
- package/build/src/ignitor/test.js +24 -1
- package/build/src/test_utils/http.d.ts +19 -3
- package/build/src/test_utils/http.js +24 -3
- package/build/src/test_utils/main.d.ts +22 -4
- package/build/src/test_utils/main.js +21 -3
- package/build/src/types.d.ts +283 -26
- package/build/src/utils.d.ts +60 -0
- package/build/src/utils.js +104 -0
- package/build/src/vine.d.ts +24 -1
- package/build/src/vine.js +27 -1
- package/build/stubs/main.js +1 -2
- package/build/stubs/make/transformer/main.stub +18 -0
- package/build/toolkit/main.js +1 -1
- package/build/types/common.d.ts +1 -0
- package/build/types/common.js +9 -0
- package/build/types/helpers.d.ts +2 -1
- package/build/types/http.d.ts +1 -0
- package/build/types/transformers.d.ts +1 -0
- package/build/types/transformers.js +9 -0
- package/package.json +55 -52
- package/build/src/helpers/parse_binding_reference.d.ts +0 -45
- package/build/src/helpers/parse_binding_reference.js +0 -83
- package/build/src/internal_helpers.d.ts +0 -15
- package/build/src/internal_helpers.js +0 -63
|
@@ -6,13 +6,32 @@
|
|
|
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 { slash } from '@poppinss/utils';
|
|
10
9
|
import { EventEmitter } from 'node:events';
|
|
11
10
|
import { EnvEditor } from '@adonisjs/env/editor';
|
|
11
|
+
import stringHelpers from "../../src/helpers/string.js";
|
|
12
12
|
/**
|
|
13
|
-
* Codemods
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
* Codemods class for programmatically modifying AdonisJS source files.
|
|
14
|
+
* This class provides APIs to modify configuration files, register middleware,
|
|
15
|
+
* generate stubs, and install packages.
|
|
16
|
+
*
|
|
17
|
+
* The codemod APIs rely on the "@adonisjs/assembler" package, which must be
|
|
18
|
+
* installed as a dependency in the user application.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* const codemods = new Codemods(app, logger)
|
|
23
|
+
*
|
|
24
|
+
* // Generate a controller from a stub
|
|
25
|
+
* await codemods.makeUsingStub(stubsRoot, 'controller.stub', {
|
|
26
|
+
* filename: 'UserController',
|
|
27
|
+
* entity: { name: 'User' }
|
|
28
|
+
* })
|
|
29
|
+
*
|
|
30
|
+
* // Install packages
|
|
31
|
+
* await codemods.installPackages([
|
|
32
|
+
* { name: '@adonisjs/lucid', isDevDependency: false }
|
|
33
|
+
* ])
|
|
34
|
+
* ```
|
|
16
35
|
*/
|
|
17
36
|
export class Codemods extends EventEmitter {
|
|
18
37
|
/**
|
|
@@ -79,7 +98,22 @@ export class Codemods extends EventEmitter {
|
|
|
79
98
|
}
|
|
80
99
|
}
|
|
81
100
|
/**
|
|
82
|
-
* Define one or more environment variables
|
|
101
|
+
* Define one or more environment variables in the .env file
|
|
102
|
+
*
|
|
103
|
+
* @param environmentVariables - Key-value pairs of environment variables
|
|
104
|
+
* @param options - Configuration options
|
|
105
|
+
* @param options.omitFromExample - Keys to exclude from .env.example file
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```ts
|
|
109
|
+
* await codemods.defineEnvVariables({
|
|
110
|
+
* DB_CONNECTION: 'mysql',
|
|
111
|
+
* DB_HOST: 'localhost',
|
|
112
|
+
* SECRET_KEY: 'abc123'
|
|
113
|
+
* }, {
|
|
114
|
+
* omitFromExample: ['SECRET_KEY']
|
|
115
|
+
* })
|
|
116
|
+
* ```
|
|
83
117
|
*/
|
|
84
118
|
async defineEnvVariables(environmentVariables, options) {
|
|
85
119
|
const editor = new EnvEditor(this.#app.appRoot);
|
|
@@ -92,8 +126,17 @@ export class Codemods extends EventEmitter {
|
|
|
92
126
|
this.#cliLogger.action('update .env file').succeeded();
|
|
93
127
|
}
|
|
94
128
|
/**
|
|
95
|
-
* Returns the TsMorph project instance
|
|
96
|
-
* See https://ts-morph.com/
|
|
129
|
+
* Returns the TsMorph project instance for advanced AST manipulations.
|
|
130
|
+
* See https://ts-morph.com/ for documentation.
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```ts
|
|
134
|
+
* const project = await codemods.getTsMorphProject()
|
|
135
|
+
* if (project) {
|
|
136
|
+
* const sourceFile = project.getSourceFile('app/controllers/user_controller.ts')
|
|
137
|
+
* // Perform advanced AST operations
|
|
138
|
+
* }
|
|
139
|
+
* ```
|
|
97
140
|
*/
|
|
98
141
|
async getTsMorphProject() {
|
|
99
142
|
const transformer = await this.#getCodeTransformer();
|
|
@@ -220,13 +263,30 @@ export class Codemods extends EventEmitter {
|
|
|
220
263
|
}
|
|
221
264
|
}
|
|
222
265
|
/**
|
|
223
|
-
* Generate
|
|
266
|
+
* Generate a file using a stub template
|
|
267
|
+
*
|
|
268
|
+
* @param stubsRoot - Root directory containing stub files
|
|
269
|
+
* @param stubPath - Path to the specific stub file
|
|
270
|
+
* @param stubState - Template variables for stub generation
|
|
271
|
+
*
|
|
272
|
+
* @example
|
|
273
|
+
* ```ts
|
|
274
|
+
* const result = await codemods.makeUsingStub(
|
|
275
|
+
* './stubs',
|
|
276
|
+
* 'controller.stub',
|
|
277
|
+
* {
|
|
278
|
+
* filename: 'UserController',
|
|
279
|
+
* entity: { name: 'User', modelName: 'User' },
|
|
280
|
+
* resourceful: true
|
|
281
|
+
* }
|
|
282
|
+
* )
|
|
283
|
+
* ```
|
|
224
284
|
*/
|
|
225
285
|
async makeUsingStub(stubsRoot, stubPath, stubState) {
|
|
226
286
|
const stubs = await this.#app.stubs.create();
|
|
227
287
|
const stub = await stubs.build(stubPath, { source: stubsRoot });
|
|
228
288
|
const output = await stub.generate({ force: this.overwriteExisting, ...stubState });
|
|
229
|
-
const entityFileName =
|
|
289
|
+
const entityFileName = stringHelpers.toUnixSlash(this.#app.relativePath(output.destination));
|
|
230
290
|
const result = { ...output, relativeFileName: entityFileName };
|
|
231
291
|
if (output.status === 'skipped') {
|
|
232
292
|
this.#cliLogger.action(`create ${entityFileName}`).skipped(output.skipReason);
|
|
@@ -244,7 +304,7 @@ export class Codemods extends EventEmitter {
|
|
|
244
304
|
* this.installPackages([{ name: '@adonisjs/lucid@next', isDevDependency: false }])
|
|
245
305
|
* ```
|
|
246
306
|
*/
|
|
247
|
-
async installPackages(packages) {
|
|
307
|
+
async installPackages(packages, packageManager) {
|
|
248
308
|
const transformer = await this.#getCodeTransformer();
|
|
249
309
|
const appPath = this.#app.makePath();
|
|
250
310
|
const colors = this.#cliLogger.getColors();
|
|
@@ -254,30 +314,37 @@ export class Codemods extends EventEmitter {
|
|
|
254
314
|
this.#cliLogger.warning('Cannot install packages. Install "@adonisjs/assembler" or manually install following packages');
|
|
255
315
|
this.#cliLogger.log(`devDependencies: ${devDependencies.join(',')}`);
|
|
256
316
|
this.#cliLogger.log(`dependencies: ${dependencies.join(',')}`);
|
|
257
|
-
return;
|
|
317
|
+
return false;
|
|
258
318
|
}
|
|
259
|
-
|
|
260
|
-
const spinner = this.#cliLogger.await(`installing dependencies using ${packageManager
|
|
319
|
+
packageManager = packageManager ?? (await transformer.detectPackageManager(appPath)) ?? 'npm';
|
|
320
|
+
const spinner = this.#cliLogger.await(`installing dependencies using ${packageManager} `);
|
|
261
321
|
const silentLogs = !this.verboseInstallOutput;
|
|
262
322
|
if (silentLogs) {
|
|
263
323
|
spinner.start();
|
|
264
324
|
}
|
|
265
325
|
try {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
326
|
+
if (dependencies.length) {
|
|
327
|
+
await transformer.installPackage(dependencies, {
|
|
328
|
+
cwd: appPath,
|
|
329
|
+
silent: silentLogs,
|
|
330
|
+
packageManager,
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
if (devDependencies.length) {
|
|
334
|
+
await transformer.installPackage(devDependencies, {
|
|
335
|
+
dev: true,
|
|
336
|
+
cwd: appPath,
|
|
337
|
+
silent: silentLogs,
|
|
338
|
+
packageManager,
|
|
339
|
+
});
|
|
340
|
+
}
|
|
275
341
|
if (silentLogs) {
|
|
276
342
|
spinner.stop();
|
|
277
343
|
}
|
|
278
344
|
this.#cliLogger.success('Packages installed');
|
|
279
345
|
this.#cliLogger.log(devDependencies.map((dependency) => ` ${colors.dim('dev')} ${dependency} `).join('\n'));
|
|
280
346
|
this.#cliLogger.log(dependencies.map((dependency) => ` ${colors.dim('prod')} ${dependency} `).join('\n'));
|
|
347
|
+
return true;
|
|
281
348
|
}
|
|
282
349
|
catch (error) {
|
|
283
350
|
if (silentLogs) {
|
|
@@ -286,6 +353,7 @@ export class Codemods extends EventEmitter {
|
|
|
286
353
|
}
|
|
287
354
|
this.#cliLogger.fatal(error);
|
|
288
355
|
this.emit('error', error);
|
|
356
|
+
return false;
|
|
289
357
|
}
|
|
290
358
|
}
|
|
291
359
|
/**
|
|
@@ -1,10 +1,24 @@
|
|
|
1
1
|
import { BaseCommand as AceBaseCommand, ListCommand as AceListCommand } from '@adonisjs/ace';
|
|
2
|
-
import { Kernel } from './kernel.
|
|
3
|
-
import type { ApplicationService } from '../../src/types.
|
|
4
|
-
import type { CommandOptions, ParsedOutput, UIPrimitives } from '../../types/ace.
|
|
2
|
+
import { type Kernel } from './kernel.ts';
|
|
3
|
+
import type { ApplicationService } from '../../src/types.ts';
|
|
4
|
+
import type { CommandOptions, ParsedOutput, UIPrimitives } from '../../types/ace.ts';
|
|
5
5
|
/**
|
|
6
|
-
* The base command
|
|
7
|
-
*
|
|
6
|
+
* The base command class for creating custom Ace commands in AdonisJS applications.
|
|
7
|
+
* This class extends the base Ace command with AdonisJS-specific functionality like
|
|
8
|
+
* dependency injection and application lifecycle management.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* export default class MakeUser extends BaseCommand {
|
|
13
|
+
* static commandName = 'make:user'
|
|
14
|
+
* static description = 'Create a new user'
|
|
15
|
+
*
|
|
16
|
+
* async run() {
|
|
17
|
+
* this.logger.info('Creating user...')
|
|
18
|
+
* // Command implementation
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
8
22
|
*/
|
|
9
23
|
export declare class BaseCommand extends AceBaseCommand {
|
|
10
24
|
app: ApplicationService;
|
|
@@ -14,7 +28,17 @@ export declare class BaseCommand extends AceBaseCommand {
|
|
|
14
28
|
get startApp(): boolean | undefined;
|
|
15
29
|
constructor(app: ApplicationService, kernel: Kernel, parsed: ParsedOutput, ui: UIPrimitives, prompt: Kernel['prompt']);
|
|
16
30
|
/**
|
|
17
|
-
* Creates the codemods module to modify source files
|
|
31
|
+
* Creates the codemods module to modify source files programmatically.
|
|
32
|
+
* This method provides access to AST-based code transformations.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* const codemods = await this.createCodemods()
|
|
37
|
+
* await codemods.makeUsingStub(stubsRoot, 'controller.stub', {
|
|
38
|
+
* filename: 'UserController',
|
|
39
|
+
* entity: { name: 'User' }
|
|
40
|
+
* })
|
|
41
|
+
* ```
|
|
18
42
|
*/
|
|
19
43
|
createCodemods(): Promise<import("./codemods.js").Codemods>;
|
|
20
44
|
/**
|
|
@@ -39,19 +63,29 @@ export declare class BaseCommand extends AceBaseCommand {
|
|
|
39
63
|
*/
|
|
40
64
|
completed?(..._: any[]): any;
|
|
41
65
|
/**
|
|
42
|
-
* Executes the command
|
|
66
|
+
* Executes the lifecycle hooks and the run method from the command
|
|
43
67
|
*/
|
|
44
68
|
exec(): Promise<any>;
|
|
45
69
|
/**
|
|
46
|
-
* Terminate the
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
70
|
+
* Terminate the application gracefully. This method should be preferred over
|
|
71
|
+
* calling `app.terminate()` directly as it only triggers termination when
|
|
72
|
+
* the current command is the main command responsible for the process.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* export default class SomeCommand extends BaseCommand {
|
|
77
|
+
* async run() {
|
|
78
|
+
* // Do some work
|
|
79
|
+
* await this.terminate()
|
|
80
|
+
* }
|
|
81
|
+
* }
|
|
82
|
+
* ```
|
|
50
83
|
*/
|
|
51
84
|
terminate(): Promise<void>;
|
|
52
85
|
}
|
|
53
86
|
/**
|
|
54
|
-
* The List command is used to display a list of commands
|
|
87
|
+
* The List command is used to display a list of available commands.
|
|
88
|
+
* This command extends the base Ace ListCommand with AdonisJS-specific functionality.
|
|
55
89
|
*/
|
|
56
90
|
export declare class ListCommand extends AceListCommand implements BaseCommand {
|
|
57
91
|
app: ApplicationService;
|
|
@@ -61,7 +95,8 @@ export declare class ListCommand extends AceListCommand implements BaseCommand {
|
|
|
61
95
|
get startApp(): boolean | undefined;
|
|
62
96
|
constructor(app: ApplicationService, kernel: Kernel, parsed: ParsedOutput, ui: UIPrimitives, prompt: Kernel['prompt']);
|
|
63
97
|
/**
|
|
64
|
-
* Creates the codemods module to modify source files
|
|
98
|
+
* Creates the codemods module to modify source files programmatically.
|
|
99
|
+
* This method provides access to AST-based code transformations.
|
|
65
100
|
*/
|
|
66
101
|
createCodemods(): Promise<import("./codemods.js").Codemods>;
|
|
67
102
|
/**
|
|
@@ -8,8 +8,22 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { BaseCommand as AceBaseCommand, ListCommand as AceListCommand } from '@adonisjs/ace';
|
|
10
10
|
/**
|
|
11
|
-
* The base command
|
|
12
|
-
*
|
|
11
|
+
* The base command class for creating custom Ace commands in AdonisJS applications.
|
|
12
|
+
* This class extends the base Ace command with AdonisJS-specific functionality like
|
|
13
|
+
* dependency injection and application lifecycle management.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* export default class MakeUser extends BaseCommand {
|
|
18
|
+
* static commandName = 'make:user'
|
|
19
|
+
* static description = 'Create a new user'
|
|
20
|
+
*
|
|
21
|
+
* async run() {
|
|
22
|
+
* this.logger.info('Creating user...')
|
|
23
|
+
* // Command implementation
|
|
24
|
+
* }
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
13
27
|
*/
|
|
14
28
|
export class BaseCommand extends AceBaseCommand {
|
|
15
29
|
app;
|
|
@@ -27,7 +41,17 @@ export class BaseCommand extends AceBaseCommand {
|
|
|
27
41
|
this.kernel = kernel;
|
|
28
42
|
}
|
|
29
43
|
/**
|
|
30
|
-
* Creates the codemods module to modify source files
|
|
44
|
+
* Creates the codemods module to modify source files programmatically.
|
|
45
|
+
* This method provides access to AST-based code transformations.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* const codemods = await this.createCodemods()
|
|
50
|
+
* await codemods.makeUsingStub(stubsRoot, 'controller.stub', {
|
|
51
|
+
* filename: 'UserController',
|
|
52
|
+
* entity: { name: 'User' }
|
|
53
|
+
* })
|
|
54
|
+
* ```
|
|
31
55
|
*/
|
|
32
56
|
async createCodemods() {
|
|
33
57
|
const { Codemods } = await import('./codemods.js');
|
|
@@ -38,7 +62,7 @@ export class BaseCommand extends AceBaseCommand {
|
|
|
38
62
|
return codemods;
|
|
39
63
|
}
|
|
40
64
|
/**
|
|
41
|
-
* Executes the command
|
|
65
|
+
* Executes the lifecycle hooks and the run method from the command
|
|
42
66
|
*/
|
|
43
67
|
async exec() {
|
|
44
68
|
this.hydrate();
|
|
@@ -72,10 +96,19 @@ export class BaseCommand extends AceBaseCommand {
|
|
|
72
96
|
return this.result;
|
|
73
97
|
}
|
|
74
98
|
/**
|
|
75
|
-
* Terminate the
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
99
|
+
* Terminate the application gracefully. This method should be preferred over
|
|
100
|
+
* calling `app.terminate()` directly as it only triggers termination when
|
|
101
|
+
* the current command is the main command responsible for the process.
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```ts
|
|
105
|
+
* export default class SomeCommand extends BaseCommand {
|
|
106
|
+
* async run() {
|
|
107
|
+
* // Do some work
|
|
108
|
+
* await this.terminate()
|
|
109
|
+
* }
|
|
110
|
+
* }
|
|
111
|
+
* ```
|
|
79
112
|
*/
|
|
80
113
|
async terminate() {
|
|
81
114
|
if (this.kernel.getMainCommand() === this) {
|
|
@@ -84,7 +117,8 @@ export class BaseCommand extends AceBaseCommand {
|
|
|
84
117
|
}
|
|
85
118
|
}
|
|
86
119
|
/**
|
|
87
|
-
* The List command is used to display a list of commands
|
|
120
|
+
* The List command is used to display a list of available commands.
|
|
121
|
+
* This command extends the base Ace ListCommand with AdonisJS-specific functionality.
|
|
88
122
|
*/
|
|
89
123
|
export class ListCommand extends AceListCommand {
|
|
90
124
|
app;
|
|
@@ -102,7 +136,8 @@ export class ListCommand extends AceListCommand {
|
|
|
102
136
|
this.kernel = kernel;
|
|
103
137
|
}
|
|
104
138
|
/**
|
|
105
|
-
* Creates the codemods module to modify source files
|
|
139
|
+
* Creates the codemods module to modify source files programmatically.
|
|
140
|
+
* This method provides access to AST-based code transformations.
|
|
106
141
|
*/
|
|
107
142
|
async createCodemods() {
|
|
108
143
|
const { Codemods } = await import('./codemods.js');
|
|
@@ -1,12 +1,23 @@
|
|
|
1
|
-
import { Kernel } from './main.
|
|
2
|
-
import type { ApplicationService } from '../../src/types.
|
|
1
|
+
import { Kernel } from './main.ts';
|
|
2
|
+
import type { ApplicationService } from '../../src/types.ts';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Create and configure an Ace command kernel for AdonisJS applications.
|
|
5
|
+
* This function abstracts the kernel setup logic and can be used in different
|
|
6
|
+
* environments with appropriate configurations.
|
|
7
7
|
*
|
|
8
|
-
* - In console environment,
|
|
9
|
-
* - In other environments,
|
|
10
|
-
*
|
|
8
|
+
* - In console environment, Ace manages the lifecycle of the process
|
|
9
|
+
* - In other environments, Ace can be pulled from the container to run commands
|
|
10
|
+
*
|
|
11
|
+
* @param app - The AdonisJS application service instance
|
|
12
|
+
* @param commandName - Optional specific command name for optimized loading
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* const app = new Application(new URL('../', import.meta.url))
|
|
17
|
+
* const kernel = createAceKernel(app)
|
|
18
|
+
*
|
|
19
|
+
* // Run a specific command
|
|
20
|
+
* await kernel.handle(['make:controller', 'UserController'])
|
|
21
|
+
* ```
|
|
11
22
|
*/
|
|
12
23
|
export declare function createAceKernel(app: ApplicationService, commandName?: string): Kernel;
|
|
@@ -6,16 +6,27 @@
|
|
|
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 { Kernel } from
|
|
10
|
-
import { FsLoader, HelpCommand } from
|
|
9
|
+
import { Kernel } from "./main.js";
|
|
10
|
+
import { FsLoader, HelpCommand } from "../../modules/ace/main.js";
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
12
|
+
* Create and configure an Ace command kernel for AdonisJS applications.
|
|
13
|
+
* This function abstracts the kernel setup logic and can be used in different
|
|
14
|
+
* environments with appropriate configurations.
|
|
15
15
|
*
|
|
16
|
-
* - In console environment,
|
|
17
|
-
* - In other environments,
|
|
18
|
-
*
|
|
16
|
+
* - In console environment, Ace manages the lifecycle of the process
|
|
17
|
+
* - In other environments, Ace can be pulled from the container to run commands
|
|
18
|
+
*
|
|
19
|
+
* @param app - The AdonisJS application service instance
|
|
20
|
+
* @param commandName - Optional specific command name for optimized loading
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* const app = new Application(new URL('../', import.meta.url))
|
|
25
|
+
* const kernel = createAceKernel(app)
|
|
26
|
+
*
|
|
27
|
+
* // Run a specific command
|
|
28
|
+
* await kernel.handle(['make:controller', 'UserController'])
|
|
29
|
+
* ```
|
|
19
30
|
*/
|
|
20
31
|
export function createAceKernel(app, commandName) {
|
|
21
32
|
const kernel = new Kernel(app);
|
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
import { Kernel as AceKernel } from '@adonisjs/ace';
|
|
2
|
-
import { BaseCommand } from './commands.
|
|
3
|
-
import type { ApplicationService } from '../../src/types.
|
|
2
|
+
import { type BaseCommand } from './commands.ts';
|
|
3
|
+
import type { ApplicationService } from '../../src/types.ts';
|
|
4
4
|
/**
|
|
5
|
-
* The
|
|
6
|
-
*
|
|
5
|
+
* The Ace command kernel for AdonisJS applications. This kernel extends the base
|
|
6
|
+
* Ace kernel with AdonisJS-specific functionality like dependency injection and
|
|
7
|
+
* application lifecycle management.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* const app = new Application(new URL('../', import.meta.url))
|
|
12
|
+
* const kernel = new Kernel(app)
|
|
13
|
+
*
|
|
14
|
+
* await kernel.handle(['make:controller', 'UserController'])
|
|
15
|
+
* ```
|
|
7
16
|
*/
|
|
8
17
|
export declare class Kernel extends AceKernel<typeof BaseCommand> {
|
|
9
18
|
app: ApplicationService;
|
|
19
|
+
/**
|
|
20
|
+
* Create a new Ace kernel instance
|
|
21
|
+
*
|
|
22
|
+
* @param app - The AdonisJS application instance
|
|
23
|
+
*/
|
|
10
24
|
constructor(app: ApplicationService);
|
|
11
25
|
}
|
|
@@ -7,13 +7,27 @@
|
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
9
|
import { Kernel as AceKernel } from '@adonisjs/ace';
|
|
10
|
-
import { ListCommand } from
|
|
10
|
+
import { ListCommand } from "./commands.js";
|
|
11
11
|
/**
|
|
12
|
-
* The
|
|
13
|
-
*
|
|
12
|
+
* The Ace command kernel for AdonisJS applications. This kernel extends the base
|
|
13
|
+
* Ace kernel with AdonisJS-specific functionality like dependency injection and
|
|
14
|
+
* application lifecycle management.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* const app = new Application(new URL('../', import.meta.url))
|
|
19
|
+
* const kernel = new Kernel(app)
|
|
20
|
+
*
|
|
21
|
+
* await kernel.handle(['make:controller', 'UserController'])
|
|
22
|
+
* ```
|
|
14
23
|
*/
|
|
15
24
|
export class Kernel extends AceKernel {
|
|
16
25
|
app;
|
|
26
|
+
/**
|
|
27
|
+
* Create a new Ace kernel instance
|
|
28
|
+
*
|
|
29
|
+
* @param app - The AdonisJS application instance
|
|
30
|
+
*/
|
|
17
31
|
constructor(app) {
|
|
18
32
|
super(ListCommand, {
|
|
19
33
|
create: async (command, parsedOutput, $kernel) => {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { Kernel } from './kernel.
|
|
2
|
-
export { BaseCommand, ListCommand } from './commands.
|
|
3
|
-
export { args, flags, errors, Parser, FsLoader, ListLoader, cliHelpers, HelpCommand, IndexGenerator, } from '@adonisjs/ace';
|
|
1
|
+
export { Kernel } from './kernel.ts';
|
|
2
|
+
export { BaseCommand, ListCommand } from './commands.ts';
|
|
3
|
+
export { args, flags, errors, Parser, FsLoader, ListLoader, cliHelpers, HelpCommand, IndexGenerator, tracingChannels, } from '@adonisjs/ace';
|
|
@@ -6,6 +6,6 @@
|
|
|
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
|
-
export { Kernel } from
|
|
10
|
-
export { BaseCommand, ListCommand } from
|
|
11
|
-
export { args, flags, errors, Parser, FsLoader, ListLoader, cliHelpers, HelpCommand, IndexGenerator, } from '@adonisjs/ace';
|
|
9
|
+
export { Kernel } from "./kernel.js";
|
|
10
|
+
export { BaseCommand, ListCommand } from "./commands.js";
|
|
11
|
+
export { args, flags, errors, Parser, FsLoader, ListLoader, cliHelpers, HelpCommand, IndexGenerator, tracingChannels, } from '@adonisjs/ace';
|
|
@@ -1,8 +1,29 @@
|
|
|
1
|
-
import { ConsoleDumpConfig } from '@poppinss/dumper/console/types';
|
|
2
|
-
import { HTMLDumpConfig } from '@poppinss/dumper/html/types';
|
|
1
|
+
import { type ConsoleDumpConfig } from '@poppinss/dumper/console/types';
|
|
2
|
+
import { type HTMLDumpConfig } from '@poppinss/dumper/html/types';
|
|
3
3
|
/**
|
|
4
|
-
* Define
|
|
5
|
-
*
|
|
4
|
+
* Define configuration for the dumper service exported by the
|
|
5
|
+
* "@adonisjs/core/services/dumper" module. This function allows
|
|
6
|
+
* you to customize HTML and console output formatting options.
|
|
7
|
+
*
|
|
8
|
+
* @param dumperConfig - Configuration object with HTML and console options
|
|
9
|
+
* @param dumperConfig.html - HTML output formatting configuration
|
|
10
|
+
* @param dumperConfig.console - Console output formatting configuration
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* export default defineConfig({
|
|
15
|
+
* html: {
|
|
16
|
+
* showHidden: true,
|
|
17
|
+
* depth: 5,
|
|
18
|
+
* colors: true
|
|
19
|
+
* },
|
|
20
|
+
* console: {
|
|
21
|
+
* showHidden: false,
|
|
22
|
+
* depth: 3,
|
|
23
|
+
* collapse: ['Date', 'DateTime']
|
|
24
|
+
* }
|
|
25
|
+
* })
|
|
26
|
+
* ```
|
|
6
27
|
*/
|
|
7
28
|
export declare function defineConfig(dumperConfig: Partial<{
|
|
8
29
|
html: HTMLDumpConfig;
|
|
@@ -7,8 +7,29 @@
|
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
9
|
/**
|
|
10
|
-
* Define
|
|
11
|
-
*
|
|
10
|
+
* Define configuration for the dumper service exported by the
|
|
11
|
+
* "@adonisjs/core/services/dumper" module. This function allows
|
|
12
|
+
* you to customize HTML and console output formatting options.
|
|
13
|
+
*
|
|
14
|
+
* @param dumperConfig - Configuration object with HTML and console options
|
|
15
|
+
* @param dumperConfig.html - HTML output formatting configuration
|
|
16
|
+
* @param dumperConfig.console - Console output formatting configuration
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* export default defineConfig({
|
|
21
|
+
* html: {
|
|
22
|
+
* showHidden: true,
|
|
23
|
+
* depth: 5,
|
|
24
|
+
* colors: true
|
|
25
|
+
* },
|
|
26
|
+
* console: {
|
|
27
|
+
* showHidden: false,
|
|
28
|
+
* depth: 3,
|
|
29
|
+
* collapse: ['Date', 'DateTime']
|
|
30
|
+
* }
|
|
31
|
+
* })
|
|
32
|
+
* ```
|
|
12
33
|
*/
|
|
13
34
|
export function defineConfig(dumperConfig) {
|
|
14
35
|
return dumperConfig;
|