@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.
Files changed (39) hide show
  1. package/README.md +87 -59
  2. package/build/codemod_exception-vyN1VXuX.js +137 -0
  3. package/build/helpers-DDurYRsZ.js +72 -0
  4. package/build/index.d.ts +4 -0
  5. package/build/index.js +925 -1319
  6. package/build/main-BeV45LeF.js +246 -0
  7. package/build/main-CknPN3rJ.js +188 -0
  8. package/build/src/bundler.d.ts +44 -3
  9. package/build/src/code_scanners/routes_scanner/main.d.ts +63 -11
  10. package/build/src/code_scanners/routes_scanner/main.js +4 -0
  11. package/build/src/code_scanners/routes_scanner/validator_extractor.d.ts +12 -4
  12. package/build/src/code_transformer/main.d.ts +53 -43
  13. package/build/src/code_transformer/main.js +354 -599
  14. package/build/src/code_transformer/rc_file_transformer.d.ts +83 -5
  15. package/build/src/debug.d.ts +13 -1
  16. package/build/src/dev_server.d.ts +92 -17
  17. package/build/src/exceptions/codemod_exception.d.ts +178 -0
  18. package/build/src/file_buffer.d.ts +87 -0
  19. package/build/src/file_system.d.ts +46 -8
  20. package/build/src/helpers.d.ts +79 -4
  21. package/build/src/helpers.js +2 -0
  22. package/build/src/index_generator/main.d.ts +68 -0
  23. package/build/src/index_generator/main.js +3 -0
  24. package/build/src/index_generator/source.d.ts +60 -0
  25. package/build/src/paths_resolver.d.ts +29 -3
  26. package/build/src/shortcuts_manager.d.ts +42 -4
  27. package/build/src/test_runner.d.ts +57 -12
  28. package/build/src/types/code_scanners.d.ts +160 -30
  29. package/build/src/types/code_transformer.d.ts +69 -19
  30. package/build/src/types/common.d.ts +233 -55
  31. package/build/src/types/hooks.d.ts +238 -22
  32. package/build/src/types/main.d.ts +15 -1
  33. package/build/src/types/main.js +1 -0
  34. package/build/src/utils.d.ts +96 -15
  35. package/build/src/virtual_file_system.d.ts +112 -0
  36. package/build/virtual_file_system-bGeoWsK-.js +285 -0
  37. package/package.json +46 -36
  38. package/build/chunk-RR4HCA4M.js +0 -7
  39. package/build/src/ast_file_system.d.ts +0 -17
@@ -3,45 +3,123 @@ import { type AssemblerRcFile } from '../types/common.ts';
3
3
  declare const ALLOWED_ENVIRONMENTS: readonly ["web", "console", "test", "repl"];
4
4
  /**
5
5
  * RcFileTransformer is used to transform the `adonisrc.ts` file
6
- * for adding new commands, providers, meta files etc
6
+ * for adding new commands, providers, meta files etc.
7
+ *
8
+ * This class provides a fluent API for modifying the AdonisJS configuration
9
+ * file (adonisrc.ts) by adding various types of entries like providers,
10
+ * commands, preloaded files, meta files, and test suites.
11
+ *
12
+ * @example
13
+ * const transformer = new RcFileTransformer(cwd, project)
14
+ * transformer.addProvider('#providers/app_provider')
15
+ * transformer.addCommand('#commands/make_controller')
16
+ * await transformer.save()
7
17
  */
8
18
  export declare class RcFileTransformer {
9
19
  #private;
20
+ /**
21
+ * Create a new RcFileTransformer instance
22
+ *
23
+ * @param cwd - The current working directory URL
24
+ * @param project - The TsMorph project instance
25
+ */
10
26
  constructor(cwd: URL, project: Project);
11
27
  /**
12
28
  * Add a new command to the rcFile
29
+ *
30
+ * @param commandPath - The path to the command file
31
+ * @returns This RcFileTransformer instance for method chaining
13
32
  */
14
33
  addCommand(commandPath: string): this;
15
34
  /**
16
35
  * Add a new preloaded file to the rcFile
36
+ *
37
+ * @param modulePath - The path to the preload file
38
+ * @param environments - Optional array of environments where this preload should run
39
+ * @returns This RcFileTransformer instance for method chaining
17
40
  */
18
41
  addPreloadFile(modulePath: string, environments?: (typeof ALLOWED_ENVIRONMENTS)[number][]): this;
19
42
  /**
20
43
  * Add a new provider to the rcFile
44
+ *
45
+ * @param providerPath - The path to the provider file
46
+ * @param environments - Optional array of environments where this provider should run
47
+ * @returns This RcFileTransformer instance for method chaining
21
48
  */
22
49
  addProvider(providerPath: string, environments?: (typeof ALLOWED_ENVIRONMENTS)[number][]): this;
23
50
  /**
24
51
  * Add a new meta file to the rcFile
52
+ *
53
+ * @param globPattern - The glob pattern for the meta file
54
+ * @param reloadServer - Whether the server should reload when this file changes
55
+ * @returns This RcFileTransformer instance for method chaining
25
56
  */
26
57
  addMetaFile(globPattern: string, reloadServer?: boolean): this;
27
58
  /**
28
- * Set directory name and path
59
+ * Set directory name and path in the directories configuration
60
+ *
61
+ * @param key - The directory key (e.g., 'controllers', 'models')
62
+ * @param value - The directory path
63
+ * @returns This RcFileTransformer instance for method chaining
29
64
  */
30
65
  setDirectory(key: string, value: string): this;
31
66
  /**
32
- * Set command alias
67
+ * Set command alias in the command aliases configuration
68
+ *
69
+ * @param alias - The alias name
70
+ * @param command - The full command name
71
+ * @returns This RcFileTransformer instance for method chaining
33
72
  */
34
73
  setCommandAlias(alias: string, command: string): this;
35
74
  /**
36
75
  * Add a new test suite to the rcFile
76
+ *
77
+ * @param suiteName - The name of the test suite
78
+ * @param files - File patterns for the test suite (string or array)
79
+ * @param timeout - Optional timeout in milliseconds (defaults to 2000)
80
+ * @returns This RcFileTransformer instance for method chaining
37
81
  */
38
82
  addSuite(suiteName: string, files: string | string[], timeout?: number): this;
39
83
  /**
40
84
  * Add a new assembler hook
85
+ * The format `thunk` write `() => import(path)`.
86
+ *
87
+ * @param type - The type of hook to add
88
+ * @param value - The path to the hook file or value to write
89
+ * @param raw - Wether to write a thunk import or as raw value
90
+ * @returns This RcFileTransformer instance for method chaining
91
+ */
92
+ addAssemblerHook(type: keyof Exclude<AssemblerRcFile['hooks'], undefined>, value: string, raw?: boolean): this;
93
+ /**
94
+ * Add a named import
95
+ *
96
+ * @param specifier - The module specifier to import
97
+ * @param names - Names to import from the module
98
+ * @returns This RcFileTransformer instance for method chaining
99
+ */
100
+ addNamedImport(specifier: string, names: string[]): this;
101
+ /**
102
+ * Add a default import
103
+ *
104
+ * @param specifier - The module specifier to import
105
+ * @param name - Name of the default import
106
+ * @returns This RcFileTransformer instance for method chaining
107
+ */
108
+ addDefaultImport(specifier: string, name: string): this;
109
+ /**
110
+ * Get a directory value from the directories configuration.
111
+ *
112
+ * @param key - The directory key to retrieve
113
+ * @param defaultValue - The default value if not configured
114
+ * @returns The configured directory path or the default value
41
115
  */
42
- addAssemblerHook(type: keyof Exclude<AssemblerRcFile['hooks'], undefined>, path: string): this;
116
+ getDirectory(key: string, defaultValue: string): string;
43
117
  /**
44
- * Save the adonisrc.ts file
118
+ * Save the adonisrc.ts file with all applied transformations
119
+ *
120
+ * Formats the file according to editor settings and saves it to disk.
121
+ *
122
+ * @returns Promise that resolves when the file is saved
45
123
  */
46
124
  save(): Promise<void>;
47
125
  }
@@ -1,2 +1,14 @@
1
- declare const _default: import("util").DebugLogger;
1
+ /**
2
+ * Debug logger for the AdonisJS assembler package.
3
+ *
4
+ * This debug instance is configured to log messages under the 'adonisjs:assembler'
5
+ * namespace. Debug messages are only shown when the NODE_DEBUG environment variable
6
+ * includes 'adonisjs:assembler'.
7
+ *
8
+ * @example
9
+ * // Enable debug logging
10
+ * // NODE_DEBUG=adonisjs:assembler node ace serve
11
+ * debug('Starting development server...')
12
+ */
13
+ declare const _default: import("node:util").DebugLogger;
2
14
  export default _default;
@@ -1,21 +1,24 @@
1
- import type tsStatic from 'typescript';
2
1
  import type { DevServerOptions } from './types/common.ts';
3
2
  /**
4
- * Exposes the API to start the development server in HMR, watch or static mode.
3
+ * Exposes the API to start the development server in HMR, watch or static mode
5
4
  *
6
5
  * In HMR mode, the DevServer will exec the "bin/server.ts" file and let hot-hook
7
6
  * manage the changes using hot module reloading.
8
7
  *
9
- * In watch mode, the DevServer will start an internal watcher and restarts the after
10
- * every file change. The files must be part of the TypeScript project (via tsconfig.json),
8
+ * In watch mode, the DevServer will start an internal watcher and restarts the server
9
+ * after every file change. The files must be part of the TypeScript project (via tsconfig.json),
11
10
  * or registered as metaFiles.
11
+ *
12
+ * In static mode, the server runs without file watching or hot reloading.
13
+ *
14
+ * @example
15
+ * const devServer = new DevServer(cwd, { hmr: true, hooks: [] })
16
+ * await devServer.start(ts)
12
17
  */
13
18
  export declare class DevServer {
14
19
  #private;
15
- cwd: URL;
16
- options: DevServerOptions;
17
20
  /**
18
- * CLI UI to log colorful messages
21
+ * CLI UI instance for displaying colorful messages and progress information
19
22
  */
20
23
  ui: {
21
24
  colors: import("@poppinss/colors/types").Colors;
@@ -39,36 +42,108 @@ export declare class DevServer {
39
42
  useColors(colorsToUse: import("@poppinss/colors/types").Colors): void;
40
43
  };
41
44
  /**
42
- * The mode in which the DevServer is running.
45
+ * The mode in which the DevServer is running
46
+ *
47
+ * Returns the current operating mode of the development server:
48
+ * - 'hmr': Hot Module Reloading enabled
49
+ * - 'watch': File system watching with full restarts
50
+ * - 'static': No file watching or hot reloading
43
51
  */
44
52
  get mode(): "hmr" | "watch" | "static";
45
53
  /**
46
54
  * Script file to start the development server
47
55
  */
48
56
  scriptFile: string;
57
+ /**
58
+ * The current working directory URL
59
+ */
60
+ cwd: URL;
61
+ /**
62
+ * File path computed from the cwd
63
+ */
64
+ cwdPath: string;
65
+ /**
66
+ * Development server configuration options including hooks and environment variables
67
+ */
68
+ options: DevServerOptions;
69
+ /**
70
+ * Create a new DevServer instance
71
+ *
72
+ * @param cwd - The current working directory URL
73
+ * @param options - Development server configuration options
74
+ */
49
75
  constructor(cwd: URL, options: DevServerOptions);
50
76
  /**
51
- * Add listener to get notified when dev server is
52
- * closed
77
+ * Adds listener to get notified when dev server is closed
78
+ *
79
+ * Registers a callback function that will be invoked when the development
80
+ * server's child process exits. The callback receives the exit code.
81
+ *
82
+ * @param callback - Function to call when dev server closes
83
+ * @returns This DevServer instance for method chaining
84
+ *
85
+ * @example
86
+ * devServer.onClose((exitCode) => {
87
+ * console.log(`Server closed with exit code: ${exitCode}`)
88
+ * })
53
89
  */
54
90
  onClose(callback: (exitCode: number) => any): this;
55
91
  /**
56
- * Add listener to get notified when dev server exists
57
- * with an error
92
+ * Adds listener to get notified when dev server encounters an error
93
+ *
94
+ * Registers a callback function that will be invoked when the development
95
+ * server's child process encounters an error or fails to start.
96
+ *
97
+ * @param callback - Function to call when dev server encounters an error
98
+ * @returns This DevServer instance for method chaining
99
+ *
100
+ * @example
101
+ * devServer.onError((error) => {
102
+ * console.error('Dev server error:', error.message)
103
+ * })
58
104
  */
59
105
  onError(callback: (error: any) => any): this;
60
106
  /**
61
- * Close watchers and the running child process
107
+ * Closes watchers and terminates the running child process
108
+ *
109
+ * Cleans up keyboard shortcuts, stops file system watchers, and kills
110
+ * the HTTP server child process. This should be called when shutting down
111
+ * the development server.
112
+ *
113
+ * @example
114
+ * await devServer.close()
62
115
  */
63
116
  close(): Promise<void>;
64
117
  /**
65
- * Start the development server
118
+ * Starts the development server in static or HMR mode
119
+ *
120
+ * Initializes the server and starts the HTTP server. The mode is determined
121
+ * by the `hmr` option in DevServerOptions. In HMR mode, hot-hook is configured
122
+ * to enable hot module reloading.
123
+ *
124
+ * @param ts - TypeScript module reference
125
+ *
126
+ * @example
127
+ * const devServer = new DevServer(cwd, { hmr: true, hooks: [] })
128
+ * await devServer.start(ts)
66
129
  */
67
- start(ts: typeof tsStatic): Promise<void>;
130
+ start(): Promise<void>;
68
131
  /**
69
- * Start the development server in watch mode
132
+ * Starts the development server in watch mode and restarts on file changes
133
+ *
134
+ * Initializes the server, starts the HTTP server, and sets up a file system
135
+ * watcher that monitors for changes. When files are added, modified, or deleted,
136
+ * the server automatically restarts. The watcher respects TypeScript project
137
+ * configuration and metaFiles settings.
138
+ *
139
+ * @param ts - TypeScript module reference
140
+ * @param options - Watch options including polling mode
141
+ *
142
+ * @example
143
+ * const devServer = new DevServer(cwd, { hooks: [] })
144
+ * await devServer.startAndWatch(ts, { poll: false })
70
145
  */
71
- startAndWatch(ts: typeof tsStatic, options?: {
146
+ startAndWatch(options?: {
72
147
  poll: boolean;
73
148
  }): Promise<void>;
74
149
  }
@@ -0,0 +1,178 @@
1
+ import type { MiddlewareNode, EnvValidationNode, BouncerPolicyNode } from '../types/code_transformer.ts';
2
+ /**
3
+ * Options for creating a CodemodException
4
+ */
5
+ export interface CodemodExceptionOptions {
6
+ /**
7
+ * Instructions for the user to manually perform the codemod action
8
+ */
9
+ instructions?: string;
10
+ /**
11
+ * The file path that was being modified
12
+ */
13
+ filePath?: string;
14
+ }
15
+ /**
16
+ * Custom exception for codemod errors that provides helpful instructions
17
+ * to the user when automatic code transformation fails.
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * throw CodemodException.missingEnvFile('start/env.ts', {
22
+ * variables: { MY_VAR: 'Env.schema.string()' }
23
+ * })
24
+ * ```
25
+ */
26
+ export declare class CodemodException extends Error {
27
+ #private;
28
+ /**
29
+ * Instructions for the user to manually perform the codemod action
30
+ */
31
+ instructions?: string;
32
+ /**
33
+ * The file path that was being modified
34
+ */
35
+ filePath?: string;
36
+ constructor(message: string, options?: CodemodExceptionOptions);
37
+ /**
38
+ * Creates an exception when start/env.ts file is missing
39
+ *
40
+ * @param filePath - The path to the missing file
41
+ * @param definition - The environment validation definition that was being added
42
+ */
43
+ static missingEnvFile(filePath: string, definition: EnvValidationNode): CodemodException;
44
+ /**
45
+ * Creates an exception when Env.create is not found in the file
46
+ *
47
+ * @param filePath - The path to the file being modified
48
+ * @param definition - The environment validation definition that was being added
49
+ */
50
+ static missingEnvCreate(filePath: string, definition: EnvValidationNode): CodemodException;
51
+ /**
52
+ * Creates an exception when Env.create has invalid structure
53
+ *
54
+ * @param filePath - The path to the file being modified
55
+ * @param definition - The environment validation definition that was being added
56
+ */
57
+ static invalidEnvCreate(filePath: string, definition: EnvValidationNode): CodemodException;
58
+ /**
59
+ * Creates an exception when start/kernel.ts file is missing
60
+ *
61
+ * @param filePath - The path to the missing file
62
+ * @param stack - The middleware stack that was being modified
63
+ * @param middleware - The middleware entries that were being added
64
+ */
65
+ static missingKernelFile(filePath: string, stack: 'server' | 'router' | 'named', middleware: MiddlewareNode[]): CodemodException;
66
+ /**
67
+ * Creates an exception when server.use/router.use is not found
68
+ *
69
+ * @param filePath - The path to the file being modified
70
+ * @param stack - The middleware stack that was being modified
71
+ * @param middleware - The middleware entries that were being added
72
+ */
73
+ static missingMiddlewareStack(filePath: string, stack: 'server' | 'router' | 'named', middleware: MiddlewareNode[]): CodemodException;
74
+ /**
75
+ * Creates an exception when middleware array structure is invalid
76
+ *
77
+ * @param filePath - The path to the file being modified
78
+ * @param stack - The middleware stack that was being modified
79
+ * @param middleware - The middleware entries that were being added
80
+ * @param reason - The reason why the structure is invalid
81
+ */
82
+ static invalidMiddlewareStack(filePath: string, stack: 'server' | 'router' | 'named', middleware: MiddlewareNode[], reason: string): CodemodException;
83
+ /**
84
+ * Creates an exception when app/policies/main.ts file is missing
85
+ *
86
+ * @param filePath - The path to the missing file
87
+ * @param policies - The policies that were being added
88
+ */
89
+ static missingPoliciesFile(filePath: string, policies: BouncerPolicyNode[]): CodemodException;
90
+ /**
91
+ * Creates an exception when policies structure is invalid
92
+ *
93
+ * @param filePath - The path to the file being modified
94
+ * @param policies - The policies that were being added
95
+ * @param reason - The reason why the structure is invalid
96
+ */
97
+ static invalidPoliciesFile(filePath: string, policies: BouncerPolicyNode[], reason: string): CodemodException;
98
+ /**
99
+ * Creates an exception when vite.config.ts file is missing
100
+ *
101
+ * @param filePath - The path to the missing file
102
+ * @param pluginCall - The plugin call that was being added
103
+ * @param importDeclarations - The import declarations needed for the plugin
104
+ */
105
+ static missingViteConfig(filePath: string, pluginCall: string, importDeclarations: {
106
+ isNamed: boolean;
107
+ module: string;
108
+ identifier: string;
109
+ }[]): CodemodException;
110
+ /**
111
+ * Creates an exception when vite.config.ts structure is invalid
112
+ *
113
+ * @param filePath - The path to the file being modified
114
+ * @param pluginCall - The plugin call that was being added
115
+ * @param importDeclarations - The import declarations needed for the plugin
116
+ * @param reason - The reason why the structure is invalid
117
+ */
118
+ static invalidViteConfig(filePath: string, pluginCall: string, importDeclarations: {
119
+ isNamed: boolean;
120
+ module: string;
121
+ identifier: string;
122
+ }[], reason: string): CodemodException;
123
+ /**
124
+ * Creates an exception when tests/bootstrap.ts file is missing
125
+ *
126
+ * @param filePath - The path to the missing file
127
+ * @param pluginCall - The plugin call that was being added
128
+ * @param importDeclarations - The import declarations needed for the plugin
129
+ */
130
+ static missingJapaBootstrap(filePath: string, pluginCall: string, importDeclarations: {
131
+ isNamed: boolean;
132
+ module: string;
133
+ identifier: string;
134
+ }[]): CodemodException;
135
+ /**
136
+ * Creates an exception when tests/bootstrap.ts structure is invalid
137
+ *
138
+ * @param filePath - The path to the file being modified
139
+ * @param pluginCall - The plugin call that was being added
140
+ * @param importDeclarations - The import declarations needed for the plugin
141
+ * @param reason - The reason why the structure is invalid
142
+ */
143
+ static invalidJapaBootstrap(filePath: string, pluginCall: string, importDeclarations: {
144
+ isNamed: boolean;
145
+ module: string;
146
+ identifier: string;
147
+ }[], reason: string): CodemodException;
148
+ /**
149
+ * Creates an exception when adonisrc.ts file is missing
150
+ *
151
+ * @param filePath - The path to the missing file
152
+ * @param codeToAdd - The code that should be added manually
153
+ */
154
+ static missingRcFile(filePath: string, codeToAdd: string): CodemodException;
155
+ /**
156
+ * Creates an exception when adonisrc.ts structure is invalid
157
+ *
158
+ * @param filePath - The path to the file being modified
159
+ * @param codeToAdd - The code that should be added manually
160
+ * @param reason - The reason why the structure is invalid
161
+ */
162
+ static invalidRcFile(filePath: string, codeToAdd: string, reason: string): CodemodException;
163
+ /**
164
+ * Creates an exception when a file required for transformation is not found.
165
+ *
166
+ * @param filePath - The path to the missing file
167
+ * @param codeToAdd - The code that should be added manually
168
+ */
169
+ static E_CODEMOD_FILE_NOT_FOUND(filePath: string, codeToAdd: string): CodemodException;
170
+ /**
171
+ * Creates an exception when the file structure doesn't match expected patterns.
172
+ *
173
+ * @param message - Description of what structure was expected
174
+ * @param filePath - The path to the file being modified
175
+ * @param codeToAdd - The code that should be added manually
176
+ */
177
+ static E_CODEMOD_INVALID_STRUCTURE(message: string, filePath: string, codeToAdd: string): CodemodException;
178
+ }
@@ -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
  }