Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frontend/script for license #2495

Closed
wants to merge 12 commits into from
Closed
10 changes: 10 additions & 0 deletions webapp/.husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env sh
source ./webapp/scripts/license.sh

add_missed_license "/*
* CloudBeaver - Cloud Database Manager
* Copyright (C) 2020-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0.
* you may not use this file except in compliance with the License.
*/" "^.+\.(ts|tsx|css|scss)$"
5 changes: 4 additions & 1 deletion webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
},
"scripts": {
"prebuild": "lerna run gql:gen --stream --parallel",
"pretest": "lerna run gql:gen --stream --parallel && yarn lerna run test --scope @cloudbeaver/tests-runner"
"pretest": "lerna run gql:gen --stream --parallel && yarn lerna run test --scope @cloudbeaver/tests-runner",
"prepare": "cd .. && husky ./webapp/.husky",
"postinstall": "husky"
},
"devDependencies": {
"@testing-library/dom": "^9.3.4",
Expand All @@ -31,6 +33,7 @@
"@types/react": "^18.2.63",
"@types/react-dom": "^18.2.19",
"concurrently": "^8.2.2",
"husky": "^9.0.11",
"lerna": "5.5.4",
"mobx": "^6.12.0",
"mobx-react-lite": "^4.0.5",
Expand Down
21 changes: 21 additions & 0 deletions webapp/scripts/license.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

add_missed_license() {
local TEXT="$1"
local FILES_PATH="$2"
TEXT=$(echo "$TEXT" | tr '\n' '\0' | xargs -0 -n1)
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACMR | grep -E "$FILES_PATH" || true)
HAS_FILES_WITHOUT_LICENSE=false

for FILE in $STAGED_FILES; do
if ! grep -Fxq "$TEXT" "$FILE"; then
HAS_FILES_WITHOUT_LICENSE=true
echo "$TEXT\n$(cat "$FILE")" > "$FILE"
fi
done

if [ "$HAS_FILES_WITHOUT_LICENSE" = true ]; then
echo "Found files without license header. Please check the git Changes wether the license headers were added correctly"
exit 1
fi
}
7 changes: 6 additions & 1 deletion webapp/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10522,6 +10522,11 @@ humanize-ms@^1.2.1:
dependencies:
ms "^2.0.0"

husky@^9.0.11:
version "9.0.11"
resolved "https://registry.yarnpkg.com/husky/-/husky-9.0.11.tgz#fc91df4c756050de41b3e478b2158b87c1e79af9"
integrity sha512-AB6lFlbwwyIqMdHYhwPe+kjOC3Oc5P3nThEoW/AaO2BX3vJDjWPFxYLxokUZOo6RNX20He3AaT8sESs9NJcmEw==

[email protected], iconv-lite@^0.4.24:
version "0.4.24"
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b"
Expand Down Expand Up @@ -15640,7 +15645,7 @@ rc@^1.2.7:
strip-json-comments "~2.0.1"

"react-data-grid@file:packages/plugin-react-data-grid/react-data-grid-dist":
version "7.0.0-beta.41"
version "7.0.0-beta.42"
dependencies:
clsx "^2.0.0"

Expand Down
Loading