From cee3a896c753adddbb7aa2081d47064efb61aa5c Mon Sep 17 00:00:00 2001 From: mazt-dev Date: Tue, 22 Dec 2015 15:27:41 +0100 Subject: [PATCH 1/4] Get package details from svn package --- lib/service/packageDetailsProvider.js | 56 ++++++++++++++++++++------- 1 file changed, 41 insertions(+), 15 deletions(-) diff --git a/lib/service/packageDetailsProvider.js b/lib/service/packageDetailsProvider.js index 86a32a4..4dfbc83 100644 --- a/lib/service/packageDetailsProvider.js +++ b/lib/service/packageDetailsProvider.js @@ -7,28 +7,54 @@ var utils = require('../infrastructure/utils'); module.exports = function PackageDetailsProvider() { var tempFolder = path.join(utils.dirname, 'temp/packageDetails'); - + function _getPackageDetails(packageUrl) { + if (packageUrl.startsWith('svn')) { + return _getPackageDetailsSvn(packageUrl); + } + return _getPackageDetailsGit(packageUrl); + } + + function _getPackageDetailsGit(packageUrl) { return new Promise(function(resolve, reject) { var tempName = utils.getRandomString(); var gitCloneFolder = path.join(tempFolder, tempName); - + utils.exec('git clone {0} {1} --depth=1'.format(packageUrl, gitCloneFolder)) - .then(function() { - var bowerJsonLocation = path.join(gitCloneFolder, 'bower.json'); - - var fileContent = fs.readFileSync(bowerJsonLocation); - var bowerJson = JSON.parse(fileContent); - - utils.removeDirectory(gitCloneFolder); - - resolve(bowerJson); - }) - .catch(reject); + .then(function() { + var bowerJsonLocation = path.join(gitCloneFolder, 'bower.json'); + + var fileContent = fs.readFileSync(bowerJsonLocation); + var bowerJson = JSON.parse(fileContent); + + utils.removeDirectory(gitCloneFolder); + + resolve(bowerJson); + }) + .catch(reject); + }); + } + + function _getPackageDetailsSvn(packageUrl) { + return new Promise(function(resolve, reject) { + var tempName = utils.getRandomString(); + var svnExportBowerFile = path.join(tempFolder, tempName); + + packageUrl = packageUrl.replace(/svn\+/, ''); + utils.exec('svn export {0}/trunk/bower.json {1}'.format(packageUrl, svnExportBowerFile)) + .then(function() { + var fileContent = fs.readFileSync(svnExportBowerFile); + var bowerJson = JSON.parse(fileContent); + + fs.unlinkSync(svnExportBowerFile); + + resolve(bowerJson); + }) + .catch(reject); }); } - + return { getPackageDetails: _getPackageDetails }; -}(); \ No newline at end of file +}(); From 3805b00246a0de9145461b2a9333014adf4ba91d Mon Sep 17 00:00:00 2001 From: Mateus Date: Wed, 30 Dec 2015 10:29:50 -0200 Subject: [PATCH 2/4] Invalid JSON in README file --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 10b6e5d..2ca6d42 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ Must be a valid JSON "server": { "port": 5678, "hostName": null, - "siteBaseUrl": null, + "siteBaseUrl": null }, "public": { "disabled": false, From ff05b21c0cd02a0989865ab4a4b3098632c18a00 Mon Sep 17 00:00:00 2001 From: Mateus Date: Wed, 30 Dec 2015 10:37:50 -0200 Subject: [PATCH 3/4] Check if _listeningServer exists before call method .close --- lib/application.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/application.js b/lib/application.js index e259d8f..b961f3e 100644 --- a/lib/application.js +++ b/lib/application.js @@ -66,9 +66,10 @@ module.exports = function Application() { function _shutDown() { logger.log('Shutting down private-bower'); - - _listeningServer.close(); - + if(_listeningServer){ + _listeningServer.close(); + } + publicPackageStore.shutDown(); if(_repoCacheHandler) { From 33a1ad81a51df8de6322e4dbc39389b5c5a71264 Mon Sep 17 00:00:00 2001 From: Viktor Hofer Date: Sat, 23 Apr 2016 13:07:23 +0200 Subject: [PATCH 4/4] package details could not be resolved when temp dir has blanks in it --- lib/service/packageDetailsProvider.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/service/packageDetailsProvider.js b/lib/service/packageDetailsProvider.js index 4dfbc83..f0a0d2a 100644 --- a/lib/service/packageDetailsProvider.js +++ b/lib/service/packageDetailsProvider.js @@ -20,7 +20,7 @@ module.exports = function PackageDetailsProvider() { var tempName = utils.getRandomString(); var gitCloneFolder = path.join(tempFolder, tempName); - utils.exec('git clone {0} {1} --depth=1'.format(packageUrl, gitCloneFolder)) + utils.exec('git clone {0} \"{1}\" --depth=1'.format(packageUrl, gitCloneFolder)) .then(function() { var bowerJsonLocation = path.join(gitCloneFolder, 'bower.json');