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..
70 function packScript($basedir, $files, $output_path)
72 // this outputs <script tags..>
73 // either for just the original files,
74 // or the compressed version.
75 // first expand files..
78 foreach($files as $f) {
80 $arfiles[] = $basedir .'/' .$f;
83 foreach(scandir($basedir .'/' .$f.'/*.js') as $fx) {
88 print_r($arfiles);exit;
98 * wrapper arroudn packer...
99 * @param {Array} $files the files to pack
100 * @param {String} $output name fo file to output
103 function pack($files, $output)
107 $o = HTML_FlexyFramework::get()->Pman_Core;
109 if (empty($o['jspacker']) || !file_exists($o['jspacker'].'/pack.js')) {
110 throw new Exception("no jstoolkit path set [Pman_Core][jspacker] to the
111 introspection documentation directory where pack.js is located.");
113 require_once 'System.php';
114 $seed= System::which('seed');
116 throw new Exception(" no seed installed");
119 foreach($files as $i => $f) {
120 $max = max($max,filemtime($f));
121 $files[$i] = escapeshellarg($f);
123 if ($max < filemtime($output)) {
127 $eoutput = escapeshellarg($f);
128 $cmd = "$seed {$o['jspacker']}/pack.js -o $eoutput " . implode($files, ' ');
133 // we should do more checking.. return val etc..
134 if (file_exists($output) && ($max < filemtime($output) ) ) {
145 * @param {String} $proj name of Pman component to build
146 * runs pack.js -m {proj} -a $src/*.js
151 function build($proj)
153 echo "Building $proj\n";
156 $this->err = "no project";
157 if ($this->cli) echo $this->err;
160 // first item in path is always the app start directory..
161 $src= array_shift(explode(PATH_SEPARATOR, ini_get('include_path'))) .'/Pman/'. $proj;
165 //$tmp = ini_get('session.save_path')."/{$proj}_". posix_getuid(). '_'.md5($src);
168 require_once 'System.php';
169 $seed= System::which('seed');
171 $this->err ="no seed installed";
172 if ($this->cli) echo $this->err;
176 $o = HTML_FlexyFramework::get()->Pman_Core;
178 if (empty($o['jspacker']) || !file_exists($o['jspacker'].'/pack.js')) {
179 $this->err ="no jstoolkit path set [Pman_Core][jspacker] to the
180 introspection documentation directory where pack.js is located.";
181 if ($this->cli) echo $this->err;
185 // should we be more specirfic!??!?!?
187 $cmd = "$seed {$o['jspacker']}/pack.js -m $proj -a $src/*.js";
190 // technically we should trash old compiled files..
191 // or we move towards a 'cache in session directory model..'
196 $ret = $tmp . '/'. $proj . '.js';
198 echo "BUILT: $ret \n";
205 // link {PROJECT}/compiled/{PROJECT}.js to _compiled_ folder to make it live.
207 function install($proj)
210 $base = dirname(realpath($_SERVER["SCRIPT_FILENAME"]));
214 var_dump($base .'/Pman/'. $proj.'/compiled/'.$proj .'.js');
215 $src = realpath($base .'/Pman/'. $proj.'/compiled/'.$proj .'.js');
217 echo "SKIP : no js file $proj\n";
220 if (!file_exists("$base/_compiled_")) {
221 mkdir ("$base/_compiled_", 0755, true);
223 $target = "$base/_compiled_/".$proj .'.js';
224 print_R(array($src,$target));
225 if (file_exists($target)) {
226 return; // already installed.
229 symlink($src, $target);
234 function gatherProjects() {
235 $src= array_shift(explode(PATH_SEPARATOR, ini_get('include_path'))) .'/Pman';
238 foreach(scandir($src) as $f) {
239 if (!strlen($f) || $f[0] == '.') {
247 if ($f == 'templates') {