artifact-engine
Advanced tools
Comparing version 0.1.14 to 0.1.15
@@ -83,6 +83,6 @@ "use strict"; | ||
}, (err) => { | ||
retryIfRequired("Error putting file " + item.path + ":" + err); | ||
retryIfRequired("Error placing file " + item.path + ": " + err); | ||
}); | ||
}, (err) => { | ||
retryIfRequired("Error getting file " + item.path + ":" + err); | ||
retryIfRequired("Error getting file " + item.path + ": " + err); | ||
}); | ||
@@ -89,0 +89,0 @@ } |
{ | ||
"name": "artifact-engine", | ||
"version": "0.1.14", | ||
"version": "0.1.15", | ||
"description": "Artifact Engine to download artifacts from jenkins, teamcity, vsts", | ||
@@ -37,3 +37,4 @@ "repository": { | ||
"typescript": "1.8.7", | ||
"nock": "9.1.0" | ||
"nock": "9.1.0", | ||
"nconf": "0.10.0" | ||
}, | ||
@@ -40,0 +41,0 @@ "files": [ |
@@ -12,5 +12,3 @@ import * as models from '../Models'; | ||
private getItems(itemsPath, parentRelativePath?); | ||
private ensureDirectoryExistence(folder); | ||
private _rootLocation; | ||
private _createdFolders; | ||
} |
@@ -6,5 +6,5 @@ "use strict"; | ||
const logger_1 = require('../Engine/logger'); | ||
var tl = require('vsts-task-lib'); | ||
class FilesystemProvider { | ||
constructor(rootLocation) { | ||
this._createdFolders = {}; | ||
this._rootLocation = rootLocation; | ||
@@ -44,3 +44,3 @@ } | ||
try { | ||
this.ensureDirectoryExistence(folder); | ||
tl.mkdirP(folder); | ||
logger_1.Logger.logMessage('Downloading ' + item.path + ' to ' + outputFilename); | ||
@@ -55,3 +55,2 @@ const outputStream = fs.createWriteStream(outputFilename); | ||
item.metadata[models.Constants.DestinationUrlKey] = outputFilename; | ||
resolve(item); | ||
}); | ||
@@ -63,2 +62,3 @@ stream.on("error", (error) => { | ||
this.artifactItemStore.updateFileSize(item, outputStream.bytesWritten); | ||
resolve(item); | ||
}); | ||
@@ -107,15 +107,4 @@ } | ||
} | ||
ensureDirectoryExistence(folder) { | ||
if (!this._createdFolders.hasOwnProperty(folder)) { | ||
var dirName = path.dirname(folder); | ||
if (fs.existsSync(folder)) { | ||
return; | ||
} | ||
this.ensureDirectoryExistence(dirName); | ||
fs.mkdirSync(folder); | ||
this._createdFolders[folder] = true; | ||
} | ||
} | ||
} | ||
exports.FilesystemProvider = FilesystemProvider; | ||
//# sourceMappingURL=filesystemProvider.js.map |
export { WebProvider } from "./webProvider"; | ||
export { FilesystemProvider } from "./filesystemProvider"; | ||
export { ZipProvider } from "./zipProvider"; | ||
export { StubProvider } from "./stubProvider"; |
@@ -6,4 +6,6 @@ "use strict"; | ||
exports.FilesystemProvider = filesystemProvider_1.FilesystemProvider; | ||
var zipProvider_1 = require("./zipProvider"); | ||
exports.ZipProvider = zipProvider_1.ZipProvider; | ||
var stubProvider_1 = require("./stubProvider"); | ||
exports.StubProvider = stubProvider_1.StubProvider; | ||
//# sourceMappingURL=index.js.map |
@@ -306,3 +306,3 @@ "use strict"; | ||
if (proxyConfig.proxyUsername || proxyConfig.proxyPassword) { | ||
proxyAuth = proxyConfig.proxyUsername + ":" + encodeURIComponent(proxyConfig.proxyPassword); | ||
proxyAuth = proxyConfig.proxyUsername + ":" + proxyConfig.proxyPassword; | ||
} | ||
@@ -309,0 +309,0 @@ } |
@@ -17,4 +17,2 @@ import * as stream from 'stream'; | ||
private extend(target, source); | ||
private initializeProxy(); | ||
private _readTaskLibSecrets(lookupKey); | ||
private rootItemsLocation; | ||
@@ -24,3 +22,2 @@ private templateFile; | ||
httpc: httpm.HttpClient; | ||
private options; | ||
} |
"use strict"; | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const crypto = require('crypto'); | ||
const zlib = require('zlib'); | ||
var handlebars = require('handlebars'); | ||
const httpm = require('./typed-rest-client/HttpClient'); | ||
var tl = require('vsts-task-lib'); | ||
const models = require('../Models'); | ||
const logger_1 = require('../Engine/logger'); | ||
var packagejson = require('../package.json'); | ||
const factory = require('./webClientFactory'); | ||
var handlebars = require('handlebars'); | ||
class WebProvider { | ||
constructor(rootItemsLocation, templateFile, variables, handler, requestOptions) { | ||
this.httpc = new httpm.HttpClient('artifact-engine'); | ||
this.options = {}; | ||
this.rootItemsLocation = rootItemsLocation; | ||
this.templateFile = templateFile; | ||
this.options = requestOptions || {}; | ||
this.options.keepAlive = true; | ||
this.initializeProxy(); | ||
this.httpc = new httpm.HttpClient('artifact-engine ' + packagejson.version, [handler], this.options); | ||
this.httpc = factory.WebClientFactory.getClient([handler], requestOptions); | ||
this.variables = variables; | ||
@@ -40,7 +34,11 @@ } | ||
} | ||
var downloadSize = 0; | ||
var itemUrl = artifactItem.metadata['downloadUrl']; | ||
itemUrl = itemUrl.replace(/([^:]\/)\/+/g, "$1"); | ||
this.httpc.get(itemUrl).then((res) => { | ||
res.message.on('data', (chunk) => { | ||
downloadSize += chunk.length; | ||
}); | ||
res.message.on('end', () => { | ||
this.artifactItemStore.updateDownloadSize(artifactItem, res.message.socket.bytesRead); | ||
this.artifactItemStore.updateDownloadSize(artifactItem, downloadSize); | ||
}); | ||
@@ -111,43 +109,4 @@ if (res.message.headers['content-encoding'] === 'gzip') { | ||
} | ||
initializeProxy() { | ||
if (!this.options.proxy || !this.options.proxy.proxyUrl) { | ||
if (global['_vsts_task_lib_proxy']) { | ||
let proxyFromEnv = { | ||
proxyUrl: global['_vsts_task_lib_proxy_url'], | ||
proxyUsername: global['_vsts_task_lib_proxy_username'], | ||
proxyPassword: this._readTaskLibSecrets(global['_vsts_task_lib_proxy_password']), | ||
proxyBypassHosts: JSON.parse(global['_vsts_task_lib_proxy_bypass'] || "[]"), | ||
}; | ||
this.options.proxy = proxyFromEnv; | ||
} | ||
} | ||
if (!this.options.cert) { | ||
if (global['_vsts_task_lib_cert']) { | ||
let certFromEnv = { | ||
caFile: global['_vsts_task_lib_cert_ca'], | ||
certFile: global['_vsts_task_lib_cert_clientcert'], | ||
keyFile: global['_vsts_task_lib_cert_key'], | ||
passphrase: this._readTaskLibSecrets(global['_vsts_task_lib_cert_passphrase']), | ||
}; | ||
this.options.cert = certFromEnv; | ||
} | ||
} | ||
if (!this.options.ignoreSslError) { | ||
this.options.ignoreSslError = !!global['_vsts_task_lib_skip_cert_validation']; | ||
} | ||
} | ||
_readTaskLibSecrets(lookupKey) { | ||
if (lookupKey && lookupKey.indexOf(':') > 0) { | ||
let lookupInfo = lookupKey.split(':', 2); | ||
let keyFile = new Buffer(lookupInfo[0], 'base64').toString('utf8'); | ||
let encryptKey = new Buffer(fs.readFileSync(keyFile, 'utf8'), 'base64'); | ||
let encryptedContent = new Buffer(lookupInfo[1], 'base64').toString('utf8'); | ||
let decipher = crypto.createDecipher("aes-256-ctr", encryptKey); | ||
let decryptedContent = decipher.update(encryptedContent, 'hex', 'utf8'); | ||
decryptedContent += decipher.final('utf8'); | ||
return decryptedContent; | ||
} | ||
} | ||
} | ||
exports.WebProvider = WebProvider; | ||
//# sourceMappingURL=webProvider.js.map |
@@ -1,2 +0,2 @@ | ||
# Artifact Engine | ||
# Artifact Engine | ||
@@ -13,8 +13,24 @@ ## Overview | ||
## Development | ||
*Build* | ||
**Build** | ||
--------- | ||
1. Run npm install in ArtifactEngine folder | ||
2. Use command ctrl-shift-b to build from vscode | ||
*Testing* | ||
**Testing** | ||
---------- | ||
*vscode* | ||
---------- | ||
1. Install [mocha sidebar](https://marketplace.visualstudio.com/items?itemName=maty.vscode-mocha-sidebar) extension to run tests from vscode. | ||
2. Optional install [node tdd](https://marketplace.visualstudio.com/items?itemName=prashaantt.node-tdd) extension to automatically run tests on build. | ||
*gulp* | ||
------ | ||
1. To run ArtifactEngine integration and unit tests from root directory use | ||
`gulp test --suite=ArtifactEngine` | ||
2. To run Performance tests update [test config file](test.config.json.example) and rename it to test.config.json and run | ||
`gulp test --suite=ArtifactEngine --perf` | ||
3. To run End-to-End tests update [test config file](test.config.json.example) and rename it to test.config.json and run | ||
`gulp test --suite=ArtifactEngine --e2e` |
148601
70
2193
36
14
7