(options: SWACLIConfig)
| 19 | const packageInfo = loadPackageJson(); |
| 20 | |
| 21 | export async function deploy(options: SWACLIConfig) { |
| 22 | const { SWA_CLI_DEPLOYMENT_TOKEN, SWA_CLI_DEBUG } = swaCLIEnv(); |
| 23 | const isVerboseEnabled = SWA_CLI_DEBUG === "silly"; |
| 24 | |
| 25 | let { |
| 26 | appLocation, |
| 27 | apiLocation, |
| 28 | dataApiLocation, |
| 29 | outputLocation, |
| 30 | dryRun, |
| 31 | deploymentToken, |
| 32 | printToken, |
| 33 | appName, |
| 34 | swaConfigLocation, |
| 35 | verbose, |
| 36 | apiLanguage, |
| 37 | apiVersion, |
| 38 | } = options; |
| 39 | |
| 40 | if (dryRun) { |
| 41 | logger.warn("***********************************************************************"); |
| 42 | logger.warn("* WARNING: Running in dry run mode. This project will not be deployed *"); |
| 43 | logger.warn("***********************************************************************"); |
| 44 | logger.warn(""); |
| 45 | } |
| 46 | |
| 47 | // make sure appLocation is set |
| 48 | appLocation = path.resolve(appLocation || process.cwd()); |
| 49 | |
| 50 | // make sure dataApiLocation is set |
| 51 | if (dataApiLocation) { |
| 52 | dataApiLocation = path.resolve(dataApiLocation); |
| 53 | if (!fs.existsSync(dataApiLocation)) { |
| 54 | logger.error(`The provided Data API folder ${dataApiLocation} does not exist. Abort.`, true); |
| 55 | return; |
| 56 | } else { |
| 57 | logger.log(`Deploying Data API from folder:`); |
| 58 | logger.log(` ${chalk.green(dataApiLocation)}`); |
| 59 | logger.log(``); |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | logger.silly(`Resolving outputLocation=${outputLocation} full path...`); |
| 64 | let resolvedOutputLocation = path.resolve(appLocation, outputLocation as string); |
| 65 | |
| 66 | // if folder exists, deploy from a specific build folder (outputLocation), relative to appLocation |
| 67 | if (!fs.existsSync(resolvedOutputLocation)) { |
| 68 | if (!fs.existsSync(outputLocation as string)) { |
| 69 | logger.error(`The folder "${resolvedOutputLocation}" is not found. Exit.`, true); |
| 70 | return; |
| 71 | } |
| 72 | // otherwise, build folder (outputLocation) is using the absolute location |
| 73 | resolvedOutputLocation = path.resolve(outputLocation as string); |
| 74 | } |
| 75 | |
| 76 | logger.log(`Deploying front-end files from folder:`); |
| 77 | logger.log(` ${chalk.green(resolvedOutputLocation)}`); |
| 78 | logger.log(``); |
no test coverage detected
searching dependent graphs…