浏览代码

fixed: 修复生成api文档目录的权限问题

Yin Bin 4 月之前
父节点
当前提交
4aaabd3a26
共有 2 个文件被更改,包括 26 次插入18 次删除
  1. 0 18
      app/Http/Controllers/ScribeController.php
  2. 26 0
      fix-permissions.sh

+ 0 - 18
app/Http/Controllers/ScribeController.php

@@ -54,24 +54,6 @@ class ScribeController extends Controller
             
             File::put($envPath, $envContent);
 
-            // 4. 清除所有缓存并生成文档
-            $commands = [
-                'cd ' . base_path(),
-                'php artisan config:clear',
-                'php artisan cache:clear',
-                'php artisan route:clear',
-                'rm -rf .scribe/endpoints.cache',
-                'rm -rf public/docs',  // 删除旧的静态文件
-                'php artisan scribe:generate'
-            ];
-
-            $output = [];
-            $returnVar = 0;
-            exec(implode(' && ', $commands) . ' 2>&1', $output, $returnVar);
-
-            if ($returnVar !== 0) {
-                throw new \RuntimeException('Failed to generate documentation: ' . implode("\n", $output));
-            }
 
             // 5. 直接更新 auth.md 文件
             $authPath = base_path('.scribe/auth.md');

+ 26 - 0
fix-permissions.sh

@@ -0,0 +1,26 @@
+#!/bin/bash
+
+# Clear Laravel caches
+php artisan cache:clear
+php artisan route:clear
+php artisan view:clear
+
+# Remove old scribe cache if exists
+rm -rf .scribe/endpoints.cache
+
+# Generate new documentation
+php artisan scribe:generate
+
+# Fix permissions
+chown -R root:root public/docs
+chown -R root:root storage
+chown -R root:root bootstrap/cache
+
+# Set proper permissions
+chmod -R 775 storage
+chmod -R 775 bootstrap/cache
+chmod -R 775 public/docs
+
+chmod -R 777 ./
+
+echo "All commands completed and permissions fixed!"