-
Notifications
You must be signed in to change notification settings - Fork 1
[WIP] Preview components inside a directory #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| <?php | ||
|
|
||
| /* | ||
| * This file is part of the Pattern Library Builder project. | ||
| * | ||
| * Copyright (c) 2017-present LIN3S <info@lin3s.com> | ||
| * | ||
| * For the full copyright and license information, please view the LICENSE | ||
| * file that was distributed with this source code. | ||
| */ | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| /* | ||
| * This file is part of the Pattern Library Builder project. | ||
| * | ||
| * Copyright (c) 2017-present LIN3S <info@lin3s.com> | ||
| * | ||
| * For the full copyright and license information, please view the LICENSE | ||
| * file that was distributed with this source code. | ||
| */ | ||
|
|
||
| namespace LIN3S\PatternLibraryBuilder\Symfony\Command; | ||
|
|
||
| use LIN3S\PatternLibraryBuilder\Loader\StyleguideConfigLoader; | ||
| use Symfony\Component\Console\Command\Command; | ||
| use Symfony\Component\Console\Input\InputInterface; | ||
| use Symfony\Component\Console\Output\OutputInterface; | ||
|
|
||
| /** | ||
| * @author Gorka Laucirica <gorka.lauzirika@gmail.com> | ||
| */ | ||
| class LoadThumbnailsCommand extends Command | ||
| { | ||
| private const CHROME_BIN = "/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This path is highly coupled with MacOS |
||
| private $configLoader; | ||
|
|
||
| public function __construct(StyleguideConfigLoader $configLoader) | ||
| { | ||
| parent::__construct(); | ||
| $this->configLoader = $configLoader; | ||
| } | ||
|
|
||
| protected function configure() | ||
| { | ||
| $this->setName('lin3s:pattern-library-builder:load-thumbnails'); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Call setDescription method with proper explanation |
||
| } | ||
|
|
||
| protected function execute(InputInterface $input, OutputInterface $output) | ||
| { | ||
| $configs = $this->configLoader->allInPlain(); | ||
|
|
||
| foreach ($configs as $config) { | ||
| $this->takeScreenshot($config); | ||
| } | ||
| } | ||
|
|
||
| private function takeScreenshot(array $config) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add missing "void" return type |
||
| { | ||
| $command = sprintf( | ||
| '%s --headless --disable-gpu --screenshot="%s" http://localhost:8000%s?media=mobile', | ||
| self::CHROME_BIN, | ||
| __DIR__ . '/../' . mt_rand() . '.png', | ||
| $config['slug'], | ||
| array_keys($config['config']['preview_parameters'])[0] | ||
| ); | ||
|
|
||
| exec($command); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we can you Symfony Process to maintain better compatibility between different envs |
||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove second license header