diff --git a/.gitignore b/.gitignore index 8cfc7624..f269eb8c 100644 --- a/.gitignore +++ b/.gitignore @@ -283,6 +283,9 @@ cypress/videos cypress/screenshots cypress/test-reports +git-crypt-encrypted-files-check.txt + + /server/vbv_lernwelt/static/css/tailwind.css /server/vbv_lernwelt/static/vue/ /server/vbv_lernwelt/templates/vue/index.html diff --git a/README.md b/README.md index 5ec75e70..7bcecbeb 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # VBV Lernwelt -Project setup is based on [cookiecutter-django](https://github.com/cookiecutter/cookiecutter-django) project template. +Project setup is based +on [cookiecutter-django](https://github.com/cookiecutter/cookiecutter-django) project +template. ## Run for development @@ -28,7 +30,6 @@ export IT_APP_ENVIRONMENT=development See `.env_secrets/local_daniel.env` for more possible environment variables. Especially set correct values for `POSTGRES_*` and `DATABASE_URL` - ### Server part Install python dependencies: @@ -37,7 +38,8 @@ Install python dependencies: pip install -r server/requirements/requirements-dev.txt ``` -The "prepare_server.sh" script will create the database according to `POSTGRES_*` environment variables. +The "prepare_server.sh" script will create the database according to `POSTGRES_*` +environment variables. It will also setup the tables for django and run the django development server. ```bash @@ -61,13 +63,32 @@ npm run dev ### General part -Cypress is installed for client and server, so there is this package.json on the project root directory +Cypress is installed for client and server, so there is this package.json on the project +root directory ```bash # in project root directory npm install ``` +### Git hooks + +```bash +# install git hooks +ln -s ../../git-pre-commit.sh .git/hooks/pre-commit +ln -s ../../git-pre-push.sh .git/hooks/pre-push +``` + +### Actions on Save + +You can enable some useful "Actions on Save" in your JetBrains IDE: + +Preferences -> Tools -> Actions on Save + +* Reformat Code +* Optimize Imports +* Run eslint --fix +* Run prettier ## Deployment to CapRover diff --git a/bitbucket-pipelines.yml b/bitbucket-pipelines.yml index 71bec961..ada2ec88 100644 --- a/bitbucket-pipelines.yml +++ b/bitbucket-pipelines.yml @@ -6,6 +6,19 @@ pipelines: - step: name: python tests max-time: 15 + services: + - postgres + caches: + - vbvpip + script: + - source ./env/bitbucket/prepare_for_test.sh + - python -m venv vbvvenv + - source vbvvenv/bin/activate + - pip install -r server/requirements/requirements-dev.txt + - ./server/run_tests_coverage.sh + - step: + name: python linting + max-time: 15 services: - postgres caches: @@ -17,8 +30,7 @@ pipelines: - pip install -r server/requirements/requirements-dev.txt - git-crypt status -e | sort > git-crypt-encrypted-files-check.txt && diff git-crypt-encrypted-files.txt git-crypt-encrypted-files-check.txt - trufflehog --exclude_paths trufflehog-exclude-patterns.txt --allow trufflehog-allow.json --entropy=True --max_depth=100 . - - ./server/run_tests_coverage.sh -# - ./src/run_pylint.sh + - ufmt check server - step: name: js tests max-time: 15 @@ -30,6 +42,18 @@ pipelines: - pwd - npm install - npm test + - step: + name: js linting + max-time: 15 + caches: + - node + - clientnode + script: + - cd client + - pwd + - npm install + - npm run prettier:check + - npm run lint - step: name: cypress tests max-time: 45 diff --git a/client/.eslintrc.cjs b/client/.eslintrc.cjs index 581abdaf..a466cbee 100644 --- a/client/.eslintrc.cjs +++ b/client/.eslintrc.cjs @@ -1,18 +1,21 @@ /* eslint-env node */ -require('@rushstack/eslint-patch/modern-module-resolution'); +require("@rushstack/eslint-patch/modern-module-resolution"); module.exports = { - 'root': true, - 'extends': [ - 'plugin:vue/vue3-essential', - 'eslint:recommended', - '@vue/eslint-config-typescript/recommended', - // "@vue/eslint-config-prettier" + root: true, + extends: [ + "plugin:vue/vue3-recommended", + "eslint:recommended", + "@vue/eslint-config-typescript/recommended", + "@vue/eslint-config-prettier", ], - 'env': { - 'vue/setup-compiler-macros': true + env: { + "vue/setup-compiler-macros": true, }, - 'rules': { - '@typescript-eslint/no-unused-vars': ['warn'], - } -} + ignorePatterns: ["versionize.js", "tailwind.config.js", "postcss.config.js"], + rules: { + "@typescript-eslint/no-unused-vars": ["warn"], + "@typescript-eslint/ban-ts-comment": ["warn"], + "prefer-const": ["warn"], + }, +}; diff --git a/client/.prettierignore b/client/.prettierignore new file mode 100644 index 00000000..de4d1f00 --- /dev/null +++ b/client/.prettierignore @@ -0,0 +1,2 @@ +dist +node_modules diff --git a/client/.prettierrc b/client/.prettierrc index f63033f0..cce623d3 100644 --- a/client/.prettierrc +++ b/client/.prettierrc @@ -1,6 +1,7 @@ { - "semi": false, - "singleQuote": true, - "tabWidth": 2, - "printWidth": 120 + "semi": true, + "singleQuote": false, + "tabWidth": 2, + "printWidth": 88, + "organizeImportsSkipDestructiveCodeActions": true } diff --git a/client/.vscode/extensions.json b/client/.vscode/extensions.json index 806eacda..738e0ecb 100644 --- a/client/.vscode/extensions.json +++ b/client/.vscode/extensions.json @@ -1,3 +1,6 @@ { - "recommendations": ["johnsoncodehk.volar", "johnsoncodehk.vscode-typescript-vue-plugin"] + "recommendations": [ + "johnsoncodehk.volar", + "johnsoncodehk.vscode-typescript-vue-plugin" + ] } diff --git a/client/README.md b/client/README.md index 629a5f03..9e8c2d7e 100644 --- a/client/README.md +++ b/client/README.md @@ -11,4 +11,5 @@ VBV Frontend `npm run dev` ## Vue layouts + [How layouts are implemented](https://itnext.io/vue-tricks-smart-layouts-for-vuejs-5c61a472b69b) diff --git a/client/index.html b/client/index.html index d51b3bec..e115132f 100644 --- a/client/index.html +++ b/client/index.html @@ -6,7 +6,10 @@ - + diff --git a/client/package.json b/client/package.json index a4dd240a..a0fd247e 100644 --- a/client/package.json +++ b/client/package.json @@ -9,6 +9,8 @@ "coverage": "vitest run --coverage", "typecheck": "vue-tsc --noEmit -p tsconfig.app.json --composite false", "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore", + "prettier": "prettier . --write", + "prettier:check": "prettier . --check", "tailwind": "tailwindcss -i tailwind.css -o ../server/vbv_lernwelt/static/css/tailwind.css --watch" }, "dependencies": { @@ -33,17 +35,20 @@ "@types/lodash": "^4.14.184", "@types/node": "^18.7.14", "@vitejs/plugin-vue": "^3.0.3", + "@volar/vue-typescript": "^0.40.13", "@vue/eslint-config-prettier": "^7.0.0", "@vue/eslint-config-typescript": "^11.0.0", "@vue/test-utils": "^2.0.2", "@vue/tsconfig": "^0.1.3", "autoprefixer": "^10.4.8", "eslint": "8.22.0", + "eslint-config-prettier": "^8.5.0", "eslint-plugin-vue": "^9.4.0", "jsdom": "^20.0.0", "postcss": "^8.4.14", "postcss-import": "^14.1.0", "prettier": "^2.7.1", + "prettier-plugin-organize-imports": "^3.1.1", "replace-in-file": "^6.3.5", "sass": "^1.54.6", "sass-loader": "^12.6.0", diff --git a/client/postcss.config.js b/client/postcss.config.js index 33ad091d..12a703d9 100644 --- a/client/postcss.config.js +++ b/client/postcss.config.js @@ -3,4 +3,4 @@ module.exports = { tailwindcss: {}, autoprefixer: {}, }, -} +}; diff --git a/client/src/App.vue b/client/src/App.vue index b91f07f0..46133b7b 100644 --- a/client/src/App.vue +++ b/client/src/App.vue @@ -1,28 +1,26 @@ diff --git a/client/src/components/Footer.vue b/client/src/components/AppFooter.vue similarity index 80% rename from client/src/components/Footer.vue rename to client/src/components/AppFooter.vue index 25289d1b..927b6d3e 100644 --- a/client/src/components/Footer.vue +++ b/client/src/components/AppFooter.vue @@ -1,7 +1,7 @@