[1.0.x] Multisite Easy Commands

Created on 1 May 2023, about 1 year ago
Updated 7 May 2023, about 1 year ago

This module is a custom drush command, which makes it easy for user to select between the sites in their multisite setup.
The module provides a config form to add sites, and fetches and displays all the sites setup in their project.
User can select the site from the list provided in the terminal, he/she don't have to copy or remember the sites to run a long drush command for eg. drush uli --uri=https://example.com.

By using this module user only have to type drush msl uli and it gives all the sites list, which user can select and voila.

Project link

https://www.drupal.org/project/msl →

đŸ“Œ Task
Status

Fixed

Component

module

Created by

đŸ‡®đŸ‡³India sandeepkavalur

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @sandeepkavalur
  • Issue was unassigned.
  • đŸ‡®đŸ‡¹Italy apaderno Brescia, đŸ‡®đŸ‡¹

    Thank you for applying!

    Please read Review process for security advisory coverage: What to expect → for more details and Security advisory coverage application checklist → to understand what reviewers look for. Tips for ensuring a smooth review → gives some hints for a smother review.

    The important notes are the following.

    • If you have not done it yet, you should run phpcs --standard=Drupal,DrupalPractice on the project, which alone fixes most of what reviewers would report.
    • For the time this application is open, only your commits are allowed.
    • The purpose of this application is giving you a new drupal.org role that allows you to opt projects into security advisory coverage, either projects you already created, or projects you will create. The project status won't be changed by this application and no other user will be able to opt projects into security advisory policy.
    • We only accept an application per user. If you change your mind about the project to use for this application, please update the issue summary to give the link to the correct project link and the issue title to contain that project name.

    To the reviewers

    Please read How to review security advisory coverage applications → , What to cover in an application review → , and Drupal.org security advisory coverage application workflow → .
    Reviewers only describe what needs to be changed; they don't provide patches to fix what reported in a review.

  • đŸ‡®đŸ‡³India Rajan Kumar

    1. Fix phpcs isssues.

    There are many "Bad line endings" and comment missing in your project. use phpcs to identify and fix.

    2. Remarks on /src/MSLConfigurationForm.php:

    unused statement use Symfony\Component\HttpFoundation\RedirectResponse;

    3. Remarks on /multisite_easy_commands.info.yml:

    Don't use version: '1.0' from self, it will add by drupal.org

    4. Readme.txt is not following recommendation: see template
    https://www.drupal.org/docs/develop/managing-a-drupalorg-theme-module-or... →

  • Status changed to Needs work about 1 year ago
  • đŸ‡®đŸ‡³India vishal.kadam Mumbai

    1. Fix phpcs issues.

    phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml msl

    FILE: msl/css/style.css
    ----------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ----------------------------------------------------------------------
    3 | ERROR | [x] Expected 1 newline at end of file; 0 found
    ----------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------

    FILE: msl/drush.services.yml
    ----------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ----------------------------------------------------------------------
    6 | ERROR | [x] Expected 1 newline at end of file; 0 found
    ----------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------

    FILE: msl/multisite_easy_commands.info.yml
    --------------------------------------------------------------------------------
    FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
    --------------------------------------------------------------------------------
    1 | WARNING | [ ] Remove "version" from the info file, it will be added by drupal.org packaging automatically
    9 | ERROR | [x] Expected 1 newline at end of file; 0 found
    --------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------

    FILE: msl/multisite_easy_commands.libraries.yml
    -------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -------------------------------------------------------------------------------
    8 | ERROR | [x] Expected 1 newline at end of file; 0 found
    -------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -------------------------------------------------------------------------------

    FILE: msl/multisite_easy_commands.links.menu.yml
    --------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------
    6 | ERROR | [x] Expected 1 newline at end of file; 0 found
    --------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------

    FILE: msl/multisite_easy_commands.module
    ------------------------------------------------------------------------
    FOUND 3 ERRORS AFFECTING 3 LINES
    ------------------------------------------------------------------------
    1 | ERROR | [x] Missing file doc comment
    3 | ERROR | [x] Missing function doc comment
    6 | ERROR | [x] Expected 1 newline at end of file; 0 found
    ------------------------------------------------------------------------
    PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ------------------------------------------------------------------------

    FILE: msl/multisite_easy_commands.routing.yml
    -----------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------------
    7 | ERROR | [x] Expected 1 newline at end of file; 0 found
    -----------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------

    FILE: msl/src/Commands/MultiSiteEasyCommands.php
    --------------------------------------------------------------------------------
    FOUND 85 ERRORS AND 50 WARNINGS AFFECTING 106 LINES
    --------------------------------------------------------------------------------
    3 | ERROR | [x] Namespaced classes, interfaces and traits should not begin with a file doc comment
    11 | WARNING | [x] Unused use statement
    16 | WARNING | [x] Unused use statement
    17 | WARNING | [x] Unused use statement
    18 | WARNING | [x] Unused use statement
    19 | WARNING | [x] Unused use statement
    21 | WARNING | [x] Unused use statement
    22 | WARNING | [x] Unused use statement
    23 | WARNING | [x] Unused use statement
    25 | WARNING | [x] Unused use statement
    26 | WARNING | [x] Unused use statement
    28 | WARNING | [x] Unused use statement
    29 | WARNING | [x] Unused use statement
    31 | WARNING | [x] Unused use statement
    33 | WARNING | [x] Unused use statement
    33 | ERROR | [x] There must be one blank line after the last USE statement; 0 found;
    42 | ERROR | [ ] Comment indentation error, expected only 1 spaces
    47 | WARNING | [ ] Line exceeds 80 characters; contains 87 characters
    57 | ERROR | [x] You must use "/**" style comments for a class comment
    58 | ERROR | [ ] Parameter $options is not described in comment
    63 | ERROR | [ ] Parameter tags must be grouped together in a doc comment
    63 | ERROR | [x] Parameter comment must be on the next line
    64 | WARNING | [ ] Line exceeds 80 characters; contains 92 characters
    65 | ERROR | [x] Parameter comment must end with a full stop
    66 | ERROR | [x] Separate the @param and @option sections by a blank line.
    82 | ERROR | [ ] PHP4 style constructors are not allowed; use "__construct()" instead
    82 | ERROR | [x] Expected 1 blank line before function; 0 found
    82 | ERROR | [ ] The array declaration extends to column 105 (the limit is 80). The array content should be split up over multiple lines
    87 | WARNING | [x] There must be no blank line following an inline comment
    87 | WARNING | [ ] There must be no blank line following an inline comment
    87 | ERROR | [x] Inline comments must start with a capital letter
    88 | ERROR | [x] Whitespace found at end of line
    90 | WARNING | [ ] Line exceeds 80 characters; contains 84 characters
    90 | WARNING | [x] There must be no blank line following an inline comment
    90 | WARNING | [ ] There must be no blank line following an inline comment
    94 | ERROR | [ ] Comment indentation error, expected only 1 spaces
    95 | WARNING | [x] There must be no blank line following an inline comment
    95 | WARNING | [ ] There must be no blank line following an inline comment
    97 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
    99 | WARNING | [ ] Unused variable $addSiteUrllist.
    100 | WARNING | [ ] Unused variable $addSiteNamelist.
    101 | ERROR | [x] Whitespace found at end of line
    105 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
    106 | ERROR | [x] Expected 1 space after IF keyword; 0 found
    106 | ERROR | [x] Expected 1 space after closing parenthesis; found 0
    111 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
    112 | ERROR | [x] Expected 1 space after IF keyword; 0 found
    112 | ERROR | [x] Expected 1 space after closing parenthesis; found 0
    116 | ERROR | [x] list(...) is forbidden, use [...] instead.
    118 | ERROR | [x] Expected newline after closing brace
    125 | ERROR | [x] Expected 1 space after closing parenthesis; found 0
    132 | ERROR | [x] Whitespace found at end of line
    133 | WARNING | [x] There must be no blank line following an inline comment
    133 | WARNING | [ ] There must be no blank line following an inline comment
    136 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
    137 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
    139 | WARNING | [x] There must be no blank line following an inline comment
    139 | WARNING | [ ] There must be no blank line following an inline comment
    144 | WARNING | [ ] Unused variable $my_setting.
    145 | ERROR | [x] Whitespace found at end of line
    148 | WARNING | [x] There must be no blank line following an inline comment
    148 | WARNING | [ ] There must be no blank line following an inline comment
    150 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
    155 | ERROR | [x] Expected newline after closing brace
    159 | ERROR | [x] Expected newline after closing brace
    161 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
    164 | ERROR | [x] Whitespace found at end of line
    165 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
    166 | ERROR | [x] Expected 1 space after IF keyword; 0 found
    167 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
    170 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
    171 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
    171 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "NULL" but found "null"
    172 | ERROR | [x] Expected 1 space after closing parenthesis; found 0
    175 | ERROR | [x] Expected newline after closing brace
    180 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
    186 | ERROR | [x] Missing function doc comment
    187 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
    190 | ERROR | [x] Expected 1 space after IF keyword; 0 found
    190 | ERROR | [x] Expected 1 space after closing parenthesis; found 0
    190 | ERROR | [x] Whitespace found at end of line
    192 | ERROR | [x] list(...) is forbidden, use [...] instead.
    193 | ERROR | [x] Expected newline after closing brace
    195 | ERROR | [x] Whitespace found at end of line
    199 | WARNING | [x] A comma should follow the last multiline array item. Found: $addSiteName
    201 | ERROR | [x] Whitespace found at end of line
    203 | ERROR | [x] Expected 1 space after IF keyword; 0 found
    203 | ERROR | [x] Expected 1 space after closing parenthesis; found 0
    207 | ERROR | [x] Expected newline after closing brace
    212 | WARNING | [x] A comma should follow the last multiline array item. Found: $addSiteName
    215 | ERROR | [x] Expected 1 space after IF keyword; 0 found
    215 | ERROR | [x] Expected 1 space after closing parenthesis; found 0
    223 | ERROR | [x] Missing function doc comment
    224 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
    232 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
    238 | ERROR | [x] Whitespace found at end of line
    240 | ERROR | [x] Expected 1 space after closing parenthesis; found 0
    242 | ERROR | [x] Whitespace found at end of line
    244 | ERROR | [x] Expected newline after closing brace
    246 | ERROR | [x] Whitespace found at end of line
    249 | ERROR | [x] Whitespace found at end of line
    254 | ERROR | [x] Missing function doc comment
    255 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
    259 | WARNING | [ ] Unused variable $index.
    265 | ERROR | [x] Missing function doc comment
    285 | ERROR | [x] Missing function doc comment
    293 | ERROR | [x] Expected newline after closing brace
    300 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
    305 | ERROR | [x] Whitespace found at end of line
    308 | ERROR | [x] Expected 1 space after closing parenthesis; found 0
    310 | ERROR | [x] Expected newline after closing brace
    312 | ERROR | [x] Whitespace found at end of line
    316 | ERROR | [x] Inline comments must start with a capital letter
    316 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
    318 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
    320 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
    320 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "NULL" but found "null"
    321 | ERROR | [x] Expected 1 space after closing parenthesis; found 0
    323 | ERROR | [x] Expected newline after closing brace
    327 | ERROR | [x] Expected newline after closing brace
    327 | ERROR | [x] Whitespace found at end of line
    332 | ERROR | [x] Whitespace found at end of line
    336 | ERROR | [x] Whitespace found at end of line
    345 | WARNING | [x] There must be no blank line following an inline comment
    345 | WARNING | [ ] There must be no blank line following an inline comment
    347 | WARNING | [ ] Line exceeds 80 characters; contains 96 characters
    347 | ERROR | [x] Inline comments must start with a capital letter
    349 | WARNING | [x] There must be no blank line following an inline comment
    349 | WARNING | [ ] There must be no blank line following an inline comment
    349 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
    351 | ERROR | [x] Inline comments must start with a capital letter
    352 | WARNING | [ ] Line exceeds 80 characters; contains 88 characters
    352 | WARNING | [ ] There must be no blank line following an inline comment
    352 | ERROR | [ ] Comment indentation error, expected only 1 spaces
    352 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
    --------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 102 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------

    FILE: msl/src/Form/MSLConfigurationForm.php
    --------------------------------------------------------------------------------
    FOUND 19 ERRORS AND 3 WARNINGS AFFECTING 19 LINES
    --------------------------------------------------------------------------------
    7 | WARNING | [x] Unused use statement
    16 | ERROR | [x] Expected 1 blank line before function; 0 found
    35 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 2
    54 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 2
    55 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 4
    65 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 4
    75 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 4
    85 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 2
    87 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 2
    99 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 2
    101 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 2
    105 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 2
    111 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 2
    112 | ERROR | [x] Inline comments must start with a capital letter
    112 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
    113 | ERROR | [x] Expected 1 blank line after function; 0 found
    130 | WARNING | [x] A comma should follow the last multiline array item. Found: ''
    154 | ERROR | [x] Missing function doc comment
    163 | WARNING | [ ] Line exceeds 80 characters; contains 82 characters
    163 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
    167 | ERROR | [x] Expected 1 newline at end of file; 0 found
    167 | ERROR | [x] The closing brace for the class must have an empty line before it
    --------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 21 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------

    2. Since the project machine name (its short name as indicated in https://www.drupal.org/project/msl → ) is msl the module must contain the msl.module, msl.info.yml, msl.links.menu.yml, msl.routing.yml and msl.libraries.yml files. All the functions (not the methods) implemented by the module must have a name starting with msl_. The namespaces used by the modules need to start with Drupal\msl\.
    The project machine name cannot be changed anymore; those files, all the functions, and the namespaces must be renamed.

    3. Replace README.txt with README.md file and follow the guidelines.

    4. FILE: src/Commands/MultiSiteEasyCommands.php

    Line 126
    MultiSiteEasyCommands::removeSiteFromConfigData();
    Line 131
    MultiSiteEasyCommands::addNewSiteToConfig($options, FALSE);
    Line 162-163

        $sites = MultiSiteEasyCommands::fetchSites($sites_copyfile_path);
        $sites = array_merge($sites, MultiSiteEasyCommands::fetchSitesFromConfig());

    Line 176
    $set_drush_command = MultiSiteEasyCommands::selectSiteFromList($sites, $set_drush_command, $options);
    Line 292
    $selectedOption = MultiSiteEasyCommands::addNewSiteToConfig($options, TRUE);
    Line 309
    $selectedOption = MultiSiteEasyCommands::addNewSiteToConfig($options, TRUE);

    Use self keyword to access a method in the same class.

    Line 41-56

    // /**
    //  * Provides a custom Drush command for my module.
    //  *
    //  * @Plugin(
    //  *   id = "multisite_easy_commands",
    //  *   title = @Translation("My Custom Drush Command"),
    //  *   description = @Translation("Runs a custom Drush command based on user input."),
    //  *   arguments = {
    //  *     "input" = @Drupal\Component\Annotation\Plugin\Argument(
    //  *       type = "string",
    //  *       label = @Translation("Input"),
    //  *       description = @Translation("The input to process.")
    //  *     )
    //  *   }
    //  * )
    //  */

    Line 87-95

        // drush msl "cr" --opt="uri=http://example.com,foo=bar,baz=qux"
        
        // // get config data
        // $value = \Drupal::config('my_module.my_config_item')->get('my_config_value');
    
        // // set config data
        // \Drupal::config('my_module.my_config_item')
        //   ->set('my_config_value', $new_value)
        //   ->save();

    Line 133
    // var_dump($addSiteUrllist);die;

    Line 136
    // $pathToMyModule = \Drupal::service('extension.list.module')->getPath('multisite_easy_commands');

    Line 139
    // $pathToMyModule = drupal_get_path('module', 'multisite_easy_commands');

    Line 146-148

        // $config = ['my_input' => $params];
        // $yaml = Yaml::dump($config);
        // file_put_contents($pathToMyModule, $yaml);

    Line 232
    // var_dump($index, $option);

    Line 256
    // $config->set('sites', NULL)->save();die;

    Line 281
    // var_dump($sites);die;

    Line 287
    // $sites = NULL;

    Line 300
    // var_dump($index, $option);

    Line 336-352

    // * @param mixed[] $params 
    // *   Array of arguments with drush command to be executed.
    // * @param mixed[] $options
    // *   An array of options.
    // * @param mixed[] $dynamic_options
    // *   An array of user-defined options and their values.
    // *   Each key in the array is an option name, and the corresponding value
    // *   is an array of option values.
    // * @param mixed[] $args
    // *   Any additional arguments passed in.
    
    // function myfunc(array $params, array $options, array $dynamic_options = [], array $args = [])
    // Merge the user-defined options into the $options array.
    // $options = array_merge($options, $dynamic_options);
    
    // array of params passing as string
    //   drush mycommand "param1 param2 param3" --opt[foo]=bar --opt[baz]=qux --opt[abc]=def
    

    Remove commented code.

    5. FILE: src/Form/MSLConfigurationForm.php

    Line 32
    // $config->set('sites', NULL)->save();die;
    Line 57
    // '#title' => $this->t('URL'),
    Line 67
    // '#title' => $this->t('Name'),
    Line 112
    // return $form;
    Line 163
    // drupal_set_message($this->t('The configuration options have been saved.'));

    Remove commented code.

  • Status changed to Needs review about 1 year ago
  • đŸ‡®đŸ‡³India sandeepkavalur

    Thank you all for reviews and suggestions.

  • Status changed to Needs work about 1 year ago
  • Status changed to Needs review about 1 year ago
  • đŸ‡®đŸ‡¹Italy apaderno Brescia, đŸ‡®đŸ‡¹
  • đŸ‡®đŸ‡³India vishal.kadam Mumbai

    @sandeepkavalur

    I have reviewed the changes, and they look fine to me.

    Let’s wait for other reviewers to take a look and if everything goes fine, you will get the role.

  • Assigned to apaderno
  • Status changed to RTBC about 1 year ago
  • đŸ‡®đŸ‡¹Italy apaderno Brescia, đŸ‡®đŸ‡¹
        $this->messenger()->addMessage('The configuration options have been saved.');
        parent::submitForm($form, $form_state);
    

    That message is already given by the parent method. (See ConfigFormBase::submitForm().)

      $this->messenger()->addStatus($this->t('The configuration options have been saved.'));
    
  • Status changed to Fixed about 1 year ago
  • đŸ‡®đŸ‡¹Italy apaderno Brescia, đŸ‡®đŸ‡¹

    Thank you for your contribution! I am going to update your account.

    These are some recommended readings to help with excellent maintainership:

    You can find more contributors chatting on the Slack → #contribute channel. So, come hang out and stay involved → .
    Thank you, also, for your patience with the review process.
    Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review → . I encourage you to learn more about that process and join the group of reviewers.

    I thank all the reviewers.

  • đŸ‡®đŸ‡³India sandeepkavalur

    Thank you @apaderno, also thank you @vishal.kadam and @Rajan Kumar for your time and effort in this review process.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.69.0 2024