From 5bc5bc5cbdd0c0e7de651b3d0f068b7b91241060 Mon Sep 17 00:00:00 2001 From: Samuel Abt Date: Tue, 20 Dec 2022 17:59:45 +0100 Subject: [PATCH 1/3] feat: [apache/streampipes#771] add husky pre commit hook for linting --- ui/.husky/pre-commit | 4 ++++ ui/.lintstagedrc.json | 4 ++++ ui/package.json | 16 ++++++++++++---- 3 files changed, 20 insertions(+), 4 deletions(-) create mode 100755 ui/.husky/pre-commit create mode 100644 ui/.lintstagedrc.json diff --git a/ui/.husky/pre-commit b/ui/.husky/pre-commit new file mode 100755 index 0000000000..a0951ea805 --- /dev/null +++ b/ui/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +cd ui && npm run lint-staged diff --git a/ui/.lintstagedrc.json b/ui/.lintstagedrc.json new file mode 100644 index 0000000000..ca7497c491 --- /dev/null +++ b/ui/.lintstagedrc.json @@ -0,0 +1,4 @@ +{ + "*.*": "prettier --check", + "src/**/*.ts": ["ng-lint-staged lint --"] +} diff --git a/ui/package.json b/ui/package.json index 9c7934c00d..c424637cc9 100644 --- a/ui/package.json +++ b/ui/package.json @@ -18,11 +18,16 @@ "run-prebuild-script": "node ./deployment/prebuild.js", "build": "node ./deployment/prebuild.js && set NODE_OPTIONS=--max-old-space-size=8192 && npm run build-libraries && ng build --configuration production", "build-dev": "node ./deployment/prebuild.js && set NODE_OPTIONS=--max-old-space-size=8192 && npm run build-libraries && ng build", - "lint": "prettier --check . && ng lint", + "lint": "ng lint", + "lint:fix": "ng lint --fix", + "format": "prettier --check .", + "format:fix": "prettier --fix .", + "lint-staged": "lint-staged", "analyze": "webpack-bundle-analyzer dist/stats.json", "test-cypress-open": "cypress open", "test-cypress-smoke": "npx cypress run --spec 'cypress/tests/**/*.smoke.spec.ts'", - "test-cypress-all": "npx cypress run --spec 'cypress/tests/**/*.spec.ts'" + "test-cypress-all": "npx cypress run --spec 'cypress/tests/**/*.spec.ts'", + "prepare": "cd ../ && husky install ./ui/.husky" }, "peerDependencies": { "@streampipes/platform-services": "0.0.1", @@ -120,9 +125,10 @@ "csv-string": "^4.1.0", "cypress": "^10.9.0", "cypress-file-upload": "^5.0.8", - "eslint": "8.22.0", + "eslint": "8.28.0", "eslint-config-prettier": "^8.5.0", "html-webpack-plugin": "^5.5.0", + "husky": "^8.0.2", "jasmine-core": "^3.6.0", "js-yaml": "^3.14.0", "karma": "~6.3.4", @@ -132,10 +138,12 @@ "karma-jasmine": "~4.0.0", "karma-jasmine-html-reporter": "^1.5.0", "karma-verbose-reporter": "0.0.6", + "lint-staged": "^13.1.0", "mustache": "^2.3.0", + "ng-lint-staged": "^12.0.4", "ng-packagr": "^14.2.2", "path": "^0.12.7", - "prettier": "1.14.2", + "prettier": "2.8.0", "raw-loader": "^4.0.2", "resize-observer-polyfill": "^1.5.1", "to-string-loader": "^1.1.5", From e6d981dabf7e65441c8912c28494fc866b5d5329 Mon Sep 17 00:00:00 2001 From: Samuel Abt Date: Tue, 20 Dec 2022 22:45:44 +0100 Subject: [PATCH 2/3] fix: [apache/streampipes#771] add missing apache header --- ui/.husky/pre-commit | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ui/.husky/pre-commit b/ui/.husky/pre-commit index a0951ea805..1adc974da7 100755 --- a/ui/.husky/pre-commit +++ b/ui/.husky/pre-commit @@ -1,3 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + #!/usr/bin/env sh . "$(dirname -- "$0")/_/husky.sh" From 88287d5115ab9ba455b2d572ab9a9dd52b9b3d8f Mon Sep 17 00:00:00 2001 From: Samuel Abt Date: Tue, 20 Dec 2022 23:14:13 +0100 Subject: [PATCH 3/3] docs: [apache/streampipes#771] add README for ui --- ui/README.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 ui/README.md diff --git a/ui/README.md b/ui/README.md new file mode 100644 index 0000000000..72e8d47c85 --- /dev/null +++ b/ui/README.md @@ -0,0 +1,38 @@ + + +# Streampipes UI + +## Development + +Please make sure you have a recent version of [node](https://nodejs.org/en/) and npm (bundled with node) installed. + +To build the ui, perform the following steps: + +``` + npm install + # for NPM > v7, run npm install --legacy-peer-deps + npm run build +``` + +### Formatting and Linting + +Running `npm install` will cause a pre-commit hook to be created. +This hook ensures that if you want to commit changes to this repository, these changes are compliant with our [formatting](https://prettier.io/) and [linting](https://eslint.org/) rules. + +If you see errors there, you can try to run `npm run format:fix` and `npm run lint:fix` to fix these issues automatically. Otherwise you have to run `npm run format` and `npm run lint` to get additional information about the problems.