@adonisjs/assembler 8.0.0-next.2 → 8.0.0-next.20

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.
Files changed (35) hide show
  1. package/README.md +88 -84
  2. package/build/chunk-4452KFDQ.js +465 -0
  3. package/build/chunk-JFBQ4OEM.js +434 -0
  4. package/build/chunk-NAASGAFO.js +478 -0
  5. package/build/chunk-TIKQQRMX.js +116 -0
  6. package/build/index.d.ts +3 -0
  7. package/build/index.js +800 -447
  8. package/build/src/bundler.d.ts +44 -3
  9. package/build/src/code_scanners/routes_scanner/main.d.ts +119 -0
  10. package/build/src/code_scanners/routes_scanner/main.js +8 -0
  11. package/build/src/code_scanners/routes_scanner/validator_extractor.d.ts +26 -0
  12. package/build/src/code_transformer/main.d.ts +44 -43
  13. package/build/src/code_transformer/main.js +123 -101
  14. package/build/src/code_transformer/rc_file_transformer.d.ts +56 -4
  15. package/build/src/debug.d.ts +12 -0
  16. package/build/src/dev_server.d.ts +92 -17
  17. package/build/src/file_buffer.d.ts +87 -0
  18. package/build/src/file_system.d.ts +46 -8
  19. package/build/src/helpers.d.ts +115 -0
  20. package/build/src/helpers.js +16 -0
  21. package/build/src/index_generator/main.d.ts +68 -0
  22. package/build/src/index_generator/main.js +7 -0
  23. package/build/src/index_generator/source.d.ts +60 -0
  24. package/build/src/paths_resolver.d.ts +41 -0
  25. package/build/src/shortcuts_manager.d.ts +43 -28
  26. package/build/src/test_runner.d.ts +57 -12
  27. package/build/src/types/code_scanners.d.ts +226 -0
  28. package/build/src/types/code_transformer.d.ts +61 -19
  29. package/build/src/types/common.d.ts +270 -51
  30. package/build/src/types/hooks.d.ts +235 -22
  31. package/build/src/types/main.d.ts +15 -1
  32. package/build/src/utils.d.ts +99 -15
  33. package/build/src/virtual_file_system.d.ts +112 -0
  34. package/package.json +33 -20
  35. package/build/chunk-RR4HCA4M.js +0 -7
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Buffer class to construct template output with proper indentation and formatting.
3
+ *
4
+ * The FileBuffer class provides a fluent API for building text output with automatic
5
+ * indentation management. It's commonly used for generating code or template files
6
+ * where proper formatting is important.
7
+ *
8
+ * @example
9
+ * const buffer = new FileBuffer()
10
+ * buffer
11
+ * .writeLine('function example() {')
12
+ * .indent()
13
+ * .writeLine('return "Hello World"')
14
+ * .dedent()
15
+ * .writeLine('}')
16
+ * console.log(buffer.flush())
17
+ */
18
+ export declare class FileBuffer {
19
+ #private;
20
+ /**
21
+ * Creates a new child buffer instance
22
+ *
23
+ * @returns A new FileBuffer instance
24
+ */
25
+ create(): FileBuffer;
26
+ /**
27
+ * Returns the size of buffer text
28
+ *
29
+ * @returns The number of lines in the buffer
30
+ */
31
+ get size(): number;
32
+ /**
33
+ * Enable or disable end-of-line character at the end of output
34
+ *
35
+ * @param enabled - Whether to add EOL character
36
+ * @returns This FileBuffer instance for method chaining
37
+ *
38
+ * @example
39
+ * const buffer = new FileBuffer()
40
+ * buffer.eol(true).writeLine('Hello').flush() // 'Hello\n\n'
41
+ */
42
+ eol(enabled: boolean): this;
43
+ /**
44
+ * Write a new line to the output with current indentation
45
+ *
46
+ * @param text - The text to write as a new line
47
+ * @returns This FileBuffer instance for method chaining
48
+ */
49
+ writeLine(text: string | FileBuffer): this;
50
+ /**
51
+ * Write text to the output without adding a new line
52
+ *
53
+ * @param text - The text to write without a newline
54
+ * @returns This FileBuffer instance for method chaining
55
+ */
56
+ write(text: string | FileBuffer): this;
57
+ /**
58
+ * Increase indentation by 2 spaces
59
+ *
60
+ * @returns This FileBuffer instance for method chaining
61
+ */
62
+ indent(): this;
63
+ /**
64
+ * Decrease indentation by 2 spaces (minimum of 0)
65
+ *
66
+ * @returns This FileBuffer instance for method chaining
67
+ */
68
+ dedent(): this;
69
+ /**
70
+ * Convert the buffer to a string representation
71
+ *
72
+ * @example
73
+ * const buffer = new FileBuffer()
74
+ * buffer.writeLine('Hello')
75
+ * console.log(buffer.toString())
76
+ */
77
+ toString(): string;
78
+ /**
79
+ * Return template as a string, joining all buffer lines
80
+ *
81
+ * Once called, the output is cached and subsequent calls return the same result.
82
+ * The flush method becomes a no-op after the first call.
83
+ *
84
+ * @returns The complete buffer content as a string
85
+ */
86
+ flush(): string;
87
+ }
@@ -1,4 +1,4 @@
1
- import type tsStatic from 'typescript';
1
+ import { type TsConfigResult } from 'get-tsconfig';
2
2
  import { type InspectedFile, type AssemblerRcFile } from './types/common.ts';
3
3
  /**
4
4
  * Exposes an intutive API to run actions when different kind of files
@@ -14,6 +14,10 @@ import { type InspectedFile, type AssemblerRcFile } from './types/common.ts';
14
14
  *
15
15
  * Using FileSystem you can register actions to be executed when a file changes in
16
16
  * one of the above categories.
17
+ *
18
+ * @example
19
+ * const fs = new FileSystem(cwd, tsConfig, rcFile)
20
+ * const file = fs.inspect('./app/controllers/users_controller.ts')
17
21
  */
18
22
  export declare class FileSystem {
19
23
  #private;
@@ -37,24 +41,58 @@ export declare class FileSystem {
37
41
  */
38
42
  get excludes(): string[];
39
43
  /**
40
- * Inspect a relative path to find its source in the project
44
+ * Inspect a file path to determine its type and properties within the project.
45
+ *
46
+ * This method analyzes a file to categorize it as a script file, test file, or meta file,
47
+ * and determines whether changes to the file should trigger server restarts. Results
48
+ * are memoized for performance optimization.
49
+ *
50
+ * @param absolutePath - The absolute Unix path to the file
51
+ * @param relativePath - The relative Unix path from the project root
52
+ * @returns File inspection result or null if the file should be ignored
53
+ *
54
+ * @example
55
+ * const file = fileSystem.inspect('/project/app/models/user.ts', 'app/models/user.ts')
56
+ * if (file) {
57
+ * console.log(file.fileType) // 'script'
58
+ * console.log(file.reloadServer) // true
59
+ * }
41
60
  */
42
- inspect: (input: string) => InspectedFile | null;
61
+ inspect: (input: string, args_0?: string | undefined) => InspectedFile | null;
43
62
  /**
44
- * Returns true if the directory should be watched. Chokidar sends
45
- * absolute unix paths to the ignored callback.
63
+ * Determines if a directory should be watched by the file watcher.
64
+ *
65
+ * This method checks if a directory should be monitored for file changes
66
+ * based on the TypeScript configuration includes/excludes patterns.
67
+ * Results are memoized for performance. Chokidar sends absolute Unix paths.
46
68
  *
47
- * You must use "shouldWatchFile" method for files and call this method
48
- * for directories only.
69
+ * Note: Use shouldWatchFile for files and this method for directories only.
70
+ *
71
+ * @param absolutePath - The absolute Unix path to the directory
72
+ * @returns True if the directory should be watched
73
+ *
74
+ * @example
75
+ * const shouldWatch = fileSystem.shouldWatchDirectory('/project/app/controllers')
76
+ * console.log(shouldWatch) // true
49
77
  */
50
78
  shouldWatchDirectory: (input: string) => unknown;
51
- constructor(cwd: URL | string, tsConfig: tsStatic.ParsedCommandLine, rcFile: AssemblerRcFile);
79
+ /**
80
+ * Create a new FileSystem instance
81
+ *
82
+ * @param cwd - The current working directory URL or string path
83
+ * @param tsConfig - Parsed TypeScript configuration
84
+ * @param rcFile - AdonisJS RC file configuration
85
+ */
86
+ constructor(cwd: string, tsConfig: TsConfigResult, rcFile: AssemblerRcFile);
52
87
  /**
53
88
  * Returns true if the file should be watched. Chokidar sends
54
89
  * absolute unix paths to the ignored callback.
55
90
  *
56
91
  * You must use "shouldWatchDirectory" method for directories and call
57
92
  * this method for files only.
93
+ *
94
+ * @param absolutePath - The absolute path to the file
95
+ * @returns True if the file should be watched
58
96
  */
59
97
  shouldWatchFile(absolutePath: string): boolean;
60
98
  }
@@ -0,0 +1,115 @@
1
+ import { type SgNode } from '@ast-grep/napi';
2
+ import type { Import } from './types/common.ts';
3
+ /**
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
+ * }
19
+ */
20
+ export declare function findImport(code: string, importReference: string): Promise<Import | null>;
21
+ /**
22
+ * Returns a node that represents a TypeScript class or null
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
+ * }
36
+ */
37
+ export declare function inspectClass(node: SgNode): SgNode | null;
38
+ /**
39
+ * Returns an array of SgNodes for class methods. The input node
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
+ * }
54
+ */
55
+ export declare function inspectClassMethods(node: SgNode): SgNode[];
56
+ /**
57
+ * Converts an SgNode to plain text by removing whitespaces,
58
+ * indentation and comments in between. Tested with the following
59
+ * children nodes only.
60
+ *
61
+ * - MemberExpression
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'
74
+ */
75
+ export declare function nodeToPlainText(node: SgNode): string;
76
+ /**
77
+ * Inspects arguments for one or more method calls. If you want to
78
+ * scope the search within a specific context, then make sure to
79
+ * first narrow down the AST and pass a specific SgNode.
80
+ *
81
+ * For example: In case of validators, we will first find the Controller
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()))
95
+ */
96
+ export declare function inspectMethodArguments(node: SgNode, methodCalls: string[]): SgNode[];
97
+ /**
98
+ * Inspect the validator direct usage code snippets. A member expression
99
+ * calling the ".validate" method is considered as direct usage of
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
+ * })
114
+ */
115
+ export declare function searchValidatorDirectUsage(node: SgNode): SgNode[];
@@ -0,0 +1,16 @@
1
+ import {
2
+ findImport,
3
+ inspectClass,
4
+ inspectClassMethods,
5
+ inspectMethodArguments,
6
+ nodeToPlainText,
7
+ searchValidatorDirectUsage
8
+ } from "../chunk-TIKQQRMX.js";
9
+ export {
10
+ findImport,
11
+ inspectClass,
12
+ inspectClassMethods,
13
+ inspectMethodArguments,
14
+ nodeToPlainText,
15
+ searchValidatorDirectUsage
16
+ };
@@ -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,7 @@
1
+ import {
2
+ IndexGenerator
3
+ } from "../../chunk-4452KFDQ.js";
4
+ import "../../chunk-JFBQ4OEM.js";
5
+ export {
6
+ IndexGenerator
7
+ };
@@ -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
+ }
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Encapsulates the API to resolve import specifiers with the ability
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')
13
+ */
14
+ export declare class PathsResolver {
15
+ #private;
16
+ constructor(appRoot: string);
17
+ /**
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
24
+ */
25
+ use(resolver: (specifier: string) => string): void;
26
+ /**
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')
39
+ */
40
+ resolve(specifier: string, rewriteAliasImportExtension?: boolean): string;
41
+ }
@@ -1,47 +1,62 @@
1
- import type { Logger } from '@poppinss/cliui';
1
+ import { type ShortcutsManagerOptions } from './types/common.ts';
2
2
  /**
3
- * Keyboard shortcut definition
4
- */
5
- export interface KeyboardShortcut {
6
- key: string;
7
- description: string;
8
- handler: () => void;
9
- }
10
- /**
11
- * Callbacks for keyboard shortcuts actions
12
- */
13
- export interface KeyboardShortcutsCallbacks {
14
- onRestart: () => void;
15
- onClear: () => void;
16
- onQuit: () => void;
17
- }
18
- /**
19
- * Shortcuts manager options
20
- */
21
- export interface ShortcutsManagerOptions {
22
- logger: Logger;
23
- callbacks: KeyboardShortcutsCallbacks;
24
- }
25
- /**
26
- * 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()
27
20
  */
28
21
  export declare class ShortcutsManager {
29
22
  #private;
23
+ /**
24
+ * Create a new ShortcutsManager instance
25
+ *
26
+ * @param options - Configuration options for the shortcuts manager
27
+ */
30
28
  constructor(options: ShortcutsManagerOptions);
31
29
  /**
32
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
33
36
  */
34
37
  setServerUrl(url: string): void;
35
38
  /**
36
- * 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.
37
44
  */
38
45
  setup(): void;
39
46
  /**
40
- * 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.
41
52
  */
42
53
  showHelp(): void;
43
54
  /**
44
- * 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.
45
60
  */
46
61
  cleanup(): void;
47
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 functions as follows.
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 to log colorful messages
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 dev server is
49
- * closed
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 dev server exists
54
- * with an error
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(ts: typeof tsStatic, options?: {
113
+ runAndWatch(options?: {
69
114
  poll: boolean;
70
115
  }): Promise<void>;
71
116
  }