Skip to content

Commit 947b56e

Browse files
Cyprien AutexierCyprien Autexier
Cyprien Autexier
authored and
Cyprien Autexier
committed
node execution engine
1 parent d2003e5 commit 947b56e

File tree

6 files changed

+136
-3
lines changed

6 files changed

+136
-3
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,8 @@ site/
101101
# Visual Studio Code
102102
####################
103103

104-
.vscode
104+
.vscode
105+
106+
src/GitVersionTfsTask/node_modules/
107+
src/GitVersionTfsTask/*.d.ts
108+
src/GitVersionTfsTask/*.js

appveyor.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ configuration:
1010
build_script:
1111
- cmd: nuget restore src/GitVersion.sln
1212
- cmd: npm i -g tfx-cli
13+
- cmd: npm i -g typescript
14+
15+
- cmd: mkdir src\GitVersionTfsTask\node_modules
16+
- cmd: cd src\GitVersionTfsTask
17+
- cmd: npm install
18+
- cmd: cd ..\..
19+
- cmd: tsc -p src/GitVersionTfsTask
1320

1421
- cmd: msbuild src/GitVersion.sln "/p:Configuration=%CONFIGURATION%;Platform=%PLATFORM%"
1522
- ps: .\build\NuGetCommandLineBuild\tools\GitVersion.exe /l console /output buildserver /updateAssemblyInfo

src/GitVersionTfsTask/GitVersion.ts

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import tl = require('vsts-task-lib/task');
2+
import { IExecOptions, ToolRunner } from 'vsts-task-lib/toolrunner';
3+
import path = require('path');
4+
import q = require('q');
5+
import os = require('os');
6+
7+
var updateAssemblyInfo = tl.getBoolInput('updateAssemblyInfo');
8+
var updateAssemblyInfoFilename = tl.getInput('updateAssemblyInfoFilename');
9+
var additionalArguments = tl.getInput('additionalArguments');
10+
var gitVersionPath = tl.getInput('gitVersionPath');
11+
var preferBundledVersion = tl.getBoolInput('preferBundledVersion');
12+
13+
var currentDirectory = __dirname;
14+
15+
var sourcesDirectory = tl.getVariable("Build.SourcesDirectory")
16+
17+
if (!gitVersionPath) {
18+
gitVersionPath = tl.which("GitVersion.exe");
19+
if (preferBundledVersion || !gitVersionPath) {
20+
gitVersionPath = path.join(currentDirectory, "GitVersion.exe");
21+
}
22+
}
23+
24+
(async function execute() {
25+
try {
26+
27+
var execOptions: IExecOptions = {
28+
cwd: undefined,
29+
env: undefined,
30+
silent: undefined,
31+
failOnStdErr: undefined,
32+
ignoreReturnCode: undefined,
33+
errStream: undefined,
34+
outStream: undefined,
35+
windowsVerbatimArguments: undefined
36+
};
37+
38+
var toolRunner: ToolRunner;
39+
40+
var isWin32 = os.platform() == "win32";
41+
42+
if (isWin32) {
43+
toolRunner = tl.tool(gitVersionPath);
44+
} else {
45+
toolRunner = tl.tool("mono");
46+
toolRunner.arg(gitVersionPath);
47+
}
48+
49+
toolRunner.arg([
50+
sourcesDirectory,
51+
"/output",
52+
"buildserver",
53+
"/nofetch"
54+
]);
55+
56+
if (updateAssemblyInfo) {
57+
toolRunner.arg("/updateassemblyinfo")
58+
if (updateAssemblyInfoFilename) {
59+
toolRunner.arg(updateAssemblyInfoFilename);
60+
} else {
61+
toolRunner.arg("true");
62+
}
63+
}
64+
65+
if (additionalArguments) {
66+
toolRunner.line(additionalArguments);
67+
}
68+
69+
var result = await toolRunner.exec(execOptions);
70+
if (result) {
71+
tl.setResult(tl.TaskResult.Failed, "An error occured during GitVersion execution")
72+
} else {
73+
tl.setResult(tl.TaskResult.Succeeded, "GitVersion executed successfully")
74+
}
75+
}
76+
catch (err) {
77+
tl.debug(err.stack)
78+
tl.setResult(tl.TaskResult.Failed, err);
79+
}
80+
})();

src/GitVersionTfsTask/package.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "gitversion",
3+
"version": "1.0.0",
4+
"private": true,
5+
"description": "",
6+
"main": "index.js",
7+
"scripts": {
8+
"test": "echo \"Error: no test specified\" && exit 1"
9+
},
10+
"author": "",
11+
"license": "MIT",
12+
"dependencies": {
13+
"vsts-task-lib": "1.1.0",
14+
"q" : "1.4.1"
15+
},
16+
"devDependencies" :{
17+
"@types/minimatch": "^2.0.29",
18+
"@types/node": "^7.0.5",
19+
"@types/q": "0.0.32"
20+
}
21+
}

src/GitVersionTfsTask/task.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,19 @@
5656
"required": false,
5757
"helpMarkDown": "Optionally supply the path to GitVersion.exe",
5858
"groupName": "additional"
59+
},
60+
{
61+
"name": "preferBundledVersion",
62+
"type": "boolean",
63+
"label": "Prefer bundled GiVersion.exe",
64+
"required": false,
65+
"helpMarkDown": "If checked it will prefer the bundled version over a version found in path",
66+
"groupName": "additional"
5967
}
6068
],
6169
"execution": {
62-
"PowerShell": {
63-
"target": "$(currentDirectory)\\GitVersion.ps1",
70+
"Node": {
71+
"target": "GitVersion.js",
6472
"argumentFormat": "",
6573
"workingDirectory": ""
6674
}

src/GitVersionTfsTask/tsconfig.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"compilerOptions": {
3+
"module": "commonjs",
4+
"moduleResolution": "node",
5+
"noImplicitAny": true,
6+
"removeComments": true,
7+
"preserveConstEnums": true,
8+
"target": "es6",
9+
"sourceMap": false,
10+
"inlineSourceMap": true,
11+
"declaration": true
12+
}
13+
}

0 commit comments

Comments
 (0)