DeployStaticOptions.php 7.9 KB
Newer Older
Ketan's avatar
Ketan committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308
<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

namespace Magento\Deploy\Console;

use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;

/**
 * Static Content Deployment Options helper
 *
 * This class contains the list options and their related constants,
 * which can be used for static content deployment CLI command
 */
class DeployStaticOptions
{
    /**
     * Key for area option
     */
    const AREA = 'area';

    /**
     * Key for exclude area option
     */
    const EXCLUDE_AREA = 'exclude-area';

    /**
     * Key for theme option
     */
    const THEME = 'theme';

    /**
     * Key for exclude theme option
     */
    const EXCLUDE_THEME = 'exclude-theme';

    /**
     * Key for languages parameter
     */
    const LANGUAGE = 'language';

    /**
     * Key for exclude languages parameter
     */
    const EXCLUDE_LANGUAGE = 'exclude-language';

    /**
     * Use specific deployment strategy
     */
    const STRATEGY = 'strategy';

    /**
     * Key for jobs option
     */
    const JOBS_AMOUNT = 'jobs';

    /**
     * Force run of static deploy
     */
    const FORCE_RUN = 'force';

    /**
     * Symlink locale if it not customized
     */
    const SYMLINK_LOCALE = 'symlink-locale';

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

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

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

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

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

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

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

    /**
     * Key for dry-run option
     *
     * @deprecated since 2.2.0
     */
    const DRY_RUN = 'dry-run';

    /**
     * Key for less option
     *
     * @deprecated since 2.2.0
     */
    const NO_LESS = 'no-less';

    /**
     * Default jobs amount
     */
    const DEFAULT_JOBS_AMOUNT = 0;

    /**
     * Key for languages parameter
     */
    const LANGUAGES_ARGUMENT = 'languages';

    /**
     * Static content version
     */
    const CONTENT_VERSION = 'content-version';

    /**
     * Key for refresh content version only mode
     */
    const REFRESH_CONTENT_VERSION_ONLY = 'refresh-content-version-only';

    /**
     * Deploy static command options list
     *
     * @return array
     */
    public function getOptionsList()
    {
        return array_merge($this->getBasicOptions(), $this->getSkipOptions());
    }

    /**
     * Basic options
     *
     * @return array
     */
    private function getBasicOptions()
    {
        return [
            new InputOption(
                self::FORCE_RUN,
                '-f',
                InputOption::VALUE_NONE,
                'Deploy files in any mode.'
            ),
            new InputOption(
                self::STRATEGY,
                '-s',
                InputOption::VALUE_OPTIONAL,
                'Deploy files using specified strategy.',
                'quick'
            ),
            new InputOption(
                self::AREA,
                '-a',
                InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL,
                'Generate files only for the specified areas.',
                ['all']
            ),
            new InputOption(
                self::EXCLUDE_AREA,
                null,
                InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL,
                'Do not generate files for the specified areas.',
                ['none']
            ),
            new InputOption(
                self::THEME,
                '-t',
                InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL,
                'Generate static view files for only the specified themes.',
                ['all']
            ),
            new InputOption(
                self::EXCLUDE_THEME,
                null,
                InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL,
                'Do not generate files for the specified themes.',
                ['none']
            ),
            new InputOption(
                self::LANGUAGE,
                '-l',
                InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL,
                'Generate files only for the specified languages.',
                ['all']
            ),
            new InputOption(
                self::EXCLUDE_LANGUAGE,
                null,
                InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL,
                'Do not generate files for the specified languages.',
                ['none']
            ),
            new InputOption(
                self::JOBS_AMOUNT,
                '-j',
                InputOption::VALUE_OPTIONAL,
                'Enable parallel processing using the specified number of jobs.',
                self::DEFAULT_JOBS_AMOUNT
            ),
            new InputOption(
                self::SYMLINK_LOCALE,
                null,
                InputOption::VALUE_NONE,
                'Create symlinks for the files of those locales, which are passed for deployment, '
                . 'but have no customizations.'
            ),
            new InputOption(
                self::CONTENT_VERSION,
                null,
                InputArgument::OPTIONAL,
                'Custom version of static content can be used if running deployment on multiple nodes '
                . 'to ensure that static content version is identical and caching works properly.'
            ),
            new InputOption(
                self::REFRESH_CONTENT_VERSION_ONLY,
                null,
                InputOption::VALUE_NONE,
                'Refreshing the version of static content only can be used to refresh static content '
                . 'in browser cache and CDN cache.'
            ),
            new InputArgument(
                self::LANGUAGES_ARGUMENT,
                InputArgument::IS_ARRAY,
                'Space-separated list of ISO-639 language codes for which to output static view files.'
            ),
        ];
    }

    /**
     * Additional options
     *
     * Used to re-deploy specific types of static files
     *
     * @return array
     */
    private function getSkipOptions()
    {
        return [
            new InputOption(
                self::NO_JAVASCRIPT,
                null,
                InputOption::VALUE_NONE,
                'Do not deploy JavaScript files.'
            ),
            new InputOption(
                self::NO_CSS,
                null,
                InputOption::VALUE_NONE,
                'Do not deploy CSS files.'
            ),
            new InputOption(
                self::NO_LESS,
                null,
                InputOption::VALUE_NONE,
                'Do not deploy LESS files.'
            ),
            new InputOption(
                self::NO_IMAGES,
                null,
                InputOption::VALUE_NONE,
                'Do not deploy images.'
            ),
            new InputOption(
                self::NO_FONTS,
                null,
                InputOption::VALUE_NONE,
                'Do not deploy font files.'
            ),
            new InputOption(
                self::NO_HTML,
                null,
                InputOption::VALUE_NONE,
                'Do not deploy HTML files.'
            ),
            new InputOption(
                self::NO_MISC,
                null,
                InputOption::VALUE_NONE,
                'Do not deploy files of other types (.md, .jbf, .csv, etc.).'
            ),
            new InputOption(
                self::NO_HTML_MINIFY,
                null,
                InputOption::VALUE_NONE,
                'Do not minify HTML files.'
            )
        ];
    }
}