Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ticktackk committed Feb 1, 2018
0 parents commit c852d9e
Show file tree
Hide file tree
Showing 59 changed files with 7,881 additions and 0 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# DeveloperToolsForXF2

Developer tools for XenForo 2

## Features

- Display order next to option group under Setup > Options
- Display order next to permission interface title and permission
- Developer Options under drop down menu for every add-on allows you to specify what the contents of LICENSE, .gitignore and README.md file should be
- Upon running CLI command `xf-addon:build-release [addon_id]` a new directory is added into the add-on directory named "_repo" which can be used for VCS (Version Control System)

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details
4 changes: 4 additions & 0 deletions upload/src/addons/TickTackk/DeveloperTools/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
_releases
_data
hashes.json
/.idea/
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
<?php

/**
* This file is part of bit3/git-php.
*
* (c) Tristan Lins <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* This project is provided in good faith and hope to be usable by anyone.
*
* @package bit3/git-php
* @author Tristan Lins <[email protected]>
* @author Christian Schiffler <[email protected]>
* @copyright 2014 Tristan Lins <[email protected]>
* @license https://github.com/bit3/git-php/blob/master/LICENSE MIT
* @link https://github.com/bit3/git-php
* @filesource
*/

namespace TickTackk\DeveloperTools\Git\Command;

use TickTackk\DeveloperTools\Git\GitException;
use TickTackk\DeveloperTools\Git\GitRepository;
use Symfony\Component\Process\ProcessBuilder;

/**
* Abstract command builder.
*
* @SuppressWarnings(PHPMD.NumberOfChildren)
*/
abstract class AbstractCommandBuilder implements CommandBuilderInterface
{
/**
* The path to the git repository.
*
* @var GitRepository
*/
public $repository;

/**
* The process builder in use.
*
* @var ProcessBuilder
*/
protected $processBuilder;

/**
* The process output.
*
* @var null|string
*/
protected $output = null;

/**
* Flag if we want to dry run.
*
* @var bool
*/
protected $dryRun = false;

/**
* Constructor.
*
* @param GitRepository $repository The git repository to work on.
*/
public function __construct(GitRepository $repository)
{
$this->repository = $repository;

$this->processBuilder = new ProcessBuilder();
$this->processBuilder->setWorkingDirectory($repository->getRepositoryPath());
$this->processBuilder->add($this->repository->getConfig()->getGitExecutablePath());

$this->initializeProcessBuilder();
}

/**
* Enable dry run. If dry run is enabled, the execute() method return the executed command.
*
* @return $this
*/
public function enableDryRun()
{
$this->dryRun = true;
return $this;
}

/**
* Initialize the process builder.
*
* @return void
*/
protected function initializeProcessBuilder()
{
}

/**
* Retrieve the output text.
*
* @return null|string
*/
public function getOutput()
{
return $this->output;
}

/**
* Execute the command.
*
* @return mixed Depend on the command.
*
* @throws GitException When the command is executed the second time or could not be executed.
*/
protected function run()
{
$process = $this->processBuilder->getProcess();

if ($this->output !== null) {
throw new GitException(
'Command cannot be executed twice',
$process->getWorkingDirectory(),
$process->getCommandLine(),
$this->output,
''
);
}

$this->repository->getConfig()->getLogger()->debug(
sprintf('[ccabs-repository-git] exec [%s] %s', $process->getWorkingDirectory(), $process->getCommandLine())
);

if ($this->dryRun) {
return $process->getCommandLine();
}

$process->run();
$this->output = $process->getOutput();
$this->output = rtrim($this->output, "\r\n");

if (!$process->isSuccessful()) {
throw GitException::createFromProcess('Could not execute git command', $process);
}

return $this->output;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
<?php

/**
* This file is part of bit3/git-php.
*
* (c) Tristan Lins <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* This project is provided in good faith and hope to be usable by anyone.
*
* @package bit3/git-php
* @author Tristan Lins <[email protected]>
* @author Christian Schiffler <[email protected]>
* @copyright 2014 Tristan Lins <[email protected]>
* @license https://github.com/bit3/git-php/blob/master/LICENSE MIT
* @link https://github.com/bit3/git-php
* @filesource
*/

namespace TickTackk\DeveloperTools\Git\Command;

/**
* Add command builder.
*
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
*/
class AddCommandBuilder extends AbstractCommandBuilder
{
/**
* {@inheritDoc}
*/
protected function initializeProcessBuilder()
{
$this->processBuilder->add('add');
}

/**
* Add the dry run option to the command line.
*
* @return AddCommandBuilder
*/
public function dryRun()
{
$this->processBuilder->add('--dry-run');
return $this;
}

/**
* Add the verbose option to the command line.
*
* @return AddCommandBuilder
*/
public function verbose()
{
$this->processBuilder->add('--verbose');
return $this;
}

/**
* Add the force option to the command line.
*
* @return AddCommandBuilder
*/
public function force()
{
$this->processBuilder->add('--force');
return $this;
}

/**
* Add the patch option to the command line.
*
* @return AddCommandBuilder
*/
public function patch()
{
$this->processBuilder->add('--patch');
return $this;
}

/**
* Add the update option to the command line.
*
* @return AddCommandBuilder
*/
public function update()
{
$this->processBuilder->add('--update');
return $this;
}

/**
* Add the all option to the command line.
*
* @return AddCommandBuilder
*/
public function all()
{
$this->processBuilder->add('--all');
return $this;
}

/**
* Add the no-all option to the command line.
*
* @return AddCommandBuilder
*/
public function noAll()
{
$this->processBuilder->add('--no-all');
return $this;
}

/**
* Add the intent-to-add option to the command line.
*
* @return AddCommandBuilder
*/
public function intentToAdd()
{
$this->processBuilder->add('--intent-to-add');
return $this;
}

/**
* Add the refresh option to the command line.
*
* @return AddCommandBuilder
*/
public function refresh()
{
$this->processBuilder->add('--refresh');
return $this;
}

/**
* Add the ignore-errors option to the command line.
*
* @return AddCommandBuilder
*/
public function ignoreErrors()
{
$this->processBuilder->add('--ignore-errors');
return $this;
}

/**
* Add the ignore-missing option to the command line.
*
* @return AddCommandBuilder
*/
public function ignoreMissing()
{
$this->processBuilder->add('--ignore-missing');
return $this;
}

/**
* Build the command and execute it.
*
* @param null|string $pathspec Optional path spec to add to the command line.
*
* @param null|string $_ More arguments to append to the command.
*
* @return mixed
*
* @SuppressWarnings(PHPMD.ShortVariableName)
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
* @SuppressWarnings(PHPMD.CamelCaseParameterName)
*/
public function execute($pathspec = null, $_ = null)
{
$args = func_get_args();
if (count($args)) {
$this->processBuilder->add('--');
foreach ($args as $pathspec) {
$this->processBuilder->add($pathspec);
}
}
return parent::run();
}
}
Loading

0 comments on commit c852d9e

Please sign in to comment.