コード例 #1
0
 /**
  * Do this execute.
  *
  * @return  mixed
  */
 protected function doExecute()
 {
     $dest = $this->config['dir.dest'];
     $migName = $this->config['replace.controller.item.name.cap'] . 'Init';
     if (!is_dir($dest . '/Migration')) {
         return;
     }
     // Copy migration
     $files = Folder::files($dest . '/Migration');
     $file = false;
     // If last migration with same name exists, delete duplicated migration.
     foreach ($files as $file) {
         $fileName = pathinfo($file, PATHINFO_BASENAME);
         if (strpos($file, $migName . '.php') !== false && $fileName != '19700101000000_' . $migName . '.php') {
             if (is_file($dest . '/Migration/' . '19700101000000_' . $migName . '.php')) {
                 File::delete($dest . '/Migration/' . '19700101000000_' . $migName . '.php');
             }
             return;
         }
     }
     foreach ($files as $file) {
         if (strpos($file, $migName . '.php') !== false) {
             break;
         }
     }
     // Migration not exists, return.
     if (!$file) {
         return;
     }
     $newName = gmdate('YmdHis') . '_' . $migName . '.php';
     File::move($file, $dest . '/Migration/' . $newName);
     $this->io->out('[<info>Action</info>] Rename migration file to: ' . $newName);
 }
コード例 #2
0
 /**
  * move
  *
  * @param string  $src
  * @param string  $dest
  * @param bool    $force
  *
  * @return  bool
  */
 public static function move($src, $dest, $force = false)
 {
     if (is_dir($src)) {
         Folder::move($src, $dest, $force);
     } elseif (is_file($src)) {
         File::move($src, $dest, $force);
     }
     return true;
 }
コード例 #3
0
 /**
  * Execute the controller.
  *
  * @return  boolean  True if controller finished execution, false if the controller did not
  *                   finish execution. A controller might return false if some precondition for
  *                   the controller to run has not been satisfied.
  *
  * @throws  \LogicException
  * @throws  \RuntimeException
  */
 public function execute()
 {
     // Flip src and dest because we want to convert template.
     $dest = $this->config->get('dir.dest');
     $src = $this->config->get('dir.src');
     $this->config->set('dir.dest', $src);
     $this->config->set('dir.src', $dest);
     $this->doAction(new Action\ConvertTemplateAction());
     // Rename migration
     if (is_dir($src . '/Migration')) {
         $file = Folder::files($src . '/Migration')[0];
         $time = '19700101000000';
         $newFilename = preg_replace('/\\d+(_.+Init\\.php\\.tpl)/', $time . '$1', $file);
         File::move($file, $newFilename);
     }
     return true;
 }
コード例 #4
0
ファイル: Folder.php プロジェクト: rokite/windwalker
 /**
  * Moves a folder.
  *
  * @param   string $src       The path to the source folder.
  * @param   string $dest      The path to the destination folder.
  * @param   bool   $override  Override files.
  *
  * @throws Exception\FilesystemException
  * @return  mixed  Error message on false or boolean true on success.
  *
  * @since    2.0
  */
 public static function move($src, $dest, $override = false)
 {
     if (!is_dir($src)) {
         throw new FilesystemException('Cannot find source folder');
     }
     if (is_dir($dest)) {
         if (!$override) {
             throw new FilesystemException('Folder already exists');
         }
         foreach (static::items($src, true, static::PATH_RELATIVE) as $item) {
             if (is_file($src . '/' . $item)) {
                 File::move($src . '/' . $item, $dest . '/' . $item, true);
             } elseif (is_dir($src . '/' . $item)) {
                 static::create($dest . '/' . $item);
             }
         }
         static::delete($src);
         return true;
     }
     if (!@rename($src, $dest)) {
         throw new FilesystemException('Rename failed');
     }
     return true;
 }
コード例 #5
0
ファイル: FileTest.php プロジェクト: rokite/windwalker
 /**
  * Method to test move().
  *
  * @return void
  *
  * @covers Windwalker\Filesystem\File::move
  */
 public function testMove()
 {
     File::move(static::$dest . '/folder1/path1', static::$dest . '/folder2/level3/path2');
     $this->assertFileExists(static::$dest . '/folder2/level3/path2');
     // Move force
     File::move(static::$dest . '/folder1/level2/file3', static::$dest . '/folder2/level3/path2', true);
     $this->assertFileExists(static::$dest . '/folder2/level3/path2');
 }
コード例 #6
0
ファイル: config.php プロジェクト: ZerGabriel/flarum-notify
    $task->writeln('Copying files over.');
    recursiveCopy('dev', $basepath, $distfolder);
    $task->writeln('Running composer');
    $task->exec(function ($process) {
        $basepath = realpath(__DIR__ . '/..');
        $distfolder = Path::clean($basepath . '/dist');
        $distfolder = str_replace(' ', '\\ ', $distfolder);
        $process->runLocally("cd " . $distfolder . '/dev' . " && composer install --prefer-dist --optimize-autoloader");
        $process->runLocally("cd .. && cd ..");
    });
    Folder::move($distfolder . '/dev', $distfolder . '/notify');
    $task->writeln('Zipping');
    $zippy = Zippy::load();
    $archive = $zippy->create('flarum-notify.zip', array('notify' => $distfolder . '/notify'));
    $task->writeln('Deleting copied folder');
    Folder::delete($distfolder . '/notify');
    File::move($basepath . '/flarum-notify.zip', $distfolder . '/flarum-notify.zip');
})->description("Builds a release ready package from the current project state and stores it in /dist.");
function recursiveCopy($filename, $initialfolder, $targetfolder)
{
    $badfiles = ['vendor', 'node_modules', '.DS_Store', 'sftp-config.json', '.git', '.gitignore', 'build.sh'];
    foreach (Folder::items($initialfolder . '/' . $filename, false, Folder::PATH_BASENAME) as $item) {
        if (!in_array($item, $badfiles)) {
            if (is_dir($initialfolder . '/' . $filename . '/' . $item)) {
                recursiveCopy($item, $initialfolder . '/' . $filename, $targetfolder . '/' . $filename);
            } else {
                File::copy($initialfolder . '/' . $filename . '/' . $item, $targetfolder . '/' . $filename . '/' . $item);
            }
        }
    }
}