Builds config file to packages folder

@param {string} file - Config file
559229
async function buildConfig(file) {
  const { default: config } = await import(`${CONFIGS_PATH}/${file}`);
  const { creator, name, packageName } = config;

  creator
    .then((data) => {
      const stringifiedData = JSON.stringify(data);
      const generatedData = TEMPLATE.replace(/{{ data }}/, stringifiedData);
      const packageFile = path.resolve(PACKAGES_PATH, packageName, 'index.js');
      fs.writeFileSync(packageFile, generatedData);
    })
    .then(
      () => console.log(`Finished building ${name} config to ./packages/${packageName}`),
      error => console.log(error),
    );
}
1265261
function(file){
        const list = require(utils.getAppLocalPath() + file);
        if(!isObject(list)) return false;

        Object.keys(list).forEach(key => {
            let window = list[key];
            this.createNew(key, window.title, window.url, window.setupTemplate, window.setup);
        });
    }
1292716
function generateDistFiles(config) {
	// Delete package.json from the cache since it can get updated by npm version
	delete require.cache[require.resolve('./package.json')];

	var pkg = require('./package.json'),
		distFilename = DIST_DIR + config.name + '.js',
		minDistFilename = distFilename.replace(/\.js$/, '.min.js'),
		minDistSourcemapFilename = minDistFilename + '.map',
		distTestingFilename = DIST_DIR + config.name + '-testing' + '.js';

	// Add copyrights and version info
	var versionComment = '/*! ' + config.name + ' v' + pkg.version + ' */\n',
		testingVersionComment = '/*! ' + config.name + '-testing v' + pkg.version + ' */\n',
		copyrightComment = cat('./config/copyright.txt');

	// concatenate files together and add version/copyright notices
	(versionComment + copyrightComment + cat(config.files)).to(distFilename);
	(testingVersionComment + copyrightComment + cat(config.testingFiles)).to(distTestingFilename);

	// create minified version with source maps
	var result = uglifyjs.minify(distFilename, {
		output: {
			comments: /^!/
		},
		outSourceMap: path.basename(minDistSourcemapFilename)
	});
	result.code.to(minDistFilename);
	result.map.to(minDistSourcemapFilename);

	// create filenames with version in them
	cp(distFilename, distFilename.replace('.js', '-' + pkg.version + '.js'));
	cp(minDistFilename, minDistFilename.replace('.min.js', '-' + pkg.version + '.min.js'));
	cp(distTestingFilename, distTestingFilename.replace('.js', '-' + pkg.version + '.js'));
}
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);
}
1184106
function (file) {
  let port = program.port,
    host = program.host || '127.0.0.1',
    dbname = program.dbname || '-deployd',
    mongoPort = program.mongoPort ? Number(program.mongoPort) : '27017',
    env = program.environment || process.env.DPD_ENV || 'development',
    retries = 0,
    credentials = {};


  if (!port) {
    port = 2403;
    retries = env === 'development' && 5;
  }

  if (file) {
    process.chdir(path.dirname(file));
  }
  if (test('-f', 'app.dpd')) {
    console.log(`deployd CLI version ${packageInfo.version}`);
    console.log('starting deployd');

    if (fs.existsSync(latestversionFile)) {
      const latest = fs.readFileSync(latestversionFile, 'utf-8');
      if (latest && semver.gt(latest, packageInfo.version)) {
        console.log(`deployd CLI v${latest} is available.`);
        console.log();
      }
    }
    checkForUpdates();

    if (!test('-d', './.dpd')) mkdir('-p', './.dpd');
    if (!test('-d', './.dpd/pids')) mkdir('-p', './.dpd/pids');
    if (!test('-d', './data')) mkdir('-p', './data');

    if (program.auth && program.host === undefined) {
      console.error("Authentication requires the '-h' host flag... exiting.");
      process.exit();
    }

    function setCredentials(username, password) { // eslint-disable-line no-inner-declarations
      Step(function () {
        const next = this;
        if (username && username !== '') {
          credentials.username = username;
          next();
        } else {
          console.error('Username cannot be blank.');
          process.exit();
        }
      },
        function () {
          const next = this;
          if (password && password !== '') {
            credentials.password = password;
            next();
          } else {
            console.error('Password cannot be blank.');
            process.exit();
          }
        },
        startup
      );
    }

    if (program.host) {
      if (program.auth) {
        const auth = program.auth.split(':'),
          username = auth[0],
          password = auth[1];
        setCredentials(username, password);
      } else if (program.username || program.password) {
        setCredentials(program.username, program.password);
      } else {
        startup();
      }
    } else {
      mongod.restart(program.mongod || 'mongod', env, mongoPort, startup);
    }
  } else {
    console.log('This directory does not contain a Deployd app!');
    console.log('Use "dpd create <appname>" to create a new app');
    console.log('or use "dpd path/to/app.dpd" to start an app in another directory');
    stop(1);
  }

  function startup(err) {
    if (err) {
      console.log("Failed to start MongoDB (Make sure 'mongod' are in your $PATH or use dpd --mongod option. Ref: http://docs.deployd.com/docs/basics/cli.html)");
      return stop(1);
    }

    const options = { port, env: 'development', db: { host, port: mongoPort, name: dbname } };

    options.env = program.environment || process.env.DPD_ENV || options.env;
    if (options.env !== 'development') console.log('starting in %s mode', options.env);

    if (credentials && credentials.length > 0) options.db.credentials = credentials;

    let dpd = createServer(options);
    dpd.on('listening', onListening);
    dpd.on('error', onError);
    dpd.listen();
    dpd.deploydPath = program.deploydPath;

    function onListening() {
      console.info('listening on port', options.port);
      const commands = repl(dpd);
      if (program.dashboard) {
        commands.dashboard();
      } else if (program.open) {
        commands.open();
      }
    }

    function onError(err2) {
      if (err2.code === 'EADDRINUSE') {
        console.error();
        console.error(`ERROR: port ${options.port} is already in use`);
        if (retries > 0) {
          options.port += 1;
          console.log(`Trying again on port ${options.port}...`);
          console.log();
          retries -= 1;
          dpd = createServer(options);
          dpd.on('listening', onListening);
          dpd.on('error', onError);
          dpd.listen();
        } else {
          process.exit();
        }
      } else {
        console.error(err2);
        process.exit();
      }
    }
  }
}
1115837
async function flowBuildPlugin(pkg, options) {
  const buildOutputRoot = path.resolve(
    pkg.paths.root,
    options.outputDir || './build',
  )
  const patterns = (
    options.inputs || ['**/*.js', '!__tests__', '!test.js']
  ).concat(['!node_modules/**/*', `!${path.basename(buildOutputRoot)}/**/*`])
  const sourceRoot =
    options.sourceDir != null
      ? path.resolve(pkg.paths.root, options.sourceDir)
      : pkg.paths.root

  // :: string -> Array<string>
  const getJsFilePaths = () =>
    globby(patterns, {
      cwd: sourceRoot,
    })

  const filePaths = await getJsFilePaths()

  // :: string -> Promise<void>
  const transpileFile = filePath =>
    new Promise(resolve => {
      const module = path.resolve(sourceRoot, filePath)
      const input = fs.readFileSync(module, 'utf8')
      const output = flowRemoveTypes(input)
      const outFile = path.resolve(buildOutputRoot, filePath)
      ensureParentDirectoryExists(outFile)
      fs.writeFileSync(outFile, output.toString(), { encoding: 'utf8' })
      fs.writeFileSync(`${outFile}.flow`, input, { encoding: 'utf8' })
      resolve()
    })

  const limit = pLimit(maxConcurrentTranspiles)
  const queueTranspile = filePath => limit(() => transpileFile(filePath))
  await Promise.all(R.map(queueTranspile, filePaths))
}
900585
function buildBrowser(file, watch) {
  const props = {
    entries: [paths.src + file + '.js'],
    debug : true,
    cache: {},
    packageCache: {},
    standalone: 'swapi'
  };

  const bundler = watch ? watchify(browserify(props)) : browserify(props);

  function rebundle() {
    let stream = bundler.transform('babelify')
      .bundle();
    return stream
      .pipe($.plumber())
      .on('error', (err) => { $.notify().write(err); })
      .pipe(source(file + '.browser.js'))
      .pipe(buffer())
      .pipe($.uglify())
      .pipe(gulp.dest(paths.dist));
  }

  bundler.on('update', function() {
    rebundle();
    $.util.log('Rebundle...');
  });

  return rebundle();
}
220668
function globFile (file) {
    return stat(file).then(({ err, stats }) => {
      if (err) throw err
      if (stats.isDirectory()) {
        // TODO what if file is already slash-terminated?
        switch (file) {
          case './':
            return globPromise('./*.js')
          case 'bin':
            return globPromise('bin/*')
          default:
            return globPromise(`${file}/**/*.js`)
        }
      } else {
        return Promise.resolve(file)
      }
    })
  }
854001
function getConfigSettings(packageJsonFile) {
  // Locate and read package.json
  const pkg = JSON.parse(fs.readFileSync(packageJsonFile));

  return {
    searchDir:
      getConfigSetting(pkg, 'searchDir', true) || getDefaultValue('searchDir'),
    outputFile:
      getConfigSetting(pkg, 'outputFile') || getDefaultValue('outputFile'),
    pattern: getConfigSetting(pkg, 'pattern') || getDefaultValue('pattern'),
  };
}
1062740
function compileFile( sourceBundle, bundleFile, config, callback ) {
	var fname = sourceBundle + "/bundle.json";
	fs.readFile(fname, 'utf8', function (err,data) {
		if (err) {
			console.error("Unable to load file",fname);
			if (callback) callback( err, null );
			return;
		}

		// Update path if missing
		if (!config['path'])
			config['path'] = path.dirname( sourceBundle );

		// Compile
		compile( JSON.parse(data), bundleFile, config, callback );

	});
}
691303
function generateEmbed(config, file) {
  const targetPath = path.join(config.destDir, path.relative(config.src, file));
  const document = parseDocument(file);
  const sampleSections = document.sections.filter(
    s => s.inBody && !s.isEmptyCodeSection()
  );
  sampleSections.forEach((section, index) => {
    highlight(section.codeSnippet()).then(code => {
      const tag = section.doc ? slug(section.doc.toLowerCase()) : index;
      const context = {
        sample: {
          file: path.basename(targetPath),
          preview: addFlag(targetPath, tag, 'preview'),
          embed: addFlag(targetPath, tag, 'embed'),
          template: addFlag(targetPath, tag, 'template'),
          body: section.code,
          code: code,
        },
        config: config,
        document: document,
      };
      generate(context.sample.preview, templates.preview, context, /* minify */ true);
      generate(context.sample.embed, templates.embed, context, /* minify */ true);
      generateTemplate(context);
    });
  });
}
1127675
function readConfigFromFile(filePath) {
  var config = {};

  if (isFilePath(filePath)) {
    try {
      config = yaml.safeLoad(stripComments(fs.readFileSync(filePath, 'utf8'))) || {};
    } catch (e) {
      e.message = 'Cannot read config file: ' + filePath + '\nError: ' + e.message;
      throw e;
    }

    if (path.basename(filePath) === PACKAGE_CONFIG_FILENAME) {
      config = config[PACKAGE_CONFIG_FIELD_NAME] || {};
    }

  } else {

        // it's a package

    if (filePath.charAt(0) === '@') {
            // it's a scoped package

            // package name is 'nplint-config', or just a username
      var scopedPackageShortcutRegex = /^(@[^\/]+)(?:\/(?:eslint-config)?)?$/;
      if (scopedPackageShortcutRegex.test(filePath)) {
        filePath = filePath.replace(scopedPackageShortcutRegex, '$1/nplint-config');
      } else if (filePath.split('/')[1].indexOf('eslint-config-') !== 0) {
                // for scoped packages, insert the eslint-config after the first /
        filePath = filePath.replace(/^@([^\/]+)\/(.*)$/, '@$1/nplint-config-$2');
      }
    } else if (filePath.indexOf('nplint-config-') !== 0) {
      filePath = 'nplint-config-' + filePath;
    }

    config = util.mergeConfigs(config, require(filePath));
  }
  return config;
}
146112
function(file) {
      var sections = file.contents.toString().split(END_REG);

      var blocks = [],
        files = [];

      var self = this;

      sections.forEach(function(s) {
        if (s.match(START_REG)) {
          // s[0] html code
          // s[1] string 'css' or 'js'
          // s[2] string dest url
          // s[3] tags of link or script
          s = s.split(START_REG);
          blocks.push(s[0]);
          switch (s[1]) {
            case 'css':
              blocks.push('<link rel="stylesheet" href="' + s[2] + '">');
              break;
            case 'js':
              blocks.push('<script src="' + s[2] + '"></script>');
              break;
            default:
              throw new gutil.PluginError('gulp-htmlbuild', 'only build:css build:js accept\n');
          }
          var paths = self.matchContentPaths(s[1] === 'css' ? CSSFILE_REG : JSFILE_REG, s[3]);
          var source = concatSource(paths);
          files.push({
            type: s[1],
            dest: resolveSrc(s[2], self.filedir),
            source: source
          });
        } else {
          blocks.push(s);
        }
      });

      return {
        blocks: blocks,
        files: files
      }
    }
154910
function buildString(file, enc, cb) {
		var currentFilePath = file.path;
		var fileName = getFileName(currentFilePath);

		//don't read the destination path (if in same folder)
		if (fileName === destFileName || file.isNull()) {
			cb();
			return;
		}

		if (file.isStream()) {
			cb(new PluginError(PLUGIN_NAME, 'Streaming not supported'));
			return;
		}

		addImportToList(currentFilePath, file, fileName, opts);
		return cb();
	}
296135
function buildDep(file, pkg){
  var files = [];

  if (file.processed || file.package != pkg)
    return files;

  file.processed = true;

  for (var i = 0, depFile; depFile = file.deps[i++];)
    files.push.apply(files, buildDep(depFile, file.package));

  files.push(file);

  return files;
}
350449
function buildStructureForFile(file) {
  var names = [];
  var targetLink;

  if (file.dox.length === 0) { return false; }

  file.dox.forEach(function(method){
    if (method.ctx && !method.ignore) { names.push(method.ctx.name); }
  });

  // How deep is your love?
  // If the splitted currentFile (the file we are currently rendering) path got one folder
  // in the path or more, add ../ for each level found
  if(file.currentFile && file.currentFile.split(path.sep).length > 1 ){
    // Depth of current file
    var depth = file.currentFile.split(path.sep).length,
    // Create a prefix with n "../"
    prefix = new Array(depth).join('../');
    // Set up target link with prefix
    targetLink = prefix + file.targetFile;
  } else {
    // Link does not have to be altered
    targetLink = file.targetFile;
  }

  return {
    source: {
      full: file.sourceFile,
      dir: path.dirname(file.sourceFile),
      file: path.basename(file.sourceFile)
    },
    target: file.targetFile,
    methods: names,
    link : targetLink
  };
}
1299257
public static CacheConfiguration build(File file) throws IOException {
		ConfigMap<String, String> config = ConfigMap.load(file);
		return CacheConfiguration.build(config);
	}