Exemple #1
0
 public function __construct($config)
 {
     $this->config = $config;
     $dir = dirname(__FILE__);
     if (file_exists($dir . '/repos.yml')) {
         $this->repos = YAML::decode_file($dir . '/repos.yml');
         if ($this->verify_repos() && file_exists($dir . '/flat.yml')) {
             $this->flat = YAML::decode_file($dir . '/flat.yml');
         } else {
             $this->flat = $this->flatten($this->repos);
         }
     } else {
         $this->rebuild();
     }
     //write file back out
     file_put_contents($dir . '/repos.yml', YAML::encode($this->repos));
     file_put_contents($dir . '/flat.yml', YAML::encode($this->flat));
 }
Exemple #2
0
 private function parse_manifest($package_path)
 {
     $package_path = preg_replace('/\\/$/', '', $package_path) . '/';
     $manifest = YAML::decode_file($package_path . 'package.yml');
     if (empty($manifest)) {
         throw new Exception("package.yml not found in {$package_path}, or unable to parse manifest.");
     }
     $package_name = $manifest['name'];
     if ($this->root == null) {
         $this->root = $package_name;
     }
     if (array_has($this->manifests, $package_name)) {
         return;
     }
     $manifest['path'] = $package_path;
     $this->manifests[$package_name] = $manifest;
     foreach ($manifest['sources'] as $i => $path) {
         $path = $package_path . $path;
         // this is where we "hook" for possible other replacers.
         $source = $this->replace_build($package_path, file_get_contents($path));
         $descriptor = array();
         // get contents of first comment
         preg_match('/^\\s*\\/\\*\\s*(.*?)\\s*\\*\\//s', $source, $matches);
         if (!empty($matches)) {
             // get contents of YAML front matter
             preg_match('/^-{3}\\s*$(.*?)^(?:-{3}|\\.{3})\\s*$/ms', $matches[1], $matches);
             if (!empty($matches)) {
                 $descriptor = YAML::decode($matches[1]);
             }
         }
         // populate / convert to array requires and provides
         $requires = (array) (!empty($descriptor['requires']) ? $descriptor['requires'] : array());
         $provides = (array) (!empty($descriptor['provides']) ? $descriptor['provides'] : array());
         $file_name = !empty($descriptor['name']) ? $descriptor['name'] : basename($path, '.js');
         // "normalization" for requires. Fills up the default package name from requires, if not present.
         foreach ($requires as $i => $require) {
             $requires[$i] = implode('/', $this->parse_name($package_name, $require));
         }
         $license = array_get($descriptor, 'license');
         $this->packages[$package_name][$file_name] = array_merge($descriptor, array('package' => $package_name, 'requires' => $requires, 'provides' => $provides, 'source' => $source, 'path' => $path, 'package/name' => $package_name . '/' . $file_name, 'license' => empty($license) ? array_get($manifest, 'license') : $license));
     }
 }
Exemple #3
0
 public function __construct($manifest_path)
 {
     $this->package_path = dirname($manifest_path) . '/';
     $this->manifest = YAML::decode_file($manifest_path);
     $this->files = array();
     foreach ($this->manifest['sources'] as $i => $path) {
         $path = $this->package_path . $path;
         $file = file_get_contents($path);
         // yaml header
         preg_match("/\\/\\*\\s*[-]{3}(.*)[.]{3}\\s*\\*\\//s", $file, $matches);
         // this is a crappy regexp :)
         // hack to support unindented lists. hell might break loose. -- Taken from http://github.com/Guille/PluginsKit by Guillermo Rauch
         $rawYAML = preg_replace('/$([\\s]+)-/m', '$1 -', trim($matches[1]));
         $descriptor = YAML::decode($rawYAML);
         // populate / convert to array requires and provides
         if (!empty($descriptor['requires'])) {
             if (!is_array($descriptor['requires'])) {
                 $descriptor['requires'] = array($descriptor['requires']);
             }
         } else {
             $descriptor['requires'] = array();
         }
         if (!empty($descriptor['provides'])) {
             if (!is_array($descriptor['provides'])) {
                 $descriptor['provides'] = array($descriptor['provides']);
             }
         } else {
             $descriptor['provides'] = array();
         }
         if (!array_key_exists('name', $descriptor)) {
             $descriptor['name'] = basename($path, '.js');
         }
         // Strip out beginning "/" to support `requires: [/Foo, /Bar]`
         foreach ($descriptor['requires'] as $key => $require) {
             $descriptor['requires'][$key] = preg_replace('/^\\//', '', $require);
         }
         $this->files[$descriptor['name']] = array('description' => $descriptor['description'], 'requires' => $descriptor['requires'], 'provides' => $descriptor['provides'], 'source' => $file, 'path' => $path);
     }
 }
Exemple #4
0
 private function parse_manifest($path)
 {
     $pathinfo = pathinfo($path);
     if (is_dir($path)) {
         $package_path = $pathinfo['dirname'] . '/' . $pathinfo['basename'] . '/';
         if (file_exists($package_path . 'package.yml')) {
             $manifest_path = $package_path . 'package.yml';
             $manifest_format = 'yaml';
         } else {
             if (file_exists($package_path . 'package.yaml')) {
                 $manifest_path = $package_path . 'package.yaml';
                 $manifest_format = 'yaml';
             } else {
                 if (file_exists($package_path . 'package.json')) {
                     $manifest_path = $package_path . 'package.json';
                     $manifest_format = 'json';
                 }
             }
         }
     } else {
         if (file_exists($path)) {
             $package_path = $pathinfo['dirname'] . '/';
             $manifest_path = $package_path . $pathinfo['basename'];
             $manifest_format = $pathinfo['extension'];
         }
     }
     if ($manifest_format == 'json') {
         $manifest = json_decode(file_get_contents($manifest_path), true);
     } else {
         if ($manifest_format == 'yaml' || $manifest_format == 'yml') {
             $manifest = YAML::decode_file($manifest_path);
         }
     }
     if (empty($manifest)) {
         throw new Exception("manifest not found in {$package_path}, or unable to parse manifest.");
     }
     $package_name = $manifest['name'];
     if ($this->root == null) {
         $this->root = $package_name;
     }
     if (array_has($this->manifests, $package_name)) {
         return;
     }
     $manifest['path'] = $package_path;
     $manifest['manifest'] = $manifest_path;
     $this->manifests[$package_name] = $manifest;
     foreach ($manifest['sources'] as $i => $path) {
         $path = $package_path . $path;
         // this is where we "hook" for possible other replacers.
         $source = file_get_contents($path);
         $descriptor = array();
         // get contents of first comment
         preg_match('/\\/\\*\\s*^---(.*?)^\\.\\.\\.\\s*\\*\\//ms', $source, $matches);
         if (!empty($matches)) {
             $descriptor = YAML::decode($matches[0]);
         }
         // populate / convert to array requires and provides
         $requires = (array) (!empty($descriptor['requires']) ? $descriptor['requires'] : array());
         $provides = (array) (!empty($descriptor['provides']) ? $descriptor['provides'] : array());
         $file_name = !empty($descriptor['name']) ? $descriptor['name'] : basename($path, '.js');
         // "normalization" for requires. Fills up the default package name from requires, if not present.
         foreach ($requires as $i => $require) {
             $requires[$i] = implode('/', $this->parse_name($package_name, $require));
         }
         $license = array_get($descriptor, 'license');
         $this->packages[$package_name][$file_name] = array_merge($descriptor, array('package' => $package_name, 'requires' => $requires, 'provides' => $provides, 'source' => $source, 'path' => $path, 'package/name' => $package_name . '/' . $file_name, 'license' => empty($license) ? array_get($manifest, 'license') : $license));
     }
 }
Exemple #5
0
<?php

putenv('LC_ALL=en_US.UTF-8');
setlocale(LC_ALL, null);
require "libs/packager/packager.php";
require "libs/control/control.php";
require "libs/markdown.php";
$packages = YAML::decode_file('packages.yml');
if (empty($packages)) {
    $packages = array();
}
$config = YAML::decode_file('config.yml');
if (empty($config['view']['theme'])) {
    $config['view']['theme'] = 'packager';
}
Control::config('default_controller', 'web');
new Control();
Exemple #6
0
<?php

// connect database
$db_conf = YAML::decode_file('config/database.yml');
$mysql = mysql_connect($db_conf[ENV]['host'] . ':' . $db_conf[ENV]['port'], $db_conf[ENV]['user'], $db_conf[ENV]['pass']) or die('Could not connect: ' . mysql_error());
mysql_select_db($db_conf[ENV]['database']) or die('Could not select database');
Exemple #7
0
 function __construct($params = array())
 {
     $this->properties = YAML::decode_file("db/schemas/{$this->table}.yml");
     $this->set_properties($params);
 }