Skip to content
This repository has been archived by the owner on Apr 24, 2020. It is now read-only.

Commit

Permalink
Merge branch 'release/1.0.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
justb3a committed Jun 16, 2019
2 parents c601a20 + e7e8a0c commit 2423f35
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 46 deletions.
2 changes: 1 addition & 1 deletion README.md
@@ -1,7 +1,7 @@
# wireshell
**ProcessWire command-line companion**

Version 1.0.5, compatibility: ProcessWire 3.x
Version 1.0.6, compatibility: ProcessWire 3.x

A command-line interface for CMS/CMF [ProcessWire](https://processwire.com) based on the Symfony Console component.
Can be easily extended through ProcessWire's ability of being bootstrapped into other applications, its great [API](https://processwire.com/api/) and
Expand Down
2 changes: 1 addition & 1 deletion app/wireshell.php
Expand Up @@ -49,7 +49,7 @@
require __DIR__.'/../vendor/autoload.php';
}

$app = new Application('wireshell - An extendable ProcessWire CLI', '1.0.3');
$app = new Application('wireshell - An extendable ProcessWire CLI', '1.0.6');

$app->add(new UserCreateCommand());
$app->add(new UserUpdateCommand());
Expand Down
6 changes: 5 additions & 1 deletion docs/changelog.md
Expand Up @@ -4,9 +4,13 @@ Dates using [ISO 8601 Format](http://www.iso.org/iso/iso8601) (YYYY-MM-DD).

Check whether the latest build has passed: [Builds | Read the Docs](https://readthedocs.org/projects/wireshell/builds/)

**1.0.6** (2019-06-16)

- Updates `new` and `upgrade` command, adds option to install the latest dev version using `--dev` [Issue #69](https://github.com/wireshell/wireshell/issues/69)

**1.0.5** (2019-02-14)

- Update Documentation, increase mkdocs version
- Updates Documentation, increase mkdocs version

**1.0.4** (2019-02-13)

Expand Down
2 changes: 2 additions & 0 deletions docs/commands/common.md
Expand Up @@ -33,6 +33,7 @@ $ wireshell new {directory}*
--profile : Default site profile: `path/to/profile.zip` OR one of `beginner, blank, classic, default, languages`
--src : Path to pre-downloaded folder, zip or tgz: `path/to/src`
--sha : Download specific commit
--dev : Download latest develeopment version
--no-install : Disable installation
--v : Increase the verbosity of messages
```
Expand Down Expand Up @@ -90,6 +91,7 @@ $ wireshell upgrade

```sh
--sha : Download specific commit
--dev : Download latest develeopment version
--check : Just check for core upgrades.
--download : Just download core upgrades.
```
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Expand Up @@ -2,7 +2,7 @@

**ProcessWire command-line companion**

Version 1.0.5, compatibility: ProcessWire 3.x
Version 1.0.6, compatibility: ProcessWire 3.x

A command-line interface for CMS/CMF [ProcessWire](https://processwire.com) based on the Symfony Console component.
Can be easily extended through ProcessWire's ability of being bootstrapped into other applications, its great [API](https://processwire.com/api/) and
Expand Down
25 changes: 8 additions & 17 deletions src/Commands/Common/NewCommand.php
@@ -1,6 +1,5 @@
<?php namespace Wireshell\Commands\Common;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
Expand All @@ -13,7 +12,6 @@
use Wireshell\Helpers\Downloader;
use Wireshell\Helpers\Installer;
use Wireshell\Helpers\PwConnector;
use Wireshell\Helpers\WsTools as Tools;
use Distill\Distill;

/**
Expand All @@ -32,7 +30,7 @@
* @author Tabea David
*
*/
class NewCommand extends Command {
class NewCommand extends PWConnector {

/**
* @var Filesystem
Expand All @@ -44,7 +42,6 @@ class NewCommand extends Command {
private $compressedFilePath;
private $requirementsErrors = array();
private $installer;
private $tools;

/**
* @field array default config values
Expand All @@ -69,11 +66,6 @@ class NewCommand extends Command {
'color' => 'classic',
);

/**
* @var OutputInterface
*/
private $output;

/**
* Configures the current command.
*/
Expand All @@ -100,6 +92,7 @@ protected function configure() {
->addOption('profile', null, InputOption::VALUE_REQUIRED, 'Default site profile: `path/to/profile.zip` OR one of `beginner, blank, classic, default, languages`')
->addOption('src', null, InputOption::VALUE_REQUIRED, 'Path to pre-downloaded folder, zip or tgz: `path/to/src`')
->addOption('sha', null, InputOption::VALUE_REQUIRED, 'Download specific commit')
->addOption('dev', null, InputOption::VALUE_NONE, 'Download latest develeopment version')
->addOption('no-install', null, InputOption::VALUE_NONE, 'Disable installation')
->addOption('v', null, InputOption::VALUE_NONE, 'verbose');
}
Expand All @@ -110,8 +103,7 @@ protected function configure() {
* @return int|null|void
*/
protected function execute(InputInterface $input, OutputInterface $output) {
$this->input = $input;
$this->output = $output;
$this->init($input, $output, false);
$this->fs = new Filesystem();
$this->projectDir = $this->getDirectory();
$this->projectName = basename($this->projectDir);
Expand All @@ -125,8 +117,7 @@ protected function execute(InputInterface $input, OutputInterface $output) {
$logger = new Logger('name');
$logger->pushHandler(new StreamHandler("php://output"));
$this->installer = new Installer($logger, $this->projectDir, $this->verbose);
$this->tools = new Tools($output);
$this->version = PwConnector::getVersion();
$this->version = $this->getVersion();
$this->helper = $this->getHelper('question');

try {
Expand Down Expand Up @@ -169,7 +160,7 @@ protected function execute(InputInterface $input, OutputInterface $output) {
}

$this->defaults['timezone'] = $this->ask('timezone', 'Please enter the timezone', 'Europe/Berlin', false, timezone_identifiers_list());
$httpHosts = $this->ask('httpHosts', 'Please enter the hostname without `www.`', 'pw.dev');
$httpHosts = $this->ask('httpHosts', 'Please enter the hostname without `www.`', 'pw.local');
$this->defaults['httpHosts'] = $httpHosts . "\n" . "www." . $httpHosts;
$this->defaults['username'] = $this->ask('username', 'Please enter admin user name', 'admin');
$this->defaults['userpass'] = $this->ask('userpass', 'Please enter admin password', 'password', true);
Expand Down Expand Up @@ -320,9 +311,9 @@ private function getDirectory() {
* @return string
*/
private function getZipURL() {
$targetBranch = $this->input->getOption('sha') ? $this->input->getOption('sha') : PwConnector::BRANCH_MASTER;
$branch = str_replace('{branch}', $targetBranch, PwConnector::zipURL);
$check = str_replace('{branch}', $targetBranch, PwConnector::versionURL);
$targetBranch = $this->determineBranch();
$branch = str_replace('{branch}', $targetBranch, self::zipURL);
$check = str_replace('{branch}', $targetBranch, self::versionURL);

try {
$ch = curl_init($check);
Expand Down
8 changes: 6 additions & 2 deletions src/Commands/Common/StatusCommand.php
Expand Up @@ -76,9 +76,13 @@ protected function getPWStatus($showPass) {
$on = $this->tools->writeInfo('On', false);
$off = $this->tools->writeComment('Off', false);
$none = $this->tools->writeComment('None', false);

$version = $config->version;
$latestVersion = parent::getVersion();
$latestVersion = parent::getVersion(); // master

if (version_compare($version, $latestVersion, '>')) {
$latestVersion = parent::getVersion('', self::BRANCH_DEV); // dev
$version .= ' ' . self::BRANCH_DEV;
}

if ($version !== $latestVersion) {
$version .= ' ' . $this->tools->writeMark("(upgrade available: $latestVersion)", false);
Expand Down
1 change: 1 addition & 0 deletions src/Commands/Common/UpgradeCommand.php
Expand Up @@ -46,6 +46,7 @@ protected function configure() {
->setName('upgrade')
->setDescription('Checks for core upgrades.')
->addOption('sha', null, InputOption::VALUE_REQUIRED, 'Download specific commit')
->addOption('dev', null, InputOption::VALUE_NONE, 'Download latest develeopment version')
->addOption('check', null, InputOption::VALUE_NONE, 'Just check for core upgrades.')
->addOption('download', null, InputOption::VALUE_NONE, 'Just download core upgrades.');
}
Expand Down
53 changes: 36 additions & 17 deletions src/Helpers/PwConnector.php
Expand Up @@ -23,6 +23,7 @@ abstract class PwConnector extends SymfonyCommand {
const versionURL = 'https://raw.githubusercontent.com/processwire/processwire/{branch}/wire/core/ProcessWire.php';
const zipURL = 'https://github.com/processwire/processwire/archive/{branch}.zip';
const BRANCH_MASTER = 'master';
const BRANCH_DEV = 'dev';
const USER_PAGE_ID = '29';
const ROLE_PAGE_ID = '30';

Expand All @@ -40,12 +41,16 @@ abstract class PwConnector extends SymfonyCommand {
*
* @param InputInterface $input
* @param OutputInterface $output
* @param Boolean $checkForPW
*/
public function init(InputInterface $input, OutputInterface $output) {
public function init(InputInterface $input, OutputInterface $output, $checkForPW = true) {
$this
->setInput($input)
->setOutput($output)
->bootstrapProcessWire();
->setOutput($output);

if ($checkForPW) {
$this->bootstrapProcessWire();
}
}

/**
Expand Down Expand Up @@ -133,8 +138,14 @@ protected function getModuleDirectory() {
/**
* Determine branch
*/
protected function determineBranch() {
return $this->input->getOption('sha') ? $this->input->getOption('sha') : self::BRANCH_MASTER;
public function determineBranch() {
$branch = self::BRANCH_MASTER;
if ($this->input->getOption('dev')) {
$branch = self::BRANCH_DEV;
} elseif ($this->input->getOption('sha')) {
$branch = $this->input->getOption('sha');
}
return $branch;
}

/**
Expand All @@ -144,16 +155,21 @@ protected function checkForCoreUpgrades() {
$config = \ProcessWire\wire('config');
$targetBranch = $this->determineBranch();
$branches = $this->getCoreBranches($targetBranch);

if ($targetBranch === self::BRANCH_MASTER && version_compare($config->version, $branches[$targetBranch]['version'], '>')) {
$targetBranch = self::BRANCH_DEV;
}

$upgrade = false;
$new = version_compare($branches['master']['version'], $config->version);
$branch = $branches['master'];
$branch = $branches[$targetBranch];

// branch does not exist - assume commit hash
if (!array_key_exists($targetBranch, $branches)) {
$branch = $branches['sha'];
$upgrade = true;
} elseif ($new > 0 && $targetBranch === self::BRANCH_MASTER) {
// master is newer than current
} elseif (version_compare($branches[$targetBranch]['version'], $config->version) > 0
&& ($targetBranch === self::BRANCH_MASTER || $targetBranch === self::BRANCH_DEV)) {
// branch is newer than current
$upgrade = true;
}

Expand Down Expand Up @@ -229,12 +245,15 @@ protected function getBranchInformations($name, $http) {
);

switch ($name) {
case 'master':
$branch['title'] = 'Stable/Master';
break;
default:
$branch['title'] = 'Specific commit sha';
break;
case 'master':
$branch['title'] = 'Stable/Master';
break;
case 'dev':
$branch['title'] = 'Development';
break;
default:
$branch['title'] = 'Specific commit sha';
break;
}

$content = $http->get($branch['versionURL']);
Expand All @@ -248,9 +267,9 @@ protected function getBranchInformations($name, $http) {
*
* @param string $content
*/
public static function getVersion($content = '') {
public static function getVersion($content = '', $branch = 'master') {
if (!$content) {
$ch = curl_init(str_replace('{branch}', 'master', PwConnector::versionURL));
$ch = curl_init(str_replace('{branch}', $branch, PwConnector::versionURL));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'ProcessWireGetVersion');
$content = curl_exec($ch);
Expand Down
11 changes: 8 additions & 3 deletions src/Helpers/PwModuleTools.php
Expand Up @@ -40,12 +40,17 @@ class PwModuleTools extends PwConnector {
*
* @param InputInterface $input
* @param OutputInterface $output
* @param Boolean $checkForPW
*/
public function init(InputInterface $input, OutputInterface $output) {
public function init(InputInterface $input, OutputInterface $output, $checkForPW = true) {
$this
->setInput($input)
->setOutput($output)
->bootstrapProcessWire();
->setOutput($output);

if ($checkForPW) {
$this->bootstrapProcessWire();
}

$this->tools = parent::setTools();
}

Expand Down
10 changes: 7 additions & 3 deletions src/Helpers/PwUserTools.php
Expand Up @@ -19,12 +19,16 @@ class PwUserTools extends PwConnector {
*
* @param InputInterface $input
* @param OutputInterface $output
* @param Boolean $checkForPW
*/
public function init(InputInterface $input, OutputInterface $output) {
public function init(InputInterface $input, OutputInterface $output, $checkForPW = true) {
$this
->setInput($input)
->setOutput($output)
->bootstrapProcessWire();
->setOutput($output);

if ($checkForPW) {
$this->bootstrapProcessWire();
}
}

/**
Expand Down

0 comments on commit 2423f35

Please sign in to comment.