{"size": 1194, "ext": "js", "max_stars_repo_path": "ci/update_appinfo.js", "max_stars_repo_name": "BASChain/baschain-portal", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ci/update_appinfo.js", "max_issues_repo_name": "BASChain/baschain-portal", "max_issues_repo_issues_event_min_datetime": "2020-07-11T01:22:14.000Z", "max_issues_repo_issues_event_max_datetime": "2020-07-21T00:14:15.000Z", "max_forks_repo_path": "ci/update_appinfo.js", "max_forks_repo_name": "BASChain/baschain-portal", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 3, "max_forks_count": null, "avg_line_length": 21.3214285714, "max_line_length": 80, "alphanum_fraction": 0.6273031826}
const DateFormat = require('fast-date-format'),
  fs = require('fs-extra'),
  path = require('path'),
  pkgJson = require('../package.json');

const r = (...p) => path.resolve(__dirname, '../', ...p)

const infoPath = 'src/bascore/info.json';

const infoFile = r(infoPath);

const dateFormat = new DateFormat('YYMMDD_HHmm')

updateAppInfo(infoFile)

async function updateAppInfo(infoFilePath){

  console.log(process.env.PRE_REL)
  const PRE_REL = process.env.PRE_REL || false

  fs.ensureFileSync(infoFilePath)

  const ver = pkgJson.version||'2.1.0';
  const name = pkgJson.name || 'bas-exchange'
  const author = pkgJson.author || "bas-team"
  const tagts = dateFormat.format(new Date())
  const buildTag = Boolean(PRE_REL) ? `Pre-${ver}_${tagts}` : `${ver}_${tagts}`;


  let info = {
    name:"bas-portal"
  }
  // try{
  //    info = fs.readJsonSync(infoFilePath);
  // }catch(ex){
  //   console.log(ex)
  // }

  const infoJson = Object.assign({},info,{
    "name":name,
    "author":author,
    "version":ver,
    "buildTag": buildTag,
    "description":"BAS Chain Exchange"
  })

  fs.outputJsonSync(
    infoFilePath,
    infoJson,
    {
      spaces: 2,
      EOL: '\n'
    }
  )
}
