# Helper Scripts

Build and maintenance scripts for the @c8y/style package.

## Scripts

### `convert-scss-to-less.sh`
Semi-automated SCSS to LESS converter with syntax transformation.

**Usage:**
```bash
# Convert all modified SCSS files
./helper-scripts/convert-scss-to-less.sh --all

# Convert specific file (interactive)
./helper-scripts/convert-scss-to-less.sh styles/path/to/file.scss

# Auto-convert without prompts (used by pre-commit hook)
./helper-scripts/convert-scss-to-less.sh --yes --all

# Dry run (preview changes only)
./helper-scripts/convert-scss-to-less.sh --dry-run styles/path/to/file.scss
```

**Features:**
- Converts SCSS syntax to LESS (@use → @import, $var → @var, @mixin → .mixin)
- Transforms mixin parameter separators (commas → semicolons)
- Converts @extend to :extend() syntax
- Warns about complex patterns (@if/@else, @content)
- Respects skip list (`scss-to-less-skip`)
- Calls specialized converter for stroke icons
- Verifies compilation after conversion

### `convert-stroke-icons-to-less.js`
Specialized Node.js converter for stroke icon files.

**Usage:**
```bash
node ./helper-scripts/convert-stroke-icons-to-less.js
```

**Purpose:**
- Handles complex stroke icon file conversion
- Called automatically by `convert-scss-to-less.sh` when processing icon files

### `sync-scss-to-less.sh`
Checks if LESS files are in sync with modified SCSS files.

**Usage:**
```bash
./helper-scripts/sync-scss-to-less.sh
```

**Purpose:**
- Detects when SCSS files have been modified
- Warns if corresponding LESS files haven't been updated
- Suggests conversion commands

### `test-compile.sh`
Quick compilation test for both LESS and SCSS.

**Usage:**
```bash
# Run directly
./helper-scripts/test-compile.sh

# Or via npm
npm test
```

**Checks:**
- LESS compilation succeeds
- SCSS compilation succeeds
- Output file sizes match (within 5%)
- Displays deprecation warnings

## Configuration Files

### `scss-to-less-skip`

Lists files that should NOT be automatically converted.

Files in this list require manual synchronization due to complex syntax patterns that the converter cannot reliably handle.

See `../markdown-files/MANUAL-SYNC-FILES.md` for details on manually maintained files.

## Git Hook Integration

The `convert-scss-to-less.sh` script is automatically run by the pre-commit hook (`.husky/pre-commit`) when SCSS files are modified on `develop` or `feat/*` branches.

## Directory Structure

```
packages/style/
├── helper-scripts/              # All build/maintenance scripts
│   ├── README.md                # This file
│   ├── scss-to-less-skip        # Config: files to skip during conversion
│   ├── convert-scss-to-less.sh  # Main SCSS→LESS converter
│   ├── convert-stroke-icons-to-less.js  # Specialized icon converter
│   ├── sync-scss-to-less.sh     # Sync checker
│   └── test-compile.sh          # Compilation test
└── markdown-files/              # Documentation
    └── MANUAL-SYNC-FILES.md     # Manual sync documentation
```
