Skip to content

Commit

Permalink
A few engineering improvements (#762)
Browse files Browse the repository at this point in the history
1. Update typescript version
1. Update tslint version
    1. One of my favorite new rules is "no-implicit-dependencies" which makes sure you have a dependency listed in "package.json" if you're using it. A month-ish ago we had a problem where the storage package was listed as a devDependency instead of a dependency and this rule would've prevented that
1. Update to next alpha
1. Clean up tasks.json/launch.json
1. Set 'DEBUGTELEMETRY' on launch since gdpr is updated daily now
  • Loading branch information
ejizba committed Oct 23, 2018
1 parent 2e32d31 commit 80142b1
Show file tree
Hide file tree
Showing 34 changed files with 153 additions and 161 deletions.
20 changes: 12 additions & 8 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,39 @@
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceRoot}"
"--extensionDevelopmentPath=${workspaceFolder}"
],
"stopOnEntry": false,
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/out/src/**/*.js"
"${workspaceFolder}/out/src/**/*.js"
],
"preLaunchTask": "npm"
"preLaunchTask": "npm: compile",
"env": {
"DEBUGTELEMETRY": "1"
}
},
{
"name": "Launch Tests",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceRoot}",
"--extensionTestsPath=${workspaceRoot}/out/test"
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test"
],
"stopOnEntry": false,
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/out/test/**/*.js"
"${workspaceFolder}/out/test/**/*.js"
],
"preLaunchTask": "npm",
"preLaunchTask": "npm: compile",
"env": {
"MOCHA_grep": "", // RegExp of tests to run (empty for all)
"MOCHA_enableTimeouts": "0", // Disable time-outs
"DEBUGTELEMETRY": "1",
"NODE_DEBUG": ""
"NODE_DEBUG": "",
"ENABLE_LONG_RUNNING_TESTS": ""
}
}
]
Expand Down
13 changes: 3 additions & 10 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,12 @@
"version": "2.0.0",
"tasks": [
{
"taskName": "npm",
"type": "shell",
"command": "npm",
"type": "npm",
"script": "compile",
"group": {
"kind": "build",
"isDefault": true
},
"args": [
"run",
"compile",
"--loglevel",
"silent"
],
"isBackground": true,
"presentation": {
"reveal": "silent"
Expand All @@ -30,4 +23,4 @@
}
}
]
}
}
11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vscode-azurefunctions",
"displayName": "Azure Functions",
"description": "%extension.description%",
"version": "0.12.0",
"version": "0.12.1-alpha",
"publisher": "ms-azuretools",
"icon": "resources/azure-functions.png",
"aiKey": "AIF-d9b70cd4-b9f9-4d70-929b-a071c400b217",
Expand Down Expand Up @@ -701,27 +701,26 @@
"@types/websocket": "^0.0.37",
"@types/xml2js": "^0.4.2",
"@types/xregexp": "^3.0.29",
"azure-arm-resource": "^3.0.0-preview",
"azure-storage": "^2.8.1",
"gulp": "^3.9.1",
"gulp-decompress": "^2.0.1",
"gulp-download": "^0.0.1",
"mocha": "^2.3.3",
"tslint": "^5.7.0",
"tslint-microsoft-contrib": "5.0.1",
"typescript": "^2.0.3",
"tslint-microsoft-contrib": "5.2.1",
"typescript": "^3.1.3",
"vscode": "^1.0.0",
"vsce": "^1.37.5"
},
"dependencies": {
"azure-arm-cosmosdb": "^1.1.2",
"azure-arm-resource": "^3.0.0-preview",
"azure-arm-sb": "^2.3.0-preview",
"azure-arm-storage": "^3.1.0",
"azure-arm-storage": "^4.0.0",
"azure-arm-website": "^5.3.0",
"clipboardy": "^1.2.2",
"extract-zip": "^1.6.6",
"fs-extra": "^4.0.2",
"ms-rest": "^2.2.2",
"ms-rest-azure": "^2.3.1",
"opn": "^5.2.0",
"portfinder": "^1.0.13",
Expand Down
6 changes: 3 additions & 3 deletions src/DebugProxy.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 { User } from 'azure-arm-website/lib/models';
import { WebSiteManagementModels } from 'azure-arm-website';
import * as EventEmitter from 'events';
import { createServer, Server, Socket } from 'net';
import { OutputChannel } from 'vscode';
Expand All @@ -16,11 +16,11 @@ export class DebugProxy extends EventEmitter {
private _wsconnection: websocket.connection | undefined;
private _client: SiteClient;
private _port: number;
private _publishCredential: User;
private _publishCredential: WebSiteManagementModels.User;
private _keepAlive: boolean;
private _outputChannel: OutputChannel;

constructor(outputChannel: OutputChannel, client: SiteClient, port: number, publishCredential: User) {
constructor(outputChannel: OutputChannel, client: SiteClient, port: number, publishCredential: WebSiteManagementModels.User) {
super();
this._client = client;
this._port = port;
Expand Down
5 changes: 2 additions & 3 deletions src/LocalAppSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { ext } from './extensionVariables';
import { localize } from './localize';
import { getResourceTypeLabel, ResourceType } from './templates/IFunctionSetting';
import * as azUtil from './utils/azure';
import { IResourceResult } from './utils/azure';
import * as fsUtil from './utils/fs';

export interface ILocalAppSettings {
Expand Down Expand Up @@ -40,7 +39,7 @@ export async function promptForAppSetting(actionContext: IActionContext, localSe
}
}

let resourceResult: IResourceResult | undefined;
let resourceResult: azUtil.IResourceResult | undefined;
try {
switch (resourceType) {
case ResourceType.DocumentDB:
Expand Down Expand Up @@ -108,7 +107,7 @@ export async function validateAzureWebJobsStorage(actionContext: IActionContext,
let connectionString: string;

try {
const resourceResult: IResourceResult = await azUtil.promptForStorageAccount(
const resourceResult: azUtil.IResourceResult = await azUtil.promptForStorageAccount(
actionContext,
{
kind: [
Expand Down
13 changes: 6 additions & 7 deletions src/ProjectSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import * as fse from 'fs-extra';
// tslint:disable-next-line:no-require-imports
import opn = require("opn");
import * as path from 'path';
import { MessageItem, QuickPickItem, QuickPickOptions, WorkspaceConfiguration } from "vscode";
import * as vscode from 'vscode';
import { ConfigurationTarget, MessageItem, QuickPickItem, QuickPickOptions, Uri, workspace, WorkspaceConfiguration } from "vscode";
import { DialogResponses, IAzureQuickPickItem, IAzureQuickPickOptions, IAzureUserInput } from 'vscode-azureextensionui';
import { extensionPrefix, ProjectLanguage, projectLanguageSetting, ProjectRuntime, projectRuntimeSetting, TemplateFilter, templateFilterSetting } from './constants';
import { ext } from './extensionVariables';
Expand All @@ -17,12 +16,12 @@ import { localize } from "./localize";
const previewDescription: string = localize('previewDescription', '(Preview)');

export async function updateGlobalSetting<T = string>(section: string, value: T): Promise<void> {
const projectConfiguration: WorkspaceConfiguration = vscode.workspace.getConfiguration(extensionPrefix);
await projectConfiguration.update(section, value, vscode.ConfigurationTarget.Global);
const projectConfiguration: WorkspaceConfiguration = workspace.getConfiguration(extensionPrefix);
await projectConfiguration.update(section, value, ConfigurationTarget.Global);
}

export async function updateWorkspaceSetting<T = string>(section: string, value: T, fsPath: string): Promise<void> {
const projectConfiguration: WorkspaceConfiguration = vscode.workspace.getConfiguration(extensionPrefix, vscode.Uri.file(fsPath));
const projectConfiguration: WorkspaceConfiguration = workspace.getConfiguration(extensionPrefix, Uri.file(fsPath));
await projectConfiguration.update(section, value);
}

Expand Down Expand Up @@ -80,13 +79,13 @@ export async function selectTemplateFilter(projectPath: string, ui: IAzureUserIn
}

export function getGlobalFuncExtensionSetting<T>(key: string): T | undefined {
const projectConfiguration: WorkspaceConfiguration = vscode.workspace.getConfiguration(extensionPrefix);
const projectConfiguration: WorkspaceConfiguration = workspace.getConfiguration(extensionPrefix);
const result: { globalValue?: T } | undefined = projectConfiguration.inspect<T>(key);
return result && result.globalValue;
}

export function getFuncExtensionSetting<T>(key: string, fsPath?: string): T | undefined {
const projectConfiguration: WorkspaceConfiguration = vscode.workspace.getConfiguration(extensionPrefix, fsPath ? vscode.Uri.file(fsPath) : undefined);
const projectConfiguration: WorkspaceConfiguration = workspace.getConfiguration(extensionPrefix, fsPath ? Uri.file(fsPath) : undefined);
return projectConfiguration.get<T>(key);
}

Expand Down
4 changes: 2 additions & 2 deletions 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 { StringDictionary } from "azure-arm-website/lib/models";
import { WebSiteManagementModels } from "azure-arm-website";
import * as fse from 'fs-extra';
import * as vscode from 'vscode';
import { AppSettingsTreeItem, SiteClient } from "vscode-azureappservice";
Expand Down Expand Up @@ -43,7 +43,7 @@ export async function downloadAppSettings(node?: AppSettingsTreeItem): Promise<v
localSettings.Values = {};
}

const remoteSettings: StringDictionary = await client.listApplicationSettings();
const remoteSettings: WebSiteManagementModels.StringDictionary = await client.listApplicationSettings();
if (remoteSettings.properties) {
await confirmOverwriteSettings(remoteSettings.properties, localSettings.Values, localSettingsFileName);
}
Expand Down
4 changes: 2 additions & 2 deletions 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 { StringDictionary } from "azure-arm-website/lib/models";
import { WebSiteManagementModels } from "azure-arm-website";
import * as fse from 'fs-extra';
import * as vscode from 'vscode';
import { AppSettingsTreeItem, SiteClient } from "vscode-azureappservice";
Expand Down Expand Up @@ -41,7 +41,7 @@ export async function uploadAppSettings(node?: AppSettingsTreeItem): Promise<voi
}

if (localSettings.Values) {
const remoteSettings: StringDictionary = await client.listApplicationSettings();
const remoteSettings: WebSiteManagementModels.StringDictionary = await client.listApplicationSettings();
if (!remoteSettings.properties) {
remoteSettings.properties = {};
}
Expand Down
4 changes: 2 additions & 2 deletions src/commands/createFunction/CSharpFunctionCreator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class CSharpFunctionCreator extends FunctionCreatorBase {
super(functionAppPath, template);
}

public async promptForSettings(ui: IAzureUserInput, functionName: string | undefined, functionSettings: { [key: string]: string | undefined; }): Promise<void> {
public async promptForSettings(ui: IAzureUserInput, functionName: string | undefined, functionSettings: { [key: string]: string | undefined }): Promise<void> {
if (!functionName) {
const defaultFunctionName: string | undefined = await fsUtil.getUniqueFsPath(this._functionAppPath, this._template.defaultFunctionName, '.cs');
this._functionName = await ui.showInputBox({
Expand All @@ -39,7 +39,7 @@ export class CSharpFunctionCreator extends FunctionCreatorBase {
}

if (functionSettings.namespace !== undefined) {
this._namespace = <string>functionSettings.namespace;
this._namespace = functionSettings.namespace;
} else {
this._namespace = await ui.showInputBox({
placeHolder: localize('azFunc.namespacePlaceHolder', 'Namespace'),
Expand Down
2 changes: 1 addition & 1 deletion src/commands/createFunction/FunctionCreatorBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ export abstract class FunctionCreatorBase {
* Prompt for any settings that are specific to this creator
* This includes the function name (Since the name could have different restrictions for different languages)
*/
public abstract async promptForSettings(ui: IAzureUserInput, functionName: string | undefined, functionSettings: { [key: string]: string | undefined; }): Promise<void>;
public abstract async promptForSettings(ui: IAzureUserInput, functionName: string | undefined, functionSettings: { [key: string]: string | undefined }): Promise<void>;
public abstract async createFunction(userSettings: { [propertyName: string]: string }, runtime: ProjectRuntime): Promise<string | undefined>;
}
2 changes: 1 addition & 1 deletion src/commands/createFunction/ScriptFunctionCreator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class ScriptFunctionCreator extends FunctionCreatorBase {
}
}

public async createFunction(userSettings: { [propertyName: string]: string; }): Promise<string | undefined> {
public async createFunction(userSettings: { [propertyName: string]: string }): Promise<string | undefined> {
const functionPath: string = path.join(this._functionAppPath, this._functionName);
await fse.ensureDir(functionPath);
await Promise.all(Object.keys(this._template.templateFiles).map(async (fileName: string) => {
Expand Down
15 changes: 7 additions & 8 deletions src/commands/createFunction/createFunction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
import * as fse from 'fs-extra';
import * as path from 'path';
import { isString } from 'util';
import { QuickPickItem } from 'vscode';
import * as vscode from 'vscode';
import { InputBoxOptions, MessageItem, QuickPickItem, Uri, window, workspace } from 'vscode';
import { DialogResponses, IActionContext, IAzureQuickPickItem, TelemetryProperties } from 'vscode-azureextensionui';
import { localSettingsFileName, ProjectLanguage, projectLanguageSetting, ProjectRuntime, projectRuntimeSetting, TemplateFilter } from '../../constants';
import { ext } from '../../extensionVariables';
Expand Down Expand Up @@ -57,7 +56,7 @@ async function promptForBooleanSetting(setting: IFunctionSetting): Promise<strin
}

async function promptForStringSetting(setting: IFunctionSetting): Promise<string> {
const options: vscode.InputBoxOptions = {
const options: InputBoxOptions = {
placeHolder: setting.label,
prompt: setting.description || localize('azFunc.stringSettingPrompt', 'Provide a \'{0}\'', setting.label),
validateInput: (s: string): string | undefined => setting.validateSetting(s),
Expand All @@ -72,11 +71,11 @@ export async function createFunction(
functionAppPath?: string,
templateId?: string,
functionName?: string,
caseSensitiveFunctionSettings?: { [key: string]: string | undefined; },
caseSensitiveFunctionSettings?: { [key: string]: string | undefined },
language?: ProjectLanguage,
runtime?: ProjectRuntime): Promise<void> {

const functionSettings: { [key: string]: string | undefined; } = {};
const functionSettings: { [key: string]: string | undefined } = {};
if (caseSensitiveFunctionSettings) {
Object.keys(caseSensitiveFunctionSettings).forEach((key: string) => functionSettings[key.toLowerCase()] = caseSensitiveFunctionSettings[key]);
}
Expand All @@ -90,7 +89,7 @@ export async function createFunction(
let templateFilter: TemplateFilter;
if (!await isFunctionProject(functionAppPath)) {
const message: string = localize('azFunc.notFunctionApp', 'The selected folder is not a function app project. Initialize Project?');
const result: vscode.MessageItem = await ext.ui.showWarningMessage(message, { modal: true }, DialogResponses.yes, DialogResponses.skipForNow, DialogResponses.cancel);
const result: MessageItem = await ext.ui.showWarningMessage(message, { modal: true }, DialogResponses.yes, DialogResponses.skipForNow, DialogResponses.cancel);
if (result === DialogResponses.yes) {
await createNewProject(actionContext, functionAppPath, undefined, undefined, false);
isNewProject = true;
Expand Down Expand Up @@ -161,8 +160,8 @@ export async function createFunction(

const newFilePath: string | undefined = await functionCreator.createFunction(userSettings, runtime);
if (newFilePath && (await fse.pathExists(newFilePath))) {
const newFileUri: vscode.Uri = vscode.Uri.file(newFilePath);
vscode.window.showTextDocument(await vscode.workspace.openTextDocument(newFileUri));
const newFileUri: Uri = Uri.file(newFilePath);
window.showTextDocument(await workspace.openTextDocument(newFileUri));
}

if (!template.isHttpTrigger) {
Expand Down
5 changes: 2 additions & 3 deletions src/commands/createNewProject/JavaProjectCreator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
import * as fse from 'fs-extra';
import * as os from 'os';
import * as path from 'path';
import * as vscode from 'vscode';
import { InputBoxOptions } from 'vscode';
import { InputBoxOptions, window } from 'vscode';
import { IActionContext } from "vscode-azureextensionui";
import { ProjectRuntime, TemplateFilter } from '../../constants';
import { ext } from '../../extensionVariables';
Expand Down Expand Up @@ -134,7 +133,7 @@ export class JavaProjectCreator extends ProjectCreatorBase {
const functionAppName: string | undefined = await mavenUtils.getFunctionAppNameInPom(pomFilePath);
if (!functionAppName) {
this._javaTargetPath = '<function_build_path>';
vscode.window.showWarningMessage(localize('functionAppNameNotFound', 'Cannot parse the Azure Functions name from pom file, you may need to specify it in the tasks.json.'));
window.showWarningMessage(localize('functionAppNameNotFound', 'Cannot parse the Azure Functions name from pom file, you may need to specify it in the tasks.json.'));
} else {
this._javaTargetPath = `target/azure-functions/${functionAppName}/`;
}
Expand Down
9 changes: 4 additions & 5 deletions src/commands/createNewProject/ScriptProjectCreatorBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import * as path from 'path';
import { gitignoreFileName, hostFileName, localSettingsFileName, ProjectRuntime, proxiesFileName, TemplateFilter } from '../../constants';
import { funcHostCommand, funcHostTaskLabel } from "../../funcCoreTools/funcHostTask";
import { ILocalAppSettings } from '../../LocalAppSettings';
import { confirmOverwriteFile } from "../../utils/fs";
import * as fsUtil from '../../utils/fs';
import { confirmOverwriteFile, writeFormattedJson } from "../../utils/fs";
import { funcWatchProblemMatcher, ProjectCreatorBase } from './IProjectCreator';

// tslint:disable-next-line:no-multiline-string
Expand Down Expand Up @@ -71,7 +70,7 @@ export class ScriptProjectCreatorBase extends ProjectCreatorBase {
const hostJson: {} = {
version: '2.0'
};
await fsUtil.writeFormattedJson(hostJsonPath, hostJson);
await writeFormattedJson(hostJsonPath, hostJson);
}

const localSettingsJsonPath: string = path.join(this.functionAppPath, localSettingsFileName);
Expand All @@ -88,7 +87,7 @@ export class ScriptProjectCreatorBase extends ProjectCreatorBase {
localSettingsJson.Values!.FUNCTIONS_WORKER_RUNTIME = this.functionsWorkerRuntime;
}

await fsUtil.writeFormattedJson(localSettingsJsonPath, localSettingsJson);
await writeFormattedJson(localSettingsJsonPath, localSettingsJson);
}

const proxiesJsonPath: string = path.join(this.functionAppPath, proxiesFileName);
Expand All @@ -98,7 +97,7 @@ export class ScriptProjectCreatorBase extends ProjectCreatorBase {
$schema: 'http://json.schemastore.org/proxies',
proxies: {}
};
await fsUtil.writeFormattedJson(proxiesJsonPath, proxiesJson);
await writeFormattedJson(proxiesJsonPath, proxiesJson);
}

const gitignorePath: string = path.join(this.functionAppPath, gitignoreFileName);
Expand Down
2 changes: 1 addition & 1 deletion src/commands/createNewProject/createNewProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export async function createNewProject(
openFolder: boolean = true,
templateId?: string,
functionName?: string,
caseSensitiveFunctionSettings?: { [key: string]: string | undefined; }): Promise<void> {
caseSensitiveFunctionSettings?: { [key: string]: string | undefined }): Promise<void> {

if (functionAppPath === undefined) {
functionAppPath = await workspaceUtil.selectWorkspaceFolder(ext.ui, localize('azFunc.selectFunctionAppFolderNew', 'Select the folder that will contain your function app'));
Expand Down

0 comments on commit 80142b1

Please sign in to comment.