|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +Google Spreadsheet to DB is a WordPress plugin that imports data from Google Sheets into WordPress database using Google's Sheets API (v4). This is a PHP/TypeScript hybrid project with a modern frontend build system. |
| 8 | + |
| 9 | +## Development Commands |
| 10 | + |
| 11 | +### PHP Development |
| 12 | +```bash |
| 13 | +# Install PHP dependencies |
| 14 | +cd functions/composer/ |
| 15 | +composer install |
| 16 | + |
| 17 | +# Run PHPStan static analysis |
| 18 | +composer phpstan |
| 19 | + |
| 20 | +# Run PHPUnit tests |
| 21 | +./vendor/bin/phpunit |
| 22 | + |
| 23 | +# Run PHP CodeSniffer |
| 24 | +./vendor/bin/phpcs |
| 25 | + |
| 26 | +# Clear PHPStan cache |
| 27 | +composer phpstan-clear |
| 28 | +``` |
| 29 | + |
| 30 | +### Frontend Development |
| 31 | +```bash |
| 32 | +# Install Node.js dependencies |
| 33 | +pnpm install |
| 34 | + |
| 35 | +# Development build with watch mode |
| 36 | +pnpm dev |
| 37 | + |
| 38 | +# Production build |
| 39 | +pnpm build |
| 40 | + |
| 41 | +# Type checking |
| 42 | +pnpm type-check |
| 43 | +pnpm type-check:watch |
| 44 | + |
| 45 | +# Linting |
| 46 | +pnpm lint |
| 47 | +pnpm lint:fix |
| 48 | +pnpm lint:css |
| 49 | +``` |
| 50 | + |
| 51 | +## Code Architecture |
| 52 | + |
| 53 | +### PHP Backend Structure |
| 54 | +- **Main Plugin File**: `google-spreadsheet-to-db.php` - Entry point, handles plugin activation and includes |
| 55 | +- **Core Classes**: Located in `includes/` directory |
| 56 | + - `class-google-spreadsheet-to-db-query.php` - Database query interface for retrieving stored data |
| 57 | + - `class-google-spreadsheet-to-db-activator.php` - Plugin activation logic |
| 58 | + - `admin.php` - WordPress admin interface |
| 59 | + - `save.php` - Data saving functionality |
| 60 | + - `index.php` - Core plugin functionality |
| 61 | +- **Helper Functions**: `functions/functions.php` |
| 62 | +- **Database**: Uses custom table `wp_google_ss2db` to store spreadsheet data as JSON |
| 63 | + |
| 64 | +### Frontend Structure |
| 65 | +- **TypeScript Source**: `src/assets/ts/` - Modular TypeScript components |
| 66 | +- **CSS Source**: `src/assets/css/` - PostCSS stylesheets |
| 67 | +- **Build Tool**: Rspack (configured in `rspack.config.ts`) |
| 68 | + |
| 69 | +### Configuration Constants |
| 70 | +Plugin requires WordPress constants in `wp-config.php`: |
| 71 | +- `GOOGLE_SS2DB_CLIENT_SECRET_PATH` - Path to Google API credentials JSON file |
| 72 | +- `GOOGLE_SS2DB_DEBUG` (optional) - Enable debug mode for detailed JSON responses |
| 73 | + |
| 74 | +## Key Features |
| 75 | +- Imports Google Sheets data via API and stores as JSON in WordPress database |
| 76 | +- Provides WordPress admin interface for configuration |
| 77 | +- Offers hooks for data manipulation before/after save (`google_ss2db_before_save`, `google_ss2db_after_save`) |
| 78 | +- Query API for retrieving stored data with filtering and sorting capabilities |
| 79 | + |
| 80 | +## Quality Tools |
| 81 | +- **PHP**: PHPStan (level 9), PHPCS with WordPress Coding Standards, PHPUnit |
| 82 | +- **TypeScript**: ESLint with Airbnb config, TypeScript strict mode |
| 83 | +- **CSS**: Stylelint with standard config |
| 84 | +- **Formatting**: Prettier for JS/TS/CSS |
| 85 | + |
| 86 | +## Testing |
| 87 | +- PHP tests located in `tests/` directory |
| 88 | +- Uses PHPUnit with WordPress test framework |
| 89 | +- Test configuration in `phpunit.xml.dist` |
| 90 | + |
| 91 | +## Dependencies |
| 92 | +- PHP 8.0+ required |
| 93 | +- Google API Client Library for PHP |
| 94 | +- Modern Node.js toolchain (pnpm, TypeScript, Rspack) |
0 commit comments