UNPKG

3.35 kBTypeScriptView Raw
1/// <reference types="node" />
2import { PromptModule } from '@ionic/cli-framework-prompts';
3import { BaseBuildOptions, BuildOptions, CommandLineInputs, CommandLineOptions, CommandMetadata, CommandMetadataOption, IConfig, ILogger, IProject, IShell, NpmClient, Runner } from '../definitions';
4export declare const BUILD_SCRIPT = "ionic:build";
5export declare const COMMON_BUILD_COMMAND_OPTIONS: readonly CommandMetadataOption[];
6export interface BuildRunnerDeps {
7 readonly config: IConfig;
8 readonly log: ILogger;
9 readonly project: IProject;
10 readonly prompt: PromptModule;
11 readonly shell: IShell;
12}
13export declare abstract class BuildRunner<T extends BuildOptions<any>> implements Runner<T, void> {
14 protected abstract readonly e: BuildRunnerDeps;
15 abstract getCommandMetadata(): Promise<Partial<CommandMetadata>>;
16 abstract createOptionsFromCommandLine(inputs: CommandLineInputs, options: CommandLineOptions): T;
17 abstract buildProject(options: T): Promise<void>;
18 getPkgManagerBuildCLI(): PkgManagerBuildCLI;
19 createBaseOptionsFromCommandLine(inputs: CommandLineInputs, options: CommandLineOptions): BaseBuildOptions;
20 determineEngineFromCommandLine(options: CommandLineOptions): string;
21 beforeBuild(options: T): Promise<void>;
22 run(options: T): Promise<void>;
23 afterBuild(options: T): Promise<void>;
24}
25export declare abstract class BuildCLI<T extends object> {
26 protected readonly e: BuildRunnerDeps;
27 /**
28 * The pretty name of this Build CLI.
29 */
30 abstract readonly name: string;
31 /**
32 * The npm package of this Build CLI.
33 */
34 abstract readonly pkg: string;
35 /**
36 * The bin program to use for this Build CLI.
37 */
38 abstract readonly program: string;
39 /**
40 * If specified, `package.json` is inspected for this script to use instead
41 * of `program`.
42 */
43 abstract readonly script?: string;
44 /**
45 * If true, the Build CLI will not prompt to be installed.
46 */
47 readonly global: boolean;
48 private _resolvedProgram?;
49 constructor(e: BuildRunnerDeps);
50 get resolvedProgram(): string;
51 /**
52 * Build the arguments for starting this Build CLI. Called by `this.run()`.
53 */
54 protected abstract buildArgs(options: T): Promise<string[]>;
55 /**
56 * Build the environment variables for this Build CLI. Called by `this.run()`.
57 */
58 protected buildEnvVars(options: T): Promise<NodeJS.ProcessEnv>;
59 resolveScript(): Promise<string | undefined>;
60 build(options: T): Promise<void>;
61 protected runWrapper(options: T): Promise<void>;
62 protected run(options: T): Promise<void>;
63 protected resolveProgram(): Promise<string>;
64 protected promptToInstall(): Promise<boolean>;
65}
66declare abstract class PkgManagerBuildCLI extends BuildCLI<BaseBuildOptions> {
67 readonly abstract program: NpmClient;
68 readonly global = true;
69 readonly script = "ionic:build";
70 protected resolveProgram(): Promise<string>;
71 protected buildArgs(options: BaseBuildOptions): Promise<string[]>;
72}
73export declare class NpmBuildCLI extends PkgManagerBuildCLI {
74 readonly name = "npm CLI";
75 readonly pkg = "npm";
76 readonly program = "npm";
77}
78export declare class YarnBuildCLI extends PkgManagerBuildCLI {
79 readonly name = "Yarn";
80 readonly pkg = "yarn";
81 readonly program = "yarn";
82}
83export {};