|
| 1 | +import process from 'node:process' |
1 | 2 | import { yellow } from 'kolorist'
|
2 | 3 | import type { Browser, Page } from 'puppeteer'
|
3 | 4 | import puppeteer from 'puppeteer'
|
@@ -56,13 +57,20 @@ export async function jumpToVersions() {
|
56 | 57 | }
|
57 | 58 | spinner.start('正在跳转到版本管理页面...')
|
58 | 59 | await versionManage.click()
|
| 60 | + |
59 | 61 | const submitReviewBtn = await page.waitForSelector('.mod_default_box.code_version_dev .weui-desktop-btn.weui-desktop-btn_primary')
|
60 | 62 | if (!submitReviewBtn) {
|
61 | 63 | spinner.fail('未找到提交审核按钮')
|
62 | 64 | throw new Error('未找到提交审核按钮')
|
63 | 65 | }
|
| 66 | + // 判断是否有提交审核中的版本 |
| 67 | + const testVersion = await page.$('.mod_default_bd.default_box.test_version') |
| 68 | + if (testVersion && !await testVersion.evaluate(el => el.textContent?.includes('你暂无提交审核的版本或者版本已发布上线'))) { |
| 69 | + spinner.warn('存在提交审核中的版本') |
| 70 | + throw new Error('存在提交审核中的版本') |
| 71 | + } |
64 | 72 | await submitReviewBtn.click()
|
65 |
| - await sleep(1000) |
| 73 | + await sleep(1200) // 可能会报错 |
66 | 74 | }
|
67 | 75 |
|
68 | 76 | /**
|
@@ -135,13 +143,23 @@ export async function toRelease() {
|
135 | 143 | }
|
136 | 144 |
|
137 | 145 | export default async function weixinRobot(action: ACTION) {
|
138 |
| - await getLoginScanCode() |
139 |
| - await jumpToVersions() |
140 |
| - if (action === ACTION.REVIEW) { |
141 |
| - await jumpToConfirmPage() |
142 |
| - await toSubmitAudit() |
| 146 | + try { |
| 147 | + await getLoginScanCode() |
| 148 | + await jumpToVersions() |
| 149 | + if (action === ACTION.REVIEW) { |
| 150 | + await jumpToConfirmPage() |
| 151 | + await toSubmitAudit() |
| 152 | + } |
| 153 | + else { |
| 154 | + await toRelease() |
| 155 | + } |
| 156 | + process.exit(0) |
143 | 157 | }
|
144 |
| - else { |
145 |
| - await toRelease() |
| 158 | + catch (err) { |
| 159 | + if (process.env.NODE_ENV === 'development') { |
| 160 | + console.error(err) |
| 161 | + return |
| 162 | + } |
| 163 | + process.exit(1) |
146 | 164 | }
|
147 | 165 | }
|
0 commit comments