background

An application needs to be deployed in multiple regions (region/city/country), and the version varies according to region. For example, 1.0.0 needs to be deployed in region A, 1.1.0 in region B, and 2.0.0 in region C.

Assume the following directory structure

app/
  common/ # Application function core code, public resources.
  area-1/ Locale-specific resources such as configuration files, static data, etc.
  area-2/
  area-3/
  ...
  area-n/
  package.json
Copy the code

Branch management

The branch management model in this paper references A successful Git Reference model adjustment.

  • Master: Development branch. Code pulled from master is always up to date.
  • Prod /* : Regional production branch. Each region has its own production branch for regional deployment.
  • Feat: Function branch, merged into master, deleted
  • Fix: Fixes the branch, merges it into the master and related region production branch, and deletes it after merging.

Submit code

Refer to Conventional Commits.

Each commit is prefixed to indicate what the code change is for the commit.

  • feat(scope):: New module, new function, new component, etc.
  • fix(scope):: Functional bug fixes.
  • style(scope):: Style changes, pure CSS changes.
  • docs(scope):: Document changes, such as README.
  • refactor(scope):: Code refactoring. Note that code refactoring refers to refactoring existing code using better algorithms or logic without changing any existing functionality.
  • build(scope):: Build (compile/package) related, such as change webpack configuration, change Babel configuration, etc.
  • chore(scope):: Miscellaneous items unrelated to the previous type. Such as redundant code cleaning, adding and deleting comments.

Each prefix has a scope, which indicates the change scope of the module, component, or file name. For example, feat(Auth): Add Reset Password. It is possible that the scope cannot be specified, in which case this part can be omitted, for example chore: Clean Up Redundant Code.

Note: Don’t try to do multiple things in one commit. It’s a good habit to commit everything once.

Version management

Currently, front-end projects are basically inseparable from the package management tool NPM, so we can use NPM version management policies and commands to achieve version management.

Release notes

Define the version number format as major.minor.patch.

  • Major: Major releases, such as architecture tweaks, framework tweaks, backwards-incompatible changes, etc.
  • Minor: A minor version that adds new features, etc.
  • Patch: Patch version, such as bug fixes.

Operation command

Reference NPM version

npm version [major|minor|patch]
Copy the code

The NPM version command does two operations at a time

  • Update the version field of package.json and package-lock.json.
  • Add a git tag with the new version number.

Comments or suggestions are welcome.