Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Contributing

Contributions are **welcome** and will be fully **credited**.

Please read and understand the contribution guide before creating an issue or pull request.

## Etiquette

This project is open source, and as such, the maintainers give their free time to build and maintain the source code
held within. They make the code freely available in the hope that it will be of use to other developers. It would be
extremely unfair for them to suffer abuse or anger for their hard work.

Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the
world that developers are civilized and selfless people.

It's the duty of the maintainer to ensure that all submissions to the project are of sufficient
quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used.

## Viability

When requesting or submitting new features, first consider whether it might be useful to others. Open
source projects are used by many developers, who may have entirely different needs to your own. Think about
whether or not your feature is likely to be used by other users of the project.

## Procedure

Before filing an issue:

- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident.
- Check to make sure your feature suggestion isn't already present within the project.
- Check the pull requests tab to ensure that the bug doesn't have a fix in progress.
- Check the pull requests tab to ensure that the feature isn't already in progress.

Before submitting a pull request:

- Check the codebase to ensure that your feature doesn't already exist.
- Check the pull requests to ensure that another person hasn't already submitted the feature or fix.

## Requirements

If the project maintainer has any additional requirements, you will find them listed here.

- **Add tests!** — Your patch won't be accepted if it doesn't have tests.

- **100% code coverage** — Run `composer coverage` locally. The minimum threshold is 100% for `src/`.

- **Run the quality suite** — Run `composer quality` before submitting (tests, PHPStan, Pint).

- **Document any change in behaviour** — Make sure the `README.md` and any other relevant documentation are kept up-to-date.

- **Consider our release cycle** — We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option.

- **One pull request per feature** — If you want to do more than one thing, send multiple pull requests.

- **Send coherent history** — Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](https://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting.

**Happy coding**!
3 changes: 3 additions & 0 deletions .github/SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Security Policy

If you discover any security related issues, please email security@justbetter.nl instead of using the issue tracker.
34 changes: 34 additions & 0 deletions .github/workflows/analyse.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: analyse

on: ['push', 'pull_request']

jobs:
analyse:
runs-on: ubuntu-latest

strategy:
fail-fast: true
matrix:
php: [8.4, 8.5]
laravel: ['12.40.*', '13.*']

name: P${{ matrix.php }} - L${{ matrix.laravel }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
coverage: none

- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update
composer install
- name: Analyse
run: composer analyse
28 changes: 28 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: coverage

on: ['push', 'pull_request']

jobs:
coverage:
runs-on: ubuntu-latest

name: Coverage

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.5
extensions: dom, curl, libxml, mbstring, zip, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo, xdebug
coverage: xdebug

- name: Install dependencies
run: |
composer require "laravel/framework:13.*" --no-interaction --no-update
composer install

- name: Coverage
run: composer coverage
28 changes: 28 additions & 0 deletions .github/workflows/style.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: style

on: ['push', 'pull_request']

jobs:
style:
runs-on: ubuntu-latest

name: Style

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.5
extensions: dom, curl, libxml, mbstring, zip, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
coverage: none

- name: Install dependencies
run: |
composer require "laravel/framework:13.*" --no-interaction --no-update
composer install

- name: Style
run: composer style
34 changes: 34 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: tests

on: ['push', 'pull_request']

jobs:
tests:
runs-on: ubuntu-latest

strategy:
fail-fast: true
matrix:
php: [8.4, 8.5]
laravel: ['12.40.*', '13.*']

name: P${{ matrix.php }} - L${{ matrix.laravel }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
coverage: none

- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update
composer install

- name: Tests
run: composer test
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/vendor/
/vendor
node_modules/
npm-debug.log
yarn-error.log
Expand Down Expand Up @@ -28,3 +28,8 @@ Homestead.json
.env.production
.phpactor.json
auth.json

resources/dist/hot
/composer.lock
package-lock.json
yarn.lock
70 changes: 70 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Statamic Base

Foundation addon for JustBetter Statamic packages. Provides a Control Panel overview of installed `justbetter/*` and `just-better/*` Composer packages.

## Features

- **JustBetter** CP navigation section with a **Packages** overview
- Lists production and development JustBetter packages separately
- Shows installed version, latest stable Packagist version, and semver-aware update badges
- JustBetter nav and overview header use `icon_url` (and optional `icon_dark_url`) as SVG `<image href="…">` markup (browser loads assets; no server-side fetch). Dark variant toggles with Tailwind `dark:` like the rest of the CP.
- Custom permission: `view justbetter packages`

## Requirements

- PHP ^8.4
- Laravel ^12.40 or ^13.0
- Statamic ^6.0

## Installation

```bash
composer require justbetter/statamic-base
```

Publish the config (optional):

```bash
php artisan vendor:publish --tag=justbetter-statamic-base
```

Build CP assets (required for the Inertia overview page):

```bash
cd vendor/justbetter/statamic-base
npm install
npm run build
```

During development:

```bash
npm run dev
```

## Configuration

Config file: `config/justbetter/statamic-base.php`

| Key | Default | Description |
|-----|---------|-------------|
| `packagist_cache_ttl` | `3600` | Seconds to cache Packagist responses |
| `icon_url` | `https://opensource.justbetter.nl/statamic/justbetter-logo-small-black.svg` | Light / default theme: URL for the `<image>` in the nav/header SVG |
| `icon_dark_url` | `null` | Optional. When set to a valid URL, dark mode uses this asset (same SVG, second `<image>` behind `hidden dark:block`) |

Environment variables: `STATAMIC_BASE_PACKAGIST_CACHE_TTL`, `STATAMIC_BASE_ICON_URL`, `STATAMIC_BASE_ICON_DARK_URL`

## Permissions

Assign the **View JustBetter packages** permission to roles that should access the overview. Super users always have access.

## Quality

```bash
composer quality
composer coverage
```

## License

MIT
61 changes: 61 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"name": "justbetter/statamic-base",
"description": "Foundation addon for JustBetter Statamic packages.",
"license": "MIT",
"require": {
"php": "^8.4",
"composer/semver": "^3.4",
"guzzlehttp/guzzle": "^7.0",
"laravel/framework": "^12.40|^13.0",
"statamic/cms": "^6.0"
},
"require-dev": {
"larastan/larastan": "^3.4",
"laravel/pint": "^1.22",
"orchestra/testbench": "^10.8|^11.0",
"pestphp/pest": "^3.7",
"phpstan/phpstan-mockery": "^2.0",
"phpunit/phpunit": "^11.5"
},
"autoload": {
"psr-4": {
"JustBetter\\StatamicBase\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"JustBetter\\StatamicBase\\Tests\\": "tests/"
}
},
"extra": {
"statamic": {
"name": "Statamic Base",
"description": "Foundation addon for JustBetter Statamic packages."
},
"laravel": {
"providers": [
"JustBetter\\StatamicBase\\ServiceProvider"
]
}
},
"scripts": {
"test": "phpunit",
"analyse": "phpstan --memory-limit=1G",
"style": "pint --test",
"style:fix": "pint",
"coverage": "XDEBUG_MODE=coverage php vendor/bin/pest --coverage --min=100",
"quality": [
"@test",
"@analyse",
"@style"
]
},
"config": {
"allow-plugins": {
"pixelfear/composer-dist-plugin": true,
"pestphp/pest-plugin": true
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
14 changes: 14 additions & 0 deletions config/statamic-base.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

return [

'permissions' => [
'view' => 'view justbetter packages',
],

'packagist_cache_ttl' => (int) env('STATAMIC_BASE_PACKAGIST_CACHE_TTL', 3600),

'icon_url' => 'https://opensource.justbetter.nl/statamic/justbetter-logo-small-black.svg',

'icon_dark_url' => 'https://opensource.justbetter.nl/statamic/justbetter-logo-small-white.svg',
];
18 changes: 18 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build"
},
"dependencies": {
"@statamic/cms": "file:./vendor/statamic/cms/resources/dist-package",
"@tailwindcss/vite": "^4.1.18",
"laravel-vite-plugin": "^1.2.0",
"tailwindcss": "^4.1.18",
"vue": "^3.5.31"
},
"devDependencies": {
"vite": "^6.3.4"
}
}
9 changes: 9 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
includes:
- ./vendor/larastan/larastan/extension.neon
- ./vendor/phpstan/phpstan-mockery/extension.neon

parameters:
paths:
- src
- tests
level: 9
Loading
Loading