preface
What is a front-end specification
Front-end specification is a set of standards and rules for front-end development behavior
Meaning of norms
- Improve development efficiency, team cooperation efficiency, reduce communication costs
- Reduce the cost of integrating new members into the team, and also avoid digging holes to a certain extent
- Achieve highly uniform code style, improve readability, convenient review, on the other hand, can improve the maintainability of the project
Specification object (process specification)
- Development process specification
- Interaction, design specifications
- Interaction, design and front end docking gauge
- Front-end development specification
- Specification for back-end interfaces and data structures
- Specifications for front-end and back-end interconnection
- Front-end code of conduct
Project development process specification
UI design specification
What are the design specifications?
A normative document that manages and summarizes design elements (Logo, color, font, typography, etc.) and common component resources in the interface and UI.
What is the role of a design specification?
Design specification can solve many problems for the team and greatly improve the efficiency of team collaboration. Its role is mainly reflected in the following aspects:
1. Solve the confusion in the use of team collaboration project controls
A large project with dozens or even hundreds of pages is usually done by a team. If there is no established design specification, it is almost impossible to maintain the uniformity of the same control on different pages. However, if a UI designer creates a design specification before many people collaborate on a project, and the rest of the team follows it, visual unity can be effectively controlled and productivity can be much easier.
2. Maintain brand consistency during product iteration
Iteration is indispensable in the later maintenance process of the product. Without a design specification, after many iterations, it is possible to forget the original design. The LOGO style in version 3 is likely to diverge further and further from version 1. With design specifications, it is easy to maintain the original intention and maintain the brand image in the later iteration process.
3. Greatly improve the work efficiency of developers and reduce unnecessary code duplication
With a design specification, developers can quickly invoke a set of code, greatly increasing productivity.
Existing mature open source component libraries
For Design specifications, it is highly recommended to look at Ant Design’s Design principles, Design values (natural, deterministic), and understanding of human-computer interaction
- Ant Design
- Element UI
Development process specification
Git Flow specification
Git installation and configuration and basic use
- Download the installation package from the official website and install it manually.
- Open the Git Bash command line tool and run the ssh-keygen -t rsa -c emer-addresss command to generate a key pair.
- SSH /id_rsa.pub. Copy the contents of the. SSH /id_rsa.pub file in the user directory to the Key.
- Click New Project, then click Create Project to Create a repository, click Activity, and click SSH to copy the address in the SSH sidebar.
- Open the Git Bash command line tool, switch to an appropriate directory, and use the Git clone command to clone the repository you just copied.
- Git config –global user. Email your-email
- Git config –global user.name your-name
Execute command:
- Git status: check the current status and find untraced files
- Git add. Adds all files in the current directory to the staging area
- Git diff compares the difference between the current workspace and the staging area
- Git status: indicates that a file is not committed
- Git commit -m “comment” to commit the staging contents to the local repository
- Git push -u origin master
- Git log to view commit logs
Git local branch management
Create, merge, and delete branches
- Git branch, showing all branches
- Git branch -a displays all local and remote branches
- Git checkout -b b1, create a branch called b1 from the current branch and switch to branch B1
- Git checkout master
- Git merge b1, merge b1 into master
- Git branch -d b1 indicates that branch B1 cannot be deleted
Git Tag management
Create and delete labels
- Git tag t1 creates a tag named T1 from the current branch
- Git tag -d t1
Naming rules
- Each submission must be annotated, and if it is a Bug fix, please add a Bug number
- Create a feature branch with a name starting with feture/ and adding the feature name
- Create a release branch with a name starting with release/ and a pre-release version number
- Create a Bug fix branch with a name starting with hotfix/ and a Bug number
- Create a label with a name starting with tag/ and a release number
- The –no-ff parameter must be used when merging branches to preserve the merge history
Branch model
Overall flow chart:
Main branch (Protection branch)
The main branch of develop is the one that stabilizes code and prepares it for production.
Auxiliary branch
1. Feature branches
Created from the Develop branch for feature development and merged back into the Develop branch (it is recommended to create merge Request merges online). Operation process:
- Git checkout -b feature/ feature-name develop branch
- Git Checkout Develop, merge back to the Develop branch
- Git merge –no-ff feature/ feature-name
- Git branch -d feature/ feature-name: Deletes a feature branch
- Git push Origin Develop to push the merged Develop branch to a remote repository
The branch relationship is similar to the following figure:
2. Publish branches
Created from the Develop branch for pre-release versions to allow minor bug fixes and then merged back to Develop and Master (recommended to create merge Request merges online). Operation process:
- Git checkou -b release/1.2 develop
- Git checkout master
- Git merge –no-ff release/1.2
- Git tag 1.2, a tag from the master branch
- Git checkou develop, switch to the Develop branch, and prepare the merge
- Git merge –no-ff release/1.2
- Git branch -d release/1.2
3. Repair branches
Created from the Master branch for Bug fixes on the production environment and merged back to Develop and Master (recommended to create merge Request merges online). Operation process:
- Git checkout -b hotfix/1.2.1 master
- Git checkout master
- Git merge –no-ff hotfix/1.2.1
- Git tag 1.2.1 creates a tag for the master branch
- Git Checkout Develop, switch to the Develop branch, and prepare to merge
- Git merge –no-ff hotfix/1.2.1
- Git branch -d hotfix/1.2.1
The branch relationship is similar to the following figure:
Reference:
1.Git – website
2,Git – a concise guide
Git Rebase Flow
Git basic process steps
When you want to develop a new feature, cut off a branch from Master
- // 1. Pull the latest code
- git pull –rebase
- // start a new branch
- Functional Branches:
- git checkout -b feat/xxxx
- Repair branch:
- git checkout -b fix/xxxx
After developing merge Request, if there is no conflict in the merge Request, it is enough to notify the corresponding personnel directly. If there is conflict, please follow the following steps
Second, after the function is developed, it needs to be merged into master. Rebase the latest master branch and merge it
- // 1. Switch the master branch
- git checkout master
- // 2. Pull the latest code
- git pull –rebase
- // 3. Switch to your branch
- git checkout feat/xxx
After the above steps are complete, follow the following steps
- // 1. Rebase on master
- git rebase master
- // 2. If a conflict occurs, manually resolve the conflict
- git add .
- // 3. Move on to the next conflict
- git rebase –continue
- // 4. If all is settled
- git push –force-with-lease
- // 5. We are done, let Mr Directly merge the code
Some other commands for rebase
- // If the current log is not needed
- git rebase –skip
- // If the current rebase needs to be terminated
- git rebase –abort
Git Commit specification
Commit specification format
The most popular Git Commit specification is the one used by angular. js projects: the Header section is a single line with three fields: Type (required), scope (optional), and subject (required).
1, the Header
type:
- Feat: New Feature
- Fix: Fixes bugs
- -Jenny: There are some docs.
- Style: format (changes that do not affect code execution)
- Refactor: refactoring (i.e. code changes that are not new features or bug fixes)
- Test: Adds a test
- Chore: Changes to the build process or helper
scope
Scope is used to specify the scope of the commit impact, such as the data layer, control layer, view layer, and so on, depending on the project. For example, in Angular, $location, $browser, $compile, $rootScope, ngHref, ngClick, ngView, etc. If your changes affect more than one scope, you can use * instead.
subject
Subject is a short description of the commit purpose, no more than 50 characters long. Other notes:
- Start with a verb and use the present first-person tense such as’ change ‘rather than’ changed ‘or’ changes’
- The first letter is lowercase
- Ending without a period (.)
2, the Body
The Body section is a detailed description of the commit, broken into multiple lines. Here’s an example.
- More detailed explanatory text, if necessary. Wrap it to
- about 72 characters or so.
- Further paragraphs come after blank lines.
- – Bullet points are okay, too
- – Use a hanging indent
Note:
- Use the present tense of the first person, such as “change” instead of “changed” or “changes”.
- Never forget that line 2 is blank
- Explain the motivation for the code change and how it compares to previous behavior.
3, Footer
The Footer section is only used in the following two cases: Incompatible changes If the current code is incompatible with the previous version, the Footer section begins with BREAKING CHANGE, followed by a description of the CHANGE, the reason for the CHANGE, and the migration method.
- BREAKING CHANGE: isolate scope bindings definition has changed.
To migrate the code follow the example below: Copy the code
Before: Copy the code
scope: { Copy the code
myAttr: 'attribute', Copy the code
} Copy the code
After: Copy the code
scope: { Copy the code
myAttr: '@', Copy the code
} Copy the code
The removed `inject` wasn't generaly useful for directives so there should be no code using it. Copy the code
Close the Issue
If the current commit is for an issue, you can close the issue in the Footer section.
- Closes #234
Revert
In a special case, if the current COMMIT is used to undo a previous COMMIT, you must start with REVERT:, followed by the headers of the revoked commit.
- revert: feat(pencil): add ‘graphiteWidth’ option
- This reverts commit 667ecc1654a317a13331b17617d973392f415f02.
The format of the Body part is fixed and must be This reverts commit < Hash >., where hash is the SHA identifier that was revoked. If the current commit is in the same release as the revoked commit, neither of them will appear in the Change log. If the two are published at different times, the current commit appears under the Reverts subheading of the Change log.
For example
Git Commit (feat(login)) Add Login Module Feat indicates the commit type, login indicates the domain scope, and Add Login Module indicates the short description of subject for the commit purpose
Git Commit Git Cz
Git CZ tool can be used to achieve standardization. I have also studied and tried it, and it is not bad. Here’s how I tried it:
Git cZ
Git cZ
- Install the plugin Commitizen globally
- npm install -g commitizen
- Go to the git project initializer (install + Configure) where you want to use git cz.
- commitizen init cz-conventional-changelog –save –save-exact
- Now you can use git Cz instead of git commit to generate a professional commit.
Git cz
Just follow the prompts step by step!
- git cz
- # specify the type of commit
- ? Select the type of change that you’re committing:
- This is used to describe the scope of the change in the format of project name/module name
- ? What is the scope of this change (e.g. component or file name): (press enter t** **o skip)
- # Give a short description of the changes
- ? Write a short, imperative tense description of the change (max 83 chars): (11)
- Long description of changes
- ? Provide a longer description of the change: (press enter to skip)
- Is # a destructive change
- ? Are there any breaking changes?
- Does # affect any issue? If yes, enter the issue number next
- ? Does this change affect any open issues?
Commitlint + husky constraint
1. Install CommitLint
- # Install and configure if needed
- npm install –save-dev @commitlint/{cli,config-conventional}
- Initialize the configuration file
- echo “module.exports = {extends: [‘@commitlint/config-conventional’]};” > commitlint.config.js
2. Install HusKY V4
- # Install Husky v5
- NPM install [email protected] – save – dev
- # or
- Yarn add [email protected] – dev
3. Add hooks to package.json
- “husky”: {
"hooks": { Copy the code
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS" Copy the code
} Copy the code
- }
4. Submit the command test
- git commit -m “foo: this will fail”
- Husky > commit- MSG (node v10.1.0)
- No staged files match any of provided globs.
- ⧗ input: foo: this will fail
- * Type must be one of [build, chore, CI, docs, feat, fix, perf, Refactor, Style, test] [Type-enum]
- * Found 1 problems, 0 warnings
- ⓘ Get help: github.com/conventiona…
- husky > commit-msg hook failed (add –no-verify to bypass)
Refer to the website CommitLint:commitlint.js.org/
Version of the specification
Version format: Major version number. The second version number. The increment rule is as follows:
- Major version number: When you make incompatible API changes,
- Minor version number: When you make a backward-compatible feature addition,
- Revision number: When you make a backward compatible problem fix.
The prior version number and version build metadata can be added to the major version number. Second version number. Revision number “is followed as an extension. Reference: 1. Semantic version