Skip to content

Commit 1796be2

Browse files
committed
Initial upload
1 parent 169193f commit 1796be2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2469
-0
lines changed

.gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.php linguist-language=PHP
2+
*.js linguist-language=PHP

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
vendor/
2+
build/
3+
composer.lock

.php_cs

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?php
2+
3+
use Symfony\CS\Config\Config;
4+
use Symfony\CS\FixerInterface;
5+
use Symfony\CS\Finder\DefaultFinder;
6+
7+
$fixers = [
8+
'blankline_after_open_tag',
9+
'braces',
10+
'concat_without_spaces',
11+
'double_arrow_multiline_whitespaces',
12+
'duplicate_semicolon',
13+
'elseif',
14+
'empty_return',
15+
'encoding',
16+
'eof_ending',
17+
'extra_empty_lines',
18+
'function_call_space',
19+
'function_declaration',
20+
'include',
21+
'indentation',
22+
'join_function',
23+
'line_after_namespace',
24+
'linefeed',
25+
'list_commas',
26+
'logical_not_operators_with_successor_space',
27+
'lowercase_constants',
28+
'lowercase_keywords',
29+
'method_argument_space',
30+
'multiline_array_trailing_comma',
31+
'multiline_spaces_before_semicolon',
32+
'multiple_use',
33+
'namespace_no_leading_whitespace',
34+
'no_blank_lines_after_class_opening',
35+
'no_empty_lines_after_phpdocs',
36+
'object_operator',
37+
'operators_spaces',
38+
'parenthesis',
39+
'phpdoc_indent',
40+
'phpdoc_inline_tag',
41+
'phpdoc_no_access',
42+
'phpdoc_no_package',
43+
'phpdoc_scalar',
44+
'phpdoc_short_description',
45+
'phpdoc_to_comment',
46+
'phpdoc_trim',
47+
'phpdoc_type_to_var',
48+
'phpdoc_var_without_name',
49+
'remove_leading_slash_use',
50+
'remove_lines_between_uses',
51+
'return',
52+
'self_accessor',
53+
'short_array_syntax',
54+
'short_echo_tag',
55+
'short_tag',
56+
'single_array_no_trailing_comma',
57+
'single_blank_line_before_namespace',
58+
'single_line_after_imports',
59+
'single_quote',
60+
'spaces_before_semicolon',
61+
'spaces_cast',
62+
'standardize_not_equal',
63+
'ternary_spaces',
64+
'trailing_spaces',
65+
'trim_array_spaces',
66+
'unalign_equals',
67+
'unary_operators_spaces',
68+
'unused_use',
69+
'visibility',
70+
'whitespacy_lines',
71+
];
72+
73+
return Config::create()
74+
->finder(DefaultFinder::create()->in(__DIR__))
75+
->fixers($fixers)
76+
->level(FixerInterface::NONE_LEVEL)
77+
->setUsingCache(true);

.travis.yml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
language: php
2+
3+
sudo: true
4+
5+
php:
6+
- 5.6
7+
- 7.0
8+
- 7.1
9+
- 7.2
10+
- nightly
11+
12+
matrix:
13+
fast_finish: true
14+
15+
allow_failures:
16+
- php: 7.2
17+
- php: nightly
18+
19+
cache:
20+
directories:
21+
- $HOME/.composer/cache
22+
23+
services:
24+
- sqlite
25+
26+
before_script:
27+
- composer install
28+
- travis_retry composer self-update
29+
- travis_retry composer update ${COMPOSER_FLAGS} --no-interaction --prefer-dist
30+
31+
script:
32+
# - vendor/bin/phpunit

ISSUE_TEMPLATE

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
- Hooks Version: #.#.#
2+
- Laravel Version: #.#.#
3+
- PHP Version:
4+
5+
### Description:
6+
7+
8+
### Steps To Reproduce:

composer.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "larapack/hooks",
3+
"description": "",
4+
"require-dev": {
5+
"orchestra/testbench": "~3.0"
6+
},
7+
"autoload": {
8+
"psr-4": {
9+
"Larapack\\Hooks\\": "src/"
10+
}
11+
},
12+
"autoload-dev": {
13+
"psr-4": {
14+
"Larapack\\Hooks\\Tests\\": "tests/"
15+
}
16+
}
17+
}

phpunit.xml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit backupGlobals="false"
3+
backupStaticAttributes="false"
4+
bootstrap="tests/bootstrap.php"
5+
colors="true"
6+
verbose="true"
7+
convertErrorsToExceptions="true"
8+
convertNoticesToExceptions="true"
9+
convertWarningsToExceptions="true"
10+
processIsolation="false"
11+
stopOnFailure="false"
12+
syntaxCheck="true"
13+
>
14+
<testsuites>
15+
<testsuite name="Hooks Test Suite">
16+
<directory>tests</directory>
17+
</testsuite>
18+
</testsuites>
19+
<logging>
20+
<log type="tap" target="build/report.tap"/>
21+
<log type="junit" target="build/report.junit.xml"/>
22+
<log type="coverage-html" target="build/coverage" charset="UTF-8" yui="true" highlight="true"/>
23+
<log type="coverage-text" target="build/coverage.txt"/>
24+
<log type="coverage-clover" target="build/logs/clover.xml"/>
25+
</logging>
26+
<php>
27+
<env name="APP_DEBUG" value="true"/>
28+
<env name="APP_KEY" value="base64:M1igrxNfAWlVGyxxDholHqvVqvtPjAzCoJ+2/ILAVPw="/>
29+
</php>
30+
</phpunit>

publishable/config/hooks.php

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
return [
4+
5+
/*
6+
|--------------------------------------------------------------------------
7+
| Github Configuration
8+
|--------------------------------------------------------------------------
9+
|
10+
| In order to download unlimited hooks from Github and to get private
11+
| repositories, you must define a Github Token below. You can gather
12+
| your Github token at https://github.com/settings/tokens/new
13+
|
14+
*/
15+
16+
'github' => [
17+
'token' => env('HOOK_GITHUB_TOKEN'),
18+
],
19+
20+
];

src/Commands/CheckCommand.php

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
namespace Larapack\Hooks\Commands;
4+
5+
use Larapack\Hooks\Hooks;
6+
use Illuminate\Console\Command;
7+
8+
class CheckCommand extends Command
9+
{
10+
protected $signature = 'hook:check';
11+
12+
protected $description = 'Check for updates and show hooks that can be updated';
13+
14+
protected $hooks;
15+
16+
public function __construct(Hooks $hooks)
17+
{
18+
$this->hooks = $hooks;
19+
20+
parent::__construct();
21+
}
22+
23+
public function fire()
24+
{
25+
$hooks = $this->hooks->checkForUpdates();
26+
27+
$count = $hooks->count();
28+
29+
if ($count == 0) {
30+
$this->info('No updates available.');
31+
}
32+
33+
$this->info(($count == 1 ? '1 update' : $count.' updates') . 'available.');
34+
35+
foreach ($hooks as $hook) {
36+
$this->comment($hook->name . ' ' . $hook->remoteVersion);
37+
}
38+
}
39+
}

src/Commands/DisableCommand.php

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace Larapack\Hooks\Commands;
4+
5+
use Larapack\Hooks\Hooks;
6+
use Illuminate\Console\Command;
7+
8+
class DisableCommand extends Command
9+
{
10+
protected $signature = 'hook:disable {name}';
11+
12+
protected $description = 'Disable a hook';
13+
14+
protected $hooks;
15+
16+
public function __construct(Hooks $hooks)
17+
{
18+
$this->hooks = $hooks;
19+
20+
parent::__construct();
21+
}
22+
23+
public function fire()
24+
{
25+
$name = $this->argument('name');
26+
27+
$this->hooks->disable($name);
28+
29+
$this->info("Hook [{$name}] have been disabled.");
30+
}
31+
}

src/Commands/EnableCommand.php

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace Larapack\Hooks\Commands;
4+
5+
use Larapack\Hooks\Hooks;
6+
use Illuminate\Console\Command;
7+
8+
class EnableCommand extends Command
9+
{
10+
protected $signature = 'hook:enable {name}';
11+
12+
protected $description = 'Enable a hook';
13+
14+
protected $hooks;
15+
16+
public function __construct(Hooks $hooks)
17+
{
18+
$this->hooks = $hooks;
19+
20+
parent::__construct();
21+
}
22+
23+
public function fire()
24+
{
25+
$name = $this->argument('name');
26+
27+
$this->hooks->enable($name);
28+
29+
$this->info("Hook [{$name}] have been enabled.");
30+
}
31+
}

src/Commands/InfoCommand.php

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
namespace Larapack\Hooks\Commands;
4+
5+
use Larapack\Hooks\Hooks;
6+
use Illuminate\Console\Command;
7+
8+
class InfoCommand extends Command
9+
{
10+
protected $signature = 'hook:info {name}';
11+
12+
protected $description = 'Get information on a hook';
13+
14+
protected $hooks;
15+
16+
public function __construct(Hooks $hooks)
17+
{
18+
$this->hooks = $hooks;
19+
20+
parent::__construct();
21+
}
22+
23+
public function fire()
24+
{
25+
$name = $this->argument('name');
26+
27+
$hook = $this->hooks->hooks()->where('name', $name)->first();
28+
29+
if (is_null($hook)) {
30+
return $this->error("Hook [{$name}] not found.");
31+
}
32+
33+
$this->comment($name);
34+
$this->line(" <info>Name:</info> {$name}");
35+
$this->line(" <info>Status:</info> ".($hook['enabled'] ? 'Enabled' : 'Disabled'));
36+
$this->line(" <info>Version:</info> ".(!is_null($hook['version']) ? $hook['version'] : 'None'));
37+
}
38+
}

src/Commands/InstallCommand.php

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
namespace Larapack\Hooks\Commands;
4+
5+
use Larapack\Hooks\Hooks;
6+
use Illuminate\Console\Command;
7+
8+
class InstallCommand extends Command
9+
{
10+
protected $signature = 'hook:install {name} {version?} {--enable}';
11+
12+
protected $description = 'Download and install a hook from remote https://larapack.io';
13+
14+
protected $hooks;
15+
16+
public function __construct(Hooks $hooks)
17+
{
18+
$this->hooks = $hooks;
19+
20+
parent::__construct();
21+
}
22+
23+
public function fire()
24+
{
25+
$name = $this->argument('name');
26+
27+
$this->hooks->install($name, $this->argument('version'));
28+
29+
if ($this->option('enable')) {
30+
$this->hooks->enable($name);
31+
32+
$this->info("Hook [{$name}] have been installed and enabled.");
33+
} else {
34+
$this->info("Hook [{$name}] have been installed.");
35+
}
36+
}
37+
}

0 commit comments

Comments
 (0)