Skip to content

Commit

Permalink
[TASK] Initialize
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminkott committed Jul 28, 2020
0 parents commit 210c36d
Show file tree
Hide file tree
Showing 25 changed files with 1,311 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# EditorConfig is awesome: http://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 4

[*.yml]
indent_size = 2

[*.md]
trim_trailing_whitespace = false
20 changes: 20 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Folders
/.github export-ignore
/tests export-ignore

# Files
.editorconfig export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.php_cs.dist export-ignore
.phplint.yml export-ignore
phpunit.xml.dist export-ignore

# Enforce checkout with linux lf consistent over all plattforms
.php_cs.dist text eol=lf
*.json text eol=lf
*.md text eol=lf
*.php text eol=lf
*.xml text eol=lf
*.xml.dist text eol=lf
*.yml text eol=lf
65 changes: 65 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: CI

on: [push, pull_request]

jobs:
build-php:
name: PHP ${{ matrix.php-versions }} with Composer ${{ matrix.composer-versions }} on ${{ matrix.operating-system }}
runs-on: ${{ matrix.operating-system }}
strategy:
max-parallel: 4
matrix:
operating-system:
- 'ubuntu-latest'
- 'windows-latest'
php-versions:
- '7.3'
- '7.4'
composer-versions:
- 'v1'
- 'v2'
steps:

- name: Checkout Code
uses: actions/checkout@v2

- name: Set up PHP Version
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
tools: composer:${{ matrix.composer-versions }}

- name: Environment Check
run: |
php --version
composer --version
- name: Require Composer@v1
if: ${{ matrix.composer-versions == 'v1' }}
run: |
composer require "composer/composer:^1.10" --dev --no-update
- name: Require Composer@v2
if: ${{ matrix.composer-versions == 'v2' }}
run: |
composer require "composer/composer:2.0.x-dev" --dev --no-update
- name: Install
run: |
composer install --no-progress
- name: Info
run: |
composer info
- name: Lint
run: |
composer test:php:lint
- name: CGL
run: |
composer cgl
- name: Unit Tests
run: |
composer test:php:unit
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
bin
build
vendor
*.cache
composer.lock
69 changes: 69 additions & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

if (PHP_SAPI !== 'cli') {
die('This script supports command line usage only. Please check your command.');
}
if (function_exists('xdebug_disable')) {
xdebug_disable();
}

/**
* Read composer.json
*/
$string = file_get_contents("composer.json");
$composer = json_decode($string, true);
if (is_array($composer)) {
$name = $composer['name'];
} else {
$name = dirname(".");
}

$header = <<<EOF
This file is part of the $name.
For the full copyright and license information, please read the
LICENSE file that was distributed with this source code.
EOF;

return PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setRules([
'@PSR2' => true,
'declare_strict_types' => true,
'header_comment' => [
'header' => $header
],
'general_phpdoc_annotation_remove' => [
'annotations' => [
'author'
]
],
'no_leading_import_slash' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_unused_imports' => true,
'concat_space' => ['spacing' => 'one'],
'no_whitespace_in_blank_line' => true,
'ordered_imports' => true,
'single_quote' => true,
'no_empty_statement' => true,
'no_extra_blank_lines' => true,
'phpdoc_no_package' => true,
'phpdoc_scalar' => true,
'no_blank_lines_after_phpdoc' => true,
'array_syntax' => ['syntax' => 'short'],
'whitespace_after_comma_in_array' => true,
'function_typehint_space' => true,
'single_line_comment_style' => true,
'no_alias_functions' => true,
'lowercase_cast' => true,
'no_leading_namespace_whitespace' => true,
'native_function_casing' => true,
'self_accessor' => true,
'no_short_bool_cast' => true,
'no_unneeded_control_parentheses' => true
])
->setFinder(
PhpCsFixer\Finder::create()
->in(['src', 'tests'])
);
9 changes: 9 additions & 0 deletions .phplint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
path: ./
jobs: 10
cache: .phplint.cache
extensions:
- php
exclude:
- bin
- build
- vendor
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2020 Benjamin Kott, http://www.bk2k.info

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.
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Project Configuration Installer

Installer for Configuration Packages.
Example: https://github.com/benjaminkott/config-phpcsfixer-typo3

## Build your own configuration package

Adapt the `composer.json` of your **configuration package**.

1. Ensure the type is set to `project-configuration`.
1. Ensure `bk2k/configuration-installer` is required in any version.

```json
{
"type": "project-configuration",
"require": {
"bk2k/configuration-installer": "*"
}
}
```

### Add a manifest to your configuration package root.

The `manifest.json` file instructs the installer.

1. It defines which `files` should be copied to your project
1. It defines which `gitignore` entries will be added to your projects .gitignore file.


```json
{
"files": {
".php_cs.dist": ".php_cs.dist"
},
"gitignore": [
"/.php_cs.dist",
"/.php_cs.cache"
]
}
```
73 changes: 73 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"name": "bk2k/configuration-installer",
"type": "composer-plugin",
"description": "Configuration Installer",
"homepage": "https://github.com/benjaminkott/configuration-installer",
"authors": [
{
"name": "Benjamin Kott",
"email": "[email protected]",
"role": "Developer",
"homepage": "http://www.bk2k.info/"
}
],
"support": {
"issues": "https://github.com/benjaminkott/configuration-installer/issues"
},
"minimum-stability": "dev",
"prefer-stable": true,
"license": "MIT",
"require": {
"php": "^7.3",
"composer-plugin-api": "^1.1 || ^2.0"
},
"require-dev": {
"composer/composer": "^1.10 || ^2.0@dev",
"friendsofphp/php-cs-fixer": "^2.16 || ^3.0@dev",
"overtrue/phplint": "^2.0",
"phpunit/phpunit": "^9.2"
},
"autoload": {
"psr-4": {
"BK2K\\ConfigurationInstaller\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"BK2K\\ConfigurationInstallerTest\\": "tests/"
}
},
"config": {
"bin-dir": "bin",
"optimize-autoloader": true,
"sort-packages": true,
"vendor-dir": "vendor"
},
"scripts": {
"test:php:lint": [
"phplint"
],
"test:php:unit": [
"Composer\\Config::disableProcessTimeout",
"phpunit"
],
"test:php:cover": [
"Composer\\Config::disableProcessTimeout",
"phpunit --coverage-html build/coverage-report"
],
"test": [
"@cgl",
"@test:php:lint",
"@test:php:unit"
],
"cgl:fix": [
"php-cs-fixer fix"
],
"cgl": [
"php-cs-fixer fix --dry-run"
]
},
"extra": {
"class": "BK2K\\ConfigurationInstaller\\Installer\\Plugin"
}
}
24 changes: 24 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="tests/bootstrap.php"
>

<testsuites>
<testsuite name="configuration-installer-unit-tests">
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
</whitelist>
</filter>

</phpunit>
32 changes: 32 additions & 0 deletions src/Configuration/File.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php declare(strict_types=1);

/*
* This file is part of the bk2k/configuration-installer.
*
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/

namespace BK2K\ConfigurationInstaller\Configuration;

class File
{
protected $source;
protected $target;

public function __construct(string $source, string $target)
{
$this->source = $source;
$this->target = $target;
}

public function getSource(): string
{
return $this->source;
}

public function getTarget():string
{
return $this->target;
}
}
Loading

0 comments on commit 210c36d

Please sign in to comment.