Skip to content

Commit

Permalink
List of changes:
Browse files Browse the repository at this point in the history
* v0.42-alpha   - Changes Made:

          1) Arun code auto-generation (Domains, Actions, Parameters), thanks to domain "gen" included "out-of-the-box"
          2) @set\DomainEnabled and @set\ActionEnabled fixed
          3) Improved documentation (README.md)
          4) Published on 2018-11-14

Changes committed:
	modified:   .envcli
	modified:   README.md
	new file:   app/Console/Domains/GenDomain.php
	new file:   app/Console/Schemas/Action.skm
	new file:   app/Console/Schemas/Domain.skm
	modified:   arun
	modified:   changelog.txt
	modified:   composer.json
	modified:   containers/core.php
  • Loading branch information
afonzeca committed Nov 13, 2018
1 parent 5fad65c commit f815a96
Show file tree
Hide file tree
Showing 9 changed files with 715 additions and 117 deletions.
12 changes: 11 additions & 1 deletion .envcli
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,21 @@ APP_NAME="Arun"
#
# APPLICATION VERSION
#
APP_VERSION="0.41-alpha"
APP_VERSION="0.42-alpha"

#
# COMMAND LINE COLORS (0 = disabled, 1 = enabled)
#
# ENABLE COLORS ONLY ON LINUX
#
COLORS=1

#
# DOMAINS PATH
#
DOMAINS=app/Console/Domains

#
# SCHEMAS PATH
#
SCHEMAS=app/Console/Schemas
592 changes: 480 additions & 112 deletions README.md

Large diffs are not rendered by default.

151 changes: 151 additions & 0 deletions app/Console/Domains/GenDomain.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
<?php
/**
* This file is part of "Arun - CLI Microframework for Php7.2+" released under the following terms
*
* Copyright 2018 Angelo FONZECA ( https://www.linkedin.com/in/angelo-f-1806868/ )
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Linkedin contact ( https://www.linkedin.com/in/angelo-f-1806868/ ) - Project @ https://github.com/afonzeca/arun
*
* Code Example made using the Arun CLI Micro-framework for PHP7.2+
*
*/

namespace App\Console\Domains;

use ArunCore\Interfaces\CodeBuilders\ActionManipulatorInterface;
use ArunCore\Interfaces\CodeBuilders\DomainManipulatorInterface;
use ArunCore\Traits\Builder\CommonOptions;
use ArunCore\Traits\Builder\PlaceholderManipulator;
use ArunCore\Interfaces\IO\FileContentGeneratorInterface;

use ArunCore\Annotations as SET;

/**
* Class GenerateDomain
*
* @SET\DomainSyn("Generates code for Arun Development Speed-up")
* @SET\DomainEnabled(true)
*
*/
class GenDomain extends DomainCommand
{
use PlaceholderManipulator, CommonOptions;

/**
* @var DomainManipulatorInterface $dmc
*/
private $dmc;

/**
* @var ActionManipulatorInterface $amc
*/
private $amc;

/**
* GenDomain constructor.
*
* @param FileContentGeneratorInterface $fileGen
* @param DomainManipulatorInterface $dmc
* @param ActionManipulatorInterface $amc
*/
public function __construct(
FileContentGeneratorInterface $fileGen,
DomainManipulatorInterface $dmc,
ActionManipulatorInterface $amc
) {
$this->dmc = $dmc;
$this->amc = $amc;
}

/**
*
* @SET\ActionEnabled(true)
* @SET\ActionSyn("This action generates a Domain class for Arun automatically")
* @SET\ActionOption("--synopsis='your domain description':Set the description of the domain")
* @SET\ActionOption("--disabled:Generate the Domain class file but with DomainEnabled set to FALSE")
* @SET\ActionOption("-f|--force:Force domain code overwriting - NOTE! It will destroy your hand-made code! -")
*
* @param string $domainName
*
* @throws
*/
public function domain(string $domainName)
{
$force = false;

$isEnabled = $this->isEnabled();
$synopsis = $this->getSynopsis();

if ($this->hasOption("force") || $this->hasOption("f")) {
$force = true;
}

$this->dmc->createDomain($domainName, $synopsis, $isEnabled, $force);
}

/**
*
* @SET\ActionEnabled(true)
* @SET\ActionSyn("This action generates ARUN CODE for an Action linked to a Domain class")
* @SET\ActionOption("--synopsis='your action description':Set the description of the action")
* @SET\ActionOption("--disabled:Generate the Action method but disabled")
*
* @param string $domainName
*
* @throws
*/
public function action(string $domainName, string $actionName)
{
$isEnabled = $this->isEnabled();
$synopsis = $this->getSynopsis();

$this->dmc->addActionIntoDomain($domainName, $actionName, $synopsis, $isEnabled);
}

/**
*
* @SET\ActionEnabled(true)
* @SET\ActionSyn("This action adds a parameter to a specified action(method) linked to a domain(class)")
* @SET\ActionOption("--type='int|string':Set the 'type'. Otherwise the type will be 'string'")
* @SET\ActionOption("--default='your default value':Otherwise the value will be not set.")
*
* @param string $domainName
* @param string $actionName
* @param string $paramName
* @param string $type
* @param string $defaultValue
*
* @return bool
*/
public function parameter(
string $domainName,
string $actionName,
string $paramName
): bool {

$type = $this->getType("string");
$defaultValue = $this->getDefault("");

return $this->amc->addParameterToAction(
$domainName,
$actionName,
$paramName,
$type,
$defaultValue
);
}

}

14 changes: 14 additions & 0 deletions app/Console/Schemas/Action.skm
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

/**
*
* ##!ACTIONNAME!## - ##!SYNOPSIS!##
*
* @SET\ActionEnabled(##!ENABLED!##)
* @SET\ActionSyn("##!SYNOPSIS!##")
*
* @SET\ActionEOA("##!ACTIONNAME!##")
*/
public function ##!ACTIONNAME!##()
{
$this->cOut->writeln("This action must be defined.");
}
39 changes: 39 additions & 0 deletions app/Console/Schemas/Domain.skm
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
/**
* This file ##!DOMAINNAME!##.php has been generated by "Arun - CLI Microframework for Php7.2+" released under the following terms
*
* Copyright 2018 Angelo FONZECA ( https://www.linkedin.com/in/angelo-f-1806868/ )
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Linkedin contact ( https://www.linkedin.com/in/angelo-f-1806868/ ) - Project @ https://github.com/afonzeca/arun
*
* Code Example made using the Arun CLI Micro-framework for PHP7.2+
*
*/

namespace App\Console\Domains;

use ArunCore\Annotations as SET;

/**
* Class ##!DOMAINNAME!## - ##!SYNOPSIS!##
*
* @SET\DomainSyn("##!SYNOPSIS!##")
* @SET\DomainEnabled(##!ENABLED!##)
*
* @SET\DomainEOA("##!DOMAINNAME!##")
*/
class ##!DOMAINNAME!## extends DomainCommand
{
}
2 changes: 1 addition & 1 deletion arun
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ try {

} catch (\Exception $ex) {

printf("\r\nArun EXCEPTION: %s\r\n\r\n", $ex->getMessage());
printf("\r\n\r\nArun EXCEPTION: %s\r\n\r\n", $ex->getMessage());

}
8 changes: 7 additions & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
List of changes:

* v0.42-alpha - Changes Made:

1) Arun code auto-generation (Domains, Actions, Parameters), thanks to domain "gen" included "out-of-the-box"
2) @SET\DomainEnabled and @SET\ActionEnabled fixed
3) Improved documentation (README.md)
4) Published on 2018-11-14

* v0.41-alpha - Changes Made:

Expand All @@ -17,7 +23,7 @@ List of changes:
composer.json and the whole documentation)

5) All "core" code removed from this repository and
replublished on arun-core repository (refer to point 1)
republished on arun-core repository (refer to point 1)


* v0.4-alpha - Changes made:
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"ext-mbstring": "*",
"php-di/php-di": "^6.0",
"vlucas/phpdotenv": "^2.5",
"afonzeca/arun-core": "v0.41-alpha",
"afonzeca/arun-core": "v0.42-alpha",
"doctrine/annotations": "^1.6",
"doctrine/doctrine-bundle": "^1.9",
"doctrine/doctrine-module": "^2.1",
Expand Down
12 changes: 11 additions & 1 deletion containers/core.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
use ArunCore\Interfaces\Core\ArunCoreInterface;
use ArunCore\Interfaces\Helpers\LowLevelHelperInterface;
use ArunCore\Interfaces\Security\SanitizerInterface;
use ArunCore\Interfaces\CodeBuilders\DomainManipulatorInterface;
use ArunCore\Interfaces\CodeBuilders\ActionManipulatorInterface;

return [

Expand All @@ -39,8 +41,12 @@

DomainActionExecutorInterface::class => DI\autowire("ArunCore\\Core\\Domain\\DomainActionExecutor"),

\ArunCore\Interfaces\IO\FileContentGeneratorInterface::class => DI\autowire("ArunCore\\Core\\IO\\FileContentGenerator")
->constructorParameter("domainsPath", realpath(__DIR__ . "/../" . getenv("DOMAINS")))
->constructorParameter("schemasPath", realpath(__DIR__ . "/../" . getenv("SCHEMAS"))),

LowLevelHelperInterface::class => DI\autowire("ArunCore\\Core\\Helpers\\LowLevelHelper")
->constructorParameter("basePath",realpath(__DIR__."/../")),
->constructorParameter("basePath", realpath(__DIR__ . "/../")),

ConsoleInputInterface::class => DI\autowire("ArunCore\\Core\\IO\\ConsoleInput")
->constructorParameter("args", $_SERVER["argv"]),
Expand All @@ -50,6 +56,10 @@

DomainActionNameGeneratorInterface::class => DI\autowire("ArunCore\\Core\\Domain\\DomainActionNameGenerator"),

DomainManipulatorInterface::class => DI\autowire("ArunCore\\Core\\CodeBuilders\\DomainManipulator"),

ActionManipulatorInterface::class => DI\autowire("ArunCore\\Core\\CodeBuilders\\ActionManipulator"),

HelpGeneratorInterface::class => DI\autowire("ArunCore\\Core\\Helpers\\HelpGenerator"),

Doctrine\Common\Annotations\Reader::class => DI\get("Doctrine\Common\Annotations\AnnotationReader")
Expand Down

0 comments on commit f815a96

Please sign in to comment.