Skip to content

Commit

Permalink
Merge branch 'release/4.0.2' into v4
Browse files Browse the repository at this point in the history
  • Loading branch information
khalwat committed Jan 20, 2025
2 parents e305b59 + c618181 commit a396fd8
Show file tree
Hide file tree
Showing 38 changed files with 6,137 additions and 1,854 deletions.
1 change: 0 additions & 1 deletion .craftplugin

This file was deleted.

8 changes: 4 additions & 4 deletions .github/workflows/build-and-deploy-docs.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Build and Deploy Docs
env:
DOCS_DEST_DIR: /units/
DOCS_DEST_DIR: /units/v4/
on:
push:
branches:
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 Down
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.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 }}
25 changes: 5 additions & 20 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Units Changelog

## 4.0.2 - 2025.01.19
### Added
* Add `ecs` and `phpstan` code quality tools
* Add a GraphQL interface for Units fields, closes ([#5](https://github.com/nystudio107/craft-units/issues/5))

## 4.0.1 - 2023.04.24
### Changed
* Updated the docs to use VitePress `^1.0.0-alpha.29`
Expand All @@ -21,23 +26,3 @@
### Added

* Initial Craft CMS 4 compatibility

## 1.0.4 - 2020-10-27
### Fixed
- Fixed Composer 2 compatibility

## 1.0.3 - 2018-05-16
### Changed
- Handle incoming numeric values from a converted Number field type

## 1.0.2 - 2018-05-14
### Changed
- Handle cases where there is no `min` or `max` properly in the validator

## 1.0.1 - 2018-05-14
### Changed
- Added null checks in the Field's `init()` method

## 1.0.0 - 2018-05-12
### Added
- Initial release
24 changes: 24 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
MAJOR_VERSION?=4
PLUGINDEV_PROJECT_DIR?=/Users/andrew/webdev/sites/plugindev/cms_v${MAJOR_VERSION}/
VENDOR?=nystudio107
PROJECT_PATH?=${VENDOR}/$(shell basename $(CURDIR))

.PHONY: dev docs release

# Start up the buildchain dev server
dev:
# Start up the docs dev server
docs:
${MAKE} -C docs/ dev
# Run code quality tools, tests, and build the buildchain & docs in preparation for a release
release: --code-quality --code-tests --buildchain-clean-build --docs-clean-build
# The internal targets used by the dev & release targets
--buildchain-clean-build:
--code-quality:
${MAKE} -C ${PLUGINDEV_PROJECT_DIR} -- ecs check vendor/${PROJECT_PATH}/src --fix
${MAKE} -C ${PLUGINDEV_PROJECT_DIR} -- phpstan analyze -c vendor/${PROJECT_PATH}/phpstan.neon
--code-tests:
--docs-clean-build:
${MAKE} -C docs/ clean
${MAKE} -C docs/ image-build
${MAKE} -C docs/ fix
18 changes: 16 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "nystudio107/craft-units",
"description": "Units is a plugin that can convert between any units of measure, and comes with a Field for content authors to use",
"type": "craft-plugin",
"version": "4.0.1",
"version": "4.0.2",
"keywords": [
"craft",
"cms",
Expand All @@ -16,7 +16,7 @@
"support": {
"docs": "https://nystudio107.com/docs/units/",
"issues": "https://nystudio107.com/plugins/units/support",
"source": "https://github.com/nystudio107/craft-typogrify"
"source": "https://github.com/nystudio107/craft-units"
},
"license": "MIT",
"authors": [
Expand All @@ -29,12 +29,26 @@
"craftcms/cms": "^4.0.0",
"php-units-of-measure/php-units-of-measure": "^2.1.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,
"platform": {
"php": "8.0.2"
},
"platform-check": false,
"sort-packages": true
},
"autoload": {
Expand Down
4 changes: 2 additions & 2 deletions docs/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ARG TAG=14-alpine
ARG TAG=20-alpine
FROM node:$TAG

USER node
RUN npm install -g npm@^11.0.0

WORKDIR /app/

Expand Down
4 changes: 2 additions & 2 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
MAJOR_VERSION?=4
TAG?=14-alpine
TAG?=20-alpine
CONTAINER?=$(shell basename $(dir $(CURDIR)))-v${MAJOR_VERSION}-docs
DOCS_DEV_PORT?=400${MAJOR_VERSION}
DOCS_DEST?=../../../sites/nystudio107/web/docs/code-field
DOCS_DEST?=../../../sites/nystudio107/web/docs/units/v4
IMAGE_INFO=$(shell docker image inspect $(CONTAINER):$(TAG))
IMAGE_NAME=${CONTAINER}:${TAG}
DOCKER_RUN=docker container run --rm -it -v "${CURDIR}":/app
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 @@
# `units` docs

This buildchain is a self-contained build system for the `units` 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.
12 changes: 8 additions & 4 deletions docs/docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {defineConfig} from 'vitepress'
export default defineConfig({
title: 'Units Plugin',
description: 'Documentation for the Units plugin',
base: '/docs/units/',
base: '/docs/units/v4/',
lang: 'en-US',
head: [
['meta', {content: 'https://github.com/nystudio107', property: 'og:see_also',}],
Expand All @@ -18,13 +18,16 @@ export default defineConfig({
],
logo: '/img/plugin-logo.svg',
editLink: {
pattern: 'https://github.com/nystudio107/craft-units/edit/develop/docs/docs/:path',
pattern: 'https://github.com/nystudio107/craft-units/edit/develop-v4/docs/docs/:path',
text: 'Edit this page on GitHub'
},
algolia: {
appId: 'TVGT09IBL5',
apiKey: 'd2d2de61619265d05d80bf26ad24f9b4',
indexName: 'nystudio107-units'
indexName: 'nystudio107-units',
searchParameters: {
facetFilters: ["version:v4"],
},
},
lastUpdatedText: 'Last Updated',
sidebar: [],
Expand All @@ -35,8 +38,9 @@ export default defineConfig({
{text: 'Issues', link: 'https://github.com/nystudio107/craft-units/issues'},
{
text: 'v4', items: [
{text: 'v5', link: 'https://nystudio107.com/docs/units/'},
{text: 'v4', link: '/'},
{text: 'v3', link: 'https://nystudio107.com/docs/units/v3/'},
{text: 'v1', link: 'https://nystudio107.com/docs/units/v1/'},
],
},
]
Expand Down
1 change: 0 additions & 1 deletion docs/docs/@types/sitemap-plugin.d.ts

This file was deleted.

Loading

0 comments on commit a396fd8

Please sign in to comment.