-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
710 additions
and
284 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// eslint-disable-next-line no-promise-executor-return | ||
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)); | ||
|
||
const fetch = async (url, opts) => { | ||
let retryCount = 3; | ||
const nodeFetch = (await import('node-fetch')).default; | ||
|
||
while (retryCount > 0) { | ||
try { | ||
// eslint-disable-next-line no-await-in-loop | ||
const responseRaw = await nodeFetch(url, opts); | ||
if (!responseRaw.ok) { | ||
throw new Error(`Error ${responseRaw.status} from registry: ${responseRaw.statusText}`); | ||
} else { | ||
return responseRaw; | ||
} | ||
} catch (e) { | ||
retryCount -= 1; | ||
if (retryCount === 0) { | ||
throw e; | ||
} | ||
// eslint-disable-next-line no-await-in-loop | ||
await sleep(1000); | ||
} | ||
} | ||
|
||
throw new Error(); | ||
}; | ||
|
||
module.exports = fetch; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
const { | ||
processDependenciesForPackage, | ||
processPlaceholders, | ||
makeNode, | ||
seedNodes, | ||
} = require('./utils'); | ||
|
||
const generateComposerGraph = ({data, manifest}) => { | ||
const allPackages = []; | ||
const placeholders = []; | ||
|
||
seedNodes({ | ||
initialNodes: [ | ||
{ | ||
...manifest, | ||
dependencies: manifest.require, | ||
devDependencies: manifest['require-dev'], | ||
}, | ||
], | ||
allPackages, | ||
placeholders, | ||
altTilde: true, | ||
}); | ||
|
||
const root = allPackages[0]; | ||
|
||
(data.packages || []).forEach((packageData) => { | ||
const {name, version} = packageData; | ||
|
||
const newPackage = makeNode({ | ||
name, | ||
version, | ||
}); | ||
|
||
processDependenciesForPackage({ | ||
dependencies: { | ||
dependencies: packageData.require, | ||
devDependencies: packageData['require-dev'], | ||
}, | ||
newPackage, | ||
allPackages, | ||
placeholders, | ||
altTilde: true, | ||
}); | ||
|
||
processPlaceholders({newPackage, placeholders}); | ||
|
||
allPackages.push(newPackage); | ||
}); | ||
|
||
return {root, allPackages}; | ||
}; | ||
|
||
module.exports = generateComposerGraph; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.