diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..6b40fbfbb --- /dev/null +++ b/.editorconfig @@ -0,0 +1,14 @@ +# editorconfig.org + +root = true + +[*] +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true +indent_style = space +indent_size = 2 + +[*.md] +trim_trailing_whitespace = false \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..ef482b7bd --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,33 @@ +name: Release + +on: + schedule: + - cron: "0 */8 * * *" + +jobs: + lint: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + with: + token: ${{ secrets.GITHUB_PAT_FROM_ZEKE }} + - name: npm ci + run: npm ci + - name: release + run: | + git checkout master + git config --global user.name "github-actions" + git config --global user.email "github-actions@users.noreply.github.com" + + node update + npm test + [[ `git status --porcelain` ]] || exit + + echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc + + git add . + npm version patch -f -m "Update all-the-package-names to %s" + + git push origin master --follow-tags + npm publish \ No newline at end of file diff --git a/.gitignore b/.gitignore index 2bfd1b3a6..bf49adf3f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ node_modules skimdb.json +yarn.lock +package-lock.json \ No newline at end of file diff --git a/example.js b/example.js index 5d8dfe9b7..2956a06ca 100644 --- a/example.js +++ b/example.js @@ -1,19 +1,20 @@ -const names = require('./') +const names = require('all-the-package-names') // Most-depended-on names are first. See what's popular! -names.slice(0,5) -// [ -// 'mocha', -// 'chai', -// 'lodash', -// 'grunt', -// 'eslint' -// ] +names.slice(0, 5) +/* +[ + 'mocha', + 'chai', + 'lodash', + 'grunt', + 'eslint' +] +*/ names.includes('superagent') // => true -// Check if a given package name exists names.includes('crazy-new-package-name') // => false @@ -22,6 +23,3 @@ names.length names.filter(name => name.includes('banana')) // => [ 'banana', 'banana-banana', 'banana-split', ...] - -// Note: This example requires node 4 or greater because it uses -// const, arrow functions, and the `includes` array/string helper. diff --git a/license b/license new file mode 100644 index 000000000..9ed6a583f --- /dev/null +++ b/license @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2015 - 2020 nice-registry + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/package.json b/package.json index 23d4975f9..33ba0c0a6 100644 --- a/package.json +++ b/package.json @@ -1,15 +1,17 @@ { "name": "all-the-package-names", "version": "1.3904.0", - "description": "A list of all the public package names on npm. Updated daily.", + "description": "A list of all the public package names on npm. Updated every 8 hours.", "main": "names.json", "bin": "cli.js", + "files": [ + "names.json", + "cli.js" + ], "scripts": { - "build": "script/build", - "release": "script/release", - "test": "node test/index.js | tap-spec" + "test": "standard && mocha" }, - "repository": "https://github.com/zeke/all-the-package-names", + "repository": "https://github.com/nice-registry/all-the-package-names", "keywords": [ "npm", "registry", @@ -24,12 +26,18 @@ "author": "zeke", "license": "MIT", "devDependencies": { + "chai": "^4.2.0", "dependent-counts": "^2.0.0", - "is-number": "^4.0.0", - "lodash": "^3.10.0", - "ora": "^0.4.0", - "package-stream": "^1.0.2", - "tap-spec": "^4.1.1", - "tape": "^4.5.1" + "mocha": "^8.0.1", + "num-sort": "^2.1.0", + "ora": "^4.0.4", + "package-stream": "^3.1.0", + "standard": "^14.3.4", + "write-json-file": "^4.3.0" + }, + "standard": { + "ignore": [ + "example.js" + ] } } diff --git a/readme.md b/readme.md index 9d5a9c50c..08c2e1ef1 100644 --- a/readme.md +++ b/readme.md @@ -1,39 +1,40 @@ # all-the-package-names -A list of all the public package names on npm. +A list of all the public package names on npm. The list is just a JSON file and can be used wherever. -- Includes scoped packages -- Sorted by [dependent count](https://github.com/zeke/dependent-counts) -- Uses npm's [replicate.npmjs.com](https://github.com/npm/registry/blob/198b449e5ec11f0cc3e424ce2721dd66e8111589/docs/follower.md) service. -- Updated [daily](http://zeke.sikelianos.com/npm-and-github-automation-with-heroku/) +## Highlights -## Installation +- Includes scoped packages. +- Sorted by [dependent count](https://github.com/zeke/dependent-counts). +- Uses npm's [replicate.npmjs.com](https://github.com/npm/registry/blob/198b449e5ec11f0cc3e424ce2721dd66e8111589/docs/follower.md) service. +- Updated every 8 hours. + +## Install ```sh -npm install all-the-package-names --save +npm install all-the-package-names ``` ## Usage -The module exports a big flat array of package names: - ```js -const names = require("all-the-package-names") +const names = require('all-the-package-names') // Most-depended-on names are first. See what's popular! -names.slice(0,5) -// [ -// 'mocha', -// 'chai', -// 'lodash', -// 'grunt', -// 'eslint' -// ] +names.slice(0, 5) +/* +[ + 'mocha', + 'chai', + 'lodash', + 'grunt', + 'eslint' +] +*/ names.includes('superagent') // => true -// Check if a given package name exists names.includes('crazy-new-package-name') // => false @@ -42,57 +43,30 @@ names.length names.filter(name => name.includes('banana')) // => [ 'banana', 'banana-banana', 'banana-split', ...] - -// Note: This example requires node 4 or greater because it uses -// const, arrow functions, and the `includes` array/string helper. - ``` ## CLI Usage -You can also use it on the command line. Newline-delimited names are piped to -STDOUT: - ```sh -npm i -g all-the-package-names -all-the-package-names | grep spell +$ npm i -g all-the-package-names +$ all-the-package-names +mocha +chai +lodash +grunt +eslint +... ``` -## ⚠️ Gotchas +## Common pitfalls Note that while mixed-case package names are no longer allowed to be published to the npm registry, there are over 2800 legacy mixed-case packages, many of which have the same spelling as other existing lowercase packages. See [nice-registry/mixed-case-package-names](https://github.com/nice-registry/mixed-case-package-names) -for the the full list. +for the full list. -To avoid the mixed-case names when working with this data, -just filter them out: +To avoid the mixed-case names when working with this data, just filter them out: ```js -const names = require('all-the-package-names') - .filter(name => name === name.toLowerCase()) +const names = require('all-the-package-names').filter(name => name === name.toLowerCase()) ``` - -## Tests - -```sh -npm install -npm test -``` - -## Dependencies - -None - -## Dev Dependencies - -- [dependent-counts](https://github.com/zeke/dependent-counts): Get counts of how many packages depend on the given package. Works offline. -- [lodash](https://github.com/lodash/lodash): The modern build of lodash modular utilities. -- [ora](https://github.com/sindresorhus/ora): Elegant terminal spinner -- [package-stream](https://github.com/zeke/package-stream): An endless stream of clean package data from the npm registry. -- [tap-spec](https://github.com/scottcorgan/tap-spec): Formatted TAP output like Mocha's spec reporter -- [tape](https://github.com/substack/tape): tap-producing test harness for node and browsers - -## License - -MIT diff --git a/script/build b/script/build deleted file mode 100755 index 7317e206f..000000000 --- a/script/build +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env node - -const fs = require('fs') -const path = require('path') -const names = require('dependent-counts').map(count => count.name) -const chain = require('lodash').chain -const isNumber = require('is-number') -const ora = require('ora') -const spinner = ora('').start() -const registry = require('package-stream')({ - db: 'https://replicate.npmjs.com', - include_docs: true -}) - -registry - .on('package', addPackage) - .on('up-to-date', finish) - -function addPackage (pkg) { - const name = pkg.name - if (name && name.length) names.push(name) - - // to check the finish function early... - // if (names.length > 100 * 1000) finish() -} - -function finish () { - const filename = path.join(__dirname, '../names.json') - const finalNames = chain(names) - .compact() - .uniq() - .value() - .filter(name => !isNumber(name)) - - fs.writeFileSync(filename, JSON.stringify(finalNames, null, 2)) - console.log(`\nwrote ${finalNames.length} package names to ${filename}`) - process.exit() -} - -setInterval(() => { - spinner.text = `${names.length} names collected` -}, 50) diff --git a/script/release b/script/release deleted file mode 100755 index 4a50ac20e..000000000 --- a/script/release +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash - -set -x # print commands before execution -set -o errexit # always exit on error -set -o pipefail # honor exit codes when piping -set -o nounset # fail on unset variables - -# clone the repo and fetch new names -git clone https://github.com/zeke/all-the-package-names -cd all-the-package-names -npm run build -npm test - -# bail if no changes are present -[[ `git status --porcelain` ]] || exit - -count=$(cat names.json | wc -l) -git add names.json -git config user.email "zeke@sikelianos.com" -git config user.name "Zeke Sikelianos" -git commit -m "$count package names" -npm version minor -m "bump minor to %s" -npm publish -git push origin master --follow-tags - -# clean up -cd .. -rm -rf all-the-package-names diff --git a/test.js b/test.js new file mode 100644 index 000000000..be90e7817 --- /dev/null +++ b/test.js @@ -0,0 +1,9 @@ +const { describe, it } = require('mocha') +const { expect } = require('chai') +const packageNames = require('.') + +describe('names', () => { + it('is an array', () => { + expect(packageNames).to.be.an('array') + }) +}) diff --git a/test/index.js b/test/index.js deleted file mode 100644 index b09cbc848..000000000 --- a/test/index.js +++ /dev/null @@ -1,9 +0,0 @@ -const test = require('tape') -const names = require('..') - -test('names', function (t) { - t.ok(Array.isArray(names), 'is an array') - t.ok(names.length > 260*1000, 'has hella names') - t.notOk(names.find(name => name === '69'), 'does not include numerical packages') - t.end() -}) diff --git a/update.js b/update.js new file mode 100644 index 000000000..fe189f4e4 --- /dev/null +++ b/update.js @@ -0,0 +1,26 @@ +const path = require('path') +const writeJsonFile = require('write-json-file') +const ora = require('ora') +const numberSort = require('num-sort') +const registry = require('package-stream')() +const totalDirectDependents = new Map(require('dependent-counts').map(({ name, totalDirectDependents }) => [name, totalDirectDependents])) + +const packageNames = new Set() +const spinner = ora('Collecting package names').start() + +registry + .on('package', ({ name }) => { + if (typeof name === 'string') { + packageNames.add(name) + spinner.text = `${packageNames.size} package names collected` + } + }) + .on('up-to-date', async () => { + const filename = path.join(__dirname, 'names.json') + const finalPackageNames = [...packageNames].sort((a, b) => numberSort.descending(totalDirectDependents.get(a) || 0, totalDirectDependents.get(b) || 0)) + + await writeJsonFile(filename, finalPackageNames, { indent: undefined }) + spinner.stop() + console.log(`Wrote ${finalPackageNames.length} package names to ${filename}`) + process.exit() + })