<commit_before>#!/usr/bin/env node

// compile itch for production environemnts

const $ = require('./common')
const bluebird = require('bluebird');
const humanize = require('humanize-plus');

async function main () {
  $.say(`Preparing to compile ${$.appName()} ${$.buildVersion()}`);

  await $.showVersions(['npm', 'node']);

  $(await $.npm('install'));

  $.say('Wiping dist...');
  $(await $.sh('rm -rf dist'));

  $.say('Compiling sources...');
  const jsOutputs = await bluebird.all([
    $.getOutput('npm run -s build-metal-prod'),
    $.getOutput('npm run -s build-chrome-prod')
  ]);

  $.say('Sources compilation output:');
  $.putln('-------- Metal -------:\n' + jsOutputs[0]);
  $.putln('------- Chrome -------:\n' + jsOutputs[1]);

  $.say('Generating custom package.json...')
  const pkg = JSON.parse(await $.readFile('package.json'));
  for (const field of ['name', 'productName', 'desktopName']) {
    pkg[field] = $.appName();
  }
  pkg.version = $.buildVersion();
  const pkgContents = JSON.stringify(pkg, null, 2);
  await $.writeFile(`dist/package.json`, pkgContents);
<commit_msg>ci: build metal & chrome separately to avoid running out of memory (yay, javascript o/)<commit_after>#!/usr/bin/env node

// compile itch for production environemnts

const $ = require('./common')
const bluebird = require('bluebird');
const humanize = require('humanize-plus');

async function main () {
  $.say(`Preparing to compile ${$.appName()} ${$.buildVersion()}`);

  await $.showVersions(['npm', 'node']);

  $(await $.npm('install'));

  $.say('Wiping dist...');
  $(await $.sh('rm -rf dist'));

  $.say('Compiling sources...');
  $(await $.sh('npm run -s build-metal-prod'))
  $(await $.sh('npm run -s build-chrome-prod'))

  $.say('Generating custom package.json...')
  const pkg = JSON.parse(await $.readFile('package.json'));
  for (const field of ['name', 'productName', 'desktopName']) {
    pkg[field] = $.appName();
  }
  pkg.version = $.buildVersion();
  const pkgContents = JSON.stringify(pkg, null, 2);
  await $.writeFile(`dist/package.json`, pkgContents);

{'fraction_non_alphanumeric': 0.22537241710716002, 'fraction_numerical': 0.0019221528111484864, 'mean_word_length': 3.8531468531468533, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3999035', 'n_tokens_mistral': 692, 'n_tokens_neox': 663, 'n_words': 170}