<commit_before>require('shelljs/global');

const platform = {
  path: 'sashimi-platform',
  buildPath: 'public'
};
const webapp = {
  path: 'sashimi-webapp',
  buildPath: 'dist'
};

let statusBuild = -1;
let statusStart = -1;

printTitle('Build web application')

cd(`./${webapp.path}`);
statusBuild = exec('yarn run build').code;
throwErrorIfFailedToExec(statusBuild, 'build failed')

printTitle('Copy webapp to server folder');

rm('-rf', `../${platform.path}/${platform.buildPath}/*`);
cp('-R', `${webapp.buildPath}/*`, `../${platform.path}/${platform.buildPath}/`);

cd(`..`);

printTitle('Run web server')

cd(`./${platform.path}`);
statusStart = exec('yarn start').code;
throwErrorIfFailedToExec(statusStart, 'run failed')




function throwErrorIfFailedToExec(statusCode, message) {
  if (statusCode !== 0) {
    printTitle(`Error: ${message}`);
    printMessage(`Script exit(${statusCode})`);    
    exit(1);
  }
}

function printMessage(message) {
  let echoMsg = message || '';
  echo(` [Deploy] > ${echoMsg}`);
}

function printTitle(message) {
  let echoMsg = message || '----------------';<commit_msg>Fix deployment script to include yarn"<commit_after>require('shelljs/global');

const platform = {
  path: 'sashimi-platform',
  buildPath: 'public'
};
const webapp = {
  path: 'sashimi-webapp',
  buildPath: 'dist'
};

let statusBuild = -1;
let statusStart = -1;

printTitle('Build web application');

cd(`./${webapp.path}`);
exec('yarn');
statusBuild = exec('yarn run build').code;
throwErrorIfFailedToExec(statusBuild, 'build failed')

printTitle('Copy webapp to server folder');

rm('-rf', `../${platform.path}/${platform.buildPath}/*`);
cp('-R', `${webapp.buildPath}/*`, `../${platform.path}/${platform.buildPath}/`);

cd(`..`);

printTitle('Run web server')

cd(`./${platform.path}`);
exec('yarn')
statusStart = exec('yarn start').code;
throwErrorIfFailedToExec(statusStart, 'run failed')




function throwErrorIfFailedToExec(statusCode, message) {
  if (statusCode !== 0) {
    printTitle(`Error: ${message}`);
    printMessage(`Script exit(${statusCode})`);    
    exit(1);
  }
}

function printMessage(message) {
  let echoMsg = message || '';
  echo(` [Deploy] > ${echoMsg}`);
}

function printTitle(message) {
  let echoMsg = message || '----------------';
{'fraction_non_alphanumeric': 0.21419185282522996, 'fraction_numerical': 0.003504161191414805, 'mean_word_length': 4.681592039800995, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '4198747', 'n_tokens_mistral': 762, 'n_tokens_neox': 770, 'n_words': 157}