@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.
- package/README.md +88 -84
- package/build/chunk-4452KFDQ.js +465 -0
- package/build/chunk-JFBQ4OEM.js +434 -0
- package/build/chunk-NAASGAFO.js +478 -0
- package/build/chunk-TIKQQRMX.js +116 -0
- package/build/index.d.ts +3 -0
- package/build/index.js +800 -447
- package/build/src/bundler.d.ts +44 -3
- package/build/src/code_scanners/routes_scanner/main.d.ts +119 -0
- package/build/src/code_scanners/routes_scanner/main.js +8 -0
- package/build/src/code_scanners/routes_scanner/validator_extractor.d.ts +26 -0
- 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 +92 -17
- package/build/src/file_buffer.d.ts +87 -0
- package/build/src/file_system.d.ts +46 -8
- package/build/src/helpers.d.ts +115 -0
- package/build/src/helpers.js +16 -0
- package/build/src/index_generator/main.d.ts +68 -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 +41 -0
- package/build/src/shortcuts_manager.d.ts +43 -28
- package/build/src/test_runner.d.ts +57 -12
- package/build/src/types/code_scanners.d.ts +226 -0
- package/build/src/types/code_transformer.d.ts +61 -19
- package/build/src/types/common.d.ts +270 -51
- package/build/src/types/hooks.d.ts +235 -22
- package/build/src/types/main.d.ts +15 -1
- package/build/src/utils.d.ts +99 -15
- package/build/src/virtual_file_system.d.ts +112 -0
- package/package.json +33 -20
- package/build/chunk-RR4HCA4M.js +0 -7
|
@@ -1,149 +1,368 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { Logger } from '@poppinss/cliui';
|
|
2
|
+
import { type Prettify } from '@poppinss/utils/types';
|
|
3
|
+
import type StringBuilder from '@poppinss/utils/string_builder';
|
|
4
|
+
import { type AllHooks } from './hooks.ts';
|
|
5
|
+
import { type FileBuffer } from '../file_buffer.ts';
|
|
6
|
+
import { type VirtualFileSystem } from '../virtual_file_system.ts';
|
|
7
|
+
/**
|
|
8
|
+
* Recursive file tree structure for representing nested directory hierarchies
|
|
9
|
+
*/
|
|
10
|
+
export type RecursiveFileTree = {
|
|
11
|
+
[key: string]: string | RecursiveFileTree;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Options accepted by the VirtualFileSystem class
|
|
15
|
+
*/
|
|
16
|
+
export type VirtualFileSystemOptions = {
|
|
17
|
+
glob?: string[];
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Source configuration accepted by the index generator
|
|
21
|
+
*/
|
|
22
|
+
export type IndexGeneratorSourceConfig = ({
|
|
23
|
+
exportName: string;
|
|
24
|
+
as: 'barrelFile';
|
|
25
|
+
/**
|
|
26
|
+
* Disable the use of lazy imports and instead import the
|
|
27
|
+
* files using the import expression
|
|
28
|
+
*/
|
|
29
|
+
disableLazyImports?: boolean;
|
|
30
|
+
} | {
|
|
31
|
+
as: (vfs: VirtualFileSystem, buffer: FileBuffer, config: IndexGeneratorSourceConfig, helpers: {
|
|
32
|
+
toImportPath(filePath: string): string;
|
|
33
|
+
}) => void;
|
|
34
|
+
}) & {
|
|
35
|
+
computeBaseName?: (baseName: StringBuilder) => StringBuilder;
|
|
36
|
+
source: string;
|
|
37
|
+
output: string;
|
|
38
|
+
glob?: string[];
|
|
39
|
+
importAlias?: string;
|
|
40
|
+
removeSuffix?: string;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Marks a given optional property as required
|
|
44
|
+
*
|
|
45
|
+
* @template T - The source type
|
|
46
|
+
* @template K - The keys from T that should be made required
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* type User = { name?: string; email?: string; age: number }
|
|
50
|
+
* type UserWithName = AsRequired<User, 'name'> // { name: string; email?: string; age: number }
|
|
51
|
+
*/
|
|
52
|
+
export type AsRequired<T, K extends keyof T> = Prettify<Omit<T, K> & Required<{
|
|
53
|
+
[O in K]: T[K];
|
|
54
|
+
}>>;
|
|
55
|
+
/**
|
|
56
|
+
* Represents an import statement parsed from TypeScript/JavaScript code
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* // For: import { User } from './models/user'
|
|
60
|
+
* const importInfo: Import = {
|
|
61
|
+
* specifier: './models/user',
|
|
62
|
+
* isConstant: true,
|
|
63
|
+
* clause: { type: 'named', value: 'User' }
|
|
64
|
+
* }
|
|
65
|
+
*/
|
|
66
|
+
export type Import = {
|
|
67
|
+
/** The module specifier being imported from */
|
|
68
|
+
specifier: string;
|
|
69
|
+
/** Whether the import specifier is a constant string literal */
|
|
70
|
+
isConstant: boolean;
|
|
71
|
+
/** The import clause details */
|
|
72
|
+
clause: {
|
|
73
|
+
/** The type of import clause */
|
|
74
|
+
type: 'namespace' | 'default' | 'named';
|
|
75
|
+
/** The imported identifier name */
|
|
76
|
+
value: string;
|
|
77
|
+
/** Optional alias for named imports with 'as' keyword */
|
|
78
|
+
alias?: string;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
2
81
|
/**
|
|
3
82
|
* File inspected by the filesystem based upon the provided globs
|
|
4
83
|
* and the current file path
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* const inspectedFile: InspectedFile = {
|
|
87
|
+
* fileType: 'script',
|
|
88
|
+
* reloadServer: true,
|
|
89
|
+
* unixRelativePath: 'app/controllers/users_controller.ts',
|
|
90
|
+
* unixAbsolutePath: '/project/app/controllers/users_controller.ts'
|
|
91
|
+
* }
|
|
5
92
|
*/
|
|
6
93
|
export type InspectedFile = {
|
|
94
|
+
/** The category of the file based on its purpose */
|
|
7
95
|
fileType: 'script' | 'meta' | 'test';
|
|
96
|
+
/** Whether changes to this file should trigger server reload */
|
|
8
97
|
reloadServer: boolean;
|
|
98
|
+
/** Unix-style relative path from project root */
|
|
9
99
|
unixRelativePath: string;
|
|
100
|
+
/** Unix-style absolute path to the file */
|
|
10
101
|
unixAbsolutePath: string;
|
|
11
102
|
};
|
|
12
103
|
/**
|
|
13
104
|
* Subset of properties assembler needs from the "adonisrc.ts" file.
|
|
105
|
+
* Contains configuration for file watching, hooks, and test suites.
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* const rcFile: AssemblerRcFile = {
|
|
109
|
+
* metaFiles: [
|
|
110
|
+
* { pattern: 'config/**', reloadServer: true }
|
|
111
|
+
* ],
|
|
112
|
+
* hooks: {
|
|
113
|
+
* devServerStarted: [() => import('./hooks/server_started')]
|
|
114
|
+
* },
|
|
115
|
+
* suites: [
|
|
116
|
+
* { name: 'unit', files: ['tests/unit/**\/*.spec.ts'] }
|
|
117
|
+
* ]
|
|
118
|
+
* }
|
|
14
119
|
*/
|
|
15
120
|
export type AssemblerRcFile = {
|
|
16
121
|
/**
|
|
17
|
-
* An array of metaFiles glob patterns to watch
|
|
122
|
+
* An array of metaFiles glob patterns to watch for changes
|
|
18
123
|
*/
|
|
19
124
|
metaFiles?: {
|
|
125
|
+
/** Glob pattern to match files */
|
|
20
126
|
pattern: string;
|
|
127
|
+
/** Whether to reload server when these files change */
|
|
21
128
|
reloadServer: boolean;
|
|
22
129
|
}[];
|
|
23
130
|
/**
|
|
24
|
-
* Hooks to execute at different stages
|
|
131
|
+
* Hooks to execute at different stages of development and build processes
|
|
25
132
|
*/
|
|
26
|
-
hooks?: Partial<
|
|
133
|
+
hooks?: Partial<AllHooks>;
|
|
27
134
|
/**
|
|
28
|
-
* An array of suites
|
|
135
|
+
* An array of test suites configuration
|
|
29
136
|
*/
|
|
30
137
|
suites?: {
|
|
138
|
+
/** Name of the test suite */
|
|
31
139
|
name: string;
|
|
140
|
+
/** Glob pattern(s) for test files in this suite */
|
|
32
141
|
files: string | string[];
|
|
33
142
|
}[];
|
|
34
143
|
};
|
|
35
144
|
/**
|
|
36
|
-
* Options needed to run a script file
|
|
145
|
+
* Options needed to run a script file as a child process
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* const options: RunScriptOptions = {
|
|
149
|
+
* script: 'bin/server.ts',
|
|
150
|
+
* scriptArgs: ['--watch'],
|
|
151
|
+
* nodeArgs: ['--loader', 'ts-node/esm'],
|
|
152
|
+
* stdio: 'inherit',
|
|
153
|
+
* env: { NODE_ENV: 'development' },
|
|
154
|
+
* reject: true
|
|
155
|
+
* }
|
|
37
156
|
*/
|
|
38
157
|
export type RunScriptOptions = {
|
|
39
|
-
/**
|
|
40
|
-
* Script to run
|
|
41
|
-
*/
|
|
158
|
+
/** Path to the script file to run */
|
|
42
159
|
script: string;
|
|
43
|
-
/**
|
|
44
|
-
* Arguments to pass to the script
|
|
45
|
-
*/
|
|
160
|
+
/** Arguments to pass to the script */
|
|
46
161
|
scriptArgs: string[];
|
|
47
|
-
/**
|
|
48
|
-
* Arguments to pass to NodeJS CLI
|
|
49
|
-
*/
|
|
162
|
+
/** Arguments to pass to the Node.js CLI */
|
|
50
163
|
nodeArgs: string[];
|
|
51
|
-
/**
|
|
52
|
-
* Standard input ouput stream options
|
|
53
|
-
*/
|
|
164
|
+
/** Standard input/output stream options */
|
|
54
165
|
stdio?: 'pipe' | 'inherit';
|
|
55
|
-
/**
|
|
56
|
-
* Environment variables to pass to the child process
|
|
57
|
-
*/
|
|
166
|
+
/** Environment variables to pass to the child process */
|
|
58
167
|
env?: NodeJS.ProcessEnv;
|
|
59
|
-
/**
|
|
60
|
-
* Whether or not to reject the promise. Defaults
|
|
61
|
-
* false
|
|
62
|
-
*/
|
|
168
|
+
/** Whether to reject the promise on script failure (defaults to false) */
|
|
63
169
|
reject?: boolean;
|
|
64
170
|
};
|
|
65
171
|
/**
|
|
66
|
-
* Options accepted when starting the
|
|
172
|
+
* Options accepted when starting the development server
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* const devOptions: DevServerOptions = {
|
|
176
|
+
* hmr: true,
|
|
177
|
+
* scriptArgs: [],
|
|
178
|
+
* nodeArgs: ['--inspect'],
|
|
179
|
+
* clearScreen: true,
|
|
180
|
+
* env: { DEBUG: 'adonis:*' },
|
|
181
|
+
* hooks: {
|
|
182
|
+
* devServerStarted: [() => import('./dev_hooks')]
|
|
183
|
+
* }
|
|
184
|
+
* }
|
|
67
185
|
*/
|
|
68
186
|
export type DevServerOptions = {
|
|
69
187
|
/**
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* Default:true
|
|
188
|
+
* Whether the dev server should use Hot Module Replacement (HMR)
|
|
189
|
+
* @default true
|
|
73
190
|
*/
|
|
74
191
|
hmr?: boolean;
|
|
75
192
|
/**
|
|
76
|
-
* Arguments to pass to the "bin/server.js" file
|
|
77
|
-
* executed a child process
|
|
193
|
+
* Arguments to pass to the "bin/server.js" file executed as a child process
|
|
78
194
|
*/
|
|
79
195
|
scriptArgs: string[];
|
|
80
196
|
/**
|
|
81
|
-
* Arguments to pass to Node.js CLI when executing
|
|
82
|
-
* the "bin/server.js" file
|
|
197
|
+
* Arguments to pass to Node.js CLI when executing the "bin/server.js" file
|
|
83
198
|
*/
|
|
84
199
|
nodeArgs: string[];
|
|
85
200
|
/**
|
|
86
|
-
*
|
|
201
|
+
* Whether to clear screen after every file change
|
|
87
202
|
*/
|
|
88
203
|
clearScreen?: boolean;
|
|
89
204
|
/**
|
|
90
|
-
* Environment variables to share with the "bin/server.js"
|
|
91
|
-
* file.
|
|
205
|
+
* Environment variables to share with the "bin/server.js" file
|
|
92
206
|
*/
|
|
93
207
|
env?: NodeJS.ProcessEnv;
|
|
94
208
|
} & AssemblerRcFile;
|
|
95
209
|
/**
|
|
96
|
-
* Options accepted by the test runner
|
|
210
|
+
* Options accepted by the test runner for configuring test execution
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* const testOptions: TestRunnerOptions = {
|
|
214
|
+
* scriptArgs: ['--reporter', 'spec'],
|
|
215
|
+
* nodeArgs: ['--max-old-space-size=4096'],
|
|
216
|
+
* clearScreen: true,
|
|
217
|
+
* reporters: ['spec', 'json'],
|
|
218
|
+
* timeout: 30000,
|
|
219
|
+
* retries: 2,
|
|
220
|
+
* failed: false,
|
|
221
|
+
* filters: {
|
|
222
|
+
* suites: ['unit', 'integration'],
|
|
223
|
+
* tags: ['@slow']
|
|
224
|
+
* }
|
|
225
|
+
* }
|
|
97
226
|
*/
|
|
98
227
|
export type TestRunnerOptions = {
|
|
99
228
|
/**
|
|
100
|
-
* Arguments to pass to the
|
|
101
|
-
* executed a child process
|
|
229
|
+
* Arguments to pass to the test script file executed as a child process
|
|
102
230
|
*/
|
|
103
231
|
scriptArgs: string[];
|
|
104
232
|
/**
|
|
105
|
-
* Arguments to pass to Node.js CLI when executing
|
|
106
|
-
* the "bin/server.js" file
|
|
233
|
+
* Arguments to pass to Node.js CLI when executing the test script
|
|
107
234
|
*/
|
|
108
235
|
nodeArgs: string[];
|
|
109
236
|
/**
|
|
110
|
-
*
|
|
237
|
+
* Whether to clear screen after every file change
|
|
111
238
|
*/
|
|
112
239
|
clearScreen?: boolean;
|
|
113
240
|
/**
|
|
114
|
-
* Environment variables to share with the
|
|
115
|
-
* file.
|
|
241
|
+
* Environment variables to share with the test script
|
|
116
242
|
*/
|
|
117
243
|
env?: NodeJS.ProcessEnv;
|
|
118
244
|
/**
|
|
119
|
-
*
|
|
245
|
+
* Test reporters to use (e.g., 'spec', 'json', 'tap')
|
|
120
246
|
*/
|
|
121
247
|
reporters?: string[];
|
|
122
248
|
/**
|
|
123
|
-
*
|
|
249
|
+
* Global timeout for tests in milliseconds
|
|
124
250
|
*/
|
|
125
251
|
timeout?: number;
|
|
126
252
|
/**
|
|
127
|
-
*
|
|
253
|
+
* Number of times to retry failed tests
|
|
128
254
|
*/
|
|
129
255
|
retries?: number;
|
|
130
256
|
/**
|
|
131
|
-
*
|
|
257
|
+
* Whether to run only previously failed tests
|
|
132
258
|
*/
|
|
133
259
|
failed?: boolean;
|
|
134
260
|
/**
|
|
135
|
-
* Filter
|
|
136
|
-
* pair, so that we can mutate them (if needed)
|
|
261
|
+
* Filter options for controlling which tests to run
|
|
137
262
|
*/
|
|
138
263
|
filters: Partial<{
|
|
264
|
+
/** Specific test names to run */
|
|
139
265
|
tests: string[];
|
|
266
|
+
/** Test suite names to run */
|
|
140
267
|
suites: string[];
|
|
268
|
+
/** Test group names to run */
|
|
141
269
|
groups: string[];
|
|
270
|
+
/** Specific test file patterns to run */
|
|
142
271
|
files: string[];
|
|
272
|
+
/** Test tags to filter by */
|
|
143
273
|
tags: string[];
|
|
144
274
|
}>;
|
|
145
275
|
} & AssemblerRcFile;
|
|
146
276
|
/**
|
|
147
|
-
* Options accepted by the project bundler
|
|
277
|
+
* Options accepted by the project bundler for production builds
|
|
278
|
+
* Extends AssemblerRcFile to inherit hooks and meta files configuration
|
|
279
|
+
*
|
|
280
|
+
* @example
|
|
281
|
+
* const bundlerOptions: BundlerOptions = {
|
|
282
|
+
* hooks: {
|
|
283
|
+
* buildStarting: [() => import('./build_hooks')]
|
|
284
|
+
* },
|
|
285
|
+
* metaFiles: [
|
|
286
|
+
* { pattern: 'public/**', reloadServer: false }
|
|
287
|
+
* ]
|
|
288
|
+
* }
|
|
148
289
|
*/
|
|
149
290
|
export type BundlerOptions = AssemblerRcFile;
|
|
291
|
+
/**
|
|
292
|
+
* Keyboard shortcut definition for development server interactions
|
|
293
|
+
*
|
|
294
|
+
* @example
|
|
295
|
+
* const shortcut: KeyboardShortcut = {
|
|
296
|
+
* key: 'r',
|
|
297
|
+
* description: 'restart server',
|
|
298
|
+
* handler: () => server.restart()
|
|
299
|
+
* }
|
|
300
|
+
*/
|
|
301
|
+
export interface KeyboardShortcut {
|
|
302
|
+
/** The keyboard key that triggers this shortcut */
|
|
303
|
+
key: string;
|
|
304
|
+
/** Human-readable description of what this shortcut does */
|
|
305
|
+
description: string;
|
|
306
|
+
/** Function to execute when the shortcut is triggered */
|
|
307
|
+
handler: () => void;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Callbacks for keyboard shortcuts actions in the development server
|
|
311
|
+
*
|
|
312
|
+
* @example
|
|
313
|
+
* const callbacks: KeyboardShortcutsCallbacks = {
|
|
314
|
+
* onRestart: () => devServer.restart(),
|
|
315
|
+
* onClear: () => process.stdout.write('\u001B[2J\u001B[0;0f'),
|
|
316
|
+
* onQuit: () => process.exit(0)
|
|
317
|
+
* }
|
|
318
|
+
*/
|
|
319
|
+
export interface KeyboardShortcutsCallbacks {
|
|
320
|
+
/** Callback to restart the development server */
|
|
321
|
+
onRestart: () => void;
|
|
322
|
+
/** Callback to clear the console screen */
|
|
323
|
+
onClear: () => void;
|
|
324
|
+
/** Callback to quit the development server */
|
|
325
|
+
onQuit: () => void;
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Configuration options for the keyboard shortcuts manager
|
|
329
|
+
*
|
|
330
|
+
* @example
|
|
331
|
+
* const options: ShortcutsManagerOptions = {
|
|
332
|
+
* logger: cliui().logger,
|
|
333
|
+
* callbacks: {
|
|
334
|
+
* onRestart: () => devServer.restart(),
|
|
335
|
+
* onClear: () => console.clear(),
|
|
336
|
+
* onQuit: () => process.exit()
|
|
337
|
+
* }
|
|
338
|
+
* }
|
|
339
|
+
*/
|
|
340
|
+
export interface ShortcutsManagerOptions {
|
|
341
|
+
/** Logger instance for displaying messages */
|
|
342
|
+
logger: Logger;
|
|
343
|
+
/** Callback functions for different shortcut actions */
|
|
344
|
+
callbacks: KeyboardShortcutsCallbacks;
|
|
345
|
+
}
|
|
346
|
+
export type AdonisJSServerReadyMessage = {
|
|
347
|
+
isAdonisJS: true;
|
|
348
|
+
environment: 'web';
|
|
349
|
+
port: number;
|
|
350
|
+
host: string;
|
|
351
|
+
duration?: [number, number];
|
|
352
|
+
};
|
|
353
|
+
export type AdonisJSRoutesSharedMessage = {
|
|
354
|
+
isAdonisJS: true;
|
|
355
|
+
routesFileLocation: string;
|
|
356
|
+
};
|
|
357
|
+
export type HotHookMessage = {
|
|
358
|
+
type: 'hot-hook:full-reload';
|
|
359
|
+
path: string;
|
|
360
|
+
shouldBeReloadable?: boolean;
|
|
361
|
+
} | {
|
|
362
|
+
type: 'hot-hook:invalidated';
|
|
363
|
+
paths: string[];
|
|
364
|
+
} | {
|
|
365
|
+
type: 'hot-hook:file-changed';
|
|
366
|
+
path: string;
|
|
367
|
+
action: 'change' | 'add' | 'unlink';
|
|
368
|
+
};
|