@adonisjs/core 7.0.0-next.0 → 7.0.0-next.10
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 +32 -0
- package/build/commands/add.js +17 -0
- package/build/commands/build.d.ts +22 -0
- package/build/commands/build.js +18 -0
- package/build/commands/commands.json +1 -1
- package/build/commands/configure.d.ts +32 -9
- package/build/commands/configure.js +36 -9
- package/build/commands/eject.d.ts +27 -2
- package/build/commands/eject.js +21 -2
- package/build/commands/env/add.d.ts +39 -2
- package/build/commands/env/add.js +30 -3
- package/build/commands/generate_key.d.ts +19 -0
- package/build/commands/generate_key.js +13 -0
- package/build/commands/inspect_rcfile.d.ts +19 -1
- package/build/commands/inspect_rcfile.js +19 -1
- package/build/commands/list/routes.d.ts +31 -9
- package/build/commands/list/routes.js +26 -3
- package/build/commands/make/command.d.ts +25 -2
- package/build/commands/make/command.js +22 -2
- package/build/commands/make/controller.d.ts +33 -0
- package/build/commands/make/controller.js +18 -0
- package/build/commands/make/event.d.ts +28 -2
- package/build/commands/make/event.js +25 -2
- package/build/commands/make/exception.d.ts +28 -2
- package/build/commands/make/exception.js +25 -2
- package/build/commands/make/listener.d.ts +36 -3
- package/build/commands/make/listener.js +30 -3
- package/build/commands/make/middleware.d.ts +23 -0
- package/build/commands/make/middleware.js +17 -0
- package/build/commands/make/preload.d.ts +30 -3
- package/build/commands/make/preload.js +24 -4
- package/build/commands/make/provider.d.ts +31 -2
- package/build/commands/make/provider.js +25 -3
- package/build/commands/make/service.d.ts +19 -0
- package/build/commands/make/service.js +16 -0
- package/build/commands/make/test.d.ts +26 -3
- package/build/commands/make/test.js +34 -6
- package/build/commands/make/transformer.d.ts +43 -0
- package/build/commands/make/transformer.js +65 -0
- package/build/commands/make/validator.d.ts +34 -3
- package/build/commands/make/validator.js +28 -3
- package/build/commands/make/view.d.ts +25 -2
- package/build/commands/make/view.js +22 -2
- package/build/commands/repl.d.ts +22 -2
- package/build/commands/repl.js +22 -2
- package/build/commands/serve.d.ts +36 -0
- package/build/commands/serve.js +26 -9
- package/build/commands/test.d.ts +66 -3
- package/build/commands/test.js +37 -13
- package/build/modules/ace/codemods.d.ts +109 -14
- package/build/modules/ace/codemods.js +119 -16
- package/build/modules/ace/commands.d.ts +0 -1
- package/build/modules/ace/commands.js +0 -3
- package/build/modules/ace/main.d.ts +30 -0
- package/build/modules/ace/main.js +30 -0
- package/build/modules/app.d.ts +17 -0
- package/build/modules/app.js +17 -0
- package/build/modules/config.d.ts +17 -0
- package/build/modules/config.js +17 -0
- package/build/modules/dumper/dumper.d.ts +5 -0
- package/build/modules/dumper/dumper.js +11 -1
- package/build/modules/dumper/main.d.ts +21 -0
- package/build/modules/dumper/main.js +21 -0
- package/build/modules/encryption.d.ts +17 -0
- package/build/modules/encryption.js +17 -0
- package/build/modules/env/main.d.ts +19 -0
- package/build/modules/env/main.js +19 -0
- package/build/modules/hash/drivers/bcrypt.d.ts +11 -0
- package/build/modules/hash/drivers/bcrypt.js +11 -0
- package/build/modules/hash/main.d.ts +18 -0
- package/build/modules/hash/main.js +18 -0
- package/build/modules/http/url_builder_client.d.ts +1 -0
- package/build/modules/http/url_builder_client.js +9 -0
- package/build/providers/app_provider.d.ts +11 -23
- package/build/providers/app_provider.js +41 -45
- package/build/providers/edge_provider.js +62 -1
- package/build/src/assembler_hooks/index_entities.d.ts +3 -17
- package/build/src/assembler_hooks/index_entities.js +31 -15
- package/build/src/cli_formatters/routes_list.js +23 -7
- package/build/src/helpers/http.d.ts +20 -0
- package/build/src/helpers/http.js +28 -0
- package/build/src/helpers/main.d.ts +1 -5
- package/build/src/helpers/main.js +1 -5
- package/build/src/helpers/string.js +24 -0
- package/build/src/helpers/types.d.ts +1 -0
- package/build/src/ignitor/http.js +18 -5
- package/build/src/types.d.ts +7 -0
- package/build/src/utils.d.ts +26 -0
- package/build/src/utils.js +65 -0
- package/build/src/vine.js +14 -6
- package/build/stubs/make/transformer/main.stub +18 -0
- package/build/types/common.d.ts +1 -0
- package/build/types/common.js +9 -0
- package/build/types/helpers.d.ts +20 -0
- package/build/types/http.d.ts +1 -0
- package/package.json +26 -23
|
@@ -1,14 +1,37 @@
|
|
|
1
1
|
import { BaseCommand } from '../../modules/ace/main.ts';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Command to create a new Edge.js template file.
|
|
4
|
+
* Edge templates are used for rendering HTML views in your web application,
|
|
5
|
+
* supporting layouts, partials, components, and template inheritance.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```
|
|
9
|
+
* ace make:view home
|
|
10
|
+
* ace make:view users/profile
|
|
11
|
+
* ace make:view components/navbar
|
|
12
|
+
* ace make:view layouts/app
|
|
13
|
+
* ```
|
|
4
14
|
*/
|
|
5
15
|
export default class MakeView extends BaseCommand {
|
|
16
|
+
/**
|
|
17
|
+
* The command name
|
|
18
|
+
*/
|
|
6
19
|
static commandName: string;
|
|
20
|
+
/**
|
|
21
|
+
* The command description
|
|
22
|
+
*/
|
|
7
23
|
static description: string;
|
|
24
|
+
/**
|
|
25
|
+
* Name of the template file to create
|
|
26
|
+
*/
|
|
8
27
|
name: string;
|
|
9
28
|
/**
|
|
10
|
-
* The stub to use for generating the template
|
|
29
|
+
* The stub template file to use for generating the Edge template
|
|
11
30
|
*/
|
|
12
31
|
protected stubPath: string;
|
|
32
|
+
/**
|
|
33
|
+
* Execute the command to create a new Edge.js template file.
|
|
34
|
+
* Generates the template file in the views directory.
|
|
35
|
+
*/
|
|
13
36
|
run(): Promise<void>;
|
|
14
37
|
}
|
|
@@ -15,15 +15,35 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
15
15
|
import { stubsRoot } from "../../stubs/main.js";
|
|
16
16
|
import { args, BaseCommand } from "../../modules/ace/main.js";
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
18
|
+
* Command to create a new Edge.js template file.
|
|
19
|
+
* Edge templates are used for rendering HTML views in your web application,
|
|
20
|
+
* supporting layouts, partials, components, and template inheritance.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```
|
|
24
|
+
* ace make:view home
|
|
25
|
+
* ace make:view users/profile
|
|
26
|
+
* ace make:view components/navbar
|
|
27
|
+
* ace make:view layouts/app
|
|
28
|
+
* ```
|
|
19
29
|
*/
|
|
20
30
|
export default class MakeView extends BaseCommand {
|
|
31
|
+
/**
|
|
32
|
+
* The command name
|
|
33
|
+
*/
|
|
21
34
|
static commandName = 'make:view';
|
|
35
|
+
/**
|
|
36
|
+
* The command description
|
|
37
|
+
*/
|
|
22
38
|
static description = 'Create a new Edge.js template file';
|
|
23
39
|
/**
|
|
24
|
-
* The stub to use for generating the template
|
|
40
|
+
* The stub template file to use for generating the Edge template
|
|
25
41
|
*/
|
|
26
42
|
stubPath = 'make/view/main.stub';
|
|
43
|
+
/**
|
|
44
|
+
* Execute the command to create a new Edge.js template file.
|
|
45
|
+
* Generates the template file in the views directory.
|
|
46
|
+
*/
|
|
27
47
|
async run() {
|
|
28
48
|
const codemods = await this.createCodemods();
|
|
29
49
|
await codemods.makeUsingStub(stubsRoot, this.stubPath, {
|
package/build/commands/repl.d.ts
CHANGED
|
@@ -1,14 +1,34 @@
|
|
|
1
1
|
import { BaseCommand } from '../modules/ace/main.ts';
|
|
2
2
|
import { type CommandOptions } from '../types/ace.ts';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Command to start an interactive REPL (Read-Eval-Print Loop) session for AdonisJS.
|
|
5
|
+
* The REPL provides a command-line interface where you can execute JavaScript code
|
|
6
|
+
* in the context of your AdonisJS application, allowing you to interact with models,
|
|
7
|
+
* services, and other application components in real-time.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```
|
|
11
|
+
* ace repl
|
|
12
|
+
* ```
|
|
5
13
|
*/
|
|
6
14
|
export default class ReplCommand extends BaseCommand {
|
|
15
|
+
/**
|
|
16
|
+
* The command name
|
|
17
|
+
*/
|
|
7
18
|
static commandName: string;
|
|
19
|
+
/**
|
|
20
|
+
* The command description
|
|
21
|
+
*/
|
|
8
22
|
static description: string;
|
|
23
|
+
/**
|
|
24
|
+
* Command options configuration.
|
|
25
|
+
* Requires the application to be started and keeps the process alive.
|
|
26
|
+
*/
|
|
9
27
|
static options: CommandOptions;
|
|
10
28
|
/**
|
|
11
|
-
*
|
|
29
|
+
* Execute the command to start the REPL server.
|
|
30
|
+
* Creates a REPL instance from the container and sets up an exit handler
|
|
31
|
+
* that properly terminates the application when the REPL session ends.
|
|
12
32
|
*/
|
|
13
33
|
run(): Promise<void>;
|
|
14
34
|
}
|
package/build/commands/repl.js
CHANGED
|
@@ -8,17 +8,37 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { BaseCommand } from "../modules/ace/main.js";
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* Command to start an interactive REPL (Read-Eval-Print Loop) session for AdonisJS.
|
|
12
|
+
* The REPL provides a command-line interface where you can execute JavaScript code
|
|
13
|
+
* in the context of your AdonisJS application, allowing you to interact with models,
|
|
14
|
+
* services, and other application components in real-time.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```
|
|
18
|
+
* ace repl
|
|
19
|
+
* ```
|
|
12
20
|
*/
|
|
13
21
|
export default class ReplCommand extends BaseCommand {
|
|
22
|
+
/**
|
|
23
|
+
* The command name
|
|
24
|
+
*/
|
|
14
25
|
static commandName = 'repl';
|
|
26
|
+
/**
|
|
27
|
+
* The command description
|
|
28
|
+
*/
|
|
15
29
|
static description = 'Start a new REPL session';
|
|
30
|
+
/**
|
|
31
|
+
* Command options configuration.
|
|
32
|
+
* Requires the application to be started and keeps the process alive.
|
|
33
|
+
*/
|
|
16
34
|
static options = {
|
|
17
35
|
startApp: true,
|
|
18
36
|
staysAlive: true,
|
|
19
37
|
};
|
|
20
38
|
/**
|
|
21
|
-
*
|
|
39
|
+
* Execute the command to start the REPL server.
|
|
40
|
+
* Creates a REPL instance from the container and sets up an exit handler
|
|
41
|
+
* that properly terminates the application when the REPL session ends.
|
|
22
42
|
*/
|
|
23
43
|
async run() {
|
|
24
44
|
const repl = await this.app.container.make('repl');
|
|
@@ -5,17 +5,53 @@ import { BaseCommand } from '../modules/ace/main.ts';
|
|
|
5
5
|
* Serve command is used to run the AdonisJS HTTP server during development. The
|
|
6
6
|
* command under the hood runs the "bin/server.ts" file and watches for file
|
|
7
7
|
* system changes
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```
|
|
11
|
+
* ace serve
|
|
12
|
+
* ace serve --watch
|
|
13
|
+
* ace serve --hmr
|
|
14
|
+
* ace serve --poll
|
|
15
|
+
* ace serve --no-clear
|
|
16
|
+
* ```
|
|
8
17
|
*/
|
|
9
18
|
export default class Serve extends BaseCommand {
|
|
10
19
|
#private;
|
|
20
|
+
/**
|
|
21
|
+
* The command name
|
|
22
|
+
*/
|
|
11
23
|
static commandName: string;
|
|
24
|
+
/**
|
|
25
|
+
* The command description
|
|
26
|
+
*/
|
|
12
27
|
static description: string;
|
|
28
|
+
/**
|
|
29
|
+
* Help text for the command
|
|
30
|
+
*/
|
|
13
31
|
static help: string[];
|
|
32
|
+
/**
|
|
33
|
+
* Command options configuration
|
|
34
|
+
*/
|
|
14
35
|
static options: CommandOptions;
|
|
36
|
+
/**
|
|
37
|
+
* The development server instance
|
|
38
|
+
*/
|
|
15
39
|
devServer: DevServer;
|
|
40
|
+
/**
|
|
41
|
+
* Start the server with HMR support
|
|
42
|
+
*/
|
|
16
43
|
hmr?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Watch filesystem and restart the HTTP server on file change
|
|
46
|
+
*/
|
|
17
47
|
watch?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Use polling to detect filesystem changes
|
|
50
|
+
*/
|
|
18
51
|
poll?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Clear the terminal for new logs after file change
|
|
54
|
+
*/
|
|
19
55
|
clear?: boolean;
|
|
20
56
|
/**
|
|
21
57
|
* Runs the HTTP server
|
package/build/commands/serve.js
CHANGED
|
@@ -12,16 +12,34 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
12
12
|
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;
|
|
13
13
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
14
14
|
};
|
|
15
|
+
import { importAssembler } from "../src/utils.js";
|
|
15
16
|
import { BaseCommand, flags } from "../modules/ace/main.js";
|
|
16
|
-
import { importAssembler, importTypeScript } from "../src/utils.js";
|
|
17
17
|
/**
|
|
18
18
|
* Serve command is used to run the AdonisJS HTTP server during development. The
|
|
19
19
|
* command under the hood runs the "bin/server.ts" file and watches for file
|
|
20
20
|
* system changes
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```
|
|
24
|
+
* ace serve
|
|
25
|
+
* ace serve --watch
|
|
26
|
+
* ace serve --hmr
|
|
27
|
+
* ace serve --poll
|
|
28
|
+
* ace serve --no-clear
|
|
29
|
+
* ```
|
|
21
30
|
*/
|
|
22
31
|
export default class Serve extends BaseCommand {
|
|
32
|
+
/**
|
|
33
|
+
* The command name
|
|
34
|
+
*/
|
|
23
35
|
static commandName = 'serve';
|
|
36
|
+
/**
|
|
37
|
+
* The command description
|
|
38
|
+
*/
|
|
24
39
|
static description = 'Start the development HTTP server along with the file watcher to perform restarts on file change';
|
|
40
|
+
/**
|
|
41
|
+
* Help text for the command
|
|
42
|
+
*/
|
|
25
43
|
static help = [
|
|
26
44
|
'Start the development server with file watcher using the following command.',
|
|
27
45
|
'```',
|
|
@@ -39,11 +57,16 @@ export default class Serve extends BaseCommand {
|
|
|
39
57
|
'{{ binaryName }} serve --assets-args="--debug --base=/public"',
|
|
40
58
|
'```',
|
|
41
59
|
];
|
|
60
|
+
/**
|
|
61
|
+
* Command options configuration
|
|
62
|
+
*/
|
|
42
63
|
static options = {
|
|
43
64
|
staysAlive: true,
|
|
44
65
|
};
|
|
45
66
|
/**
|
|
46
67
|
* Log a development dependency is missing
|
|
68
|
+
*
|
|
69
|
+
* @param dependency - The name of the missing dependency
|
|
47
70
|
*/
|
|
48
71
|
#logMissingDevelopmentDependency(dependency) {
|
|
49
72
|
this.logger.error([
|
|
@@ -96,20 +119,14 @@ export default class Serve extends BaseCommand {
|
|
|
96
119
|
this.exitCode = 1;
|
|
97
120
|
this.terminate();
|
|
98
121
|
});
|
|
99
|
-
const ts = await importTypeScript(this.app);
|
|
100
|
-
if (!ts) {
|
|
101
|
-
this.#logMissingDevelopmentDependency('typescript');
|
|
102
|
-
this.exitCode = 1;
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
122
|
/**
|
|
106
123
|
* Start the development server
|
|
107
124
|
*/
|
|
108
125
|
if (this.watch) {
|
|
109
|
-
await this.devServer.startAndWatch(
|
|
126
|
+
await this.devServer.startAndWatch({ poll: this.poll || false });
|
|
110
127
|
}
|
|
111
128
|
else {
|
|
112
|
-
await this.devServer.start(
|
|
129
|
+
await this.devServer.start();
|
|
113
130
|
}
|
|
114
131
|
}
|
|
115
132
|
}
|
package/build/commands/test.d.ts
CHANGED
|
@@ -2,29 +2,92 @@ import type { TestRunner } from '@adonisjs/assembler';
|
|
|
2
2
|
import type { CommandOptions } from '../types/ace.ts';
|
|
3
3
|
import { BaseCommand } from '../modules/ace/main.ts';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* Command to run application tests using the Japa test runner.
|
|
6
|
+
* Supports filtering tests by suites, files, tags, groups, and individual tests.
|
|
7
|
+
* Can run in watch mode to automatically re-run tests when files change.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```
|
|
11
|
+
* ace test
|
|
12
|
+
* ace test unit integration
|
|
13
|
+
* ace test --watch
|
|
14
|
+
* ace test --files=user.spec.ts
|
|
15
|
+
* ace test --tags=slow --groups="User tests"
|
|
16
|
+
* ace test --reporters=spec,dot
|
|
17
|
+
* ace test --timeout=5000 --retries=2
|
|
18
|
+
* ```
|
|
7
19
|
*/
|
|
8
20
|
export default class Test extends BaseCommand {
|
|
9
21
|
#private;
|
|
22
|
+
/**
|
|
23
|
+
* The command name
|
|
24
|
+
*/
|
|
10
25
|
static commandName: string;
|
|
26
|
+
/**
|
|
27
|
+
* The command description
|
|
28
|
+
*/
|
|
11
29
|
static description: string;
|
|
30
|
+
/**
|
|
31
|
+
* Command options configuration.
|
|
32
|
+
* Allows unknown flags to be passed to Japa and keeps the process alive.
|
|
33
|
+
*/
|
|
12
34
|
static options: CommandOptions;
|
|
35
|
+
/**
|
|
36
|
+
* The test runner instance from the assembler package
|
|
37
|
+
*/
|
|
13
38
|
testsRunner: TestRunner;
|
|
39
|
+
/**
|
|
40
|
+
* Test suite names to run. When provided, only tests from the specified suites will be executed
|
|
41
|
+
*/
|
|
14
42
|
suites?: string[];
|
|
43
|
+
/**
|
|
44
|
+
* Filter tests by filename patterns
|
|
45
|
+
*/
|
|
15
46
|
files?: string[];
|
|
47
|
+
/**
|
|
48
|
+
* Filter tests by tags
|
|
49
|
+
*/
|
|
16
50
|
tags?: string[];
|
|
51
|
+
/**
|
|
52
|
+
* Filter tests by parent group title
|
|
53
|
+
*/
|
|
17
54
|
groups?: string[];
|
|
55
|
+
/**
|
|
56
|
+
* Filter tests by test title
|
|
57
|
+
*/
|
|
18
58
|
tests?: string[];
|
|
59
|
+
/**
|
|
60
|
+
* Specify one or more test reporters to use for output formatting
|
|
61
|
+
*/
|
|
19
62
|
reporters?: string[];
|
|
63
|
+
/**
|
|
64
|
+
* Enable watch mode to automatically re-run tests when files change
|
|
65
|
+
*/
|
|
20
66
|
watch?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Use polling instead of native filesystem events to detect file changes
|
|
69
|
+
*/
|
|
21
70
|
poll?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Default timeout in milliseconds for all tests
|
|
73
|
+
*/
|
|
22
74
|
timeout?: number;
|
|
75
|
+
/**
|
|
76
|
+
* Default number of retries for failed tests
|
|
77
|
+
*/
|
|
23
78
|
retries?: number;
|
|
79
|
+
/**
|
|
80
|
+
* Execute only tests that failed during the last run
|
|
81
|
+
*/
|
|
24
82
|
failed?: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Clear the terminal for new logs after file change in watch mode
|
|
85
|
+
*/
|
|
25
86
|
clear?: boolean;
|
|
26
87
|
/**
|
|
27
|
-
*
|
|
88
|
+
* Execute the test command. Sets up the test runner with all configured options
|
|
89
|
+
* and filters, then runs tests either once or in watch mode. Handles missing
|
|
90
|
+
* dependencies and properly configures the test environment.
|
|
28
91
|
*/
|
|
29
92
|
run(): Promise<void>;
|
|
30
93
|
}
|
package/build/commands/test.js
CHANGED
|
@@ -12,21 +12,46 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
12
12
|
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;
|
|
13
13
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
14
14
|
};
|
|
15
|
+
import { importAssembler } from "../src/utils.js";
|
|
15
16
|
import { BaseCommand, flags, args } from "../modules/ace/main.js";
|
|
16
|
-
import { importAssembler, importTypeScript } from "../src/utils.js";
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
18
|
+
* Command to run application tests using the Japa test runner.
|
|
19
|
+
* Supports filtering tests by suites, files, tags, groups, and individual tests.
|
|
20
|
+
* Can run in watch mode to automatically re-run tests when files change.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```
|
|
24
|
+
* ace test
|
|
25
|
+
* ace test unit integration
|
|
26
|
+
* ace test --watch
|
|
27
|
+
* ace test --files=user.spec.ts
|
|
28
|
+
* ace test --tags=slow --groups="User tests"
|
|
29
|
+
* ace test --reporters=spec,dot
|
|
30
|
+
* ace test --timeout=5000 --retries=2
|
|
31
|
+
* ```
|
|
20
32
|
*/
|
|
21
33
|
export default class Test extends BaseCommand {
|
|
34
|
+
/**
|
|
35
|
+
* The command name
|
|
36
|
+
*/
|
|
22
37
|
static commandName = 'test';
|
|
38
|
+
/**
|
|
39
|
+
* The command description
|
|
40
|
+
*/
|
|
23
41
|
static description = 'Run tests along with the file watcher to re-run tests on file change';
|
|
42
|
+
/**
|
|
43
|
+
* Command options configuration.
|
|
44
|
+
* Allows unknown flags to be passed to Japa and keeps the process alive.
|
|
45
|
+
*/
|
|
24
46
|
static options = {
|
|
25
47
|
allowUnknownFlags: true,
|
|
26
48
|
staysAlive: true,
|
|
27
49
|
};
|
|
28
50
|
/**
|
|
29
|
-
* Log a development dependency is missing
|
|
51
|
+
* Log an error message when a required development dependency is missing.
|
|
52
|
+
* Provides helpful instructions for resolving the issue.
|
|
53
|
+
*
|
|
54
|
+
* @param dependency - The name of the missing dependency package
|
|
30
55
|
*/
|
|
31
56
|
#logMissingDevelopmentDependency(dependency) {
|
|
32
57
|
this.logger.error([
|
|
@@ -38,7 +63,10 @@ export default class Test extends BaseCommand {
|
|
|
38
63
|
].join('\n'));
|
|
39
64
|
}
|
|
40
65
|
/**
|
|
41
|
-
*
|
|
66
|
+
* Collect unknown flags and format them to pass to the Japa test runner.
|
|
67
|
+
* Handles boolean flags, arrays, and single values appropriately.
|
|
68
|
+
*
|
|
69
|
+
* @returns Array of formatted command-line arguments for Japa
|
|
42
70
|
*/
|
|
43
71
|
#getPassthroughFlags() {
|
|
44
72
|
return this.parsed.unknownFlags
|
|
@@ -61,7 +89,9 @@ export default class Test extends BaseCommand {
|
|
|
61
89
|
.flat(2);
|
|
62
90
|
}
|
|
63
91
|
/**
|
|
64
|
-
*
|
|
92
|
+
* Execute the test command. Sets up the test runner with all configured options
|
|
93
|
+
* and filters, then runs tests either once or in watch mode. Handles missing
|
|
94
|
+
* dependencies and properly configures the test environment.
|
|
65
95
|
*/
|
|
66
96
|
async run() {
|
|
67
97
|
process.env.NODE_ENV = 'test';
|
|
@@ -121,13 +151,7 @@ export default class Test extends BaseCommand {
|
|
|
121
151
|
* Start the test runner in watch mode
|
|
122
152
|
*/
|
|
123
153
|
if (this.watch) {
|
|
124
|
-
|
|
125
|
-
if (!ts) {
|
|
126
|
-
this.#logMissingDevelopmentDependency('typescript');
|
|
127
|
-
this.exitCode = 1;
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
await this.testsRunner.runAndWatch(ts, { poll: this.poll || false });
|
|
154
|
+
await this.testsRunner.runAndWatch({ poll: this.poll || false });
|
|
131
155
|
}
|
|
132
156
|
else {
|
|
133
157
|
await this.testsRunner.run();
|
|
@@ -75,29 +75,101 @@ export declare class Codemods extends EventEmitter {
|
|
|
75
75
|
*/
|
|
76
76
|
getTsMorphProject(): Promise<CodeTransformer['project'] | undefined>;
|
|
77
77
|
/**
|
|
78
|
-
* Define validations for the environment variables
|
|
78
|
+
* Define validations for the environment variables in the start/env.ts file.
|
|
79
|
+
* This method updates the environment validation schema using the assembler.
|
|
80
|
+
*
|
|
81
|
+
* @param validations - Validation schema node for environment variables
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```ts
|
|
85
|
+
* await codemods.defineEnvValidations({
|
|
86
|
+
* NODE_ENV: 'Env.schema.enum(["development", "production", "test"] as const)',
|
|
87
|
+
* PORT: 'Env.schema.number()',
|
|
88
|
+
* HOST: 'Env.schema.string({ format: "host" })'
|
|
89
|
+
* })
|
|
90
|
+
* ```
|
|
79
91
|
*/
|
|
80
92
|
defineEnvValidations(validations: EnvValidationNode): Promise<void>;
|
|
81
93
|
/**
|
|
82
|
-
*
|
|
94
|
+
* Register middleware in the start/kernel.ts file.
|
|
95
|
+
* This method adds middleware to the specified stack (server, router, or named).
|
|
96
|
+
*
|
|
97
|
+
* @param stack - The middleware stack to register to ('server' | 'router' | 'named')
|
|
98
|
+
* @param middleware - Array of middleware nodes to register
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```ts
|
|
102
|
+
* await codemods.registerMiddleware('server', [
|
|
103
|
+
* {
|
|
104
|
+
* name: 'cors',
|
|
105
|
+
* path: '@adonisjs/cors/cors_middleware'
|
|
106
|
+
* }
|
|
107
|
+
* ])
|
|
108
|
+
* ```
|
|
83
109
|
*/
|
|
84
110
|
registerMiddleware(stack: 'server' | 'router' | 'named', middleware: MiddlewareNode[]): Promise<void>;
|
|
85
111
|
/**
|
|
86
|
-
* Register bouncer policies to the list of policies
|
|
87
|
-
*
|
|
88
|
-
*
|
|
112
|
+
* Register bouncer policies to the list of policies collection exported from
|
|
113
|
+
* the "app/policies/main.ts" file. This method adds new policy definitions
|
|
114
|
+
* to the policies export.
|
|
115
|
+
*
|
|
116
|
+
* @param policies - Array of policy nodes to register
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```ts
|
|
120
|
+
* await codemods.registerPolicies([
|
|
121
|
+
* {
|
|
122
|
+
* name: 'UserPolicy',
|
|
123
|
+
* path: '#policies/user_policy'
|
|
124
|
+
* }
|
|
125
|
+
* ])
|
|
126
|
+
* ```
|
|
89
127
|
*/
|
|
90
128
|
registerPolicies(policies: BouncerPolicyNode[]): Promise<void>;
|
|
91
129
|
/**
|
|
92
|
-
* Update
|
|
130
|
+
* Update the adonisrc.ts file with new configuration settings.
|
|
131
|
+
* This method allows modification of the AdonisJS runtime configuration.
|
|
132
|
+
*
|
|
133
|
+
* @param params - Parameters for updating the RC file (varies based on update type)
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* ```ts
|
|
137
|
+
* await codemods.updateRcFile((rcFile) => {
|
|
138
|
+
* rcFile.addCommand('make:custom')
|
|
139
|
+
* rcFile.addPreloadFile('#app/events/main')
|
|
140
|
+
* })
|
|
141
|
+
* ```
|
|
93
142
|
*/
|
|
94
143
|
updateRcFile(...params: Parameters<CodeTransformer['updateRcFile']>): Promise<void>;
|
|
95
144
|
/**
|
|
96
|
-
* Register a new Vite plugin in the
|
|
145
|
+
* Register a new Vite plugin in the vite.config.ts file.
|
|
146
|
+
* This method adds plugin configuration to the Vite build configuration.
|
|
147
|
+
*
|
|
148
|
+
* @param params - Parameters for adding the Vite plugin (varies based on plugin type)
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* ```ts
|
|
152
|
+
* await codemods.registerVitePlugin({
|
|
153
|
+
* name: 'vue',
|
|
154
|
+
* import: 'import vue from "@vitejs/plugin-vue"',
|
|
155
|
+
* options: '()'
|
|
156
|
+
* })
|
|
157
|
+
* ```
|
|
97
158
|
*/
|
|
98
159
|
registerVitePlugin(...params: Parameters<CodeTransformer['addVitePlugin']>): Promise<void>;
|
|
99
160
|
/**
|
|
100
|
-
* Register a new Japa plugin in the
|
|
161
|
+
* Register a new Japa plugin in the tests/bootstrap.ts file.
|
|
162
|
+
* This method adds plugin configuration to the test runner setup.
|
|
163
|
+
*
|
|
164
|
+
* @param params - Parameters for adding the Japa plugin (varies based on plugin type)
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* ```ts
|
|
168
|
+
* await codemods.registerJapaPlugin({
|
|
169
|
+
* name: 'expect',
|
|
170
|
+
* import: 'import { expect } from "@japa/expect"'
|
|
171
|
+
* })
|
|
172
|
+
* ```
|
|
101
173
|
*/
|
|
102
174
|
registerJapaPlugin(...params: Parameters<CodeTransformer['addJapaPlugin']>): Promise<void>;
|
|
103
175
|
/**
|
|
@@ -143,12 +215,19 @@ export declare class Codemods extends EventEmitter {
|
|
|
143
215
|
skipReason: string;
|
|
144
216
|
}>;
|
|
145
217
|
/**
|
|
146
|
-
* Install packages using the
|
|
147
|
-
*
|
|
148
|
-
* name like
|
|
218
|
+
* Install packages using the detected or specified package manager.
|
|
219
|
+
* Automatically detects npm, yarn, or pnpm and installs dependencies accordingly.
|
|
220
|
+
* You can specify version of each package by setting it in the name like '@adonisjs/lucid@next'.
|
|
149
221
|
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
222
|
+
* @param packages - Array of packages with their dependency type
|
|
223
|
+
* @param packageManager - Optional package manager to use (auto-detected if not provided)
|
|
224
|
+
*
|
|
225
|
+
* @example
|
|
226
|
+
* ```ts
|
|
227
|
+
* const success = await codemods.installPackages([
|
|
228
|
+
* { name: '@adonisjs/lucid', isDevDependency: false },
|
|
229
|
+
* { name: '@types/node', isDevDependency: true }
|
|
230
|
+
* ])
|
|
152
231
|
* ```
|
|
153
232
|
*/
|
|
154
233
|
installPackages(packages: {
|
|
@@ -156,7 +235,23 @@ export declare class Codemods extends EventEmitter {
|
|
|
156
235
|
isDevDependency: boolean;
|
|
157
236
|
}[], packageManager?: SupportedPackageManager | 'pnpm@6' | 'deno'): Promise<boolean>;
|
|
158
237
|
/**
|
|
159
|
-
* List the packages
|
|
238
|
+
* List the packages that should be installed manually.
|
|
239
|
+
* This method displays installation commands for different package managers
|
|
240
|
+
* when automatic installation is not available or desired.
|
|
241
|
+
*
|
|
242
|
+
* @param packages - Array of packages with their dependency type
|
|
243
|
+
*
|
|
244
|
+
* @example
|
|
245
|
+
* ```ts
|
|
246
|
+
* await codemods.listPackagesToInstall([
|
|
247
|
+
* { name: '@adonisjs/lucid', isDevDependency: false },
|
|
248
|
+
* { name: '@types/node', isDevDependency: true }
|
|
249
|
+
* ])
|
|
250
|
+
* // Output:
|
|
251
|
+
* // Please install following packages
|
|
252
|
+
* // npm i -D @types/node
|
|
253
|
+
* // npm i @adonisjs/lucid
|
|
254
|
+
* ```
|
|
160
255
|
*/
|
|
161
256
|
listPackagesToInstall(packages: {
|
|
162
257
|
name: string;
|