Skip to content

Commit

Permalink
Merge pull request #195 from dc7290/main
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
dc7290 authored Jan 15, 2023
2 parents 9f0f63d + 0e94898 commit be35056
Show file tree
Hide file tree
Showing 16 changed files with 4,320 additions and 794 deletions.
8 changes: 8 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
.eslintrc.js
jest.config.js
commitlint.config.js
commit-types.config.js
release.config.js
changelog.config.js

examples/*
lib/*
esm/*
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ module.exports = {
node: true,
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
'prettier',
],
parser: '@typescript-eslint/parser',
parserOptions: {
Expand Down
31 changes: 10 additions & 21 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,19 @@
# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
branches: [main]

jobs:
build:

test:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- run: yarn install
- run: yarn test
- uses: actions/checkout@v3
- name: Use Node.js 16
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'yarn'
- run: yarn install
- run: yarn test
28 changes: 28 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Release

on:
push:
branches: [release]

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js 16
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'yarn'
- run: yarn install
- run: yarn test
- run: yarn build
- name: Release
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GIT_AUTHOR_NAME: 'dc7290'
GIT_AUTHOR_EMAIL: 'dhkh.cba0927@gmail.com'
GIT_COMMITTER_NAME: 'dc7290'
GIT_COMMITTER_EMAIL: 'dhkh.cba0927@gmail.com'
run: yarn semantic-release
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname -- "$0")/_/husky.sh"

yarn commitmsg
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn lint-staged
6 changes: 6 additions & 0 deletions .husky/prepare-commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh
. "$(dirname -- "$0")/_/husky.sh"

[ -z "${SKIP_BY_SEMANTIC_RELEASE}" ] && {
exec < /dev/tty && yarn git-cz --hook
} || true
55 changes: 55 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Contributing

Your contributions are most welcome!
These guidelines will be useful for Issues and PR.

## Issue

Basically, please report using the template provided.
Of course, you may also write your own report.

The template contains a

- Bug report
- Feature request

and choose the one that best suits the issue you wish to submit.

Also, please help us by filling out the form as much as possible, as it will speed up the time it takes to fix bugs and add features.

## Pull Request

Fork this repository and create a branch from the latest `main` branch.

### Setup

Run `yarn` to install dependencies.

### Development

You can run the test as follows.

| common | watch |
| ----------- | ----------------- |
| `yarn test` | `yarn test:watch` |

### Commit

When committing, changed files are automatically linted and formatted, and commit messages are created interactively by `git-cz`.
(Attention: `git commit` will automatically run `git-cz`.)

The rules for doing so are as follows.

| type | description |
| -------- | -------------------------------------------------------- |
| feat | A new feature |
| fix | A bug fix |
| sec | A vulnerability fix |
| perf | A code change that improves performance |
| refactor | A code change that neither fixes a bug or adds a feature |
| docs | Documentation only changes |
| release | Create a release commit |
| style | Markup, white-space, formatting, missing semi-colons... |
| test | Adding missing tests |
| ci | CI related changes |
| chore | Build process or auxiliary tool changes |
53 changes: 53 additions & 0 deletions changelog.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* This is a configuration for git-cz.
*
* @see {@link https://github.com/streamich/git-cz#custom-config} for documentation
* @see {@link https://github.com/streamich/git-cz/blob/master/lib/defaults.js} for default configs.
*/

const types = require('./commit-types.config')

module.exports = {
/**
* コミットメッセージに絵文字を含めないか
*/
disableEmoji: false,
/**
* コミットメッセージの題目の書式
*/
format: "{type}{scope}: {emoji}{subject}",
/**
* コミット時に選択可能な型
*/
list: types.map(({ type }) => type),
/**
* コミットメッセージ最大文字数
*/
// maxMessageLength: 64,
/**
* コミットメッセージ最小文字数
*/
// minMessageLength: 3,
/**
* コミット時に入力する項目
*/
questions: [
"type", // 型
"subject", // コミットの題名
"body", // コミットの本文
"breaking", // breaking changeの内容
"issues", // クローズするGitHub issues
],
/**
* 各型の設定
*/
types: Object.fromEntries(types.map(({ type, description, emoji }) => [type, { description, emoji, value: type }])),
/**
* BREAKING CHANGEに表示する絵文字
*/
breakingChangePrefix: "🧨",
/**
* Closesに表示する絵文字
*/
closedIssuePrefix: "✅",
}
102 changes: 102 additions & 0 deletions commit-types.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/**
* @typedef {Object} Type conventional commitsの型の設定
* @property {string} type conventional commitsの型
* @property {"major" | "minor" | "patch" | undefined } [release] セマンティックバージョンの上げ方。undefinedはリリースされません。
* @property {string} description git-czに表示される説明文
* @property {string} emoji git-czで使う絵文字
* @property {string | undefined} [section] changelogに表示する見出し
* @property {boolean | undefined} [hidden] changelogに表示するか否か
*/

/**
* @type {Array.<Type>}
*/
module.exports = [
{
type: "feat", // 機能追加
release: "minor",
description: "A new feature",
emoji: "🚀",
section: "Features",
hidden: false,
},
{
type: "fix", // バグ修正
release: "patch",
description: "A bug fix",
emoji: "🐛",
section: "Bug Fixes",
hidden: false,
},
{
type: "sec", // 脆弱性の解消
release: "patch",
description: "A vulnerability fix",
emoji: "👮‍",
section: "Security",
hidden: false,
},
{
type: "perf", // パフォーマンスのみの改善
release: "patch",
description: "A code change that improves performance",
emoji: "⚡️",
section: "Performance Improvements",
hidden: false,
},
{
type: "refactor", // 機能追加やバグ修正を伴わないリファクタリング
release: undefined,
description: "A code change that neither fixes a bug or adds a feature",
emoji: "💡",
section: "Code Refactoring",
hidden: true,
},
{
type: "docs", // ドキュメントのみの変更
release: undefined,
description: "Documentation only changes",
emoji: "✏️",
section: `Documentation`,
hidden: false,
},
{
type: "release", // リリースコミット
release: undefined,
description: "Create a release commit",
emoji: "🏹",
hidden: true,
},
{
type: "style", // コーディングスタイル関連の修正
release: undefined,
description: "Markup, white-space, formatting, missing semi-colons...",
emoji: "💄",
section: "Styles",
hidden: true,
},
{
type: "test", // テストの追加変更
release: undefined,
description: "Adding missing tests",
emoji: "💍",
section: "Tests",
hidden: false,
},
{
type: "ci", // CI関連の変更
release: undefined,
description: "CI related changes",
emoji: "🎡",
section: `Continuous Integration`,
hidden: false,
},
{
type: "chore", // ビルドプロセスや補助ツールの変更
release: undefined,
description: "Build process or auxiliary tool changes",
emoji: "🤖",
section: `Chore`,
hidden: true,
},
];
26 changes: 26 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* A configuration for commitlint.
* @see {@link https://commitlint.js.org/#/} for details.
*/

const typeEnum = require('./commit-types.config').map(({ type }) => type)
const scopeEnum = require('./changelog.config').scopes
const subjectMinLength = require('./changelog.config').minMessageLength ?? 3
const subjectMaxLength = require('./changelog.config').maxMessageLength ?? 64

module.exports = {
extends: ['@commitlint/config-conventional'],
/**
* @see {@link https://commitlint.js.org/#/reference-rules} for rule details.
*/
rules: {
'type-enum': [2, 'always', typeEnum],
'scope-enum': [2, 'always', scopeEnum],
'subject-min-length': [2, 'always', subjectMinLength],
'subject-max-length': [2, 'always', subjectMaxLength],
'body-max-length': [0], // releaseコミットがエラーになるため無効化する
'body-max-line-length': [0], // releaseコミットがエラーになるため無効化する
'footer-max-length': [0], // releaseコミットがエラーになるため無効化する
'footer-max-line-length': [0], // releaseコミットがエラーになるため無効化する
},
}
Loading

0 comments on commit be35056

Please sign in to comment.