-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample.js
45 lines (39 loc) · 1.28 KB
/
example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/* eslint-disable */
const RegistryResolver = require('.')
const fs = require('fs')
const resolver = new RegistryResolver({
epsilon: 0.000001 // the smallest weight that will be assigned to a package before exiting
})
async function resolveNpmWeightsMap () {
const packageWeightMap = await resolver.computePackageWeight({
language: 'javascript',
registry: 'npm',
topLevelPackages: ['standard', 'react', 'webpack'],
noCompList: new Set(['react'])
})
console.error({ packageWeightMap })
}
async function resolveRubyWeightsMap () {
fs.readFile('./testData/Gemfile.octobox', async (err, data) => {
const res = await resolver.extractDependenciesFromManifests([{
language: 'ruby',
registry: 'rubygems',
manifest: data.toString()
}])
try {
const packageWeightMap = await resolver.computePackageWeight({
language: 'ruby',
registry: 'rubygems',
topLevelPackages: res[0].deps,
noCompList: undefined
})
// console.error({ packageWeightMap })
const output = [...packageWeightMap.entries()].map(([packageName, weight]) => [
packageName, weight * 10000])
fs.writeFileSync('./output.json', JSON.stringify(output))
} catch (e) {
console.error({ e })
}
})
}
resolveRubyWeightsMap()