Skip to content

Commit

Permalink
Merge branch 'release/4.0.1' into v4
Browse files Browse the repository at this point in the history
  • Loading branch information
khalwat committed Apr 28, 2024
2 parents 2b50aeb + 1e83cd2 commit 9019793
Show file tree
Hide file tree
Showing 34 changed files with 4,788 additions and 1,918 deletions.
1 change: 0 additions & 1 deletion .craftplugin

This file was deleted.

14 changes: 7 additions & 7 deletions .github/workflows/build-and-deploy-docs.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
name: Build and Deploy Docs
env:
DOCS_DEST_DIR: /similar/
DOCS_DEST_DIR: /similar/v4/
on:
push:
branches:
- v1
- v4
paths:
- 'docs/**'
pull_request:
branches:
- v1
- v4
paths:
- 'docs/**'
workflow_dispatch:
Expand All @@ -22,11 +22,11 @@ jobs:
strategy:
fail-fast: true
matrix:
node-version: [14.x]
node-version: [ 20.x ]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
Expand All @@ -35,7 +35,7 @@ jobs:
- name: rsync deployments
uses: burnett01/[email protected]
with:
switches: -avzr --delete
switches: -avzr
path: ./dist/
remote_path: ${{ secrets.NYS_DOCS_ROOT }}${{ env.DOCS_DEST_DIR }}
remote_host: ${{ secrets.NYS_DEPLOY_REMOTE_HOST }}
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/code-analysis.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
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.2
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 }}
21 changes: 21 additions & 0 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Create Release
run-name: Create release for ${{ github.event.client_payload.version }}

on:
repository_dispatch:
types:
- craftcms/new-release

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: ncipollo/release-action@v1
with:
body: ${{ github.event.client_payload.notes }}
makeLatest: ${{ github.event.client_payload.latest }}
name: ${{ github.event.client_payload.version }}
prerelease: ${{ github.event.client_payload.prerelease }}
tag: ${{ github.event.client_payload.tag }}
81 changes: 14 additions & 67 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,81 +1,28 @@
# Similar Changelog

## 4.0.0 - 2022.05.09
### Added
* Initial Craft CMS 4 release

### Fixed
* Fixed an issue where passing an `ElementQuery` into `criteria` would cause it to throw a type error ([#44](https://github.com/nystudio107/craft-similar/issues/44))

## 4.0.0-beta.1 - 2022.03.15

## 4.0.1 - 2024.04.28
### Added
* Added `ServicesTrait` for the plugin service component registration
* Add `phpstan` and `ecs` code linting
* Add `code-analysis.yaml` GitHub action

* Initial Craft CMS 4 compatibility

## 1.1.5 - 2021.06.03
### Changed
* If `orderBy` criteria is omitted, entries are now sorted by the number of relations in common. (https://github.com/nystudio107/craft-similar/issues/35)
* Switch to VitePress for documentation
* Updated `Makefile` to use `node-14-alpine`
* Updated docs to use node 20 & a new sitemap plugin
* PHPstan code cleanup
* ECS code cleanup

## 1.1.4 - 2021.03.27
### Changed
* Move settings from the `composer.json` “extra” to the plugin main class

## 1.1.3 - 2021.03.27
### Fixed
* Fixed an issue with using `RAND()` in the sort criteria (https://github.com/nystudio107/craft-similar/issues/32)
* Fixed an issue where an exception would be thrown if `orderBy` was `null` ([#49](https://github.com/nystudio107/craft-similar/issues/49))

## 1.1.2 - 2021.03.23
### Fixed
* Fixed an SQL error related to even stricter GROUP BY rules.
* Fixed an error where using a tag field that had no matches on other elements could return a random set of entries. (https://github.com/nystudio107/craft-similar/issues/31)

## 1.1.1 - 2021.03.11
### Fixed
* Ensure that the key in `$similarCount` exists before referencing it

## 1.1.0 - 2021.03.05
## 4.0.0 - 2022.05.09
### Added
* Added buildchain for docs

### Changed
* Similar elements are now fetched with the eager-loading conditions intact that were set on the criteria object. (https://github.com/nystudio107/craft-similar/issues/14)
* Similar elements are now searched in the source element site only by default.
* Similar plugin now requires at least Craft CMS 3.2.0.
* Initial Craft CMS 4 release

### Fixed
* Fix an SQL error related to stricter GROUP BY rules. (https://github.com/nystudio107/craft-similar/issues/19)
* Fix an SQL error that could occur if no structure data was selected for entries. (https://github.com/nystudio107/craft-similar/issues/22)

## 1.0.6 - 2019-04-20
### Changed
* Add `structureelements.structureId` to `GROUP BY` clause

## 1.0.5 - 2019-01-05
### Changed
* Fix SQL error: Unknown column `structureelements.lft` in 'group statement for Products

## 1.0.4 - 2018-10-08
### Changed
* Only try to fetch elements if SQL query returns an `id`
* Update GROUP BY clause in SELECT queries to ensure they are compatible with `sql_mode=only_full_group_by`

## 1.0.3 - 2018-08-04
### Changed
* Fixed a regression of the returned query results

## 1.0.2 - 2018-07-21
### Changed
* Fixed an issue that errantly prefixed the sub-query with the table name
* Fixed an issue where passing an `ElementQuery` into `criteria` would cause it to throw a type error ([#44](https://github.com/nystudio107/craft-similar/issues/44))

## 1.0.1 - 2018-07-21
### Changed
* Added grouping to the sub-query to ensure that it returns the correct number of results
* Moved the anonymous function `EVENT_AFTER_PREPARE` event handler to a named function to avoid serialization errors in cache tags
* Optimizations and code cleanup
## 4.0.0-beta.1 - 2022.03.15

## 1.0.0 - 2018-01-16
### Added
* Initial release

* Initial Craft CMS 4 compatibility
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2022 nystudio107.com
Copyright (c) nystudio107.com

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:

Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/nystudio107/craft-similar/badges/quality-score.png?b=v1)](https://scrutinizer-ci.com/g/nystudio107/craft-similar/?branch=v1) [![Code Coverage](https://scrutinizer-ci.com/g/nystudio107/craft-similar/badges/coverage.png?b=v1)](https://scrutinizer-ci.com/g/nystudio107/craft-similar/?branch=v1) [![Build Status](https://scrutinizer-ci.com/g/nystudio107/craft-similar/badges/build.png?b=v1)](https://scrutinizer-ci.com/g/nystudio107/craft-similar/build-status/v1) [![Code Intelligence Status](https://scrutinizer-ci.com/g/nystudio107/craft-similar/badges/code-intelligence.svg?b=v1)](https://scrutinizer-ci.com/code-intelligence)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/nystudio107/craft-similar/badges/quality-score.png?b=v4)](https://scrutinizer-ci.com/g/nystudio107/craft-similar/?branch=v4) [![Code Coverage](https://scrutinizer-ci.com/g/nystudio107/craft-similar/badges/coverage.png?b=v4)](https://scrutinizer-ci.com/g/nystudio107/craft-similar/?branch=v4) [![Build Status](https://scrutinizer-ci.com/g/nystudio107/craft-similar/badges/build.png?b=v4)](https://scrutinizer-ci.com/g/nystudio107/craft-similar/build-status/v4) [![Code Intelligence Status](https://scrutinizer-ci.com/g/nystudio107/craft-similar/badges/code-intelligence.svg?b=v4)](https://scrutinizer-ci.com/code-intelligence)

# Similar plugin for Craft CMS 4.x

Similar for Craft lets you find elements, Entries, Categories, Commerce Products, etc, that are similar, based on... other related elements.

![Screenshot](./docs/docs/resources/img/plugin-logo.png)

Related: [Similar for Craft 2.x](https://github.com/aelvan/Similar-Craft)

## Requirements

This plugin requires Craft CMS 4.0.0 or later.
Expand Down
20 changes: 19 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "nystudio107/craft-similar",
"description": "Similar for Craft lets you find elements, Entries, Categories, Commerce Products, etc, that are similar, based on... other related elements.",
"type": "craft-plugin",
"version": "4.0.0",
"version": "4.0.1",
"keywords": [
"craft",
"cms",
Expand All @@ -27,6 +27,24 @@
"require": {
"craftcms/cms": "^4.0.0"
},
"require-dev": {
"craftcms/ecs": "dev-main",
"craftcms/phpstan": "dev-main",
"craftcms/rector": "dev-main"
},
"scripts": {
"phpstan": "phpstan --ansi --memory-limit=1G",
"check-cs": "ecs check --ansi",
"fix-cs": "ecs check --fix --ansi"
},
"config": {
"allow-plugins": {
"craftcms/plugin-installer": true,
"yiisoft/yii2-composer": true
},
"optimize-autoloader": true,
"sort-packages": true
},
"autoload": {
"psr-4": {
"nystudio107\\similar\\": "src/"
Expand Down
2 changes: 2 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
/vendor
/node_modules
/docs/.vitepress/dist
/docs/.vitepress/cache
4 changes: 3 additions & 1 deletion docs/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
ARG TAG=14-alpine
ARG TAG=20-alpine
FROM node:$TAG

RUN npm install -g npm@^10.0.0

WORKDIR /app/

CMD ["run build"]
Expand Down
76 changes: 39 additions & 37 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -1,45 +1,47 @@
TAG?=14-alpine
CONTAINER?=$(shell basename $(dir $(CURDIR)))-docs
DOCKERRUN=docker container run \
--name ${CONTAINER} \
--rm \
-p 3002:3002 \
-t \
-v `pwd`:/app \
${CONTAINER}:${TAG}
DOCSDEST?=../../../sites/nystudio107/web/docs/similar
MAJOR_VERSION?=4
TAG?=20-alpine
CONTAINER?=$(shell basename $(dir $(CURDIR)))-v${MAJOR_VERSION}-docs
DOCS_DEV_PORT?=400${MAJOR_VERSION}
DOCS_DEST?=../../../sites/nystudio107/web/docs/similar/v4
IMAGE_INFO=$(shell docker image inspect $(CONTAINER):$(TAG))
IMAGE_NAME=${CONTAINER}:${TAG}
DOCKER_RUN=docker container run --rm -it -v "${CURDIR}":/app

.PHONY: docker build dev fix install lint clean npm
.PHONY: build clean dev fix image-build image-check lint npm ssh

docker:
docker build \
. \
-t ${CONTAINER}:${TAG} \
--build-arg TAG=${TAG} \
--no-cache
build: clean docker install
${DOCKERRUN} \
run docs:build
rm -rf ${DOCSDEST}
mv ./docs/.vitepress/dist ${DOCSDEST}
dev: docker install
${DOCKERRUN} \
run docs:dev
fix: docker install
${DOCKERRUN} \
run docs:fix
install: docker
${DOCKERRUN} \
install
lint: docker install
${DOCKERRUN} \
run docs:lint
# Perform a dist build via npm run docs:build
build: image-check
${DOCKER_RUN} --name ${CONTAINER}-$@ ${IMAGE_NAME} run docs:build
rm -rf ${DOCS_DEST}
mv ./docs/.vitepress/dist ${DOCS_DEST}
# Remove node_modules/ & package-lock.json
clean:
rm -rf node_modules/
rm -f package-lock.json
npm: docker
${DOCKERRUN} \
$(filter-out $@,$(MAKECMDGOALS))
# Run the development server via npm run docs:dev
dev: image-check
${DOCKER_RUN} --name ${CONTAINER}-$@ -e DOCS_DEV_PORT="${DOCS_DEV_PORT}" -p ${DOCS_DEV_PORT}:${DOCS_DEV_PORT} ${IMAGE_NAME} run docs:dev
# Fix the docs with textlint via npm run docs:fix
fix: image-check
${DOCKER_RUN} --name ${CONTAINER}-$@ ${IMAGE_NAME} run docs:fix
# Build the Docker image & run npm install
image-build:
docker build . -t ${IMAGE_NAME} --build-arg TAG=${TAG} --no-cache
${DOCKER_RUN} --name ${CONTAINER}-$@ ${IMAGE_NAME} install
# Ensure the image has been created
image-check:
ifeq ($(IMAGE_INFO), [])
image-check: image-build
endif
# Lint the docs with textlint via npm run docs:lint
lint: image-check
${DOCKER_RUN} --name ${CONTAINER}-$@ ${IMAGE_NAME} run docs:lint
# Run the passed in npm command
npm: image-check
${DOCKER_RUN} --name ${CONTAINER}-$@ ${IMAGE_NAME} $(filter-out $@,$(MAKECMDGOALS)) $(MAKEFLAGS)
# Open a shell inside of the container
ssh: image-check
${DOCKER_RUN} --name ${CONTAINER}-$@ --entrypoint=/bin/sh ${IMAGE_NAME}
%:
@:
# ref: https://stackoverflow.com/questions/6273608/how-to-pass-argument-to-makefile-from-command-line
Loading

0 comments on commit 9019793

Please sign in to comment.