# Scripts Documentation

This directory contains utility scripts for the Recast Paywall plugin.

## Available Scripts

### `download-deps.js`

Downloads external JavaScript dependencies from unpkg and places them in `assets/js/vendor/`.

**Dependencies:**
- `jose@6.0.12` - JWT verification library
- `@recast-sdk/recast-jwt@1.1.1` - Recast JWT utilities
- `@recast-sdk/recast-browser@1.6.3` - Recast browser SDK

**Usage:**
```bash
npm run download-deps
```

This script runs automatically after `npm install` via the `postinstall` hook.

**Why separate files?**
WordPress.org plugin guidelines prohibit calling remote files. By downloading dependencies locally, we:
- Comply with WordPress.org guidelines
- Improve performance (no external HTTP requests)
- Ensure reliability (no dependency on external CDNs)
- Maintain security (dependencies are versioned and verified)

**CI/CD Integration:**
The script is integrated into GitHub Actions workflows:
- `release-create.yml` - Downloads deps when creating releases
- `wordpress-deploy.yml` - Downloads deps before deploying to WordPress.org

### `sync-version.js`

Synchronizes version numbers across plugin files (`recast-paywall.php`, `readme.txt`, `package.json`, `composer.json`).

**Usage:**
```bash
npm run sync-version -- --from 1.2.3
```

## Development Setup

1. Clone the repository
2. Run `npm install` (automatically downloads dependencies)
3. Start development with `npm start`

## Production Build

The GitHub Actions workflows automatically handle dependency downloads before building and deploying:

```bash
npm ci
npm run download-deps
npm run build
```

## Troubleshooting

### Dependencies not downloading
- Ensure you have internet connectivity
- Check that the unpkg URLs are accessible
- Verify Node.js version (requires Node 14+)

### Files missing in production
- Check that `.gitignore` excludes `assets/js/vendor/`
- Verify GitHub Actions workflows include the download step
- Ensure the script runs before building the plugin package
