AdonisJS API
    Preparing search index...

    StubsManager handles reading, copying, and building stubs from various sources. Stubs are template files used for code generation in AdonisJS applications.

    The manager can source stubs from:

    • Application's local stubs directory (publishTarget)
    • Custom file system paths
    • Package exports with stubsRoot
    const stubsManager = new StubsManager(app, '/path/to/stubs')
    const stub = await stubsManager.build('controller.stub')
    const files = await stubsManager.copy('models', { pkg: '@adonisjs/lucid' })
    Index
    • Creates a Stub instance by locating and loading a stub file. Searches in publishTarget first, then optional source or package locations.

      Parameters

      • stubName: string

        Name of the stub file to build (e.g., 'controller.stub')

      • Optionaloptions: { source?: string; pkg?: string }

        Optional configuration for stub source

        • Optionalsource?: string

          Custom file system path to search for stubs

        • Optionalpkg?: string

          Package name to source stubs from

      Returns Promise<Stub>

      Promise that resolves to a Stub instance

      When stub file cannot be found in any source

    • Copies stub files from a source location to the publish target directory. Can copy individual files or entire directories recursively.

      Parameters

      • stubPath: string

        Relative path to the stub file or directory to copy

      • options: { overwrite?: boolean } & ({ source: string } | { pkg: string })

        Copy configuration options

        • Optionaloverwrite?: boolean

          Whether to overwrite existing files

        • { source: string }
          • source: string

            Source file system path (mutually exclusive with pkg)

        • { pkg: string }
          • pkg: string

            Package name to copy from (mutually exclusive with source)

      Returns Promise<string[]>

      Promise that resolves to an array of copied file paths

      When source path cannot be found