Skip to content

Commit 346b6c9

Browse files
committed
feature : add profile in cli deployment
1 parent 25e043f commit 346b6c9

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

bin/index.ts

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ async function createModules(app_name,language) {
9696
return template
9797

9898
}
99+
async function listProfiles() {
100+
let profiles = (exec("aws configure list-profiles").toString()).split("\n")
101+
if (profiles[profiles.length - 1] == "") profiles.splice(profiles.length - 1, 1)
102+
return profiles
103+
}
99104
async function run(argv: AnyObject) {
100105
try {
101106
if (rover_utilities.npmrootTest()) {
@@ -191,13 +196,16 @@ async function run(argv: AnyObject) {
191196
template = { ...template, repoConfig };
192197
let repoconfig = await Promise.resolve(util.jsonCreation(template));
193198
if (repoconfig !== undefined) {
199+
194200
await deployment.setupRepo(JSON.parse(repoconfig)["repoConfig"]);
201+
rover_utilities.generateRoverConfig("",JSON.parse(repoconfig)["repoConfig"],"rover_generate_pipeline")
195202
}
196203
} else {
197204
await rover_utilities.samValidate(undefined);
198205
if (fs.existsSync("samconfig.toml")) {
199206
exec("rm -rf samconfig.toml");
200207
}
208+
let profiles=await listProfiles()
201209
let filenamearray = exec("pwd").toString().split("/");
202210
let file_name = filenamearray[filenamearray.length - 1].replace(
203211
"\n",
@@ -216,6 +224,8 @@ async function run(argv: AnyObject) {
216224
"Bucket Name(optional) :"
217225
);
218226
let choice = buildConfig.samConfig.choices.deploymentregion;
227+
let profile = (await util.inputType("AWS profile", profiles))["AWS profile"]
228+
console.log(profile)
219229
let deploymentregion = await util.inputType(
220230
"Deployment region",
221231
choice
@@ -232,18 +242,15 @@ async function run(argv: AnyObject) {
232242
}
233243
let region = deploymentregion["Deployment region"];
234244

235-
exec(
236-
"sh " +
237-
rover_config.npmroot +
238-
"/@rover-tools/cli/cli-main/exec.sh " +
239-
file_name +
240-
" " +
241-
stack_name +
242-
" " +
243-
region +
244-
" " +
245-
bucketName
246-
);
245+
exec("sh " + rover_config.npmroot + "/@rover-tools/cli/cli-main/exec.sh " + file_name + " " + stack_name + " " + region + " " + bucketName + " "+profile);
246+
247+
let configdata = {}
248+
configdata["bucket"] = bucketName
249+
configdata["stack name"] = stack_name
250+
configdata["region"] = region
251+
configdata["bucket"] = bucketName``
252+
configdata["profile"] = profile
253+
rover_utilities.generateRoverConfig("",configdata,"rover_deploy_cli")
247254
}
248255
} else if (argv[0] === "-v" || argv[0] === "--version") {
249256
// show current package version in the console
@@ -260,7 +267,7 @@ async function run(argv: AnyObject) {
260267
);
261268
}
262269
} catch (error) {
263-
console.log("Error: ", error.message);
270+
console.log("Error: ", error);
264271
}
265272
}
266273
export let stackNames: any = stack_resource_Name;

cli-main/exec.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
sam build
2-
sam deploy --no-confirm-changeset --capabilities CAPABILITY_NAMED_IAM CAPABILITY_IAM CAPABILITY_AUTO_EXPAND --stack-name $2 --region $3 $4
2+
sam deploy --no-confirm-changeset --capabilities CAPABILITY_NAMED_IAM CAPABILITY_IAM CAPABILITY_AUTO_EXPAND --stack-name $2 --region $3 --profile $5 $4

0 commit comments

Comments
 (0)