Skip to content
Snippets Groups Projects
Commit e7d04ba7 authored by Grzegorz Rola's avatar Grzegorz Rola
Browse files

Merge branch 'feature/no-dev' into 'main'

Feature/no dev

See merge request !5
parents be815c69 d3972ea1
No related branches found
No related tags found
1 merge request!5Feature/no dev
Pipeline #11503 passed with warnings
## [1.1.0] - 2021-08-16
### Added
- no-dev option handling
## [1.0.2] - 2021-08-12
### Added
- Popup
......
......@@ -82,7 +82,9 @@ class Plugin implements PluginInterface, Capable, EventSubscriberInterface {
* @param Event $event
*/
public function generateReminder(Event $event) {
passthru("composer prepare-activation-reminder" );
global $argv;
$arg = in_array( '--no-dev', $argv, true ) ? '--no-dev' : '';
passthru("composer prepare-activation-reminder $arg" );
}
}
......@@ -19,7 +19,8 @@ class PrepareActivationReminderCommand extends BaseCommand
{
$this
->setName('prepare-activation-reminder')
->setDescription('Prepares activation reminder for WP Desk plugin.');
->setDescription('Prepares activation reminder for WP Desk plugin.')
->addOption( 'no-dev' );
}
/**
......@@ -54,11 +55,24 @@ class PrepareActivationReminderCommand extends BaseCommand
$this->prepare_class( $random_class . $random_letter, $target_file, $popup_javascript_file, $popup_css_file, $settings );
}
$this->regenerate_autoload( $target_file );
$this->regenerate_autoload( $target_file, $input );
$output->writeln( "Activation reminder created." );
}
private function create_or_get_target_file_name( array $class_map, $random_class, $random_letter ) {
$target_file_store = 'vendor/wpdesk/wp-wpdesk-activation-reminder/target-file';
if ( ! file_exists( $target_file_store ) ) {
$target_file = $class_map[ $random_class ];
$target_file = str_replace( '.php', $random_letter . '.php', $target_file );
$target_file = str_replace( getcwd() . '/vendor/composer/../../', '', $target_file );
file_put_contents( $target_file_store, $target_file );
}
return file_get_contents( $target_file_store );
}
private function create_or_get_target_file_name( array $class_map, $random_class, $random_letter ) {
$target_file_store = 'vendor/wpdesk/wp-wpdesk-activation-reminder/target-file';
if ( ! file_exists( $target_file_store ) ) {
......@@ -74,8 +88,9 @@ class PrepareActivationReminderCommand extends BaseCommand
/**
* @param string $class_file
* @param InputInterface $input
*/
private function regenerate_autoload( $class_file ) {
private function regenerate_autoload( $class_file, InputInterface $input ) {
$composer = $this->getComposer();
$config = $composer->getConfig();
$localRepo = $composer->getRepositoryManager()->getLocalRepository();
......@@ -88,7 +103,7 @@ class PrepareActivationReminderCommand extends BaseCommand
$autoload['files'][] = $class_file;
$package->setAutoload( $autoload );
$composer->getAutoloadGenerator()->setDevMode( true );
$composer->getAutoloadGenerator()->setDevMode( ! $input->getOption( 'no-dev' ) );
$composer->getAutoloadGenerator()->dump( $config, $localRepo, $package, $installationManager, 'composer', $optimize );
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment