1 |
|
2 | import { PromptModule } from '@ionic/cli-framework-prompts';
|
3 | import { NetworkInterface } from '@ionic/utils-network';
|
4 | import { EventEmitter } from 'events';
|
5 | import * as stream from 'stream';
|
6 | import { CommandLineInputs, CommandLineOptions, CommandMetadata, CommandMetadataOption, IConfig, ILogger, IProject, IShell, IonicEnvironmentFlags, LabServeDetails, NpmClient, Runner, ServeDetails, ServeOptions } from '../definitions';
|
7 | export declare const DEFAULT_DEV_LOGGER_PORT = 53703;
|
8 | export declare const DEFAULT_LIVERELOAD_PORT = 35729;
|
9 | export declare const DEFAULT_SERVER_PORT = 8100;
|
10 | export declare const DEFAULT_LAB_PORT = 8200;
|
11 | export declare const DEFAULT_DEVAPP_COMM_PORT = 53233;
|
12 | export declare const DEFAULT_ADDRESS = "localhost";
|
13 | export declare const BIND_ALL_ADDRESS = "0.0.0.0";
|
14 | export declare const LOCAL_ADDRESSES: string[];
|
15 | export declare const BROWSERS: string[];
|
16 | export declare const SERVE_SCRIPT = "ionic:serve";
|
17 | export declare const COMMON_SERVE_COMMAND_OPTIONS: readonly CommandMetadataOption[];
|
18 | export interface ServeRunnerDeps {
|
19 | readonly config: IConfig;
|
20 | readonly flags: IonicEnvironmentFlags;
|
21 | readonly log: ILogger;
|
22 | readonly project: IProject;
|
23 | readonly prompt: PromptModule;
|
24 | readonly shell: IShell;
|
25 | }
|
26 | export declare abstract class ServeRunner<T extends ServeOptions> implements Runner<T, ServeDetails> {
|
27 | protected devAppConnectionMade: boolean;
|
28 | protected abstract readonly e: ServeRunnerDeps;
|
29 | abstract getCommandMetadata(): Promise<Partial<CommandMetadata>>;
|
30 | abstract serveProject(options: T): Promise<ServeDetails>;
|
31 | abstract modifyOpenUrl(url: string, options: T): string;
|
32 | getPkgManagerServeCLI(): PkgManagerServeCLI;
|
33 | createOptionsFromCommandLine(inputs: CommandLineInputs, options: CommandLineOptions): ServeOptions;
|
34 | determineEngineFromCommandLine(options: CommandLineOptions): string;
|
35 | beforeServe(options: T): Promise<void>;
|
36 | run(options: T): Promise<ServeDetails>;
|
37 | afterServe(options: T, details: ServeDetails): Promise<void>;
|
38 | scheduleAfterServe(options: T, details: ServeDetails): void;
|
39 | getUsedPorts(options: T, details: ServeDetails): number[];
|
40 | runLab(options: T, serveDetails: ServeDetails): Promise<LabServeDetails>;
|
41 | selectExternalIP(options: T): Promise<[string, NetworkInterface[]]>;
|
42 | }
|
43 | export interface ServeCLIOptions {
|
44 | readonly host: string;
|
45 | readonly port: number;
|
46 | }
|
47 | export interface ServeCLI<T extends ServeCLIOptions> {
|
48 | emit(event: 'compile', chunks: number): boolean;
|
49 | emit(event: 'ready'): boolean;
|
50 | on(event: 'compile', handler: (chunks: number) => void): this;
|
51 | on(event: 'ready', handler: () => void): this;
|
52 | once(event: 'compile', handler: (chunks: number) => void): this;
|
53 | once(event: 'ready', handler: () => void): this;
|
54 | }
|
55 | export declare abstract class ServeCLI<T extends ServeCLIOptions> extends EventEmitter {
|
56 | protected readonly e: ServeRunnerDeps;
|
57 | |
58 |
|
59 |
|
60 | abstract readonly name: string;
|
61 | |
62 |
|
63 |
|
64 | abstract readonly pkg: string;
|
65 | |
66 |
|
67 |
|
68 | abstract readonly program: string;
|
69 | |
70 |
|
71 |
|
72 | abstract readonly prefix: string;
|
73 | |
74 |
|
75 |
|
76 |
|
77 | abstract readonly script?: string;
|
78 | |
79 |
|
80 |
|
81 | readonly global: boolean;
|
82 | private _resolvedProgram?;
|
83 | constructor(e: ServeRunnerDeps);
|
84 | get resolvedProgram(): string;
|
85 | /**
|
86 | * Build the arguments for starting this Serve CLI. Called by `this.start()`.
|
87 | */
|
88 | protected abstract buildArgs(options: T): Promise<string[]>;
|
89 | /**
|
90 | * Build the environment variables to be passed to the Serve CLI. Called by `this.start()`;
|
91 | */
|
92 | protected buildEnvVars(options: T): Promise<NodeJS.ProcessEnv>;
|
93 | /**
|
94 | * Called whenever a line of stdout is received.
|
95 | *
|
96 | * If `false` is returned, the line is not emitted to the log.
|
97 | *
|
98 | * By default, the CLI is considered ready whenever stdout is emitted. This
|
99 | * method should be overridden to more accurately portray readiness.
|
100 | *
|
101 | * @param line A line of stdout.
|
102 | */
|
103 | protected stdoutFilter(line: string): boolean;
|
104 | /**
|
105 | * Called whenever a line of stderr is received.
|
106 | *
|
107 | * If `false` is returned, the line is not emitted to the log.
|
108 | */
|
109 | protected stderrFilter(line: string): boolean;
|
110 | resolveScript(): Promise<string | undefined>;
|
111 | serve(options: T): Promise<void>;
|
112 | protected spawnWrapper(options: T): Promise<void>;
|
113 | protected spawn(options: T): Promise<void>;
|
114 | protected createLoggerStream(): NodeJS.WritableStream;
|
115 | protected resolveProgram(): Promise<string>;
|
116 | protected createStreamFilter(filter: (line: string) => boolean): stream.Transform;
|
117 | protected promptToInstall(): Promise<boolean>;
|
118 | }
|
119 | declare abstract class PkgManagerServeCLI extends ServeCLI<ServeOptions> {
|
120 | readonly abstract program: NpmClient;
|
121 | readonly global = true;
|
122 | readonly script = "ionic:serve";
|
123 | protected resolveProgram(): Promise<string>;
|
124 | protected buildArgs(options: ServeOptions): Promise<string[]>;
|
125 | }
|
126 | export declare class NpmServeCLI extends PkgManagerServeCLI {
|
127 | readonly name = "npm CLI";
|
128 | readonly pkg = "npm";
|
129 | readonly program = "npm";
|
130 | readonly prefix = "npm";
|
131 | }
|
132 | export declare class YarnServeCLI extends PkgManagerServeCLI {
|
133 | readonly name = "Yarn";
|
134 | readonly pkg = "yarn";
|
135 | readonly program = "yarn";
|
136 | readonly prefix = "yarn";
|
137 | }
|
138 | export {};
|