Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilyes512 committed Mar 25, 2021
0 parents commit 51dc1c7
Show file tree
Hide file tree
Showing 14 changed files with 538 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
ARG IMAGE_TAG_PHP_VSCODE=vscode-latest
FROM ilyes512/php80-fpm:$IMAGE_TAG_PHP_VSCODE

ARG USERNAME=code
ARG USER_UID=1000
ARG USER_GID=$USER_UID
ARG WORKSPACE_PATH=/workspace

RUN groupadd --gid "$USER_GID" "$USERNAME" \
&& useradd --uid "$USER_UID" --gid "$USER_GID" --create-home "$USERNAME" \
&& mkdir -p \
"$WORKSPACE_PATH" \
"/home/$USERNAME/.vscode-server/extensions" \
&& chown -R "$USER_UID":"$USER_GID" \
"$WORKSPACE_PATH" \
"/home/$USERNAME/.vscode-server" \
&& echo "$USERNAME" ALL=\(root\) NOPASSWD:ALL > "/etc/sudoers.d/$USERNAME" \
&& chmod 0440 "/etc/sudoers.d/$USERNAME"

USER $USERNAME
WORKDIR $WORKSPACE_PATH

CMD ["docker-cmd.sh"]
23 changes: 23 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "ECS Signet",
"remoteUser": "code",
"dockerComposeFile": ["docker-compose.yml"],
"service": "php",
"workspaceFolder": "/workspace",
"settings": {
"terminal.integrated.shell.linux": "bash",
"dotfiles.repository": "signet-connectivity/dotfiles",
"dotfiles.targetPath": "~/dotfiles",
"dotfiles.installCommand": "~/dotfiles/install.sh"
},
// "shutdownAction": "none",
"extensions": [
"bmewburn.vscode-intelephense-client",
"redhat.vscode-yaml",
"esbenp.prettier-vscode",
"mehedidracula.php-namespace-resolver",
"editorconfig.editorconfig",
"mhutchie.git-graph",
"ms-vsliveshare.vsliveshare"
]
}
18 changes: 18 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: "3.7"
services:
php:
image: signet/ecs/php/vscode:latest
entrypoint: ["sh", "-c", "trap : 15 ; sleep 9999d & wait"]
build:
context: ../.
dockerfile: .devcontainer/Dockerfile
args:
IMAGE_TAG_PHP_VSCODE: ${IMAGE_TAG_PHP_VSCODE:-vscode-latest}
volumes:
- $HOME/.ssh/known_hosts:/home/code/.ssh/known_hosts:ro
# - $HOME/auth.json:/root/auth.json:ro
- ../.:/workspace:delegated
- vscode-extensions:/home/code/.vscode-server/extensions

volumes:
vscode-extensions:
18 changes: 18 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

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

[*.j2]
insert_final_newline = false
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
COMPOSE_PROJECT_NAME=ecs
17 changes: 17 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Path-based git attributes
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html

# Ignore all test and documentation with "export-ignore".
/.editorconfig export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.gitlab-ci.yml export-ignore
/ecs.php export-ignore
/Taskfile.yml export-ignore
/.env export-ignore
/docs export-ignore
/.vscode export-ignore
/.devcontainer export-ignore
/.vsls.json export-ignore
/.dockerignore export-ignore
/auth.json export-ignore
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
!.env
/coverage
/composer.lock
/vendor
/.phplint-cache
/.DS_Store
/auth.json
4 changes: 4 additions & 0 deletions .vsls.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "http://json.schemastore.org/vsls",
"gitignore": "none"
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Signet B.V.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
69 changes: 69 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# signet/ecs

An ECS Signet codestyle package.

## Installation

You can install the package via composer:

```bash
composer require signet/ecs
```

**NOTE**:
You might need to set the minimum stability to dev to allow usage of `dev-master`. This is currently needed for (better)
PHP 8 support. Add the following keys to the root of your projects `composer.json`-file (prior to installing the
`signet\ecs` package):

```json
{
"minimum-stability": "dev",
"prefer-stable": true
}
```

## Usage

Add a `ecs.php` file to the root of your project (if it doesn't exist) with the below contents

`ecs.php`:
```php
<?php

declare(strict_types=1);

use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\EasyCodingStandard\ValueObject\Option;

return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->import(__DIR__ . '/vendor/signet/ecs/signet-ecs.php');

$services = $containerConfigurator->services();

// $services->set(...);

$parameters = $containerConfigurator->parameters();

$parameters->set(Option::PATHS, [
__DIR__ . '/src',
__DIR__ . '/config',
__DIR__ . '/tests',
__DIR__ . '/ecs.php',
]);
};
```

If you already got an existing ecs.php and you want to use the `signet-ecs` style you can add the following line:

```php
// ...
$containerConfigurator->import(__DIR__ . '/vendor/signet/ecs/signet-ecs.php');
// ...
```

**NOTE**:
`signet-ecs` applies the same fixers as the preconfigured ecs `PSR-12` set (see [SetList::PSR_12](https://github.com/symplify/easy-coding-standard/blob/master/src/ValueObject/Set/SetList.php#L19)).

## Links

[Configuration example](https://github.com/symplify/easy-coding-standard#configuration)
79 changes: 79 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
version: "3"

dotenv: ['.env']

silent: true

########################################################################################################################
#
# TOC
#
########################################################################################################################
#
# 1. COMPOSER
# 2. MISCELLANEOUS
#
########################################################################################################################

tasks:
######################################################################################################################
#
# 1. COMPOSER
#
######################################################################################################################

c:update:
desc: Run composer update
cmds:
- task: c:exec
vars:
SUBCMD: update

c:install:
desc: Run composer install
cmds:
- task: c:exec
vars:
SUBCMD: install

c:exec:
preconditions:
- sh: test '{{.SUBCMD}}' = 'install' -o '{{.SUBCMD}}' = 'update'
msg: SUBCMD value needs to be either 'install' or 'update'
cmds:
- docker volume create php_composer_cache
- docker run
--interactive
--tty
--rm
--volume "$(pwd)":/var/www
--volume php_composer_cache:/home/composer/.composer
--entrypoint ''
-e COMPOSER_HOME=/home/composer/.composer
ilyes512/php80-fpm:builder-latest
composer {{.SUBCMD}}
--no-progress
--prefer-dist
--ignore-platform-reqs

######################################################################################################################
#
# 2. MISCELLANEOUS
#
######################################################################################################################

dc:down:
desc: Cleanup Devcontainer including volumes
cmds:
- docker-compose
-f .devcontainer/docker-compose.yml
down --volumes

cleanup:
desc: Cleanup generated files and vendor files
cmds:
- rm -rf
vendor
composer.lock
.phplint-cache
&& printf "%s\n" "Successfully removed vendor/generated files..."
37 changes: 37 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "signet/ecs",
"type": "library",
"description": "An ECS Signet code style package.",
"keywords": [
"package",
"ecs"
],
"license": "MIT",
"require": {
"php": ">=8.0",
"slevomat/coding-standard": "dev-master",
"symplify/easy-coding-standard": "^9.2.1"
},
"require-dev": {
"overtrue/phplint": "^2.1.0"
},
"scripts": {
"check-style": "XDEBUG_MODE=off ecs check",
"fix-style": "XDEBUG_MODE=off ecs check --fix",
"lint": "XDEBUG_MODE=off phplint --exclude=vendor .",
"check-all": [
"composer lint",
"composer check-style"
]
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"config": {
"sort-packages": true
},
"minimum-stability": "dev",
"prefer-stable": true
}
17 changes: 17 additions & 0 deletions ecs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\EasyCodingStandard\ValueObject\Option;

return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->import(__DIR__ . '/signet-ecs.php');

$containerConfigurator
->parameters()
->set(Option::PATHS, [
__DIR__ . '/ecs.php',
__DIR__ . '/signet-ecs.php',
]);
};
Loading

0 comments on commit 51dc1c7

Please sign in to comment.