text: /**
   * Created By shli on 2018/10/17
   */
  const Components = require('../../components.json')
  const fs = require('fs')
  const render = require('json-templater/string')
  const uppercamelcase = require('uppercamelcase')
  const path = require('path')
  const endOfLine = require('os').EOL
  
  const OUTPUT_PATH = path.join(__dirname, '../../src/index.js')
  const IMPORT_TEMPLATE = "import {{name}} from '../packages/{{package}}/index.js'"
  const INSTALL_COMPONENT_TEMPLATE = " {{name}}"
  const MAIN_TEMPALTE = ` /* Automatically generated by './build/bin/build-entry.js' */
    
    {{include}}
    import directives from './directives'
    
    const components = [
      {{install}}
    ]
    
    const install = (Vue, opts = {}) => {
      components.forEach(component => {
        Vue.component(component.name, component)
      })
      
      Vue.use(directives)
      Vue.prototype.$sst = {
        size: opts.size || '',
        zIndex: opts.zIndex || 2000
      } 
    }
    
     /* istanbul ignore if */
    if(typeof window !== 'undefined' && window.Vue) {
      install(window.install)
    }
    
    export default  {
      version: '{{version}}',
      install,
      {{list}}
    }
  
  `
  
  const ComponentNames = Object.keys(Components)
  const includeComponentTemplate = []
  const installTemplate = []
  const listTemplate = []
  
  ComponentNames.forEach(name => {
    let compoenentName = uppercamelcase(name)
  
    includeComponentTemplate.push(render(IMPORT_TEMPLATE, {
      name: compoenentName,
      package: name
    }))
  
    installTemplate.push(render(INSTALL_COMPONENT_TEMPLATE, {
      name: compoenentName,
      package: name
    }))
  
    listTemplate.push(`  ${compoenentName}`)
  })
  const template = render(MAIN_TEMPALTE,{
    include: includeComponentTemplate.join(endOfLine),
    install: installTemplate.join(',' + endOfLine),
    list: listTemplate.join("," + endOfLine),
    version: process.env.VERSION || require('../../package.json').version
  })
  
  fs.writeFileSync(OUTPUT_PATH, template)
  