Skip to content
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

Static deploy flags #4294

Merged
merged 17 commits into from
Aug 17, 2016
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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