Skip to content

Commit

Permalink
Merge pull request #39 from alleyinteractive/specify-dev-version
Browse files Browse the repository at this point in the history
Adding support for installing a specific version of Mantle via the command
  • Loading branch information
srtfisher authored Aug 3, 2023
2 parents df9c422 + a308e78 commit 8f24fa7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion bin/mantle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if ( file_exists( __DIR__ . '/../../../autoload.php' ) ) {
require __DIR__ . '/../vendor/autoload.php';
}

$app = new Symfony\Component\Console\Application( 'Mantle Installer', '1.0.3' );
$app = new Symfony\Component\Console\Application( 'Mantle Installer', '1.0.4' );
$app->add( new Mantle\Installer\Console\Install_Command() );

$app->run();
9 changes: 5 additions & 4 deletions src/class-install-command.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ protected function configure() {
->addOption( 'install', 'i', InputOption::VALUE_NONE, 'Install WordPress in the current location if it doesn\'t exist.' )
->addOption( 'no-must-use', 'no-mu', InputOption::VALUE_OPTIONAL, 'Don\'t load Mantle as a must-use plugin.', false )
->addOption( 'dev', 'd', InputOption::VALUE_NONE, 'Setup mantle for development on the framework.' )
->addOption( 'setup-dev', null, InputOption::VALUE_NONE, '(Legacy) setup mantle for development on the framework.' );
->addOption( 'mantle-version', null, InputOption::VALUE_OPTIONAL, 'Version of alleyinteractive/mantle to install.', 'latest' );
}

/**
Expand Down Expand Up @@ -270,14 +270,15 @@ protected function install_mantle( string $dir, InputInterface $input, OutputInt
throw new RuntimeException( "Directory is not empty: [{$mantle_dir}]" );
}

$version = $input->getOption( 'mantle-version' ) ? ':' . $input->getOption( 'mantle-version' ) : '';
$composer = $this->find_composer();
$commands = [
$composer . " create-project alleyinteractive/mantle {$mantle_dir} --remove-vcs --stability=dev --no-interaction --no-scripts",
$composer . " create-project alleyinteractive/mantle{$version} {$mantle_dir} --remove-vcs --stability=dev --no-interaction --no-scripts",
"rm -rf {$mantle_dir}/docs",
];

// Setup the application for local development on the framework.
if ( $input->getOption( 'dev' ) || $input->getOption( 'setup-dev' ) ) {
if ( $input->getOption( 'dev' ) ) {
if ( is_dir( $framework_dir ) && file_exists( "{$framework_dir}/composer.json" ) ) {
throw new RuntimeException( "Mantle Framework is already installed: [{$framework_dir}'" );
}
Expand Down Expand Up @@ -305,7 +306,7 @@ protected function install_mantle( string $dir, InputInterface $input, OutputInt

$output->writeln( "Mantle installed successfully at <fg=yellow>{$mantle_dir}</>." );

if ( $input->getOption( 'setup-dev' ) ) {
if ( $input->getOption( 'dev' ) ) {
$output->writeln( "Mantle Framework installed successfully at <fg=yellow>{$framework_dir}</>." );
}

Expand Down

0 comments on commit 8f24fa7

Please sign in to comment.