Skip to content

Commit

Permalink
Merge tag '1.2.1'
Browse files Browse the repository at this point in the history
* tag '1.2.1': (434 commits)
  Bump 1.2.1
  Adjust block inserter style. (#3075)
  Update dependency eslint-plugin-jest to v22.15.2
  Fix flaky CTA test (#3057)
  Add more resizing handles (#3023)
  Bump version to 1.2.1-RC1
  Improve story page background media with image srcset, reduced image size, and a11y text (#3006)
  Wait until content loaded before calculating font size. (#3052)
  Harden logic for normalizing image metadata before adding story images (#3049)
  Update dependency uuid to v3.3.3 (#3046)
  Inline color support (#3033)
  Update dependency webpack-cli to v3.3.7 (#3040)
  Tiny prop-types fix
  Update dependency babel-jest to v24.9.0 (#3037)
  Update e2e test setup (#3031)
  Include amp-script among dynamic_element_selectors in tree shaking
  Another try to fix tests.
  Ensure selecting the first page before removing the block.
  Move setting input selection to the end to helpers.
  Fix editor test.
  ...
  • Loading branch information
westonruter committed Aug 22, 2019
2 parents 5153582 + 16c3bba commit 6ecbf9a
Show file tree
Hide file tree
Showing 491 changed files with 27,444 additions and 12,635 deletions.
5 changes: 1 addition & 4 deletions .dev-lib
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@
DEFAULT_BASE_BRANCH=develop
ASSETS_DIR=wp-assets
PROJECT_SLUG=amp
SKIP_ECHO_PATHS_SCOPE=1
README_MD_TITLE="AMP Plugin for WordPress"
DEV_LIB_SKIP="$DEV_LIB_SKIP,jshint"
if [[ ! -z $TRAVIS ]]; then
CHECK_SCOPE=all
fi
CHECK_SCOPE=all

function after_wp_install {
if [[ "$WP_VERSION" != "4.9" ]]; then
Expand Down
70 changes: 66 additions & 4 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"root": true,
"extends": [ "plugin:@wordpress/eslint-plugin/recommended", "plugin:jest/recommended" ],
"extends": [
"plugin:@wordpress/eslint-plugin/recommended",
"plugin:jest/all",
"plugin:import/recommended",
"plugin:eslint-comments/recommended"
],
"settings": {
"react": {
"pragma": "wp",
Expand All @@ -9,11 +14,68 @@
},
"globals": {
"browser": true,
"page": true,
"wp": true,
"Set": true
},
"rules": {
"react/prop-types": 2
}
"block-scoped-var": "error",
"complexity": ["error", { "max": 20 } ],
"consistent-return": "error",
"default-case": "error",
"guard-for-in": "error",
"no-await-in-loop": "error",
"no-extra-bind": "error",
"no-extra-label": "error",
"no-floating-decimal": "error",
"no-implicit-coercion": "error",
"no-implicit-globals": "error",
"no-implied-eval": "error",
"no-loop-func": "error",
"no-new": "error",
"no-new-func": "error",
"no-new-wrappers": "error",
"no-restricted-properties": "error",
"no-return-assign": "error",
"no-return-await": "error",
"no-sequences": "error",
"no-shadow": "error",
"no-template-curly-in-string": "error",
"no-throw-literal": "error",
"no-unmodified-loop-condition": "error",
"no-useless-call": "error",
"no-useless-concat": "error",
"prefer-object-spread": "error",
"prefer-promise-reject-errors": "error",
"prefer-rest-params": "error",
"prefer-spread": "error",
"radix": [ "error", "as-needed" ],
"require-await": "error",
"rest-spread-spacing": [ "error", "never" ],
"jest/lowercase-name": [
"error",
{
"ignore": [ "describe" ]
}
],
"jest/no-hooks": "off",
"jest/prefer-expect-assertions": "off",
"jest/prefer-inline-snapshots": "off",
"react/prop-types": "error",
"import/no-unresolved": [ "error", {
"ignore": [ "jquery", "amp-block-editor-data" ]
} ]
},
"overrides": [
{
"files": [ "tests/e2e/**/*.js" ],
"env": {
"browser": true
},
"globals": {
"browser": true,
"page": true,
"wp": true
}
}
]
}
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
node_modules
wiki
amp.zip
assets/css/*-compiled.css
assets/css/*-compiled-rtl.css
assets/css/*.map
/assets/css/*
!/assets/css/src/
assets/js/*.js
assets/js/*.deps.json
!assets/js/amp-service-worker-runtime-precaching.js
Expand Down
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
save-exact = true
13 changes: 13 additions & 0 deletions .rtlcssrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"options": {
"autoRename": false,
"autoRenameStrict": false,
"blacklist":{},
"clean": true,
"greedy": false,
"processUrls": false,
"stringMap":[]
},
"plugins": [ ],
"map": false
}
9 changes: 6 additions & 3 deletions .stylelintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
assets/css/admin-bar.css
assets/css/*-compiled.css
assets/css/*-compiled-rtl.css
/assets/css/*.css
/assets/css/src/admin-bar.css
/bin
/build
/tests
/vendor
41 changes: 35 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ notifications:
cache:
directories:
- $HOME/.composer/cache
- $HOME/.jest-cache
- $HOME/.npm
- $HOME/.nvm/.cache
- $HOME/phpunit-bin
Expand All @@ -29,20 +30,29 @@ branches:
- develop
- /^\d+\.\d+$/

env: PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
env:
global:
- PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true

install:
- nvm install
- composer install
- export DEV_LIB_PATH=vendor/xwp/wp-dev-lib/scripts
- export DIFF_HEAD=HEAD
- source "$DEV_LIB_PATH/travis.install.sh"

before_script:
- phpenv config-rm xdebug.ini || echo "xdebug.ini does not exist."

script:
- npm run build:js
- npm run build:css
- source "$DEV_LIB_PATH/travis.script.sh"
- |
if [[ ! -z "$PHPUNIT_EXTRA_GROUP" ]]; then
echo "Running phpunit group $PHPUNIT_EXTRA_GROUP"
phpunit --group $PHPUNIT_EXTRA_GROUP
fi
after_script:
- source "$DEV_LIB_PATH/travis.after_script.sh"
Expand All @@ -64,18 +74,36 @@ jobs:
- composer validate --no-check-all
- composer normalize --dry-run
- npm run lint
- npm run build:js
after_success:
- npx sizereport --config

- stage: test
name: JavaScript unit tests
php: "7.3"
env: WP_VERSION=latest DEV_LIB_SKIP=phpcs,eslint,xmllint,phpsyntax,phpunit
script:
- source "$DEV_LIB_PATH/travis.script.sh"
- npm run test:js -- --ci
- npm run test:js -- --ci --cacheDirectory="$HOME/.jest-cache"

- name: E2E tests
php: "7.3"
env: WP_VERSION=latest DEV_LIB_SKIP=phpcs,eslint,xmllint,phpsyntax,phpunit PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=
install:
- nvm install
- composer install
- npm install
script:
- npm run build:js
- npm run build:css
- npm run env:start
- npm run env:reset-site
- npm run test:e2e:ci
- npm run env:stop

- name: PHP unit tests (7.3, WordPress latest)
- name: PHP unit tests w/ external-http (7.3, WordPress latest)
php: "7.3"
env: WP_VERSION=latest DEV_LIB_ONLY=phpunit INSTALL_PWA_PLUGIN=1
env: WP_VERSION=latest DEV_LIB_ONLY=phpunit INSTALL_PWA_PLUGIN=1 PHPUNIT_EXTRA_GROUP=external-http

- name: PHP unit tests (7.2, WordPress latest)
php: "7.2"
Expand All @@ -101,9 +129,9 @@ jobs:
php: "5.5"
env: WP_VERSION=5.0 DEV_LIB_ONLY=phpunit,phpsyntax

- name: PHP unit tests (5.4, WordPress 4.9)
- name: PHP unit tests w/ external-http (5.4, WordPress 4.9)
php: "5.4"
env: WP_VERSION=4.9 DEV_LIB_ONLY=phpunit,phpsyntax
env: WP_VERSION=4.9 DEV_LIB_ONLY=phpunit,phpsyntax PHPUNIT_EXTRA_GROUP=external-http

- name: PHP unit tests (7.3, WordPress trunk)
php: "7.3"
Expand All @@ -117,6 +145,7 @@ jobs:
- echo "Running unit tests with code coverage..."
script:
- npm run build:js
- npm run build:css
- source "$DEV_LIB_PATH/travis.script.sh"
- bash <(curl -s https://codecov.io/bash) -cF php -f /tmp/wordpress/src/wp-content/plugins/amp/build/logs/clover.xml
- npm run test:js -- --collectCoverage
Expand Down
5 changes: 2 additions & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* eslint-env node */
/* eslint-disable camelcase, no-console, no-param-reassign */

module.exports = function( grunt ) {
'use strict';
Expand Down Expand Up @@ -88,7 +87,7 @@ module.exports = function( grunt ) {
const versionAppend = new Date().toISOString().replace( /\.\d+/, '' ).replace( /-|:/g, '' ) + '-' + commitHash;

const paths = lsOutput.trim().split( /\n/ ).filter( function( file ) {
return ! /^(blocks|\.|bin|([^/]+)+\.(md|json|xml)|Gruntfile\.js|postcss\.config\.js|tests|wp-assets|readme\.md|composer\..*|patches|webpack.*|assets\/src|docker-compose\.yml|babel\.config\.js|codecov\.yml)/.test( file );
return ! /^(blocks|\.|bin|([^/]+)+\.(md|json|xml)|Gruntfile\.js|tests|wp-assets|readme\.md|composer\..*|patches|webpack.*|assets\/images\/stories-editor\/.*\.svg|assets\/src|assets\/css\/src|docker-compose\.yml|.*\.config\.js|codecov\.yml)/.test( file );
} );

paths.push( 'vendor/autoload.php' );
Expand Down Expand Up @@ -116,7 +115,7 @@ module.exports = function( grunt ) {
matches = content.match( versionRegex );
if ( matches ) {
version = matches[ 2 ] + '-' + versionAppend;
console.log( 'Updating version in amp.php to ' + version );
console.log( 'Updating version in amp.php to ' + version ); // eslint-disable-line no-console
content = content.replace( versionRegex, '$1' + version );
content = content.replace( /(define\(\s*'AMP__VERSION',\s*')(.+?)(?=')/, '$1' + version );
}
Expand Down
21 changes: 12 additions & 9 deletions amp.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,28 @@
* Plugin URI: https://amp-wp.org
* Author: AMP Project Contributors
* Author URI: https://github.com/ampproject/amp-wp/graphs/contributors
* Version: 1.2.0
* Version: 1.2.1
* Text Domain: amp
* Domain Path: /languages/
* License: GPLv2 or later
*
* @package AMP
*/

define( 'AMP__FILE__', __FILE__ );
define( 'AMP__DIR__', dirname( __FILE__ ) );
define( 'AMP__VERSION', '1.2.1' );

/**
* Errors encountered while loading the plugin.
*
* This has to be a global for the same of PHP 5.2.
*
* @var \WP_Error $_amp_load_errors
* @var WP_Error $_amp_load_errors
*/
global $_amp_load_errors;

$_amp_load_errors = new \WP_Error();
$_amp_load_errors = new WP_Error();

if ( version_compare( phpversion(), '5.4', '<' ) ) {
$_amp_load_errors->add(
Expand Down Expand Up @@ -145,7 +149,7 @@

unset( $_amp_required_extensions, $_amp_missing_extensions, $_amp_required_constructs, $_amp_missing_classes, $_amp_missing_functions, $_amp_required_extension, $_amp_construct_type, $_amp_construct, $_amp_constructs );

if ( ! file_exists( __DIR__ . '/vendor/autoload.php' ) || ! file_exists( __DIR__ . '/vendor/sabberworm/php-css-parser' ) || ! file_exists( __DIR__ . '/assets/js/amp-block-editor.js' ) ) {
if ( ! file_exists( AMP__DIR__ . '/vendor/autoload.php' ) || ! file_exists( AMP__DIR__ . '/vendor/sabberworm/php-css-parser' ) || ! file_exists( AMP__DIR__ . '/assets/js/amp-block-editor.js' ) ) {
$_amp_load_errors->add(
'build_required',
sprintf(
Expand All @@ -160,7 +164,7 @@
* Displays an admin notice about why the plugin is unable to load.
*
* @since 1.1.2
* @global \WP_Error $_amp_load_errors
* @global WP_Error $_amp_load_errors
*/
function _amp_show_load_errors_admin_notice() {
global $_amp_load_errors;
Expand Down Expand Up @@ -207,9 +211,6 @@ function _amp_show_load_errors_admin_notice() {
return;
}

define( 'AMP__FILE__', __FILE__ );
define( 'AMP__DIR__', dirname( __FILE__ ) );
define( 'AMP__VERSION', '1.2.0' );

/**
* Print admin notice if plugin installed with incorrect slug (which impacts WordPress's auto-update system).
Expand Down Expand Up @@ -363,9 +364,11 @@ function amp_init() {

if ( AMP_Options_Manager::is_stories_experience_enabled() ) {
AMP_Story_Post_Type::register();
add_action( 'wp_loaded', 'amp_story_templates' );
}

// Does its own is_stories_experience_enabled() check.
add_action( 'wp_loaded', 'amp_story_templates' );

if ( defined( 'WP_CLI' ) && WP_CLI ) {
WP_CLI::add_command( 'amp', new AMP_CLI() );
}
Expand Down
Loading

0 comments on commit 6ecbf9a

Please sign in to comment.