Skip to content

Commit ffb2060

Browse files
authored
Enable TS strict mode (#553)
* Clear some of the easier errors * Major improvements in nullability * Redo telemetry a bit * Fix the last nullability error * Trim tsconfig a bit * New nullability fixes * Fix some errors and logic flaws * Handle filtered sessions correctly * Handle no suitable app service * Better service connection progress notification * Fix always cancelling after checking in * Fix getting commit * Move updateScmType to bottom * Consistency * Remove duplicate repositoryName * Formatting * Rethrow errors * Add separate notification for pushing * Fetch commit from a fresh HEAD * Add quick pick to create new project * Fix GitHub integration * Get tests working again * Actually compile the tests ✌️ * deepStrictEqual
1 parent 772fe42 commit ffb2060

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+987
-1035
lines changed

.azure-pipelines/common-steps.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,11 @@ steps:
1818
# echo no-op
1919
# displayName: Generate service-schema.json
2020

21-
- script: npm run unittest
22-
displayName: Run unit tests
23-
2421
- script: Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
2522
displayName: Start xvfb
2623

2724
- script: npm run test
28-
displayName: Run integration tests
25+
displayName: Run tests
2926
env:
3027
DISPLAY: ':99.0'
3128

package-lock.json

Lines changed: 8 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,9 @@
134134
"vscode:prepublish": "npm run compile",
135135
"compile": "webpack --mode production --progress --color",
136136
"compile:dev": "webpack --mode development --progress --color",
137+
"compile:test": "tsc --project ./tsconfig.test.json",
137138
"watch": "webpack --mode development --progress --color --watch",
138-
"compile:test": "npm run compile:dev && tsc -p ./",
139-
"test": "npm run compile:test && node ./out/test/runTest.js",
140-
"unittest": "npm run compile:test && mocha -u tdd out/unittest/**/*.js"
139+
"test": "npm run compile:test && node ./out/test/runTest.js"
141140
},
142141
"devDependencies": {
143142
"@types/fs-extra": "4.0.5",
@@ -157,13 +156,12 @@
157156
"ts-loader": "^8.0.14",
158157
"ts-node": "7.0.1",
159158
"tslint": "5.8.0",
160-
"typescript": "^4.1.0",
159+
"typescript": "~5.2.2",
161160
"webpack": "^5.76.0",
162161
"webpack-cli": "^4.4.0"
163162
},
164163
"dependencies": {
165164
"@azure/arm-appservice": "^6.1.0",
166-
"@azure/arm-resources": "^4.0.0",
167165
"@azure/arm-subscriptions": "^3.0.0",
168166
"@azure/ms-rest-azure-env": "^2.0.0",
169167
"@azure/ms-rest-nodeauth": "^3.0.6",

src/configure/activate.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import { telemetryHelper } from '../helpers/telemetryHelper';
55

66
export async function activateConfigurePipeline(): Promise<void> {
77
vscode.commands.registerCommand('azure-pipelines.configure-pipeline', async () => {
8-
telemetryHelper.initialize('configure-pipeline');
9-
await telemetryHelper.callWithTelemetryAndErrorHandling(async () => {
8+
await telemetryHelper.callWithTelemetryAndErrorHandling('azurePipelines.configure-pipeline', async () => {
109
await configurePipeline();
1110
});
1211
});

src/configure/clients/azure/appServiceClient.ts

Lines changed: 30 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,81 @@
11
import { v4 as uuid } from 'uuid';
2-
import { ResourceManagementModels } from '@azure/arm-resources';
32
import { WebSiteManagementClient, WebSiteManagementModels } from '@azure/arm-appservice';
43
import { TokenCredentialsBase } from '@azure/ms-rest-nodeauth';
54

6-
import { AzureResourceClient } from './azureResourceClient';
7-
import { WebAppKind, ParsedAzureResourceId } from '../../model/models';
5+
import { WebAppKind, ValidatedSite } from '../../model/models';
86
import { Messages } from '../../../messages';
97

10-
export class AppServiceClient extends AzureResourceClient {
8+
export class AppServiceClient {
119

12-
private static resourceType = 'Microsoft.Web/sites';
1310
private webSiteManagementClient: WebSiteManagementClient;
1411
private tenantId: string;
1512
private portalUrl: string;
1613

1714
constructor(credentials: TokenCredentialsBase, tenantId: string, portalUrl: string, subscriptionId: string) {
18-
super(credentials, subscriptionId);
1915
this.webSiteManagementClient = new WebSiteManagementClient(credentials, subscriptionId);
2016
this.tenantId = tenantId;
2117
this.portalUrl = portalUrl;
2218
}
2319

24-
public async getAppServiceResource(resourceId: string): Promise<ResourceManagementModels.GenericResource> {
25-
let parsedResourceId: ParsedAzureResourceId = new ParsedAzureResourceId(resourceId);
26-
return await this.webSiteManagementClient.webApps.get(parsedResourceId.resourceGroup, parsedResourceId.resourceName);
27-
}
28-
29-
public async GetAppServices(filterForResourceKind: WebAppKind): Promise<ResourceManagementModels.ResourceListResult> {
30-
let resourceList = await this.getResourceList(AppServiceClient.resourceType);
31-
if (!!filterForResourceKind) {
32-
resourceList = resourceList.filter(resource => resource.kind === filterForResourceKind);
33-
}
34-
35-
return resourceList;
20+
public async getAppServices(filterForResourceKind: WebAppKind): Promise<WebSiteManagementModels.Site[]> {
21+
const sites = await this.webSiteManagementClient.webApps.list();
22+
return sites.filter(site => site.kind === filterForResourceKind);
3623
}
3724

3825
public async getDeploymentCenterUrl(resourceId: string): Promise<string> {
3926
return `${this.portalUrl}/#@${this.tenantId}/resource/${resourceId}/vstscd`;
4027
}
4128

42-
public async getAzurePipelineUrl(resourceId: string): Promise<string> {
43-
let metadata = await this.getAppServiceMetadata(resourceId);
44-
if (metadata.properties['VSTSRM_BuildDefinitionWebAccessUrl']) {
29+
public async getAzurePipelineUrl(site: ValidatedSite): Promise<string> {
30+
const metadata = await this.getAppServiceMetadata(site);
31+
if (metadata.properties?.['VSTSRM_BuildDefinitionWebAccessUrl']) {
4532
return metadata.properties['VSTSRM_BuildDefinitionWebAccessUrl'];
4633
}
4734

4835
throw new Error(Messages.cannotFindPipelineUrlInMetaDataException);
4936
}
5037

51-
public async getAppServiceConfig(resourceId: string): Promise<WebSiteManagementModels.SiteConfigResource> {
52-
let parsedResourceId: ParsedAzureResourceId = new ParsedAzureResourceId(resourceId);
53-
return this.webSiteManagementClient.webApps.getConfiguration(parsedResourceId.resourceGroup, parsedResourceId.resourceName);
38+
public async getAppServiceConfig(site: ValidatedSite): Promise<WebSiteManagementModels.SiteConfigResource> {
39+
return this.webSiteManagementClient.webApps.getConfiguration(site.resourceGroup, site.name);
5440
}
5541

56-
public async updateScmType(resourceId: string): Promise<WebSiteManagementModels.SiteConfigResource> {
57-
let siteConfig = await this.getAppServiceConfig(resourceId);
42+
public async updateScmType(site: ValidatedSite): Promise<WebSiteManagementModels.SiteConfigResource> {
43+
const siteConfig = await this.getAppServiceConfig(site);
5844
siteConfig.scmType = ScmType.VSTSRM;
59-
let parsedResourceId: ParsedAzureResourceId = new ParsedAzureResourceId(resourceId);
60-
return this.webSiteManagementClient.webApps.updateConfiguration(parsedResourceId.resourceGroup, parsedResourceId.resourceName, siteConfig);
45+
return this.webSiteManagementClient.webApps.updateConfiguration(site.resourceGroup, site.name, siteConfig);
6146
}
6247

63-
public async getAppServiceMetadata(resourceId: string): Promise<WebSiteManagementModels.StringDictionary> {
64-
let parsedResourceId: ParsedAzureResourceId = new ParsedAzureResourceId(resourceId);
65-
return this.webSiteManagementClient.webApps.listMetadata(parsedResourceId.resourceGroup, parsedResourceId.resourceName);
48+
public async getAppServiceMetadata(site: ValidatedSite): Promise<WebSiteManagementModels.StringDictionary> {
49+
return this.webSiteManagementClient.webApps.listMetadata(site.resourceGroup, site.name);
6650
}
6751

68-
public async updateAppServiceMetadata(resourceId: string, metadata: WebSiteManagementModels.StringDictionary): Promise<WebSiteManagementModels.StringDictionary> {
69-
let parsedResourceId: ParsedAzureResourceId = new ParsedAzureResourceId(resourceId);
70-
return this.webSiteManagementClient.webApps.updateMetadata(parsedResourceId.resourceGroup, parsedResourceId.resourceName, metadata);
52+
public async updateAppServiceMetadata(site: ValidatedSite, metadata: WebSiteManagementModels.StringDictionary): Promise<WebSiteManagementModels.StringDictionary> {
53+
return this.webSiteManagementClient.webApps.updateMetadata(site.resourceGroup, site.name, metadata);
7154
}
7255

73-
public async publishDeploymentToAppService(resourceId: string, buildDefinitionUrl: string, releaseDefinitionUrl: string, triggeredBuildUrl: string): Promise<WebSiteManagementModels.Deployment> {
74-
let parsedResourceId: ParsedAzureResourceId = new ParsedAzureResourceId(resourceId);
75-
56+
public async publishDeploymentToAppService(site: ValidatedSite, buildDefinitionUrl: string, releaseDefinitionUrl: string, triggeredBuildUrl: string): Promise<WebSiteManagementModels.Deployment> {
7657
// create deployment object
77-
let deploymentId = uuid();
78-
let deployment = this.createDeploymentObject(deploymentId, buildDefinitionUrl, releaseDefinitionUrl, triggeredBuildUrl);
79-
return this.webSiteManagementClient.webApps.createDeployment(parsedResourceId.resourceGroup, parsedResourceId.resourceName, deploymentId, deployment);
58+
const deploymentId = uuid();
59+
const deployment = this.createDeploymentObject(deploymentId, buildDefinitionUrl, releaseDefinitionUrl, triggeredBuildUrl);
60+
return this.webSiteManagementClient.webApps.createDeployment(site.resourceGroup, site.name, deploymentId, deployment);
8061
}
8162

8263
private createDeploymentObject(deploymentId: string, buildDefinitionUrl: string, releaseDefinitionUrl: string, triggeredBuildUrl: string): WebSiteManagementModels.Deployment {
83-
let deployment: WebSiteManagementModels.Deployment = {
84-
id: deploymentId,
85-
status: 4,
86-
author: 'VSTS',
87-
deployer: 'VSTS'
88-
};
89-
90-
let deploymentMessage: DeploymentMessage = {
64+
const message: DeploymentMessage = {
9165
type: "CDDeploymentConfiguration",
9266
message: "Successfully set up continuous delivery from VS Code and triggered deployment to Azure Web App.",
9367
VSTSRM_BuildDefinitionWebAccessUrl: `${buildDefinitionUrl}`,
9468
VSTSRM_ConfiguredCDEndPoint: '',
9569
VSTSRM_BuildWebAccessUrl: `${triggeredBuildUrl}`,
9670
};
97-
deployment.message = JSON.stringify(deploymentMessage);
98-
return deployment;
71+
72+
return {
73+
id: deploymentId,
74+
status: 4,
75+
author: 'VSTS',
76+
deployer: 'VSTS',
77+
message: JSON.stringify(message),
78+
};
9979
}
10080
}
10181

src/configure/clients/azure/azureResourceClient.ts

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/configure/clients/devOps/operationsClient.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ export class OperationsClient {
3030
}
3131

3232
const operation = response.result;
33-
if (operation.status === OperationStatus.Succeeded) {
33+
if (operation?.status === OperationStatus.Succeeded) {
3434
return;
3535
}
3636

37-
if (operation.status === OperationStatus.Failed) {
37+
if (operation?.status === OperationStatus.Failed) {
3838
// OperationReference is missing some properties so cast it to any
3939
throw new Error(util.format(Messages.failedToCreateAzureDevOpsProject, (operation as any).detailedMessage));
4040
}

0 commit comments

Comments
 (0)