Skip to content

Commit cbc29dd

Browse files
committed
Initial commit
0 parents  commit cbc29dd

File tree

2,348 files changed

+207673
-0
lines changed

Some content is hidden

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

2,348 files changed

+207673
-0
lines changed

.editorconfig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
11+
[*.php]
12+
indent_size = 4
13+
14+
[*.json}]
15+
indent_size = 2
16+
17+
[*.md]
18+
trim_trailing_whitespace = false

.github/workflows/unittests.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Unittests
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
build:
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
os: ['ubuntu-latest']
16+
php: [8.2]
17+
steps:
18+
- uses: actions/checkout@v2
19+
20+
- name: Setup PHP
21+
uses: shivammathur/setup-php@v2
22+
with:
23+
php-version: ${{ matrix.php }}
24+
extensions: redis
25+
26+
- name: Validate composer.json and composer.lock
27+
run: composer validate
28+
29+
- name: Cache Composer packages
30+
id: composer-cache
31+
uses: actions/cache@v2
32+
with:
33+
path: vendor
34+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
35+
restore-keys: |
36+
${{ runner.os }}-php-
37+
38+
- name: Set env
39+
run: echo "PHP_CS_FIXER_IGNORE_ENV=1" >> $GITHUB_ENV
40+
41+
- name: Install Dependencies (ignore platform)
42+
uses: nick-invision/retry@v1
43+
with:
44+
timeout_minutes: 5
45+
max_attempts: 3
46+
command: composer install --no-interaction --no-progress --ignore-platform-req=php
47+
48+
- name: Run test suite
49+
run: composer run-script qa

.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
data/Makefile
2+
src/Public/avatare
3+
src/Public/sites
4+
*.po~
5+
docu/de/_build/*
6+
vendor
7+
config.json
8+
config.json.backup
9+
src/Public/assets
10+
src/Public/version_*
11+
backup
12+
build
13+
OrmProxy
14+
src/lang/*/*/*.mo
15+
.php-cs-fixer.cache
16+
.githooks

.php-cs-fixer.dist.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()
4+
->in(['src', 'tests'])
5+
->exclude(['Public/assets']);
6+
$config = new PhpCsFixer\Config();
7+
$config->setRules(
8+
[
9+
'@PSR12' => true,
10+
'@PHP74Migration' => true,
11+
'array_syntax' => ['syntax' => 'short'],
12+
'method_argument_space' => [
13+
'on_multiline' => 'ensure_fully_multiline',
14+
'keep_multiple_spaces_after_comma' => false
15+
],
16+
'no_unused_imports' => true,
17+
'ordered_imports' => [
18+
'sort_algorithm' => 'alpha',
19+
'imports_order' => ['const', 'class', 'function'],
20+
],
21+
]
22+
)->setFinder($finder);
23+
24+
return $config;

.phpstorm.meta.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
namespace PHPSTORM_META
3+
{
4+
override(\Psr\Container\ContainerInterface::get(0), map([
5+
'' => '@',
6+
]));
7+
override(\DI\Container::get(0), map([
8+
'' => '@',
9+
]));
10+
override(\Mockery::mock(0), type(0));
11+
override(\Stu\StuTestCase::mock(0), type(0));
12+
}

.scrutinizer.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
build:
2+
image: default-bionic
3+
environment:
4+
php:
5+
version: "8.2"
6+
ini:
7+
memory_limit: "-1"
8+
pecl_extensions:
9+
- redis
10+
redis: true
11+
nodes:
12+
analysis:
13+
tests:
14+
override:
15+
- php-scrutinizer-run
16+
coverage:
17+
tests:
18+
override:
19+
- command: XDEBUG_MODE=coverage ./vendor/bin/phpunit --coverage-clover build/coverage-clover.xml tests
20+
coverage:
21+
file: build/coverage-clover.xml
22+
format: clover
23+
filter:
24+
paths:
25+
- 'src/'
26+
checks:
27+
php:
28+
code_rating: true
29+
tools:
30+
php_mess_detector:
31+
enabled: true
32+
filter:
33+
paths:
34+
- 'src/'
35+
php_code_sniffer:
36+
enabled: false
37+
php_pdepend:
38+
enabled: true
39+
configuration_file: null
40+
suffixes:
41+
- php
42+
excluded_dirs: { }
43+
filter:
44+
paths:
45+
- 'src/'
46+
php_analyzer:
47+
enabled: true
48+
extensions:
49+
- php
50+
filter:
51+
paths:
52+
- 'src/'
53+
path_configs: { }
54+
php_loc:
55+
enabled: true
56+
excluded_dirs:
57+
- 'vendor/*'
58+
- 'tests/*'
59+
- '.phpstorm.meta.php'
60+
php_cpd:
61+
enabled: true
62+
excluded_dirs: { }
63+
filter:
64+
paths:
65+
- 'src/'

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Daniel Jakob
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# DEFAULT
2+
PHONY=init init-production tests coverage update dev-serve dev-create-db dev-wipe-db dev-start-db dev-stop-db dev-migrate-db dirs migrateDatabase showDatabaseChanges
3+
4+
SUITE=
5+
6+
all:init dirs
7+
8+
dirs:force
9+
for a in src/admin/backup src/Public/avatare/user src/Public/avatare/alliance; do mkdir -p "$$a"; chmod 770 "$$a"; done
10+
11+
init:force
12+
composer install
13+
14+
init-production:force
15+
composer install -a --no-dev
16+
17+
tests:force
18+
./vendor/bin/phpunit tests $$SUITE
19+
20+
coverage:force
21+
./vendor/bin/phpunit -c phpunit-coverage.xml tests $$SUITE
22+
23+
update:force
24+
composer update
25+
26+
dev-serve:force
27+
php -S localhost:1337 -t src/Public/
28+
29+
dev-create-db:force
30+
docker-compose up -d stu-db
31+
sleep 15
32+
docker-compose exec -T stu-db sh -c 'exec psql -U stu stu_db -c "create role postgres;"'
33+
docker-compose exec -T stu-db sh -c 'exec pg_restore -U stu -d stu_db < /dump/stu.dump'
34+
35+
dev-wipe-db:force
36+
docker-compose kill stu-db
37+
docker-compose rm -f stu-db
38+
39+
dev-start-db:force
40+
docker-compose up -d stu-db
41+
42+
dev-stop-db:force
43+
docker-compose kill stu-db
44+
45+
clearCache:force
46+
bin/doctrine orm:clear-cache:metadata
47+
bin/doctrine orm:clear-cache:query
48+
49+
migrateDatabase:force
50+
bin/doctrine orm:schema-tool:update --force
51+
bin/doctrine orm:generate-proxies
52+
53+
showDatabaseChanges:force
54+
bin/doctrine orm:schema-tool:update --dump-sql --complete
55+
56+
force:

README.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# ST-Universe Source
2+
3+
[![Unittests](https://github.com/st-universe/core/actions/workflows/unittests.yml/badge.svg?branch=master)](https://github.com/st-universe/core/actions/workflows/unittests.yml)
4+
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/st-universe/core/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/st-universe/core)
5+
[![Code Coverage](https://scrutinizer-ci.com/g/st-universe/core/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/st-universe/core/?branch=master)
6+
7+
## Lokales Setup
8+
9+
Benötigte Software: Linux (geht u.U. auch unter macOS) docker, php 8.2,
10+
composer, git.
11+
12+
- Repository forken und das Source-Code auschecken
13+
- config.dist.json nach config.json kopieren und anpassen
14+
- make init
15+
- make dev-create-db
16+
- make migrateDatabase
17+
- ./bin/cli game:reset
18+
- make dev-serve
19+
- Use the cli command to create a new user `./bin/cli user:create --help`
20+
21+
Danach sollte die Software via http://localhost:1337 erreichbar sein, ggf. kann
22+
es sein, dass der Hostname (stu-db) nicht aufgelöst werden kann. In diesem
23+
Fall muss für die im `docker-compose.yml` File hinterlegte IP ein Eintrag in
24+
der Hosts-Datei des Betriebssystems gemacht werden.
25+
26+
## Server-Deployment
27+
28+
Code:
29+
30+
- Repository auschecken
31+
- make init-production
32+
- make dirs
33+
- rsync -rv --delete-after --exclude=assets --links --exclude=config.json --exclude=src/Public/admin/manage --exclude=src/Public/avatare/* src bin vendor Makefile cli-config.php config.dist.json /path/to/stuniverse-source/
34+
- cd /path/to/stuniverse-source && make clearCache && make migrateDatabase
35+
36+
### Assets
37+
38+
- Repository auschecken
39+
- php generator/building_generator/gen.php
40+
- php generator/field_generator/generator.php
41+
- rsync -rv --delete-after --exclude=dist --exclude=".git" . /path/to/stuniverse-source/assets/
42+
43+
## DB-Dump aus Backups einspielen
44+
45+
- aktuelles Schema umbenennen, z.B. in 'stuDamaged'
46+
- neue Datenbank mit Original-Name erstellen, z.B. 'stu'
47+
- auf Kommandozeile in den postgres user einloggen, mittels 'sudo su - postgres'
48+
- in Backup-Folder wechseln, z.B: core/dist/db/backup
49+
- Backup einspielen mittels 'pg_restore -d stu -U postgres -C dd-MM-yyyy.dump'
50+
51+
## Automatische Scripte (Rundenwechsel, etc)
52+
53+
Um alle automatisierte Scripte zu den definierten Zeiten laufen zu lassen, muss folgender `cronjob` hinzugefügt werden.
54+
55+
```shell
56+
* * * * * cd /path/to/stu/core && vendor/bin/crunz schedule:run
57+
```
58+
59+
Die Tasks und deren Schedules werden in Dateien innerhalb des `resource/cron` Ordners definiert.
60+
61+
## Command Line Interface (cli)
62+
63+
Mittels dem Shell-Befehl `./bin/cli` kann das STU CLI gestartet werden. Hier können diverse Befehle ausgeführt werden,
64+
z.B. das manuelle Auslösen der Rundenwechsel. Alle verfügbaren Befehle können via `./bin/cli --help` eingesehen werden.

0 commit comments

Comments
 (0)