MCPcopy Create free account
hub / github.com/Azure/static-web-apps-cli / deploy

Function deploy

src/cli/commands/deploy/deploy.ts:21–357  ·  view source on GitHub ↗
(options: SWACLIConfig)

Source from the content-addressed store, hash-verified

19const packageInfo = loadPackageJson();
20
21export 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(``);

Callers 2

deploy.spec.tsFile · 0.85
registerCommandFunction · 0.85

Calls 14

swaCLIEnvFunction · 0.85
findApiFolderInPathFunction · 0.85
isUserOrConfigOptionFunction · 0.85
getDefaultVersionFunction · 0.85
getStaticSiteDeploymentFunction · 0.85
updateSwaCliConfigFileFunction · 0.85
readWorkflowFileFunction · 0.85
findSWAConfigFileFunction · 0.85
getDeployClientPathFunction · 0.85
cleanUpFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…