Skip to content

Commit

Permalink
Merge branch 'release/v0.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
betterthanclay committed Dec 11, 2023
2 parents a58d8e2 + 6ab50de commit d0ee745
Show file tree
Hide file tree
Showing 23 changed files with 1,492 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# https://EditorConfig.org

root = true

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

[*.yml]
indent_size = 2

[*.md]
trim_trailing_whitespace = false
11 changes: 11 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.editorconfig export-ignore
.gitattributes export-ignore
.github/ export-ignore
.gitignore export-ignore
CHANGELOG.md export-ignore
ecs.php export-ignore
phpstan.neon export-ignore
phpunit.xml.dist export-ignore
docs/ export-ignore
tests/ export-ignore
stubs/ export-ignore
130 changes: 130 additions & 0 deletions .github/workflows/integrate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow

name: "Integrate"

on:
push:
branches:
- "develop"
pull_request: null

env:
PHP_EXTENSIONS: "intl"

jobs:
file_consistency:
name: "1️⃣ File consistency"
runs-on: "ubuntu-latest"
steps:
- name: "Set up PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "8.1"
extensions: "${{ env.PHP_EXTENSIONS }}"
ini-values: "post_max_size=256M"

- name: "Checkout code"
uses: "actions/checkout@v3"

- name: Install Effigy
run: |
composer global config --no-plugins allow-plugins.phpstan/extension-installer true
composer global require decodelabs/effigy
- name: "Install dependencies"
uses: "ramsey/composer-install@v2"
with:
dependency-versions: "highest"

- name: "Check file permissions"
run: |
composer global exec effigy check-executable-permissions
- name: "Check exported files"
run: |
composer global exec effigy check-git-exports
- name: "Find non-printable ASCII characters"
run: |
composer global exec effigy check-non-ascii
- name: "Check source code for syntax errors"
run: |
composer global exec effigy lint
static_analysis:
name: "3️⃣ Static Analysis"
needs:
- "file_consistency"
runs-on: "ubuntu-latest"
strategy:
matrix:
php-version:
- "8.1"
- "8.2"
- "8.3"
steps:
- name: "Set up PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "${{ matrix.php-version }}"
extensions: "${{ env.PHP_EXTENSIONS }}"
ini-values: "post_max_size=256M"

- name: "Checkout code"
uses: "actions/checkout@v3"

- name: Install Effigy
run: |
composer global config --no-plugins allow-plugins.phpstan/extension-installer true
composer global require decodelabs/effigy
- name: "Validate Composer configuration"
run: "composer validate --strict"

- name: "Install dependencies"
uses: "ramsey/composer-install@v2"
with:
dependency-versions: "highest"

- name: "Execute static analysis"
run: |
composer global exec effigy analyze -- --headless
coding_standards:
name: "4️⃣ Coding Standards"
needs:
- "file_consistency"
runs-on: "ubuntu-latest"
steps:
- name: "Set up PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "8.1"
extensions: "${{ env.PHP_EXTENSIONS }}"
ini-values: "post_max_size=256M"

- name: "Checkout code"
uses: "actions/checkout@v3"

- name: "Check EditorConfig configuration"
run: "test -f .editorconfig"

- name: "Check adherence to EditorConfig"
uses: "greut/eclint-action@v0"

- name: Install Effigy
run: |
composer global config --no-plugins allow-plugins.phpstan/extension-installer true
composer global require decodelabs/effigy
- name: "Install dependencies"
uses: "ramsey/composer-install@v2"
with:
dependency-versions: "highest"

- name: "Check coding style"
run: |
composer global exec effigy format -- --headless
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/vendor
composer.phar
composer.lock
.DS_Store
Thumbs.db
/phpunit.xml
/.idea
/.env
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
## v0.1.0 (2023-12-08)
* Built initial implementation
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Indoctrination

[![PHP from Packagist](https://img.shields.io/packagist/php-v/decodelabs/indoctrination?style=flat)](https://packagist.org/packages/decodelabs/indoctrination)
[![Latest Version](https://img.shields.io/packagist/v/decodelabs/indoctrination.svg?style=flat)](https://packagist.org/packages/decodelabs/indoctrination)
[![Total Downloads](https://img.shields.io/packagist/dt/decodelabs/indoctrination.svg?style=flat)](https://packagist.org/packages/decodelabs/indoctrination)
[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/decodelabs/indoctrination/integrate.yml?branch=develop)](https://github.com/decodelabs/indoctrination/actions/workflows/integrate.yml)
[![PHPStan](https://img.shields.io/badge/PHPStan-enabled-44CC11.svg?longCache=true&style=flat)](https://github.com/phpstan/phpstan)
[![License](https://img.shields.io/packagist/l/decodelabs/indoctrination?style=flat)](https://packagist.org/packages/decodelabs/indoctrination)

### Doctrine DBAL and ORM integration tools

Indoctrination provides ...

_Get news and updates on the [DecodeLabs blog](https://blog.decodelabs.com)._

---

## Installation

Install via Composer:

```bash
composer require decodelabs/indoctrination
```

## Usage

Coming soon...

## Licensing

Indoctrination is licensed under the MIT License. See [LICENSE](./LICENSE) for the full license text.
56 changes: 56 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"name": "decodelabs/indoctrination",
"description": "Doctrine DBAL and ORM integration tools",
"type": "library",
"keywords": [ ],
"license": "MIT",
"authors": [ {
"name": "Tom Wright",
"email": "[email protected]"
} ],
"require": {
"php": "^8.1",
"decodelabs/dovetail": "^0.2.2",
"decodelabs/exceptional": "^0.4.4",
"decodelabs/guidance": "^0.1.7",
"decodelabs/slingshot": "^0.1.4",
"decodelabs/stash": "^0.3.0",
"decodelabs/veneer": "^0.10.24",

"doctrine/orm": "^2.17",
"doctrine/dbal": "^3.7",
"doctrine/migrations": "^3.7"
},
"require-dev": {
"decodelabs/cipher": "^0.1.1",
"decodelabs/clip": "^0.3.10",
"decodelabs/genesis": "^0.8.3",
"decodelabs/glitch": "^0.18.10",
"decodelabs/phpstan-decodelabs": "^0.6.7",
"martin-georgiev/postgresql-for-doctrine": "^2.1",
"nesbot/carbon": "^2.72"
},
"suggest": {
"decodelabs/cipher": "JWT token support",
"decodelabs/clip": "Command line tools",
"martin-georgiev/postgresql-for-doctrine": "Extended PostgreSQL support for Doctrine",
"nesbot/carbon": "Better Date/time handling"
},
"autoload": {
"psr-4": {
"DecodeLabs\\Indoctrination\\": "src/Indoctrination/"
},
"classmap": [
"src/Clip/",
"src/Dovetail/"
],
"files": [
"src/Indoctrination/Context.php"
]
},
"extra": {
"branch-alias": {
"dev-develop": "0.1.x-dev"
}
}
}
13 changes: 13 additions & 0 deletions ecs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

// ecs.php

declare(strict_types=1);

use Symplify\EasyCodingStandard\Config\ECSConfig;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;

return static function (ECSConfig $ecsConfig): void {
$ecsConfig->paths([__DIR__.'/src']);
$ecsConfig->sets([SetList::CLEAN_CODE, SetList::PSR_12]);
};
4 changes: 4 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
parameters:
paths:
- src
level: max
63 changes: 63 additions & 0 deletions src/Clip/Task/Doctrine.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

/**
* @package Indoctrination
* @license http://opensource.org/licenses/MIT
*/

declare(strict_types=1);

namespace DecodeLabs\Clip\Task;

use DecodeLabs\Clip\Task;
use DecodeLabs\Dovetail\Config\Doctrine as DoctrineConfig;
use DecodeLabs\Indoctrination;
use Doctrine\Migrations\Configuration\EntityManager\ExistingEntityManager;
use Doctrine\Migrations\Configuration\Migration\ConfigurationArray;
use Doctrine\Migrations\DependencyFactory;
use Doctrine\Migrations\Tools\Console\ConsoleRunner as MigrationsConsoleRunner;
use Doctrine\ORM\Tools\Console\ConsoleRunner;
use Doctrine\ORM\Tools\Console\EntityManagerProvider\SingleManagerProvider;

class Doctrine implements Task
{
public const COMMANDS = [];

public function execute(): bool
{
Indoctrination::clearCache();

unset($_SERVER['argv'][1]);
$_SERVER['argv'] = array_values($_SERVER['argv']);
$_SERVER['argc']--;

$command = $_SERVER['argv'][1] ?? '';
$target = explode(':', $command)[0] ?? '';

match ($target) {
'migrations' => $this->runMigrations(),
default => $this->runRoot()
};

return true;
}

protected function runRoot(): void
{
$entityManager = Indoctrination::getEntityManager();

ConsoleRunner::run(
new SingleManagerProvider($entityManager),
self::COMMANDS
);
}

protected function runMigrations(): void
{
$config = DoctrineConfig::load();
$migrationConfig = new ConfigurationArray($config->getMigrationsConfig());
$entityManager = Indoctrination::getEntityManager();
$dependencyFactory = DependencyFactory::fromEntityManager($migrationConfig, new ExistingEntityManager($entityManager));
MigrationsConsoleRunner::run([], $dependencyFactory);
}
}
Loading

0 comments on commit d0ee745

Please sign in to comment.