Skip to content

Commit 3ec03a8

Browse files
Merge pull request #57 from antstackio/ROVGPT
feature: seperate the init and add command
2 parents 97b3b71 + 83ddf5e commit 3ec03a8

File tree

7 files changed

+32
-11
lines changed

7 files changed

+32
-11
lines changed

bin/index.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,19 @@ import { version } from "../package.json"
1212
import * as util from "../src/utilities/cliUtil"
1313

1414
async function handleInitCommand() {
15-
const editedSam = <string>(<unknown>await util.confirmation())
15+
const editedSam = <string>(<unknown>await util.initConfirmation())
1616
if (editedSam === "create new SAM project") {
1717
await createSAMCLI()
1818
} else if (editedSam === "create custom SAM project") {
1919
await createCustomSAMCLI()
20-
} else if (editedSam === "add components to existing SAM") {
20+
} else {
21+
console.log(editedSam)
22+
throw new Error(`Unknown option ${editedSam}`)
23+
}
24+
}
25+
async function handleAddCommand() {
26+
const editedSam = <string>(<unknown>await util.addConfirmation())
27+
if (editedSam === "add components to existing SAM") {
2128
await addComponentCLI()
2229
} else if (editedSam === "add modules to existing SAM") {
2330
await addModuleCLI()
@@ -49,6 +56,9 @@ async function run(argv: Array<string>): Promise<void> {
4956
case "init":
5057
await handleInitCommand()
5158
break
59+
case "add":
60+
await handleAddCommand()
61+
break
5262
case "deploy":
5363
await handleDeployCommand()
5464
break

scripts/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 --profile $5 $4
2+
sam deploy --no-confirm-changeset --capabilities CAPABILITY_NAMED_IAM CAPABILITY_IAM CAPABILITY_AUTO_EXPAND --stack-name $2 --profile $3 --region $4 $5

src/configs/buildConfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export const samConfig: Record<
44
> = {
55
choices: {
66
tool: ["GitHub", "GitLab", "BitBucket"],
7-
language: ["js", "python"],
7+
language: ["js"],
88
framework: ["sam", "cdk"],
99
deploymentregion: [
1010
"us-east-2",

src/configs/cliConfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export const app: Record<
4141
choices: {
4242
methods: ["put", "get", "post", "delete"],
4343
resourcetype: ["lambda", "stepfunction", "dynamodb"],
44-
language: ["Node", "Python"],
44+
language: ["Node"],
4545
type: Object.values(moduleDescription),
4646
pipeline: ["generate pipeline", "cli", "repository and pipeline"],
4747
},

src/roverCLI/roverDeployCLI.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export async function deployCLI() {
7070
const region = deploymentregion["Deployment region"]
7171

7272
exec(
73-
`sh ${roverHelpers.npmroot}/@rover-tools/cli/scripts/exec.sh ${fileName} ${stack_name} ${region} ${bucketName} ${profile} `
73+
`sh ${roverHelpers.npmroot}/@rover-tools/cli/scripts/exec.sh ${fileName} ${stack_name} ${profile} ${region} ${bucketName}`
7474
)
7575

7676
const configdata: IroverDeploymentConfig = <IroverDeploymentConfig>{}

src/roverCLI/roverGenerateCLI.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as rover from "@rover-tools/engine/dist/bin/index"
22
const roverHelpers = rover.helpers
3-
const rover_addComponent = rover.addComponents
3+
//const rover_addComponent = rover.addComponents
4+
const rover_addComponent = rover.addComponent
45
const rover_addModules = rover.addModules
56
const rover_generateSAM = rover.generateSAM
67
const rover_addModulesToexisting = rover.addModulesToExisting

src/utilities/cliUtil.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export async function inputString(
7575
return (
7676
optional ||
7777
stringpattern.test(value) ||
78-
`${message} should have only alphanumeric values`
78+
`${message} ${name} ${value} should have only alphanumeric values `
7979
)
8080
}
8181
},
@@ -134,15 +134,25 @@ export const inputType = async function (
134134
return takeInput
135135
}
136136

137-
export const confirmation = async function () {
137+
export const initConfirmation = async function () {
138+
const r = await inquirer.prompt([
139+
{
140+
type: "rawlist",
141+
name: "choice",
142+
message: `Hey, what do you want ?`,
143+
choices: ["create new SAM project", "create custom SAM project"],
144+
},
145+
])
146+
147+
return r.choice
148+
}
149+
export const addConfirmation = async function () {
138150
const r = await inquirer.prompt([
139151
{
140152
type: "rawlist",
141153
name: "choice",
142154
message: `Hey, what do you want ?`,
143155
choices: [
144-
"create new SAM project",
145-
"create custom SAM project",
146156
"add components to existing SAM",
147157
"add modules to existing SAM",
148158
],

0 commit comments

Comments
 (0)