Skip to content

Commit 11d069d

Browse files
authored
Merge pull request #22 from sfoslund/TSLintingCI
Adding TSLinting to CI
2 parents eb949ec + 00e4e97 commit 11d069d

26 files changed

+264
-235
lines changed

azure-pipelines.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,21 @@ jobs:
5454
workingDirectory: 'sample'
5555
displayName: Build Sample
5656
57+
##### TSLint #####
58+
- job: TSLint
59+
displayName: 'TSLint'
60+
pool:
61+
vmImage: 'vs2017-win2016'
62+
steps:
63+
- task: NodeTool@0
64+
inputs:
65+
versionSpec: '12.x'
66+
displayName: 'Install Node.js'
67+
- bash: |
68+
npm install -g tslint
69+
tslint -c tslint.json 'dotnetcore-acquisition-library/src/**/*.ts' 'dotnetcore-acquisition-extension/src/**/*.ts'
70+
displayName: Run Lint
71+
5772
##### Package and Publish #####
5873
- job: Publish
5974
displayName: 'Package and Publish'

dotnetcore-acquisition-extension/package-lock.json

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

dotnetcore-acquisition-extension/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"dotnetcore-acquisition-library": "file:../dotnetcore-acquisition-library"
3636
},
3737
"devDependencies": {
38+
"@types/chai": "^4.2.7",
3839
"@types/mocha": "5.2.6",
3940
"@types/node": "12.0.0",
4041
"@types/rimraf": "2.0.2",

dotnetcore-acquisition-extension/src/test/functional/DotnetCoreAcquisitionExtension.test.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,32 @@
22
* Copyright (c) Microsoft Corporation. All rights reserved.
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
* ------------------------------------------------------------------------------------------ */
5-
6-
import * as extension from '../../extension';
5+
import * as chai from 'chai';
6+
import { MockExtensionContext } from 'dotnetcore-acquisition-library';
77
import * as fs from 'fs';
88
import * as path from 'path';
99
import * as rimraf from 'rimraf';
1010
import * as vscode from 'vscode';
11-
import { MockExtensionContext } from 'dotnetcore-acquisition-library'
12-
var assert = require('chai').assert;
11+
import * as extension from '../../extension';
12+
const assert = chai.assert;
1313

14-
suite('DotnetCoreAcquisitionExtension End to End', function () {
14+
suite('DotnetCoreAcquisitionExtension End to End', function() {
1515
const storagePath = path.join(__dirname, 'tmp');
1616
const mockState = new MockExtensionContext();
1717
const extensionPath = path.join(__dirname, '/../../..');
1818
let context: vscode.ExtensionContext;
1919

20-
this.beforeAll(async function() {
20+
this.beforeAll(async () => {
2121
context = {
2222
subscriptions: [],
2323
globalStoragePath: storagePath,
2424
globalState: mockState,
25-
extensionPath: extensionPath
25+
extensionPath,
2626
} as any;
2727
extension.activate(context);
2828
});
2929

30-
this.afterEach(async function() {
30+
this.afterEach(async () => {
3131
// Tear down tmp storage for fresh run
3232
await vscode.commands.executeCommand<string>('dotnet.uninstallAll');
3333
rimraf.sync(storagePath);
@@ -40,15 +40,15 @@ suite('DotnetCoreAcquisitionExtension End to End', function () {
4040
});
4141

4242
test('Install Command', async () => {
43-
const version = '2.2'
43+
const version = '2.2';
4444
const dotnetPath = await vscode.commands.executeCommand<string>('dotnet.acquire', version);
4545
assert.exists(dotnetPath);
4646
assert.isTrue(fs.existsSync(dotnetPath!));
4747
assert.include(dotnetPath, version);
4848
}).timeout(20000);
4949

5050
test('Uninstall Command', async () => {
51-
const version = '2.1'
51+
const version = '2.1';
5252
const dotnetPath = await vscode.commands.executeCommand<string>('dotnet.acquire', version);
5353
assert.exists(dotnetPath);
5454
assert.isTrue(fs.existsSync(dotnetPath!));
@@ -60,7 +60,7 @@ suite('DotnetCoreAcquisitionExtension End to End', function () {
6060
test('Install and Uninstall Multiple Versions', async () => {
6161
const versions = ['1.1', '2.2', '1.0'];
6262
let dotnetPaths: string[] = [];
63-
for (var version of versions) {
63+
for (const version of versions) {
6464
const dotnetPath = await vscode.commands.executeCommand<string>('dotnet.acquire', version);
6565
assert.exists(dotnetPath);
6666
assert.include(dotnetPath, version);
@@ -69,8 +69,8 @@ suite('DotnetCoreAcquisitionExtension End to End', function () {
6969
}
7070
}
7171
// All versions are still there after all installs are completed
72-
for (let dotnetPath of dotnetPaths) {
72+
for (const dotnetPath of dotnetPaths) {
7373
assert.isTrue(fs.existsSync(dotnetPath));
7474
}
7575
}).timeout(40000);
76-
});
76+
});

dotnetcore-acquisition-extension/src/test/functional/index.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22
* Copyright (c) Microsoft Corporation. All rights reserved.
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
* ------------------------------------------------------------------------------------------ */
5-
6-
import * as path from 'path';
7-
import * as Mocha from 'mocha';
85
import * as glob from 'glob';
6+
import * as Mocha from 'mocha';
7+
import * as path from 'path';
98

109
export function run(): Promise<void> {
1110
// Create the mocha test
1211
const mocha = new Mocha({
13-
ui: 'tdd'
12+
ui: 'tdd',
1413
});
1514
mocha.useColors(true);
1615

@@ -39,4 +38,4 @@ export function run(): Promise<void> {
3938
}
4039
});
4140
});
42-
}
41+
}

dotnetcore-acquisition-extension/src/test/functional/runTest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ async function main() {
2525
}
2626
}
2727

28-
main();
28+
main();

dotnetcore-acquisition-library/package-lock.json

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

dotnetcore-acquisition-library/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
},
2323
"devDependencies": {
2424
"@types/chai": "^4.2.4",
25+
"@types/chai-as-promised": "^7.1.2",
2526
"@types/mocha": "5.2.6",
2627
"@types/node": "12.0.0",
2728
"@types/request-promise-native": "^1.0.17",

dotnetcore-acquisition-library/src/AcquisitionInvoker.ts

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,10 @@ import { IDotnetInstallationContext } from './IDotnetInstallationContext';
1818

1919
export class AcquisitionInvoker extends IAcquisitionInvoker {
2020
private scriptPath: string;
21-
21+
2222
constructor(scriptPath: string, eventStream: IEventStream) {
2323
super(eventStream);
24-
this.scriptPath = path.join(scriptPath, 'node_modules', 'dotnetcore-acquisition-library', 'install scripts', 'dotnet-install' + this.getScriptEnding());
25-
}
26-
27-
private getInstallCommand(version: string, dotnetInstallDir: string): string {
28-
const args = [
29-
'-InstallDir', `'${dotnetInstallDir}'`, // Use single quotes instead of double quotes (see https://github.com/dotnet/cli/issues/11521)
30-
'-Runtime', 'dotnet',
31-
'-Version', version,
32-
];
33-
34-
return `"${this.scriptPath}" ${args.join(' ')}`;
35-
}
36-
private getScriptEnding(): string {
37-
return os.platform() === 'win32' ? '.cmd' : '.sh';
24+
this.scriptPath = path.join(scriptPath, 'node_modules', 'dotnetcore-acquisition-library', 'install scripts', `dotnet-install${this.getScriptEnding()}`);
3825
}
3926

4027
public installDotnet(installContext: IDotnetInstallationContext): Promise<void> {
@@ -59,4 +46,18 @@ export class AcquisitionInvoker extends IAcquisitionInvoker {
5946
}
6047
});
6148
}
49+
50+
private getInstallCommand(version: string, dotnetInstallDir: string): string {
51+
const args = [
52+
'-InstallDir', `'${dotnetInstallDir}'`, // Use single quotes instead of double quotes (see https://github.com/dotnet/cli/issues/11521)
53+
'-Runtime', 'dotnet',
54+
'-Version', version,
55+
];
56+
57+
return `"${this.scriptPath}" ${args.join(' ')}`;
58+
}
59+
60+
private getScriptEnding(): string {
61+
return os.platform() === 'win32' ? '.cmd' : '.sh';
62+
}
6263
}

dotnetcore-acquisition-library/src/DotnetCoreAcquisitionWorker.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ import * as path from 'path';
99
import rimraf = require('rimraf');
1010
import { Memento } from 'vscode';
1111
import { IEventStream } from './EventStream';
12-
import { DotnetAcquisitionStarted, DotnetUninstallAllStarted, DotnetUninstallAllCompleted } from './EventStreamEvents';
12+
import {
13+
DotnetAcquisitionStarted,
14+
DotnetUninstallAllCompleted,
15+
DotnetUninstallAllStarted,
16+
} from './EventStreamEvents';
1317
import { IAcquisitionInvoker } from './IAcquisitionInvoker';
1418
import { IDotnetInstallationContext } from './IDotnetInstallationContext';
1519
import { IVersionResolver } from './IVersionResolver';
@@ -22,10 +26,10 @@ export class DotnetCoreAcquisitionWorker {
2226
private acquisitionPromises: { [version: string]: Promise<string> | undefined };
2327

2428
constructor(private readonly storagePath: string,
25-
private readonly extensionState: Memento,
26-
private readonly eventStream: IEventStream,
27-
private readonly acquisitionInvoker: IAcquisitionInvoker,
28-
private readonly versionResolver: IVersionResolver) {
29+
private readonly extensionState: Memento,
30+
private readonly eventStream: IEventStream,
31+
private readonly acquisitionInvoker: IAcquisitionInvoker,
32+
private readonly versionResolver: IVersionResolver) {
2933
this.installDir = path.join(this.storagePath, '.dotnet');
3034
const dotnetExtension = os.platform() === 'win32' ? '.exe' : '';
3135
this.dotnetExecutable = `dotnet${dotnetExtension}`;
@@ -40,12 +44,12 @@ export class DotnetCoreAcquisitionWorker {
4044
rimraf.sync(this.installDir);
4145

4246
await this.extensionState.update(this.installingVersionsKey, []);
43-
47+
4448
this.eventStream.post(new DotnetUninstallAllCompleted());
4549
}
4650

4751
public async acquire(version: string): Promise<string> {
48-
version = await this.versionResolver.getFullVersion(version);
52+
version = await this.versionResolver.getFullVersion(version);
4953

5054
const existingAcquisitionPromise = this.acquisitionPromises[version];
5155
if (existingAcquisitionPromise) {
@@ -57,7 +61,7 @@ export class DotnetCoreAcquisitionWorker {
5761

5862
const acquisitionPromise = this.acquireCore(version).catch((error: Error) => {
5963
delete this.acquisitionPromises[version];
60-
throw new Error('Dotnet Core Acquisition Failed: ' + error.message);
64+
throw new Error(`Dotnet Core Acquisition Failed: ${error.message}`);
6165
});
6266

6367
this.acquisitionPromises[version] = acquisitionPromise;
@@ -88,8 +92,8 @@ export class DotnetCoreAcquisitionWorker {
8892

8993
const installContext = {
9094
installDir: dotnetInstallDir,
91-
version: version,
92-
dotnetPath: dotnetPath
95+
version,
96+
dotnetPath,
9397
} as IDotnetInstallationContext;
9498
this.eventStream.post(new DotnetAcquisitionStarted(version));
9599
await this.acquisitionInvoker.installDotnet(installContext);
@@ -105,7 +109,7 @@ export class DotnetCoreAcquisitionWorker {
105109

106110
return dotnetPath;
107111
}
108-
112+
109113
private async uninstall(version: string) {
110114
delete this.acquisitionPromises[version];
111115

@@ -121,7 +125,7 @@ export class DotnetCoreAcquisitionWorker {
121125
}
122126

123127
private getDotnetInstallDir(version: string) {
124-
const dotnetInstallDir = path.join(this.installDir, version)
128+
const dotnetInstallDir = path.join(this.installDir, version);
125129
return dotnetInstallDir;
126130
}
127131
}

0 commit comments

Comments
 (0)