public static function pack($data)
 {
     $cmd = getcwd() . "/" . VENDOR_PATH . "/bin/node " . __DIR__ . "/BrowserPack.js";
     $process = new Symfony\Component\Process\Process($cmd);
     $process->setInput(json_encode($data));
     $process->mustRun();
     return $process->getOutput();
 }
 public static function count($contents)
 {
     $cmd = getcwd() . "/" . VENDOR_PATH . "/bin/node " . KWF_PATH . "/Kwf/Assets/Util/CssSelectorCount.js";
     $cmd .= " 2>&1";
     $process = new Symfony\Component\Process\Process($cmd);
     $process->setEnv(array('NODE_PATH' => getcwd() . '/node_modules'));
     $process->setInput($contents);
     $process->mustRun();
     $out = json_decode($process->getOutput(), true);
     return $out['selectors'];
 }
 public static function parse($filename)
 {
     $cmd = getcwd() . "/" . VENDOR_PATH . "/bin/node " . __DIR__ . "/ModuleDepsParser.js " . $filename;
     $process = new Symfony\Component\Process\Process($cmd);
     $process->mustRun();
     $out = json_decode($process->getOutput(), true);
     $ret = array('source' => $out[0]['source'], 'deps' => array());
     foreach (array_keys($out[0]['deps']) as $i) {
         $ret['deps'][] = $i;
     }
     return $ret;
 }
示例#4
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $dir = implode(DIRECTORY_SEPARATOR, [$this->getContainer()->get('kernel')->getRootDir(), '..', 'utils', 'dumpdb']);
     $command = implode(DIRECTORY_SEPARATOR, [$dir, 'dumpdb']);
     chdir($dir);
     $process = new \Symfony\Component\Process\Process($command);
     $process->mustRun();
     if (!$process->isSuccessful()) {
         throw new ProcessFailedException($process);
     }
     $stderr = $process->getErrorOutput();
     $stderr = trim($stderr);
     $stdout = $process->getOutput();
     $result = implode("\n\n", [$stderr, $stdout]);
     $output->writeln($result);
 }
示例#5
0
 public static function parse($filename)
 {
     if (substr($filename, 0, strlen(getcwd() . '/temp/')) == getcwd() . '/temp/') {
         $cacheId = md5_file($filename);
     } else {
         $cacheId = str_replace(array('/', '.', '-'), '_', $filename) . '__' . md5_file($filename);
     }
     $ret = self::_getCache()->load($cacheId);
     if ($ret === false) {
         $cmd = getcwd() . "/" . VENDOR_PATH . "/bin/node " . __DIR__ . "/Parser.js " . $filename;
         $process = new Symfony\Component\Process\Process($cmd);
         $process->mustRun();
         $out = json_decode($process->getOutput(), true);
         $ret = array();
         foreach (array_keys($out[0]['deps']) as $i) {
             $ret[] = $i;
         }
         self::_getCache()->save($ret, $cacheId);
     }
     return $ret;
 }
 public function filter(Kwf_SourceMaps_SourceMap $sourcemap)
 {
     putenv("NODE_PATH=" . getcwd() . "/node_modules");
     $cmd = getcwd() . "/" . VENDOR_PATH . "/bin/node " . __DIR__ . "/CssChunks.js";
     $cmd .= " 2>&1";
     $process = new Symfony\Component\Process\Process($cmd);
     $process->setInput($sourcemap->getFileContentsInlineMap(false));
     $process->mustRun();
     $out = $process->getOutput();
     $out = explode("\n/* ***** NEXT CHUNK ***** */\n", $out);
     $ret = array();
     foreach ($out as $chunk) {
         if (Kwf_SourceMaps_SourceMap::hasInline($chunk)) {
             $mapChunk = Kwf_SourceMaps_SourceMap::createFromInline($chunk);
         } else {
             $mapChunk = Kwf_SourceMaps_SourceMap::createEmptyMap($chunk);
             $mapChunk->setMimeType('text/css');
         }
         $ret[] = $mapChunk;
     }
     return $ret;
 }
示例#7
0
 /**
  * Adds a web and login system-user.
  *
  * Both are in the <name>_grp group
  *
  * _web has writeaccess to the webroot and nothing else
  * _login has write-access to
  */
 private function taskCreateSystemUserAndGroup()
 {
     // Create the web-user.
     $group_esc = escapeshellarg($this->virtualHostConfiguration['group']);
     $process = new \Symfony\Component\Process\Process('addgroup --force-badname ' . $group_esc);
     try {
         $process->mustRun();
     } catch (ProcessFailedException $e) {
         $this->output->writeln('Could not create the group ' . $this->virtualHostConfiguration['group'] . ': ' . $e->getMessage());
         throw $e;
     }
     $web_homedir_esc = escapeshellarg($this->virtualHostConfiguration['web_homedir']);
     $web_user_esc = escapeshellarg($this->virtualHostConfiguration['web_user']);
     $process = new \Symfony\Component\Process\Process('adduser --force-badname --no-create-home --home ' . $web_homedir_esc . ' --shell /bin/false --disabled-login --gecos \'\' --ingroup ' . $group_esc . ' ' . $web_user_esc);
     try {
         $process->mustRun();
     } catch (ProcessFailedException $e) {
         $this->output->writeln('Unable to create user ' . $this->virtualHostConfiguration['web_user'] . ': ' . $e->getMessage());
         throw $e;
     }
     // Create the login-user.
     $login_homedir_esc = escapeshellarg($this->virtualHostConfiguration['login_homedir']);
     $login_user_esc = escapeshellarg($this->virtualHostConfiguration['login_user']);
     $process = new \Symfony\Component\Process\Process('adduser --force-badname --no-create-home --home ' . $login_homedir_esc . ' --disabled-login --gecos \'\' --ingroup ' . $group_esc . ' ' . $login_user_esc);
     try {
         $process->mustRun();
     } catch (ProcessFailedException $e) {
         $this->output->writeln('Unable to create user ' . $this->virtualHostConfiguration['login_user'] . ': ' . $e->getMessage());
         throw $e;
     }
 }
示例#8
0
        $process->mustRun();
        return $process->getOutput();
    };
    if (is_file($app['docs.path'] . '/README.md')) {
        $output->write($run('git reset --hard origin/master'));
        $output->write($run('git pull https://github.com/deployphp/docs.git master 2>&1'));
    } else {
        $output->write($run('git clone --depth 1 https://github.com/deployphp/docs.git . 2>&1'));
    }
});
$console->add($updateDocumentationCommand);
$updateRecipesCommand = new \Symfony\Component\Console\Command\Command('update:recipes');
$updateRecipesCommand->setCode(function ($input, $output) use($app) {
    $run = function ($command) use($app) {
        $process = new \Symfony\Component\Process\Process('cd ' . $app['recipes.path'] . ' && ' . $command);
        $process->mustRun();
        return $process->getOutput();
    };
    if (is_file($app['recipes.path'] . '/README.md')) {
        $output->write($run('git reset --hard origin/master'));
        $output->write($run('git pull https://github.com/deployphp/recipes.git master 2>&1'));
    } else {
        $output->write($run('git clone --depth 1 https://github.com/deployphp/recipes.git . 2>&1'));
    }
});
$console->add($updateRecipesCommand);
$scheduleCommand = new \Symfony\Component\Console\Command\Command('schedule');
$scheduleCommand->setCode(function ($input, $output) use($app) {
    $commands = explode("\n", file_get_contents($app['schedule']));
    while (count($commands) > 0) {
        $command = array_shift($commands);