Added license checker

This commit is contained in:
gbuomprisco
2024-09-22 11:53:54 +02:00
parent 8d13d31162
commit 1433acfff7
6 changed files with 78 additions and 0 deletions

2
pnpm-lock.yaml generated
View File

@@ -1467,6 +1467,8 @@ importers:
specifier: ^5.6.2
version: 5.6.2
tooling/license: {}
tooling/prettier:
dependencies:
'@ianvs/prettier-plugin-sort-imports':

View 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
View File

@@ -0,0 +1,6 @@
#!/bin/sh
set -e
sh visibility.sh
sh license.sh

View File

@@ -0,0 +1,8 @@
{
"name": "license",
"private": true,
"version": "0.1.0",
"scripts": {
"dev": "sh main.sh"
}
}

View 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

View File

@@ -92,6 +92,9 @@
},
"//#clean": {
"cache": false
},
"license#dev": {
"outputLogs": "none"
}
}
}