import { switchVersion, loadModule }  from './utils.js'
const Vue = loadModule('vue')
import fs from 'node:fs'
import path from 'node:path'

function postinstall() {
  if (!Vue || typeof Vue.version !== 'string') {
    console.warn(
      '[@qdll/business] Vue is not found. Please run "npm install vue" to install.'
    )
  } else if (fs.existsSync(path.resolve(__dirname, '../packages/main.ts'))) {
    return
  } else if (Vue.version.startsWith('2.')) {
    switchVersion(2)
  } else if (Vue.version.startsWith('3.')) {
    switchVersion(3)
  } else {
    console.warn(
      `[@qdll/business] Vue version v${Vue.version} is not suppported.`
    )
  }
}
postinstall()
