NPM Trends

NPM软件包比较。(NPM package comparison)

  • 所有者: uidotdev/npm-trends
  • 平台: Linux, Mac, Windows
  • 許可證:
  • 分類:
  • 主題:
  • 喜歡:
    16
      比較:

Github星跟蹤圖

NPM 趋势 -- 前端客户端 (npmtrends.com)

NPM 包比较应用。

为什么这么说呢?

NPM Trends 最初是在 2015 年末建立的,当时我刚刚开始从事前端开发。来自 Rails 的背景,我对作为一个 javascript 开发者早期必须做出的众多决定感到沮丧。我并不关心我的构建工具是什么,我只想尽快把一个 web 应用送到用户面前。我首先是一个创业者,其次才是一个 web 开发者。

我不想担心 6 个月后,我决定使用的框架不再被支持。我希望有一种方法可以看到哪些包正在被使用,以及它们的使用趋势如何。我的假设是,你可以利用下载次数随时间的变化来预测某个包或库的开发者社区在可预见的未来是否强大。

这种方法在早期就得到了回报,当NPM趋势使我选择 Redux 而不是当时的众多其他 Flux 框架时,我就选择了 Redux。当我看2015年11月的下载趋势时,我看到 Redux 开始与众人拉开距离。如果你看现在的统计数据,就没有可比性了。

Redux Trend Graph

你不应该仅仅根据包的下载量来使用一个NPM包,但它绝对应该是你决策过程中的另一个数据点。希望 NPM 趋势能帮助你做出更好的决策,这样你就可以花更少的时间从一个包跳到另一个包,而花更多的时间来构建有意义的应用。

干杯!


(The first version translated by vz on 2020.09.12)

主要指標

概覽
名稱與所有者uidotdev/npm-trends
主編程語言TypeScript
編程語言JavaScript (語言數: 3)
平台Linux, Mac, Windows
許可證
所有者活动
創建於2015-11-15 05:50:47
推送於2024-06-06 02:40:01
最后一次提交2024-06-05 20:40:01
發布數0
用户参与
星數814
關注者數13
派生數58
提交數273
已啟用問題?
問題數108
打開的問題數57
拉請求數45
打開的拉請求數9
關閉的拉請求數27
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?

NPM Trends (npmtrends.com)

NPM package comparison app

Why?

NPM Trends was initially built in late 2015 when I was just getting into frontend development. Coming from a background in Rails, I was frustrated with how many decisions you had to make early on as a javascript developer. I didn't give an F what my build tool was, I just wanted to get a web app in front of users as quickly as possible. I'm a startup founder first and a web developer second.

I didn't want to have to worry that 6 months down the road, the framework that I decided to use wouldn't be supported anymore. I wanted a way to see what packages were being used and what way their use was trending. My hypothesis was that you could use the change in download counts over time to predict whether the developer community of a given package or library would be strong for the foreseeable future.

This approach paid off early on when NPM Trends led me to choose Redux over the multitude of other Flux frameworks out at the time. When I looked at the download trends in November of 2015, I saw Redux beginning to pull away from the pack. If you look at the stats now, there is no comparison.

Redux Trend Graph

You shouldn't use an NPM package solely based on the number of downloads the package has, but it should definitely be another data point in your decision making process. Hopefully NPM Trends will help you make better decisions, so you can spend less time jumping from package to package and more time building meaningful applications.

Cheers! ?

About the code

This app was originally built with a plain React front end and Node.js (Koa) backend (this commit and earlier). It is now Ruby on Rails with React and Redux (using the awesome React on Rails gem).

This is partly because I have a lot more experience with a Rails backend and partly because the RRRR stack just sounds pretty cool ?. I apologize for bringing Rails into an app all about Javascript, but ¯_(ツ)_/¯.

Getting Started

There are 3 steps to replicate this app in development:

  1. Set up this repository

  2. Set up the proxy server using npm-trends-proxy

  3. Create an Elasticsearch DB for autocomplete (optional)

1. Set up this repository

Make sure you have Ruby 2.2.3, Node.js 5.1.0, NPM 3.3.12, and a Postgres database installed before continuing.

Install ruby gems (Gemfile):

bundle install

Install npm packages (packages.json):

yarn

Prepare the database (first download and run Postgres App):

$ rails db:create
$ rails db:migrate

Start server:

foreman start -f Procfile.dev

note: localhost:5000 (won't work as expected until you set up your proxy server)

optional:

Tail the logs

tail -f log/development.log

LiveReload (for live css changes)

guard

2. Set up the proxy server

There are two reasons we use a proxy server:

  1. To enable cors for the registry.npmjs.com request

  2. To cache the api responses (helps with response times and api call limits)

Install redis locally (used as cache store)

Start your redis server

redis-server

Clone the repository npm-trends-proxy:

git clone https://github.com/johnmpotter/npm-trends-proxy

Install npm packages (packages.json):

npm install

Start server (runs on port 4444 by default):

npm start

The app should now be functioning correctly aside from the autocomplete

3. Create an Elasticsearch DB for autocomplete (optional)

This step is optional, but you will not see the autocomplete functionality and it will throw annoying js errors in the web console. Other than that, the app should work as expected without this.

Create an elasticsearch DB locally or remotely. (We use aws elasticsearch for npmtrends.com.)

Create a file in the root directory named .env (we'll be storing our environment variable here)

Set the elasticsearch env variable:

# .env
# example: ELASTICSEARCH_URL=npm-elasticsearch-4z0fkk893jms8ukdhfsh5m.us-east-1.es.amazonaws.com

ELASTICSEARCH_URL=your_elasticsearch_url

Set up the elasticsearch DB:

npm run init-elasticsearch

Load data from npm to the elasticsearch DB (this could take awhile):

We are batch requesting 200,000+ packages from npm, then saving to elasticsearch all packages with over 100 downloads in the last month

npm run seed-elasticsearch

note: If it ever gets hung up, you can change the currentRequest var in the elasticsearch.js file to the number of your last completed request and then run node elasticsearch.js again. The process will then start from that most recently completed request.

You should now have a functioning autocomplete backed by your elasticsearch DB.