Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/refactor #307

Merged
merged 65 commits into from
Jul 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
dbb43a3
refactoring cli commands
iruzevic Jun 8, 2022
80e5a9f
fixing tests and geolocation
iruzevic Jun 13, 2022
7a74707
release preparation
iruzevic Jun 13, 2022
056146f
fixing and linting tests
iruzevic Jun 13, 2022
8840804
fixing and linting tests
iruzevic Jun 13, 2022
717dd69
fixing and linting tests
iruzevic Jun 13, 2022
a9447df
Merge branch 'feature/tests' into feature/cli-refactor
iruzevic Jun 13, 2022
ef017a4
fixing and linting tests
iruzevic Jun 14, 2022
69e615f
fixing and linting tests
iruzevic Jun 15, 2022
5a9da1d
Merge branch 'develop' into feature/cli-refactor
iruzevic Jun 28, 2022
82eedeb
fixing paths
iruzevic Jun 29, 2022
fb2fb70
fixing paths for wpcli
iruzevic Jun 29, 2022
4cb6e56
fixing paths for wpcli
iruzevic Jun 29, 2022
f8a9eee
fixing paths for wpcli
iruzevic Jun 30, 2022
1ff1fed
fixing paths for wpcli
iruzevic Jun 30, 2022
e38cc57
fixing paths for wpcli
iruzevic Jun 30, 2022
43c1399
fixing paths for wpcli
iruzevic Jun 30, 2022
2846f36
fixing paths for wpcli
iruzevic Jun 30, 2022
9a9625c
fixing paths for wpcli
iruzevic Jun 30, 2022
59f327c
fixing paths for wpcli
iruzevic Jul 1, 2022
836885b
fixing paths for wpcli
iruzevic Jul 1, 2022
3e2f733
fixing paths for wpcli
iruzevic Jul 1, 2022
e1ce984
fixing paths for wpcli
iruzevic Jul 1, 2022
fe64509
fixing paths for wpcli
iruzevic Jul 1, 2022
52c2320
fixing paths for wpcli
iruzevic Jul 1, 2022
47ae09c
fixing paths for wpcli
iruzevic Jul 1, 2022
22fafe4
fixing paths for wpcli
iruzevic Jul 1, 2022
dab693f
fixing paths for wpcli
iruzevic Jul 1, 2022
7e790bb
fixing paths for wpcli
iruzevic Jul 1, 2022
8db17a1
fixing paths for wpcli
iruzevic Jul 1, 2022
729d154
fixing paths for wpcli
iruzevic Jul 1, 2022
77373d3
fixing paths for wpcli
iruzevic Jul 1, 2022
a402881
fixing paths for wpcli
iruzevic Jul 4, 2022
b88a57a
fixing paths for wpcli
iruzevic Jul 4, 2022
07716ed
fixing paths for wpcli
iruzevic Jul 4, 2022
89455ca
fixing paths for wpcli
iruzevic Jul 4, 2022
4bfec12
fixing paths for wpcli
iruzevic Jul 4, 2022
a9f506a
fixing paths for wpcli
iruzevic Jul 4, 2022
6a0d154
fixing paths for wpcli
iruzevic Jul 4, 2022
87abd92
fixing paths for wpcli
iruzevic Jul 4, 2022
4abc0aa
fixing paths for wpcli
iruzevic Jul 4, 2022
d39e3b0
fixing paths for wpcli
iruzevic Jul 4, 2022
3746258
fixing paths for wpcli
iruzevic Jul 4, 2022
40fad4e
fixing paths for wpcli
iruzevic Jul 4, 2022
5766786
fixing paths for wpcli
iruzevic Jul 4, 2022
c1525a7
fixing paths for wpcli
iruzevic Jul 5, 2022
32e2094
fixing paths for wpcli
iruzevic Jul 5, 2022
26ef54a
fixing paths for wpcli
iruzevic Jul 5, 2022
a67e1d8
fixing paths for wpcli
iruzevic Jul 5, 2022
5a68c38
fixing paths for wpcli
iruzevic Jul 5, 2022
838e7d2
fixing paths for wpcli
iruzevic Jul 5, 2022
629c940
fixing paths for wpcli
iruzevic Jul 5, 2022
2c51d27
fixing paths for wpcli
iruzevic Jul 5, 2022
b8a04e3
fixing paths for wpcli
iruzevic Jul 5, 2022
bd7873c
fixing paths for wpcli
iruzevic Jul 5, 2022
ddc4480
fixing paths for wpcli
iruzevic Jul 5, 2022
f549c9a
fixing paths for wpcli
iruzevic Jul 5, 2022
2211107
fixing paths for wpcli
iruzevic Jul 5, 2022
cca421b
fixing paths for wpcli
iruzevic Jul 5, 2022
ff70f97
fixing paths for wpcli
iruzevic Jul 5, 2022
8b8ede1
fixing paths for wpcli
iruzevic Jul 5, 2022
a6cacc7
fixing paths for wpcli
iruzevic Jul 5, 2022
ad19ae9
fixing paths for wpcli
iruzevic Jul 5, 2022
c18bc25
fixing paths for wpcli
iruzevic Jul 5, 2022
19836cf
fixing paths for wpcli
iruzevic Jul 5, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions bin/cli.php

This file was deleted.

1 change: 1 addition & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<exclude-pattern>*/src/commands/templates/*</exclude-pattern>
<exclude-pattern>*/src/Build/BuildExample.php</exclude-pattern>
<exclude-pattern>*/bin/cli.php</exclude-pattern>
<exclude-pattern>*/src/CiExclude/CiExcludeExample.php</exclude-pattern>

<!-- Additional arguments. -->
<arg value="sp"/>
Expand Down
4 changes: 2 additions & 2 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
</testsuite>
</testsuites>
<php>
<env name="ES_TEST" value="true" force="true" />
</php>
<env name="ES_TEST" value="true" force="true" />
</php>
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./src</directory>
Expand Down
41 changes: 28 additions & 13 deletions src/AdminMenus/AbstractAdminMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,37 @@ abstract class AbstractAdminMenu implements ServiceInterface, RenderableBlockInt
*/
public function register(): void
{
\add_action(
'admin_menu',
function () {
\add_menu_page(
$this->getTitle(),
$this->getMenuTitle(),
$this->getCapability(),
$this->getMenuSlug(),
[$this, 'processAdminMenu'],
$this->getIcon(),
$this->getPosition()
);
}
\add_action('admin_menu', [$this, 'callback'], $this->getPriorityOrder());
}

/**
* Return action callback method.
*
* @return void
*/
public function callback(): void
{
\add_menu_page(
$this->getTitle(),
$this->getMenuTitle(),
$this->getCapability(),
$this->getMenuSlug(),
[$this, 'processAdminMenu'],
$this->getIcon(),
$this->getPosition()
);
}

/**
* Return hook priority order.
*
* @return integer
*/
public function getPriorityOrder(): int
{
return 10;
}

/**
* Process the admin menu attributes and prepare rendering.
*
Expand Down
31 changes: 4 additions & 27 deletions src/AdminMenus/AdminMenuCli.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,13 @@

use EightshiftLibs\Cli\AbstractCli;
use EightshiftLibs\Cli\ParentGroups\CliCreate;
use EightshiftLibs\Helpers\Components;

/**
* Class AdminMenuCli
*/
class AdminMenuCli extends AbstractCli
{
/**
* Output dir relative path.
*
* @var string
*/
public const OUTPUT_DIR = 'src' . \DIRECTORY_SEPARATOR . 'AdminMenus';

/**
* Get WPCLI command parent name
*
Expand All @@ -45,25 +39,6 @@ public function getCommandName(): string
return 'admin_menu';
}

/**
* Define default develop props.
*
* @param string[] $args WPCLI eval-file arguments.
*
* @return array<string, int|string|boolean>
*/
public function getDevelopArgs(array $args): array
{
return [
'title' => 'Test Title',
'menu_title' => 'Test Menu Title',
'capability' => 'test_edit_posts',
'menu_slug' => 'test_title',
'menu_icon' => 'dashicons-admin-media',
'menu_position' => 50,
];
}

/**
* Define default arguments.
*
Expand Down Expand Up @@ -151,6 +126,8 @@ public function getDoc(): array
/* @phpstan-ignore-next-line */
public function __invoke(array $args, array $assocArgs)
{
$this->getIntroText($assocArgs);

// Get Arguments.
$title = $this->getArg($assocArgs, 'title');
$menuTitle = $this->getArg($assocArgs, 'menu_title');
Expand Down Expand Up @@ -183,6 +160,6 @@ public function __invoke(array $args, array $assocArgs)
}

// Output final class to new file/folder and finish.
$class->outputWrite(static::OUTPUT_DIR, $className, $assocArgs);
$class->outputWrite(Components::getProjectPaths('srcDestination', 'AdminMenus'), "{$className}.php", $assocArgs);
}
}
34 changes: 6 additions & 28 deletions src/AdminMenus/AdminReusableBlocksMenuCli.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,13 @@

use EightshiftLibs\Cli\AbstractCli;
use EightshiftLibs\Cli\ParentGroups\CliCreate;
use EightshiftLibs\Helpers\Components;

/**
* Class AdminReusableBlocksMenuCli
*/
class AdminReusableBlocksMenuCli extends AbstractCli
{
/**
* Output dir relative path.
*
* @var string
*/
public const OUTPUT_DIR = 'src' . \DIRECTORY_SEPARATOR . 'AdminMenus';

/**
* Get WPCLI command parent name
*
Expand All @@ -45,24 +39,6 @@ public function getCommandName(): string
return 'admin_reusable_blocks_menu';
}

/**
* Define default develop props.
*
* @param string[] $args WPCLI eval-file arguments.
*
* @return array<string, int|string|boolean>
*/
public function getDevelopArgs(array $args): array
{
return [
'title' => 'Test Reusable Blocks',
'menu_title' => 'Test Reusable Blocks',
'capability' => 'test_edit_posts',
'menu_icon' => 'dashicons-editor-generic',
'menu_position' => 100,
];
}

/**
* Define default arguments.
*
Expand Down Expand Up @@ -94,14 +70,14 @@ public function getDoc(): array
'name' => 'title',
'description' => 'The text to be displayed in the title tags of the page when the menu is selected.',
'optional' => true,
'default' => 'Reusable Blocks',
'default' => $this->getDefaultArg('title'),
],
[
'type' => 'assoc',
'name' => 'menu_title',
'description' => 'The text to be used for the menu.',
'optional' => true,
'default' => 'Reusable Blocks',
'default' => $this->getDefaultArg('menu_title'),
],
[
'type' => 'assoc',
Expand Down Expand Up @@ -146,6 +122,8 @@ public function getDoc(): array
/* @phpstan-ignore-next-line */
public function __invoke(array $args, array $assocArgs)
{
$this->getIntroText($assocArgs);

// Get Arguments.
$title = $this->getArg($assocArgs, 'title');
$menuTitle = $this->getArg($assocArgs, 'menu_title');
Expand Down Expand Up @@ -176,6 +154,6 @@ public function __invoke(array $args, array $assocArgs)
}

// Output final class to new file/folder and finish.
$class->outputWrite(static::OUTPUT_DIR, $className, $assocArgs);
$class->outputWrite(Components::getProjectPaths('srcDestination', 'AdminMenus'), "{$className}.php", $assocArgs);
}
}
36 changes: 6 additions & 30 deletions src/AdminMenus/AdminSubMenuCli.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,13 @@

use EightshiftLibs\Cli\AbstractCli;
use EightshiftLibs\Cli\ParentGroups\CliCreate;
use EightshiftLibs\Helpers\Components;

/**
* Class AdminSubMenuCli
*/
class AdminSubMenuCli extends AbstractCli
{
/**
* Output dir relative path.
*
* @var string
*/
public const OUTPUT_DIR = 'src' . \DIRECTORY_SEPARATOR . 'AdminMenus';

/**
* Get WPCLI command parent name
*
Expand All @@ -45,24 +39,6 @@ public function getCommandName(): string
return 'admin_sub_menu';
}

/**
* Define default develop props.
*
* @param string[] $args WPCLI eval-file arguments.
*
* @return array<string, int|string|boolean>
*/
public function getDevelopArgs(array $args): array
{
return [
'parent_slug' => 'test-example-menu-slug',
'title' => 'Test Admin Title',
'menu_title' => 'Test Admin Sub Menu Title',
'capability' => 'test_edit_posts',
'menu_slug' => 'test_admin_title',
];
}

/**
* Define default arguments.
*
Expand Down Expand Up @@ -141,6 +117,8 @@ public function getDoc(): array
/* @phpstan-ignore-next-line */
public function __invoke(array $args, array $assocArgs)
{
$this->getIntroText($assocArgs);

// Get Arguments.
$parentSlug = $this->getArg($assocArgs, 'parent_slug');
$title = $this->getArg($assocArgs, 'title');
Expand All @@ -153,7 +131,7 @@ public function __invoke(array $args, array $assocArgs)
$className = $className . $this->getClassShortName();

// Read the template contents, and replace the placeholders with provided variables.
$class = $this->getExampleTemplate(__DIR__, $this->getClassShortName())
$this->getExampleTemplate(__DIR__, $this->getClassShortName())
->renameClassNameWithPrefix($this->getClassShortName(), $className)
->renameNamespace($assocArgs)
->renameUse($assocArgs)
Expand All @@ -162,9 +140,7 @@ public function __invoke(array $args, array $assocArgs)
->searchReplaceString($this->getArgTemplate('title'), $title)
->searchReplaceString($this->getArgTemplate('menu_title'), $menuTitle)
->searchReplaceString($this->getArgTemplate('capability'), $capability)
->searchReplaceString($this->getArgTemplate('menu_slug'), $menuSlug);

// Output final class to new file/folder and finish.
$class->outputWrite(static::OUTPUT_DIR, $className, $assocArgs);
->searchReplaceString($this->getArgTemplate('menu_slug'), $menuSlug)
->outputWrite(Components::getProjectPaths('srcDestination', 'AdminMenus'), "{$className}.php", $assocArgs);
}
}
10 changes: 4 additions & 6 deletions src/AnalyticsGdpr/AnalyticsGdprCli.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,13 @@

use EightshiftLibs\Cli\AbstractCli;
use EightshiftLibs\Cli\ParentGroups\CliCreate;
use EightshiftLibs\Helpers\Components;

/**
* Class AnalyticsGdprCli
*/
class AnalyticsGdprCli extends AbstractCli
{
/**
* Output dir relative path.
*/
public const OUTPUT_DIR = 'src' . \DIRECTORY_SEPARATOR . 'AnalyticsGdpr';

/**
* Get WPCLI command parent name
*
Expand Down Expand Up @@ -77,13 +73,15 @@ public function getDoc(): array
/* @phpstan-ignore-next-line */
public function __invoke(array $args, array $assocArgs) // phpcs:ignore
{
$this->getIntroText($assocArgs);

$className = $this->getClassShortName();

$this->getExampleTemplate(__DIR__, $className)
->renameClassName($className)
->renameNamespace($assocArgs)
->renameUse($assocArgs)
->renameTextDomain($assocArgs)
->outputWrite(static::OUTPUT_DIR, $className, $assocArgs);
->outputWrite(Components::getProjectPaths('srcDestination', 'AnalyticsGdpr'), "{$className}.php", $assocArgs);
}
}
Loading