3
3
* SPDX-License-Identifier: Apache-2.0
4
4
*/
5
5
6
- import { openUrl } from '../../../shared/utilities/vsCodeUtils'
6
+ import { openUrl , showExtensionPage } from '../../../shared/utilities/vsCodeUtils'
7
7
import * as vscode from 'vscode'
8
8
import * as nls from 'vscode-nls'
9
9
10
- import { samAboutInstallUrl , vscodeMarketplaceUrl } from '../../constants'
10
+ import { samInstallUrl } from '../../constants'
11
11
import { getIdeProperties } from '../../extensionUtilities'
12
12
import {
13
13
InvalidSamCliError ,
@@ -18,6 +18,7 @@ import {
18
18
SamCliVersionValidation ,
19
19
SamCliVersionValidatorResult ,
20
20
} from './samCliValidator'
21
+ import { VSCODE_EXTENSION_ID } from '../../extensions'
21
22
22
23
const localize = nls . loadMessageBundle ( )
23
24
@@ -28,17 +29,20 @@ export interface SamCliValidationNotificationAction {
28
29
}
29
30
30
31
const actionGoToSamCli : SamCliValidationNotificationAction = {
31
- label : localize ( 'AWS.samcli.userChoice.visit.install.url' , 'Get SAM CLI' ) ,
32
+ label : localize ( 'AWS.samcli.userChoice.visit.install.url' , 'Install latest SAM CLI' ) ,
32
33
invoke : async ( ) => {
33
- openUrl ( samAboutInstallUrl )
34
+ openUrl ( samInstallUrl )
34
35
} ,
35
36
}
36
37
37
38
const actionGoToVsCodeMarketplace : SamCliValidationNotificationAction = {
38
- label : localize ( 'AWS.samcli.userChoice.update.awstoolkit.url' , 'Visit Marketplace' ) ,
39
+ label : localize (
40
+ 'AWS.samcli.userChoice.update.awstoolkit.url' ,
41
+ 'Install latest {0} Toolkit' ,
42
+ getIdeProperties ( ) . company
43
+ ) ,
39
44
invoke : async ( ) => {
40
- // TODO : Switch to the Extension panel in VS Code instead
41
- await vscode . env . openExternal ( vscode . Uri . parse ( vscodeMarketplaceUrl ) )
45
+ showExtensionPage ( VSCODE_EXTENSION_ID . awstoolkit )
42
46
} ,
43
47
}
44
48
@@ -74,12 +78,11 @@ export async function notifySamCliValidation(samCliValidationError: InvalidSamCl
74
78
return
75
79
}
76
80
77
- const notification : SamCliValidationNotification = makeSamCliValidationNotification ( samCliValidationError )
78
-
81
+ const notification = getInvalidSamMsg ( samCliValidationError )
79
82
await notification . show ( )
80
83
}
81
84
82
- export function makeSamCliValidationNotification (
85
+ export function getInvalidSamMsg (
83
86
samCliValidationError : InvalidSamCliError ,
84
87
onCreateNotification : (
85
88
message : string ,
@@ -97,46 +100,56 @@ export function makeSamCliValidationNotification(
97
100
)
98
101
} else if ( samCliValidationError instanceof InvalidSamCliVersionError ) {
99
102
return onCreateNotification (
100
- makeVersionValidationNotificationMessage ( samCliValidationError . versionValidation ) ,
101
- makeVersionValidationActions ( samCliValidationError . versionValidation . validation )
103
+ getInvalidVersionMsg ( samCliValidationError . versionValidation ) ,
104
+ getActions ( samCliValidationError . versionValidation . validation )
102
105
)
103
106
} else {
104
107
return onCreateNotification (
105
108
localize (
106
109
'AWS.samcli.notification.unexpected.validation.issue' ,
107
- 'An unexpected issue occured while validating SAM CLI: {0}' ,
110
+ 'Unexpected error while validating SAM CLI: {0}' ,
108
111
samCliValidationError . message
109
112
) ,
110
113
[ ]
111
114
)
112
115
}
113
116
}
114
117
115
- function makeVersionValidationNotificationMessage ( validationResult : SamCliVersionValidatorResult ) : string {
116
- const recommendationUpdateToolkit : string = localize (
117
- 'AWS.samcli.recommend.update.toolkit' ,
118
- 'Check the Marketplace for an updated {0} Toolkit.' ,
119
- getIdeProperties ( ) . company
118
+ function getInvalidVersionMsg ( validationResult : SamCliVersionValidatorResult ) : string {
119
+ const win185msg = localize (
120
+ 'AWS.sam.updateSamWindows' ,
121
+ 'SAM CLI 1.85-1.86 has [known issues](https://github.com/aws/aws-sam-cli/issues/5243) on Windows. Update SAM CLI.'
120
122
)
121
-
122
- const recommendationUpdateSamCli : string = localize ( 'AWS.samcli.recommend.update.samcli' , 'Update your SAM CLI.' )
123
-
124
- const recommendation : string =
125
- validationResult . validation === SamCliVersionValidation . VersionTooHigh
126
- ? recommendationUpdateToolkit
127
- : recommendationUpdateSamCli
123
+ let recommendation : string
124
+
125
+ switch ( validationResult . validation ) {
126
+ case SamCliVersionValidation . VersionTooHigh :
127
+ recommendation = localize ( 'AWS.sam.updateToolkit' , 'Update {0} Toolkit.' , getIdeProperties ( ) . company )
128
+ break
129
+ case SamCliVersionValidation . Version185Win :
130
+ return win185msg
131
+ case SamCliVersionValidation . VersionNotParseable : {
132
+ if ( process . platform === 'win32' ) {
133
+ return win185msg
134
+ }
135
+ return localize ( 'AWS.sam.installSam' , 'SAM CLI failed to run.' )
136
+ }
137
+ default :
138
+ recommendation = localize ( 'AWS.sam.updateSam' , 'Update SAM CLI.' )
139
+ break
140
+ }
128
141
129
142
return localize (
130
- 'AWS.samcli.notification.version .invalid' ,
131
- 'Your SAM CLI version {0} does not meet requirements ({1} ≤ version < {2}). {3}' ,
143
+ 'AWS.sam .invalid' ,
144
+ 'SAM CLI {0} is not in required range ({1} ≤ version < {2}). {3}' ,
132
145
validationResult . version ,
133
146
minSamCliVersion ,
134
147
maxSamCliVersionExclusive ,
135
148
recommendation
136
149
)
137
150
}
138
151
139
- function makeVersionValidationActions ( validation : SamCliVersionValidation ) : SamCliValidationNotificationAction [ ] {
152
+ function getActions ( validation : SamCliVersionValidation ) : SamCliValidationNotificationAction [ ] {
140
153
const actions : SamCliValidationNotificationAction [ ] = [ ]
141
154
142
155
if ( validation === SamCliVersionValidation . VersionTooHigh ) {
0 commit comments