-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5041660
Showing
41 changed files
with
11,838 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@echo off | ||
|
||
node --loader ts-node/esm --no-warnings=ExperimentalWarning "%~dp0\dev" %* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env -S node --loader ts-node/esm --disable-warning=ExperimentalWarning | ||
|
||
// eslint-disable-next-line n/shebang | ||
import {execute} from '@oclif/core' | ||
|
||
await execute({development: true, dir: import.meta.url}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@echo off | ||
|
||
node "%~dp0\run" %* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env node | ||
|
||
import {execute} from '@oclif/core' | ||
|
||
await execute({dir: import.meta.url}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { Command } from "@oclif/core"; | ||
export default class Init extends Command { | ||
static description: string; | ||
run(): Promise<void>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Command } from "@oclif/core"; | ||
import ora from "ora"; | ||
import { exec } from "child_process"; | ||
import { promisify } from "util"; | ||
import configureAWS from "../utils/configureAWS.js"; | ||
// Promisify exec for async/await usage | ||
const execPromise = promisify(exec); | ||
const spinner = ora(); | ||
export default class Init extends Command { | ||
static description = "Initialize the CDK project"; | ||
// TODOS | ||
// - What happens if the stack fails? -> give cdk deploy responsibilities to user | ||
// - How to retrieve information from user (# of caches, names in DB, etc), and how to enter those values into CDK | ||
async run() { | ||
console.log("Welcome to the Cerebellum CLI!"); | ||
// await confirmAwsCliInstall(); | ||
await configureAWS(); | ||
// await cloneCDK(); | ||
// await npmInstallCDK(); | ||
// await npmInstallLambda(); | ||
// await confirmAwsCdkInstall(); | ||
// await cdkSynth(); | ||
// await cdkBootstrap(); | ||
// await cdkDeploy() // better to let them deploy so they can see progress and address any errors that arise | ||
console.log("Success! You are now ready to deploy your infrastructure!"); | ||
console.log("When ready, enter `cd cdk && cdk deploy` and follow the prompts."); | ||
console.log("Deployment can take 10-20 minutes, depending on complexity."); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { run } from '@oclif/core'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { run } from '@oclif/core'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
declare const cdkBootstrap: () => Promise<void>; | ||
export default cdkBootstrap; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import ora from 'ora'; | ||
import { exec } from 'child_process'; | ||
import { promisify } from 'util'; | ||
// Promisify exec for async/await usage | ||
const execPromise = promisify(exec); | ||
const spinner = ora(); | ||
const cdkBootstrap = async () => { | ||
spinner.start('Creating bootstrap resources for CDK...'); | ||
try { | ||
await execPromise('cd cdk && cdk bootstrap'); | ||
spinner.succeed('CDK bootstrap creation success!'); | ||
} | ||
catch (error) { | ||
spinner.fail('An error occurred creating cdk bootstrap'); | ||
console.error(error); | ||
} | ||
}; | ||
export default cdkBootstrap; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
declare const cdkDeploy: () => Promise<void>; | ||
export default cdkDeploy; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import ora from 'ora'; | ||
import { exec } from 'child_process'; | ||
import { promisify } from 'util'; | ||
const execPromise = promisify(exec); | ||
const spinner = ora(); | ||
const cdkDeploy = async () => { | ||
spinner.start('Deploying CDK... (this may take 10-20 minutes, depending on the complexity)'); | ||
try { | ||
await execPromise('cd cdk && cdk deploy --require-approval never'); | ||
spinner.succeed('CDK successfuly deployed!'); | ||
} | ||
catch (error) { | ||
spinner.fail('An error occurred'); | ||
console.error(error); | ||
} | ||
}; | ||
export default cdkDeploy; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
declare const cdkSynth: () => Promise<void>; | ||
export default cdkSynth; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import ora from 'ora'; | ||
import { exec } from 'child_process'; | ||
import { promisify } from 'util'; | ||
// Promisify exec for async/await usage | ||
const execPromise = promisify(exec); | ||
const spinner = ora(); | ||
const cdkSynth = async () => { | ||
spinner.start('Running cdk synth...'); | ||
try { | ||
await execPromise('cd cdk && cdk synth'); | ||
spinner.succeed('CDK successfully synthesized!'); | ||
} | ||
catch (error) { | ||
spinner.fail('An error occurred'); | ||
console.error(error); | ||
} | ||
}; | ||
export default cdkSynth; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
declare const cloneCDK: () => Promise<void>; | ||
export default cloneCDK; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import ora from 'ora'; | ||
import { exec } from 'child_process'; | ||
import { promisify } from 'util'; | ||
// Promisify exec for async/await usage | ||
const execPromise = promisify(exec); | ||
const spinner = ora(); | ||
const cloneCDK = async () => { | ||
spinner.start('Cloning CDK repo from Github...'); | ||
try { | ||
await execPromise('git clone https://github.com/Capstone2408-Team-2/cdk.git'); | ||
spinner.succeed('CDK successfully cloned!'); | ||
} | ||
catch (error) { | ||
spinner.fail('An error occurred'); | ||
console.error(error); | ||
} | ||
}; | ||
export default cloneCDK; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
declare const configureAWS: () => Promise<void>; | ||
export default configureAWS; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import ora from "ora"; | ||
import { spawn } from "child_process"; | ||
const spinner = ora(); | ||
const configureAWS = async () => { | ||
try { | ||
console.log("Loading AWS Configure..."); | ||
await new Promise((resolve, reject) => { | ||
const child = spawn("aws", ["configure"], { | ||
stdio: "inherit", // This allows for interactive input/output | ||
}); | ||
child.stdout?.on("data", () => { | ||
console.log("Here"); | ||
}); | ||
child.on("close", (code) => { | ||
if (code === 0) { | ||
resolve(null); | ||
} | ||
else { | ||
reject(new Error(`Command failed with exit code ${code}`)); | ||
} | ||
}); | ||
}); | ||
// Restart the spinner after the command completes | ||
spinner.succeed("AWS configure success!"); | ||
} | ||
catch (error) { | ||
spinner.fail("An error occurred"); | ||
console.error(error); | ||
} | ||
}; | ||
export default configureAWS; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
declare const confirmAwsCdkInstall: () => Promise<void>; | ||
export default confirmAwsCdkInstall; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import ora from 'ora'; | ||
import { exec } from 'child_process'; | ||
import { promisify } from 'util'; | ||
import { cli } from 'cli-ux'; | ||
// Promisify exec for async/await usage | ||
const execPromise = promisify(exec); | ||
const spinner = ora(); | ||
const confirmAwsCdkInstall = async () => { | ||
spinner.start('Checking if aws-cli is installed...'); | ||
const alreadyInstalled = await execPromise('cdk --version').catch(() => false); | ||
if (alreadyInstalled) { | ||
spinner.succeed('aws-cdk is installed!'); | ||
return; | ||
} | ||
spinner.stop(); | ||
try { | ||
const response = await cli.prompt('You will need aws-cdk to be globally installed to deploy the infrastructure.\n Would you like it to be installed? (y/n)'); | ||
if (response.toLowerCase() === 'n') { | ||
throw new Error('Permission denied by user. Please globally install aws-cdk independently or run script again.'); | ||
} | ||
spinner.start('Globally installing aws-cdk!'); | ||
await execPromise('npm install -g aws-cdk'); | ||
spinner.succeed('aws-cdk globally installed!'); | ||
} | ||
catch (error) { | ||
spinner.fail('An error occurred'); | ||
console.error(error); | ||
} | ||
}; | ||
export default confirmAwsCdkInstall; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
declare const confirmAwsCliInstall: () => Promise<void>; | ||
export default confirmAwsCliInstall; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import ora from 'ora'; | ||
import { exec } from 'child_process'; | ||
import { promisify } from 'util'; | ||
import { cli } from 'cli-ux'; | ||
// Promisify exec for async/await usage | ||
const execPromise = promisify(exec); | ||
const spinner = ora(); | ||
const confirmAwsCliInstall = async () => { | ||
spinner.start('Checking if aws-cli is installed...'); | ||
const alreadyInstalled = await execPromise('aws --version').catch(() => false); | ||
if (alreadyInstalled) { | ||
spinner.succeed('aws-cli is installed!'); | ||
return; | ||
} | ||
spinner.stop(); | ||
try { | ||
const response = await cli.prompt('You will need aws-cli to be globally installed to deploy the infrastructure.\n Would you like it to be installed? (y/n)'); | ||
if (response.toLowerCase() === 'n') { | ||
throw new Error('Permission denied by user. Please globally install aws-cli independently or run script again.'); | ||
} | ||
spinner.start('Globally installing aws-cli!'); | ||
await execPromise('npm install -g aws-cli'); | ||
spinner.succeed('aws-cli globally installed!'); | ||
} | ||
catch (error) { | ||
spinner.fail('An error occurred'); | ||
console.error(error); | ||
} | ||
}; | ||
export default confirmAwsCliInstall; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
declare const npmInstallCDK: () => Promise<void>; | ||
export default npmInstallCDK; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import ora from 'ora'; | ||
import { exec } from 'child_process'; | ||
import { promisify } from 'util'; | ||
// Promisify exec for async/await usage | ||
const execPromise = promisify(exec); | ||
const spinner = ora(); | ||
const npmInstallCDK = async () => { | ||
spinner.start('Installing dependencies in the CDK...'); | ||
try { | ||
await execPromise('cd cdk && npm install'); | ||
spinner.succeed('Dependencies within the CDK successfully installed!'); | ||
} | ||
catch (error) { | ||
spinner.fail('An error occurred'); | ||
console.error(error); | ||
} | ||
}; | ||
export default npmInstallCDK; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
declare const npmInstallLambda: () => Promise<void>; | ||
export default npmInstallLambda; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import ora from 'ora'; | ||
import { exec } from 'child_process'; | ||
import { promisify } from 'util'; | ||
const execPromise = promisify(exec); | ||
const spinner = ora(); | ||
const npmInstallLambda = async () => { | ||
spinner.start('Installing dependencies for lambda functions...'); | ||
try { | ||
await execPromise('cd cdk/lambda && npm install'); | ||
spinner.succeed('Lambda dependencies installed successfully!'); | ||
} | ||
catch (error) { | ||
spinner.fail('An error occurred'); | ||
console.error(error); | ||
} | ||
}; | ||
export default npmInstallLambda; |
Oops, something went wrong.