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, $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($src) as $f) {
95 * wrapper arroudn packer...
96 * @param {Array} $files the files to pack
97 * @param {String} $output name fo file to output
100 function pack($files, $output)
104 $o = HTML_FlexyFramework::get()->Pman_Core;
106 if (empty($o['jspacker']) || !file_exists($o['jspacker'].'/pack.js')) {
107 throw new Exception("no jstoolkit path set [Pman_Core][jspacker] to the
108 introspection documentation directory where pack.js is located.");
110 require_once 'System.php';
111 $seed= System::which('seed');
113 throw new Exception(" no seed installed");
116 foreach($files as $i => $f) {
117 $max = max($max,filemtime($f));
118 $files[$i] = escapeshellarg($f);
120 if ($max < filemtime($output)) {
124 $eoutput = escapeshellarg($f);
125 $cmd = "$seed {$o['jspacker']}/pack.js -o $eoutput " . implode($files, ' ');
130 // we should do more checking.. return val etc..
131 if (file_exists($output) && ($max < filemtime($output) ) ) {
142 * @param {String} $proj name of Pman component to build
143 * runs pack.js -m {proj} -a $src/*.js
148 function build($proj)
150 echo "Building $proj\n";
153 $this->err = "no project";
154 if ($this->cli) echo $this->err;
157 // first item in path is always the app start directory..
158 $src= array_shift(explode(PATH_SEPARATOR, ini_get('include_path'))) .'/Pman/'. $proj;
162 //$tmp = ini_get('session.save_path')."/{$proj}_". posix_getuid(). '_'.md5($src);
165 require_once 'System.php';
166 $seed= System::which('seed');
168 $this->err ="no seed installed";
169 if ($this->cli) echo $this->err;
173 $o = HTML_FlexyFramework::get()->Pman_Core;
175 if (empty($o['jspacker']) || !file_exists($o['jspacker'].'/pack.js')) {
176 $this->err ="no jstoolkit path set [Pman_Core][jspacker] to the
177 introspection documentation directory where pack.js is located.";
178 if ($this->cli) echo $this->err;
182 // should we be more specirfic!??!?!?
184 $cmd = "$seed {$o['jspacker']}/pack.js -m $proj -a $src/*.js";
187 // technically we should trash old compiled files..
188 // or we move towards a 'cache in session directory model..'
193 $ret = $tmp . '/'. $proj . '.js';
195 echo "BUILT: $ret \n";
202 // link {PROJECT}/compiled/{PROJECT}.js to _compiled_ folder to make it live.
204 function install($proj)
207 $base = dirname(realpath($_SERVER["SCRIPT_FILENAME"]));
211 var_dump($base .'/Pman/'. $proj.'/compiled/'.$proj .'.js');
212 $src = realpath($base .'/Pman/'. $proj.'/compiled/'.$proj .'.js');
214 echo "SKIP : no js file $proj\n";
217 if (!file_exists("$base/_compiled_")) {
218 mkdir ("$base/_compiled_", 0755, true);
220 $target = "$base/_compiled_/".$proj .'.js';
221 print_R(array($src,$target));
222 if (file_exists($target)) {
223 return; // already installed.
226 symlink($src, $target);
231 function gatherProjects() {
232 $src= array_shift(explode(PATH_SEPARATOR, ini_get('include_path'))) .'/Pman';
235 foreach(scandir($src) as $f) {
236 if (!strlen($f) || $f[0] == '.') {
244 if ($f == 'templates') {