Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async serveProject(options: AngularServeOptions): Promise {
const [ externalIP, availableInterfaces ] = await this.selectExternalIP(options);
const port = options.port = await findClosestOpenPort(options.port);
const ng = new AngularServeCLI(this.e);
await ng.serve(options);
return {
custom: ng.resolvedProgram !== ng.program,
protocol: options.ssl ? 'https' : 'http',
localAddress: 'localhost',
externalAddress: externalIP,
externalNetworkInterfaces: availableInterfaces,
port,
externallyAccessible: ![BIND_ALL_ADDRESS, ...LOCAL_ADDRESSES].includes(externalIP),
};
}
export async function findOpenIonicPorts(address: string, ports: Ports): Promise {
try {
const [ port, livereloadPort, notificationPort ] = await Promise.all([
findClosestOpenPort(ports.port),
findClosestOpenPort(ports.livereloadPort),
findClosestOpenPort(ports.notificationPort),
]);
if (ports.port !== port) {
debug(`Port ${strong(String(ports.port))} taken, using ${strong(String(port))}.`);
ports.port = port;
}
if (ports.livereloadPort !== livereloadPort) {
debug(`Port ${strong(String(ports.livereloadPort))} taken, using ${strong(String(livereloadPort))}.`);
ports.livereloadPort = livereloadPort;
}
if (ports.notificationPort !== notificationPort) {
debug(`Port ${strong(String(ports.notificationPort))} taken, using ${strong(String(notificationPort))}.`);
ports.notificationPort = notificationPort;
}
async serveProject(options: CustomServeOptions): Promise {
const cli = this.getPkgManagerServeCLI();
if (!await cli.resolveScript()) {
throw new RunnerException(
`Cannot perform serve.\n` +
`Since you're using the ${strong('custom')} project type, you must provide the ${input(cli.script)} npm script so the Ionic CLI can serve your project.`
);
}
const [ externalIP, availableInterfaces ] = await this.selectExternalIP(options);
const port = options.port = await findClosestOpenPort(options.port);
await cli.serve(options);
return {
custom: true,
protocol: 'http',
localAddress: 'localhost',
externalAddress: externalIP,
externalNetworkInterfaces: availableInterfaces,
port,
externallyAccessible: ![BIND_ALL_ADDRESS, ...LOCAL_ADDRESSES].includes(externalIP),
};
}
}
async serveProject(options: ReactServeOptions): Promise {
const [externalIP, availableInterfaces] = await this.selectExternalIP(options);
const port = options.port = await findClosestOpenPort(options.port);
const reactScripts = new ReactServeCLI(this.e);
await reactScripts.serve(options);
return {
custom: reactScripts.resolvedProgram !== reactScripts.program,
protocol: options.https ? 'https' : 'http',
localAddress: 'localhost',
externalAddress: externalIP,
externalNetworkInterfaces: availableInterfaces,
port,
externallyAccessible: ![BIND_ALL_ADDRESS, ...LOCAL_ADDRESSES].includes(externalIP),
};
}
}
async serveProject(options: VueServeOptions): Promise {
const cli = this.getPkgManagerServeCLI();
if (!await cli.resolveScript()) {
throw new RunnerException(
`Cannot perform serve.\n` +
`Since you're using the ${chalk.bold('Vue')} project type, you must provide the ${chalk.green(cli.script)} npm script so the Ionic CLI can serve your project.`
);
}
const [ externalIP, availableInterfaces ] = await this.selectExternalIP(options);
const port = options.port = await findClosestOpenPort(options.port);
await cli.serve(options);
return {
custom: false,
protocol: 'http',
localAddress: 'localhost',
externalAddress: externalIP,
externalNetworkInterfaces: availableInterfaces,
port,
externallyAccessible: ![BIND_ALL_ADDRESS, ...LOCAL_ADDRESSES].includes(externalIP),
};
}
}
export async function findOpenIonicPorts(address: string, ports: Ports): Promise {
try {
const [ port, livereloadPort, notificationPort ] = await Promise.all([
findClosestOpenPort(ports.port),
findClosestOpenPort(ports.livereloadPort),
findClosestOpenPort(ports.notificationPort),
]);
if (ports.port !== port) {
debug(`Port ${strong(String(ports.port))} taken, using ${strong(String(port))}.`);
ports.port = port;
}
if (ports.livereloadPort !== livereloadPort) {
debug(`Port ${strong(String(ports.livereloadPort))} taken, using ${strong(String(livereloadPort))}.`);
ports.livereloadPort = livereloadPort;
}
if (ports.notificationPort !== notificationPort) {
debug(`Port ${strong(String(ports.notificationPort))} taken, using ${strong(String(notificationPort))}.`);
export async function findOpenIonicPorts(address: string, ports: Ports): Promise {
try {
const [ port, livereloadPort, notificationPort ] = await Promise.all([
findClosestOpenPort(ports.port),
findClosestOpenPort(ports.livereloadPort),
findClosestOpenPort(ports.notificationPort),
]);
if (ports.port !== port) {
debug(`Port ${strong(String(ports.port))} taken, using ${strong(String(port))}.`);
ports.port = port;
}
if (ports.livereloadPort !== livereloadPort) {
debug(`Port ${strong(String(ports.livereloadPort))} taken, using ${strong(String(livereloadPort))}.`);
ports.livereloadPort = livereloadPort;
}
if (ports.notificationPort !== notificationPort) {
debug(`Port ${strong(String(ports.notificationPort))} taken, using ${strong(String(notificationPort))}.`);
ports.notificationPort = notificationPort;