Skip to content

Commit

Permalink
Revert "Revert "Added flags to static deploy command to skip filetype…
Browse files Browse the repository at this point in the history
…s (js, css, less, images, fonts...) and filter by theme""

This reverts commit 04ebbe796c2a11608581fecdf4d9b6645e19d2e1.
  • Loading branch information
Denis Ristic committed Apr 25, 2016
1 parent e60afa2 commit 8216e12
Show file tree
Hide file tree
Showing 2 changed files with 266 additions and 28 deletions.
137 changes: 135 additions & 2 deletions app/code/Magento/Deploy/Console/Command/DeployStaticContentCommand.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,51 @@ class DeployStaticContentCommand extends Command
*/
const LANGUAGE_OPTION = 'languages';

/**
* Key for javascript option
*/
const JAVASCRIPT_OPTION = 'no-javascript';

/**
* Key for css option
*/
const CSS_OPTION = 'no-css';

/**
* Key for less option
*/
const LESS_OPTION = 'no-less';

/**
* Key for images option
*/
const IMAGES_OPTION = 'no-images';

/**
* Key for fonts option
*/
const FONTS_OPTION = 'no-fonts';

/**
* Key for misc option
*/
const MISC_OPTION = 'no-misc';

/**
* Key for html option
*/
const HTML_OPTION = 'no-html';

/**
* Key for html option
*/
const HTML_MINIFY_OPTION = 'no-html-minify';

/**
* Key for themes option
*/
const THEMES_OPTION = 'themes';

/**
* @var Locale
*/
Expand Down Expand Up @@ -84,13 +129,68 @@ protected function configure()
InputOption::VALUE_NONE,
'If specified, then no files will be actually deployed.'
),
new InputOption(
self::JAVASCRIPT_OPTION,
'',
InputOption::VALUE_NONE,
'If specified, no JavaScript will be deployed.'
),
new InputOption(
self::CSS_OPTION,
'',
InputOption::VALUE_NONE,
'If specified, no CSS will be deployed.'
),
new InputOption(
self::LESS_OPTION,
'',
InputOption::VALUE_NONE,
'If specified, no LESS will be deployed.'
),
new InputOption(
self::IMAGES_OPTION,
'',
InputOption::VALUE_NONE,
'If specified, no images will be deployed.'
),
new InputOption(
self::FONTS_OPTION,
'',
InputOption::VALUE_NONE,
'If specified, no font files will be deployed.'
),
new InputOption(
self::HTML_OPTION,
'',
InputOption::VALUE_NONE,
'If specified, no html files will be deployed.'
),
new InputOption(
self::MISC_OPTION,
'',
InputOption::VALUE_NONE,
'If specified, no miscellaneous files will be deployed.'
),
new InputOption(
self::HTML_MINIFY_OPTION,
'',
InputOption::VALUE_NONE,
'If specified, just html will not be minified and actually deployed.'
),
new InputOption(
self::THEMES_OPTION,
'-t',
InputOption::VALUE_IS_ARRAY + InputOption::VALUE_OPTIONAL,
'If specified, just specific themes will be actually deployed.'
),
new InputArgument(
self::LANGUAGE_OPTION,
InputArgument::IS_ARRAY,
'List of languages you want the tool populate files for.',
['en_US']
),
]);

parent::configure();
}

Expand All @@ -114,10 +214,43 @@ protected function execute(InputInterface $input, OutputInterface $output)
// run the deployment logic
$filesUtil = $this->objectManager->create(Files::class);

$mageThemes = [];
$files = $filesUtil->getStaticPreProcessingFiles();
foreach ($files as $info) {
list(, $themePath) = $info;
if ($themePath && !in_array($themePath, $mageThemes)) {
$mageThemes[] = $themePath;
}
}

$themes = $input->getOption(self::THEMES_OPTION);

foreach ($themes as $theme) {

if ($theme != 'all' && !in_array($theme, $mageThemes)) {
throw new \InvalidArgumentException(
$theme . ' argument has invalid value, avalilable areas are: ' . implode(', ', $mageThemes)
);
}
}

$deployer = $this->objectManager->create(
'Magento\Deploy\Model\Deployer',
['filesUtil' => $filesUtil, 'output' => $output, 'isDryRun' => $options[self::DRY_RUN_OPTION]]
[
'filesUtil' => $filesUtil,
'output' => $output,
'isDryRun' => $options[self::DRY_RUN_OPTION],
'isJavaScript' => $options[self::JAVASCRIPT_OPTION],
'isCss' => $options[self::CSS_OPTION],
'isLess' => $options[self::LESS_OPTION],
'isImages' => $options[self::IMAGES_OPTION],
'isFonts' => $options[self::FONTS_OPTION],
'isHtml' => $options[self::HTML_OPTION],
'isMisc' => $options[self::MISC_OPTION],
'isHtmlMinify' => $options[self::HTML_MINIFY_OPTION]
]
);
$deployer->deploy($this->objectManagerFactory, $languages);

$deployer->deploy($this->objectManagerFactory, $languages, $themes);
}
}
Loading

0 comments on commit 8216e12

Please sign in to comment.