Initial commit
This commit is contained in:
87
commands/setup-env.md
Normal file
87
commands/setup-env.md
Normal file
@@ -0,0 +1,87 @@
|
||||
Interactive setup wizard for configuring Odoo PWA environment variables.
|
||||
|
||||
## What this command does:
|
||||
- Guides the user through setting up their `.env` file
|
||||
- Validates Odoo connection credentials
|
||||
- Tests API connectivity
|
||||
- Configures model-specific settings
|
||||
- Provides troubleshooting help if connection fails
|
||||
|
||||
## Required Information:
|
||||
Gather from the user:
|
||||
1. **Odoo Instance URL** (e.g., "https://yourcompany.odoo.com")
|
||||
2. **Database Name** (e.g., "yourcompany-main")
|
||||
3. **API Key** (from Odoo user preferences)
|
||||
4. **Username/Email** (Odoo user email)
|
||||
5. **Primary Model Name** (e.g., "x_expense", "x_inventory")
|
||||
|
||||
## Steps:
|
||||
1. Check if `.env.example` exists in the current directory
|
||||
2. If not, ask if this is an Odoo PWA project
|
||||
3. Ask the user for each environment variable interactively
|
||||
4. Validate URL format (must start with http:// or https://)
|
||||
5. Create or update `.env` file with the provided values
|
||||
6. Test the connection by making a simple API call to Odoo
|
||||
7. If connection fails, provide troubleshooting steps
|
||||
8. Display success message with next steps
|
||||
|
||||
## Environment Variables to Set:
|
||||
```bash
|
||||
# Odoo Instance Configuration
|
||||
VITE_ODOO_URL=https://yourcompany.odoo.com
|
||||
VITE_ODOO_DB=yourcompany-main
|
||||
|
||||
# Authentication (keep these secret!)
|
||||
ODOO_API_KEY=your_api_key_here
|
||||
ODOO_USERNAME=your.email@company.com
|
||||
|
||||
# Model Configuration
|
||||
VITE_MODEL_NAME=x_expense
|
||||
VITE_MODEL_DISPLAY_NAME=Expense
|
||||
```
|
||||
|
||||
## Validation Tests:
|
||||
After creating `.env`, run these checks:
|
||||
1. Test Odoo URL is reachable
|
||||
2. Verify API key is valid
|
||||
3. Check if the model exists in Odoo
|
||||
4. Test read permissions on the model
|
||||
5. Verify required fields are accessible
|
||||
|
||||
## Example prompts to use this command:
|
||||
- `/setup-env` - Interactive setup wizard
|
||||
- User: "Help me configure my Odoo credentials"
|
||||
- User: "Set up environment variables for Odoo PWA"
|
||||
|
||||
## Security Reminders:
|
||||
After setup, remind the user:
|
||||
1. ✅ `.env` should be in `.gitignore` (verify this)
|
||||
2. ✅ Never commit API keys to version control
|
||||
3. ✅ Use different credentials for development and production
|
||||
4. ✅ For deployment, set environment variables in the hosting platform
|
||||
5. ✅ Rotate API keys periodically
|
||||
|
||||
## Troubleshooting Common Issues:
|
||||
|
||||
### Connection Failed
|
||||
- Verify Odoo URL is correct and accessible
|
||||
- Check if API key is valid (generate new one in Odoo)
|
||||
- Ensure username matches the API key owner
|
||||
- Check firewall/network restrictions
|
||||
|
||||
### Model Not Found
|
||||
- Verify the model exists in Odoo Studio
|
||||
- Check model name has `x_` prefix
|
||||
- Ensure user has access permissions to the model
|
||||
|
||||
### Authentication Error
|
||||
- Regenerate API key in Odoo (Settings → Users → API Keys)
|
||||
- Verify database name is correct
|
||||
- Check if account is active and not locked
|
||||
|
||||
## After Setup:
|
||||
Remind the user to:
|
||||
1. Restart the development server to load new environment variables
|
||||
2. Test the application and verify data loads correctly
|
||||
3. Keep the `.env.example` file updated for team members
|
||||
4. Document any custom configuration in project README
|
||||
Reference in New Issue
Block a user