Skip to content

Commit 6ecbf9a

Browse files
committed
Merge tag '1.2.1'
* 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. ...
2 parents 5153582 + 16c3bba commit 6ecbf9a

File tree

491 files changed

+27444
-12635
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

491 files changed

+27444
-12635
lines changed

.dev-lib

+1-4
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@
33
DEFAULT_BASE_BRANCH=develop
44
ASSETS_DIR=wp-assets
55
PROJECT_SLUG=amp
6-
SKIP_ECHO_PATHS_SCOPE=1
76
README_MD_TITLE="AMP Plugin for WordPress"
87
DEV_LIB_SKIP="$DEV_LIB_SKIP,jshint"
9-
if [[ ! -z $TRAVIS ]]; then
10-
CHECK_SCOPE=all
11-
fi
8+
CHECK_SCOPE=all
129

1310
function after_wp_install {
1411
if [[ "$WP_VERSION" != "4.9" ]]; then

.eslintrc

+66-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
{
22
"root": true,
3-
"extends": [ "plugin:@wordpress/eslint-plugin/recommended", "plugin:jest/recommended" ],
3+
"extends": [
4+
"plugin:@wordpress/eslint-plugin/recommended",
5+
"plugin:jest/all",
6+
"plugin:import/recommended",
7+
"plugin:eslint-comments/recommended"
8+
],
49
"settings": {
510
"react": {
611
"pragma": "wp",
@@ -9,11 +14,68 @@
914
},
1015
"globals": {
1116
"browser": true,
12-
"page": true,
1317
"wp": true,
1418
"Set": true
1519
},
1620
"rules": {
17-
"react/prop-types": 2
18-
}
21+
"block-scoped-var": "error",
22+
"complexity": ["error", { "max": 20 } ],
23+
"consistent-return": "error",
24+
"default-case": "error",
25+
"guard-for-in": "error",
26+
"no-await-in-loop": "error",
27+
"no-extra-bind": "error",
28+
"no-extra-label": "error",
29+
"no-floating-decimal": "error",
30+
"no-implicit-coercion": "error",
31+
"no-implicit-globals": "error",
32+
"no-implied-eval": "error",
33+
"no-loop-func": "error",
34+
"no-new": "error",
35+
"no-new-func": "error",
36+
"no-new-wrappers": "error",
37+
"no-restricted-properties": "error",
38+
"no-return-assign": "error",
39+
"no-return-await": "error",
40+
"no-sequences": "error",
41+
"no-shadow": "error",
42+
"no-template-curly-in-string": "error",
43+
"no-throw-literal": "error",
44+
"no-unmodified-loop-condition": "error",
45+
"no-useless-call": "error",
46+
"no-useless-concat": "error",
47+
"prefer-object-spread": "error",
48+
"prefer-promise-reject-errors": "error",
49+
"prefer-rest-params": "error",
50+
"prefer-spread": "error",
51+
"radix": [ "error", "as-needed" ],
52+
"require-await": "error",
53+
"rest-spread-spacing": [ "error", "never" ],
54+
"jest/lowercase-name": [
55+
"error",
56+
{
57+
"ignore": [ "describe" ]
58+
}
59+
],
60+
"jest/no-hooks": "off",
61+
"jest/prefer-expect-assertions": "off",
62+
"jest/prefer-inline-snapshots": "off",
63+
"react/prop-types": "error",
64+
"import/no-unresolved": [ "error", {
65+
"ignore": [ "jquery", "amp-block-editor-data" ]
66+
} ]
67+
},
68+
"overrides": [
69+
{
70+
"files": [ "tests/e2e/**/*.js" ],
71+
"env": {
72+
"browser": true
73+
},
74+
"globals": {
75+
"browser": true,
76+
"page": true,
77+
"wp": true
78+
}
79+
}
80+
]
1981
}

.gitignore

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
node_modules
55
wiki
66
amp.zip
7-
assets/css/*-compiled.css
8-
assets/css/*-compiled-rtl.css
9-
assets/css/*.map
7+
/assets/css/*
8+
!/assets/css/src/
109
assets/js/*.js
1110
assets/js/*.deps.json
1211
!assets/js/amp-service-worker-runtime-precaching.js

.npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
save-exact = true

.rtlcssrc

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"options": {
3+
"autoRename": false,
4+
"autoRenameStrict": false,
5+
"blacklist":{},
6+
"clean": true,
7+
"greedy": false,
8+
"processUrls": false,
9+
"stringMap":[]
10+
},
11+
"plugins": [ ],
12+
"map": false
13+
}

.stylelintignore

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1-
assets/css/admin-bar.css
2-
assets/css/*-compiled.css
3-
assets/css/*-compiled-rtl.css
1+
/assets/css/*.css
2+
/assets/css/src/admin-bar.css
3+
/bin
4+
/build
5+
/tests
6+
/vendor

.travis.yml

+35-6
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ notifications:
1818
cache:
1919
directories:
2020
- $HOME/.composer/cache
21+
- $HOME/.jest-cache
2122
- $HOME/.npm
2223
- $HOME/.nvm/.cache
2324
- $HOME/phpunit-bin
@@ -29,20 +30,29 @@ branches:
2930
- develop
3031
- /^\d+\.\d+$/
3132

32-
env: PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
33+
env:
34+
global:
35+
- PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
3336

3437
install:
3538
- nvm install
3639
- composer install
3740
- export DEV_LIB_PATH=vendor/xwp/wp-dev-lib/scripts
41+
- export DIFF_HEAD=HEAD
3842
- source "$DEV_LIB_PATH/travis.install.sh"
3943

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

4347
script:
4448
- npm run build:js
49+
- npm run build:css
4550
- source "$DEV_LIB_PATH/travis.script.sh"
51+
- |
52+
if [[ ! -z "$PHPUNIT_EXTRA_GROUP" ]]; then
53+
echo "Running phpunit group $PHPUNIT_EXTRA_GROUP"
54+
phpunit --group $PHPUNIT_EXTRA_GROUP
55+
fi
4656
4757
after_script:
4858
- source "$DEV_LIB_PATH/travis.after_script.sh"
@@ -64,18 +74,36 @@ jobs:
6474
- composer validate --no-check-all
6575
- composer normalize --dry-run
6676
- npm run lint
77+
- npm run build:js
78+
after_success:
79+
- npx sizereport --config
6780

6881
- stage: test
6982
name: JavaScript unit tests
7083
php: "7.3"
7184
env: WP_VERSION=latest DEV_LIB_SKIP=phpcs,eslint,xmllint,phpsyntax,phpunit
7285
script:
7386
- source "$DEV_LIB_PATH/travis.script.sh"
74-
- npm run test:js -- --ci
87+
- npm run test:js -- --ci --cacheDirectory="$HOME/.jest-cache"
88+
89+
- name: E2E tests
90+
php: "7.3"
91+
env: WP_VERSION=latest DEV_LIB_SKIP=phpcs,eslint,xmllint,phpsyntax,phpunit PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=
92+
install:
93+
- nvm install
94+
- composer install
95+
- npm install
96+
script:
97+
- npm run build:js
98+
- npm run build:css
99+
- npm run env:start
100+
- npm run env:reset-site
101+
- npm run test:e2e:ci
102+
- npm run env:stop
75103

76-
- name: PHP unit tests (7.3, WordPress latest)
104+
- name: PHP unit tests w/ external-http (7.3, WordPress latest)
77105
php: "7.3"
78-
env: WP_VERSION=latest DEV_LIB_ONLY=phpunit INSTALL_PWA_PLUGIN=1
106+
env: WP_VERSION=latest DEV_LIB_ONLY=phpunit INSTALL_PWA_PLUGIN=1 PHPUNIT_EXTRA_GROUP=external-http
79107

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

104-
- name: PHP unit tests (5.4, WordPress 4.9)
132+
- name: PHP unit tests w/ external-http (5.4, WordPress 4.9)
105133
php: "5.4"
106-
env: WP_VERSION=4.9 DEV_LIB_ONLY=phpunit,phpsyntax
134+
env: WP_VERSION=4.9 DEV_LIB_ONLY=phpunit,phpsyntax PHPUNIT_EXTRA_GROUP=external-http
107135

108136
- name: PHP unit tests (7.3, WordPress trunk)
109137
php: "7.3"
@@ -117,6 +145,7 @@ jobs:
117145
- echo "Running unit tests with code coverage..."
118146
script:
119147
- npm run build:js
148+
- npm run build:css
120149
- source "$DEV_LIB_PATH/travis.script.sh"
121150
- bash <(curl -s https://codecov.io/bash) -cF php -f /tmp/wordpress/src/wp-content/plugins/amp/build/logs/clover.xml
122151
- npm run test:js -- --collectCoverage

Gruntfile.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/* eslint-env node */
2-
/* eslint-disable camelcase, no-console, no-param-reassign */
32

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

9089
const paths = lsOutput.trim().split( /\n/ ).filter( function( file ) {
91-
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 );
90+
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 );
9291
} );
9392

9493
paths.push( 'vendor/autoload.php' );
@@ -116,7 +115,7 @@ module.exports = function( grunt ) {
116115
matches = content.match( versionRegex );
117116
if ( matches ) {
118117
version = matches[ 2 ] + '-' + versionAppend;
119-
console.log( 'Updating version in amp.php to ' + version );
118+
console.log( 'Updating version in amp.php to ' + version ); // eslint-disable-line no-console
120119
content = content.replace( versionRegex, '$1' + version );
121120
content = content.replace( /(define\(\s*'AMP__VERSION',\s*')(.+?)(?=')/, '$1' + version );
122121
}

amp.php

+12-9
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,28 @@
55
* Plugin URI: https://amp-wp.org
66
* Author: AMP Project Contributors
77
* Author URI: https://github.com/ampproject/amp-wp/graphs/contributors
8-
* Version: 1.2.0
8+
* Version: 1.2.1
99
* Text Domain: amp
1010
* Domain Path: /languages/
1111
* License: GPLv2 or later
1212
*
1313
* @package AMP
1414
*/
1515

16+
define( 'AMP__FILE__', __FILE__ );
17+
define( 'AMP__DIR__', dirname( __FILE__ ) );
18+
define( 'AMP__VERSION', '1.2.1' );
19+
1620
/**
1721
* Errors encountered while loading the plugin.
1822
*
1923
* This has to be a global for the same of PHP 5.2.
2024
*
21-
* @var \WP_Error $_amp_load_errors
25+
* @var WP_Error $_amp_load_errors
2226
*/
2327
global $_amp_load_errors;
2428

25-
$_amp_load_errors = new \WP_Error();
29+
$_amp_load_errors = new WP_Error();
2630

2731
if ( version_compare( phpversion(), '5.4', '<' ) ) {
2832
$_amp_load_errors->add(
@@ -145,7 +149,7 @@
145149

146150
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 );
147151

148-
if ( ! file_exists( __DIR__ . '/vendor/autoload.php' ) || ! file_exists( __DIR__ . '/vendor/sabberworm/php-css-parser' ) || ! file_exists( __DIR__ . '/assets/js/amp-block-editor.js' ) ) {
152+
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' ) ) {
149153
$_amp_load_errors->add(
150154
'build_required',
151155
sprintf(
@@ -160,7 +164,7 @@
160164
* Displays an admin notice about why the plugin is unable to load.
161165
*
162166
* @since 1.1.2
163-
* @global \WP_Error $_amp_load_errors
167+
* @global WP_Error $_amp_load_errors
164168
*/
165169
function _amp_show_load_errors_admin_notice() {
166170
global $_amp_load_errors;
@@ -207,9 +211,6 @@ function _amp_show_load_errors_admin_notice() {
207211
return;
208212
}
209213

210-
define( 'AMP__FILE__', __FILE__ );
211-
define( 'AMP__DIR__', dirname( __FILE__ ) );
212-
define( 'AMP__VERSION', '1.2.0' );
213214

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

364365
if ( AMP_Options_Manager::is_stories_experience_enabled() ) {
365366
AMP_Story_Post_Type::register();
366-
add_action( 'wp_loaded', 'amp_story_templates' );
367367
}
368368

369+
// Does its own is_stories_experience_enabled() check.
370+
add_action( 'wp_loaded', 'amp_story_templates' );
371+
369372
if ( defined( 'WP_CLI' ) && WP_CLI ) {
370373
WP_CLI::add_command( 'amp', new AMP_CLI() );
371374
}

0 commit comments

Comments
 (0)