mirror of https://github.com/buster-so/buster.git
update package creator
This commit is contained in:
parent
0e0accb358
commit
cedd740965
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
|
||||
"extends": ["../../biome.json"],
|
||||
"files": {
|
||||
"include": ["src/**/*", "scripts/**/*"]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
declare global {
|
||||
namespace NodeJS {
|
||||
interface ProcessEnv {
|
||||
NODE_ENV?: 'development' | 'production' | 'test';
|
||||
// Add your environment variables here
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export {};
|
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
"name": "@buster/nate",
|
||||
"version": "1.0.0",
|
||||
"type": "module",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"default": "./dist/index.js"
|
||||
},
|
||||
"./*": {
|
||||
"types": "./dist/*.d.ts",
|
||||
"default": "./dist/*.js"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"prebuild": "node scripts/validate-env.js",
|
||||
"build": "tsc",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"dev": "tsc --watch",
|
||||
"lint": "biome check",
|
||||
"test": "vitest run",
|
||||
"test:watch": "vitest watch",
|
||||
"test:coverage": "vitest run --coverage"
|
||||
},
|
||||
"dependencies": {
|
||||
"@buster/typescript-config": "workspace:*",
|
||||
"@buster/vitest-config": "workspace:*",
|
||||
"dotenv": "^16.5.0"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
// Load environment variables from .env file
|
||||
import { config } from 'dotenv';
|
||||
config();
|
||||
|
||||
// Build-time environment validation
|
||||
|
||||
console.log('🔍 Validating environment variables...');
|
||||
|
||||
const env = {
|
||||
NODE_ENV: process.env.NODE_ENV || 'development',
|
||||
// Add your required environment variables here
|
||||
// DATABASE_URL: process.env.DATABASE_URL,
|
||||
// API_KEY: process.env.API_KEY,
|
||||
};
|
||||
|
||||
let hasErrors = false;
|
||||
|
||||
for (const [envKey, value] of Object.entries(env)) {
|
||||
if (!value) {
|
||||
console.error(`❌ Missing required environment variable: ${envKey}`);
|
||||
hasErrors = true;
|
||||
} else {
|
||||
console.log(`✅ ${envKey} is set`);
|
||||
}
|
||||
}
|
||||
|
||||
if (hasErrors) {
|
||||
console.error('');
|
||||
console.error('❌ Build cannot continue with missing environment variables.');
|
||||
console.error('Please check your .env file and ensure all required variables are set.');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log('✅ All required environment variables are present');
|
|
@ -0,0 +1 @@
|
|||
export * from './lib/index';
|
|
@ -0,0 +1,4 @@
|
|||
// Export your library functions here
|
||||
export const example = () => {
|
||||
return 'Hello from @buster/nate!';
|
||||
};
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"extends": "@buster/typescript-config/base.json",
|
||||
"compilerOptions": {
|
||||
"tsBuildInfoFile": "dist/.cache/tsbuildinfo.json",
|
||||
"outDir": "dist",
|
||||
"rootDir": "src"
|
||||
},
|
||||
"include": ["src/**/*", "env.d.ts"],
|
||||
"exclude": ["node_modules", "dist", "tests", "**/*.test.ts", "**/*.spec.ts"]
|
||||
}
|
|
@ -670,6 +670,18 @@ importers:
|
|||
specifier: 'catalog:'
|
||||
version: 3.25.67
|
||||
|
||||
packages/nate:
|
||||
dependencies:
|
||||
'@buster/typescript-config':
|
||||
specifier: workspace:*
|
||||
version: link:../typescript-config
|
||||
'@buster/vitest-config':
|
||||
specifier: workspace:*
|
||||
version: link:../vitest-config
|
||||
dotenv:
|
||||
specifier: ^16.5.0
|
||||
version: 16.5.0
|
||||
|
||||
packages/rerank:
|
||||
dependencies:
|
||||
'@buster/typescript-config':
|
||||
|
|
|
@ -164,6 +164,7 @@ async function createPackageFiles(config: PackageConfig) {
|
|||
dependencies: {
|
||||
"@buster/typescript-config": "workspace:*",
|
||||
"@buster/vitest-config": "workspace:*",
|
||||
"dotenv": "^16.5.0",
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -227,16 +228,50 @@ export {};
|
|||
// Create lib directory and basic lib file
|
||||
await mkdir(join(directory, "src", "lib"), { recursive: true });
|
||||
const libIndex = `// Export your library functions here
|
||||
export const example = () => {
|
||||
export const howdy = () => {
|
||||
return 'Hello from @buster/${name}!';
|
||||
};
|
||||
`;
|
||||
|
||||
await writeFile(join(directory, "src", "lib", "index.ts"), libIndex);
|
||||
|
||||
// Create a basic validate-env.js script
|
||||
const validateEnv = `// Validate environment variables here
|
||||
console.log('Environment validation passed');
|
||||
// Create a proper validate-env.js script
|
||||
const validateEnv = `#!/usr/bin/env node
|
||||
|
||||
// Load environment variables from .env file
|
||||
import { config } from 'dotenv';
|
||||
config();
|
||||
|
||||
// Build-time environment validation
|
||||
|
||||
console.log('🔍 Validating environment variables...');
|
||||
|
||||
const env = {
|
||||
NODE_ENV: process.env.NODE_ENV || 'development',
|
||||
// Add your required environment variables here
|
||||
// DATABASE_URL: process.env.DATABASE_URL,
|
||||
// API_KEY: process.env.API_KEY,
|
||||
};
|
||||
|
||||
let hasErrors = false;
|
||||
|
||||
for (const [envKey, value] of Object.entries(env)) {
|
||||
if (!value) {
|
||||
console.error(\`❌ Missing required environment variable: \${envKey}\`);
|
||||
hasErrors = true;
|
||||
} else {
|
||||
console.log(\`✅ \${envKey} is set\`);
|
||||
}
|
||||
}
|
||||
|
||||
if (hasErrors) {
|
||||
console.error('');
|
||||
console.error('❌ Build cannot continue with missing environment variables.');
|
||||
console.error('Please check your .env file and ensure all required variables are set.');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log('✅ All required environment variables are present');
|
||||
`;
|
||||
|
||||
await writeFile(join(directory, "scripts", "validate-env.js"), validateEnv);
|
||||
|
|
Loading…
Reference in New Issue