add cli checks to Php code
[roojs1] / buildSDK / scss-bootstrap.php
index 6bf0dc7..022c86c 100644 (file)
@@ -1,5 +1,7 @@
 <?php
-
+if (php_sapi_name() != 'cli') {
+    die("CLI ONLY");
+}
 $cwd = getcwd();
 
 $cc = explode('/', $cwd);
@@ -23,18 +25,55 @@ $files = array(
         'name' => 'bootstrap.css',
         'minify' => 'bootstrap.min.css',
         'sourceMapRootpath' => '../scss/bootstrap/',
-    //    'variables' => array("@import 'variables.less';")
+        'variables' =>  ""
     ),
-    /*
-    "{$rootDir}/roojs1/less/roojs-bootstrap/roojs-bootstrap.less" => array(
-        'baseDir' => "{$rootDir}/roojs1/css-bootstrap",
+    
+    "roojs-bootstrap.scss" => array(
+        "scssDir" => "{$rootDir}/roojs1/scss/roojs-bootstrap",
+        'baseDir' => "{$rootDir}/roojs1/css-bootstrap4",
         'name' => 'roojs-bootstrap-debug.css',
         'minify' => 'roojs-bootstrap.css',
-        'sourceMapRootpath' => '../less/roojs-bootstrap/',
-        'variables' => array("@import '../bootstrap/variables.less';")
-    )
-    */
+        'sourceMapRootpath' => '../scss/roojs-bootstrap/',
+        '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){
     
@@ -104,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'
             
         ));
        
@@ -120,7 +159,7 @@ foreach ($files as $src => $file){
         $scss->setImportPaths($file['scssDir']);
         $scss->setFormatter('Expanded');
         
-        file_put_contents($css, $scss->compile("@import \"{$src}\";"));
+        file_put_contents($css, $scss->compile("{$file['variables']}\n@import \"{$src}\";"));
         
         
         $min = "{$file['baseDir']}/{$file['minify']}";
@@ -131,7 +170,7 @@ foreach ($files as $src => $file){
         
         $scss->setFormatter('Crunched');
         
-        file_put_contents($min,  $scss->compile("@import \"{$src}\";")  );
+        file_put_contents($min,  $scss->compile("{$file['variables']}\n@import \"{$src}\";")  );
     } catch (Exception $ex) {
         echo "scss fatal error: {$ex->getMessage()}\n";
     }