4 * wrapper code around js builder...
6 * -- we will use this later to compile on the fly...
8 require_once 'Pman.php';
11 class Pman_Core_JsCompile extends Pman
16 // command line only ATM
17 $this->cli = HTML_FlexyFramework::get()->cli;
18 // var_dump($this->cli);
26 function get($proj, $args)
29 die("missing action : eg. build or install");
32 if (empty($args[1])) {
34 $ar = $this->gatherProjects();
35 echo "SELECT Component to build\n";
39 $ar = array($args[1]);
52 case 'install' : // needed for install on remote sites..
63 * wrapper arroudn packer...
66 function pack($files, $output) {
68 $o = HTML_FlexyFramework::get()->Pman_Core;
70 if (empty($o['jspacker']) || !file_exists($o['jspacker'].'/pack.js')) {
71 throw new Exception("no jstoolkit path set [Pman_Core][jspacker] to the
72 introspection documentation directory where pack.js is located.");
75 require_once 'System.php';
76 $seed= System::which('seed');
78 throw new Exception(" no seed installed");
81 foreach($files as $i => $f) {
82 $max = max($max,filemtime($f));
83 $files[$i] = escapeshellarg($f);
85 if ($max < filemtime($output)) {
89 $eoutput = escapeshellarg($f);
90 $cmd = "$seed {$o['jspacker']}/pack.js -o $eoutput " . implode($files, ' ');
93 // we should do more checking.. return val etc..
94 if (file_exists($output) && ($max < filemtime($output) ) ) {
105 * @param {String} $proj name of Pman component to build
106 * runs pack.js -m {proj} -a $src/*.js
111 function build($proj)
113 echo "Building $proj\n";
116 $this->err = "no project";
117 if ($this->cli) echo $this->err;
120 // first item in path is always the app start directory..
121 $src= array_shift(explode(PATH_SEPARATOR, ini_get('include_path'))) .'/Pman/'. $proj;
125 //$tmp = ini_get('session.save_path')."/{$proj}_". posix_getuid(). '_'.md5($src);
128 require_once 'System.php';
129 $seed= System::which('seed');
131 $this->err ="no seed installed";
132 if ($this->cli) echo $this->err;
136 $o = HTML_FlexyFramework::get()->Pman_Core;
138 if (empty($o['jspacker']) || !file_exists($o['jspacker'].'/pack.js')) {
139 $this->err ="no jstoolkit path set [Pman_Core][jspacker] to the
140 introspection documentation directory where pack.js is located.";
141 if ($this->cli) echo $this->err;
145 // should we be more specirfic!??!?!?
147 $cmd = "$seed {$o['jspacker']}/pack.js -m $proj -a $src/*.js";
150 // technically we should trash old compiled files..
151 // or we move towards a 'cache in session directory model..'
156 $ret = $tmp . '/'. $proj . '.js';
158 echo "BUILT: $ret \n";
165 // link {PROJECT}/compiled/{PROJECT}.js to _compiled_ folder to make it live.
167 function install($proj)
170 $base = dirname(realpath($_SERVER["SCRIPT_FILENAME"]));
174 var_dump($base .'/Pman/'. $proj.'/compiled/'.$proj .'.js');
175 $src = realpath($base .'/Pman/'. $proj.'/compiled/'.$proj .'.js');
177 echo "SKIP : no js file $proj\n";
180 if (!file_exists("$base/_compiled_")) {
181 mkdir ("$base/_compiled_", 0755, true);
183 $target = "$base/_compiled_/".$proj .'.js';
184 print_R(array($src,$target));
185 if (file_exists($target)) {
186 return; // already installed.
189 symlink($src, $target);
194 function gatherProjects() {
195 $src= array_shift(explode(PATH_SEPARATOR, ini_get('include_path'))) .'/Pman';
198 foreach(scandir($src) as $f) {
199 if (!strlen($f) || $f[0] == '.') {
207 if ($f == 'templates') {