Skip to content

Commit

Permalink
Merge pull request #4019 from ampproject/add/958-amp-optimizer
Browse files Browse the repository at this point in the history
Add AMP Optimizer library
  • Loading branch information
westonruter authored Mar 7, 2020
2 parents 47a57de + 8559dfc commit b6f86b6
Show file tree
Hide file tree
Showing 443 changed files with 28,008 additions and 2,305 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
**/assets/js/*.js
!assets/js/amp-service-worker-runtime-precaching.js
build/*
lib/*
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ built
/amphtml
.env
.idea/
/lib/*/vendor/
/lib/*/composer.lock
2 changes: 2 additions & 0 deletions .stylelintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
/build
/tests
/vendor
/lib/optimizer
/lib/common
18 changes: 18 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,21 @@ jobs:
- 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
- bash <(curl -s https://codecov.io/bash) -cF javascript -f build/logs/lcov.info

- name: Libraries that are meant to be externalized (5.6)
php: "5.6"
install:
- composer --working-dir=lib/common install
- composer --working-dir=lib/optimizer install
script:
- composer --working-dir=lib/common test
- composer --working-dir=lib/optimizer test

- name: Libraries that are meant to be externalized (7.3)
php: "7.3"
install:
- composer --working-dir=lib/common install
- composer --working-dir=lib/optimizer install
script:
- composer --working-dir=lib/common test
- composer --working-dir=lib/optimizer test
14 changes: 13 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ module.exports = function( grunt ) {
const productionVendorExcludedFilePatterns = [
'composer.*',
'patches',
'lib',
'vendor/*/*/.editorconfig',
'vendor/*/*/.git',
'vendor/*/*/.gitignore',
Expand All @@ -40,7 +41,10 @@ module.exports = function( grunt ) {
'vendor/*/*/*.yml',
'vendor/*/*/.*.yml',
'vendor/*/*/tests',
'vendor/amp/optimizer/bin',
'vendor/bin',
'vendor/amp/common/vendor',
'vendor/amp/optimizer/vendor',
];

grunt.initConfig( {
Expand Down Expand Up @@ -70,7 +74,14 @@ module.exports = function( grunt ) {
command: 'php bin/verify-version-consistency.php',
},
composer_install: {
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( ' ' ),
command: [
'if [ ! -e build ]; then echo "Run grunt build first."; exit 1; fi',
'cd build',
'composer install --no-dev -o',
'for symlinksource in $(find vendor/amp -type l); do symlinktarget=$(readlink "$symlinksource") && rm "$symlinksource" && cp -r "vendor/amp/$symlinktarget" "$symlinksource"; done',
'composer remove cweagans/composer-patches --update-no-dev -o',
'rm -r ' + productionVendorExcludedFilePatterns.join( ' ' )
].join( ' && ' ),
},
create_build_zip: {
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"',
Expand Down Expand Up @@ -150,6 +161,7 @@ module.exports = function( grunt ) {
} );

paths.push( 'composer.*' ); // Copy in order to be able to do run composer_install.
paths.push( 'lib/**' );
paths.push( 'assets/js/*.js' ); // @todo Also include *.map files?
paths.push( 'assets/js/*.asset.php' );
paths.push( 'assets/css/*.css' );
Expand Down
2 changes: 2 additions & 0 deletions amp.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@
'curl' => array(
'functions' => array(
'curl_close',
'curl_errno',
'curl_error',
'curl_exec',
'curl_getinfo',
'curl_init',
'curl_setopt',
),
Expand Down
20 changes: 19 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
"ext-iconv": "*",
"ext-libxml": "*",
"ext-spl": "*",
"amp/common": "^1",
"amp/optimizer": "^1",
"cweagans/composer-patches": "1.6.7",
"fasterimage/fasterimage": "1.5.0",
"sabberworm/php-css-parser": "dev-master#134f4e6"
Expand Down Expand Up @@ -58,10 +60,26 @@
}
},
"repositories": [
{
"type": "path",
"url": "lib/common",
"options": {
"symlink": true
}
},
{
"type": "path",
"url": "lib/optimizer",
"options": {
"symlink": true
}
},
{
"type": "vcs",
"url": "https://github.com/sabberworm/PHP-CSS-Parser.git",
"no-api": true
}
]
],
"minimum-stability": "dev",
"prefer-stable": true
}
Loading

0 comments on commit b6f86b6

Please sign in to comment.