Skip to content

Commit

Permalink
feat(bundler): extract bundler compatibility from Gemfile.lock
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed Jan 21, 2019
1 parent 28a1f86 commit 8dfca59
Show file tree
Hide file tree
Showing 4 changed files with 628 additions and 11 deletions.
22 changes: 17 additions & 5 deletions lib/manager/bundler/extract.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = {
extractPackageFile,
};

function extractPackageFile(content) {
async function extractPackageFile(content, fileName) {
const res = {
registryUrls: [],
deps: [],
Expand Down Expand Up @@ -58,7 +58,7 @@ function extractPackageFile(content) {
groupContent += groupLine.replace(/^ {2}/, '') + '\n';
}
}
const groupRes = extractPackageFile(groupContent);
const groupRes = await extractPackageFile(groupContent);
if (groupRes) {
res.deps = res.deps.concat(
groupRes.deps.map(dep => ({
Expand All @@ -82,7 +82,7 @@ function extractPackageFile(content) {
sourceContent += sourceLine.replace(/^ {2}/, '') + '\n';
}
}
const sourceRes = extractPackageFile(sourceContent);
const sourceRes = await extractPackageFile(sourceContent);
if (sourceRes) {
res.deps = res.deps.concat(
sourceRes.deps.map(dep => ({
Expand All @@ -105,7 +105,7 @@ function extractPackageFile(content) {
platformsContent += platformsLine.replace(/^ {2}/, '') + '\n';
}
}
const platformsRes = extractPackageFile(platformsContent);
const platformsRes = await extractPackageFile(platformsContent);
if (platformsRes) {
res.deps = res.deps.concat(
// eslint-disable-next-line no-loop-func
Expand All @@ -128,7 +128,7 @@ function extractPackageFile(content) {
ifContent += ifLine.replace(/^ {2}/, '') + '\n';
}
}
const ifRes = extractPackageFile(ifContent);
const ifRes = await extractPackageFile(ifContent);
if (ifRes) {
res.deps = res.deps.concat(
// eslint-disable-next-line no-loop-func
Expand All @@ -143,5 +143,17 @@ function extractPackageFile(content) {
if (!res.deps.length && !res.registryUrls.length) {
return null;
}
if (fileName) {
const gemfileLock = fileName + '.lock';
const lockContent = await platform.getFile(gemfileLock);
if (lockContent) {
logger.debug({ packageFile: fileName }, 'Found Gemfile.lock file');
const bundledWith = lockContent.match(/\nBUNDLED WITH\n\s+(.*?)(\n|$)/);
if (bundledWith) {
res.compatibility = res.compatibility || {};
res.compatibility.bundler = bundledWith[1];
}
}
}
return res;
}

0 comments on commit 8dfca59

Please sign in to comment.