Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to new azure-sdk-for-js #2257

Merged
merged 8 commits into from
Aug 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions gulpfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
// tslint:disable:typedef
// tslint:disable:no-unsafe-any

import * as msRest from '@azure/ms-rest-js';
import * as fse from 'fs-extra';
import * as gulp from 'gulp';
import * as chmod from 'gulp-chmod';
Expand All @@ -18,10 +19,9 @@ import * as filter from 'gulp-filter';
import * as os from 'os';
import * as path from 'path';
import * as request from 'request';
import * as requestP from 'request-promise';
import * as buffer from 'vinyl-buffer';
import * as source from 'vinyl-source-stream';
import { gulp_installAzureAccount, gulp_installVSCodeExtension, gulp_webpack } from 'vscode-azureextensiondev';
import { gulp_installVSCodeExtension, gulp_webpack } from 'vscode-azureextensiondev';

async function prepareForWebpack(): Promise<void> {
const mainJsPath: string = path.join(__dirname, 'main.js');
Expand All @@ -34,9 +34,8 @@ async function prepareForWebpack(): Promise<void> {

let downloadLink;
async function getFuncLink() {
// tslint:disable-next-line:no-any
const body = await <any>requestP('https://aka.ms/V00v5v');
const cliFeed = JSON.parse(body);
const client = new msRest.ServiceClient();
const cliFeed = (await client.sendRequest({ method: 'GET', url: 'https://aka.ms/V00v5v' })).parsedBody;
const version = cliFeed.tags['v3-prerelease'].release;
console.log(`Func cli feed version: ${version}`);
const cliRelease = cliFeed.releases[version].standaloneCli.find((rel) => {
Expand Down Expand Up @@ -80,9 +79,13 @@ function installFuncCli() {
}

async function gulp_installPythonExtension() {
return gulp_installVSCodeExtension('ms-python', 'python');
return gulp_installVSCodeExtension('ms-python', 'python', true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why change this to use Insiders only?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Azure Account extension stuff is a part of VS Code 1.48 (see this comment), so we have to run tests on insiders until 1.48 goes stable

}

async function gulp_installInsidersAzureAccount(): Promise<void> {
return gulp_installVSCodeExtension('ms-vscode', 'azure-account', true);
}

exports['webpack-dev'] = gulp.series(prepareForWebpack, () => gulp_webpack('development'));
exports['webpack-prod'] = gulp.series(prepareForWebpack, () => gulp_webpack('production'));
exports.preTest = gulp.series(gulp_installAzureAccount, gulp_installPythonExtension, getFuncLink, installFuncCli);
exports.preTest = gulp.series(gulp_installInsidersAzureAccount, gulp_installPythonExtension, getFuncLink, installFuncCli);
832 changes: 596 additions & 236 deletions package-lock.json

Large diffs are not rendered by default.

32 changes: 15 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"icon": "resources/azure-functions.png",
"aiKey": "AIF-d9b70cd4-b9f9-4d70-929b-a071c400b217",
"engines": {
"vscode": "^1.40.0"
"vscode": "^1.48.0"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -1025,13 +1025,12 @@
"@types/p-retry": "^3.0.1",
"@types/ps-tree": "^1.1.0",
"@types/request": "2.0.7",
"@types/request-promise": "4.1.38",
"@types/semver": "^5.5.0",
"@types/vscode": "1.40.0",
"@types/vscode": "1.47.0",
"@types/websocket": "^1.0.0",
"@types/xml2js": "^0.4.5",
"@types/xregexp": "^3.0.30",
"azure-arm-resource": "^3.0.0-preview",
"@azure/arm-resources": "^3.0.0",
"copy-webpack-plugin": "^5.1.1",
"glob": "^7.1.6",
"gulp": "^4.0.2",
Expand All @@ -1041,39 +1040,38 @@
"mocha": "^7.1.1",
"mocha-junit-reporter": "^1.23.3",
"mocha-multi-reporters": "^1.1.7",
"request": "^2.88.2",
"ts-node": "^7.0.1",
"tslint": "^5.20.1",
"tslint-microsoft-contrib": "^6.2.0",
"typescript": "^3.8.3",
"vinyl-buffer": "^1.0.1",
"vinyl-source-stream": "^2.0.0",
"vsce": "^1.71.0",
"vscode-azureextensiondev": "^0.4.0",
"vscode-azureextensiondev": "^0.5.0",
"vscode-test": "^1.3.0",
"webpack": "^4.41.5",
"webpack-cli": "^3.3.10"
},
"dependencies": {
"azure-arm-appinsights": "^2.1.0",
"azure-arm-cosmosdb": "^1.1.2",
"azure-arm-eventhub": "^3.2.0",
"azure-arm-sb": "^2.3.0-preview",
"azure-arm-storage": "^4.0.0",
"azure-arm-website": "^5.3.0",
"@azure/arm-appinsights": "^2.1.0",
"@azure/arm-appservice": "^6.0.0",
"@azure/arm-cosmosdb": "^9.0.0",
"@azure/arm-eventhub": "^3.2.0",
"@azure/arm-servicebus": "^3.2.0",
"@azure/arm-storage": "^15.0.0",
"@azure/ms-rest-js": "^2.0.7",
"azure-storage": "^2.10.3",
"extract-zip": "^1.6.6",
"fs-extra": "^4.0.2",
"ms-rest": "^2.5.3",
"ms-rest-azure": "^2.3.1",
"opn": "^6.0.0",
"portfinder": "^1.0.23",
"p-retry": "^4.1.0",
"ps-tree": "^1.1.1",
"request-promise": "^4.2.4",
"semver": "^5.7.1",
"vscode-azureappservice": "^0.64.0",
"vscode-azureextensionui": "^0.33.8",
"vscode-azurekudu": "^0.1.8",
"vscode-azureappservice": "^0.65.0",
"vscode-azureextensionui": "^0.34.0",
"vscode-azurekudu": "^0.2.0",
"vscode-nls": "^4.1.1",
"websocket": "^1.0.29",
"xml2js": "^0.4.19",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { CosmosDBManagementClient, CosmosDBManagementModels } from 'azure-arm-cosmosdb';
import { CosmosDBManagementClient, CosmosDBManagementModels } from '@azure/arm-cosmosdb';
import { createAzureClient } from 'vscode-azureextensionui';
import { getResourceGroupFromId } from '../../../../utils/azure';
import { nonNullProp } from '../../../../utils/nonNull';
Expand All @@ -13,7 +13,7 @@ import { ICosmosDBWizardContext } from './ICosmosDBWizardContext';

export class CosmosDBConnectionCreateStep extends AzureConnectionCreateStepBase<IBindingWizardContext & ICosmosDBWizardContext> {
public async getConnection(context: ICosmosDBWizardContext): Promise<IConnection> {
const databaseAccount: CosmosDBManagementModels.DatabaseAccount = nonNullProp(context, 'databaseAccount');
const databaseAccount: CosmosDBManagementModels.DatabaseAccountGetResults = nonNullProp(context, 'databaseAccount');
const name: string = nonNullProp(databaseAccount, 'name');

const client: CosmosDBManagementClient = createAzureClient(context, CosmosDBManagementClient);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { CosmosDBManagementClient } from 'azure-arm-cosmosdb';
import { CosmosDBManagementClient } from '@azure/arm-cosmosdb';
import { AzureWizardPromptStep, createAzureClient } from 'vscode-azureextensionui';
import { localize } from '../../../../localize';
import { promptForResource } from '../../../../utils/azure';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { CosmosDBManagementModels } from 'azure-arm-cosmosdb';
import { CosmosDBManagementModels } from '@azure/arm-cosmosdb';
import { ISubscriptionWizardContext } from 'vscode-azureextensionui';

export interface ICosmosDBWizardContext extends ISubscriptionWizardContext {
databaseAccount?: CosmosDBManagementModels.DatabaseAccount;
databaseAccount?: CosmosDBManagementModels.DatabaseAccountGetResults;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { EventHubManagementClient, EventHubManagementModels } from 'azure-arm-eventhub';
import { EventHubManagementClient, EventHubManagementModels } from '@azure/arm-eventhub';
import { AzureWizardPromptStep, createAzureClient } from 'vscode-azureextensionui';
import { localize } from '../../../../localize';
import { IBaseResourceWithName, promptForResource } from '../../../../utils/azure';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { EventHubManagementClient, EventHubManagementModels } from 'azure-arm-eventhub';
import { EventHubManagementClient, EventHubManagementModels } from '@azure/arm-eventhub';
import { createAzureClient } from 'vscode-azureextensionui';
import { nonNullProp } from '../../../../utils/nonNull';
import { IBindingWizardContext } from '../../IBindingWizardContext';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { EventHubManagementClient, EventHubManagementModels } from 'azure-arm-eventhub';
import { EventHubManagementClient, EventHubManagementModels } from '@azure/arm-eventhub';
import { AzureWizardPromptStep, createAzureClient } from 'vscode-azureextensionui';
import { localize } from '../../../../localize';
import { promptForResource } from '../../../../utils/azure';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { EventHubManagementClient, EventHubManagementModels } from 'azure-arm-eventhub';
import { EventHubManagementClient, EventHubManagementModels } from '@azure/arm-eventhub';
import { AzureWizardPromptStep, createAzureClient } from 'vscode-azureextensionui';
import { localize } from '../../../../localize';
import { getResourceGroupFromId, promptForResource } from '../../../../utils/azure';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { ServiceBusManagementModels } from 'azure-arm-sb';
import { ServiceBusManagementModels } from '@azure/arm-servicebus';
import { ISubscriptionWizardContext } from 'vscode-azureextensionui';

export interface IServiceBusWizardContext extends ISubscriptionWizardContext {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { ServiceBusManagementClient, ServiceBusManagementModels } from 'azure-arm-sb';
import { ServiceBusManagementClient, ServiceBusManagementModels } from '@azure/arm-servicebus';
import { createAzureClient } from 'vscode-azureextensionui';
import { localize } from '../../../../localize';
import { getResourceGroupFromId } from '../../../../utils/azure';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { ServiceBusManagementClient } from 'azure-arm-sb';
import { ServiceBusManagementClient } from '@azure/arm-servicebus';
import { AzureWizardPromptStep, createAzureClient } from 'vscode-azureextensionui';
import { localize } from '../../../../localize';
import { promptForResource } from '../../../../utils/azure';
Expand Down
2 changes: 1 addition & 1 deletion src/commands/appSettings/downloadAppSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { WebSiteManagementModels } from "azure-arm-website";
import { WebSiteManagementModels } from "@azure/arm-appservice";
import * as fse from 'fs-extra';
import * as vscode from 'vscode';
import { AppSettingsTreeItem, IAppSettingsClient } from "vscode-azureappservice";
Expand Down
2 changes: 1 addition & 1 deletion src/commands/appSettings/getLocalSettingsFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { tryGetFunctionProjectRoot } from "../createNewProject/verifyIsProject";
*/
export async function getLocalSettingsFile(message: string, workspacePath?: string): Promise<string> {
// tslint:disable-next-line: strict-boolean-expressions
const folders: WorkspaceFolder[] = workspace.workspaceFolders || [];
const folders: readonly WorkspaceFolder[] = workspace.workspaceFolders || [];
if (workspacePath || folders.length === 1) {
workspacePath = workspacePath || folders[0].uri.fsPath;
const projectPath: string | undefined = await tryGetFunctionProjectRoot(workspacePath, true /* suppressPrompt */);
Expand Down
2 changes: 1 addition & 1 deletion src/commands/appSettings/uploadAppSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { WebSiteManagementModels } from "azure-arm-website";
import { WebSiteManagementModels } from "@azure/arm-appservice";
import * as fse from 'fs-extra';
import * as vscode from 'vscode';
import { AppSettingsTreeItem, IAppSettingsClient } from "vscode-azureappservice";
Expand Down
2 changes: 1 addition & 1 deletion src/commands/createFunctionApp/FunctionAppCreateStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { WebSiteManagementClient, WebSiteManagementModels as SiteModels } from 'azure-arm-website';
import { WebSiteManagementClient, WebSiteManagementModels as SiteModels } from '@azure/arm-appservice';
import { Progress } from 'vscode';
import { SiteClient, WebsiteOS } from 'vscode-azureappservice';
import { AzureWizardExecuteStep, createAzureClient, parseError } from 'vscode-azureextensionui';
Expand Down
2 changes: 1 addition & 1 deletion src/commands/createNewProject/OpenFolderStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class OpenFolderStep extends AzureWizardExecuteStep<IProjectWizardContext

public async execute(context: IProjectWizardContext): Promise<void> {
// tslint:disable-next-line:strict-boolean-expressions
const openFolders: WorkspaceFolder[] = workspace.workspaceFolders || [];
const openFolders: readonly WorkspaceFolder[] = workspace.workspaceFolders || [];
if (context.openBehavior === 'AddToWorkspace' && openFolders.length === 0) {
// no point in adding to an empty workspace
context.openBehavior = 'OpenInCurrentWindow';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { HttpOperationResponse } from '@azure/ms-rest-js';
import * as fse from 'fs-extra';
import * as path from 'path';
import { Progress } from 'vscode';
import * as xml2js from 'xml2js';
import { localize } from '../../../localize';
import { confirmOverwriteFile } from "../../../utils/fs";
import { requestUtils } from '../../../utils/requestUtils';
Expand Down Expand Up @@ -97,43 +97,24 @@ export class PowerShellProjectCreateStep extends ScriptProjectCreateStep {
});

try {
const xmlResult: string = await this.getPSGalleryAzModuleInfo();
const versionResult: string = await this.parseLatestAzModuleVersion(xmlResult);
const response: HttpOperationResponse = await requestUtils.sendRequestWithTimeout({ method: 'GET', url: this.azModuleGalleryUrl });
const versionResult: string = this.parseLatestAzModuleVersion(response);
const [major]: string[] = versionResult.split('.');
return parseInt(major);
} catch {
return undefined;
}
}

private async getPSGalleryAzModuleInfo(): Promise<string> {
const request: requestUtils.Request = await requestUtils.getDefaultRequestWithTimeout(this.azModuleGalleryUrl, undefined, 'GET');
return await requestUtils.sendRequest(request);
}

private async parseLatestAzModuleVersion(azModuleInfo: string): Promise<string> {
const moduleInfo: string = await new Promise((
resolve: (ret: string) => void,
// tslint:disable-next-line:no-any
rejects: (reason: any) => void): void => {
// tslint:disable-next-line:no-any
xml2js.parseString(azModuleInfo, { explicitArray: false }, (err: any, result: string): void => {
if (err) {
rejects(err);
} else {
resolve(result);
}
});
});

// tslint:disable-next-line:no-string-literal no-unsafe-any
if (moduleInfo['feed'] && moduleInfo['feed']['entry'] && Array.isArray(moduleInfo['feed']['entry'])) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How come you were able to get rid of this logic completely?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new sdk will automatically parse xml and return it in response.parsedBody, so I changed to use that instead of manually parsing with "xml2js" ourselves. When I went to test it, the parsed object was slightly different, not entirely sure why. The new sdk still uses "xml2js" under the covers, but maybe they pass in different options?

// tslint:disable-next-line:no-string-literal no-unsafe-any
const releasedVersions: string[] = moduleInfo['feed']['entry']
// tslint:disable-next-line:no-string-literal no-unsafe-any
.filter(entry => entry['m:properties']['d:IsPrerelease']['_'] === 'false')
// tslint:disable-next-line:no-string-literal no-unsafe-any
private parseLatestAzModuleVersion(response: HttpOperationResponse): string {
// tslint:disable-next-line: no-any
const moduleInfo: any = response.parsedBody;
// tslint:disable: no-unsafe-any
if (moduleInfo?.entry && Array.isArray(moduleInfo.entry)) {
const releasedVersions: string[] = moduleInfo.entry
.filter(entry => entry['m:properties']['d:IsPrerelease']._ === 'false')
.map(entry => entry['m:properties']['d:Version']);
// tslint:enable: no-unsafe-any

// Select the latest version
if (releasedVersions.length > 0) {
Expand All @@ -143,6 +124,6 @@ export class PowerShellProjectCreateStep extends ScriptProjectCreateStep {
}

// If no version is found, throw exception
throw new Error(`Failed to parse latest Az module version ${azModuleInfo}`);
throw new Error(`Failed to parse latest Az module version ${response.bodyAsText}`);
}
}
2 changes: 1 addition & 1 deletion src/commands/deploy/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { WebSiteManagementModels } from 'azure-arm-website';
import { WebSiteManagementModels } from '@azure/arm-appservice';
import * as vscode from 'vscode';
import { deploy as innerDeploy, getDeployFsPath, getDeployNode, IDeployContext, IDeployPaths, showDeployConfirmation } from 'vscode-azureappservice';
import { IActionContext } from 'vscode-azureextensionui';
Expand Down
2 changes: 1 addition & 1 deletion src/commands/deploy/verifyAppSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { WebSiteManagementModels } from 'azure-arm-website';
import { WebSiteManagementModels } from '@azure/arm-appservice';
import * as vscode from 'vscode';
import { SiteClient } from 'vscode-azureappservice';
import { DialogResponses, IActionContext } from 'vscode-azureextensionui';
Expand Down
Loading