mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-23 08:35:35 +08:00
Merge pull request #190 from zhamao-robot/fix-init-command-dir
修复相对路径问题
This commit is contained in:
@@ -8,6 +8,6 @@ class LoadGlobalDefines
|
|||||||
{
|
{
|
||||||
public function bootstrap(array $config): void
|
public function bootstrap(array $config): void
|
||||||
{
|
{
|
||||||
require zm_dir(SOURCE_ROOT_DIR . '/src/Globals/global_defines_framework.php');
|
require FRAMEWORK_ROOT_DIR . '/src/Globals/global_defines_framework.php';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,9 +44,7 @@ class InitCommand extends Command
|
|||||||
'Module\\' => 'src/Module',
|
'Module\\' => 'src/Module',
|
||||||
'Custom\\' => 'src/Custom',
|
'Custom\\' => 'src/Custom',
|
||||||
],
|
],
|
||||||
'files' => [
|
'files' => [],
|
||||||
'src/Custom/global_function.php',
|
|
||||||
],
|
|
||||||
];
|
];
|
||||||
|
|
||||||
$section->write('<fg=gray>更新 composer.json ... </>');
|
$section->write('<fg=gray>更新 composer.json ... </>');
|
||||||
@@ -117,7 +115,6 @@ class InitCommand extends Command
|
|||||||
'/zhamao',
|
'/zhamao',
|
||||||
'/.gitignore',
|
'/.gitignore',
|
||||||
'/config/*',
|
'/config/*',
|
||||||
'/src/Globals/*.php',
|
|
||||||
];
|
];
|
||||||
|
|
||||||
return $this->getFilesFromPatterns($patterns);
|
return $this->getFilesFromPatterns($patterns);
|
||||||
@@ -184,12 +181,7 @@ class InitCommand extends Command
|
|||||||
|
|
||||||
private function getVendorPath(string $file): string
|
private function getVendorPath(string $file): string
|
||||||
{
|
{
|
||||||
try {
|
return FRAMEWORK_ROOT_DIR . $file;
|
||||||
$package_name = json_decode(file_get_contents(__DIR__ . '/../../../composer.json'), true, 512, JSON_THROW_ON_ERROR)['name'];
|
|
||||||
} catch (\JsonException) {
|
|
||||||
throw new InitException('无法读取框架包的 composer.json', '请检查框架包完整性,或者重新安装框架包');
|
|
||||||
}
|
|
||||||
return $this->base_path . '/vendor/' . $package_name . $file;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function extractFiles(array $files, OutputInterface $output): void
|
private function extractFiles(array $files, OutputInterface $output): void
|
||||||
|
|||||||
@@ -28,7 +28,19 @@ final class ConsoleApplication extends Application
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 初始化命令
|
// 初始化命令
|
||||||
$command_classes = FileSystem::getClassesPsr4(zm_dir('src/ZM/Command'), 'ZM\\Command');
|
$command_classes = [];
|
||||||
|
// 先加载框架内置命令
|
||||||
|
$command_classes = array_merge(
|
||||||
|
$command_classes,
|
||||||
|
FileSystem::getClassesPsr4(FRAMEWORK_ROOT_DIR . '/src/ZM/Command', 'ZM\\Command')
|
||||||
|
);
|
||||||
|
// 再加载用户自定义命令(如存在)
|
||||||
|
if (is_dir(SOURCE_ROOT_DIR . '/src/Command')) {
|
||||||
|
$command_classes = array_merge(
|
||||||
|
$command_classes,
|
||||||
|
FileSystem::getClassesPsr4(SOURCE_ROOT_DIR . '/src/Command', 'Command')
|
||||||
|
);
|
||||||
|
}
|
||||||
$commands = [];
|
$commands = [];
|
||||||
foreach ($command_classes as $command_class) {
|
foreach ($command_classes as $command_class) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user