How to use bower - 10 common examples

To help you get started, we’ve selected a few bower examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Polymer / tools / packages / cli / src / build / build.ts View on Github external
(resolve, _reject) =>
            bower.commands.list({}, {offline: true})
                .on('end',
                    // tslint:disable-next-line: no-any
                    (result: any) => {
                      if (result && result.dependencies &&
                          result.dependencies.polymer &&
                          result.dependencies.polymer.pkgMeta &&
                          result.dependencies.polymer.pkgMeta.version) {
                        resolve(result.dependencies.polymer.pkgMeta.version);
                      } else {
                        resolve('');
                      }
                    })
                .on('error', (oops: Error) => {
                  resolve('');
                  console.warn(oops.message);
                }));
github Backbase / bb-cli / commands / install.js View on Github external
componentPathAbsolute = path.join(baseUrl, output.fsPaths[componentEndpoint]);

                            console.log('componentPathAbsolute', componentPathAbsolute);

                        } else {
                            // If we're asked to install relative component, we can't get it's name and path
                            noName = true;
                        }
                    }

                    if (argCatalog) {
                        if (!noName) {
                            restUtils.submitToPortal(baseUrl, output.fsPaths, false, componentPathAbsolute);
                        } else {
                            // Get component name by endpoint
                            bower.commands.info(componentEndpoint)
                                .on('end', function (componentInfo) {
                                    var componentName = componentInfo.latest.name;
                                    var componentPath = path.join(baseUrl, output.fsPaths[componentName]);

                                    restUtils.submitToPortal(baseUrl, {}, false, componentPath);
                                });
                        }
                    }
                }).fail(function(err){
                    console.log(chalk.red('Something went wrong during requirejs configuration generation: '), err);
github zumwald / oss-attribution-generator / index.js View on Github external
// first - check that this is even a bower project
    var baseDir;
    if (Array.isArray(options.baseDir)) {
        baseDir = options.baseDir[0];
        if (options.baseDir.length > 1) {
            console.warn("Checking multiple directories is not yet supported for Bower projects.\n" +
                "Checking only the first directory: " + baseDir);
        }
    }
    if (!jetpack.exists(path.join(baseDir, 'bower.json'))) {
        console.log('this does not look like a Bower project, skipping Bower checks.');
        return [];
    }

    bower.config.cwd = baseDir;
    var bowerComponentsDir = path.join(bower.config.cwd, bower.config.directory);
    return jetpack.inspectTreeAsync(bowerComponentsDir, { relativePath: true })
        .then((result) => {
            /**
             * for each component, try to calculate the license from the NPM package info
             * if it is a available because license-checker more closely aligns with our
             * objective.
             */
            return bluebird.map(result.children, (component) => {
                var absPath = path.join(bowerComponentsDir, component.relativePath);
                // npm license check didn't work
                // try to get the license and package info from .bower.json first
                // because it has more metadata than the plain bower.json
      
                var package = '';
      
                try {
github endel / lazy-assets / lib / lazy / utils.js View on Github external
var files = (asset.main && asset.main.split(",")) || [],
          fullDir = this.getPath(asset.href)
          dir = path.basename(fullDir),
          jsonPath = fullDir + '/bower.json';

      if (files.length === 0 && fs.existsSync(jsonPath)) {
        var json = JSON.parse(fs.readFileSync(jsonPath).toString());
        if (json.main) {
          if (typeof(json.main)==="string") {
            json.main = [json.main];
          }
          files = files.concat(json.main);
        }
      }

      var directory = bower.config.directory.replace(this.getBasePath(), "");

      // Try another main file from alternative patterns
      if (files.length === 0) {
        var dependency_root = directory + "/" + dir;

        // it 'seems' we need recursivity here. lazy programming
        var found, patterns = [
          dependency_root + '/' + dir,
          dependency_root + '/' + dir + '.min.{js,css}',
          dependency_root + '/' + dir + '.{js,css}',
          dependency_root + '/' + dir + '.min.{js,css}',
          dependency_root + '/jquery.' + dir,
          dependency_root + '/jquery.' + dir + '.{js,css}',
          dependency_root + '/jquery.' + dir + '.min.{js,css}',
          dependency_root + '/{css,dist,build}/' + dir,
          dependency_root + '/{css,dist,build}/' + dir + '.{js,css}',
github btford / grunt-google-cdn / tasks / cdnify.js View on Github external
'use strict';

var path = require('path');
var eachAsync = require('each-async');
var googlecdn = require('google-cdn');
var bowerConfig = require('bower').config;
var chalk = require('chalk');

module.exports = function (grunt) {

  grunt.registerMultiTask('cdnify', 'Replace scripts with refs to the Google CDN', function () {
    // collect files
    var files = grunt.file.expand({ filter: 'isFile' }, this.data.html);
    var compJson = grunt.file.readJSON('bower.json');
    var options = this.options({
      cdn: 'google'
    });

    // Strip the leading path segment off, e.g. `app/bower_components` ->
    // `bower_components`
    var bowerDirBits = bowerConfig.directory.split(path.sep);
    bowerDirBits.shift();
github btford / grunt-google-cdn / tasks / cdnify.js View on Github external
grunt.registerMultiTask('cdnify', 'Replace scripts with refs to the Google CDN', function () {
    // collect files
    var files = grunt.file.expand({ filter: 'isFile' }, this.data.html);
    var compJson = grunt.file.readJSON('bower.json');
    var options = this.options({
      cdn: 'google'
    });

    // Strip the leading path segment off, e.g. `app/bower_components` ->
    // `bower_components`
    var bowerDirBits = bowerConfig.directory.split(path.sep);
    bowerDirBits.shift();
    var componentsPath = bowerDirBits.join(path.sep);

    grunt.log
      .writeln('Going through ' + grunt.log.wordlist(files) + ' to update script refs');

    files = files.map(function (filepath) {
      return {
        path: filepath,
        body: grunt.file.read(filepath)
      };
    });

    eachAsync(files, function (file, index, cbInner) {
      var content = file.body;
github btford / grunt-google-cdn / util / bower.js View on Github external
bowerUtil.joinComponent = function joinComponent(component) {
  // Strip the leading path segment from the configured bower components
  // directory. E.g. app/bower_components -> bower_components
  var dirBits = bowerConfig.directory.split(path.sep);
  dirBits.shift();

  // Always join the path with a forward slash, because it's used to replace the
  // path in HTML.
  return path.join(dirBits.join('/'), component).replace(/\\/g, '/');
};
github adaptlearning / adapt_authoring / lib / bowermanager.js View on Github external
.on('end', function (results) {
      if (!results || results.length == 0) {
        logger.log('warn', 'Plugin ' + packageName + ' not found!');
        return callback('Plugin ' + packageName + ' not found!');
      }
      // The plugin exists -- remove any fuzzy matches, e.g. adapt-contrib-assessment would
      // also bring in adapt-contrib-assessmentResults, etc.
      var bowerPackage = _.findWhere(results, {name: pluginName});
      bower.commands.info(bowerPackage.url)
        .on('error', callback)
        .on('end', function (latestInfo) {
          // the versions will be in version order, rather than release date,
          // so no need for ordering
          installHelpers.getInstalledFrameworkVersion(function(error, installedFrameworkVersion) {
            if(error) {
              return callback(error);
            }
            var requiredFrameworkVersion;
            var index = -1;
            async.doUntil(function iterator(cb) {
              bower.commands.info(bowerPackage.url + '#' + latestInfo.versions[++index])
                .on('error', cb)
                .on('end', function (result) {
                  requiredFrameworkVersion = result.framework;
                  cb();
github happyplan / happyplan / grunt_tasks / lib / load-config.js View on Github external
// (happyplan default first, parents, & the local)
  var happyplan = deepmerge(grunt.config.get('pkg'), grunt.file.readJSON(happyplanRoot + '/happyplan.json'))

  happyplan.env = grunt.option('env')
  grunt.verbose.writeln('Environnment is'.grey, happyplan.env)

  happyplan.cwd = process.cwd()
  grunt.verbose.writeln('CWD is'.grey, happyplan.cwd.cyan)

  happyplan._ = happyplanRoot
  grunt.verbose.writeln('happyplan wd is'.grey, happyplan._.cyan)

  happyplan.pkg = grunt.file.readJSON(happyplanRoot + '/package.json')

  // load bower config
  happyplan.bower_components = require('bower').config.directory

  grunt.config.set('happyplan', happyplan)
}
github JonAbrams / synth / lib / commands.js View on Github external
var both = !!(nodeModuleIndex && bowerComponentIndex);

  if (nodeModuleIndex || both) {
    var nodeModules = getModules(args, nodeModuleIndex);

    process.chdir('back');
    npm.load({ save: true }, function (err) {
      npm.commands.uninstall(nodeModules);
    });
  }

  if (bowerComponentIndex || both) {
    var bowerComponents = getModules(args, bowerComponentIndex);

    process.chdir('front');
    bower.config.cwd = process.cwd();
    promises = {};
    bowerComponents.forEach(function(component, index){
      promises[component] = new Promise(function(resolve){
        bower.commands.info(component).on('end', function(info){
          return resolve({
            pkgMeta: info.latest
          });
        });
      });
    });
    bower.commands[command](bowerComponents, { save: true })
    .on('end', function (uninstalled) {
      Promise.props(promises).then(function(infos){
        /* Remove uninstalled components from the asset manifest files */
        bowerSupport.removeFromManifestFiles(infos);
      });