Beispiel #1
0
 public function run($token)
 {
     $env = Environment::where('token', $token)->first();
     if (is_null($env)) {
         return json_encode(['error' => true, 'output' => 'invalid token']);
     }
     if (\Storage::exists($token . '.php')) {
         $tokenFile = \Storage::disk('local')->getDriver()->getAdapter()->getPathPrefix() . "/" . $token . ".php";
         $output = null;
         $error = false;
         foreach ($this->steps as $step) {
             $command = "dep --ansi --file={$tokenFile} {$step} " . $env->server->host;
             $output .= $command . "\n";
             $process = new Process($command);
             $process->run();
             if (!$process->isSuccessful()) {
                 $output .= $process->getErrorOutput();
                 $error = true;
                 break;
             } else {
                 $output .= $process->getOutput();
             }
         }
         $history = EnvironmentHistory::create(['environment_id' => $env->id, 'status' => $error ? 'fail' : 'success', 'history' => $output]);
         return json_encode(['error' => $error, 'output' => $output]);
     }
 }
 public function show($id)
 {
     $history = EnvironmentHistory::findOrFail($id);
     $theme = new SolarizedTheme();
     $converter = new AnsiToHtmlConverter($theme, false);
     $css = $theme->asCss();
     $output = $converter->convert($history->history);
     return view('history.show', ['history' => $history, 'output' => $output, 'css' => $css]);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $env = Environment::findOrFail($id);
     EnvironmentHistory::where('environment_id', $env->id)->delete();
     \Storage::delete($env->token . '.php');
     $env->delete();
     return redirect()->route('environment.index');
 }