diff --git a/src/commands/deployment/testservers/create/create.ts b/src/commands/deployment/testservers/create/create.ts index 18208c3..08a3173 100644 --- a/src/commands/deployment/testservers/create/create.ts +++ b/src/commands/deployment/testservers/create/create.ts @@ -5,6 +5,7 @@ const chalk = require('chalk'); const { AutoComplete, Input, Confirm } = require('enquirer'); import { defaultMenuSettings, getSettings } from '../../../../globals'; import { getRepoBranches } from '../../../../services/github_rest'; +const { spawn } = require('child_process'); const getConfirmation = async (branchName: string, stackName: string) => { const url = stackName.replace('photowall-', ''); @@ -115,11 +116,34 @@ module.exports = { cmd, )}] in folder [${`${config.photowall_repo}/cloudformation/`}]`, ); - const output = await system.run(cmd, { - cwd: `${config.photowall_repo}/cloudformation/`, - trim: true, + const child = spawn( + 'make', + [ + 'create-stack', + `STACK_ENVIRONMENT_NAME=${stacksuffix}`, + `GITHUB_BRANCH=${branchName}`, + ], + { + cwd: `${config.photowall_repo}/cloudformation/`, + }, + ); + + child.stdout.setEncoding('utf8'); + child.stdout.on('data', (data) => { + process.stdout.write(data); + }); + child.stderr.on('data', (data) => { + process.stderr.write(data); + }); + await new Promise((resolve, reject) => { + child.on('close', (code) => { + if (code === 0) { + resolve(0); + } else { + reject(new Error(`make exited with code ${code}`)); + } + }); }); - print.fancy(output); } } catch (e) { console.log(`e`, e); diff --git a/src/commands/deployment/testservers/update/update.ts b/src/commands/deployment/testservers/update/update.ts index a67cef9..218b352 100644 --- a/src/commands/deployment/testservers/update/update.ts +++ b/src/commands/deployment/testservers/update/update.ts @@ -10,6 +10,7 @@ import { getSettings, sleep, } from '../../../../globals'; +const { spawn } = require('child_process'); type Stack = { name: string; @@ -126,11 +127,33 @@ module.exports = { cmd, )}] in folder [${`${config.photowall_repo}/cloudformation/`}]`, ); - const output = await system.run(cmd, { - cwd: `${config.photowall_repo}/cloudformation/`, - trim: true, + const child = spawn( + 'make', + [ + 'update-stack', + `STACK_ENVIRONMENT_NAME=${stacksuffix}`, + `GITHUB_BRANCH=${branchName}`, + ], + { + cwd: `${config.photowall_repo}/cloudformation/`, + }, + ); + child.stdout.setEncoding('utf8'); + child.stdout.on('data', (data) => { + process.stdout.write(data); + }); + child.stderr.on('data', (data) => { + process.stderr.write(data); + }); + await new Promise((resolve, reject) => { + child.on('close', (code) => { + if (code === 0) { + resolve(0); + } else { + reject(new Error(`make exited with code ${code}`)); + } + }); }); - print.fancy(output); // Check the status const spinner = print.spin(`Waiting for stack to update`);