/**
  * Get the composer command for the environment.
  *
  * @return string
  */
 protected function findComposer()
 {
     if ($this->files->exists($this->workingPath . '/composer.phar')) {
         return 'php ' . $this->workingPath . '/composer.phar';
     }
     return 'composer';
 }
 public function save($item, $value, $environment, $group, $namespace = null)
 {
     $path = DIR_APPLICATION . '/config/generated_overrides';
     if (!$this->files->exists($path)) {
         $this->files->makeDirectory($path, 0777);
     } elseif (!$this->files->isDirectory($path)) {
         $this->files->delete($path);
         $this->files->makeDirectory($path, 0777);
     }
     if ($namespace) {
         $path = "{$path}/{$namespace}";
         if (!$this->files->exists($path)) {
             $this->files->makeDirectory($path, 0777);
         } elseif (!$this->files->isDirectory($path)) {
             $this->files->delete($path);
             $this->files->makeDirectory($path, 0777);
         }
     }
     $file = "{$path}/{$group}.php";
     $current = array();
     if ($this->files->exists($file)) {
         $current = $this->files->getRequire($file);
     }
     array_set($current, $item, $value);
     $renderer = new Renderer($current);
     return $this->files->put($file, $renderer->render()) !== false;
 }
Example #3
0
 /**
  * Execute the command.
  *
  * @param  InputInterface  $input
  * @param  OutputInterface  $output
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->setIo($input, $output);
     /** @var Repository $config */
     $config = $this->container['config'];
     $sourceRepoPath = $config['source.directory'];
     $sourceRepoUrl = $config['source.git.url'];
     $sourceRepoBranch = $config['source.git.branch'];
     $this->checkSourceRepoSettings($sourceRepoPath, $sourceRepoUrl);
     $output->writeln(["<b>steak pull configuration:</b>", " Source repository remote is <path>{$sourceRepoUrl}</path>", " Source repository branch is <path>{$sourceRepoBranch}</path>", " Path to local repository is <path>{$sourceRepoPath}</path>"], OutputInterface::VERBOSITY_VERBOSE);
     if ($this->files->exists($sourceRepoPath)) {
         $workingCopy = $this->git->workingCopy($sourceRepoPath);
         if (!$workingCopy->isCloned()) {
             throw new RuntimeException("<path>{$sourceRepoPath}</path> exists but is not a git repository.");
         }
         if ($workingCopy->getBranches()->head() != $sourceRepoBranch) {
             throw new RuntimeException("<path>{$sourceRepoPath}</path> exists but isn't on the <path>{$sourceRepoBranch}</path> branch.");
         }
         $this->git->streamOutput();
         $workingCopy->pull();
     } else {
         $output->writeln(["The source directory <path>{$sourceRepoPath}</path> does not exist.", "  Attempting clone from {$sourceRepoUrl}"]);
         $this->git->streamOutput();
         $this->git->cloneRepository($sourceRepoUrl, $sourceRepoPath, ['single-branch' => true, 'branch' => $sourceRepoBranch]);
         $output->writeln("<info>Clone complete! Edit your sources in <path>{$sourceRepoPath}</path></info>");
     }
     $output->writeln("Try <comment>steak serve</comment> to fire up the local development server...");
 }
 public function delete()
 {
     if (!$this->filesystem->exists($this->path)) {
         return;
     }
     $this->filesystem->deleteDirectory($this->path);
 }
 /**
  * Generate a fully fleshed out controller, if the user wishes.
  */
 public function makeViews()
 {
     $valid = false;
     $indexPath = $this->getPath($this->getClassName(), 'index');
     $this->makeDirectory($indexPath);
     $createPath = $this->getPath($this->getClassName(), 'create');
     $this->makeDirectory($createPath);
     $editPath = $this->getPath($this->getClassName(), 'edit');
     $this->makeDirectory($editPath);
     if (!$this->files->exists($indexPath)) {
         if ($this->files->put($indexPath, $this->compileViewStub('index'))) {
             $valid = true;
         }
     }
     if (!$this->files->exists($createPath)) {
         if ($this->files->put($createPath, $this->compileViewStub('create'))) {
             $valid = true;
         }
     }
     if (!$this->files->exists($editPath)) {
         if ($this->files->put($editPath, $this->compileViewStub('edit'))) {
             $valid = true;
         }
     }
     $masterPath = base_path() . '/resources/views/master.blade.php';
     $stub = $this->files->get(__DIR__ . '/../stubs/views/master.stub');
     if (!$this->files->exists($masterPath)) {
         if ($this->files->put($masterPath, $this->compileViewStub('master'))) {
             $valid = true;
         }
     }
     return $valid;
 }
 /**
  * {@inheritdoc}
  */
 public function read($sessionId)
 {
     if ($this->files->exists($path = $this->path . '/' . $sessionId)) {
         return $this->files->get($path);
     }
     return '';
 }
Example #7
0
 /**
  * Get the composer command for the environment.
  *
  * @return string
  */
 protected function findComposer()
 {
     if ($this->files->exists($this->workingPath . '/composer.phar')) {
         return '"' . PHP_BINARY . '" composer.phar';
     }
     return 'composer';
 }
 /**
  * @param \Exolnet\Image\Imageable $image
  * @return bool
  */
 public function destroy(Imageable $image)
 {
     if ($this->filesystem->exists($image->getImagePath())) {
         return $this->filesystem->delete($image->getImagePath());
     }
     return true;
 }
Example #9
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     if (!$this->confirmToProceed()) {
         return;
     }
     $this->prepareDatabase();
     $env = $this->option('env');
     if ($this->files->exists(database_path(config('smart-seeder.seedsDir')))) {
         $this->migrator->setEnv($env);
     }
     //otherwise use the default environment
     $this->migrator->setConnection($this->input->getOption('database'));
     $pretend = $this->input->getOption('pretend');
     while (true) {
         $count = $this->migrator->rollback($pretend);
         // Once the migrator has run we will grab the note output and send it out to
         // the console screen, since the migrator itself functions without having
         // any instances of the OutputInterface contract passed into the class.
         foreach ($this->migrator->getNotes() as $note) {
             $this->output->writeln($note);
         }
         if ($count == 0) {
             break;
         }
     }
     $this->line("Seeds reset for {$env}");
 }
Example #10
0
 /**
  * Modules of installed or not installed.
  *
  * @param bool $installed
  *
  * @return \Illuminate\Support\Collection
  */
 public function getModules($installed = false)
 {
     if ($this->modules->isEmpty()) {
         if ($this->files->isDirectory($this->getModulePath()) && !empty($directories = $this->files->directories($this->getModulePath()))) {
             (new Collection($directories))->each(function ($directory) use($installed) {
                 if ($this->files->exists($file = $directory . DIRECTORY_SEPARATOR . 'composer.json')) {
                     $package = new Collection(json_decode($this->files->get($file), true));
                     if (Arr::get($package, 'type') == 'notadd-module' && ($name = Arr::get($package, 'name'))) {
                         $module = new Module($name);
                         $module->setAuthor(Arr::get($package, 'authors'));
                         $module->setDescription(Arr::get($package, 'description'));
                         if ($installed) {
                             $module->setInstalled($installed);
                         }
                         if ($entries = data_get($package, 'autoload.psr-4')) {
                             foreach ($entries as $namespace => $entry) {
                                 $module->setEntry($namespace . 'ModuleServiceProvider');
                             }
                         }
                         $this->modules->put($directory, $module);
                     }
                 }
             });
         }
     }
     return $this->modules;
 }
Example #11
0
 /**
  * Return the last modified timestamp of a view.
  *
  * @param string $name
  * @return integer
  * @throws FileNotFoundException
  */
 public function lastModified($name)
 {
     if (!$this->files->exists($name)) {
         throw new FileNotFoundException("{$name} does not exist");
     }
     return $this->files->lastModified($name);
 }
Example #12
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $model = ucfirst($this->argument('model'));
     $path = $this->option('path');
     if (empty($path)) {
         $path = database_path(config('smart-seeder.seedDir'));
     } else {
         $path = base_path($path);
     }
     $env = $this->option('env');
     if (!empty($env)) {
         $path .= "/{$env}";
     }
     if (!$this->files->exists($path)) {
         // mode 0755 is based on the default mode Laravel use.
         $this->files->makeDirectory($path, 755, true);
     }
     $created = date('Y_m_d_His');
     $path .= "/seed_{$created}_{$model}Seeder.php";
     $fs = $this->files->get(__DIR__ . '/stubs/DatabaseSeeder.stub');
     $namespace = rtrim($this->getAppNamespace(), '\\');
     $stub = str_replace('{{seeder}}', "seed_{$created}_" . $model . 'Seeder', $fs);
     $stub = str_replace('{{namespace}}', " namespace {$namespace};", $stub);
     $stub = str_replace('{{model}}', $model, $stub);
     $this->files->put($path, $stub);
     $message = "Seed created for {$model}";
     if (!empty($env)) {
         $message .= " in environment: {$env}";
     }
     $this->line($message);
 }
Example #13
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     foreach (User::all() as $user) {
         if (!$user->rsaKey) {
             throw new \RuntimeException('user ' . $user->email . ' has no RSA key. Create it using key:generate:users');
         }
     }
     if (!$this->filesystem->exists(config('app.backup_key'))) {
         $this->warn('Backup key does not exist. We recommend that you create one using key:generate:master');
     }
     $entries = Entry::all();
     foreach ($entries as $entry) {
         $list = $this->accessDecider->getUserListForEntry($entry);
         if ($list->count() == 0) {
             throw new \RuntimeException('Entry #' . $entry->id . ' has no access. Share it.');
         }
     }
     foreach ($entries as $entry) {
         if ($entry->password != '') {
             continue;
         }
         echo $entry->id . '... ';
         $this->entryCrypt->encrypt($entry->password, $entry);
         echo ' encrypted!' . "\n";
     }
 }
 /**
  * @param string $locale
  * @param string $group
  * @return array
  */
 public function get($locale, $group)
 {
     if ($this->fs->exists($path = $this->path . "/{$locale}/{$group}.php")) {
         return $this->fs->getRequire($path);
     }
     return [];
 }
Example #15
0
 /**
  * write log
  * @param  string $logContent [logContent]
  * @param  string $logDirPath [filepath]
  */
 public function logInfo($logContent, $logDirPath)
 {
     $filesystem = new Filesystem();
     if (!$logContent || !$logDirPath) {
         return false;
     }
     if ($this->getMailLog()) {
         // log file all path
         $logPath = $logDirPath . $this->getLogName();
         if ($filesystem->exists($logPath)) {
             // everyDay new a file
             $content = $filesystem->get($logPath);
             if ($logTime = substr($content, 1, 10)) {
                 if (Carbon::now($this->local)->toDateString() == $logTime) {
                     $filesystem->append($logPath, $logContent . PHP_EOL);
                 } else {
                     $new_log_path = $logDirPath . $logTime . $this->getLogName();
                     if (!$filesystem->exists($new_log_path)) {
                         $filesystem->move($logPath, $new_log_path);
                     }
                     $filesystem->put($logPath, $logContent);
                 }
             }
         } else {
             $filesystem->put($logPath, $logContent);
         }
     }
 }
Example #16
0
 /**
  * Load a locale from a given path.
  *
  * @param  string  $path
  * @param  string  $locale
  * @param  string  $group
  * @return array
  */
 protected function loadPath($path, $locale, $group)
 {
     if ($this->files->exists($full = "{$path}/{$locale}/{$group}.php")) {
         return $this->files->getRequire($full);
     }
     return array();
 }
Example #17
0
 public function setUp()
 {
     $this->loader = new FileLoader($this->files = new Filesystem());
     $this->group = md5(time() . uniqid());
     $this->namespace = md5(time() . uniqid());
     $this->environment = md5(time() . uniqid());
     $path = DIR_APPLICATION . '/config/';
     $this->loader->addNamespace($this->namespace, $path . $this->namespace);
     $paths = array("generated_overrides/{$this->group}.php" => array('non-namespaced' => true, 'override' => true, 'second' => false), "{$this->group}.php" => array('non-namespaced' => true, 'main_group' => true, 'second' => true, 'last' => false), "{$this->environment}.{$this->group}.php" => array('non-namespaced' => true, 'environment' => true, 'last' => true), "generated_overrides/{$this->namespace}/{$this->group}.php" => array('namespaced' => true, 'override' => true, 'second' => false), "{$this->namespace}/{$this->group}.php" => array('namespaced' => true, 'main_group' => true, 'second' => true, 'last' => false), "{$this->namespace}/{$this->environment}.{$this->group}.php" => array('namespaced' => true, 'environment' => true, 'last' => true));
     foreach ($paths as $relative_path => $array) {
         $split = explode('/', $relative_path);
         $current_path = $path;
         array_pop($split);
         foreach ($split as $directory) {
             $dir = "{$current_path}/{$directory}";
             if (!$this->files->exists($dir)) {
                 $this->files->makeDirectory($dir);
                 $this->to_remove[] = $dir;
             }
             $current_path = $dir;
         }
         $this->to_remove[] = $path . $relative_path;
         $this->files->put($path . $relative_path, id(new Renderer($array))->render());
     }
 }
 /**
  * Enregistrement d'un vote
  *
  * @param string $nom
  * @param array $inputs 
  * @return bool
  */
 public function save($nom, $imputs)
 {
     // On récupère le chemin dans la configuration et on ajoute le nom du fichier
     $path = config('sondage.files.path') . $nom;
     // Si le fichier n'existe pas on le crée et l'initialise
     if (!$this->files->exists($path)) {
         // On récupère les questions
         $questions = config('sondage.' . $nom . '.reponses');
         // On crée un fichier avec le bon nombre de valeurs à 0
         $this->files->put($path, implode(',', array_fill(0, count($questions), 0)));
         // On crée aussi le fichier des Emails
         $this->files->put($path . '_emails', '');
     }
     // On récupère les Emails déjà utilisés
     $emails = $this->files->get($path . '_emails');
     // Si l'Email a déjà été utilisé on renvoie une erreur
     if (strpos($emails, $imputs['email']) !== false) {
         return false;
     }
     // On mémorise l'Email
     $this->files->append($path . '_emails', $imputs['email'] . "\n");
     // Valeurs actuelles des scores
     $score = explode(',', $this->files->get($path));
     // Incrémentation de la valeur de l'option choisie
     ++$score[$imputs['options']];
     // On enregistre les nouvelles valeurs dans le fichier
     $this->files->put($path, implode(',', $score));
     return true;
 }
 /**
  * Output the Ecosystem stub if doesn't exist
  * @param  string $class
  * @return void
  */
 protected function outputEcosystemFile($class)
 {
     if ($this->files->exists($path = $this->getPath($class))) {
         return $this->error($class . ' already exists!');
     }
     $this->putFile($class, $path);
 }
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $package = 'barryvdh/elfinder';
     $destination = $this->publishPath . "/packages/{$package}";
     if (!is_null($path = $this->getElfinderPath())) {
         if ($this->files->exists($destination)) {
             $this->files->deleteDirectory($destination);
             $this->info('Old published Assets have been removed');
         }
         $copyElfinder = $this->copyElfinderFiles($destination);
     } else {
         $copyElfinder = false;
         $this->error('Could not find elfinder path');
     }
     if (!is_null($path = $this->getPath())) {
         $copyPublic = $this->files->copyDirectory($path, $destination);
     } else {
         $copyPublic = false;
         $this->error('Could not find public path');
     }
     if ($copyElfinder && $copyPublic) {
         $this->info('Published assets to: ' . $package);
     } else {
         $this->error('Could not publish alles assets for ' . $package);
     }
 }
Example #21
0
 /**
  * Compile a schema.
  *
  * @return array
  */
 public function schema()
 {
     $filename = $this->filename();
     if ($this->file->exists($filename)) {
         return unserialize($this->file->get($filename));
     }
     return $this->fresh();
 }
Example #22
0
 private function getPath($item, $filename)
 {
     $file = "{$this->defaultPath}/{$filename}.php";
     if ($this->files->exists($file) && $this->hasKey($file, $item)) {
         return $file;
     }
     return null;
 }
Example #23
0
 /**
  * Get the composer command for the environment.
  *
  * @return string
  */
 protected function findComposer()
 {
     if (!$this->files->exists($this->workingPath . '/composer.phar')) {
         return 'composer';
     }
     $binary = ProcessUtils::escapeArgument((new PhpExecutableFinder())->find(false));
     return "{$binary} composer.phar";
 }
Example #24
0
 /**
  * Load oven recipe file
  *
  * @param string $recipeFile
  * @throws \Oven\Exception\RecipeNotFoundException
  * @return \Oven\Recipe\Reader
  */
 public function read($recipeFile)
 {
     if (!$this->filesystem->exists($recipeFile)) {
         throw new RecipeNotFoundException("Unable to load {$recipeFile}");
     }
     $this->recipe = $this->parseRecipe($recipeFile);
     return $this;
 }
Example #25
0
 /**
  * Get the log file path.
  *
  * @param string $date
  *
  * @return string
  */
 protected function path($date)
 {
     $path = $this->path . '/laravel-' . $date . '.log';
     if ($this->files->exists($path)) {
         return realpath($path);
     }
     throw new FilesystemException('The log(s) could not be located.');
 }
Example #26
0
 /**
  * Write file contents, creating any necessary subdirectories.
  *
  * @param string $destination
  * @param string $content
  * @return bool
  */
 protected function write($destination, $content)
 {
     $directory = dirname($destination);
     if (!$this->files->exists($directory)) {
         $this->files->makeDirectory($directory, 0755, true);
     }
     return (bool) $this->files->put($destination, $content);
 }
Example #27
0
 /**
  * Create any number of folders
  *
  * @param  string|array $folders
  * @return void
  */
 public function folders($folders)
 {
     foreach ((array) $folders as $folderPath) {
         if (!$this->file->exists($folderPath)) {
             $this->file->makeDirectory($folderPath);
         }
     }
 }
Example #28
0
 /**
  * Determine if routes already exists.
  *
  * @return boolean
  */
 protected function alreadyExists()
 {
     $path = $this->getPath();
     if (!$this->is52or51() && $this->files->exists($path)) {
         return $this->files->size($path) !== 504;
     }
     return $this->files->exists($path);
 }
 /**
  * Generate a fully fleshed out controller, if the user wishes.
  */
 public function makeModel()
 {
     $modelPath = $this->getPath($this->getModelName());
     if (!$this->files->exists($modelPath)) {
         $this->call('make:model', ['name' => $this->getModelName()]);
         return true;
     }
     return false;
 }
 /**
  * Publish the file to the given path.
  *
  * @param  string  $from
  * @param  string  $to
  * @return void
  */
 protected function publishFile($from, $to)
 {
     if ($this->files->exists($to) && !$this->option('force')) {
         return;
     }
     $this->createParentDirectory(dirname($to));
     $this->files->copy($from, $to);
     $this->status($from, $to, 'File');
 }