text: const fs = require('fs')
  const path = require('path')
  const render = require('json-templater/string')
  const endOfLine = require('os').EOL
  
  // 遍历所有packages，生成主要内容
  const components = fs.readdirSync(path.resolve(__dirname, '../../packages'))
  const navList = [`  {
      path: 'README',
      name: 'README',
      meta: {
        name: 'README'
      }
    },
    {
      path: 'CHANGELOG',
      name: 'CHANGELOG',
      meta: {
        name: '更新日志'
      }
    }`]
  const componentJson = []
  components.forEach(name => {
    navList.push(`  {
      path: '${name}',
      name: '${name}'
    }`)
    componentJson.push(`  "${name}": "./packages/${name}/index.js"`)
  })
  
  // 定义路径与文件模板
  const OUTPUT_PATH_NAV_LIST = path.join(__dirname, '../../src/nav-list.js')
  const NAV_LIST_TEMPLATE = `/**
   * Automatically generated by '/build/bin/prepare-files.js'
   * CopyRight (C) HDVON.
   * Created by weibin on 2019/04/22
   */
  export default [
  {{list}}
  ]
  `
  
  const OUTPUT_PATH_JSON = path.join(__dirname, '../../components.json')
  const COMPONENT_JSON_TEMPLATE = `{
  {{path}}
  }
  `
  
  fs.writeFileSync(OUTPUT_PATH_NAV_LIST, render(NAV_LIST_TEMPLATE, {
    list: navList.join(',' + endOfLine)
  }))
  fs.writeFileSync(OUTPUT_PATH_JSON, render(COMPONENT_JSON_TEMPLATE, {
    path: componentJson.join(',' + endOfLine)
  }))
  
  