zoukankan      html  css  js  c++  java
  • rushjs来自微软的单体仓库管理工具

    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/

  • 相关阅读:
    和为S的连续正数序列
    数组中只出现一次的数字
    平衡二叉树
    二叉树的深度
    水仙花数
    数列求和
    数值统计
    奇数乘积
    求绝对值
    求两点的距离
  • 原文地址:https://www.cnblogs.com/rongfengliang/p/11639983.html
Copyright © 2011-2022 走看看