Skip to content

Commit

Permalink
Merge pull request #4 from alleyinteractive/feature/allow-dev-install
Browse files Browse the repository at this point in the history
  • Loading branch information
srtfisher authored Dec 28, 2020
2 parents ac4800e + f17ff91 commit 73842db
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 42 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Coding Standards

on:
pull_request:
schedule:
- cron: '0 0 * * *'

jobs:
tests:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
php: [7.4]
name: PHP ${{ matrix.php }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Get Composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Set up Composer caching
uses: actions/cache@v2
env:
cache-name: cache-composer-dependencies
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ matrix.php }}-composer-
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd
tools: composer:v2
coverage: none
- name: Validate Composer
run: composer validate --strict
- name: Install dependencies
uses: nick-invision/retry@v1
with:
timeout_minutes: 5
max_attempts: 5
command: composer install
- name: Run phpcs
run: composer run phpcs
45 changes: 45 additions & 0 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Testing Suite

on:
pull_request:
schedule:
- cron: '0 0 * * *'

jobs:
tests:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
php: [7.3, 7.4]
name: PHP ${{ matrix.php }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Get Composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Set up Composer caching
uses: actions/cache@v2
env:
cache-name: cache-composer-dependencies
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ matrix.php }}-composer-
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd
tools: composer:v2
coverage: none
- name: Install dependencies
uses: nick-invision/retry@v1
with:
timeout_minutes: 5
max_attempts: 5
command: composer install
- name: Run phpunit
run: composer run phpunit
38 changes: 0 additions & 38 deletions .travis.yml

This file was deleted.

3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Mantle Installer

Documentation can be found inside the [Mantle documentation](https://mantle.alley.co/).

![Testing Suite](https://github.com/alleyinteractive/mantle-installer/workflows/Testing%20Suite/badge.svg)
![Coding Standards](https://github.com/alleyinteractive/mantle-installer/workflows/Coding%20Standards/badge.svg)
29 changes: 25 additions & 4 deletions src/class-install-command.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ protected function configure() {
->addOption( 'dev', null, InputOption::VALUE_NONE, 'Installs the latest "development" release' )
->addOption( 'force', 'f', InputOption::VALUE_NONE, 'Install even if the directory already exists' )
->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( 'no-must-use', 'no-mu', InputOption::VALUE_OPTIONAL, 'Don\'t load Mantle as a must-use plugin.', false )
->addOption( 'setup-dev', null, InputOption::VALUE_NONE, 'Setup mantle for development on the framework.' );
}

/**
Expand Down Expand Up @@ -96,7 +97,7 @@ protected function get_wordpress_root( InputInterface $input, OutputInterface $o

// Bail if the folder already exists.
if ( $name && is_dir( $name ) && ! $input->getOption( 'force' ) ) {
$style->error( 'Directory already exists: ' . $abspath );
$style->error( "Directory already exists: [{$abspath}] Use --force to override." );
return null;
}

Expand Down Expand Up @@ -229,8 +230,9 @@ function ( $type, $line ) use ( $output ) {
protected function install_mantle( string $dir, InputInterface $input, OutputInterface $output ) {
$wp_content = $dir . '/wp-content';

$name = $input->getArgument( 'name' )[0] ?? 'mantle';
$mantle_dir = "{$wp_content}/plugins/{$name}";
$name = $input->getArgument( 'name' )[0] ?? 'mantle';
$mantle_dir = "{$wp_content}/plugins/{$name}";
$framework_dir = "{$wp_content}/plugins/{$name}-framework";

// Check if Mantle exists at the current location.
if ( is_dir( $mantle_dir ) && file_exists( $mantle_dir . '/composer.json' ) ) {
Expand All @@ -243,6 +245,21 @@ protected function install_mantle( string $dir, InputInterface $input, OutputInt
"rm -rf {$mantle_dir}/docs",
];

// Setup the application for local development on the framework.
if ( $input->getOption( 'setup-dev' ) ) {
if ( is_dir( $framework_dir ) && file_exists( "{$framework_dir}/composer.json" ) ) {
throw new RuntimeException( "Mantle Framework is already installed: [{$framework_dir}'" );
}

$commands = [
"git clone git@github.com:alleyinteractive/mantle-framework.git {$framework_dir}",
"cd {$framework_dir} && composer install",
"git clone git@github.com:alleyinteractive/mantle.git {$mantle_dir}",
"cd {$mantle_dir} && composer config repositories.mantle-framework '{\"type\": \"path\", \"url\": \"../{$name}-framework\", \"options\": {\"symlink\": true}}' --file composer.json",
"cd {$mantle_dir} && composer install --no-scripts",
];
}

$output->writeln( 'Installing Mantle...' );

$process = $this->run_commands( $commands, $input, $output );
Expand All @@ -253,6 +270,10 @@ protected function install_mantle( string $dir, InputInterface $input, OutputInt

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

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

// Add Mantle as a must-use plugin.
if ( false === $input->getOption( 'no-must-use' ) ) {
$mu_plugins = "{$wp_content}/mu-plugins";
Expand Down

0 comments on commit 73842db

Please sign in to comment.