How to use the @ionic/utils-network.findClosestOpenPort function in @ionic/utils-network

To help you get started, we’ve selected a few @ionic/utils-network examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ionic-team / ionic-cli / packages / ionic / src / lib / project / angular / serve.ts View on Github external
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),
    };
  }
github ionic-team / ionic-cli / packages / ionic / src / lib / project / common.ts View on Github external
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;
    }
github ionic-team / ionic-cli / packages / ionic / src / lib / project / custom / serve.ts View on Github external
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),
    };
  }
}
github ionic-team / ionic-cli / packages / ionic / src / lib / project / react / serve.ts View on Github external
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),
    };
  }
}
github ionic-team / ionic-cli / packages / ionic / src / lib / project / vue / serve.ts View on Github external
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),
    };
  }
}
github ionic-team / ionic-cli / packages / ionic / src / lib / project / common.ts View on Github external
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))}.`);
github ionic-team / ionic-cli / packages / ionic / src / lib / project / common.ts View on Github external
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;

@ionic/utils-network

Network utils for Node

MIT
Latest version published 11 months ago

Package Health Score

72 / 100
Full package analysis

Popular @ionic/utils-network functions

Similar packages