Documentation
    Preparing search index...

    IndexGenerator manages the generation of index files for AdonisJS applications.

    This class provides a way to configure multiple sources and generate index files that export collections of modules, typically used for barrel exports or auto-discovery patterns in AdonisJS applications.

    const generator = new IndexGenerator(appRoot)
    generator.add('controllers', {
    source: 'app/controllers',
    output: 'app/controllers/index.ts',
    as: 'barrelFile',
    exportName: 'controllers'
    })
    await generator.generate()
    Index

    Constructors

    Methods

    • Set the logger instance used for CLI output

      Updates the CLI logger instance for this index generator and all registered sources to use the new logger for output.

      Parameters

      • cliLogger: Logger

        New logger instance to use

      Returns void

    • Add a file to all registered index generator sources

      This method propagates the file addition to all registered sources, allowing them to regenerate their index files if the new file matches their glob patterns.

      Parameters

      • filePath: string

        Absolute path of the file to add

      Returns Promise<void>

    • Remove a file from all registered index generator sources

      This method propagates the file removal to all registered sources, allowing them to regenerate their index files if the removed file was previously tracked.

      Parameters

      • filePath: string

        Absolute path of the file to remove

      Returns Promise<void>

    • Generate all registered index files

      Iterates through all registered sources and generates their corresponding index files.

      Returns Promise<void>