<commit_before>// required for async/await to work
import 'babel-polyfill';
import colors from 'colors';
import splitFile from 'split-file';
import del from 'delete';
import spinner from './spinner';
import Command from './command';
import logger from './logger';
import { dockerfile } from './dockerfile';
import { readFile, writeFile, isStringJson, getNodeEnv, didPassParam } from './utils';

let meteorSettingsVar;

const buildMeteorApp = async () => {
  const message = 'building meteor app';
  spinner.start(`${message} (this can take several minutes)`);
  const buildCommand = new Command(`meteor build .meteor/local/builds ${dockerfile.serverOnly} --architecture=os.linux.x86_64`);
  await buildCommand.run();
  spinner.succeed(message);
};


const createDockerfile = async () => {
  const dockerfileContents = dockerfile.getContents(didPassParam('MONGO_URL'));
  logger('creating Dockerfile');
  await writeFile('.meteor/local/builds/Dockerfile', dockerfileContents);
};

const createSupervisorFile = async () => {
  logger('creating supervisor');
  await writeFile('.meteor/local/builds/supervisord.conf', dockerfile.getSupervisor());
};

const splitBuild = async () => {
  logger('splitting bundle');
  await new Promise((resolve, reject) => {
    splitFile.splitFileBySize(`.meteor/local/builds/${dockerfile.buildzip}`, 999999, (err, names) => {
      if (err) {
        reject(err);
      }
      resolve(names);
    });
  });
};

const handleMeteorSettings = async () => {
  if (!didPassParam('METEOR_SETTINGS')) {
    const env = getNodeEnv();
    const settingsFile = `${env}.settings.json`;
    logger(`looking for meteor settings file ${settingsFile} in root of project`);
    const settingsString = await readFile(settingsFile);
    if (settingsString) {
      // settings file found
      if (!isStringJson(settingsString)) {
        throw new Error(`ERROR: ${settingsFile} file is not valid JSON`);
      } else {
        meteorSettingsVar = settingsString.replace(/[\n ]/g, '');
        logger('found settings file');
      }
    } else {
      logger('no settings file found');
    }
  }
};

const deployMeteorApp = async () => {
  const message = 'deploying build';
  let mongoUrl = '';
  if (!didPassParam('MONGO_URL')) {<commit_msg>delete original bundle after it has been split<commit_after>// required for async/await to work
import 'babel-polyfill';
import colors from 'colors';
import splitFile from 'split-file';
import del from 'delete';
import spinner from './spinner';
import Command from './command';
import logger from './logger';
import { dockerfile } from './dockerfile';
import { readFile, writeFile, isStringJson, getNodeEnv, didPassParam } from './utils';

let meteorSettingsVar;

const buildMeteorApp = async () => {
  const message = 'building meteor app';
  spinner.start(`${message} (this can take several minutes)`);
  const buildCommand = new Command(`meteor build .meteor/local/builds ${dockerfile.serverOnly} --architecture=os.linux.x86_64`);
  await buildCommand.run();
  spinner.succeed(message);
};


const createDockerfile = async () => {
  const dockerfileContents = dockerfile.getContents(didPassParam('MONGO_URL'));
  logger('creating Dockerfile');
  await writeFile('.meteor/local/builds/Dockerfile', dockerfileContents);
};

const createSupervisorFile = async () => {
  logger('creating supervisor');
  await writeFile('.meteor/local/builds/supervisord.conf', dockerfile.getSupervisor());
};

const splitBuild = async () => {
  logger('splitting bundle');
  await new Promise((resolve, reject) => {
    splitFile.splitFileBySize(`.meteor/local/builds/${dockerfile.buildzip}`, 999999, async (err, names) => {
      if (err) {
        reject(err);
      }
      // delete original bundle file so that it doesnt get uploaded to now
      await del.promise([`.meteor/local/builds/${dockerfile.buildzip}`]);
      resolve(names);
    });
  });
};

const handleMeteorSettings = async () => {
  if (!didPassParam('METEOR_SETTINGS')) {
    const env = getNodeEnv();
    const settingsFile = `${env}.settings.json`;
    logger(`looking for meteor settings file ${settingsFile} in root of project`);
    const settingsString = await readFile(settingsFile);
    if (settingsString) {
      // settings file found
      if (!isStringJson(settingsString)) {
        throw new Error(`ERROR: ${settingsFile} file is not valid JSON`);
      } else {
        meteorSettingsVar = settingsString.replace(/[\n ]/g, '');
        logger('found settings file');
      }
    } else {
      logger('no settings file found');
    }
  }
};

const deployMeteorApp = async () => {
  const message = 'deploying build';
  let mongoUrl = '';
  if (!didPassParam('MONGO_URL')) {
{'fraction_non_alphanumeric': 0.1446193109315185, 'fraction_numerical': 0.004253509145044662, 'mean_word_length': 4.035331905781584, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6830243', 'n_tokens_mistral': 1438, 'n_tokens_neox': 1384, 'n_words': 364}