From c1a5f0945cbf0852f0adc8e4b3538e36533a1087 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20de=20Le=C3=B3n=20Guerrero?= Date: Wed, 29 Sep 2021 21:53:11 +0200 Subject: [PATCH] chore: separate changelogs (#13) * chore: separate changelogs * feat: add release cli * chore(release): @myscope-webapp@1.2.0 * chore(release): @myscope-webapp-redux@1.2.0 * chore(release): @myscope-common@1.2.0 * fix: improve docs --- .versionrc | 50 - README.md | 167 +- package.json | 17 +- packages/common/.versionrc | 43 + packages/common/.yarnrc | 1 + packages/common/CHANGELOG.md | 24 + packages/common/package.json | 2 +- packages/webapp-redux/.versionrc | 43 + packages/webapp-redux/.yarnrc | 1 + packages/webapp-redux/CHANGELOG.md | 47 + packages/webapp-redux/package.json | 2 +- packages/webapp/.versionrc | 43 + packages/webapp/.yarnrc | 1 + packages/webapp/CHANGELOG.md | 26 + packages/webapp/package.json | 2 +- scripts/release.js | 67 + yarn.lock | 4600 ++++++++++++++-------------- 17 files changed, 2644 insertions(+), 2492 deletions(-) create mode 100644 packages/common/.versionrc create mode 100644 packages/common/.yarnrc create mode 100644 packages/common/CHANGELOG.md create mode 100644 packages/webapp-redux/.versionrc create mode 100644 packages/webapp-redux/.yarnrc create mode 100644 packages/webapp-redux/CHANGELOG.md create mode 100644 packages/webapp/.versionrc create mode 100644 packages/webapp/.yarnrc create mode 100644 packages/webapp/CHANGELOG.md create mode 100644 scripts/release.js diff --git a/.versionrc b/.versionrc index 60a70cd..37e4b1d 100644 --- a/.versionrc +++ b/.versionrc @@ -7,56 +7,6 @@ { "filename": "yarn.lock", "type": "json" - }, - { - "filename": "packages/webapp/package.json", - "type": "json" - }, - { - "filename": "packages/webapp-redux/package.json", - "type": "json" - }, - { - "filename": "packages/common/package.json", - "type": "json" - } - ], - "types": [ - { - "type": "feat", - "section": "Features" - }, - { - "type": "fix", - "section": "Bug Fixes" - }, - { - "type": "test", - "section": "Tests" - }, - { - "type": "ci", - "section": "Continuous Integration" - }, - { - "type": "chore", - "section": "Chore" - }, - { - "type": "style", - "section": "Styling" - }, - { - "type": "docs", - "section": "Documentation updates" - }, - { - "type": "refactor", - "section": "Refactors" - }, - { - "type": "perf", - "section": "Performance improvements" } ] } diff --git a/README.md b/README.md index 9e8de05..40eec68 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Welcome to the project! -Below you will find some information on how to perform common tasks.
+Below you will find some information on how to perform common tasks. ## Table of Contents @@ -15,14 +15,17 @@ Below you will find some information on how to perform common tasks.
- [`yarn build:webapp`](#yarn-buildwebapp) - [`yarn build:dep:webapp`](#yarn-builddepwebapp) - [`yarn test:webapp`](#yarn-testwebapp) + - [`yarn release:webapp`](#yarn-releasewebapp) - [`yarn start:webapp-redux`](#yarn-startwebapp-redux) - [`yarn build:webapp-redux`](#yarn-buildwebapp-redux) - [`yarn build:dep:webapp-redux`](#yarn-builddepwebapp-redux) - [`yarn test:webapp-redux`](#yarn-testwebapp-redux) + - [`yarn release:webapp-redux`](#yarn-releasewebapp-redux) - [`yarn start:common`](#yarn-startcommon) - [`yarn build:common`](#yarn-buildcommon) - [`yarn build:dep:common`](#yarn-builddepcommon) - [`yarn test:common`](#yarn-testcommon) + - [`yarn release:common`](#yarn-releasecommon) - [`yarn clean`](#yarn-clean) - [`yarn clean:install`](#yarn-cleaninstall) - [`yarn build`](#yarn-build) @@ -31,19 +34,15 @@ Below you will find some information on how to perform common tasks.
- [`yarn test:ci`](#yarn-testci) - [`yarn lint`](#yarn-lint) - [`yarn release`](#yarn-release) - - [`yarn release:patch`](#yarn-releasepatch) - - [`yarn release:minor`](#yarn-releaseminor) - - [`yarn release:major`](#yarn-releasemajor) - - [`yarn release:tags`](#yarn-releasetags) - [`yarn ncu`](#yarn-ncu) - [Generate changelog](#generate-changelog) - [Installing a Dependency](#installing-a-dependency) - [Updating Dependencies](#updating-dependencies) - [Importing a Component](#importing-a-component) - - [`Button.tsx`](#buttontsx) + - [`ButtonExample.tsx`](#buttonexampletsx) - [`ButtonAndMore.tsx`](#buttonandmoretsx) - [Styling with Emotion](#styling-with-emotion) - - [`Button.tsx`](#buttontsx-1) + - [`Button.tsx`](#buttontsx) - [`RedButton.tsx`](#redbuttontsx) - [Adding Custom Environment Variables](#adding-custom-environment-variables) - [Adding Temporary Environment Variables In Your Shell](#adding-temporary-environment-variables-in-your-shell) @@ -67,13 +66,14 @@ Below you will find some information on how to perform common tasks.
- [Editor Integration](#editor-integration) - [Developing Components in Isolation](#developing-components-in-isolation) - [Troubleshooting](#troubleshooting) + - [How to fix it](#how-to-fix-it) - [Usefull VSCode extensions](#usefull-vscode-extensions) ## Folder Structure This monorepo is structured as follows -``` +```text monorepo/ README.md node_modules/ @@ -100,13 +100,13 @@ In the project directory, you can run: Run -``` +```sh yarn ``` to install the projects dependencies, and the dependencies within the different workspaces. You can run also -``` +```sh yarn `command` ``` @@ -114,16 +114,16 @@ which will do whatever `command` does, and must be defined on `scripts` section ### `yarn start:webapp` -Runs the Main web application in the development mode.
+Runs the Main web application in the development mode. Open [http://localhost:3000](http://localhost:3000) to view it in the browser. -The page will reload if you make edits.
+The page will reload if you make edits. You will also see any lint errors in the console. ### `yarn build:webapp` -Generates the build folder of the compiled files for Main web application
-The build is minified and the filenames include the hashes.
+Generates the build folder of the compiled files for Main web application +The build is minified and the filenames include the hashes. Your app is ready to be deployed! ### `yarn build:dep:webapp` @@ -132,21 +132,30 @@ Same as `yarn build:webapp` but it moves the files to the root directory. ### `yarn test:webapp` -Launches the test runner for the Main web application.
+Launches the test runner for the Main web application. See the section about [running tests](#running-tests) for more information. +### `yarn release:webapp` + +It launches a release for Webapp application. +If there is any commit since the last release starting with: + +- `fix` will do a patch bump +- `feat` will do a minor bump +- `!` will do a major bump. + ### `yarn start:webapp-redux` -Runs the Redux web application in the development mode.
+Runs the Redux web application in the development mode. Open [http://localhost:3000](http://localhost:3000) to view it in the browser. -The page will reload if you make edits.
+The page will reload if you make edits. You will also see any lint errors in the console. ### `yarn build:webapp-redux` -Generates the build folder of the compiled files for Redux web application
-The build is minified and the filenames include the hashes.
+Generates the build folder of the compiled files for Redux web application +The build is minified and the filenames include the hashes. Your app is ready to be deployed! ### `yarn build:dep:webapp-redux` @@ -155,22 +164,30 @@ Same as `yarn build:webapp-redux` but it moves the files to the root directory. ### `yarn test:webapp-redux` -Launches the test runner for the Redux web application.
+Launches the test runner for the Redux web application. See the section about [running tests](#running-tests) for more information. +### `yarn release:webapp-redux` + +It launches a release for Webapp Redux application. + +- `fix` will do a patch bump +- `feat` will do a minor bump +- `!` will do a major bump. + ### `yarn start:common` -Runs the Common components library in the development mode.
+Runs the Common components library in the development mode. Open [http://localhost:9000](http://localhost:9000) to view it in the browser. -The page will reload if you make edits.
+The page will reload if you make edits. You will also see any lint errors in the console. ### `yarn build:common` -Generates the build folder of the compiled files for Common components library
-The build is minified and the filenames include the hashes.
-It will generate a static folder that can be deployed anywhere.
+Generates the build folder of the compiled files for Common components library +The build is minified and the filenames include the hashes. +It will generate a static folder that can be deployed anywhere. ### `yarn build:dep:common` @@ -178,88 +195,78 @@ Same as `yarn build:common` but it moves the files to the root directory. ### `yarn test:common` -Launches the test runner for the Common components library.
+Launches the test runner for the Common components library. See the section about [running tests](#running-tests) for more information. +### `yarn release:common` + +It launches a release for Common library. + +- `fix` will do a patch bump +- `feat` will do a minor bump +- `!` will do a major bump. + ### `yarn clean` -Removes `dist` folder.
+Removes `dist` folder. ### `yarn clean:install` -Removes `node_modules` folder and executes installation command.
+Removes `node_modules` folder and executes installation command. ### `yarn build` -Generates builds for Common components library and Main web application
+Generates builds for Common components library and Main web application ### `yarn test` -Launches the test runner for entire monorepo.
+Launches the test runner for entire monorepo. See the section about [running tests](#running-tests) for more information. ### `yarn test:watch` -Launches the test runner in interactive mode for entire ts-monorepo.
+Launches the test runner in interactive mode for entire ts-monorepo. See the section about [running tests](#running-tests) for more information. ### `yarn test:ci` -Launches the test runner for entire ts-monorepo and generates the coverage folder.
+Launches the test runner for entire ts-monorepo and generates the coverage folder. See the section about [running tests](#running-tests) for more information. ### `yarn lint` -Launches eslint checker in the entire monorepo.
+Launches eslint checker in the entire monorepo. ### `yarn release` -Releases an automatic version bump based on commit messages and generates the Changelog.md.
- -### `yarn release:patch` - -Releases a patch version bump based on commit messages and generates the Changelog.md.
- -### `yarn release:minor` - -Releases a minor version bump based on commit messages and generates the Changelog.md.
- -### `yarn release:major` - -Releases a major version bump based on commit messages and generates the Changelog.md.
- -### `yarn release:tags` - -Releases an automatic version bump based on commit messages and generates the Changelog.md. It generate Git tags and pushes them.
+Releases an automatic version bump based on commit messages and generates the Changelog.md. ### `yarn ncu` -Checks the dependencies in all `package.json` files to see if there are updates.
+Checks the dependencies in all `package.json` files to see if there are updates. ## Generate changelog -To generate the changelog from the latest git tag, follow the next steps: +To generate the changelog from the latest git tag for a given package, follow the next steps: -1. Open a branch `chore/release` from latest `master` -2. Execute one of the `release` commands (_release_, _release:patch_, _release:minor_, _release:major_) - 1. This command will update the [CHANGELOG.md](./CHANGELOG.md) adding the commits from the latest git tag - 2. Then an automatic commit will be created and will tag the commit with the new tag according to the version number of the main `package.json` -3. Push the changes with the tags with `git push --follow-tags origin chore/release` -4. Open a PR and **merge** the `chore/release` branch (DO NOT SQUASH IT) into `master` branch - -You can run `yarn release:tags` that will run steps `2` to `3` but it will decide automatically which version to apply, (_patch_, _minor_, _major_) +1. Open a branch `chore/release-packageName` from latest `master` +2. Execute one of the `release` commands (_release_, _release:packageName_) + 1. This command will update the `CHANGELOG.md` of the given package, or all `CHANGELOG.md` files if not package has been selected + 2. Then an automatic commit will be created and will tag the commit with the new tag according to the version number of the package json file of the package. The package.json of the root directory will always be 1.0.0 +3. Push the changes with the tags with `git push --follow-tags origin chore/release-packageName` +4. Open a PR and **merge** the `chore/release-packageName` branch (**DO NOT SQUASH IT**) into `master` branch ## Installing a Dependency You may install other dependencies with `yarn`. The flag `-W` indicates that the dependency must be installed in the package.json at root level. -``` +```sh yarn -W add ``` If you want to install a dependency in a specific workspace, then you can do: -``` +```sh yarn workspace add ``` @@ -267,7 +274,7 @@ yarn workspace add You can install globally [npm-check-updates](https://www.npmjs.com/package/npm-check-updates) and run: -``` +```sh ncu ``` @@ -275,29 +282,29 @@ that will show the dependencies with new versions available to download. With the following command, you will be able to upgrade versions number: -``` +```sh ncu -u ``` and then -``` +```sh yarn ``` ## Importing a Component -This project setup supports ES6 modules thanks to Babel.
+This project setup supports ES6 modules thanks to Babel. While you can still use `require()` and `module.exports`, we encourage you to use [`import` and `export`](http://exploringjs.com/es6/ch_modules.html) instead. For example: -### `Button.tsx` +### `ButtonExample.tsx` ```js import React from 'react' -export const Button: React.FunctionComponent = () => { +export const ButtonExample: React.FunctionComponent = () => { ... } ``` @@ -306,11 +313,11 @@ export const Button: React.FunctionComponent = () => { ```js import React from 'react'; -import { Button } from './Button'; // Import a component from another file +import { ButtonExample } from './ButtonExample'; // Import a component from another file export const ButtonAndMore: React.FunctionComponent = () => { <> -