Skip to content

Commit

Permalink
Merge branch 'release/3.2.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
stmh committed Nov 23, 2019
2 parents 407b2b4 + c8b37f4 commit 7cfefe5
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 8 deletions.
10 changes: 10 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## 3.2.4 / 2019-11-23

### New:

* Add dedicated `npm` method, similar to yarn-method.

### Fixed:

* Issue #62: Switch to using single -m for commit message

## 3.2.3 / 2019-11-18

### Fixed:
Expand Down
9 changes: 7 additions & 2 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ This will print all host configuration for the host `staging`.
* `yarnRootFolder` folder where the package.json is located.
* `yarnBuildCommand` build-command for yarn to execute when running the install- or reset-task.

#### Configuration of the npm-method

* `npmRootFolder` folder where the package.json is located.
* `npmBuildCommand` build-command for npm to execute when running the install- or reset-task.

#### Configuration of the artifacts--ftp-method

* `target` keeps all configuration bundled:
Expand All @@ -209,13 +214,13 @@ This will print all host configuration for the host `staging`.
* `branch` the branch to use for commits
* `useLocalRepository` if set to true, phab will use the current directory as a source for the artifact, if set to false, phab will create a new app in a temporary folder and use that as a artifact
* `actions` a list of actions to perform. See detailed documentation for more info.

#### Configuration of the artifacts--custom method

* `target` contains the following options
* `actions` a list of actions to perform. See detailed documentation for more info.
* `stages` a list of custom stages to perform. A combination of these values:

```
- installCode
- installDependencies
Expand Down
13 changes: 7 additions & 6 deletions src/Method/ArtifactsGitMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ protected function pullTargetRepository(HostConfig $host_config, TaskContextInte
$target_dir = $context->get('targetDir', false);
$target_branch = $host_config[self::PREFS_KEY]['branch'];
$target_repository = $host_config[self::PREFS_KEY]['repository'];

/** @var ShellProviderInterface $shell */
$shell = $context->get('outerShell', $host_config->shell());
$shell->run(sprintf('#!git clone --depth 30 -b %s %s %s', $target_branch, $target_repository, $target_dir));
Expand Down Expand Up @@ -252,12 +252,13 @@ protected function pushToTargetRepository(HostConfig $host_config, TaskContextIn
$shell->run('#!find . -name .git -not -path "./.git" -type d -exec rm -rf {} +');

$shell->run('#!git add -A .');

// Reformat each message by escaping them with backslash.
foreach ($detailed_messages as &$detailed_message) {
$detailed_message = addslashes($detailed_message);
$formatted_message = $message;
// Add two new lines to the end of the short message for detailed messages.
if (!empty($detailed_messages)) {
$formatted_message .= "\n\n * " . implode("\n * ", $detailed_messages);
}
$shell->run(sprintf('#!git commit -m "%s" -m "%s" || true', $message, implode('" -m "', $detailed_messages)));

$shell->run(sprintf('#!git commit -m "%s" || true', escapeshellarg($formatted_message)));
if ($tag = $context->getResult('commitTag')) {
$shell->run(sprintf('#!git push origin :refs/tags/%s || true', $tag));
$shell->run(sprintf('#!git tag --delete %s || true', $tag));
Expand Down
66 changes: 66 additions & 0 deletions src/Method/NpmMethod.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php

namespace Phabalicious\Method;

use Phabalicious\Configuration\HostConfig;
use Phabalicious\Validation\ValidationErrorBagInterface;
use Phabalicious\Validation\ValidationService;

class NpmMethod extends RunCommandBaseMethod
{

public function getName(): string
{
return 'npm';
}

protected function getExecutableName(): string
{
return 'npm';
}

protected function getRootFolderKey(): string
{
return 'npmRootFolder';
}

public function validateConfig(array $config, ValidationErrorBagInterface $errors)
{
parent::validateConfig($config, $errors); // TODO: Change the autogenerated stub
$service = new ValidationService($config, $errors, 'NPM');
$service->hasKey('npmBuildCommand', 'build command to run with npm');
}

protected function prepareCommand(HostConfig $host_config, TaskContextInterface $context, string $command)
{
$production = !in_array($host_config['type'], array('dev', 'test'));
$command .= ' --no-interaction --silent';

return $command;
}
/**
* @param HostConfig $host_config
* @param TaskContextInterface $context
*/
public function resetPrepare(HostConfig $host_config, TaskContextInterface $context)
{
$this->runCommand($host_config, $context, 'install');
$this->runCommand($host_config, $context, $host_config->get('npmBuildCommand'));
}

public function installPrepare(HostConfig $host_config, TaskContextInterface $context)
{
$this->resetPrepare($host_config, $context);
}

public function appCreate(HostConfig $host_config, TaskContextInterface $context)
{
if (!$current_stage = $context->get('currentStage', false)) {
throw new \InvalidArgumentException('Missing currentStage on context!');
}

if ($current_stage == 'installDependencies') {
$this->resetPrepare($host_config, $context);
}
}
}
3 changes: 3 additions & 0 deletions symfony.lock
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@
"ref": "c276fa48d4713de91eb410289b3b1834acb7e403"
}
},
"psr/cache": {
"version": "1.0.1"
},
"psr/container": {
"version": "1.0.0"
},
Expand Down

0 comments on commit 7cfefe5

Please sign in to comment.