This repository was archived by the owner on Jun 30, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +52
-2
lines changed Expand file tree Collapse file tree 6 files changed +52
-2
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ The CLI performs the following operations on your behalf:
2424> Your Virtual Assistant must have been deployed using the [ deployment tutorial] ( /docs/tutorials/assistantandskilldeploymentsteps.md ) before using the ` botskills ` CLI as it relies on the Dispatch models being available and a deployed Bot for authentication connection information.
2525
2626## Prerequisites
27+ - Install the [ Azure Command Line Tools (CLI)] ( https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-windows?view=azure-cli-latest )
2728- [ Node.js] ( https://nodejs.org/ ) version 10.8 or higher
2829- Install the Dispatch, LUDown and LUISGen CLI tools
2930
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ import {
1414 IOauthConnection ,
1515 IScopeManifest ,
1616 ISkillManifest } from '../models' ;
17- import { ChildProcessUtils } from './' ;
17+ import { ChildProcessUtils , isValidAzVersion } from './' ;
1818
1919export class AuthenticationUtils {
2020 public childProcessUtils : ChildProcessUtils ;
@@ -95,6 +95,13 @@ export class AuthenticationUtils {
9595 } ] ;
9696 }
9797
98+ private async validateAzVersion ( logger : ILogger ) : Promise < void > {
99+ // Validating the version of az that the user has (due to preview tag issue)
100+ if ( await isValidAzVersion ( ) ) {
101+ logger . warning ( `This az version may contain issues during the execution of internal az commands` ) ;
102+ }
103+ }
104+
98105 // tslint:disable-next-line:max-func-body-length export-name
99106 public async authenticate ( configuration : IConnectConfiguration , manifest : ISkillManifest , logger : ILogger ) : Promise < boolean > {
100107 let currentCommand : string [ ] = [ ] ;
@@ -105,6 +112,7 @@ export class AuthenticationUtils {
105112 const aadConfig : IAuthenticationConnection | undefined = manifest . authenticationConnections . find (
106113 ( connection : IAuthenticationConnection ) => connection . serviceProviderId === 'Azure Active Directory v2' ) ;
107114 if ( aadConfig ) {
115+ this . validateAzVersion ( logger ) ;
108116 logger . message ( 'Configuring Azure AD connection ...' ) ;
109117
110118 let connectionName : string = aadConfig . id ;
Original file line number Diff line number Diff line change 1+ /**
2+ * Copyright(c) Microsoft Corporation.All rights reserved.
3+ * Licensed under the MIT License.
4+ */
5+
6+ import { gte } from 'semver' ;
7+ import { ChildProcessUtils } from './childProcessUtils' ;
8+
9+ const azPreviewMessage : string = `Command group 'bot' is in preview. It may be changed/removed in a future release.\r\n` ;
10+
11+ /**
12+ * @returns Returns if it is a preview message (az version greater than 2.0.66)
13+ */
14+ export function isAzPreviewMessage ( message : string ) : boolean {
15+ return message === azPreviewMessage ;
16+ }
17+
18+ /**
19+ * @returns Returns if it is a valid azure-cli version (lower than 2.0.66)
20+ */
21+ const childProcess : ChildProcessUtils = new ChildProcessUtils ( ) ;
22+ // tslint:disable-next-line:export-name
23+ export async function isValidAzVersion ( ) : Promise < boolean > {
24+ const azVersionCommand : string [ ] = [ 'az' , '--version' ] ;
25+ const azVersion : string = await childProcess . tryExecute ( azVersionCommand ) ;
26+ const azVersionArr : string | undefined = azVersion . split ( '\r\n' )
27+ . find ( ( val : string ) => {
28+ return val . includes ( 'azure-cli' ) ;
29+ } ) ;
30+ if ( azVersionArr ) {
31+ const azVersionNum : string = azVersionArr . split ( ' ' )
32+ . filter ( ( elem : string ) => elem ) [ 1 ] ;
33+
34+ return gte ( azVersionNum , '2.0.67' ) ;
35+ }
36+
37+ return false ;
38+ }
Original file line number Diff line number Diff line change 55
66import * as child_process from 'child_process' ;
77import { join } from 'path' ;
8+ import { isAzPreviewMessage } from './' ;
89
910export class ChildProcessUtils {
1011
@@ -48,7 +49,7 @@ export class ChildProcessUtils {
4849 child_process . exec (
4950 `${ command . join ( ' ' ) } ` ,
5051 ( err : child_process . ExecException | null , stdout : string , stderr : string ) => {
51- if ( stderr ) {
52+ if ( stderr && ! isAzPreviewMessage ( stderr ) ) {
5253 pReject ( stderr ) ;
5354 }
5455 pResolve ( stdout ) ;
Original file line number Diff line number Diff line change 33 * Licensed under the MIT License.
44 */
55
6+ export { isAzPreviewMessage , isValidAzVersion } from './azUtils' ;
67export { ChildProcessUtils } from './childProcessUtils' ;
78export { AuthenticationUtils } from './authenticationUtils' ;
89export { sanitizePath , wrapPathWithQuotes } from './sanitizationUtils' ;
Original file line number Diff line number Diff line change @@ -129,6 +129,7 @@ https://github.com/microsoft/botframework-solutions/blob/master/docs/howto/assis
129129 logger : new TestLogger ( )
130130 } ;
131131
132+ sandbox . replace ( authenticationUtils , "validateAzVersion" , ( logger ) => { } ) ;
132133 // Mock the execution of az bot authsetting list (listAuthSettingsCommand)
133134 this . callback . onCall ( 0 ) . returns ( Promise . resolve ( emptyAzureAuthSettings ) ) ;
134135 // Mock the execution of az ad app show (azureAppShowCommand)
You can’t perform that action at this time.
0 commit comments