Skip to content

Commit

Permalink
Update to scaffold 0.12.1 (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexSkrypnyk authored Feb 25, 2024
1 parent d9ff91d commit 985a762
Show file tree
Hide file tree
Showing 29 changed files with 397 additions and 249 deletions.
14 changes: 9 additions & 5 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# Drupal editor configuration normalization
# @see http://editorconfig.org/

# This is the top-most .editorconfig file; do not search in parent directories.
root = true

Expand All @@ -13,10 +10,17 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[composer.{json,lock}]
[*.php]
indent_size = 2


[*.{json,lock}]
indent_size = 4

[*.yml]
[*.{yml,yaml}]
indent_size = 2

[*.{sh,bash,bats}]
indent_size = 2

[*.xml]
Expand Down
17 changes: 10 additions & 7 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# Ignore files for distribution archives.

.gitattributes export-ignore
.gitignore export-ignore
.editorconfig export-ignore
tests export-ignore
.circle export-ignore
phpcs.xml export-ignore
phpunit.xml export-ignore
/.circleci export-ignore
/.editorconfig export-ignore
/.gitattributes export-ignore
/.github export-ignore
/.gitignore export-ignore
/tests export-ignore
/phpcs.xml export-ignore
/phpmd.xml export-ignore
/phpstan.neon export-ignore
/phpunit.xml export-ignore
9 changes: 3 additions & 6 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
## Checklist before requesting a review

- [ ] I have formatted the subject to include ticket number
as `[#123] Verb in past tense with dot at the end.`
- [ ] I have formatted the subject to include ticket number as `[#123] Verb in past tense with dot at the end.`
- [ ] I have added a link to the issue tracker
- [ ] I have provided information in `Changed` section about WHY something was
done if this was not a normal implementation
- [ ] I have provided information in `Changed` section about WHY something was done if this was not a normal implementation
- [ ] I have performed a self-review of my code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] I have run new and existing relevant tests locally with my changes, and
they passed
- [ ] I have run new and existing relevant tests locally with my changes, and they passed
- [ ] I have provided screenshots, where applicable

## Changed
Expand Down
8 changes: 5 additions & 3 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
name-template: '$NEXT_MINOR_VERSION'
tag-template: '$NEXT_MINOR_VERSION'
name-template: '$RESOLVED_VERSION'
tag-template: '$RESOLVED_VERSION'
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
version-resolver:
default: minor
template: |
## What's new since $PREVIOUS_TAG
$CHANGES
**Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...$NEXT_MINOR_VERSION
**Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...$RESOLVED_VERSION
$CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ permissions:
jobs:
assign-author:
runs-on: ubuntu-latest

steps:
- uses: toshimaru/[email protected]
- name: Assign author
uses: toshimaru/[email protected]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Release
name: Draft release notes

on:
push:
Expand All @@ -15,8 +15,11 @@ jobs:
permissions:
contents: write
pull-requests: write

runs-on: ubuntu-latest

steps:
- uses: release-drafter/release-drafter@v6
- name: Draft release notes
uses: release-drafter/release-drafter@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
11 changes: 6 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# To ignore OS temporary files use global .gitignore
# https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files#configuring-ignored-files-for-all-repositories-on-your-computer

vendor
artifact
composer.lock
git_*
.phpunit.cache
/.build
/.coverage-html
/.phpunit.cache
/cobertura.xml
/composer.lock
/vendor
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ would reult in the branch name `release/1.2.0-secondtag`.

```bash
composer lint
composer lint:fix
composer lint-fix
```

### Run tests
Expand Down
28 changes: 19 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,9 @@
"phpmd/phpmd": "^2.15",
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^10.5",
"rector/rector": "^1.0.0",
"squizlabs/php_codesniffer": "^3.6"
},
"scripts": {
"lint": [
"phpcs",
"phpmd --exclude vendor . text phpmd.xml",
"phpstan"
],
"lint:fix": "phpcbf",
"test": "if [ \"${XDEBUG_MODE}\" = 'coverage' ]; then phpunit; else phpunit --no-coverage; fi"
},
"autoload": {
"psr-4": {
"DrevOps\\Robo\\": "src"
Expand All @@ -49,5 +41,23 @@
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"scripts": {
"lint": [
"phpcs",
"phpmd --exclude vendor,vendor-bin,node_modules . text phpmd.xml",
"phpstan",
"rector --clear-cache --dry-run"
],
"lint-fix": [
"rector --clear-cache",
"phpcbf"
],
"test": "if [ \"${XDEBUG_MODE}\" = 'coverage' ]; then phpunit; else phpunit --no-coverage; fi",
"build": [
"@composer bin box require --dev humbug/box",
"box validate",
"box compile"
]
}
}
7 changes: 7 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,10 @@ parameters:
- node_modules/*

ignoreErrors:
-
# Since tests and data providers do not have to have parameter docblocks,
# it is not possible to specify the type of the parameter, so we ignore
# this error.
message: '#.*no value type specified in iterable type array.#'
path: tests/*
reportUnmatched: false
6 changes: 3 additions & 3 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
displayDetailsOnTestsThatTriggerNotices="true"
>
<testsuites>
<testsuite name="GitArtefact">
<directory>./tests/</directory>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>

<source restrictDeprecations="true" restrictNotices="true" restrictWarnings="true">
<include>
<file>src</file>
<directory>src</directory>
</include>
</source>

Expand Down
65 changes: 65 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

/**
* @file
* Rector configuration.
*
* Usage:
* ./vendor/bin/rector process .
*
* @see https://github.com/palantirnet/drupal-rector/blob/main/rector.php
*/

declare(strict_types=1);

use Rector\CodeQuality\Rector\ClassMethod\InlineArrayReturnAssignRector;
use Rector\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRector;
use Rector\CodingStyle\Rector\ClassMethod\NewlineBeforeNewAssignSetRector;
use Rector\CodingStyle\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector;
use Rector\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector;
use Rector\CodingStyle\Rector\PostInc\PostIncDecToPreIncDecRector;
use Rector\CodingStyle\Rector\Stmt\NewlineAfterStatementRector;
use Rector\Config\RectorConfig;
use Rector\DeadCode\Rector\If_\RemoveAlwaysTrueIfConditionRector;
use Rector\Set\ValueObject\SetList;
use Rector\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
__DIR__ . '/**',
]);

$rectorConfig->sets([
SetList::PHP_80,
SetList::PHP_81,
SetList::CODE_QUALITY,
SetList::CODING_STYLE,
SetList::DEAD_CODE,
SetList::INSTANCEOF,
SetList::TYPE_DECLARATION,
]);

$rectorConfig->skip([
// Rules added by Rector's rule sets.
ArraySpreadInsteadOfArrayMergeRector::class,
CountArrayToEmptyArrayComparisonRector::class,
DisallowedEmptyRuleFixerRector::class,
InlineArrayReturnAssignRector::class,
NewlineAfterStatementRector::class,
NewlineBeforeNewAssignSetRector::class,
PostIncDecToPreIncDecRector::class,
RemoveAlwaysTrueIfConditionRector::class,
SimplifyEmptyCheckOnEmptyArrayRector::class,
// Dependencies.
'*/vendor/*',
'*/node_modules/*',
]);

$rectorConfig->fileExtensions([
'php',
'inc',
]);

$rectorConfig->importNames(TRUE, FALSE);
$rectorConfig->importShortClasses(FALSE);
};
25 changes: 13 additions & 12 deletions src/ArtefactTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ trait ArtefactTrait
*
* @var string|null
*/
protected $originalBranch = null;
protected $originalBranch;

/**
* Destination branch with optional tokens.
Expand Down Expand Up @@ -277,7 +277,7 @@ protected function doPush(): void
$this->result = $result->wasSuccessful();
} catch (\Exception $exception) {
// Re-throw the message with additional context.
throw new \Exception(sprintf('Error occurred while pushing branch "%s": %s', $this->dstBranch, $exception->getMessage()));
throw new \Exception(sprintf('Error occurred while pushing branch "%s": %s', $this->dstBranch, $exception->getMessage()), $exception->getCode(), $exception);
}

if ($this->result) {
Expand All @@ -301,7 +301,7 @@ protected function doPush(): void
*/
protected function resolveOptions(array $options): void
{
$this->now = !empty($options['now']) ? (int) $options['now'] : time();
$this->now = empty($options['now']) ? time() : (int) $options['now'];

$this->debug = !empty($options['debug']);

Expand All @@ -310,7 +310,7 @@ protected function resolveOptions(array $options): void
$this->fsSetRootDir($options['root']);

// Default source to the root directory.
$srcPath = !empty($options['src']) ? $this->fsGetAbsolutePath($options['src']) : $this->fsGetRootDir();
$srcPath = empty($options['src']) ? $this->fsGetRootDir() : $this->fsGetAbsolutePath($options['src']);
$this->gitSetSrcRepo($srcPath);

$this->originalBranch = $this->resolveOriginalBranch($this->src);
Expand All @@ -329,7 +329,7 @@ protected function resolveOptions(array $options): void

$this->needsPush = !empty($options['push']);

$this->report = !empty($options['report']) ? $options['report'] : null;
$this->report = empty($options['report']) ? null : $options['report'];

$this->setMode($options['mode'], $options);
}
Expand Down Expand Up @@ -617,11 +617,11 @@ protected function localExcludeEmpty(string $path, bool $strict = false): bool
$lines = file($filename);
if ($lines) {
$lines = array_map('trim', $lines);
$lines = array_filter($lines, function ($line) {
$lines = array_filter($lines, static function ($line) : bool {
return strlen($line) > 0;
});
$lines = array_filter($lines, function ($line) {
return strpos(trim($line), '#') !== 0;
$lines = array_filter($lines, static function ($line) : bool {
return !str_starts_with(trim($line), '#');
});
}

Expand Down Expand Up @@ -856,20 +856,21 @@ protected function sayOkay(string $text): void
{
$color = 'green';
$char = $this->decorationCharacter('V', '');
$format = "<fg=white;bg=$color;options=bold>%s %s</fg=white;bg=$color;options=bold>";
$format = sprintf('<fg=white;bg=%s;options=bold>%%s %%s</fg=white;bg=%s;options=bold>', $color, $color);
$this->writeln(sprintf($format, $char, $text));
}

/**
* Print debug information.
*
* @param mixed ...$args
* The args.
*/
protected function printDebug(): void
protected function printDebug(mixed ...$args): void
{
if (!$this->debug) {
return;
}

$args = func_get_args();
$message = array_shift($args);
/* @phpstan-ignore-next-line */
$this->writeln(vsprintf($message, $args));
Expand Down
Loading

0 comments on commit 985a762

Please sign in to comment.