Files
fichajes/setup.js
Antoni Nuñez Romeu 114fda056d
Some checks failed
Build and Deploy / build-and-deploy (push) Failing after 3m51s
Hotfixes and CI/CD
2026-04-17 15:33:19 +02:00

52 lines
1.9 KiB
JavaScript

#!/usr/bin/env node
// Setup script to help users configure their environment
const fs = require('fs');
const path = require('path');
console.log('Time Tracker App Setup Script');
console.log('============================');
// Check if .env file exists
const envPath = path.join(__dirname, '.env');
const envExamplePath = path.join(__dirname, '.env.example');
if (!fs.existsSync(envPath)) {
console.log('\n.env file not found. Creating one from .env.example...');
if (fs.existsSync(envExamplePath)) {
fs.copyFileSync(envExamplePath, envPath);
console.log('.env file created successfully!');
console.log('Please edit .env file with your Supabase credentials.');
} else {
console.log('Warning: .env.example not found. Creating minimal .env file...');
const minimalEnv = `
# Supabase Configuration
REACT_APP_SUPABASE_URL=https://your-supabase-project.supabase.co
REACT_APP_SUPABASE_ANON_KEY=your-supabase-anon-key-here
# Application Settings
REACT_APP_APP_NAME=Time Tracker
`;
fs.writeFileSync(envPath, minimalEnv);
console.log('.env file created successfully!');
console.log('Please edit .env file with your Supabase credentials.');
}
} else {
console.log('\n.env file already exists. Skipping creation.');
}
console.log('\nNext steps:');
console.log('1. Edit .env file with your Supabase URL and anon key');
console.log('2. Run "npm install" to install dependencies');
console.log('3. Run "npm start" to start the development server');
console.log('\nFor Supabase setup:');
console.log('- Visit https://supabase.io to create an account');
console.log('- Create a new project');
console.log('- Find your project URL and anon key in the project settings');
console.log('- Create the required tables (users and timers) in the SQL editor');
console.log('- Optionally, set up automatic session closure (preserves history) by running the SQL in supabase/close_sessions_cron.sql');