import Builder, { BuilderOptions } from './builders/base'; export interface ProjectOptions { dir?: string; docs?: true; environment?: string; printSlowTrees?: true; } export interface WatchOptions { builder?: Builder; destDir?: string; afterBuild?(project: Project): void; beforeRebuild?(): Promise | void; } /** * The Project class represents a complete, self contained, root directory for * a Denali project (an app or an addon). The Project class exposes three * primary APIs: * * 1. **`build()`** performs a one-off build of the project, returning a promise * that resolves when the build is complete. * 2. **`watch()`** builds the project, then watches the source directories for * changes, rebuilding when detected * 3. **`createApplicationInstance()`** builds the project, then sets up an * instance of the application in-memory, but without starting any of the * network protocols. This is useful for commands like `console` or `routes`, * which need to access to the Denali runtime environment, but without the * overhead of starting the actual server. * * The Project class doesn't directly build the app/addon. Instead, it delegates to * the appropriate Builder class (AppBuilder/AddonBuilder), which in turn creates * AddonBuilders for any child addons in the dependency graph, and so on. * * @module denali-cli */ export default class Project { /** * The root dir of the project's package */ dir: string; /** * The build target environment, defaults to 'development' */ environment: string; /** * The package.json for this project's package */ pkg: any; /** * Should the project print out the slowest parts of the build upon completion? */ printSlowTrees: boolean; builderOptions: BuilderOptions; /** * Creates an instance of Project */ constructor(options?: ProjectOptions); readonly isAddon: any; _build(tree: any, destDir: string): Promise; build(destDir?: string): Promise; buildDummy(destDir?: string): Promise; /** * Build the project and start watching the source files for changes, rebuilding when they occur */ _watch(tree: any, options?: WatchOptions): Promise; watch(options?: WatchOptions): Promise; watchDummy(options?: WatchOptions): Promise; /** * Build the project and create an application instance for this app. Useful if you want to * perform actions based on the runtime state of the application, i.e. print a list of routes. * * Note: we don't type the return here as Promise in the code because that would * introduce a hornet's nest of circular dependency (i.e. denali-cli -> denali -> denali-cli ...). * But the documentation is correct here - the resolved value of the promise is an Applciation * instance. And consuming apps/addons already have a dependency on denali, so they can cast the * return value here to an Application. */ createApplication(): Promise; /** * After a build completes, this method cleans up the result. It copies the results out of tmp and * into the output directory, and kicks off any optional behaviors post-build. */ finishBuild(results: { directory: string; graph: any; }, destDir: string): void; }