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

Function swaMagic

src/cli/index.ts:101–130  ·  view source on GitHub ↗
(_options: SWACLIConfig)

Source from the content-addressed store, hash-verified

99}
100
101export async function swaMagic(_options: SWACLIConfig) {
102 try {
103 const hasLoadedConfig = getCurrentSwaCliConfigFromFile();
104 if (!hasLoadedConfig) {
105 logger.log(`${chalk.cyan("→")} No configuration found, running ${chalk.cyan("swa init")}...\n`);
106 runCommand("swa init");
107 }
108
109 logger.log(`${chalk.cyan("→")} Running ${chalk.cyan("swa build")}...\n`);
110 runCommand("swa build");
111 logger.log("");
112
113 const response = await promptOrUseDefault(false, {
114 type: "confirm",
115 name: "deploy",
116 message: "Do you want to deploy your app now?",
117 initial: true,
118 });
119 if (!response.deploy) {
120 logger.log(`\nWhen you'll be ready to deploy your app, just use ${chalk.cyan("swa")} again.`);
121 return;
122 }
123
124 logger.log(`\n${chalk.cyan("→")} Running ${chalk.cyan("swa deploy")}...\n`);
125 runCommand("swa deploy");
126 } catch (_) {
127 // Pokemon, go catch'em all!
128 // (Errors are already caught an displayed in individual commands)
129 }
130}

Callers 1

runFunction · 0.85

Calls 3

runCommandFunction · 0.85
promptOrUseDefaultFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…