refactor: migrate from ESLint to Biome and extract SQL queries to data.ts
- Replace ESLint with Biome for linting and formatting - Configure Biome with tabs, double quotes, and organized imports - Move all SQL/Drizzle queries from page.tsx files to data.ts files - Create new data.ts files for: ajustes, dashboard, relatorios/categorias - Update existing data.ts files: extrato, fatura (add lancamentos queries) - Remove all drizzle-orm imports from page.tsx files - Update README.md with new tooling info Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
#!/usr/bin/env tsx
|
||||
|
||||
import { execSync } from 'child_process';
|
||||
import { config } from 'dotenv';
|
||||
import { execSync } from "node:child_process";
|
||||
import { config } from "dotenv";
|
||||
|
||||
// Carregar variáveis de ambiente
|
||||
config();
|
||||
|
||||
const port = process.env.PORT || '3000';
|
||||
const port = process.env.PORT || "3000";
|
||||
|
||||
console.log(`Starting Next.js development server on port ${port}...`);
|
||||
|
||||
// Executar next dev com a porta especificada
|
||||
execSync(`npx next dev --turbopack --port ${port}`, {
|
||||
stdio: 'inherit',
|
||||
env: { ...process.env, PORT: port }
|
||||
});
|
||||
stdio: "inherit",
|
||||
env: { ...process.env, PORT: port },
|
||||
});
|
||||
|
||||
@@ -1,45 +1,45 @@
|
||||
import * as fs from "node:fs";
|
||||
import * as path from "node:path";
|
||||
import { config } from "dotenv";
|
||||
import { drizzle } from "drizzle-orm/node-postgres";
|
||||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
import { Pool } from "pg";
|
||||
|
||||
// Load environment variables from .env
|
||||
config();
|
||||
|
||||
async function initDatabase() {
|
||||
const databaseUrl = process.env.DATABASE_URL;
|
||||
const databaseUrl = process.env.DATABASE_URL;
|
||||
|
||||
if (!databaseUrl) {
|
||||
console.error("DATABASE_URL environment variable is required");
|
||||
process.exit(1);
|
||||
}
|
||||
if (!databaseUrl) {
|
||||
console.error("DATABASE_URL environment variable is required");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const pool = new Pool({ connectionString: databaseUrl });
|
||||
const db = drizzle(pool);
|
||||
const pool = new Pool({ connectionString: databaseUrl });
|
||||
const db = drizzle(pool);
|
||||
|
||||
try {
|
||||
console.log("🔧 Initializing database extensions...");
|
||||
try {
|
||||
console.log("🔧 Initializing database extensions...");
|
||||
|
||||
// Read and execute init.sql as a single query
|
||||
const initSqlPath = path.join(
|
||||
process.cwd(),
|
||||
"scripts",
|
||||
"postgres",
|
||||
"init.sql"
|
||||
);
|
||||
const initSql = fs.readFileSync(initSqlPath, "utf-8");
|
||||
// Read and execute init.sql as a single query
|
||||
const initSqlPath = path.join(
|
||||
process.cwd(),
|
||||
"scripts",
|
||||
"postgres",
|
||||
"init.sql",
|
||||
);
|
||||
const initSql = fs.readFileSync(initSqlPath, "utf-8");
|
||||
|
||||
console.log("Executing init.sql...");
|
||||
await db.execute(initSql);
|
||||
console.log("Executing init.sql...");
|
||||
await db.execute(initSql);
|
||||
|
||||
console.log("✅ Database initialization completed");
|
||||
} catch (error) {
|
||||
console.error("❌ Database initialization failed:", error);
|
||||
process.exit(1);
|
||||
} finally {
|
||||
await pool.end();
|
||||
}
|
||||
console.log("✅ Database initialization completed");
|
||||
} catch (error) {
|
||||
console.error("❌ Database initialization failed:", error);
|
||||
process.exit(1);
|
||||
} finally {
|
||||
await pool.end();
|
||||
}
|
||||
}
|
||||
|
||||
initDatabase();
|
||||
|
||||
Reference in New Issue
Block a user