add cli checks to Php code
[roojs1] / buildSDK / scss-bootstrap.php
index d150711..022c86c 100644 (file)
@@ -1,5 +1,7 @@
 <?php
-
+if (php_sapi_name() != 'cli') {
+    die("CLI ONLY");
+}
 $cwd = getcwd();
 
 $cc = explode('/', $cwd);
@@ -23,19 +25,55 @@ $files = array(
         'name' => 'bootstrap.css',
         'minify' => 'bootstrap.min.css',
         'sourceMapRootpath' => '../scss/bootstrap/',
-        'variables' =>  "@import 'variables';"
+        'variables' =>  ""
     ),
-     
+    
     "roojs-bootstrap.scss" => array(
         "scssDir" => "{$rootDir}/roojs1/scss/roojs-bootstrap",
-        'baseDir' => "{$rootDir}/roojs1/css-bootstrap",
+        'baseDir' => "{$rootDir}/roojs1/css-bootstrap4",
         'name' => 'roojs-bootstrap-debug.css',
         'minify' => 'roojs-bootstrap.css',
         'sourceMapRootpath' => '../scss/roojs-bootstrap/',
-        'variables' => "@import '../bootstrap/variables';"
-    )
+        'variables' => "@import '../bootstrap/functions';\n@import '../bootstrap/variables';"
+    ),
+    
+    // this is a test to see if we can get this theme to build..
+    // note our classic roojs-bootstrap will need a rebuild as well as it uses different variables.
+    "sb-admin-2.scss" => array(
+        "scssDir" => "{$rootDir}/roojs1/scss/startbootstrap-sb-admin-2",
+        'baseDir' => "{$rootDir}/roojs1/css-bootstrap4",
+        'name' => 'sb-admin-2.css',
+        'minify' => 'sb-admin-2.min.css',
+        'sourceMapRootpath' => '../scss/startbootstrap-sb-admin-2/',
+        'variables' =>  ""
+    ),
+    
      
 );
+require_once 'System.php';
+$sassc = System::which("sassc");
+if (empty($sassc)) {
+    die("INSTALL sassc");
+}
+foreach($files as $file => $f) {
+    
+    $tmpFile = tempnam("/tmp/", "scss");
+    file_put_contents($tmpFile, "{$f['variables']}\n@import \"{$file}\";\n");
+    echo file_get_contents($tmpFile);
+    
+    
+    
+    $cmd = "{$sassc}  --sourcemap=auto -I {$f['scssDir']} $tmpFile {$f['baseDir']}/{$f['name']}";
+    echo "$cmd\n";
+    echo `$cmd`;
+    $cmd = "{$sassc} --style=compressed --sourcemap=auto -I {$f['scssDir']} $tmpFile {$f['baseDir']}/{$f['minify']}";
+    echo "$cmd\n";
+    echo `$cmd`;
+}
+exit;
+
+
+
 /*
 foreach ($files as $src => $file){
     
@@ -105,11 +143,11 @@ foreach ($files as $src => $file){
                 // output source contents?
                 'outputSourceFiles' => false,
         
-                // base path for filename normalization
-                'sourceMapRootpath' => '',
+                // this is added to the file path.
+                'sourceMapRootpath' =>  '../',
         
-                // base path for filename normalization
-                'sourceMapBasepath' => ''
+                // this is removed from the filepath.
+                'sourceMapBasepath' => $rootDir .'/roojs1/scss'
             
         ));