mirror of
http://124.126.16.154:8888/singularity/composer-template.git
synced 2026-01-15 00:35:08 +08:00
feat: 适配 hdk
This commit is contained in:
23
.php-cs-fixer.dist.php
Normal file
23
.php-cs-fixer.dist.php
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* .php-cs-fixer.dist.php@HDK-Core
|
||||||
|
*
|
||||||
|
* @author 李东云 <Dongyun.Li@LuxCreo.Ai>
|
||||||
|
* Powered by PhpStorm
|
||||||
|
* Created on 2023/1/9
|
||||||
|
*/
|
||||||
|
|
||||||
|
$finder = PhpCsFixer\Finder::create()->in([
|
||||||
|
__DIR__ . '/publish',
|
||||||
|
__DIR__ . '/src',
|
||||||
|
__DIR__ . '/tests',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$config = new PhpCsFixer\Config();
|
||||||
|
return $config->setRules([
|
||||||
|
'@PSR12' => true,
|
||||||
|
'strict_param' => true,
|
||||||
|
'array_syntax' => ['syntax' => 'short'],
|
||||||
|
])
|
||||||
|
->setUsingCache(false)
|
||||||
|
->setFinder($finder);
|
||||||
68
.versionrc
Normal file
68
.versionrc
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
{
|
||||||
|
"header": "# 版本更新日志",
|
||||||
|
"preMajor": true,
|
||||||
|
"types": [
|
||||||
|
{
|
||||||
|
"type": "feat",
|
||||||
|
"section": "✨ Features | 新功能"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "fix",
|
||||||
|
"section": "🐛 Bug Fixes | Bug 修复"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "init",
|
||||||
|
"section": "🎉 Init | 初始化"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "docs",
|
||||||
|
"section": "✏️ Documentation | 文档"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "style",
|
||||||
|
"section": "💄 Styles | 风格"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "refactor",
|
||||||
|
"section": "♻️ Code Refactoring | 代码重构"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "perf",
|
||||||
|
"section": "⚡ Performance Improvements | 性能优化"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "tests",
|
||||||
|
"section": "✅ Tests | 测试"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "test",
|
||||||
|
"section": "✅ Tests | 测试"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "revert",
|
||||||
|
"section": "⏪ Revert | 回退"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "build",
|
||||||
|
"section": "📦 Build System | 打包构建"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "chore",
|
||||||
|
"section": "🚀 Chore | 构建/工程依赖/工具"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "ci",
|
||||||
|
"section": "👷 Continuous Integration | CI 配置"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"bumpFiles": [
|
||||||
|
{
|
||||||
|
"filename": "VERSION_TRACKER.txt",
|
||||||
|
"type": "plain-text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename": "composer.json",
|
||||||
|
"type": "json"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -1,44 +1,102 @@
|
|||||||
{
|
{
|
||||||
"name": "singularity/php-package-boilperplate",
|
"name": "singularity/hdk-boilerplate",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"description": "PHP 通用包模板",
|
"description": "HDK 包模板",
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "李东云",
|
||||||
|
"email": "dongyun.li@luxcreo.ai"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"extra": {
|
||||||
|
"hyperf": {
|
||||||
|
"config": "Singularity\\HDK\\Boilerplate\\ConfigProvider"
|
||||||
|
},
|
||||||
|
"hooks": {
|
||||||
|
"config": {
|
||||||
|
"stop-on-failure": [
|
||||||
|
"pre-push"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"pre-push": [
|
||||||
|
"echo committing as $(git config user.name)",
|
||||||
|
"docker run --rm -t -v \"$(pwd)\":/srv/www harbor.luxcreo.cn/library/hyperf:8.0-swoole composer ci"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"Example\\": "src/Example/"
|
"Singularity\\HDK\\Boilerplate\\": "src/"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload-dev": {
|
"autoload-dev": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"Tests\\Example\\": "tests/Example/"
|
"Singularity\\HDK\\Test\\Boilerplate\\": "tests/"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^8.0",
|
"php": "^8.0",
|
||||||
"composer/composer": "~2.0.14"
|
"composer/composer": ">=2.0",
|
||||||
|
"singularity/hdk-core": "^0.2.9",
|
||||||
|
"symfony/polyfill-php81": "^1.27"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^9.5"
|
"brainmaestro/composer-git-hooks": "^2.8",
|
||||||
|
"friendsofphp/php-cs-fixer": "^3.0",
|
||||||
|
"hyperf/devtool": "3.0.*",
|
||||||
|
"hyperf/testing": "3.0.*",
|
||||||
|
"pestphp/pest": "^1.22",
|
||||||
|
"phpstan/phpstan": "^1.10.6",
|
||||||
|
"swoole/ide-helper": "^4.5"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"singularity/hdk-auth": "用户、鉴权相关逻辑必需",
|
||||||
|
"singularity/hyperf-saml": "接入单点登录必需"
|
||||||
},
|
},
|
||||||
"minimum-stability": "dev",
|
|
||||||
"prefer-stable": true,
|
"prefer-stable": true,
|
||||||
"config": {
|
"config": {
|
||||||
"optimize-autoloader": true,
|
"optimize-autoloader": true,
|
||||||
"sort-packages": true
|
"sort-packages": true,
|
||||||
|
"secure-http": false,
|
||||||
|
"allow-plugins": {
|
||||||
|
"pestphp/pest-plugin": true
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"extra": [],
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"post-root-package-install": [
|
"post-root-package-install": [
|
||||||
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
|
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
|
||||||
],
|
],
|
||||||
"test": "vendor/bin/phpunit --prepend test/bootstrap.php -c phpunit.xml --colors=always",
|
"test": [
|
||||||
"cs-fix": "php-cs-fixer fix $1",
|
"rm -rf runtime",
|
||||||
"analyse": "phpstan analyse --memory-limit 300M -l 0 -c phpstan.neon ./app ./config"
|
"Composer\\Config::disableProcessTimeout",
|
||||||
|
"co-phpunit --prepend test/bootstrap.php -c phpunit.xml --colors=always"
|
||||||
|
],
|
||||||
|
"cs-fix": "vendor/bin/php-cs-fixer fix $1 --rules=@PSR12 --allow-risky=yes",
|
||||||
|
"analyse": "vendor/bin/phpstan analyse $1",
|
||||||
|
"ci": [
|
||||||
|
"@analyse publish/ src/ tests/",
|
||||||
|
"@cs-fix",
|
||||||
|
"@test --ci",
|
||||||
|
"echo CI Success"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"repositories": {
|
"repositories": {
|
||||||
|
"lux-map": {
|
||||||
|
"type": "composer",
|
||||||
|
"url": "https://satis.luxcreo.cn/"
|
||||||
|
},
|
||||||
"packagist": {
|
"packagist": {
|
||||||
"type": "composer",
|
"type": "composer",
|
||||||
"url": "https://mirrors.aliyun.com/composer"
|
"url": "https://mirrors.aliyun.com/composer/"
|
||||||
|
},
|
||||||
|
"packagist-tx": {
|
||||||
|
"type": "composer",
|
||||||
|
"url": "https://mirrors.cloud.tencent.com/composer/"
|
||||||
|
},
|
||||||
|
"packagist-hw": {
|
||||||
|
"type": "composer",
|
||||||
|
"url": "https://repo.huaweicloud.com/repository/php/"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
5801
composer.lock
generated
5801
composer.lock
generated
File diff suppressed because it is too large
Load Diff
13
phpstan.dist.neon
Normal file
13
phpstan.dist.neon
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
parameters:
|
||||||
|
level: 6
|
||||||
|
reportUnmatchedIgnoredErrors: false
|
||||||
|
checkGenericClassInNonGenericObjectType: false
|
||||||
|
paths:
|
||||||
|
- publish
|
||||||
|
- src
|
||||||
|
- testsi
|
||||||
|
ignoreErrors:
|
||||||
|
- '#Constant BASE_PATH not found#'
|
||||||
|
- '#Property [a-zA-Z0-9\\_]+::\$[a-zA-Z0-9]+ is never written, only read\.#'
|
||||||
|
- '#Method [a-zA-Z0-9\\_]+::[a-zA-Z0-9]+\(\) is unused\.#'
|
||||||
|
- '#Method [a-zA-Z0-9\\_]+::[a-zA-Z0-9]+\(\) has parameter \$response with no value type specified in iterable type array\.#'
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
docker login harbor.luxcreo.cn -u php -p fTr6oVvqqdzVlYgnZhRPPAP54u7SmqGA
|
docker login harbor.luxcreo.cn -u php -p fTr6oVvqqdzVlYgnZhRPPAP54u7SmqGA
|
||||||
|
|
||||||
image_name=harbor.luxcreo.cn/php/composer-template
|
image_name=harbor.luxcreo.cn/php/hdk-boilerplate
|
||||||
docker build --tag $image_name .
|
docker build --tag $image_name .
|
||||||
|
|
||||||
#docker push $image_name
|
#docker push $image_name
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
#!/usr/bin/env sh
|
|
||||||
|
|
||||||
export name
|
|
||||||
export email
|
|
||||||
|
|
||||||
git config --global user.email "${email}"
|
|
||||||
git config --global user.name "${name}"
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
alias ll='ls $LS_OPTIONS -l --color=auto' 2>/dev/null
|
|
||||||
alias l.='ls $LS_OPTIONS -d .* --color=auto' 2>/dev/null
|
|
||||||
alias ls='ls $LS_OPTIONS --color=auto' 2>/dev/null
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
chmod -R 700 ~/.ssh
|
|
||||||
#chmod 600 ~/.ssh/authorized_keys
|
|
||||||
|
|
||||||
#chown -R git:git ~/.ssh
|
|
||||||
9
scripts/docker-env.sh
Executable file
9
scripts/docker-env.sh
Executable file
@@ -0,0 +1,9 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
docker run \
|
||||||
|
--pull always \
|
||||||
|
-ti --rm --name "hdk-boilerplate" \
|
||||||
|
-w "/srv/www" \
|
||||||
|
-v "$(pwd)":/srv/www \
|
||||||
|
-v ~/.ssh:/root/.ssh \
|
||||||
|
harbor.luxcreo.cn/library/hyperf:8.0-swoole /bin/ash
|
||||||
5
scripts/release.sh
Executable file
5
scripts/release.sh
Executable file
@@ -0,0 +1,5 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
docker run --rm -it \
|
||||||
|
-v $(pwd):/app -e "GIT_AUTHOR_NAME=ch4o5" -e "EMAIL=dongyun.li@luxcreo.ai" \
|
||||||
|
detouched/standard-version:latest $1
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
#!/usr/bin/env sh
|
|
||||||
|
|
||||||
docker run \
|
|
||||||
-ti --rm --name "composer-template" \
|
|
||||||
-w "/srv/www" \
|
|
||||||
-v "$(pwd)":/srv/www \
|
|
||||||
-v ~/.ssh:/root/.ssh \
|
|
||||||
-p 8866:80 \
|
|
||||||
php:cli-alpine /bin/ash
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
docker login harbor.luxcreo.cn -u admin -p Mao+690629
|
|
||||||
|
|
||||||
set image_name=composer-template
|
|
||||||
docker build --force-rm=true --target cd --tag %image_name% --target dev --tag %image_name%-dev .
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
@echo off
|
|
||||||
|
|
||||||
for /F %%i in ('chdir') do ( set current_dir=%%i)
|
|
||||||
|
|
||||||
docker run ^
|
|
||||||
-ti --rm --name "composer-template" ^
|
|
||||||
-v "%current_dir%":"/srv/www" ^
|
|
||||||
-v "%USERPROFILE%\.ssh":"/root/.ssh" ^
|
|
||||||
-p 8866:80 ^
|
|
||||||
--env-file=.env ^
|
|
||||||
php:cli-alpine /bin/ash
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
if "%*"=="" (echo <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>/<2F>ļ<EFBFBD><C4BC><EFBFBD> & exit 1) else .\vendor\bin\phpcs.bat %* || echo. & echo <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>⣬<EFBFBD><E2A3AC><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ctrl-c ȡ<><C8A1> & pause &.\vendor\bin\phpcbf %* && echo <20><>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
::@echo off ::<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7>ھ<EFBFBD><DABE>ᱨ<D7BB><E1B1A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֪<EFBFBD><D6AA>ɶԭ<C9B6><D4AD>
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
# Windows 系统常用脚本
|
|
||||||
|
|
||||||
## 格式化
|
|
||||||
```bat
|
|
||||||
.\scripts\win\prettier.bat .\application\alpha.php
|
|
||||||
```
|
|
||||||
47
src/ConfigProvider.php
Normal file
47
src/ConfigProvider.php
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
/**
|
||||||
|
* This file is part of Hyperf.
|
||||||
|
*
|
||||||
|
* @link https://www.hyperf.io
|
||||||
|
* @document https://doc.hyperf.io
|
||||||
|
* @contact group@hyperf.io
|
||||||
|
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Singularity\HDK\Boilerplate;
|
||||||
|
|
||||||
|
class ConfigProvider
|
||||||
|
{
|
||||||
|
/** @phpstan-ignore-next-line */
|
||||||
|
public function __invoke(): array
|
||||||
|
{
|
||||||
|
/** @noinspection PhpUndefinedConstantInspection */
|
||||||
|
return [
|
||||||
|
// 合并到 config/autoload/dependencies.php 文件
|
||||||
|
'dependencies' => [],
|
||||||
|
// 合并到 config/autoload/annotations.php 文件
|
||||||
|
'annotations' => [
|
||||||
|
'scan' => [
|
||||||
|
'paths' => [
|
||||||
|
__DIR__,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
// 默认 Command 的定义,合并到 Hyperf\Contract\ConfigInterface 内,换个方式理解也就是与 config/autoload/commands.php 对应
|
||||||
|
'commands' => [],
|
||||||
|
// 与 commands 类似
|
||||||
|
'listeners' => [],
|
||||||
|
// 组件默认配置文件,即执行命令后会把 source 的对应的文件复制为 destination 对应的的文件
|
||||||
|
'publish' => [
|
||||||
|
[
|
||||||
|
'id' => 'config',
|
||||||
|
'description' => 'The common config for HDK',
|
||||||
|
'source' => __DIR__ . '/../publish/common.php',
|
||||||
|
'destination' => BASE_PATH . '/config/autoload/common.php',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Example;
|
namespace Singularity\HDK\Boilerplate\Example;
|
||||||
|
|
||||||
class Greeting
|
class Greeting
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,17 +2,17 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Tests\Example;
|
namespace Singularity\HDK\Test\Boilerplate\Example;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Example\Greeting;
|
use Singularity\HDK\Boilerplate\Example\Greeting;
|
||||||
|
|
||||||
class GreetingTest extends TestCase
|
class GreetingTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testItGreetsUser(): void
|
public function testItGreetsUser(): void
|
||||||
{
|
{
|
||||||
$greeting = new Greeting('Rasmus Lerdorf');
|
$greeting = new Greeting('Singularity');
|
||||||
|
|
||||||
$this->assertSame('Hello Rasmus Lerdorf', $greeting->sayHello());
|
$this->assertSame('Hello Singularity', $greeting->sayHello());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user