rushjs 是来自微软的单体仓库管理工具 ,与lerna 类似但是使用上稍显复杂

安装

npm install -g @microsoft/rush
 

简单使用

  • 一个传统的基于npm 的处理
~$ cd my-toolchain
~/my-toolchain$ npm run build
~/my-toolchain$ npm link
~/my-toolchain$ cd ../my-controls
~/my-controls$ npm link my-toolchain
~/my-controls$ npm run build
~/my-controls$ npm link
~/my-app$ cd ../my-app
~/my-app$ npm link my-toolchain
~/my-app$ npm link my-controls
~/my-app$ npm run build
 
 

说明:

my-app: web app
my-controls: web app 需要使用的control包
my-toolchain: nodejs 构建工具,用来编译其他项目
  • 使用rushjs的方式
    初始化项目:
 
rush init

效果:

Rush Multi-Project Build Tool 5.15.0 (unmanaged) - https://rushjs.io
Node.js version is 8.14.0 (LTS)
Starting "rush init"
Generating: /Users/dalong/mylearning/rushjs-learning/first/rush.json
Generating: /Users/dalong/mylearning/rushjs-learning/first/.gitattributes
Generating: /Users/dalong/mylearning/rushjs-learning/first/.gitignore
Generating: /Users/dalong/mylearning/rushjs-learning/first/.travis.yml
Generating: /Users/dalong/mylearning/rushjs-learning/first/common/config/rush/.npmrc
Generating: /Users/dalong/mylearning/rushjs-learning/first/common/config/rush/command-line.json
Generating: /Users/dalong/mylearning/rushjs-learning/first/common/config/rush/common-versions.json
Generating: /Users/dalong/mylearning/rushjs-learning/first/common/config/rush/experiments.json
Generating: /Users/dalong/mylearning/rushjs-learning/first/common/config/rush/pnpmfile.js
Generating: /Users/dalong/mylearning/rushjs-learning/first/common/config/rush/version-policies.json
 
 

说明:
具体文件的参数说明参考 https://rushjs.io/pages/maintainer/setup_new_repo/
添加git 源代码管理

 
git init  
git add  --all
git commit -m "init project"
 

创建一个包

mkdir -p tools/user
cd tools/user
yarn init -y
touch  index.js
/**
 * user commonjs module
 */
module.exports = {
    name: "dalong",
    age:33
}
package.json 内容

添加项目到rush 管理

编辑 rush.json 文件,追加

    {
      "packageName": "tools-user",
      "projectFolder": "tools/user",
      "reviewCategory": "tools"
    }
 

更新rush 项目

rush update 

效果

Rush Multi-Project Build Tool 5.15.0 - https://rushjs.io
Node.js version is 10.14.0 (LTS)
Starting "rush update"
Trying to acquire lock for pnpm-2.15.1
Acquired lock for pnpm-2.15.1
Installing pnpm version 2.15.1
Deleting old files from /Users/dalong/.rush/node-v10.14.0/pnpm-2.15.1
Copying /Users/dalong/mylearning/rushjs-learning/first/common/config/rush/.npmrc --> /Users/dalong/.rush/node-v10.14.0/pnpm-2.15.1/.npmrc
Running "npm install" in /Users/dalong/.rush/node-v10.14.0/pnpm-2.15.1
npm WARN deprecated pnpm@2.15.1: Please use the latest version of pnpm
npm notice created a lockfile as package-lock.json. You should commit this file.
added 1 package from 1 contributor and audited 1 package in 13.314s
found 0 vulnerabilities
Successfully installed pnpm version 2.15.1
Symlinking "/Users/dalong/mylearning/rushjs-learning/first/common/temp/pnpm-local"
  --> "/Users/dalong/.rush/node-v10.14.0/pnpm-2.15.1"
Using the default variant for installation.
Updating temp projects in /Users/dalong/mylearning/rushjs-learning/first/common/temp/projects
Copying /Users/dalong/mylearning/rushjs-learning/first/common/config/rush/.npmrc --> /Users/dalong/mylearning/rushjs-learning/first/common/temp/.npmrc
Updating /Users/dalong/mylearning/rushjs-learning/first/common/temp/pnpmfile.js
Updating /Users/dalong/mylearning/rushjs-learning/first/common/temp/projects/tools-user.tgz
Finished creating temporary modules (0.02 seconds)
Checking node_modules in /Users/dalong/mylearning/rushjs-learning/first/common/temp
Running "pnpm install" in /Users/dalong/mylearning/rushjs-learning/first/common/temp
Using hooks from: /Users/dalong/mylearning/rushjs-learning/first/common/temp/pnpmfile.js
readPackage hook is declared. Manifests of dependencies might get overridden
Packages: +1
+
Resolving: total 1, reused 0, downloaded 1, done
dependencies:
+ @rush-temp/tools-user 0.0.0
   ╭──────────────────────────────────────────────────────────────────╮
   │ │
   │ Update available! 2.25.4 → 2.25.6 │
   │ Changelog: https://github.com/pnpm/pnpm/releases/tag/v2.25.6 │
   │ Run pnpm i -g pnpm to update! │
   │ │
   │ Follow @pnpmjs for updates: https://twitter.com/pnpmjs │
   │ │
   ╰──────────────────────────────────────────────────────────────────╯
Updating /Users/dalong/mylearning/rushjs-learning/first/common/config/rush/shrinkwrap.yaml
Linking projects together...
LINKING: tools-user
Purging /Users/dalong/mylearning/rushjs-learning/first/tools/user/node_modules
Writing "/Users/dalong/mylearning/rushjs-learning/first/common/temp/rush-link.json"
Linking finished successfully. (0.02 seconds)
Next you should probably run "rush build" or "rush rebuild"
Rush update finished successfully. (18.73 seconds)
 

后续添加项目类似

说明

总的来说稍有复杂, 对于一般的项目使用这个工具有点吃力,使用yarn 或者 lerna 这样的工具还是很不错的,后期再研究下

参考资料

https://rushjs.io/pages/maintainer/setup_new_repo/

最新文章

  1. 纯CSS3实现多层云彩变换飞行动画
  2. HTML5桌面通知:notification
  3. PPT产品的重要性
  4. PE355
  5. iOS-多线程-内存管理
  6. Android Studio no debuggable applications解决方案2
  7. java10-3 equals方法
  8. JavaWeb项目前端规范(采用命名空间使js深度解耦合)
  9. Find The Multiple 分类: 搜索 POJ 2015-08-09 15:19 3人阅读 评论(0) 收藏
  10. U3D刚体测试2(ForceMode,AddForce,RelativeAddForce)
  11. leetcode@ [289] Game of Life (Array)
  12. MVC小系列(五)【在过滤器里引入重定向】
  13. iOS 9之分屏多任务(Split View)
  14. 极化码之tal-vardy算法(2)
  15. iOS学习——iOS 整体框架及类继承框架图
  16. Python Web 框架:Tornado
  17. [CERC2017] Intrinsic Interval
  18. java 调用c# web api 代码
  19. swift - 代码创建 pickerView 显示或隐藏横线
  20. 团队博客-第六周:Alpha阶段项目复审(科利尔拉弗队)

热门文章

  1. Linux 常用文件描述
  2. 信安周报-第03周:DB系统表
  3. 使用docker部署titpetric/netdata
  4. SQL小技巧(一)拼音首字母的模糊查询
  5. Options of the DB storage of prometheus
  6. Ubuntu 使用scrapy-splash
  7. ASP.NET Core中使用Cache缓存
  8. ObjC: 源文件的组织
  9. ORACLE数据库导出表,字段名,长度,类型,字段注释,表注释语句
  10. ES6 对象解构赋值(浅拷贝 VS 深拷贝)