<commit_before>fs = require 'fs'
request = require 'request'
Q = require 'q'
_ = require 'underscore'

uuid = require 'uuid'

fsIsDirectorySync = (path) ->
  try
    stat = fs.statSync(path)
    stat.isDirectory()
  catch
    false

module.exports =
class BuildManager

  activate: ->
    atom.workspaceView.command "atom-chameleon:publish-application", => @cmdPublishApplication()
    @server = atom.config.get('atom-butterfly.puzzleServerAddress')

    atom.workspaceView.command "atom-chameleon:build-list", => @cmdBuildList()

  deactivate: ->

  cmdBuildList: ->
    new (require './build-list-view')().attach()

  cmdPublishApplication: ->

    PublishAppView = require './publish-wizard-view'
    buildWizard = new PublishAppView().attach()
    buildStateView = new (require './build-state-view')()

    # 这样就可以可以不仅在windows还是mac都可以获取到.atom路径
    decs = "#{atom.getConfigDirPath()}/atom-butterfly"
    zipFile = "#{uuid.v1()}.zip"
    unless fsIsDirectorySync(decs)
      console.log "新建文件夹：#{decs}"
      fs.mkdirSync decs
    removeZipPath = "#{decs}/#{zipFile}"

    buildWizard.finishPromise()
    .then (result) ->
      console.log "开始压缩..."
      buildWizard.destroy()
      buildStateView.attach()

      require('../../utils/zip')(atom.project.path,removeZipPath).then (zip_path) ->_.extend(result, asset: zip_path)
    .then (result) ->
      console.log "结束压缩...#{result}"
      Q.Promise (resolve, reject, notify) ->
        buildStateView.socket.on "resSocketId",(sid)-><commit_msg>fix a bug<commit_after>fs = require 'fs'
request = require 'request'
Q = require 'q'
_ = require 'underscore'

uuid = require 'uuid'

os = require 'os'

fsIsDirectorySync = (path) ->
  try
    stat = fs.statSync(path)
    stat.isDirectory()
  catch
    false

module.exports =
class BuildManager

  activate: ->
    atom.workspaceView.command "atom-chameleon:publish-application", => @cmdPublishApplication()
    @server = atom.config.get('atom-butterfly.puzzleServerAddress')

    atom.workspaceView.command "atom-chameleon:build-list", => @cmdBuildList()

  deactivate: ->

  cmdBuildList: ->
    new (require './build-list-view')().attach()

  cmdPublishApplication: ->

    PublishAppView = require './publish-wizard-view'
    buildWizard = new PublishAppView().attach()
    buildStateView = new (require './build-state-view')()

    # 这样就可以可以不仅在windows还是mac都可以获取到.atom路径
    decs = "#{os.tmpdir()}/atom-butterfly"
    zipFile = "#{uuid.v1()}.zip"
    unless fsIsDirectorySync(decs)
      console.log "新建文件夹：#{decs}"
      fs.mkdirSync decs
    removeZipPath = "#{decs}/#{zipFile}"

    buildWizard.finishPromise()
    .then (result) ->
      console.log "开始压缩..."
      buildWizard.destroy()
      buildStateView.attach()

      require('../../utils/zip')(atom.project.path,removeZipPath).then (zip_path) ->_.extend(result, asset: zip_path)
    .then (result) ->
      console.log "结束压缩...#{result}"
      Q.Promise (resolve, reject, notify) ->
        buildStateView.socket.on "resSocketId",(sid)->
{'fraction_non_alphanumeric': 0.15806988352745424, 'fraction_numerical': 0.0006655574043261231, 'mean_word_length': 3.3947368421052633, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 27, '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': '6862880', 'n_tokens_mistral': 1041, 'n_tokens_neox': 1038, 'n_words': 174}