Skip to content

Commit cf5f7b2

Browse files
committed
Initial addon setup
1 parent 44acfce commit cf5f7b2

54 files changed

Lines changed: 2165 additions & 1 deletion

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/CONTRIBUTING.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Contributing
2+
3+
Contributions are **welcome** and will be fully **credited**.
4+
5+
Please read and understand the contribution guide before creating an issue or pull request.
6+
7+
## Etiquette
8+
9+
This project is open source, and as such, the maintainers give their free time to build and maintain the source code
10+
held within. They make the code freely available in the hope that it will be of use to other developers. It would be
11+
extremely unfair for them to suffer abuse or anger for their hard work.
12+
13+
Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the
14+
world that developers are civilized and selfless people.
15+
16+
It's the duty of the maintainer to ensure that all submissions to the project are of sufficient
17+
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.
18+
19+
## Viability
20+
21+
When requesting or submitting new features, first consider whether it might be useful to others. Open
22+
source projects are used by many developers, who may have entirely different needs to your own. Think about
23+
whether or not your feature is likely to be used by other users of the project.
24+
25+
## Procedure
26+
27+
Before filing an issue:
28+
29+
- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident.
30+
- Check to make sure your feature suggestion isn't already present within the project.
31+
- Check the pull requests tab to ensure that the bug doesn't have a fix in progress.
32+
- Check the pull requests tab to ensure that the feature isn't already in progress.
33+
34+
Before submitting a pull request:
35+
36+
- Check the codebase to ensure that your feature doesn't already exist.
37+
- Check the pull requests to ensure that another person hasn't already submitted the feature or fix.
38+
39+
## Requirements
40+
41+
If the project maintainer has any additional requirements, you will find them listed here.
42+
43+
- **Add tests!** — Your patch won't be accepted if it doesn't have tests.
44+
45+
- **100% code coverage** — Run `composer coverage` locally. The minimum threshold is 100% for `src/`.
46+
47+
- **Run the quality suite** — Run `composer quality` before submitting (tests, PHPStan, Pint).
48+
49+
- **Document any change in behaviour** — Make sure the `README.md` and any other relevant documentation are kept up-to-date.
50+
51+
- **Consider our release cycle** — We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option.
52+
53+
- **One pull request per feature** — If you want to do more than one thing, send multiple pull requests.
54+
55+
- **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.
56+
57+
**Happy coding**!

.github/SECURITY.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Security Policy
2+
3+
If you discover any security related issues, please email security@justbetter.nl instead of using the issue tracker.

.github/workflows/analyse.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: analyse
2+
3+
on: ['push', 'pull_request']
4+
5+
jobs:
6+
analyse:
7+
runs-on: ubuntu-latest
8+
9+
strategy:
10+
fail-fast: true
11+
matrix:
12+
php: [8.4, 8.5]
13+
laravel: ['12.40.*', '13.*']
14+
15+
name: P${{ matrix.php }} - L${{ matrix.laravel }}
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Setup PHP
22+
uses: shivammathur/setup-php@v2
23+
with:
24+
php-version: ${{ matrix.php }}
25+
extensions: dom, curl, libxml, mbstring, zip, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
26+
coverage: none
27+
28+
- name: Install dependencies
29+
run: |
30+
composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update
31+
composer install
32+
33+
- name: Analyse
34+
run: composer analyse

.github/workflows/coverage.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: coverage
2+
3+
on: ['push', 'pull_request']
4+
5+
jobs:
6+
coverage:
7+
runs-on: ubuntu-latest
8+
9+
name: Coverage
10+
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v4
14+
15+
- name: Setup PHP
16+
uses: shivammathur/setup-php@v2
17+
with:
18+
php-version: 8.5
19+
extensions: dom, curl, libxml, mbstring, zip, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo, xdebug
20+
coverage: xdebug
21+
22+
- name: Install dependencies
23+
run: |
24+
composer require "laravel/framework:13.*" --no-interaction --no-update
25+
composer install
26+
27+
- name: Coverage
28+
run: composer coverage

.github/workflows/style.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: style
2+
3+
on: ['push', 'pull_request']
4+
5+
jobs:
6+
style:
7+
runs-on: ubuntu-latest
8+
9+
name: Style
10+
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v4
14+
15+
- name: Setup PHP
16+
uses: shivammathur/setup-php@v2
17+
with:
18+
php-version: 8.5
19+
extensions: dom, curl, libxml, mbstring, zip, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
20+
coverage: none
21+
22+
- name: Install dependencies
23+
run: |
24+
composer require "laravel/framework:13.*" --no-interaction --no-update
25+
composer install
26+
27+
- name: Style
28+
run: composer style

.github/workflows/tests.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: tests
2+
3+
on: ['push', 'pull_request']
4+
5+
jobs:
6+
tests:
7+
runs-on: ubuntu-latest
8+
9+
strategy:
10+
fail-fast: true
11+
matrix:
12+
php: [8.4, 8.5]
13+
laravel: ['12.40.*', '13.*']
14+
15+
name: P${{ matrix.php }} - L${{ matrix.laravel }}
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Setup PHP
22+
uses: shivammathur/setup-php@v2
23+
with:
24+
php-version: ${{ matrix.php }}
25+
extensions: dom, curl, libxml, mbstring, zip, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
26+
coverage: none
27+
28+
- name: Install dependencies
29+
run: |
30+
composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update
31+
composer install
32+
33+
- name: Tests
34+
run: composer test

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/vendor/
1+
/vendor
22
node_modules/
33
npm-debug.log
44
yarn-error.log
@@ -28,3 +28,8 @@ Homestead.json
2828
.env.production
2929
.phpactor.json
3030
auth.json
31+
32+
resources/dist/hot
33+
/composer.lock
34+
package-lock.json
35+
yarn.lock

README.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Statamic Base
2+
3+
Foundation addon for JustBetter Statamic packages. Provides a Control Panel overview of installed `justbetter/*` and `just-better/*` Composer packages.
4+
5+
## Features
6+
7+
- **JustBetter** CP navigation section with a **Packages** overview
8+
- Lists production and development JustBetter packages separately
9+
- Shows installed version, latest stable Packagist version, and semver-aware update badges
10+
- 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.
11+
- Custom permission: `view justbetter packages`
12+
13+
## Requirements
14+
15+
- PHP ^8.4
16+
- Laravel ^12.40 or ^13.0
17+
- Statamic ^6.0
18+
19+
## Installation
20+
21+
```bash
22+
composer require justbetter/statamic-base
23+
```
24+
25+
Publish the config (optional):
26+
27+
```bash
28+
php artisan vendor:publish --tag=justbetter-statamic-base
29+
```
30+
31+
Build CP assets (required for the Inertia overview page):
32+
33+
```bash
34+
cd vendor/justbetter/statamic-base
35+
npm install
36+
npm run build
37+
```
38+
39+
During development:
40+
41+
```bash
42+
npm run dev
43+
```
44+
45+
## Configuration
46+
47+
Config file: `config/justbetter/statamic-base.php`
48+
49+
| Key | Default | Description |
50+
|-----|---------|-------------|
51+
| `packagist_cache_ttl` | `3600` | Seconds to cache Packagist responses |
52+
| `icon_url` | `https://opensource.justbetter.nl/statamic/justbetter-logo-small-black.svg` | Light / default theme: URL for the `<image>` in the nav/header SVG |
53+
| `icon_dark_url` | `null` | Optional. When set to a valid URL, dark mode uses this asset (same SVG, second `<image>` behind `hidden dark:block`) |
54+
55+
Environment variables: `STATAMIC_BASE_PACKAGIST_CACHE_TTL`, `STATAMIC_BASE_ICON_URL`, `STATAMIC_BASE_ICON_DARK_URL`
56+
57+
## Permissions
58+
59+
Assign the **View JustBetter packages** permission to roles that should access the overview. Super users always have access.
60+
61+
## Quality
62+
63+
```bash
64+
composer quality
65+
composer coverage
66+
```
67+
68+
## License
69+
70+
MIT

composer.json

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"name": "justbetter/statamic-base",
3+
"description": "Foundation addon for JustBetter Statamic packages.",
4+
"license": "MIT",
5+
"require": {
6+
"php": "^8.4",
7+
"composer/semver": "^3.4",
8+
"guzzlehttp/guzzle": "^7.0",
9+
"laravel/framework": "^12.40|^13.0",
10+
"statamic/cms": "^6.0"
11+
},
12+
"require-dev": {
13+
"larastan/larastan": "^3.4",
14+
"laravel/pint": "^1.22",
15+
"orchestra/testbench": "^10.8|^11.0",
16+
"pestphp/pest": "^3.7",
17+
"phpstan/phpstan-mockery": "^2.0",
18+
"phpunit/phpunit": "^11.5"
19+
},
20+
"autoload": {
21+
"psr-4": {
22+
"JustBetter\\StatamicBase\\": "src/"
23+
}
24+
},
25+
"autoload-dev": {
26+
"psr-4": {
27+
"JustBetter\\StatamicBase\\Tests\\": "tests/"
28+
}
29+
},
30+
"extra": {
31+
"statamic": {
32+
"name": "Statamic Base",
33+
"description": "Foundation addon for JustBetter Statamic packages."
34+
},
35+
"laravel": {
36+
"providers": [
37+
"JustBetter\\StatamicBase\\ServiceProvider"
38+
]
39+
}
40+
},
41+
"scripts": {
42+
"test": "phpunit",
43+
"analyse": "phpstan --memory-limit=1G",
44+
"style": "pint --test",
45+
"style:fix": "pint",
46+
"coverage": "XDEBUG_MODE=coverage php vendor/bin/pest --coverage --min=100",
47+
"quality": [
48+
"@test",
49+
"@analyse",
50+
"@style"
51+
]
52+
},
53+
"config": {
54+
"allow-plugins": {
55+
"pixelfear/composer-dist-plugin": true,
56+
"pestphp/pest-plugin": true
57+
}
58+
},
59+
"minimum-stability": "dev",
60+
"prefer-stable": true
61+
}

config/statamic-base.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
return [
4+
5+
'permissions' => [
6+
'view' => 'view justbetter packages',
7+
],
8+
9+
'packagist_cache_ttl' => (int) env('STATAMIC_BASE_PACKAGIST_CACHE_TTL', 3600),
10+
11+
'icon_url' => env('STATAMIC_BASE_ICON_URL', 'https://opensource.justbetter.nl/statamic/justbetter-logo-small-black.svg'),
12+
13+
'icon_dark_url' => env('STATAMIC_BASE_ICON_DARK_URL', 'https://opensource.justbetter.nl/statamic/justbetter-logo-small-white.svg'),
14+
];

0 commit comments

Comments
 (0)