Create a component from the given file using RVC

@param {String} file
@param {Object} options
@returns {Promise}
@public
508773
function load(file, options) {
	if (options.cache && rr.cache['rvc!' + file]) {
		return Promise.resolve(rr.cache['rvc!' + file]);
	}

	return requireJSAsync(file).then(function (Component) {
		// flush requireJS's cache
		_.forEach(requireJS.s.contexts._.defined, function (value, key, array) {
			if (key.substr(0, 4) === 'rvc!') {
				delete array[key];
			}
		});

		return utils.wrap(utils.selectTemplate(options, Component), options).then(function (template) {
			var basePath = path.relative(options.settings.views, path.dirname(file));
			Component.defaults.template = options.template = template;

			return Promise.join(utils.buildComponentsRegistry(options), utils.buildPartialsRegistry(basePath, options), function (components, partials) {
				_.assign(Component.components, components);
				_.assign(Component.partials, partials);
				options.components = {};
				options.partials = {};

				if (options.cache) {
					rr.cache['rvc!' + file] = Component;
				}

				return Component;
			});
		});
	});
}
366
function readSpecFile(file, options) {
    if (options.verbose > 1) {
        file ? console.error('GET ' + file) : console.error('GET <stdin>');
    }
    if (!file) {
        // standard input
        return readFileStdinAsync();
    } else if (file && file.startsWith('http')) {
        // remote file
        return fetch(file).then(res => {
            if (res.status !== 200) {
                throw new Error(`Received status code ${res.status}`);
            }
            return res.text();
        })
    } else {
        // local file
        // TODO error handlers?
        return readFileAsync(file, 'utf8');
    }
}
980896
function readFile (file, options) {
    // return new Promise that will be resolved with data
    return new Promise((resolve, reject) => {
        // create write stream
        this.createReadStream(file, options).then(stream => {
            // create new concat stream that will call back with stream data
            var concatStream = ConcatStream(buffer => {
                // resolve with string if encoding set or buffer
                var data = defined(options) && defined(options.encoding)
                    ? buffer.toString(options.encoding)
                    : buffer
                // resolve with data
                resolve(data)
            })
            // reject on errors
            stream.on('error', reject)
            // pipe read stream to concat stream which will resolve when done
            stream.pipe(concatStream)
        })
        // pass rejection
        .catch(reject)
    })
}
1122616
function readPromise(file, defaultContent){
	return new Promise(function(resolve, reject){
		if ( exists(file) ) {
			fs.readFile(file, 'utf-8', (err, data) => err ? reject(err) : resolve(data));
		}else{
			defaultContent === undefined ? reject('file not found: ' + file) : resolve(defaultContent);
		}
	});
}
440959
function(options) {
    var stream = through.obj(function(file, enc, cb) {
        var out = options.out;

        // Convert to the main file to a vinyl file
        options.out = function(text) {
            cb(null, new gutil.File({
                path: out,
                contents: new Buffer(text)
            }));
        };

        // Optimize the main file
        requirejs.optimize(options, null, function(err) {
            stream.emit('error', new gutil.PluginError('gulp-rjs', err.message));
        });
    });

    return stream;
}
569029
function Plugin(options) {

  options = options || {};

  var reactOptions = {
    harmony: typeof options.harmony === 'undefined' ? true : options.harmony,
    stripTypes: typeof options.stripTypes === 'undefined' ? true : options.stripTypes
  };

  if (options.template && options.template.indexOf('<') === -1) {
    options.template = fs.readFileSync(options.template, {encoding: 'utf8'});
  }

  var originalJsTransform = require.extensions['.js'];

  var reactTransform = function(module, filename) {
    if (filename.indexOf('node_modules') === -1) {
      var src = fs.readFileSync(filename, {encoding: 'utf8'});
      src = appendJsxPragma(filename, src);
      src = ReactTools.transform(src, reactOptions);
      module._compile(src, filename);
    } else {
      originalJsTransform(module, filename);
    }
  };

  require.extensions['.js'] = reactTransform;
  require.extensions['.jsx'] = reactTransform;

  // Creates a stream through which each file will pass
  var stream = through.obj(function(file, enc, cb) {

    if (!file.isNull()) {

      if (file.isStream()) {
        this.emit('error', new PluginError(PLUGIN_NAME, 'Streams are not supported!'));
        return cb();
      }

      if (file.isBuffer()) {

        try {
          var contents = file.contents.toString('utf8');
          contents = appendJsxPragma(file.path, contents);
          contents = ReactTools.transform(contents, reactOptions);
          var m = new Module();
          m.id = file.path;
          m.filename = file.path;
          m.paths = module.paths.slice(1);
          m._compile(contents, file.path);
          var Component = m.exports;
          var markup = options.staticMarkup ? renderToStaticMarkup(Component) : renderToString(Component);

          if (options.template) {
            var data = _.extend({}, (typeof(options.data) == 'function' ? options.data(file) : options.data));
            data.body = markup;

            // Set default values to avoid null-reference exceptions
            data.title = data.title || '';
            data.description = data.description || '';
            data.keywords = data.keywords || '';

            markup = template(options.template, data);
          }

          file.contents = new Buffer(markup);
          var filename = gutil.replaceExtension(file.path, '.html');

          if (typeof options.hyphenate === 'undefined' || options.hyphenate) {
            filename = hyphenate(path.basename(filename));
            filename = filename.lastIndexOf('-', 0) === 0 ? filename.substring(1) : filename;
            filename = path.join(path.dirname(file.path), filename);
          }

          file.path = filename;
        } catch (err) {
          this.emit('error', new PluginError(PLUGIN_NAME, err));
          return cb();
        }
      }
    }

    // Make sure the file goes through the next gulp plugin
    this.push(file);
    // Tell the stream engine that we are done with this file
    return cb();
  });

  // Return the file stream
  return stream;
}
478350
function runCompile(file, options) {
  if (!file) {
    throw new PluginError('can-compile', 'Missing file option for can-compile');
  }

  var templatePaths = [],
      latestFile;

  options = options || {};
  
  function bufferStream (file, enc, cb) {
    // ignore empty files
    if (file.isNull()) {
      cb();
      return;
    }

    // can't do streams yet
    if (file.isStream()) {
      this.emit('error', new PluginError('can-compile',  'Streaming not supported for can-compile'));
      cb();
      return;
    }

    // set latest file if not already set,
    // or if the current file was modified more recently.
    if (!latestFile || file.stat && file.stat.mtime > latestFile.stat.mtime) {
      latestFile = file;
    }

    templatePaths.push(file.path);
    cb();
  }

  function endStream(cb) {
    var self = this;

    // no files passed in, no file goes out
    if (!latestFile || !templatePaths.length) {
      cb();
      return;
    }

    compile(templatePaths, options, function (err, result) {
      if (err) {
        self.emit('error', new PluginError('can-compile',  err));
        return cb(err);
      }

      var joinedFile;

      // if file opt was a file path
      // clone everything from the latest file
      if (typeof file === 'string') {
        joinedFile = latestFile.clone({ contents: false });
        joinedFile.path = path.join(latestFile.base, file);
      } else {
        joinedFile = new File(file);
      }

      joinedFile.contents = new Buffer(result);

      self.push(joinedFile);

      cb();
    });
  }

  return through.obj(bufferStream, endStream);
}
55655
function create(opts) {	
	function absolute_path(arg_path) {
		return path.resolve(process.cwd(), arg_path);
	}
	
	// Parse arguments
	function parse_with_flag(flag) {
		return function(arg) {
			var parts = arg.split(":");
			if(parts.length < 2) {
				parts.unshift(null);
			}
			
			return {name: parts[0], path: absolute_path(parts[1]), flag: flag};
		}
	}

	opts.l = ((opts.l && opts.l !== true) ? [].concat(opts.l) : []).map(parse_with_flag("l"));
	opts.b = ((opts.b && opts.b !== true) ? [].concat(opts.b) : []).map(parse_with_flag("b"));
	opts.s = ((opts.s && opts.s !== true) ? [].concat(opts.s) : []).map(parse_with_flag("s"));
	if(!opts.j) {
		opts.x = ((opts.x && opts.x !== true) ? [].concat(opts.x) : []).map(parse_with_flag("x"));
	}
	opts._ = opts._.map(parse_with_flag(""));
	
	// Merge all arguments
	var args;
	if(!opts.j) {
		args = opts.l.concat(opts.b).concat(opts.s).concat(opts._).concat(opts.x);
	} else {
		args = opts._;
	}
	
	if(args.length === 0) {
		throw new Error("no input file");
	}
	
	// Determine link root
	var bundle_root;
	if(args.length < 2) {
		bundle_root = path.dirname(args[0].path);
	} else if(!opts.j) {
		bundle_root = args.reduce(function(arg1, arg2) {
			var path1 = (typeof arg1 === "string") ? arg1 : arg1.path;
			var path2 = arg2.path;
			
			var i = 0;
			for(; i < path1.length && path1.charAt(i) === path2.charAt(i); i++);
			return path1.slice(0, i);
		});
	}

	// Bundle
	var bundle = new Bundle
	
	var symbols_loaded = {};
	var join = [];
	if(typeof opts.j !== "string") {
		opts.j = false;
	}
	
	// Load symbols
	function load_symbol(symbol) {
		// Merge bundle
		if(symbol.flag === "l") {
			var sub = new Bundle(symbol.path);
			for(var subsym_name in sub.symbols()) {
				var subsym = sub.symbol(subsym_name);
				
				// Merge prefix
				if(symbol.name === null) {
					var subpath = path.dirname(symbol.path);
					var prefix = path.relative(bundle_root, subpath);
					if(prefix !== "") {
						prefix += "/";
					}
					symbol.name = prefix;
				}
				
				subsym_name = symbol.name + subsym_name;
				subsym.path = symbol.name + subsym.path;
				
				bundle.addSymbol(subsym_name, subsym.data, subsym.path, subsym.flag);
			}
			return;
		}
		
		var data = fs.readFileSync(symbol.path, (symbol.flag === "b" ? "base64" : "utf8"));
		
		if(opts.c && (symbol.flag === "" || symbol.flag === "x")) {
			// Remove shebang
			data = data.replace(/^\#\!.*/, "");
			if(!opts.j) {
				data = compress(data, {
					debug: opts.d
				});
			}
		}
		
		if(opts.j) {
			join.push(data);
			return;
		}
		
		var sym_path = path.relative(bundle_root, symbol.path);
		if(!symbol.name) {
			symbol.name = opts.f ? path.basename(sym_path) : sym_path;
		}
		
		if(symbols_loaded[symbol.name]) {
			warning("symbol collision on " + symbol.name, opts);
			bundle.removeSymbol(symbol.name);
		} else {
			symbols_loaded[symbol.name] = true;
		}
		
		bundle.addSymbol(symbol.name, data, sym_path, symbol.flag);
	}
	
	args.forEach(load_symbol);
	
	// Handle join
	if(opts.j) {
		var data = join.join(";\n");
		if(opts.c) {
			data = compress(data, {
				debug: opts.d
			});
		}
		bundle.addSymbol(opts.j, data, opts.j, (opts.x ?  "x" : ""));
	}
	
	do_compile(bundle, opts);
}
319398
function(file) {
      var deferred = $q.defer();

      var reader = angular.extend(new FileReader(), {
        onload: function(e) {
          deferred.resolve(e.target.result);
          if (!$rootScope.$$phase) $rootScope.$apply();
        },
        onerror: function(e) {
          deferred.reject(e);
          if (!$rootScope.$$phase) $rootScope.$apply();
        },
        onabort: function(e) {
          deferred.reject(e);
          if (!$rootScope.$$phase) $rootScope.$apply();
        }
        // onprogress: Gee, it'd be great to get some progress support from $q...
      });
      reader.readAsDataURL(file);

      return angular.extend(deferred.promise, {
        abort: function() { reader.abort(); }
      });
    }
709496
function (file, writeOptions) {
  writeOptions = writeOptions || {};
  function toBuffer(ab) {
    var buffer = new Buffer(ab.byteLength);
    var view = new Uint8Array(ab);
    for (var i = 0; i < buffer.length; ++i) {
      buffer[i] = view[i];
    }
    return buffer;
  }
  var buf = index$14.structure(file);
  return toBuffer(buf.buffer);
}
15109
function(options, filename){	    
	    Joi.assert(filename, Joi.string())
	    return new Promise(function(resolve, reject){

	        try{	            

	            var writestream = fs.createWriteStream(filename);
	            request(options).pipe(writestream);

	            writestream.on('finish', function(err){                 
	                if(err){
	                    reject({
	                        "path" : filename,
	                        "status" : false,
	                        "error": err
	                    });
	                }else{
	                    resolve({
	                        "path" : filename,
	                        "status" : true
	                    });
	                }
	            });

	        }catch(e){
	            reject(e);
	        }
	    });
	}
861868
async function validateFile (file, options) {
  if (file instanceof File === false) {
    return null
  }

  await file.setOptions(Object.assign(file.validationOptions, options)).runValidations()
  return _.size(file.error()) ? file.error().message : null
}
807400
function(files, props, options) {
        options = grunt.utils._.defaults(options || {}, {
          process: function(contents) {
            return grunt.template.process(contents, props, 'init');
          }
        });
        Object.keys(files).forEach(function(destpath) {
          var o = Object.create(options);
          var srcpath = files[destpath];
          // If srcpath is relative, match it against options.noProcess if
          // necessary, then make srcpath absolute.
          var relpath;
          if (srcpath && !grunt.file.isPathAbsolute(srcpath)) {
            if (o.noProcess) {
              relpath = srcpath.slice(pathPrefix.length);
              o.noProcess = grunt.file.isMatch(o.noProcess, relpath);
            }
            srcpath = grunt.task.getFile(srcpath);
          }
          // Copy!
          init.copy(srcpath, destpath, o);
        });
      }
579307
function (file) {
    this.src = file.src || {};
    if (this.path) {
      this.src.path = this.path;
    }
    if (Buffer.isBuffer(this.contents)) {
      this.content = this.contents.toString();
    }
    if (this.content) {
      this.options.orig = this.content;
    }

    // ensure that `file` has `path` and `content` properties
    this.validate(file);

    this.options.orig = file.content;
    this.options.plural = this.collection.options.plural;
    this.options.handled = this.options.handled = [];

    this.src = file.src || {};
    this.src.path = this.src.path || this.path;

    // add non-emumerable properties
    this.defineOption('route', this.options.route);
    this.define('_callbacks', this._callbacks);
    file.__proto__ = this;
    file.path = this.path;

    // handle `onLoad` middleware routes
    this.app.handle('onLoad', file);
  }
851693
function createFile(file) {
    fs.ensureFileSync(file.name);
    fs.writeFileSync(file.name, file.source);
    return;
}
688540
function writeHTMLFile(options) {
  return new Promise(function(resolve, reject) {
    var templateFile = path.join(__dirname, '../template/cli.html');
     // read our template file
     fs.readFile(templateFile, 'utf8', function (err,data) {
      if (err) {
        reject(err);
      }
      // insert the generated json data
      var result = data.replace('{{ insertJSONHere }}', 'var embeddedJsonData = '+ options.json + ';');

      // write file to directory
      fs.writeFile(path.join(options.directory, 'index.html'), result, 'utf8', function (err) {
         if (err) {
          reject(err);
         }
         resolve(options.directory);
      });
    });
  });
}
48344
function (files, component) {
            var self = this;
            return files.map(function (file) {
                return file.replace(path.normalize(self._resolvePath(component) + path.sep), '');
            });
        }