Generates project from copied repository
@param  {Object}    config     Configuration information
@param  {String}    gitFolder  Temporary foler to save unzipped item into
@param  {Function}  callback   Called on completion
333375
function generateProject(config, callback) {
  var dirName = config.siteName;

  if(config.firebase !== 'webhook') {
    dirName = unescapeSite(dirName);
  }

  wrench.copyDirSyncRecursive('.wh-generate/', process.cwd() + '/' + dirName, {
      forceDelete: true
  });

  var siteDir = process.cwd() + '/' + dirName;

  if(fs.existsSync(siteDir + '/.wh-original')) {
    if(fs.existsSync(siteDir + '/.wh-original/pages')) {
      wrench.rmdirSyncRecursive(siteDir + '/pages');
      wrench.copyDirSyncRecursive(siteDir + '/.wh-original/pages', siteDir + '/pages', {
        forceDelete: true
      })
    }
    if(fs.existsSync(siteDir + '/.wh-original/templates')) {
      wrench.rmdirSyncRecursive(siteDir + '/templates');
      wrench.copyDirSyncRecursive(siteDir + '/.wh-original/templates', siteDir + '/templates', {
        forceDelete: true
      })
    }
    if(fs.existsSync(siteDir + '/.wh-original/static')) {
      wrench.rmdirSyncRecursive(siteDir + '/static');
      wrench.copyDirSyncRecursive(siteDir + '/.wh-original/static', siteDir + '/static', {
        forceDelete: true
      })
    }

    wrench.rmdirSyncRecursive(siteDir + '/.wh-original'); 
  }

  callback();
}
577918
function _config(args) {
  var opts = {};

  if(args.removeExtraneous){
    opts.removeExtraneous = true;
  }

  if (args.bitbucketAuthUser || args.bitbucketAuthPass) {
    opts.bitbucket = {
      authUser: args.bitbucketAuthUser,
      authPass: args.bitbucketAuthPass
    };

  } else if (args.githubUser || args.githubOrg || args.githubAuthUser || args.githubAuthPass) {
    opts.github = {
      user    : args.githubUser,
      org     : args.githubOrg,
      authUser: args.githubAuthUser,
      authPass: args.githubAuthPass,
      useSsh : args.githubUseSsh
    };

  } else if (args.gitoriousUrl || args.gitoriousProject) {
    opts.gitorious = {
      url    : args.gitoriousUrl,
      project: args.gitoriousProject
    };

  } else if (args.local) {
    opts.local = {
      dir: process.cwd()
    };
  }

  new Repoman().config(opts, bag.exit);
}
1063528
function(config, cb){
    // This will tell webpack to create a new chunk
    rq.ensure(['INDEX_PATH'],function(rq){
      let library = rq('INDEX_PATH');
      library = library.default || library; // To preven issues between versions
      cb(
        // Expected to export an initializing function
        library(config)
      );
    },'NAME');
  }
16788
function (config) {
    config = config || {};
    Appender.call(this, config);

    /**
     * True to log strings instead of objects
     */
    this.appendStrings = (typeof config.appendStrings !== 'undefined') ?
      config.appendStrings :
      true;
  }
1073442
function copyJekyllConfig() {
    return streamToPromise(
        gulp.src(paths.src.jekyll)
            .pipe(rename('_config.yaml'))
            .pipe(gulp.dest(paths.out.docs.base))
    );
}
1100463
function entrifyFromPkg(dir, options) {

  // Find package.json files.
  const pkgPaths = glob.sync('**/package.json', { cwd: dir, nodir: true, absolute: true })

  pkgPaths.forEach((pkgPath) => {
    console.log('[entrify]', 'Found:', pkgPath)
    const pkg = require(pkgPath)

    // A package.json file should have a main entry.
    if (!pkg.main) {
      console.warn('[entrify]', pkgPath, 'does not have a main entry.')
      return
    }

    // The main entry should not point to an index.js file.
    if (pkg.main === 'index.js' || pkg.main === './index.js') {
      console.warn('[entrify]', pkgPath, 'main entry is index.js.')
      return
    }

    // Ensure the index.js file to create doesn't already exist.
    const pkgDir = path.dirname(pkgPath)
    const indexPath = `${pkgDir}/index.js`

    if (fs.existsSync(indexPath)) {
      console.warn('[entrify]', indexPath, 'already exists.')
      return
    }

    // Create an index.js file alongside the package.json.
    const name = camelize(path.basename(pkgDir))
    const main = pkg.main.startsWith('./') ? pkg.main : `./${pkg.main}`

    fs.writeFileSync(indexPath, indexTemplate(options.format, { name, main }))
    console.log('[entrify]', indexPath, 'created!')

    // Delete the package.json file.
    fs.unlinkSync(pkgPath)
    console.log('[entrify]', pkgPath, 'deleted!')
  })
}
395783
function compileJBB( config, parseCallback, resultCallback ) {

	// Continue compiling the JBB bundle
	var compile = function( bundleJSON, bundlePath, tempName ) {

		// Update path in config
		if (!config['path'])
			config['path'] = path.dirname(bundlePath);

		// Create the JBB bundle
		JBBCompiler.compile(
				bundleJSON,
				tempName,
				config,
				function() {

					// Check for sparse bundles
					if (config['sparse']) {
						resultCallback( null, {
							'basename': tempName,
							'suffix': [
								'.jbbp', '_b16.jbbp', 
							  	'_b32.jbbp', '_b64.jbbp' 
							]
						}); 
					} else {
						// Trigger callback
						resultCallback( null, {
							'basename': tempName,
							'suffix': [ '.jbb' ]
						});
					}

				}
			);

	};

	// Open a new temporary file (to be tracked by temp)
	temp.open({suffix: '_tmp'}, function(err, info) {

		// Handle errors
		if (err) {
			resultCallback(err, null);
			return;
		}
	    fs.close(info.fd, function(err) {
	      if (err) {
			resultCallback(err, null);
			return;
	      }

	      // We are ready, continue with compiling
	      parseCallback(function( bundleJSON, baseName ) {
		      compile( bundleJSON, baseName, info.path );
	      });
	    });

	});

}
268873
function customStrategy(projectDir, builder, cb)
{
  const dest = builder.getTargetDestination(projectDir);
  shelljs.rm('-rf', dest);

  const copyOptions = { overwrite: true, expand: true, dot: true };

  const onCustomInstallerFilesReady = function (err) {
    builder.buildFromSource(dest, projectDir);
    cb();
  };

  const onInstallerFilesReady = function (err) {
    if (err) {
      cb(err);
      return;
    }

    let customInstallerSrc = path.resolve(projectDir, "src", "installer");
    customInstallerSrc = fs.realpathSync(customInstallerSrc);

    const customInstallerTarget = path.resolve(dest, "src", "settings");
    copy(customInstallerSrc, customInstallerTarget, copyOptions, onCustomInstallerFilesReady);
  };

  let installerDir = path.resolve(projectDir, "node_modules", "@deskpro", INSTALLER_PACKAGE_NAME);
  installerDir = fs.realpathSync(installerDir);
  copy(installerDir, dest, copyOptions, onInstallerFilesReady);
}
692271
function bundlePreprocessor(config) {

    var debug = config.browserify && config.browserify.debug;

    function updateSourceMap(file, content) {
      var map;

      if (debug) {

        map = extractSourceMap(content);

        file.sourceMap = map && map.sourcemap;
      }
    }

    return function(content, file, done) {

      if (b._builtOnce) {
        updateSourceMap(file, content);
        return done(content);
      }

      log.debug('building bundle');

      // wait for the initial bundle to be created
      b.deferredBundle(function(err, content) {

        b._builtOnce = config.autoWatch;

        if (err) {
          return done(BUNDLE_ERROR_TPL);
        }

        content = content.toString('utf-8');
        updateSourceMap(file, content);

        log.info('bundle built');

        done(content);
      });
    };
  }
460975
def save_configure(self,
                       repo=None,
                       name=None,
                       groups=None,
                       config_val='',
                       from_registry=False,
                       main_cfg=False,
                       instances=1):
        
        def template_to_manifest(vent_template, manifest, tool, instances):
            """
            Helper function to transfer information from vent.template
            to plugin_manifest
            """
            sections = vent_template.sections()
            if sections[0]:
                for section in sections[1]:
                    section_dict = {}
                    if section == 'settings':
                        section_dict.update({'instances': str(instances)})
                    options = vent_template.options(section)
                    if options[0]:
                        for option in options[1]:
                            option_name = option
                            if option == 'name':
                                option_name = 'link_name'
                            opt_val = vent_template.option(section,
                                                           option)[1]
                            section_dict[option_name] = opt_val
                    if section_dict:
                        manifest.set_option(tool, section,
                                            json.dumps(section_dict))
                    elif manifest.option(tool, section)[0]:
                        manifest.del_option(tool, section)

        constraints = locals()
        del constraints['config_val']
        del constraints['from_registry']
        del constraints['main_cfg']
        del constraints['instances']
        del constraints['template_to_manifest']
        status = (True, None)
        fd = None
        # ensure instances is an int and remove instances from config_val to
        # ensure correct info
        instances = int(instances)
        config_val = re.sub(r'instances\ *=\ *\d+\n', '', config_val)
        api_system = System()
        manifest = api_system.manifest
        if not main_cfg:
            if not from_registry:
                # creating new instances
                if instances > 1:
                    fd, template_path = tempfile.mkstemp(suffix='.template')
                    # scrub name for clean section name
                    if re.search(r'\d+$', name):
                        name = re.sub(r'\d+$', '', name)
                    t_identifier = {'name': name,
                                    'branch': branch,
                                    'version': version}
                    result = Template(manifest).constrain_opts(
                        t_identifier, [])
                    tools = result[0]
                    tool = list(tools.keys())[0]
                else:
                    options = ['path', 'multi_tool', 'name']
                    tools, _ = Template(manifest).constrain_opts(
                        constraints, options)
                    # only one tool in tools because perform this function for
                    # every tool
                    if tools:
                        tool = list(tools.keys())[0]
                        if ('multi_tool' in tools[tool] and
                                tools[tool]['multi_tool'] == 'yes'):
                            name = tools[tool]['name']
                            if name == 'unspecified':
                                name = 'vent'
                            template_path = join(tools[tool]['path'],
                                                 name+'.template')
                        else:
                            template_path = join(tools[tool]['path'],
                                                 'vent.template')
                    else:
                        status = (False, "Couldn't save configuration")
            else:
                fd, template_path = tempfile.mkstemp(suffix='.template')
                options = ['namespace']
                constraints.update({'type': 'registry'})
                tools, _ = Template(manifest).constrain_opts(constraints,
                                                             options)
                if tools:
                    tool = list(tools.keys())[0]
                else:
                    status = (False, "Couldn't save configuration")
            if status[0]:
                try:
                    # save in vent.template
                    with open(template_path, 'w') as f:
                        f.write(config_val)
                    # save in plugin_manifest
                    vent_template = Template(template_path)
                    manifest = Template(manifest)
                    if instances > 1:
                        # add instances as needed
                        for i in range(1, instances + 1):
                            i_section = tool.rsplit(':', 2)
                            i_section[0] += str(i) if i != 1 else ''
                            i_section = ':'.join(i_section)
                            if not manifest.section(i_section)[0]:
                                manifest.add_section(i_section)
                                for val_pair in manifest.section(tool)[1]:
                                    name = val_pair[0]
                                    val = val_pair[1]
                                    if name == 'name':
                                        val += str(i)
                                    elif name == 'last_updated':
                                        val = Timestamp()
                                    elif name == 'running':
                                        val = 'no'
                                    manifest.set_option(i_section, name, val)
                                template_to_manifest(vent_template, manifest,
                                                     i_section, instances)
                            else:
                                settings = manifest.option(i_section,
                                                           'settings')
                                if settings[0]:
                                    settings_dict = json.loads(settings[1])
                                    settings_dict['instances'] = str(instances)
                                    manifest.set_option(i_section, 'settings',
                                                        json.dumps(
                                                            settings_dict))
                                else:
                                    inst = str(instances)
                                    settings_dict = {'instances': inst}
                                    manifest.set_option(i_section, 'settings',
                                                        json.dumps(
                                                            settings_dict))
                    else:
                        try:
                            settings_str = manifest.option(tool, 'settings')[1]
                            settings_dict = json.loads(settings_str)
                            old_instances = int(settings_dict['instances'])
                        except Exception:
                            old_instances = 1
                        template_to_manifest(vent_template, manifest,
                                             tool, old_instances)
                    manifest.write_config()
                    status = (True, manifest)
                except Exception as e:  # pragma: no cover
                    self.logger.error('save_configure error: ' + str(e))
                    status = (False, str(e))
            # close os file handle and remove temp file
            if from_registry or instances > 1:
                try:
                    close(fd)
                    remove(template_path)
                except Exception as e:  # pragma: no cover
                    self.logger.error('save_configure error: ' + str(e))
        else:
            with open(self.vent_config, 'w') as f:
                f.write(config_val)
        return status
602107
async function deploy() {
  // Initialize a new repository
  await makeDir('build');
  await spawn('git', ['init', '--quiet'], options);

  // Changing a remote's URL
  let isRemoteExists = false;
  try {
    await spawn(
      'git',
      ['config', '--get', `remote.${remote.name}.url`],
      options,
    );
    isRemoteExists = true;
  } catch (error) {
    /* skip */
  }
  await spawn(
    'git',
    ['remote', isRemoteExists ? 'set-url' : 'add', remote.name, remote.url],
    options,
  );

  // Fetch the remote repository if it exists
  let isRefExists = false;
  try {
    await spawn(
      'git',
      ['ls-remote', '--quiet', '--exit-code', remote.url, remote.branch],
      options,
    );
    isRefExists = true;
  } catch (error) {
    await spawn('git', ['update-ref', '-d', 'HEAD'], options);
  }
  if (isRefExists) {
    await spawn('git', ['fetch', remote.name], options);
    await spawn(
      'git',
      ['reset', `${remote.name}/${remote.branch}`, '--hard'],
      options,
    );
    await spawn('git', ['clean', '--force'], options);
  }

  // Build the project in RELEASE mode which
  // generates optimized and minimized bundles
  process.argv.push('--release');
  if (remote.static) process.argv.push('--static');
  await run(require('./build').default); // eslint-disable-line global-require
  if (process.argv.includes('--static')) {
    await cleanDir('build/*', {
      nosort: true,
      dot: true,
      ignore: ['build/.git', 'build/public'],
    });
    await moveDir('build/public', 'build');
  }

  // Push the contents of the build folder to the remote server via Git
  await spawn('git', ['add', '.', '--all'], options);
  try {
    await spawn('git', ['diff', '--cached', '--exit-code', '--quiet'], options);
  } catch (error) {
    await spawn(
      'git',
      ['commit', '--message', `Update ${new Date().toISOString()}`],
      options,
    );
  }
  await spawn(
    'git',
    ['push', remote.name, `master:${remote.branch}`, '--set-upstream'],
    options,
  );

  // Check if the site was successfully deployed
  const response = await fetch(remote.website);
  console.info(
    `${remote.website} => ${response.status} ${response.statusText}`,
  );
}
747669
def fetch_git_package(self, config):
        
        # only loading git here when needed to avoid load errors on systems
        # without git installed
        from git import Repo

        ref = self.determine_git_ref(config)
        dir_name = self.sanitize_git_path(uri=config['uri'], ref=ref)
        cached_dir_path = os.path.join(self.package_cache_dir, dir_name)

        # We can skip cloning the repo if it's already been cached
        if not os.path.isdir(cached_dir_path):
            logger.debug("Remote repo %s does not appear to have been "
                         "previously downloaded - starting clone to %s",
                         config['uri'],
                         cached_dir_path)
            tmp_dir = tempfile.mkdtemp(prefix='stacker')
            try:
                tmp_repo_path = os.path.join(tmp_dir, dir_name)
                with Repo.clone_from(config['uri'], tmp_repo_path) as repo:
                    repo.head.reference = ref
                    repo.head.reset(index=True, working_tree=True)
                shutil.move(tmp_repo_path, self.package_cache_dir)
            finally:
                shutil.rmtree(tmp_dir)
        else:
            logger.debug("Remote repo %s appears to have been previously "
                         "cloned to %s -- bypassing download",
                         config['uri'],
                         cached_dir_path)

        # Update sys.path & merge in remote configs (if necessary)
        self.update_paths_and_config(config=config,
                                     pkg_dir_name=dir_name)
652377
function(repo, version, hash, meta, outDir) {

    var url, tempRepoDir, packageJSONData, self = this;

    if (meta.vPrefix) {
      version = 'v' + version;
    }

    // Automatically track and cleanup files at exit
    temp.track();

    url = createGitUrl(self.options.baseurl, repo, self.options.reposuffix, self.auth);

    return createTempDir().then(function(tempDir) {
      tempRepoDir = tempDir;
      return exportGitRepo(tempRepoDir, version, url, self.execOpt, self.options.shallowclone);
    }).then(function() {
      return readPackageJSON(tempRepoDir);
    }).then(function(data) {
      packageJSONData = data;
      return moveRepoToOutDir(tempRepoDir, outDir);
    }).then(function() {
      return packageJSONData;
    });
  }
1254382
function (buildConfig) {
        var projectRoot = buildConfig.projectRoot;
        var packageFile = path.join(projectRoot, 'package.json');

        var url = require(packageFile).repository.url;
        var prefix = 'github.com/';

        return url.substring(url.indexOf(prefix) + prefix.length, url.lastIndexOf('.git'));
    }
269056
function loadConfigFile(configInfo) {
    const { filePath } = configInfo;
    let config;

    switch (path.extname(filePath)) {
        case ".js":
            config = loadJSConfigFile(filePath);
            if (configInfo.configName) {
                config = config.configs[configInfo.configName];
                if (!config) {
                    throw configMissingError(configInfo.configFullName);
                }
            }
            break;

        case ".json":
            if (path.basename(filePath) === "package.json") {
                config = loadPackageJSONConfigFile(filePath);
                if (config === null) {
                    return null;
                }
            } else {
                config = loadJSONConfigFile(filePath);
            }
            break;

        case ".yaml":
        case ".yml":
            config = loadYAMLConfigFile(filePath);
            break;

        default:
            config = loadLegacyConfigFile(filePath);
    }

    return ConfigOps.merge(ConfigOps.createEmptyConfig(), config);
}
786932
function _configFilter ( f ) {
        var parts = f.split("."),
            ext = parts[ parts.length - 1 ],
            pre = parts[ parts.length - 2 ],
            name = parts[ parts.length - 3];

        return !!(ext === "dist" && pre === "json" &&
                    exports.__ignores.indexOf( name ) === -1 && exports.__ignores.indexOf( f ) === -1 );
    }
318320
function createModuleConfig(loader) {
	var tmp = require("tmp");
	var config = {};
	var virtualModules = loader.virtualModules || {};
	for(var moduleName in virtualModules) {
		var filename = tmp.fileSync().name;
		var source = virtualModules[moduleName];
		fs.writeFileSync(filename, source, "utf8");

		var paths = config.paths = config.paths || {};
		paths[moduleName] = "file:"+filename;
	}
	return config;
}