text: /* eslint-disable @typescript-eslint/no-var-requires */
  
  const fs = require('fs')
  const fsExtra = require('fs-extra')
  const path = require('path')
  const yargs = require('yargs/yargs')
  const { hideBin } = require('yargs/helpers')
  
  function resolvePackageName(type, name) {
    return `@vue-storage-hooks/${type}-${name}`
  }
  
  function resolveBaseDir(type, name) {
    return `packages/${type}-${name}`
  }
  
  function genReadme(type, name) {
    return `# ${resolvePackageName(type, name)} \n > TODO:...`
  }
  
  function genIndex() {
    return 'export default {}'
  }
  
  function genPackageJson(type, name) {
    return JSON.stringify(
      {
        name: resolvePackageName(type, name),
        version: '0.0.0',
        description: '',
        main: 'dist/index.cjs.js',
        module: 'dist/index.es.js',
        browser: 'dist/index.umd.js',
        types: 'dist/index.d.ts',
        files: ['dist'],
        private: true,
        keywords: [],
        author: 'Kaz <objectkaz@163.com>',
        license: 'MIT',
        devDependencies: {},
        dependencies: {},
      },
      '',
      '  '
    )
  }
  
  function main() {
    const argv = yargs(hideBin(process.argv)).argv
    const type = argv._[0]
    const name = argv._[1]
  
    if (name.trim() === '') {
      throw new Error('`name` is required.')
    }
  
    const baseDir = path.resolve(__dirname, '../', resolveBaseDir(type, name))
    if (fs.existsSync(baseDir)) {
      throw new Error(resolvePackageName(type, name) + ' is already exists.')
    }
  
    const fileTrees = {
      'package.json': genPackageJson(type, name),
      'README.md': genReadme(type, name),
      'src/index.ts': genIndex(),
    }
  
    for (const fileName in fileTrees) {
      const fullPath = path.resolve(baseDir, fileName)
      fsExtra.ensureFileSync(fullPath)
      fs.writeFileSync(fullPath, fileTrees[fileName], {
        recursive: true,
      })
    }
  }
  
  main()
  