@adonisjs/assembler 8.0.0-next.5 → 8.0.0-next.7
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/chunk-25Q3N5JR.js +392 -0
- package/build/chunk-PORDZS62.js +391 -0
- package/build/chunk-TIKQQRMX.js +116 -0
- package/build/index.d.ts +2 -0
- package/build/index.js +825 -430
- package/build/src/bundler.d.ts +44 -3
- package/build/src/code_scanners/routes_scanner/main.d.ts +49 -9
- package/build/src/code_scanners/routes_scanner/main.js +445 -0
- package/build/src/code_scanners/routes_scanner/validator_extractor.d.ts +12 -4
- package/build/src/code_transformer/main.d.ts +44 -43
- package/build/src/code_transformer/main.js +123 -101
- package/build/src/code_transformer/rc_file_transformer.d.ts +56 -4
- package/build/src/debug.d.ts +12 -0
- package/build/src/dev_server.d.ts +38 -9
- package/build/src/file_buffer.d.ts +67 -0
- package/build/src/file_system.d.ts +45 -7
- package/build/src/helpers.d.ts +79 -4
- package/build/src/helpers.js +16 -0
- package/build/src/hooks.d.ts +224 -0
- package/build/src/index_generator/main.d.ts +64 -0
- package/build/src/index_generator/main.js +7 -0
- package/build/src/index_generator/source.d.ts +60 -0
- package/build/src/paths_resolver.d.ts +27 -2
- package/build/src/shortcuts_manager.d.ts +42 -4
- package/build/src/test_runner.d.ts +56 -10
- package/build/src/types/code_scanners.d.ts +138 -24
- package/build/src/types/code_transformer.d.ts +61 -19
- package/build/src/types/common.d.ts +199 -55
- package/build/src/types/hooks.d.ts +235 -22
- package/build/src/types/main.d.ts +13 -0
- package/build/src/utils.d.ts +88 -13
- package/build/src/virtual_file_system.d.ts +112 -0
- package/package.json +9 -3
- package/build/chunk-RR4HCA4M.js +0 -7
- package/build/src/ast_file_system.d.ts +0 -17
|
@@ -9,13 +9,15 @@ import type { DevServerOptions } from './types/common.ts';
|
|
|
9
9
|
* In watch mode, the DevServer will start an internal watcher and restarts the after
|
|
10
10
|
* every file change. The files must be part of the TypeScript project (via tsconfig.json),
|
|
11
11
|
* or registered as metaFiles.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* const devServer = new DevServer(cwd, { hmr: true, hooks: [] })
|
|
15
|
+
* await devServer.start(ts)
|
|
12
16
|
*/
|
|
13
17
|
export declare class DevServer {
|
|
14
18
|
#private;
|
|
15
|
-
cwd: URL;
|
|
16
|
-
options: DevServerOptions;
|
|
17
19
|
/**
|
|
18
|
-
* CLI UI
|
|
20
|
+
* CLI UI instance for displaying colorful messages and progress information
|
|
19
21
|
*/
|
|
20
22
|
ui: {
|
|
21
23
|
colors: import("@poppinss/colors/types").Colors;
|
|
@@ -46,15 +48,37 @@ export declare class DevServer {
|
|
|
46
48
|
* Script file to start the development server
|
|
47
49
|
*/
|
|
48
50
|
scriptFile: string;
|
|
51
|
+
/**
|
|
52
|
+
* The current working directory URL
|
|
53
|
+
*/
|
|
54
|
+
cwd: URL;
|
|
55
|
+
/**
|
|
56
|
+
* File path computed from the cwd
|
|
57
|
+
*/
|
|
58
|
+
cwdPath: string;
|
|
59
|
+
/**
|
|
60
|
+
* Development server configuration options including hooks and environment variables
|
|
61
|
+
*/
|
|
62
|
+
options: DevServerOptions;
|
|
63
|
+
/**
|
|
64
|
+
* Create a new DevServer instance
|
|
65
|
+
*
|
|
66
|
+
* @param cwd - The current working directory URL
|
|
67
|
+
* @param options - Development server configuration options
|
|
68
|
+
*/
|
|
49
69
|
constructor(cwd: URL, options: DevServerOptions);
|
|
50
70
|
/**
|
|
51
|
-
* Add listener to get notified when dev server is
|
|
52
|
-
*
|
|
71
|
+
* Add listener to get notified when dev server is closed
|
|
72
|
+
*
|
|
73
|
+
* @param callback - Function to call when dev server closes
|
|
74
|
+
* @returns This DevServer instance for method chaining
|
|
53
75
|
*/
|
|
54
76
|
onClose(callback: (exitCode: number) => any): this;
|
|
55
77
|
/**
|
|
56
|
-
* Add listener to get notified when dev server
|
|
57
|
-
*
|
|
78
|
+
* Add listener to get notified when dev server encounters an error
|
|
79
|
+
*
|
|
80
|
+
* @param callback - Function to call when dev server encounters an error
|
|
81
|
+
* @returns This DevServer instance for method chaining
|
|
58
82
|
*/
|
|
59
83
|
onError(callback: (error: any) => any): this;
|
|
60
84
|
/**
|
|
@@ -62,11 +86,16 @@ export declare class DevServer {
|
|
|
62
86
|
*/
|
|
63
87
|
close(): Promise<void>;
|
|
64
88
|
/**
|
|
65
|
-
* Start the development server
|
|
89
|
+
* Start the development server in static or HMR mode
|
|
90
|
+
*
|
|
91
|
+
* @param ts - TypeScript module reference
|
|
66
92
|
*/
|
|
67
93
|
start(ts: typeof tsStatic): Promise<void>;
|
|
68
94
|
/**
|
|
69
|
-
* Start the development server in watch mode
|
|
95
|
+
* Start the development server in watch mode and restart on file changes
|
|
96
|
+
*
|
|
97
|
+
* @param ts - TypeScript module reference
|
|
98
|
+
* @param options - Watch options including polling mode
|
|
70
99
|
*/
|
|
71
100
|
startAndWatch(ts: typeof tsStatic, options?: {
|
|
72
101
|
poll: boolean;
|
|
@@ -0,0 +1,67 @@
|
|
|
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
|
+
* Write a new line to the output with current indentation
|
|
34
|
+
*
|
|
35
|
+
* @param text - The text to write as a new line
|
|
36
|
+
* @returns This FileBuffer instance for method chaining
|
|
37
|
+
*/
|
|
38
|
+
writeLine(text: string): this;
|
|
39
|
+
/**
|
|
40
|
+
* Write text to the output without adding a new line
|
|
41
|
+
*
|
|
42
|
+
* @param text - The text to write without a newline
|
|
43
|
+
* @returns This FileBuffer instance for method chaining
|
|
44
|
+
*/
|
|
45
|
+
write(text: string): this;
|
|
46
|
+
/**
|
|
47
|
+
* Increase indentation by 2 spaces
|
|
48
|
+
*
|
|
49
|
+
* @returns This FileBuffer instance for method chaining
|
|
50
|
+
*/
|
|
51
|
+
indent(): this;
|
|
52
|
+
/**
|
|
53
|
+
* Decrease indentation by 2 spaces (minimum of 0)
|
|
54
|
+
*
|
|
55
|
+
* @returns This FileBuffer instance for method chaining
|
|
56
|
+
*/
|
|
57
|
+
dedent(): this;
|
|
58
|
+
/**
|
|
59
|
+
* Return template as a string, joining all buffer lines
|
|
60
|
+
*
|
|
61
|
+
* Once called, the output is cached and subsequent calls return the same result.
|
|
62
|
+
* The flush method becomes a no-op after the first call.
|
|
63
|
+
*
|
|
64
|
+
* @returns The complete buffer content as a string
|
|
65
|
+
*/
|
|
66
|
+
flush(): string;
|
|
67
|
+
}
|
|
@@ -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
|
|
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
|
-
*
|
|
45
|
-
*
|
|
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
|
-
*
|
|
48
|
-
*
|
|
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
|
-
|
|
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: tsStatic.ParsedCommandLine, 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
|
}
|
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,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,224 @@
|
|
|
1
|
+
import { type AsyncOrSync } from '@poppinss/utils/types';
|
|
2
|
+
import { type HookParams } from './types/hooks.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Collection of hooks that can be used to listen for various events during
|
|
5
|
+
* the application lifecycle. These hooks allow you to execute custom logic
|
|
6
|
+
* at specific points in the development server, build process, and testing.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```js
|
|
10
|
+
* const { hooks } = await import('@adonisjs/assembler/hooks')
|
|
11
|
+
*
|
|
12
|
+
* hooks.init((app) => {
|
|
13
|
+
* console.log('Application initialized')
|
|
14
|
+
* })
|
|
15
|
+
*
|
|
16
|
+
* hooks.devServerStarted((server) => {
|
|
17
|
+
* console.log('Dev server started on port', server.port)
|
|
18
|
+
* })
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare const hooks: {
|
|
22
|
+
/**
|
|
23
|
+
* Hook called during application initialization. This is the first hook
|
|
24
|
+
* that gets executed when the assembler starts up.
|
|
25
|
+
*
|
|
26
|
+
* @param callback - Function to execute when the init event occurs
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```js
|
|
30
|
+
* hooks.init((app) => {
|
|
31
|
+
* console.log('Application is initializing')
|
|
32
|
+
* // Setup global configurations
|
|
33
|
+
* })
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
init(callback: (...args: HookParams<"init">) => AsyncOrSync<void>): (parent: import("./dev_server.ts").DevServer | import("./test_runner.ts").TestRunner | import("./bundler.ts").Bundler, indexGenerator: import("./index_generator/main.ts").IndexGenerator) => AsyncOrSync<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Hook called after routes have been committed to the router.
|
|
39
|
+
* This occurs after all route definitions have been processed.
|
|
40
|
+
*
|
|
41
|
+
* @param callback - Function to execute when routes are committed
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```js
|
|
45
|
+
* hooks.routesCommitted((router) => {
|
|
46
|
+
* console.log('All routes have been committed to the router')
|
|
47
|
+
* // Perform route-based setup
|
|
48
|
+
* })
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
routesCommitted(callback: (...args: HookParams<"routesCommitted">) => AsyncOrSync<void>): (parent: import("./dev_server.ts").DevServer, routes: Record<string, import("./types/code_scanners.ts").RoutesListItem[]>) => AsyncOrSync<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Hook called when the assembler starts scanning for route files.
|
|
54
|
+
* This happens before any route files are actually processed.
|
|
55
|
+
*
|
|
56
|
+
* @param callback - Function to execute when route scanning begins
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```js
|
|
60
|
+
* hooks.routesScanning(() => {
|
|
61
|
+
* console.log('Starting to scan for route files')
|
|
62
|
+
* // Setup route scanning configurations
|
|
63
|
+
* })
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
routesScanning(callback: (...args: HookParams<"routesScanning">) => AsyncOrSync<void>): (parent: import("./dev_server.ts").DevServer, routesScanner: import("./code_scanners/routes_scanner/main.ts").RoutesScanner) => AsyncOrSync<void>;
|
|
67
|
+
/**
|
|
68
|
+
* Hook called after all route files have been scanned and processed.
|
|
69
|
+
* This occurs once the route scanning phase is complete.
|
|
70
|
+
*
|
|
71
|
+
* @param callback - Function to execute when route scanning is finished
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```js
|
|
75
|
+
* hooks.routesScanned((scannedRoutes) => {
|
|
76
|
+
* console.log('Route scanning completed')
|
|
77
|
+
* // Process scanned route information
|
|
78
|
+
* })
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
routesScanned(callback: (...args: HookParams<"routesScanned">) => AsyncOrSync<void>): (parent: import("./dev_server.ts").DevServer, routesScanner: import("./code_scanners/routes_scanner/main.ts").RoutesScanner) => AsyncOrSync<void>;
|
|
82
|
+
/**
|
|
83
|
+
* Hook called when a file is modified during development.
|
|
84
|
+
* This is triggered by the file watcher when changes are detected.
|
|
85
|
+
*
|
|
86
|
+
* @param callback - Function to execute when a file changes
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```js
|
|
90
|
+
* hooks.fileChanged((filePath, stats) => {
|
|
91
|
+
* console.log(`File changed: ${filePath}`)
|
|
92
|
+
* // Handle file change logic
|
|
93
|
+
* })
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
fileChanged(callback: (...args: HookParams<"fileChanged">) => AsyncOrSync<void>): (relativePath: string, absolutePath: string, info: {
|
|
97
|
+
source: "hot-hook" | "watcher";
|
|
98
|
+
hotReloaded: boolean;
|
|
99
|
+
fullReload: boolean;
|
|
100
|
+
}, parent: import("./dev_server.ts").DevServer | import("./test_runner.ts").TestRunner) => AsyncOrSync<void>;
|
|
101
|
+
/**
|
|
102
|
+
* Hook called when a new file is added during development.
|
|
103
|
+
* This is triggered by the file watcher when new files are created.
|
|
104
|
+
*
|
|
105
|
+
* @param callback - Function to execute when a file is added
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```js
|
|
109
|
+
* hooks.fileAdded((filePath, stats) => {
|
|
110
|
+
* console.log(`New file added: ${filePath}`)
|
|
111
|
+
* // Handle new file logic
|
|
112
|
+
* })
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
fileAdded(callback: (...args: HookParams<"fileAdded">) => AsyncOrSync<void>): (relativePath: string, absolutePath: string, server: import("./dev_server.ts").DevServer | import("./test_runner.ts").TestRunner) => AsyncOrSync<void>;
|
|
116
|
+
/**
|
|
117
|
+
* Hook called when a file is removed during development.
|
|
118
|
+
* This is triggered by the file watcher when files are deleted.
|
|
119
|
+
*
|
|
120
|
+
* @param callback - Function to execute when a file is removed
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```js
|
|
124
|
+
* hooks.fileRemoved((filePath) => {
|
|
125
|
+
* console.log(`File removed: ${filePath}`)
|
|
126
|
+
* // Handle file removal logic
|
|
127
|
+
* })
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
fileRemoved(callback: (...args: HookParams<"fileRemoved">) => AsyncOrSync<void>): (relativePath: string, absolutePath: string, server: import("./dev_server.ts").DevServer | import("./test_runner.ts").TestRunner) => AsyncOrSync<void>;
|
|
131
|
+
/**
|
|
132
|
+
* Hook called when the development server is about to start.
|
|
133
|
+
* This occurs before the server begins listening for connections.
|
|
134
|
+
*
|
|
135
|
+
* @param callback - Function to execute when dev server is starting
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```js
|
|
139
|
+
* hooks.devServerStarting((server) => {
|
|
140
|
+
* console.log('Development server is starting')
|
|
141
|
+
* // Setup server configurations
|
|
142
|
+
* })
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
145
|
+
devServerStarting(callback: (...args: HookParams<"devServerStarting">) => AsyncOrSync<void>): (server: import("./dev_server.ts").DevServer) => AsyncOrSync<void>;
|
|
146
|
+
/**
|
|
147
|
+
* Hook called after the development server has successfully started.
|
|
148
|
+
* This occurs once the server is listening and ready to accept requests.
|
|
149
|
+
*
|
|
150
|
+
* @param callback - Function to execute when dev server has started
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```js
|
|
154
|
+
* hooks.devServerStarted((server) => {
|
|
155
|
+
* console.log(`Development server started on port ${server.port}`)
|
|
156
|
+
* // Notify external services or open browser
|
|
157
|
+
* })
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
devServerStarted(callback: (...args: HookParams<"devServerStarted">) => AsyncOrSync<void>): (server: import("./dev_server.ts").DevServer, info: {
|
|
161
|
+
port: number;
|
|
162
|
+
host: string;
|
|
163
|
+
}, uiInstructions: import("@poppinss/cliui").Instructions) => AsyncOrSync<void>;
|
|
164
|
+
/**
|
|
165
|
+
* Hook called when the build process is about to start.
|
|
166
|
+
* This occurs before any build tasks are executed.
|
|
167
|
+
*
|
|
168
|
+
* @param callback - Function to execute when build is starting
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* ```js
|
|
172
|
+
* hooks.buildStarting((buildConfig) => {
|
|
173
|
+
* console.log('Build process is starting')
|
|
174
|
+
* // Setup build configurations or clean directories
|
|
175
|
+
* })
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
178
|
+
buildStarting(callback: (...args: HookParams<"buildStarting">) => AsyncOrSync<void>): (server: import("./bundler.ts").Bundler) => AsyncOrSync<void>;
|
|
179
|
+
/**
|
|
180
|
+
* Hook called after the build process has completed.
|
|
181
|
+
* This occurs once all build tasks have finished executing.
|
|
182
|
+
*
|
|
183
|
+
* @param callback - Function to execute when build is finished
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```js
|
|
187
|
+
* hooks.buildFinished((buildResult) => {
|
|
188
|
+
* console.log('Build process completed')
|
|
189
|
+
* // Deploy artifacts or notify build completion
|
|
190
|
+
* })
|
|
191
|
+
* ```
|
|
192
|
+
*/
|
|
193
|
+
buildFinished(callback: (...args: HookParams<"buildFinished">) => AsyncOrSync<void>): (server: import("./bundler.ts").Bundler, uiInstructions: import("@poppinss/cliui").Instructions) => AsyncOrSync<void>;
|
|
194
|
+
/**
|
|
195
|
+
* Hook called when the test suite is about to start.
|
|
196
|
+
* This occurs before any test files are executed.
|
|
197
|
+
*
|
|
198
|
+
* @param callback - Function to execute when tests are starting
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
* ```js
|
|
202
|
+
* hooks.testsStarting((testConfig) => {
|
|
203
|
+
* console.log('Test suite is starting')
|
|
204
|
+
* // Setup test database or mock services
|
|
205
|
+
* })
|
|
206
|
+
* ```
|
|
207
|
+
*/
|
|
208
|
+
testsStarting(callback: (...args: HookParams<"testsStarting">) => AsyncOrSync<void>): (server: import("./test_runner.ts").TestRunner) => AsyncOrSync<void>;
|
|
209
|
+
/**
|
|
210
|
+
* Hook called after the test suite has completed.
|
|
211
|
+
* This occurs once all test files have finished executing.
|
|
212
|
+
*
|
|
213
|
+
* @param callback - Function to execute when tests are finished
|
|
214
|
+
*
|
|
215
|
+
* @example
|
|
216
|
+
* ```js
|
|
217
|
+
* hooks.testsFinished((testResults) => {
|
|
218
|
+
* console.log('Test suite completed')
|
|
219
|
+
* // Generate test reports or cleanup test resources
|
|
220
|
+
* })
|
|
221
|
+
* ```
|
|
222
|
+
*/
|
|
223
|
+
testsFinished(callback: (...args: HookParams<"testsFinished">) => AsyncOrSync<void>): (server: import("./test_runner.ts").TestRunner) => AsyncOrSync<void>;
|
|
224
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
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
|
+
* Create a new IndexGenerator instance
|
|
24
|
+
*
|
|
25
|
+
* @param appRoot - The application root directory path
|
|
26
|
+
* @param cliLogger - Logger instance for CLI output
|
|
27
|
+
*/
|
|
28
|
+
constructor(appRoot: string, cliLogger: Logger);
|
|
29
|
+
/**
|
|
30
|
+
* Add a new index generator source
|
|
31
|
+
*
|
|
32
|
+
* @param name - Unique name for the source
|
|
33
|
+
* @param config - Configuration for the index generator source
|
|
34
|
+
* @returns This IndexGenerator instance for method chaining
|
|
35
|
+
*/
|
|
36
|
+
add(name: string, config: IndexGeneratorSourceConfig): this;
|
|
37
|
+
/**
|
|
38
|
+
* Add a file to all registered index generator sources
|
|
39
|
+
*
|
|
40
|
+
* This method propagates the file addition to all registered sources,
|
|
41
|
+
* allowing them to regenerate their index files if the new file matches
|
|
42
|
+
* their glob patterns.
|
|
43
|
+
*
|
|
44
|
+
* @param filePath - Absolute path of the file to add
|
|
45
|
+
*/
|
|
46
|
+
addFile(filePath: string): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Remove a file from all registered index generator sources
|
|
49
|
+
*
|
|
50
|
+
* This method propagates the file removal to all registered sources,
|
|
51
|
+
* allowing them to regenerate their index files if the removed file
|
|
52
|
+
* was previously tracked.
|
|
53
|
+
*
|
|
54
|
+
* @param filePath - Absolute path of the file to remove
|
|
55
|
+
*/
|
|
56
|
+
removeFile(filePath: string): Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Generate all registered index files
|
|
59
|
+
*
|
|
60
|
+
* Iterates through all registered sources and generates their
|
|
61
|
+
* corresponding index files.
|
|
62
|
+
*/
|
|
63
|
+
generate(): Promise<void>;
|
|
64
|
+
}
|