Skip to content

Commit b4af93c

Browse files
committed
fixing to comply with PSR4 loading standards
1 parent 900b7f9 commit b4af93c

File tree

4 files changed

+141
-77
lines changed

4 files changed

+141
-77
lines changed

Makefile

+69-19
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,16 @@ ENVIRONMENT=
3434
LANG=nl
3535
NPM_ASSETS=public/css/app.css public/js/app.js
3636
NPM_ENV=development
37+
OS:=$(shell uname -s)
38+
NPROCS:=$(shell [ Darwin = $(OS) ] && sysctl -n hw.ncpu || nproc)
3739
PHP=php -d memory_limit=256M $(PHP_EXTRA)
3840
PHPUNIT=$(PHP) vendor/bin/phpunit -d xdebug.max_nesting_level=250 -d memory_limit=1024M $(PHPUNIT_EXTRA)
3941
PRETEND=--pretend
4042
SCOUT_MODELS=
41-
SRCS= Makefile README.md webpack.mix.js composer.json package-lock.json package.json Envoy.blade.php \
42-
opcache_reset.php server.php phpunit.xml app bootstrap/app.php bootstrap/autoload.php config \
43-
database model resources routes tests
43+
PHP_SRC=app bootstrap/app.php config database resources routes public/*.php tests
44+
SRC= Makefile README.md webpack.mix.js composer.json package-lock.json package.json Envoy.blade.php \
45+
opcache_reset.php server.php phpunit.xml app bootstrap/app.php bootstrap/autoload.php config \
46+
database model resources routes tests
4447
USER_AGENT:=$(shell $(CURL) --version | head -1 | awk '{printf("%s/%s", $$1, $$2);}')
4548
WGET=wget --no-check-certificate $(WGET_EXTRA)
4649
WRITABLE_DIRS=storage/*/* bootstrap/cache
@@ -51,6 +54,9 @@ TEMP_DEPLOY_DIR := $(shell echo .deploy.tmp.$$$$)
5154

5255
all: rw
5356

57+
#
58+
# Setup
59+
#
5460
rw:
5561
sudo chmod -R g+w $(WRITABLE_DIRS)
5662
sudo chown -R $(USER):$(WWW_GROUP_ID) $(WRITABLE_DIRS)
@@ -84,6 +90,12 @@ init-elastic:
8490
time $(ARTISAN) db:seed --class=DummyDataSeeder
8591
[ -z $(SCOUT_MODELS) ] || for model in $(SCOUT_MODELS); do $(ARTISAN) scout:import "$$model"; done
8692

93+
get-envoy:
94+
$(WGET) -N https://raw.githubusercontent.com/papertank/envoy-deploy/master/Envoy.blade.php
95+
96+
#
97+
# Deployment
98+
#
8799
deploy-checkout-copy-manual:
88100
@[ ! -z '$(BRANCH)' -a ! -z '$(DST)' ] || (echo "missing BRANCH=... or DST=..." 1>&2; exit 1)
89101
(rm -rf $(TEMP_DEPLOY_DIR) && git clone --recursive -j8 -b $(BRANCH) . $(TEMP_DEPLOY_DIR) && rsync -zaSHx $(TEMP_DEPLOY_DIR)/ $(DST)/); rm -rf $(TEMP_DEPLOY_DIR)
@@ -129,6 +141,15 @@ ant build: .build.dummy.
129141
.build.dummy.:
130142
time $(ANT) $(EXTRA) $(ANT_TARGET)
131143

144+
#
145+
# Docker
146+
#
147+
docker-image:
148+
docker build --squash .
149+
150+
#
151+
# Testing
152+
#
132153
test: rw clear-cache autodump
133154
time $(PHPUNIT) $(EXTRA)
134155

@@ -167,6 +188,9 @@ test-elastic testelastic:
167188
test-migrate:
168189
time $(ARTISAN) --env=testing migrate $(EXTRA)
169190

191+
#
192+
# NPM
193+
#
170194
$(NPM_ASSETS): Makefile webpack.mix.js resources/assets/sass/*.scss resources/assets/js/*.js
171195
time npm run $(NPM_ENV)
172196

@@ -184,12 +208,10 @@ npm-watch:
184208
npm-prod npm-production:
185209
@make npm-dev NPM_ENV=production
186210

187-
get-envoy:
188-
$(WGET) -N https://raw.githubusercontent.com/papertank/envoy-deploy/master/Envoy.blade.php
189-
190-
docker-image:
191-
docker build --squash .
192211

212+
#
213+
# Lint
214+
#
193215
lint lint-parallel:
194216
@make -j4 jsonlint xmllint phplint bladelint
195217

@@ -213,6 +235,42 @@ xmllint xml-lint lint-xml lintxml:
213235
@echo lint - XML...
214236
@find *.xml app bootstrap public resources routes tests -name '*.xml' | while read file; do nice -20 xmllint --noout "$$file"; done
215237

238+
#
239+
# Static code analysis
240+
#
241+
loc:
242+
@echo making fast copy...
243+
@rm -rf build/src
244+
@mkdir -p build/src
245+
@for i in $(SRC) ; do ln -s ../../"$$i" build/src/; done
246+
@echo running sloccount...
247+
#sloccount --datadir .sloccount --follow build/src
248+
@sloccount --addlang js --addlang makefile --addlang sql --addlangall --follow $(EXTRA) -- build/src/ 2>&1 | fgrep -v 'Warning! Unclosed PHP file'
249+
@echo running cloc...
250+
@cloc --follow-links build/src
251+
252+
static-analysis static-analyzis static analysis analyzis analyse analyze stat anal: phpcpd phpcs phploc phpmd phpstan
253+
254+
phpcpd:
255+
vendor/bin/phpcpd $(EXTRA) $(PHP_SRC)
256+
257+
phpcs:
258+
vendor/bin/phpcs --standard=PSR2 -p --parallel=$(NPROCS) -s $(EXTRA) $(PHP_SRC)
259+
260+
phploc:
261+
vendor/bin/phploc $(EXTRA) $(PHP_SRC)
262+
263+
phpmd:
264+
for ruleset in cleancode codesize controversial design naming unusedcode; do \
265+
vendor/bin/phpmd $(PHP_SRC) ansi $$ruleset $(EXTRA); \
266+
done
267+
268+
phpstan:
269+
vendor/bin/phpstan analyse $(EXTRA) $(PHP_SRC)
270+
271+
#
272+
# Translations
273+
#
216274
find-texts:
217275
@egrep -Er '>[A-Z][a-z]|^\s*[A-Z][a-z][A-Za-z0-9 _.-]*\s*$$' resources/views/ $(CMD_EXTRA)
218276

@@ -224,17 +282,9 @@ gentrans:
224282
gentrans-en:
225283
@make gentrans LANG=en
226284

227-
loc:
228-
@echo making fast copy...
229-
@rm -rf build/src
230-
@mkdir -p build/src
231-
@for i in $(SRCS) ; do ln -s ../../"$$i" build/src/; done
232-
@echo running sloccount...
233-
#sloccount --datadir .sloccount --follow build/src
234-
@sloccount --addlang js --addlang makefile --addlang sql --addlangall --follow $(EXTRA) -- build/src/ 2>&1 | fgrep -v 'Warning! Unclosed PHP file'
235-
@echo running cloc...
236-
@cloc --follow-links build/src
237-
285+
#
286+
# Shortcuts
287+
#
238288
clean: clear
239289
rm -f Envoy[0-9a-f]*.php
240290

composer.json

+10-3
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
}
1616
],
1717
"minimum-stability": "dev",
18-
"require": {},
19-
"autoload": {
18+
"autoload": {
2019
"psr-4": {
2120
"Magentron\\LaravelScripts\\": "src"
2221
},
@@ -30,5 +29,13 @@
3029
"Magentron\\LaravelScripts\\Providers\\LaravelScriptsServiceProvider"
3130
]
3231
}
33-
}
32+
},
33+
"require-dev": {
34+
"phpstan/phpstan": "0.12.x-dev",
35+
"friendsofphp/php-cs-fixer": "9999999-dev",
36+
"phpmd/phpmd": "9999999-dev",
37+
"squizlabs/php_codesniffer": "4.0.x-dev",
38+
"sebastian/phpcpd": "6.0.x-dev",
39+
"phploc/phploc": "7.0.x-dev"
40+
}
3441
}

src/Providers/LaravelScriptsProvider.php

-55
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
3+
/**
4+
* laravel-scripts - Laravel service provider
5+
*
6+
* @author Jeroen Derks <jeroen@derks.it>
7+
* @since 2018/Nov/26
8+
* @license GPLv3 https://www.gnu.org/licenses/gpl.html
9+
* @copyright Copyright (c) 2018 Jeroen Derks / Derks.IT
10+
* @url https://github.com/Magentron/laravel-scripts/
11+
*
12+
* This file is part of laravel-scripts.
13+
*
14+
* laravel-scripts is free software: you can redistribute it and/or modify
15+
* it under the terms of the GNU General Public License as published by
16+
* the Free Software Foundation, either version 3 of the License, or (at
17+
* your option) any later version.
18+
*
19+
* laravel-scripts is distributed in the hope that it will be useful, but
20+
* WITHOUT ANY WARRANTY; without even the implied warranty of
21+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22+
* GNU General Public License for more details.
23+
*
24+
* You should have received a copy of the GNU General Public License along
25+
* with laravel-scripts. If not, see <http://www.gnu.org/licenses/>.
26+
*/
27+
28+
namespace Magentron\LaravelScripts\Providers;
29+
30+
use Illuminate\Support\ServiceProvider;
31+
32+
/**
33+
* Class LaravelScriptsServiceProvider
34+
*
35+
* @package Magentron\LaravelScripts\Providers
36+
*/
37+
class LaravelScriptsServiceProvider extends ServiceProvider
38+
{
39+
/**
40+
* Files to publish.
41+
*/
42+
const FILES = [
43+
'Envoy.blade.php',
44+
'Makefile',
45+
'opcache_reset.php',
46+
];
47+
48+
49+
/**
50+
* Bootstrap the laravel-script provider.
51+
*
52+
* @return void
53+
*/
54+
public function boot()
55+
{
56+
foreach (self::FILES as $file) {
57+
$this->publishes([
58+
realpath(__DIR__ . '/../../' . $file) => base_path($file),
59+
], 'deployment');
60+
}
61+
}
62+
}

0 commit comments

Comments
 (0)