{"id":13671218,"url":"https://github.com/example-repo/lerna-example","last_synced_at":"2025-04-27T14:33:09.401Z","repository":{"id":217144554,"uuid":"133106192","full_name":"example-repo/lerna-example","owner":"example-repo","description":"introduce lerna workfow, Ref https://github.com/pigcan/blog/issues/16","archived":false,"fork":false,"pushed_at":"2018-05-25T07:41:32.000Z","size":13,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-11T08:44:08.476Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/example-repo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-05-12T02:15:57.000Z","updated_at":"2024-02-02T14:29:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"3bc8b1c6-94ae-4f18-82bd-ca41ac553e68","html_url":"https://github.com/example-repo/lerna-example","commit_stats":null,"previous_names":["example-repo/lerna-example"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/example-repo%2Flerna-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/example-repo%2Flerna-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/example-repo%2Flerna-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/example-repo%2Flerna-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/example-repo","download_url":"https://codeload.github.com/example-repo/lerna-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251154352,"owners_count":21544482,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T09:01:03.297Z","updated_at":"2025-04-27T14:33:09.391Z","avatar_url":"https://github.com/example-repo.png","language":"JavaScript","readme":"# lerna-example\nintroduce lerna workfow, Ref https://github.com/pigcan/blog/issues/16\n\n## 仓库结构说明\n\n`packages` 目录下存放的是所有的子仓库\n`tasks` 目录下存放一些全局的任务脚本，当前有用的是 `publish.js` 和 `changelog.js`\n\n- `changelog.js`，当有发布任务时，请事先执行 npm run changelog，此举意为生成本次版本发布的 changelog，执行脚本时会提醒，本次发布是正式版还是 beta，会予以生成不同版本信息供予发布\n- `publish.js`，当 changelog 生成并调整相关内容完毕后，执行 `npm run publish`，会对如上所有的子 packages 进行版本发布，执行脚本时会提醒，本次发布是正式版还是 beta，会予以不同 npm dist-tag 进行发布\n\n\n## 日常开发流程\n\n在常规开发中，我们的操作方式会变更为如下：\n\n\u003e 第一步：使用 commitizen 替代 git commit\n\n即当我们需要 commit 时，请使用如下命令\n\n```bash\n$ npm run ct\n```\n如果你在全局安装过 `commitizen` 那么，直接在项目目录下执行\n\n```bash\n$ git ct\n```\n\n执行时，会有引导式的方式让你书写 commit 的 message 信息\n\n如果你是 sourceTree 用户，其实也不用担心，你完全可以可视化操作完后，再在命令行里面执行 `npm run ct` 命令，这一部分确实破坏了整体的体验，当前并没有找到更好的方式来解决。\n\n关于为什么需要 commitizen，可以参考 [这篇文章](https://github.com/pigcan/blog/issues/15)\n\n当前我们遵循的是 angular 的 commit 规范。\n\n具体格式为:\n\n```\n\u003ctype\u003e(\u003cscope\u003e): \u003csubject\u003e\n\u003cBLANK LINE\u003e\n\u003cbody\u003e\n\u003cBLANK LINE\u003e\n\u003cfooter\u003e\n```\n\n`type`: 本次 commit 的类型，诸如 bugfix docs style 等\n`scope`: 本次 commit 波及的范围\n`subject`: 简明扼要的阐述下本次 commit 的主旨，在原文中特意强调了几点 1. 使用祈使句，是不是很熟悉又陌生的一个词，来传送门在此 [祈使句](https://baike.baidu.com/item/%E7%A5%88%E4%BD%BF%E5%8F%A5/19650285) 2. 首字母不要大写 3. 结尾`无需`添加标点\n`body`: 同样使用祈使句，在主体内容中我们需要把本次 commit 详细的描述一下，比如此次变更的动机，如需换行，则使用 `|`\n`footer`: 描述下与之关联的 issue 或 break change，详见[案例](https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit#heading=h.gbbngquhe0qa)\n\n\n\u003e 第二步：格式化代码\n\n这一步，并不需要人为干预，因为 `precommit` 中的 `lint-staged` 会自动化格式，以保证代码风格尽量一致\n\n\u003e 第三步：commit message 校验\n\n这一步，同样也不需要人为介入，因为 `commitmsg` 中的 `commitlint` 会自动校验 msg 的规范\n\n\u003e 第四步：当有发布需求时，先生成 changelog\n\n使用\n```bash\n$ npm run changelog\n```\n\n在这一步中我们借助了 `commitizen` 标准化的 commit-msg 以及 `lerna` 中 `publish` 的 `--conventional-commits` 来自动化生成了版本号以及 changelog，但过程中我们忽略了  git tag  以及 npm publish （ `--skip-git --skip-npm`），原因是我们需要一个时机去修改自动化生成的  changelog。\n\n\n\u003e 第五步：再发布\n\n由于第四步中，我们并没有实质意义上做版本发布，而是借以 lerna 的 publish 功能，生成了 changelog，所以后续的 publish 操作被实现在了自定义脚本中，即 publish.js 中。\n\n```bash\n$ npm run publish\n```\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexample-repo%2Flerna-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fexample-repo%2Flerna-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexample-repo%2Flerna-example/lists"}