added prettier tool

This commit is contained in:
Artur Stolear
2020-03-10 11:42:51 +02:00
parent 5c4fb6ec6b
commit 2690f37786
32 changed files with 930 additions and 902 deletions

View File

@@ -1,14 +0,0 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
plugins: [
'@typescript-eslint',
'sort-keys-fix'
],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'prettier/@typescript-eslint',
],
};

View File

@@ -23,6 +23,7 @@ jobs:
git fetch --prune --unshallow git fetch --prune --unshallow
- run: | - run: |
npm install npm install
npm run format-check
npm run build:github npm run build:github
npm run build:azure npm run build:azure
name: Build code name: Build code

2
.prettierignore Normal file
View File

@@ -0,0 +1,2 @@
node_modules/
src/*/node_modules/

11
.prettierrc.json Normal file
View File

@@ -0,0 +1,11 @@
{
"printWidth": 80,
"tabWidth": 4,
"useTabs": false,
"semi": false,
"singleQuote": true,
"trailingComma": "none",
"bracketSpacing": false,
"arrowParens": "avoid",
"parser": "typescript"
}

199
package-lock.json generated
View File

@@ -57,26 +57,6 @@
} }
} }
}, },
"@babel/code-frame": {
"version": "7.8.3",
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.8.3.tgz",
"integrity": "sha512-a9gxpmdXtZEInkCSHUJDLHZVBgb1QS0jhss4cPP93EW7s+uC5bikET2twEF3KV+7rDblJcmNvTR7VJejqd2C2g==",
"dev": true,
"requires": {
"@babel/highlight": "^7.8.3"
}
},
"@babel/highlight": {
"version": "7.8.3",
"resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.8.3.tgz",
"integrity": "sha512-PX4y5xQUvy0fnEVHrYOarRPXVWafSjTW9T0Hab8gVIawpl2Sj0ORyrygANq+KjcNlSSTw0YCLSNA8OyZ1I4yEg==",
"dev": true,
"requires": {
"chalk": "^2.0.0",
"esutils": "^2.0.2",
"js-tokens": "^4.0.0"
}
},
"@types/node": { "@types/node": {
"version": "13.9.0", "version": "13.9.0",
"resolved": "https://registry.npmjs.org/@types/node/-/node-13.9.0.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-13.9.0.tgz",
@@ -294,9 +274,9 @@
"dev": true "dev": true
}, },
"acorn": { "acorn": {
"version": "6.4.0", "version": "6.4.1",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-6.4.0.tgz", "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.4.1.tgz",
"integrity": "sha512-gac8OEcQ2Li1dxIEWGZzsp2BitJxwkwcOm0zHAJLcPJaVvm58FRnk6RkuLRpU1EujipU2ZFODv2P9DLMfnV8mw==", "integrity": "sha512-ZVA9k326Nwrj3Cj9jlh3wGFutC2ZornPNARZwsNYqQYgN0EsV2d53w5RN/co65Ohn4sUAUtb1rSUAOD6XN9idA==",
"dev": true "dev": true
}, },
"aggregate-error": { "aggregate-error": {
@@ -531,15 +511,6 @@
"readable-stream": "^2.0.0" "readable-stream": "^2.0.0"
} }
}, },
"argparse": {
"version": "1.0.10",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
"integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
"dev": true,
"requires": {
"sprintf-js": "~1.0.2"
}
},
"arr-diff": { "arr-diff": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz",
@@ -954,12 +925,6 @@
"integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk=", "integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk=",
"dev": true "dev": true
}, },
"builtin-modules": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz",
"integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=",
"dev": true
},
"builtin-status-codes": { "builtin-status-codes": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz", "resolved": "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz",
@@ -1516,12 +1481,6 @@
"regexp.prototype.flags": "^1.2.0" "regexp.prototype.flags": "^1.2.0"
} }
}, },
"deep-extend": {
"version": "0.6.0",
"resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz",
"integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==",
"dev": true
},
"define-properties": { "define-properties": {
"version": "1.1.3", "version": "1.1.3",
"resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz",
@@ -1588,12 +1547,6 @@
"integrity": "sha1-8NZtA2cqglyxtzvbP+YjEMjlUrc=", "integrity": "sha1-8NZtA2cqglyxtzvbP+YjEMjlUrc=",
"dev": true "dev": true
}, },
"diff": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz",
"integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==",
"dev": true
},
"diffie-hellman": { "diffie-hellman": {
"version": "5.0.3", "version": "5.0.3",
"resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz",
@@ -1739,12 +1692,6 @@
"estraverse": "^4.1.1" "estraverse": "^4.1.1"
} }
}, },
"esprima": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
"integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==",
"dev": true
},
"esrecurse": { "esrecurse": {
"version": "4.2.1", "version": "4.2.1",
"resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz",
@@ -1760,12 +1707,6 @@
"integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==",
"dev": true "dev": true
}, },
"esutils": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz",
"integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==",
"dev": true
},
"events": { "events": {
"version": "3.1.0", "version": "3.1.0",
"resolved": "https://registry.npmjs.org/events/-/events-3.1.0.tgz", "resolved": "https://registry.npmjs.org/events/-/events-3.1.0.tgz",
@@ -2205,17 +2146,6 @@
"integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==", "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==",
"dev": true "dev": true
}, },
"fs-extra": {
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz",
"integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==",
"dev": true,
"requires": {
"graceful-fs": "^4.2.0",
"jsonfile": "^4.0.0",
"universalify": "^0.1.0"
}
},
"fs-minipass": { "fs-minipass": {
"version": "2.1.0", "version": "2.1.0",
"resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz", "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz",
@@ -3362,22 +3292,6 @@
"integrity": "sha1-o6vicYryQaKykE+EpiWXDzia4yo=", "integrity": "sha1-o6vicYryQaKykE+EpiWXDzia4yo=",
"dev": true "dev": true
}, },
"js-tokens": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
"integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==",
"dev": true
},
"js-yaml": {
"version": "3.13.1",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz",
"integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==",
"dev": true,
"requires": {
"argparse": "^1.0.7",
"esprima": "^4.0.0"
}
},
"json-in-place": { "json-in-place": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/json-in-place/-/json-in-place-1.0.1.tgz", "resolved": "https://registry.npmjs.org/json-in-place/-/json-in-place-1.0.1.tgz",
@@ -3405,33 +3319,6 @@
"integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==",
"dev": true "dev": true
}, },
"json-update": {
"version": "5.3.0",
"resolved": "https://registry.npmjs.org/json-update/-/json-update-5.3.0.tgz",
"integrity": "sha512-NUvwm6DMKTVY4raxzAdQiakhD57BKxZwO/7xDYKO10purZiyFK9Gae+fVmAPl0g1WzuwfAJwZzuOcQUavgjE6w==",
"dev": true,
"requires": {
"deep-extend": "^0.6.0",
"fs-extra": "^8.1.0",
"lockfile": "~1.0.4",
"pify": "^4.0.1",
"underscore": "^1.9.2"
},
"dependencies": {
"pify": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz",
"integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==",
"dev": true
},
"underscore": {
"version": "1.9.2",
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.9.2.tgz",
"integrity": "sha512-D39qtimx0c1fI3ya1Lnhk3E9nONswSKhnffBI0gME9C99fYOkNi04xs8K6pePLhvl1frbDemkaBQ5ikWllR2HQ==",
"dev": true
}
}
},
"json5": { "json5": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz",
@@ -3449,15 +3336,6 @@
} }
} }
}, },
"jsonfile": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz",
"integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=",
"dev": true,
"requires": {
"graceful-fs": "^4.1.6"
}
},
"jszip": { "jszip": {
"version": "3.1.5", "version": "3.1.5",
"resolved": "https://registry.npmjs.org/jszip/-/jszip-3.1.5.tgz", "resolved": "https://registry.npmjs.org/jszip/-/jszip-3.1.5.tgz",
@@ -3500,9 +3378,9 @@
} }
}, },
"kind-of": { "kind-of": {
"version": "6.0.2", "version": "6.0.3",
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz",
"integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==",
"dev": true "dev": true
}, },
"lazystream": { "lazystream": {
@@ -3571,15 +3449,6 @@
"path-exists": "^3.0.0" "path-exists": "^3.0.0"
} }
}, },
"lockfile": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/lockfile/-/lockfile-1.0.4.tgz",
"integrity": "sha512-cvbTwETRfsFh4nHsL1eGWapU1XFi5Ot9E85sWAwia7Y7EgB7vfqcZhTKZ+l7hCGxSPoushMv5GKhT5PdLv03WA==",
"dev": true,
"requires": {
"signal-exit": "^3.0.2"
}
},
"lodash": { "lodash": {
"version": "4.17.15", "version": "4.17.15",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz",
@@ -4429,6 +4298,12 @@
"integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=", "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=",
"dev": true "dev": true
}, },
"prettier": {
"version": "1.19.1",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz",
"integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==",
"dev": true
},
"process": { "process": {
"version": "0.11.10", "version": "0.11.10",
"resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz",
@@ -5213,12 +5088,6 @@
"extend-shallow": "^3.0.0" "extend-shallow": "^3.0.0"
} }
}, },
"sprintf-js": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
"integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=",
"dev": true
},
"ssri": { "ssri": {
"version": "7.1.0", "version": "7.1.0",
"resolved": "https://registry.npmjs.org/ssri/-/ssri-7.1.0.tgz", "resolved": "https://registry.npmjs.org/ssri/-/ssri-7.1.0.tgz",
@@ -5661,36 +5530,6 @@
"integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==", "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==",
"dev": true "dev": true
}, },
"tslint": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/tslint/-/tslint-6.0.0.tgz",
"integrity": "sha512-9nLya8GBtlFmmFMW7oXXwoXS1NkrccqTqAtwXzdPV9e2mqSEvCki6iHL/Fbzi5oqbugshzgGPk7KBb2qNP1DSA==",
"dev": true,
"requires": {
"@babel/code-frame": "^7.0.0",
"builtin-modules": "^1.1.1",
"chalk": "^2.3.0",
"commander": "^2.12.1",
"diff": "^4.0.1",
"glob": "^7.1.1",
"js-yaml": "^3.13.1",
"minimatch": "^3.0.4",
"mkdirp": "^0.5.1",
"resolve": "^1.3.2",
"semver": "^5.3.0",
"tslib": "^1.10.0",
"tsutils": "^2.29.0"
}
},
"tsutils": {
"version": "2.29.0",
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz",
"integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==",
"dev": true,
"requires": {
"tslib": "^1.8.1"
}
},
"tty-browserify": { "tty-browserify": {
"version": "0.0.0", "version": "0.0.0",
"resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz", "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz",
@@ -5766,12 +5605,6 @@
"imurmurhash": "^0.1.4" "imurmurhash": "^0.1.4"
} }
}, },
"universalify": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz",
"integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==",
"dev": true
},
"unset-value": { "unset-value": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz", "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz",
@@ -6147,6 +5980,14 @@
"regex-not": "^1.0.0", "regex-not": "^1.0.0",
"snapdragon": "^0.8.1", "snapdragon": "^0.8.1",
"to-regex": "^3.0.2" "to-regex": "^3.0.2"
},
"dependencies": {
"kind-of": {
"version": "6.0.3",
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz",
"integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==",
"dev": true
}
} }
}, },
"pify": { "pify": {

View File

@@ -8,6 +8,8 @@
}, },
"main": "main.js", "main": "main.js",
"scripts": { "scripts": {
"format": "prettier --write src/**/*.ts",
"format-check": "prettier --check src/**/*.ts",
"build:mock": "webpack --config webpack.config.js --env.agent=mock", "build:mock": "webpack --config webpack.config.js --env.agent=mock",
"build:azure": "webpack --config webpack.config.js --env.agent=azure", "build:azure": "webpack --config webpack.config.js --env.agent=azure",
"build:github": "webpack --config webpack.config.js --env.agent=github", "build:github": "webpack --config webpack.config.js --env.agent=github",
@@ -39,13 +41,12 @@
"@types/q": "^1.5.2", "@types/q": "^1.5.2",
"@types/semver-compare": "^1.0.1", "@types/semver-compare": "^1.0.1",
"@types/uuid": "^3.4.7", "@types/uuid": "^3.4.7",
"json-update": "^5.3.0", "prettier": "^1.19.1",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"replace-in-file-webpack-plugin": "^1.0.6", "replace-in-file-webpack-plugin": "^1.0.6",
"terser-webpack-plugin": "^2.3.5", "terser-webpack-plugin": "^2.3.5",
"tfx-cli": "^0.7.11", "tfx-cli": "^0.7.11",
"ts-loader": "^6.2.1", "ts-loader": "^6.2.1",
"tslint": "^6.0.0",
"typescript": "^3.8.3", "typescript": "^3.8.3",
"webpack": "^4.42.0", "webpack": "^4.42.0",
"webpack-cli": "^3.3.11" "webpack-cli": "^3.3.11"

View File

@@ -1,106 +1,108 @@
import { injectable } from "inversify"; import {injectable} from 'inversify'
import * as taskLib from "azure-pipelines-task-lib/task"; import * as taskLib from 'azure-pipelines-task-lib/task'
import * as toolLib from "azure-pipelines-tool-lib/tool"; import * as toolLib from 'azure-pipelines-tool-lib/tool'
import { IBuildAgent, IExecResult } from "../../core/models"; import {IBuildAgent, IExecResult} from '../../core/models'
@injectable() @injectable()
class BuildAgent implements IBuildAgent { class BuildAgent implements IBuildAgent {
public get agentName(): string { public get agentName(): string {
return "Azure Pipelines"; return 'Azure Pipelines'
} }
public find(toolName: string, versionSpec: string, arch?: string): string { public find(toolName: string, versionSpec: string, arch?: string): string {
return toolLib.findLocalTool(toolName, versionSpec, arch); return toolLib.findLocalTool(toolName, versionSpec, arch)
} }
public cacheDir(sourceDir: string, tool: string, version: string, arch?: string): Promise<string> { public cacheDir(
return toolLib.cacheDir(sourceDir, tool, version, arch); sourceDir: string,
tool: string,
version: string,
arch?: string
): Promise<string> {
return toolLib.cacheDir(sourceDir, tool, version, arch)
} }
public createTempDir(): Promise<string> { public createTempDir(): Promise<string> {
return Promise.resolve(taskLib.getVariable("Agent.TempDirectory")); return Promise.resolve(taskLib.getVariable('Agent.TempDirectory'))
} }
public debug(message: string): void { public debug(message: string): void {
taskLib.debug(message); taskLib.debug(message)
} }
public setFailed(message: string, done?: boolean): void { public setFailed(message: string, done?: boolean): void {
taskLib.setResult(taskLib.TaskResult.Failed, message, done); taskLib.setResult(taskLib.TaskResult.Failed, message, done)
} }
public setSucceeded(message: string, done?: boolean): void { public setSucceeded(message: string, done?: boolean): void {
taskLib.setResult(taskLib.TaskResult.Succeeded, message, done); taskLib.setResult(taskLib.TaskResult.Succeeded, message, done)
} }
public exportVariable(name: string, val: string): void { public exportVariable(name: string, val: string): void {
taskLib.setVariable(name, val); taskLib.setVariable(name, val)
} }
public getVariable(name: string): string { public getVariable(name: string): string {
return taskLib.getVariable(name); return taskLib.getVariable(name)
} }
public addPath(inputPath: string): void { public addPath(inputPath: string): void {
toolLib.prependPath(inputPath); toolLib.prependPath(inputPath)
} }
public which(tool: string, check?: boolean): Promise<string> { public which(tool: string, check?: boolean): Promise<string> {
return Promise.resolve(taskLib.which(tool, check)); return Promise.resolve(taskLib.which(tool, check))
} }
public exec(exec: string, args: string[]): Promise<IExecResult> { public exec(exec: string, args: string[]): Promise<IExecResult> {
const tr = taskLib.tool(exec); const tr = taskLib.tool(exec)
tr.arg(args); tr.arg(args)
const result = tr.execSync(); const result = tr.execSync()
return Promise.resolve({ return Promise.resolve({
code: result.code, code: result.code,
error: result.error, error: result.error,
stderr: result.stderr, stderr: result.stderr,
stdout: result.stdout, stdout: result.stdout
}); })
} }
public getSourceDir(): string { public getSourceDir(): string {
return this.getVariable("Build.SourcesDirectory"); return this.getVariable('Build.SourcesDirectory')
} }
public setOutput(name: string, value: string): void { public setOutput(name: string, value: string): void {
taskLib.setVariable(name, value); taskLib.setVariable(name, value)
} }
public getInput(input: string, required?: boolean): string { public getInput(input: string, required?: boolean): string {
return taskLib.getInput(input, required); return taskLib.getInput(input, required)
} }
public getListInput(input: string, required?: boolean): string[] { public getListInput(input: string, required?: boolean): string[] {
return taskLib return taskLib
.getInput(input, required) .getInput(input, required)
.split("\n") .split('\n')
.filter(x => x !== ""); .filter(x => x !== '')
} }
public getBooleanInput(input: string, required?: boolean): boolean { public getBooleanInput(input: string, required?: boolean): boolean {
return taskLib.getBoolInput(input, required); return taskLib.getBoolInput(input, required)
} }
public isValidInputFile(input: string, file: string): boolean { public isValidInputFile(input: string, file: string): boolean {
return taskLib.filePathSupplied(input) && this.fileExists(file); return taskLib.filePathSupplied(input) && this.fileExists(file)
} }
public fileExists(file: string): boolean { public fileExists(file: string): boolean {
return taskLib.exist(file) && taskLib.stats(file).isFile(); return taskLib.exist(file) && taskLib.stats(file).isFile()
} }
public directoryExists(file: string): boolean { public directoryExists(file: string): boolean {
return taskLib.exist(file) && taskLib.stats(file).isDirectory(); return taskLib.exist(file) && taskLib.stats(file).isDirectory()
} }
} }
export { export {BuildAgent}
BuildAgent,
};

View File

@@ -1,62 +1,66 @@
import * as fs from "fs"; import * as fs from 'fs'
import * as path from "path"; import * as path from 'path'
import uuidv4 from "uuid"; import uuidv4 from 'uuid'
import * as core from "@actions/core"; import * as core from '@actions/core'
import * as exe from "@actions/exec"; import * as exe from '@actions/exec'
import * as io from "@actions/io"; import * as io from '@actions/io'
import * as toolCache from "@actions/tool-cache"; import * as toolCache from '@actions/tool-cache'
import { injectable } from "inversify"; import {injectable} from 'inversify'
import { IBuildAgent, IExecResult } from "../../core/models"; import {IBuildAgent, IExecResult} from '../../core/models'
@injectable() @injectable()
class BuildAgent implements IBuildAgent { class BuildAgent implements IBuildAgent {
public get agentName(): string { public get agentName(): string {
return "GitHub Actions"; return 'GitHub Actions'
} }
public find(toolName: string, versionSpec: string, arch?: string): string { public find(toolName: string, versionSpec: string, arch?: string): string {
return toolCache.find(toolName, versionSpec, arch); return toolCache.find(toolName, versionSpec, arch)
} }
public cacheDir(sourceDir: string, tool: string, version: string, arch?: string): Promise<string> { public cacheDir(
return toolCache.cacheDir(sourceDir, tool, version, arch); sourceDir: string,
tool: string,
version: string,
arch?: string
): Promise<string> {
return toolCache.cacheDir(sourceDir, tool, version, arch)
} }
public async createTempDir(): Promise<string> { public async createTempDir(): Promise<string> {
const IS_WINDOWS = process.platform === "win32"; const IS_WINDOWS = process.platform === 'win32'
let tempDirectory: string = process.env.RUNNER_TEMP || ""; let tempDirectory: string = process.env.RUNNER_TEMP || ''
if (!tempDirectory) { if (!tempDirectory) {
let baseLocation: string; let baseLocation: string
if (IS_WINDOWS) { if (IS_WINDOWS) {
// On Windows use the USERPROFILE env variable // On Windows use the USERPROFILE env variable
baseLocation = process.env.USERPROFILE || "C:\\"; baseLocation = process.env.USERPROFILE || 'C:\\'
} else { } else {
if (process.platform === "darwin") { if (process.platform === 'darwin') {
baseLocation = "/Users"; baseLocation = '/Users'
} else { } else {
baseLocation = "/home"; baseLocation = '/home'
} }
} }
tempDirectory = path.join(baseLocation, "actions", "temp"); tempDirectory = path.join(baseLocation, 'actions', 'temp')
} }
const dest = path.join(tempDirectory, uuidv4()); const dest = path.join(tempDirectory, uuidv4())
await io.mkdirP(dest); await io.mkdirP(dest)
return dest; return dest
} }
public debug(message: string): void { public debug(message: string): void {
core.debug(message); core.debug(message)
} }
public setFailed(message: string, done?: boolean): void { public setFailed(message: string, done?: boolean): void {
core.setFailed(message); core.setFailed(message)
} }
public setSucceeded(message: string, done?: boolean): void { public setSucceeded(message: string, done?: boolean): void {
@@ -64,108 +68,103 @@ class BuildAgent implements IBuildAgent {
} }
public exportVariable(name: string, val: string): void { public exportVariable(name: string, val: string): void {
core.exportVariable(name, val); core.exportVariable(name, val)
} }
public getVariable(name: string): string { public getVariable(name: string): string {
return process.env[name]; return process.env[name]
} }
public addPath(inputPath: string): void { public addPath(inputPath: string): void {
core.addPath(inputPath); core.addPath(inputPath)
} }
public which(tool: string, check?: boolean): Promise<string> { public which(tool: string, check?: boolean): Promise<string> {
return io.which(tool, check); return io.which(tool, check)
} }
public async exec(exec: string, args: string[]): Promise<IExecResult> { public async exec(exec: string, args: string[]): Promise<IExecResult> {
const dotnetPath = await io.which(exec, true); const dotnetPath = await io.which(exec, true)
let resultCode = 0; let resultCode = 0
let stdout = ""; let stdout = ''
let stderr = ""; let stderr = ''
resultCode = await exe.exec( resultCode = await exe.exec(`"${dotnetPath}"`, args, {
`"${dotnetPath}"`, listeners: {
args, stderr: (data: Buffer) => {
{ stderr += data.toString()
listeners: {
stderr: (data: Buffer) => {
stderr += data.toString();
},
stdout: (data: Buffer) => {
stdout += data.toString();
},
}, },
}); stdout: (data: Buffer) => {
stdout += data.toString()
}
}
})
return { return {
code: resultCode, code: resultCode,
error: null, error: null,
stderr, stderr,
stdout, stdout
}; }
} }
public getSourceDir(): string { public getSourceDir(): string {
return this.getVariable("GITHUB_WORKSPACE"); return this.getVariable('GITHUB_WORKSPACE')
} }
public setOutput(name: string, value: string): void { public setOutput(name: string, value: string): void {
core.setOutput(name, value); core.setOutput(name, value)
} }
public getInput(input: string, required?: boolean): string { public getInput(input: string, required?: boolean): string {
return core.getInput(input, { required } as core.InputOptions); return core.getInput(input, {required} as core.InputOptions)
} }
public getListInput(input: string, required?: boolean): string[] { public getListInput(input: string, required?: boolean): string[] {
return core return core
.getInput(input, { required } as core.InputOptions) .getInput(input, {required} as core.InputOptions)
.split("\n") .split('\n')
.filter(x => x !== ""); .filter(x => x !== '')
} }
public getBooleanInput(input: string, required?: boolean): boolean { public getBooleanInput(input: string, required?: boolean): boolean {
const inputValue = this.getInput(input, required); const inputValue = this.getInput(input, required)
return (inputValue || "false").toLowerCase() === "true"; return (inputValue || 'false').toLowerCase() === 'true'
} }
public isValidInputFile(input: string, file: string): boolean { public isValidInputFile(input: string, file: string): boolean {
return this.filePathSupplied(input) && this.fileExists(file); return this.filePathSupplied(input) && this.fileExists(file)
} }
public filePathSupplied(file: string): boolean { public filePathSupplied(file: string): boolean {
const pathValue = path.resolve(this.getInput(file) || ""); const pathValue = path.resolve(this.getInput(file) || '')
const repoRoot = this.getSourceDir(); const repoRoot = this.getSourceDir()
return pathValue !== repoRoot; return pathValue !== repoRoot
} }
public fileExists(file: string): boolean { public fileExists(file: string): boolean {
return this._exist(file) && this._stats(file).isFile(); return this._exist(file) && this._stats(file).isFile()
} }
public directoryExists(file: string): boolean { public directoryExists(file: string): boolean {
return this._exist(file) && this._stats(file).isDirectory(); return this._exist(file) && this._stats(file).isDirectory()
} }
private _exist(file: string): boolean { private _exist(file: string): boolean {
let exist = false; let exist = false
try { try {
exist = !!(file && fs.statSync(file) != null); exist = !!(file && fs.statSync(file) != null)
} catch (err) { } catch (err) {
if (err && err.code === "ENOENT") { if (err && err.code === 'ENOENT') {
exist = false; exist = false
} else { } else {
throw err; throw err
} }
} }
return exist; return exist
} }
private _stats(file: string): fs.Stats { private _stats(file: string): fs.Stats {
return fs.statSync(file); return fs.statSync(file)
} }
} }
export { export {BuildAgent}
BuildAgent,
};

View File

@@ -1,109 +1,111 @@
import { injectable } from "inversify"; import {injectable} from 'inversify'
import { IBuildAgent, IExecResult } from "../../core/models"; import {IBuildAgent, IExecResult} from '../../core/models'
@injectable() @injectable()
class BuildAgent implements IBuildAgent { class BuildAgent implements IBuildAgent {
public get agentName(): string { public get agentName(): string {
console.log("getAgentName"); console.log('getAgentName')
return "Mock"; return 'Mock'
} }
public find(toolName: string, versionSpec: string, arch?: string): string { public find(toolName: string, versionSpec: string, arch?: string): string {
console.log("find"); console.log('find')
return "find"; return 'find'
} }
public cacheDir(sourceDir: string, tool: string, version: string, arch?: string): Promise<string> { public cacheDir(
console.log("cacheDir"); sourceDir: string,
return Promise.resolve("cacheDir"); tool: string,
version: string,
arch?: string
): Promise<string> {
console.log('cacheDir')
return Promise.resolve('cacheDir')
} }
public createTempDir(): Promise<string> { public createTempDir(): Promise<string> {
console.log("createTempDir"); console.log('createTempDir')
return Promise.resolve("createTempDir"); return Promise.resolve('createTempDir')
} }
public debug(message: string): void { public debug(message: string): void {
console.log("debug"); console.log('debug')
} }
public setFailed(message: string, done?: boolean): void { public setFailed(message: string, done?: boolean): void {
console.log("setFailed"); console.log('setFailed')
} }
public setSucceeded(message: string, done?: boolean): void { public setSucceeded(message: string, done?: boolean): void {
console.log("setSucceeded"); console.log('setSucceeded')
} }
public exportVariable(name: string, val: string): void { public exportVariable(name: string, val: string): void {
console.log("exportVariable"); console.log('exportVariable')
} }
public getVariable(name: string): string { public getVariable(name: string): string {
console.log("getVariable"); console.log('getVariable')
return "getVariable"; return 'getVariable'
} }
public addPath(inputPath: string): void { public addPath(inputPath: string): void {
console.log("addPath"); console.log('addPath')
} }
public which(tool: string, check?: boolean): Promise<string> { public which(tool: string, check?: boolean): Promise<string> {
console.log("which"); console.log('which')
return Promise.resolve("which"); return Promise.resolve('which')
} }
public exec(exec: string, args: string[]): Promise<IExecResult> { public exec(exec: string, args: string[]): Promise<IExecResult> {
return Promise.resolve({ return Promise.resolve({
code: 0, code: 0,
error: null, error: null,
stderr: "result.stderr", stderr: 'result.stderr',
stdout: "result.stdout", stdout: 'result.stdout'
}); })
} }
public getSourceDir(): string { public getSourceDir(): string {
console.log("getSourceDir"); console.log('getSourceDir')
return "getSourceDir"; return 'getSourceDir'
} }
public setOutput(name: string, value: string): void { public setOutput(name: string, value: string): void {
console.log("setOutput"); console.log('setOutput')
} }
public getInput(input: string, required?: boolean): string { public getInput(input: string, required?: boolean): string {
console.log("getInput"); console.log('getInput')
return "getInput"; return 'getInput'
} }
public getListInput(input: string, required?: boolean): string[] { public getListInput(input: string, required?: boolean): string[] {
console.log("getListInput"); console.log('getListInput')
return ["getInput"]; return ['getInput']
} }
public getBooleanInput(input: string, required?: boolean): boolean { public getBooleanInput(input: string, required?: boolean): boolean {
console.log("getBooleanInput"); console.log('getBooleanInput')
return false; return false
} }
public isValidInputFile(input: string, file: string) { public isValidInputFile(input: string, file: string) {
console.log("isValidInputFile"); console.log('isValidInputFile')
return false; return false
} }
public fileExists(file: string) { public fileExists(file: string) {
console.log("fileExists"); console.log('fileExists')
return false; return false
} }
public directoryExists(file: string) { public directoryExists(file: string) {
console.log("directoryExists"); console.log('directoryExists')
return false; return false
} }
} }
export { export {BuildAgent}
BuildAgent,
};

View File

@@ -1,68 +1,76 @@
import * as fs from "fs"; import * as fs from 'fs'
import * as os from "os"; import * as os from 'os'
import * as path from "path"; import * as path from 'path'
import * as http from "typed-rest-client/HttpClient"; import * as http from 'typed-rest-client/HttpClient'
import { inject, injectable } from "inversify"; import {inject, injectable} from 'inversify'
import { TYPES, IExecResult, IBuildAgent } from "./models"; import {TYPES, IExecResult, IBuildAgent} from './models'
import { IVersionManager } from "./versionManager"; import {IVersionManager} from './versionManager'
export interface IDotnetTool { export interface IDotnetTool {
disableTelemetry(): void; disableTelemetry(): void
toolInstall(toolName: string, versionSpec: string, checkLatest: boolean, includePre: boolean): Promise<string>; toolInstall(
toolName: string,
versionSpec: string,
checkLatest: boolean,
includePre: boolean
): Promise<string>
} }
@injectable() @injectable()
export class DotnetTool implements IDotnetTool { export class DotnetTool implements IDotnetTool {
protected buildAgent: IBuildAgent
protected buildAgent: IBuildAgent; protected versionManager: IVersionManager
protected versionManager: IVersionManager; private httpClient: http.HttpClient
private httpClient: http.HttpClient;
constructor( constructor(
@inject(TYPES.IBuildAgent) buildAgent: IBuildAgent, @inject(TYPES.IBuildAgent) buildAgent: IBuildAgent,
@inject(TYPES.IVersionManager) versionManager: IVersionManager, @inject(TYPES.IVersionManager) versionManager: IVersionManager
) { ) {
this.buildAgent = buildAgent; this.buildAgent = buildAgent
this.versionManager = versionManager; this.versionManager = versionManager
this.httpClient = new http.HttpClient("dotnet"); this.httpClient = new http.HttpClient('dotnet')
} }
public disableTelemetry(): void { public disableTelemetry(): void {
this.buildAgent.exportVariable("DOTNET_CLI_TELEMETRY_OPTOUT", "1"); this.buildAgent.exportVariable('DOTNET_CLI_TELEMETRY_OPTOUT', '1')
} }
public execute(cmd: string, args: string[]): Promise<IExecResult> { public execute(cmd: string, args: string[]): Promise<IExecResult> {
console.log(`Command: ${cmd} ${args.join(' ')}`); console.log(`Command: ${cmd} ${args.join(' ')}`)
return this.buildAgent.exec(cmd, args); return this.buildAgent.exec(cmd, args)
} }
public async toolInstall(toolName: string, versionSpec: string, checkLatest: boolean, includePre: boolean) public async toolInstall(
: Promise<string> { toolName: string,
console.log(""); versionSpec: string,
console.log("--------------------------"); checkLatest: boolean,
console.log(`Installing ${toolName} version ` + versionSpec); includePre: boolean
console.log("--------------------------"); ): Promise<string> {
console.log('')
console.log('--------------------------')
console.log(`Installing ${toolName} version ` + versionSpec)
console.log('--------------------------')
if (this.versionManager.isExplicitVersion(versionSpec)) { if (this.versionManager.isExplicitVersion(versionSpec)) {
checkLatest = false; // check latest doesn't make sense when explicit version checkLatest = false // check latest doesn't make sense when explicit version
} }
let toolPath: string; let toolPath: string
if (!checkLatest) { if (!checkLatest) {
// //
// Let's try and resolve the version spec locally first // Let's try and resolve the version spec locally first
// //
toolPath = this.buildAgent.find(toolName, versionSpec); toolPath = this.buildAgent.find(toolName, versionSpec)
} }
if (!toolPath) { if (!toolPath) {
let version: string; let version: string
if (this.versionManager.isExplicitVersion(versionSpec)) { if (this.versionManager.isExplicitVersion(versionSpec)) {
// //
// Explicit version was specified. No need to query for list of versions. // Explicit version was specified. No need to query for list of versions.
// //
version = versionSpec; version = versionSpec
} else { } else {
// //
// Let's query and resolve the latest version for the versionSpec. // Let's query and resolve the latest version for the versionSpec.
@@ -70,21 +78,27 @@ export class DotnetTool implements IDotnetTool {
// If your tool doesn't offer a mechanism to query, // If your tool doesn't offer a mechanism to query,
// then it can only support exact version inputs. // then it can only support exact version inputs.
// //
version = await this.queryLatestMatch(toolName, versionSpec, includePre); version = await this.queryLatestMatch(
toolName,
versionSpec,
includePre
)
if (!version) { if (!version) {
throw new Error(`Unable to find ${toolName} version '${versionSpec}'.`); throw new Error(
`Unable to find ${toolName} version '${versionSpec}'.`
)
} }
// //
// Check the cache for the resolved version. // Check the cache for the resolved version.
// //
toolPath = this.buildAgent.find(toolName, version); toolPath = this.buildAgent.find(toolName, version)
} }
if (!toolPath) { if (!toolPath) {
// //
// Download, extract, cache // Download, extract, cache
// //
toolPath = await this.acquireTool(toolName, version); toolPath = await this.acquireTool(toolName, version)
} }
} }
@@ -92,62 +106,79 @@ export class DotnetTool implements IDotnetTool {
// Prepend the tools path. This prepends the PATH for the current process and // Prepend the tools path. This prepends the PATH for the current process and
// instructs the agent to prepend for each task that follows. // instructs the agent to prepend for each task that follows.
// //
this.buildAgent.debug(`toolPath: ${toolPath}`); this.buildAgent.debug(`toolPath: ${toolPath}`)
if (os.platform() !== "win32" && !this.buildAgent.getVariable("DOTNET_ROOT")) { if (
let dotnetPath = await this.buildAgent.which("dotnet"); os.platform() !== 'win32' &&
dotnetPath = fs.readlinkSync(dotnetPath) || dotnetPath; !this.buildAgent.getVariable('DOTNET_ROOT')
const dotnetRoot = path.dirname(dotnetPath); ) {
this.buildAgent.exportVariable("DOTNET_ROOT", dotnetRoot); let dotnetPath = await this.buildAgent.which('dotnet')
dotnetPath = fs.readlinkSync(dotnetPath) || dotnetPath
const dotnetRoot = path.dirname(dotnetPath)
this.buildAgent.exportVariable('DOTNET_ROOT', dotnetRoot)
} }
this.buildAgent.addPath(toolPath); this.buildAgent.addPath(toolPath)
return toolPath; return toolPath
} }
private async queryLatestMatch(toolName: string, versionSpec: string, includePrerelease: boolean): Promise<string> { private async queryLatestMatch(
this.buildAgent.debug(`querying tool versions for ${toolName}${versionSpec ? `@${versionSpec}` : ""} ${includePrerelease ? "including pre-releases" : ""}`); toolName: string,
versionSpec: string,
includePrerelease: boolean
): Promise<string> {
this.buildAgent.debug(
`querying tool versions for ${toolName}${
versionSpec ? `@${versionSpec}` : ''
} ${includePrerelease ? 'including pre-releases' : ''}`
)
const downloadPath = `https://api-v2v3search-0.nuget.org/query?q=${encodeURIComponent(toolName.toLowerCase())}&prerelease=${includePrerelease ? "true" : "false"}&semVerLevel=2.0.0`; const downloadPath = `https://api-v2v3search-0.nuget.org/query?q=${encodeURIComponent(
const res = await this.httpClient.get(downloadPath); toolName.toLowerCase()
)}&prerelease=${includePrerelease ? 'true' : 'false'}&semVerLevel=2.0.0`
const res = await this.httpClient.get(downloadPath)
if (!res || res.message.statusCode !== 200) { if (!res || res.message.statusCode !== 200) {
return null; return null
} }
const body: string = await res.readBody(); const body: string = await res.readBody()
const data = JSON.parse(body).data; const data = JSON.parse(body).data
const versions = (data[0].versions as { version: string }[]).map((x) => x.version); const versions = (data[0].versions as {version: string}[]).map(
x => x.version
)
if (!versions || !versions.length) { if (!versions || !versions.length) {
return null; return null
} }
this.buildAgent.debug(`got versions: ${versions.join(", ")}`); this.buildAgent.debug(`got versions: ${versions.join(', ')}`)
return this.versionManager.evaluateVersions(versions, versionSpec); return this.versionManager.evaluateVersions(versions, versionSpec)
} }
private async acquireTool(toolName: string, version: string): Promise<string> { private async acquireTool(
toolName: string,
const tempDirectory = await this.buildAgent.createTempDir(); version: string
let args = ["tool", "install", toolName, "--tool-path", tempDirectory]; ): Promise<string> {
const tempDirectory = await this.buildAgent.createTempDir()
let args = ['tool', 'install', toolName, '--tool-path', tempDirectory]
if (version) { if (version) {
version = this.versionManager.cleanVersion(version); version = this.versionManager.cleanVersion(version)
args = args.concat(["--version", version]); args = args.concat(['--version', version])
} }
const result = await this.execute("dotnet", args); const result = await this.execute('dotnet', args)
const status = result.code === 0 ? "success" : "failure"; const status = result.code === 0 ? 'success' : 'failure'
const message = result.code === 0 ? result.stdout : result.stderr; const message = result.code === 0 ? result.stdout : result.stderr
this.buildAgent.debug(`tool install result: ${status} ${message}`); this.buildAgent.debug(`tool install result: ${status} ${message}`)
if (result.code) { if (result.code) {
throw new Error("Error installing tool"); throw new Error('Error installing tool')
} }
return await this.buildAgent.cacheDir(tempDirectory, toolName, version); return await this.buildAgent.cacheDir(tempDirectory, toolName, version)
} }
} }

View File

@@ -1,11 +1,11 @@
import { Container } from "inversify"; import {Container} from 'inversify'
import { IVersionManager, VersionManager } from "./versionManager"; import {IVersionManager, VersionManager} from './versionManager'
import { TYPES, IBuildAgent } from "./models"; import {TYPES, IBuildAgent} from './models'
import { BuildAgent } from "../agent/mock/build-agent"; import {BuildAgent} from '../agent/mock/build-agent'
const container = new Container(); const container = new Container()
container.bind<IVersionManager>(TYPES.IVersionManager).to(VersionManager); container.bind<IVersionManager>(TYPES.IVersionManager).to(VersionManager)
container.bind<IBuildAgent>(TYPES.IBuildAgent).to(BuildAgent); container.bind<IBuildAgent>(TYPES.IBuildAgent).to(BuildAgent)
export default container; export default container

View File

@@ -1,49 +1,54 @@
export const TYPES = { export const TYPES = {
IBuildAgent: Symbol.for("BuildAgent"), IBuildAgent: Symbol.for('BuildAgent'),
IDotnetTool: Symbol.for("DotnetTool"), IDotnetTool: Symbol.for('DotnetTool'),
IGitVersionTool: Symbol.for("GitVersionTool"), IGitVersionTool: Symbol.for('GitVersionTool'),
IGitReleaseManagerTool: Symbol.for("GitReleaseManagerTool"), IGitReleaseManagerTool: Symbol.for('GitReleaseManagerTool'),
IVersionManager: Symbol.for("VersionManager"), IVersionManager: Symbol.for('VersionManager')
}; }
export enum SetupFields { export enum SetupFields {
includePrerelease = "includePrerelease", includePrerelease = 'includePrerelease',
versionSpec = "versionSpec", versionSpec = 'versionSpec'
}; }
export interface ISetupSettings { export interface ISetupSettings {
[SetupFields.versionSpec]: string; [SetupFields.versionSpec]: string
[SetupFields.includePrerelease]: boolean; [SetupFields.includePrerelease]: boolean
} }
export interface IExecResult { export interface IExecResult {
stdout: string; stdout: string
stderr: string; stderr: string
code: number; code: number
error: Error; error: Error
} }
export interface IBuildAgent { export interface IBuildAgent {
agentName: string; agentName: string
find(toolName: string, versionSpec: string, arch?: string): string; find(toolName: string, versionSpec: string, arch?: string): string
cacheDir(sourceDir: string, tool: string, version: string, arch?: string): Promise<string>; cacheDir(
createTempDir(): Promise<string>; sourceDir: string,
debug(message: string): void; tool: string,
setFailed(message: string, done?: boolean): void; version: string,
setSucceeded(message: string, done?: boolean): void; arch?: string
exportVariable(name: string, val: string): void; ): Promise<string>
getVariable(name: string): string; createTempDir(): Promise<string>
addPath(inputPath: string): void; debug(message: string): void
which(tool: string, check?: boolean): Promise<string>; setFailed(message: string, done?: boolean): void
exec(exec: string, args: string[]): Promise<IExecResult>; setSucceeded(message: string, done?: boolean): void
exportVariable(name: string, val: string): void
getVariable(name: string): string
addPath(inputPath: string): void
which(tool: string, check?: boolean): Promise<string>
exec(exec: string, args: string[]): Promise<IExecResult>
getSourceDir(): string; getSourceDir(): string
isValidInputFile(input: string, file: string): boolean; isValidInputFile(input: string, file: string): boolean
fileExists(file: string): boolean; fileExists(file: string): boolean
directoryExists(file: string): boolean; directoryExists(file: string): boolean
setOutput(name: string, value: string): void; setOutput(name: string, value: string): void
getInput(input: string, required?: boolean): string; getInput(input: string, required?: boolean): string
getListInput(input: string, required?: boolean): string[]; getListInput(input: string, required?: boolean): string[]
getBooleanInput(input: string, required?: boolean): boolean; getBooleanInput(input: string, required?: boolean): boolean
} }

View File

@@ -1,10 +1,11 @@
import { IBuildAgent, SetupFields, ISetupSettings } from "./models"; import {IBuildAgent, SetupFields, ISetupSettings} from './models'
export class Settings { export class Settings {
public static getSetupSettings(buildAgent: IBuildAgent): ISetupSettings { public static getSetupSettings(buildAgent: IBuildAgent): ISetupSettings {
const versionSpec = buildAgent.getInput(SetupFields.versionSpec); const versionSpec = buildAgent.getInput(SetupFields.versionSpec)
const includePrerelease = buildAgent.getBooleanInput(SetupFields.includePrerelease); const includePrerelease = buildAgent.getBooleanInput(
SetupFields.includePrerelease
)
return { return {
versionSpec, versionSpec,

View File

@@ -1,59 +1,56 @@
import cmp from "semver-compare"; import cmp from 'semver-compare'
import * as semver from "semver"; import * as semver from 'semver'
import { injectable, inject } from "inversify"; import {injectable, inject} from 'inversify'
import { IBuildAgent, TYPES } from "./models"; import {IBuildAgent, TYPES} from './models'
export interface IVersionManager { export interface IVersionManager {
isExplicitVersion(versionSpec: string): boolean; isExplicitVersion(versionSpec: string): boolean
evaluateVersions(versions: string[], versionSpec: string): string; evaluateVersions(versions: string[], versionSpec: string): string
cleanVersion(version: string): string; cleanVersion(version: string): string
} }
@injectable() @injectable()
export class VersionManager implements IVersionManager { export class VersionManager implements IVersionManager {
private buildAgent: IBuildAgent
private buildAgent: IBuildAgent; constructor(@inject(TYPES.IBuildAgent) buildAgent: IBuildAgent) {
constructor( this.buildAgent = buildAgent
@inject(TYPES.IBuildAgent) buildAgent: IBuildAgent,
) {
this.buildAgent = buildAgent;
} }
public isExplicitVersion(versionSpec: string): boolean { public isExplicitVersion(versionSpec: string): boolean {
const c = semver.clean(versionSpec); const c = semver.clean(versionSpec)
this.buildAgent.debug("isExplicit: " + c); this.buildAgent.debug('isExplicit: ' + c)
const valid = semver.valid(c) != null; const valid = semver.valid(c) != null
this.buildAgent.debug("explicit? " + valid); this.buildAgent.debug('explicit? ' + valid)
return valid; return valid
} }
public evaluateVersions(versions: string[], versionSpec: string): string { public evaluateVersions(versions: string[], versionSpec: string): string {
let version: string; let version: string
this.buildAgent.debug("evaluating " + versions.length + " versions"); this.buildAgent.debug('evaluating ' + versions.length + ' versions')
versions = versions.sort(cmp); versions = versions.sort(cmp)
for (let i = versions.length - 1; i >= 0; i--) { for (let i = versions.length - 1; i >= 0; i--) {
const potential: string = versions[i]; const potential: string = versions[i]
const satisfied: boolean = semver.satisfies(potential, versionSpec); const satisfied: boolean = semver.satisfies(potential, versionSpec)
if (satisfied) { if (satisfied) {
version = potential; version = potential
break; break
}
} }
}
if (version) { if (version) {
this.buildAgent.debug("matched: " + version); this.buildAgent.debug('matched: ' + version)
} else { } else {
this.buildAgent.debug("match not found"); this.buildAgent.debug('match not found')
} }
return version; return version
} }
public cleanVersion(version: string): string { public cleanVersion(version: string): string {
this.buildAgent.debug("cleaning: " + version); this.buildAgent.debug('cleaning: ' + version)
return semver.clean(version); return semver.clean(version)
} }
} }

View File

@@ -1,4 +1,4 @@
import "reflect-metadata"; import 'reflect-metadata'
import { addAsset } from "./main"; import {addAsset} from './main'
addAsset(); addAsset()

View File

@@ -1,4 +1,4 @@
import "reflect-metadata"; import 'reflect-metadata'
import { close } from "./main"; import {close} from './main'
close(); close()

View File

@@ -1,4 +1,4 @@
import "reflect-metadata"; import 'reflect-metadata'
import { create } from "./main"; import {create} from './main'
create(); create()

View File

@@ -1,4 +1,4 @@
import "reflect-metadata"; import 'reflect-metadata'
import { discard } from "./main"; import {discard} from './main'
discard(); discard()

View File

@@ -1,116 +1,140 @@
import { IBuildAgent, TYPES, SetupFields } from "../../core/models"; import {IBuildAgent, TYPES, SetupFields} from '../../core/models'
import { IGitReleaseManagerTool, GitReleaseManagerTool } from "../../tools/gitreleasemanager/tool"; import {
import { Settings as CommonSettings } from "../../core/settings"; IGitReleaseManagerTool,
import { Settings } from "../../tools/gitreleasemanager/settings"; GitReleaseManagerTool
} from '../../tools/gitreleasemanager/tool'
import {Settings as CommonSettings} from '../../core/settings'
import {Settings} from '../../tools/gitreleasemanager/settings'
import container from "../../core/ioc"; import container from '../../core/ioc'
container.bind<IGitReleaseManagerTool>(TYPES.IGitReleaseManagerTool).to(GitReleaseManagerTool); container
.bind<IGitReleaseManagerTool>(TYPES.IGitReleaseManagerTool)
.to(GitReleaseManagerTool)
const gitReleaseManagerTool = container.get<IGitReleaseManagerTool>(TYPES.IGitReleaseManagerTool); const gitReleaseManagerTool = container.get<IGitReleaseManagerTool>(
const buildAgent = container.get<IBuildAgent>(TYPES.IBuildAgent); TYPES.IGitReleaseManagerTool
)
const buildAgent = container.get<IBuildAgent>(TYPES.IBuildAgent)
export async function setup() { export async function setup() {
try { try {
gitReleaseManagerTool.disableTelemetry()
gitReleaseManagerTool.disableTelemetry(); const settings = CommonSettings.getSetupSettings(buildAgent)
const settings = CommonSettings.getSetupSettings(buildAgent); await gitReleaseManagerTool.install(
settings.versionSpec,
settings.includePrerelease
)
await gitReleaseManagerTool.install(settings.versionSpec, settings.includePrerelease); buildAgent.setSucceeded(
'GitVersionManager installed successfully',
buildAgent.setSucceeded("GitVersionManager installed successfully", true); true
)
} catch (error) { } catch (error) {
buildAgent.setFailed(error.message, true); buildAgent.setFailed(error.message, true)
} }
} }
export async function create() { export async function create() {
try { try {
gitReleaseManagerTool.disableTelemetry()
gitReleaseManagerTool.disableTelemetry(); const settings = Settings.getCreateSettings(buildAgent)
const settings = Settings.getCreateSettings(buildAgent); await gitReleaseManagerTool.create(settings)
await gitReleaseManagerTool.create(settings); buildAgent.setSucceeded(
'GitVersionManager created release successfully',
buildAgent.setSucceeded("GitVersionManager created release successfully", true); true
)
} catch (error) { } catch (error) {
buildAgent.setFailed(error.message, true); buildAgent.setFailed(error.message, true)
} }
} }
export async function discard() { export async function discard() {
try { try {
gitReleaseManagerTool.disableTelemetry()
gitReleaseManagerTool.disableTelemetry(); const settings = Settings.getDiscardSettings(buildAgent)
const settings = Settings.getDiscardSettings(buildAgent); await gitReleaseManagerTool.discard(settings)
await gitReleaseManagerTool.discard(settings); buildAgent.setSucceeded(
'GitVersionManager discarded release successfully',
buildAgent.setSucceeded("GitVersionManager discarded release successfully", true); true
)
} catch (error) { } catch (error) {
buildAgent.setFailed(error.message, true); buildAgent.setFailed(error.message, true)
} }
} }
export async function close() { export async function close() {
try { try {
gitReleaseManagerTool.disableTelemetry()
gitReleaseManagerTool.disableTelemetry(); const settings = Settings.getCloseSettings(buildAgent)
const settings = Settings.getCloseSettings(buildAgent); await gitReleaseManagerTool.close(settings)
await gitReleaseManagerTool.close(settings); buildAgent.setSucceeded(
'GitVersionManager closed release successfully',
buildAgent.setSucceeded("GitVersionManager closed release successfully", true); true
)
} catch (error) { } catch (error) {
buildAgent.setFailed(error.message, true); buildAgent.setFailed(error.message, true)
} }
} }
export async function open() { export async function open() {
try { try {
gitReleaseManagerTool.disableTelemetry()
gitReleaseManagerTool.disableTelemetry(); const settings = Settings.getOpenSettings(buildAgent)
const settings = Settings.getOpenSettings(buildAgent); await gitReleaseManagerTool.open(settings)
await gitReleaseManagerTool.open(settings); buildAgent.setSucceeded(
'GitVersionManager opened release successfully',
buildAgent.setSucceeded("GitVersionManager opened release successfully", true); true
)
} catch (error) { } catch (error) {
buildAgent.setFailed(error.message, true); buildAgent.setFailed(error.message, true)
} }
} }
export async function publish() { export async function publish() {
try { try {
gitReleaseManagerTool.disableTelemetry()
gitReleaseManagerTool.disableTelemetry(); const settings = Settings.getPublishSettings(buildAgent)
const settings = Settings.getPublishSettings(buildAgent); await gitReleaseManagerTool.publish(settings)
await gitReleaseManagerTool.publish(settings); buildAgent.setSucceeded(
'GitVersionManager published release successfully',
buildAgent.setSucceeded("GitVersionManager published release successfully", true); true
)
} catch (error) { } catch (error) {
buildAgent.setFailed(error.message, true); buildAgent.setFailed(error.message, true)
} }
} }
export async function addAsset() { export async function addAsset() {
try { try {
gitReleaseManagerTool.disableTelemetry()
gitReleaseManagerTool.disableTelemetry(); const settings = Settings.getAddAssetSettings(buildAgent)
const settings = Settings.getAddAssetSettings(buildAgent); await gitReleaseManagerTool.addAsset(settings)
await gitReleaseManagerTool.addAsset(settings); buildAgent.setSucceeded(
'GitVersionManager added assets to release successfully',
buildAgent.setSucceeded("GitVersionManager added assets to release successfully", true); true
)
} catch (error) { } catch (error) {
buildAgent.setFailed(error.message, true); buildAgent.setFailed(error.message, true)
} }
} }

View File

@@ -1,4 +1,4 @@
import "reflect-metadata"; import 'reflect-metadata'
import { open } from "./main"; import {open} from './main'
open(); open()

View File

@@ -1,4 +1,4 @@
import "reflect-metadata"; import 'reflect-metadata'
import { publish } from "./main"; import {publish} from './main'
publish(); publish()

View File

@@ -1,4 +1,4 @@
import "reflect-metadata"; import 'reflect-metadata'
import { setup } from "./main"; import {setup} from './main'
setup(); setup()

View File

@@ -1,4 +1,4 @@
import "reflect-metadata"; import 'reflect-metadata'
import { run } from "./main"; import {run} from './main'
run(); run()

View File

@@ -1,50 +1,55 @@
import { IBuildAgent, TYPES, SetupFields } from "../../core/models"; import {IBuildAgent, TYPES, SetupFields} from '../../core/models'
import { Settings as CommonSettings } from "../../core/settings"; import {Settings as CommonSettings} from '../../core/settings'
import { Settings } from "../../tools/gitversion/settings"; import {Settings} from '../../tools/gitversion/settings'
import { IGitVersionTool, GitVersionTool } from "../../tools/gitversion/tool"; import {IGitVersionTool, GitVersionTool} from '../../tools/gitversion/tool'
import { GitVersionSettings, GitVersionOutput } from "../../tools/gitversion/models"; import {
GitVersionSettings,
GitVersionOutput
} from '../../tools/gitversion/models'
import container from "../../core/ioc"; import container from '../../core/ioc'
container.bind<IGitVersionTool>(TYPES.IGitVersionTool).to(GitVersionTool); container.bind<IGitVersionTool>(TYPES.IGitVersionTool).to(GitVersionTool)
const gitVersionTool = container.get<IGitVersionTool>(TYPES.IGitVersionTool); const gitVersionTool = container.get<IGitVersionTool>(TYPES.IGitVersionTool)
const buildAgent = container.get<IBuildAgent>(TYPES.IBuildAgent); const buildAgent = container.get<IBuildAgent>(TYPES.IBuildAgent)
export async function setup() { export async function setup() {
try { try {
gitVersionTool.disableTelemetry()
gitVersionTool.disableTelemetry(); const settings = CommonSettings.getSetupSettings(buildAgent)
const settings = CommonSettings.getSetupSettings(buildAgent); await gitVersionTool.install(
settings.versionSpec,
settings.includePrerelease
)
await gitVersionTool.install(settings.versionSpec, settings.includePrerelease); buildAgent.setSucceeded('GitVersion installed successfully', true)
buildAgent.setSucceeded("GitVersion installed successfully", true);
} catch (error) { } catch (error) {
buildAgent.setFailed(error.message, true); buildAgent.setFailed(error.message, true)
} }
} }
export async function run() { export async function run() {
try { try {
gitVersionTool.disableTelemetry()
gitVersionTool.disableTelemetry(); const settings: GitVersionSettings = Settings.getGitVersionSettings(
buildAgent
)
const settings: GitVersionSettings = Settings.getGitVersionSettings(buildAgent); const result = await gitVersionTool.run(settings)
const result = await gitVersionTool.run(settings); const gitversion = JSON.parse(result.stdout) as GitVersionOutput
gitVersionTool.writeGitVersionToAgent(gitversion)
const gitversion = JSON.parse(result.stdout) as GitVersionOutput;
gitVersionTool.writeGitVersionToAgent(gitversion);
if (result.code === 0) { if (result.code === 0) {
buildAgent.setSucceeded("GitVersion executed successfully", true); buildAgent.setSucceeded('GitVersion executed successfully', true)
} else { } else {
buildAgent.setFailed(result.error.message, true); buildAgent.setFailed(result.error.message, true)
} }
} catch (error) { } catch (error) {
buildAgent.setFailed(error, true); buildAgent.setFailed(error, true)
} }
} }

View File

@@ -1,4 +1,4 @@
import "reflect-metadata"; import 'reflect-metadata'
import { setup } from "./main"; import {setup} from './main'
setup(); setup()

View File

@@ -1,73 +1,79 @@
export enum CommonFields { export enum CommonFields {
repository = "repository", repository = 'repository',
owner = "owner", owner = 'owner',
token = "token", token = 'token',
targetDirectory = "targetDirectory", targetDirectory = 'targetDirectory'
} }
export enum CreateFields { export enum CreateFields {
milestone = "milestone", milestone = 'milestone',
name = "name", name = 'name',
inputFileName = "inputFileName", inputFileName = 'inputFileName',
isPreRelease = "isPreRelease", isPreRelease = 'isPreRelease',
commit = "commit", commit = 'commit',
assets = "assets", assets = 'assets'
} }
export enum DiscardFields { export enum DiscardFields {
milestone = "milestone", milestone = 'milestone'
} }
export enum CloseFields { export enum CloseFields {
milestone = "milestone", milestone = 'milestone'
} }
export enum OpenFields { export enum OpenFields {
milestone = "milestone", milestone = 'milestone'
} }
export enum PublishFields { export enum PublishFields {
tagName = "tagName", tagName = 'tagName'
} }
export enum AddAssetFields { export enum AddAssetFields {
tagName = "tagName", tagName = 'tagName',
assets = "assets", assets = 'assets'
} }
export interface GitReleaseManagerSettings { export interface GitReleaseManagerSettings {
[CommonFields.repository]: string; [CommonFields.repository]: string
[CommonFields.owner]: string; [CommonFields.owner]: string
[CommonFields.token]: string; [CommonFields.token]: string
[CommonFields.targetDirectory]: string; [CommonFields.targetDirectory]: string
} }
export interface GitReleaseManagerCreateSettings extends GitReleaseManagerSettings { export interface GitReleaseManagerCreateSettings
[CreateFields.milestone]: string; extends GitReleaseManagerSettings {
[CreateFields.name]: string; [CreateFields.milestone]: string
[CreateFields.inputFileName]: string; [CreateFields.name]: string
[CreateFields.isPreRelease]: boolean; [CreateFields.inputFileName]: string
[CreateFields.commit]: string; [CreateFields.isPreRelease]: boolean
[CreateFields.assets]?: string[]; [CreateFields.commit]: string
[CreateFields.assets]?: string[]
} }
export interface GitReleaseManagerDiscardSettings extends GitReleaseManagerSettings { export interface GitReleaseManagerDiscardSettings
[DiscardFields.milestone]: string; extends GitReleaseManagerSettings {
[DiscardFields.milestone]: string
} }
export interface GitReleaseManagerCloseSettings extends GitReleaseManagerSettings { export interface GitReleaseManagerCloseSettings
[CloseFields.milestone]: string; extends GitReleaseManagerSettings {
[CloseFields.milestone]: string
} }
export interface GitReleaseManagerOpenSettings extends GitReleaseManagerSettings { export interface GitReleaseManagerOpenSettings
[OpenFields.milestone]: string; extends GitReleaseManagerSettings {
[OpenFields.milestone]: string
} }
export interface GitReleaseManagerPublishSettings extends GitReleaseManagerSettings { export interface GitReleaseManagerPublishSettings
[PublishFields.tagName]: string; extends GitReleaseManagerSettings {
[PublishFields.tagName]: string
} }
export interface GitReleaseManagerAddAssetSettings extends GitReleaseManagerSettings { export interface GitReleaseManagerAddAssetSettings
[AddAssetFields.tagName]: string; extends GitReleaseManagerSettings {
[AddAssetFields.assets]: string[]; [AddAssetFields.tagName]: string
[AddAssetFields.assets]: string[]
} }

View File

@@ -1,29 +1,35 @@
import { IBuildAgent } from "../../core/models"; import {IBuildAgent} from '../../core/models'
import { import {
GitReleaseManagerSettings, GitReleaseManagerSettings,
CommonFields, CreateFields, DiscardFields, CommonFields,
CloseFields, OpenFields, PublishFields, CreateFields,
DiscardFields,
CloseFields,
OpenFields,
PublishFields,
AddAssetFields, AddAssetFields,
GitReleaseManagerCreateSettings, GitReleaseManagerCreateSettings,
GitReleaseManagerDiscardSettings, GitReleaseManagerDiscardSettings,
GitReleaseManagerCloseSettings, GitReleaseManagerCloseSettings,
GitReleaseManagerOpenSettings, GitReleaseManagerOpenSettings,
GitReleaseManagerPublishSettings, GitReleaseManagerPublishSettings,
GitReleaseManagerAddAssetSettings, GitReleaseManagerAddAssetSettings
} from "./models"; } from './models'
export class Settings { export class Settings {
public static getCreateSettings(
buildAgent: IBuildAgent
): GitReleaseManagerCreateSettings {
const milestone = buildAgent.getInput(CreateFields.milestone)
const name = buildAgent.getInput(CreateFields.name)
const inputFileName = buildAgent.getInput(CreateFields.inputFileName)
const isPreRelease = buildAgent.getBooleanInput(
CreateFields.isPreRelease
)
const commit = buildAgent.getInput(CreateFields.commit)
const assets = buildAgent.getListInput(CreateFields.assets)
public static getCreateSettings(buildAgent: IBuildAgent): GitReleaseManagerCreateSettings { const commonSettings = Settings.getCommonSettings(buildAgent)
const milestone = buildAgent.getInput(CreateFields.milestone);
const name = buildAgent.getInput(CreateFields.name);
const inputFileName = buildAgent.getInput(CreateFields.inputFileName);
const isPreRelease = buildAgent.getBooleanInput(CreateFields.isPreRelease);
const commit = buildAgent.getInput(CreateFields.commit);
const assets = buildAgent.getListInput(CreateFields.assets);
const commonSettings = Settings.getCommonSettings(buildAgent);
return { return {
...commonSettings, ...commonSettings,
milestone, milestone,
@@ -35,51 +41,61 @@ export class Settings {
} }
} }
public static getDiscardSettings(buildAgent: IBuildAgent): GitReleaseManagerDiscardSettings { public static getDiscardSettings(
const milestone = buildAgent.getInput(DiscardFields.milestone); buildAgent: IBuildAgent
): GitReleaseManagerDiscardSettings {
const milestone = buildAgent.getInput(DiscardFields.milestone)
const commonSettings = Settings.getCommonSettings(buildAgent); const commonSettings = Settings.getCommonSettings(buildAgent)
return { return {
...commonSettings, ...commonSettings,
milestone, milestone
} }
} }
public static getCloseSettings(buildAgent: IBuildAgent): GitReleaseManagerCloseSettings { public static getCloseSettings(
const milestone = buildAgent.getInput(CloseFields.milestone); buildAgent: IBuildAgent
): GitReleaseManagerCloseSettings {
const milestone = buildAgent.getInput(CloseFields.milestone)
const commonSettings = Settings.getCommonSettings(buildAgent); const commonSettings = Settings.getCommonSettings(buildAgent)
return { return {
...commonSettings, ...commonSettings,
milestone, milestone
} }
} }
public static getOpenSettings(buildAgent: IBuildAgent): GitReleaseManagerOpenSettings { public static getOpenSettings(
const milestone = buildAgent.getInput(OpenFields.milestone); buildAgent: IBuildAgent
): GitReleaseManagerOpenSettings {
const milestone = buildAgent.getInput(OpenFields.milestone)
const commonSettings = Settings.getCommonSettings(buildAgent); const commonSettings = Settings.getCommonSettings(buildAgent)
return { return {
...commonSettings, ...commonSettings,
milestone, milestone
} }
} }
public static getPublishSettings(buildAgent: IBuildAgent): GitReleaseManagerPublishSettings { public static getPublishSettings(
const tagName = buildAgent.getInput(PublishFields.tagName); buildAgent: IBuildAgent
): GitReleaseManagerPublishSettings {
const tagName = buildAgent.getInput(PublishFields.tagName)
const commonSettings = Settings.getCommonSettings(buildAgent); const commonSettings = Settings.getCommonSettings(buildAgent)
return { return {
...commonSettings, ...commonSettings,
tagName, tagName
} }
} }
public static getAddAssetSettings(buildAgent: IBuildAgent): GitReleaseManagerAddAssetSettings { public static getAddAssetSettings(
const tagName = buildAgent.getInput(AddAssetFields.tagName); buildAgent: IBuildAgent
const assets = buildAgent.getListInput(AddAssetFields.assets); ): GitReleaseManagerAddAssetSettings {
const tagName = buildAgent.getInput(AddAssetFields.tagName)
const assets = buildAgent.getListInput(AddAssetFields.assets)
const commonSettings = Settings.getCommonSettings(buildAgent); const commonSettings = Settings.getCommonSettings(buildAgent)
return { return {
...commonSettings, ...commonSettings,
tagName, tagName,
@@ -87,17 +103,21 @@ export class Settings {
} }
} }
private static getCommonSettings(buildAgent: IBuildAgent): GitReleaseManagerSettings { private static getCommonSettings(
const owner = buildAgent.getInput(CommonFields.owner, true); buildAgent: IBuildAgent
const repository = buildAgent.getInput(CommonFields.repository, true); ): GitReleaseManagerSettings {
const token = buildAgent.getInput(CommonFields.token, true); const owner = buildAgent.getInput(CommonFields.owner, true)
const targetDirectory = buildAgent.getInput(CommonFields.targetDirectory); const repository = buildAgent.getInput(CommonFields.repository, true)
const token = buildAgent.getInput(CommonFields.token, true)
const targetDirectory = buildAgent.getInput(
CommonFields.targetDirectory
)
return { return {
owner, owner,
repository, repository,
token, token,
targetDirectory, targetDirectory
}; }
} }
} }

View File

@@ -1,9 +1,9 @@
import path = require("path"); import path = require('path')
import { TYPES, IBuildAgent, IExecResult } from "../../core/models"; import {TYPES, IBuildAgent, IExecResult} from '../../core/models'
import { injectable, inject } from "inversify"; import {injectable, inject} from 'inversify'
import { DotnetTool, IDotnetTool } from "../../core/dotnet-tool"; import {DotnetTool, IDotnetTool} from '../../core/dotnet-tool'
import { IVersionManager } from "../../core/versionManager"; import {IVersionManager} from '../../core/versionManager'
import { import {
GitReleaseManagerSettings, GitReleaseManagerSettings,
@@ -12,186 +12,222 @@ import {
GitReleaseManagerCloseSettings, GitReleaseManagerCloseSettings,
GitReleaseManagerOpenSettings, GitReleaseManagerOpenSettings,
GitReleaseManagerPublishSettings, GitReleaseManagerPublishSettings,
GitReleaseManagerAddAssetSettings, GitReleaseManagerAddAssetSettings
} from "./models"; } from './models'
export interface IGitReleaseManagerTool extends IDotnetTool { export interface IGitReleaseManagerTool extends IDotnetTool {
install(versionSpec: string, includePrerelease: boolean): Promise<void>; install(versionSpec: string, includePrerelease: boolean): Promise<void>
create(settings: GitReleaseManagerCreateSettings): Promise<IExecResult>; create(settings: GitReleaseManagerCreateSettings): Promise<IExecResult>
discard(settings: GitReleaseManagerDiscardSettings): Promise<IExecResult>; discard(settings: GitReleaseManagerDiscardSettings): Promise<IExecResult>
close(settings: GitReleaseManagerCloseSettings): Promise<IExecResult>; close(settings: GitReleaseManagerCloseSettings): Promise<IExecResult>
open(settings: GitReleaseManagerOpenSettings): Promise<IExecResult>; open(settings: GitReleaseManagerOpenSettings): Promise<IExecResult>
publish(settings: GitReleaseManagerPublishSettings): Promise<IExecResult>; publish(settings: GitReleaseManagerPublishSettings): Promise<IExecResult>
addAsset(settings: GitReleaseManagerAddAssetSettings): Promise<IExecResult>; addAsset(settings: GitReleaseManagerAddAssetSettings): Promise<IExecResult>
} }
@injectable() @injectable()
export class GitReleaseManagerTool extends DotnetTool implements IGitReleaseManagerTool { export class GitReleaseManagerTool extends DotnetTool
implements IGitReleaseManagerTool {
constructor( constructor(
@inject(TYPES.IBuildAgent) buildAgent: IBuildAgent, @inject(TYPES.IBuildAgent) buildAgent: IBuildAgent,
@inject(TYPES.IVersionManager) versionManager: IVersionManager @inject(TYPES.IVersionManager) versionManager: IVersionManager
) { ) {
super(buildAgent, versionManager); super(buildAgent, versionManager)
} }
public async install(versionSpec: string, includePrerelease: boolean): Promise<void> { public async install(
await this.toolInstall("GitReleaseManager.Tool", versionSpec, false, includePrerelease); versionSpec: string,
includePrerelease: boolean
): Promise<void> {
await this.toolInstall(
'GitReleaseManager.Tool',
versionSpec,
false,
includePrerelease
)
} }
public create(settings: GitReleaseManagerCreateSettings): Promise<IExecResult> { public create(
const args = this.getCreateArguments(settings); settings: GitReleaseManagerCreateSettings
): Promise<IExecResult> {
const args = this.getCreateArguments(settings)
return this.execute("dotnet-gitreleasemanager", args); return this.execute('dotnet-gitreleasemanager', args)
} }
public discard(settings: GitReleaseManagerDiscardSettings): Promise<IExecResult> { public discard(
const args = this.getDiscardArguments(settings); settings: GitReleaseManagerDiscardSettings
): Promise<IExecResult> {
const args = this.getDiscardArguments(settings)
return this.execute("dotnet-gitreleasemanager", args); return this.execute('dotnet-gitreleasemanager', args)
} }
public close(settings: GitReleaseManagerCloseSettings): Promise<IExecResult> { public close(
const args = this.getCloseArguments(settings); settings: GitReleaseManagerCloseSettings
): Promise<IExecResult> {
const args = this.getCloseArguments(settings)
return this.execute("dotnet-gitreleasemanager", args); return this.execute('dotnet-gitreleasemanager', args)
} }
public open(settings: GitReleaseManagerOpenSettings): Promise<IExecResult> { public open(settings: GitReleaseManagerOpenSettings): Promise<IExecResult> {
const args = this.getOpenArguments(settings); const args = this.getOpenArguments(settings)
return this.execute("dotnet-gitreleasemanager", args); return this.execute('dotnet-gitreleasemanager', args)
} }
public publish(settings: GitReleaseManagerPublishSettings): Promise<IExecResult> { public publish(
const args = this.getPublishArguments(settings); settings: GitReleaseManagerPublishSettings
): Promise<IExecResult> {
const args = this.getPublishArguments(settings)
return this.execute("dotnet-gitreleasemanager", args); return this.execute('dotnet-gitreleasemanager', args)
} }
public addAsset(settings: GitReleaseManagerAddAssetSettings): Promise<IExecResult> { public addAsset(
const args = this.getAddAssetArguments(settings); settings: GitReleaseManagerAddAssetSettings
): Promise<IExecResult> {
const args = this.getAddAssetArguments(settings)
return this.execute("dotnet-gitreleasemanager", args); return this.execute('dotnet-gitreleasemanager', args)
} }
private getCommonArguments(settings: GitReleaseManagerSettings): string[] { private getCommonArguments(settings: GitReleaseManagerSettings): string[] {
const args: string[] = []; const args: string[] = []
args.push("--owner", settings.owner); args.push('--owner', settings.owner)
args.push("--repository", settings.repository); args.push('--repository', settings.repository)
args.push("--token", settings.token); args.push('--token', settings.token)
settings.targetDirectory = this.getRepoDir(settings.targetDirectory); settings.targetDirectory = this.getRepoDir(settings.targetDirectory)
args.push("--targetDirectory", settings.targetDirectory); args.push('--targetDirectory', settings.targetDirectory)
return args; return args
} }
private getCreateArguments(settings: GitReleaseManagerCreateSettings): string[] { private getCreateArguments(
const args: string[] = ['create', ...this.getCommonArguments(settings)]; settings: GitReleaseManagerCreateSettings
): string[] {
const args: string[] = ['create', ...this.getCommonArguments(settings)]
if (settings.milestone) { if (settings.milestone) {
args.push("--milestone", settings.milestone); args.push('--milestone', settings.milestone)
} }
if (settings.name) { if (settings.name) {
args.push("--name", settings.name); args.push('--name', settings.name)
} }
if (settings.commit) { if (settings.commit) {
args.push("--targetcommitish", settings.commit); args.push('--targetcommitish', settings.commit)
} }
if (settings.inputFileName) { if (settings.inputFileName) {
if (this.buildAgent.fileExists(settings.inputFileName)) { if (this.buildAgent.fileExists(settings.inputFileName)) {
args.push("--inputFilePath", settings.inputFileName); args.push('--inputFilePath', settings.inputFileName)
} else { } else {
throw new Error("GitReleaseManager inputFilePath not found at " + settings.inputFileName); throw new Error(
'GitReleaseManager inputFilePath not found at ' +
settings.inputFileName
)
} }
} }
if (settings.isPreRelease) { if (settings.isPreRelease) {
args.push("--pre"); args.push('--pre')
} }
if (settings.assets && settings.assets.length > 0) { if (settings.assets && settings.assets.length > 0) {
settings.assets = settings.assets.map(asset => { settings.assets = settings.assets.map(asset => {
return path.join(settings.targetDirectory, asset) return path.join(settings.targetDirectory, asset)
}) })
args.push("--assets", settings.assets.join(",")); args.push('--assets', settings.assets.join(','))
} }
return args; return args
} }
private getDiscardArguments(settings: GitReleaseManagerDiscardSettings): string[] { private getDiscardArguments(
const args: string[] = ['discard', ...this.getCommonArguments(settings)]; settings: GitReleaseManagerDiscardSettings
): string[] {
const args: string[] = ['discard', ...this.getCommonArguments(settings)]
if (settings.milestone) { if (settings.milestone) {
args.push("--milestone", settings.milestone); args.push('--milestone', settings.milestone)
} }
return args; return args
} }
private getCloseArguments(settings: GitReleaseManagerCloseSettings): string[] { private getCloseArguments(
const args: string[] = ['close', ...this.getCommonArguments(settings)]; settings: GitReleaseManagerCloseSettings
): string[] {
const args: string[] = ['close', ...this.getCommonArguments(settings)]
if (settings.milestone) { if (settings.milestone) {
args.push("--milestone", settings.milestone); args.push('--milestone', settings.milestone)
} }
return args; return args
} }
private getOpenArguments(settings: GitReleaseManagerOpenSettings): string[] { private getOpenArguments(
const args: string[] = ['open', ...this.getCommonArguments(settings)]; settings: GitReleaseManagerOpenSettings
): string[] {
const args: string[] = ['open', ...this.getCommonArguments(settings)]
if (settings.milestone) { if (settings.milestone) {
args.push("--milestone", settings.milestone); args.push('--milestone', settings.milestone)
} }
return args; return args
} }
private getPublishArguments(settings: GitReleaseManagerPublishSettings): string[] { private getPublishArguments(
const args: string[] = ['publish', ...this.getCommonArguments(settings)]; settings: GitReleaseManagerPublishSettings
): string[] {
const args: string[] = ['publish', ...this.getCommonArguments(settings)]
if (settings.tagName) { if (settings.tagName) {
args.push("--tagName", settings.tagName); args.push('--tagName', settings.tagName)
} }
return args; return args
} }
private getAddAssetArguments(settings: GitReleaseManagerAddAssetSettings): string[] { private getAddAssetArguments(
const args: string[] = ['addasset', ...this.getCommonArguments(settings)]; settings: GitReleaseManagerAddAssetSettings
): string[] {
const args: string[] = [
'addasset',
...this.getCommonArguments(settings)
]
if (settings.tagName) { if (settings.tagName) {
args.push("--tagName", settings.tagName); args.push('--tagName', settings.tagName)
} }
if (settings.assets && settings.assets.length > 0) { if (settings.assets && settings.assets.length > 0) {
settings.assets = settings.assets.map(asset => { settings.assets = settings.assets.map(asset => {
return path.join(settings.targetDirectory, asset) return path.join(settings.targetDirectory, asset)
}) })
args.push("--assets", settings.assets.join(",")); args.push('--assets', settings.assets.join(','))
} }
return args; return args
} }
private getRepoDir(targetPath: string): string { private getRepoDir(targetPath: string): string {
let workDir: string; let workDir: string
const srcDir = this.buildAgent.getSourceDir(); const srcDir = this.buildAgent.getSourceDir()
if (!targetPath) { if (!targetPath) {
workDir = srcDir; workDir = srcDir
} else { } else {
if (this.buildAgent.directoryExists(targetPath)) { if (this.buildAgent.directoryExists(targetPath)) {
workDir = path.join(srcDir, targetPath); workDir = path.join(srcDir, targetPath)
} else { } else {
throw new Error("Directory not found at " + targetPath); throw new Error('Directory not found at ' + targetPath)
} }
} }
return workDir.replace(/\\/g, "/"); return workDir.replace(/\\/g, '/')
} }
} }

View File

@@ -1,52 +1,52 @@
export enum ExecuteFields { export enum ExecuteFields {
targetPath = "targetPath", targetPath = 'targetPath',
useConfigFile = "useConfigFile", useConfigFile = 'useConfigFile',
configFilePath = "configFilePath", configFilePath = 'configFilePath',
updateAssemblyInfo = "updateAssemblyInfo", updateAssemblyInfo = 'updateAssemblyInfo',
updateAssemblyInfoFilename = "updateAssemblyInfoFilename", updateAssemblyInfoFilename = 'updateAssemblyInfoFilename',
additionalArguments = "additionalArguments", additionalArguments = 'additionalArguments',
srcDir = "srcDir", srcDir = 'srcDir'
}; }
export interface GitVersionSettings { export interface GitVersionSettings {
[ExecuteFields.targetPath]: string; [ExecuteFields.targetPath]: string
[ExecuteFields.useConfigFile]: boolean; [ExecuteFields.useConfigFile]: boolean
[ExecuteFields.configFilePath]: string; [ExecuteFields.configFilePath]: string
[ExecuteFields.updateAssemblyInfo]: boolean; [ExecuteFields.updateAssemblyInfo]: boolean
[ExecuteFields.updateAssemblyInfoFilename]: string; [ExecuteFields.updateAssemblyInfoFilename]: string
[ExecuteFields.additionalArguments]: string; [ExecuteFields.additionalArguments]: string
[ExecuteFields.srcDir]: string; [ExecuteFields.srcDir]: string
} }
export interface GitVersionOutput { export interface GitVersionOutput {
Major: number; Major: number
Minor: number; Minor: number
Patch: number; Patch: number
PreReleaseTag: string; PreReleaseTag: string
PreReleaseTagWithDash: string; PreReleaseTagWithDash: string
PreReleaseLabel: string; PreReleaseLabel: string
PreReleaseNumber: number; PreReleaseNumber: number
WeightedPreReleaseNumber: number; WeightedPreReleaseNumber: number
BuildMetaData: number; BuildMetaData: number
BuildMetaDataPadded: string; BuildMetaDataPadded: string
FullBuildMetaData: string; FullBuildMetaData: string
MajorMinorPatch: string; MajorMinorPatch: string
SemVer: string; SemVer: string
LegacySemVer: string; LegacySemVer: string
LegacySemVerPadded: string; LegacySemVerPadded: string
AssemblySemVer: string; AssemblySemVer: string
AssemblySemFileVer: string; AssemblySemFileVer: string
FullSemVer: string; FullSemVer: string
InformationalVersion: string; InformationalVersion: string
BranchName: string; BranchName: string
Sha: string; Sha: string
ShortSha: string; ShortSha: string
NuGetVersionV2: string; NuGetVersionV2: string
NuGetVersion: string; NuGetVersion: string
NuGetPreReleaseTagV2: string; NuGetPreReleaseTagV2: string
NuGetPreReleaseTag: string; NuGetPreReleaseTag: string
VersionSourceSha: string; VersionSourceSha: string
CommitsSinceVersionSource: number; CommitsSinceVersionSource: number
CommitsSinceVersionSourcePadded: string; CommitsSinceVersionSourcePadded: string
CommitDate: string; CommitDate: string
} }

View File

@@ -1,21 +1,30 @@
import { IBuildAgent } from "../../core/models"; import {IBuildAgent} from '../../core/models'
import { GitVersionSettings, ExecuteFields } from "./models"; import {GitVersionSettings, ExecuteFields} from './models'
export class Settings { export class Settings {
public static getGitVersionSettings(
buildAgent: IBuildAgent
): GitVersionSettings {
const targetPath = buildAgent.getInput(ExecuteFields.targetPath)
public static getGitVersionSettings(buildAgent: IBuildAgent): GitVersionSettings { const useConfigFile = buildAgent.getBooleanInput(
const targetPath = buildAgent.getInput(ExecuteFields.targetPath); ExecuteFields.useConfigFile
)
const configFilePath = buildAgent.getInput(ExecuteFields.configFilePath)
const useConfigFile = buildAgent.getBooleanInput(ExecuteFields.useConfigFile); const updateAssemblyInfo = buildAgent.getBooleanInput(
const configFilePath = buildAgent.getInput(ExecuteFields.configFilePath); ExecuteFields.updateAssemblyInfo
)
const updateAssemblyInfoFilename = buildAgent.getInput(
ExecuteFields.updateAssemblyInfoFilename
)
const updateAssemblyInfo = buildAgent.getBooleanInput(ExecuteFields.updateAssemblyInfo); const additionalArguments = buildAgent.getInput(
const updateAssemblyInfoFilename = buildAgent.getInput(ExecuteFields.updateAssemblyInfoFilename); ExecuteFields.additionalArguments
)
const additionalArguments = buildAgent.getInput(ExecuteFields.additionalArguments); const srcDir = buildAgent.getSourceDir().replace(/\\/g, '/')
const srcDir = buildAgent.getSourceDir().replace(/\\/g, "/");
return { return {
targetPath, targetPath,
@@ -24,7 +33,7 @@ export class Settings {
updateAssemblyInfo, updateAssemblyInfo,
updateAssemblyInfoFilename, updateAssemblyInfoFilename,
additionalArguments, additionalArguments,
srcDir, srcDir
}; }
} }
} }

View File

@@ -1,120 +1,183 @@
import path = require("path"); import path = require('path')
import { injectable, inject } from "inversify"; import {injectable, inject} from 'inversify'
import { IExecResult, IBuildAgent, TYPES } from "../../core/models"; import {IExecResult, IBuildAgent, TYPES} from '../../core/models'
import { DotnetTool, IDotnetTool } from "../../core/dotnet-tool"; import {DotnetTool, IDotnetTool} from '../../core/dotnet-tool'
import { GitVersionSettings, GitVersionOutput, ExecuteFields } from "./models"; import {GitVersionSettings, GitVersionOutput, ExecuteFields} from './models'
import { IVersionManager } from "../../core/versionManager"; import {IVersionManager} from '../../core/versionManager'
export interface IGitVersionTool extends IDotnetTool { export interface IGitVersionTool extends IDotnetTool {
install(versionSpec: string, includePrerelease: boolean): Promise<void>; install(versionSpec: string, includePrerelease: boolean): Promise<void>
run(options: GitVersionSettings): Promise<IExecResult>; run(options: GitVersionSettings): Promise<IExecResult>
writeGitVersionToAgent(gitversion: GitVersionOutput): void; writeGitVersionToAgent(gitversion: GitVersionOutput): void
} }
@injectable() @injectable()
export class GitVersionTool extends DotnetTool implements IGitVersionTool { export class GitVersionTool extends DotnetTool implements IGitVersionTool {
constructor( constructor(
@inject(TYPES.IBuildAgent) buildAgent: IBuildAgent, @inject(TYPES.IBuildAgent) buildAgent: IBuildAgent,
@inject(TYPES.IVersionManager) versionManager: IVersionManager @inject(TYPES.IVersionManager) versionManager: IVersionManager
) { ) {
super(buildAgent, versionManager); super(buildAgent, versionManager)
} }
public async install(versionSpec: string, includePrerelease: boolean): Promise<void> { public async install(
await this.toolInstall("GitVersion.Tool", versionSpec, false, includePrerelease); versionSpec: string,
includePrerelease: boolean
): Promise<void> {
await this.toolInstall(
'GitVersion.Tool',
versionSpec,
false,
includePrerelease
)
} }
public run(options: GitVersionSettings): Promise<IExecResult> { public run(options: GitVersionSettings): Promise<IExecResult> {
const workDir = this.getRepoDir(options.targetPath); const workDir = this.getRepoDir(options.targetPath)
const args = this.getArguments(workDir, options); const args = this.getArguments(workDir, options)
return this.execute("dotnet-gitversion", args); return this.execute('dotnet-gitversion', args)
} }
private getRepoDir(targetPath: string): string { private getRepoDir(targetPath: string): string {
let workDir: string; let workDir: string
const srcDir = this.buildAgent.getSourceDir(); const srcDir = this.buildAgent.getSourceDir()
if (!targetPath) { if (!targetPath) {
workDir = srcDir; workDir = srcDir
} else { } else {
if (this.buildAgent.directoryExists(targetPath)) { if (this.buildAgent.directoryExists(targetPath)) {
workDir = path.join(srcDir, targetPath); workDir = path.join(srcDir, targetPath)
} else { } else {
throw new Error("Directory not found at " + targetPath); throw new Error('Directory not found at ' + targetPath)
} }
} }
return workDir.replace(/\\/g, "/"); return workDir.replace(/\\/g, '/')
} }
private getArguments(workDir: string, options: GitVersionSettings): string[] { private getArguments(
const args = [ workDir: string,
workDir, options: GitVersionSettings
"/output", "json", ): string[] {
"/output", "buildserver", const args = [workDir, '/output', 'json', '/output', 'buildserver']
];
const { const {
useConfigFile, useConfigFile,
configFilePath, configFilePath,
updateAssemblyInfo, updateAssemblyInfo,
updateAssemblyInfoFilename, updateAssemblyInfoFilename,
additionalArguments, additionalArguments
} = options; } = options
if (useConfigFile) { if (useConfigFile) {
if (this.buildAgent.isValidInputFile("configFilePath", configFilePath)) { if (
args.push("/config", configFilePath); this.buildAgent.isValidInputFile(
'configFilePath',
configFilePath
)
) {
args.push('/config', configFilePath)
} else { } else {
throw new Error("GitVersion configuration file not found at " + configFilePath); throw new Error(
'GitVersion configuration file not found at ' +
configFilePath
)
} }
} }
if (updateAssemblyInfo) { if (updateAssemblyInfo) {
args.push("/updateassemblyinfo"); args.push('/updateassemblyinfo')
if (this.buildAgent.isValidInputFile("updateAssemblyInfoFilename", updateAssemblyInfoFilename)) { if (
args.push(updateAssemblyInfoFilename); this.buildAgent.isValidInputFile(
'updateAssemblyInfoFilename',
updateAssemblyInfoFilename
)
) {
args.push(updateAssemblyInfoFilename)
} else { } else {
throw new Error("AssemblyInfoFilename file not found at " + updateAssemblyInfoFilename); throw new Error(
'AssemblyInfoFilename file not found at ' +
updateAssemblyInfoFilename
)
} }
} }
args.push(additionalArguments); args.push(additionalArguments)
return args; return args
} }
public writeGitVersionToAgent(gitversion: GitVersionOutput): void { public writeGitVersionToAgent(gitversion: GitVersionOutput): void {
this.buildAgent.setOutput('major', gitversion.Major.toString())
this.buildAgent.setOutput("major", gitversion.Major.toString()); this.buildAgent.setOutput('minor', gitversion.Minor.toString())
this.buildAgent.setOutput("minor", gitversion.Minor.toString()); this.buildAgent.setOutput('patch', gitversion.Patch.toString())
this.buildAgent.setOutput("patch", gitversion.Patch.toString()); this.buildAgent.setOutput('preReleaseTag', gitversion.PreReleaseTag)
this.buildAgent.setOutput("preReleaseTag", gitversion.PreReleaseTag); this.buildAgent.setOutput(
this.buildAgent.setOutput("preReleaseTagWithDash", gitversion.PreReleaseTagWithDash); 'preReleaseTagWithDash',
this.buildAgent.setOutput("preReleaseLabel", gitversion.PreReleaseLabel); gitversion.PreReleaseTagWithDash
this.buildAgent.setOutput("preReleaseNumber", gitversion.PreReleaseNumber.toString()); )
this.buildAgent.setOutput("weightedPreReleaseNumber", gitversion.WeightedPreReleaseNumber.toString()); this.buildAgent.setOutput('preReleaseLabel', gitversion.PreReleaseLabel)
this.buildAgent.setOutput("buildMetaData", gitversion.BuildMetaData.toString()); this.buildAgent.setOutput(
this.buildAgent.setOutput("buildMetaDataPadded", gitversion.BuildMetaDataPadded); 'preReleaseNumber',
this.buildAgent.setOutput("fullBuildMetaData", gitversion.FullBuildMetaData); gitversion.PreReleaseNumber.toString()
this.buildAgent.setOutput("majorMinorPatch", gitversion.MajorMinorPatch); )
this.buildAgent.setOutput("semVer", gitversion.SemVer); this.buildAgent.setOutput(
this.buildAgent.setOutput("legacySemVer", gitversion.LegacySemVer); 'weightedPreReleaseNumber',
this.buildAgent.setOutput("legacySemVerPadded", gitversion.LegacySemVerPadded); gitversion.WeightedPreReleaseNumber.toString()
this.buildAgent.setOutput("assemblySemVer", gitversion.AssemblySemVer); )
this.buildAgent.setOutput("assemblySemFileVer", gitversion.AssemblySemFileVer); this.buildAgent.setOutput(
this.buildAgent.setOutput("fullSemVer", gitversion.FullSemVer); 'buildMetaData',
this.buildAgent.setOutput("informationalVersion", gitversion.InformationalVersion); gitversion.BuildMetaData.toString()
this.buildAgent.setOutput("branchName", gitversion.BranchName); )
this.buildAgent.setOutput("sha", gitversion.Sha); this.buildAgent.setOutput(
this.buildAgent.setOutput("shortSha", gitversion.ShortSha); 'buildMetaDataPadded',
this.buildAgent.setOutput("nuGetVersionV2", gitversion.NuGetVersionV2); gitversion.BuildMetaDataPadded
this.buildAgent.setOutput("nuGetVersion", gitversion.NuGetVersion); )
this.buildAgent.setOutput("nuGetPreReleaseTagV2", gitversion.NuGetPreReleaseTagV2); this.buildAgent.setOutput(
this.buildAgent.setOutput("nuGetPreReleaseTag", gitversion.NuGetPreReleaseTag); 'fullBuildMetaData',
this.buildAgent.setOutput("versionSourceSha", gitversion.VersionSourceSha); gitversion.FullBuildMetaData
this.buildAgent.setOutput("commitsSinceVersionSource", gitversion.CommitsSinceVersionSource.toString()); )
this.buildAgent.setOutput("commitsSinceVersionSourcePadded", gitversion.CommitsSinceVersionSourcePadded); this.buildAgent.setOutput('majorMinorPatch', gitversion.MajorMinorPatch)
this.buildAgent.setOutput("commitDate", gitversion.CommitDate); this.buildAgent.setOutput('semVer', gitversion.SemVer)
this.buildAgent.setOutput('legacySemVer', gitversion.LegacySemVer)
this.buildAgent.setOutput(
'legacySemVerPadded',
gitversion.LegacySemVerPadded
)
this.buildAgent.setOutput('assemblySemVer', gitversion.AssemblySemVer)
this.buildAgent.setOutput(
'assemblySemFileVer',
gitversion.AssemblySemFileVer
)
this.buildAgent.setOutput('fullSemVer', gitversion.FullSemVer)
this.buildAgent.setOutput(
'informationalVersion',
gitversion.InformationalVersion
)
this.buildAgent.setOutput('branchName', gitversion.BranchName)
this.buildAgent.setOutput('sha', gitversion.Sha)
this.buildAgent.setOutput('shortSha', gitversion.ShortSha)
this.buildAgent.setOutput('nuGetVersionV2', gitversion.NuGetVersionV2)
this.buildAgent.setOutput('nuGetVersion', gitversion.NuGetVersion)
this.buildAgent.setOutput(
'nuGetPreReleaseTagV2',
gitversion.NuGetPreReleaseTagV2
)
this.buildAgent.setOutput(
'nuGetPreReleaseTag',
gitversion.NuGetPreReleaseTag
)
this.buildAgent.setOutput(
'versionSourceSha',
gitversion.VersionSourceSha
)
this.buildAgent.setOutput(
'commitsSinceVersionSource',
gitversion.CommitsSinceVersionSource.toString()
)
this.buildAgent.setOutput(
'commitsSinceVersionSourcePadded',
gitversion.CommitsSinceVersionSourcePadded
)
this.buildAgent.setOutput('commitDate', gitversion.CommitDate)
} }
} }

View File

@@ -1,14 +0,0 @@
{
"defaultSeverity": "error",
"extends": [
"tslint:recommended"
],
"jsRules": {},
"rules": {
"max-classes-per-file":false,
"no-console":false,
"no-var-requires":false,
"object-literal-sort-keys":false
},
"rulesDirectory": []
}