feat: turbostarter boilerplate
Production-ready Next.js boilerplate with: - Runtime env validation (fail-fast on missing vars) - Feature-gated config (S3, Stripe, email, OAuth) - Docker + Coolify deployment pipeline - PostgreSQL + pgvector, MinIO S3, Better Auth - TypeScript strict mode (no ignoreBuildErrors) - i18n (en/es), AI modules, billing, monitoring Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
86
tooling/scripts/src/license.mjs
Normal file
86
tooling/scripts/src/license.mjs
Normal file
@@ -0,0 +1,86 @@
|
||||
import { execSync } from "child_process";
|
||||
|
||||
function validateVisibility() {
|
||||
let remoteUrl;
|
||||
|
||||
try {
|
||||
remoteUrl = execSync("git config --get remote.origin.url")
|
||||
.toString()
|
||||
.trim();
|
||||
} catch (error) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
if (!remoteUrl.includes("github.com")) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
let ownerRepo;
|
||||
|
||||
if (remoteUrl.startsWith("https://github.com/")) {
|
||||
ownerRepo = remoteUrl.slice("https://github.com/".length);
|
||||
} else if (remoteUrl.startsWith("git@github.com:")) {
|
||||
ownerRepo = remoteUrl.slice("git@github.com:".length);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
ownerRepo = ownerRepo.replace(/\.git$/, "");
|
||||
|
||||
return fetch(`https://api.github.com/repos/${ownerRepo}`)
|
||||
.then((res) => {
|
||||
if (res.status === 200) {
|
||||
return res.json();
|
||||
} else if (res.status === 404) {
|
||||
return Promise.resolve();
|
||||
} else {
|
||||
return Promise.reject(
|
||||
new Error(
|
||||
`GitHub API request failed with status code: ${res.status}`,
|
||||
),
|
||||
);
|
||||
}
|
||||
})
|
||||
.then((data) => {
|
||||
if (data && !data.private) {
|
||||
console.error(
|
||||
"The repository has been LEAKED on GitHub. Please delete the repository. A Takedown Request will automatically be requested in the coming hours.",
|
||||
);
|
||||
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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() {
|
||||
const isUserOnline = await isOnline();
|
||||
|
||||
if (!isUserOnline) {
|
||||
return process.exit(0);
|
||||
}
|
||||
|
||||
await validateVisibility();
|
||||
}
|
||||
|
||||
void main().catch((error) => {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in New Issue
Block a user