Skip to content

Amphtml generator update#6

Open
marcelovani wants to merge 37 commits intomasterfrom
amphtml-generator
Open

Amphtml generator update#6
marcelovani wants to merge 37 commits intomasterfrom
amphtml-generator

Conversation

@marcelovani
Copy link
Copy Markdown

@marcelovani marcelovani commented Dec 5, 2018

On this pull request I did the following:

  • Added a Vagrantfile to spin a VM with all the dependencies to generate the PHP validator
  • Fixed the autoloader include to make it work from different folders
  • Copied the WP Plugin generator scripts into bin folder
  • Copied the Lullabot AMP generator scripts into bin folder and made minor tweaks
  • Resolved issue #249

See Lullabot#231

Comment thread Vagrantfile
config.vm.provider "virtualbox" do |vb|
vb.memory = "1024"
end
end
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This Vagrant file is used to download all dependencies inside a VM. We could have an alternative docker file.

Comment thread bin/amp-console
require_once ($autoload);
break;
}
}
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allow the script to work from different folders

Comment thread bin/build.sh
cp dist/validator-generated.php $PROJECT_PATH/src/Spec/

echo "Generated files"
ls $PROJECT_PATH/src/Spec/*.php
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adapted version of https://github.com/Automattic/amp-wp/blob/develop/bin/amphtml-update.sh
This script generates both the WP and Lullabot versions of validation rules

Comment thread bin/validator_gen_php.py
GeneratePHP(out_dir)

if __name__ == '__main__':
Main()
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread composer.json
"sebastian/diff": "^1.2 || ^2 || ^3",
"marc1706/fast-image-size": "1.*",
"masterminds/html5": "^2.2.0",
"masterminds/html5": "~2.0",
Copy link
Copy Markdown
Author

@marcelovani marcelovani Dec 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments here Lullabot#249

{
// We embed a scanner so that $this->startTag() knows the current line number
$this->scanner = new Scanner($inputstream);
$this->scanner = new Scanner($data);
Copy link
Copy Markdown
Author

@marcelovani marcelovani Dec 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments here Lullabot#249

Comment thread src/Utility/AMPHTML5.php
// User options override default options in $this->options
$final_options = array_merge($this->options, $options);
$amp_tree_builder = new AMPDOMTreeBuilder($inputstream, $final_options);
$amp_tree_builder = new AMPDOMTreeBuilder($data, $final_options);
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments here Lullabot#249

Comment thread composer.json
},
"bin": [
"bin/amp-console"
]
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put the executable inside vendor/bin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant