Skip to content

Commit d7db33c

Browse files
committed
Add https option in cli run
1 parent bb13864 commit d7db33c

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

cli/src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,13 +240,14 @@ export function runProgram(config: Config): void {
240240
.option('--host <host>', 'Host used for live reload')
241241
.option('--port <port>', 'Port used for live reload')
242242
.option('--configuration <name>', 'Configuration name of the iOS Scheme')
243+
.option('--https', 'Enable HTTPS for live reload server')
243244
.action(
244245
wrapAction(
245246
telemetryAction(
246247
config,
247248
async (
248249
platform,
249-
{ scheme, flavor, list, json, target, sync, forwardPorts, liveReload, host, port, configuration },
250+
{ scheme, flavor, list, json, target, sync, forwardPorts, liveReload, host, port, configuration, https },
250251
) => {
251252
const { runCommand } = await import('./tasks/run');
252253
await runCommand(config, platform, {
@@ -261,6 +262,7 @@ export function runProgram(config: Config): void {
261262
host,
262263
port,
263264
configuration,
265+
https,
264266
});
265267
},
266268
),

cli/src/tasks/run.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export interface RunCommandOptions {
3232
host?: string;
3333
port?: string;
3434
configuration?: string;
35+
https?: boolean;
3536
}
3637

3738
export async function runCommand(
@@ -90,7 +91,7 @@ export async function runCommand(
9091
}
9192
const cordovaPlugins = await getCordovaPlugins(config, platformName);
9293
if (options.liveReload) {
93-
await CapLiveReloadHelper.editCapConfigForLiveReload(config, platformName, options);
94+
await CapLiveReloadHelper.editCapConfigForLiveReload(config, platformName, options, false, options.https);
9495
if (platformName === config.android.name) {
9596
await await writeCordovaAndroidManifest(cordovaPlugins, config, platformName, true);
9697
}
@@ -106,7 +107,7 @@ export async function runCommand(
106107
})
107108
.then(() => process.exit());
108109
logger.info(
109-
`App running with live reload listing for: http://${options.host}:${options.port}. Press Ctrl+C to quit.`,
110+
`App running with live reload listing for: ${options.https ? 'https' : 'http'}://${options.host}:${options.port}. Press Ctrl+C to quit.`,
110111
);
111112
await sleepForever();
112113
}

cli/src/util/livereload.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ class CapLiveReload {
146146
platformName: string,
147147
options: RunCommandOptions,
148148
rootConfigChange = false,
149+
useHttps = false,
149150
): Promise<void> {
150151
const platformAbsPath =
151152
platformName == config.ios.name
@@ -161,7 +162,7 @@ class CapLiveReload {
161162
const configJson = readJSONSync(capConfigPath);
162163
this.configJsonToRevertTo.json = JSON.stringify(configJson, null, 2);
163164
this.configJsonToRevertTo.platformPath = capConfigPath;
164-
const url = `http://${options.host}:${options.port}`;
165+
const url = `${useHttps ? 'https' : 'http'}://${options.host}:${options.port}`;
165166
configJson.server = {
166167
url,
167168
};

0 commit comments

Comments
 (0)