Look at the Nuxt 3 documentation to learn more.
-
Make sure to install the dependencies:
# yarn npx husky-init && yarn install
-
Install commitlint with a config, which will be used to lint your commit message:
yarn add @commitlint/{cli,config-conventional}
-
As we are using config-conventional we are automatically following the Angular commit convention. Now we need to tell Husky to run commitlint during the Git commit hook. Therefore, we need to add a commit-msg file to the .husky folder:
#!/bin/sh . "$(dirname "$0")/_/husky.sh" npx --no-install commitlint --edit "$1"
-
Finally, we create a .commitlintrc.json file which extends the rules from config-conventional:
{ "extends": ["@commitlint/config-conventional"] }
-
Fix "The '.husky/commit-msg' hook was ignored because it's not set as executable."
#terminal chmod ug+x .husky/*
-
npm i --save-dev standard-version
Now we can create some npm scripts in our package.json:
"scripts": { "release": "standard-version", "release:minor": "standard-version --release-as minor", "release:patch": "standard-version --release-as patch", "release:major": "standard-version --release-as major" },
The changelog generation can be configured via a .versionrc.json file or placing a standard-version stanza in your package.json.
In our demo we use a .versionrc.json file based on the Conventional Changelog Configuration Spec:
{ "types": [ { "type": "feat", "section": "Features" }, { "type": "fix", "section": "Bug Fixes" }, { "type": "chore", "hidden": true }, { "type": "docs", "hidden": true }, { "type": "style", "hidden": true }, { "type": "refactor", "hidden": true }, { "type": "perf", "hidden": true }, { "type": "test", "hidden": true } ], "commitUrlFormat": "https://github.com/mokkapps/changelog-generator-demo/commits/{{hash}}", "compareUrlFormat": "https://github.com/mokkapps/changelog-generator-demo/compare/{{previousTag}}...{{currentTag}}" }
An array of type objects represents the explicitly supported commit message types, and whether they should show up in the generated changelog file. commitUrlFormat is an URL representing a specific commit at a hash and compareUrlFormat is an URL representing the comparison between two git shas.
- The first release can be created by running npm run release -- --first-release in the terminal:
▶ npm run release -- --first-release
> [email protected] release /Users/mhoffman/workspace/changelog-generator-demo
> standard-version "--first-release"
✖ skip version bump on first release
✔ created CHANGELOG.md
✔ outputting changes to CHANGELOG.md
✔ committing CHANGELOG.md
✔ tagging release v0.0.0
ℹ Run `git push --follow-tags origin master` to publish
Start the development server on http://localhost:3000
npm run dev
Build the application for production:
npm run build
Locally preview production build:
npm run preview
Check out the deployment documentation for more information.