@devix-tecnologia/directus-extension-inframe
Version:
DEPRECATED: Use 'directus-extension-inframe' instead. This package is no longer maintained.
401 lines (280 loc) โข 10.4 kB
Markdown
# Contributing to Directus Extension inFrame
Thank you for your interest in contributing! This guide will help you set up your development environment and understand
our workflow.
## ๐ ๏ธ Development Setup
### Prerequisites
- Node.js 18+
- pnpm (recommended) or npm
- Docker and Docker Compose (for testing)
- Git
### Getting Started
1. **Fork and clone the repository:**
```bash
git clone https://github.com/YOUR_USERNAME/directus-extension-inframe.git
cd directus-extension-inframe
```
2. **Install dependencies:**
```bash
pnpm install
```
3. **Build the extension:**
```bash
pnpm build
```
## ๐งช Testing
This extension includes automated tests that verify compatibility with different versions of Directus.
### Test Structure
```
tests/
โโโ index.spec.ts # Main integration tests
โโโ setup-hook.spec.ts # Auto-setup system tests
โโโ setup.ts # Test environment configuration
โโโ helper_test.ts # Helper functions
โโโ test-env.ts # Environment variables
โโโ test-logger.ts # Logging system
โโโ directus-versions.js # Tested versions
```
### Running Tests
```bash
# Run all tests
pnpm test
# Test with a specific Directus version
DIRECTUS_TEST_VERSION=11.13.1 pnpm test
# Check formatting and types
pnpm lint
pnpm typecheck
```
### Clean Test Containers
```bash
# Remove all test containers
docker rm -f $(docker ps -aq --filter "name=directus-inframe") 2>/dev/null
docker network prune -f
```
### Tested Directus Versions
Tests run on the following versions:
- **Directus 9.x**: 9.22.4, 9.23.1, 9.24.0
- **Directus 10.x**: 10.8.3
- **Directus 11.x**: 11.13.1 and newer
**Note:** Directus 11.10.1 has known issues and is blocked in tests.
### Test Architecture
Tests use:
- โ
**Docker Compose** for isolated environment
- โ
**Vitest** for test execution
- โ
**SQLite** for test database
- โ
**Docker exec** for HTTP communication (no port mapping)
- โ
**Parallel tests** with `maxConcurrency: 3`
- โ
**Generous timeouts** (300s) for slow containers
#### Communication via Docker Exec
Tests use `docker exec` to make HTTP requests directly inside the container, eliminating the need for port mapping and
allowing safe parallel execution of multiple versions simultaneously.
## ๐๏ธ Project Structure
```
src/
โโโ index.ts # Main module definition
โโโ List.vue # Main list component
โโโ types.ts # TypeScript type definitions
โโโ shims.d.ts # Vue type declarations
โโโ components/
โ โโโ ItemDetail.vue # Item detail component
โ โโโ NavMenu.vue # Navigation menu component
โโโ utils/
โโโ useFetchItems.ts # Composable for fetching data
```
## ๐ Code Standards
### TypeScript
- Always use strict typing
- Define interfaces for complex objects in `types.ts`
- Use Directus types when available (`@directus/types`)
### Vue 3
- **ALWAYS** use Composition API with `<script setup>`
- Use composables for reusable logic (pattern `use*`)
- Components should have PascalCase names
- Props must be typed with TypeScript interfaces
### Naming Conventions
- Component files: PascalCase (e.g., `ItemDetail.vue`)
- Composables: camelCase starting with "use" (e.g., `useFetchItems.ts`)
- Variables and functions: camelCase
- Constants: UPPER_SNAKE_CASE
- Interfaces: PascalCase with optional "I" prefix
### Vue Component Structure
```vue
<template>
<!-- HTML template -->
</template>
<script setup lang="ts">
// Imports
// Props/Emits definitions
// Composables usage
// Reactive data
// Computed properties
// Methods
// Lifecycle hooks
</script>
<style scoped>
/* Component-specific styles */
</style>
```
## ๐ Development Workflow
### Available Scripts
```bash
pnpm build # Build for production
pnpm dev # Build in development mode with watch
pnpm lint # Check code with ESLint
pnpm lint:fix # Auto-fix ESLint issues
pnpm format # Format code with Prettier
pnpm format:check # Check formatting
pnpm typecheck # TypeScript type checking
pnpm test # Run tests
```
### Local Development with Directus
1. **Start a local Directus instance:**
```bash
docker compose up -d
```
2. **Configure CSP to allow iframes:**
The provided `docker-compose.yml` is configured to allow iframes from any domain (for development):
```yaml
CONTENT_SECURITY_POLICY_DIRECTIVES__FRAME_SRC: '*'
```
> [!WARNING] In production, configure CSP to allow only trusted domains.
3. **Build the extension in watch mode:**
```bash
pnpm dev
```
4. **The extension will be automatically reloaded** when you make changes.
## ๐ CI/CD & Automated Updates
### Dependency Management with Renovate
This project uses **Renovate** for automated dependency updates with age filtering:
- ๐ฆ **npm packages**: Checked weekly on Mondays at 6 AM (Sรฃo Paulo timezone)
- ๐ **Age filtering**: Packages must be at least **5 days old** before being adopted
- ๐ฏ **Auto-grouping**: Minor and patch updates are grouped together
- ๐ **Security patches**: Applied immediately (0 days)
**Age filtering by dependency type:**
- Production dependencies: 5 days minimum
- Dev dependencies: 3 days minimum
- Major updates: 7 days minimum
- Directus packages: 5 days minimum
- Security patches: 0 days (immediate)
> To enable Renovate: Install the [Renovate GitHub App](https://github.com/apps/renovate) on your repository.
> Configuration is already in `renovate.json`.
### Directus Version Testing Strategy
The project automatically tests against multiple Directus versions to ensure compatibility. To prevent issues with newly
released versions, we implement a **version age filter**:
- **Default**: New Directus versions are only adopted after **5 days** from their release date
- **Configurable**: Adjust via GitHub repository variable `DIRECTUS_VERSION_MIN_AGE_DAYS`
#### Why Age Filtering Matters
- โ
**Stability**: Avoids immediate adoption of versions with potential critical bugs
- โ
**Safety**: Gives time for the community to identify breaking changes
- โ
**Reliability**: Ensures patches and hotfixes are released before we test against them
### Configuration
#### 1. PAT Token (Recommended - Enables Automated CI)
**Status**: Optional, but highly recommended for full automation.
**Without PAT_TOKEN**: PRs will be created automatically, but CI tests won't run (you'll need to manually verify).
**With PAT_TOKEN**: PRs will be created AND tests will run automatically before merge.
To enable automated CI tests on version update PRs:
1. Go to **GitHub.com** โ Your profile **Settings** โ **Developer settings** โ **Personal access tokens** โ **Tokens
(classic)**
2. Click **Generate new token** with permissions:
- โ `repo` (all)
- โ `workflow`
3. Copy the token and add it to your repository:
- Repository **Settings** โ **Secrets and variables** โ **Actions** โ **New repository secret**
- Name: `PAT_TOKEN`
- Value: paste your token
> **Why?** GitHub's security prevents `GITHUB_TOKEN` from triggering workflows to avoid infinite loops. A PAT bypasses
> this limitation.
#### 2. Version Age Filter (Optional)
To customize the minimum age for Directus versions:
1. Go to repository **Settings** โ **Secrets and variables** โ **Actions** โ **Variables** tab
2. Click **New repository variable**:
- Name: `DIRECTUS_VERSION_MIN_AGE_DAYS`
- Value: `5` (or any number of days you prefer)
**Recommended values:**
- Conservative: `14` days
- Balanced: `5` days (default)
- Aggressive: `3` days
## ๐ Pull Request Process
1. **Create a feature branch:**
```bash
git checkout -b feature/amazing-feature
```
2. **Make your changes** following our code standards
3. **Run tests and linting:**
```bash
pnpm lint
pnpm typecheck
pnpm test
```
4. **Commit your changes** using semantic commits:
```bash
git commit -m "feat: add amazing feature"
```
See [Semantic Commits](#semantic-commits) below.
5. **Push to your fork:**
```bash
git push origin feature/amazing-feature
```
6. **Open a Pull Request** with a clear description of the changes
## ๐ Semantic Commits
Use semantic commits with messages in **English**. Follow the
[Conventional Commits](https://www.conventionalcommits.org/) standard:
### Format
```
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]
```
### Commit Types
- **feat**: New feature
- **fix**: Bug fix
- **docs**: Documentation changes
- **style**: Code style changes (formatting, etc.)
- **refactor**: Code changes that neither fix bugs nor add features
- **perf**: Performance improvements
- **test**: Adding or fixing tests
- **chore**: Changes to build tools, dependencies, etc.
- **ci**: Changes to CI/CD files
### Examples
```bash
feat: add advanced filter component
fix: correct iframe rendering on mobile devices
docs: update README with installation instructions
style: apply prettier formatting to components
refactor: reorganize utils folder structure
perf: optimize API data loading
test: add unit tests for NavMenu
chore: update project dependencies
ci: configure automatic deploy workflow
```
### Breaking Changes
For breaking changes, add `!` after the type or include `BREAKING CHANGE:` in the footer:
```bash
feat!: remove support for Directus v9
feat: add new API
BREAKING CHANGE: the new API is not compatible with previous versions
```
## ๐ Reporting Issues
When reporting issues, please include:
- Directus version
- Extension version
- Steps to reproduce
- Expected behavior
- Actual behavior
- Screenshots (if applicable)
- Browser/environment details
## ๐ก Suggesting Features
We love feature suggestions! Please:
1. Check if the feature already exists
2. Check if it's already been suggested in Issues
3. Open a new issue with the "enhancement" label
4. Clearly describe the use case and benefits
## ๐ License
By contributing, you agree that your contributions will be licensed under the MIT License.
## ๐ Questions?
Feel free to open an issue or contact us:
- **Sidarta Veloso** - [GitHub](https://github.com/sidartaveloso) |
[LinkedIn](https://www.linkedin.com/in/sidartaveloso)
- **Fernando Gatti** - [GitHub](https://github.com/gattifernando) |
[LinkedIn](https://www.linkedin.com/in/gattifernando/)
---
Thank you for contributing! ๐