|
1 | 1 | import path from 'node:path'; |
2 | | -import { getRNVersion, translateOptions, checkXcodeScript } from './utils'; |
| 2 | +import { getRNVersion, translateOptions, checkXcodeScript, checkAndroidStudioScript } from './utils'; |
3 | 3 | import * as fs from 'fs-extra'; |
4 | 4 | import { ZipFile } from 'yazl'; |
5 | 5 | import { open as openZipFile } from 'yauzl'; |
@@ -722,12 +722,20 @@ export const commands = { |
722 | 722 |
|
723 | 723 | if (platform === 'ios') { |
724 | 724 | hasSentryScript = checkXcodeScript(); |
725 | | - } else { |
726 | | - hasSentryScript = false; |
| 725 | + } else if (platform === 'android') { |
| 726 | + hasSentryScript = checkAndroidStudioScript(); |
727 | 727 | } |
728 | 728 |
|
729 | 729 | if (hasSentryScript && platform === 'ios') { |
730 | | - throw new Error('请先执行xcodebuild命令,然后再执行pushy bundleAfterXcodeBuild'); |
| 730 | + throw new Error( |
| 731 | + '请先执行xcode build命令,然后再执行pushy bundleAfterXcodeBuild', |
| 732 | + ); |
| 733 | + } |
| 734 | + |
| 735 | + if (hasSentryScript && platform === 'android') { |
| 736 | + throw new Error( |
| 737 | + '请先执行android build命令,然后再执行pushy bundleAfterAndroidStudioBuild', |
| 738 | + ); |
731 | 739 | } |
732 | 740 |
|
733 | 741 | const { bundleName, entryFile, intermediaDir, output, dev, sourcemap } = |
@@ -790,6 +798,26 @@ export const commands = { |
790 | 798 | } |
791 | 799 | }, |
792 | 800 |
|
| 801 | + bundleAfterAndroidStudioBuild: async function ({ options }) { |
| 802 | + const { intermediaDir, output } = translateOptions({ |
| 803 | + ...options, |
| 804 | + platform: 'android', |
| 805 | + }); |
| 806 | + |
| 807 | + const realOutput = output.replace(/\$\{time\}/g, `${Date.now()}`); |
| 808 | + await pack(path.resolve(intermediaDir), realOutput); |
| 809 | + |
| 810 | + const v = await question('是否现在上传此热更包?(Y/N)'); |
| 811 | + if (v.toLowerCase() === 'y') { |
| 812 | + await this.publish({ |
| 813 | + args: [realOutput], |
| 814 | + options: { |
| 815 | + platform: 'android', |
| 816 | + }, |
| 817 | + }); |
| 818 | + } |
| 819 | + }, |
| 820 | + |
793 | 821 | async diff({ args, options }) { |
794 | 822 | const { origin, next, realOutput } = diffArgsCheck(args, options, 'diff'); |
795 | 823 |
|
|
0 commit comments