refactor: complete migration from .env to YAML configuration

BREAKING CHANGE: Application now uses config.yaml instead of .env files

## Changes:
- Remove dotenv dependency from package.json
- Update all services to use ConfigManager for configuration
- Update tests to use fixed credentials instead of env vars
- Delete obsolete config-manager.test.ts (used old .env API)
- Update documentation (README.md, CLAUDE.md) to reflect new config system

## Configuration Architecture:
- ConfigManager: Centralized YAML configuration with Zod validation
- config.yaml location:
  - Development: Project root (easy to edit and version control)
  - Production: User AppData (persists across updates)
- ERP credentials: Stored in database (dbo_BIPUsers) per user
- Other settings: Stored in config.yaml (database, paths, extraction, etc.)

## Files Modified:
- package.json: Removed dotenv dependency
- cleaner-handler.ts: Use ConfigManager.getDatabaseType()
- run-migration.ts: Read from config.yaml instead of .env
- All integration tests: Use fixed test credentials
- tests/setup.ts: Removed dotenv loading
- README.md, CLAUDE.md: Updated documentation

Migration is complete. Application no longer depends on .env files.
This commit is contained in:
test
2026-03-07 17:22:13 +08:00
parent 2d6838c0e7
commit 54a82200b6
14 changed files with 128 additions and 359 deletions

View File

@@ -44,7 +44,7 @@ ERPAuto is an **Electron desktop application** for automating ERP system data pr
- Node.js environment managing application lifecycle
- Entry point: `src/main/index.ts`
- Registers all IPC handlers via `registerIpcHandlers()`
- Loads environment variables from `.env` at startup
- Loads configuration from `config.yaml` via ConfigManager at startup
2. **Preload Script** (`src/preload/`)
- Security bridge between main and renderer processes
@@ -113,13 +113,23 @@ Admin users see logout buttons and can access user switching. Non-admin users ha
- `@services``src/main/services` (main process, tests only)
- `@types``src/main/types` (main process, tests only)
## Environment Configuration
## Configuration Management
The application requires a `.env` file in the project root. Reference `.env.example` for the full structure. Key configurations:
The application uses a YAML-based configuration system (`config.yaml`) managed by `ConfigManager`:
- **ERP Settings**: URL, credentials, headless mode, HTTPS error handling
- **Development**: `config.yaml` in project root (easy to edit and version control)
- **Production**: `config.yaml` in user data directory (AppData on Windows)
Key configurations in `config.yaml`:
- **ERP Settings**: URL (fixed infrastructure)
- **Database**: MySQL and SQL Server connection configs (dual support)
- **App Settings**: Log level, download/temp directories
- **Paths**: Data directory and output file settings
- **Extraction**: Batch size, verbosity, persistence options
- **Validation**: Data source, batch size, match mode
- **Order Resolution**: Database table and field names for order number lookup
Note: ERP credentials (username/password) are stored in the database (`dbo_BIPUsers` table) per user, managed via the Settings UI.
## Key Technologies