Skip to content

Commit dc6de32

Browse files
authored
refactor(appbuilder): combine sync/deploy wizard, add multipick
## Problem Multiple bugs related to Sync/Build wizard ## Solution Bug7: conflict params will be auto-resolved now Bug8: code is no longer auto applied Bug9: conflict params will be auto-resolved now Bug11: Now back button in sync deploy wizard will work Deploy Parameter wizard will remember recent input
1 parent 64f3bbd commit dc6de32

File tree

13 files changed

+745
-571
lines changed

13 files changed

+745
-571
lines changed

packages/core/src/awsService/appBuilder/activation.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@ import { getLogger } from '../../shared/logger'
1818
import path from 'path'
1919
import { TreeNode } from '../../shared/treeview/resourceTreeDataProvider'
2020
import { runBuild } from '../../shared/sam/build'
21-
import { deployTypePrompt, runOpenHandler, runOpenTemplate } from './utils'
21+
import { runOpenHandler, runOpenTemplate } from './utils'
2222
import { ResourceNode } from './explorer/nodes/resourceNode'
23+
import { getSyncWizard, runSync } from '../../shared/sam/sync'
24+
import { getDeployWizard, runDeploy } from '../../shared/sam/deploy'
25+
import { DeployTypeWizard } from './wizards/deployTypeWizard'
2326

2427
export const templateToOpenAppComposer = 'aws.toolkit.appComposer.templateToOpenOnStart'
2528

@@ -185,11 +188,17 @@ async function registerAppBuilderCommands(context: ExtContext): Promise<void> {
185188
})
186189
),
187190
Commands.register({ id: 'aws.appBuilder.deploy', autoconnect: true }, async (arg) => {
188-
const params = await deployTypePrompt()
189-
if (params === 'deploy') {
190-
await vscode.commands.executeCommand('aws.deploySamApplication', arg)
191-
} else if (params === 'sync') {
192-
await vscode.commands.executeCommand('aws.samcli.sync', arg)
191+
const wizard = new DeployTypeWizard(
192+
await getSyncWizard('infra', arg, undefined, false),
193+
await getDeployWizard(arg, false)
194+
)
195+
const choices = await wizard.run()
196+
if (choices) {
197+
if (choices.choice === 'deploy' && choices.deployParam) {
198+
await runDeploy(arg, choices.deployParam)
199+
} else if (choices.choice === 'sync' && choices.syncParam) {
200+
await runSync('infra', arg, undefined, choices.syncParam)
201+
}
193202
}
194203
})
195204
)
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*!
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
import { samDeployUrl } from '../../../shared/constants'
7+
import { createCommonButtons } from '../../../shared/ui/buttons'
8+
import { DataQuickPickItem, createQuickPick } from '../../../shared/ui/pickerPrompter'
9+
import * as nls from 'vscode-nls'
10+
import { Wizard } from '../../../shared/wizards/wizard'
11+
import { DeployParams, DeployWizard } from '../../../shared/sam/deploy'
12+
import { SyncParams, SyncWizard } from '../../../shared/sam/sync'
13+
import { WizardPrompter } from '../../../shared/ui/wizardPrompter'
14+
import { createExitPrompter } from '../../../shared/ui/common/exitPrompter'
15+
const localize = nls.loadMessageBundle()
16+
17+
export class DeployTypeWizard extends Wizard<{
18+
choice: string
19+
syncParam: SyncParams
20+
deployParam: DeployParams
21+
}> {
22+
public constructor(syncWizard: SyncWizard, deployWizard: DeployWizard) {
23+
super({ exitPrompterProvider: createExitPrompter })
24+
const form = this.form
25+
26+
const items: DataQuickPickItem<string>[] = [
27+
{
28+
label: 'Sync',
29+
data: 'sync',
30+
detail: 'Speed up your development and testing experience in the AWS Cloud. With the --watch parameter, sync will build, deploy and watch for local changes',
31+
description: 'Development environments',
32+
},
33+
{
34+
label: 'Deploy',
35+
data: 'deploy',
36+
detail: 'Deploys your template through CloudFormation',
37+
description: 'Production environments',
38+
},
39+
]
40+
form.choice.bindPrompter(() => {
41+
return createQuickPick(items, {
42+
title: localize('AWS.appBuilder.deployType.title', 'Select deployment command'),
43+
placeholder: 'Press enter to proceed with highlighted option',
44+
buttons: createCommonButtons(samDeployUrl),
45+
})
46+
})
47+
form.deployParam.bindPrompter((state) => new WizardPrompter(deployWizard), {
48+
showWhen: (state) => state.choice === 'deploy',
49+
})
50+
form.syncParam.bindPrompter((state) => new WizardPrompter(syncWizard), {
51+
showWhen: (state) => state.choice === 'sync',
52+
})
53+
}
54+
}

packages/core/src/shared/constants.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@ export const lambdaFunctionUrlConfigUrl: string = 'https://docs.aws.amazon.com/l
7575
export const samSyncUrl = vscode.Uri.parse(
7676
'https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/accelerate-getting-started.html'
7777
)
78+
// URLs for "sam build param selection"
79+
export const samBuildParamUrl = vscode.Uri.parse(
80+
'https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-cli-command-reference-sam-build.html'
81+
)
82+
// URLs for "sam sync prarm selection"
83+
export const samSyncParamUrl = vscode.Uri.parse(
84+
'https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-cli-command-reference-sam-sync.html'
85+
)
7886

7987
//URLs for "sam build" wizard.
8088
export const samBuildUrl = vscode.Uri.parse(

packages/core/src/shared/sam/activation.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import { SamCliSettings } from './cli/samCliSettings'
3535
import { Commands } from '../vscode/commands2'
3636
import { runSync } from './sync'
3737
import { showExtensionPage } from '../utilities/vsCodeUtils'
38-
import { runDeploy } from '../../lambda/commands/deploySamApplication'
38+
import { runDeploy } from './deploy'
3939
import { telemetry } from '../telemetry/telemetry'
4040

4141
const sharedDetectSamCli = shared(detectSamCli)
@@ -122,14 +122,6 @@ export async function activate(ctx: ExtContext): Promise<void> {
122122
if (globals.didReload) {
123123
await resumeCreateNewSamApp(ctx)
124124
}
125-
126-
Commands.register(
127-
{
128-
id: 'aws.samcli.sync',
129-
autoconnect: true,
130-
},
131-
async (arg?, validate?: boolean) => await runSync('infra', arg, validate)
132-
)
133125
}
134126

135127
async function registerCommands(ctx: ExtContext, settings: SamCliSettings): Promise<void> {
@@ -159,7 +151,14 @@ async function registerCommands(ctx: ExtContext, settings: SamCliSettings): Prom
159151
Commands.register({ id: 'aws.toggleSamCodeLenses', autoconnect: false }, async () => {
160152
const toggled = !settings.get('enableCodeLenses', false)
161153
await settings.update('enableCodeLenses', toggled)
162-
})
154+
}),
155+
Commands.register(
156+
{
157+
id: 'aws.samcli.sync',
158+
autoconnect: true,
159+
},
160+
async (arg?, validate?: boolean) => await runSync('infra', arg, validate)
161+
)
163162
)
164163
}
165164

0 commit comments

Comments
 (0)