File tree Expand file tree Collapse file tree 3 files changed +31
-4
lines changed
__tests__/commands/flex/plugins Expand file tree Collapse file tree 3 files changed +31
-4
lines changed Original file line number Diff line number Diff line change @@ -320,6 +320,32 @@ describe('Commands/FlexPluginsStart', () => {
320
320
expect ( cmd . removeLegacyPlugin ) . toHaveBeenCalledTimes ( 1 ) ;
321
321
} ) ;
322
322
323
+ it ( 'should call upgrade notification' , async ( ) => {
324
+ const cmd = await createTest ( FlexPluginsUpgradePlugin ) ( '--yes' ) ;
325
+ mockForDoRun ( cmd ) ;
326
+ // @ts -ignore
327
+ const upgradeNotification = jest . spyOn ( cmd . prints , 'upgradeNotification' ) ;
328
+ jest . spyOn ( cmd , 'pkgVersion' , 'get' ) . mockReturnValue ( 4 ) ;
329
+
330
+ await cmd . doRun ( ) ;
331
+
332
+ expect ( upgradeNotification ) . toHaveBeenCalledTimes ( 1 ) ;
333
+ expect ( upgradeNotification ) . toHaveBeenCalledWith ( true , '4.0.0' ) ;
334
+ } ) ;
335
+
336
+ it ( 'should call upgrade notification without yes flag' , async ( ) => {
337
+ const cmd = await createTest ( FlexPluginsUpgradePlugin ) ( ) ;
338
+ mockForDoRun ( cmd ) ;
339
+ // @ts -ignore
340
+ const upgradeNotification = jest . spyOn ( cmd . prints , 'upgradeNotification' ) ;
341
+ jest . spyOn ( cmd , 'pkgVersion' , 'get' ) . mockReturnValue ( 4 ) ;
342
+
343
+ await cmd . doRun ( ) ;
344
+
345
+ expect ( upgradeNotification ) . toHaveBeenCalledTimes ( 1 ) ;
346
+ expect ( upgradeNotification ) . toHaveBeenCalledWith ( undefined , '4.0.0' ) ;
347
+ } ) ;
348
+
323
349
it ( 'should not call cleanupNodeModules if already latest version' , async ( ) => {
324
350
const cmd = await createTest ( FlexPluginsUpgradePlugin ) ( ) ;
325
351
mockForDoRun ( cmd ) ;
Original file line number Diff line number Diff line change @@ -124,7 +124,8 @@ export default class FlexPluginsUpgradePlugin extends FlexPlugin {
124
124
return ;
125
125
}
126
126
127
- await this . prints . upgradeNotification ( this . _flags . yes ) ;
127
+ const pkgJson = await this . getLatestVersionOfDep ( flexPluginScript , this . _flags . beta ) ;
128
+ await this . prints . upgradeNotification ( this . _flags . yes , pkgJson . version as string ) ;
128
129
129
130
const currentPkgVersion = this . pkgVersion ;
130
131
switch ( currentPkgVersion ) {
@@ -142,7 +143,6 @@ export default class FlexPluginsUpgradePlugin extends FlexPlugin {
142
143
break ;
143
144
}
144
145
145
- const pkgJson = await this . getLatestVersionOfDep ( flexPluginScript , this . _flags . beta ) ;
146
146
const latestVersion = pkgJson ? semver . coerce ( pkgJson . version as string ) ?. major : 0 ;
147
147
if ( currentPkgVersion !== latestVersion ) {
148
148
await this . cleanupNodeModules ( ) ;
Original file line number Diff line number Diff line change @@ -8,8 +8,9 @@ const cracoUpgradeGuideLink = 'https://twilio.com';
8
8
* Upgrade notification
9
9
*/
10
10
// eslint-disable-next-line @typescript-eslint/no-unused-vars
11
- const upgradeNotification = ( logger : Logger ) => async ( skip : boolean ) => {
12
- boxen . warning ( 'You are about to upgrade your plugin to use the latest version of Flex Plugin CLI.' ) ;
11
+ const upgradeNotification = ( logger : Logger ) => async ( skip : boolean , version ?: string ) => {
12
+ const latestVersion = version ? `version ${ version } ` : 'the latest version' ;
13
+ boxen . warning ( `You are about to upgrade your plugin to use ${ latestVersion } of the Flex Plugin CLI.` ) ;
13
14
if ( ! skip ) {
14
15
const answer = await confirm ( 'Please backup your plugin either locally or on GitHub. Do you want to continue?' ) ;
15
16
if ( ! answer ) {
You can’t perform that action at this time.
0 commit comments