Skip to content

Node execution engine #1189

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,10 @@ site/
/tools
/*.zip
GitVersion.CommandLine/*/

####################
# Node and Typescript
####################
src/GitVersionTfsTask/node_modules/
src/GitVersionTfsTask/*.d.ts
src/GitVersionTfsTask/*.js
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
install:
npm i -g tfx-cli
npm i -g typescript

assembly_info:
patch: false
Expand Down
80 changes: 80 additions & 0 deletions src/GitVersionTfsTask/GitVersion.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import tl = require('vsts-task-lib/task');
import { IExecOptions, ToolRunner } from 'vsts-task-lib/toolrunner';
import path = require('path');
import q = require('q');
import os = require('os');

var updateAssemblyInfo = tl.getBoolInput('updateAssemblyInfo');
var updateAssemblyInfoFilename = tl.getInput('updateAssemblyInfoFilename');
var additionalArguments = tl.getInput('additionalArguments');
var gitVersionPath = tl.getInput('gitVersionPath');
var preferBundledVersion = tl.getBoolInput('preferBundledVersion');

var currentDirectory = __dirname;

var sourcesDirectory = tl.getVariable("Build.SourcesDirectory")

if (!gitVersionPath) {
gitVersionPath = tl.which("GitVersion.exe");
if (preferBundledVersion || !gitVersionPath) {
gitVersionPath = path.join(currentDirectory, "GitVersion.exe");
}
}

(async function execute() {
try {

var execOptions: IExecOptions = {
cwd: undefined,
env: undefined,
silent: undefined,
failOnStdErr: undefined,
ignoreReturnCode: undefined,
errStream: undefined,
outStream: undefined,
windowsVerbatimArguments: undefined
};

var toolRunner: ToolRunner;

var isWin32 = os.platform() == "win32";

if (isWin32) {
toolRunner = tl.tool(gitVersionPath);
} else {
toolRunner = tl.tool("mono");
toolRunner.arg(gitVersionPath);
}

toolRunner.arg([
sourcesDirectory,
"/output",
"buildserver",
"/nofetch"
]);

if (updateAssemblyInfo) {
toolRunner.arg("/updateassemblyinfo")
if (updateAssemblyInfoFilename) {
toolRunner.arg(updateAssemblyInfoFilename);
} else {
toolRunner.arg("true");
}
}

if (additionalArguments) {
toolRunner.line(additionalArguments);
}

var result = await toolRunner.exec(execOptions);
if (result) {
tl.setResult(tl.TaskResult.Failed, "An error occured during GitVersion execution")
} else {
tl.setResult(tl.TaskResult.Succeeded, "GitVersion executed successfully")
}
}
catch (err) {
tl.debug(err.stack)
tl.setResult(tl.TaskResult.Failed, err);
}
})();
21 changes: 21 additions & 0 deletions src/GitVersionTfsTask/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "gitversion",
"version": "1.0.0",
"private": true,
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "MIT",
"dependencies": {
"vsts-task-lib": "1.1.0",
"q" : "1.4.1"
},
"devDependencies" :{
"@types/minimatch": "^2.0.29",
"@types/node": "^7.0.5",
"@types/q": "0.0.32"
}
}
12 changes: 10 additions & 2 deletions src/GitVersionTfsTask/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,19 @@
"required": false,
"helpMarkDown": "Optionally supply the path to GitVersion.exe",
"groupName": "additional"
},
{
"name": "preferBundledVersion",
"type": "boolean",
"label": "Prefer bundled GiVersion.exe",
"required": false,
"helpMarkDown": "If checked it will prefer the bundled version over a version found in path",
"groupName": "additional"
}
],
"execution": {
"PowerShell": {
"target": "$(currentDirectory)\\GitVersion.ps1",
"Node": {
"target": "GitVersion.js",
"argumentFormat": "",
"workingDirectory": ""
}
Expand Down
13 changes: 13 additions & 0 deletions src/GitVersionTfsTask/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node",
"noImplicitAny": true,
"removeComments": true,
"preserveConstEnums": true,
"target": "es6",
"sourceMap": false,
"inlineSourceMap": true,
"declaration": true
}
}