@adonisjs/assembler 8.0.0-next.3 → 8.0.0-next.30
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/README.md +87 -59
- package/build/codemod_exception-vyN1VXuX.js +137 -0
- package/build/helpers-DDurYRsZ.js +72 -0
- package/build/index.d.ts +4 -0
- package/build/index.js +925 -1319
- package/build/main-BeV45LeF.js +246 -0
- package/build/main-CknPN3rJ.js +188 -0
- package/build/src/bundler.d.ts +44 -3
- package/build/src/code_scanners/routes_scanner/main.d.ts +63 -11
- package/build/src/code_scanners/routes_scanner/main.js +4 -0
- package/build/src/code_scanners/routes_scanner/validator_extractor.d.ts +12 -4
- package/build/src/code_transformer/main.d.ts +53 -43
- package/build/src/code_transformer/main.js +354 -599
- package/build/src/code_transformer/rc_file_transformer.d.ts +83 -5
- package/build/src/debug.d.ts +13 -1
- package/build/src/dev_server.d.ts +92 -17
- package/build/src/exceptions/codemod_exception.d.ts +178 -0
- package/build/src/file_buffer.d.ts +87 -0
- package/build/src/file_system.d.ts +46 -8
- package/build/src/helpers.d.ts +79 -4
- package/build/src/helpers.js +2 -0
- package/build/src/index_generator/main.d.ts +68 -0
- package/build/src/index_generator/main.js +3 -0
- package/build/src/index_generator/source.d.ts +60 -0
- package/build/src/paths_resolver.d.ts +29 -3
- package/build/src/shortcuts_manager.d.ts +42 -4
- package/build/src/test_runner.d.ts +57 -12
- package/build/src/types/code_scanners.d.ts +160 -30
- package/build/src/types/code_transformer.d.ts +69 -19
- package/build/src/types/common.d.ts +233 -55
- package/build/src/types/hooks.d.ts +238 -22
- package/build/src/types/main.d.ts +15 -1
- package/build/src/types/main.js +1 -0
- package/build/src/utils.d.ts +96 -15
- package/build/src/virtual_file_system.d.ts +112 -0
- package/build/virtual_file_system-bGeoWsK-.js +285 -0
- package/package.json +46 -36
- package/build/chunk-RR4HCA4M.js +0 -7
- package/build/src/ast_file_system.d.ts +0 -17
package/build/src/helpers.d.ts
CHANGED
|
@@ -1,26 +1,76 @@
|
|
|
1
1
|
import { type SgNode } from '@ast-grep/napi';
|
|
2
2
|
import type { Import } from './types/common.ts';
|
|
3
3
|
/**
|
|
4
|
-
* Finds an import reference inside a code snippet
|
|
4
|
+
* Finds an import reference inside a code snippet by analyzing the import statements
|
|
5
|
+
* and matching against the provided import reference identifier.
|
|
6
|
+
*
|
|
7
|
+
* The function searches through all import statements in the code and matches
|
|
8
|
+
* against default, namespace, or named imports based on the import reference.
|
|
9
|
+
*
|
|
10
|
+
* @param code - The code snippet to search for imports
|
|
11
|
+
* @param importReference - The import reference identifier to find (can include dot notation)
|
|
12
|
+
* @returns Promise that resolves to an Import object or null if not found
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* const importInfo = await findImport(code, 'validateUser')
|
|
16
|
+
* if (importInfo) {
|
|
17
|
+
* console.log(importInfo.specifier) // '@/validators/user'
|
|
18
|
+
* }
|
|
5
19
|
*/
|
|
6
20
|
export declare function findImport(code: string, importReference: string): Promise<Import | null>;
|
|
7
21
|
/**
|
|
8
22
|
* Returns a node that represents a TypeScript class or null
|
|
9
23
|
* when unable to find the class.
|
|
24
|
+
*
|
|
25
|
+
* This function searches for class declarations within the provided AST node
|
|
26
|
+
* using ast-grep's pattern matching capabilities.
|
|
27
|
+
*
|
|
28
|
+
* @param node - The AST node to search within for class declarations
|
|
29
|
+
* @returns The SgNode representing the class or null if not found
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* const classNode = inspectClass(rootNode)
|
|
33
|
+
* if (classNode) {
|
|
34
|
+
* console.log('Found class:', classNode.text())
|
|
35
|
+
* }
|
|
10
36
|
*/
|
|
11
37
|
export declare function inspectClass(node: SgNode): SgNode | null;
|
|
12
38
|
/**
|
|
13
39
|
* Returns an array of SgNodes for class methods. The input node
|
|
14
40
|
* must represent a class.
|
|
41
|
+
*
|
|
42
|
+
* This function finds all method definitions within a class node,
|
|
43
|
+
* including both regular methods and static methods.
|
|
44
|
+
*
|
|
45
|
+
* @param node - The AST node representing a class to search for methods
|
|
46
|
+
* @returns Array of SgNodes representing method definitions within the class
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* const classNode = inspectClass(rootNode)
|
|
50
|
+
* if (classNode) {
|
|
51
|
+
* const methods = inspectClassMethods(classNode)
|
|
52
|
+
* methods.forEach(method => console.log('Method:', method.text()))
|
|
53
|
+
* }
|
|
15
54
|
*/
|
|
16
55
|
export declare function inspectClassMethods(node: SgNode): SgNode[];
|
|
17
56
|
/**
|
|
18
|
-
* Converts an
|
|
19
|
-
*
|
|
57
|
+
* Converts an SgNode to plain text by removing whitespaces,
|
|
58
|
+
* indentation and comments in between. Tested with the following
|
|
20
59
|
* children nodes only.
|
|
21
60
|
*
|
|
22
61
|
* - MemberExpression
|
|
23
|
-
* -
|
|
62
|
+
* - Identifier
|
|
63
|
+
*
|
|
64
|
+
* This function recursively traverses the AST node and extracts only
|
|
65
|
+
* the meaningful text content without any formatting or whitespace.
|
|
66
|
+
*
|
|
67
|
+
* @param node - The AST node to convert to plain text
|
|
68
|
+
* @returns String representation of the node without formatting
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* const memberExpression = node.find({ rule: { kind: 'member_expression' } })
|
|
72
|
+
* const plainText = nodeToPlainText(memberExpression)
|
|
73
|
+
* console.log(plainText) // 'user.validate'
|
|
24
74
|
*/
|
|
25
75
|
export declare function nodeToPlainText(node: SgNode): string;
|
|
26
76
|
/**
|
|
@@ -30,11 +80,36 @@ export declare function nodeToPlainText(node: SgNode): string;
|
|
|
30
80
|
*
|
|
31
81
|
* For example: In case of validators, we will first find the Controller
|
|
32
82
|
* method for which we want the validation method calls.
|
|
83
|
+
*
|
|
84
|
+
* This function searches for call expressions that match the provided method
|
|
85
|
+
* names and returns their argument nodes for further analysis.
|
|
86
|
+
*
|
|
87
|
+
* @param node - The AST node to search within for method calls
|
|
88
|
+
* @param methodCalls - Array of method call names to search for (supports dot notation)
|
|
89
|
+
* @returns Array of SgNodes representing the arguments of matching method calls
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* const controllerMethod = classNode.find({ rule: { kind: 'method_definition' } })
|
|
93
|
+
* const validatorArgs = inspectMethodArguments(controllerMethod, ['validate', 'request.validate'])
|
|
94
|
+
* validatorArgs.forEach(arg => console.log('Validator argument:', arg.text()))
|
|
33
95
|
*/
|
|
34
96
|
export declare function inspectMethodArguments(node: SgNode, methodCalls: string[]): SgNode[];
|
|
35
97
|
/**
|
|
36
98
|
* Inspect the validator direct usage code snippets. A member expression
|
|
37
99
|
* calling the ".validate" method is considered as direct usage of
|
|
38
100
|
* the validator.
|
|
101
|
+
*
|
|
102
|
+
* This function specifically looks for patterns where validators are called
|
|
103
|
+
* directly with the `.validate()` method, which is common in AdonisJS applications.
|
|
104
|
+
*
|
|
105
|
+
* @param node - The AST node to search within for validator direct usage
|
|
106
|
+
* @returns Array of SgNodes representing validator expressions that call validate method
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* const methodNode = classNode.find({ rule: { kind: 'method_definition' } })
|
|
110
|
+
* const validators = searchValidatorDirectUsage(methodNode)
|
|
111
|
+
* validators.forEach(validator => {
|
|
112
|
+
* console.log('Direct validator usage:', nodeToPlainText(validator))
|
|
113
|
+
* })
|
|
39
114
|
*/
|
|
40
115
|
export declare function searchValidatorDirectUsage(node: SgNode): SgNode[];
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as nodeToPlainText, i as inspectMethodArguments, n as inspectClass, o as searchValidatorDirectUsage, r as inspectClassMethods, t as findImport } from "../helpers-DDurYRsZ.js";
|
|
2
|
+
export { findImport, inspectClass, inspectClassMethods, inspectMethodArguments, nodeToPlainText, searchValidatorDirectUsage };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { type Logger } from '@poppinss/cliui';
|
|
2
|
+
import { type IndexGeneratorSourceConfig } from '../types/common.ts';
|
|
3
|
+
/**
|
|
4
|
+
* IndexGenerator manages the generation of index files for AdonisJS applications.
|
|
5
|
+
*
|
|
6
|
+
* This class provides a way to configure multiple sources and generate index files
|
|
7
|
+
* that export collections of modules, typically used for barrel exports or
|
|
8
|
+
* auto-discovery patterns in AdonisJS applications.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const generator = new IndexGenerator(appRoot)
|
|
12
|
+
* generator.add('controllers', {
|
|
13
|
+
* source: 'app/controllers',
|
|
14
|
+
* output: 'app/controllers/index.ts',
|
|
15
|
+
* as: 'barrelFile',
|
|
16
|
+
* exportName: 'controllers'
|
|
17
|
+
* })
|
|
18
|
+
* await generator.generate()
|
|
19
|
+
*/
|
|
20
|
+
export declare class IndexGenerator {
|
|
21
|
+
#private;
|
|
22
|
+
/**
|
|
23
|
+
* The application root directory path
|
|
24
|
+
*/
|
|
25
|
+
appRoot: string;
|
|
26
|
+
/**
|
|
27
|
+
* Create a new IndexGenerator instance
|
|
28
|
+
*
|
|
29
|
+
* @param appRoot - The application root directory path
|
|
30
|
+
* @param cliLogger - Logger instance for CLI output
|
|
31
|
+
*/
|
|
32
|
+
constructor(appRoot: string, cliLogger: Logger);
|
|
33
|
+
/**
|
|
34
|
+
* Add a new index generator source
|
|
35
|
+
*
|
|
36
|
+
* @param name - Unique name for the source
|
|
37
|
+
* @param config - Configuration for the index generator source
|
|
38
|
+
* @returns This IndexGenerator instance for method chaining
|
|
39
|
+
*/
|
|
40
|
+
add(name: string, config: IndexGeneratorSourceConfig): this;
|
|
41
|
+
/**
|
|
42
|
+
* Add a file to all registered index generator sources
|
|
43
|
+
*
|
|
44
|
+
* This method propagates the file addition to all registered sources,
|
|
45
|
+
* allowing them to regenerate their index files if the new file matches
|
|
46
|
+
* their glob patterns.
|
|
47
|
+
*
|
|
48
|
+
* @param filePath - Absolute path of the file to add
|
|
49
|
+
*/
|
|
50
|
+
addFile(filePath: string): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Remove a file from all registered index generator sources
|
|
53
|
+
*
|
|
54
|
+
* This method propagates the file removal to all registered sources,
|
|
55
|
+
* allowing them to regenerate their index files if the removed file
|
|
56
|
+
* was previously tracked.
|
|
57
|
+
*
|
|
58
|
+
* @param filePath - Absolute path of the file to remove
|
|
59
|
+
*/
|
|
60
|
+
removeFile(filePath: string): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Generate all registered index files
|
|
63
|
+
*
|
|
64
|
+
* Iterates through all registered sources and generates their
|
|
65
|
+
* corresponding index files.
|
|
66
|
+
*/
|
|
67
|
+
generate(): Promise<void>;
|
|
68
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { type Logger } from '@poppinss/cliui';
|
|
2
|
+
import { type IndexGeneratorSourceConfig } from '../types/common.ts';
|
|
3
|
+
/**
|
|
4
|
+
* IndexGeneratorSource handles the generation of a single index file.
|
|
5
|
+
*
|
|
6
|
+
* This class is responsible for scanning a source directory, processing files
|
|
7
|
+
* according to configuration, and generating an index file that exports the
|
|
8
|
+
* discovered modules. It supports both barrel file generation and custom
|
|
9
|
+
* generation strategies.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const source = new IndexGeneratorSource(appRoot, {
|
|
13
|
+
* source: 'app/controllers',
|
|
14
|
+
* output: 'app/controllers/index.ts',
|
|
15
|
+
* as: 'barrelFile',
|
|
16
|
+
* exportName: 'controllers'
|
|
17
|
+
* })
|
|
18
|
+
* await source.generate()
|
|
19
|
+
*/
|
|
20
|
+
export declare class IndexGeneratorSource {
|
|
21
|
+
#private;
|
|
22
|
+
/**
|
|
23
|
+
* Unique name for this index generator source
|
|
24
|
+
*/
|
|
25
|
+
name: string;
|
|
26
|
+
/**
|
|
27
|
+
* Create a new IndexGeneratorSource instance
|
|
28
|
+
*
|
|
29
|
+
* @param name - Unique name for this index generator source
|
|
30
|
+
* @param appRoot - The application root directory path
|
|
31
|
+
* @param cliLogger - Logger instance for CLI output
|
|
32
|
+
* @param config - Configuration for this index generator source
|
|
33
|
+
*/
|
|
34
|
+
constructor(name: string, appRoot: string, cliLogger: Logger, config: IndexGeneratorSourceConfig);
|
|
35
|
+
/**
|
|
36
|
+
* Add a file to the virtual file system and regenerate index if needed
|
|
37
|
+
*
|
|
38
|
+
* If the file matches the configured glob patterns, it will be added
|
|
39
|
+
* to the virtual file system and the index file will be regenerated.
|
|
40
|
+
*
|
|
41
|
+
* @param filePath - Absolute path of the file to add
|
|
42
|
+
*/
|
|
43
|
+
addFile(filePath: string): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Remove a file from the virtual file system and regenerate index if needed
|
|
46
|
+
*
|
|
47
|
+
* If the file was previously tracked, it will be removed from the
|
|
48
|
+
* virtual file system and the index file will be regenerated.
|
|
49
|
+
*
|
|
50
|
+
* @param filePath - Absolute path of the file to remove
|
|
51
|
+
*/
|
|
52
|
+
removeFile(filePath: string): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Generate the index file
|
|
55
|
+
*
|
|
56
|
+
* This method scans the source directory, processes files according to
|
|
57
|
+
* the configuration, and writes the generated index file to disk.
|
|
58
|
+
*/
|
|
59
|
+
generate(): Promise<void>;
|
|
60
|
+
}
|
|
@@ -1,15 +1,41 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Encapsulates the API to resolve import specifiers with the ability
|
|
3
|
-
* to define
|
|
3
|
+
* to define custom resolver functions.
|
|
4
|
+
*
|
|
5
|
+
* The PathsResolver provides a caching mechanism to avoid resolving the same
|
|
6
|
+
* specifier multiple times and supports custom resolvers for handling
|
|
7
|
+
* special import patterns like path aliases.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* const resolver = new PathsResolver()
|
|
11
|
+
* resolver.use((specifier) => '/custom/path/' + specifier)
|
|
12
|
+
* const resolved = resolver.resolve('#app/models/user')
|
|
4
13
|
*/
|
|
5
14
|
export declare class PathsResolver {
|
|
6
15
|
#private;
|
|
16
|
+
constructor(appRoot: string);
|
|
7
17
|
/**
|
|
8
18
|
* Define a custom resolver that resolves a path
|
|
19
|
+
*
|
|
20
|
+
* The custom resolver function will be used instead of the default
|
|
21
|
+
* import.meta.resolve() for resolving import specifiers.
|
|
22
|
+
*
|
|
23
|
+
* @param resolver - Function that takes a specifier and returns resolved path
|
|
9
24
|
*/
|
|
10
25
|
use(resolver: (specifier: string) => string): void;
|
|
11
26
|
/**
|
|
12
|
-
* Resolve import specifier
|
|
27
|
+
* Resolve import specifier to an absolute file path
|
|
28
|
+
*
|
|
29
|
+
* This method caches resolved paths to improve performance on repeated
|
|
30
|
+
* resolutions. Relative paths are not supported and will throw an error.
|
|
31
|
+
*
|
|
32
|
+
* @param specifier - The import specifier to resolve (must not be relative)
|
|
33
|
+
* @returns The resolved absolute file path
|
|
34
|
+
* @throws Error when attempting to resolve relative paths
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* const path = resolver.resolve('#app/models/user')
|
|
38
|
+
* const path2 = resolver.resolve('@/utils/helper')
|
|
13
39
|
*/
|
|
14
|
-
resolve(specifier: string): string;
|
|
40
|
+
resolve(specifier: string, rewriteAliasImportExtension?: boolean): string;
|
|
15
41
|
}
|
|
@@ -1,24 +1,62 @@
|
|
|
1
1
|
import { type ShortcutsManagerOptions } from './types/common.ts';
|
|
2
2
|
/**
|
|
3
|
-
* Manages keyboard shortcuts for development server
|
|
3
|
+
* Manages keyboard shortcuts for development server interaction.
|
|
4
|
+
*
|
|
5
|
+
* The ShortcutsManager provides a convenient way to handle keyboard inputs
|
|
6
|
+
* during development, allowing users to restart servers, clear console,
|
|
7
|
+
* open browsers, and perform other common development tasks through simple
|
|
8
|
+
* key presses.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const shortcuts = new ShortcutsManager({
|
|
12
|
+
* logger: ui.logger,
|
|
13
|
+
* callbacks: {
|
|
14
|
+
* onRestart: () => server.restart(),
|
|
15
|
+
* onClear: () => console.clear(),
|
|
16
|
+
* onQuit: () => process.exit()
|
|
17
|
+
* }
|
|
18
|
+
* })
|
|
19
|
+
* shortcuts.setup()
|
|
4
20
|
*/
|
|
5
21
|
export declare class ShortcutsManager {
|
|
6
22
|
#private;
|
|
23
|
+
/**
|
|
24
|
+
* Create a new ShortcutsManager instance
|
|
25
|
+
*
|
|
26
|
+
* @param options - Configuration options for the shortcuts manager
|
|
27
|
+
*/
|
|
7
28
|
constructor(options: ShortcutsManagerOptions);
|
|
8
29
|
/**
|
|
9
30
|
* Set server url for opening in browser
|
|
31
|
+
*
|
|
32
|
+
* This URL will be used when the user presses 'o' to open the
|
|
33
|
+
* development server in their default browser.
|
|
34
|
+
*
|
|
35
|
+
* @param url - The server URL to open when 'o' key is pressed
|
|
10
36
|
*/
|
|
11
37
|
setServerUrl(url: string): void;
|
|
12
38
|
/**
|
|
13
|
-
* Initialize keyboard shortcuts
|
|
39
|
+
* Initialize keyboard shortcuts by setting up raw mode on stdin
|
|
40
|
+
*
|
|
41
|
+
* This method enables raw mode on stdin to capture individual keypresses
|
|
42
|
+
* and sets up the event listener for handling keyboard input. Only works
|
|
43
|
+
* in TTY environments.
|
|
14
44
|
*/
|
|
15
45
|
setup(): void;
|
|
16
46
|
/**
|
|
17
|
-
* Show available keyboard shortcuts
|
|
47
|
+
* Show available keyboard shortcuts in the console
|
|
48
|
+
*
|
|
49
|
+
* Displays a formatted list of all available keyboard shortcuts
|
|
50
|
+
* and their descriptions to help users understand what actions
|
|
51
|
+
* are available.
|
|
18
52
|
*/
|
|
19
53
|
showHelp(): void;
|
|
20
54
|
/**
|
|
21
|
-
* Cleanup keyboard shortcuts
|
|
55
|
+
* Cleanup keyboard shortcuts and restore terminal state
|
|
56
|
+
*
|
|
57
|
+
* Disables raw mode on stdin, removes event listeners, and restores
|
|
58
|
+
* the terminal to its normal state. Should be called when shutting down
|
|
59
|
+
* the development server.
|
|
22
60
|
*/
|
|
23
61
|
cleanup(): void;
|
|
24
62
|
}
|
|
@@ -1,22 +1,31 @@
|
|
|
1
|
-
import type tsStatic from 'typescript';
|
|
2
1
|
import type { TestRunnerOptions } from './types/common.ts';
|
|
3
2
|
/**
|
|
4
3
|
* Exposes the API to run Japa tests and optionally watch for file
|
|
5
4
|
* changes to re-run the tests.
|
|
6
5
|
*
|
|
7
|
-
* The watch mode
|
|
6
|
+
* The TestRunner provides intelligent test execution with watch mode capabilities.
|
|
7
|
+
* When files change, it can selectively run specific tests or the entire suite
|
|
8
|
+
* based on what changed.
|
|
8
9
|
*
|
|
10
|
+
* The watch mode functions as follows:
|
|
9
11
|
* - If the changed file is a test file, then only tests for that file
|
|
10
12
|
* will be re-run.
|
|
11
13
|
* - Otherwise, all tests will re-run with respect to the initial
|
|
12
14
|
* filters applied when running the `node ace test` command.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* const testRunner = new TestRunner(cwd, { suites: [], hooks: [] })
|
|
18
|
+
* await testRunner.run()
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* // Run tests in watch mode
|
|
22
|
+
* const testRunner = new TestRunner(cwd, { suites: [], hooks: [] })
|
|
23
|
+
* await testRunner.runAndWatch(ts, { poll: false })
|
|
13
24
|
*/
|
|
14
25
|
export declare class TestRunner {
|
|
15
26
|
#private;
|
|
16
|
-
cwd: URL;
|
|
17
|
-
options: TestRunnerOptions;
|
|
18
27
|
/**
|
|
19
|
-
* CLI UI
|
|
28
|
+
* CLI UI instance for displaying colorful messages and progress information
|
|
20
29
|
*/
|
|
21
30
|
ui: {
|
|
22
31
|
colors: import("@poppinss/colors/types").Colors;
|
|
@@ -43,29 +52,65 @@ export declare class TestRunner {
|
|
|
43
52
|
* The script file to run as a child process
|
|
44
53
|
*/
|
|
45
54
|
scriptFile: string;
|
|
55
|
+
/**
|
|
56
|
+
* The current working directory URL
|
|
57
|
+
*/
|
|
58
|
+
cwd: URL;
|
|
59
|
+
/**
|
|
60
|
+
* The current working directory path as a string
|
|
61
|
+
*/
|
|
62
|
+
cwdPath: string;
|
|
63
|
+
/**
|
|
64
|
+
* Test runner configuration options including filters, reporters, and hooks
|
|
65
|
+
*/
|
|
66
|
+
options: TestRunnerOptions;
|
|
67
|
+
/**
|
|
68
|
+
* Create a new TestRunner instance
|
|
69
|
+
*
|
|
70
|
+
* @param cwd - The current working directory URL
|
|
71
|
+
* @param options - Test runner configuration options
|
|
72
|
+
*/
|
|
46
73
|
constructor(cwd: URL, options: TestRunnerOptions);
|
|
47
74
|
/**
|
|
48
|
-
* Add listener to get notified when
|
|
49
|
-
*
|
|
75
|
+
* Add listener to get notified when test runner is closed
|
|
76
|
+
*
|
|
77
|
+
* @param callback - Function to call when test runner closes
|
|
78
|
+
* @returns This TestRunner instance for method chaining
|
|
50
79
|
*/
|
|
51
80
|
onClose(callback: (exitCode: number) => any): this;
|
|
52
81
|
/**
|
|
53
|
-
* Add listener to get notified when
|
|
54
|
-
*
|
|
82
|
+
* Add listener to get notified when test runner encounters an error
|
|
83
|
+
*
|
|
84
|
+
* @param callback - Function to call when test runner encounters an error
|
|
85
|
+
* @returns This TestRunner instance for method chaining
|
|
55
86
|
*/
|
|
56
87
|
onError(callback: (error: any) => any): this;
|
|
57
88
|
/**
|
|
58
89
|
* Close watchers and running child processes
|
|
90
|
+
*
|
|
91
|
+
* Cleans up file system watchers and terminates any running test
|
|
92
|
+
* processes to ensure graceful shutdown.
|
|
59
93
|
*/
|
|
60
94
|
close(): Promise<void>;
|
|
61
95
|
/**
|
|
62
|
-
* Runs tests
|
|
96
|
+
* Runs tests once without watching for file changes
|
|
97
|
+
*
|
|
98
|
+
* Executes the test suite a single time and exits. This is the
|
|
99
|
+
* equivalent of running tests in CI/CD environments.
|
|
63
100
|
*/
|
|
64
101
|
run(): Promise<void>;
|
|
65
102
|
/**
|
|
66
|
-
* Run tests in watch mode
|
|
103
|
+
* Run tests in watch mode and re-run them when files change
|
|
104
|
+
*
|
|
105
|
+
* Starts the test runner in watch mode, monitoring the file system
|
|
106
|
+
* for changes and automatically re-running tests when relevant files
|
|
107
|
+
* are modified. Uses intelligent filtering to run only affected tests
|
|
108
|
+
* when possible.
|
|
109
|
+
*
|
|
110
|
+
* @param ts - TypeScript module reference for parsing configuration
|
|
111
|
+
* @param options - Watch options including polling mode for file system monitoring
|
|
67
112
|
*/
|
|
68
|
-
runAndWatch(
|
|
113
|
+
runAndWatch(options?: {
|
|
69
114
|
poll: boolean;
|
|
70
115
|
}): Promise<void>;
|
|
71
116
|
}
|