GithubHelp home page GithubHelp logo

yao-cli's Introduction

yao-cli

参考文章:

技术栈

cli 工具,涉及到一下技术:

  • Monorepo:Monorepo 是管理项目代码的一个方式,指在一个项目仓库(repo)中管理多个模块/包(package)
  • lerna:lerna 是一个管理工具,用于管理包含多个软件包(package)的 JavaScript 项目
  • commander:Nodejs 命令配置工具
  • Inquirer:一个用户与命令行交互的工具
  • execa:execa 是可以调用 shell 和本地外部程序的 javascript 封装
  • chalk:一个可以修改终端输出字符样式的工具
  • download-git-repo:是用于 从 GitHub, GitLab, Bitbucket 下载一个 git 仓库
  • didyoumean:一个简单的,经过优化的 js 库 和 node.js 模块,能够将人的个性化输入和各种可能性进行匹配

准备

Monorepo

目前最常见的 Monorepo 解决方案是 Lerna 和 Yarn 的 Workspaces 特性。用 Yarn 处理依赖问题,Lerna 处理发布问题

Lerna

开启 Yarn Workspaces

yarn config set workspaces-experimental true

作用:它会在你的操作系统主文件夹的 .yarnrc 文件中添加 workspaces-experimental true。Yarn Workspaces 允许用户在单个根 package.json 文件的子文件夹中从多个 package.json 文件中安装依赖

全局安装 Lerna

yarn add lerna --global

初始化项目

# 创建并进入项目
mkdir project && cd project

# 初始化
yarn init

# lerna 初始化
lerna init

生成目录如下

├── packages
├── lerna.json
├── package.json

package.json

{
  "name": "project",
  "private": true, // 私有的,不会被发布,是管理整个项目,与要发布的npm包解耦
  "devDependencies": {
    "lerna": "^3.22.1"
  }
}

lerna.json

{
  "packages": ["packages/*"],
  "version": "0.0.0"
}

常用代码

# lerna create <package>创建包
lerna create cli 0

提交规范

commitizen && cz-lerna-changelog

yarn add commitizen cz-lerna-changelog -D -W

yao-cli's People

Contributors

yaoyao1987 avatar

Stargazers

Roman avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.