Bring third party dependencies from node_modules into vendor directory
498033
function modules() {
  // Bootstrap
  var bootstrap = gulp.src('./node_modules/bootstrap/dist/**/*')
    .pipe(gulp.dest('./vendor/bootstrap'));
  // Font Awesome
  var fontAwesome = gulp.src('./node_modules/@fortawesome/**/*')
    .pipe(gulp.dest('./vendor'));
  // jQuery
  var jquery = gulp.src([
      './node_modules/jquery/dist/*',
      '!./node_modules/jquery/dist/core.js'
    ])
    .pipe(gulp.dest('./vendor/jquery'));
  return merge(bootstrap, fontAwesome, jquery);
}
553583
def __install_node_dependencies(kudu_client):
    
    if not kudu_client._KuduClient__initialized:  # pylint:disable=protected-access
        kudu_client._KuduClient__initialize()  # pylint:disable=protected-access

    payload = {
        'command': 'npm install',
        'dir': r'site\wwwroot'
    }
    response = requests.post(kudu_client._KuduClient__scm_url + '/api/command', data=json.dumps(payload),  # pylint:disable=protected-access
                             headers=kudu_client._KuduClient__get_application_json_headers())   # pylint:disable=protected-access
    HttpResponseValidator.check_response_status(response)
    return response.json()
889447
function getProdModules(externalModules, packagePath, dependencyGraph, forceExcludes) {
  const packageJsonPath = path.join(process.cwd(), packagePath);
  const packageJson = require(packageJsonPath);
  const prodModules = [];

  // only process the module stated in dependencies section
  if (!packageJson.dependencies) {
    return [];
  }

  // Get versions of all transient modules
  _.forEach(externalModules, module => {
    let moduleVersion = packageJson.dependencies[module.external];

    if (moduleVersion) {
      prodModules.push(`${module.external}@${moduleVersion}`);

      // Check if the module has any peer dependencies and include them too
      try {
        const modulePackagePath = path.join(
          path.dirname(path.join(process.cwd(), packagePath)),
          'node_modules',
          module.external,
          'package.json'
        );
        const peerDependencies = require(modulePackagePath).peerDependencies;
        if (!_.isEmpty(peerDependencies)) {
          this.options.verbose && this.serverless.cli.log(`Adding explicit peers for dependency ${module.external}`);
          const peerModules = getProdModules.call(this, _.map(peerDependencies, (value, key) => ({ external: key })), packagePath, dependencyGraph, forceExcludes);
          Array.prototype.push.apply(prodModules, peerModules);
        }
      } catch (e) {
        this.serverless.cli.log(`WARNING: Could not check for peer dependencies of ${module.external}`);
      }
    } else {
      if (!packageJson.devDependencies || !packageJson.devDependencies[module.external]) {
        // Add transient dependencies if they appear not in the service's dev dependencies
        const originInfo = _.get(dependencyGraph, 'dependencies', {})[module.origin] || {};
        moduleVersion = _.get(_.get(originInfo, 'dependencies', {})[module.external], 'version');
        if (!moduleVersion) {
          this.serverless.cli.log(`WARNING: Could not determine version of module ${module.external}`);
        }
        prodModules.push(moduleVersion ? `${module.external}@${moduleVersion}` : module.external);
      } else if (packageJson.devDependencies && packageJson.devDependencies[module.external] && !_.includes(forceExcludes, module.external)) {
        // To minimize the chance of breaking setups we whitelist packages available on AWS here. These are due to the previously missing check
        // most likely set in devDependencies and should not lead to an error now.
        const ignoredDevDependencies = ['aws-sdk'];

        if (!_.includes(ignoredDevDependencies, module.external)) {
          // Runtime dependency found in devDependencies but not forcefully excluded
          this.serverless.cli.log(`ERROR: Runtime dependency '${module.external}' found in devDependencies. Move it to dependencies or use forceExclude to explicitly exclude it.`);
          throw new this.serverless.classes.Error(`Serverless-webpack dependency error: ${module.external}.`);
        }

        this.options.verbose && this.serverless.cli.log(`INFO: Runtime dependency '${module.external}' found in devDependencies. It has been excluded automatically.`);
      }
    }
  });

  return prodModules;
}
1169249
function(app) {
    this._super(app);

    const vendorTree = this.treePaths.vendor;

    // Import the PubNub package and shim.
    app.import(`${vendorTree}/pubnub.js`);
    app.import(`${vendorTree}/shims/pubnub.js`, {
      exports: {
        PubNub: ['default']
      }
    });
  }
1012420
function () {
      return _.map([].concat(this.pkgs, this.devPkgs), function (pkg) {
        return path.join(pkg.path, "node_modules/.bin");
      });
    }
1256526
private void pullInDependencies(ModuleIdentifier modID, File modDir) {
    // Load the module configuration file.
    File modJsonFile = new File(modDir, MOD_JSON_FILE);
    ModuleInfo info = loadModuleInfo(modID, modJsonFile);

    // Pull in all dependencies according to the "includes" and "deploys" fields.
    ModuleFields fields = info.fields();
    List<String> mods = new ArrayList<>();

    // Add "includes" modules.
    String sincludes = fields.getIncludes();
    if (sincludes != null) {
      String[] includes = parseIncludes(sincludes);
      if (includes != null) {
        mods.addAll(Arrays.asList(includes));
      }
    }

    // Add "deploys" modules.
    String sdeploys = fields.getDeploys();
    if (sdeploys != null) {
      String[] deploys = parseIncludes(sdeploys);
      if (deploys != null) {
        mods.addAll(Arrays.asList(deploys));
      }
    }

    // Iterate through "includes" and "deploys" and attempt to move them
    // into the module directory if they can be found. Note that this
    // requires that the modules be installed. It does not check remote
    // repositories since it's assumed that remote repositories can be
    // access from any node to which the module goes.
    if (!mods.isEmpty()) {
      File internalModsDir = new File(modDir, "mods");
      if (!internalModsDir.exists()) {
        if (!internalModsDir.mkdir()) {
          throw new PlatformManagerException("Failed to create directory " + internalModsDir);
        }
      }

      for (String moduleName : mods) {
        File internalModDir = new File(internalModsDir, moduleName);
        if (!internalModDir.exists()) {
          ModuleIdentifier childModID = new ModuleIdentifier(moduleName);
          File includeModDir = locateModule(childModID);
          if (includeModDir != null) {
            vertx.fileSystem().copySync(includeModDir.getAbsolutePath(), internalModDir.getAbsolutePath(), true);
            pullInDependencies(childModID, internalModDir);
          }
        }
      }
    }
  }
313485
def pull_dependencies(self, nodes):
        """"""
        visitor = DependencyFinderVisitor()
        for node in nodes:
            visitor.visit(node)
        for dependency in 'filters', 'tests':
            mapping = getattr(self, dependency)
            for name in getattr(visitor, dependency):
                if name not in mapping:
                    mapping[name] = self.temporary_identifier()
                self.writeline('%s = environment.%s[%r]' %
                               (mapping[name], dependency, name))
1364169
def vendor!(dir = nil, force = false)
      resolve! if paths.empty?
      dir ||= options[:vendor_dir]
      dir ||= 'vendor' # default
      logger.debug "Vendoring #{paths.length} files to #{dir}"
      paths.collect {|n, p| p }.flatten.each do |path, name, version|
        if index.in_jimhome?(path)
          Jim::Installer.new(path, dir, :shallow => true, :force => force).install
        end
      end
      dir
    end
1220918
function nodeModulesResolverFn(normalizedId) {
		if (!nodeModulesAt) {
			throw new Error('Before you can load external dependencies, you must specify where node_modules can be found by ' +
				'setting the \'nodeModulesAt\' option when creating the context');
		}

		var extId = normalizedId.id;

		var modulePath = path.join(nodeModulesAt, extId);
		if (!externalDepExists[modulePath]) {
			// yes I know the docs don't like this method.
			// But it's a little better user experience than trying to require a file that isn't there.
			if (fs.existsSync(modulePath)) {
				externalDepExists[modulePath] = true; // cache it so we avoid the lookup next time

			} else {
				var msg = 'Could not find external dependency [' + extId + '] at path [' + modulePath + ']';
				throw new Error(buildMissingDepMsg(msg, extId, allExternalIds()));
			}

		}

		return require(modulePath);
	}
1336259
function loadNodeModule(nodeModulePath, name) {
  return plugin.myrmex.fire('beforeNodeModuleLoad', nodeModulePath, name)
  .spread((nodeModulePath, name) => {
    let packageJson = {};
    try {
      packageJson = _.cloneDeep(require(path.join(nodeModulePath, 'package.json')));
    } catch (e) {
      if (e.code !== 'MODULE_NOT_FOUND') {
        throw e;
      }
    }

    // Lasy loading because the plugin has to be registered in a Myrmex instance before requiring ./node-module
    const NodeModule = require('./node-module');
    const nodePackage = new NodeModule(packageJson, name, nodeModulePath);

    // This event allows to inject code to alter the Lambda configuration
    return plugin.myrmex.fire('afterNodeModuleLoad', nodePackage);
  })
  .spread(nodePackage => {
    return Promise.resolve(nodePackage);
  });
}
512373
function dependentLink (pkg, cb) {
  asyncMap(pkg._resolvedDeps, function (dep, cb) {
    var dependents = path.join(npm.dir, dep.name, dep.version, "dependents")
      , to = path.join(dependents, pkg.name + "@" + pkg.version)
      , from = path.join(npm.dir, pkg.name, pkg.version)
    link(from, to, cb)
  }, cb)
}
1026005
function (module_name, module_folder, callback) {
    var module_folder = path.resolve(module_folder)
    var module_packaged = _load_package(module_folder);

    var module_dependencies = _.d.get(module_packaged, "/dependencies");
    if (!module_dependencies) {
        return callback();
    }

    module_dependencies = _.keys(module_dependencies);

    var _install_next = function() {
        if (module_dependencies.length === 0) {
            return callback();
        }

        var dname = module_dependencies.pop();
        var dependency_folder = path.join(module_folder, "node_modules", dname);
        var dependency_homestard = _load_homestar(dependency_folder);

        var is_module = _.d.get(dependency_homestard, "/module", false);
        if (!is_module) {
            return _install_next();
        }

        console.log("- found dependency:", dname);
        _install(dname, function() {
            try {
                console.log("- cleanup");
                console.log("  path:", dependency_folder);
                _rmdirSync(dependency_folder);
            } catch (x) {
            }

            _install_next();
        });
    }

    _install_next();
}
1170895
function(exists, cb) {
          if(!exists) {
            fs.mkdir(rootDir + '/node_modules', function(error) {
              cb(error);
            });
          } else {
            cb(null);
          }
        }
1129727
function(loader, packageJSON, isRoot){
		var deps = crawl.getDependencyMap(loader, packageJSON, isRoot);

		var dependencies = [];
		for(var name in deps) {
			dependencies.push(deps[name]);
		}

		return dependencies;
	}
277403
def install_modules(wip):
    """"""

    def install_module(hfos_module):
        """Install a single module via setuptools"""
        try:
            setup = Popen(
                [
                    sys.executable,
                    'setup.py',
                    'develop'
                ],
                cwd='modules/' + hfos_module + "/"
            )

            setup.wait()
        except Exception as e:
            log("Problem during module installation: ", hfos_module, e,
                type(e), exc=True, lvl=error)
            return False
        return True

    # TODO: Sort module dependencies via topological sort or let pip do this in future.
    # # To get the module dependencies:
    # packages = {}
    # for provision_entrypoint in iter_entry_points(group='hfos.provisions',
    #                                               name=None):
    #     log("Found packages: ", provision_entrypoint.dist.project_name, lvl=warn)
    #
    #     _package_name = provision_entrypoint.dist.project_name
    #     _package = pkg_resources.working_set.by_key[_package_name]
    #
    #     print([str(r) for r in _package.requires()])  # retrieve deps from setup.py

    modules_production = [
        # TODO: Poor man's dependency management, as long as the modules are
        # installed from local sources and they're not available on pypi,
        # which would handle real dependency management for us:
        'navdata',

        # Now all the rest:
        'alert',
        'automat',
        'busrepeater',
        'calendar',
        'countables',
        'dash',
        # 'dev',
        'enrol',
        'mail',
        'maps',
        'nmea',
        'nodestate',
        'project',
        'webguides',
        'wiki'
    ]

    modules_wip = [
        'calc',
        'camera',
        'chat',
        'comms',
        'contacts',
        'crew',
        'equipment',
        'filemanager',
        'garden',
        'heroic',
        'ldap',
        'library',
        'logbook',
        'protocols',
        'polls',
        'mesh',
        'robot',
        'switchboard',
        'shareables',
    ]

    installables = modules_production

    if wip:
        installables.extend(modules_wip)

    success = []
    failed = []

    for installable in installables:
        log('Installing module ', installable)
        if install_module(installable):
            success.append(installable)
        else:
            failed.append(installable)

    log('Installed modules: ', success)
    if len(failed) > 0:
        log('Failed modules: ', failed)
    log('Done: Install Modules')
444539
def vendorize(ctx, PACKAGES=None, dest_dir=None, internal_call=False):
    """"""
    if not internal_call:
        colorama.init()
        text.title("Minchin Vendorize-er for Python Projects v{}".format(__version__))

        print()

    text.subtitle("Configuration")
    extra_keys = ['here',
                  'source',
                  'module_name',
                  'vendor_dest',
                  'vendor_packages',
                  'vendor_override_src',
                 ]
    if not internal_call:
        check_configuration(ctx, 'releaser', extra_keys)
        check_existence(ctx.releaser.here, "base dir", "releaser.here")
    here = Path(ctx.releaser.here).resolve()

    if not internal_call:
        try:
            check_existence(ctx.releaser.source, "source", "releaser.source", here)
        except FileNotFoundError:
            sys.exit(1)

    check_existence(ctx.releaser.vendor_dest, "vendor dir", "releaser.vendor_dest",
                    here, allow_not_existing=True)
    check_existence(ctx.releaser.vendor_override_src, "override dir",
                    "releaser.vendor_override_src", here, True)
    print()


    dest_dir = Path(ctx.releaser.vendor_dest).resolve()
    base_pkg_dir = Path(ctx.releaser.source)
    # remove and recreate base folder
    text.subtitle("Removing existing vendored directory.")
    try:
        shutil.rmtree(str(dest_dir))
    except FileNotFoundError:
        # directory already deleted
        pass
    dest_dir.mkdir(exist_ok=True)
    print()

    my_req = ['# Requirements for {}'.format(ctx.releaser.module_name),
              '#',
              '# This is built by the minchin.releaser.vendorize script. Do not edit it directly.',
              '',
             ]
    my_req_add = []

    PACKAGES = tuple(ctx.releaser.vendor_packages.keys())

    for package in PACKAGES:
        text.subtitle("Vendorizing {}".format(package))
        req_to_add = []
        # copy python code
        root_dir = (here / ctx.releaser.vendor_packages[package].src).resolve()
        pkg_dest_dir = (dest_dir / ctx.releaser.vendor_packages[package].dest).resolve()
        pkg_dest_dir.mkdir(exist_ok=True)
        print("Copying code from {}".format(root_dir))
        copytree(str(root_dir), str(pkg_dest_dir), True, ['__pycache__'])


        # build requirements file
        try:
            pkg_req_override = (here / ctx.releaser.vendor_packages[package].requirements).resolve()
        except AttributeError:
            pkg_req_override = None
        pkg_req = root_dir / 'requirements.in'
        pkg_req_alt = root_dir / 'requirements.txt'
        if pkg_req_override and pkg_req_override.exists():
            print("  Using project override requirements.")
            req_to_add = read_requirements(str(pkg_req_override))
        elif pkg_req.exists():
            req_to_add = read_requirements(str(pkg_req))
        elif pkg_req_alt.exists():
            print("  Using requirements.TXT.")
            req_to_add = read_requirements(str(pkg_req_alt))
        else:
            print("  No requirements found.")
        my_req_add.extend(req_to_add)
        print()

    text.subtitle("Building requirements-vendor.in")
    # remove vendorized items from requirements list
    my_req_add = [i for i in set(my_req_add) if not i.startswith(PACKAGES)]
    my_req_add.sort()
    my_req.extend(my_req_add)

    # write out requirements file
    dst_req = here / 'requirements-vendor.in'
    dst_req.write_text('\n'.join(my_req) + '\n')
    print()

    # copy over project specific override files
    text.subtitle("Copying over project-specific vendorized overrides.")
    root_dir = Path(ctx.releaser.vendor_override_src)
    copytree(str(root_dir), str(dest_dir), overwrite=True,
             ignore_list=['__pycache__'])
    print()

    if not internal_call:
        text.centered("--- FIN ---")
531227
def install_module(
    self, target=None, package_manager=None, 
    install_optional=False, production_only=False, force=False, 
    node_paths=None, frozen_lockfile=None, workunit_name=None, workunit_labels=None):
    """"""
    package_manager = package_manager or self.get_package_manager(target=target)
    command = package_manager.install_module(
      install_optional=install_optional,
      force=force,
      production_only=production_only,
      node_paths=node_paths,
      frozen_lockfile=frozen_lockfile
    )
    return self._execute_command(
      command, workunit_name=workunit_name, workunit_labels=workunit_labels)