mirror of https://github.com/buster-so/buster.git
fix: update .gitignore to properly ignore dist folder and remove tracked dist files
This commit is contained in:
parent
32792e6212
commit
da11cd8b30
|
@ -1,5 +1,90 @@
|
|||
dist*
|
||||
node_modules*
|
||||
/dist/
|
||||
# Dependencies
|
||||
node_modules/
|
||||
|
||||
**/dist/*
|
||||
# Build outputs
|
||||
dist/
|
||||
build/
|
||||
*.tsbuildinfo
|
||||
|
||||
# Environment files
|
||||
.env
|
||||
.env.local
|
||||
.env.*.local
|
||||
|
||||
# IDE files
|
||||
.vscode/
|
||||
.idea/
|
||||
*.swp
|
||||
*.swo
|
||||
|
||||
# OS files
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# Logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage/
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Dependency directories
|
||||
jspm_packages/
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Microbundle cache
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
.parcel-cache
|
||||
|
||||
# next.js build output
|
||||
.next
|
||||
|
||||
# nuxt.js build output
|
||||
.nuxt
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# TernJS port file
|
||||
.tern-port
|
File diff suppressed because one or more lines are too long
|
@ -1,13 +0,0 @@
|
|||
export declare function loadRootEnv(): void;
|
||||
export interface EnvValidationResult {
|
||||
hasErrors: boolean;
|
||||
missingVariables: string[];
|
||||
}
|
||||
export interface EnvValidationOptions {
|
||||
skipInCI?: boolean;
|
||||
skipInProduction?: boolean;
|
||||
skipInDocker?: boolean;
|
||||
}
|
||||
export declare function validateEnv(requiredVars: Record<string, string | undefined>, options?: EnvValidationOptions): EnvValidationResult;
|
||||
export declare function createValidateEnvScript(requiredEnvVars: string[]): string;
|
||||
//# sourceMappingURL=index.d.ts.map
|
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAsBA,wBAAgB,WAAW,IAAI,IAAI,CAelC;AAED,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,OAAO,CAAC;IACnB,gBAAgB,EAAE,MAAM,EAAE,CAAC;CAC5B;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAGD,wBAAgB,WAAW,CACzB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,EAChD,OAAO,GAAE,oBAAyB,GACjC,mBAAmB,CAwCrB;AAGD,wBAAgB,uBAAuB,CAAC,eAAe,EAAE,MAAM,EAAE,GAAG,MAAM,CAyBzE"}
|
|
@ -1,95 +0,0 @@
|
|||
import { existsSync } from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { config } from 'dotenv';
|
||||
// Get the directory of the current module
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
// Find the root of the monorepo (where turbo.json is)
|
||||
function findMonorepoRoot() {
|
||||
let currentDir = __dirname;
|
||||
while (currentDir !== '/') {
|
||||
if (existsSync(path.join(currentDir, 'turbo.json'))) {
|
||||
return currentDir;
|
||||
}
|
||||
currentDir = path.dirname(currentDir);
|
||||
}
|
||||
throw new Error('Could not find monorepo root (turbo.json)');
|
||||
}
|
||||
// Load environment variables from root .env file
|
||||
export function loadRootEnv() {
|
||||
let envPath;
|
||||
try {
|
||||
const rootDir = findMonorepoRoot();
|
||||
envPath = path.join(rootDir, '.env');
|
||||
if (!existsSync(envPath)) {
|
||||
// If .env does not exist in root, fallback to .env in current directory
|
||||
envPath = path.join(__dirname, '.env');
|
||||
}
|
||||
}
|
||||
catch {
|
||||
// If monorepo root not found, fallback to .env in current directory
|
||||
envPath = path.join(__dirname, '.env');
|
||||
}
|
||||
config({ path: envPath });
|
||||
}
|
||||
// Validate required environment variables
|
||||
export function validateEnv(requiredVars, options = {}) {
|
||||
const { skipInCI = true, skipInProduction = true, skipInDocker = true } = options;
|
||||
console.info('🔍 Validating environment variables...');
|
||||
// Skip validation in certain environments
|
||||
if ((skipInDocker && process.env.DOCKER_BUILD) ||
|
||||
(skipInCI && process.env.CI) ||
|
||||
(skipInProduction && process.env.NODE_ENV === 'production')) {
|
||||
console.info('🐳 Docker/CI/Production build detected - skipping environment validation');
|
||||
return { hasErrors: false, missingVariables: [] };
|
||||
}
|
||||
const missingVariables = [];
|
||||
for (const [envKey, value] of Object.entries(requiredVars)) {
|
||||
if (!value) {
|
||||
console.error(`❌ Missing required environment variable: ${envKey}`);
|
||||
missingVariables.push(envKey);
|
||||
}
|
||||
else {
|
||||
console.info(`✅ ${envKey} is set`);
|
||||
}
|
||||
}
|
||||
if (missingVariables.length > 0) {
|
||||
console.error('');
|
||||
console.error('❌ Build cannot continue with missing environment variables.');
|
||||
console.error('Please check your .env file at the project root and ensure all required variables are set.');
|
||||
}
|
||||
else {
|
||||
console.info('✅ All required environment variables are present');
|
||||
}
|
||||
return {
|
||||
hasErrors: missingVariables.length > 0,
|
||||
missingVariables,
|
||||
};
|
||||
}
|
||||
// Create a validate-env script for a package
|
||||
export function createValidateEnvScript(requiredEnvVars) {
|
||||
const envVarsObject = requiredEnvVars
|
||||
.map((varName) => ` ${varName}: process.env.${varName},`)
|
||||
.join('\n');
|
||||
return `#!/usr/bin/env node
|
||||
|
||||
// This script uses the shared env-utils to validate environment variables
|
||||
import { loadRootEnv, validateEnv } from '@buster/env-utils';
|
||||
|
||||
// Load environment variables from root .env file
|
||||
loadRootEnv();
|
||||
|
||||
// Define required environment variables for this package
|
||||
const requiredEnv = {
|
||||
${envVarsObject}
|
||||
};
|
||||
|
||||
// Validate environment variables
|
||||
const { hasErrors } = validateEnv(requiredEnv);
|
||||
|
||||
if (hasErrors) {
|
||||
process.exit(1);
|
||||
}
|
||||
`;
|
||||
}
|
Loading…
Reference in New Issue