Example #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]);
     }
 }
 protected function resolveScriptIncludes()
 {
     parent::resolveScriptIncludes();
     $includes = $this->getScriptIncludes();
     $appWebPath = Environment::getVars()->get('appPackageWebPath');
     //TODO
     /*$includes->addFile($appWebPath . '/deps/foo/foo.js', [
     			'bundleKey' => 'app',
     		]);*/
 }
Example #3
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     //$partner_id = \App\Partner::where('acronym','=','MBA')->pluck('id');
     //$application_id = \App\Application::where('acronym','=','MBAGrades')->pluck('id');
     $environment_id = \App\Environment::where('name', '=', 'CEE')->pluck('id');
     DB::table('runs')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'name' => 'Test Run #1', 'description' => 'MBA Grades Smoke Tests', 'start_date_time' => Carbon\Carbon::now()->toDateTimeString(), 'end_date_time' => Carbon\Carbon::now()->toDateTimeString(), 'environment_id' => $environment_id]);
     $partner_id = \App\Partner::where('acronym', '=', 'MBA')->pluck('id');
     $application_id = \App\Application::where('acronym', '=', 'MBAGrades')->pluck('id');
     $environment_id = \App\Environment::where('name', '=', 'CEE')->pluck('id');
     DB::table('runs')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'name' => 'Test Run #2', 'description' => 'MBA Grades Smoke Tests', 'start_date_time' => Carbon\Carbon::now()->toDateTimeString(), 'end_date_time' => Carbon\Carbon::now()->toDateTimeString(), 'environment_id' => $environment_id]);
     $partner_id = \App\Partner::where('acronym', '=', 'MBA')->pluck('id');
     $application_id = \App\Application::where('acronym', '=', 'MBAGrades')->pluck('id');
     $environment_id = \App\Environment::where('name', '=', 'CEE')->pluck('id');
     DB::table('runs')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'name' => 'Test Run #3', 'description' => 'MBA Grades Smoke Tests', 'start_date_time' => Carbon\Carbon::now()->toDateTimeString(), 'end_date_time' => Carbon\Carbon::now()->toDateTimeString(), 'environment_id' => $environment_id]);
     $partner_id = \App\Partner::where('acronym', '=', 'DOC')->pluck('id');
     $application_id = \App\Application::where('acronym', '=', 'DOCGrades')->pluck('id');
     $environment_id = \App\Environment::where('name', '=', 'CEE')->pluck('id');
     DB::table('runs')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'name' => 'Test Run #4', 'description' => 'Doctoral Grades Smoke Tests', 'start_date_time' => Carbon\Carbon::now()->toDateTimeString(), 'end_date_time' => Carbon\Carbon::now()->toDateTimeString(), 'environment_id' => $environment_id]);
     $partner_id = \App\Partner::where('acronym', '=', 'EE')->pluck('id');
     $application_id = \App\Application::where('acronym', '=', 'Atlas')->pluck('id');
     $environment_id = \App\Environment::where('name', '=', 'CEE')->pluck('id');
     DB::table('runs')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'name' => 'Test Run #5', 'description' => 'Atlas Smoke Tests', 'start_date_time' => Carbon\Carbon::now()->toDateTimeString(), 'end_date_time' => Carbon\Carbon::now()->toDateTimeString(), 'environment_id' => $environment_id]);
     $partner_id = \App\Partner::where('acronym', '=', 'EE')->pluck('id');
     $application_id = \App\Application::where('acronym', '=', 'Atlas')->pluck('id');
     $environment_id = \App\Environment::where('name', '=', 'CEE')->pluck('id');
     DB::table('runs')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'name' => 'Test Run #6', 'description' => 'Atlas Smoke Tests', 'start_date_time' => Carbon\Carbon::now()->toDateTimeString(), 'end_date_time' => Carbon\Carbon::now()->toDateTimeString(), 'environment_id' => $environment_id]);
     $partner_id = \App\Partner::where('acronym', '=', 'EE')->pluck('id');
     $application_id = \App\Application::where('acronym', '=', 'Atlas')->pluck('id');
     $environment_id = \App\Environment::where('name', '=', 'CEE')->pluck('id');
     DB::table('runs')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'name' => 'Test Run #7', 'description' => 'Atlas Smoke Tests', 'start_date_time' => Carbon\Carbon::now()->toDateTimeString(), 'end_date_time' => Carbon\Carbon::now()->toDateTimeString(), 'environment_id' => $environment_id]);
     $partner_id = \App\Partner::where('acronym', '=', 'OPS')->pluck('id');
     $application_id = \App\Application::where('acronym', '=', 'QuickCodes')->pluck('id');
     $environment_id = \App\Environment::where('name', '=', 'CEE')->pluck('id');
     DB::table('runs')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'name' => 'Test Run #8', 'description' => 'Quick Codes Smoke Tests', 'start_date_time' => Carbon\Carbon::now()->toDateTimeString(), 'end_date_time' => Carbon\Carbon::now()->toDateTimeString(), 'environment_id' => $environment_id]);
     $partner_id = \App\Partner::where('acronym', '=', 'OPS')->pluck('id');
     $application_id = \App\Application::where('acronym', '=', 'QuickCodes')->pluck('id');
     $environment_id = \App\Environment::where('name', '=', 'CEE')->pluck('id');
     DB::table('runs')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'name' => 'Test Run #9', 'description' => 'Quick Codes Smoke Tests', 'start_date_time' => Carbon\Carbon::now()->toDateTimeString(), 'end_date_time' => Carbon\Carbon::now()->toDateTimeString(), 'environment_id' => $environment_id]);
     $partner_id = \App\Partner::where('acronym', '=', 'OPS')->pluck('id');
     $application_id = \App\Application::where('acronym', '=', 'QuickCodes')->pluck('id');
     $environment_id = \App\Environment::where('name', '=', 'CEE')->pluck('id');
     DB::table('runs')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'name' => 'Test Run #10', 'description' => 'Quick Codes Smoke Tests', 'start_date_time' => Carbon\Carbon::now()->toDateTimeString(), 'end_date_time' => Carbon\Carbon::now()->toDateTimeString(), 'environment_id' => $environment_id]);
     $partner_id = \App\Partner::where('acronym', '=', 'OPS')->pluck('id');
     $application_id = \App\Application::where('acronym', '=', 'QuickCodes')->pluck('id');
     $environment_id = \App\Environment::where('name', '=', 'CEE')->pluck('id');
     DB::table('runs')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'name' => 'Test Run #11', 'description' => 'Quick Codes Smoke Tests', 'start_date_time' => Carbon\Carbon::now()->toDateTimeString(), 'end_date_time' => Carbon\Carbon::now()->toDateTimeString(), 'environment_id' => $environment_id]);
 }
 /**
  * @param array $aOptions
  * @return int The exit status code.
  */
 public static function go(array $aOptions = [])
 {
     $exitCode = 1;
     try {
         //register the composer autoloader
         require_once $aOptions['projectPackageFilePath'] . '/vendor/autoload.php';
         $autoloader = new \Composer\Autoload\ClassLoader();
         $autoloader->addPsr4('App\\', realpath($aOptions['appPackageFilePath'] . '/App'));
         $autoloader->register();
         //boot the environment
         \App\Environment::init(['projectPackageFilePath' => $aOptions['projectPackageFilePath'], 'appPackageFilePath' => $aOptions['appPackageFilePath']]);
         //boot the controller
         $exitCode = \App\Controller::bootstrap();
     } catch (Throwable $e) {
         error_log($e);
     }
     return $exitCode;
 }
 public function markResolved()
 {
     parent::markResolved();
     Env::getStandardOutput()->addEventListener('standard-output', [$this, 'handleStandardOutput']);
 }
 public function getResolvedFiles()
 {
     $resolvedItems = [];
     ksort($this->items);
     foreach ($this->items as $groupIndex => $group) {
         $groupItemCounter = 0;
         foreach ($group as $item) {
             $resolvedUrl = null;
             $resolvedFileFilePath = null;
             //if the item is relative to the app or module
             if ($item['base'] == 'app' || $item['base'] == 'module') {
                 $moduleCode = $this->view->getCode();
                 $chain = $this->view->getController()->getChain($moduleCode);
                 if ($item['base'] == 'app') {
                     $link = array_key_exists('app', $chain) ? $chain['app'] : null;
                 } else {
                     $link = array_key_exists('module', $chain) ? $chain['module'] : null;
                 }
                 if ($link) {
                     $sourceDirUrl = Env::getVars()->get('appSourceWebPath') . '/' . str_replace('\\', '/', $link['namespace']);
                     //if item specifies an explicit file path (relative to link)
                     if ($item['filePath']) {
                         //if file exists on disk
                         if ($path = realpath($link['path'] . $item['filePath'])) {
                             //if item's url is a url path
                             if (mb_substr($item['url'], 0, 1) == '/') {
                                 $resolvedUrl = $sourceDirUrl . $item['url'];
                                 $resolvedFileFilePath = $path;
                             } else {
                                 $resolvedUrl = $item['url'];
                             }
                         }
                     } else {
                         //if file exists on disk
                         if ($path = realpath($link['path'] . $item['url'])) {
                             $resolvedFileFilePath = $path;
                             $resolvedUrl = $sourceDirUrl . $item['url'];
                         }
                     }
                 }
             } else {
                 //if we should check that the file exists in the filesystem
                 if ($item['onlyIfExists']) {
                     if ($item['filePath']) {
                         if ($realPath = realpath($item['filePath'])) {
                             $resolvedFileFilePath = $realPath;
                             $resolvedUrl = $item['url'];
                         }
                     } else {
                         if ($realPath = realpath($item['url'])) {
                             $resolvedFileFilePath = $realPath;
                             $resolvedUrl = $item['url'];
                         }
                     }
                 } else {
                     $resolvedUrl = $item['url'];
                 }
             }
             if ($resolvedUrl) {
                 $resolvedItem = $item;
                 $resolvedItem['resolvedUrl'] = $resolvedUrl;
                 $resolvedItem['resolvedFilePath'] = $resolvedFileFilePath;
                 $resolvedItems[] = $resolvedItem;
                 $groupItemCounter++;
             }
         }
     }
     return $resolvedItems;
 }
Example #7
0
    /**
     * Creates early-output <script> elements used to set up the script environment.
     * @return mixed|string
     * @throws \Exception
     */
    public function createInitScriptElements()
    {
        $this->resolveJsEnvironment();
        $depsPath = Env::getVars()->get('appDependenciesWebPath');
        $jsSystemConfig = $this->getJsEnvironment()->get('systemConfig');
        ob_start();
        ?>
		<script type="text/javascript" src="<?php 
        $this->out($depsPath . '/systemjs/systemjs/dist/system-csp-production.js');
        ?>
" class="appBootstrapScript"></script>

		<script type="text/javascript" class="appBootstrapScript">
			<?php 
        if ($jsSystemConfig) {
            ?>
				System.config(<?php 
            echo JsonUtils::toJson($jsSystemConfig);
            ?>
);
				<?php 
        }
        ?>

			window.define = System.amdDefine;
			window.require = System.amdRequire;
		</script>
		<?php 
        $html = ob_get_clean();
        $html = str_replace("\n", '', $html);
        $html = preg_replace('/\\s{2,}/', '', $html);
        return $html;
    }
 public function handleResolveOptions()
 {
     $options = $this->getController()->getOptions();
     $options->add('pagerPlugin.pagesDirectoryFilePath', Env::getVars()->get('projectPackageFilePath') . '/libs/static-pager');
 }
 public function handleException(Throwable $aEx)
 {
     Env::getLogger()->error((string) $aEx, ['requestId' => Env::getVars()->get('requestId'), 'exception' => $aEx]);
     Env::getStandardOutput()->write('FATAL ERROR: ' . $aEx->getMessage());
 }
 private function doLoad()
 {
     $model = $this->getModel();
     $model->set('requestId', Environment::getVars()->get('requestId'));
 }
 /**
  * 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');
 }
 protected function executeScript()
 {
     $stdout = Environment::getStandardOutput();
     $stdout->write("Hello World.");
 }