Skip to content

Commit a66af91

Browse files
committed
able to modify cloc-cli download url
1 parent db5af31 commit a66af91

16 files changed

+1429
-23
lines changed

DETAILS.md

+6
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,14 @@ By default the cloc CLI is running in the root of the repository, you can modify
4545

4646
![Working folder is the path, where the cloc CLI will run](https://raw.githubusercontent.com/Dealogic/cloc-vsts-extension/master/screenshots/WorkingFolder.png)
4747

48+
By default the cloc CLI is downloaded from the url: `https://github.com/AlDanial/cloc/releases/download/1.80/cloc-1.80.exe`:
49+
50+
![The download URL of the cloc-cli tool](https://raw.githubusercontent.com/Dealogic/cloc-vsts-extension/master/screenshots/WorkingFolder.png)
51+
4852
## <a id="release-notes"></a>Release Notes
4953

54+
* 1.1.0 (12/12/2018)
55+
* Option to modify the cloc-cli download URL
5056
* 1.0.0 (14/08/2017)
5157
* Counting lines of code with cloc CLI (by Al Danial)
5258
* Result of the cloc CLI is reported onto the Build Summary page

GitVersion.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
next-version: 1.0.0
1+
next-version: 1.1.0
22
assembly-informational-format: '{SemVer}'

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,14 @@ By default the cloc CLI is running in the root of the repository, you can modify
4545

4646
![Working folder is the path, where the cloc CLI will run](https://raw.githubusercontent.com/Dealogic/cloc-vsts-extension/master/screenshots/WorkingFolder.png)
4747

48+
By default the cloc CLI is downloaded from the url: `https://github.com/AlDanial/cloc/releases/download/1.80/cloc-1.80.exe`:
49+
50+
![The download URL of the cloc-cli tool](https://raw.githubusercontent.com/Dealogic/cloc-vsts-extension/master/screenshots/WorkingFolder.png)
51+
4852
## <a id="release-notes"></a>Release Notes
4953

54+
* 1.1.0 (12/12/2018)
55+
* Option to modify the cloc-cli download URL
5056
* 1.0.0 (14/08/2017)
5157
* Counting lines of code with cloc CLI (by Al Danial)
5258
* Result of the cloc CLI is reported onto the Build Summary page

package.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
{
22
"name": "cloc-vsts-extension",
3-
"version": "1.0.0",
3+
"version": "1.1.0",
44
"description": "cloc Visual Studio Team System (VTST) extension",
55
"main": "index.js",
66
"scripts": {
7-
"setup": "npm install && cd tasks/cloc-build-task && npm install",
7+
"setup": "yarn && cd tasks/cloc-build-task && yarn install",
88
"tslint": "tslint tasks/cloc-build-task/**/*.ts -e tasks/cloc-build-task/node_modules/**/*",
9-
"build-without-setup": "tsc && npm run tslint",
10-
"build": "npm run setup && npm run build-without-setup",
11-
"release": "npm run build && node updateVersion.js && node node_modules/tfx-cli/_build/tfx-cli.js extension create --manifest-glob vss-extension.json --output-path ./dist",
9+
"build-without-setup": "tsc && yarn tslint",
10+
"build": "yarn setup && yarn build-without-setup",
11+
"release": "yarn build && node updateVersion.js && node node_modules/tfx-cli/_build/tfx-cli.js extension create --manifest-glob vss-extension.json --output-path ./dist",
1212
"test-reporter": "cd tasks/cloc-build-task && mocha tests/suite.js --reporter mocha-junit-reporter --reporter-options mochaFile=./test-results.xml",
13-
"test": "npm run build-without-setup && cd tasks/cloc-build-task && mocha tests/suite.js"
13+
"test": "yarn build-without-setup && cd tasks/cloc-build-task && mocha tests/suite.js"
1414
},
1515
"keywords": [
1616
"VSTS",
@@ -26,7 +26,7 @@
2626
"chai": "4.1.1",
2727
"mocha": "3.5.0",
2828
"mocha-junit-reporter": "1.13.0",
29-
"tfx-cli": "0.4.9",
29+
"tfx-cli": "0.6.3",
3030
"tslint": "5.6.0",
3131
"typescript": "2.4.2"
3232
}

tasks/cloc-build-task/clocCli.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as path from "path";
44

55
const executeClocCli = (clocCliArguments: string) => {
66
const clocCliResultFilename = "cloc.result.md";
7-
const commandToExecute = `cloc-1.72.exe ${clocCliArguments} --sum-one --md --out ${clocCliResultFilename}`;
7+
const commandToExecute = `cloc.exe ${clocCliArguments} --sum-one --md --out ${clocCliResultFilename}`;
88

99
console.log(`Executing command: ${commandToExecute}`);
1010

tasks/cloc-build-task/clocCliDownloader.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
import * as https from "https";
22
import * as fs from "fs";
3-
import * as child_process from "child_process";
4-
import * as path from "path";
5-
6-
const downloadClocCli = (downloadFinishedCallback: () => void) => {
7-
const clocExeFilename = "cloc-1.72.exe";
8-
const clocExeDownloadUrl = "https://github.com/AlDanial/cloc/releases/download/v1.72/cloc-1.72.exe";
93

4+
const downloadClocCli = (clocExeDownloadUrl: string, downloadFinishedCallback: () => void) => {
5+
const clocExeFilename = "cloc.exe";
106
const clocExeFile = fs.createWriteStream(clocExeFilename);
117

128
console.log(`Downloading cloc.exe from '${clocExeDownloadUrl}'`);

tasks/cloc-build-task/index.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,18 @@ async function run(): Promise<void> {
2222
tl.cd(workingFolder);
2323
process.chdir(workingFolder);
2424

25+
const clocCliDownloadUrl = tl.getInput("clocCliDownloadUrl", true);
26+
console.log(`cloc-cli download url: ${clocCliDownloadUrl}`);
27+
2528
const clocCliArguments = tl.getInput("arguments", true);
2629
console.log(`arguments: ${clocCliArguments}`);
2730

2831
try {
29-
downloadClocCli(() => {
30-
executeClocCli(clocCliArguments);
31-
});
32+
downloadClocCli(
33+
clocCliDownloadUrl,
34+
() => {
35+
executeClocCli(clocCliArguments);
36+
});
3237
} catch (err) {
3338
tl.setResult(tl.TaskResult.Failed, `${taskDisplayName} failed`);
3439
tl.error(err);

tasks/cloc-build-task/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cloc-build-task",
3-
"version": "1.0.0",
3+
"version": "1.1.0",
44
"description": "cloc Visual Studio Team System (VTST) extension",
55
"main": "index.js",
66
"scripts": {},

tasks/cloc-build-task/task.json

+9-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
],
1717
"version": {
1818
"Major": 1,
19-
"Minor": 0,
19+
"Minor": 1,
2020
"Patch": 0
2121
},
2222
"minimumAgentVersion": "1.95.0",
@@ -38,6 +38,14 @@
3838
"helpMarkDown": "Working folder where cloc CLI is run. If you leave it blank it is the root of the repository.",
3939
"groupName": "advanced"
4040
},
41+
{
42+
"name": "clocCliDownloadUrl",
43+
"type": "string",
44+
"label": "Download url of cloc-cli",
45+
"defaultValue": "https://github.com/AlDanial/cloc/releases/download/1.80/cloc-1.80.exe",
46+
"required": true,
47+
"helpMarkDown": "Download URL of cloc-cli. Default value: https://github.com/AlDanial/cloc/releases/download/1.80/cloc-1.80.exe"
48+
},
4149
{
4250
"name": "arguments",
4351
"type": "string",

tasks/cloc-build-task/tests/mockRunnerDefinitions/shared/ITestRunConfiguration.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export interface ITestRunConfiguration {
22
workingFolder?: string;
3+
clocCliDownloadUrl?: string;
34
clocCliArguments?: string;
45
taskDisplayName?: string;
56
nullTaskDisplayName?: boolean;

tasks/cloc-build-task/tests/mockRunnerDefinitions/shared/testTaskRunner.ts

+5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ const runTestTask = (testRunConfiguration: ITestRunConfiguration) => {
1616
testRunConfiguration.workingFolder = path.resolve(__dirname, "..", "..");
1717
}
1818

19+
if (!testRunConfiguration.clocCliDownloadUrl) {
20+
testRunConfiguration.clocCliDownloadUrl = "https://github.com/AlDanial/cloc/releases/download/1.80/cloc-1.80.exe";
21+
}
22+
1923
if (!testRunConfiguration.clocCliArguments) {
2024
testRunConfiguration.clocCliArguments = "./mockCodeFiles";
2125
}
@@ -24,6 +28,7 @@ const runTestTask = (testRunConfiguration: ITestRunConfiguration) => {
2428

2529
taskMockRunner.setInput("workingFolder", testRunConfiguration.workingFolder);
2630
taskMockRunner.setInput("arguments", testRunConfiguration.clocCliArguments);
31+
taskMockRunner.setInput("clocCliDownloadUrl", testRunConfiguration.clocCliDownloadUrl);
2732

2833
taskMockRunner.run();
2934
};

tasks/cloc-build-task/tests/shouldProduceClocResultMdFile.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ const mockRunnerDefinitions = "mockRunnerDefinitions";
77

88
export function executeTest(done: MochaDone): void {
99
// tslint:disable-next-line:no-invalid-this
10-
this.timeout(15000);
10+
this.timeout(30000);
1111

1212
const testPath = path.join(__dirname, mockRunnerDefinitions, "shouldProduceClocResultMdFile.js");
1313
const testRunner = new MockTestRunner(testPath);
1414

1515
testRunner.run();
1616

17+
console.log(testRunner.stdout);
18+
1719
assert.isTrue(fs.existsSync("tests/cloc.result.md"));
1820
const clocResultMdFileContent = fs.readFileSync("tests/cloc.result.md", {
1921
encoding: "utf8"

tasks/cloc-build-task/yarn.lock

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2+
# yarn lockfile v1
3+
4+
5+
balanced-match@^1.0.0:
6+
version "1.0.0"
7+
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"
8+
9+
brace-expansion@^1.1.7:
10+
version "1.1.11"
11+
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
12+
dependencies:
13+
balanced-match "^1.0.0"
14+
concat-map "0.0.1"
15+
16+
17+
version "0.0.1"
18+
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
19+
20+
minimatch@^3.0.0:
21+
version "3.0.4"
22+
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
23+
dependencies:
24+
brace-expansion "^1.1.7"
25+
26+
mockery@^1.7.0:
27+
version "1.7.0"
28+
resolved "https://registry.yarnpkg.com/mockery/-/mockery-1.7.0.tgz#f4ede0d8750c1c9727c272ea2c60629e2c9a1c4f"
29+
30+
q@^1.1.2:
31+
version "1.5.1"
32+
resolved "https://registry.yarnpkg.com/q/-/q-1.5.1.tgz#7e32f75b41381291d04611f1bf14109ac00651d7"
33+
34+
semver@^5.1.0:
35+
version "5.6.0"
36+
resolved "https://registry.yarnpkg.com/semver/-/semver-5.6.0.tgz#7e74256fbaa49c75aa7c7a205cc22799cac80004"
37+
38+
shelljs@^0.3.0:
39+
version "0.3.0"
40+
resolved "http://registry.npmjs.org/shelljs/-/shelljs-0.3.0.tgz#3596e6307a781544f591f37da618360f31db57b1"
41+
42+
uuid@^3.0.1:
43+
version "3.3.2"
44+
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.3.2.tgz#1b4af4955eb3077c501c23872fc6513811587131"
45+
46+
47+
version "2.0.7"
48+
resolved "https://registry.yarnpkg.com/vsts-task-lib/-/vsts-task-lib-2.0.7.tgz#554b02cffe6b161b077787be68fd425811dee72b"
49+
dependencies:
50+
minimatch "^3.0.0"
51+
mockery "^1.7.0"
52+
q "^1.1.2"
53+
semver "^5.1.0"
54+
shelljs "^0.3.0"
55+
uuid "^3.0.1"

version.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export default "__GitVersion.SemVer__".replace("GitVersion.SemVer", "1.0.0").replace(/__/g, "");
1+
export default "__GitVersion.SemVer__".replace("GitVersion.SemVer", "1.1.0").replace(/__/g, "");

vss-extension.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"manifestVersion": 1,
33
"id": "cloc-vsts-extension",
4-
"version": "1.0.0",
4+
"version": "1.1.0",
55
"name": "Count Lines of Code",
66
"description": "Count Lines of Code with cloc CLI by Al Danial.",
77
"publisher": "Dealogic",

0 commit comments

Comments
 (0)