diff --git a/docs/other/tips/angular.md b/docs/other/tips/angular.md new file mode 100644 index 00000000..3fd8c233 --- /dev/null +++ b/docs/other/tips/angular.md @@ -0,0 +1,38 @@ +--- +title: Angular +--- +## Tips and Tricks for Angular + +### Build with 0 downtime on Angular + +The recommended way to have 0 downtime it's using dockerized builds with a docker registry service. +In case that this isn't possible in your project, here you have a quick fix. + +Create this folders on `/dist`: + +1. `/dist/previousbuild` +1. `/dist/nginx` (the new production path) + +`package.json` add on `scripts` section: +```json +... +"prebuild": "rm -rf dist/previousbuild", +"build": "ng build --prod --source-map --optimization=true --buildOptimizer=true --progress=true", +"postbuild": "mv dist/nginx dist/previousbuild && mv dist/tempbuild dist/nginx", +... +``` + +`angular.json` add on `projects -> *projectname* -> architect -> build -> options`: +```json +... +"outputPath": "dist/tempbuild", +... +``` + +And the result: + +1. on build starts, the folder `previousbuild` will be erased +1. the new build will be created on `tempbuild` +1. when the new build is done, the previous production build will move to `previousbuild` and the new one will be on + `nginx` folder +1. in case that you need to recover the previous version, you only need rename the two folders diff --git a/docs/other/tips/git.md b/docs/other/tips/git.md new file mode 100644 index 00000000..5b1c7184 --- /dev/null +++ b/docs/other/tips/git.md @@ -0,0 +1,56 @@ +--- +title: Git +--- +## Tips and Tricks for Git + +### Git Submodules + +```bash +// 1. Add submodule to a new repo +git submodule add https://github.com/chaconinc/DbConnector + +// 2. Updating repo with new submodule +git pull +git submodule update --init --recursive + +// 2. Or Cloning repo with new submodule +git clone --recurse-submodules https://github.com/chaconinc/MainProject + +// 3. Pulling repo with submodules +git pull --recurse-submodules +``` + +by [git](https://git-scm.com/book/en/v2/Git-Tools-Submodules) + +### Delete branch locally and remotely + +```bash +// 1. locally +git branch -d localBranchName + +// 2. remote +git push origin :remoteBranchName +``` + +by [FreeCodeCamp](https://forum.freecodecamp.org/t/how-to-delete-a-git-branch-both-locally-and-remotely/13211) + +### Apply .gitignore to committed files + +```bash +// Edit your .gitignore with the file to ignore and run +git rm --cached /path/to/file +``` + +by [SO](https://stackoverflow.com/questions/7527982/applying-gitignore-to-committed-files) + +### Git ignore file mode (chmod) changes + +```bash +// Only current repo +git config core.fileMode false + +// General +git config --global core.fileMode false +``` + +by [SO](https://stackoverflow.com/questions/1580596/how-do-i-make-git-ignore-file-mode-chmod-changes) diff --git a/docs/other/tips/node.md b/docs/other/tips/node.md new file mode 100644 index 00000000..079b1d4e --- /dev/null +++ b/docs/other/tips/node.md @@ -0,0 +1,10 @@ +--- +title: Node +--- +## Tips and Tricks for Node + +### npm install + +Unlike with PHP `composer install`, the command `npm install` takes `package.json` and resolves the dependencies which means that you might introduce a version different from the one you tested on. + +For deploys, CI or initial local environment setup, the **recommended** way to install the dependencies of a project is using `npm ci`. diff --git a/src/sidebars.js b/src/sidebars.js index 12e5cbe3..48ae1a2a 100644 --- a/src/sidebars.js +++ b/src/sidebars.js @@ -150,6 +150,15 @@ module.exports = { } ] }, + { + type: 'category', + label: 'Tips and Tricks', + items: [ + 'other/tips/node', + 'other/tips/angular', + 'other/tips/git' + ] + }, { type: 'category', label: 'Old',