HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux ip-172-31-42-149 5.15.0-1084-aws #91~20.04.1-Ubuntu SMP Fri May 2 07:00:04 UTC 2025 aarch64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //proc/self/root/usr/local/lib/node_modules/@ionic/cli/commands/serve.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ServeCommand = void 0;
const tslib_1 = require("tslib");
const utils_process_1 = require("@ionic/utils-process");
const lodash = tslib_1.__importStar(require("lodash"));
const color_1 = require("../lib/color");
const command_1 = require("../lib/command");
const errors_1 = require("../lib/errors");
const serve_1 = require("../lib/serve");
class ServeCommand extends command_1.Command {
    async getMetadata() {
        const groups = [];
        let options = [
            ...serve_1.COMMON_SERVE_COMMAND_OPTIONS,
            {
                name: 'open',
                summary: 'Do not open a browser window',
                type: Boolean,
                default: true,
                // TODO: Adding 'b' to aliases here has some weird behavior with minimist.
            },
            {
                name: 'browser',
                summary: `Specifies the browser to use (${serve_1.BROWSERS.map(b => (0, color_1.input)(b)).join(', ')})`,
                aliases: ['w'],
                groups: ["advanced" /* MetadataGroup.ADVANCED */],
            },
            {
                name: 'browseroption',
                summary: `Specifies a path to open to (${(0, color_1.input)('/#/tab/dash')})`,
                aliases: ['o'],
                groups: ["advanced" /* MetadataGroup.ADVANCED */],
                spec: { value: 'path' },
            },
        ];
        const exampleCommands = ['', '--external'];
        const footnotes = [];
        let description = `
Easily spin up a development server which launches in your browser. It watches for changes in your source files and automatically reloads with the updated build.

By default, ${(0, color_1.input)('ionic serve')} boots up a development server on ${(0, color_1.input)('localhost')}. To serve to your LAN, specify the ${(0, color_1.input)('--external')} option, which will use all network interfaces and print the external address(es) on which your app is being served.`;
        const runner = this.project && await this.project.getServeRunner();
        if (runner) {
            const libmetadata = await runner.getCommandMetadata();
            groups.push(...libmetadata.groups || []);
            options = lodash.uniqWith([...libmetadata.options || [], ...options], (optionA, optionB) => optionA.name === optionB.name);
            description += `\n\n${(libmetadata.description || '').trim()}`;
            footnotes.push(...libmetadata.footnotes || []);
            exampleCommands.push(...libmetadata.exampleCommands || []);
        }
        return {
            name: 'serve',
            type: 'project',
            summary: 'Start a local dev server for app dev/testing',
            description,
            footnotes,
            groups,
            exampleCommands,
            options,
        };
    }
    async preRun(inputs, options, { location }) {
        if (options['nolivereload']) {
            this.env.log.warn(`The ${(0, color_1.input)('--nolivereload')} option has been deprecated. Please use ${(0, color_1.input)('--no-livereload')}.`);
            options['livereload'] = false;
        }
        if (options['nobrowser']) {
            this.env.log.warn(`The ${(0, color_1.input)('--nobrowser')} option has been deprecated. Please use ${(0, color_1.input)('--no-open')}.`);
            options['open'] = false;
        }
        if (options['b']) {
            options['open'] = false;
        }
        if (options['noproxy']) {
            this.env.log.warn(`The ${(0, color_1.input)('--noproxy')} option has been deprecated. Please use ${(0, color_1.input)('--no-proxy')}.`);
            options['proxy'] = false;
        }
        if (options['x']) {
            options['proxy'] = false;
        }
    }
    async run(inputs, options, runinfo) {
        if (!this.project) {
            throw new errors_1.FatalException(`Cannot run ${(0, color_1.input)('ionic serve')} outside a project directory.`);
        }
        try {
            const runner = await this.project.requireServeRunner();
            const runnerOpts = runner.createOptionsFromCommandLine(inputs, options);
            await runner.run(runnerOpts);
        }
        catch (e) {
            if (e instanceof errors_1.RunnerException) {
                throw new errors_1.FatalException(e.message);
            }
            throw e;
        }
        await (0, utils_process_1.sleepForever)();
    }
}
exports.ServeCommand = ServeCommand;