Browse Source

chore: adopt convention commits (#453)

* chore: adopt conventional commits via standard-version

Conversation which stareted it all: #452

* docs(github): add DEVELOPERS.md

Add a DEVELOPERS.md file to denote:

(1) How to run tests
(2) Git Commit Guidelines

See #452 for history.

* docs(site): update deploy-docs

Two main things:

(1) Made it conform to convention commits
(2) Added script in package.json

* chore(package): made tests not spit out results during postbump

* chore(release): remove old release script to make way for standard-version

* docs(github): add details to dev contributions

* docs: update links in DEVELOPERS.md
Kiro Risk 2 years ago
parent
commit
0467de5bb9
7 changed files with 885 additions and 144 deletions
  1. 110 0
      CONTRIBUTING.md
  2. 70 0
      DEVELOPERS.md
  3. 6 38
      README.md
  4. 24 3
      package.json
  5. 19 9
      scripts/deploy-docs.sh
  6. 0 74
      scripts/release.sh
  7. 656 20
      yarn.lock

+ 110 - 0
CONTRIBUTING.md

@@ -0,0 +1,110 @@
+# Contributing to Fuse.js
+
+We'd love for you to contribute to our source code and to make Fuse.js better! Here are the guidelines we'd like you to follow:
+
+- [Questions and Problems](#question)
+- [Issues and Bugs](#issue)
+- [Pull Request Submission Guidelines](#submit-pr)
+
+## <a name="requests"></a> Questions, Bugs, Features
+
+### <a name="question"></a> Got a Question or Problem?
+
+Do not open issues for general support questions as we want to keep GitHub issues for bug reports and feature requests. You've got much better chances of getting your question answered on dedicated support platforms, the best being [Stack Overflow][stackoverflow].
+
+### <a name="issue"></a> Found an Issue or Bug?
+
+If you find a bug in the source code, you can help us by submitting an issue to our
+[GitHub Repository][github]. Even better, you can submit a Pull Request with a fix.
+
+When creating issues, it's important to follow common guidelines to make them extra clear. Here is a few links to help you achieve that:
+
+- [GitHub Guides: Mastering Issues](https://guides.github.com/features/issues/)
+- [Wiredcraft: How We Write Github Issues](https://wiredcraft.com/blog/how-we-write-our-github-issues/)
+- [NYC Planning Digital: Writing Useful Github Issues](https://medium.com/nyc-planning-digital/writing-a-proper-github-issue-97427d62a20f)
+
+## <a name="submit-pr"></a> Pull Request Submission Guidelines
+
+Before you submit your pull request consider the following guidelines:
+
+- Search [GitHub](https://github.com/krisk/Fuse/pulls) for an open or closed Pull Request that relates to your submission. You don't want to duplicate effort.
+- Make your changes in a new git branch:
+
+  ```shell
+  git checkout -b my-fix-branch master
+  ```
+
+- Create your patch commit, **including appropriate test cases**.
+- Run `yarn lint` to check that you have followed the automatically enforced coding rules
+- Commit your changes using a descriptive commit message that follows our
+  [commit message conventions][developers.commits]. Adherence to the
+  [commit message conventions][developers.commits] is required, because release notes are
+  automatically generated from these messages.
+
+  ```shell
+   git commit -a
+  ```
+
+- Before creating the Pull Request, package and run all tests a last time:
+
+  ```shell
+  yarn test
+  ```
+
+- Push your branch to GitHub:
+
+  ```shell
+  git push origin my-fix-branch
+  ```
+
+- If we suggest changes, then:
+
+  - Make the required updates.
+  - Re-run the test suite to ensure tests are still passing.
+  - Commit your changes to your branch (e.g. `my-fix-branch`).
+  - Push the changes to your GitHub repository (this will update your Pull Request).
+
+    You can also amend the initial commits and force push them to the branch.
+
+    ```shell
+    git rebase master -i
+    git push origin my-fix-branch -f
+    ```
+
+    This is generally easier to follow, but separate commits are useful if the Pull Request contains
+    iterations that might be interesting to see side-by-side.
+
+That's it! Thank you for your contribution!
+
+#### After your pull request is merged
+
+After your pull request is merged, you can safely delete your branch and pull the changes
+from the main (upstream) repository:
+
+- Delete the remote branch on GitHub either through the GitHub web UI or your local shell as follows:
+
+  ```shell
+  git push origin --delete my-fix-branch
+  ```
+
+- Check out the master branch:
+
+  ```shell
+  git checkout master -f
+  ```
+
+- Delete the local branch:
+
+  ```shell
+  git branch -D my-fix-branch
+  ```
+
+- Update your master with the latest upstream version:
+
+  ```shell
+  git pull --ff upstream master
+  ```
+
+[stackoverflow]: http://stackoverflow.com/questions/tagged/fuse.js
+[github]: https://github.com/krisk/Fuse/issues
+[developers.commits]: DEVELOPERS.md#commits

+ 70 - 0
DEVELOPERS.md

@@ -0,0 +1,70 @@
+# Developing Fuse.js
+
+- [Running Tests](#tests)
+- [Commit Message Guidelines](#commits)
+
+## <a name="tests"> Running Tests
+
+```shell
+yarn test
+```
+
+## <a name="commits"></a> Git Commit Guidelines
+
+Fuse.js follows [conventional commits](conventional-commits). This leads to **more readable messages** that are easy to follow when looking through the **project history**. Also, these git commit messages are used to **generate the [changelog](changelog)**.
+
+### Commit Message Format
+
+Each commit message consists of a **header**, a **body** and a **footer**. The header has a special format that includes a **type**, a **scope** and a **subject**:
+
+```
+<type>(<scope>): <subject>
+<BLANK LINE>
+<body>
+<BLANK LINE>
+<footer>
+```
+
+### Type
+
+Must be one of the following:
+
+- **feat**: A new feature
+- **fix**: A bug fix
+- **docs**: Documentation only changes
+- **style**: Changes that do not affect the meaning of the code (white-space, formatting, missing
+  semi-colons, etc)
+- **refactor**: A code change that neither fixes a bug nor adds a feature
+- **perf**: A code change that improves performance
+- **test**: Adding missing or correcting existing tests
+- **chore**: Changes to the build process or auxiliary tools and libraries such as documentation
+  generation
+
+### Scope
+
+The scope could be anything specifying place of the commit change. For example `options`,
+`search`, `index`, etc...
+
+You can use `*` when the change affects more than a single scope.
+
+### Subject
+
+The subject contains succinct description of the change:
+
+- use the imperative, present tense: "change" not "changed" nor "changes"
+- don't capitalize first letter
+- no dot (.) at the end
+
+### Body
+
+Just as in the **subject**, use the imperative, present tense: "change" not "changed" nor "changes". The body should include the motivation for the change and contrast this with previous behavior.
+
+### Footer
+
+The footer should contain any information about **Breaking Changes** and is also the place to [reference GitHub issues that this commit closes][closing-issues].
+
+**Breaking Changes** should start with the word `BREAKING CHANGE:` with a space or two newlines. The rest of the commit message is then used for this.
+
+[closing-issues]: https://help.github.com/articles/closing-issues-via-commit-messages/
+[conventional-commits]: https://www.conventionalcommits.org/en/v1.0.0-beta.2/
+[changelog]: CHANGELOG.md

+ 6 - 38
README.md

@@ -27,45 +27,13 @@ Fuse.js supports all browsers that are ES5-compliant (IE8 and below are not supp
 
 ## Documentation
 
-To checkout out live examples and docs, visit [fusejs.io](https://fusejs.io).
+Go to [fusejs.io](https://fusejs.io).
 
-## Installation
+## Develop
 
-**NPM**
+Here's a separate document for [developers](https://github.com/krisk/Fuse/blob/master/DEVELOPERS.md).
 
-```sh
-$ npm install --save fuse.js
-```
+## Contribute
 
-**Yarn**
-
-```sh
-$ yarn add fuse.js
-```
-
-**CDN**
-
-Available on CDN via [jsDelivr](https://cdn.jsdelivr.net/npm/fuse.js/dist/).
-
-> Note: it takes some time for the CDNs to sync with the latest version
-
-**Deno**
-
-Available in Deno via [deno.land/x](https://deno.land/x/fuse)
-
-```typescript
-// @deno-types="https://deno.land/x/fuse@v6.0.4/dist/fuse.d.ts"
-import Fuse from 'https://deno.land/x/fuse@v6.0.4/dist/fuse.esm.min.js';
-```
-
-### Explanation of Different Builds
-
-In the [`dist/` directory of the NPM package](https://cdn.jsdelivr.net/npm/fuse.js/dist/) you will find many different builds of Fuse.js. Here's an [overview](https://fusejs.io/getting-started/different-builds.html) of the difference between them.
-
-## Issues
-
-This repository serves as [the main issue tracker](https://github.com/krisk/Fuse/issues). When creating issues, it's important to follow common guidelines to make them extra clear. Here is a few links to help you achieve that:
-
-- [GitHub Guides: Mastering Issues](https://guides.github.com/features/issues/)
-- [Wiredcraft: How We Write Github Issues](https://wiredcraft.com/blog/how-we-write-our-github-issues/)
-- [NYC Planning Digital: Writing Useful Github Issues](https://medium.com/nyc-planning-digital/writing-a-proper-github-issue-97427d62a20f)
+We've set up a separate document for our
+[contribution guidelines](https://github.com/krisk/Fuse/blob/master/CONTRIBUTING.md).

+ 24 - 3
package.json

@@ -30,12 +30,29 @@
     "dev": "rollup -w -c scripts/configs.js --environment TARGET:umd-dev-full",
     "dev:cjs": "rollup -w -c scripts/configs.js --environment TARGET:commonjs-full",
     "dev:esm": "rollup -w -c scripts/configs.js --environment TARGET:esm-dev-full",
-    "build": "node scripts/build.main.js",
+    "build": "rm -r dist && mkdir dist && node ./scripts/build.main.js",
     "test": "jest",
     "lint": "eslint src scripts test",
-    "release": "bash scripts/release.sh",
+    "release": "standard-version -a",
     "docs:dev": "vuepress dev docs",
-    "docs:build": "vuepress build docs"
+    "docs:build": "vuepress build docs",
+    "docs:release": "./scripts/deploy-docs.sh"
+  },
+  "standard-version": {
+    "scripts": {
+      "postbump": "yarn build && yarn lint && yarn test 2>/dev/null",
+      "precommit": "git add dist/*.js dist/*.ts"
+    }
+  },
+  "husky": {
+    "hooks": {
+      "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
+    }
+  },
+  "commitlint": {
+    "extends": [
+      "@commitlint/config-conventional"
+    ]
   },
   "devDependencies": {
     "@babel/cli": "^7.2.3",
@@ -43,6 +60,8 @@
     "@babel/plugin-proposal-object-rest-spread": "7.9.0",
     "@babel/preset-env": "7.3.4",
     "@babel/preset-typescript": "7.9.0",
+    "@commitlint/cli": "^9.0.1",
+    "@commitlint/config-conventional": "^9.0.1",
     "@rollup/plugin-node-resolve": "^7.1.1",
     "@rollup/plugin-replace": "^2.3.1",
     "@types/jest": "25.1.4",
@@ -55,12 +74,14 @@
     "eslint-config-prettier": "6.10.1",
     "eslint-plugin-vue": "7.0.0-alpha.0",
     "faker": "4.1.0",
+    "husky": "^4.2.5",
     "jest": "^25.1.0",
     "prettier": "2.0.2",
     "rimraf": "3.0.2",
     "rollup": "2.1.0",
     "rollup-plugin-babel": "^4.4.0",
     "rollup-plugin-copy": "3.3.0",
+    "standard-version": "^8.0.0",
     "terser-webpack-plugin": "2.3.5",
     "typescript": "^3.8.3",
     "vue-codemirror": "^4.0.6",

+ 19 - 9
scripts/deploy-docs.sh

@@ -3,16 +3,26 @@
 # abort on errors
 set -e
 
-# build
-npm run docs:build
+read -p "Do you want to publish the website? (y/n) " -n 1 -r
 
-# navigate into the build output directory
-cd docs/.vuepress/dist
+echo
 
-echo 'fusejs.io' > CNAME
+if [[ $REPLY =~ ^[Yy]$ ]]; then
+  # build
+  npm run docs:build
 
-git init
-git add -A
-git commit -m 'deploy'
+  # navigate into the build output directory
+  cd docs/.vuepress/dist
 
-git push -f git@github.com:krisk/fuse.git master:gh-pages
+  echo 'fusejs.io' > CNAME
+
+  git init
+  git add -A
+  git commit -m 'docs(site): publish site'
+
+  git push -f git@github.com:krisk/fuse.git master:gh-pages
+
+  echo "✅ Pushed to GitHub"
+else
+  echo "\033[0;31mCancelling...\033[0m"
+fi

+ 0 - 74
scripts/release.sh

@@ -1,74 +0,0 @@
-#!/usr/bin/env bash
-set -e
-
-if [[ -z $1 ]]; then
-  echo "Enter new version: "
-  read -r VERSION
-else
-  VERSION=$1
-fi
-
-PS3='Please enter your choice: '
-options=("latest" "beta" "alpha")
-select opt in "${options[@]}"
-do
-  case $opt in
-    "latest")
-      break
-      ;;
-    "beta")
-      RELEASE_TAG='beta'
-      break
-      ;;
-    "alpha")
-      RELEASE_TAG='alpha'
-      break
-      ;;
-    *) echo "invalid option $REPLY";;
-  esac
-done
-
-if [[ -z $RELEASE_TAG ]]; then
-  read -p "Releasing $VERSION (latest) - are you sure? (y/n) " -n 1 -r
-else
-  read -p "Releasing $VERSION ($RELEASE_TAG) - are you sure? (y/n) " -n 1 -r
-fi
-
-echo
-
-if [[ $REPLY =~ ^[Yy]$ ]]; then
-  echo -e "\033[0;32mReleasing $VERSION...\033[0m"
-  echo
-  # Build
-  VERSION=$VERSION npm run build
-
-  ## Run tests
-  echo -e "\033[0;32mRunning tests...\033[0m"
-  npm run lint
-  npm test 2>/dev/null
-
-  # commit
-  echo -e "\033[0;32mCommitting...\033[0m"
-  git add -A
-  git add -f dist/*.js dist/*.ts
-  git commit -m "Build $VERSION"
-
-  # tag version
-  npm version "$VERSION" --message "Release $VERSION"
-  git push origin refs/tags/v"$VERSION"
-
-  # Push to repo
-  git push origin HEAD
-  echo "✅ released to Github"
-
-  # Publish
-  if [[ -z $RELEASE_TAG ]]; then
-    npm publish
-  else
-    npm publish --tag "$RELEASE_TAG"
-  fi
-
-  echo "✅ released to NPM"
-else
-  echo -e "\033[0;31mCancelling...\033[0m"
-fi

File diff suppressed because it is too large
+ 656 - 20
yarn.lock


Some files were not shown because too many files changed in this diff