1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- import 'dart:async';
- import 'dart:convert';
- import 'dart:io';
- import 'dart:math';
- import 'package:process_run/shell.dart';
- import 'package:upload/upload.dart' as upload;
- /// fvm dart compile exe -o upload.exe bin\upload.dart
- Future<void> main(List<String> arguments) async {
- if (!arguments.contains("--nobuild")) {
- final stdinController = StreamController<List<int>>.broadcast();
- final stdoutController = StreamController<List<int>>.broadcast();
- final stderrController = StreamController<List<int>>.broadcast();
- stdoutController.stream.listen((event) {
- // print(utf8.decode(event));
- });
- int errCount = 0;
- stderrController.stream.listen((event) {
- // print(utf8.decode(event));
- errCount++;
- stdout.write("\r打包过程出现警告:$errCount");
- });
- var shell = Shell(
- stdout: stdoutController.sink,
- stdin: stdinController.stream,
- stderr: stderrController.sink,
- );
- try {
- stdout.write("\n准备并开始打包APK文件\n");
- await shell.run("flutter clean");
- await shell.run("flutter pub get");
- await shell.run("flutter build apk");
- stdout.write("\nAPK文件打包成功🎈🎈\n");
- stdout.write("\n准备上传APK至蒲公英");
- } catch (e) {
- stdout.write("\n打包过程中发生了错误");
- exit(1);
- }
- }
- upload.getToken();
- }
|