Skip to content

Commit

Permalink
Fix #4588 pm:enable renamed to pm:install (backward compat preserved) (
Browse files Browse the repository at this point in the history
  • Loading branch information
rajeshreeputra committed Apr 15, 2022
1 parent 71dbbc6 commit 3cfabb5
Show file tree
Hide file tree
Showing 27 changed files with 51 additions and 49 deletions.
5 changes: 2 additions & 3 deletions docs/usage.md
Expand Up @@ -15,8 +15,8 @@ Using the --uri option and --root options.

For multi-site installations, use a site alias or the --uri option to target a particular site.

$ drush --uri=http://example.com pm:enable
$ drush --uri=http://example.com pm:install

If you are outside the Composer project and not using a site alias, you need to specify --root and --uri for Drush to locate and bootstrap the right Drupal site.

Site Aliases
Expand All @@ -34,4 +34,3 @@ $ drush sql:sync --structure-tables-key=custom @live @self
```

See [Site aliases](site-aliases.md) for more information.

1 change: 0 additions & 1 deletion src/Commands/LegacyCommands.php
Expand Up @@ -8,7 +8,6 @@ class LegacyCommands extends DrushCommands
* The core:init command was removed. Please edit your .bashrc manually.
*
* @command core:init
* @aliases init
* @hidden
* @obsolete
*/
Expand Down
8 changes: 4 additions & 4 deletions src/Drupal/Commands/pm/PmCommands.php
Expand Up @@ -65,12 +65,12 @@ public function getExtensionListModule(): ModuleExtensionList
/**
* Enable one or more modules.
*
* @command pm:enable
* @command pm:install
* @param $modules A comma delimited list of modules.
* @aliases en,pm-enable
* @aliases in, install, pm-install, en, pm-enable, pm:enable
* @bootstrap root
*/
public function enable(array $modules): void
public function install(array $modules): void
{
$modules = StringUtils::csvToArray($modules);
$todo = $this->addInstallDependencies($modules);
Expand All @@ -97,7 +97,7 @@ public function enable(array $modules): void
/**
* Run requirements checks on the module installation.
*
* @hook validate pm:enable
* @hook validate pm:install
*
* @throws UserAbortException
* @throws MissingDependencyException
Expand Down
6 changes: 5 additions & 1 deletion src/Preflight/Preflight.php
Expand Up @@ -141,7 +141,11 @@ protected function remapCommandAliases(): array
{
return [
'si' => 'site:install',
'en' => 'pm:enable',
'in' => 'pm:install',
'install' => 'pm:install',
'pm-install' => 'pm:install',
'en' => 'pm:install',
'pm-enable' => 'pm:install',
// php was an alias for core-cli which got renamed to php-cli. See https://github.com/drush-ops/drush/issues/3091.
'php' => 'php:cli',
];
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/COVERAGE.txt
@@ -1,6 +1,6 @@
COMMANDS
------------
pm:enable: GOOD. testEnDisUnList().
pm:install: GOOD. testEnDisUnList().
pm:uninstall: GOOD. testEnDisUnList().
pm:list: GOOD. testEnDisUnList().
pm:security: GOOD.
Expand Down Expand Up @@ -38,4 +38,4 @@ state: NONE
ssh: GOOD
topic
watchdog:*: GOOD
user:*: GOOD.
user:*: GOOD.
2 changes: 1 addition & 1 deletion tests/functional/CommandInfoAlterTest.php
Expand Up @@ -19,7 +19,7 @@ public function testCommandInfoAlter()
{
$this->setUpDrupal(1, true);
$this->setupModulesForTests(['woot'], Path::join(__DIR__, '/../fixtures/modules'));
$this->drush('pm-enable', ['woot']);
$this->drush('pm-install', ['woot']);
$this->drush('woot:altered', [], ['help' => true, 'debug' => true]);
$this->assertStringNotContainsString('woot-initial-alias', $this->getOutput());
$this->assertStringContainsString('woot-new-alias', $this->getOutput());
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/ConfigTest.php
Expand Up @@ -21,7 +21,7 @@ public function setup(): void
$this->setUpDrupal(1, true);
// Field module is needed for now for --existing-config. It is not actually
// enabled after testing profile is installed. Its required by file and update though.
$this->drush('pm:enable', ['config, field']);
$this->drush('pm:install', ['config, field']);
}
}

Expand Down Expand Up @@ -126,7 +126,7 @@ public function testConfigImport()
'include' => __DIR__,
];
$this->setupModulesForTests(['woot'], Path::join(__DIR__, '/../fixtures/modules'));
$this->drush('pm-enable', ['woot'], $options);
$this->drush('pm-install', ['woot'], $options);

// Export the configuration.
$this->drush('config:export');
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/ContainerTest.php
Expand Up @@ -26,7 +26,7 @@ public function testContainer()
$this->setupModulesForTests(['woot'], Path::join(__DIR__, '/../fixtures/modules'));

// Enable our module.
$this->drush('pm-enable', ['woot']);
$this->drush('pm-install', ['woot']);

// Set up for a config import with just one small piece.
$this->drush('config-export');
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/DeployHookTest.php
Expand Up @@ -20,7 +20,7 @@ public function testDeployHooks()
'yes' => null,
];
$this->setupModulesForTests(['woot'], Path::join(__DIR__, '/../fixtures/modules'));
$this->drush('pm-enable', ['woot'], $options);
$this->drush('pm-install', ['woot'], $options);

// Run deploy hooks.
$this->drush('deploy:hook', [], $options, null, null, self::EXIT_ERROR);
Expand Down Expand Up @@ -60,7 +60,7 @@ public function testSkipDeployHooks()
{
$this->setUpDrupal(1, true);
$this->setupModulesForTests(['woot'], Path::join(__DIR__, '/../fixtures/modules'));
$this->drush('pm-enable', ['woot'], ['yes' => null]);
$this->drush('pm-install', ['woot'], ['yes' => null]);

$options = [
'format' => 'json'
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/FieldTest.php
Expand Up @@ -17,7 +17,7 @@ public function setup(): void
$this->setUpDrupal(1, true);
// Create a content entity with bundles.
CreateEntityType::createContentEntity($this);
$this->drush('pm-enable', ['text,field_ui,unish_article']);
$this->drush('pm-install', ['text,field_ui,unish_article']);
$this->drush('php:script', ['create_unish_article_bundles'], ['script-path' => Path::join(__DIR__, 'resources')]);
}
}
Expand Down
6 changes: 3 additions & 3 deletions tests/functional/LanguageAddTest.php
Expand Up @@ -17,7 +17,7 @@ protected function setup(): void
parent::setUp();
if (empty($this->getSites())) {
$this->setUpDrupal(1, true);
$this->drush('pm-enable', ['language']);
$this->drush('pm-install', ['language']);
}
}

Expand All @@ -40,7 +40,7 @@ public function testLanguageAddWithTranslations()
$this->markTestSkipped('Devel dev snapshot detected. Incompatible with translation import.');
}

$this->drush('pm-enable', ['language', 'locale', 'dblog']);
$this->drush('pm-install', ['language', 'locale', 'dblog']);
$this->drush('config-set', ['locale.settings', 'translation.import_enabled', true]);

// Setup the interface translation system and prepare a source translation file.
Expand All @@ -54,7 +54,7 @@ public function testLanguageAddWithTranslations()
$this->mkdir($translationDir);
copy($source, Path::join($translationDir, 'drush_empty_module.nl.po'));

$this->drush('pm-enable', ['drush_empty_module']);
$this->drush('pm-install', ['drush_empty_module']);
$this->drush('language-add', ['nl']);

$this->drush('watchdog-show', []);
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/LocaleTest.php
Expand Up @@ -22,7 +22,7 @@ public function setup(): void
if (!$this->getSites()) {
$this->setUpDrupal(1, true);
}
$this->drush('pm:enable', ['language', 'locale']);
$this->drush('pm:install', ['language', 'locale']);
$this->drush('language:add', ['nl'], ['skip-translations' => null]);

$this->sourceFile = Path::join(__DIR__, '/resources/drush_empty_module.nl.po');
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/MulitsiteContainerTest.php
Expand Up @@ -40,7 +40,7 @@ function my_module_cron() {
$options['uri'] = 'dev';
file_put_contents($conf_dir . '/modules/my_module/my_module.info.yml', $info);
file_put_contents($conf_dir . '/modules/my_module/my_module.module', $module);
$this->drush('pm-enable', ['my_module'], $options);
$this->drush('pm-install', ['my_module'], $options);

$this->drush('cron', [], $options);
$this->assertStringContainsString('Message: test', $this->getErrorOutput());
Expand Down
8 changes: 4 additions & 4 deletions tests/functional/PmEnDisUnListInfoTest.php
Expand Up @@ -24,9 +24,9 @@ public function testEnDisUnList()
$out = $this->getOutput();
$this->assertStringContainsString('drush_empty_module', $out);

// Test that pm-enable does not install a module if the install
// Test that pm-install does not install a module if the install
// requirements are not met.
$this->drush('pm-enable', ['drush_empty_module'], [], null, null, self::EXIT_ERROR, null, [
$this->drush('pm-install', ['drush_empty_module'], [], null, null, self::EXIT_ERROR, null, [
'UNISH_FAIL_INSTALL_REQUIREMENTS' => 'drush_empty_module',
]);
$err = $this->getErrorOutput();
Expand All @@ -37,8 +37,8 @@ public function testEnDisUnList()
$out = $this->getOutput();
$this->assertStringContainsString('drush_empty_module', $out);

// Test pm-enable enables a module, and pm-list verifies that.
$this->drush('pm-enable', ['drush_empty_module']);
// Test pm-install enables a module, and pm-list verifies that.
$this->drush('pm-install', ['drush_empty_module']);
$this->drush('pm-list', [], ['status' => 'enabled']);
$out = $this->getOutput();
$this->assertStringContainsString('drush_empty_module', $out);
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/PmEnLocaleImportTest.php
Expand Up @@ -23,7 +23,7 @@ public function testBatchImportTranslations()
$this->setUpDrupal(1, true);
$root = $this->webroot();

$this->drush('pm-enable', ['language', 'locale', 'dblog']);
$this->drush('pm-install', ['language', 'locale', 'dblog']);
$this->drush('config-set', ['locale.settings', 'translation.import_enabled', true]);

// Setup the interface translation system and prepare a source translation file.
Expand All @@ -39,7 +39,7 @@ public function testBatchImportTranslations()

$this->drush('language-add', ['nl']);

$this->drush('pm-enable', ['drush_empty_module']);
$this->drush('pm-install', ['drush_empty_module']);
$this->drush('watchdog-show');
$this->assertStringContainsString('Translations imported:', $this->getSimplifiedOutput());

Expand Down
4 changes: 2 additions & 2 deletions tests/functional/QueueTest.php
Expand Up @@ -23,7 +23,7 @@ public function testRequeueException()

// Enable woot module, which contains a queue worker that throws a
// RequeueException.
$this->drush('pm:enable', ['woot'], [], null, null, self::EXIT_SUCCESS);
$this->drush('pm:install', ['woot'], [], null, null, self::EXIT_SUCCESS);

// Add an item to the queue.
$this->drush('php:script', ['requeue_script'], ['script-path' => __DIR__ . '/resources']);
Expand Down Expand Up @@ -63,7 +63,7 @@ public function testCustomExceptionAndCommands()

// Enable woot module, which contains a queue worker that throws a
// custom exception.
$this->drush('pm:enable', ['woot'], [], null, null, self::EXIT_SUCCESS);
$this->drush('pm:install', ['woot'], [], null, null, self::EXIT_SUCCESS);

// Add a couple of items to the queue.
$this->drush('php:script', ['queue_custom_exception_script'], ['script-path' => __DIR__ . '/resources']);
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/RoleTest.php
Expand Up @@ -22,7 +22,7 @@ public function testRole()
// In D8+, the testing profile has no perms.
// Copy the module to where Drupal expects it.
$this->setupModulesForTests(['user_form_test'], Path::join($this->webroot(), 'core/modules/user/tests/modules'));
$this->drush('pm-enable', ['user_form_test']);
$this->drush('pm-install', ['user_form_test']);

$this->drush('role-list');
$output = $this->getOutput();
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/SqlSyncTest.php
Expand Up @@ -95,7 +95,7 @@ public function localSqlSync()
$mail = "joe.user@myhome.com";

// Add user fields and a test User.
$this->drush('pm-enable', ['field,text,telephone,comment'], $stage_options + ['yes' => null]);
$this->drush('pm-install', ['field,text,telephone,comment'], $stage_options + ['yes' => null]);
$this->drush('php-script', ['user_fields-D8', $name, $mail], $stage_options + ['script-path' => __DIR__ . '/resources',]);

// Copy stage to dev, and then sql:sanitize.
Expand Down
16 changes: 8 additions & 8 deletions tests/functional/UpdateDBTest.php
Expand Up @@ -21,7 +21,7 @@ public function testUpdateDBStatus()
}

$this->setUpDrupal(1, true);
$this->drush('pm:enable', ['drush_empty_module']);
$this->drush('pm:install', ['drush_empty_module']);
$this->drush('updatedb:status');
$err = $this->getErrorOutput();
$this->assertStringContainsString('[success] No database updates required.', $err);
Expand Down Expand Up @@ -71,7 +71,7 @@ public function testFailedUpdate($last_successful_update, $expected_status_repor
'yes' => null,
];
$this->setupModulesForTests(['woot'], Path::join(__DIR__, '/../fixtures/modules'));
$this->drush('pm-enable', ['woot'], $options);
$this->drush('pm-install', ['woot'], $options);

// Force a pending update.
$this->drush('php-script', ['updatedb_script'], ['script-path' => __DIR__ . '/resources']);
Expand Down Expand Up @@ -158,7 +158,7 @@ public function testFailedPostUpdate()
'yes' => null,
];
$this->setupModulesForTests(['woot'], Path::join(__DIR__, '/../fixtures/modules'));
$this->drush('pm-enable', ['woot'], $options);
$this->drush('pm-install', ['woot'], $options);

// Force re-run of woot_update_8104().
$this->drush('php:eval', array('Drupal::service("update.update_hook_registry")->setInstalledVersion("woot", 8103)'), $options);
Expand Down Expand Up @@ -208,7 +208,7 @@ public function testUpdateModuleWithServiceDependency()
'include' => __DIR__,
];
$this->setupModulesForTests(['woot'], Path::join(__DIR__, '/../fixtures/modules'));
$this->drush('pm-enable', ['woot'], $options);
$this->drush('pm-install', ['woot'], $options);

// Force re-run of the post-update woot_post_update_install_drush_empty_module().
$this->forcePostUpdate('woot_post_update_install_drush_empty_module', $options);
Expand Down Expand Up @@ -258,7 +258,7 @@ public function testSuccessfulUpdate()
'yes' => null,
];
$this->setupModulesForTests(['woot'], Path::join(__DIR__, '/../fixtures/modules'));
$this->drush('pm-enable', ['woot'], $options);
$this->drush('pm-install', ['woot'], $options);

// Force re-run of woot_update_8104() which is expected to be completed successfully.
$this->drush('php:eval', array('Drupal::service("update.update_hook_registry")->setInstalledVersion("woot", 8103)'), $options);
Expand Down Expand Up @@ -293,7 +293,7 @@ public function testBatchUpdateLogMessages()
];
$this->setUpDrupal(1, true);
$this->setupModulesForTests(['woot'], Path::join(__DIR__, '/../fixtures/modules'));
$this->drush('pm:enable', ['woot'], $options);
$this->drush('pm:install', ['woot'], $options);

// Force re-run of woot_update_8105().
$this->drush('php:eval', ['Drupal::service("update.update_hook_registry")->setInstalledVersion("woot", 8104)'], $options);
Expand Down Expand Up @@ -340,7 +340,7 @@ public function testEnableModuleViaUpdate()
];
$this->setUpDrupal(1, true);
$this->setupModulesForTests(['woot'], Path::join(__DIR__, '/../fixtures/modules'));
$this->drush('pm:enable', ['woot'], $options);
$this->drush('pm:install', ['woot'], $options);

// Force re-run of woot_update_8106().
$this->drush('php:eval', ['Drupal::service("update.update_hook_registry")->setInstalledVersion("woot", 8105)'], $options);
Expand All @@ -366,7 +366,7 @@ public function testEnableModuleViaPostUpdate()
];
$this->setUpDrupal(1, true);
$this->setupModulesForTests(['woot'], Path::join(__DIR__, '/../fixtures/modules'));
$this->drush('pm:enable', ['woot'], $options);
$this->drush('pm:install', ['woot'], $options);

// Force re-run of woot_post_update_install_taxonomy().
$this->forcePostUpdate('woot_post_update_install_taxonomy', $options);
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/UserTest.php
Expand Up @@ -168,7 +168,7 @@ public function testUserLogin()
public function testUserCancel()
{
CreateEntityType::createContentEntity($this);
$this->drush('pm-enable', ['text,unish_article']);
$this->drush('pm-install', ['text,unish_article']);
$this->drush('php:script', ['create_unish_article_bundles'], ['script-path' => Path::join(__DIR__, 'resources')]);
// Create one unish_article owned by our example user.
$this->drush('php-script', ['create_unish_articles'], ['script-path' => Path::join(__DIR__, 'resources')]);
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/WatchdogTailTest.php
Expand Up @@ -17,7 +17,7 @@ class WatchdogTailTest extends CommandUnishTestCase
public function testWatchdogTail()
{
$this->setUpDrupal(1, true);
$ret = $this->drush('pm-enable', ['dblog']);
$ret = $this->drush('pm-install', ['dblog']);
$this->assertEquals($ret, 0);
$options = [];
$childDrushProcess = $this->drushBackground('watchdog-tail', [], $options + ['simulate' => null]);
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/CoreTest.php
Expand Up @@ -53,7 +53,7 @@ public function testDrupalDirectory()
$output = $this->getOutput();
$this->assertEquals(Path::join($root, $sitewide . '/modules'), $output);

$this->drush('pm-enable', ['drush_empty_module']);
$this->drush('pm-install', ['drush_empty_module']);
$this->drush('theme-enable', ['drush_empty_theme']);

$this->drush('drupal-directory', ['drush_empty_module']);
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/ImageTest.php
Expand Up @@ -11,7 +11,7 @@ class ImageTest extends UnishIntegrationTestCase
{
public function testImage()
{
$this->drush('pm-enable', ['image']);
$this->drush('pm-install', ['image']);
$logo = 'core/themes/bartik/screenshot.png';
$styles_dir = $this->webroot() . '/sites/default/files/styles/';
$thumbnail = $styles_dir . 'thumbnail/public/' . $logo;
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/MigrateRunnerTest.php
Expand Up @@ -20,7 +20,7 @@ protected function setUp(): void
{
parent::setUp();
$this->setupModulesForTests(['woot'], Path::join(__DIR__, '/../fixtures/modules'));
$this->drush('pm:enable', ['migrate', 'node', 'woot']);
$this->drush('pm:install', ['migrate', 'node', 'woot']);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/ModuleGeneratorTest.php
Expand Up @@ -17,7 +17,7 @@ class ModuleGeneratorTest extends UnishIntegrationTestCase
public function testModuleGenerators(): void
{
$this->setupModulesForTests(['woot'], Path::join(__DIR__, '/../fixtures/modules'));
$this->drush('pm:enable', ['woot']);
$this->drush('pm:install', ['woot']);
$this->drush('cc', ['drush']);
$this->drush('generate', ['list']);
$this->assertStringContainsString('woot:example', $this->getOutput());
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/WatchdogTest.php
Expand Up @@ -9,7 +9,7 @@ class WatchdogTest extends UnishIntegrationTestCase
{
public function testWatchdog()
{
$this->drush('pm-enable', ['dblog']);
$this->drush('pm-install', ['dblog']);
$this->drush('watchdog-delete', ['all'], ['yes' => true]);
$output = $this->getErrorOutput();
$this->assertStringContainsString('All watchdog messages have been deleted', $output);
Expand Down

0 comments on commit 3cfabb5

Please sign in to comment.