4 * wrapper code around js builder...
6 * -- we will use this later to compile on the fly...
10 * $x = new Pman_Core_JsCompile();
11 * $x->pack('/path/to/files/', 'destination')
14 require_once 'Pman.php';
17 class Pman_Core_JsCompile extends Pman
22 // command line only ATM
23 $this->cli = HTML_FlexyFramework::get()->cli;
24 // var_dump($this->cli);
32 function get($proj, $args)
35 die("missing action : eg. build or install");
38 if (empty($args[1])) {
40 $ar = $this->gatherProjects();
41 echo "SELECT Component to build\n";
45 $ar = array($args[1]);
58 case 'install' : // needed for install on remote sites..
69 * wrapper arroudn packer...
70 * @param {Array} $files the files to pack
71 * @param {String} $output name fo file to output
74 function pack($files, $output)
79 $o = HTML_FlexyFramework::get()->Pman_Core;
81 if (empty($o['jspacker']) || !file_exists($o['jspacker'].'/pack.js')) {
82 throw new Exception("no jstoolkit path set [Pman_Core][jspacker] to the
83 introspection documentation directory where pack.js is located.");
85 require_once 'System.php';
86 $seed= System::which('seed');
88 throw new Exception(" no seed installed");
91 foreach($files as $i => $f) {
92 $max = max($max,filemtime($f));
93 $files[$i] = escapeshellarg($f);
95 if ($max < filemtime($output)) {
99 $eoutput = escapeshellarg($f);
100 $cmd = "$seed {$o['jspacker']}/pack.js -o $eoutput " . implode($files, ' ');
105 // we should do more checking.. return val etc..
106 if (file_exists($output) && ($max < filemtime($output) ) ) {
117 * @param {String} $proj name of Pman component to build
118 * runs pack.js -m {proj} -a $src/*.js
123 function build($proj)
125 echo "Building $proj\n";
128 $this->err = "no project";
129 if ($this->cli) echo $this->err;
132 // first item in path is always the app start directory..
133 $src= array_shift(explode(PATH_SEPARATOR, ini_get('include_path'))) .'/Pman/'. $proj;
137 //$tmp = ini_get('session.save_path')."/{$proj}_". posix_getuid(). '_'.md5($src);
140 require_once 'System.php';
141 $seed= System::which('seed');
143 $this->err ="no seed installed";
144 if ($this->cli) echo $this->err;
148 $o = HTML_FlexyFramework::get()->Pman_Core;
150 if (empty($o['jspacker']) || !file_exists($o['jspacker'].'/pack.js')) {
151 $this->err ="no jstoolkit path set [Pman_Core][jspacker] to the
152 introspection documentation directory where pack.js is located.";
153 if ($this->cli) echo $this->err;
157 // should we be more specirfic!??!?!?
159 $cmd = "$seed {$o['jspacker']}/pack.js -m $proj -a $src/*.js";
162 // technically we should trash old compiled files..
163 // or we move towards a 'cache in session directory model..'
168 $ret = $tmp . '/'. $proj . '.js';
170 echo "BUILT: $ret \n";
177 // link {PROJECT}/compiled/{PROJECT}.js to _compiled_ folder to make it live.
179 function install($proj)
182 $base = dirname(realpath($_SERVER["SCRIPT_FILENAME"]));
186 var_dump($base .'/Pman/'. $proj.'/compiled/'.$proj .'.js');
187 $src = realpath($base .'/Pman/'. $proj.'/compiled/'.$proj .'.js');
189 echo "SKIP : no js file $proj\n";
192 if (!file_exists("$base/_compiled_")) {
193 mkdir ("$base/_compiled_", 0755, true);
195 $target = "$base/_compiled_/".$proj .'.js';
196 print_R(array($src,$target));
197 if (file_exists($target)) {
198 return; // already installed.
201 symlink($src, $target);
206 function gatherProjects() {
207 $src= array_shift(explode(PATH_SEPARATOR, ini_get('include_path'))) .'/Pman';
210 foreach(scandir($src) as $f) {
211 if (!strlen($f) || $f[0] == '.') {
219 if ($f == 'templates') {