diff --git a/.github/workflows/build-and-deploy-docs.yml b/.github/workflows/build-and-deploy-docs.yml index bb478bf..e269c83 100644 --- a/.github/workflows/build-and-deploy-docs.yml +++ b/.github/workflows/build-and-deploy-docs.yml @@ -1,6 +1,6 @@ name: Build and Deploy Docs env: - DOCS_DEST_DIR: /youtubeliveembed/v3/ + DOCS_DEST_DIR: /youtubeliveembed/v1/ on: push: branches: @@ -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 @@ -35,7 +35,7 @@ jobs: - name: rsync deployments uses: burnett01/rsync-deployments@4.1 with: - switches: -avzr + switches: -avzr --delete path: ./dist/ remote_path: ${{ secrets.NYS_DOCS_ROOT }}${{ env.DOCS_DEST_DIR }} remote_host: ${{ secrets.NYS_DEPLOY_REMOTE_HOST }} diff --git a/.github/workflows/code-analysis.yaml b/.github/workflows/code-analysis.yaml new file mode 100644 index 0000000..b4c2511 --- /dev/null +++ b/.github/workflows/code-analysis.yaml @@ -0,0 +1,42 @@ +name: Code Analysis + +on: + pull_request: null + push: + branches: + - develop + 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 }} diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml new file mode 100644 index 0000000..8e33492 --- /dev/null +++ b/.github/workflows/create-release.yml @@ -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 }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ab5c1a..90e7142 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # YouTube Live Embed Changelog +## 1.0.12 - 2025.01.04 +### Added +* Add `phpstan` and `ecs` code linting +* Add `code-analysis.yaml` GitHub action + ## 1.0.11 - 2023.04.19 ### Changed * Updated the docs to use VitePress `^1.0.0-alpha.29` diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9574450 --- /dev/null +++ b/Makefile @@ -0,0 +1,24 @@ +MAJOR_VERSION?=3 +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 diff --git a/composer.json b/composer.json index 68f7d71..6e67472 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "nystudio107/craft-youtubeliveembed", "description": "This plugin allows you to embed a YouTube live stream and/or live chat on your webpage", "type": "craft-plugin", - "version": "1.0.11", + "version": "1.0.12", "keywords": [ "craft", "cms", @@ -29,6 +29,16 @@ "require": { "craftcms/cms": "^3.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, diff --git a/docs/Dockerfile b/docs/Dockerfile index 88ac9a3..b279b37 100644 --- a/docs/Dockerfile +++ b/docs/Dockerfile @@ -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/ diff --git a/docs/Makefile b/docs/Makefile index 0775a9c..f8bbabf 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -1,8 +1,8 @@ MAJOR_VERSION?=3 -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/youtube-live-embed/v1 IMAGE_INFO=$(shell docker image inspect $(CONTAINER):$(TAG)) IMAGE_NAME=${CONTAINER}:${TAG} DOCKER_RUN=docker container run --rm -it -v "${CURDIR}":/app diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..36b70d0 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,74 @@ +# `youtube-live-embed` docs + +This buildchain is a self-contained build system for the `youtube-live-embed` 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. diff --git a/docs/docs/.vitepress/config.ts b/docs/docs/.vitepress/config.ts index 7bd2054..353195a 100644 --- a/docs/docs/.vitepress/config.ts +++ b/docs/docs/.vitepress/config.ts @@ -3,7 +3,7 @@ import {defineConfig} from 'vitepress' export default defineConfig({ title: 'YouTube Live Embed Plugin', description: 'Documentation for the YouTube Live Embed plugin', - base: '/docs/youtubeliveembed/v3/', + base: '/docs/youtubeliveembed/v1/', lang: 'en-US', head: [ ['meta', {content: 'https://github.com/nystudio107', property: 'og:see_also',}], @@ -24,7 +24,10 @@ export default defineConfig({ algolia: { appId: '9WVGU2S0Q9', apiKey: 'f3e0e6146b913085e5b5f9fc8408d4a6', - indexName: 'nystudio107-youtubeliveembed' + indexName: 'nystudio107-youtubeliveembed', + searchParameters: { + facetFilters: ["version:v1"], + }, }, lastUpdatedText: 'Last Updated', sidebar: [], @@ -34,9 +37,10 @@ export default defineConfig({ {text: 'Changelog', link: 'https://nystudio107.com/plugins/youtube-live-embed/changelog'}, {text: 'Issues', link: 'https://github.com/nystudio107/craft-youtubeliveembed/issues'}, { - text: 'v3', items: [ - {text: 'v4', link: 'https://nystudio107.com/docs/youtubeliveembed/'}, - {text: 'v3', link: '/'}, + text: 'v1', items: [ + {text: 'v5', link: 'https://nystudio107.com/docs/youtubeliveembed/'}, + {text: 'v4', link: 'https://nystudio107.com/docs/youtubeliveembed/v4/'}, + {text: 'v1', link: '/'}, ], }, ] diff --git a/docs/docs/@types/sitemap-plugin.d.ts b/docs/docs/@types/sitemap-plugin.d.ts deleted file mode 100644 index 3328d68..0000000 --- a/docs/docs/@types/sitemap-plugin.d.ts +++ /dev/null @@ -1 +0,0 @@ -type SiteMapPluginUrls = { path: string; name: string; }[] | undefined; diff --git a/docs/docs/index.md b/docs/docs/index.md index 5f7c218..df83779 100644 --- a/docs/docs/index.md +++ b/docs/docs/index.md @@ -2,7 +2,7 @@ # YouTube Live Embed plugin for Craft CMS -This plugin allows you to embed a YouTube live stream and/or live chat on your webpage +This plugin allows you to embed a YouTube live stream and/or live chat on your web page ![Screenshot](./resources/img/plugin-logo.png) @@ -28,7 +28,7 @@ You can also install YouTube Live Embed via the **Plugin Store** in the Craft Co ## YouTube Live Embed Overview -YouTube Live Embed allows you to embed a YouTube live stream and/or live chat on your webpage. +YouTube Live Embed allows you to embed a YouTube live stream and/or live chat on your web page. Both the live stream and the live stream chat are embedded as responsive `