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