1 | {"version":3,"sources":["../../cli/next-export.ts"],"names":["nextExport","argv","validArgs","Boolean","String","Number","args","error","code","message","console","log","process","exit","dir","_","options","silent","threads","outdir","then","catch","err"],"mappings":"AAAA;+DACA,0BACA,sBACA,8EACA,yDACA,0C,mFAGA,KAAMA,CAAAA,UAAsB,CAAIC,IAAD,EAAU,CACvC,KAAMC,CAAAA,SAAmB,CAAG,CAC1B;AACA,SAAUC,OAFgB,CAG1B,WAAYA,OAHc,CAI1B,WAAYC,MAJc,CAK1B,YAAaC,MALa,CAO1B;AACA,KAAM,QARoB,CAS1B,KAAM,UAToB,CAU1B,KAAM,UAVoB,CAA5B,CAYA,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,KAdI,EAeAC,OAAO,CAACC,IAAR,CAAa,CAAb,EACD,CAED,KAAMC,CAAAA,GAAG,CAAG,kBAAQR,IAAI,CAACS,CAAL,CAAO,CAAP,GAAa,GAArB,CAAZ,CAEA;AACA,GAAI,CAAC,mBAAWD,GAAX,CAAL,CAAsB,CACpB,wBAAc,mDAAkDA,GAAI,EAApE,EACD,CAED,KAAME,CAAAA,OAAO,CAAG,CACdC,MAAM,CAAEX,IAAI,CAAC,UAAD,CAAJ,EAAoB,KADd,CAEdY,OAAO,CAAEZ,IAAI,CAAC,WAAD,CAFC,CAGda,MAAM,CAAEb,IAAI,CAAC,UAAD,CAAJ,CAAmB,kBAAQA,IAAI,CAAC,UAAD,CAAZ,CAAnB,CAA+C,eAAKQ,GAAL,CAAU,KAAV,CAHzC,CAAhB,CAMA,oBAAUA,GAAV,CAAeE,OAAf,EACGI,IADH,CACQ,IAAM,CACV,wBAAc,uCAAsCJ,OAAO,CAACG,MAAO,EAAnE,CAAsE,CAAtE,EACD,CAHH,EAIGE,KAJH,CAIUC,GAAD,EAAS,CACd,wBAAaA,GAAb,EACD,CANH,EAOD,CA7DD,C","sourcesContent":["#!/usr/bin/env node\nimport { resolve, join } from 'path'\nimport { existsSync } from 'fs'\nimport arg from 'next/dist/compiled/arg/index.js'\nimport exportApp from '../export'\nimport { printAndExit } from '../server/lib/utils'\nimport { cliCommand } from '../bin/next'\n\nconst nextExport: cliCommand = (argv) => {\n const validArgs: arg.Spec = {\n // Types\n '--help': Boolean,\n '--silent': Boolean,\n '--outdir': String,\n '--threads': Number,\n\n // Aliases\n '-h': '--help',\n '-s': '--silent',\n '-o': '--outdir',\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 Exports the application for production deployment\n\n Usage\n $ next export [options] <dir>\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 -h - list this help\n -o - set the output dir (defaults to 'out')\n -s - do not print any messages to console\n `)\n process.exit(0)\n }\n\n const dir = resolve(args._[0] || '.')\n\n // Check if pages dir exists and warn if not\n if (!existsSync(dir)) {\n printAndExit(`> No such directory exists as the project root: ${dir}`)\n }\n\n const options = {\n silent: args['--silent'] || false,\n threads: args['--threads'],\n outdir: args['--outdir'] ? resolve(args['--outdir']) : join(dir, 'out'),\n }\n\n exportApp(dir, options)\n .then(() => {\n printAndExit(`Export successful. Files written to ${options.outdir}`, 0)\n })\n .catch((err) => {\n printAndExit(err)\n })\n}\n\nexport { nextExport }\n"]} |