Added license checker
This commit is contained in:
23
tooling/license/license.sh
Normal file
23
tooling/license/license.sh
Normal file
@@ -0,0 +1,23 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
if [ "$NODE_ENV" = "production" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
GIT_USER=$(git config user.name)
|
||||
GIT_EMAIL=$(git config user.email)
|
||||
|
||||
if [ -z "$GIT_USER" ]; then
|
||||
echo "Please set the git user name with the command 'git config user.name <username>'. The username needs to match the username in your Makerkit organization."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
STATUS_CODE=$(curl -s -o /dev/null -w "%{http_code}" -X GET "https://makerkit.dev/api/license/check?username=$GIT_USER&email=$GIT_EMAIL")
|
||||
|
||||
if [ "$STATUS_CODE" = "200" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
exit 1
|
||||
6
tooling/license/main.sh
Normal file
6
tooling/license/main.sh
Normal file
@@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
sh visibility.sh
|
||||
sh license.sh
|
||||
8
tooling/license/package.json
Normal file
8
tooling/license/package.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"name": "license",
|
||||
"private": true,
|
||||
"version": "0.1.0",
|
||||
"scripts": {
|
||||
"dev": "sh main.sh"
|
||||
}
|
||||
}
|
||||
36
tooling/license/visibility.sh
Normal file
36
tooling/license/visibility.sh
Normal file
@@ -0,0 +1,36 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
remote_url=$(git config --get remote.origin.url)
|
||||
|
||||
if [[ $remote_url == *"github.com"* ]]; then
|
||||
if [[ $remote_url == https://github.com/* ]]; then
|
||||
owner_repo=${remote_url#https://github.com/}
|
||||
elif [[ $remote_url == git@github.com:* ]]; then
|
||||
owner_repo=${remote_url#git@github.com:}
|
||||
else
|
||||
echo "Unsupported GitHub URL format"
|
||||
exit 1
|
||||
fi
|
||||
owner_repo=${owner_repo%.git}
|
||||
|
||||
api_url="https://api.github.com/repos/$owner_repo"
|
||||
response=$(curl -s -o /dev/null -w "%{http_code}" $api_url)
|
||||
|
||||
if [ $response -eq 200 ]; then
|
||||
visibility=$(curl -s $api_url | grep -o '"private": \(true\|false\)' | awk '{print $2}')
|
||||
if [ "$visibility" = "false" ]; then
|
||||
echo "The repository has been LEAKED on GitHub. Please delete the repository. A DMCA Takedown Request will automatically be requested in the coming hours."
|
||||
exit 1
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
elif [ $response -eq 404 ]; then
|
||||
exit 0
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
Reference in New Issue
Block a user