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

hospital60-cli

v1.0.10

Published

峰禾医院子应用脚手架:基于模板快速生成新的医院定制化项目

Readme

fh-hospital · create-hospital

峰禾医院子应用脚手架 CLI:基于 templates/ 目录生成新的医院定制化子项目,并自动初始化 git 子模块。

安装

通过 npm / pnpm 全局安装:

npm install -g hospital60-cli

安装完成后 create-hospital 命令会自动注册到全局 PATH。

使用

create-hospital 必须在目标仓库根目录下执行:

# 1. 完全交互
create-hospital

# 2. 全部参数传齐(跳过所有交互)
create-hospital \
  --name demo \
  --description "示例医院定制化项目" \
  --branch rel2608

# 3. 只指定医院名,其它走交互 / 默认值
create-hospital --name demo

CLI 选项

| 选项 | 说明 | |---|---| | -n, --name <name> | 医院英文名称(kebab-case),用作目录名、占位符替换值 | | -d, --description <desc> | 项目描述(写入 <仓库根>/README 等文件) | | -b, --branch <branch> | 基线分支版本,写入 .gitmodules 的 modules/baseline | | --skip-submodule-confirm | 跳过子模块初始化的二次确认,直接执行 git submodule add |

完整行为

  1. 空目录检查——目标 cwd 非空时给出三选一:清空 / 保留 / 取消(.git 等隐藏项不算干扰)。
  2. 参数收集——依次询问医院英文名、项目描述、基线分支(已通过 CLI 传入则跳过)。
  3. 预览面板——打印汇总:医院名称 / 英文名 / 描述 / 基线分支 / 生成目录 / 访问前缀 / pnpm 脚本。
  4. 用户确认——二次确认是否生成。
  5. 文件迁移 (processTemplate):
    • 把 templates/ 目录全量复制到仓库根目录。
    • 把 templates/modules/hospital/ 落地为 modules/<医院英文名>/。
    • 在所有非二进制文件里替换占位符:__HOSPITAL_NAME_EN__ / __HOSPITAL_NAME__ / __HOSPITAL_DESCRIPTION__ / customNamePlaceholder。
    • 改写子项目 package.json 的 name / scripts.dev* / scripts.build* / description。
    • 在 <仓库根>/README 写入用户输入的描述。
  6. 基线分支写入——updateGitmodulesBranch 把 .gitmodules 里 modules/baseline 的 branch 改成用户输入;并按 bin/lib/baseline-map.json 联动改 packages 等子模块的 branch。
  7. 子模块初始化 (initSubmodulesFromGitmodules):
    • 再校准一次 packages 的 branch(兜底,模板残留 main 时也能修)。
    • 按 path 深度叶子优先排序。
    • 打印命令清单 → 用户二次确认 → 逐条 git submodule add -b <branch> <url> <path>。
    • 失败跳过继续,最后输出「成功 N,跳过 N,失败 N」汇总。
  8. 后续提示——cd modules/<dir> && pnpm install && pnpm dev:<scriptKey>。

占位符

| 占位符 | 替换为 | 说明 | |---|---|---| | __HOSPITAL_NAME_EN__ | 医院英文名 | kebab-case 后的小写名(如 demo-hospital) | | __HOSPITAL_NAME__ | 医院英文名 | 同上 | | __HOSPITAL_DESCRIPTION__ | 项目描述 | 写入 <仓库根>/README | | customNamePlaceholder | 医院英文名 | modules/<医院名>/src/hook/config.ts、index.html、package.json |

基线 → packages 分支映射

bin/lib/baseline-map.json 维护「基线分支 ↔ 其它子模块分支」的对应关系:

[
  { "baseline": "rel2608", "targets": [{ "path": "packages", "branch": "rel2604" }] }
]

语义:用户最终要的 baseline 是 rel2608 → packages 必须配套使用 rel2604。迁移 / 初始化阶段都会按这张表自动同步。

修改示例:新增一行即可,无需改代码:

{ "baseline": "rel2610", "targets": [{ "path": "packages", "branch": "rel2604" }] }

目录结构

hospital/
├── bin/
│   ├── create-hospital.mjs       # CLI 入口
│   ├── init-hospital.mjs         # 另一个命令
│   └── lib/
│       ├── constants.mjs         # CUSTOM_TEMPLATES / SKIP_DIRS / PATHS
│       ├── copy.mjs              # copyTemplate 递归复制
│       ├── customize.mjs         # 占位符替换 / .gitmodules 处理 / 联动
│       ├── process.mjs           # 流水线编排
│       ├── prompts.mjs           # inquirer 交互
│       ├── submodules.mjs        # git submodule add 执行
│       ├── utils.mjs             # toKebab / replaceInFile / 空目录工具
│       └── baseline-map.json     # 基线 → 子模块 branch 映射
├── templates/                    # = 模板源(modules/{basic,custom,hospital,...})
│   ├── .gitmodules
│   ├── README
│   ├── package.json
│   └── modules/
│       ├── basic/
│       ├── custom/
│       └── hospital/             # 医院子项目模板
└── package.json                  # name: hospital60-cli

依赖

CLI 自身依赖:

  • chalk — 控制台颜色
  • commander — 参数解析
  • inquirer — 交互输入
  • ora — Loading 动画

注意事项

  • 目标目录检查:迁移前会检查 cwd 是否「视为空」(忽略 .git / .gitignore / .DS_Store)。非空时强制三选一。
  • 目标生成目录:modules/<医院英文名>。若已存在同名目录,CLI 中止并提示。
  • 子模块失败不阻塞:URL 不可达、git 未安装等场景不会让整个 create-hospital 失败,仅 warn + 汇总。
  • 基线分支不在映射表:当用户输入的 baseline 不在 baseline-map.json 里,仅改 baseline.branch,不联动 packages。