Create a configured ESformatter factory
@private
@param  {options} options - Job options
@return {Function} - Generate an ESFormatter configuration
760006
function configureESFormatter(options) {
	const ESFormatConfig = {
		root: true,
		allowShebang: true,
		indent: {value: '\t'},
		whiteSpace: {
			before: {
				IfStatementConditionalOpening: -1
			},
			after: {
				IfStatementConditionalClosing: -1,
				FunctionReservedWord: 1
			}
		},
		lineBreak: {after: {ClassDeclarationClosingBrace: 0}}
	}
	if (options.space > 0) {
		ESFormatConfig.indent.value = ' '.repeat(parseInt(options.space, 10))
	}

	console.debug(stripIndent`
		${clr.title}esFormatter Options${clr.title.out}:
	`)
	if (console.canWrite(5)) {
		console.pretty(ESFormatConfig, 2)
	}

	return () => esFormatter.rc(ESFormatConfig)
}
473278
function createService (app, Service, Model, options) {
  Model = options.Model || Model;
  if (typeof Model === 'function') {
    assert(options.ModelName, 'createService but options.ModelName not provided');
    options.Model = Model(app, options.ModelName);
  } else {
    options.Model = Model;
  }
  const service = new Service(options);
  return service;
}
1118314
function customize(opts /*: Options */) {
  var renderers = opts.renderers || {};

  return function markings(strings /*: Array<string> */ /*::, ...values: Array<ReactNode> */) {
    var values = Array.prototype.slice.call(arguments, 1);
    var input = stripIndent(strings.join(PLACEHOLDER));
    var parser = new Parser();
    var ast = parser.parse(input);

    if (!validate(ast)) {
      throw new Error('react-markings cannot interpolate React elements non-block positions');
    }

    var index = 0;
    var renderer = new Renderer({
      renderers: Object.assign({}, renderers, {
        Paragraph: function(props) {
          if (props.children.length === 1 && props.children[0] === PLACEHOLDER) {
            var value = values[index];
            index = index + 1 < values.length ? index + 1 : 0;
            return value;
          } else if (renderers.Paragraph) {
            return renderers.Paragraph(props);
          } else if (renderers.paragraph) {
            return renderers.paragraph(props);
          } else {
            return React.createElement('p', {}, props.children);
          }
        },
      })
    });

    return React.createElement('div', {}, renderer.render(ast));
  }
}
882983
function createETagGenerator (options) {
  return function generateETag (body, encoding) {
    var buf = !Buffer.isBuffer(body)
      ? Buffer.from(body, encoding)
      : body

    return etag(buf, options)
  }
}
564579
function plugin(options){
  options = options || {};
  var keys = options.keys || [];

  return function(files, metalsmith, done){
    setImmediate(done);
    var md = new MarkdownIt(options);
    Object.keys(files).forEach(function(file){
      if (!markdown(file)) return;
      var data = files[file];
      var dir = dirname(file);
      var html = basename(file, extname(file)) + '.html';
      if ('.' != dir) html = dir + '/' + html;

      var str = md.render(data.contents.toString());
      data.contents = new Buffer(str);
      keys.forEach(function(key) {
        data[key] = md.render(data[key]);
      });

      delete files[file];
      files[html] = data;
    });
  };
}
577827
async function generateJson(options, generatorResult) {
  const jsonPath = (
    options.jsonPath ||
    `${ path.join(options.outputDir, '/' + options.fontName) }.json`
  )

  const css = generatorResult.generateCss()
  let map = {}

  css.replace(CSS_PARSE_REGEX, (match, name, code) => map[name] = code)

  await fsAsync.writeFile(jsonPath, JSON.stringify(map, null, 4))
}
732839
function generateTSConfig(options, fileNames) {
        var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions);
        var configurations = {
            compilerOptions: serializeCompilerOptions(compilerOptions)
        };
        if (fileNames && fileNames.length) {
            // only set the files property if we have at least one file
            configurations.files = fileNames;
        }
        return configurations;
        function getCustomTypeMapOfCommandLineOption(optionDefinition) {
            if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean") {
                // this is of a type CommandLineOptionOfPrimitiveType
                return undefined;
            }
            else if (optionDefinition.type === "list") {
                return getCustomTypeMapOfCommandLineOption(optionDefinition.element);
            }
            else {
                return optionDefinition.type;
            }
        }
        function getNameOfCompilerOptionValue(value, customTypeMap) {
            // There is a typeMap associated with this command-line option so use it to map value back to its name
            for (var key in customTypeMap) {
                if (customTypeMap[key] === value) {
                    return key;
                }
            }
            return undefined;
        }
        function serializeCompilerOptions(options) {
            var result = ts.createMap();
            var optionsNameMap = getOptionNameMap().optionNameMap;
            for (var name_35 in options) {
                if (ts.hasProperty(options, name_35)) {
                    // tsconfig only options cannot be specified via command line,
                    // so we can assume that only types that can appear here string | number | boolean
                    switch (name_35) {
                        case "init":
                        case "watch":
                        case "version":
                        case "help":
                        case "project":
                            break;
                        default:
                            var value = options[name_35];
                            var optionDefinition = optionsNameMap[name_35.toLowerCase()];
                            if (optionDefinition) {
                                var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition);
                                if (!customTypeMap) {
                                    // There is no map associated with this compiler option then use the value as-is
                                    // This is the case if the value is expect to be string, number, boolean or list of string
                                    result[name_35] = value;
                                }
                                else {
                                    if (optionDefinition.type === "list") {
                                        var convertedValue = [];
                                        for (var _i = 0, _a = value; _i < _a.length; _i++) {
                                            var element = _a[_i];
                                            convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap));
                                        }
                                        result[name_35] = convertedValue;
                                    }
                                    else {
                                        // There is a typeMap associated with this command-line option so use it to map value back to its name
                                        result[name_35] = getNameOfCompilerOptionValue(value, customTypeMap);
                                    }
                                }
                            }
                            break;
                    }
                }
            }
            return result;
        }
    }
569029
function Plugin(options) {

  options = options || {};

  var reactOptions = {
    harmony: typeof options.harmony === 'undefined' ? true : options.harmony,
    stripTypes: typeof options.stripTypes === 'undefined' ? true : options.stripTypes
  };

  if (options.template && options.template.indexOf('<') === -1) {
    options.template = fs.readFileSync(options.template, {encoding: 'utf8'});
  }

  var originalJsTransform = require.extensions['.js'];

  var reactTransform = function(module, filename) {
    if (filename.indexOf('node_modules') === -1) {
      var src = fs.readFileSync(filename, {encoding: 'utf8'});
      src = appendJsxPragma(filename, src);
      src = ReactTools.transform(src, reactOptions);
      module._compile(src, filename);
    } else {
      originalJsTransform(module, filename);
    }
  };

  require.extensions['.js'] = reactTransform;
  require.extensions['.jsx'] = reactTransform;

  // Creates a stream through which each file will pass
  var stream = through.obj(function(file, enc, cb) {

    if (!file.isNull()) {

      if (file.isStream()) {
        this.emit('error', new PluginError(PLUGIN_NAME, 'Streams are not supported!'));
        return cb();
      }

      if (file.isBuffer()) {

        try {
          var contents = file.contents.toString('utf8');
          contents = appendJsxPragma(file.path, contents);
          contents = ReactTools.transform(contents, reactOptions);
          var m = new Module();
          m.id = file.path;
          m.filename = file.path;
          m.paths = module.paths.slice(1);
          m._compile(contents, file.path);
          var Component = m.exports;
          var markup = options.staticMarkup ? renderToStaticMarkup(Component) : renderToString(Component);

          if (options.template) {
            var data = _.extend({}, (typeof(options.data) == 'function' ? options.data(file) : options.data));
            data.body = markup;

            // Set default values to avoid null-reference exceptions
            data.title = data.title || '';
            data.description = data.description || '';
            data.keywords = data.keywords || '';

            markup = template(options.template, data);
          }

          file.contents = new Buffer(markup);
          var filename = gutil.replaceExtension(file.path, '.html');

          if (typeof options.hyphenate === 'undefined' || options.hyphenate) {
            filename = hyphenate(path.basename(filename));
            filename = filename.lastIndexOf('-', 0) === 0 ? filename.substring(1) : filename;
            filename = path.join(path.dirname(file.path), filename);
          }

          file.path = filename;
        } catch (err) {
          this.emit('error', new PluginError(PLUGIN_NAME, err));
          return cb();
        }
      }
    }

    // Make sure the file goes through the next gulp plugin
    this.push(file);
    // Tell the stream engine that we are done with this file
    return cb();
  });

  // Return the file stream
  return stream;
}
1093998
function createCoreConfig(moduleFormat, productive, copyAssets) {
  return {
    input: 'src/main/js-surface/index.js',

    output: {
      file: productive
        ? `dist/js-surface.${moduleFormat}.production.js`
        : `dist/js-surface.${moduleFormat}.development.js`,

      format: moduleFormat,
      name: 'jsSurface',
      exports: 'named',
      sourcemap: productive ? false : 'inline',

      globals: {
      }
    },

    plugins: [
      resolve({
        jsnext: true,
        main: true,
        module: true,
        browser: true,
      }),
      commonjs({
      }),
      eslint({
      }),
      replace({
        exclude: 'node_modules/**',

        values: {
          'process.env.NODE_ENV': productive ? "'production'" : "'development'",
          "import 'preact/devtools'": productive ? '' : "import 'preact/devtools'"
        }
      }),
      babel({
        //exclude: 'node_modules/**',
        //externalHelpers: true,
        presets: [['@babel/preset-env', { modules: false }]],
      }),
      productive && (moduleFormat === 'esm' ? uglifyES() : uglifyJS()),
      productive && gzip(),
      copyAssets && copy({ 'assets': 'dist' })
    ],
  }
}
1031337
function Renderer(options) {
  var defaults = {
    headers: {
      included: true,
      downcase: true,
      upcase: true
    },

    delimiter: 'tab',
    decimalSign: 'comma',
    outputDataType: 'json',
    columnDelimiter: "\t",
    rowDelimiter: '\n',

    inputHeader: {},
    outputHeader: {},
    dataSelect: {},

    outputText: '',

    newline: '\n',
    indent: '  ',

    commentLine: '//',
    commentLineEnd: '',
    tableName: 'converter',

    useUnderscores: true,
    includeWhiteSpace: true,
    useTabsForIndent: false
  };

  this.options = merge({}, defaults, options);
  if (this.options.includeWhiteSpace) {
    this.options.newline = '\n';
  } else {
    this.options.indent = '';
    this.options.newline = '';
  }
}
927917
function factory(key, options) {
  var settings = options || {}

  function one(value) {
    var fn = one.invalid
    var handlers = one.handlers

    if (value && own.call(value, key)) {
      fn = own.call(handlers, value[key]) ? handlers[value[key]] : one.unknown
    }

    return (fn || noop).apply(this, arguments)
  }

  one.handlers = settings.handlers || {}
  one.invalid = settings.invalid
  one.unknown = settings.unknown

  return one
}
757289
function WorkerJob(msg, options, callback) {
  this.msg = msg || {};
  this.options = options || {};
  this.callback = callback;
}
507879
function eslint(options) {
  if (typeof options === 'boolean') {
    options = { fail: options }
  }
  options = { ...new ESLintOptions(), ...options }

  return new Promise((resolve, reject) => {
    const args = generateArguments(options)
    const child = spawn('node', args, { stdio: options.stdio, cwd: path.resolve(options.appRootPath || getRootPath()) })

    function handleError(error) {
      if (options.fail === false) {
        resolve(false)
      } else {
        reject(cleanupError(error))
      }
    }

    child.on('error', handleError)

    child.on('exit', error => {
      if (error) {
        handleError(error)
      } else {
        resolve(true)
      }
    })
  })
}
25259
function createModuleConfig(options) {
  return {
    strictExportPresence: true,
    rules: [// Disable require.ensure as it's not a standard language feature.
    {
      parser: {
        requireEnsure: false
      }
    }, // tsx? / jsx?
    {
      test: options.typescript ? /\.[tj]sx?$/ : /\.jsx?$/,
      include: [path.resolve(options.paths.src), ...options.includeModules.map(includeModule => {
        const packageJson = findUp.sync('package.json', {
          cwd: path.dirname( // requireFromPwd.resolve(includeModule)
          fs.realpathSync(resolveFrom(process.cwd(), includeModule)))
        });
        if (!packageJson) return;
        return packageJson.slice(0, -12);
      }).filter(Boolean), ...options.includePaths],
      loaders: [{
        loader: require.resolve('babel-loader'),
        options: {
          babelrc: false,
          cacheDirectory: true,
          ...options.babel
        }
      }, ...(options.jsLoaders || [])]
    }, // other rules
    ...(options.moduleRules || [])]
  };
}
382349
function formatter(options, severity, date, elems) {

    /*
    OPTIONS
    */
    const indent = options.indent || defaultIndent;
    const objectDepth = options.objectDepth;
    const timestamp = (function () {
        if (check.function(options.timestamp)) {
            return options.timestamp; // user-provided timestamp generating function
        } else if (options.timestamp === false) {
            return false; // no timestamp
        } else {
            return getTimestampString; // default timestamp generating function
        }
    })();
    const rootFolderName = options.rootFolderName;

    /*
    LOGIC
    */

    // the last element is an aggregate object of all of the additional passed in elements
    var aggObj = elems[elems.length - 1];

    // initial log string
    var build = ' ';

    // add the date
    if (timestamp !== false) {
        // otherwise, use the default timestamp generator function
        build += ' ' + timestamp(date);
    }

    build += ' ' + getColorSeverity(severity) + ' ';

    // add the component if provided
    if (aggObj.scope) {
        build += getScopeString(aggObj.scope) + ' ';
        delete aggObj.scope;
    }

    // errors are a special case that we absolutely need to keep track of and log the entire stack
    var errors = [];

    for (let i = 0; i < elems.length - 1; i++) { // iterate through all elements in the array except the last (obj map of options)
        let element = elems[i];

        // Attempt to determine an appropriate title given the first element
        if (i === 0) {
            let elementConsumed = false;
            if (check.string(element)) {
                // string is obviously the title
                build += chalk.blue(element);
                elementConsumed = true;
            } else if (check.instance(element, Error)) {
                // title is the error text representation
                build += chalk.blue(element.message || '[no message]');
                // also store error stacktrace in the aggregate object
                errors.push(element);
                elementConsumed = true;
            }

            // add on the file and line number, which always go after the title, inline
            if (aggObj.file && aggObj.line) {
                aggObj.file = truncFilename(aggObj.file, rootFolderName);
                build += chalk.dim(` (${aggObj.file}:${aggObj.line})`);
                delete aggObj.file;
                delete aggObj.line;
            }

            // do not add element 0 to the 'extra' data section
            if (elementConsumed) {
                continue;
            }
        }

        // add the element to the errors array if it's an error
        if (check.instance(element, Error)) {
            errors.push(element);
            // the error will be concatinated later so continue to the next element
            continue;
        }

        let objString = '\n' + util.inspect(element, { colors: true, depth: objectDepth });
        build += objString.replace(/\n/g, indent);
    }

    if (Object.keys(aggObj).length > 0) {
        let objString = '\n' + util.inspect(aggObj, { colors: true, depth: objectDepth });
        build += objString.replace(/\n/g, indent);
    }

    // iterate through the top-level object keys looking for Errors as well
    for (let o of Object.keys(aggObj)) {
        if (check.instance(o, Error)) {
            errors.push(o);
        }
    }

    // iterate through all the Error objects and print the stacks
    for (let e of errors) {
        build += indent + e.stack.replace(/\n/g, indent);
    }

    return build;
}
964431
function esmangleify(opt) {

  // options is mostly the escodegen format
  var format = {
    renumber   : true,
    hexadecimal: true,
    escapeless : true,
    compact    : true,
    semicolons : false,
    parentheses: false
  }

  // fail silently allows us to process json (and other non js) files that make it through the transform process
  //  alternatively you could implement a options.filter
  var options = merge(format, {
    failSilently: true
  }, opt);

  // transform
  return esprimaTools.createTransform(updater, options);
}
757461
function constructTransformer(options) {
  const transform = getTransform(options)
  if (transform && typeof transform === 'object') {
    return jstransformer(transform)
  }

  return jstransformer(require('jstransformer-' + transform))
}