Loads a theme from an extension package.

@param {Object} themePackage is a package from the extension manager for the theme to be loaded.
@return {$.Promise} promise object resolved with the theme to be loaded from the pacakge
174393
function loadPackage(themePackage) {
        var fileName = themePackage.path + "/" + themePackage.metadata.theme.file;
        return loadFile(fileName, themePackage.metadata);
    }
585705
function loadTemplatesFiles (dir, files, options, templates) {
    // require files
    if (!Array.isArray(files)) {
        return Promise.resolve()
    }
    // load template for each file
    return Promise.each(files, file => {
        // get absolute file from dir
        var absFile = dir+'/'+file
        // get express template name by stripping off extension
        file = file.replace(GLOBAL.extRegExp, '')
        // if template has already been defined then do not replace so that
        // first incidence of file in multiple paths is used
        if (templates[file]) {
            return
        }
        // load template
        var promise = templates[file] = loadTemplate(absFile, options)
        // once template is loaded replace promise with template
        .then(template => {
            templates[file] = template
        })
        // wait for template to load
        return promise
    })
}
818736
function loadCurrentTheme() {
        var theme = getCurrentTheme();

        var pending = theme && FileUtils.readAsText(theme.file)
            .then(function (lessContent) {
                return lessifyTheme(lessContent.replace(commentRegex, ""), theme);
            })
            .then(function (content) {
                var result = extractScrollbars(content);
                theme.scrollbar = result.scrollbar;
                return result.content;
            })
            .then(function (cssContent) {
                $("body").toggleClass("dark", theme.dark);
                styleNode.text(cssContent);
                return theme;
            });

        return $.when(pending);
    }
1095510
function findPackages(path) {
  return new Promise(function (resolve, reject) {
    (0, _glob.glob)(path, function (err, res) {
      if (err) {
        reject(err);
      }
      resolve(res.filter(function (file) {
        return file.endsWith('.json');
      }));
    });
  });
}
600170
public <T> void load(ExtensionRepository<T> repository, Class<T> extensionType) {
//		loadExtensionFromPackage(repository, extensionType, getDefaultScanPackage());
//		String customScanPackage = getCustomScanPackage();
//		if (!Strings.isNullOrEmpty(customScanPackage)) {
//			loadExtensionFromPackage(repository, extensionType, customScanPackage);
//		}
		loadMetricsFromSPI(repository, extensionType);
	}
1109446
function getPackageSet(index, callback) {
	var page = {
		limit  : 100,
		offset : index*100
	}

	ckan.exec('current_package_list_with_resources', page, function(err, resp){
		checkError(err, resp);
		
		for( var i = 0; i < resp.result.length; i++ ) {
			data.packages[resp.result[i].id] = resp.result[i];
		}

		if( resp.result.length == 0 ) {
			if( callback ) callback();
		} else {
			if( options.debug ) console.log("CKAN EXPORT: Package data loaded ("+(index*100)+" to "+((index+1)*100)+")");
			index++;
			getPackageSet(index, callback);
		}
	});
}
1031197
function(moduleDir, packageJson) {
      var t = this,
          resolved = null,
          templates = t.get('templates');

      // Remove the -monitor portion of the app
      var appName = packageJson.name.replace(/-monitor$/,'');

      // Don't overwrite a more "locally" defined app
      if (t.apps[appName]) {
        return false;
      }

      // The app module must be found
      try {
        resolved = require.resolve(moduleDir);
      } catch (e) {
        console.error("Problem loading plug-in: " + moduleDir, e);
        return false;
      }

      // Clear module cache for reloads
      log.info('Loading app ' + appName + ' from ' + moduleDir);
      delete require.cache[resolved];

      // Load the module
      var server;
      try {
        server = require(resolved);
      } catch (e) {
        console.error('Problem loading the "' + appName + '" module: ', e.stack);
        return false;
      }

      var views = {}, // key: view name, value: {icon:'iconfile'}
          css = [],
          images = {}, // key: basename, value: filename
          appPath = '/app/' + appName + '/';

      // Add extensions
      try {
        FS.readdirSync(moduleDir + '/lib/ext').sort().forEach(function(filename) {
          var ext = Path.extname(filename).toLowerCase();
          var base = Path.basename(filename, ext);
          if (ext === '.js') {
            PAGE_PARAMS.scripts += JS_TEMPLATE({scriptFile: appPath + 'ext/' + filename});
          }
        });
      } catch (e) {
        if (e.code !== 'ENOENT') {
          console.error('Error reading ' + moduleDir + '/lib/ext', e);
        }
      }

      // Gather views to expose on the page
      try {
        FS.readdirSync(moduleDir + '/lib/view').sort().forEach(function(filename) {
          var ext = Path.extname(filename).toLowerCase();
          var base = Path.basename(filename, ext);
          if (ext === '.js') {
            views[base] = '';
            PAGE_PARAMS.scripts += JS_TEMPLATE({scriptFile: appPath + 'view/' + filename});
          }
        });
      } catch (e) {
        if (e.code !== 'ENOENT') {
          console.error('Error reading ' + moduleDir + '/lib/view', e);
        }
      }

      // Gather CSS to expose on the page
      try {
        FS.readdirSync(moduleDir + '/lib/css').sort().forEach(function(filename) {
          var ext = Path.extname(filename).toLowerCase();
          var base = Path.basename(filename, ext);
          if (ext === '.css') {
            css.push(filename);
            PAGE_PARAMS.styles += CSS_TEMPLATE({cssFile: appPath + 'css/' + filename});
          }
        });
      } catch (e) {
        if (e.code !== 'ENOENT') {
          console.error('Error reading ' + moduleDir + '/lib/css', e);
        }
      }

      // Gather templates to expose
      try {
        FS.readdirSync(moduleDir + '/lib/template').sort().forEach(function(filename) {
          var ext = Path.extname(filename).toLowerCase();
          var base = Path.basename(filename, ext);
          if (ext === '.html') {
            templates.add({id:appName + '-' + base, path:moduleDir + '/lib/template/' + filename});
          }
        });
      } catch (e) {
        if (e.code !== 'ENOENT') {
          console.error('Error reading ' + moduleDir + '/lib/template', e);
        }
      }

      // Gather images
      try {
        FS.readdirSync(moduleDir + '/lib/image').sort().forEach(function(filename) {
          var ext = Path.extname(filename).toLowerCase();
          var base = Path.basename(filename, ext);
          if (ext.match('\\.jpg|\\.jpeg|\\.ico|\\.bmp|\\.tif|\\.tiff|\\.gif')) {
            images[base] = appPath + 'image/' + filename;
          }
        });
      } catch (e) {
        if (e.code !== 'ENOENT') {
          console.error('Error reading ' + moduleDir + '/lib/image', e);
        }
      }

      // Match views to their icon image (if available)
      for (var viewName in views) {
        views[viewName] = {icon: images[viewName]};
      }

      // Record app information
      t.apps[appName] = {
        label: packageJson.label,
        description: packageJson.description,
        moduleDir: moduleDir,
        server: server,
        staticServer: Connect['static'](Path.join(moduleDir, '/view')),
        views: views,
        css: css
      };

      return appName;

    }
691447
function getAllPackages () {
  const packages = [
    // main package
    {
      entry: config.entry,
      jsName: 'index',
      cssName: 'style',
      globName: config.fullname,
      amdName: config.name,
    },
  ]

  return Promise.all([
    packagesFromPath(utils.resolve('src/component'), utils.resolve('src/component')),
    packagesFromPath(utils.resolve('src/mixin'), srcPath),
    packagesFromPath(utils.resolve('src/ol-ext'), srcPath),
    packagesFromPath(utils.resolve('src/rx-ext'), srcPath),
    packagesFromPath(utils.resolve('src/util'), srcPath),
  ]).then(otherPackages => {
    return packages.concat(otherPackages.reduce((all, packages) => all.concat(packages), []))
  })
}
358300
function loadTemplate() {
  generateData();

  return new Promise(function(resolve, reject) {

    // Load handlebars page template.
    $.get('src/demo-template.html', function(response) {
      template = response;
      render();
      resolve();
    }).fail(function() {
      reject();
    });
  });
}
1203846
function (packages) {
  var resolvedPackages = {};

  _.forOwn(packages, function (definition, packageName) {
    if (!definition) return;

    var git = definition.git;
    if (!git) return;

    var repo = resolvedPackages[git] = resolvedPackages[git] || {};

    // If no branch provided - checkout origin HEAD and
    // don't show 'detached HEAD' notification
    branch = definition.branch || '-q origin';
    // If no version provided - pull HEAD
    version = definition.version || 'HEAD';
    repo[branch] = repo[branch] || {};
    repo[branch][version] = repo[branch][version] || {};
    repo[branch][version][packageName] = definition.path || '';
  });

  return resolvedPackages;
}
45127
function generatePackageJson (config) {

	// Read the user's package.json
	var user_file;
	try {
		// Read from current file
		user_file = fs.readFileSync('./package.json').toString();
	} catch (e) {
		user_file = null;
	}

	// Parse the user's package.json
	var user_json = null;
	if (user_file) {
		try {
			user_json = JSON.parse(user_file);
		} catch (e) {
			console.log(colors.bold.red('Your package.json was invalid!\n\
	We skipped the merging of your package.json with template.'));
			console.log(user_json);
			return null;
		}
	} else {
		user_json = {};
	}

	// Read the template package.json
	var tmpl_file = fs.readFileSync(__dirname + '/../templates/package.json.tmpl').toString();

	// Replace the placeholders (e.g. %deviceType%) of whole of template
	for (var config_key in config) {
		tmpl_file = tmpl_file.replace(new RegExp('\\%' + config_key + '\\%', 'g'), config[config_key]);
	}
	tmpl_file = tmpl_file.replace(new RegExp('\\%libVersion\\%', 'g'), helper.getPackageInfo().version);

	// Parse the template package.json
	var tmpl_json = null;
	try {
		tmpl_json = JSON.parse(tmpl_file);
	} catch (e) {
		console.error('Could not parse the template file:\n' + tmpl_file + '\n' + e.stack.toString());
		process.exit(0);
	}

	// Merge the fields with template package.json
	for (var key in tmpl_json) {
		if (user_json[key] == null) {
			user_json[key] = tmpl_json[key];
		} else if (helper.isType(user_json[key], 'Object')) {
			for (var key_ in tmpl_json[key]) {
				if (user_json[key][key_] == null) user_json[key][key_] = tmpl_json[key][key_];
			}
		}
	}

	// Done
	return JSON.stringify(user_json,  null, '  ');

}
62616
function requirePackage(pkg, mainjs) {
			var processed = {};
			var pkgName = path.basename(pkg);
			var code = grunt.file.read(mainjs);
			while (true) {
				var requires = detective(code);
				if (!requires.length) break;
				for (var requireIdx in requires) {
					var name = requires[requireIdx];
					var requiredCode = '';
					if (!processed[name]) {
						var filepath = path.join(pkg, 'lib', name.replace(pkgName + '/', '') + '.js');
						requiredCode = grunt.file.read(filepath);
						processed[name] = true;
					}
					code = code.replace(new RegExp('require\\([\\\'\"]' + name + '[\\\'\"]\\);?'), requiredCode);
				}
			}
			return code;
		}
274897
function definePackage(name, dependencies, callback) {
    // Adjust arguments
    if (typeof name === "function") {
        callback = name;
        name = null;
        dependencies = null;
    } else if (typeof dependencies === "function") {
        callback = dependencies;
        dependencies = null;

        if (name instanceof Array) {
            dependencies = name;
            name = null;
        }
    }

    // Check name conflicts
    if (typeof name === "string") {
        if (packages.has(name)) {
            throw new Error("Package '" + name + "' is already loaded!");
        }
    }

    // Resolve timeout
    var timeout = _config2.default.get('package_timeout', 5000),
        timer = null;

    return new _es6Promise.Promise(function (succeed, fail) {

        // Start timeout
        if (typeof timeout === "number") {
            timer = setTimeout(function () {
                timer = null;

                if (_config2.default.get("debug", true)) {
                    throw new Error("Package '" + name + "' timed out!");
                }
            }, timeout);
        }

        // Resolve dependencies
        requireDependencies(dependencies).then(function (requirements) {
            try {

                // register package
                var register = function register(pack) {
                    // cancel timeout
                    if (timer) {
                        clearTimeout(timer);
                        timer = null;
                    }

                    if (pack === false) {
                        return;
                    }

                    if (typeof name === "string") {
                        packages.set(name, pack);
                        events.emit("load:" + name, packages.get(name));
                    }

                    return succeed(pack);
                };

                // Check boot response


                var bootResponse = typeof callback === "function" ? callback(requirements) : callback;return bootResponse instanceof _es6Promise.Promise ? bootResponse.then(register) : register(bootResponse);
            } catch (ex) {
                if (_config2.default.get("debug", true)) {
                    console.error(ex);
                }

                return fail(ex);
            }
        });
    });
}
1137520
function loadSVGText() {
        if (svgLoaded ||
            // @NOTE: these embed strategies don't require svg text to be loaded
            embedStrategy === EMBED_STRATEGY_BASIC_OBJECT ||
            embedStrategy === EMBED_STRATEGY_BASIC_IMG)
        {
            // don't load the SVG text, just return an empty promise
            return $.Deferred().resolve().promise({
                abort: function() {}
            });
        } else {
            return scope.get('page-svg', page);
        }
    }
142582
function bundle() {
  return new Promise((resolve, reject) => {
    webpack(webpackConfig).run((err, stats) => {
      if (err) {
        return reject(err);
      }

      console.log(stats.toString(webpackConfig[0].stats));
      return resolve();
    });
  });
}
832390
function loadPlugin(book, plugin) {
    var logger = book.getLogger();

    var name = plugin.getName();
    var pkgPath = plugin.getPath();

    // Try loading plugins from different location
    var p = Promise()
    .then(function() {
        var packageContent;
        var packageMain;
        var content;

        // Locate plugin and load package.json
        try {
            var res = resolve.sync('./package.json', { basedir: pkgPath });

            pkgPath = path.dirname(res);
            packageContent = require(res);
        } catch (err) {
            if (!isModuleNotFound(err)) throw err;

            packageContent = undefined;
            content = undefined;

            return;
        }

        // Locate the main package
        try {
            var indexJs = path.normalize(packageContent.main || 'index.js');
            packageMain = resolve.sync('./' + indexJs, { basedir: pkgPath });
        } catch (err) {
            if (!isModuleNotFound(err)) throw err;
            packageMain = undefined;
        }

        // Load plugin JS content
        if (packageMain) {
            try {
                content = require(packageMain);
            } catch(err) {
                throw new error.PluginError(err, {
                    plugin: name
                });
            }
        }

        // Update plugin
        return plugin.merge({
            'package': Immutable.fromJS(packageContent),
            'content': Immutable.fromJS(content || {})
        });
    })

    .then(validatePlugin);

    p = timing.measure('plugin.load', p);

    logger.info('loading plugin "' + name + '"... ');
    return logger.info.promise(p);
}
1282955
protected void addPackageResources(Package aPackage, Map<String, ClassResource> urlSet, ClassLoader[] classLoaders) {
        String packageName = aPackage.getName();
        String relativePath = getPackageRelativePath(packageName);
        List<URL> resources = getResources(relativePath, classLoaders);
        for (URL resource : resources) {
            String key = getJavaResourceKey(resource);
            urlSet.put(key, new ClassResource(packageName, resource));
        }
    }