#/// git stash ///
#/// git stash pop /// перенести изменения в нужную ветку
Инициализация:
git init // Инициализация локального репозитория
git remout ...репозиторий... // клонирование удаленного репозитория
git clone ...репозиторий... _/
git branch -M main // создание основной ветки main или master
git commit -m"init" --allow-empty // пустой коммит
#/////
###2. NODE.js // nvm - установка любой версии NODE // https://github.com/nvm-sh/nvm
npm init -y /// базовый (пустой) package.json
git repository: ...репозиторий
keywords: ...ключевые слова
/// .gitignore -> node_modules
###3. JEST /// Запуск тестов
npm install jest @types/jest -D /// установка JEST в DEV -D
npx jest --init // инициализация конфиг jest
✔ Would you like to use Jest when running "test" script in "package.json"? ... yes
✔ Would you like to use Typescript for the configuration file? ... no
✔ Choose the test environment that will be used for testing › ... jsdom (browser-like)
✔ Do you want Jest to add coverage reports? ... no/yes /// покрытие тестов
✔ Which provider should be used to instrument code for coverage? › ... v8
✔ Automatically clear mock calls and instances between every test? ... yes
npm i jest-environment-jsdom -D //// установка jsdom
создав файл в корне вашего проекта babel.config.js :
presets: [['@babel/preset-env', {targets: {node: 'current'}}]],
npx jest /// запуск тестов
###4.1 ESLINT /// поиск ошибок в коде
npm i eslint -D // установка
npx eslint --init // конфиг
"no-unused-vars": "error",
"lint:fix": "eslint src --fix",
###4.2 ESLint и Jest https://www.npmjs.com/package/eslint-plugin-jest
npm i eslint-plugin-jest -D // установка
import jest from "eslint-plugin-jest";
files: ["src/**/*.test.js"],
...jest.configs['flat/recommended'],
###5. PRETTIER
npm install --save-dev eslint-plugin-prettier eslint-config-prettier // установка
npm install --save-dev --save-exact prettier _/
import eslintRecommended from "eslint-plugin-prettier/recommended";
###6. Lint-Staged /// хуки
npm install --save-dev husky lint-staged
npx husky init // husky config
node --eval "fs.writeFileSync('.husky/pre-commit','npx lint-staged\n')" /// в файле pre-commit прописали npx lint-staged
#7. Sanity check
.github/workflows/sanity-check.yml
создаем папку .github в ней папку workflows в ней файл sanity-check.yml :
#on: pull_request
#jobs:
runs-on: ubuntu-22.04 /// версия 20.04 больше не подерживается
###8. Add codesandbox link
name: Add codesandbox link
#on:
#jobs:
name: Add codesandbox link comment
- uses: mshick/add-pr-comment@v2
v GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
You can check this code at CodeSandbox with the link
#9. Modul
npx -y node-static src // сервер
#10. eslint-config-airbnb-base //// https://www.npmjs.com/package/eslint-config-airbnb-base
npx install-peerdeps --dev eslint-config-airbnb-base
#11. GtHub Pages
#on:
#jobs:
- uses: actions/checkout@v3
uses: peaceiris/actions-gh-pages@v4
github_token: ${{ secrets.GITHUB_TOKEN }}
#12. Webpack
npm install webpack webpack-cli --save-dev
y // none // yes // no //no // none //npm
const path = require('path');
#module.exports = {
path: path.resolve(__dirname, 'dist'),
},
#};
npm install --save-dev html-webpack-plugin
"dev": "webpack serve --mode=development",
"build": "webpack --mode=production",
const path = require('path');
#const HtmlWebpackPlugin = require('html-webpack-plugin');
#module.exports = {
path: path.resolve(__dirname, 'dist'),
},
template: 'src/index.html',
}),
],
directory: path.join(__dirname, 'public'),
},
},
#};