Skip to content

Commit

Permalink
Merge branch 'release/4.0.39' into v4
Browse files Browse the repository at this point in the history
  • Loading branch information
khalwat committed Feb 9, 2024
2 parents 2508dd5 + 6291f69 commit d24f153
Show file tree
Hide file tree
Showing 1,632 changed files with 255,909 additions and 255,805 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/code-analysis.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Code Analysis

on:
pull_request: null
push:
branches:
- develop-v4
workflow_dispatch:
permissions:
contents: read
jobs:
code_analysis:
strategy:
fail-fast: false
matrix:
actions:
-
name: 'PHPStan'
run: composer phpstan
-
name: 'Coding Standards'
run: composer fix-cs
name: ${{ matrix.actions.name }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: /tmp/composer-cache
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}
- name: Setup PHP
id: setup-php
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
extensions: 'ctype,curl,dom,iconv,imagick,intl,json,mbstring,openssl,pcre,pdo,reflection,spl,zip'
ini-values: post_max_size=256M, max_execution_time=180, memory_limit=512M
tools: composer:v2
- name: Install Composer dependencies
run: composer install --no-interaction --no-ansi --no-progress
- run: ${{ matrix.actions.run }}
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# SEOmatic Changelog

## 4.0.39 - 2024.02.09
### Added
* Add `phpstan` and `ecs` code linting
* Add `code-analysis.yaml` GitHub action

### Changed
* PHPstan code cleanup
* ECS code cleanup

### Fixed
* Fixed an issue where `DynamicMeta` didn't properly take into account that `robots` can be a comma delimited list of values now ([#1399](https://github.com/nystudio107/craft-seomatic/issues/1399))
* Fixed an issue where a `robots` setting of `none` or `noindex` in the Content SEO settings make it impossible to override the `robots` setting in an SEO Settings field ([#1399](https://github.com/nystudio107/craft-seomatic/issues/1399))
* Added the unused `static` to the Tailwind CSS `blocklist` to avoid a name collision with a Craft CSS class ([#1412](https://github.com/nystudio107/craft-seomatic/issues/1412))
* Added `webp` and `gif` as allowed social media image formats now that the social media sites accept them, and guard against no transform existing ([#1411](https://github.com/nystudio107/craft-seomatic/issues/1411))

## 4.0.38 - 2024.01.22
### Changed
* Updated docs to use node 20 & a new sitemap plugin
Expand Down
3 changes: 2 additions & 1 deletion buildchain/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ CONTAINER?=$(shell basename $(dir $(CURDIR)))-v${MAJOR_VERSION}-buildchain
DEV_PORT?=300${MAJOR_VERSION}
IMAGE_INFO=$(shell docker image inspect $(CONTAINER):$(TAG))
IMAGE_NAME=${CONTAINER}:${TAG}
DOCKER_RUN=docker container run --rm -it --network plugindev_default -v "${CURDIR}"/../:/app
DOCKER_NETWORK?=plugindev_default
DOCKER_RUN=docker container run --rm -it --network "${DOCKER_NETWORK}" -v "${CURDIR}"/../:/app

.PHONY: build clean dev image-build image-check npm ssh

Expand Down
58 changes: 58 additions & 0 deletions buildchain/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# `seomatic` buildchain

This buildchain is a self-contained build system for the `seomatic` JavaScript bundle.

## Overview

The buildchain builds & bundles all of the `seomatic` TypeScript/JavaScript code, Vue components, CSS, and any other static resources via Vite via a Docker container.

Source files:

`buildchain/src/`

Built distribution files:

`src/web/assets/dist/`

## Prerequisites

To run the buildchain for development purposes:

- You must have [Docker Desktop](https://www.docker.com/products/docker-desktop/) (or the equivalent) installed
- We assume you're using the [`plugindev`](https://github.com/nystudio107/plugindev) development project. If you're not, see the **If you're not using `plugindev`** section below

## Commands

This buildchain uses `make` as an interface to the buildchain. The following commands are available from the `buildchain/` directory:

- `make build` - Do a distribution build of the CantoDamAsset asset bundle resources into `src/web/assets/dist/`
- `make dev` - Start Vite HMR dev server for local development
- `make clean` - Remove `node_modules/` and `package-lock.json` to start clean (need to run `make image-build` after doing this, see below)
- `make npm XXX` - Run an `npm` command inside the container, e.g.: `make npm run lint` or `make npm install`
- `make ssh` - Open up a shell session into the buildchain Docker container
- `make image-build` - Build the Docker image & run `npm install`

### If you're not using `plugindev`

If you're not using the [`plugindev`](https://github.com/nystudio107/plugindev) development project, you'll need to follow these steps in order to use the HMR for development in local dev:

- For HMR during local development, you'll need the following variable set in your project's `.env` file:
```dotenv
VITE_PLUGIN_DEVSERVER=1
```
The [`craft-plugin-vite`](https://github.com/nystudio107/craft-plugin-vite) library looks for this environment variable to determine whether it should check for a running Vite dev server.

#### If you're also using Docker

- So your project can access the buildchain container over the [internal Docker network](https://docs.docker.com/compose/networking/), you'll need to set the `DOCKER_NETWORK` environment variable before running any buildchain `make` commands:
```bash
env DOCKER_NETWORK=myproject_default make dev
```
...or use any other method for [setting environment variables](https://www.twilio.com/blog/how-to-set-environment-variables.html). This environment variable needs to be set in the shell where you run the buildchain's various `make` commands from, so setting it in your project's `.env` file won't work.

The network your project uses is typically the project name with `_default` appended to it, but it can be explicitly set in the `docker-composer.yaml` like this:
```yaml
networks:
default:
name: someproject_default
```
2 changes: 1 addition & 1 deletion buildchain/src/js/content-seo.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* SEOmatic plugin for Craft CMS 3.x
* SEOmatic plugin for Craft CMS.x
*
* A turnkey SEO implementation for Craft CMS that is comprehensive, powerful,
* and flexible
Expand Down
2 changes: 1 addition & 1 deletion buildchain/src/js/seomatic-meta.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* SEOmatic plugin for Craft CMS 3.x
* SEOmatic plugin for Craft CMS.x
*
* A turnkey SEO implementation for Craft CMS that is comprehensive, powerful,
* and flexible
Expand Down
2 changes: 1 addition & 1 deletion buildchain/src/js/seomatic.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* SEOmatic plugin for Craft CMS 3.x
* SEOmatic plugin for Craft CMS.x
*
* A turnkey SEO implementation for Craft CMS that is comprehensive, powerful,
* and flexible
Expand Down
3 changes: 3 additions & 0 deletions buildchain/tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ export default {
'../src/templates/**/*.{twig,html}',
'./src/vue/**/*.{vue,html}',
],
blocklist: [
'static',
],
theme: {},
plugins: [],
};
34 changes: 24 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "nystudio107/craft-seomatic",
"description": "SEOmatic facilitates modern SEO best practices & implementation for Craft CMS 4. It is a turnkey SEO system that is comprehensive, powerful, and flexible.",
"type": "craft-plugin",
"version": "4.0.38",
"version": "4.0.39",
"keywords": [
"craft",
"cms",
Expand All @@ -29,15 +29,6 @@
"homepage": "https://nystudio107.com"
}
],
"require-dev": {
"codeception/codeception": "^4.1.29",
"codeception/module-asserts": "^1.3.1",
"codeception/module-datafactory": "^1.1.0",
"codeception/module-phpbrowser": "^1.0.2",
"codeception/module-rest": "^1.4.2",
"codeception/module-yii2": "^1.1.5",
"vlucas/phpdotenv": "^3.0"
},
"require": {
"php": "^8.0.2",
"craftcms/cms": "^4.0.0",
Expand All @@ -47,7 +38,30 @@
"davechild/textstatistics": "^1.0.3",
"sunra/php-simple-html-dom-parser": "^1.5.2"
},
"require-dev": {
"codeception/codeception": "^4.1.29",
"codeception/module-asserts": "^1.3.1",
"codeception/module-datafactory": "^1.1.0",
"codeception/module-phpbrowser": "^1.0.2",
"codeception/module-rest": "^1.4.2",
"codeception/module-yii2": "^1.1.5",
"craftcms/ecs": "dev-main",
"craftcms/phpstan": "dev-main",
"craftcms/rector": "dev-main",
"craftcms/commerce": "^4.0.0",
"craftcms/digital-products": "^3.0.0",
"craftcms/feed-me": "^5.0.0",
"putyourlightson/craft-campaign": "^2.0.0",
"solspace/craft-calendar": "^4.0.0",
"spicyweb/craft-neo": "^4.0.0",
"verbb/doxter": "^5.0.0",
"verbb/super-table": "^3.0.0",
"vlucas/phpdotenv": "^3.0"
},
"scripts": {
"phpstan": "phpstan --ansi --memory-limit=1G",
"check-cs": "ecs check --ansi",
"fix-cs": "ecs check --fix --ansi",
"test": "codecept run unit --coverage-xml"
},
"config": {
Expand Down
74 changes: 74 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# `seomatic` docs

This buildchain is a self-contained build system for the `seomatic` documentation.

## Overview

The buildchain uses [VitePress](https://vitepress.dev/) via a Docker container to facilitate writing the docs as [markdown](https://vitepress.dev/guide/markdown), linting them via [textlint](https://textlint.github.io/), building them as HTML files with bundled assets, and publishing them automatically via a [GitHub action](https://docs.github.com/en/actions).

It also uses a [Rollup](https://rollupjs.org/) [sitemap plugin](https://github.com/aminnairi/rollup-plugin-sitemap) to generate a `sitemap.xml` for the generated docs.

The markdown sources for the docs and assets are in the `docs/docs/` directory.

The built distribution docs are created via the `build-and-deploy-docs.yaml`

## Prerequisites

To run the buildchain for development purposes:

- You must have [Docker Desktop](https://www.docker.com/products/docker-desktop/) (or the equivalent) installed

## Commands

This buildchain uses `make` as an interface to the buildchain. The following commands are available from the `buildchain/` directory:

- `make image-build` - Build the Docker image & run `npm install`. This command must be run once before using the Docker container.
- `make dev` - Start Vite HMR dev server while writing/editing the docs. Click on the link displayed in the terminal to open the docs up
- `make lint` - Run `textlint` on the docs, reporting on any errors and warnings
- `make fix` - Run `textlint` on the docs, automatically fixing any errors, and reporting any warnings
- `make clean` - Remove `node_modules/` and `package-lock.json` to start clean (need to run `make image-build` after doing this, see below)
- `make npm XXX` - Run an `npm` command inside the container, e.g.: `make npm run lint` or `make npm install`
- `make ssh` - Open up a shell session into the buildchain Docker container
- `make build` - Do a local distribution build of the docs; normally not needed since they are built & deployed via GitHub action

## Docs versioning

Each major version of the plugin corresponds to a major version of Craft.

Each major version of the plugin has separate documentation that needs to be updated when changes span plugin versions.

The latest version of the docs that correspond to the latest version of the plugin is always the root of the docs tree, with older versions appearing in sub-directories:

```
│ index.html
├── v4
│ └── index.html
├── v3
│ └── index.html
```

The docs are entirely separate, but linked to eachother via a version menu, configured in the `docs/docs/.vitepress/config.ts` file.

## Algolia Docsearch

The docs uses [Algolia Docsearch](https://docsearch.algolia.com/) to index them, and allow for easy searching via a search field with auto-complete.

Algolia Docsearch is configured in the `docs/docs/.vitepress/config.ts` file.

## textlint

The buildchain uses [textlint](https://textlint.github.io/) to automatically fix errors on build, and also issue writing style warnings.

`textlint` automatically uses any rules added to the `docs/package.json` file, which can be overridden or customized via the `docs/.textlintrc.js` file.

See the [textlint docs](https://textlint.github.io/docs/getting-started.html) for details.

## Overriding environment variables

The `Makefile` contains sane defaults for most things, but you can override them via environment variables if you need to.

For instance, if you want to change the `DOCS_DEST` environment variable to change where `make build` builds the docs locally, you can set it before running any buildchain `make` commands:
```bash
env DOCS_DEST=../path/to/some/dir make build
```
...or use any other method for [setting environment variables](https://www.twilio.com/blog/how-to-set-environment-variables.html). This environment variable needs to be set in the shell where you run the buildchain's various `make` commands from, so setting it in your project's `.env` file won't work.
13 changes: 13 additions & 0 deletions ecs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

use craft\ecs\SetList;
use Symplify\EasyCodingStandard\Config\ECSConfig;

return static function(ECSConfig $ecsConfig): void {
$ecsConfig->paths([
__DIR__ . '/src',
__FILE__,
]);
$ecsConfig->parallel();
$ecsConfig->sets([SetList::CRAFT_CMS_4]);
};
7 changes: 7 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
includes:
- %currentWorkingDirectory%/vendor/craftcms/phpstan/phpstan.neon

parameters:
level: 5
paths:
- src
6 changes: 3 additions & 3 deletions src/Node/Expression/EmptyCoalesceExpression.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* SEOmatic plugin for Craft CMS 3.x
* SEOmatic plugin for Craft CMS
*
* A turnkey SEO implementation for Craft CMS that is comprehensive, powerful,
* and flexible
Expand Down Expand Up @@ -64,11 +64,11 @@ public function compile(Compiler $compiler)
{
//$this->getNode('expr1')->setAttribute('always_defined', true);
$compiler
->raw('(('.self::class.'::empty(')
->raw('((' . self::class . '::empty(')
->subcompile($this->getNode('left'))
->raw(') ? null : ')
->subcompile($this->getNode('left'))
->raw(') ?? ('.self::class.'::empty(')
->raw(') ?? (' . self::class . '::empty(')
->subcompile($this->getNode('right'))
->raw(') ? null : ')
->subcompile($this->getNode('right'))
Expand Down
Loading

0 comments on commit d24f153

Please sign in to comment.