1 | {"version":3,"sources":["../../cli/next-start.ts"],"names":["nextStart","argv","validArgs","Boolean","Number","String","args","error","code","message","console","log","process","exit","dir","_","port","env","PORT","parseInt","host","appUrl","then","app","Log","ready","prepare","catch","err"],"mappings":"AAAA;8DAEA,0BACA,8EACA,+EACA,0CAEA,gE,w4BAEA,KAAMA,CAAAA,SAAqB,CAAIC,IAAD,EAAU,CACtC,KAAMC,CAAAA,SAAmB,CAAG,CAC1B;AACA,SAAUC,OAFgB,CAG1B,SAAUC,MAHgB,CAI1B,aAAcC,MAJY,CAM1B;AACA,KAAM,QAPoB,CAQ1B,KAAM,QARoB,CAS1B,KAAM,YAToB,CAA5B,CAWA,GAAIC,CAAAA,IAAJ,CACA,GAAI,CACFA,IAAI,CAAG,mBAAIJ,SAAJ,CAAe,CAAED,IAAF,CAAf,CAAP,CACD,CAAC,MAAOM,KAAP,CAAc,CACd,GAAIA,KAAK,CAACC,IAAN,GAAe,oBAAnB,CAAyC,CACvC,MAAO,wBAAaD,KAAK,CAACE,OAAnB,CAA4B,CAA5B,CAAP,CACD,CACD,KAAMF,CAAAA,KAAN,CACD,CACD,GAAID,IAAI,CAAC,QAAD,CAAR,CAAoB,CAClBI,OAAO,CAACC,GAAR,CAAa;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAfI,EAgBAC,OAAO,CAACC,IAAR,CAAa,CAAb,EACD,CAED,KAAMC,CAAAA,GAAG,CAAG,kBAAQR,IAAI,CAACS,CAAL,CAAO,CAAP,GAAa,GAArB,CAAZ,CACA,KAAMC,CAAAA,IAAI,CACRV,IAAI,CAAC,QAAD,CAAJ,EAAmBM,OAAO,CAACK,GAAR,CAAYC,IAAZ,EAAoBC,QAAQ,CAACP,OAAO,CAACK,GAAR,CAAYC,IAAb,CAA/C,EAAsE,IADxE,CAEA,KAAME,CAAAA,IAAI,CAAGd,IAAI,CAAC,YAAD,CAAJ,EAAsB,SAAnC,CACA,KAAMe,CAAAA,MAAM,CAAI,UAASD,IAAI,GAAK,SAAT,CAAqB,WAArB,CAAmCA,IAAK,IAAGJ,IAAK,EAAzE,CACA,yBAAY,CAAEF,GAAF,CAAZ,CAAqBE,IAArB,CAA2BI,IAA3B,EACGE,IADH,CACQ,KAAOC,CAAAA,GAAP,EAAe,CACnBC,GAAG,CAACC,KAAJ,CAAW,qBAAoBL,IAAK,IAAGJ,IAAK,UAASK,MAAO,EAA5D,EACA,KAAME,CAAAA,GAAG,CAACG,OAAJ,EAAN,CACD,CAJH,EAKGC,KALH,CAKUC,GAAD,EAAS,CACdlB,OAAO,CAACH,KAAR,CAAcqB,GAAd,EACAhB,OAAO,CAACC,IAAR,CAAa,CAAb,EACD,CARH,EASD,CAvDD,C","sourcesContent":["#!/usr/bin/env node\n\nimport { resolve } from 'path'\nimport arg from 'next/dist/compiled/arg/index.js'\nimport startServer from '../server/lib/start-server'\nimport { printAndExit } from '../server/lib/utils'\nimport { cliCommand } from '../bin/next'\nimport * as Log from '../build/output/log'\n\nconst nextStart: cliCommand = (argv) => {\n const validArgs: arg.Spec = {\n // Types\n '--help': Boolean,\n '--port': Number,\n '--hostname': String,\n\n // Aliases\n '-h': '--help',\n '-p': '--port',\n '-H': '--hostname',\n }\n let args: arg.Result<arg.Spec>\n try {\n args = arg(validArgs, { argv })\n } catch (error) {\n if (error.code === 'ARG_UNKNOWN_OPTION') {\n return printAndExit(error.message, 1)\n }\n throw error\n }\n if (args['--help']) {\n console.log(`\n Description\n Starts the application in production mode.\n The application should be compiled with \\`next build\\` first.\n\n Usage\n $ next start <dir> -p <port>\n\n <dir> represents the directory of the Next.js application.\n If no directory is provided, the current directory will be used.\n\n Options\n --port, -p A port number on which to start the application\n --hostname, -H Hostname on which to start the application (default: 0.0.0.0)\n --help, -h Displays this message\n `)\n process.exit(0)\n }\n\n const dir = resolve(args._[0] || '.')\n const port =\n args['--port'] || (process.env.PORT && parseInt(process.env.PORT)) || 3000\n const host = args['--hostname'] || '0.0.0.0'\n const appUrl = `http://${host === '0.0.0.0' ? 'localhost' : host}:${port}`\n startServer({ dir }, port, host)\n .then(async (app) => {\n Log.ready(`started server on ${host}:${port}, url: ${appUrl}`)\n await app.prepare()\n })\n .catch((err) => {\n console.error(err)\n process.exit(1)\n })\n}\n\nexport { nextStart }\n"]} |