Skip to content

Commit

Permalink
Merge pull request #1 from likesistemas/first-stable-release
Browse files Browse the repository at this point in the history
🎉 First stable release
  • Loading branch information
ricardoapaes authored Apr 4, 2022
2 parents 93fbc01 + 9a7180a commit c52c575
Show file tree
Hide file tree
Showing 21 changed files with 391 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "like/composer-empty",
"name": "eloquent-ide-helper",
"dockerComposeFile": [
"../docker-compose.yml"
],
Expand Down
25 changes: 25 additions & 0 deletions .docker/sql/database.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
CREATE TABLE `products` (
`id` int(6) NOT NULL,
`subcategory_id` int(6) NOT NULL,
`name` varchar(100) NOT NULL,
`reference` int(10) NULL DEFAULT NULL,
`price` decimal(10,2) NOT NULL DEFAULT 0.00
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE `subcategories` (
`id` int(6) NOT NULL,
`name` varchar(40) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

ALTER TABLE `products`
ADD PRIMARY KEY (`id`);

ALTER TABLE `subcategories`
ADD PRIMARY KEY (`id`);

ALTER TABLE `products`
MODIFY `id` int(6) NOT NULL AUTO_INCREMENT;

ALTER TABLE `subcategories`
MODIFY `id` int(6) NOT NULL AUTO_INCREMENT;
COMMIT;
5 changes: 2 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
GITHUB_TOKEN=
CODECOMMIT_USER=
CODECOMMIT_PASSWORD=
PHP_VERSION=56|73|74|80
PHP_VERSION=56|73|74|80
PMA_PORT=
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ composer.lock
tests/phpunit.*.xml
.phpunit.result.cache
.php_cs.cache
.php-cs-fixer.cache
.php-cs-fixer.cache
.docker/data/
26 changes: 17 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
{
"name": "likesistemas/nomedalib",
"name": "likesistemas/eloquent-ide-helper",
"type": "library",
"description": "Descriçãoo da biblioteca.",
"repositories": [
{"type": "composer", "url": "https://composer.likesistemas.com.br/"}
],
"description": "Using `barryvdh/laravel-ide-helper` without laravel framework.",
"require": {
"php": ">=5.6"
"php": ">=5.6",
"barryvdh/laravel-ide-helper": "^2.4",
"illuminate/filesystem": "^5.4",
"illuminate/container": "^5.4",
"doctrine/dbal": "^2.5"
},
"require-dev": {
"phpunit/phpunit": "^5.0 || ^9.0"
"phpunit/phpunit": "^5.0 || ^9.0",
"likesistemas/eloquent-external": "^1.1"
},
"autoload": {
"psr-4": {
"Like\\NomeDaLib\\": "src/"
"Like\\Eloquent\\IdeHelper\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Like\\NomeDaLib\\Tests\\": "tests/"
"Like\\Eloquent\\IdeHelper\\Tests\\": "tests/"
}
},
"bin": ["bin/ide-helper"],
"authors": [
{
"name": "Like Sistemas",
Expand All @@ -33,5 +36,10 @@
"fix:ci": "php-cs-fixer fix --dry-run --stop-on-violation",
"test": "phpunit",
"analyse": "phpstan analyse"
},
"config": {
"allow-plugins": {
"kylekatarnls/update-helper": true
}
}
}
18 changes: 18 additions & 0 deletions docker-compose.phpmyadmin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: '3.7'

networks:
github:
name: github
driver: bridge

services:

phpmyadmin:
image: phpmyadmin/phpmyadmin:latest
environment:
- PMA_HOSTS=mysql
- UPLOAD_LIMIT=300M
ports:
- ${PMA_PORT:-9000}:80
networks:
- github
18 changes: 18 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,25 @@ services:
- CODECOMMIT_USER=$CODECOMMIT_USER
- CODECOMMIT_PASSWORD=$CODECOMMIT_PASSWORD
- URL_SENTRY=${URL_SENTRY}
- DB_HOST=mysql
volumes:
- ./:/var/www/public/
networks:
- github
links:
- mysql
depends_on:
- mysql

mysql:
image: ${DB_ENGINE:-mariadb}:${DB_VERSION:-10.4.12}
command: --innodb-use-native-aio=0 --character-set-server=latin1 --collation-server=latin1_swedish_ci
volumes:
- ./.docker/data/${DB_ENGINE:-mariadb}-${DB_VERSION:-10.4.12}/:/var/lib/mysql
- ./.docker/sql/:/docker-entrypoint-initdb.d/
environment:
- MYSQL_DATABASE=${MYSQL_DATABASE:-eloquent}
- MYSQL_ROOT_PASSWORD=root
- TZ=America/Fortaleza
networks:
- github
13 changes: 13 additions & 0 deletions src/Application.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Like\Eloquent\IdeHelper;

use Like\Eloquent\IdeHelper\Commands\GenerateDocsModelsCommand;
use Symfony\Component\Console\Application as ConsoleApplication;

class Application extends ConsoleApplication {
public function __construct() {
parent::__construct('ide-helper');
$this->add(new GenerateDocsModelsCommand());
}
}
49 changes: 49 additions & 0 deletions src/Commands/AbstractCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

namespace Like\Eloquent\IdeHelper\Commands;

use Illuminate\Container\Container;
use Like\Eloquent\IdeHelper\Config;
use LogicException;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

abstract class AbstractCommand extends Command {

/**
* @var SymfonyStyle
*/
protected $style;

public function initialize(InputInterface $input, OutputInterface $output) {
$this->style = new SymfonyStyle($input, $output);

if (! Container::getInstance()->bound('config')) {
$this->loadConfig();
}
}

private function loadConfig() {
$cwd = getcwd() . DIRECTORY_SEPARATOR;
$filename = 'ide-helper.php';
$src = $cwd . $filename;

if (! file_exists($src)) {
throw new LogicException("Config file not found. Filename: {$src}.");
}

$config = include($src);

if (! $config instanceof Config) {
throw new LogicException("Config not is \Like\Eloquent\IdeHelper\Config.");
}

Container::getInstance()->instance('config', $config);

$this->style->title('Reading configurations...');
$this->style->text('Using base path: ' . base_path());
$this->style->text('Using models folders: ' . join(', ', $config['ide-helper.model_locations']));
}
}
33 changes: 33 additions & 0 deletions src/Commands/GenerateDocsModelsCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace Like\Eloquent\IdeHelper\Commands;

use Barryvdh\LaravelIdeHelper\Console\ModelsCommand;
use Illuminate\Container\Container;
use Illuminate\Filesystem\Filesystem;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Output\OutputInterface;

class GenerateDocsModelsCommand extends AbstractCommand {
public function __construct() {
parent::__construct('generate-docs-models');
}

public function configure() {
$this->setAliases(['models']);
}

protected function execute(InputInterface $input, OutputInterface $output) {
$this->style->title('Writing documentation to models');

$fileSystem = new Filesystem();
$command = new ModelsCommand($fileSystem);
$command->setLaravel(Container::getInstance());
return $command->run(
new ArrayInput(['--write' => true, '--reset' => true]),
new ConsoleOutput()
);
}
}
39 changes: 39 additions & 0 deletions src/Config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace Like\Eloquent\IdeHelper;

use ArrayAccess;
use Illuminate\Support\Arr;
use RuntimeException;

class Config implements ArrayAccess {

/**
* @var array
*/
private $config = [];

public function __construct(array $config) {
$this->config = $config;
}

public function get($key, $defaultVaue = null) {
return Arr::get($this->config, $key, $defaultVaue);
}

public function offsetExists($offset) {
throw new RuntimeException('Not implemented because we didn\'t need it yet');
}

public function offsetGet($offset) {
return $this->get($offset);
}

public function offsetSet($offset, $value) {
throw new RuntimeException('Not implemented because we didn\'t need it yet');
}

public function offsetUnset($offset) {
throw new RuntimeException('Not implemented because we didn\'t need it yet');
}
}
6 changes: 0 additions & 6 deletions src/NomeDaLib.php

This file was deleted.

13 changes: 13 additions & 0 deletions src/bin/ide-helper
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env php
<?php

use Like\Eloquent\IdeHelper\Application;

include __DIR__ . '/../laravel-functions.php';

if (! class_exists(Application::class)) {
include $_composer_autoload_path ?? __DIR__ . '/../../vendor/autoload.php';
}

$app = new Application();
$app->run();
11 changes: 11 additions & 0 deletions src/laravel-functions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

use Illuminate\Container\Container;

function base_path() {
return Container::getInstance()->resolved('base-path') ?: getcwd();
}

function config() {
return Container::getInstance()->resolved('config');
}
12 changes: 12 additions & 0 deletions tests/ApplicationTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace Like\Eloquent\IdeHelper\Tests;

use Like\Eloquent\IdeHelper\Application;
use PHPUnit\Framework\TestCase;

class ApplicationTest extends TestCase {
public function testInstance() {
$this->assertInstanceOf(Application::class, new Application());
}
}
47 changes: 47 additions & 0 deletions tests/Config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

namespace Like\Eloquent\IdeHelper\Tests;

use Like\Database\Config as DatabaseConfig;

class Config implements DatabaseConfig {
const DRIVER = 'mysql';
const HOST = 'mysql';
const USER = 'root';
const PASSWORD = 'root';
const DB = 'eloquent';
const FACTORY_FOLDER = __DIR__ . '/./Factories/';
const FAKER_LANGUAGE = 'pt_BR';

public function getDriver() {
return self::DRIVER;
}

public function getHost() {
return self::HOST;
}

public function getDb() {
return self::DB;
}

public function getUser() {
return self::USER;
}

public function getPassword() {
return self::PASSWORD;
}

public function getFactoryFolder() {
return self::FACTORY_FOLDER;
}

public function getFakerLanguage() {
return self::FAKER_LANGUAGE;
}

public function getFakerProviders() {
return [];
}
}
Loading

0 comments on commit c52c575

Please sign in to comment.