/**
 * deploy-ios
 *
 * @author Cator Vee  hi@catorv.com
 */
const project = require('../../project')
const { exec } = require('../../utils/shell')

const deployIOS = async () => {
    const cwd = project.fs.rootDir()
    const gitCwd = project.fs.resolve('Release_ios/pushGit.sh')
    const cocoapodCwd = project.fs.resolve('Release_ios/push.sh')

    try {
        console.spin()
        await exec(`sh ${gitCwd}`, { cwd })
        console.ok('iOS Git发布版本成功')

        try {
            console.spin()
            await exec(`sh ${cocoapodCwd}`, { cwd })
            console.ok('iOS 发布组件成功')
        } catch (e) {
            console.fail('iOS 发布组件失败')
            console.fatal(e.message)
        }
    } catch (e) {
        console.fail('iOS Git发布版本失败')
        console.fatal(e.message)
    }
}

module.exports = deployIOS
