npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ee-front/kort

v2.10.12

Published

轻量 nodejs 项目自动打包服务

Readme

Kort

轻量 nodejs 项目自动打包服务

安装 kort

安装 kort 前确认你已经准备好 nodejs(>=14) 和 git

# 安装kort 及 yarn pnpm
$ npm install -g kort yarn pnpm --registry=https://tsp.aopacloud.net/verdaccio/

创建 kort 项目

新建目录, 在目录内配置一份 kort.json

// ./my-project/kort.json
[
  {
    // 要打包的远程仓库地址
    origin: 'https://hostname.com/owner/repository.git',
    // 要打包的分支(缺省分支为master分支)
    branches: ['test', 'dev'],
    // 打包消息将会post给webhook
    webhook: 'https://tsp.aopacloud.net/korthub/message'
  }
]

安装项目资源

安装 kort.json 中声明的资源

$ cd ./my-project
$ kort install

打包方式

现在, kort 依赖已经准备好了, 下面有三种打包方式功供你选择, 任选其一即可:

1. 使用定时任务触发打包:

你可以指示 kort 开启定时任务每 5min 扫描仓库变更,并打包变更项目:

$ kort cron

定时打包方式是最简单的打包方式,你不需要做其它配置或工作,只用提交代码到仓库 kort 会定时打包有更新项目

2. 使用 kort 服务,向服务提交打包任务来触发打包

$ kort serve

kort serve 会在 3010 端口开启一个 http 服务, 你需要将此 http 服务发布到公网, 并将此服务的"/github"路由配置到 github 仓库的 webhook 钩子中, 选择由 push 事件触发 webhook, 这样每当 github 仓库有 push 事件发生时,就会触发 kort 服务打包相应项目;

tips: kort 服务提供了一个打包 web 管理后台,你可以在此后台管理打包任务, 访问 kort 服务根路由即可进入管理后台

3. 使用 kort build 命令

如果你的服务器上已经有一套 ci 服务和部署脚本,你只想要 kort 的打包和通知功能, 那么你可以使用 kort build

kort build --selector HEAD^...HEAD --webhook "https://tsp.aopacloud.net/korthub/message"

selector 选择器说明:

  • 项目包名选择器,即 package.json 中的 name 字段如: olapcweb
  • glob 选择器, 相对于仓库根目录的相对路径如: ./h5/olapcweb; ./act/banban*;
  • git 选择器, 如: HEAD^^...HEAD, 会选中两次提交之间有变更的项目

发布

刚配置好的 kort 服务或定时任务还没有打过包,你需要按上节所述触发一次打包后, 才能在 my-project 目录下看到打包的产物, 然后你可以配置 nginx 或者 apache, 将这些打包产物发布出去了

守护 kort 进程

服务不会一直跑在前台, 使用你熟悉的方式守护 kort 进程, 这里以 nodejs 进程管理模块 pm2 为例

# 安装pm2
$ npm i pm2 -g

$ cd my-project

# 使用kort定时任务:
$ pm2 start kort -- cron

# 或者kort定时服务:
$ pm2 start kort -- serve

# 或者你也可以同时开启kort服务与kort定时任务:
$ pm2 start kort -- serve --cron

部署 nginx 配置参考

server {
    listen 80;
    server_name  hostname.com;
    index  index.html index.htm index.php;
    # 发布产物地址
    root  my-project/owner/repository/master;

    expires -1;

    # 支持browserHistory路由
    location ~ /([^\/]+)/[^.]*$ {
        try_files $uri $uri.html $uri/ /$1/index.html /index.html;
    }

    location ~.*\.(js|css|png|jpg|gif|ico|webp|svg|mp4|mp3|ttf|woff|woff2)$
    {
        expires 365d;
    }

    location ~ /\. {
        deny all;
    }
}

打包要求

kort 打包的项目需要满足以下要求:

  1. 项目需要是一个 nodejs 包(即项目根目录下需要有一份 package.json 文件)
  2. 项目需要在 package.json 中的 scripts 字段中提供一个 build 命令,来进行具体的打包动作
  3. 项目打包结果需要是一个保存了打包产物的 dist 目录
  4. 项目需要有一份 lockfile 来保证开发环境和打包环境依赖一致 (package-lock.json, yarn.lock, pnpm-lock.yaml 任意一个)