Skip to content

Commit

Permalink
[#111] Move VigetWP Composer Install to ddev post-start hook
Browse files Browse the repository at this point in the history
  • Loading branch information
bd-viget committed Jul 1, 2024
1 parent bd3cc77 commit dccbda5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 26 deletions.
1 change: 1 addition & 0 deletions .ddev/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ corepack_enable: false
override_config: true
hooks:
post-start:
- composer: install -d /var/www/html/wp-content/mu-plugins/viget-wp
- composer: install -d /var/www/html/wp-content/themes/wp-starter
- exec-host: ddev launch && exit
web_environment:
Expand Down
41 changes: 15 additions & 26 deletions bin/composer-scripts/ProjectEvents/PostInstallScript.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public static function init( Event $event, bool $fromExecute = false ): void {
// Give database population options
self::populateDatabase();
} else {
// Pre-populate Site Info
// Pre-configure the Setup
self::$info = [
'title' => 'WordPress Site Starter',
'description' => 'A project developed by Viget.',
Expand All @@ -101,6 +101,10 @@ public static function init( Event $event, bool $fromExecute = false ): void {
'email' => '[email protected]',
];

// Do not activate Project Plugins
unset( self::$activatePlugins['seo-by-rank-math'] );
unset( self::$activatePlugins['wordfence'] );

// Automatically install WordPress
self::doFreshInstall();
}
Expand All @@ -110,10 +114,10 @@ public static function init( Event $event, bool $fromExecute = false ): void {

// Remove Hello Dolly.
self::deleteCorePlugins();
}

// Run the Viget WP Composer Install
self::vigetWPComposerInstall();
// Show the success message.
self::renderSuccessMessage();
}
}

/**
Expand Down Expand Up @@ -327,9 +331,6 @@ private static function doFreshInstall(): void {

// Configure plugins.
self::configurePlugins();

// Show the success message.
self::renderSuccessMessage();
}

/**
Expand Down Expand Up @@ -574,8 +575,13 @@ private static function activatePlugins(): void {
private static function configurePlugins(): void {
self::writeComment( 'Configuring plugins...' );

self::configureRankMath();
self::configureWordfence();
if( ! empty( self::$activatePlugins['seo-by-rank-math'] ) ) {
self::configureRankMath();
}

if( ! empty( self::$activatePlugins['wordfence'] ) ) {
self::configureWordfence();
}

self::writeInfo( 'Plugins configured.' );
}
Expand Down Expand Up @@ -700,21 +706,4 @@ public static function renderSuccessMessage(): void {

self::writeLine( $success );
}

/**
* Run the Viget WP Composer Installer.
*
* @return void
*/
private static function vigetWPComposerInstall(): void {
self::writeInfo( 'Running Viget WP Composer Install...' );

// Run composer install from the viget-wp directory
$directory = self::translatePath( './wp-content/mu-plugins/viget-wp' );
$cmd = 'composer install -d ' . escapeshellarg( $directory );

self::runCommand( $cmd );

self::writeInfo( 'VigetWP Composer Install complete.' );
}
}

0 comments on commit dccbda5

Please sign in to comment.