<commit_before>var cp = require('child_process');
var fs = require('fs-extra');
var asar = require('asar');
var path = require('path');
var temp = require('temp');
var series = require('async').series;
var format = require('util').format;
var debug = require('debug')('electron-installer-squirrel-windows');
var _template = require('lodash.template');

temp.track();

var Model = require('ampersand-model');

// @todo (imlucas): move this to `ampersand-sync-errback`
var createSyncErrback = function(method, model, options) {
  var fn = options.error;
  options.error = function(resp) {
    if (fn) {
      fn(model, resp, options);
    }
    model.trigger('error', model, resp, options);
  };

  var success = options.success;
  options.success = function(resp) {
    if (!model.set(model.parse(resp, options), options)) return false;
    if (success) {
      success(model, resp, options);
    }
  };
  return function(err, resp) {
    if (err) {
      options.error(err);
    } else {
      options.success(resp);
    }
  };
};

var App = Model.extend({
  props: {
    name: 'string',
    version: 'string',
    description: 'string',
    copyright: 'string',
    // Path to the app.
    path: 'string',
    // Directory to put installers in.
    out: 'string',
    product_name: 'string',
    electron_version: {
      type: 'string',
      default: function() {
        // @todo (imlucas): make a module that just has the latest electron
        // version number, e.g.
        // require('electron-latest-version');
        // -> '0.29.2'
        return '0.29.2';
      }
    },
    authors: 'string',
    owners: 'string',
    title: 'string',
    exe: 'string',
    icon_url: 'string',
    setup_icon: 'string',
    loading_gif: 'string',
    remote_releases: 'string'
  },
  derived: {
    asar: {
      deps: ['resources'],
      fn: function() {
        return path.join(this.resources, 'app.asar');
      }
    },
    resources: {
      deps: ['path'],
      fn: function() {
        return path.join(this.path, 'resources');
      }
    },
    setup_path: {
      deps: ['out', 'product_name'],
      fn: function() {
        return path.join(this.out, format('%sSetup.exe', this.product_name.replace(/ /g, '')));
      }
    }
  },
  parse: function(resp) {
    resp.product_name = resp.product_name || resp.productName || resp.name;
    resp.icon_url = resp.icon_url || resp.iconUrl;

    if (!resp.authors) {
      resp.authors = resp.author ? resp.author.name : '';
    }
    if (!resp.exe) {
      resp.exe = format('%s.exe', resp.name);
    }

    resp.loading_gif = resp.loading_gif || resp.loadingGif;
    if (!resp.loading_gif) {
      resp.loading_gif = path.resolve(__dirname, 'resources', 'install-spinner.gif');
    }

    if (!resp.owners) {
      resp.owners = resp.authors;
    }

    if (!resp.title) {
      resp.title = resp.product_name;
    }

    resp.icon_url = resp.icon_url || resp.iconUrl;
    if (!resp.icon_url) {
      resp.icon_url = 'https://raw.githubusercontent.com/atom/electron/'
        + 'master/atom/browser/resources/win/atom.ico';
    }

    if (!resp.copyright) {<commit_msg>more debugging with real apps<commit_after>var cp = require('child_process');
var fs = require('fs-extra');
var asar = require('asar');
var path = require('path');
var temp = require('temp');
var series = require('async').series;
var format = require('util').format;
var debug = require('debug')('electron-installer-squirrel-windows');
var _template = require('lodash.template');

temp.track();

var Model = require('ampersand-model');

// @todo (imlucas): move this to `ampersand-sync-errback`
var createSyncErrback = function(method, model, options) {
  var fn = options.error;
  options.error = function(resp) {
    if (fn) {
      fn(model, resp, options);
    }
    model.trigger('error', model, resp, options);
  };

  var success = options.success;
  options.success = function(resp) {
    if (!model.set(model.parse(resp, options), options)) return false;
    if (success) {
      success(model, resp, options);
    }
  };
  return function(err, resp) {
    if (err) {
      options.error(err);
    } else {
      options.success(resp);
    }
  };
};

var App = Model.extend({
  props: {
    name: 'string',
    version: 'string',
    description: 'string',
    copyright: 'string',
    // Path to the app.
    path: 'string',
    // Directory to put installers in.
    out: 'string',
    product_name: 'string',
    electron_version: {
      type: 'string',
      default: function() {
        // @todo (imlucas): make a module that just has the latest electron
        // version number, e.g.
        // require('electron-latest-version');
        // -> '0.29.2'
        return '0.29.2';
      }
    },
    authors: 'string',
    owners: 'string',
    title: 'string',
    exe: 'string',
    icon_url: 'string',
    setup_icon: 'string',
    loading_gif: 'string',
    remote_releases: 'string'
  },
  derived: {
    asar: {
      deps: ['resources'],
      fn: function() {
        return path.join(this.resources, 'app.asar');
      }
    },
    resources: {
      deps: ['path'],
      fn: function() {
        return path.join(this.path, 'resources');
      }
    },
    setup_path: {
      deps: ['out', 'product_name'],
      fn: function() {
        return path.join(this.out, format('%sSetup.exe', this.product_name.replace(/ /g, '')));
      }
    }
  },
  parse: function(resp) {
    resp.product_name = resp.product_name || resp.productName || resp.name;
    resp.icon_url = resp.icon_url || resp.iconUrl;

    if (!resp.authors) {
      resp.authors = resp.author ? resp.author.name : '';
    }
    if (!resp.exe) {
      resp.exe = format('%s.exe', resp.product_name);
    }

    resp.loading_gif = resp.loading_gif || resp.loadingGif;
    if (!resp.loading_gif) {
      resp.loading_gif = path.resolve(__dirname, 'resources', 'install-spinner.gif');
    }

    if (!resp.owners) {
      resp.owners = resp.authors;
    }

    if (!resp.title) {
      resp.title = resp.product_name;
    }

    resp.icon_url = resp.icon_url || resp.iconUrl;
    if (!resp.icon_url) {
      resp.icon_url = 'https://raw.githubusercontent.com/atom/electron/'
        + 'master/atom/browser/resources/win/atom.ico';
    }

    if (!resp.copyright) {
{'fraction_non_alphanumeric': 0.16746259153135945, 'fraction_numerical': 0.0025469595670168737, 'mean_word_length': 2.6213256484149854, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '3556227', 'n_tokens_mistral': 2108, 'n_tokens_neox': 2054, 'n_words': 444}