Updated license checker to log errors; updated dependencies.
This commit is contained in:
@@ -1,27 +1,41 @@
|
||||
import { execSync } from 'child_process';
|
||||
|
||||
const endpoint = 'https://makerkit.dev/api/license/check';
|
||||
|
||||
async function checkLicense() {
|
||||
let gitUser, gitEmail;
|
||||
|
||||
try {
|
||||
gitUser = execSync('git config user.name').toString().trim();
|
||||
gitEmail = execSync('git config user.email').toString().trim();
|
||||
} catch (error) {
|
||||
console.error('Error getting git config:', error.message);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (!gitUser) {
|
||||
console.error(
|
||||
"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.",
|
||||
throw new Error(
|
||||
"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.",
|
||||
);
|
||||
}
|
||||
|
||||
process.exit(1);
|
||||
try {
|
||||
gitEmail = execSync('git config user.email').toString().trim();
|
||||
} catch (error) {
|
||||
console.info('Error getting git config:', error.message);
|
||||
}
|
||||
|
||||
const searchParams = new URLSearchParams();
|
||||
|
||||
searchParams.append('username', gitUser);
|
||||
|
||||
if (gitEmail) {
|
||||
searchParams.append('email', gitEmail);
|
||||
}
|
||||
|
||||
const res = await fetch(
|
||||
`https://makerkit.dev/api/license/check?username=${encodeURIComponent(gitUser)}&email=${encodeURIComponent(gitEmail)}`,
|
||||
`${endpoint}?${searchParams.toString()}`,
|
||||
);
|
||||
|
||||
if (res.status === 200) {
|
||||
return Promise.resolve();
|
||||
} else {
|
||||
@@ -39,7 +53,7 @@ function checkVisibility() {
|
||||
.toString()
|
||||
.trim();
|
||||
} catch (error) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
if (!remoteUrl.includes('github.com')) {
|
||||
@@ -77,20 +91,19 @@ function checkVisibility() {
|
||||
console.error(
|
||||
'The repository has been LEAKED on GitHub. Please delete the repository. A DMCA Takedown Request will automatically be requested in the coming hours.',
|
||||
);
|
||||
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function main() {
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await checkVisibility();
|
||||
await checkLicense();
|
||||
} catch (error) {
|
||||
console.error(`Check failed with error: ${error.message}`);
|
||||
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user