Skip to content

Commit

Permalink
[#3] Install PHP ECS and run fix
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuapease committed May 20, 2024
1 parent e64cac9 commit 85ffb31
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 27 deletions.
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"vlucas/phpdotenv": "^5.4.0"
},
"require-dev": {
"craftcms/ecs": "dev-main",
"craftcms/generator": "^2.0.0",
"yiisoft/yii2-shell": "^2.0.3"
},
Expand Down Expand Up @@ -44,6 +45,8 @@
],
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example.dev', '.env');\""
]
],
"ecs-check": "ecs check --ansi",
"ecs-fix": "ecs check --ansi --fix"
}
}
94 changes: 92 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions ecs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

use craft\ecs\SetList;
use Symplify\EasyCodingStandard\Config\ECSConfig;

return static function(ECSConfig $ecsConfig): void {
$ecsConfig->parallel();
$ecsConfig->paths([
__DIR__ . '/modules',
__DIR__ . '/install-scripts',
__DIR__ . '/bootstrap.php',
__DIR__ . '/web/index.php',
__FILE__,
]);

// TODO waiting on this PR or similar https://github.com/craftcms/ecs/pull/4
$ecsConfig->sets([SetList::CRAFT_CMS_4]); // for Craft 4 projects
};
46 changes: 23 additions & 23 deletions install-scripts/ScriptHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,44 +5,44 @@ class ScriptHelpers
/**
* Escape character
*/
const ESC = "\033";
public const ESC = "\033";

/**
* ANSI colours
*/
const ANSI_BLACK = self::ESC . "[30m";
const ANSI_RED = self::ESC . "[31m";
const ANSI_GREEN = self::ESC . "[32m";
const ANSI_YELLOW = self::ESC . "[33m";
const ANSI_BLUE = self::ESC . "[34m";
const ANSI_MAGENTA = self::ESC . "[35m";
const ANSI_CYAN = self::ESC . "[36m";
const ANSI_WHITE = self::ESC . "[37m";
public const ANSI_BLACK = self::ESC . "[30m";
public const ANSI_RED = self::ESC . "[31m";
public const ANSI_GREEN = self::ESC . "[32m";
public const ANSI_YELLOW = self::ESC . "[33m";
public const ANSI_BLUE = self::ESC . "[34m";
public const ANSI_MAGENTA = self::ESC . "[35m";
public const ANSI_CYAN = self::ESC . "[36m";
public const ANSI_WHITE = self::ESC . "[37m";

/**
* ANSI background colours
*/
const ANSI_BACKGROUND_BLACK = self::ESC . "[40m";
const ANSI_BACKGROUND_RED = self::ESC . "[41m";
const ANSI_BACKGROUND_GREEN = self::ESC . "[42m";
const ANSI_BACKGROUND_YELLOW = self::ESC . "[43m";
const ANSI_BACKGROUND_BLUE = self::ESC . "[44m";
const ANSI_BACKGROUND_MAGENTA = self::ESC . "[45m";
const ANSI_BACKGROUND_CYAN = self::ESC . "[46m";
const ANSI_BACKGROUND_WHITE = self::ESC . "[47m";
public const ANSI_BACKGROUND_BLACK = self::ESC . "[40m";
public const ANSI_BACKGROUND_RED = self::ESC . "[41m";
public const ANSI_BACKGROUND_GREEN = self::ESC . "[42m";
public const ANSI_BACKGROUND_YELLOW = self::ESC . "[43m";
public const ANSI_BACKGROUND_BLUE = self::ESC . "[44m";
public const ANSI_BACKGROUND_MAGENTA = self::ESC . "[45m";
public const ANSI_BACKGROUND_CYAN = self::ESC . "[46m";
public const ANSI_BACKGROUND_WHITE = self::ESC . "[47m";

/**
* ANSI styles
*/
const ANSI_BOLD = self::ESC . "[1m";
const ANSI_ITALIC = self::ESC . "[3m"; // limited support. ymmv.
const ANSI_UNDERLINE = self::ESC . "[4m";
const ANSI_STRIKETHROUGH = self::ESC . "[9m";
public const ANSI_BOLD = self::ESC . "[1m";
public const ANSI_ITALIC = self::ESC . "[3m"; // limited support. ymmv.
public const ANSI_UNDERLINE = self::ESC . "[4m";
public const ANSI_STRIKETHROUGH = self::ESC . "[9m";

/**
* Clear all ANSI styling
*/
const ANSI_CLOSE = self::ESC . "[0m";
public const ANSI_CLOSE = self::ESC . "[0m";

public static function output(string $message): int|false
{
Expand Down Expand Up @@ -78,4 +78,4 @@ public static function kebabCase(string $string)
// Lowercase each word and join them with dashes
return strtolower(implode('-', $words));
}
}
}
2 changes: 1 addition & 1 deletion install-scripts/rename-ddev.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@

file_put_contents($file_path, $file_content);

ScriptHelpers::success("Your DDEV project is now named $projectName!");
ScriptHelpers::success("Your DDEV project is now named $projectName!");
3 changes: 3 additions & 0 deletions modules/todo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

// TODO add a default module

0 comments on commit 85ffb31

Please sign in to comment.