Skip to content

Commit a396fd8

Browse files
committed
Merge branch 'release/4.0.2' into v4
2 parents e305b59 + c618181 commit a396fd8

38 files changed

+6137
-1854
lines changed

.craftplugin

Lines changed: 0 additions & 1 deletion
This file was deleted.

.github/workflows/build-and-deploy-docs.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Build and Deploy Docs
22
env:
3-
DOCS_DEST_DIR: /units/
3+
DOCS_DEST_DIR: /units/v4/
44
on:
55
push:
66
branches:
@@ -22,11 +22,11 @@ jobs:
2222
strategy:
2323
fail-fast: true
2424
matrix:
25-
node-version: [ 14.x ]
25+
node-version: [ 20.x ]
2626
steps:
27-
- uses: actions/checkout@v2
27+
- uses: actions/checkout@v4
2828
- name: Use Node.js ${{ matrix.node-version }}
29-
uses: actions/setup-node@v2
29+
uses: actions/setup-node@v4
3030
with:
3131
node-version: ${{ matrix.node-version }}
3232
- run: npm ci
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Code Analysis
2+
3+
on:
4+
pull_request: null
5+
push:
6+
branches:
7+
- develop-v4
8+
workflow_dispatch:
9+
permissions:
10+
contents: read
11+
jobs:
12+
code_analysis:
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
actions:
17+
-
18+
name: 'PHPStan'
19+
run: composer phpstan
20+
-
21+
name: 'Coding Standards'
22+
run: composer fix-cs
23+
name: ${{ matrix.actions.name }}
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v4
27+
- name: Cache Composer dependencies
28+
uses: actions/cache@v4
29+
with:
30+
path: /tmp/composer-cache
31+
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}
32+
- name: Setup PHP
33+
id: setup-php
34+
uses: shivammathur/setup-php@v2
35+
with:
36+
php-version: 8.2
37+
extensions: 'ctype,curl,dom,iconv,imagick,intl,json,mbstring,openssl,pcre,pdo,reflection,spl,zip'
38+
ini-values: post_max_size=256M, max_execution_time=180, memory_limit=512M
39+
tools: composer:v2
40+
- name: Install Composer dependencies
41+
run: composer install --no-interaction --no-ansi --no-progress
42+
- run: ${{ matrix.actions.run }}

CHANGELOG.md

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Units Changelog
22

3+
## 4.0.2 - 2025.01.19
4+
### Added
5+
* Add `ecs` and `phpstan` code quality tools
6+
* Add a GraphQL interface for Units fields, closes ([#5](https://github.com/nystudio107/craft-units/issues/5))
7+
38
## 4.0.1 - 2023.04.24
49
### Changed
510
* Updated the docs to use VitePress `^1.0.0-alpha.29`
@@ -21,23 +26,3 @@
2126
### Added
2227

2328
* Initial Craft CMS 4 compatibility
24-
25-
## 1.0.4 - 2020-10-27
26-
### Fixed
27-
- Fixed Composer 2 compatibility
28-
29-
## 1.0.3 - 2018-05-16
30-
### Changed
31-
- Handle incoming numeric values from a converted Number field type
32-
33-
## 1.0.2 - 2018-05-14
34-
### Changed
35-
- Handle cases where there is no `min` or `max` properly in the validator
36-
37-
## 1.0.1 - 2018-05-14
38-
### Changed
39-
- Added null checks in the Field's `init()` method
40-
41-
## 1.0.0 - 2018-05-12
42-
### Added
43-
- Initial release

Makefile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
MAJOR_VERSION?=4
2+
PLUGINDEV_PROJECT_DIR?=/Users/andrew/webdev/sites/plugindev/cms_v${MAJOR_VERSION}/
3+
VENDOR?=nystudio107
4+
PROJECT_PATH?=${VENDOR}/$(shell basename $(CURDIR))
5+
6+
.PHONY: dev docs release
7+
8+
# Start up the buildchain dev server
9+
dev:
10+
# Start up the docs dev server
11+
docs:
12+
${MAKE} -C docs/ dev
13+
# Run code quality tools, tests, and build the buildchain & docs in preparation for a release
14+
release: --code-quality --code-tests --buildchain-clean-build --docs-clean-build
15+
# The internal targets used by the dev & release targets
16+
--buildchain-clean-build:
17+
--code-quality:
18+
${MAKE} -C ${PLUGINDEV_PROJECT_DIR} -- ecs check vendor/${PROJECT_PATH}/src --fix
19+
${MAKE} -C ${PLUGINDEV_PROJECT_DIR} -- phpstan analyze -c vendor/${PROJECT_PATH}/phpstan.neon
20+
--code-tests:
21+
--docs-clean-build:
22+
${MAKE} -C docs/ clean
23+
${MAKE} -C docs/ image-build
24+
${MAKE} -C docs/ fix

composer.json

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "nystudio107/craft-units",
33
"description": "Units is a plugin that can convert between any units of measure, and comes with a Field for content authors to use",
44
"type": "craft-plugin",
5-
"version": "4.0.1",
5+
"version": "4.0.2",
66
"keywords": [
77
"craft",
88
"cms",
@@ -16,7 +16,7 @@
1616
"support": {
1717
"docs": "https://nystudio107.com/docs/units/",
1818
"issues": "https://nystudio107.com/plugins/units/support",
19-
"source": "https://github.com/nystudio107/craft-typogrify"
19+
"source": "https://github.com/nystudio107/craft-units"
2020
},
2121
"license": "MIT",
2222
"authors": [
@@ -29,12 +29,26 @@
2929
"craftcms/cms": "^4.0.0",
3030
"php-units-of-measure/php-units-of-measure": "^2.1.0"
3131
},
32+
"require-dev": {
33+
"craftcms/ecs": "dev-main",
34+
"craftcms/phpstan": "dev-main",
35+
"craftcms/rector": "dev-main"
36+
},
37+
"scripts": {
38+
"phpstan": "phpstan --ansi --memory-limit=1G",
39+
"check-cs": "ecs check --ansi",
40+
"fix-cs": "ecs check --fix --ansi"
41+
},
3242
"config": {
3343
"allow-plugins": {
3444
"craftcms/plugin-installer": true,
3545
"yiisoft/yii2-composer": true
3646
},
3747
"optimize-autoloader": true,
48+
"platform": {
49+
"php": "8.0.2"
50+
},
51+
"platform-check": false,
3852
"sort-packages": true
3953
},
4054
"autoload": {

docs/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
ARG TAG=14-alpine
1+
ARG TAG=20-alpine
22
FROM node:$TAG
33

4-
USER node
4+
RUN npm install -g npm@^11.0.0
55

66
WORKDIR /app/
77

docs/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
MAJOR_VERSION?=4
2-
TAG?=14-alpine
2+
TAG?=20-alpine
33
CONTAINER?=$(shell basename $(dir $(CURDIR)))-v${MAJOR_VERSION}-docs
44
DOCS_DEV_PORT?=400${MAJOR_VERSION}
5-
DOCS_DEST?=../../../sites/nystudio107/web/docs/code-field
5+
DOCS_DEST?=../../../sites/nystudio107/web/docs/units/v4
66
IMAGE_INFO=$(shell docker image inspect $(CONTAINER):$(TAG))
77
IMAGE_NAME=${CONTAINER}:${TAG}
88
DOCKER_RUN=docker container run --rm -it -v "${CURDIR}":/app

docs/README.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# `units` docs
2+
3+
This buildchain is a self-contained build system for the `units` documentation.
4+
5+
## Overview
6+
7+
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).
8+
9+
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.
10+
11+
The markdown sources for the docs and assets are in the `docs/docs/` directory.
12+
13+
The built distribution docs are created via the `build-and-deploy-docs.yaml`
14+
15+
## Prerequisites
16+
17+
To run the buildchain for development purposes:
18+
19+
- You must have [Docker Desktop](https://www.docker.com/products/docker-desktop/) (or the equivalent) installed
20+
21+
## Commands
22+
23+
This buildchain uses `make` as an interface to the buildchain. The following commands are available from the `buildchain/` directory:
24+
25+
- `make image-build` - Build the Docker image & run `npm install`. This command must be run once before using the Docker container.
26+
- `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
27+
- `make lint` - Run `textlint` on the docs, reporting on any errors and warnings
28+
- `make fix` - Run `textlint` on the docs, automatically fixing any errors, and reporting any warnings
29+
- `make clean` - Remove `node_modules/` and `package-lock.json` to start clean (need to run `make image-build` after doing this, see below)
30+
- `make npm XXX` - Run an `npm` command inside the container, e.g.: `make npm run lint` or `make npm install`
31+
- `make ssh` - Open up a shell session into the buildchain Docker container
32+
- `make build` - Do a local distribution build of the docs; normally not needed since they are built & deployed via GitHub action
33+
34+
## Docs versioning
35+
36+
Each major version of the plugin corresponds to a major version of Craft.
37+
38+
Each major version of the plugin has separate documentation that needs to be updated when changes span plugin versions.
39+
40+
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:
41+
42+
```
43+
│ index.html
44+
├── v4
45+
│ └── index.html
46+
├── v3
47+
│ └── index.html
48+
```
49+
50+
The docs are entirely separate, but linked to eachother via a version menu, configured in the `docs/docs/.vitepress/config.ts` file.
51+
52+
## Algolia Docsearch
53+
54+
The docs uses [Algolia Docsearch](https://docsearch.algolia.com/) to index them, and allow for easy searching via a search field with auto-complete.
55+
56+
Algolia Docsearch is configured in the `docs/docs/.vitepress/config.ts` file.
57+
58+
## textlint
59+
60+
The buildchain uses [textlint](https://textlint.github.io/) to automatically fix errors on build, and also issue writing style warnings.
61+
62+
`textlint` automatically uses any rules added to the `docs/package.json` file, which can be overridden or customized via the `docs/.textlintrc.js` file.
63+
64+
See the [textlint docs](https://textlint.github.io/docs/getting-started.html) for details.
65+
66+
## Overriding environment variables
67+
68+
The `Makefile` contains sane defaults for most things, but you can override them via environment variables if you need to.
69+
70+
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:
71+
```bash
72+
env DOCS_DEST=../path/to/some/dir make build
73+
```
74+
...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.

docs/docs/.vitepress/config.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {defineConfig} from 'vitepress'
33
export default defineConfig({
44
title: 'Units Plugin',
55
description: 'Documentation for the Units plugin',
6-
base: '/docs/units/',
6+
base: '/docs/units/v4/',
77
lang: 'en-US',
88
head: [
99
['meta', {content: 'https://github.com/nystudio107', property: 'og:see_also',}],
@@ -18,13 +18,16 @@ export default defineConfig({
1818
],
1919
logo: '/img/plugin-logo.svg',
2020
editLink: {
21-
pattern: 'https://github.com/nystudio107/craft-units/edit/develop/docs/docs/:path',
21+
pattern: 'https://github.com/nystudio107/craft-units/edit/develop-v4/docs/docs/:path',
2222
text: 'Edit this page on GitHub'
2323
},
2424
algolia: {
2525
appId: 'TVGT09IBL5',
2626
apiKey: 'd2d2de61619265d05d80bf26ad24f9b4',
27-
indexName: 'nystudio107-units'
27+
indexName: 'nystudio107-units',
28+
searchParameters: {
29+
facetFilters: ["version:v4"],
30+
},
2831
},
2932
lastUpdatedText: 'Last Updated',
3033
sidebar: [],
@@ -35,8 +38,9 @@ export default defineConfig({
3538
{text: 'Issues', link: 'https://github.com/nystudio107/craft-units/issues'},
3639
{
3740
text: 'v4', items: [
41+
{text: 'v5', link: 'https://nystudio107.com/docs/units/'},
3842
{text: 'v4', link: '/'},
39-
{text: 'v3', link: 'https://nystudio107.com/docs/units/v3/'},
43+
{text: 'v1', link: 'https://nystudio107.com/docs/units/v1/'},
4044
],
4145
},
4246
]

0 commit comments

Comments
 (0)