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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/README.md +88 -84
  2. package/build/chunk-4452KFDQ.js +465 -0
  3. package/build/chunk-JFBQ4OEM.js +434 -0
  4. package/build/chunk-NAASGAFO.js +478 -0
  5. package/build/chunk-TIKQQRMX.js +116 -0
  6. package/build/index.d.ts +3 -0
  7. package/build/index.js +800 -447
  8. package/build/src/bundler.d.ts +44 -3
  9. package/build/src/code_scanners/routes_scanner/main.d.ts +119 -0
  10. package/build/src/code_scanners/routes_scanner/main.js +8 -0
  11. package/build/src/code_scanners/routes_scanner/validator_extractor.d.ts +26 -0
  12. package/build/src/code_transformer/main.d.ts +44 -43
  13. package/build/src/code_transformer/main.js +123 -101
  14. package/build/src/code_transformer/rc_file_transformer.d.ts +56 -4
  15. package/build/src/debug.d.ts +12 -0
  16. package/build/src/dev_server.d.ts +92 -17
  17. package/build/src/file_buffer.d.ts +87 -0
  18. package/build/src/file_system.d.ts +46 -8
  19. package/build/src/helpers.d.ts +115 -0
  20. package/build/src/helpers.js +16 -0
  21. package/build/src/index_generator/main.d.ts +68 -0
  22. package/build/src/index_generator/main.js +7 -0
  23. package/build/src/index_generator/source.d.ts +60 -0
  24. package/build/src/paths_resolver.d.ts +41 -0
  25. package/build/src/shortcuts_manager.d.ts +43 -28
  26. package/build/src/test_runner.d.ts +57 -12
  27. package/build/src/types/code_scanners.d.ts +226 -0
  28. package/build/src/types/code_transformer.d.ts +61 -19
  29. package/build/src/types/common.d.ts +270 -51
  30. package/build/src/types/hooks.d.ts +235 -22
  31. package/build/src/types/main.d.ts +15 -1
  32. package/build/src/utils.d.ts +99 -15
  33. package/build/src/virtual_file_system.d.ts +112 -0
  34. package/package.json +33 -20
  35. package/build/chunk-RR4HCA4M.js +0 -7
@@ -1,15 +1,6 @@
1
- import {
2
- debug_default
3
- } from "../../chunk-RR4HCA4M.js";
4
-
5
1
  // src/code_transformer/main.ts
2
+ import { join } from "path";
6
3
  import { fileURLToPath as fileURLToPath2 } from "url";
7
- import string from "@poppinss/utils/string";
8
- import { isScriptFile } from "@poppinss/utils";
9
- import { fsReadAll } from "@poppinss/utils/fs";
10
- import { mkdir, writeFile } from "fs/promises";
11
- import StringBuilder from "@poppinss/utils/string_builder";
12
- import { basename, dirname, extname, join, relative } from "path";
13
4
  import { installPackage, detectPackageManager } from "@antfu/install-pkg";
14
5
  import {
15
6
  Node as Node2,
@@ -26,7 +17,13 @@ import {
26
17
  } from "ts-morph";
27
18
  var ALLOWED_ENVIRONMENTS = ["web", "console", "test", "repl"];
28
19
  var RcFileTransformer = class {
20
+ /**
21
+ * The current working directory URL
22
+ */
29
23
  #cwd;
24
+ /**
25
+ * The TsMorph project instance
26
+ */
30
27
  #project;
31
28
  /**
32
29
  * Settings to use when persisting files
@@ -40,12 +37,21 @@ var RcFileTransformer = class {
40
37
  // @ts-expect-error SemicolonPreference doesn't seem to be re-exported from ts-morph
41
38
  semicolons: "remove"
42
39
  };
40
+ /**
41
+ * Create a new RcFileTransformer instance
42
+ *
43
+ * @param cwd - The current working directory URL
44
+ * @param project - The TsMorph project instance
45
+ */
43
46
  constructor(cwd, project) {
44
47
  this.#cwd = cwd;
45
48
  this.#project = project;
46
49
  }
47
50
  /**
48
51
  * Get the `adonisrc.ts` source file
52
+ *
53
+ * @returns The adonisrc.ts source file
54
+ * @throws Error if the file cannot be found
49
55
  */
50
56
  #getRcFileOrThrow() {
51
57
  const kernelUrl = fileURLToPath(new URL("./adonisrc.ts", this.#cwd));
@@ -53,6 +59,9 @@ var RcFileTransformer = class {
53
59
  }
54
60
  /**
55
61
  * Check if environments array has a subset of available environments
62
+ *
63
+ * @param environments - Optional array of environment names
64
+ * @returns True if the provided environments are a subset of available ones
56
65
  */
57
66
  #isInSpecificEnvironment(environments) {
58
67
  if (!environments) {
@@ -62,6 +71,10 @@ var RcFileTransformer = class {
62
71
  }
63
72
  /**
64
73
  * Locate the `defineConfig` call inside the `adonisrc.ts` file
74
+ *
75
+ * @param file - The source file to search in
76
+ * @returns The defineConfig call expression
77
+ * @throws Error if defineConfig call cannot be found
65
78
  */
66
79
  #locateDefineConfigCallOrThrow(file) {
67
80
  const call = file.getDescendantsOfKind(SyntaxKind.CallExpression).find((statement) => statement.getExpression().getText() === "defineConfig");
@@ -72,6 +85,10 @@ var RcFileTransformer = class {
72
85
  }
73
86
  /**
74
87
  * Return the ObjectLiteralExpression of the defineConfig call
88
+ *
89
+ * @param defineConfigCall - The defineConfig call expression
90
+ * @returns The configuration object literal expression
91
+ * @throws Error if the object literal cannot be found
75
92
  */
76
93
  #getDefineConfigObjectOrThrow(defineConfigCall) {
77
94
  const configObject = defineConfigCall.getArguments()[0].asKindOrThrow(SyntaxKind.ObjectLiteralExpression);
@@ -80,6 +97,10 @@ var RcFileTransformer = class {
80
97
  /**
81
98
  * Check if the defineConfig() call has the property assignment
82
99
  * inside it or not. If not, it will create one and return it.
100
+ *
101
+ * @param propertyName - The name of the property to find or create
102
+ * @param initializer - The initial value if the property needs to be created
103
+ * @returns The property assignment node
83
104
  */
84
105
  #getPropertyAssignmentInDefineConfigCall(propertyName, initializer) {
85
106
  const file = this.#getRcFileOrThrow();
@@ -151,6 +172,9 @@ var RcFileTransformer = class {
151
172
  }
152
173
  /**
153
174
  * Add a new command to the rcFile
175
+ *
176
+ * @param commandPath - The path to the command file
177
+ * @returns This RcFileTransformer instance for method chaining
154
178
  */
155
179
  addCommand(commandPath) {
156
180
  const commandsProperty = this.#getPropertyAssignmentInDefineConfigCall("commands", "[]");
@@ -166,6 +190,10 @@ var RcFileTransformer = class {
166
190
  }
167
191
  /**
168
192
  * Add a new preloaded file to the rcFile
193
+ *
194
+ * @param modulePath - The path to the preload file
195
+ * @param environments - Optional array of environments where this preload should run
196
+ * @returns This RcFileTransformer instance for method chaining
169
197
  */
170
198
  addPreloadFile(modulePath, environments) {
171
199
  const preloadsProperty = this.#getPropertyAssignmentInDefineConfigCall("preloads", "[]");
@@ -182,6 +210,10 @@ var RcFileTransformer = class {
182
210
  }
183
211
  /**
184
212
  * Add a new provider to the rcFile
213
+ *
214
+ * @param providerPath - The path to the provider file
215
+ * @param environments - Optional array of environments where this provider should run
216
+ * @returns This RcFileTransformer instance for method chaining
185
217
  */
186
218
  addProvider(providerPath, environments) {
187
219
  const property = this.#getPropertyAssignmentInDefineConfigCall("providers", "[]");
@@ -196,6 +228,10 @@ var RcFileTransformer = class {
196
228
  }
197
229
  /**
198
230
  * Add a new meta file to the rcFile
231
+ *
232
+ * @param globPattern - The glob pattern for the meta file
233
+ * @param reloadServer - Whether the server should reload when this file changes
234
+ * @returns This RcFileTransformer instance for method chaining
199
235
  */
200
236
  addMetaFile(globPattern, reloadServer = false) {
201
237
  const property = this.#getPropertyAssignmentInDefineConfigCall("metaFiles", "[]");
@@ -213,7 +249,11 @@ var RcFileTransformer = class {
213
249
  return this;
214
250
  }
215
251
  /**
216
- * Set directory name and path
252
+ * Set directory name and path in the directories configuration
253
+ *
254
+ * @param key - The directory key (e.g., 'controllers', 'models')
255
+ * @param value - The directory path
256
+ * @returns This RcFileTransformer instance for method chaining
217
257
  */
218
258
  setDirectory(key, value) {
219
259
  const property = this.#getPropertyAssignmentInDefineConfigCall("directories", "{}");
@@ -222,7 +262,11 @@ var RcFileTransformer = class {
222
262
  return this;
223
263
  }
224
264
  /**
225
- * Set command alias
265
+ * Set command alias in the command aliases configuration
266
+ *
267
+ * @param alias - The alias name
268
+ * @param command - The full command name
269
+ * @returns This RcFileTransformer instance for method chaining
226
270
  */
227
271
  setCommandAlias(alias, command) {
228
272
  const aliasProperty = this.#getPropertyAssignmentInDefineConfigCall("commandsAliases", "{}");
@@ -232,6 +276,11 @@ var RcFileTransformer = class {
232
276
  }
233
277
  /**
234
278
  * Add a new test suite to the rcFile
279
+ *
280
+ * @param suiteName - The name of the test suite
281
+ * @param files - File patterns for the test suite (string or array)
282
+ * @param timeout - Optional timeout in milliseconds (defaults to 2000)
283
+ * @returns This RcFileTransformer instance for method chaining
235
284
  */
236
285
  addSuite(suiteName, files, timeout) {
237
286
  const testProperty = this.#getPropertyAssignmentInDefineConfigCall(
@@ -256,6 +305,10 @@ var RcFileTransformer = class {
256
305
  }
257
306
  /**
258
307
  * Add a new assembler hook
308
+ *
309
+ * @param type - The type of hook to add
310
+ * @param path - The path to the hook file
311
+ * @returns This RcFileTransformer instance for method chaining
259
312
  */
260
313
  addAssemblerHook(type, path) {
261
314
  const hooksProperty = this.#getPropertyAssignmentInDefineConfigCall("hooks", "{}");
@@ -274,7 +327,11 @@ var RcFileTransformer = class {
274
327
  return this;
275
328
  }
276
329
  /**
277
- * Save the adonisrc.ts file
330
+ * Save the adonisrc.ts file with all applied transformations
331
+ *
332
+ * Formats the file according to editor settings and saves it to disk.
333
+ *
334
+ * @returns Promise that resolves when the file is saved
278
335
  */
279
336
  save() {
280
337
  const file = this.#getRcFileOrThrow();
@@ -286,18 +343,23 @@ var RcFileTransformer = class {
286
343
  // src/code_transformer/main.ts
287
344
  var CodeTransformer = class {
288
345
  /**
289
- * Exporting utilities to install package and detect
290
- * the package manager
346
+ * Utility function for installing packages
291
347
  */
292
348
  installPackage = installPackage;
349
+ /**
350
+ * Utility function for detecting the package manager
351
+ */
293
352
  detectPackageManager = detectPackageManager;
294
353
  /**
295
354
  * Directory of the adonisjs project
296
355
  */
297
356
  #cwd;
357
+ /**
358
+ * String path version of the current working directory
359
+ */
298
360
  #cwdPath;
299
361
  /**
300
- * The TsMorph project
362
+ * The TsMorph project instance for AST manipulation
301
363
  */
302
364
  project;
303
365
  /**
@@ -312,6 +374,11 @@ var CodeTransformer = class {
312
374
  // @ts-expect-error SemicolonPreference doesn't seem to be re-exported from ts-morph
313
375
  semicolons: "remove"
314
376
  };
377
+ /**
378
+ * Create a new CodeTransformer instance
379
+ *
380
+ * @param cwd - The current working directory URL
381
+ */
315
382
  constructor(cwd) {
316
383
  this.#cwd = cwd;
317
384
  this.#cwdPath = fileURLToPath2(this.#cwd);
@@ -321,8 +388,14 @@ var CodeTransformer = class {
321
388
  });
322
389
  }
323
390
  /**
324
- * Add a new middleware to the middleware array of the
325
- * given file
391
+ * Add a new middleware to the middleware array of the given file
392
+ *
393
+ * This method locates middleware stack calls (like server.use or router.use)
394
+ * and adds the middleware entry to the appropriate position in the array.
395
+ *
396
+ * @param file - The source file to modify
397
+ * @param target - The target method call (e.g., 'server.use', 'router.use')
398
+ * @param middlewareEntry - The middleware entry to add
326
399
  */
327
400
  #addToMiddlewareArray(file, target, middlewareEntry) {
328
401
  const callExpressions = file.getDescendantsOfKind(SyntaxKind2.CallExpression).filter((statement) => statement.getExpression().getText() === target);
@@ -345,6 +418,12 @@ var CodeTransformer = class {
345
418
  }
346
419
  /**
347
420
  * Add a new middleware to the named middleware of the given file
421
+ *
422
+ * This method adds middleware entries to the named middleware object,
423
+ * typically used for route-specific middleware registration.
424
+ *
425
+ * @param file - The source file to modify
426
+ * @param middlewareEntry - The middleware entry to add (must have a name)
348
427
  */
349
428
  #addToNamedMiddleware(file, middlewareEntry) {
350
429
  if (!middlewareEntry.name) {
@@ -365,7 +444,13 @@ var CodeTransformer = class {
365
444
  }
366
445
  }
367
446
  /**
368
- * Add a policy to the list of pre-registered policy
447
+ * Add a policy to the list of pre-registered policies
448
+ *
449
+ * This method adds bouncer policy entries to the policies object,
450
+ * allowing them to be used in route authorization.
451
+ *
452
+ * @param file - The source file to modify
453
+ * @param policyEntry - The policy entry to add
369
454
  */
370
455
  #addToPoliciesList(file, policyEntry) {
371
456
  const policiesObject = file.getVariableDeclarationOrThrow("policies").getInitializerIfKindOrThrow(SyntaxKind2.ObjectLiteralExpression);
@@ -410,8 +495,9 @@ var CodeTransformer = class {
410
495
  return writer.blankLine().writeLine("/*").writeLine(`|----------------------------------------------------------`).writeLine(`| ${comment}`).writeLine(`|----------------------------------------------------------`).writeLine(`*/`);
411
496
  }
412
497
  /**
413
- * Add new env variable validation in the
414
- * `env.ts` file
498
+ * Add new env variable validation in the `env.ts` file
499
+ *
500
+ * @param definition - Environment validation definition containing variables and comment
415
501
  */
416
502
  async defineEnvValidations(definition) {
417
503
  const kernelUrl = join(this.#cwdPath, "./start/env.ts");
@@ -448,12 +534,14 @@ var CodeTransformer = class {
448
534
  await file.save();
449
535
  }
450
536
  /**
451
- * Define new middlewares inside the `start/kernel.ts`
452
- * file
537
+ * Define new middlewares inside the `start/kernel.ts` file
453
538
  *
454
539
  * This function is highly based on some assumptions
455
540
  * and will not work if you significantly tweaked
456
541
  * your `start/kernel.ts` file.
542
+ *
543
+ * @param stack - The middleware stack to add to ('server', 'router', or 'named')
544
+ * @param middleware - Array of middleware entries to add
457
545
  */
458
546
  async addMiddlewareToStack(stack, middleware) {
459
547
  const kernelUrl = join(this.#cwdPath, "./start/kernel.ts");
@@ -469,7 +557,9 @@ var CodeTransformer = class {
469
557
  await file.save();
470
558
  }
471
559
  /**
472
- * Update the `adonisrc.ts` file
560
+ * Update the `adonisrc.ts` file using the provided callback
561
+ *
562
+ * @param callback - Function that receives the RcFileTransformer for modifications
473
563
  */
474
564
  async updateRcFile(callback) {
475
565
  const rcFileTransformer = new RcFileTransformer(this.#cwd, this.project);
@@ -478,6 +568,9 @@ var CodeTransformer = class {
478
568
  }
479
569
  /**
480
570
  * Add a new Japa plugin in the `tests/bootstrap.ts` file
571
+ *
572
+ * @param pluginCall - The plugin function call to add
573
+ * @param importDeclarations - Import declarations needed for the plugin
481
574
  */
482
575
  async addJapaPlugin(pluginCall, importDeclarations) {
483
576
  const testBootstrapUrl = join(this.#cwdPath, "./tests/bootstrap.ts");
@@ -493,7 +586,10 @@ var CodeTransformer = class {
493
586
  await file.save();
494
587
  }
495
588
  /**
496
- * Add a new Vite plugin
589
+ * Add a new Vite plugin to the `vite.config.ts` file
590
+ *
591
+ * @param pluginCall - The plugin function call to add
592
+ * @param importDeclarations - Import declarations needed for the plugin
497
593
  */
498
594
  async addVitePlugin(pluginCall, importDeclarations) {
499
595
  const viteConfigTsUrl = join(this.#cwdPath, "./vite.config.ts");
@@ -520,6 +616,8 @@ var CodeTransformer = class {
520
616
  /**
521
617
  * Adds a policy to the list of `policies` object configured
522
618
  * inside the `app/policies/main.ts` file.
619
+ *
620
+ * @param policies - Array of bouncer policy entries to add
523
621
  */
524
622
  async addPolicies(policies) {
525
623
  const kernelUrl = join(this.#cwdPath, "./app/policies/main.ts");
@@ -530,82 +628,6 @@ var CodeTransformer = class {
530
628
  file.formatText(this.#editorSettings);
531
629
  await file.save();
532
630
  }
533
- /**
534
- * Creates an index file that exports an object in which the key is the PascalCase
535
- * name of the entity and the value is a dynamic import.
536
- *
537
- * For example, in case of controllers, the index file will be the list of controller
538
- * names pointing a dynamically imported controller file.
539
- *
540
- * ```ts
541
- * export const controllers = {
542
- * LoginController: () => import('#controllers/login_controller'),
543
- * LogoutController: () => import('#controllers/logout_controller'),
544
- * }
545
- * ```
546
- *
547
- * @param source
548
- * @param outputPath
549
- * @param importAlias
550
- */
551
- async makeEntityIndex(input, output) {
552
- const inputs = Array.isArray(input) ? input : [input];
553
- const outputPath = join(this.#cwdPath, output.destination);
554
- const outputDir = dirname(outputPath);
555
- const exportName = output.exportName ?? new StringBuilder(basename(output.destination)).removeExtension().camelCase();
556
- debug_default(
557
- 'creating index for "%s" at destination "%s" using sources %O',
558
- exportName,
559
- outputPath,
560
- inputs
561
- );
562
- const entries = await Promise.all(
563
- inputs.map(async ({ source, importAlias, allowedExtensions }) => {
564
- const sourcePath = join(this.#cwdPath, source);
565
- const filesList = await fsReadAll(sourcePath, {
566
- filter: (filePath) => {
567
- if (allowedExtensions) {
568
- const ext = extname(filePath);
569
- return allowedExtensions.includes(ext);
570
- }
571
- return isScriptFile(filePath);
572
- },
573
- pathType: "absolute"
574
- });
575
- const knownBaseNames = /* @__PURE__ */ new Set();
576
- return filesList.map((filePath) => {
577
- let baseName = basename(filePath);
578
- if (output.computeBaseName) {
579
- baseName = output.computeBaseName?.(filePath, sourcePath);
580
- } else {
581
- if (knownBaseNames.has(baseName)) {
582
- baseName = string.toUnixSlash(relative(sourcePath, filePath));
583
- }
584
- knownBaseNames.add(baseName);
585
- }
586
- const name = new StringBuilder(baseName).removeExtension().removeSuffix(output.removeNameSuffix ?? "").pascalCase().toString();
587
- const baseImportPath = importAlias ? string.toUnixSlash(relative(sourcePath, filePath)) : string.toUnixSlash(relative(outputDir, filePath));
588
- const importPath = importAlias ? `${importAlias}/${new StringBuilder(baseImportPath).removeExtension().toString()}` : baseImportPath;
589
- return {
590
- name,
591
- importPath
592
- };
593
- });
594
- })
595
- );
596
- const computeOutput = output.computeOutput ?? ((list) => {
597
- return list.reduce(
598
- (result, entry) => {
599
- debug_default('adding "%O" to the index', entry);
600
- result.push(` ${entry.name}: () => import('${entry.importPath}'),`);
601
- return result;
602
- },
603
- [`export const ${exportName} = {`]
604
- ).concat("}").join("\n");
605
- });
606
- await mkdir(outputDir, { recursive: true });
607
- await writeFile(outputPath, computeOutput(entries.flat(2)));
608
- }
609
631
  };
610
632
  export {
611
633
  CodeTransformer
@@ -3,45 +3,97 @@ 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
+ *
86
+ * @param type - The type of hook to add
87
+ * @param path - The path to the hook file
88
+ * @returns This RcFileTransformer instance for method chaining
41
89
  */
42
90
  addAssemblerHook(type: keyof Exclude<AssemblerRcFile['hooks'], undefined>, path: string): this;
43
91
  /**
44
- * Save the adonisrc.ts file
92
+ * Save the adonisrc.ts file with all applied transformations
93
+ *
94
+ * Formats the file according to editor settings and saves it to disk.
95
+ *
96
+ * @returns Promise that resolves when the file is saved
45
97
  */
46
98
  save(): Promise<void>;
47
99
  }
@@ -1,2 +1,14 @@
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
+ */
1
13
  declare const _default: import("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
  }