Skip to content

Commit b6f86b6

Browse files
authored
Merge pull request #4019 from ampproject/add/958-amp-optimizer
Add AMP Optimizer library
2 parents 47a57de + 8559dfc commit b6f86b6

File tree

443 files changed

+28008
-2305
lines changed

Some content is hidden

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

443 files changed

+28008
-2305
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
**/assets/js/*.js
55
!assets/js/amp-service-worker-runtime-precaching.js
66
build/*
7+
lib/*

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ built
1414
/amphtml
1515
.env
1616
.idea/
17+
/lib/*/vendor/
18+
/lib/*/composer.lock

.stylelintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
/build
44
/tests
55
/vendor
6+
/lib/optimizer
7+
/lib/common

.travis.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,21 @@ jobs:
151151
- bash <(curl -s https://codecov.io/bash) -cF php -f /tmp/wordpress/src/wp-content/plugins/amp/build/logs/clover.xml
152152
- npm run test:js -- --collectCoverage
153153
- bash <(curl -s https://codecov.io/bash) -cF javascript -f build/logs/lcov.info
154+
155+
- name: Libraries that are meant to be externalized (5.6)
156+
php: "5.6"
157+
install:
158+
- composer --working-dir=lib/common install
159+
- composer --working-dir=lib/optimizer install
160+
script:
161+
- composer --working-dir=lib/common test
162+
- composer --working-dir=lib/optimizer test
163+
164+
- name: Libraries that are meant to be externalized (7.3)
165+
php: "7.3"
166+
install:
167+
- composer --working-dir=lib/common install
168+
- composer --working-dir=lib/optimizer install
169+
script:
170+
- composer --working-dir=lib/common test
171+
- composer --working-dir=lib/optimizer test

Gruntfile.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ module.exports = function( grunt ) {
2828
const productionVendorExcludedFilePatterns = [
2929
'composer.*',
3030
'patches',
31+
'lib',
3132
'vendor/*/*/.editorconfig',
3233
'vendor/*/*/.git',
3334
'vendor/*/*/.gitignore',
@@ -40,7 +41,10 @@ module.exports = function( grunt ) {
4041
'vendor/*/*/*.yml',
4142
'vendor/*/*/.*.yml',
4243
'vendor/*/*/tests',
44+
'vendor/amp/optimizer/bin',
4345
'vendor/bin',
46+
'vendor/amp/common/vendor',
47+
'vendor/amp/optimizer/vendor',
4448
];
4549

4650
grunt.initConfig( {
@@ -70,7 +74,14 @@ module.exports = function( grunt ) {
7074
command: 'php bin/verify-version-consistency.php',
7175
},
7276
composer_install: {
73-
command: 'if [ ! -e build ]; then echo "Run grunt build first."; exit 1; fi; cd build; composer install --no-dev -o && composer remove cweagans/composer-patches --update-no-dev -o && rm -r ' + productionVendorExcludedFilePatterns.join( ' ' ),
77+
command: [
78+
'if [ ! -e build ]; then echo "Run grunt build first."; exit 1; fi',
79+
'cd build',
80+
'composer install --no-dev -o',
81+
'for symlinksource in $(find vendor/amp -type l); do symlinktarget=$(readlink "$symlinksource") && rm "$symlinksource" && cp -r "vendor/amp/$symlinktarget" "$symlinksource"; done',
82+
'composer remove cweagans/composer-patches --update-no-dev -o',
83+
'rm -r ' + productionVendorExcludedFilePatterns.join( ' ' )
84+
].join( ' && ' ),
7485
},
7586
create_build_zip: {
7687
command: 'if [ ! -e build ]; then echo "Run grunt build first."; exit 1; fi; if [ -e amp.zip ]; then rm amp.zip; fi; cd build; zip -r ../amp.zip .; cd ..; echo; echo "ZIP of build: $(pwd)/amp.zip"',
@@ -150,6 +161,7 @@ module.exports = function( grunt ) {
150161
} );
151162

152163
paths.push( 'composer.*' ); // Copy in order to be able to do run composer_install.
164+
paths.push( 'lib/**' );
153165
paths.push( 'assets/js/*.js' ); // @todo Also include *.map files?
154166
paths.push( 'assets/js/*.asset.php' );
155167
paths.push( 'assets/css/*.css' );

amp.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,10 @@
4545
'curl' => array(
4646
'functions' => array(
4747
'curl_close',
48+
'curl_errno',
4849
'curl_error',
4950
'curl_exec',
51+
'curl_getinfo',
5052
'curl_init',
5153
'curl_setopt',
5254
),

composer.json

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
"ext-iconv": "*",
1313
"ext-libxml": "*",
1414
"ext-spl": "*",
15+
"amp/common": "^1",
16+
"amp/optimizer": "^1",
1517
"cweagans/composer-patches": "1.6.7",
1618
"fasterimage/fasterimage": "1.5.0",
1719
"sabberworm/php-css-parser": "dev-master#134f4e6"
@@ -58,10 +60,26 @@
5860
}
5961
},
6062
"repositories": [
63+
{
64+
"type": "path",
65+
"url": "lib/common",
66+
"options": {
67+
"symlink": true
68+
}
69+
},
70+
{
71+
"type": "path",
72+
"url": "lib/optimizer",
73+
"options": {
74+
"symlink": true
75+
}
76+
},
6177
{
6278
"type": "vcs",
6379
"url": "https://github.com/sabberworm/PHP-CSS-Parser.git",
6480
"no-api": true
6581
}
66-
]
82+
],
83+
"minimum-stability": "dev",
84+
"prefer-stable": true
6785
}

0 commit comments

Comments
 (0)