From 36986aa3ee786e7d3590547fb88b467ca92143db Mon Sep 17 00:00:00 2001 From: ronkelementor <80328720+ronkelementor@users.noreply.github.com> Date: Thu, 10 Jun 2021 13:47:01 +0300 Subject: [PATCH] New: Add Github actions lint + build [ARCH-38] (#159) * New: Add Github actions lint + build [ARCH-38] * move to right folder * remove if * change name * remove unused code * fix * fix lint js * fix phplint + temp * change php * remove temp --- .editorconfig | 21 + .github/workflows/build.yml | 47 + .github/workflows/lint.yml | 65 + .gitignore | 2 + Gruntfile.js | 12 +- .../dev/js/editor/hooks/ui/controls-hook.js | 4 +- composer.lock | 238 + includes/customizer/elementor-upsell.php | 2 +- includes/elementor-functions.php | 6 +- includes/settings/settings-footer.php | 4 +- includes/settings/settings-header.php | 8 +- package-lock.json | 11434 ++++++++++++++++ package.json | 17 +- template-parts/single.php | 3 +- webpack.config.js | 139 + webpack.js | 92 - 16 files changed, 11977 insertions(+), 117 deletions(-) create mode 100644 .editorconfig create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/lint.yml create mode 100644 composer.lock create mode 100644 package-lock.json create mode 100644 webpack.config.js delete mode 100644 webpack.js diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..a541e47 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,21 @@ +# This file is for unifying the coding style for different editors and IDEs +# editorconfig.org + +# WordPress Coding Standards +# https://make.wordpress.org/core/handbook/coding-standards/ + +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +indent_style = tab + +[*.yml] +indent_style = space +indent_size = 2 + +[*.md] +trim_trailing_whitespace = false diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..56e8269 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,47 @@ +name: Build + +on: [push, pull_request] + + +jobs: + build_plugin: + name: Build theme + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Set up Node.js + uses: actions/setup-node@v1 + with: + node-version: 14.x + - name: Cache node modules + uses: actions/cache@v2 + env: + cache-name: cache-node-modules + with: + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + - name: Install Dependencies + run: npm ci + - name: Bump version on push to release or develop + if: github.event_name == 'push' && (startsWith(github.ref, 'refs/heads/release/') || github.ref == 'refs/heads/develop') + run: | + npm config set git-tag-version false + if [ "${GITHUB_REF:11}" == "develop" ]; + then npm version patch + fi + if [[ "${GITHUB_REF:11:7}" == "release" ]]; + then npm version minor + fi + - name: Build + run: npm run zip + - name: Upload zip file to GitHub actions artifact + uses: actions/upload-artifact@v2 + with: + name: hello-elementor + path: hello-elementor.*.zip + retention-days: 7 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..46f2380 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,65 @@ +name: Lint + +on: [push, pull_request] + +jobs: + eslint: + name: ESLint + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Set up Node.js + uses: actions/setup-node@v1 + with: + node-version: 14.x + - name: Cache node modules + uses: actions/cache@v2 + env: + cache-name: cache-node-modules + with: + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + - name: Install Dependencies + run: npm ci + - name: Run Lint + run: npm run lint:js + + phpcs: + name: PHPCS + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup PHP 7.4 + uses: shivammathur/setup-php@9882bed06691b3a085010c1602ce43ef18f15c5b # v2 + with: + php-version: '7.4' + - name: Get composer cache directory + id: composer-cache + run: | + echo "::set-output name=dir::$(composer config cache-files-dir)" + - name: Cache composer dependencies + uses: actions/cache@v1 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-composer- + - name: Install composer packages + run: | + composer install --no-progress + composer require php-parallel-lint/php-parallel-lint + - name: Run Lint + run: | + vendor/bin/phpcs -p -s -n . --standard=./phpcs.xml --extensions=php + - name: Run PHP Syntax Lint + run: | + export PATH=$HOME/.composer/vendor/bin:$PATH + vendor/bin/parallel-lint --blame --exclude node_modules --exclude vendor . diff --git a/.gitignore b/.gitignore index 28c3771..813f399 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ node_modules/ .sass-cache/ build/ +hello-elementor/ log/ vendor/ composer.lock @@ -14,3 +15,4 @@ Thumbs.db yarn.lock assets/js/ *.css +*.zip diff --git a/Gruntfile.js b/Gruntfile.js index 7a3d9ed..451a929 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -12,8 +12,6 @@ module.exports = function( grunt ) { grunt.initConfig( { pkg: grunt.file.readJSON( 'package.json' ), - webpack: require( './webpack' ), - sass: { options: { implementation: sass, @@ -23,7 +21,7 @@ module.exports = function( grunt ) { expand: true, cwd: 'assets/scss', src: '*.scss', - dest: './', + dest: './build', ext: '.css', } ], }, @@ -62,8 +60,8 @@ module.exports = function( grunt ) { files: [ { expand: true, src: [ - '*.css', - '!*.min.css', + 'build/*.css', + '!build/*.min.css', ], ext: '.min.css', } ], @@ -135,10 +133,6 @@ module.exports = function( grunt ) { 'wp_readme_to_markdown', ] ); - grunt.registerTask( 'watch_scripts', ( isDevMode = false ) => { - grunt.task.run( 'webpack:development' ); - } ); - grunt.registerTask( 'styles', [ 'sass', 'postcss', diff --git a/assets/dev/js/editor/hooks/ui/controls-hook.js b/assets/dev/js/editor/hooks/ui/controls-hook.js index c149bc2..b38aeaa 100644 --- a/assets/dev/js/editor/hooks/ui/controls-hook.js +++ b/assets/dev/js/editor/hooks/ui/controls-hook.js @@ -178,7 +178,7 @@ export default class ControlsHook extends $e.modules.hookUI.After { */ toggleLayoutClass( element, classPrefix, inputOptions, inputValue ) { // Loop through the possible classes and remove the one that's not in use - Object.entries( inputOptions ).forEach( ( [ key, value ] ) => { + Object.entries( inputOptions ).forEach( ( [ key ] ) => { element.removeClass( classPrefix + key ); } ); @@ -210,7 +210,7 @@ export default class ControlsHook extends $e.modules.hookUI.After { /** * The hook logic. */ - apply( args, result ) { + apply( args ) { const allThemeControls = this.getHelloThemeControls(), // Extract the control ID from the passed args controlId = Object.keys( args.settings )[ 0 ], diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..5ad9d64 --- /dev/null +++ b/composer.lock @@ -0,0 +1,238 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "a622e373d113e65b40d9fc8226a50733", + "packages": [ + { + "name": "dealerdirect/phpcodesniffer-composer-installer", + "version": "v0.7.1", + "source": { + "type": "git", + "url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git", + "reference": "fe390591e0241955f22eb9ba327d137e501c771c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/fe390591e0241955f22eb9ba327d137e501c771c", + "reference": "fe390591e0241955f22eb9ba327d137e501c771c", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0 || ^2.0", + "php": ">=5.3", + "squizlabs/php_codesniffer": "^2.0 || ^3.0 || ^4.0" + }, + "require-dev": { + "composer/composer": "*", + "phpcompatibility/php-compatibility": "^9.0", + "sensiolabs/security-checker": "^4.1.0" + }, + "type": "composer-plugin", + "extra": { + "class": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" + }, + "autoload": { + "psr-4": { + "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Franck Nijhof", + "email": "franck.nijhof@dealerdirect.com", + "homepage": "http://www.frenck.nl", + "role": "Developer / IT Manager" + } + ], + "description": "PHP_CodeSniffer Standards Composer Installer Plugin", + "homepage": "http://www.dealerdirect.com", + "keywords": [ + "PHPCodeSniffer", + "PHP_CodeSniffer", + "code quality", + "codesniffer", + "composer", + "installer", + "phpcs", + "plugin", + "qa", + "quality", + "standard", + "standards", + "style guide", + "stylecheck", + "tests" + ], + "support": { + "issues": "https://github.com/dealerdirect/phpcodesniffer-composer-installer/issues", + "source": "https://github.com/dealerdirect/phpcodesniffer-composer-installer" + }, + "time": "2020-12-07T18:04:37+00:00" + }, + { + "name": "elementor/elementor-sniffs", + "version": "v0.2.0", + "source": { + "type": "git", + "url": "https://github.com/elementor/elementor-sniffs.git", + "reference": "065f099cbe1a216e92ec23c573b3739b5f805dcb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/elementor/elementor-sniffs/zipball/065f099cbe1a216e92ec23c573b3739b5f805dcb", + "reference": "065f099cbe1a216e92ec23c573b3739b5f805dcb", + "shasum": "" + }, + "require": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.7.0", + "php": ">=5.6", + "wp-coding-standards/wpcs": "^2.3" + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-3.0+" + ], + "authors": [ + { + "name": "Elementor Team", + "email": "support@elementor.com" + } + ], + "description": "Elementor sniffs", + "keywords": [ + "elementor", + "phpcs", + "standards", + "wordpress" + ], + "support": { + "source": "https://github.com/elementor/elementor-sniffs/tree/v0.2.0" + }, + "time": "2020-12-06T15:03:57+00:00" + }, + { + "name": "squizlabs/php_codesniffer", + "version": "3.6.0", + "source": { + "type": "git", + "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", + "reference": "ffced0d2c8fa8e6cdc4d695a743271fab6c38625" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/ffced0d2c8fa8e6cdc4d695a743271fab6c38625", + "reference": "ffced0d2c8fa8e6cdc4d695a743271fab6c38625", + "shasum": "" + }, + "require": { + "ext-simplexml": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + }, + "bin": [ + "bin/phpcs", + "bin/phpcbf" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Greg Sherwood", + "role": "lead" + } + ], + "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", + "keywords": [ + "phpcs", + "standards" + ], + "support": { + "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", + "source": "https://github.com/squizlabs/PHP_CodeSniffer", + "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" + }, + "time": "2021-04-09T00:54:41+00:00" + }, + { + "name": "wp-coding-standards/wpcs", + "version": "2.3.0", + "source": { + "type": "git", + "url": "https://github.com/WordPress/WordPress-Coding-Standards.git", + "reference": "7da1894633f168fe244afc6de00d141f27517b62" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/7da1894633f168fe244afc6de00d141f27517b62", + "reference": "7da1894633f168fe244afc6de00d141f27517b62", + "shasum": "" + }, + "require": { + "php": ">=5.4", + "squizlabs/php_codesniffer": "^3.3.1" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.5 || ^0.6", + "phpcompatibility/php-compatibility": "^9.0", + "phpcsstandards/phpcsdevtools": "^1.0", + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + }, + "suggest": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.6 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically." + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Contributors", + "homepage": "https://github.com/WordPress/WordPress-Coding-Standards/graphs/contributors" + } + ], + "description": "PHP_CodeSniffer rules (sniffs) to enforce WordPress coding conventions", + "keywords": [ + "phpcs", + "standards", + "wordpress" + ], + "support": { + "issues": "https://github.com/WordPress/WordPress-Coding-Standards/issues", + "source": "https://github.com/WordPress/WordPress-Coding-Standards", + "wiki": "https://github.com/WordPress/WordPress-Coding-Standards/wiki" + }, + "time": "2020-05-13T23:57:56+00:00" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [], + "plugin-api-version": "2.0.0" +} diff --git a/includes/customizer/elementor-upsell.php b/includes/customizer/elementor-upsell.php index 42b6799..764f5b3 100644 --- a/includes/customizer/elementor-upsell.php +++ b/includes/customizer/elementor-upsell.php @@ -89,7 +89,7 @@ class Elementor_Upsell extends \WP_Customize_Control { echo $customizer_content; } - private function get_customizer_upsell_html( $title, $text, $url, $button_text, $image ){ + private function get_customizer_upsell_html( $title, $text, $url, $button_text, $image ) { return sprintf( '