Skip to content

Commit

Permalink
🎉 feat: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Cambis committed May 1, 2024
0 parents commit ff91d3f
Show file tree
Hide file tree
Showing 35 changed files with 807 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/config@3.0.0/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "restricted",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}
20 changes: 20 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# For more information about the properties used in this file,
# please see the EditorConfig documentation:
# https://editorconfig.org/

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.{yml,js,json,css,scss}]
indent_size = 2

[composer.json]
indent_size = 4
34 changes: 34 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# IDE
.editorconfig export-ignore

# Git
.gitattributes export-ignore
.gitignore export-ignore
.github export-ignore

# Quality tools
.changeset export-ignore
.husky export-ignore
commitlint.config.js export-ignore
lint-staged.config.js export-ignore

# Tests
phpunit.xml.dist export-ignore
tests export-ignore

# Coding standards
ecs.php export-ignore
phpstan.neon.dist export-ignore
rector.php export-ignore
stubs export-ignore

# Documentation
CHANGELOG.md export
CONTRIBUTING.md export-ignore

# Docker
compose.yml export-ignore
docker export-ignore

# Extra
package.json export-ignore
28 changes: 28 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Lint 👮

on:
pull_request:
branches:
- main
push:
branches:
- main

env:
# see https://github.com/composer/composer/issues/9368#issuecomment-718112361
COMPOSER_ROOT_VERSION: dev-main

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: shivammathur/setup-php@v2
with:
php-version: 8.3
coverage: none

- uses: ramsey/composer-install@v2

- run: composer lint
38 changes: 38 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Publish 🔖
on:
workflow_run:
workflows:
- lint
- test
branches:
- main
types:
- completed

concurrency: ${{ github.workflow }}-${{ github.ref }}

permissions:
contents: write
pull-requests: write

jobs:
publish:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18

- run: yarn install

- name: Create release pull request or publish
id: changesets
uses: changesets/action@v1
with:
commit: ":memo: ci: update changelog"
title: ":memo: ci: update changelog"
publish: "echo 'versioned'"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
69 changes: 69 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Release 🚀

# https://tomasvotruba.com/blog/how-to-release-php-81-and-72-package-in-the-same-repository/
# https://github.com/TomasVotruba/cognitive-complexity/blob/main/.github/workflows/downgraded_release.yaml
# https://github.com/symplify/config-transformer/blob/main/.github/workflows/downgraded_release.yaml
# https://github.com/driftingly/rector-laravel/blob/main/.github/workflows/downgraded_release.yaml

on:
push:
tags:
- "*"

jobs:
release:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- uses: shivammathur/setup-php@v2
with:
php-version: 8.3
coverage: none

- uses: ramsey/composer-install@v2

# Downgrade to PHP 7.4
- run: vendor/bin/rector process src --config build/rector-downgrade-php-74.php --ansi

# Copy composer
- run: cp build/composer-php-74.json composer.json

# Clear the dev files
- run: |
rm -rf \
.editorconfig \
.gitattributes \
.gitignore \
.github \
.changeset \
.husky \
commitlint.config.js \
lint-staged.config.js \
phpunit.xml.dist \
tests \
ecs.php \
phpstan.neon.dist \
rector.php \
build \
stubs \
package.json \
CHANGELOG.md \
CONTRIBUTING.md \
docker \
compose.yml \
# Setup git bot user
- run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
# Publish to the same repository with a new tag
- name: Tag downgraded code
run: |
git commit -a -m ":package: ci: php-7.4 downgraded ${GITHUB_REF#refs/tags/}"
# Force push tag, so there is only a single version
git tag "${GITHUB_REF#refs/tags/}" --force
git push origin "${GITHUB_REF#refs/tags/}" --force
23 changes: 23 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Test 🧑‍🔬

on:
pull_request:
branches:
- main
push:
branches:
- main

env:
# see https://github.com/composer/composer/issues/9368#issuecomment-718112361
COMPOSER_ROOT_VERSION: dev-main

jobs:
test:
name: test
uses: silverstripe/gha-ci/.github/workflows/ci.yml@v1
with:
simple_matrix: true
phplinting: false
endtoend: false
js: false
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# OS
.DS_Store

# IDE
.idea
.vscode

# Silverstripe
public/
app/

# Dependencies
node_modules/
vendor/
composer.lock
yarn-error.log
yarn.lock

# Tests
.phpunit.result.cache
coverage/
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx --no -- commitlint --edit "$1"
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged
60 changes: 60 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Contributing 🤩

Kia ora! Would you like to contribute? That's awesome, thank you so much for your interest in this project!

Before you go committing your amazing contribution please read the following guidelines.

## Getting started 🐤

Here are some things to know before you start coding.

We use the following dependencies for development:

- php 8.3
- composer
- node >=18

We use a number of quality of life tools to streamline development, install them via the command line.

```sh
composer install
yarn install
```

## Coding standards 👮‍♂️

To keep the codebase tidy, use the following script to clean each commit.

```sh
composer lint
```

## Commit standards 👮‍♀️

This project uses the [gitmoji config for commitlint](https://www.npmjs.com/package/commitlint-config-gitmoji#structure).

Each commit should adhere to the following structure.

```sh
:gitmoji: type(scope?): subject
body?
footer?
```

## Testing 🧑‍🔬

Be sure to run the test suite regularly. New tests should be added for new features.

```sh
vendor/bin/phpunit
```

## Making a pull request ✨

This project uses [changesets](https://github.com/changesets/changesets). This tool helps us to streamline our changelog.

When making a pull request, be sure to add a changeset if there has been a change to the project.

```sh
npx changeset
```
10 changes: 10 additions & 0 deletions LICENCE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
The MIT License (MIT)
-----

Copyright (c) 2024 - present Cameron Bryers

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Silverstripe Module | Kōwae Ponga

A personal Silverstripe module boilerplate.

## What's included? 🤔

### Coding standards
- [Easy Coding Standard](https://github.com/easy-coding-standard/easy-coding-standard)
- [PHP Parallel Lint](https://github.com/php-parallel-lint/PHP-Parallel-Lint)
- [PHPStan](https://phpstan.org/)
- [Rector](https://getrector.com/)

### Continuous integration
- [Github Actions](https://github.com/features/actions)

### Developer environment
- [Docker](https://docs.docker.com/get-docker/)

### Quality tools
- [Changesets](https://github.com/changesets/changesets)
- [Commitlint](https://commitlint.js.org/)
- [Husky](https://typicode.github.io/husky/)
- [Lint Staged](https://github.com/lint-staged/lint-staged)

### Testing
- [PHPUnit](https://phpunit.de/index.html)

## Getting started 🐤

Once you have cloned this repo or used the 'create template' function check the [contributing guide](./CONTRIBUTING.md#getting-started-🐤). This guide will contain useful information about the developer tools that are provided.

Once you have set everything up, feel free to modify this template as you please.
4 changes: 4 additions & 0 deletions _config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php

// You need this file if you don't have anything in the _config folder. If that folder exists
// and is not empty then you can delete this file.
Loading

0 comments on commit ff91d3f

Please sign in to comment.