Skip to content

duidae/kids-reporter-monorepo

 
 

Repository files navigation

kids-reporter-monorepo

Monorepo setup

This is a monorepo containing sub-packages:

This monorepo adopts husky, lint-staged and yarn workspaces. husky and lint-staged will

  1. run eslint for needed sub-packages before git commit

yarn workspaces will install dependencies of all the sub-packages wisely and effienciently.

Development

Before modifying sub-packages' source codes, make sure you install dependencies on root. We need husky and lint-staged installed first.

Installation

yarn install

如何在 workspaces 中新增 subpkg?

新增 subpkg 的 convention 是在 ${root}/packages/ 底下新增資料夾和檔案, 並且在 root 的 packages.json#workspaces 的 array 中新增 "packages/${subpkg}"

若在同一個 monorepo 中的 subpkgs 之間有相依性,例如:@kids-reporter/cms 依賴 @kids-reporter/cms-core,而 @kids-reporter/core 依賴 @kids-reporter/draft-editor,workspaces 能讓你在 local 端使用 soft link 的方式連結到其他的 subpkgs 去;但要注意你在 packages.json 的 dependencies 裡標示的 name 和 version 要正確。

例如:

// in packages/cms/package.json

"dependencies": {
  "@kids-reporter/cms-core": "^0.4.35",
}

// in packages/core/package.json
"name": "@kids-reporter/cms-core",
"version": "0.4.35"

packages/core/package.jsonnameversionpackages/cms/package.jsondependencies.@kids-reporter/cms-core 一樣時,yarn install 並不會額外從 npm registry 下載 @kids-reporter/cms-core pkg,反倒是會建立 soft link,讓 ${root}/node_modules/@kids-reporter/cms-core 指到 ${root}/packages/core 去。

如此一來,就可以在 local 端一次開發多個 subpkgs。

如何update subpkg version

使用@changeset/cli來update版號, ex:

yarn update

or

yarn changeset && yarn changeset version

Troubleshootings

Q1: 我在 root 資料夾底下跑 yarn install 時,在 yarn postinstall 階段發生錯誤。

A1: 如果錯誤訊息與 @kids-reporter/(draft-editor|draft-renderer|cms-core|) 有關,可以嘗試先到 packages/(draft-editor|draft-renderer|core) 底下,執行 yarn build

確保 local 端有相關的檔案可以讓 packages/cms 載入。

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 89.4%
  • CSS 5.4%
  • JavaScript 3.9%
  • Dockerfile 0.6%
  • Makefile 0.5%
  • Shell 0.1%
  • HTML 0.1%