Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for installing a specific version of Mantle via the command #39

Merged
merged 4 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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