Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/auto lint #378

Merged
merged 25 commits into from
Jul 31, 2024
Merged
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
34 changes: 33 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,38 @@
"**/.build": true
},
"files.watcherExclude": {
"**/.build": true,
"**/.build": true
},
"prettier.documentSelectors": [
"**/*.{js,jsx,ts,tsx,vue,html,css,scss,less,json,md,mdx,graphql,yaml,yml,php}"
],
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[markdown]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"[css]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"[scss]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"[blade]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"[php]": {
"editor.defaultFormatter": "open-southeners.laravel-pint",
"editor.formatOnSave": true
}
}
92 changes: 51 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,22 @@ _See [roots/bedrock](https://github.com/roots/bedrock#readme) readme for notes a

## Genero features

* Build tasks using [Robo](https://robo.li/) and our [generoi/robo-genero](https://github.com/generoi/robo-genero) package.
* Atomic deploys using [Deployer](https://deployer.org/) and our [generoi/deployer-genero](https://github.com/generoi/deployer-genero) package.
* Composer tasks for building and linting the project. If needed you can customize these for your project.
* [DDEV](https://ddev.readthedocs.io/) local development environment.
* [GitHub actions](https://github.com/generoi/bedrock/tree/master/.github/workflows) for deploying, linting, e2e and lighthouse.
* Bundled opinionated [sage fork](https://github.com/generoi/bedrock/tree/master/web/app/themes/gds) using laravel mix
* Automatic production/staging `.env` environment detection on Kinsta
* Various [mu-plugins](https://github.com/generoi/bedrock/tree/master/web/app/mu-plugins) to increase security and set sane defaults.

- Build tasks using [Robo](https://robo.li/) and our [generoi/robo-genero](https://github.com/generoi/robo-genero) package.
- Atomic deploys using [Deployer](https://deployer.org/) and our [generoi/deployer-genero](https://github.com/generoi/deployer-genero) package.
- Composer tasks for building and linting the project. If needed you can customize these for your project.
- [DDEV](https://ddev.readthedocs.io/) local development environment.
- [GitHub actions](https://github.com/generoi/bedrock/tree/master/.github/workflows) for deploying, linting, e2e and lighthouse.
- Bundled opinionated [sage fork](https://github.com/generoi/bedrock/tree/master/web/app/themes/gds) using laravel mix
- Automatic production/staging `.env` environment detection on Kinsta
- Various [mu-plugins](https://github.com/generoi/bedrock/tree/master/web/app/mu-plugins) to increase security and set sane defaults.

## Requirements

* PHP 8.0 - [Installation](https://formulae.brew.sh/formula/php@8.0)
* Composer - [Installation](https://getcomposer.org/doc/00-intro.md#installation-linux-unix-macos)
* DDEV - [Installation](https://ddev.readthedocs.io/en/latest/users/install/ddev-installation/)
- PHP 8.0 - [Installation](https://formulae.brew.sh/formula/php@8.0)
- Composer - [Installation](https://getcomposer.org/doc/00-intro.md#installation-linux-unix-macos)
- DDEV - [Installation](https://ddev.readthedocs.io/en/latest/users/install/ddev-installation/)
- Prettier - [Installation](https://prettier.io/docs/en/editors.html)
- EditorConfig - [Installation](https://editorconfig.org/#download)

### Authenticate with satispress

Expand All @@ -32,6 +33,15 @@ You will need an authentication token, we have a shared one added to LastPass/1P

npm config set "//npm.fontawesome.com/:_authToken" <API-KEY>

### Suggested extensions for Visual Studio Code

- [EditorConfig for VS Code](https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig)
- [Prettier - Code formatter](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode)
- [PHP Intelephense](https://marketplace.visualstudio.com/items?itemName=bmewburn.vscode-intelephense-client)
- [PHP Debug](https://marketplace.visualstudio.com/items?itemName=xdebug.php-debug)
- [laravel-blade](https://marketplace.visualstudio.com/items?itemName=cjhowe7.laravel-blade)
- [Laravel Pint](https://marketplace.visualstudio.com/items?itemName=open-southeners.laravel-pint)

## Local project development with DDEV

_If you are on Windows you should read the latest DDEV documentation and recommendations for getting things running. You'll need to run all composer, npm, robo and dep commands from within the DDEV container. Remember to send your SSH keys to container using `ddev auth ssh`_
Expand Down Expand Up @@ -124,45 +134,45 @@ _NOTE: If possible set the project name and repo name to use the domain name of

1. Create a new project in a new folder for your project

```sh
# Prompt, create and enter directory
echo 'Project directory:'; read project; composer create-project --keep-vcs --repository-url="https://packagist.minasithil.genero.fi" generoi/bedrock:dev-master $project; cd $project;
```sh
# Prompt, create and enter directory
echo 'Project directory:'; read project; composer create-project --keep-vcs --repository-url="https://packagist.minasithil.genero.fi" generoi/bedrock:dev-master $project; cd $project;

# Just create
composer create-project --keep-vcs --repository-url="https://packagist.minasithil.genero.fi" generoi/bedrock:dev-master <project-dir>
# If you cloned the repo rather than used `create-project` you'll need to:
# 1. You need to first install robo.
composer install:development
# 2. replace the placeholder names with a project machine name.
./vendor/bin/robo search:replace
```
# Just create
composer create-project --keep-vcs --repository-url="https://packagist.minasithil.genero.fi" generoi/bedrock:dev-master <project-dir>

# If you cloned the repo rather than used `create-project` you'll need to:
# 1. You need to first install robo.
composer install:development
# 2. replace the placeholder names with a project machine name.
./vendor/bin/robo search:replace
```

2. Setup the DDEV container

```sh
ddev start
```
```sh
ddev start
```

3. Setup the staging/production environment

```sh
# Configure the environment
vim wp-cli.yml
vim robo.yml
```sh
# Configure the environment
vim wp-cli.yml
vim robo.yml

# Prep the remote environment
./vendor/bin/dep setup staging
# Prep the remote environment
./vendor/bin/dep setup staging

# Make a first deployment (this will fail due to there not being any database)
./vendor/bin/dep setup staging
# Make a first deployment (this will fail due to there not being any database)
./vendor/bin/dep setup staging

# Deploy your code, files and database
./vendor/bin/robo db:push @staging
./vendor/bin/robo files:push @staging
# Deploy your code, files and database
./vendor/bin/robo db:push @staging
./vendor/bin/robo files:push @staging

# Deploy once more with database available
./vendor/bin/dep deploy staging
```
# Deploy once more with database available
./vendor/bin/dep deploy staging
```

4. Setup the GitHub actions, E2E tests etc.
5 changes: 3 additions & 2 deletions RoboFile.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
<?php

if (file_exists($composer = __DIR__ . '/vendor/autoload.php')) {
if (file_exists($composer = __DIR__.'/vendor/autoload.php')) {
require_once $composer;
}

// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
class RoboFile extends \Robo\Tasks
{
use \Generoi\Robo\Command\loadCommands;

// phpcs:enable
use \Generoi\Robo\Task\loadTasks;
use \Generoi\Robo\Command\loadCommands;

/**
* Pull uploads directory from remote to local.
Expand Down
64 changes: 47 additions & 17 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,30 @@
}
],
"keywords": [
"bedrock", "composer", "roots", "wordpress", "wp", "wp-config"
"bedrock",
"composer",
"roots",
"wordpress",
"wp",
"wp-config"
],
"support": {
"issues": "https://github.com/roots/bedrock/issues",
"forum": "https://discourse.roots.io/category/bedrock"
},
"repositories": [
{ "type": "composer", "url": "https://wpackagist.org" },
{ "type": "composer", "url": "https://packagist.minasithil.genero.fi/" },
{ "type": "composer", "url": "https://satispress.generodigital.com/satispress/" }
{
"type": "composer",
"url": "https://wpackagist.org"
},
{
"type": "composer",
"url": "https://packagist.minasithil.genero.fi/"
},
{
"type": "composer",
"url": "https://satispress.generodigital.com/satispress/"
}
],
"require": {
"php": ">=8.0",
Expand All @@ -47,12 +61,10 @@
"generoi/robo-genero": "^0.4",
"wp-cli/wp-cli-bundle": "^2.9",
"aaemnnosttv/wp-cli-login-command": "^1.5",

"wpackagist-plugin/show-environment-in-admin-bar": "^1.1",
"jameelmoses/wordpress-kint-debugger": "^2.0",
"wpackagist-plugin/query-monitor": "^3.3",
"wpackagist-plugin/user-switching": "^1.5",

"roots/acorn": "^4.0",
"log1x/navi": "^3.0",
"log1x/sage-svg": "^2.0",
Expand All @@ -61,7 +73,6 @@
"spatie/laravel-google-fonts": "^1.2",
"generoi/sage-woocommerce": "^1.1",
"generoi/sage-cachetags": "^1.1",

"wpackagist-plugin/safe-svg": "^2.1",
"wpackagist-plugin/limit-login-attempts-reloaded": "^2.6.1",
"wpackagist-plugin/wp-sanitize-file-name-plus": "^1.0",
Expand All @@ -77,11 +88,11 @@
"spatie/laravel-csp": "^2.10"
},
"require-dev": {
"squizlabs/php_codesniffer": "^3.4.2",
"brainmaestro/composer-git-hooks": "^3.0.0",
"deployer/deployer": "^7.0",
"generoi/deployer-genero": "^0.3",
"staabm/annotate-pull-request-from-checkstyle": "^1.5"
"staabm/annotate-pull-request-from-checkstyle": "^1.5",
"laravel/pint": "^1.17"
},
"config": {
"optimize-autoloader": true,
Expand All @@ -105,20 +116,28 @@
"prefer-stable": true,
"extra": {
"dropin-paths": {
"web/app/mu-plugins": ["package:aaemnnosttv/wp-cli-login-command:plugin/wp-cli-login-server.php"],
"web/": ["package:generoi/genero-status:genero-status.php"]
"web/app/mu-plugins": [
"package:aaemnnosttv/wp-cli-login-command:plugin/wp-cli-login-server.php"
],
"web/": [
"package:generoi/genero-status:genero-status.php"
]
},
"hooks": {
"pre-commit": "composer test",
"pre-commit": "composer lint:fix && composer test",
"post-merge": "composer install:development"
},
"installer-paths": {
"web/app/mu-plugins/{$name}/": [
"type:wordpress-muplugin",
"wpackagist-plugin/show-environment-in-admin-bar"
],
"web/app/plugins/{$name}/": ["type:wordpress-plugin"],
"web/app/themes/{$name}/": ["type:wordpress-theme"]
"web/app/plugins/{$name}/": [
"type:wordpress-plugin"
],
"web/app/themes/{$name}/": [
"type:wordpress-theme"
]
},
"wordpress-install-dir": "web/wp",
"wp-translation-downloader": {
Expand Down Expand Up @@ -153,10 +172,21 @@
"scripts": {
"post-create-project-cmd": "Generoi\\Robo\\Composer\\ComposerScript::postCreateProject",
"post-update-cmd": "php -r \"if (is_executable('vendor/bin/cghooks')) exec('vendor/bin/cghooks update');\"",
"test": "Generoi\\Robo\\Composer\\ComposerScript::test",
"test": [
"@composer validate --no-check-all",
"@composer lint"
],
"lint": [
"pint --test",
"cd web/app/themes/gds; npm run lint"
],
"lint:fix": [
"pint",
"cd web/app/themes/gds; npm run lint:fix"
],
"ci": [
"composer validate --no-check-all",
"vendor/bin/phpcs --report=checkstyle | vendor/bin/cs2pr",
"@composer validate --no-check-all",
"pint --format=checkstyle | vendor/bin/cs2pr",
"(cd web/app/themes/gds; npm run ci:scripts --silent) | vendor/bin/cs2pr",
"(cd web/app/themes/gds; npm run ci:styles --silent 2>&1) | vendor/bin/cs2pr"
],
Expand Down
Loading