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

pub-dir-replace

v1.0.6

Published

CLI:将 build/dist 目录内容覆盖同步到目标目录,支持多项目路径配置

Readme

pub-dir-replace

A 目录(build/dist) 的内容覆盖同步到 B 目录 的 CLI 工具,支持多组路径配置。


给安装依赖的人(npm 用户)

npm install -g pub-dir-replace
# 或项目内:npm install -D pub-dir-replace && npx pub ...

pub init          # 交互选择配置文件路径(可填 D:\xxx\pub.json),已有则沿用
pub init -c D:/tools/pub-config.json   # 非交互指定路径
pub add           # 交互添加:源目录、目标目录、环境等
pub search        # 确认配置
pub rep dev       # 按环境选择后替换
pub rpj my-app-dev  # 或按配置 id 直接替换

配置写在你本机,不会写在 npm 包目录里:

| 优先级 | 说明 | |--------|------| | 1 | 环境变量 PUB_CONFIG(配置文件绝对路径) | | 2 | 当前目录 .pubrc.json(项目级) | | 3 | 用户目录 ~/.pub-dir-replace/settings.json(只存配置文件路径,任意目录可用 pub) | | 4 | ~/.pub-cli/settings.json(默认方式,配置可在 D 盘等) | | 5 | 默认 ~/.pub-cli/config.json |

pub init -c D:/xxx/pub-config.jsonpub setpath D:/xxx/pub-config.json:配置在 用户目录 .pub-cli 之外 时,会写入 ~/.pub-dir-replace/settings.json,并默认清理 ~/.pub-cli。不再生成 D 盘侧的 .pub-settings.json(若存在会在 setpath 时删除)。保留 C 盘旧登记加 --no-clean-home

pub init文件已存在则不覆盖;再次 init 若已登记且文件在,直接提示沿用。

字段说明见 pathInfo.example.json(仅作格式参考,不会自动写入你的配置)。


给维护者(本仓库 vs 旧目录)

| 目录 | 用途 | |------|------| | testGlobal / main | 你原来的本地脚本(pathInfo.json 在包内),保持不动、继续 npm link 用这套即可 | | testGlobal优化 / main-optimize-branch | 可发 npm 的版本,配置外置,不要在这里 npm link,除非你打算切换全局 pub |

两套目录互不影响;唯一会「抢」全局命令的是:后执行 npm link 的那个目录


安装方式

npm install -g pub-dir-replace
npm install -D pub-dir-replace
npx pub --help

常用命令

| 命令 | 别名 | 说明 | |------|------|------| | pub init [file] | | 初始化;-c 指定路径;已有文件不覆盖 | | pub showConfigPath | pub where | 查看当前生效的配置文件路径 | | pub setConfigPath [path] | pub setpath | 改登记路径,整文件搬到新路径并删旧文件;自定义路径默认清理 C 盘 ~/.pub-cli | | pub cleanHomeRegistry | pub cleanhome | 配置已在自定义路径时,手动清理 C 盘 ~/.pub-cli 登记 | | pub replace <env> | pub rep | 按环境选项目后替换 | | pub replaceByProject [id] | pub rpj | 按 id 替换,省略 id 则交互选择 | | pub addConfig | pub add | 新增一条配置 | | pub searchConfig | pub search | 查看全部配置 | | pub editConfig | pub edit | 修改配置 | | pub deleteConfig | pub delete | 删除配置 |

配置项

| 字段 | 含义 | |------|------| | id | 唯一标识 | | source | 源目录 | | dest | 目标目录 | | remark | 描述 | | env | 环境名,如 dev / prd |

在 package.json 中

{
  "scripts": {
    "replace:dev": "pub rep dev",
    "replace:local": "pub rpj my-app-dev"
  }
}

发布 npm

详见 PUBLISH.md

日常发布:versiongit tag v1.0.xgit push origin v1.0.x(需先在 GitHub 配置 NPM_TOKEN)。

维护者: JaneCjr · 文档更新: 2026-07-23

说明

  • 替换:对源目录顶层每一项,删除目标同名路径后复制(无自动备份,请确认路径)。
  • 包内 pathInfo.json 已忽略,不会发布;仅本地旧习惯或导入用:pub init ./pathInfo.json