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

drgame-cc-3

v1.0.6

Published

道然游戏适配包

Readme

drgame-cc

道然游戏 Cocos Creator 2.4.15 适配包(npm 包),为宿主项目提供组件脚本、资源与构建模板。

  • 包名:drgame-cc
  • 适用引擎:Cocos Creator 2.4.15
  • 主要组件:BtnExtra(继承 cc.Component)、ExitWin、Toast 等

一、安装

在宿主 Cocos Creator 项目的根目录执行:

npm install drgame-cc

安装完成后会自动触发 postinstall,把包内资源拷贝到宿主项目对应目录(见下文)。

也可在任意位置手动运行安装:npm install drgame-cc --prefix /path/to/CocosProject


二、postinstall(安装后自动 / 手动拷贝)

scripts/postinstall.js 负责把包内的资源同步到宿主 Cocos 项目。

拷贝映射

| 包内目录 | 宿主项目目录 | 说明 | | --- | --- | --- | | build-templates | <CocosRoot>/build-templates | 构建模板 | | drres | <CocosRoot>/assets/resources/drres | 运行时资源 | | drscript | <CocosRoot>/assets/drscript | 组件脚本(@ccclass 组件,编辑器在此识别) |

指定 Cocos 项目路径

默认目标目录为 node_modules 的父目录。可通过命令行参数显式指定 Cocos 项目根目录

# 位置参数
node scripts/postinstall.js D:/MyCocosProject

# 选项形式
node scripts/postinstall.js --cocos-path D:/MyCocosProject
node scripts/postinstall.js --cocos-path=D:/MyCocosProject
node scripts/postinstall.js -p D:/MyCocosProject
  • 优先级:命令行参数 > 默认目录
  • 相对路径会基于当前工作目录解析
  • 目录不存在时打印 [SKIP] 跳过,不影响其它项

注意:要让组件(如 BtnExtra)被编辑器识别,.ts 源文件必须位于宿主 assets/ 内且配套 .meta。请确保发包前 drres/drscript 已生成并纳入 package.json 的 files。


三、sync-back(反向同步,开发调试用)

在宿主项目里改动了脚本或资源后,用 scripts/sync-back.js 把修改反向拷回 npm 包原始目录,便于提交/发包。

拷贝映射(与 postinstall 完全对称,方向相反):

| 宿主项目目录 | 包内目录 | | --- | --- | | <CocosRoot>/build-templates | build-templates | | <CocosRoot>/assets/resources/drres | drres | | <CocosRoot>/assets/drscript | drscript |

用法

node scripts/sync-back.js D:/MyCocosProject
node scripts/sync-back.js --cocos-path D:/MyCocosProject
node scripts/sync-back.js -p D:/MyCocosProject

该脚本会直接覆盖包内同名文件(含 .meta 中宿主生成的 uuid)。建议在 git 版本控制下运行,便于回滚。

建议加入 package.json 的 scripts 作为快捷入口:

"scripts": {
  "postinstall": "node scripts/postinstall.js && echo '完成'",
  "sync-back": "node scripts/sync-back.js"
}

四、发布流程

1. 安全登录(二选一)

方式 A:交互式登录(推荐,不落盘明文密码)

npm login
# 依次输入 Username: banshenghuiyi / Password / Email

方式 B:使用 authToken(写入用户级 ~/.npmrc,不要提交到项目)

npm config set //registry.npmjs.org/:_authToken=<你的TOKEN>

也可在项目根新建 .npmrc,但务必加入 .gitignore,切勿提交:

//registry.npmjs.org/:_authToken=${NPM_TOKEN}

并通过环境变量 NPM_TOKEN 注入。

2. 确认 registry

发布到公共 npm:

npm config get registry   # 应为 https://registry.npmjs.org/

如需发布到私有源,先设置:

npm config set registry https://your-private-registry/

3. 更新版本号

遵循语义化版本(SemVer):

npm version patch   # 1.0.14 -> 1.0.15 修复
npm version minor   # 1.0.14 -> 1.1.0 小特性
npm version major   # 1.0.14 -> 2.0.0 破坏性变更

4. 发布

npm publish

发布前请确认:

  • package.json 的 files 已包含 drres、drscript、build-templates、tvui 等需要分发的目录;
  • 已执行构建,生成最新的 drres/drscript 产物;
  • 没有把 .npmrc、本地凭据、密钥提交进去。

5. 在宿主项目更新

npm update drgame-cc
# 或指定版本
npm install [email protected]

安装后会自动触发 postinstall,把新资源同步到宿主项目。


五、常见问题

Q:编辑器识别不到 BtnExtra 等组件? A:组件 .ts 源文件必须位于宿主 assets/ 内且带 .meta。请确认发包时 drscript(含组件脚本与 .meta)已生成并纳入 files,安装后确实出现在 <CocosRoot>/assets/drscript 下。

Q:postinstall 提示源目录不存在? A:drres/drscript 为空或不存在,通常是未执行构建生成产物。先在包内生成这两个目录再发包。

Q:反向同步后 uuid 变了? A:sync-back 会把宿主项目的 .meta(含其 uuid)覆盖回包内。这是预期行为,便于保持一致;如不需要,可只同步 .ts/资源而忽略 .meta。