This commit is contained in:
Zeke Sikelianos 2016-07-07 16:21:34 -07:00
Родитель 403549bc25
Коммит 8040dd1948
2 изменённых файлов: 14 добавлений и 59 удалений

Просмотреть файл

@ -1,62 +1,19 @@
const ChangesStream = require('changes-stream')
const fs = require('fs')
const path = require('path')
const got = require('got')
// const db = 'https://replicate.npmjs.com'
const db = 'https://skimdb.npmjs.com/registry'
const get = require('lodash.get')
const normalize = require('normalize-registry-metadata')
const registry = require('package-stream')()
var changes = new ChangesStream({
db: db,
include_docs: true
})
class Package {
constructor(doc) {
var pkg = normalize(doc)
var latest = get(pkg, 'dist-tags.latest')
if (!latest) return this
pkg = pkg.versions[latest]
Object.keys(pkg).forEach(prop => {
this[prop] = pkg[prop]
})
return this
}
devDependsOn(dep) {
return this.devDeps.indexOf(dep) > -1
}
mentions(string) {
return !!JSON.stringify(this).toLowerCase().includes(string.toLowerCase())
}
save() {
fs.writeFileSync(
path.join(__dirname, 'packages', `${this.name}.json`),
JSON.stringify(this, null, 2)
)
}
get devDeps() {
return this.devDependencies ? Object.keys(this.devDependencies) : []
}
}
got(db).then(response => {
changes.on('data', function (change) {
// stop after we've parsed all the things
if (change.seq >= response.body.update_seq) {
console.log('done')
process.exit(0)
}
registry
.on('package', function (pkg) {
process.stdout.write('.')
var pkg = new Package(change.doc)
if (pkg.mentions('electron') && !pkg.mentions('electronic')) {
if (pkg.valid && pkg.mentions('electron') && !pkg.mentions('electronic')) {
console.log(pkg.name)
pkg.save()
fs.writeFileSync(
path.join(__dirname, 'packages', `${pkg.name}.json`),
JSON.stringify(pkg, null, 2)
)
}
})
})
.on('up-to-date', function () {
console.log('done')
process.exit()
})

Просмотреть файл

@ -4,7 +4,7 @@
"description": "A collection of all npm packages that mention `electron` in their package.json",
"main": "index.js",
"scripts": {
"build": "mkdir -p packages && rm packages/* && node build.js && npm run docs",
"build": "mkdir -p packages && touch packages/___.json && rm packages/* && node build.js && npm run docs",
"docs": "npm run docs:keywords && npm run docs:packages",
"docs:keywords": "node keywords.js > keywords.md",
"docs:packages": "node packages.js > packages.md"
@ -27,17 +27,15 @@
},
"homepage": "https://github.com/zeke/electron-npm-packages#readme",
"devDependencies": {
"changes-stream": "^1.1.0",
"got": "^6.3.0",
"limiter": "^1.1.0",
"lodash.find": "^4.4.0",
"lodash.get": "^4.3.0",
"lodash.sortby": "^4.5.0",
"normalize-registry-metadata": "^1.1.2",
"path-exists": "^3.0.0"
},
"dependencies": {
"object-values": "^1.0.0",
"package-stream": "^1.0.0",
"require-dir": "^0.3.0"
}
}