<commit_before>import React from 'react'
import cx from 'suitcx'
import ExternalLink from '../ExternalLink'

const { env } = process
const pkg = mapEnvToProps(env, 'npm_package')
const appName = pkg.displayName || pkg.name
const versionString = `v${pkg.version}`
const hash = pkg.gitHead ? pkg.gitHead.slice(0, 8) : 'dev'
const commitUrl = pkg.repository_url ? pkg.repository_url.replace(/(^git\+|\.git$)/g, '') + '/commit/' + hash : ''

export default function AboutPanel () {
  return (
    <div className={cx('Panel', { background: 'fill', center: true })}>
      <h1>{appName} <small>{versionString}</small></h1>
      <h4>Crafted with love by <strong>jimotosan</strong></h4>
      <h5><small>{process.platform} ({process.arch}) &mdash; electron v{process.versions.electron}</small></h5>
      {commitUrl && hash && (
        <div className={'version-info'}>
          <small>
            <ExternalLink href={commitUrl}>
              <code>{hash}</code>
            </ExternalLink>
          </small>
        </div>
      )}
    </div>
  )
}

function mapEnvToProps (env, prefix, name) {
  const prefixPath = prefix.split(/_/g)
  return Object.keys(env)
    .reduce((out, key) => {
      if (key.startsWith(`${prefix}_`)) {
        const path = key.split(/_/g).slice(prefixPath.length).join('_')
        out[path] = env[key]
      }
      return out
    }, {})
}<commit_msg>Use package.json instead of build env for version info on About page<commit_after>import React from 'react'
import cx from 'suitcx'
import ExternalLink from '../ExternalLink'
import pkg from '../../../../package.json'

const appName = pkg.displayName || pkg.name
const versionString = `v${pkg.version}`
const hash = pkg.gitHead ? pkg.gitHead.slice(0, 8) : 'dev'
const commitUrl = pkg.repository.url ? pkg.repository.url.replace(/(^git\+|\.git$)/g, '') + '/commit/' + hash : ''

export default function AboutPanel () {
  return (
    <div className={cx('Panel', { background: 'fill', center: true })}>
      <h1>{appName} <small>{versionString}</small></h1>
      <h4>Crafted with love by <strong>jimotosan</strong></h4>
      <h5><small>{process.platform} ({process.arch}) &mdash; electron v{process.versions.electron}</small></h5>
      {commitUrl && hash && (
        <div className={'version-info'}>
          <small>
            <ExternalLink href={commitUrl}>
              <code>{hash}</code>
            </ExternalLink>
          </small>
        </div>
      )}
    </div>
  )
}
{'fraction_non_alphanumeric': 0.1797160243407708, 'fraction_numerical': 0.006490872210953347, 'mean_word_length': 2.9902912621359223, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 48, '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': '3811941', 'n_tokens_mistral': 798, 'n_tokens_neox': 782, 'n_words': 175}