1 |
|
2 | import { PromptModule } from '@ionic/cli-framework';
|
3 | import { NetworkInterface } from '@ionic/utils-network';
|
4 | import { EventEmitter } from 'events';
|
5 | import * as stream from 'stream';
|
6 | import { CommandLineInputs, CommandLineOptions, CommandMetadata, CommandMetadataOption, DevAppDetails, 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 | displayDevAppMessage(options: T): Promise<void>;
|
36 | beforeServe(options: T): Promise<void>;
|
37 | run(options: T): Promise<ServeDetails>;
|
38 | afterServe(options: T, details: ServeDetails): Promise<void>;
|
39 | scheduleAfterServe(options: T, details: ServeDetails): void;
|
40 | getUsedPorts(options: T, details: ServeDetails): number[];
|
41 | gatherDevAppDetails(options: T, details: ServeDetails): Promise<DevAppDetails | undefined>;
|
42 | publishDevApp(options: T, details: DevAppDetails): Promise<string | undefined>;
|
43 | getSupportedDevAppPlugins(): Promise<Set<string>>;
|
44 | runLab(options: T, serveDetails: ServeDetails): Promise<LabServeDetails>;
|
45 | selectExternalIP(options: T): Promise<[string, NetworkInterface[]]>;
|
46 | }
|
47 | export interface ServeCLIOptions {
|
48 | readonly address: string;
|
49 | readonly port: number;
|
50 | }
|
51 | export interface ServeCLI<T extends ServeCLIOptions> {
|
52 | emit(event: 'compile', chunks: number): boolean;
|
53 | emit(event: 'ready'): boolean;
|
54 | on(event: 'compile', handler: (chunks: number) => void): this;
|
55 | on(event: 'ready', handler: () => void): this;
|
56 | once(event: 'compile', handler: (chunks: number) => void): this;
|
57 | once(event: 'ready', handler: () => void): this;
|
58 | }
|
59 | export declare abstract class ServeCLI<T extends ServeCLIOptions> extends EventEmitter {
|
60 | protected readonly e: ServeRunnerDeps;
|
61 | |
62 |
|
63 |
|
64 | abstract readonly name: string;
|
65 | |
66 |
|
67 |
|
68 | abstract readonly pkg: string;
|
69 | |
70 |
|
71 |
|
72 | abstract readonly program: string;
|
73 | |
74 |
|
75 |
|
76 | abstract readonly prefix: string;
|
77 | |
78 |
|
79 |
|
80 |
|
81 | abstract readonly script?: string;
|
82 | |
83 |
|
84 |
|
85 | readonly global: boolean;
|
86 | private _resolvedProgram?;
|
87 | constructor(e: ServeRunnerDeps);
|
88 | readonly resolvedProgram: string;
|
89 | /**
|
90 | * Build the arguments for starting this Serve CLI. Called by `this.start()`.
|
91 | */
|
92 | protected abstract buildArgs(options: T): Promise<string[]>;
|
93 | /**
|
94 | * Build the environment variables to be passed to the Serve CLI. Called by `this.start()`;
|
95 | */
|
96 | protected buildEnvVars(options: T): Promise<NodeJS.ProcessEnv>;
|
97 | /**
|
98 | * Called whenever a line of stdout is received.
|
99 | *
|
100 | * If `false` is returned, the line is not emitted to the log.
|
101 | *
|
102 | * By default, the CLI is considered ready whenever stdout is emitted. This
|
103 | * method should be overridden to more accurately portray readiness.
|
104 | *
|
105 | * @param line A line of stdout.
|
106 | */
|
107 | protected stdoutFilter(line: string): boolean;
|
108 | /**
|
109 | * Called whenever a line of stderr is received.
|
110 | *
|
111 | * If `false` is returned, the line is not emitted to the log.
|
112 | */
|
113 | protected stderrFilter(line: string): boolean;
|
114 | resolveScript(): Promise<string | undefined>;
|
115 | serve(options: T): Promise<void>;
|
116 | protected spawnWrapper(options: T): Promise<void>;
|
117 | protected spawn(options: T): Promise<void>;
|
118 | protected createLoggerStream(): NodeJS.WritableStream;
|
119 | protected resolveProgram(): Promise<string>;
|
120 | protected createStreamFilter(filter: (line: string) => boolean): stream.Transform;
|
121 | protected promptToInstall(): Promise<boolean>;
|
122 | }
|
123 | declare abstract class PkgManagerServeCLI extends ServeCLI<ServeOptions> {
|
124 | readonly abstract program: NpmClient;
|
125 | readonly global = true;
|
126 | readonly script = "ionic:serve";
|
127 | protected resolveProgram(): Promise<string>;
|
128 | protected buildArgs(options: ServeOptions): Promise<string[]>;
|
129 | }
|
130 | export declare class NpmServeCLI extends PkgManagerServeCLI {
|
131 | readonly name = "npm CLI";
|
132 | readonly pkg = "npm";
|
133 | readonly program = "npm";
|
134 | readonly prefix = "npm";
|
135 | }
|
136 | export declare class YarnServeCLI extends PkgManagerServeCLI {
|
137 | readonly name = "Yarn";
|
138 | readonly pkg = "yarn";
|
139 | readonly program = "yarn";
|
140 | readonly prefix = "yarn";
|
141 | }
|
142 | export {};
|