├── .changelogrc.js ├── .eslintrc.js ├── .fatherrc.ts ├── .github └── workflows │ ├── release.yml │ └── test.yml ├── .gitignore ├── .husky ├── commit-msg └── pre-commit ├── .npmrc ├── .prettierrc.js ├── .releaserc.js ├── LICENSE ├── README.md ├── commitlint.config.js ├── jest.config.base.ts ├── jest.config.ts ├── lerna.json ├── package.json ├── packages ├── changelog │ ├── .changelogrc.js │ ├── .fatherrc.ts │ ├── CHANGELOG.md │ ├── README.md │ ├── jest.config.ts │ ├── package.json │ ├── src │ │ ├── customConfig.ts │ │ ├── finalizeContext │ │ │ ├── __snapshots__ │ │ │ │ └── index.test.ts.snap │ │ │ ├── index.test.ts │ │ │ └── index.ts │ │ ├── handleWriterOpts.ts │ │ ├── index.ts │ │ ├── templates │ │ │ ├── author-avatar.hbs │ │ │ ├── author.hbs │ │ │ ├── back-to-top.hbs │ │ │ ├── commit.hbs │ │ │ ├── footer.hbs │ │ │ ├── header-newline-timestamp.hbs │ │ │ ├── header.hbs │ │ │ ├── summary-avatar.hbs │ │ │ ├── summary-template.hbs │ │ │ └── template.hbs │ │ ├── transformer │ │ │ ├── index.test.ts │ │ │ ├── index.ts │ │ │ ├── scopeMapDisplayName.test.ts │ │ │ ├── scopeMapDisplayName.ts │ │ │ ├── typeDisplayName.test.ts │ │ │ └── typeDisplayName.ts │ │ └── utils │ │ │ ├── conventional-changelog.ts │ │ │ ├── conventional-recommended-bump.ts │ │ │ ├── git-raw-commit.ts │ │ │ ├── parserOpts.ts │ │ │ └── writerOpts.ts │ ├── test │ │ ├── index.test.ts │ │ └── utils.ts │ └── tsconfig.json ├── commit-types │ ├── .fatherrc.ts │ ├── CHANGELOG.md │ ├── README.md │ ├── jest.config.ts │ ├── package.json │ ├── src │ │ └── index.ts │ ├── test │ │ ├── __snapshots__ │ │ │ └── index.test.ts.snap │ │ └── index.test.ts │ └── tsconfig.json ├── commitlint-config │ ├── .changelogrc.js │ ├── .fatherrc.ts │ ├── CHANGELOG.md │ ├── README.md │ ├── jest.config.ts │ ├── package.json │ ├── src │ │ └── index.ts │ ├── test │ │ ├── index.test.ts │ │ └── utils.ts │ └── tsconfig.json ├── commitlint-plugin │ ├── .changelogrc.js │ ├── .fatherrc.ts │ ├── CHANGELOG.md │ ├── README.md │ ├── jest.config.ts │ ├── package.json │ ├── src │ │ ├── gitmojiCode.ts │ │ ├── index.ts │ │ └── rule.ts │ ├── test │ │ ├── gitmojiCode.test.ts │ │ └── rule.test.ts │ └── tsconfig.json ├── gitmoji-regex │ ├── .changelogrc.js │ ├── .fatherrc.ts │ ├── CHANGELOG.md │ ├── README.md │ ├── jest.config.ts │ ├── package.json │ ├── src │ │ └── index.ts │ ├── tests │ │ └── index.test.ts │ └── tsconfig.json ├── parser-opts │ ├── .changelogrc.js │ ├── .fatherrc.ts │ ├── CHANGELOG.md │ ├── README.md │ ├── jest.config.ts │ ├── package.json │ ├── src │ │ └── index.ts │ ├── tests │ │ └── index.test.ts │ └── tsconfig.json └── release-config │ ├── .changelogrc.js │ ├── .fatherrc.ts │ ├── CHANGELOG.md │ ├── README.md │ ├── jest.config.ts │ ├── package.json │ ├── src │ ├── __snapshots__ │ │ └── index.test.ts.snap │ ├── createConfig.ts │ ├── index.test.ts │ ├── index.ts │ ├── plugins │ │ ├── commitAnalyzer.test.ts │ │ ├── commitAnalyzer.ts │ │ ├── git.test.ts │ │ ├── git.ts │ │ ├── github.test.ts │ │ ├── github.ts │ │ ├── npm.test.ts │ │ └── npm.ts │ └── type.ts │ ├── tests │ ├── config │ │ ├── custom.js │ │ └── default.js │ ├── createConfig.test.ts │ └── e2e.test.ts │ └── tsconfig.json ├── pnpm-workspace.yaml ├── tsconfig-check.json └── tsconfig.json /.changelogrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | displayTypes: ['feat', 'fix', 'styles', 'pref'], 3 | showSummary: true, 4 | reduceHeadingLevel: true, 5 | newlineTimestamp: true, 6 | addBackToTop: true, 7 | }; 8 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | const config = require('@umijs/max/eslint'); 2 | 3 | module.exports = { 4 | ...config, 5 | }; 6 | -------------------------------------------------------------------------------- /.fatherrc.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'father'; 2 | 3 | export default defineConfig({ 4 | cjs: { output: 'lib', platform: 'browser' }, 5 | extraBabelPlugins: ['add-module-exports'], 6 | }); 7 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release CI 2 | on: 3 | push: 4 | branches: 5 | - master 6 | - beta 7 | - rc-* 8 | 9 | jobs: 10 | test: 11 | name: Test 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v3 15 | 16 | - name: Install pnpm 17 | uses: pnpm/action-setup@v2 18 | with: 19 | version: 7 20 | 21 | - name: Setup Node.js environment 22 | uses: actions/setup-node@v3 23 | with: 24 | node-version: '16' 25 | 26 | - name: Install deps 27 | run: pnpm install 28 | 29 | - name: Test 30 | run: pnpm run test 31 | 32 | - name: Health check with doctor 33 | run: pnpm run doctor 34 | 35 | release: 36 | needs: test 37 | name: Release 38 | runs-on: ubuntu-latest 39 | steps: 40 | - uses: actions/checkout@v3 41 | 42 | - name: Install pnpm 43 | uses: pnpm/action-setup@v2 44 | with: 45 | version: 7 46 | 47 | - name: Setup Node.js environment 48 | uses: actions/setup-node@v3 49 | with: 50 | node-version: '16' 51 | 52 | # npm 8 和 9 会在 `npm version` 时执行依赖树命令,进而报错退出 53 | # Refs: https://github.com/semantic-release/npm/issues/540 54 | - name: Setup npm 7 55 | run: npm i -g npm@7 --registry=https://registry.npmjs.org 56 | 57 | - name: Install deps 58 | run: pnpm install 59 | 60 | - name: build 61 | run: pnpm run build 62 | 63 | - name: release 64 | run: pnpm run release 65 | env: 66 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 67 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} 68 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Test CI 2 | on: [push, pull_request] 3 | jobs: 4 | test: 5 | runs-on: ubuntu-latest 6 | 7 | steps: 8 | - uses: actions/checkout@v3 9 | 10 | - name: Install pnpm 11 | uses: pnpm/action-setup@v2 12 | with: 13 | version: 7 14 | 15 | - name: Setup Node.js environment 16 | uses: actions/setup-node@v3 17 | with: 18 | node-version: '16' 19 | 20 | - name: Install deps 21 | run: pnpm install 22 | 23 | - name: Test and coverage 24 | run: pnpm run test:coverage 25 | 26 | - name: Health check with doctor 27 | run: pnpm run doctor 28 | 29 | - name: Upload coverage to Codecov 30 | uses: codecov/codecov-action@v3 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | ### Node ### 3 | # Logs 4 | logs 5 | npm-debug.log* 6 | yarn-debug.log* 7 | yarn-error.log* 8 | 9 | # Optional npm cache directory 10 | .npm 11 | 12 | # Dependency directories 13 | node_modules 14 | /jspm_packages 15 | /bower_components 16 | 17 | # Yarn Integrity file 18 | .yarn-integrity 19 | 20 | # Optional eslint cache 21 | .eslintcache 22 | 23 | # dotenv environment variables file(s) 24 | .env 25 | .env.* 26 | 27 | #Build generated 28 | dist/ 29 | build/ 30 | 31 | # Serverless generated files 32 | .serverless/ 33 | 34 | ### SublimeText ### 35 | # cache files for sublime text 36 | *.tmlanguage.cache 37 | *.tmPreferences.cache 38 | *.stTheme.cache 39 | 40 | # workspace files are user-specific 41 | *.sublime-workspace 42 | 43 | # project files should be checked into the repository, unless a significant 44 | # proportion of contributors will probably not be using SublimeText 45 | # *.sublime-project 46 | 47 | 48 | ### VisualStudioCode ### 49 | .vscode/* 50 | !.vscode/settings.json 51 | !.vscode/tasks.json 52 | !.vscode/launch.json 53 | !.vscode/extensions.json 54 | 55 | ### Vim ### 56 | *.sw[a-p] 57 | 58 | ### WebStorm/IntelliJ ### 59 | /.idea 60 | modules.xml 61 | *.ipr 62 | 63 | 64 | ### System Files ### 65 | *.DS_Store 66 | 67 | # Windows thumbnail cache files 68 | Thumbs.db 69 | ehthumbs.db 70 | ehthumbs_vista.db 71 | 72 | # Folder config file 73 | Desktop.ini 74 | 75 | # Recycle Bin used on file shares 76 | $RECYCLE.BIN/ 77 | 78 | # Thumbnails 79 | ._* 80 | 81 | # Files that might appear in the root of a volume 82 | .DocumentRevisions-V100 83 | .fseventsd 84 | .Spotlight-V100 85 | .TemporaryItems 86 | .Trashes 87 | .VolumeIcon.icns 88 | .com.apple.timemachine.donotpresent 89 | 90 | coverage 91 | lib 92 | gitmojis.json 93 | /lerna-debug.log 94 | tmp 95 | -------------------------------------------------------------------------------- /.husky/commit-msg: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | . "$(dirname -- "$0")/_/husky.sh" 3 | 4 | npx --no -- commitlint --edit ${1} -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | . "$(dirname -- "$0")/_/husky.sh" 3 | 4 | npx --no-install lint-staged 5 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | lockfile=false 2 | -------------------------------------------------------------------------------- /.prettierrc.js: -------------------------------------------------------------------------------- 1 | const config = require('@umijs/max/prettier'); 2 | 3 | module.exports = { 4 | ...config, 5 | printWidth: 100, 6 | overrides: [ 7 | { 8 | files: '*.md', 9 | options: { 10 | parser: 'markdown', 11 | proseWrap: 'preserve', 12 | }, 13 | }, 14 | ], 15 | }; 16 | -------------------------------------------------------------------------------- /.releaserc.js: -------------------------------------------------------------------------------- 1 | const { createConfig } = require('./packages/release-config/lib/createConfig'); 2 | 3 | const config = createConfig({ monorepo: true }); 4 | 5 | module.exports = { ...config }; -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 - Current Arvin Xu 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | > 😉 Use gitmoji commit in your workflow 2 | 3 | # Gitmoji Commit Workflow 4 | 5 | [![Gitmoji][gitmoji]][gitmoji-url] [![lerna][lerna]][lerna-url] [![Build With father][father]][father-url] [![semantic-release][semantic-release]][semantic-release-repo] ![][license-url] 6 | 7 | [![Test CI status][test-ci]][test-ci-url] [![Release CI][release-ci]][deploy-ci-url] [![Coverage][coverage]][codecov-url] 8 | 9 | 10 | 11 | [father]: https://img.shields.io/badge/build%20with-father-028fe4.svg 12 | [father-url]: https://github.com/umijs/father/ 13 | [lerna]: https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg 14 | [lerna-url]: https://lernajs.io/ 15 | [gitmoji]: https://img.shields.io/badge/gitmoji-%20😜%20😍-FFDD67.svg 16 | [gitmoji-url]: https://gitmoji.carloscuesta.me/ 17 | [semantic-release]: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg 18 | [semantic-release-repo]: https://github.com/semantic-release/semantic-release 19 | [license-url]: https://img.shields.io/github/license/arvinxx/gitmoji-commit-workflow 20 | 21 | 22 | 23 | [test-ci]: https://github.com/arvinxx/gitmoji-commit-workflow/workflows/Test%20CI/badge.svg 24 | [release-ci]: https://github.com/arvinxx/gitmoji-commit-workflow/workflows/Release%20CI/badge.svg 25 | [test-ci-url]: https://github.com/arvinxx/gitmoji-commit-workflow/actions?query=workflow%3A%22Test+CI%22 26 | [deploy-ci-url]: https://github.com/arvinxx/gitmoji-commit-workflow/actions?query=workflow%3A%22Release+CI%22 27 | [coverage]: https://codecov.io/gh/arvinxx/gitmoji-commit-workflow/branch/master/graph/badge.svg 28 | [codecov-url]: https://codecov.io/gh/arvinxx/gitmoji-commit-workflow/branch/master 29 | 30 | ## What is Gitmoji Commit Workflow? 31 | 32 | English(TODO) | [中文](https://www.yuque.com/arvinxx-fe/workflow/gitmoji-commit-workflow) 33 | 34 | ## Template 35 | 36 | Refer to this repository to get a [template](https://github.com/arvinxx/gitmoji-commit-workflow-template) of Gitmoji Commit Workflow 37 | 38 | ## Packages 39 | 40 | ### Shareable Configuration 41 | 42 | Here are some packages for gitmoji commit workflow 43 | 44 | | Packages | Status | Description | 45 | | ------------------------------------------------------------- | ---------------------------------------------------------- | ---------------------------------------------------------------------------------------- | 46 | | [commitlint-config-gitmoji](packages/commitlint-config) | [![NPM version][config-image]][config-url] | a shareable commitlint configuration to enforcing gitmoji commit | 47 | | [conventional-changelog-gitmoji-config](./packages/changelog) | [![NPM version][changelog-image]][changelog-url] | a shareable conventional-changelog configuration to generate changelog of gitmoji commit | 48 | | [semantic-release-config-gitmoji](packages/release-config) | [![NPM version][release-module-image]][release-module-url] | a shareable conventional-changelog configuration to generate changelog of gitmoji commit | 49 | 50 | [config-image]: http://img.shields.io/npm/v/commitlint-config-gitmoji.svg?style=flat-square&color=deepgreen&label=latest 51 | [config-url]: http://npmjs.org/package/commitlint-config-gitmoji 52 | [config-download]: https://img.shields.io/npm/dm/commitlint-config-gitmoji.svg?style=flat-square 53 | [config-monorepo-image]: http://img.shields.io/npm/v/commitlint-config-gitmoji-monorepo.svg?style=flat-square&color=deepgreen&label=latest 54 | [config-monorepo-url]: http://npmjs.org/package/commitlint-config-gitmoji-monorepo 55 | [config-monorepo-download]: https://img.shields.io/npm/dm/commitlint-config-gitmoji-monorepo.svg?style=flat-square 56 | [changelog-image]: http://img.shields.io/npm/v/conventional-changelog-gitmoji-config.svg?style=flat-square&color=deepgreen&label=latest 57 | [changelog-url]: http://npmjs.org/package/conventional-changelog-gitmoji-config 58 | [changelog-download]: https://img.shields.io/npm/dm/conventional-changelog-gitmoji-config.svg?style=flat-square 59 | [release-module-image]: http://img.shields.io/npm/v/semantic-release-config-gitmoji-module.svg?style=flat-square&color=deepgreen&label=latest 60 | [release-module-url]: http://npmjs.org/package/semantic-release-config-gitmoji-module 61 | [release-module-download]: https://img.shields.io/npm/dm/semantic-release-config-gitmoji-module.svg?style=flat-square 62 | 63 | ### Helper 64 | 65 | | Packages | Status | Description | 66 | | ------------------------------------------------------- | ------------------------------------------ | ---------------------------------------------------- | 67 | | [commitlint-plugin-gitmoji](packages/commitlint-plugin) | [![NPM version][plugin-image]][plugin-url] | a commitlint plugin to add gitmoji check rule | 68 | | [@gitmoji/parser-opts](./packages/parser-opts) | [![NPM version][parser-image]][parser-url] | a shareable parser options for gitmoji styles commit | 69 | | [@gitmoji/commit-types](./packages/commit-types) | [![NPM version][types-image]][types-url] | gitmoji styles commit types | 70 | | [@gitmoji/gitmoji-regex](./packages/gitmoji-regex) | [![NPM version][regex-image]][regex-url] | a gitmoji regex | 71 | 72 | 73 | 74 | [plugin-image]: http://img.shields.io/npm/v/commitlint-plugin-gitmoji.svg?style=flat-square&color=deepgreen&label=latest 75 | [plugin-url]: http://npmjs.org/package/commitlint-plugin-gitmoji 76 | [parser-image]: http://img.shields.io/npm/v/@gitmoji/parser-opts.svg?style=flat-square&color=deepgreen&label=latest 77 | [parser-url]: http://npmjs.org/package/@gitmoji/parser-opts 78 | [types-image]: http://img.shields.io/npm/v/@gitmoji/commit-types.svg?style=flat-square&color=deepgreen&label=latest 79 | [types-url]: http://npmjs.org/package/@gitmoji/commit-types 80 | [regex-image]: http://img.shields.io/npm/v/@gitmoji/gitmoji-regex.svg?style=flat-square&color=deepgreen&label=latest 81 | [regex-url]: http://npmjs.org/package/@gitmoji/gitmoji-regex 82 | 83 | ## About this Repo 84 | 85 | The commitlint gitmoji repo is managed as a [monorepo](https://github.com/babel/babel/blob/master/doc/design/monorepo.md); it's composed of many npm packages. 86 | 87 | The original `commitlint-config-gitmoji` repo can be found in [packages/config](packages/commitlint-config). 88 | 89 | ## License 90 | 91 | [MIT](./LICENSE) ® Arvin Xu 92 | -------------------------------------------------------------------------------- /commitlint.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: ['./packages/commitlint-config/lib/index.js'], 3 | rules: { 4 | 'footer-leading-blank': [0, 'never'], 5 | 'header-max-length': [0, 'never'], 6 | }, 7 | }; 8 | -------------------------------------------------------------------------------- /jest.config.base.ts: -------------------------------------------------------------------------------- 1 | import { createConfig, Config } from '@umijs/test'; 2 | import path from 'path'; 3 | 4 | const base: Config.InitialOptions = createConfig({ 5 | jsTransformer: 'esbuild', 6 | target: 'node', 7 | }); 8 | 9 | delete base.testTimeout; 10 | 11 | const config: Config.InitialOptions = { 12 | ...base, 13 | moduleNameMapper: { 14 | ...base.moduleNameMapper, 15 | 'commitlint-plugin-gitmoji': '/packages/commitlint-plugin/src', 16 | '@gitmoji/parser-opts': '/packages/parser-opts/src', 17 | '@gitmoji/gitmoji-regex': '/packages/gitmoji-regex/src', 18 | '@gitmoji/commit-types': '/packages/commit-types/src', 19 | }, 20 | rootDir: path.resolve(__dirname, '.'), 21 | coveragePathIgnorePatterns: ['/node_modules/', '/lib/', '/es/'], 22 | }; 23 | 24 | export default config; 25 | -------------------------------------------------------------------------------- /jest.config.ts: -------------------------------------------------------------------------------- 1 | import baseConfig from './jest.config.base'; 2 | import { Config } from '@umijs/test'; 3 | 4 | const config: Config.InitialOptions = { 5 | ...baseConfig, 6 | projects: ['/packages/*/jest.config.ts'], 7 | collectCoverageFrom: ['/packages/*/src/**/*.ts'], 8 | coverageDirectory: '/coverage/', 9 | }; 10 | 11 | export default config; 12 | -------------------------------------------------------------------------------- /lerna.json: -------------------------------------------------------------------------------- 1 | { 2 | "packages": ["packages/*"], 3 | "command": { 4 | "bootstrap": { 5 | "hoist": true 6 | } 7 | }, 8 | "useWorkspaces": true, 9 | "version": "independent", 10 | "npmClient": "pnpm" 11 | } 12 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gitmoji-commit-workflow", 3 | "private": true, 4 | "description": "🎉 gitmoji commit workflow", 5 | "repository": { 6 | "type": "git", 7 | "url": "https://github.com/arvinxx/gitmoji-commit-workflow.git" 8 | }, 9 | "license": "MIT", 10 | "author": "Arvin Xu ", 11 | "workspaces": [ 12 | "packages/*" 13 | ], 14 | "scripts": { 15 | "build": "lerna run build --parallel", 16 | "clean": "lerna run clean && rm -rf es lib dist build coverage .umi .eslintcache apis", 17 | "doctor": "lerna run doctor", 18 | "postinstall": "npm run build", 19 | "lint": "npm run lint-eslint && npm run tsc", 20 | "lint-eslint": "eslint --cache --fix --ext .js,.jsx,.ts,.tsx packages/**/src", 21 | "lint-staged": "lint-staged", 22 | "lint-staged:js": "eslint --cache --ext .js,.jsx,.ts,.tsx", 23 | "lint-styles": "stylelint", 24 | "lint:fix": "eslint --fix --cache --ext .js,.jsx,.ts,.tsx ", 25 | "prepare": "husky install", 26 | "prettier": "prettier --write '**/*.{js,jsx,tsx,ts,less,md,json}'", 27 | "release": "multi-semantic-release", 28 | "release:local": "multi-semantic-release --no-ci", 29 | "test": "jest", 30 | "test:coverage": "jest --coverage", 31 | "tsc": "tsc -p tsconfig-check.json" 32 | }, 33 | "lint-staged": { 34 | "*.{js,jsx,less,md,json}": [ 35 | "prettier --write" 36 | ], 37 | "*.ts?(x)": [ 38 | "prettier --parser=typescript --write", 39 | "yarn lint:fix" 40 | ] 41 | }, 42 | "devDependencies": { 43 | "@commitlint/cli": "^17", 44 | "@types/jest": "^29", 45 | "@types/node": "^16", 46 | "@types/semantic-release": "^17", 47 | "@types/sinon": "^10.0.0", 48 | "@umijs/max": "^4", 49 | "@umijs/test": "^4", 50 | "babel-plugin-add-module-exports": "^1", 51 | "conventional-changelog-gitmoji-config": "^1", 52 | "eslint": "^8", 53 | "father": "^4", 54 | "husky": "^8", 55 | "jest": "^29", 56 | "lerna": "^4.0.0", 57 | "lint-staged": "^13", 58 | "multi-semantic-release": "^3", 59 | "prettier": "^2.2.1", 60 | "prettier-plugin-organize-imports": "^3", 61 | "prettier-plugin-packagejson": "^2", 62 | "semantic-release": "^19.0.5", 63 | "ts-jest": "^29", 64 | "ts-node": "^10", 65 | "typescript": "^4.1.3" 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /packages/changelog/.changelogrc.js: -------------------------------------------------------------------------------- 1 | const base = require('../../.changelogrc'); 2 | 3 | module.exports = { 4 | ...base, 5 | scopeDisplayName: { 6 | '*': 'misc', 7 | }, 8 | }; 9 | -------------------------------------------------------------------------------- /packages/changelog/.fatherrc.ts: -------------------------------------------------------------------------------- 1 | import config from '../../.fatherrc'; 2 | 3 | export default config; 4 | -------------------------------------------------------------------------------- /packages/changelog/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ### [Version 1.5.2](https://github.com/arvinxx/gitmoji-commit-workflow/compare/conventional-changelog-gitmoji-config@1.5.1...conventional-changelog-gitmoji-config@1.5.2) 4 | 5 | Released on **2023-06-12** 6 | 7 | #### 🐛 Bug Fixes 8 | 9 | - **changelog**: Fix subCommitScope default value and reduceHeadingLevel. 10 | 11 |
12 | 13 |
14 | Improvements and Fixes 15 | 16 | #### What's fixed 17 | 18 | - **changelog**: Fix subCommitScope default value and reduceHeadingLevel, closes [#670](https://github.com/arvinxx/gitmoji-commit-workflow/issues/670) ([e4da993](https://github.com/arvinxx/gitmoji-commit-workflow/commit/e4da993)) 19 | 20 |
21 | 22 |
23 | 24 | [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top) 25 | 26 |
27 | 28 | ## [Version 1.5.1](https://github.com/arvinxx/gitmoji-commit-workflow/compare/conventional-changelog-gitmoji-config@1.5.0...conventional-changelog-gitmoji-config@1.5.1) 29 | 30 | Released on **2023-06-10** 31 | 32 | #### 🐛 Bug Fixes 33 | 34 | - **changelog**: Add pangu deps. 35 | 36 |
37 | 38 |
39 | Improvements and Fixes 40 | 41 | ##### What's fixed 42 | 43 | - **changelog**: Add pangu deps ([f62727e](https://github.com/arvinxx/gitmoji-commit-workflow/commit/f62727e)) 44 | 45 |
46 | 47 |
48 | 49 | [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top) 50 | 51 |
52 | 53 | # conventional-changelog-gitmoji-config [1.5.0](https://github.com/arvinxx/gitmoji-commit-workflow/compare/conventional-changelog-gitmoji-config@1.4.7...conventional-changelog-gitmoji-config@1.5.0) (2023-06-10) 54 | 55 | ### ✨ Features 56 | 57 | - **changelog**: Add changelog style configs, closes [#669](https://github.com/arvinxx/gitmoji-commit-workflow/issues/669) ([f9e6585](https://github.com/arvinxx/gitmoji-commit-workflow/commit/f9e6585)) 58 | 59 | ## conventional-changelog-gitmoji-config [1.4.7](https://github.com/arvinxx/gitmoji-commit-workflow/compare/conventional-changelog-gitmoji-config@1.4.6...conventional-changelog-gitmoji-config@1.4.7) (2023-02-15) 60 | 61 | ### 🐛 Bug Fixes 62 | 63 | - 修正 changelog 日志问题 ([c4053b2](https://github.com/arvinxx/gitmoji-commit-workflow/commit/c4053b2)) 64 | 65 | ## conventional-changelog-gitmoji-config [1.4.6](https://github.com/arvinxx/gitmoji-commit-workflow/compare/conventional-changelog-gitmoji-config@1.4.5...conventional-changelog-gitmoji-config@1.4.6) (2023-02-11) 66 | 67 | ### Dependencies 68 | 69 | - **@gitmoji/parser-opts:** upgraded to 1.4.0 70 | 71 | ## conventional-changelog-gitmoji-config [1.4.5](https://github.com/arvinxx/gitmoji-commit-workflow/compare/conventional-changelog-gitmoji-config@1.4.4...conventional-changelog-gitmoji-config@1.4.5) (2023-02-11) 72 | 73 | ### Dependencies 74 | 75 | - **@gitmoji/parser-opts:** upgraded to 1.4.0 76 | 77 | ## conventional-changelog-gitmoji-config [1.4.5-beta.1](https://github.com/arvinxx/gitmoji-commit-workflow/compare/conventional-changelog-gitmoji-config@1.4.4...conventional-changelog-gitmoji-config@1.4.5-beta.1) (2023-02-11) 78 | 79 | ### Dependencies 80 | 81 | - **@gitmoji/parser-opts:** upgraded to 1.4.0-beta.2 82 | 83 | ## conventional-changelog-gitmoji-config [1.4.5-beta.1](https://github.com/arvinxx/gitmoji-commit-workflow/compare/conventional-changelog-gitmoji-config@1.4.4...conventional-changelog-gitmoji-config@1.4.5-beta.1) (2023-02-11) 84 | 85 | ### Dependencies 86 | 87 | - **@gitmoji/parser-opts:** upgraded to 1.4.0-beta.1 88 | 89 | ## conventional-changelog-gitmoji-config [1.4.4](https://github.com/arvinxx/gitmoji-commit-workflow/compare/conventional-changelog-gitmoji-config@1.4.3...conventional-changelog-gitmoji-config@1.4.4) (2022-10-09) 90 | 91 | ### Dependencies 92 | 93 | - **@gitmoji/parser-opts:** upgraded to 1.3.1 94 | 95 | ## conventional-changelog-gitmoji-config [1.4.4-beta.1](https://github.com/arvinxx/gitmoji-commit-workflow/compare/conventional-changelog-gitmoji-config@1.4.3...conventional-changelog-gitmoji-config@1.4.4-beta.1) (2022-10-09) 96 | 97 | ### Dependencies 98 | 99 | - **@gitmoji/parser-opts:** upgraded to 1.3.1-beta.1 100 | 101 | ## conventional-changelog-gitmoji-config [1.4.3](https://github.com/arvinxx/gitmoji-commit-workflow/compare/conventional-changelog-gitmoji-config@1.4.2...conventional-changelog-gitmoji-config@1.4.3) (2021-03-12) 102 | 103 | ### 🐛 Bug Fixes 104 | 105 | - fix error when there is no changelog config ([1ec76ee](https://github.com/arvinxx/gitmoji-commit-workflow/commit/1ec76ee)) 106 | 107 | ## conventional-changelog-gitmoji-config [1.4.2](https://github.com/arvinxx/gitmoji-commit-workflow/compare/conventional-changelog-gitmoji-config@1.4.1...conventional-changelog-gitmoji-config@1.4.2) (2021-03-06) 108 | 109 | ### Dependencies 110 | 111 | - **@gitmoji/parser-opts:** upgraded to 1.3.0 112 | 113 | ## conventional-changelog-gitmoji-config [1.4.1](https://github.com/arvinxx/gitmoji-commit-workflow/compare/conventional-changelog-gitmoji-config@1.4.0...conventional-changelog-gitmoji-config@1.4.1) (2021-02-26) 114 | 115 | ### Dependencies 116 | 117 | - **@gitmoji/parser-opts:** upgraded to 1.2.6 118 | 119 | # conventional-changelog-gitmoji-config [1.4.0](https://github.com/arvinxx/gitmoji-commit-workflow/compare/conventional-changelog-gitmoji-config@1.3.6...conventional-changelog-gitmoji-config@1.4.0) (2021-01-30) 120 | 121 | ### ✨ Features 122 | 123 | - **commitlint-config-gitmoji**: support more config type ([84db257](https://github.com/arvinxx/gitmoji-commit-workflow/commit/84db257)) 124 | - **i18n**: support on or off emoji ([6ad63c4](https://github.com/arvinxx/gitmoji-commit-workflow/commit/6ad63c4)) 125 | - **i18n**: support switch language ([c7dfa78](https://github.com/arvinxx/gitmoji-commit-workflow/commit/c7dfa78)) 126 | 127 | ## conventional-changelog-gitmoji-config [1.3.6](https://github.com/arvinxx/gitmoji-commit-workflow/compare/conventional-changelog-gitmoji-config@1.3.5...conventional-changelog-gitmoji-config@1.3.6) (2021-01-27) 128 | 129 | ### 🐛 Bug Fixes | 修复 130 | 131 | - **conventional-changelog-gitmoji-config**: fix style type display name ([2fe4ecf](https://github.com/arvinxx/gitmoji-commit-workflow/commit/2fe4ecf)) 132 | 133 | ## conventional-changelog-gitmoji-config [1.3.5](https://github.com/arvinxx/gitmoji-commit-workflow/compare/conventional-changelog-gitmoji-config@1.3.4...conventional-changelog-gitmoji-config@1.3.5) (2021-01-25) 134 | 135 | ### Dependencies 136 | 137 | - **@gitmoji/commit-types:** upgraded to 1.1.5 138 | 139 | ## conventional-changelog-gitmoji-config [1.3.4](https://github.com/arvinxx/gitmoji-commit-workflow/compare/conventional-changelog-gitmoji-config@1.3.3...conventional-changelog-gitmoji-config@1.3.4) (2021-01-25) 140 | 141 | ### 🐛 Bug Fixes | 修复 142 | 143 | - **conventional-changelog-gitmoji-config**: remove scope brace ([5ae3807](https://github.com/arvinxx/gitmoji-commit-workflow/commit/5ae3807)) 144 | 145 | ## conventional-changelog-gitmoji-config [1.3.3](https://github.com/arvinxx/gitmoji-commit-workflow/compare/conventional-changelog-gitmoji-config@1.3.2...conventional-changelog-gitmoji-config@1.3.3) (2021-01-25) 146 | 147 | ### 🐛 Bug Fixes | 修复 148 | 149 | - **(Other)**: clean changelog ([8479426](https://github.com/arvinxx/gitmoji-commit-workflow/commit/8479426)) 150 | - **(Other)**: link deps ([e4526ed](https://github.com/arvinxx/gitmoji-commit-workflow/commit/e4526ed)) 151 | 152 | ### Dependencies 153 | 154 | - **@gitmoji/commit-types:** upgraded to 1.1.4 155 | - **@gitmoji/parser-opts:** upgraded to 1.2.5 156 | 157 | # [conventional-changelog-gitmoji-config-v1.2.3](https://github.com/arvinxx/gitmoji-commit-workflow/compare/conventional-changelog-gitmoji-config-v1.2.2...conventional-changelog-gitmoji-config-v1.2.3) (2021-01-25) 158 | 159 | ### 🐛 Bug Fixes | 修复 160 | 161 | - **(Other)**: clean changelog ([8479426](https://github.com/arvinxx/gitmoji-commit-workflow/commit/8479426)) 162 | - **(Other)**: link deps ([e4526ed](https://github.com/arvinxx/gitmoji-commit-workflow/commit/e4526ed)) 163 | -------------------------------------------------------------------------------- /packages/changelog/README.md: -------------------------------------------------------------------------------- 1 | # conventional-changelog-gitmoji-config 2 | 3 | [![NPM version][version-image]][version-url] [![NPM downloads][download-image]][download-url] 4 | 5 | sharable conventional changelog configuration for gitmoji style commit 6 | 7 | ## Configuration File 8 | 9 | `conventional-changelog-gitmoji-config` uses [cosmiconfig](https://github.com/davidtheclark/cosmiconfig#cosmiconfigsync) to find and load your configuration object. Starting from the current working directory, it looks for the following possible sources: 10 | 11 | - a `changelog` property in `package.json` 12 | - a `.changelogrc` file 13 | - a `changelog.config.js` file exporting a JS object 14 | 15 | The `.changelogrc` file (without extension) can be in JSON or YAML format. You can add a filename extension to help your text editor provide syntax checking and highlighting: 16 | 17 | - .changelogrc.json 18 | - .changelogrc.yaml / .changelogrc.yml 19 | - .changelogrc.js 20 | 21 | The configuration object has the following signature: 22 | 23 | ```typescript 24 | interface ChangelogConfig { 25 | /** 26 | * map the scope to display name 27 | * 28 | * for example 29 | * { 30 | * 'config': 'commitlint-gitmoji-config' 31 | * } 32 | * will map all config 'scope' to 'commitlint-gitmoji-config' in the changelog 33 | * @default { } 34 | */ 35 | scopeDisplayName?: Record; 36 | /** 37 | * display types 38 | * @default undefined 39 | */ 40 | displayTypes?: string[]; 41 | /** 42 | * whether to include emoji in title 43 | * @default true 44 | */ 45 | withEmoji?: boolean; 46 | /** 47 | * title language 48 | * @default en-US 49 | */ 50 | titleLanguage?: 'en-US' | 'zh-CN' | 'mix'; 51 | /** 52 | * whether to show author 53 | * @default false 54 | */ 55 | showAuthor?: boolean; 56 | /** 57 | * whether to show author avatar 58 | * @default false 59 | */ 60 | showAuthorAvatar?: boolean; 61 | /** 62 | * whether to show summary 63 | * @default false 64 | */ 65 | showSummary?: boolean; 66 | /** 67 | * Reduce heading level from # to ## 68 | * @default false 69 | */ 70 | reduceHeadingLevel?: boolean; 71 | /** 72 | * put timestamp to second line 73 | * @default false 74 | */ 75 | newlineTimestamp?: boolean; 76 | /** 77 | * add back to top button 78 | * @default false 79 | */ 80 | addBackToTop?: boolean; 81 | /** 82 | * Custom type display map 83 | */ 84 | customTypeMap?: { [key in CommitTypes]?: CustomTypeNameMap }; 85 | } 86 | ``` 87 | 88 | > 👉 Tip: If turn on `back to top` button, should edit `CHANGELOG.md` first like below: 89 | 90 | ```markdown 91 | 92 | 93 | # Changelog 94 | ``` 95 | 96 | ## License 97 | 98 | [MIT](../../LICENSE) ® Arvin Xu 99 | 100 | 101 | 102 | [version-image]: http://img.shields.io/npm/v/conventional-changelog-gitmoji-config.svg?color=deepgreen&label=latest 103 | [version-url]: http://npmjs.org/package/conventional-changelog-gitmoji-config 104 | [download-image]: https://img.shields.io/npm/dm/conventional-changelog-gitmoji-config.svg 105 | [download-url]: https://npmjs.org/package/conventional-changelog-gitmoji-config 106 | -------------------------------------------------------------------------------- /packages/changelog/jest.config.ts: -------------------------------------------------------------------------------- 1 | import base from '../../jest.config.base'; 2 | import { Config } from '@umijs/test'; 3 | 4 | const packageName = '@gitmoji/conventional-changelog-gitmoji-config'; 5 | 6 | const root = '/packages/changelog'; 7 | 8 | const config: Config.InitialOptions = { 9 | ...base, 10 | rootDir: '../..', 11 | roots: [root], 12 | displayName: packageName, 13 | }; 14 | 15 | export default config; 16 | -------------------------------------------------------------------------------- /packages/changelog/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "conventional-changelog-gitmoji-config", 3 | "version": "1.5.2", 4 | "description": "a gitmoji commit style presets for conventional changelog", 5 | "keywords": [ 6 | "conventional-changelog", 7 | "gitmoji", 8 | "preset", 9 | "changelog", 10 | "emoji" 11 | ], 12 | "homepage": "https://github.com/arvinxx/gitmoji-commit-workflow/tree/master/packages/changelog#readme", 13 | "bugs": { 14 | "url": "https://github.com/arvinxx/gitmoji-commit-workflow/issues" 15 | }, 16 | "repository": { 17 | "type": "git", 18 | "url": "https://github.com/arvinxx/gitmoji-commit-workflow.git" 19 | }, 20 | "license": "MIT", 21 | "author": "Arvin Xu ", 22 | "main": "lib/index.js", 23 | "files": [ 24 | "lib" 25 | ], 26 | "scripts": { 27 | "build": "father build", 28 | "clean": "rm -rf es lib dist build coverage src/.umi* .eslintcache", 29 | "cov": "jest --coverage", 30 | "doctor": "father doctor", 31 | "prepublishOnly": "npm run doctor && npm run build", 32 | "start": "father dev", 33 | "test": "jest" 34 | }, 35 | "dependencies": { 36 | "@ardatan/sync-fetch": "^0", 37 | "@gitmoji/commit-types": "1.1.5", 38 | "@gitmoji/parser-opts": "1.4.0", 39 | "cosmiconfig": "^7", 40 | "lodash": "^4", 41 | "pangu": "^4" 42 | }, 43 | "devDependencies": { 44 | "@types/conventional-changelog-core": "^4", 45 | "@types/lodash": "^4", 46 | "better-than-before": "^1", 47 | "conventional-changelog-core": "^4", 48 | "conventional-changelog-writer": "^5", 49 | "conventional-commits-parser": "^3", 50 | "git-dummy-commit": "^1", 51 | "shelljs": "^0.8", 52 | "through2": "^4" 53 | }, 54 | "publishConfig": { 55 | "access": "public", 56 | "registry": "https://registry.npmjs.org/" 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /packages/changelog/src/customConfig.ts: -------------------------------------------------------------------------------- 1 | import type { CommitTypes } from '@gitmoji/commit-types'; 2 | import { cosmiconfigSync } from 'cosmiconfig'; 3 | import { CustomTypeNameMap } from './transformer/typeDisplayName'; 4 | 5 | export interface CustomConfig { 6 | /** 7 | * scope 在 Changelog 中的显示信息 8 | */ 9 | scopeDisplayName?: Record; 10 | /** 11 | * 待显示的 type 组 12 | */ 13 | displayTypes?: CommitTypes[]; 14 | /** 15 | * 待显示的 scope 16 | */ 17 | displayScopes?: string[]; 18 | /** 19 | * 是否显示作者 20 | */ 21 | showAuthor?: boolean; 22 | /** 23 | * 是否显示作者头像 24 | */ 25 | showAuthorAvatar?: boolean; 26 | /** 27 | * 是否显示摘要 28 | */ 29 | showSummary?: boolean; 30 | /** 31 | * whether to include emoji in title 32 | */ 33 | withEmoji?: boolean; 34 | /** 35 | * title language 36 | */ 37 | titleLanguage?: 'en-US' | 'zh-CN'; 38 | /** 39 | * Reduce heading level from # to ## 40 | */ 41 | reduceHeadingLevel?: boolean; 42 | /** 43 | * put timestamp to second line 44 | */ 45 | newlineTimestamp?: boolean; 46 | /** 47 | * add back to top button 48 | */ 49 | addBackToTop?: boolean; 50 | /** 51 | * Custom type display map 52 | */ 53 | customTypeMap?: { 54 | [key in CommitTypes]?: CustomTypeNameMap; 55 | }; 56 | } 57 | 58 | const explorer = cosmiconfigSync('changelog'); 59 | 60 | const { config } = explorer.search() || { config: {} }; 61 | 62 | export default config; 63 | -------------------------------------------------------------------------------- /packages/changelog/src/finalizeContext/__snapshots__/index.test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`finalizeContext should transform commitGroups correctly 1`] = ` 4 | { 5 | "authors": [ 6 | { 7 | "authorAvatar": "https://avatars.githubusercontent.com/u/17870709?v=4", 8 | "authorEmail": "i@canisminor.cc", 9 | "authorName": "canisminor1990", 10 | "authorUrl": "https://api.github.com/users/canisminor1990", 11 | }, 12 | ], 13 | "commitGroups": [ 14 | { 15 | "commits": [ 16 | { 17 | "authorAvatar": "https://avatars.githubusercontent.com/u/17870709?v=4", 18 | "authorEmail": "i@canisminor.cc", 19 | "authorName": "canisminor1990", 20 | "authorUrl": "https://api.github.com/users/canisminor1990", 21 | "first": true, 22 | "hash": "1234", 23 | "last": true, 24 | "scope": "test", 25 | "subject": "test commit", 26 | "title": "✨ Features", 27 | }, 28 | ], 29 | "subtitle": "What's improved", 30 | "title": "✨ Features", 31 | }, 32 | ], 33 | } 34 | `; 35 | -------------------------------------------------------------------------------- /packages/changelog/src/finalizeContext/index.test.ts: -------------------------------------------------------------------------------- 1 | import { typeMap } from '../transformer/typeDisplayName'; 2 | import finalizeContext from './index'; 3 | 4 | describe('finalizeContext', () => { 5 | const customConfig = { 6 | scopeDisplayName: { 7 | '*': 'all', 8 | }, 9 | customTypeMap: {}, 10 | }; 11 | const context = { 12 | commitGroups: [ 13 | { 14 | title: '✨ Features', 15 | commits: [ 16 | { 17 | hash: '1234', 18 | subject: 'test commit', 19 | scope: 'test', 20 | title: '✨ Features', 21 | authorName: 'canisminor1990', 22 | authorEmail: 'i@canisminor.cc', 23 | authorAvatar: 'https://avatars.githubusercontent.com/u/17870709?v=4', 24 | authorUrl: 'https://api.github.com/users/canisminor1990', 25 | }, 26 | ], 27 | }, 28 | ], 29 | authors: [], 30 | }; 31 | 32 | it('should transform commitGroups correctly', () => { 33 | const transformedContext = finalizeContext(customConfig)(context); 34 | expect(transformedContext).toMatchSnapshot(); 35 | }); 36 | 37 | it('should set subCommitScope correctly when it is defined in customConfig', () => { 38 | const customConfigWithSubCommitScope = { 39 | ...customConfig, 40 | scopeDisplayName: { 41 | '*': 'all', 42 | test: 'test', 43 | }, 44 | }; 45 | const transformedContext = finalizeContext(customConfigWithSubCommitScope)(context); 46 | expect(transformedContext.commitGroups[0].commits[0].first).toBe(true); 47 | }); 48 | 49 | it('should set subCommitScope to null when it is not defined in customConfig', () => { 50 | const transformedContext = finalizeContext(customConfig)(context); 51 | expect(transformedContext.commitGroups[0].commits[0].first).toBe(true); 52 | }); 53 | 54 | it('should set subtitle correctly when title contains emoji', () => { 55 | const contextWithTitleEmoji = { 56 | ...context, 57 | commitGroups: [ 58 | { 59 | title: '✨ Features', 60 | commits: [], 61 | }, 62 | ], 63 | }; 64 | const transformedContext = finalizeContext(customConfig)(contextWithTitleEmoji); 65 | expect(transformedContext.commitGroups[0].subtitle).toBe("What's improved"); 66 | }); 67 | 68 | it('should set subtitle correctly when title contains en-US', () => { 69 | const contextWithTitleEnUS = { 70 | ...context, 71 | commitGroups: [ 72 | { 73 | title: 'Features', 74 | commits: [], 75 | }, 76 | ], 77 | }; 78 | const transformedContext = finalizeContext(customConfig)({ 79 | ...contextWithTitleEnUS, 80 | commitGroups: [ 81 | { 82 | ...contextWithTitleEnUS.commitGroups[0], 83 | title: `Features ${typeMap['feat']['en-US']}`, 84 | }, 85 | ], 86 | }); 87 | expect(transformedContext.commitGroups[0].subtitle).toBe("What's improved"); 88 | }); 89 | 90 | it('should set subtitle correctly when title contains zh-CN', () => { 91 | const contextWithTitleZhCN = { 92 | ...context, 93 | commitGroups: [ 94 | { 95 | title: 'Features', 96 | commits: [], 97 | }, 98 | ], 99 | }; 100 | const transformedContext = finalizeContext(customConfig)({ 101 | ...contextWithTitleZhCN, 102 | commitGroups: [ 103 | { 104 | ...contextWithTitleZhCN.commitGroups[0], 105 | title: `Features ${typeMap['feat']['zh-CN']}`, 106 | }, 107 | ], 108 | }); 109 | expect(transformedContext.commitGroups[0].subtitle).toBe("What's improved"); 110 | }); 111 | 112 | it('should sort commits correctly when subCommitScope is defined in customConfig', () => { 113 | const customConfigWithSubCommitScope = { 114 | ...customConfig, 115 | scopeDisplayName: { 116 | '*': 'all', 117 | test: 'test', 118 | }, 119 | }; 120 | const contextWithMultipleCommits = { 121 | ...context, 122 | commitGroups: [ 123 | { 124 | title: '✨ Features', 125 | commits: [ 126 | { 127 | hash: '1234', 128 | subject: 'test commit 1', 129 | scope: 'test', 130 | title: '✨ Features', 131 | authorName: 'canisminor1990', 132 | authorEmail: 'i@canisminor.cc', 133 | authorAvatar: 'https://avatars.githubusercontent.com/u/17870709?v=4', 134 | authorUrl: 'https://api.github.com/users/canisminor1990', 135 | }, 136 | { 137 | hash: '5678', 138 | subject: 'test commit 2', 139 | scope: 'test', 140 | title: '✨ Features', 141 | authorName: 'canisminor1990', 142 | authorEmail: 'i@canisminor.cc', 143 | authorAvatar: 'https://avatars.githubusercontent.com/u/17870709?v=4', 144 | authorUrl: 'https://api.github.com/users/canisminor1990', 145 | }, 146 | ], 147 | }, 148 | ], 149 | }; 150 | const transformedContext = finalizeContext(customConfigWithSubCommitScope)( 151 | contextWithMultipleCommits, 152 | ); 153 | expect(transformedContext.commitGroups[0].commits[0].first).toBe(true); 154 | expect(transformedContext.commitGroups[0].commits[1].first).toBe(false); 155 | }); 156 | 157 | it('should set first and last correctly when commits have the same scope', () => { 158 | const contextWithMultipleCommits = { 159 | ...context, 160 | commitGroups: [ 161 | { 162 | title: '✨ Features', 163 | commits: [ 164 | { 165 | hash: '1234', 166 | subject: 'test commit 1', 167 | scope: 'test', 168 | title: '✨ Features', 169 | authorName: 'canisminor1990', 170 | authorEmail: 'i@canisminor.cc', 171 | authorAvatar: 'https://avatars.githubusercontent.com/u/17870709?v=4', 172 | authorUrl: 'https://api.github.com/users/canisminor1990', 173 | }, 174 | { 175 | hash: '5678', 176 | subject: 'test commit 2', 177 | scope: 'test', 178 | title: '✨ Features', 179 | authorName: 'canisminor1990', 180 | authorEmail: 'i@canisminor.cc', 181 | authorAvatar: 'https://avatars.githubusercontent.com/u/17870709?v=4', 182 | authorUrl: 'https://api.github.com/users/canisminor1990', 183 | }, 184 | ], 185 | }, 186 | ], 187 | }; 188 | const transformedContext = finalizeContext(customConfig)(contextWithMultipleCommits); 189 | expect(transformedContext.commitGroups[0].commits[0].first).toBe(true); 190 | expect(transformedContext.commitGroups[0].commits[0].last).toBe(false); 191 | expect(transformedContext.commitGroups[0].commits[1].first).toBe(false); 192 | expect(transformedContext.commitGroups[0].commits[1].last).toBe(true); 193 | }); 194 | 195 | it('should set author correctly when authorAvatar is not empty', () => { 196 | const contextWithAuthorNameEncode = { 197 | ...context, 198 | commitGroups: [ 199 | { 200 | title: '✨ Features', 201 | commits: [ 202 | { 203 | hash: '1234', 204 | subject: 'test commit', 205 | scope: 'test', 206 | title: '✨ Features', 207 | authorName: 'canisminor1990', 208 | authorEmail: 'i@canisminor.cc', 209 | authorAvatar: 'https://avatars.githubusercontent.com/u/17870709?v=4', 210 | authorUrl: 'https://api.github.com/users/canisminor1990', 211 | }, 212 | ], 213 | }, 214 | ], 215 | }; 216 | const transformedContext = finalizeContext(customConfig)(contextWithAuthorNameEncode); 217 | expect(transformedContext.authors).toEqual([ 218 | { 219 | authorAvatar: 'https://avatars.githubusercontent.com/u/17870709?v=4', 220 | authorEmail: 'i@canisminor.cc', 221 | authorName: 'canisminor1990', 222 | authorUrl: 'https://api.github.com/users/canisminor1990', 223 | }, 224 | ]); 225 | }); 226 | 227 | it('should not set author when authorAvatar is empty', () => { 228 | const contextWithoutAuthorNameEncode = { 229 | ...context, 230 | commitGroups: [ 231 | { 232 | title: '✨ Features', 233 | commits: [ 234 | { 235 | hash: '1234', 236 | subject: 'test commit', 237 | scope: 'test', 238 | title: '✨ Features', 239 | authorName: 'canisminor1990', 240 | authorEmail: 'i@canisminor.cc', 241 | }, 242 | ], 243 | }, 244 | ], 245 | }; 246 | const transformedContext = finalizeContext(customConfig)(contextWithoutAuthorNameEncode); 247 | expect(transformedContext.authors).toEqual([]); 248 | }); 249 | }); 250 | -------------------------------------------------------------------------------- /packages/changelog/src/finalizeContext/index.ts: -------------------------------------------------------------------------------- 1 | import type { Context } from 'conventional-changelog-writer'; 2 | import { CustomConfig } from '../customConfig'; 3 | import { defineTypeMap } from '../transformer/typeDisplayName'; 4 | export default (customConfig: CustomConfig) => (context: Context): Context => { 5 | const subCommitScope = customConfig?.scopeDisplayName?.['*'] || null; 6 | const authors = {}; 7 | const typeMap = defineTypeMap(customConfig.customTypeMap); 8 | context.commitGroups = context.commitGroups.map((item) => { 9 | const subtitle = Object.values(typeMap).find( 10 | (i) => 11 | item.title.includes(i['emoji']) || 12 | item.title.includes(i['en-US']) || 13 | item.title.includes(i['zh-CN']), 14 | ).subtitle; 15 | let group; 16 | let commits = item.commits.sort((a, b) => { 17 | if (a.scope === subCommitScope && b.scope === subCommitScope) { 18 | return 0; 19 | } else if (a.scope === subCommitScope) { 20 | return 1; 21 | } else if (b.scope === subCommitScope) { 22 | return -1; 23 | } else { 24 | return 0; 25 | } 26 | }); 27 | commits = commits.map((c, index) => { 28 | if (group !== c.scope) { 29 | group = c.scope; 30 | c.first = true; 31 | } else { 32 | c.first = false; 33 | } 34 | if (!commits[index + 1] || group !== commits[index + 1].scope) { 35 | c.last = true; 36 | } else { 37 | c.last = false; 38 | } 39 | if (c.authorAvatar && !authors[c.authorEmail]) { 40 | authors[c.authorEmail] = { 41 | authorName: c.authorName, 42 | authorEmail: c.authorEmail, 43 | authorAvatar: c.authorAvatar, 44 | authorUrl: c.authorUrl, 45 | }; 46 | } 47 | return c; 48 | }); 49 | return { 50 | title: item.title, 51 | subtitle, 52 | commits, 53 | }; 54 | }); 55 | context.authors = Object.values(authors); 56 | return context; 57 | }; 58 | -------------------------------------------------------------------------------- /packages/changelog/src/handleWriterOpts.ts: -------------------------------------------------------------------------------- 1 | import type { Options } from 'conventional-changelog-writer'; 2 | import { readFileSync } from 'fs'; 3 | import { resolve } from 'path'; 4 | import type { CustomConfig } from './customConfig'; 5 | import finalizeContext from './finalizeContext'; 6 | import transformer from './transformer'; 7 | 8 | const basePath = resolve(__dirname, './templates'); 9 | 10 | const template = readFileSync(`${basePath}/template.hbs`, 'utf-8'); 11 | const summaryTemplate = readFileSync(`${basePath}/summary-template.hbs`, 'utf-8'); 12 | const summaryAvatar = readFileSync(`${basePath}/summary-avatar.hbs`, 'utf-8'); 13 | const header = readFileSync(`${basePath}/header.hbs`, 'utf-8'); 14 | const headerNewlineTimestamp = readFileSync(`${basePath}/header-newline-timestamp.hbs`, 'utf-8'); 15 | const commit = readFileSync(`${basePath}/commit.hbs`, 'utf-8'); 16 | const footer = readFileSync(`${basePath}/footer.hbs`, 'utf-8'); 17 | const author = readFileSync(`${basePath}/author.hbs`, 'utf-8'); 18 | const authorAvatar = readFileSync(`${basePath}/author-avatar.hbs`, 'utf-8'); 19 | const backToTop = readFileSync(`${basePath}/back-to-top.hbs`, 'utf-8'); 20 | const reduceHeadingLevel = (skip: boolean, template: string): string => { 21 | if (skip) return template; 22 | return template.replace(/(^|\n)(#+)/g, (match, p1, p2) => p1 + '#' + p2); 23 | }; 24 | export default (customConfig: CustomConfig): Options => { 25 | const mainTemplate = customConfig.showSummary 26 | ? summaryTemplate.replace( 27 | /{{gitUserInfo}}/g, 28 | customConfig.showAuthor && customConfig.showAuthorAvatar ? summaryAvatar : '', 29 | ) 30 | : template; 31 | const commitPartial = commit.replace( 32 | /{{gitUserInfo}}/g, 33 | customConfig.showAuthor ? (customConfig.showAuthorAvatar ? authorAvatar : author) : '', 34 | ); 35 | const headerPartial = customConfig.newlineTimestamp ? headerNewlineTimestamp : header; 36 | const footerPartial = footer.replace( 37 | /{{backToTop}}/g, 38 | customConfig.addBackToTop ? backToTop : '', 39 | ); 40 | return { 41 | transform: transformer(customConfig), 42 | groupBy: 'type', 43 | commitGroupsSort: 'title', 44 | commitsSort: ['scope', 'subject'], 45 | noteGroupsSort: 'title', 46 | mainTemplate: reduceHeadingLevel(!customConfig.reduceHeadingLevel, mainTemplate), 47 | headerPartial: reduceHeadingLevel(!customConfig.reduceHeadingLevel, headerPartial), 48 | // 替换 commit.hbs 模板中的 gitUserInfo 49 | commitPartial: reduceHeadingLevel(!customConfig.reduceHeadingLevel, commitPartial), 50 | footerPartial: reduceHeadingLevel(!customConfig.reduceHeadingLevel, footerPartial), 51 | finalizeContext: finalizeContext(customConfig), 52 | }; 53 | }; 54 | -------------------------------------------------------------------------------- /packages/changelog/src/index.ts: -------------------------------------------------------------------------------- 1 | import conventionalChangelog from './utils/conventional-changelog'; 2 | import recommendedBumpOpts from './utils/conventional-recommended-bump'; 3 | import gitRawCommitsOpts from './utils/git-raw-commit'; // 格式化 git log 信息 4 | import parserOpts from './utils/parserOpts'; // 解析流 5 | import writerOpts from './utils/writerOpts'; // 输出流 6 | 7 | export default { 8 | conventionalChangelog, 9 | parserOpts, 10 | recommendedBumpOpts, 11 | writerOpts, 12 | gitRawCommitsOpts, 13 | }; 14 | -------------------------------------------------------------------------------- /packages/changelog/src/templates/author-avatar.hbs: -------------------------------------------------------------------------------- 1 | {{#if authorName}} - by {{#if authorAvatar}}[ **{{authorName}}**]({{authorUrl}}){{else}}**{{authorName}}**{{/if}}{{/if}} -------------------------------------------------------------------------------- /packages/changelog/src/templates/author.hbs: -------------------------------------------------------------------------------- 1 | {{#if authorName}}by: **{{authorName}}**{{#if authorEmail}}<{{authorEmail}}>{{/if}}{{/if}} -------------------------------------------------------------------------------- /packages/changelog/src/templates/back-to-top.hbs: -------------------------------------------------------------------------------- 1 |
2 | 3 | [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top) 4 | 5 |
-------------------------------------------------------------------------------- /packages/changelog/src/templates/commit.hbs: -------------------------------------------------------------------------------- 1 | *{{#if scope}} **{{scope}}**: 2 | {{~/if}} {{#if subject}} 3 | {{~subject}} 4 | {{~else}} 5 | {{~header}} 6 | {{~/if}} 7 | 8 | {{~!-- commit references --}} 9 | {{~#if references~}} 10 | , closes 11 | {{~#each references}} {{#if @root.linkReferences~}} 12 | [ 13 | {{~#if this.owner}} 14 | {{~this.owner}}/ 15 | {{~/if}} 16 | {{~this.repository}}#{{this.issue}}]( 17 | {{~#if this.bugsUrl}} 18 | {{~this.bugsUrl}}{{this.issue}} 19 | {{~else}} 20 | {{~#if @root.repository}} 21 | {{~#if @root.host}} 22 | {{~@root.host}}/ 23 | {{~/if}} 24 | {{~#if this.repository}} 25 | {{~#if this.owner}} 26 | {{~this.owner}}/ 27 | {{~/if}} 28 | {{~this.repository}} 29 | {{~else}} 30 | {{~#if @root.owner}} 31 | {{~@root.owner}}/ 32 | {{~/if}} 33 | {{~@root.repository}} 34 | {{~/if}} 35 | {{~else}} 36 | {{~@root.repoUrl}} 37 | {{~/if}}/ 38 | {{~@root.issue}}/{{this.issue}} 39 | {{~/if}}) 40 | {{~else}} 41 | {{~#if this.owner}} 42 | {{~this.owner}}/ 43 | {{~/if}} 44 | {{~this.repository}}#{{this.issue}} 45 | {{~/if}}{{/each}} 46 | {{~/if}} 47 | 48 | {{~!-- commit link --}} {{#if @root.linkReferences~}} 49 | ([{{hash}}]( 50 | {{~#if @root.repository}} 51 | {{~#if @root.host}} 52 | {{~@root.host}}/ 53 | {{~/if}} 54 | {{~#if @root.owner}} 55 | {{~@root.owner}}/ 56 | {{~/if}} 57 | {{~@root.repository}} 58 | {{~else}} 59 | {{~@root.repoUrl}} 60 | {{~/if}}/ 61 | {{~@root.commit}}/{{hash}})) 62 | {{~else}} 63 | {{~hash}} 64 | {{~/if}} 65 | {{gitUserInfo}} 66 | -------------------------------------------------------------------------------- /packages/changelog/src/templates/footer.hbs: -------------------------------------------------------------------------------- 1 | {{#if noteGroups}} 2 | {{#each noteGroups}} 3 | 4 | ### {{title}} 5 | 6 | {{#each notes}} 7 | * {{#if commit.scope}}**{{commit.scope}}**: {{/if}}{{text}} 8 | {{/each}} 9 | {{/each}} 10 | 11 | {{/if}} 12 | 13 | {{backToTop}} 14 | -------------------------------------------------------------------------------- /packages/changelog/src/templates/header-newline-timestamp.hbs: -------------------------------------------------------------------------------- 1 | {{#if isPatch~}} 2 | ## 3 | {{~else~}} 4 | # 5 | {{~/if}} {{#if @root.linkCompare~}} 6 | [Version {{version}}]( 7 | {{~#if @root.repository~}} 8 | {{~#if @root.host}} 9 | {{~@root.host}}/ 10 | {{~/if}} 11 | {{~#if @root.owner}} 12 | {{~@root.owner}}/ 13 | {{~/if}} 14 | {{~@root.repository}} 15 | {{~else}} 16 | {{~@root.repoUrl}} 17 | {{~/if~}} 18 | /compare/{{previousTag}}...{{currentTag}}) 19 | {{~else}} 20 | Version {{~version}} 21 | {{~/if}} 22 | {{~#if title}} "{{title}}" 23 | {{~/if}} 24 | 25 | {{~#if date}} 26 | 27 | Released on **{{date}}** 28 | {{/if}} -------------------------------------------------------------------------------- /packages/changelog/src/templates/header.hbs: -------------------------------------------------------------------------------- 1 | {{#if isPatch~}} 2 | ## 3 | {{~else~}} 4 | # 5 | {{~/if}} {{#if @root.linkCompare~}} 6 | [{{version}}]( 7 | {{~#if @root.repository~}} 8 | {{~#if @root.host}} 9 | {{~@root.host}}/ 10 | {{~/if}} 11 | {{~#if @root.owner}} 12 | {{~@root.owner}}/ 13 | {{~/if}} 14 | {{~@root.repository}} 15 | {{~else}} 16 | {{~@root.repoUrl}} 17 | {{~/if~}} 18 | /compare/{{previousTag}}...{{currentTag}}) 19 | {{~else}} 20 | {{~version}} 21 | {{~/if}} 22 | {{~#if title}} "{{title}}" 23 | {{~/if}} 24 | {{~#if date}} ({{date}}) 25 | {{/if}} 26 | -------------------------------------------------------------------------------- /packages/changelog/src/templates/summary-avatar.hbs: -------------------------------------------------------------------------------- 1 | {{#each authors}} 2 | {{#if authorAvatar}}[]({{authorUrl}}){{/if}} 3 | {{/each}} -------------------------------------------------------------------------------- /packages/changelog/src/templates/summary-template.hbs: -------------------------------------------------------------------------------- 1 | {{> header}} 2 | 3 | {{#each commitGroups}} 4 | 5 | {{#if title}} 6 | ### {{title}} 7 | 8 | {{/if}} 9 | {{#each commits}}{{#if first}}- {{#if scope}}**{{scope}}**: {{/if}}{{subject}}{{else}}{{rawSubject}}{{/if}}{{#if last}}. 10 | {{else}}, {{/if}}{{/each}} 11 | {{/each}} 12 | 13 |
14 | 15 | {{gitUserInfo}} 16 | 17 |
18 | Improvements and Fixes 19 | 20 | {{#each commitGroups}} 21 | 22 | {{#if title}} 23 | 24 | ### {{subtitle}} 25 | 26 | {{/if}} 27 | {{#each commits}} 28 | {{> commit root=@root}}{{/each}} 29 | {{/each}} 30 |
31 | 32 | {{> footer}} 33 | 34 | -------------------------------------------------------------------------------- /packages/changelog/src/templates/template.hbs: -------------------------------------------------------------------------------- 1 | {{> header}} 2 | 3 | {{#each commitGroups}} 4 | 5 | {{#if title}} 6 | ### {{title}} 7 | 8 | {{/if}} 9 | {{#each commits}} 10 | {{> commit root=@root}} 11 | {{/each}} 12 | 13 | {{/each}} 14 | {{> footer}} 15 | 16 | 17 | -------------------------------------------------------------------------------- /packages/changelog/src/transformer/index.test.ts: -------------------------------------------------------------------------------- 1 | import type { Commit } from 'conventional-commits-parser'; 2 | import transform from './index'; 3 | 4 | const generateCommit = (commit: Partial) => 5 | ({ 6 | header: '', 7 | notes: [], 8 | references: [], 9 | mentions: [], 10 | body: undefined, 11 | footer: undefined, 12 | merge: undefined, 13 | revert: undefined, 14 | ...commit, 15 | } as Commit); 16 | 17 | const defaultContext = { commit: '', date: '', issue: '' }; 18 | 19 | describe('transform', () => { 20 | it('return commit if has feat', () => { 21 | const transformer = transform({}); 22 | 23 | const commit = generateCommit({ 24 | header: 'amazing new module', 25 | type: 'feat', 26 | }); 27 | 28 | expect(transformer(commit, defaultContext)).toEqual({ 29 | type: '✨ Features', 30 | header: 'amazing new module', 31 | mentions: [], 32 | notes: [], 33 | references: [], 34 | }); 35 | }); 36 | 37 | it('should truncated commit hash', () => { 38 | const transformer = transform({}); 39 | const commit = generateCommit({ 40 | header: '', 41 | type: 'feat', 42 | hash: '12345678abc', 43 | }); 44 | 45 | expect(transformer(commit, defaultContext)).toEqual({ 46 | hash: '1234567', 47 | header: '', 48 | mentions: [], 49 | notes: [], 50 | references: [], 51 | type: '✨ Features', 52 | }); 53 | }); 54 | 55 | describe('Custom Config', () => { 56 | it('should only display included types', () => { 57 | const transformer = transform({ 58 | displayTypes: ['fix'], 59 | }); 60 | const featCommit = generateCommit({ 61 | type: 'feat', 62 | }); 63 | const fixCommit = generateCommit({ 64 | type: 'fix', 65 | }); 66 | 67 | expect(transformer(featCommit, defaultContext)).toBeUndefined(); 68 | expect(transformer(fixCommit, defaultContext)).toEqual({ 69 | header: '', 70 | mentions: [], 71 | notes: [], 72 | references: [], 73 | type: '🐛 Bug Fixes', 74 | }); 75 | }); 76 | 77 | it('should show scope display name', () => { 78 | const transformer = transform({ 79 | scopeDisplayName: { 80 | foo: 'module-foo', 81 | }, 82 | }); 83 | const commit = generateCommit({ 84 | type: 'feat', 85 | scope: 'foo', 86 | }); 87 | 88 | expect(transformer(commit, defaultContext)).toEqual({ 89 | header: '', 90 | mentions: [], 91 | notes: [], 92 | references: [], 93 | scope: 'module-foo', 94 | type: '✨ Features', 95 | }); 96 | }); 97 | 98 | it('should get author avatar', () => { 99 | const transformer = transform({ 100 | showAuthor: true, 101 | showAuthorAvatar: true, 102 | }); 103 | const commit = generateCommit({ 104 | type: 'feat', 105 | authorName: 'canisminor1990', 106 | authorEmail: 'i@canisminor.cc', 107 | }); 108 | 109 | expect(transformer(commit, defaultContext)).toEqual({ 110 | header: '', 111 | mentions: [], 112 | notes: [], 113 | references: [], 114 | authorName: 'canisminor1990', 115 | authorEmail: 'i@canisminor.cc', 116 | authorAvatar: 'https://avatars.githubusercontent.com/u/17870709?v=4', 117 | authorUrl: 'https://api.github.com/users/canisminor1990', 118 | type: '✨ Features', 119 | }); 120 | }); 121 | 122 | it('should format subject message', () => { 123 | const transformer = transform({}); 124 | const commitEN = generateCommit({ 125 | type: 'feat', 126 | subject: 'add Button components', 127 | }); 128 | 129 | const commitCN = generateCommit({ 130 | type: 'feat', 131 | subject: '增加Button组件', 132 | }); 133 | 134 | expect(transformer(commitEN, defaultContext)).toEqual({ 135 | header: '', 136 | mentions: [], 137 | notes: [], 138 | references: [], 139 | subject: 'Add Button components', 140 | rawSubject: 'add Button components', 141 | type: '✨ Features', 142 | }); 143 | 144 | expect(transformer(commitCN, defaultContext)).toEqual({ 145 | header: '', 146 | mentions: [], 147 | notes: [], 148 | references: [], 149 | subject: '增加 Button 组件', 150 | rawSubject: '增加Button组件', 151 | type: '✨ Features', 152 | }); 153 | }); 154 | 155 | it('should change type display', () => { 156 | const transformer = transform({ customTypeMap: { feat: { emoji: '🤯' } } }); 157 | const commit = generateCommit({ 158 | header: '', 159 | type: 'feat', 160 | }); 161 | 162 | expect(transformer(commit, defaultContext)).toEqual({ 163 | header: '', 164 | mentions: [], 165 | notes: [], 166 | references: [], 167 | type: '🤯 Features', 168 | }); 169 | }); 170 | }); 171 | }); 172 | -------------------------------------------------------------------------------- /packages/changelog/src/transformer/index.ts: -------------------------------------------------------------------------------- 1 | import fetch from '@ardatan/sync-fetch'; 2 | import type { CommitTypes } from '@gitmoji/commit-types'; 3 | import types from '@gitmoji/commit-types'; 4 | import type { Context } from 'conventional-changelog-writer'; 5 | import type { Commit } from 'conventional-commits-parser'; 6 | import pangu from 'pangu'; 7 | import type { CustomConfig } from '../customConfig'; 8 | import { scopeMapDisplayName } from './scopeMapDisplayName'; 9 | import { getDisplayName } from './typeDisplayName'; 10 | const capitalizeFirstLetter = (str: string): string => { 11 | const firstLetter = String(str).slice(0, 1).toUpperCase(); 12 | const remainingStr = String(str).slice(1); 13 | return firstLetter + remainingStr; 14 | }; 15 | 16 | const cacheUsers = {}; 17 | 18 | export default (customConfig: CustomConfig) => (commit: Commit, context: Context) => { 19 | let discard = true; 20 | const issues = []; 21 | 22 | commit.notes.forEach((note) => { 23 | note.title = `${customConfig?.withEmoji === false ? '' : '💥 '}BREAKING CHANGES`; 24 | 25 | discard = false; 26 | }); 27 | 28 | let displayTypes = types; 29 | 30 | if (customConfig.displayTypes) { 31 | displayTypes = customConfig.displayTypes; 32 | } 33 | 34 | if (!displayTypes.includes(commit.type) && discard) return; 35 | 36 | // 修改 type 标题 37 | commit.type = getDisplayName(commit.type, { 38 | language: customConfig.titleLanguage, 39 | withEmoji: customConfig.withEmoji, 40 | customTypeMap: customConfig.customTypeMap, 41 | }); 42 | 43 | /** * 处理 scope ** */ 44 | if (commit.scope === '*') { 45 | commit.scope = ''; 46 | } 47 | 48 | if (customConfig.displayScopes) { 49 | if (!customConfig.displayScopes?.includes(commit.scope)) return; 50 | } 51 | 52 | if (customConfig.scopeDisplayName) { 53 | commit.scope = scopeMapDisplayName(commit.scope, customConfig.scopeDisplayName); 54 | } 55 | 56 | if (typeof commit.hash === 'string') { 57 | commit.hash = commit.hash.substring(0, 7); 58 | } 59 | 60 | if (typeof commit.subject === 'string') { 61 | let url = context.repository 62 | ? `${context.host}/${context.owner}/${context.repository}` 63 | : context.repoUrl; 64 | if (url) { 65 | url = `${url}/issues/`; 66 | // Issue URLs. 67 | commit.subject = commit.subject.replace(/#([0-9]+)/g, (_, issue) => { 68 | issues.push(issue); 69 | return `[#${issue}](${url}${issue})`; 70 | }); 71 | } 72 | if (context.host) { 73 | // User URLs. 74 | commit.subject = commit.subject.replace( 75 | /\B@([a-z0-9](?:-?[a-z0-9/]){0,38})/g, 76 | (_, username) => { 77 | if (username.includes('/')) { 78 | return `@${username}`; 79 | } 80 | 81 | return `[@${username}](${context.host}/${username})`; 82 | }, 83 | ); 84 | } 85 | } 86 | 87 | // remove references that already appear in the subject 88 | commit.references = commit.references.filter((reference) => { 89 | return issues.indexOf(reference.issue) === -1; 90 | }); 91 | 92 | // format 93 | if (commit.subject) { 94 | commit.rawSubject = commit.subject; 95 | commit.subject = pangu.spacing(capitalizeFirstLetter(commit.subject)); 96 | } 97 | 98 | if (customConfig.showAuthor && customConfig.showAuthorAvatar && commit.authorEmail) { 99 | if (!cacheUsers[commit.authorEmail]) { 100 | const authorInfo = fetch( 101 | `https://api.github.com/search/users?q=${commit.authorEmail}`, 102 | ).json(); 103 | if (authorInfo?.items?.length > 0) { 104 | cacheUsers[commit.authorEmail] = authorInfo.items[0]; 105 | } else { 106 | cacheUsers[commit.authorEmail] = 'unknown'; 107 | } 108 | } 109 | 110 | if (cacheUsers[commit.authorEmail] !== 'unknown') { 111 | const userInfo = cacheUsers[commit.authorEmail]; 112 | commit.authorName = userInfo.login; 113 | commit.authorAvatar = userInfo.avatar_url; 114 | commit.authorUrl = userInfo.url; 115 | } 116 | } 117 | 118 | return commit; 119 | }; 120 | -------------------------------------------------------------------------------- /packages/changelog/src/transformer/scopeMapDisplayName.test.ts: -------------------------------------------------------------------------------- 1 | import { scopeMapDisplayName } from './scopeMapDisplayName'; 2 | 3 | describe('scopeMapDisplayName', () => { 4 | it('should return input if not match', () => { 5 | expect(scopeMapDisplayName('hello', {})).toEqual('hello'); 6 | }); 7 | 8 | it('should return mapped value if match the list', () => { 9 | expect( 10 | scopeMapDisplayName('hello', { 11 | hello: 'Hello', 12 | }), 13 | ).toEqual('Hello'); 14 | }); 15 | 16 | it('should return * value if scope is empty and has the * value in list', () => { 17 | expect( 18 | scopeMapDisplayName('', { 19 | '*': 'Others', 20 | }), 21 | ).toEqual('Others'); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /packages/changelog/src/transformer/scopeMapDisplayName.ts: -------------------------------------------------------------------------------- 1 | export const scopeMapDisplayName = ( 2 | scope: string, 3 | scopeDisplayNameList: Record, 4 | ) => { 5 | const entries = Object.entries(scopeDisplayNameList); 6 | 7 | // eslint-disable-next-line no-restricted-syntax 8 | for (const [key, value] of entries) { 9 | if (scope === key) { 10 | return value; 11 | } 12 | 13 | // 如果没有 scope 的情况下 且有通配符 14 | // 那么直接使用通配符的值 15 | if (!scope && scopeDisplayNameList['*']) { 16 | return scopeDisplayNameList['*']; 17 | } 18 | } 19 | // 其余情况返回原值 20 | return scope; 21 | }; 22 | -------------------------------------------------------------------------------- /packages/changelog/src/transformer/typeDisplayName.test.ts: -------------------------------------------------------------------------------- 1 | import type { DisplayNameOptions } from './typeDisplayName'; 2 | import { getDisplayName } from './typeDisplayName'; 3 | 4 | describe('typeDisplayName', () => { 5 | it('should return English and emoji by default', () => { 6 | expect(getDisplayName('feat')).toEqual('✨ Features'); 7 | expect(getDisplayName('fix')).toEqual('🐛 Bug Fixes'); 8 | expect(getDisplayName('perf')).toEqual('⚡ Performance Improvements'); 9 | expect(getDisplayName('revert')).toEqual('⏪ Reverts'); 10 | expect(getDisplayName('style')).toEqual('💄 Styles'); 11 | expect(getDisplayName('docs')).toEqual('📝 Documentation'); 12 | expect(getDisplayName('refactor')).toEqual('♻ Code Refactoring'); 13 | expect(getDisplayName('build')).toEqual('👷 Build System'); 14 | expect(getDisplayName('test')).toEqual('✅ Tests'); 15 | expect(getDisplayName('ci')).toEqual('🔧 Continuous Integration'); 16 | expect(getDisplayName('chore')).toEqual('🎫 Chores'); 17 | }); 18 | 19 | it('should return Chinese with { language: "zh-CN" }', () => { 20 | const opts: DisplayNameOptions = { language: 'zh-CN' }; 21 | expect(getDisplayName('feat', opts)).toEqual('✨ 新特性'); 22 | expect(getDisplayName('fix', opts)).toEqual('🐛 修复'); 23 | expect(getDisplayName('perf', opts)).toEqual('⚡ 性能优化'); 24 | expect(getDisplayName('revert', opts)).toEqual('⏪ 回滚'); 25 | expect(getDisplayName('style', opts)).toEqual('💄 样式'); 26 | expect(getDisplayName('docs', opts)).toEqual('📝 文档'); 27 | expect(getDisplayName('refactor', opts)).toEqual('♻ 重构'); 28 | expect(getDisplayName('build', opts)).toEqual('👷 构建系统'); 29 | expect(getDisplayName('test', opts)).toEqual('✅ 测试'); 30 | expect(getDisplayName('ci', opts)).toEqual('🔧 持续集成'); 31 | expect(getDisplayName('chore', opts)).toEqual('🎫 杂项'); 32 | }); 33 | 34 | it('should return without emoji with { withEmoji: false }', () => { 35 | const opts = { withEmoji: false }; 36 | expect(getDisplayName('feat', opts)).toEqual('Features'); 37 | expect(getDisplayName('fix', opts)).toEqual('Bug Fixes'); 38 | expect(getDisplayName('perf', opts)).toEqual('Performance Improvements'); 39 | expect(getDisplayName('revert', opts)).toEqual('Reverts'); 40 | expect(getDisplayName('style', opts)).toEqual('Styles'); 41 | expect(getDisplayName('docs', opts)).toEqual('Documentation'); 42 | expect(getDisplayName('refactor', opts)).toEqual('Code Refactoring'); 43 | expect(getDisplayName('build', opts)).toEqual('Build System'); 44 | expect(getDisplayName('test', opts)).toEqual('Tests'); 45 | expect(getDisplayName('ci', opts)).toEqual('Continuous Integration'); 46 | expect(getDisplayName('chore', opts)).toEqual('Chores'); 47 | }); 48 | 49 | it('should should return input when is not valid type', () => { 50 | expect(getDisplayName('wip')).toEqual('wip'); 51 | expect(getDisplayName('aaa')).toEqual('aaa'); 52 | }); 53 | }); 54 | -------------------------------------------------------------------------------- /packages/changelog/src/transformer/typeDisplayName.ts: -------------------------------------------------------------------------------- 1 | import type { CommitTypes } from '@gitmoji/commit-types'; 2 | import { merge } from 'lodash'; 3 | 4 | export interface DisplayNameOptions { 5 | withEmoji?: boolean; 6 | language?: 'en-US' | 'zh-CN' | 'mix'; 7 | customTypeMap?: { [key in CommitTypes]?: CustomTypeNameMap }; 8 | } 9 | 10 | export interface CustomTypeNameMap { 11 | emoji?: string; 12 | 'en-US'?: string; 13 | 'zh-CN'?: string; 14 | subtitle?: string; 15 | } 16 | 17 | interface TypeNameMap { 18 | emoji: string; 19 | 'en-US': string; 20 | 'zh-CN': string; 21 | subtitle: string; 22 | } 23 | 24 | export const typeMap: Record, TypeNameMap> = { 25 | feat: { 26 | emoji: '✨', 27 | 'en-US': 'Features', 28 | 'zh-CN': '新特性', 29 | subtitle: "What's improved", 30 | }, 31 | fix: { 32 | emoji: '🐛', 33 | 'en-US': 'Bug Fixes', 34 | 'zh-CN': '修复', 35 | subtitle: "What's fixed", 36 | }, 37 | build: { 38 | emoji: '👷', 39 | 'en-US': 'Build System', 40 | 'zh-CN': '构建系统', 41 | subtitle: 'Build system', 42 | }, 43 | chore: { 44 | emoji: '🎫', 45 | 'en-US': 'Chores', 46 | 'zh-CN': '杂项', 47 | subtitle: 'Chores', 48 | }, 49 | ci: { 50 | emoji: '🔧', 51 | 'en-US': 'Continuous Integration', 52 | 'zh-CN': '持续集成', 53 | subtitle: 'Continuous integration', 54 | }, 55 | docs: { 56 | emoji: '📝', 57 | 'zh-CN': '文档', 58 | 'en-US': 'Documentation', 59 | subtitle: 'Documentation', 60 | }, 61 | test: { 62 | emoji: '✅', 63 | 'zh-CN': '测试', 64 | 'en-US': 'Tests', 65 | subtitle: 'Tests', 66 | }, 67 | perf: { 68 | emoji: '⚡', 69 | 'en-US': 'Performance Improvements', 70 | 'zh-CN': '性能优化', 71 | subtitle: 'Performance improvements', 72 | }, 73 | refactor: { 74 | emoji: '♻', 75 | 'en-US': 'Code Refactoring', 76 | 'zh-CN': '重构', 77 | subtitle: 'Code refactoring', 78 | }, 79 | revert: { 80 | emoji: '⏪', 81 | 'zh-CN': '回滚', 82 | 'en-US': 'Reverts', 83 | subtitle: 'Reverts', 84 | }, 85 | style: { 86 | emoji: '💄', 87 | 'en-US': 'Styles', 88 | 'zh-CN': '样式', 89 | subtitle: 'Styles', 90 | }, 91 | }; 92 | 93 | export const defineTypeMap = ( 94 | customTypeMap: { [key in CommitTypes]?: CustomTypeNameMap }, 95 | ): Record, TypeNameMap> => { 96 | if (!customTypeMap) return typeMap; 97 | return merge(typeMap, customTypeMap); 98 | }; 99 | 100 | export const getDisplayName = ( 101 | type: CommitTypes | string, 102 | options: DisplayNameOptions = {}, 103 | ): string => { 104 | const { withEmoji = true, language = 'en-US' } = options; 105 | 106 | const diplayTypeMap = defineTypeMap(options.customTypeMap); 107 | 108 | if (type in diplayTypeMap) { 109 | const item = diplayTypeMap[type]; 110 | const { emoji } = item; 111 | return `${withEmoji ? `${emoji} ` : ''}${ 112 | language === 'mix' ? [item['en-US'], item['zh-CN']].join(' | ') : item[language] 113 | }`; 114 | } 115 | 116 | return type; 117 | }; 118 | -------------------------------------------------------------------------------- /packages/changelog/src/utils/conventional-changelog.ts: -------------------------------------------------------------------------------- 1 | import parserOpts from './parserOpts'; 2 | import writerOpts from './writerOpts'; 3 | 4 | export default { parserOpts, writerOpts }; 5 | -------------------------------------------------------------------------------- /packages/changelog/src/utils/conventional-recommended-bump.ts: -------------------------------------------------------------------------------- 1 | /* istanbul ignore file */ 2 | import parserOpts from './parserOpts'; 3 | 4 | export default { 5 | parserOpts, 6 | whatBump: (commits) => { 7 | let level = 2; 8 | let breakings = 0; 9 | let features = 0; 10 | 11 | commits.forEach((commit) => { 12 | if (commit.notes.length > 0) { 13 | breakings += commit.notes.length; 14 | level = 0; 15 | } else if (commit.type === `feat`) { 16 | features += 1; 17 | if (level === 2) { 18 | level = 1; 19 | } 20 | } 21 | }); 22 | 23 | return { 24 | level, 25 | reason: 26 | breakings === 1 27 | ? `There is ${breakings} BREAKING CHANGE and ${features} features` 28 | : `There are ${breakings} BREAKING CHANGES and ${features} features`, 29 | }; 30 | }, 31 | }; 32 | -------------------------------------------------------------------------------- /packages/changelog/src/utils/git-raw-commit.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | format: 3 | '%B%n-hash-%n%H%n-gitTags-%n%d%n-committerDate-%n%ci%n-authorName-%n%an%n-authorEmail-%n%ae', 4 | }; 5 | -------------------------------------------------------------------------------- /packages/changelog/src/utils/parserOpts.ts: -------------------------------------------------------------------------------- 1 | import gitmojiParserOpts from '@gitmoji/parser-opts'; 2 | 3 | export default { 4 | ...gitmojiParserOpts, 5 | noteKeywords: ['BREAKING CHANGE', 'BREAKING CHANGES'], 6 | revertPattern: /revert:\s([\s\S]*?)\s*This reverts commit (\w*)\./, 7 | revertCorrespondence: [`header`, `hash`], 8 | }; 9 | -------------------------------------------------------------------------------- /packages/changelog/src/utils/writerOpts.ts: -------------------------------------------------------------------------------- 1 | import customConfig from '../customConfig'; 2 | import handleWriterOpts from '../handleWriterOpts'; 3 | 4 | export default handleWriterOpts(customConfig); 5 | -------------------------------------------------------------------------------- /packages/changelog/test/index.test.ts: -------------------------------------------------------------------------------- 1 | import { clean, conventionalChangelog, preparing, repoURL } from './utils'; 2 | 3 | describe('Gitmoji Commit Message Preset', () => { 4 | afterAll(() => { 5 | clean(); 6 | }); 7 | xit('should work if there is no semver tag', (done) => { 8 | preparing(1); 9 | 10 | conventionalChangelog(done, (log) => { 11 | expect(log).toContain('first build setup'); 12 | expect(log).toContain('**travis**: add TravisCI pipeline'); 13 | expect(log).toContain('**travis**: Continuously integrated.'); 14 | expect(log).toContain('amazing new module'); 15 | expect(log).toContain('**compile**: avoid a bug'); 16 | // expect(log).toContain('make it faster'); 17 | expect(log).toContain(`, closes [#1](${repoURL}/issues/1) [#2](${repoURL}/issues/2)`); 18 | expect(log).toContain('New build system.'); 19 | expect(log).toContain('Not backward compatible.'); 20 | expect(log).toContain('**compile**: The Change is huge.'); 21 | expect(log).toContain('Build System'); 22 | expect(log).toContain('Continuous Integration'); 23 | expect(log).toContain('Features'); 24 | expect(log).toContain('Bug Fixes'); 25 | // expect(log).toContain('Performance Improvements'); 26 | // expect(log).toContain('Reverts'); 27 | // expect(log).toContain('bad commit'); 28 | expect(log).toContain('BREAKING CHANGE'); 29 | expect(log).toContain(': Not backward compatible.'); 30 | 31 | expect(log).not.toContain('ci'); 32 | expect(log).not.toContain('feat'); 33 | expect(log).not.toContain('fix'); 34 | expect(log).not.toContain('perf'); 35 | expect(log).not.toContain('revert'); 36 | expect(log).not.toContain('***:**'); 37 | }); 38 | }); 39 | }); 40 | -------------------------------------------------------------------------------- /packages/changelog/test/utils.ts: -------------------------------------------------------------------------------- 1 | import type { Options } from 'conventional-changelog-core'; 2 | import conventionalChangelogCore from 'conventional-changelog-core'; 3 | import through from 'through2'; 4 | import gitDummyCommit from 'git-dummy-commit'; 5 | import betterThanBefore from 'better-than-before'; 6 | import shell from 'shelljs'; 7 | import gitmojiChangelogConfig from '../src'; 8 | 9 | export const conventionalChangelog = (done, testFn: (changelog: string) => void) => { 10 | conventionalChangelogCore({ 11 | config: gitmojiChangelogConfig as Options.Config, 12 | }) 13 | .on('error', (err) => { 14 | done(err); 15 | }) 16 | .pipe( 17 | through((chunk) => { 18 | const log = chunk.toString(); 19 | testFn(log); 20 | done(); 21 | }), 22 | ); 23 | }; 24 | 25 | const { setups, preparing: _preparing } = betterThanBefore(); 26 | 27 | setups([ 28 | () => { 29 | shell.config.resetForTesting(); 30 | shell.cd(__dirname); 31 | shell.rm('-rf', 'tmp'); 32 | shell.mkdir('tmp'); 33 | shell.cd('tmp'); 34 | shell.mkdir('git-templates'); 35 | shell.exec('git init --template=./git-templates'); 36 | shell.exec('git commit --allow-empty -n -m "Initial commit"'); 37 | 38 | gitDummyCommit([ 39 | ':construction_worker: build: first build setup', 40 | 'BREAKING CHANGE: New build system.', 41 | ]); 42 | gitDummyCommit([ 43 | ':green_heart: ci(travis): add TravisCI pipeline', 44 | 'BREAKING CHANGE: Continuously integrated.', 45 | ]); 46 | gitDummyCommit([ 47 | ':sparkles: feat: amazing new module', 48 | 'BREAKING CHANGE: Not backward compatible.', 49 | ]); 50 | gitDummyCommit([':bug: fix(compile): avoid a bug', 'BREAKING CHANGE: The Change is huge.']); 51 | gitDummyCommit(':zap: perf(ngOptions): make it faster'); 52 | gitDummyCommit(':rewind: revert(ngOptions): bad commit'); 53 | gitDummyCommit([':bug: fix(*): oops', ' closes #1, #2']); 54 | }, 55 | () => { 56 | shell.exec('git tag v1.0.0'); 57 | gitDummyCommit('feat: some more features'); 58 | }, 59 | () => { 60 | gitDummyCommit(['feat(*): implementing #5 by @dlmr', ' closes #10']); 61 | }, 62 | () => { 63 | gitDummyCommit(['fix: use npm@5 (@username)']); 64 | gitDummyCommit([ 65 | 'build(deps): bump @dummy/package from 7.1.2 to 8.0.0', 66 | 'BREAKING CHANGE: The Change is huge.', 67 | ]); 68 | }, 69 | () => { 70 | gitDummyCommit([ 71 | 'Revert \\":rewind: feat: default revert format\\"', 72 | 'This reverts commit 1234.', 73 | ]); 74 | gitDummyCommit([ 75 | ':rewind: revert: :sparkles: feat: custom revert format', 76 | 'This reverts commit 5678.', 77 | ]); 78 | }, 79 | ]); 80 | 81 | export const clean = () => { 82 | shell.cd(__dirname); 83 | shell.rm('-rf', 'tmp'); 84 | }; 85 | 86 | export const preparing = _preparing; 87 | 88 | export const repoURL = 'https://github.com/arvinxx/gitmoji-commit-workflow'; 89 | -------------------------------------------------------------------------------- /packages/changelog/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "include": ["src"], 4 | "compilerOptions": { 5 | "module": "CommonJS", 6 | "target": "es5", 7 | "sourceMap": true, 8 | "moduleResolution": "Node", 9 | "lib": ["ES2020"], 10 | "esModuleInterop": true 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /packages/commit-types/.fatherrc.ts: -------------------------------------------------------------------------------- 1 | import config from '../../.fatherrc'; 2 | 3 | export default config; 4 | -------------------------------------------------------------------------------- /packages/commit-types/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## @gitmoji/commit-types [1.1.5](https://github.com/arvinxx/gitmoji-commit-workflow/compare/@gitmoji/commit-types@1.1.4...@gitmoji/commit-types@1.1.5) (2021-01-25) 4 | 5 | ### 🐛 Bug Fixes | 修复 6 | 7 | - **@gitmoji/commit-types**: add test documents ([947aacd](https://github.com/arvinxx/gitmoji-commit-workflow/commit/947aacd)) 8 | -------------------------------------------------------------------------------- /packages/commit-types/README.md: -------------------------------------------------------------------------------- 1 | # @gitmoji/commit-types 2 | 3 | [![NPM version][version-image]][version-url] [![NPM downloads][download-image]][download-url] 4 | 5 | Gitmoji styles commit types 6 | 7 | ## Signature 8 | 9 | ```typescript 10 | type CommitTypes = 11 | | 'feat' // Introducing new features 12 | | 'fix' // Fixing a bug 13 | | 'refactor' // Refactoring code (Not Introducing features or fix) 14 | | 'docs' // add documents 15 | | 'test' // Adding unit tests or e2e test 16 | | 'perf' // Improving performance 17 | | 'revert' // Reverting changes or commits 18 | | 'style' // Updating the UI and style files 19 | | 'build' // build artifacts 20 | | 'ci' // working about CI build system 21 | | 'wip' // Work in progress 22 | | 'chore'; // Work with configuration or other stuff 23 | ``` 24 | 25 | ## License 26 | 27 | [MIT](../../LICENSE) ® Arvin Xu 28 | 29 | 30 | 31 | [version-image]: http://img.shields.io/npm/v/@gitmoji/commit-types.svg?color=deepgreen&label=latest 32 | [version-url]: http://npmjs.org/package/@gitmoji/commit-types 33 | [download-image]: https://img.shields.io/npm/dm/@gitmoji/commit-types.svg 34 | [download-url]: https://npmjs.org/package/@gitmoji/commit-types 35 | -------------------------------------------------------------------------------- /packages/commit-types/jest.config.ts: -------------------------------------------------------------------------------- 1 | import base from '../../jest.config.base'; 2 | import { Config } from '@umijs/test'; 3 | 4 | const packageName = '@gitmoji/commit-types'; 5 | 6 | const root = '/packages/commit-types'; 7 | 8 | const config: Config.InitialOptions = { 9 | ...base, 10 | rootDir: '../..', 11 | roots: [root], 12 | displayName: packageName, 13 | }; 14 | 15 | export default config; 16 | -------------------------------------------------------------------------------- /packages/commit-types/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@gitmoji/commit-types", 3 | "version": "1.1.5", 4 | "description": "gitmoji styles commit types", 5 | "homepage": "https://github.com/arvinxx/gitmoji-commit-workflow/tree/master/packages/commit-types", 6 | "bugs": { 7 | "url": "https://github.com/arvinxx/gitmoji-commit-workflow/issues" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "https://github.com/arvinxx/gitmoji-commit-workflow.git" 12 | }, 13 | "license": "MIT", 14 | "author": "arvinxx ", 15 | "main": "lib/index.js", 16 | "types": "lib/index.d.ts", 17 | "files": [ 18 | "lib" 19 | ], 20 | "scripts": { 21 | "build": "father build", 22 | "clean": "rm -rf es lib dist build coverage src/.umi* .eslintcache", 23 | "doctor": "father doctor", 24 | "prepublishOnly": "npm run doctor && npm run build" 25 | }, 26 | "publishConfig": { 27 | "access": "public", 28 | "registry": "https://registry.npmjs.org/" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /packages/commit-types/src/index.ts: -------------------------------------------------------------------------------- 1 | export type CommitTypes = 2 | | 'build' 3 | | 'ci' 4 | | 'docs' 5 | | 'feat' 6 | | 'fix' 7 | | 'perf' 8 | | 'refactor' 9 | | 'revert' 10 | | 'style' 11 | | 'test' 12 | | 'wip' 13 | | 'chore'; 14 | 15 | const types: CommitTypes[] = [ 16 | 'build', 17 | 'ci', 18 | 'docs', 19 | 'feat', 20 | 'fix', 21 | 'perf', 22 | 'refactor', 23 | 'revert', 24 | 'style', 25 | 'test', 26 | 'chore', 27 | 'wip', 28 | ]; 29 | 30 | export default types; 31 | -------------------------------------------------------------------------------- /packages/commit-types/test/__snapshots__/index.test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`check types 1`] = ` 4 | [ 5 | "build", 6 | "ci", 7 | "docs", 8 | "feat", 9 | "fix", 10 | "perf", 11 | "refactor", 12 | "revert", 13 | "style", 14 | "test", 15 | "chore", 16 | "wip", 17 | ] 18 | `; 19 | -------------------------------------------------------------------------------- /packages/commit-types/test/index.test.ts: -------------------------------------------------------------------------------- 1 | import types from '../src'; 2 | 3 | test('check types', async () => { 4 | expect(types).toMatchSnapshot(); 5 | }); 6 | -------------------------------------------------------------------------------- /packages/commit-types/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "include": ["src"], 4 | "compilerOptions": { 5 | "module": "CommonJS", 6 | "target": "es5", 7 | "sourceMap": true, 8 | "moduleResolution": "Node", 9 | "lib": ["ES2020"], 10 | "esModuleInterop": true, 11 | "declaration": true 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /packages/commitlint-config/.changelogrc.js: -------------------------------------------------------------------------------- 1 | const base = require('../../.changelogrc'); 2 | 3 | module.exports = { 4 | ...base, 5 | displayScopes: ['config'], 6 | }; 7 | -------------------------------------------------------------------------------- /packages/commitlint-config/.fatherrc.ts: -------------------------------------------------------------------------------- 1 | import config from '../../.fatherrc'; 2 | 3 | export default config; 4 | -------------------------------------------------------------------------------- /packages/commitlint-config/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## commitlint-config-gitmoji [2.3.1](https://github.com/arvinxx/gitmoji-commit-workflow/compare/commitlint-config-gitmoji@2.3.0...commitlint-config-gitmoji@2.3.1) (2023-02-11) 4 | 5 | ### Dependencies 6 | 7 | - **@gitmoji/parser-opts:** upgraded to 1.4.0 8 | 9 | # commitlint-config-gitmoji [2.3.0](https://github.com/arvinxx/gitmoji-commit-workflow/compare/commitlint-config-gitmoji@2.2.11...commitlint-config-gitmoji@2.3.0) (2023-02-11) 10 | 11 | ### ✨ Features 12 | 13 | - support UCS-4 emoji unicode ([006d8e4](https://github.com/arvinxx/gitmoji-commit-workflow/commit/006d8e4)) 14 | 15 | ### Dependencies 16 | 17 | - **@gitmoji/parser-opts:** upgraded to 1.4.0 18 | - **commitlint-plugin-gitmoji:** upgraded to 2.2.6 19 | 20 | # commitlint-config-gitmoji [2.3.0-beta.1](https://github.com/arvinxx/gitmoji-commit-workflow/compare/commitlint-config-gitmoji@2.2.12-beta.2...commitlint-config-gitmoji@2.3.0-beta.1) (2023-02-11) 21 | 22 | ### ✨ Features 23 | 24 | - support UCS-4 emoji unicode ([006d8e4](https://github.com/arvinxx/gitmoji-commit-workflow/commit/006d8e4)) 25 | 26 | ### Dependencies 27 | 28 | - **@gitmoji/parser-opts:** upgraded to 1.4.0-beta.2 29 | 30 | ## commitlint-config-gitmoji [2.2.12-beta.2](https://github.com/arvinxx/gitmoji-commit-workflow/compare/commitlint-config-gitmoji@2.2.12-beta.1...commitlint-config-gitmoji@2.2.12-beta.2) (2023-02-11) 31 | 32 | ### Dependencies 33 | 34 | - **@gitmoji/parser-opts:** upgraded to 1.4.0-beta.1 35 | - **commitlint-plugin-gitmoji:** upgraded to 2.2.6-beta.1 36 | 37 | ## commitlint-config-gitmoji [2.2.11](https://github.com/arvinxx/gitmoji-commit-workflow/compare/commitlint-config-gitmoji@2.2.10...commitlint-config-gitmoji@2.2.11) (2023-02-10) 38 | 39 | ### Dependencies 40 | 41 | - **commitlint-plugin-gitmoji:** upgraded to 2.2.5 42 | 43 | ## commitlint-config-gitmoji [2.2.10](https://github.com/arvinxx/gitmoji-commit-workflow/compare/commitlint-config-gitmoji@2.2.9...commitlint-config-gitmoji@2.2.10) (2023-01-14) 44 | 45 | ### Dependencies 46 | 47 | - **commitlint-plugin-gitmoji:** upgraded to 2.2.4 48 | 49 | ## commitlint-config-gitmoji [2.2.9](https://github.com/arvinxx/gitmoji-commit-workflow/compare/commitlint-config-gitmoji@2.2.8...commitlint-config-gitmoji@2.2.9) (2023-01-06) 50 | 51 | ### Dependencies 52 | 53 | - **commitlint-plugin-gitmoji:** upgraded to 2.2.3 54 | 55 | ## commitlint-config-gitmoji [2.2.8](https://github.com/arvinxx/gitmoji-commit-workflow/compare/commitlint-config-gitmoji@2.2.7...commitlint-config-gitmoji@2.2.8) (2023-01-01) 56 | 57 | ### 🐛 Bug Fixes 58 | 59 | - **commitlint-config**: upgrade header-max-length config in commitlint ([e59891f](https://github.com/arvinxx/gitmoji-commit-workflow/commit/e59891f)) 60 | - fix missing module.exports when migration to father4 ([2da44fd](https://github.com/arvinxx/gitmoji-commit-workflow/commit/2da44fd)) 61 | 62 | ### Dependencies 63 | 64 | - **commitlint-plugin-gitmoji:** upgraded to 2.2.2 65 | 66 | ## commitlint-config-gitmoji [2.2.8-beta.3](https://github.com/arvinxx/gitmoji-commit-workflow/compare/commitlint-config-gitmoji@2.2.8-beta.2...commitlint-config-gitmoji@2.2.8-beta.3) (2023-01-01) 67 | 68 | ### 🐛 Bug Fixes 69 | 70 | - **commitlint-config**: upgrade header-max-length config in commitlint ([e59891f](https://github.com/arvinxx/gitmoji-commit-workflow/commit/e59891f)) 71 | 72 | ## commitlint-config-gitmoji [2.2.8-beta.2](https://github.com/arvinxx/gitmoji-commit-workflow/compare/commitlint-config-gitmoji@2.2.8-beta.1...commitlint-config-gitmoji@2.2.8-beta.2) (2023-01-01) 73 | 74 | ### Dependencies 75 | 76 | - **commitlint-plugin-gitmoji:** upgraded to 2.2.2-beta.1 77 | 78 | ## commitlint-config-gitmoji [2.2.8-beta.1](https://github.com/arvinxx/gitmoji-commit-workflow/compare/commitlint-config-gitmoji@2.2.7...commitlint-config-gitmoji@2.2.8-beta.1) (2023-01-01) 79 | 80 | ### 🐛 Bug Fixes 81 | 82 | - fix missing module.exports when migration to father4 ([2da44fd](https://github.com/arvinxx/gitmoji-commit-workflow/commit/2da44fd)) 83 | 84 | ## 2.2.7 (2023-01-01) 85 | 86 | - :arrow_up: chore: upgrade to father4 ([5ea649e](https://github.com/arvinxx/gitmoji-commit-workflow/commit/5ea649e)) 87 | - :arrow_up: chore: upgrade to jest29 ([9aa126b](https://github.com/arvinxx/gitmoji-commit-workflow/commit/9aa126b)) 88 | - :art: chore: reformat code with prettier ([809cbc9](https://github.com/arvinxx/gitmoji-commit-workflow/commit/809cbc9)) 89 | - :art: chore: reformat package.json with prettier ([5176c18](https://github.com/arvinxx/gitmoji-commit-workflow/commit/5176c18)) 90 | - :bookmark: chore(release): commitlint-config-gitmoji@2.2.7-beta.1 [skip ci] ([0331f34](https://github.com/arvinxx/gitmoji-commit-workflow/commit/0331f34)) 91 | - :rotating_light: chore: fix lint ([647e88e](https://github.com/arvinxx/gitmoji-commit-workflow/commit/647e88e)) 92 | 93 | ### Dependencies 94 | 95 | - **commitlint-plugin-gitmoji:** upgraded to 2.2.1 96 | 97 | ## 2.2.7-beta.1 (2022-12-24) 98 | 99 | - :arrow_up: chore: upgrade to father4 ([5ea649e](https://github.com/arvinxx/gitmoji-commit-workflow/commit/5ea649e)) 100 | - :arrow_up: chore: upgrade to jest29 ([9aa126b](https://github.com/arvinxx/gitmoji-commit-workflow/commit/9aa126b)) 101 | - :art: chore: reformat code with prettier ([809cbc9](https://github.com/arvinxx/gitmoji-commit-workflow/commit/809cbc9)) 102 | - :art: chore: reformat package.json with prettier ([5176c18](https://github.com/arvinxx/gitmoji-commit-workflow/commit/5176c18)) 103 | - :rotating_light: chore: fix lint ([647e88e](https://github.com/arvinxx/gitmoji-commit-workflow/commit/647e88e)) 104 | 105 | ### Dependencies 106 | 107 | - **commitlint-plugin-gitmoji:** upgraded to 2.2.1-beta.1 108 | 109 | ## commitlint-config-gitmoji [2.2.6](https://github.com/arvinxx/gitmoji-commit-workflow/compare/commitlint-config-gitmoji@2.2.5...commitlint-config-gitmoji@2.2.6) (2022-10-09) 110 | 111 | ### Dependencies 112 | 113 | - **@gitmoji/parser-opts:** upgraded to 1.3.1 114 | 115 | ## commitlint-config-gitmoji [2.2.6-beta.1](https://github.com/arvinxx/gitmoji-commit-workflow/compare/commitlint-config-gitmoji@2.2.5...commitlint-config-gitmoji@2.2.6-beta.1) (2022-10-09) 116 | 117 | ### Dependencies 118 | 119 | - **@gitmoji/parser-opts:** upgraded to 1.3.1-beta.1 120 | 121 | ## commitlint-config-gitmoji [2.2.5](https://github.com/arvinxx/gitmoji-commit-workflow/compare/commitlint-config-gitmoji@2.2.4...commitlint-config-gitmoji@2.2.5) (2021-05-04) 122 | 123 | ### 🐛 Bug Fixes 124 | 125 | - fix dependency error ([def947f](https://github.com/arvinxx/gitmoji-commit-workflow/commit/def947f)) 126 | 127 | ### Dependencies 128 | 129 | - **commitlint-plugin-gitmoji:** upgraded to 2.2.0 130 | 131 | ## commitlint-config-gitmoji [2.2.5-beta.3](https://github.com/arvinxx/gitmoji-commit-workflow/compare/commitlint-config-gitmoji@2.2.5-beta.2...commitlint-config-gitmoji@2.2.5-beta.3) (2021-05-04) 132 | 133 | ### Dependencies 134 | 135 | - **commitlint-plugin-gitmoji:** upgraded to 2.2.0-beta.3 136 | 137 | ## commitlint-config-gitmoji [2.2.5-beta.2](https://github.com/arvinxx/gitmoji-commit-workflow/compare/commitlint-config-gitmoji@2.2.5-beta.1...commitlint-config-gitmoji@2.2.5-beta.2) (2021-05-02) 138 | 139 | ### 🐛 Bug Fixes 140 | 141 | - fix dependency error ([def947f](https://github.com/arvinxx/gitmoji-commit-workflow/commit/def947f)) 142 | 143 | ## commitlint-config-gitmoji [2.2.5-beta.1](https://github.com/arvinxx/gitmoji-commit-workflow/compare/commitlint-config-gitmoji@2.2.4...commitlint-config-gitmoji@2.2.5-beta.1) (2021-05-02) 144 | 145 | ### Dependencies 146 | 147 | - **commitlint-plugin-gitmoji:** upgraded to 2.2.0-beta.2 148 | 149 | ## commitlint-config-gitmoji [2.2.4-beta.1](https://github.com/arvinxx/gitmoji-commit-workflow/compare/commitlint-config-gitmoji@2.2.3...commitlint-config-gitmoji@2.2.4-beta.1) (2021-05-02) 150 | 151 | ### Dependencies 152 | 153 | - **commitlint-plugin-gitmoji:** upgraded to 2.2.0-beta.1 154 | 155 | ## commitlint-config-gitmoji [2.2.4](https://github.com/arvinxx/gitmoji-commit-workflow/compare/commitlint-config-gitmoji@2.2.3...commitlint-config-gitmoji@2.2.4) (2021-05-02) 156 | 157 | ### Dependencies 158 | 159 | - **commitlint-plugin-gitmoji:** upgraded to 2.1.1 160 | 161 | ## commitlint-config-gitmoji [2.2.3](https://github.com/arvinxx/gitmoji-commit-workflow/compare/commitlint-config-gitmoji@2.2.2...commitlint-config-gitmoji@2.2.3) (2021-03-06) 162 | 163 | ### Dependencies 164 | 165 | - **@gitmoji/parser-opts:** upgraded to 1.3.0 166 | - **commitlint-plugin-gitmoji:** upgraded to 2.1.0 167 | 168 | ## commitlint-config-gitmoji [2.2.2](https://github.com/arvinxx/gitmoji-commit-workflow/compare/commitlint-config-gitmoji@2.2.1...commitlint-config-gitmoji@2.2.2) (2021-02-26) 169 | 170 | ### Dependencies 171 | 172 | - **@gitmoji/parser-opts:** upgraded to 1.2.6 173 | 174 | ## commitlint-config-gitmoji [2.2.1](https://github.com/arvinxx/gitmoji-commit-workflow/compare/commitlint-config-gitmoji@2.2.0...commitlint-config-gitmoji@2.2.1) (2021-01-28) 175 | 176 | ### Dependencies 177 | 178 | - **commitlint-plugin-gitmoji:** upgraded to 2.0.6 179 | 180 | # commitlint-config-gitmoji [2.2.0](https://github.com/arvinxx/gitmoji-commit-workflow/compare/commitlint-config-gitmoji@2.1.11...commitlint-config-gitmoji@2.2.0) (2021-01-28) 181 | 182 | ### ✨ Features | 新特性 183 | 184 | - **description**: update package description ([56dd470](https://github.com/arvinxx/gitmoji-commit-workflow/commit/56dd470)) 185 | 186 | ## commitlint-config-gitmoji [2.1.11](https://github.com/arvinxx/gitmoji-commit-workflow/compare/commitlint-config-gitmoji@2.1.10...commitlint-config-gitmoji@2.1.11) (2021-01-28) 187 | 188 | ### Dependencies 189 | 190 | - **commitlint-plugin-gitmoji:** upgraded to 2.0.5 191 | 192 | ## commitlint-config-gitmoji [2.1.10](https://github.com/arvinxx/gitmoji-commit-workflow/compare/commitlint-config-gitmoji@2.1.9...commitlint-config-gitmoji@2.1.10) (2021-01-25) 193 | 194 | ### Dependencies 195 | 196 | - **@gitmoji/commit-types:** upgraded to 1.1.5 197 | 198 | ## commitlint-config-gitmoji [2.1.9](https://github.com/arvinxx/gitmoji-commit-workflow/compare/commitlint-config-gitmoji@2.1.8...commitlint-config-gitmoji@2.1.9) (2021-01-25) 199 | 200 | ### 🐛 Bug Fixes | 修复 201 | 202 | - **(Other)**: clean changelog ([8479426](https://github.com/arvinxx/gitmoji-commit-workflow/commit/8479426)) 203 | - **(Other)**: link deps ([e4526ed](https://github.com/arvinxx/gitmoji-commit-workflow/commit/e4526ed)) 204 | 205 | ### Dependencies 206 | 207 | - **@gitmoji/commit-types:** upgraded to 1.1.4 208 | - **@gitmoji/parser-opts:** upgraded to 1.2.5 209 | - **commitlint-plugin-gitmoji:** upgraded to 2.0.4 210 | 211 | # [commitlint-config-gitmoji-v2.1.7](https://github.com/arvinxx/gitmoji-commit-workflow/compare/commitlint-config-gitmoji-v2.1.6...commitlint-config-gitmoji-v2.1.7) (2021-01-25) 212 | -------------------------------------------------------------------------------- /packages/commitlint-config/README.md: -------------------------------------------------------------------------------- 1 | > 🚦 Lint your gitmoji commits 2 | 3 | # commitlint-config-gitmoji 4 | 5 | [![NPM version][version-image]][version-url] [![NPM downloads][download-image]][download-url] 6 | 7 | 8 | 9 | [version-image]: http://img.shields.io/npm/v/commitlint-config-gitmoji.svg?color=deepgreen&label=latest 10 | [version-url]: http://npmjs.org/package/commitlint-config-gitmoji 11 | [download-image]: https://img.shields.io/npm/dm/commitlint-config-gitmoji.svg 12 | [download-url]: https://npmjs.org/package/commitlint-config-gitmoji 13 | 14 | Shareable `commitlint` config enforcing gitmoji commit message styles. Use with [commitlint](https://github.com/marionebl/commitlint) . 15 | 16 | ## Demo 17 | 18 | TODO 19 | 20 | ## Getting started 21 | 22 | ### Install 23 | 24 | Install dependencies 25 | 26 | ```sh 27 | # use npm 28 | npm i -D commitlint-config-gitmoji commitlint 29 | ``` 30 | 31 | or 32 | 33 | ``` 34 | # use pnpm 35 | pnpm i -D commitlint-config-gitmoji commitlint 36 | ``` 37 | 38 | ### Config 39 | 40 | Add commitlint config for Gitmoji 41 | 42 | ```sh 43 | echo "module.exports = {extends: ['gitmoji']};" > commitlint.config.js 44 | ``` 45 | 46 | ## Commit style 47 | 48 | ### Structure 49 | 50 | the Gitmoji Structure of commit styles is below 51 | 52 | ``` 53 | :gitmoji: type(scope?): subject 54 | body? 55 | footer? 56 | ``` 57 | 58 | ### Example 59 | 60 | ``` 61 | :sparkles: feat(changelog): support chinese title 62 | 63 | :bug: fix(config): fix a subject bug 64 | 65 | :memo: docs: update README.md 66 | 67 | :bulb: docs(plugin): update comments 68 | ``` 69 | 70 | ## Detail Rules 71 | 72 | ### Problems 73 | 74 | The following rules are considered problems for `gitmoji commit` and will yield a non-zero exit code when not met. 75 | 76 | Consult [docs/rules](https://commitlint.js.org/#/) for a list of available rules. 77 | 78 | #### type-enum 79 | 80 | - **condition**: `type` is found in value 81 | - **rule**: `always` 82 | - **value**: Refer to [@gitmoji/commiy-types](../commit-types) 83 | 84 | ```sh 85 | echo ":abc: some message" # fails 86 | echo ":feat: some message" # passes 87 | ``` 88 | 89 | #### type-case 90 | 91 | - **description**: `type` is in case `value` 92 | - **rule**: `always` 93 | - **value**: `lowerCase` 94 | 95 | ```sh 96 | echo ":ART: Format some code" # fails 97 | echo ":art: Format some code" # passes 98 | ``` 99 | 100 | #### type-empty 101 | 102 | - **condition**: `type` is empty 103 | - **rule**: `never` 104 | 105 | ```sh 106 | echo ": some message" # fails 107 | echo ":fire: Delete some file" # passes 108 | ``` 109 | 110 | #### scope-case 111 | 112 | - **condition**: `scope` is in case `value` 113 | - **rule**: `always` 114 | - **value**: `lowerCase` 115 | 116 | ```sh 117 | echo ":art:(SCOPE) some message" # fails 118 | echo ":art:(scope) some message" # passes 119 | ``` 120 | 121 | #### subject-case 122 | 123 | - **condition**: `subject` must begin with `['sentence-case', 'start-case', 'pascal-case', 'upper-case']` 124 | - **rule**: `always` 125 | 126 | ```sh 127 | echo ":art:(scope) Some Message" # pass 128 | echo ":art:(scope) some message" # Fails 129 | ``` 130 | 131 | #### subject-empty 132 | 133 | - **condition**: `subject` is empty 134 | - **rule**: `never` 135 | 136 | ```sh 137 | echo ":art: " # fails 138 | echo ":art: some message" # passes 139 | ``` 140 | 141 | #### subject-full-stop 142 | 143 | - **condition**: `subject` ends with `value` 144 | - **rule**: `never` 145 | - **value**: `.` 146 | 147 | ```sh 148 | echo ":art: some message." # fails 149 | echo ":art: some message" # passes 150 | ``` 151 | 152 | #### header-max-length 153 | 154 | - **condition**: `header` has `value` or less characters 155 | - **rule**: `always` 156 | - **value**: `100` 157 | 158 | ```sh 159 | echo ":art: some message that is way too long and breaks the line max-length by several characters" # fails 160 | echo ":art: some message" # passes 161 | ``` 162 | 163 | ## License 164 | 165 | [MIT](../../LICENSE) ® Arvin Xu 166 | -------------------------------------------------------------------------------- /packages/commitlint-config/jest.config.ts: -------------------------------------------------------------------------------- 1 | import base from '../../jest.config.base'; 2 | import { Config } from '@umijs/test'; 3 | 4 | const packageName = 'commitlint-config-gitmoji'; 5 | 6 | const root = '/packages/commitlint-config'; 7 | 8 | const config: Config.InitialOptions = { 9 | ...base, 10 | rootDir: '../..', 11 | roots: [root], 12 | displayName: packageName, 13 | }; 14 | 15 | export default config; 16 | -------------------------------------------------------------------------------- /packages/commitlint-config/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "commitlint-config-gitmoji", 3 | "version": "2.3.1", 4 | "description": "shareable commitlint config enforcing gitmoji commit message", 5 | "keywords": [ 6 | "commitlint", 7 | "gitmoji", 8 | "emoji", 9 | "commit", 10 | "git" 11 | ], 12 | "homepage": "https://github.com/arvinxx/gitmoji-commit-workflow/tree/master/packages/commitlint-config", 13 | "repository": { 14 | "type": "git", 15 | "url": "https://github.com/arvinxx/gitmoji-commit-workflow.git" 16 | }, 17 | "license": "MIT", 18 | "author": "Arvin Xu ", 19 | "main": "lib/index.js", 20 | "files": [ 21 | "lib" 22 | ], 23 | "scripts": { 24 | "build": "father build", 25 | "clean": "rm -rf es lib dist build coverage .eslintcache", 26 | "cov": "jest --coverage", 27 | "doctor": "father doctor", 28 | "prepublishOnly": "npm run doctor && npm run build", 29 | "start": "father dev", 30 | "test": "jest" 31 | }, 32 | "dependencies": { 33 | "@commitlint/types": "^17", 34 | "@gitmoji/commit-types": "1.1.5", 35 | "@gitmoji/parser-opts": "1.4.0", 36 | "commitlint-plugin-gitmoji": "2.2.6" 37 | }, 38 | "devDependencies": { 39 | "@commitlint/lint": "^17" 40 | }, 41 | "publishConfig": { 42 | "access": "public", 43 | "registry": "https://registry.npmjs.org/" 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /packages/commitlint-config/src/index.ts: -------------------------------------------------------------------------------- 1 | import type { LintOptions, QualifiedRules } from '@commitlint/types'; 2 | import { RuleConfigSeverity, type Plugin } from '@commitlint/types'; 3 | import commitTypes from '@gitmoji/commit-types'; 4 | import gitmojiParserOpts from '@gitmoji/parser-opts'; 5 | import gitmojiPlugin from 'commitlint-plugin-gitmoji'; 6 | 7 | const { Error } = RuleConfigSeverity; 8 | 9 | const rules: QualifiedRules = { 10 | // gitmoji 规则 11 | 'start-with-gitmoji': [Error, 'always'], 12 | // 使用 Angular 的类型 13 | 'type-enum': [Error, 'always', commitTypes], 14 | // 内容以空行开始 15 | 'body-leading-blank': [Error, 'always'], 16 | // 结尾以空行开始 17 | 'footer-leading-blank': [Error, 'always'], 18 | // 标题最大长度 100 个字符 19 | 'header-max-length': [Error, 'always', 100], 20 | // Scope 永远小写 21 | 'scope-case': [Error, 'always', 'lower-case'], 22 | // 不允许标题空着 23 | 'subject-empty': [Error, 'never'], 24 | // 不允许使用句号 25 | 'subject-full-stop': [Error, 'never', '.'], 26 | // type 必须小写 27 | 'type-case': [Error, 'always', 'lower-case'], 28 | // type 不能为空 29 | 'type-empty': [Error, 'never'], 30 | }; 31 | 32 | const parserPreset: LintOptions = { 33 | parserOpts: gitmojiParserOpts, 34 | plugins: { 35 | gitmoji: gitmojiPlugin, 36 | }, 37 | }; 38 | 39 | const config: { plugins: Plugin[]; parserPreset: LintOptions; rules: QualifiedRules } = { 40 | rules, 41 | parserPreset, 42 | plugins: [gitmojiPlugin], 43 | }; 44 | 45 | export default config; 46 | -------------------------------------------------------------------------------- /packages/commitlint-config/test/index.test.ts: -------------------------------------------------------------------------------- 1 | import { lint } from './utils'; 2 | 3 | describe('invalid commit', () => { 4 | it('$ chore(scope): test -> without gitmoji', async () => { 5 | const { valid, errors } = await lint('chore(scope): test'); 6 | 7 | expect(valid).toBeFalsy(); 8 | expect(errors[0].name).toBe('start-with-gitmoji'); 9 | }); 10 | 11 | it('$ :start: chore(scope): test -> invalid gitmoji', async () => { 12 | const { valid, errors } = await lint(':start: chore(scope): test'); 13 | 14 | expect(valid).toBeFalsy(); 15 | expect(errors).toHaveLength(1); 16 | expect(errors[0].name).toBe('start-with-gitmoji'); 17 | expect(errors[0].message).toBe( 18 | ':start: is not in the correct gitmoji list, please check the emoji code on https://gitmoji.dev/.', 19 | ); 20 | }); 21 | 22 | it('$ hello :test: test -> 3 error', async () => { 23 | const { valid, errors } = await lint('hello :test: test'); 24 | 25 | expect(valid).toBeFalsy(); 26 | expect(errors).toHaveLength(3); 27 | }); 28 | 29 | it('$ :start:test: test -> 3 error', async () => { 30 | const { valid, errors } = await lint(':start:test: test'); 31 | 32 | expect(valid).toBeFalsy(); 33 | expect(errors).toHaveLength(3); 34 | }); 35 | 36 | it('$ 😂 test: test -> 3 error', async () => { 37 | const { valid, errors } = await lint('😂 test: test'); 38 | 39 | expect(valid).toBeFalsy(); 40 | expect(errors).toHaveLength(1); 41 | }); 42 | }); 43 | 44 | describe('valid commit', () => { 45 | it('$ :white_check_mark: test: test -> passed', async () => { 46 | const { valid } = await lint(':white_check_mark: test: test'); 47 | 48 | expect(valid).toBeTruthy(); 49 | }); 50 | 51 | it('$ :sparkles: feat(web): add new feat -> passed', async () => { 52 | const { valid } = await lint(':sparkles: feat(web): add new feat'); 53 | 54 | expect(valid).toBeTruthy(); 55 | }); 56 | 57 | it('$ :green_heart: ci: fix ci -> passed', async () => { 58 | const { valid } = await lint(':green_heart: ci: fix ci'); 59 | 60 | expect(valid).toBeTruthy(); 61 | }); 62 | 63 | it('$ :memo: docs: update document #123 -> passed', async () => { 64 | const { valid } = await lint(':memo: docs: update document #123'); 65 | 66 | expect(valid).toBeTruthy(); 67 | }); 68 | it('$ :memo: docs: update README.md -> passed', async () => { 69 | const { valid } = await lint(':memo: docs: update README.md'); 70 | 71 | expect(valid).toBeTruthy(); 72 | }); 73 | it('$ :lipstick: style(typography): 优化信息块和内联代码样式 -> passed', async () => { 74 | const { valid } = await lint(':lipstick: style(typography): 优化信息块和内联代码样式'); 75 | 76 | expect(valid).toBeTruthy(); 77 | }); 78 | 79 | it('$ 💄 style(typography): 优化信息块和内联代码样式 -> passed', async () => { 80 | const { valid } = await lint('💄 style(typography): 优化信息块和内联代码样式'); 81 | 82 | expect(valid).toBeTruthy(); 83 | }); 84 | 85 | it('$ ⚡️ chore(scope): test -> passed', async () => { 86 | const result = await lint('⚡️ chore(scope): test'); 87 | 88 | expect(result.valid).toBeTruthy(); 89 | }); 90 | }); 91 | -------------------------------------------------------------------------------- /packages/commitlint-config/test/utils.ts: -------------------------------------------------------------------------------- 1 | import { default as commitlint } from '@commitlint/lint'; 2 | import config from '../src'; 3 | 4 | export const lint = (input) => commitlint(input, config.rules, config.parserPreset); 5 | -------------------------------------------------------------------------------- /packages/commitlint-config/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "include": ["src"], 4 | "compilerOptions": { 5 | "module": "CommonJS", 6 | "target": "es5", 7 | "sourceMap": true, 8 | "moduleResolution": "Node", 9 | "lib": ["ES2020"], 10 | "esModuleInterop": true, 11 | "baseUrl": "../..", 12 | "paths": { 13 | "conventional-changelog-gitmoji-config": ["./packages/changelog/src"], 14 | "commitlint-plugin-gitmoji": ["./packages/commitlint-plugin/src"], 15 | "@gitmoji/parser-opts": ["./packages/parser-opts/src"], 16 | "@gitmoji/commit-types": ["./packages/commit-type/src"] 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /packages/commitlint-plugin/.changelogrc.js: -------------------------------------------------------------------------------- 1 | const base = require('../../.changelogrc'); 2 | 3 | module.exports = { 4 | ...base, 5 | }; 6 | -------------------------------------------------------------------------------- /packages/commitlint-plugin/.fatherrc.ts: -------------------------------------------------------------------------------- 1 | import config from '../../.fatherrc'; 2 | 3 | export default config; 4 | -------------------------------------------------------------------------------- /packages/commitlint-plugin/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## commitlint-plugin-gitmoji [2.2.6](https://github.com/arvinxx/gitmoji-commit-workflow/compare/commitlint-plugin-gitmoji@2.2.5...commitlint-plugin-gitmoji@2.2.6) (2023-02-11) 4 | 5 | ### Dependencies 6 | 7 | - **@gitmoji/gitmoji-regex:** upgraded to 1.0.0 8 | 9 | ## commitlint-plugin-gitmoji [2.2.6-beta.1](https://github.com/arvinxx/gitmoji-commit-workflow/compare/commitlint-plugin-gitmoji@2.2.5...commitlint-plugin-gitmoji@2.2.6-beta.1) (2023-02-11) 10 | 11 | ## commitlint-plugin-gitmoji [2.2.5](https://github.com/arvinxx/gitmoji-commit-workflow/compare/commitlint-plugin-gitmoji@2.2.4...commitlint-plugin-gitmoji@2.2.5) (2023-02-10) 12 | 13 | ### 🐛 Bug Fixes 14 | 15 | - try to fix gitmoji unicode regex ([acd12b1](https://github.com/arvinxx/gitmoji-commit-workflow/commit/acd12b1)), closes [#662](https://github.com/arvinxx/gitmoji-commit-workflow/issues/662) [#56](https://github.com/arvinxx/gitmoji-commit-workflow/issues/56) [#493](https://github.com/arvinxx/gitmoji-commit-workflow/issues/493) 16 | 17 | ## commitlint-plugin-gitmoji [2.2.4](https://github.com/arvinxx/gitmoji-commit-workflow/compare/commitlint-plugin-gitmoji@2.2.3...commitlint-plugin-gitmoji@2.2.4) (2023-01-14) 18 | 19 | ### 🐛 Bug Fixes 20 | 21 | - try to fix release issue by lock gitmojis version ([c928267](https://github.com/arvinxx/gitmoji-commit-workflow/commit/c928267)) 22 | 23 | ## commitlint-plugin-gitmoji [2.2.3](https://github.com/arvinxx/gitmoji-commit-workflow/compare/commitlint-plugin-gitmoji@2.2.2...commitlint-plugin-gitmoji@2.2.3) (2023-01-06) 24 | 25 | ### 🐛 Bug Fixes 26 | 27 | - corrected grammar of complaint message ([5bac55a](https://github.com/arvinxx/gitmoji-commit-workflow/commit/5bac55a)) 28 | 29 | ## commitlint-plugin-gitmoji [2.2.2](https://github.com/arvinxx/gitmoji-commit-workflow/compare/commitlint-plugin-gitmoji@2.2.1...commitlint-plugin-gitmoji@2.2.2) (2023-01-01) 30 | 31 | ## commitlint-plugin-gitmoji [2.2.2-beta.1](https://github.com/arvinxx/commitlint-config-gitmoji/compare/commitlint-plugin-gitmoji@2.2.1...commitlint-plugin-gitmoji@2.2.2-beta.1) (2023-01-01) 32 | 33 | ## 2.2.1 (2023-01-01) 34 | 35 | - :arrow_up: chore: upgrade to father4 ([5ea649e](https://github.com/arvinxx/commitlint-config-gitmoji/commit/5ea649e)) 36 | - :arrow_up: chore: upgrade to jest29 ([9aa126b](https://github.com/arvinxx/commitlint-config-gitmoji/commit/9aa126b)) 37 | - :art: chore: reformat code with prettier ([809cbc9](https://github.com/arvinxx/commitlint-config-gitmoji/commit/809cbc9)) 38 | - :art: chore: reformat package.json with prettier ([5176c18](https://github.com/arvinxx/commitlint-config-gitmoji/commit/5176c18)) 39 | - :bookmark: chore(release): commitlint-plugin-gitmoji@2.2.1-beta.1 [skip ci] ([8a50b94](https://github.com/arvinxx/commitlint-config-gitmoji/commit/8a50b94)), closes [#40](https://github.com/arvinxx/commitlint-config-gitmoji/issues/40) [#40](https://github.com/arvinxx/commitlint-config-gitmoji/issues/40) [#40](https://github.com/arvinxx/commitlint-config-gitmoji/issues/40) [#40](https://github.com/arvinxx/commitlint-config-gitmoji/issues/40) [#104](https://github.com/arvinxx/commitlint-config-gitmoji/issues/104) [#105](https://github.com/arvinxx/commitlint-config-gitmoji/issues/105) [#106](https://github.com/arvinxx/commitlint-config-gitmoji/issues/106) [#107](https://github.com/arvinxx/commitlint-config-gitmoji/issues/107) [#108](https://github.com/arvinxx/commitlint-config-gitmoji/issues/108) [#109](https://github.com/arvinxx/commitlint-config-gitmoji/issues/109) [#110](https://github.com/arvinxx/commitlint-config-gitmoji/issues/110) [#111](https://github.com/arvinxx/commitlint-config-gitmoji/issues/111) [#113](https://github.com/arvinxx/commitlint-config-gitmoji/issues/113) [#114](https://github.com/arvinxx/commitlint-config-gitmoji/issues/114) [#115](https://github.com/arvinxx/commitlint-config-gitmoji/issues/115) [#116](https://github.com/arvinxx/commitlint-config-gitmoji/issues/116) [#117](https://github.com/arvinxx/commitlint-config-gitmoji/issues/117) [#118](https://github.com/arvinxx/commitlint-config-gitmoji/issues/118) [#119](https://github.com/arvinxx/commitlint-config-gitmoji/issues/119) [#121](https://github.com/arvinxx/commitlint-config-gitmoji/issues/121) [#306](https://github.com/arvinxx/commitlint-config-gitmoji/issues/306) [#367](https://github.com/arvinxx/commitlint-config-gitmoji/issues/367) [#522](https://github.com/arvinxx/commitlint-config-gitmoji/issues/522) [#581](https://github.com/arvinxx/commitlint-config-gitmoji/issues/581) [#655](https://github.com/arvinxx/commitlint-config-gitmoji/issues/655) 40 | - :memo: docs: Removed unnecesary documentation ([3d728e3](https://github.com/arvinxx/commitlint-config-gitmoji/commit/3d728e3)) 41 | - :white_check_mark: test: fix test ([bf7ea1c](https://github.com/arvinxx/commitlint-config-gitmoji/commit/bf7ea1c)) 42 | - :white_check_mark: test: fix test after upgrade ([30c897d](https://github.com/arvinxx/commitlint-config-gitmoji/commit/30c897d)) 43 | - :wrench: chore: fix package.json ([7a2e102](https://github.com/arvinxx/commitlint-config-gitmoji/commit/7a2e102)) 44 | - :zap: chore: Replaced fetching gitmoji.json for dependency ([cf1788f](https://github.com/arvinxx/commitlint-config-gitmoji/commit/cf1788f)) 45 | - build(deps): bump dotenv from 8.5.1 to 9.0.0 ([1ff1169](https://github.com/arvinxx/commitlint-config-gitmoji/commit/1ff1169)) 46 | 47 | ## 2.2.1-beta.1 (2022-12-24) 48 | 49 | - :arrow_up: chore: upgrade to father4 ([5ea649e](https://github.com/arvinxx/commitlint-config-gitmoji/commit/5ea649e)) 50 | - :arrow_up: chore: upgrade to jest29 ([9aa126b](https://github.com/arvinxx/commitlint-config-gitmoji/commit/9aa126b)) 51 | - :art: chore: reformat code with prettier ([809cbc9](https://github.com/arvinxx/commitlint-config-gitmoji/commit/809cbc9)) 52 | - :art: chore: reformat package.json with prettier ([5176c18](https://github.com/arvinxx/commitlint-config-gitmoji/commit/5176c18)) 53 | - :memo: docs: Removed unnecesary documentation ([3d728e3](https://github.com/arvinxx/commitlint-config-gitmoji/commit/3d728e3)) 54 | - :white_check_mark: test: fix test ([bf7ea1c](https://github.com/arvinxx/commitlint-config-gitmoji/commit/bf7ea1c)) 55 | - :white_check_mark: test: fix test after upgrade ([30c897d](https://github.com/arvinxx/commitlint-config-gitmoji/commit/30c897d)) 56 | - :wrench: chore: fix package.json ([7a2e102](https://github.com/arvinxx/commitlint-config-gitmoji/commit/7a2e102)) 57 | - :zap: chore: Replaced fetching gitmoji.json for dependency ([cf1788f](https://github.com/arvinxx/commitlint-config-gitmoji/commit/cf1788f)) 58 | - build(deps): bump dotenv from 8.5.1 to 9.0.0 ([1ff1169](https://github.com/arvinxx/commitlint-config-gitmoji/commit/1ff1169)) 59 | 60 | # commitlint-plugin-gitmoji [2.2.0](https://github.com/arvinxx/commitlint-config-gitmoji/compare/commitlint-plugin-gitmoji@2.1.1...commitlint-plugin-gitmoji@2.2.0) (2021-05-04) 61 | 62 | ### ✨ Features 63 | 64 | - support GITMOJI_PATH env ([8a81839](https://github.com/arvinxx/commitlint-config-gitmoji/commit/8a81839)) 65 | - support GITMOJI_PATH env ([2d05da1](https://github.com/arvinxx/commitlint-config-gitmoji/commit/2d05da1)), closes [#40](https://github.com/arvinxx/commitlint-config-gitmoji/issues/40) 66 | - support local gitmoji path ([6b75a95](https://github.com/arvinxx/commitlint-config-gitmoji/commit/6b75a95)) 67 | 68 | # commitlint-plugin-gitmoji [2.2.0-beta.3](https://github.com/arvinxx/commitlint-config-gitmoji/compare/commitlint-plugin-gitmoji@2.2.0-beta.2...commitlint-plugin-gitmoji@2.2.0-beta.3) (2021-05-04) 69 | 70 | ### ✨ Features 71 | 72 | - support local gitmoji path ([6b75a95](https://github.com/arvinxx/commitlint-config-gitmoji/commit/6b75a95)) 73 | 74 | # commitlint-plugin-gitmoji [2.2.0-beta.2](https://github.com/arvinxx/commitlint-config-gitmoji/compare/commitlint-plugin-gitmoji@2.2.0-beta.1...commitlint-plugin-gitmoji@2.2.0-beta.2) (2021-05-02) 75 | 76 | ### ✨ Features 77 | 78 | - support GITMOJI_PATH env ([8a81839](https://github.com/arvinxx/commitlint-config-gitmoji/commit/8a81839)) 79 | 80 | # commitlint-plugin-gitmoji [2.2.0-beta.1](https://github.com/arvinxx/commitlint-config-gitmoji/compare/commitlint-plugin-gitmoji@2.1.0...commitlint-plugin-gitmoji@2.2.0-beta.1) (2021-05-02) 81 | 82 | ### ✨ Features 83 | 84 | - support GITMOJI_PATH env ([2d05da1](https://github.com/arvinxx/commitlint-config-gitmoji/commit/2d05da1)), closes [#40](https://github.com/arvinxx/commitlint-config-gitmoji/issues/40) 85 | 86 | ## commitlint-plugin-gitmoji [2.1.1](https://github.com/arvinxx/commitlint-config-gitmoji/compare/commitlint-plugin-gitmoji@2.1.0...commitlint-plugin-gitmoji@2.1.1) (2021-05-02) 87 | 88 | ### 🐛 Bug Fixes 89 | 90 | - fix error message reference url ([351f081](https://github.com/arvinxx/commitlint-config-gitmoji/commit/351f081)) 91 | 92 | # commitlint-plugin-gitmoji [2.1.0](https://github.com/arvinxx/commitlint-config-gitmoji/compare/commitlint-plugin-gitmoji@2.0.6...commitlint-plugin-gitmoji@2.1.0) (2021-03-06) 93 | 94 | ### ✨ Features 95 | 96 | - support gitmoji unicode ([6f418a7](https://github.com/arvinxx/commitlint-config-gitmoji/commit/6f418a7)) 97 | 98 | ## commitlint-plugin-gitmoji [2.0.6](https://github.com/arvinxx/commitlint-config-gitmoji/compare/commitlint-plugin-gitmoji@2.0.5...commitlint-plugin-gitmoji@2.0.6) (2021-01-28) 99 | 100 | ### 🐛 Bug Fixes | 修复 101 | 102 | - **package**: clean unused files in package ([6805b75](https://github.com/arvinxx/commitlint-config-gitmoji/commit/6805b75)) 103 | 104 | ## commitlint-plugin-gitmoji [2.0.5](https://github.com/arvinxx/commitlint-config-gitmoji/compare/commitlint-plugin-gitmoji@2.0.4...commitlint-plugin-gitmoji@2.0.5) (2021-01-28) 105 | 106 | ### 🐛 Bug Fixes | 修复 107 | 108 | - **plugin**: throw better fetch failed msg ([c74a1ff](https://github.com/arvinxx/commitlint-config-gitmoji/commit/c74a1ff)), closes [#12](https://github.com/arvinxx/commitlint-config-gitmoji/issues/12) 109 | -------------------------------------------------------------------------------- /packages/commitlint-plugin/README.md: -------------------------------------------------------------------------------- 1 | # commitlint-plugin-gitmoji 2 | 3 | [![NPM version][version-image]][version-url] [![NPM downloads][download-image]][download-url] 4 | 5 | a commitlint plugin to add gitmoji check rule 6 | 7 | ## License 8 | 9 | [MIT](../../LICENSE) ® Arvin Xu 10 | 11 | 12 | 13 | [version-image]: http://img.shields.io/npm/v/commitlint-plugin-gitmoji.svg?color=deepgreen&label=latest 14 | [version-url]: http://npmjs.org/package/commitlint-plugin-gitmoji 15 | [download-image]: https://img.shields.io/npm/dm/commitlint-plugin-gitmoji.svg 16 | [download-url]: https://npmjs.org/package/commitlint-plugin-gitmoji 17 | -------------------------------------------------------------------------------- /packages/commitlint-plugin/jest.config.ts: -------------------------------------------------------------------------------- 1 | import base from '../../jest.config.base'; 2 | import { Config } from '@umijs/test'; 3 | 4 | const packageName = 'commitlint-plugin-gitmoji'; 5 | 6 | const root = '/packages/commitlint-plugin'; 7 | 8 | const config: Config.InitialOptions = { 9 | ...base, 10 | rootDir: '../..', 11 | roots: [root], 12 | displayName: packageName, 13 | }; 14 | 15 | export default config; 16 | -------------------------------------------------------------------------------- /packages/commitlint-plugin/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "commitlint-plugin-gitmoji", 3 | "version": "2.2.6", 4 | "description": "shareable commitlint plugin enforcing gitmoji commit rules", 5 | "keywords": [ 6 | "commitlint", 7 | "commitlint-plugin", 8 | "gitmoji", 9 | "emoji", 10 | "git" 11 | ], 12 | "homepage": "https://github.com/arvinxx/gitmoji-commit-workflow/tree/master/packages/commitlint-plugin", 13 | "repository": { 14 | "type": "git", 15 | "url": "https://github.com/arvinxx/gitmoji-commit-workflow.git" 16 | }, 17 | "license": "MIT", 18 | "author": "ArvinX", 19 | "main": "lib/index.js", 20 | "files": [ 21 | "lib" 22 | ], 23 | "scripts": { 24 | "build": "father build", 25 | "changelog": "conventional-changelog -p gitmoji-config -i CHANGELOG.md -s -r 0", 26 | "clean": "rm -rf es lib dist build coverage src/.umi* .eslintcache", 27 | "cov": "jest --coverage", 28 | "doctor": "father doctor", 29 | "prepublishOnly": "npm run doctor && npm run build", 30 | "release": "yarn build && yarn release:only", 31 | "release:only": "yarn publish", 32 | "start": "father dev", 33 | "test": "jest" 34 | }, 35 | "dependencies": { 36 | "@commitlint/types": "^17", 37 | "@gitmoji/gitmoji-regex": "1.0.0", 38 | "gitmojis": "^3" 39 | }, 40 | "publishConfig": { 41 | "access": "public", 42 | "registry": "https://registry.npmjs.org/" 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /packages/commitlint-plugin/src/gitmojiCode.ts: -------------------------------------------------------------------------------- 1 | import { gitmojis } from 'gitmojis'; 2 | 3 | export const gitmojiCodes: string[] = gitmojis.map((gitmoji) => gitmoji.code); 4 | 5 | export const gitmojiUnicode: string[] = gitmojis.map((gitmoji) => gitmoji.emoji); 6 | -------------------------------------------------------------------------------- /packages/commitlint-plugin/src/index.ts: -------------------------------------------------------------------------------- 1 | import type { Plugin } from '@commitlint/types'; 2 | import emojiRule from './rule'; 3 | 4 | const plugin: Plugin = { 5 | rules: { 6 | 'start-with-gitmoji': emojiRule, 7 | }, 8 | }; 9 | 10 | export default plugin; 11 | -------------------------------------------------------------------------------- /packages/commitlint-plugin/src/rule.ts: -------------------------------------------------------------------------------- 1 | import type { Rule } from '@commitlint/types'; 2 | import { emojiRegex, gitmojiUnicodeRegex, gitmojiCodeRegex } from '@gitmoji/gitmoji-regex'; 3 | 4 | import { gitmojiCodes, gitmojiUnicode } from './gitmojiCode'; 5 | 6 | const emoji: Rule = (parsed) => { 7 | const { raw } = parsed; 8 | 9 | // code regex test url: https://regex101.com/r/fSdOvB/1 10 | const gitmojiCodeResult = new RegExp(`(${gitmojiCodeRegex.source})\\s.*`, 'gm').exec(raw); 11 | // unicode regex test url: https://regex101.com/r/shBTBg/2 12 | const gitmojiUnicodeResult = new RegExp(`(${gitmojiUnicodeRegex.source})\\s.*`, 'gm').exec(raw); 13 | const emojiResult = new RegExp(`(${emojiRegex.source})\\s.*`, 'gm').exec(raw); 14 | 15 | let pass; 16 | let errorMsg = 'passed'; 17 | 18 | // if gitmoji code is valid 19 | if (gitmojiCodeResult) { 20 | const emojiCode = gitmojiCodeResult[1]; 21 | pass = gitmojiCodes.includes(emojiCode); 22 | if (!pass) { 23 | errorMsg = `${emojiCode} is not in the correct gitmoji list, please check the emoji code on https://gitmoji.dev/.`; 24 | } 25 | } 26 | // if gitmoji unicode is valid 27 | else if (gitmojiUnicodeResult) { 28 | const unicode = gitmojiUnicodeResult[1]; 29 | 30 | pass = gitmojiUnicode.includes(unicode); 31 | } 32 | // is emoji,but isn't included in gitmoji list 33 | else if (emojiResult) { 34 | const unicode = emojiResult[1]; 35 | 36 | pass = false; 37 | errorMsg = `${unicode} is not in the correct gitmoji list, please check the emoji code on https://gitmoji.dev/.`; 38 | } else { 39 | // if don't has gitmoji code or emoji unicode 40 | pass = false; 41 | errorMsg = 42 | 'Your commit should start with gitmoji code. Please check the emoji code on https://gitmoji.dev/.'; 43 | } 44 | 45 | return [pass, errorMsg]; 46 | }; 47 | 48 | export default emoji; 49 | -------------------------------------------------------------------------------- /packages/commitlint-plugin/test/gitmojiCode.test.ts: -------------------------------------------------------------------------------- 1 | describe('gitmojiCodes work well', () => { 2 | it('just return result', async () => { 3 | 4 | const gitmojiCodes = require('../lib/gitmojiCode'); 5 | 6 | expect(gitmojiCodes.gitmojiCodes).toBeInstanceOf(Array); 7 | }); 8 | }); 9 | -------------------------------------------------------------------------------- /packages/commitlint-plugin/test/rule.test.ts: -------------------------------------------------------------------------------- 1 | import type { Commit, RuleConfigCondition } from '@commitlint/types'; 2 | import { gitmojis } from 'gitmojis'; 3 | 4 | import emojiRule from '../src/rule'; 5 | 6 | const when: RuleConfigCondition = 'always'; 7 | 8 | test('should return error message if commit start without gitmoji code', () => { 9 | const value = emojiRule({ raw: 'chore(scope): test' } as Commit, when); 10 | 11 | expect(value).toEqual([ 12 | false, 13 | 'Your commit should start with gitmoji code. Please check the emoji code on https://gitmoji.dev/.', 14 | ]); 15 | }); 16 | 17 | describe('commit start with gitmoji code', () => { 18 | it('should return wrong gitmoji code error message if commit start with wrong gitmoji', () => { 19 | const value = emojiRule({ raw: ':st: chore(scope): test' } as Commit, when); 20 | expect(value).toEqual([ 21 | false, 22 | ':st: is not in the correct gitmoji list, please check the emoji code on https://gitmoji.dev/.', 23 | ]); 24 | }); 25 | 26 | it('🤔 should failed if commit start with unrecognized gitmoji unicode', () => { 27 | const value = emojiRule({ raw: '🤔 chore(scope): test' } as Commit, when); 28 | expect(value).toEqual([ 29 | false, 30 | '🤔 is not in the correct gitmoji list, please check the emoji code on https://gitmoji.dev/.', 31 | ]); 32 | }); 33 | 34 | it('🌙 should failed if commit start with wrong gitmoji unicode', () => { 35 | const value = emojiRule({ raw: '🌙 chore(scope): test' } as Commit, when); 36 | expect(value).toEqual([ 37 | false, 38 | '🌙 is not in the correct gitmoji list, please check the emoji code on https://gitmoji.dev/.', 39 | ]); 40 | }); 41 | 42 | it('should pass when return correct commit message code', () => { 43 | const value = emojiRule({ raw: ':tada: test' } as Commit, when); 44 | expect(value).toEqual([true, 'passed']); 45 | }); 46 | 47 | it(':construction_worker: should pass', () => { 48 | const value = emojiRule({ raw: ':construction_worker: test' } as Commit, when); 49 | expect(value).toEqual([true, 'passed']); 50 | }); 51 | 52 | it('🎉 should pass', () => { 53 | const value = emojiRule({ raw: '🎉 test' } as Commit, when); 54 | expect(value).toEqual([true, 'passed']); 55 | }); 56 | 57 | it('✅ should pass', () => { 58 | const value = emojiRule({ raw: '✅ test' } as Commit, when); 59 | expect(value).toEqual([true, 'passed']); 60 | }); 61 | 62 | it('💄 should pass', () => { 63 | const value = emojiRule({ raw: '💄 test' } as Commit, when); 64 | expect(value).toEqual([true, 'passed']); 65 | }); 66 | 67 | it('⚡️should pass', () => { 68 | const value = emojiRule({ raw: '⚡️ test' } as Commit, when); 69 | expect(value).toEqual([true, 'passed']); 70 | }); 71 | 72 | it('every emoji in gitmoji list should pass', () => { 73 | const gitmojiUnicode: string[] = gitmojis.map((gitmoji) => gitmoji.emoji); 74 | 75 | gitmojiUnicode.forEach((unicode) => { 76 | const value = emojiRule({ raw: `${unicode} test` } as Commit, when); 77 | console.log(`testing ${unicode}...`); 78 | expect(value).toEqual([true, 'passed']); 79 | }); 80 | }); 81 | }); 82 | -------------------------------------------------------------------------------- /packages/commitlint-plugin/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "include": ["src"], 3 | "exclude": ["src/gitmojis.json"], 4 | "compilerOptions": { 5 | "module": "CommonJS", 6 | "target": "es5", 7 | "sourceMap": true, 8 | "moduleResolution": "Node", 9 | "lib": ["ES2020"], 10 | "declaration": true, 11 | "esModuleInterop": true 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /packages/gitmoji-regex/.changelogrc.js: -------------------------------------------------------------------------------- 1 | const base = require('../../.changelogrc'); 2 | 3 | module.exports = { 4 | ...base, 5 | displayScopes: ['gitmoji-regex'], 6 | }; 7 | -------------------------------------------------------------------------------- /packages/gitmoji-regex/.fatherrc.ts: -------------------------------------------------------------------------------- 1 | import config from '../../.fatherrc'; 2 | 3 | export default config; 4 | -------------------------------------------------------------------------------- /packages/gitmoji-regex/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | # @gitmoji/gitmoji-regex 1.0.0 (2023-02-11) 4 | 5 | # @gitmoji/gitmoji-regex 1.0.0-beta.1 (2023-02-11) 6 | -------------------------------------------------------------------------------- /packages/gitmoji-regex/README.md: -------------------------------------------------------------------------------- 1 | # @gitmoji/gitmoji-regex 2 | 3 | [![NPM version][version-image]][version-url] [![NPM downloads][download-image]][download-url] 4 | 5 | a gitmoji regex to for both gitmoji code and gitmoji unicode 6 | 7 | this package is used in both [@gitmoji/parser-opts](../parser-opts) and [commitlint-plugin-gitmoji](../commitlint-plugin) 8 | 9 | ## emojiRegex 10 | 11 | ## gitmojiCodeRegex 12 | 13 | ## gitmojiUnicodeRegex 14 | 15 | Header regex pattern test here : [Regex101](https://regex101.com/r/gYkG99/1) 16 | 17 | ```js 18 | module.exports = { 19 | headerPattern: 20 | /^(?::\w*:|(?:\ud83c[\udf00-\udfff])|(?:\ud83d[\udc00-\ude4f\ude80-\udeff])|[\u2600-\u2B55])\s(?\w*)(?:\((?.*)\))?!?:\s(?(?:(?!#).)*(?:(?!\s).))(?:\s\(?(?#\d*)\)?)?$/, 21 | headerCorrespondence: ['type', 'scope', 'subject', 'ticket'], 22 | }; 23 | ``` 24 | 25 | ## License 26 | 27 | [MIT](../../LICENSE) ® Arvin Xu 28 | 29 | 30 | 31 | [version-image]: http://img.shields.io/npm/v/@gitmoji/gitmoji-regex.svg?color=deepgreen&label=latest 32 | [version-url]: http://npmjs.org/package/@gitmoji/gitmoji-regex 33 | [download-image]: https://img.shields.io/npm/dm/@gitmoji/gitmoji-regex.svg 34 | [download-url]: https://npmjs.org/package/@gitmoji/gitmoji-regex 35 | -------------------------------------------------------------------------------- /packages/gitmoji-regex/jest.config.ts: -------------------------------------------------------------------------------- 1 | import base from '../../jest.config.base'; 2 | import { Config } from '@umijs/test'; 3 | 4 | const packageName = '@gitmoji/gitmoji-regex'; 5 | 6 | const root = '/packages/gitmoji-regex'; 7 | 8 | const config: Config.InitialOptions = { 9 | ...base, 10 | rootDir: '../..', 11 | roots: [root], 12 | displayName: packageName, 13 | }; 14 | 15 | export default config; 16 | -------------------------------------------------------------------------------- /packages/gitmoji-regex/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@gitmoji/gitmoji-regex", 3 | "version": "1.0.0", 4 | "description": "a gitmoji regex to for both gitmoji code and gitmoji unicode", 5 | "homepage": "https://github.com/arvinxx/gitmoji-commit-workflow/tree/master/packages/gitmoji-regex", 6 | "bugs": { 7 | "url": "https://github.com/arvinxx/gitmoji-commit-workflow/issues" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "https://github.com/arvinxx/gitmoji-commit-workflow.git" 12 | }, 13 | "license": "ISC", 14 | "author": "arvinxx ", 15 | "main": "lib/index.js", 16 | "files": [ 17 | "lib" 18 | ], 19 | "scripts": { 20 | "build": "father build", 21 | "clean": "rm -rf es lib dist build coverage .eslintcache", 22 | "cov": "jest --coverage", 23 | "doctor": "father doctor", 24 | "prepublishOnly": "npm run doctor && npm run build", 25 | "test": "jest" 26 | }, 27 | "dependencies": { 28 | "emoji-regex": "^10", 29 | "gitmojis": "^3" 30 | }, 31 | "publishConfig": { 32 | "access": "public", 33 | "registry": "https://registry.npmjs.org/" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /packages/gitmoji-regex/src/index.ts: -------------------------------------------------------------------------------- 1 | import { gitmojis } from 'gitmojis'; 2 | import _emojiRegex from 'emoji-regex'; 3 | 4 | const gitmojiUnicode: string[] = gitmojis.map((gitmoji) => gitmoji.emoji); 5 | 6 | export const gitmojiCodeRegex = new RegExp(/:\w*:/); 7 | 8 | export const gitmojiUnicodeRegex = new RegExp(gitmojiUnicode.filter((i) => i).join('|')); 9 | 10 | export const emojiRegex = _emojiRegex(); 11 | -------------------------------------------------------------------------------- /packages/gitmoji-regex/tests/index.test.ts: -------------------------------------------------------------------------------- 1 | import { gitmojiUnicodeRegex } from '@gitmoji/gitmoji-regex'; 2 | import { gitmojis } from 'gitmojis'; 3 | 4 | it('every emoji in gitmoji list pass', () => { 5 | const gitmojiUnicode: string[] = gitmojis.map((gitmoji) => gitmoji.emoji); 6 | 7 | gitmojiUnicode.forEach((unicode) => { 8 | expect(gitmojiUnicodeRegex.test(unicode)).toBeTruthy(); 9 | }); 10 | }); 11 | -------------------------------------------------------------------------------- /packages/gitmoji-regex/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "module": "CommonJS", 5 | "target": "es5", 6 | "sourceMap": true, 7 | "moduleResolution": "Node", 8 | "lib": ["ES2020"], 9 | "esModuleInterop": true, 10 | "declaration": true, 11 | "baseUrl": ".", 12 | "paths": { 13 | "@gitmoji/gitmoji-regex": ["./src"] 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /packages/parser-opts/.changelogrc.js: -------------------------------------------------------------------------------- 1 | const base = require('../../.changelogrc'); 2 | 3 | module.exports = { 4 | ...base, 5 | displayScopes: ['parser-opts'], 6 | }; 7 | -------------------------------------------------------------------------------- /packages/parser-opts/.fatherrc.ts: -------------------------------------------------------------------------------- 1 | import config from '../../.fatherrc'; 2 | 3 | export default config; 4 | -------------------------------------------------------------------------------- /packages/parser-opts/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | # @gitmoji/parser-opts [1.4.0](https://github.com/arvinxx/gitmoji-commit-workflow/compare/@gitmoji/parser-opts@1.3.1...@gitmoji/parser-opts@1.4.0) (2023-02-11) 4 | 5 | ### ✨ Features 6 | 7 | - **parser-opts**: support UCS-4 unicode ([bc09794](https://github.com/arvinxx/gitmoji-commit-workflow/commit/bc09794)) 8 | - support UCS-4 emoji unicode ([006d8e4](https://github.com/arvinxx/gitmoji-commit-workflow/commit/006d8e4)) 9 | 10 | # @gitmoji/parser-opts [1.4.0-beta.2](https://github.com/arvinxx/gitmoji-commit-workflow/compare/@gitmoji/parser-opts@1.4.0-beta.1...@gitmoji/parser-opts@1.4.0-beta.2) (2023-02-11) 11 | 12 | ### ✨ Features 13 | 14 | - support UCS-4 emoji unicode ([006d8e4](https://github.com/arvinxx/gitmoji-commit-workflow/commit/006d8e4)) 15 | 16 | # @gitmoji/parser-opts [1.4.0-beta.1](https://github.com/arvinxx/gitmoji-commit-workflow/compare/@gitmoji/parser-opts@1.3.1...@gitmoji/parser-opts@1.4.0-beta.1) (2023-02-11) 17 | 18 | ### ✨ Features 19 | 20 | - **parser-opts**: support UCS-4 unicode ([bc09794](https://github.com/arvinxx/gitmoji-commit-workflow/commit/bc09794)) 21 | 22 | ## @gitmoji/parser-opts [1.3.1](https://github.com/arvinxx/gitmoji-commit-workflow/compare/@gitmoji/parser-opts@1.3.0...@gitmoji/parser-opts@1.3.1) (2022-10-09) 23 | 24 | ### 🐛 Bug Fixes 25 | 26 | - allow parenthesis around ticket number ([3393666](https://github.com/arvinxx/gitmoji-commit-workflow/commit/3393666)) 27 | 28 | ## @gitmoji/parser-opts [1.3.1-beta.1](https://github.com/arvinxx/gitmoji-commit-workflow/compare/@gitmoji/parser-opts@1.3.0...@gitmoji/parser-opts@1.3.1-beta.1) (2022-10-09) 29 | 30 | ### 🐛 Bug Fixes 31 | 32 | - allow parenthesis around ticket number ([3393666](https://github.com/arvinxx/gitmoji-commit-workflow/commit/3393666)) 33 | 34 | # @gitmoji/parser-opts [1.3.0](https://github.com/arvinxx/gitmoji-commit-workflow/compare/@gitmoji/parser-opts@1.2.6...@gitmoji/parser-opts@1.3.0) (2021-03-06) 35 | 36 | ### ✨ Features 37 | 38 | - support unicode parsing ([0d5eece](https://github.com/arvinxx/gitmoji-commit-workflow/commit/0d5eece)), closes [#13](https://github.com/arvinxx/gitmoji-commit-workflow/issues/13) 39 | 40 | ## @gitmoji/parser-opts [1.2.6](https://github.com/arvinxx/gitmoji-commit-workflow/compare/@gitmoji/parser-opts@1.2.5...@gitmoji/parser-opts@1.2.6) (2021-02-26) 41 | 42 | ### 🐛 Bug Fixes 43 | 44 | - fix parser success without gitmoji ([780064f](https://github.com/arvinxx/gitmoji-commit-workflow/commit/780064f)) 45 | 46 | ## @gitmoji/parser-opts [1.2.5](https://github.com/arvinxx/gitmoji-commit-workflow/compare/@gitmoji/parser-opts@1.2.4...@gitmoji/parser-opts@1.2.5) (2021-01-25) 47 | 48 | ### 🐛 Bug Fixes | 修复 49 | 50 | - **(@gitmoji/parser-opts)**: fix package description ([a4678ad](https://github.com/arvinxx/gitmoji-commit-workflow/commit/a4678ad)) 51 | - **(@gitmoji/parser-opts)**: fix package description ([81518c7](https://github.com/arvinxx/gitmoji-commit-workflow/commit/81518c7)) 52 | - **(Other)**: clean changelog ([8479426](https://github.com/arvinxx/gitmoji-commit-workflow/commit/8479426)) 53 | - **(Other)**: link deps ([e4526ed](https://github.com/arvinxx/gitmoji-commit-workflow/commit/e4526ed)) 54 | 55 | # [@gitmoji/parser-opts-v1.2.5](https://github.com/arvinxx/gitmoji-commit-workflow/compare/@gitmoji/parser-opts-v1.2.4...@gitmoji/parser-opts-v1.2.5) (2021-01-25) 56 | 57 | ### 🐛 Bug Fixes | 修复 58 | 59 | - **(@gitmoji/parser-opts)**: fix package description ([81518c7](https://github.com/arvinxx/gitmoji-commit-workflow/commit/81518c7)) 60 | 61 | # [@gitmoji/parser-opts-v1.2.4](https://github.com/arvinxx/gitmoji-commit-workflow/compare/@gitmoji/parser-opts-v1.2.3...@gitmoji/parser-opts-v1.2.4) (2021-01-25) 62 | -------------------------------------------------------------------------------- /packages/parser-opts/README.md: -------------------------------------------------------------------------------- 1 | # @gitmoji/parser-opts 2 | 3 | [![NPM version][version-image]][version-url] [![NPM downloads][download-image]][download-url] 4 | 5 | a shareable parser options for gitmoji styles commit 6 | 7 | this package is used in both [conventional-changelog-gitmoji-config](../changelog) and [commitlint-config-gitmoji](../commitlint-config) 8 | 9 | ## License 10 | 11 | [MIT](../../LICENSE) ® Arvin Xu 12 | 13 | 14 | 15 | [version-image]: http://img.shields.io/npm/v/@gitmoji/parser-opts.svg?color=deepgreen&label=latest 16 | [version-url]: http://npmjs.org/package/@gitmoji/parser-opts 17 | [download-image]: https://img.shields.io/npm/dm/@gitmoji/parser-opts.svg 18 | [download-url]: https://npmjs.org/package/@gitmoji/parser-opts 19 | -------------------------------------------------------------------------------- /packages/parser-opts/jest.config.ts: -------------------------------------------------------------------------------- 1 | import base from '../../jest.config.base'; 2 | import { Config } from '@umijs/test'; 3 | 4 | const packageName = '@gitmoji/parser-opts'; 5 | 6 | const root = '/packages/parser-opts'; 7 | 8 | const config: Config.InitialOptions = { 9 | ...base, 10 | rootDir: '../..', 11 | roots: [root], 12 | displayName: packageName, 13 | }; 14 | 15 | export default config; 16 | -------------------------------------------------------------------------------- /packages/parser-opts/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@gitmoji/parser-opts", 3 | "version": "1.4.0", 4 | "description": "gitmoji styles commit parser options", 5 | "homepage": "https://github.com/arvinxx/gitmoji-commit-workflow/tree/master/packages/parser-opts", 6 | "bugs": { 7 | "url": "https://github.com/arvinxx/gitmoji-commit-workflow/issues" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "https://github.com/arvinxx/gitmoji-commit-workflow.git" 12 | }, 13 | "license": "ISC", 14 | "author": "arvinxx ", 15 | "main": "lib/index.js", 16 | "files": [ 17 | "lib" 18 | ], 19 | "scripts": { 20 | "build": "father build", 21 | "clean": "rm -rf es lib dist build coverage src/.umi* .eslintcache", 22 | "cov": "jest --coverage", 23 | "doctor": "father doctor", 24 | "prepublishOnly": "npm run doctor && npm run build", 25 | "test": "jest" 26 | }, 27 | "dependencies": { 28 | "@gitmoji/gitmoji-regex": "1.0.0" 29 | }, 30 | "publishConfig": { 31 | "access": "public", 32 | "registry": "https://registry.npmjs.org/" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /packages/parser-opts/src/index.ts: -------------------------------------------------------------------------------- 1 | import { gitmojiCodeRegex, gitmojiUnicodeRegex, emojiRegex } from '@gitmoji/gitmoji-regex'; 2 | 3 | const gitmojiCodeStr = gitmojiCodeRegex.source; 4 | const gitmojiUnicodeStr = gitmojiUnicodeRegex.source; 5 | const emojiStr = emojiRegex.source; 6 | 7 | export default { 8 | // Test URL: https://regex101.com/r/gYkG99/1 9 | headerPattern: new RegExp( 10 | `^(?:${gitmojiCodeStr}|(?:${gitmojiUnicodeStr})|(?:${emojiStr}))\\s(?\\w*)(?:\\((?.*)\\))?!?:\\s(?(?:(?!#).)*(?:(?!\\s).))(?:\\s\\(?(?#\\d*)\\)?)?$`, 11 | ), 12 | 13 | headerCorrespondence: ['type', 'scope', 'subject', 'ticket'], 14 | }; 15 | -------------------------------------------------------------------------------- /packages/parser-opts/tests/index.test.ts: -------------------------------------------------------------------------------- 1 | import parserOpts from '@gitmoji/parser-opts'; 2 | 3 | const { headerPattern: regex } = parserOpts; 4 | describe('@gitmoji/parser-opts', () => { 5 | describe('invalid', () => { 6 | it('hello :test: test', () => { 7 | const result = regex.exec('hello :test: test'); 8 | expect(result).toBeNull(); 9 | }); 10 | 11 | it('chore(scope): test', () => { 12 | const result = regex.exec('hello :test: test'); 13 | expect(result).toBeNull(); 14 | }); 15 | 16 | it(':start:test: test', () => { 17 | const result = regex.exec(':start:test: test'); 18 | expect(result).toBeNull(); 19 | }); 20 | }); 21 | 22 | describe('valid', () => { 23 | it(':hello: test: test', () => { 24 | const result = regex.exec(':hello: test: test'); 25 | 26 | expect(result).toHaveLength(5); 27 | const { type, scope, subject, ticket } = result.groups; 28 | expect(type).toBe('test'); 29 | expect(scope).toBeUndefined(); 30 | expect(subject).toBe('test'); 31 | expect(ticket).toBeUndefined(); 32 | }); 33 | it(':start: chore(scope): test', () => { 34 | const result = regex.exec(':start: chore(scope): test'); 35 | 36 | expect(result).toHaveLength(5); 37 | const { type, scope, subject, ticket } = result.groups; 38 | expect(type).toBe('chore'); 39 | expect(scope).toBe('scope'); 40 | expect(subject).toBe('test'); 41 | expect(ticket).toBeUndefined(); 42 | }); 43 | it(':start: chore(scope): test #123', () => { 44 | const result = regex.exec(':start: chore(scope): test #123'); 45 | 46 | expect(result).toHaveLength(5); 47 | const { type, scope, subject, ticket } = result.groups; 48 | expect(type).toBe('chore'); 49 | expect(scope).toBe('scope'); 50 | expect(subject).toBe('test'); 51 | expect(ticket).toBe('#123'); 52 | }); 53 | it(':memo: docs: update README.md', () => { 54 | const result = regex.exec(':memo: docs: update README.md'); 55 | 56 | expect(result).toHaveLength(5); 57 | const { type, scope, subject, ticket } = result.groups; 58 | expect(type).toBe('docs'); 59 | expect(scope).toBeUndefined(); 60 | expect(subject).toBe('update README.md'); 61 | expect(ticket).toBeUndefined(); 62 | }); 63 | it(':start: chore(scope): i have a word #123', () => { 64 | const result = regex.exec(':start: chore(scope): i have a word #123'); 65 | 66 | expect(result).toHaveLength(5); 67 | const { type, scope, subject, ticket } = result.groups; 68 | expect(type).toBe('chore'); 69 | expect(scope).toBe('scope'); 70 | expect(subject).toBe('i have a word'); 71 | expect(ticket).toBe('#123'); 72 | }); 73 | it(':start: chore(scope): i have a ticket (#123)', () => { 74 | const result = regex.exec(':start: chore(scope): i have a ticket (#123)'); 75 | 76 | expect(result).toHaveLength(5); 77 | const { type, scope, subject, ticket } = result.groups; 78 | expect(type).toBe('chore'); 79 | expect(scope).toBe('scope'); 80 | expect(subject).toBe('i have a ticket'); 81 | expect(ticket).toBe('#123'); 82 | }); 83 | it(':package: feat(parser-opts): extract parser-opts packages', () => { 84 | const result = regex.exec(':package: feat(parser-opts): extract parser-opts packages'); 85 | 86 | expect(result).toHaveLength(5); 87 | const { type, scope, subject, ticket } = result.groups; 88 | expect(type).toBe('feat'); 89 | expect(scope).toBe('parser-opts'); 90 | expect(subject).toBe('extract parser-opts packages'); 91 | expect(ticket).toBeUndefined(); 92 | }); 93 | 94 | it(':sparkles: feat(changelog): 添加中文标题', () => { 95 | const result = regex.exec(':sparkles: feat(changelog): 添加中文标题'); 96 | 97 | expect(result).toHaveLength(5); 98 | const { type, scope, subject, ticket } = result.groups; 99 | expect(type).toBe('feat'); 100 | expect(scope).toBe('changelog'); 101 | expect(subject).toBe('添加中文标题'); 102 | expect(ticket).toBeUndefined(); 103 | }); 104 | 105 | it('💥 feat(unicode): support unicode', () => { 106 | const result = regex.exec('💥 feat(unicode): support unicode'); 107 | 108 | expect(result).toHaveLength(5); 109 | const { type, scope, subject, ticket } = result.groups; 110 | expect(type).toBe('feat'); 111 | expect(scope).toBe('unicode'); 112 | expect(subject).toBe('support unicode'); 113 | expect(ticket).toBeUndefined(); 114 | }); 115 | 116 | it('⚡️ feat(unicode): support UCS-4 unicode', () => { 117 | const result = regex.exec('⚡️ feat(unicode): support UCS-4 unicode'); 118 | 119 | expect(result).toHaveLength(5); 120 | const { type, scope, subject, ticket } = result.groups; 121 | expect(type).toBe('feat'); 122 | expect(scope).toBe('unicode'); 123 | expect(subject).toBe('support UCS-4 unicode'); 124 | expect(ticket).toBeUndefined(); 125 | }); 126 | 127 | it('😂 test: test', () => { 128 | const result = regex.exec('😂 feat(emoji): get emoji'); 129 | 130 | expect(result).toHaveLength(5); 131 | const { type, scope, subject, ticket } = result.groups; 132 | expect(type).toBe('feat'); 133 | expect(scope).toBe('emoji'); 134 | expect(subject).toBe('get emoji'); 135 | expect(ticket).toBeUndefined(); 136 | }); 137 | }); 138 | }); 139 | -------------------------------------------------------------------------------- /packages/parser-opts/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "module": "CommonJS", 5 | "target": "es5", 6 | "sourceMap": true, 7 | "moduleResolution": "Node", 8 | "lib": ["ES2020"], 9 | "esModuleInterop": true, 10 | "declaration": true 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /packages/release-config/.changelogrc.js: -------------------------------------------------------------------------------- 1 | const base = require('../../.changelogrc'); 2 | 3 | module.exports = { 4 | ...base, 5 | }; 6 | -------------------------------------------------------------------------------- /packages/release-config/.fatherrc.ts: -------------------------------------------------------------------------------- 1 | import config from '../../.fatherrc'; 2 | 3 | export default config; 4 | -------------------------------------------------------------------------------- /packages/release-config/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ### [Version 1.5.3](https://github.com/arvinxx/gitmoji-commit-workflow/compare/semantic-release-config-gitmoji@1.5.2...semantic-release-config-gitmoji@1.5.3) 4 | 5 | Released on **2023-06-12** 6 | 7 |
8 | 9 |
10 | Improvements and Fixes 11 | 12 |
13 | 14 |
15 | 16 | [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top) 17 | 18 |
19 | 20 | ### Dependencies 21 | 22 | - **conventional-changelog-gitmoji-config:** upgraded to 1.5.2 23 | 24 | ## [Version 1.5.2](https://github.com/arvinxx/gitmoji-commit-workflow/compare/semantic-release-config-gitmoji@1.5.1...semantic-release-config-gitmoji@1.5.2) 25 | 26 | Released on **2023-06-10** 27 | 28 |
29 | 30 |
31 | Improvements and Fixes 32 | 33 |
34 | 35 |
36 | 37 | [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top) 38 | 39 |
40 | 41 | ### Dependencies 42 | 43 | - **conventional-changelog-gitmoji-config:** upgraded to 1.5.1 44 | 45 | ## semantic-release-config-gitmoji [1.5.1](https://github.com/arvinxx/gitmoji-commit-workflow/compare/semantic-release-config-gitmoji@1.5.0...semantic-release-config-gitmoji@1.5.1) (2023-06-10) 46 | 47 | ### Dependencies 48 | 49 | - **conventional-changelog-gitmoji-config:** upgraded to 1.5.0 50 | 51 | # semantic-release-config-gitmoji [1.5.0](https://github.com/arvinxx/gitmoji-commit-workflow/compare/semantic-release-config-gitmoji@1.4.3...semantic-release-config-gitmoji@1.5.0) (2023-05-21) 52 | 53 | ### ✨ Features 54 | 55 | - support release on main branch ([e97fb35](https://github.com/arvinxx/gitmoji-commit-workflow/commit/e97fb35)) 56 | - support release on main branch ([163ea4b](https://github.com/arvinxx/gitmoji-commit-workflow/commit/163ea4b)) 57 | 58 | ## semantic-release-config-gitmoji [1.4.3](https://github.com/arvinxx/gitmoji-commit-workflow/compare/semantic-release-config-gitmoji@1.4.2...semantic-release-config-gitmoji@1.4.3) (2023-02-15) 59 | 60 | ### Dependencies 61 | 62 | - **conventional-changelog-gitmoji-config:** upgraded to 1.4.7 63 | 64 | ## semantic-release-config-gitmoji [1.4.2](https://github.com/arvinxx/gitmoji-commit-workflow/compare/semantic-release-config-gitmoji@1.4.1...semantic-release-config-gitmoji@1.4.2) (2023-02-11) 65 | 66 | ### 🐛 Bug Fixes 67 | 68 | - **release-config**: fix beta release config ([a330517](https://github.com/arvinxx/gitmoji-commit-workflow/commit/a330517)) 69 | 70 | ### Dependencies 71 | 72 | - **conventional-changelog-gitmoji-config:** upgraded to 1.4.6 73 | 74 | ## semantic-release-config-gitmoji [1.4.2-beta.1](https://github.com/arvinxx/gitmoji-commit-workflow/compare/semantic-release-config-gitmoji@1.4.1...semantic-release-config-gitmoji@1.4.2-beta.1) (2023-02-11) 75 | 76 | ### 🐛 Bug Fixes 77 | 78 | - **release-config**: fix beta release config ([a330517](https://github.com/arvinxx/gitmoji-commit-workflow/commit/a330517)) 79 | 80 | ### Dependencies 81 | 82 | - **conventional-changelog-gitmoji-config:** upgraded to 1.4.5-beta.1 83 | 84 | ## semantic-release-config-gitmoji [1.4.1](https://github.com/arvinxx/gitmoji-commit-workflow/compare/semantic-release-config-gitmoji@1.4.0...semantic-release-config-gitmoji@1.4.1) (2023-01-06) 85 | 86 | ### 🐛 Bug Fixes 87 | 88 | - fix alpha release problem ([1af7ad0](https://github.com/arvinxx/gitmoji-commit-workflow/commit/1af7ad0)) 89 | 90 | # semantic-release-config-gitmoji [1.4.0](https://github.com/arvinxx/gitmoji-commit-workflow/compare/semantic-release-config-gitmoji@1.3.0...semantic-release-config-gitmoji@1.4.0) (2023-01-02) 91 | 92 | ### ✨ Features 93 | 94 | - add rc release config ([2201864](https://github.com/arvinxx/gitmoji-commit-workflow/commit/2201864)), closes [#661](https://github.com/arvinxx/gitmoji-commit-workflow/issues/661) 95 | 96 | # semantic-release-config-gitmoji [1.4.0-rc.3](https://github.com/arvinxx/gitmoji-commit-workflow/compare/semantic-release-config-gitmoji@1.4.0-rc.2...semantic-release-config-gitmoji@1.4.0-rc.3) (2023-01-02) 97 | 98 | # semantic-release-config-gitmoji [1.4.0-rc.2](https://github.com/arvinxx/gitmoji-commit-workflow/compare/semantic-release-config-gitmoji@1.4.0-rc.1...semantic-release-config-gitmoji@1.4.0-rc.2) (2023-01-02) 99 | 100 | # semantic-release-config-gitmoji [1.4.0-rc.1](https://github.com/arvinxx/gitmoji-commit-workflow/compare/semantic-release-config-gitmoji@1.3.0...semantic-release-config-gitmoji@1.4.0-rc.1) (2023-01-02) 101 | 102 | ### ✨ Features 103 | 104 | - add rc release config ([17403dd](https://github.com/arvinxx/gitmoji-commit-workflow/commit/17403dd)) 105 | - support rc prerelease ([2457ab3](https://github.com/arvinxx/gitmoji-commit-workflow/commit/2457ab3)) 106 | 107 | ### 🐛 Bug Fixes 108 | 109 | - try to fix release tag problem ([6da470a](https://github.com/arvinxx/gitmoji-commit-workflow/commit/6da470a)) 110 | 111 | # semantic-release-config-gitmoji [1.4.0-rc.1](https://github.com/arvinxx/gitmoji-commit-workflow/compare/semantic-release-config-gitmoji@1.3.0...semantic-release-config-gitmoji@1.4.0-rc.1) (2023-01-02) 112 | 113 | ### ✨ Features 114 | 115 | - support rc prerelease ([2457ab3](https://github.com/arvinxx/gitmoji-commit-workflow/commit/2457ab3)) 116 | 117 | ### 🐛 Bug Fixes 118 | 119 | - try to fix release tag problem ([6da470a](https://github.com/arvinxx/gitmoji-commit-workflow/commit/6da470a)) 120 | 121 | # semantic-release-config-gitmoji [1.4.0-rc.1](https://github.com/arvinxx/gitmoji-commit-workflow/compare/semantic-release-config-gitmoji@1.3.0...semantic-release-config-gitmoji@1.4.0-rc.1) (2023-01-02) 122 | 123 | ### ✨ Features 124 | 125 | - support rc prerelease ([2457ab3](https://github.com/arvinxx/gitmoji-commit-workflow/commit/2457ab3)) 126 | 127 | ### 🐛 Bug Fixes 128 | 129 | - try to fix release tag problem ([6da470a](https://github.com/arvinxx/gitmoji-commit-workflow/commit/6da470a)) 130 | 131 | # semantic-release-config-gitmoji [1.3.0](https://github.com/arvinxx/gitmoji-commit-workflow/compare/semantic-release-config-gitmoji@1.2.5...semantic-release-config-gitmoji@1.3.0) (2023-01-01) 132 | 133 | ### ✨ Features 134 | 135 | - add new monorepo params to work with monorepo ([6fdbc7f](https://github.com/arvinxx/gitmoji-commit-workflow/commit/6fdbc7f)) 136 | - add new monorepo params to work with monorepo ([0c6cd36](https://github.com/arvinxx/gitmoji-commit-workflow/commit/0c6cd36)) 137 | 138 | ### 🐛 Bug Fixes 139 | 140 | - fix github rate limit on release ([3ec8a63](https://github.com/arvinxx/gitmoji-commit-workflow/commit/3ec8a63)) 141 | 142 | # semantic-release-config-gitmoji [1.3.0-beta.2](https://github.com/arvinxx/gitmoji-commit-workflow/compare/semantic-release-config-gitmoji@1.3.0-beta.1...semantic-release-config-gitmoji@1.3.0-beta.2) (2023-01-01) 143 | 144 | ### 🐛 Bug Fixes 145 | 146 | - fix github rate limit on release ([3ec8a63](https://github.com/arvinxx/gitmoji-commit-workflow/commit/3ec8a63)) 147 | 148 | # semantic-release-config-gitmoji [1.3.0-beta.1](https://github.com/arvinxx/gitmoji-commit-workflow/compare/semantic-release-config-gitmoji@1.2.5...semantic-release-config-gitmoji@1.3.0-beta.1) (2023-01-01) 149 | 150 | ### ✨ Features 151 | 152 | - add new monorepo params to work with monorepo ([6fdbc7f](https://github.com/arvinxx/gitmoji-commit-workflow/commit/6fdbc7f)) 153 | - add new monorepo params to work with monorepo ([0c6cd36](https://github.com/arvinxx/gitmoji-commit-workflow/commit/0c6cd36)) 154 | 155 | ## semantic-release-config-gitmoji [1.2.5](https://github.com/arvinxx/gitmoji-commit-workflow/compare/semantic-release-config-gitmoji@1.2.4...semantic-release-config-gitmoji@1.2.5) (2022-10-09) 156 | 157 | ### Dependencies 158 | 159 | - **conventional-changelog-gitmoji-config:** upgraded to 1.4.4 160 | 161 | ## semantic-release-config-gitmoji [1.2.5-beta.1](https://github.com/arvinxx/gitmoji-commit-workflow/compare/semantic-release-config-gitmoji@1.2.4...semantic-release-config-gitmoji@1.2.5-beta.1) (2022-10-09) 162 | 163 | ### Dependencies 164 | 165 | - **conventional-changelog-gitmoji-config:** upgraded to 1.4.4-beta.1 166 | 167 | ## semantic-release-config-gitmoji [1.2.4](https://github.com/arvinxx/gitmoji-commit-workflow/compare/semantic-release-config-gitmoji@1.2.3...semantic-release-config-gitmoji@1.2.4) (2021-03-12) 168 | 169 | ### Dependencies 170 | 171 | - **conventional-changelog-gitmoji-config:** upgraded to 1.4.3 172 | 173 | ## semantic-release-config-gitmoji [1.2.3](https://github.com/arvinxx/gitmoji-commit-workflow/compare/semantic-release-config-gitmoji@1.2.2...semantic-release-config-gitmoji@1.2.3) (2021-03-12) 174 | 175 | ### 🐛 Bug Fixes 176 | 177 | - fix can't find default ([427298d](https://github.com/arvinxx/gitmoji-commit-workflow/commit/427298d)) 178 | 179 | ## semantic-release-config-gitmoji [1.2.2](https://github.com/arvinxx/gitmoji-commit-workflow/compare/semantic-release-config-gitmoji@1.2.1...semantic-release-config-gitmoji@1.2.2) (2021-03-12) 180 | 181 | ### 🐛 Bug Fixes 182 | 183 | - fix can't find createConfig ([8a01bff](https://github.com/arvinxx/gitmoji-commit-workflow/commit/8a01bff)) 184 | 185 | ## semantic-release-config-gitmoji [1.2.1](https://github.com/arvinxx/gitmoji-commit-workflow/compare/semantic-release-config-gitmoji@1.2.0...semantic-release-config-gitmoji@1.2.1) (2021-03-07) 186 | 187 | ### 🐛 Bug Fixes 188 | 189 | - 修正找不到 createConfig 模块的错误 ([bf451ca](https://github.com/arvinxx/gitmoji-commit-workflow/commit/bf451ca)) 190 | 191 | # semantic-release-config-gitmoji [1.2.0](https://github.com/arvinxx/gitmoji-commit-workflow/compare/semantic-release-config-gitmoji@1.1.0...semantic-release-config-gitmoji@1.2.0) (2021-03-07) 192 | 193 | ### ✨ Features 194 | 195 | - add github config ([3d540ca](https://github.com/arvinxx/gitmoji-commit-workflow/commit/3d540ca)) 196 | 197 | # semantic-release-config-gitmoji [1.1.0](https://github.com/arvinxx/gitmoji-commit-workflow/compare/semantic-release-config-gitmoji@1.0.1...semantic-release-config-gitmoji@1.1.0) (2021-03-06) 198 | 199 | ### ✨ Features 200 | 201 | - add npm config ([3d4c5d5](https://github.com/arvinxx/gitmoji-commit-workflow/commit/3d4c5d5)) 202 | - add npm config ([f15d677](https://github.com/arvinxx/gitmoji-commit-workflow/commit/f15d677)) 203 | 204 | ### 🐛 Bug Fixes 205 | 206 | - fix config export error ([2577aed](https://github.com/arvinxx/gitmoji-commit-workflow/commit/2577aed)) 207 | 208 | # semantic-release-config-gitmoji [1.1.0-beta.2](https://github.com/arvinxx/gitmoji-commit-workflow/compare/semantic-release-config-gitmoji@1.1.0-beta.1...semantic-release-config-gitmoji@1.1.0-beta.2) (2021-03-06) 209 | 210 | ### ✨ Features 211 | 212 | - add npm config ([3d4c5d5](https://github.com/arvinxx/gitmoji-commit-workflow/commit/3d4c5d5)) 213 | 214 | # semantic-release-config-gitmoji [1.1.0-beta.1](https://github.com/arvinxx/gitmoji-commit-workflow/compare/semantic-release-config-gitmoji@1.0.1...semantic-release-config-gitmoji@1.1.0-beta.1) (2021-03-06) 215 | 216 | ### ✨ Features 217 | 218 | - add npm config ([f15d677](https://github.com/arvinxx/gitmoji-commit-workflow/commit/f15d677)) 219 | 220 | ### 🐛 Bug Fixes 221 | 222 | - fix config export error ([2577aed](https://github.com/arvinxx/gitmoji-commit-workflow/commit/2577aed)) 223 | 224 | ## semantic-release-config-gitmoji [1.0.1](https://github.com/arvinxx/gitmoji-commit-workflow/compare/semantic-release-config-gitmoji@1.0.0...semantic-release-config-gitmoji@1.0.1) (2021-03-06) 225 | 226 | ### 🐛 Bug Fixes 227 | 228 | - add declaration ([c46d273](https://github.com/arvinxx/gitmoji-commit-workflow/commit/c46d273)) 229 | 230 | # semantic-release-config-gitmoji 1.0.0 (2021-03-06) 231 | 232 | ### ✨ Features 233 | 234 | - add git options ([cd1ab94](https://github.com/arvinxx/gitmoji-commit-workflow/commit/cd1ab94)) 235 | - support config creator ([cf5de70](https://github.com/arvinxx/gitmoji-commit-workflow/commit/cf5de70)) 236 | 237 | # semantic-release-config-gitmoji 1.0.0-beta.1 (2021-03-06) 238 | 239 | ### ✨ Features 240 | 241 | - add git options ([cd1ab94](https://github.com/arvinxx/gitmoji-commit-workflow/commit/cd1ab94)) 242 | - support config creator ([cf5de70](https://github.com/arvinxx/gitmoji-commit-workflow/commit/cf5de70)) 243 | -------------------------------------------------------------------------------- /packages/release-config/README.md: -------------------------------------------------------------------------------- 1 | # semantic-release-config-gitmoji 2 | 3 | [![NPM version][version-image]][version-url] [![NPM downloads][download-image]][download-url] 4 | 5 | shareable [semantic-release][semantic-release] configuration for gitmoji commit style 6 | 7 | ## How to use 8 | 9 | ### Basic Usage 10 | 11 | ```js 12 | // .releaserc.js 13 | module.exports = { 14 | extends: ['semantic-release-config-gitmoji'], 15 | }; 16 | ``` 17 | 18 | ### Create your config 19 | 20 | use this in monorepo 21 | 22 | ```js 23 | // .releaserc.js 24 | const { createConfig } = require('semantic-release-config-gitmoji/lib/createConfig'); 25 | 26 | const config = createConfig({ monorepo: true }); 27 | 28 | module.exports = config; 29 | ``` 30 | 31 | ## createConfig params 32 | 33 | ### Common Options 34 | 35 | | name | type | optional | default | description | 36 | | -------------- | --------------- | -------- | -------------- | ----------- | 37 | | releaseRules | `ReleaseRule[]` | `true` | `n/a` | | 38 | | changelogTitle | `string` | `true` | `# Changelog` | | 39 | | changelogFile | `string` | `true` | `CHANGELOG.md` | | 40 | 41 | ### Git Params 42 | 43 | | name | type | optional | default | description | 44 | | --------- | -------- | ---------- | ------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------- | 45 | | message | `string` | `true` | `:bookmark: chore(release): ${nextRelease.gitTag} [skip ci]\n\n${nextRelease.notes}` | The message for the release commit. See [message](#message). | 46 | | gitAssets | `false` | `string[]` | `['CHANGELOG.md', 'package.json']` | Files to include in the release commit.Set to `false` to disable adding files to the release commit. See [assets](#assets). | 47 | 48 | ### Github Params 49 | 50 | | name | type | optional | default | description | 51 | | ------------ | --------- | -------- | ------- | ---------------- | 52 | | enableGithub | `boolean` | `true` | `true` | 开启 github 插件 | 53 | 54 | ### NPM Params 55 | 56 | | name | type | optional | default | description | 57 | | ---------- | --------- | -------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | 58 | | enableNPM | `boolean` | `true` | `true` | 开启 npm 插件 | 59 | | npmPublish | `boolean` | `true` | `n/a` | Whether to publish the `npm` package to the registry. If `false` the `package.json` version will still be updated. `false` if the `package.json` [private](https://docs.npmjs.com/files/package.json#private) property is `true`, `true` otherwise | 60 | | pkgRoot | `string` | `true` | `n/a` | Directory path to publish. default: `.` | 61 | | tarballDir | `string` | `false` | `true` | `n/a` | 62 | | monorepo | `boolean` | `true` | `n/a` | 如果是 Monorepo 仓库发布 npm 包,使用 "@semrel-extra/npm" 替代官方包 if using monorepo, use "@semrel-extra/npm" instead of the official package | 63 | 64 | # GithubPluginOpts 65 | 66 | | name | type | optional | default | description | 67 | | ------------------- | ---------- | -------- | ---------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | 68 | | githubUrl | `string` | `true` | `GH_URL` or `GITHUB_URL` environment variable. | The GitHub Enterprise endpoint. | 69 | | githubApiPathPrefix | `string` | `true` | `GH_PREFIX` or `GITHUB_PREFIX` environment variable. | The GitHub Enterprise API prefix. | 70 | | githubAssets | `string[]` | `true` | `-` | An array of files to upload to the release. See [assets](#assets). | 71 | | proxy | `string` | `true` | `HTTP_PROXY` environment variable. | The proxy to use to access the GitHub API. See [proxy](#proxy). | 72 | | successComment | `string` | `true` | :tada: This issue has been resolved in version ${nextRelease.version} :tada: | The release is available on [GitHub release](github_release_url) The [assignees](https://help.github.com/articles/assigning-issues-and-pull-requests-to-other-github-users) to add to the issue created when a release fails. | 73 | 74 | ## License 75 | 76 | [MIT](../../LICENSE) ® Arvin Xu 77 | 78 | 79 | 80 | [version-image]: http://img.shields.io/npm/v/semantic-release-config-gitmoji.svg?color=deepgreen&label=latest 81 | [version-url]: http://npmjs.org/package/semantic-release-config-gitmoji 82 | [download-image]: https://img.shields.io/npm/dm/semantic-release-config-gitmoji.svg 83 | [download-url]: https://npmjs.org/package/semantic-release-config-gitmoji 84 | [semantic-release]: https://github.com/semantic-release/semantic-release 85 | -------------------------------------------------------------------------------- /packages/release-config/jest.config.ts: -------------------------------------------------------------------------------- 1 | import base from '../../jest.config.base'; 2 | import { Config } from '@umijs/test'; 3 | 4 | const packageName = 'semantic-release-config-gitmoji'; 5 | 6 | const root = '/packages/release-config'; 7 | 8 | const config: Config.InitialOptions = { 9 | ...base, 10 | rootDir: '../..', 11 | roots: [root], 12 | displayName: packageName, 13 | }; 14 | 15 | export default config; 16 | -------------------------------------------------------------------------------- /packages/release-config/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "semantic-release-config-gitmoji", 3 | "version": "1.5.3", 4 | "description": "a gitmoji commit style presets for semantic-release", 5 | "keywords": [ 6 | "conventional-changelog", 7 | "gitmoji", 8 | "preset", 9 | "changelog", 10 | "emoji", 11 | "semantic-release" 12 | ], 13 | "homepage": "https://github.com/arvinxx/gitmoji-commit-workflow/tree/master/packages/release-config#readme", 14 | "bugs": { 15 | "url": "https://github.com/arvinxx/gitmoji-commit-workflow/issues" 16 | }, 17 | "repository": { 18 | "type": "git", 19 | "url": "https://github.com/arvinxx/gitmoji-commit-workflow.git" 20 | }, 21 | "license": "MIT", 22 | "author": "Arvin Xu ", 23 | "main": "lib/index.js", 24 | "types": "lib/index.d.ts", 25 | "files": [ 26 | "lib" 27 | ], 28 | "scripts": { 29 | "build": "father build", 30 | "clean": "rm -rf es lib dist build coverage src/.umi* .eslintcache", 31 | "cov": "jest --coverage", 32 | "doctor": "father doctor", 33 | "prepublishOnly": "npm run doctor && npm run build", 34 | "start": "father dev", 35 | "test": "jest", 36 | "test:cov": "jest --coverage", 37 | "test:update": "jest -u" 38 | }, 39 | "dependencies": { 40 | "@gitmoji/commit-types": "1.1.5", 41 | "@semantic-release/changelog": "^6", 42 | "@semantic-release/git": "^10", 43 | "@semantic-release/github": "npm:@achingbrain/semantic-release-github", 44 | "@semrel-extra/npm": "^1", 45 | "@types/semantic-release": "^17.2.0", 46 | "conventional-changelog-gitmoji-config": "1.5.2" 47 | }, 48 | "publishConfig": { 49 | "access": "public", 50 | "registry": "https://registry.npmjs.org/" 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /packages/release-config/src/__snapshots__/index.test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`get default config 1`] = ` 4 | { 5 | "branches": [ 6 | "master", 7 | "main", 8 | { 9 | "channel": "rc", 10 | "name": "rc-*", 11 | "prerelease": "rc", 12 | }, 13 | { 14 | "name": "rc", 15 | "prerelease": true, 16 | }, 17 | { 18 | "channel": "alpha", 19 | "name": "alpha", 20 | "prerelease": "alpha", 21 | }, 22 | { 23 | "channel": "beta", 24 | "name": "beta", 25 | "prerelease": "beta", 26 | }, 27 | ], 28 | "plugins": [ 29 | [ 30 | "@semantic-release/commit-analyzer", 31 | { 32 | "config": "conventional-changelog-gitmoji-config", 33 | "releaseRules": [ 34 | { 35 | "release": "patch", 36 | "type": "style", 37 | }, 38 | { 39 | "release": "patch", 40 | "type": "build", 41 | }, 42 | ], 43 | }, 44 | ], 45 | [ 46 | "@semantic-release/release-notes-generator", 47 | { 48 | "config": "conventional-changelog-gitmoji-config", 49 | }, 50 | ], 51 | [ 52 | "@semantic-release/changelog", 53 | { 54 | "changelogFile": "CHANGELOG.md", 55 | "changelogTitle": "# Changelog", 56 | }, 57 | ], 58 | "@semantic-release/npm", 59 | "@semantic-release/github", 60 | [ 61 | "@semantic-release/git", 62 | { 63 | "assets": [ 64 | "CHANGELOG.md", 65 | "package.json", 66 | ], 67 | "message": ":bookmark: chore(release): \${nextRelease.gitTag} [skip ci] 68 | 69 | \${nextRelease.notes}", 70 | }, 71 | ], 72 | ], 73 | } 74 | `; 75 | -------------------------------------------------------------------------------- /packages/release-config/src/createConfig.ts: -------------------------------------------------------------------------------- 1 | import type { Options as SemRelOptions, PluginSpec } from 'semantic-release'; 2 | 3 | import commitAnalyzer from './plugins/commitAnalyzer'; 4 | import git from './plugins/git'; 5 | import github from './plugins/github'; 6 | import npm from './plugins/npm'; 7 | import type { Options } from './type'; 8 | 9 | export type { Options, ReleaseRule } from './type'; 10 | 11 | export const createConfig = (options?: Options): SemRelOptions => { 12 | const opts = { 13 | changelogTitle: '# Changelog', 14 | changelogFile: 'CHANGELOG.md', 15 | enableNPM: true, 16 | enableGithub: true, 17 | ...options, 18 | }; 19 | // npm config 20 | const { npmPublish, pkgRoot, tarballDir, monorepo } = opts; 21 | const npmConfig = npm({ npmPublish, pkgRoot, tarballDir, monorepo }); 22 | 23 | // github config 24 | const { 25 | githubUrl, 26 | proxy, 27 | releasedLabels, 28 | failTitle, 29 | githubApiPathPrefix, 30 | labels, 31 | failComment, 32 | assignees, 33 | addReleases, 34 | githubAssets, 35 | } = opts; 36 | const githubConfig = github({ 37 | githubUrl, 38 | proxy, 39 | releasedLabels, 40 | failTitle, 41 | githubApiPathPrefix, 42 | labels, 43 | failComment, 44 | assignees, 45 | addReleases, 46 | githubAssets, 47 | }); 48 | 49 | const plugins: PluginSpec[] = [ 50 | /* 负责解析 commit */ 51 | commitAnalyzer(opts.releaseRules), 52 | /* 此处生成 github-release 的日志 */ 53 | [ 54 | '@semantic-release/release-notes-generator', 55 | { 56 | config: 'conventional-changelog-gitmoji-config', 57 | }, 58 | ], 59 | /* 此处会调用上一个插件生成的新增日志,然后合并到原有日志中 */ 60 | [ 61 | '@semantic-release/changelog', 62 | { 63 | changelogFile: opts.changelogFile, 64 | changelogTitle: opts.changelogTitle, 65 | }, 66 | ], 67 | /* 自动更新版本号 如果没有 private ,会作为 npm 模块进行发布 */ 68 | opts.enableNPM ? npmConfig : '', 69 | /* 将生成结果发布到 Github */ 70 | opts.enableGithub ? githubConfig : '', 71 | /* 推送代码回到 Git */ 72 | git(options), 73 | ]; 74 | 75 | return { 76 | plugins: plugins.filter((p) => !!p), 77 | branches: [ 78 | 'master', 79 | 'main', 80 | { name: 'rc-*', prerelease: 'rc', channel: 'rc' }, 81 | { name: 'rc', prerelease: true }, 82 | { name: 'alpha', prerelease: 'alpha', channel: 'alpha' }, 83 | { name: 'beta', prerelease: 'beta', channel: 'beta' }, 84 | ], 85 | }; 86 | }; 87 | 88 | export default createConfig; 89 | -------------------------------------------------------------------------------- /packages/release-config/src/index.test.ts: -------------------------------------------------------------------------------- 1 | import defaultConfig from './index'; 2 | 3 | test('get default config', () => { 4 | expect(defaultConfig).toMatchSnapshot(); 5 | }); 6 | -------------------------------------------------------------------------------- /packages/release-config/src/index.ts: -------------------------------------------------------------------------------- 1 | import type { Options } from 'semantic-release'; 2 | 3 | import _createConfig from './createConfig'; 4 | 5 | const defaultConfig: Options = _createConfig(); 6 | 7 | export default defaultConfig; 8 | -------------------------------------------------------------------------------- /packages/release-config/src/plugins/commitAnalyzer.test.ts: -------------------------------------------------------------------------------- 1 | import commitAnalyzer from './commitAnalyzer'; 2 | 3 | describe('commitAnalyzer', () => { 4 | it('default', () => { 5 | expect(commitAnalyzer()).toEqual([ 6 | '@semantic-release/commit-analyzer', 7 | { 8 | config: 'conventional-changelog-gitmoji-config', 9 | releaseRules: [ 10 | { 11 | release: 'patch', 12 | type: 'style', 13 | }, 14 | { 15 | release: 'patch', 16 | type: 'build', 17 | }, 18 | ], 19 | }, 20 | ]); 21 | }); 22 | 23 | it('add new release rules', () => { 24 | expect(commitAnalyzer([{ release: 'patch', type: 'perf' }])).toEqual([ 25 | '@semantic-release/commit-analyzer', 26 | { 27 | config: 'conventional-changelog-gitmoji-config', 28 | releaseRules: [ 29 | { 30 | release: 'patch', 31 | type: 'style', 32 | }, 33 | { 34 | release: 'patch', 35 | type: 'build', 36 | }, 37 | { 38 | release: 'patch', 39 | type: 'perf', 40 | }, 41 | ], 42 | }, 43 | ]); 44 | }); 45 | }); 46 | -------------------------------------------------------------------------------- /packages/release-config/src/plugins/commitAnalyzer.ts: -------------------------------------------------------------------------------- 1 | import type { ReleaseRule } from '../type'; 2 | import type { PluginSpec } from 'semantic-release'; 3 | 4 | /** 5 | * commit analyzer 6 | * @param releaseRules 7 | */ 8 | const commitAnalyzer = (releaseRules: ReleaseRule[] = []): PluginSpec => [ 9 | '@semantic-release/commit-analyzer', 10 | { 11 | // 使用 changelog-gitmoji-config 自定义配置,如果不填则是默认的 conventional-changelog-angular 12 | config: 'conventional-changelog-gitmoji-config', 13 | // 默认情况下 style 和 build 都会触发新的构建 14 | releaseRules: [ 15 | { type: 'style', release: 'patch' }, 16 | { type: 'build', release: 'patch' }, 17 | ].concat(releaseRules), 18 | }, 19 | ]; 20 | 21 | export default commitAnalyzer; 22 | -------------------------------------------------------------------------------- /packages/release-config/src/plugins/git.test.ts: -------------------------------------------------------------------------------- 1 | import git from './git'; 2 | 3 | describe('git', () => { 4 | it('default', () => { 5 | expect(git()).toEqual([ 6 | '@semantic-release/git', 7 | { 8 | assets: ['CHANGELOG.md', 'package.json'], 9 | message: 10 | // eslint-disable-next-line no-template-curly-in-string 11 | ':bookmark: chore(release): ${nextRelease.gitTag} [skip ci] \n\n${nextRelease.notes}', 12 | }, 13 | ]); 14 | }); 15 | 16 | it('add new assets rules', () => { 17 | expect(git({ gitAssets: ['file.json'] })).toEqual([ 18 | '@semantic-release/git', 19 | { 20 | assets: ['CHANGELOG.md', 'package.json', 'file.json'], 21 | message: 22 | // eslint-disable-next-line no-template-curly-in-string 23 | ':bookmark: chore(release): ${nextRelease.gitTag} [skip ci] \n\n${nextRelease.notes}', 24 | }, 25 | ]); 26 | }); 27 | 28 | it('custom message', () => { 29 | expect(git({ message: 'chore(release)' })).toEqual([ 30 | '@semantic-release/git', 31 | { 32 | assets: ['CHANGELOG.md', 'package.json'], 33 | message: 'chore(release)', 34 | }, 35 | ]); 36 | }); 37 | }); 38 | -------------------------------------------------------------------------------- /packages/release-config/src/plugins/git.ts: -------------------------------------------------------------------------------- 1 | import type { PluginSpec } from 'semantic-release'; 2 | import type { GitPluginOpts } from '../type'; 3 | 4 | /** 5 | * git 6 | * @param options 7 | */ 8 | const git = (options: GitPluginOpts = {}): PluginSpec => { 9 | return [ 10 | '@semantic-release/git', 11 | { 12 | assets: 13 | typeof options.gitAssets === 'boolean' 14 | ? false 15 | : [ 16 | // 这里的 assets 配置的是要重新 push 回去的东西 17 | // 如果不列的话会将全部内容都合并到 release 中 18 | 'CHANGELOG.md', 19 | 'package.json', 20 | ] 21 | .concat(options.gitAssets) 22 | .filter((a) => a), 23 | message: options.message 24 | ? options.message 25 | : // eslint-disable-next-line no-template-curly-in-string 26 | ':bookmark: chore(release): ${nextRelease.gitTag} [skip ci] \n\n${nextRelease.notes}', 27 | }, 28 | ]; 29 | }; 30 | 31 | export default git; 32 | -------------------------------------------------------------------------------- /packages/release-config/src/plugins/github.test.ts: -------------------------------------------------------------------------------- 1 | import github from './github'; 2 | 3 | describe('github', () => { 4 | it('default', () => { 5 | expect(github()).toEqual('@semantic-release/github'); 6 | }); 7 | 8 | it('add release assets', () => { 9 | expect(github({ githubAssets: ['release'] })).toEqual([ 10 | '@semantic-release/github', 11 | { 12 | assets: ['release'], 13 | }, 14 | ]); 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /packages/release-config/src/plugins/github.ts: -------------------------------------------------------------------------------- 1 | import type { PluginSpec } from 'semantic-release'; 2 | import type { GithubPluginOpts } from '../type'; 3 | 4 | /** 5 | * github 6 | * @param options 7 | */ 8 | const github = (options: GithubPluginOpts = {}): PluginSpec => { 9 | const noOpts = 10 | options && Object.values(options).filter((i) => typeof i !== 'undefined').length === 0; 11 | 12 | if (!options || noOpts) return '@semantic-release/github'; 13 | 14 | const { githubAssets, ...config } = options; 15 | return [ 16 | '@semantic-release/github', 17 | { 18 | assets: githubAssets, 19 | ...config, 20 | }, 21 | ]; 22 | }; 23 | 24 | export default github; 25 | -------------------------------------------------------------------------------- /packages/release-config/src/plugins/npm.test.ts: -------------------------------------------------------------------------------- 1 | import npm from './npm'; 2 | 3 | describe('npm', () => { 4 | it('default', () => { 5 | expect(npm()).toEqual('@semantic-release/npm'); 6 | }); 7 | 8 | it('set npm publish', () => { 9 | expect(npm({ npmPublish: false })).toEqual([ 10 | '@semantic-release/npm', 11 | { 12 | npmPublish: false, 13 | }, 14 | ]); 15 | }); 16 | 17 | it('use monorepo', () => { 18 | expect(npm({ monorepo: true })).toEqual('@semrel-extra/npm'); 19 | }); 20 | }); 21 | -------------------------------------------------------------------------------- /packages/release-config/src/plugins/npm.ts: -------------------------------------------------------------------------------- 1 | import type { PluginSpec } from 'semantic-release'; 2 | import type { NPMPluginOpts } from '../type'; 3 | 4 | // eslint-disable-next-line @typescript-eslint/no-unused-vars 5 | const npm = (options?: NPMPluginOpts): PluginSpec => { 6 | // if using monorepo, use "@semrel-extra/npm" instead of the official package 7 | // https://github.com/dhoulb/multi-semantic-release#npm-invalid-npm-token 8 | const pkg = options?.monorepo ? '@semrel-extra/npm' : '@semantic-release/npm'; 9 | 10 | if ( 11 | !options || 12 | (typeof options.pkgRoot !== 'string' && 13 | typeof options.npmPublish !== 'boolean' && 14 | typeof options.tarballDir === 'undefined') 15 | ) 16 | return pkg; 17 | 18 | return [pkg, options]; 19 | }; 20 | 21 | export default npm; 22 | -------------------------------------------------------------------------------- /packages/release-config/src/type.ts: -------------------------------------------------------------------------------- 1 | import type { CommitTypes } from '@gitmoji/commit-types'; 2 | import type { Release } from 'semantic-release'; 3 | 4 | export interface ReleaseRule { 5 | type: CommitTypes; 6 | release: Release['type']; 7 | } 8 | 9 | export interface Options extends GitPluginOpts, NPMPluginOpts, GithubPluginOpts { 10 | releaseRules?: ReleaseRule[]; 11 | changelogTitle?: string; 12 | changelogFile?: string; 13 | /** 14 | * 开启 npm 插件 15 | * @default true 16 | */ 17 | enableNPM?: boolean; 18 | /** 19 | * 开启 github 插件 20 | * @default true 21 | */ 22 | enableGithub?: boolean; 23 | } 24 | 25 | export interface GitPluginOpts { 26 | /** 27 | * The message for the release commit. See [message](#message). 28 | * @default :bookmark: chore(release): ${nextRelease.gitTag} [skip ci]\n\n${nextRelease.notes} 29 | */ 30 | message?: string; 31 | /** 32 | * Files to include in the release commit. 33 | * Set to `false` to disable adding files to the release commit. See [assets](#assets). 34 | * @default ['CHANGELOG.md', 'package.json'] 35 | */ 36 | gitAssets?: string[] | false; 37 | } 38 | 39 | export interface GithubPluginOpts { 40 | /** 41 | * The GitHub Enterprise endpoint. 42 | * @default `GH_URL` or `GITHUB_URL` environment variable. 43 | */ 44 | githubUrl?: string; 45 | /** 46 | * The GitHub Enterprise API prefix. 47 | * @default `GH_PREFIX` or `GITHUB_PREFIX` environment variable. 48 | */ 49 | githubApiPathPrefix?: string; 50 | /** 51 | * An array of files to upload to the release. See [assets](#assets). 52 | * @default - 53 | */ 54 | githubAssets?: string[]; 55 | /** 56 | * The proxy to use to access the GitHub API. See [proxy](#proxy). 57 | * @default `HTTP_PROXY` environment variable. 58 | */ 59 | proxy?: string; 60 | /** 61 | * The comment to add to each issue and pull request resolved by the release. Set to `false` to disable commenting on issues and pull requests. See [successComment](#successcomment). 62 | * @default `:tada: This issue has been resolved in version ${nextRelease.version} :tada:\n\nThe release is available on [GitHub release]()` 63 | */ 64 | successComment?: string; 65 | /** 66 | * The content of the issue created when a release fails. Set to `false` to disable opening an issue when a release fails. See [failComment](#failcomment). 67 | * Friendly message with links to **semantic-release** documentation and support, with the list of errors that caused the release to fail. 68 | */ 69 | failComment?: string; 70 | /** 71 | * The title of the issue created when a release fails. Set to `false` to disable opening an issue when a release fails. 72 | * @default `The automated release is failing 🚨` 73 | */ 74 | failTitle?: string; 75 | /** 76 | * The [labels](https://help.github.com/articles/about-labels) to add to the issue created when a release fails. Set to `false` to not add any label. 77 | * @default `['semantic-release']` 78 | */ 79 | labels?: string[]; 80 | 81 | /** 82 | * The [assignees](https://help.github.com/articles/assigning-issues-and-pull-requests-to-other-github-users) to add to the issue created when a release fails. 83 | * 84 | */ 85 | assignees?: string[]; 86 | /** 87 | The [labels](https://help.github.com/articles/about-labels) to add to each issue and pull request resolved by the release. Set to `false` to not add any label. See [releasedLabels](#releasedlabels). 88 | * @default `['released<%= nextRelease.channel ? \` on @\${nextRelease.channel}\` : "" %>']- 89 | */ 90 | releasedLabels?: string[]; 91 | 92 | /** 93 | Will add release links to the GitHub Release. Can be `false`, `"bottom"` or `"top"`. See [addReleases](#addReleases). 94 | * @default `false` 95 | */ 96 | addReleases?: boolean; 97 | } 98 | 99 | export interface NPMPluginOpts { 100 | /** 101 | * Whether to publish the `npm` package to the registry. If `false` the `package.json` version will still be updated. 102 | * `false` if the `package.json` [private](https://docs.npmjs.com/files/package.json#private) property is `true`, 103 | * `true` otherwise 104 | */ 105 | npmPublish?: boolean; 106 | /** 107 | * Directory path to publish. 108 | * default: `.` 109 | */ 110 | pkgRoot?: string; 111 | tarballDir?: string | false; 112 | /** 113 | * 如果是 Monorepo 仓库发布npm包,使用 "@semrel-extra/npm" 替代官方包 114 | * if using monorepo, use "@semrel-extra/npm" instead of the official package 115 | * @see https://github.com/dhoulb/multi-semantic-release#npm-invalid-npm-token 116 | */ 117 | monorepo?: boolean; 118 | } 119 | -------------------------------------------------------------------------------- /packages/release-config/tests/config/custom.js: -------------------------------------------------------------------------------- 1 | const createConfig = require('../../lib/createConfig').default; 2 | 3 | const config = createConfig({ enableNPM: false }); 4 | 5 | module.exports = config; 6 | -------------------------------------------------------------------------------- /packages/release-config/tests/config/default.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: require('../../lib'), 3 | }; 4 | -------------------------------------------------------------------------------- /packages/release-config/tests/createConfig.test.ts: -------------------------------------------------------------------------------- 1 | import { createConfig } from '../src/createConfig'; 2 | 3 | describe('createConfig', () => { 4 | it('disable npm plugin', () => { 5 | expect(createConfig({ enableNPM: false }).plugins).toEqual([ 6 | [ 7 | '@semantic-release/commit-analyzer', 8 | { 9 | config: 'conventional-changelog-gitmoji-config', 10 | releaseRules: [ 11 | { type: 'style', release: 'patch' }, 12 | { type: 'build', release: 'patch' }, 13 | ], 14 | }, 15 | ], 16 | [ 17 | '@semantic-release/release-notes-generator', 18 | { 19 | config: 'conventional-changelog-gitmoji-config', 20 | }, 21 | ], 22 | [ 23 | '@semantic-release/changelog', 24 | { 25 | changelogFile: 'CHANGELOG.md', 26 | changelogTitle: '# Changelog', 27 | }, 28 | ], 29 | '@semantic-release/github', 30 | [ 31 | '@semantic-release/git', 32 | { 33 | assets: ['CHANGELOG.md', 'package.json'], 34 | message: 35 | // eslint-disable-next-line no-template-curly-in-string 36 | ':bookmark: chore(release): ${nextRelease.gitTag} [skip ci] \n\n${nextRelease.notes}', 37 | }, 38 | ], 39 | ]); 40 | }); 41 | 42 | it('disable github plugin', () => { 43 | expect(createConfig({ enableGithub: false }).plugins).toEqual([ 44 | [ 45 | '@semantic-release/commit-analyzer', 46 | { 47 | config: 'conventional-changelog-gitmoji-config', 48 | releaseRules: [ 49 | { type: 'style', release: 'patch' }, 50 | { type: 'build', release: 'patch' }, 51 | ], 52 | }, 53 | ], 54 | [ 55 | '@semantic-release/release-notes-generator', 56 | { 57 | config: 'conventional-changelog-gitmoji-config', 58 | }, 59 | ], 60 | [ 61 | '@semantic-release/changelog', 62 | { 63 | changelogFile: 'CHANGELOG.md', 64 | changelogTitle: '# Changelog', 65 | }, 66 | ], 67 | '@semantic-release/npm', 68 | [ 69 | '@semantic-release/git', 70 | { 71 | assets: ['CHANGELOG.md', 'package.json'], 72 | message: 73 | // eslint-disable-next-line no-template-curly-in-string 74 | ':bookmark: chore(release): ${nextRelease.gitTag} [skip ci] \n\n${nextRelease.notes}', 75 | }, 76 | ], 77 | ]); 78 | }); 79 | }); 80 | -------------------------------------------------------------------------------- /packages/release-config/tests/e2e.test.ts: -------------------------------------------------------------------------------- 1 | describe('E2E', () => { 2 | it('default config', () => { 3 | // eslint-disable-next-line global-require 4 | const defaultConfig = require('./config/default'); 5 | expect(defaultConfig).toBeDefined(); 6 | }); 7 | it('custom config', () => { 8 | // eslint-disable-next-line global-require 9 | const customConfig = require('./config/custom'); 10 | 11 | expect(customConfig).toBeDefined(); 12 | }); 13 | }); 14 | -------------------------------------------------------------------------------- /packages/release-config/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json" 3 | } 4 | -------------------------------------------------------------------------------- /pnpm-workspace.yaml: -------------------------------------------------------------------------------- 1 | packages: 2 | # 所有在 packages/ 和 components/ 子目录下的 package 3 | - 'packages/**' 4 | -------------------------------------------------------------------------------- /tsconfig-check.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "noEmit": true, 5 | "skipLibCheck": true 6 | }, 7 | "include": ["packages"] 8 | } 9 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* 生成能力 */ 4 | "declaration": true, 5 | /* 模块导入配置项 */ 6 | "moduleResolution": "Node", 7 | "esModuleInterop": true, 8 | 9 | /* 模块依赖 */ 10 | // 这些选项对 babel 编译 TypeScript 没有作用 11 | // 但是可以让编辑器正确提示错误 12 | "target": "es5", 13 | "module": "CommonJS", 14 | "sourceMap": true, 15 | "lib": ["ESNext"], 16 | // 17 | /* Alias 路径 */ 18 | "baseUrl": ".", 19 | "paths": { 20 | "@gitmoji/parser-opts": ["./packages/parser-opts/src"], 21 | "@gitmoji/gitmoji-regex": ["./packages/gitmoji-regex/src"], 22 | "@gitmoji/commit-types": ["./packages/commit-types/src"], 23 | "commitlint-plugin-gitmoji": ["./packages/commitlint-plugin/src"], 24 | "conventional-changelog-gitmoji-config": ["./packages/changelog/src"], 25 | "semantic-release-config-gitmoji": ["./packages/release-config/src"] 26 | } 27 | } 28 | } 29 | --------------------------------------------------------------------------------