From b1fab7aee0606094091cebed24ab01c3f750b1b3 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Wed, 22 Nov 2023 12:57:04 -0800 Subject: [PATCH 01/22] Update wp-env symlinks to use vendor dir --- .gitignore | 8 ++++---- bin/symlink-wp-env-install-paths.sh | 6 ++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 77def782..d9a52466 100644 --- a/.gitignore +++ b/.gitignore @@ -9,9 +9,9 @@ # Generated via bin/transform-readme.php /readme.txt -# Ignore symlinked directories for wp-env -/wp-core -/wp-tests-phpunit - # In case the GitHub Wiki repo is cloned. /wiki + +# IDE files +.idea +.vscode diff --git a/bin/symlink-wp-env-install-paths.sh b/bin/symlink-wp-env-install-paths.sh index 3138505f..4ed260de 100755 --- a/bin/symlink-wp-env-install-paths.sh +++ b/bin/symlink-wp-env-install-paths.sh @@ -6,14 +6,16 @@ if [[ -z "$install_path" ]]; then exit 1 fi -core_dir="wp-core" +mkdir -p vendor/wp-env + +core_dir="vendor/wp-env/wp-core" if [[ -e "$core_dir" ]]; then rm "$core_dir" fi ln -s "$install_path/WordPress" "$core_dir" echo "Created $core_dir symlink" -tests_dir="wp-tests-phpunit" +tests_dir="vendor/wp-env/wp-tests-phpunit" if [[ -e "$tests_dir" ]]; then rm "$tests_dir" fi From 4732cf8e4c46e290a2ccae6d31b907ad00ade0ad Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Wed, 22 Nov 2023 13:10:43 -0800 Subject: [PATCH 02/22] Update .gitattributes --- .editorconfig | 1 + .gitattributes | 36 ++++++++++++++++++++++-------------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/.editorconfig b/.editorconfig index 1e71091d..0d42e245 100644 --- a/.editorconfig +++ b/.editorconfig @@ -9,6 +9,7 @@ end_of_line = lf insert_final_newline = true trim_trailing_whitespace = true indent_style = tab +tab_width = 4 [{.babelrc,.eslintrc,.rtlcssrc,*.json,*.yml,*.yaml}] indent_style = space diff --git a/.gitattributes b/.gitattributes index 7cce6fc5..2d50c501 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,15 +1,23 @@ -.editorconfig export-ignore -.eslintignore export-ignore -.eslintrc export-ignore -.gitattributes export-ignore -.gitignore export-ignore -.nvmrc export-ignore -.phpcs.xml.dist export-ignore -.travis.yml export-ignore -.wordpress-org export-ignore -Gruntfile.js export-ignore -bin export-ignore -composer.json export-ignore -composer.lock export-ignore +.editorconfig export-ignore +.eslintignore export-ignore +.eslintrc.js export-ignore +.gitattributes export-ignore +.github export-ignore +.gitignore export-ignore +.husky export-ignore +.lintstaged.js export-ignore +.lintstagedrc.js export-ignore +.nvmrc export-ignore +.phpcs.xml.dist export-ignore +.prettierrc export-ignore +.wordpress-org export-ignore +.wp-env.json export-ignore +.wp-env.sh export-ignore +Gruntfile.js export-ignore +bin export-ignore +block-library.md5 export-ignore +composer.lock export-ignore package-lock.json export-ignore -package.json export-ignore +phpstan.neon.dist export-ignore +src export-ignore +tests export-ignore From 1f7a338a8ed961bb197a84b7703c984419f7838d Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Wed, 22 Nov 2023 13:21:43 -0800 Subject: [PATCH 03/22] Remove .gitattributes --- .gitattributes | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 2d50c501..00000000 --- a/.gitattributes +++ /dev/null @@ -1,23 +0,0 @@ -.editorconfig export-ignore -.eslintignore export-ignore -.eslintrc.js export-ignore -.gitattributes export-ignore -.github export-ignore -.gitignore export-ignore -.husky export-ignore -.lintstaged.js export-ignore -.lintstagedrc.js export-ignore -.nvmrc export-ignore -.phpcs.xml.dist export-ignore -.prettierrc export-ignore -.wordpress-org export-ignore -.wp-env.json export-ignore -.wp-env.sh export-ignore -Gruntfile.js export-ignore -bin export-ignore -block-library.md5 export-ignore -composer.lock export-ignore -package-lock.json export-ignore -phpstan.neon.dist export-ignore -src export-ignore -tests export-ignore From bc626345d557a41aa9a5b31a06fade034d39d057 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Wed, 22 Nov 2023 14:03:31 -0800 Subject: [PATCH 04/22] WIP: Create new build script --- bin/build-dist.sh | 77 +++++++++++++++++++++++++++++++++++++++++++++++ inc/functions.php | 2 +- 2 files changed, 78 insertions(+), 1 deletion(-) create mode 100755 bin/build-dist.sh diff --git a/bin/build-dist.sh b/bin/build-dist.sh new file mode 100755 index 00000000..90ab90dc --- /dev/null +++ b/bin/build-dist.sh @@ -0,0 +1,77 @@ +#!/bin/bash + +set -e +cd $(dirname $0)/.. + +if [ -e dist ]; then + echo "Cleaning dist directory" + rm -r dist +fi +mkdir dist + +echo "Exporting repo to dist directory" +git archive --format=tar HEAD | (cd dist/ && tar xf -) + +cd dist + +# Symlink node_modules rather than installing anew if possible. +if [ -e ../node_modules ]; then + ln -s ../node_modules node_modules +else + npm install +fi + +# Install composer dependencies with optimized autoloader and excluding dev-dependencies. +composer install --no-dev -ao + +# Since the "highlight.php" directory name can trip up some systems, rename to "highlight-php". +mv vendor/scrivo/highlight{.php,-php} +find vendor/autoload.php vendor/composer -type f -print0 | xargs -0 sed -i.bak "s:/highlight\.php/:/highlight-php/:g" +rm vendor/autoload.php.bak $(find vendor/composer -type f -name '*.bak') + +# Build the JS. +npm run build:js + +# Convert markdown README. +npm run build:transform-readme + +# TODO: commitHash=$(git --no-pager log -1 --format=%h --date=short) +# TODO: const versionAppend = new Date().toISOString().replace(/\.\d+/, '').replace(/-|:/g, '') + '-' + commitHash; +# Append version inside of syntax-highlighting-code-block.php +# TODO: Should the version just be n.e.x.t? + + +# Remove files that we don't need anymore. +rm -r \ + .editorconfig \ + .eslintignore \ + .eslintrc.js \ + .github \ + .gitignore \ + .husky \ + .lintstagedrc.js \ + .nvmrc \ + .phpcs.xml.dist \ + .prettierrc \ + .wordpress-org \ + .wp-env.json \ + Gruntfile.js \ + README.md \ + bin \ + block-library.md5 \ + composer.json \ + composer.lock \ + node_modules \ + package-lock.json \ + package.json \ + phpstan.neon.dist \ + src \ + tests + +# Creating ZIP of build. +if [ -e ../syntax-highlighting-code-block.zip ]; then + rm ../syntax-highlighting-code-block.zip +fi +zip -r ../syntax-highlighting-code-block.zip . +cd .. +echo "ZIP of build: $(pwd)/syntax-highlighting-code-block.zip" diff --git a/inc/functions.php b/inc/functions.php index 6ef16ffb..e4e280e3 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -542,7 +542,7 @@ function get_transient_key( string $content, array $attributes, bool $is_feed, a [ 'content' => $content, 'attributes' => $attributes, - 'is_feed' => $is_feed, + 'is_feed' => $is_feed, // TODO: This is obsolete. 'auto_detect_languages' => $auto_detect_languages, 'version' => PLUGIN_VERSION, ] From 78c69f5a97f7e101f4f7e383b932d27d62ea7931 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Wed, 13 Mar 2024 17:04:08 -0700 Subject: [PATCH 05/22] Append date and commit hash to non-stable version --- bin/build-dist.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/bin/build-dist.sh b/bin/build-dist.sh index 90ab90dc..784d3f8f 100755 --- a/bin/build-dist.sh +++ b/bin/build-dist.sh @@ -35,11 +35,15 @@ npm run build:js # Convert markdown README. npm run build:transform-readme -# TODO: commitHash=$(git --no-pager log -1 --format=%h --date=short) -# TODO: const versionAppend = new Date().toISOString().replace(/\.\d+/, '').replace(/-|:/g, '') + '-' + commitHash; -# Append version inside of syntax-highlighting-code-block.php -# TODO: Should the version just be n.e.x.t? - +# Grab amend the version with the commit hash. +VERSION=$(grep 'PLUGIN_VERSION' syntax-highlighting-code-block.php | cut -d\' -f2) +if [[ $VERSION == *-* ]]; then + NEW_VERSION="$VERSION-$(date -u +%Y%m%dT%H%M%SZ)-$(git --no-pager log -1 --format=%h --date=short)" + VERSION_ESCAPED="${VERSION//./\\.}" + sed -i "s/$VERSION_ESCAPED/$NEW_VERSION/g" syntax-highlighting-code-block.php + echo "Detected non-stable version: $VERSION" + echo "Creating build for version: $NEW_VERSION" +fi # Remove files that we don't need anymore. rm -r \ From 4a7b4f0199b384fd4c4cc8a75f7bc64458125efd Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Wed, 13 Mar 2024 17:20:19 -0700 Subject: [PATCH 06/22] Add .distignore --- .distignore | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .distignore diff --git a/.distignore b/.distignore new file mode 100644 index 00000000..c65db9ab --- /dev/null +++ b/.distignore @@ -0,0 +1,25 @@ +.distignore +.editorconfig +.eslintignore +.eslintrc.js +.github +.gitignore +.husky +.lintstagedrc.js +.nvmrc +.phpcs.xml.dist +.prettierrc +.wordpress-org +.wp-env.json +Gruntfile.js +README.md +bin +block-library.md5 +composer.json +composer.lock +node_modules +package-lock.json +package.json +phpstan.neon.dist +src +tests From fef648e855ddeff6e58083a8bd6d2a6dc5b814c5 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Wed, 13 Mar 2024 17:22:55 -0700 Subject: [PATCH 07/22] Use WP-CLI to create zip --- bin/build-dist.sh | 32 +-- composer.json | 1 + composer.lock | 510 +++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 510 insertions(+), 33 deletions(-) diff --git a/bin/build-dist.sh b/bin/build-dist.sh index 784d3f8f..3d9b7801 100755 --- a/bin/build-dist.sh +++ b/bin/build-dist.sh @@ -45,37 +45,7 @@ if [[ $VERSION == *-* ]]; then echo "Creating build for version: $NEW_VERSION" fi -# Remove files that we don't need anymore. -rm -r \ - .editorconfig \ - .eslintignore \ - .eslintrc.js \ - .github \ - .gitignore \ - .husky \ - .lintstagedrc.js \ - .nvmrc \ - .phpcs.xml.dist \ - .prettierrc \ - .wordpress-org \ - .wp-env.json \ - Gruntfile.js \ - README.md \ - bin \ - block-library.md5 \ - composer.json \ - composer.lock \ - node_modules \ - package-lock.json \ - package.json \ - phpstan.neon.dist \ - src \ - tests +../vendor/bin/wp dist-archive . ../syntax-highlighting-code-block.zip -# Creating ZIP of build. -if [ -e ../syntax-highlighting-code-block.zip ]; then - rm ../syntax-highlighting-code-block.zip -fi -zip -r ../syntax-highlighting-code-block.zip . cd .. echo "ZIP of build: $(pwd)/syntax-highlighting-code-block.zip" diff --git a/composer.json b/composer.json index ed9fcca0..1ee10137 100644 --- a/composer.json +++ b/composer.json @@ -10,6 +10,7 @@ "civicrm/composer-downloads-plugin": "3.0.1", "phpcompatibility/php-compatibility": "9.3.5", "szepeviktor/phpstan-wordpress": "1.3.3", + "wp-cli/dist-archive-command": "^2.0", "wp-coding-standards/wpcs": "3.0.1" }, "config": { diff --git a/composer.lock b/composer.lock index fd399c0d..9718e0ab 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "2020d313d90262808b41622b75975b5a", + "content-hash": "e481cf1d1cfb2a6905116c573acecb33", "packages": [ { "name": "scrivo/highlight.php", @@ -218,6 +218,56 @@ }, "time": "2023-01-05T11:28:13+00:00" }, + { + "name": "mustache/mustache", + "version": "v2.14.2", + "source": { + "type": "git", + "url": "https://github.com/bobthecow/mustache.php.git", + "reference": "e62b7c3849d22ec55f3ec425507bf7968193a6cb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/bobthecow/mustache.php/zipball/e62b7c3849d22ec55f3ec425507bf7968193a6cb", + "reference": "e62b7c3849d22ec55f3ec425507bf7968193a6cb", + "shasum": "" + }, + "require": { + "php": ">=5.2.4" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "~1.11", + "phpunit/phpunit": "~3.7|~4.0|~5.0" + }, + "type": "library", + "autoload": { + "psr-0": { + "Mustache": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Justin Hileman", + "email": "justin@justinhileman.info", + "homepage": "http://justinhileman.com" + } + ], + "description": "A Mustache implementation in PHP.", + "homepage": "https://github.com/bobthecow/mustache.php", + "keywords": [ + "mustache", + "templating" + ], + "support": { + "issues": "https://github.com/bobthecow/mustache.php/issues", + "source": "https://github.com/bobthecow/mustache.php/tree/v2.14.2" + }, + "time": "2022-08-23T13:07:01+00:00" + }, { "name": "php-stubs/wordpress-stubs", "version": "v6.4.3", @@ -635,6 +685,136 @@ ], "time": "2023-12-08T12:32:31+00:00" }, + { + "name": "symfony/deprecation-contracts", + "version": "v2.5.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/e8b495ea28c1d97b5e0c121748d6f9b53d075c66", + "reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.5-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "files": [ + "function.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.2" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2022-01-02T09:53:40+00:00" + }, + { + "name": "symfony/finder", + "version": "v5.4.35", + "source": { + "type": "git", + "url": "https://github.com/symfony/finder.git", + "reference": "abe6d6f77d9465fed3cd2d029b29d03b56b56435" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/finder/zipball/abe6d6f77d9465fed3cd2d029b29d03b56b56435", + "reference": "abe6d6f77d9465fed3cd2d029b29d03b56b56435", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1|^3", + "symfony/polyfill-php80": "^1.16" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Finder\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Finds files and directories via an intuitive fluent interface", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/finder/tree/v5.4.35" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-01-23T13:51:25+00:00" + }, { "name": "symfony/polyfill-php73", "version": "v1.29.0", @@ -711,6 +891,86 @@ ], "time": "2024-01-29T20:11:03+00:00" }, + { + "name": "symfony/polyfill-php80", + "version": "v1.29.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php80.git", + "reference": "87b68208d5c1188808dd7839ee1e6c8ec3b02f1b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/87b68208d5c1188808dd7839ee1e6c8ec3b02f1b", + "reference": "87b68208d5c1188808dd7839ee1e6c8ec3b02f1b", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php80\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ion Bazan", + "email": "ion.bazan@gmail.com" + }, + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php80/tree/v1.29.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-01-29T20:11:03+00:00" + }, { "name": "szepeviktor/phpstan-wordpress", "version": "v1.3.3", @@ -810,6 +1070,252 @@ }, "time": "2019-04-19T19:16:58+00:00" }, + { + "name": "wp-cli/dist-archive-command", + "version": "v2.0.1", + "source": { + "type": "git", + "url": "https://github.com/wp-cli/dist-archive-command.git", + "reference": "ede13cd4b8084f7861290ac4fcdda7f9866efe09" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/wp-cli/dist-archive-command/zipball/ede13cd4b8084f7861290ac4fcdda7f9866efe09", + "reference": "ede13cd4b8084f7861290ac4fcdda7f9866efe09", + "shasum": "" + }, + "require": { + "php": ">=5.4", + "wp-cli/wp-cli": "^2" + }, + "require-dev": { + "behat/behat": "~2.5", + "wp-cli/extension-command": "^2", + "wp-cli/scaffold-command": "^2", + "wp-cli/wp-cli-tests": "^2.1" + }, + "type": "wp-cli-package", + "extra": { + "commands": [ + "dist-archive" + ], + "readme": { + "shields": [ + "[![CircleCI](https://circleci.com/gh/wp-cli/dist-archive-command/tree/master.svg?style=svg)](https://circleci.com/gh/wp-cli/dist-archive-command/tree/master)" + ] + } + }, + "autoload": { + "files": [ + "dist-archive-command.php" + ], + "psr-4": { + "": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Daniel Bachhuber", + "email": "daniel@runcommand.io", + "homepage": "https://runcommand.io" + } + ], + "description": "Create a distribution .zip or .tar.gz based on a plugin or theme's .distignore file.", + "homepage": "https://runcommand.io/wp/dist-archive/", + "support": { + "issues": "https://github.com/wp-cli/dist-archive-command/issues", + "source": "https://github.com/wp-cli/dist-archive-command/tree/v2.0.1" + }, + "time": "2020-06-02T00:16:00+00:00" + }, + { + "name": "wp-cli/mustangostang-spyc", + "version": "0.6.3", + "source": { + "type": "git", + "url": "https://github.com/wp-cli/spyc.git", + "reference": "6aa0b4da69ce9e9a2c8402dab8d43cf32c581cc7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/wp-cli/spyc/zipball/6aa0b4da69ce9e9a2c8402dab8d43cf32c581cc7", + "reference": "6aa0b4da69ce9e9a2c8402dab8d43cf32c581cc7", + "shasum": "" + }, + "require": { + "php": ">=5.3.1" + }, + "require-dev": { + "phpunit/phpunit": "4.3.*@dev" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.5.x-dev" + } + }, + "autoload": { + "files": [ + "includes/functions.php" + ], + "psr-4": { + "Mustangostang\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "mustangostang", + "email": "vlad.andersen@gmail.com" + } + ], + "description": "A simple YAML loader/dumper class for PHP (WP-CLI fork)", + "homepage": "https://github.com/mustangostang/spyc/", + "support": { + "source": "https://github.com/wp-cli/spyc/tree/autoload" + }, + "time": "2017-04-25T11:26:20+00:00" + }, + { + "name": "wp-cli/php-cli-tools", + "version": "v0.11.22", + "source": { + "type": "git", + "url": "https://github.com/wp-cli/php-cli-tools.git", + "reference": "a6bb94664ca36d0962f9c2ff25591c315a550c51" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/wp-cli/php-cli-tools/zipball/a6bb94664ca36d0962f9c2ff25591c315a550c51", + "reference": "a6bb94664ca36d0962f9c2ff25591c315a550c51", + "shasum": "" + }, + "require": { + "php": ">= 5.3.0" + }, + "require-dev": { + "roave/security-advisories": "dev-latest", + "wp-cli/wp-cli-tests": "^4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.11.x-dev" + } + }, + "autoload": { + "files": [ + "lib/cli/cli.php" + ], + "psr-0": { + "cli": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Daniel Bachhuber", + "email": "daniel@handbuilt.co", + "role": "Maintainer" + }, + { + "name": "James Logsdon", + "email": "jlogsdon@php.net", + "role": "Developer" + } + ], + "description": "Console utilities for PHP", + "homepage": "http://github.com/wp-cli/php-cli-tools", + "keywords": [ + "cli", + "console" + ], + "support": { + "issues": "https://github.com/wp-cli/php-cli-tools/issues", + "source": "https://github.com/wp-cli/php-cli-tools/tree/v0.11.22" + }, + "time": "2023-12-03T19:25:05+00:00" + }, + { + "name": "wp-cli/wp-cli", + "version": "v2.10.0", + "source": { + "type": "git", + "url": "https://github.com/wp-cli/wp-cli.git", + "reference": "a339dca576df73c31af4b4d8054efc2dab9a0685" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/wp-cli/wp-cli/zipball/a339dca576df73c31af4b4d8054efc2dab9a0685", + "reference": "a339dca576df73c31af4b4d8054efc2dab9a0685", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "mustache/mustache": "^2.14.1", + "php": "^5.6 || ^7.0 || ^8.0", + "symfony/finder": ">2.7", + "wp-cli/mustangostang-spyc": "^0.6.3", + "wp-cli/php-cli-tools": "~0.11.2" + }, + "require-dev": { + "roave/security-advisories": "dev-latest", + "wp-cli/db-command": "^1.3 || ^2", + "wp-cli/entity-command": "^1.2 || ^2", + "wp-cli/extension-command": "^1.1 || ^2", + "wp-cli/package-command": "^1 || ^2", + "wp-cli/wp-cli-tests": "^4.0.1" + }, + "suggest": { + "ext-readline": "Include for a better --prompt implementation", + "ext-zip": "Needed to support extraction of ZIP archives when doing downloads or updates" + }, + "bin": [ + "bin/wp", + "bin/wp.bat" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.10.x-dev" + } + }, + "autoload": { + "psr-0": { + "WP_CLI\\": "php/" + }, + "classmap": [ + "php/class-wp-cli.php", + "php/class-wp-cli-command.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "WP-CLI framework", + "homepage": "https://wp-cli.org", + "keywords": [ + "cli", + "wordpress" + ], + "support": { + "docs": "https://make.wordpress.org/cli/handbook/", + "issues": "https://github.com/wp-cli/wp-cli/issues", + "source": "https://github.com/wp-cli/wp-cli" + }, + "time": "2024-02-08T16:52:43+00:00" + }, { "name": "wp-coding-standards/wpcs", "version": "3.0.1", @@ -887,5 +1393,5 @@ "platform-overrides": { "php": "7.4" }, - "plugin-api-version": "2.6.0" + "plugin-api-version": "2.2.0" } From cd83d55dd4d5894150509698fde3242d1367441b Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Wed, 13 Mar 2024 17:28:44 -0700 Subject: [PATCH 08/22] Run dist-archive from root --- bin/build-dist.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/build-dist.sh b/bin/build-dist.sh index 3d9b7801..be71dcf0 100755 --- a/bin/build-dist.sh +++ b/bin/build-dist.sh @@ -45,7 +45,8 @@ if [[ $VERSION == *-* ]]; then echo "Creating build for version: $NEW_VERSION" fi -../vendor/bin/wp dist-archive . ../syntax-highlighting-code-block.zip - cd .. + +vendor/bin/wp dist-archive dist/ syntax-highlighting-code-block.zip + echo "ZIP of build: $(pwd)/syntax-highlighting-code-block.zip" From 87850b6a3010a427758b9c985f0caee168408e8b Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Wed, 13 Mar 2024 17:30:46 -0700 Subject: [PATCH 09/22] Use long args for composer install --- bin/build-dist.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/build-dist.sh b/bin/build-dist.sh index be71dcf0..54ce3a1d 100755 --- a/bin/build-dist.sh +++ b/bin/build-dist.sh @@ -22,7 +22,7 @@ else fi # Install composer dependencies with optimized autoloader and excluding dev-dependencies. -composer install --no-dev -ao +composer install --no-dev --classmap-authoritative --optimize-autoloader # Since the "highlight.php" directory name can trip up some systems, rename to "highlight-php". mv vendor/scrivo/highlight{.php,-php} From 135ec954cf6491b7ca56df1e2ed8652804ff2d95 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Tue, 2 Apr 2024 09:19:58 -0700 Subject: [PATCH 10/22] Update npm scripts --- bin/build-dist.sh | 8 ++------ package.json | 4 ++-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/bin/build-dist.sh b/bin/build-dist.sh index 54ce3a1d..a199d21e 100755 --- a/bin/build-dist.sh +++ b/bin/build-dist.sh @@ -3,11 +3,9 @@ set -e cd $(dirname $0)/.. -if [ -e dist ]; then - echo "Cleaning dist directory" - rm -r dist +if [ ! -e dist ]; then + mkdir dist fi -mkdir dist echo "Exporting repo to dist directory" git archive --format=tar HEAD | (cd dist/ && tar xf -) @@ -47,6 +45,4 @@ fi cd .. -vendor/bin/wp dist-archive dist/ syntax-highlighting-code-block.zip -echo "ZIP of build: $(pwd)/syntax-highlighting-code-block.zip" diff --git a/package.json b/package.json index f99162ef..ede5a74e 100644 --- a/package.json +++ b/package.json @@ -46,8 +46,8 @@ "build:transform-readme": "php ./bin/transform-readme.php", "build:clean": "if [ -e dist ]; then rm -r dist; fi; if [ -e build ]; then rm -r build; fi", "build:js": "wp-scripts build src/index.js src/customize-controls.js --output-path=build", - "build:dist": "grunt dist", - "build:zip": "if [ -e syntax-highlighting-code-block.zip ]; then rm syntax-highlighting-code-block.zip; fi; cd dist; zip -r ../syntax-highlighting-code-block.zip .; cd ..; echo; echo \"ZIP of build: $(pwd)/syntax-highlighting-code-block.zip\"", + "build:dist": "bash ./bin/build-dist.sh", + "build:zip": "vendor/bin/wp dist-archive dist/ syntax-highlighting-code-block.zip && echo \"ZIP of build: $(pwd)/syntax-highlighting-code-block.zip\"", "verify-matching-versions": "php ./bin/verify-version-consistency.php", "deploy": "npm-run-all verify-matching-versions build && grunt wp_deploy", "generate-language-names": "php ./bin/generate-language-names.php", From 1ae340569a642ec3c1c6e4e35256a12cb2a2699e Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Tue, 2 Apr 2024 09:24:27 -0700 Subject: [PATCH 11/22] Remove unused grunt-contrib-copy --- Gruntfile.js | 1 - package-lock.json | 96 ----------------------------------------------- package.json | 1 - 3 files changed, 98 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 72dba166..2585b50e 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -20,7 +20,6 @@ module.exports = function (grunt) { }); // Load tasks. - grunt.loadNpmTasks('grunt-contrib-copy'); grunt.loadNpmTasks('grunt-wp-deploy'); // Register tasks. diff --git a/package-lock.json b/package-lock.json index 25cea6cf..88005662 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,7 +21,6 @@ "@wordpress/scripts": "27.4.0", "eslint": "8.57.0", "grunt": "1.6.1", - "grunt-contrib-copy": "1.0.0", "grunt-wp-deploy": "2.1.2", "highlight.js": "git+https://github.com/highlightjs/highlight.js.git#9.18.1", "husky": "9.0.11", @@ -14526,12 +14525,6 @@ "node": "^10.12.0 || >=12.0.0" } }, - "node_modules/file-sync-cmp": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/file-sync-cmp/-/file-sync-cmp-0.1.1.tgz", - "integrity": "sha512-0k45oWBokCqh2MOexeYKpyqmGKG+8mQ2Wd8iawx+uWd/weWJQAZ6SoPybagdCI4xFisag8iAR77WPm4h3pTfxA==", - "dev": true - }, "node_modules/filename-reserved-regex": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/filename-reserved-regex/-/filename-reserved-regex-2.0.0.tgz", @@ -15668,74 +15661,6 @@ "node": ">=16" } }, - "node_modules/grunt-contrib-copy": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/grunt-contrib-copy/-/grunt-contrib-copy-1.0.0.tgz", - "integrity": "sha512-gFRFUB0ZbLcjKb67Magz1yOHGBkyU6uL29hiEW1tdQ9gQt72NuMKIy/kS6dsCbV0cZ0maNCb0s6y+uT1FKU7jA==", - "dev": true, - "dependencies": { - "chalk": "^1.1.1", - "file-sync-cmp": "^0.1.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/grunt-contrib-copy/node_modules/ansi-regex": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/grunt-contrib-copy/node_modules/ansi-styles": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha512-kmCevFghRiWM7HB5zTPULl4r9bVFSWjz62MhqizDGUrq2NWuNMQyuv4tHHoKJHs69M/MF64lEcHdYIocrdWQYA==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/grunt-contrib-copy/node_modules/chalk": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha512-U3lRVLMSlsCfjqYPbLyVv11M9CPW4I728d6TCKMAOJueEeB9/8o+eSsMnxPJD+Q+K909sdESg7C+tIkoH6on1A==", - "dev": true, - "dependencies": { - "ansi-styles": "^2.2.1", - "escape-string-regexp": "^1.0.2", - "has-ansi": "^2.0.0", - "strip-ansi": "^3.0.0", - "supports-color": "^2.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/grunt-contrib-copy/node_modules/strip-ansi": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha512-VhumSSbBqDTP8p2ZLKj40UjBCV4+v8bUSEpUb4KjRgWk9pbqGF4REFj6KEagidb2f/M6AzC0EmFyDNGaw9OCzg==", - "dev": true, - "dependencies": { - "ansi-regex": "^2.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/grunt-contrib-copy/node_modules/supports-color": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha512-KKNVtd6pCYgPIKU4cp2733HWYCpplQhddZLBUryaAHou723x+FRzQ5Df824Fj+IyyuiQTRoub4SnIFfIcrp70g==", - "dev": true, - "engines": { - "node": ">=0.8.0" - } - }, "node_modules/grunt-known-options": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/grunt-known-options/-/grunt-known-options-2.0.0.tgz", @@ -16015,27 +15940,6 @@ "node": ">= 0.4.0" } }, - "node_modules/has-ansi": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", - "integrity": "sha512-C8vBJ8DwUCx19vhm7urhTuUsr4/IyP6l4VzNQDv+ryHQObW3TTTp9yB68WpYgRe2bbaGuZ/se74IqFeVnMnLZg==", - "dev": true, - "dependencies": { - "ansi-regex": "^2.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/has-ansi/node_modules/ansi-regex": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/has-bigints": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.0.2.tgz", diff --git a/package.json b/package.json index ede5a74e..8dad2e32 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,6 @@ "@wordpress/scripts": "27.4.0", "eslint": "8.57.0", "grunt": "1.6.1", - "grunt-contrib-copy": "1.0.0", "grunt-wp-deploy": "2.1.2", "highlight.js": "git+https://github.com/highlightjs/highlight.js.git#9.18.1", "husky": "9.0.11", From c011f141143b5c373ba5d0c1082c35424ff0389f Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Tue, 2 Apr 2024 09:26:08 -0700 Subject: [PATCH 12/22] Remove unused grunt dist --- Gruntfile.js | 124 +-------------------------------------------------- 1 file changed, 1 insertion(+), 123 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 2585b50e..e7d6b2f7 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -23,127 +23,5 @@ module.exports = function (grunt) { grunt.loadNpmTasks('grunt-wp-deploy'); // Register tasks. - grunt.registerTask('default', ['dist']); - - grunt.registerTask('dist', function () { - const done = this.async(); - const spawnQueue = []; - const stdout = []; - - spawnQueue.push({ - cmd: 'git', - args: ['--no-pager', 'log', '-1', '--format=%h', '--date=short'], - }); - - function finalize() { - const commitHash = stdout.shift(); - const versionAppend = - new Date() - .toISOString() - .replace(/\.\d+/, '') - .replace(/-|:/g, '') + - '-' + - commitHash; - - const paths = [ - 'syntax-highlighting-code-block.php', - 'inc/*', - 'language-names.php', - 'editor-styles.css', - 'style.css', - 'readme.txt', - 'LICENSE', - 'build/*', - ]; - - grunt.config.set('copy', { - build: { - src: paths, - dest: 'dist', - expand: true, - options: { - noProcess: ['*/**', 'LICENSE'], // That is, only process syntax-highlighting-code-block.php and README.md. - process(content, srcpath) { - if ( - !/syntax-highlighting-code-block\.php$/.test( - srcpath - ) - ) { - return content; - } - let updatedContent = content; - const versionRegex = - /(\*\s+Version:\s+)(\d+(\.\d+)+-\w+)/; - let version; - - // If not a stable build (e.g. 0.7.0-beta), amend the version with the git commit and current timestamp. - const matches = content.match(versionRegex); - if (matches) { - version = matches[2] + '-' + versionAppend; - console.log( - 'Updating version in plugin version to ' + - version - ); - updatedContent = updatedContent.replace( - versionRegex, - '$1' + version - ); - updatedContent = updatedContent.replace( - /(const PLUGIN_VERSION = ')(.+?)(?=')/, - '$1' + version - ); - } - - updatedContent = updatedContent.replace( - /const DEVELOPMENT_MODE = true;.*/, - 'const DEVELOPMENT_MODE = false;' - ); - - return updatedContent; - }, - }, - }, - composer: { - src: ['vendor/autoload.php', 'vendor/composer/**'], - dest: 'dist', - expand: true, - options: { - noProcess: ['vendor/composer/installed.json'], - process(content) { - return content.replace( - /\/highlight\.php/g, - '/highlight-php' - ); - }, - }, - }, - vendor: { - src: ['Highlight/**', 'HighlightUtilities/**', 'styles/*'], - expand: true, - cwd: 'vendor/scrivo/highlight.php/', - dest: 'dist/vendor/scrivo/highlight-php/', - }, - }); - grunt.task.run('copy'); - - done(); - } - - function doNext() { - const nextSpawnArgs = spawnQueue.shift(); - if (!nextSpawnArgs) { - finalize(); - } else { - grunt.util.spawn(nextSpawnArgs, function (err, res) { - if (err) { - throw new Error(err.message); - } - stdout.push(res.stdout); - doNext(); - }); - } - } - - doNext(); - }); + grunt.registerTask('default', ['wp_deploy']); }; From 06707e23b54e4fcba2865c5094a3cf14d729cecc Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Tue, 2 Apr 2024 11:23:15 -0700 Subject: [PATCH 13/22] Add ZIP files to .distignore --- .distignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.distignore b/.distignore index c65db9ab..ad9e2d04 100644 --- a/.distignore +++ b/.distignore @@ -23,3 +23,4 @@ package.json phpstan.neon.dist src tests +*.zip From 37f1bd9505bad4e2d803707285b53598c0aad10e Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Tue, 2 Apr 2024 11:23:49 -0700 Subject: [PATCH 14/22] Use dev-main of dist-archive --- composer.json | 2 +- composer.lock | 84 +++++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 69 insertions(+), 17 deletions(-) diff --git a/composer.json b/composer.json index 1ee10137..8885884c 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ "civicrm/composer-downloads-plugin": "3.0.1", "phpcompatibility/php-compatibility": "9.3.5", "szepeviktor/phpstan-wordpress": "1.3.3", - "wp-cli/dist-archive-command": "^2.0", + "wp-cli/dist-archive-command": "dev-main", "wp-coding-standards/wpcs": "3.0.1" }, "config": { diff --git a/composer.lock b/composer.lock index 9718e0ab..51cb885f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "e481cf1d1cfb2a6905116c573acecb33", + "content-hash": "b5172d29665e62d36a9638f271c1b5f1", "packages": [ { "name": "scrivo/highlight.php", @@ -218,6 +218,55 @@ }, "time": "2023-01-05T11:28:13+00:00" }, + { + "name": "inmarelibero/gitignore-checker", + "version": "1.0.3", + "source": { + "type": "git", + "url": "https://github.com/inmarelibero/gitignore-checker.git", + "reference": "a489e819486216a7f4d55c708a4dd7e797166215" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/inmarelibero/gitignore-checker/zipball/a489e819486216a7f4d55c708a4dd7e797166215", + "reference": "a489e819486216a7f4d55c708a4dd7e797166215", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "require-dev": { + "phpunit/phpunit": "^9.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "Inmarelibero\\GitIgnoreChecker\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Emanuele Gaspari", + "email": "inmarelibero@gmail.com", + "role": "Developer" + } + ], + "description": "A PHP library to check if a path is ignored by GIT", + "keywords": [ + "git", + "gitignore", + "vcs" + ], + "support": { + "issues": "https://github.com/inmarelibero/gitignore-checker/issues", + "source": "https://github.com/inmarelibero/gitignore-checker/tree/1.0.3" + }, + "time": "2023-09-26T09:20:54+00:00" + }, { "name": "mustache/mustache", "version": "v2.14.2", @@ -1072,28 +1121,29 @@ }, { "name": "wp-cli/dist-archive-command", - "version": "v2.0.1", + "version": "dev-main", "source": { "type": "git", "url": "https://github.com/wp-cli/dist-archive-command.git", - "reference": "ede13cd4b8084f7861290ac4fcdda7f9866efe09" + "reference": "e226f7d4bcd4d7db0462a3644228b77d2ad5a85c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/wp-cli/dist-archive-command/zipball/ede13cd4b8084f7861290ac4fcdda7f9866efe09", - "reference": "ede13cd4b8084f7861290ac4fcdda7f9866efe09", + "url": "https://api.github.com/repos/wp-cli/dist-archive-command/zipball/e226f7d4bcd4d7db0462a3644228b77d2ad5a85c", + "reference": "e226f7d4bcd4d7db0462a3644228b77d2ad5a85c", "shasum": "" }, "require": { - "php": ">=5.4", + "inmarelibero/gitignore-checker": "^1.0.2", + "php": ">=7.4", "wp-cli/wp-cli": "^2" }, "require-dev": { - "behat/behat": "~2.5", "wp-cli/extension-command": "^2", "wp-cli/scaffold-command": "^2", - "wp-cli/wp-cli-tests": "^2.1" + "wp-cli/wp-cli-tests": "^4" }, + "default-branch": true, "type": "wp-cli-package", "extra": { "commands": [ @@ -1101,7 +1151,7 @@ ], "readme": { "shields": [ - "[![CircleCI](https://circleci.com/gh/wp-cli/dist-archive-command/tree/master.svg?style=svg)](https://circleci.com/gh/wp-cli/dist-archive-command/tree/master)" + "[![Testing](https://github.com/wp-cli/dist-archive-command/actions/workflows/testing.yml/badge.svg)](https://github.com/wp-cli/dist-archive-command/actions/workflows/testing.yml)" ] } }, @@ -1109,9 +1159,9 @@ "files": [ "dist-archive-command.php" ], - "psr-4": { - "": "src/" - } + "classmap": [ + "src/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -1125,12 +1175,12 @@ } ], "description": "Create a distribution .zip or .tar.gz based on a plugin or theme's .distignore file.", - "homepage": "https://runcommand.io/wp/dist-archive/", + "homepage": "https://github.com/wp-cli/dist-archive-command/", "support": { "issues": "https://github.com/wp-cli/dist-archive-command/issues", - "source": "https://github.com/wp-cli/dist-archive-command/tree/v2.0.1" + "source": "https://github.com/wp-cli/dist-archive-command/tree/main" }, - "time": "2020-06-02T00:16:00+00:00" + "time": "2023-12-18T14:28:49+00:00" }, { "name": "wp-cli/mustangostang-spyc", @@ -1385,7 +1435,9 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": { + "wp-cli/dist-archive-command": 20 + }, "prefer-stable": false, "prefer-lowest": false, "platform": [], From 49a5452acd4b5e5ebc16ecfb7e4bf68a1c249268 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Tue, 2 Apr 2024 11:36:17 -0700 Subject: [PATCH 15/22] Fix build-dist --- bin/build-dist.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/bin/build-dist.sh b/bin/build-dist.sh index a199d21e..da387584 100755 --- a/bin/build-dist.sh +++ b/bin/build-dist.sh @@ -24,8 +24,7 @@ composer install --no-dev --classmap-authoritative --optimize-autoloader # Since the "highlight.php" directory name can trip up some systems, rename to "highlight-php". mv vendor/scrivo/highlight{.php,-php} -find vendor/autoload.php vendor/composer -type f -print0 | xargs -0 sed -i.bak "s:/highlight\.php/:/highlight-php/:g" -rm vendor/autoload.php.bak $(find vendor/composer -type f -name '*.bak') +find vendor/autoload.php vendor/composer -type f -print0 | xargs -0 sed -i "s:/highlight\.php/:/highlight-php/:g" # Build the JS. npm run build:js @@ -41,8 +40,7 @@ if [[ $VERSION == *-* ]]; then sed -i "s/$VERSION_ESCAPED/$NEW_VERSION/g" syntax-highlighting-code-block.php echo "Detected non-stable version: $VERSION" echo "Creating build for version: $NEW_VERSION" -fi - -cd .. + sed -i "s/const DEVELOPMENT_MODE = true;.*/const DEVELOPMENT_MODE = false;/g" syntax-highlighting-code-block.php +fi From d577cf0a83c4995301295ce4124984a94fb6f578 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Tue, 2 Apr 2024 11:36:28 -0700 Subject: [PATCH 16/22] Fix creating ZIP of build --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8dad2e32..8736d0dc 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "build:clean": "if [ -e dist ]; then rm -r dist; fi; if [ -e build ]; then rm -r build; fi", "build:js": "wp-scripts build src/index.js src/customize-controls.js --output-path=build", "build:dist": "bash ./bin/build-dist.sh", - "build:zip": "vendor/bin/wp dist-archive dist/ syntax-highlighting-code-block.zip && echo \"ZIP of build: $(pwd)/syntax-highlighting-code-block.zip\"", + "build:zip": "if [ -e syntax-highlighting-code-block.zip ]; then rm syntax-highlighting-code-block.zip; fi; vendor/bin/wp dist-archive --plugin-dirname=syntax-highlighting-code-block dist syntax-highlighting-code-block.zip && echo \"ZIP of build: $(pwd)/syntax-highlighting-code-block.zip\"", "verify-matching-versions": "php ./bin/verify-version-consistency.php", "deploy": "npm-run-all verify-matching-versions build && grunt wp_deploy", "generate-language-names": "php ./bin/generate-language-names.php", From 9587d26eb6c8d2abb489fa09e034fa6d333f7b0b Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Tue, 2 Apr 2024 11:40:43 -0700 Subject: [PATCH 17/22] Use unzipped directory for dist target --- Gruntfile.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index e7d6b2f7..6344b14f 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -12,7 +12,7 @@ module.exports = function (grunt) { deploy: { options: { plugin_slug: 'syntax-highlighting-code-block', - build_dir: 'dist', + build_dir: 'syntax-highlighting-code-block', assets_dir: '.wordpress-org', }, }, diff --git a/package.json b/package.json index 8736d0dc..a3a369a9 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "build:dist": "bash ./bin/build-dist.sh", "build:zip": "if [ -e syntax-highlighting-code-block.zip ]; then rm syntax-highlighting-code-block.zip; fi; vendor/bin/wp dist-archive --plugin-dirname=syntax-highlighting-code-block dist syntax-highlighting-code-block.zip && echo \"ZIP of build: $(pwd)/syntax-highlighting-code-block.zip\"", "verify-matching-versions": "php ./bin/verify-version-consistency.php", - "deploy": "npm-run-all verify-matching-versions build && grunt wp_deploy", + "deploy": "npm-run-all verify-matching-versions build && unzip syntax-highlighting-code-block.zip && echo grunt wp_deploy && rm -r syntax-highlighting-code-block", "generate-language-names": "php ./bin/generate-language-names.php", "check-engines": "wp-scripts check-engines", "check-licenses": "wp-scripts check-licenses", From 1d887d18f6b8f59cb1a8e2dcead1773bb87df5a7 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Tue, 2 Apr 2024 11:41:06 -0700 Subject: [PATCH 18/22] Bump versions --- README.md | 6 +++--- package.json | 2 +- syntax-highlighting-code-block.php | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index c875b59b..cf462f7e 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,9 @@ Extending the Code block with syntax highlighting rendered on the server, thus b **Contributors:** [westonruter](https://profiles.wordpress.org/westonruter), [allejo](https://profiles.wordpress.org/allejo) **Tags:** [block](https://wordpress.org/plugins/tags/block), [code](https://wordpress.org/plugins/tags/code), [code syntax](https://wordpress.org/plugins/tags/code-syntax), [syntax highlight](https://wordpress.org/plugins/tags/syntax-highlight), [code highlighting](https://wordpress.org/plugins/tags/code-highlighting) -**Requires at least:** 6.3 -**Tested up to:** 6.4 -**Stable tag:** 1.4.0 +**Requires at least:** 6.4 +**Tested up to:** 6.5 +**Stable tag:** 1.5.0 **License:** [GPLv2 or later](http://www.gnu.org/licenses/gpl-2.0.html) **Requires PHP:** 7.4 diff --git a/package.json b/package.json index a3a369a9..9a4df8d2 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "build:dist": "bash ./bin/build-dist.sh", "build:zip": "if [ -e syntax-highlighting-code-block.zip ]; then rm syntax-highlighting-code-block.zip; fi; vendor/bin/wp dist-archive --plugin-dirname=syntax-highlighting-code-block dist syntax-highlighting-code-block.zip && echo \"ZIP of build: $(pwd)/syntax-highlighting-code-block.zip\"", "verify-matching-versions": "php ./bin/verify-version-consistency.php", - "deploy": "npm-run-all verify-matching-versions build && unzip syntax-highlighting-code-block.zip && echo grunt wp_deploy && rm -r syntax-highlighting-code-block", + "deploy": "npm-run-all verify-matching-versions build && unzip syntax-highlighting-code-block.zip && grunt wp_deploy && rm -r syntax-highlighting-code-block", "generate-language-names": "php ./bin/generate-language-names.php", "check-engines": "wp-scripts check-engines", "check-licenses": "wp-scripts check-licenses", diff --git a/syntax-highlighting-code-block.php b/syntax-highlighting-code-block.php index 5917c6be..7008bd42 100644 --- a/syntax-highlighting-code-block.php +++ b/syntax-highlighting-code-block.php @@ -3,7 +3,7 @@ * Plugin Name: Syntax-highlighting Code Block (with Server-side Rendering) * Plugin URI: https://github.com/westonruter/syntax-highlighting-code-block * Description: Extending the Code block with syntax highlighting rendered on the server, thus being AMP-compatible and having faster frontend performance. - * Version: 1.5.0-alpha + * Version: 1.5.0 * Author: Weston Ruter * Author URI: https://weston.ruter.net/ * License: GPL2 @@ -16,7 +16,7 @@ namespace Syntax_Highlighting_Code_Block; -const PLUGIN_VERSION = '1.5.0-alpha'; +const PLUGIN_VERSION = '1.5.0'; const PLUGIN_MAIN_FILE = __FILE__; From f53e0e92ea46c84a14859499858ff2ce8da55880 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Tue, 2 Apr 2024 11:53:37 -0700 Subject: [PATCH 19/22] Fix where setting DEVELOPMENT_MODE --- bin/build-dist.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/bin/build-dist.sh b/bin/build-dist.sh index da387584..eae8989a 100755 --- a/bin/build-dist.sh +++ b/bin/build-dist.sh @@ -25,6 +25,7 @@ composer install --no-dev --classmap-authoritative --optimize-autoloader # Since the "highlight.php" directory name can trip up some systems, rename to "highlight-php". mv vendor/scrivo/highlight{.php,-php} find vendor/autoload.php vendor/composer -type f -print0 | xargs -0 sed -i "s:/highlight\.php/:/highlight-php/:g" +sed -i "s/const DEVELOPMENT_MODE = true;.*/const DEVELOPMENT_MODE = false;/g" syntax-highlighting-code-block.php # Build the JS. npm run build:js @@ -40,7 +41,4 @@ if [[ $VERSION == *-* ]]; then sed -i "s/$VERSION_ESCAPED/$NEW_VERSION/g" syntax-highlighting-code-block.php echo "Detected non-stable version: $VERSION" echo "Creating build for version: $NEW_VERSION" - - sed -i "s/const DEVELOPMENT_MODE = true;.*/const DEVELOPMENT_MODE = false;/g" syntax-highlighting-code-block.php fi - From 26bfb24a707cfa05bfea1e8f7c37f25920538663 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Tue, 2 Apr 2024 12:08:17 -0700 Subject: [PATCH 20/22] Reduce duplication --- inc/functions.php | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/inc/functions.php b/inc/functions.php index 35f4ceed..e3bffc44 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -163,11 +163,7 @@ function get_plugin_option( string $option_name ): ?string { * Require the highlight.php functions file. */ function require_highlight_php_functions(): void { - if ( DEVELOPMENT_MODE ) { - require_once PLUGIN_DIR . '/vendor/scrivo/highlight.php/HighlightUtilities/functions.php'; - } else { - require_once PLUGIN_DIR . '/vendor/scrivo/highlight-php/HighlightUtilities/functions.php'; - } + require_once PLUGIN_DIR . '/' . get_highlight_php_vendor_path() . '/HighlightUtilities/functions.php'; } /** @@ -336,8 +332,8 @@ function register_styles(): void { $theme = get_theme_name(); $theme_style_path = sprintf( - 'vendor/scrivo/%s/styles/%s.css', - DEVELOPMENT_MODE ? 'highlight.php' : 'highlight-php', + '%s/styles/%s.css', + get_highlight_php_vendor_path(), 0 === validate_file( $theme ) ? $theme : DEFAULT_THEME ); $styles->add( @@ -620,11 +616,7 @@ function render_block( array $attributes, string $content ): string { try { if ( ! class_exists( '\Highlight\Autoloader' ) ) { - if ( DEVELOPMENT_MODE ) { - require_once PLUGIN_DIR . '/vendor/scrivo/highlight.php/Highlight/Autoloader.php'; - } else { - require_once PLUGIN_DIR . '/vendor/scrivo/highlight-php/Highlight/Autoloader.php'; - } + require_once PLUGIN_DIR . '/' . get_highlight_php_vendor_path() . '/Highlight/Autoloader.php'; spl_autoload_register( 'Highlight\Autoloader::load' ); } @@ -882,3 +874,16 @@ function register_rest_endpoint(): void { ] ); } + +/** + * Gets relative path to highlight.php library in vendor directory. + * + * @return string Relative path. + */ +function get_highlight_php_vendor_path(): string { + if ( DEVELOPMENT_MODE && file_exists( PLUGIN_DIR . '/vendor/scrivo/highlight.php' ) ) { + return 'vendor/scrivo/highlight.php'; + } else { + return 'vendor/scrivo/highlight-php'; + } +} From 18adf1cc7429d31f3b97902c6491bdf3d1dd5efa Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Tue, 2 Apr 2024 12:22:11 -0700 Subject: [PATCH 21/22] Remove obsolete composer script --- composer.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/composer.json b/composer.json index b57e2355..ad9a67a4 100644 --- a/composer.json +++ b/composer.json @@ -41,7 +41,6 @@ "analyze": "if [ -z $TEST_SKIP_PHPSTAN ]; then phpstan --version; phpstan analyze --ansi; fi", "normalize": "composer-normalize", "phpcbf": "bin/phpcbf.sh", - "phpcs": "phpcs", - "zip": "git archive --format=zip HEAD > syntax-highlighting-code-block.zip && unzip -l syntax-highlighting-code-block.zip" + "phpcs": "phpcs" } } From 520d5fdefb045ce5ca9cb567337583559b69024f Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Tue, 2 Apr 2024 12:22:57 -0700 Subject: [PATCH 22/22] Add deploy dir to gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index d9a52466..893b165c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,10 @@ /build /vendor /node_modules + +# Directories used in the dist/deploy process. /dist +/syntax-highlighting-code-block # Generated via bin/transform-readme.php /readme.txt