build.d.ts 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /// <reference types="node" />
  2. import { PromptModule } from '@ionic/cli-framework-prompts';
  3. import { BaseBuildOptions, BuildOptions, CommandLineInputs, CommandLineOptions, CommandMetadata, CommandMetadataOption, IConfig, ILogger, IProject, IShell, NpmClient, Runner } from '../definitions';
  4. export declare const BUILD_SCRIPT = "ionic:build";
  5. export declare const COMMON_BUILD_COMMAND_OPTIONS: readonly CommandMetadataOption[];
  6. export interface BuildRunnerDeps {
  7. readonly config: IConfig;
  8. readonly log: ILogger;
  9. readonly project: IProject;
  10. readonly prompt: PromptModule;
  11. readonly shell: IShell;
  12. }
  13. export 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. }
  25. export 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. }
  66. declare 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. }
  73. export declare class NpmBuildCLI extends PkgManagerBuildCLI {
  74. readonly name = "npm CLI";
  75. readonly pkg = "npm";
  76. readonly program = "npm";
  77. }
  78. export declare class PnpmBuildCLI extends PkgManagerBuildCLI {
  79. readonly name = "pnpm CLI";
  80. readonly pkg = "pnpm";
  81. readonly program = "pnpm";
  82. }
  83. export declare class YarnBuildCLI extends PkgManagerBuildCLI {
  84. readonly name = "Yarn";
  85. readonly pkg = "yarn";
  86. readonly program = "yarn";
  87. }
  88. export {};