diff --git a/tooling/scripts/src/license.mjs b/tooling/scripts/src/license.mjs index 4cdc075ca..91d05e189 100644 --- a/tooling/scripts/src/license.mjs +++ b/tooling/scripts/src/license.mjs @@ -1,13 +1,16 @@ 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.username').toString().trim(); + gitUser = execSync('git config user.username').toString().trim(); if (!gitUser) { gitUser = execSync('git config user.name').toString().trim(); @@ -50,7 +53,9 @@ async function checkLicense() { return Promise.resolve(); } else { return Promise.reject( - new Error(`License check failed. Please set the git user name with the command 'git config user.username '. The username needs to match the GitHub username in your Makerkit organization.`), + new Error( + `License check failed. Please set the git user name with the command 'git config user.username '. The username needs to match the GitHub username in your Makerkit organization.`, + ), ); } } @@ -107,8 +112,33 @@ function checkVisibility() { }); } +async function isOnline() { + const { lookup } = await import('dns'); + + try { + return await new Promise((resolve, reject) => { + lookup('google.com', (err) => { + if (err && err.code === 'ENOTFOUND') { + reject(false); + } else { + resolve(true); + } + }); + }).catch(() => false); + } catch (e) { + return false; + } +} + async function main() { try { + const isUserOnline = await isOnline(); + + // disable the check if the user is offline + if (!isUserOnline) { + return process.exit(0); + } + await checkVisibility(); await checkLicense().catch((error) => { diff --git a/tooling/scripts/src/requirements.mjs b/tooling/scripts/src/requirements.mjs index 861989b13..31e32d706 100644 --- a/tooling/scripts/src/requirements.mjs +++ b/tooling/scripts/src/requirements.mjs @@ -37,7 +37,7 @@ function checkPnpmVersion() { } // warn if the minor version is less than 12 - if (minor < 12) { + if (major < 9 && minor < 12) { console.warn( `\x1b[33m%s\x1b[0m`, `You are running pnpm ${currentPnpmVersion}. Makerkit recommends using pnpm 9.12.0 or higher.`,