Skip to content

Commit

Permalink
Merge branch 'trunk' into feature/block-theme
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiankaegy committed Dec 12, 2024
2 parents 3e5cd5b + f98306f commit 58128dc
Show file tree
Hide file tree
Showing 68 changed files with 5,375 additions and 5,679 deletions.
80 changes: 80 additions & 0 deletions .github/workflows/node.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Node

on:
push:
branches:
- main
pull_request:

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

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: "npm"

- name: Install dependencies
run: npm install

- name: Run Lint JS
run: npm run lint-js

lint-style:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: "npm"

- name: Install dependencies
run: npm install

- name: Run Lint Style
run: npm run lint-style

test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: "npm"

- name: Install dependencies
run: npm install

- name: Run Jest
run: npm run test

build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: "npm"

- name: Install dependencies
run: npm install

- name: Build
run: npm run build
30 changes: 25 additions & 5 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,35 @@ name: PHP Checks

on:
push:
branches: [ "trunk" ]
branches: ["trunk"]
pull_request:
branches: [ "trunk" ]
branches: ["trunk"]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Validate composer.json and composer.lock
- name: Setup PHP with composer v2
uses: shivammathur/setup-php@v2
with:
php-version: "8.3"
tools: composer:v2

- name: Validate Root composer.json and composer.lock
run: composer validate --strict

- name: Validate Plugin composer.json and composer.lock
run: composer validate --strict --working-dir=mu-plugins/10up-plugin

- name: Validate Theme composer.json and composer.lock
run: composer validate --strict --working-dir=themes/10up-theme

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
Expand All @@ -29,8 +40,17 @@ jobs:
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
- name: Install Root dependencies
run: composer install --prefer-dist --no-progress

- name: Install Plugin dependencies
run: composer install --prefer-dist --no-progress --working-dir=mu-plugins/10up-plugin

- name: Install Theme dependencies
run: composer install --prefer-dist --no-progress --working-dir=themes/10up-theme

- name: Run PHPCS
run: composer lint

- name: Run PHPStan
run: composer static
1 change: 0 additions & 1 deletion .husky/.gitignore

This file was deleted.

3 changes: 0 additions & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#!/bin/bash
. "$(dirname "$0")/_/husky.sh"

PARENT_DIR="$(git rev-parse --show-toplevel)"
SCAFFOLD_PATH=$(grep hooksPath "${PARENT_DIR}"/.git/config | awk '{print $3}')

Expand Down
16 changes: 4 additions & 12 deletions .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
{
"*.css": [
"10up-toolkit lint-style"
],
"*.js": [
"10up-toolkit lint-js"
],
"*.jsx": [
"10up-toolkit lint-js"
],
"*.php": [
"./vendor/bin/phpcs"
]
"*.css": ["10up-toolkit lint-style"],
"*.js": ["10up-toolkit lint-js"],
"*.jsx": ["10up-toolkit lint-js"],
"*.php": ["./vendor/bin/phpcs"]
}
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18
20
4 changes: 1 addition & 3 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{
"recommendations": [
"dbaeumer.vscode-eslint",
]
"recommendations": ["dbaeumer.vscode-eslint"]
}
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ It contains a bare bones theme and must use plugin for you to base your developm

## How to Use

*The best way to use the scaffold is to simply run `npx 10up-toolkit project init` in your terminal.*
_The best way to use the scaffold is to simply run `npx 10up-toolkit project init` in your terminal._

You can also use the scaffold manually by doing the following:

Expand All @@ -28,6 +28,7 @@ You can also use the scaffold manually by doing the following:
"mu-plugins/my-other-awesome-10up-plugin",
],
```

6. To build plugins/themes simply run `npm install` at the root and `npm run [build|start|watch]` and npm will automatically build all themes and plugins. If a WordPress critical error is received run `composer install` in all locations that have an existing `composer.lock` file; example locations: `root`, `/mu-plugins/10up-plugin`, `/themes/10up-theme`. Upon build completion set the `10up-theme` as active within WordPress admin by running `wp theme activate 10up-theme`.
7. `npm workspaces` do not have the ability to run scripts from multiple packages in parrallel. Because of that we use the `npm-run-all` package and we define specific scripts in `package.json` so you will need to update the `watch:*` scripts in `package.json` and replace `tenup-theme` and `tenup-plugin` with the actual package names.

Expand All @@ -36,17 +37,19 @@ You can also use the scaffold manually by doing the following:
"watch:plugin": "npm run watch -w=tenup-plugin",
"watch": "run-s watch:theme watch:plugin",
```

7. To add npm dependencies to your theme and/or plugins add the `-w=package-name` flag to the `npm install` command. E.g: `npm install --save prop-types -w=tenup-plugin` **DO NOT RUN** `npm install` inside an individual workspace/package. Always run the from the root folder.
8. If you're building Gutenberg blocks and importing `@wordpress/*` packages, **you do not** need to manually install them as `10up-toolkit` will handle these packages properly.

## Scaffold Rules

Much of the functionality in the scaffold is intended to be optional depending on the needs of your project e.g. i18n functionality. However, there are a few important principles that you must follow:

1. [10up Toolkit](https://github.com/10up/10up-toolkit) must be used for asset bundling. Over the years we've found differences in how assets are built across projects to be very confusing for engineers. As such, we are standardizing on 10up Toolkit (which you can extend as needed). 10up Toolkit contains in depth docs on how it works.
1. [10up Toolkit](https://github.com/10up/10up-toolkit) must be used for asset bundling. Over the years we've found differences in how assets are built across projects to be very confusing for engineers. As such, we are standardizing on 10up Toolkit (which you can extend as needed). 10up Toolkit contains in depth docs on how it works.
2. Functionality should be built into the 10up must-use functionality as much as possible. Presentation should be kept in the theme. Separating these two makes long term development, maintenance, and extensibility much easier.
3. Blocks should be built into the theme and follow the [example block](https://github.com/10up/wp-scaffold/tree/trunk/themes/10up-theme/includes/blocks/example-block) provided.
5. When creating new themes or plugins make sure to follow the `scripts` convention:
4. When creating new themes or plugins make sure to follow the `scripts` convention:

```json
"scripts": {
"start": "npm run watch",
Expand Down
17 changes: 12 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,27 @@
}
],
"require": {
"php": ">=7.0"
"php": ">=8.3"
},
"minimum-stability": "dev",
"prefer-stable": true,
"require-dev": {
"10up/phpcs-composer": "^3.0",
"wpackagist-plugin/debug-bar": "*",
"wpackagist-plugin/query-monitor":"*",
"wpackagist-plugin/debug-bar-slow-actions":"*",
"phpcompatibility/php-compatibility": "dev-develop as 9.99.99"
"wpackagist-plugin/query-monitor": "*",
"wpackagist-plugin/debug-bar-slow-actions": "*",
"phpcompatibility/php-compatibility": "dev-develop as 9.99.99",
"szepeviktor/phpstan-wordpress": "^1.3",
"php-stubs/wp-cli-stubs": "^2.11",
"phpstan/phpstan-deprecation-rules": "^1.2"
},
"scripts": {
"lint": "phpcs .",
"lint-fix": "phpcbf ."
"lint-fix": "phpcbf .",
"static": [
"Composer\\Config::disableProcessTimeout",
"phpstan --memory-limit=1G"
]
},
"extra": {
"installer-paths": {
Expand Down
Loading

0 comments on commit 58128dc

Please sign in to comment.