|
1 | 1 | import 'dart:io'; |
2 | 2 |
|
3 | 3 | import 'package:process_run/process_run.dart'; |
4 | | -import 'package:process_run/shell.dart'; |
5 | 4 | import 'package:process_run/which.dart'; |
6 | 5 |
|
7 | | -import 'tools/function.dart'; |
| 6 | +import 'src/install/install.dart'; |
| 7 | +import 'src/tool.dart'; |
8 | 8 |
|
9 | 9 | void main(List<String> args) async { |
10 | 10 | try { |
11 | | - environment.addAll(Platform.environment); |
12 | | - |
13 | 11 | parseArgs(args); |
14 | 12 |
|
15 | | - await run('chcp 437 > nul', []); |
| 13 | + showText(' START '); |
16 | 14 |
|
17 | | - var powerShell = await checkPowerShell(); |
18 | | - if (!powerShell && Platform.isWindows) { |
19 | | - stdout.writeln( |
20 | | - 'Can not find PowerShell 5.0 or newer. Please install first to continue.\n' |
21 | | - 'https://www.microsoft.com/en-us/download/confirmation.aspx?id=54616', |
22 | | - ); |
23 | | - stdin.readLineSync(); |
24 | | - exit(0); |
25 | | - } |
| 15 | + await logNewRun(); |
26 | 16 |
|
27 | | - showText(' START '); |
| 17 | + if (Platform.isWindows) { |
| 18 | + await run('chcp 437 > nul', []); |
| 19 | + var powerShell = await checkPowerShell(); |
| 20 | + if (!powerShell) { |
| 21 | + stdout.writeln( |
| 22 | + 'Can not find PowerShell 5.0 or newer. Please install first to continue.\n' |
| 23 | + 'https://www.microsoft.com/en-us/download/confirmation.aspx?id=54616', |
| 24 | + ); |
| 25 | + stdin.readLineSync(); |
| 26 | + exit(0); |
| 27 | + } |
| 28 | + } |
28 | 29 |
|
29 | 30 | await checkLatestVersion(); |
30 | 31 |
|
31 | | - var operatingSystem = Platform.operatingSystem; |
32 | 32 | var flutterPath = await which('flutter'); |
33 | | - var dartPath = await which('dart'); |
34 | | - var javaPath = await which('java'); |
35 | | - var androidPath = await which('sdkmanager'); |
36 | | - var vscodePath = await which('code'); |
37 | | - var gitPath = await which('git'); |
38 | | - |
39 | 33 | if (flutterPath == null) { |
40 | | - var winDisk = Platform.isWindows ? userHomePath.split('\\')[0] : ''; |
41 | | - installationPath = Platform.isWindows ? '$winDisk\\' : '~/'; |
42 | | - installationPath += 'Development'; |
43 | | - stdout.writeln('\nFlutter will be installed in $installationPath\n'); |
44 | | - var exists = await Directory(installationPath).exists(); |
45 | | - if (!exists) await Directory(installationPath).create(recursive: true); |
46 | | - var studio = await checkAndroidStudio(); |
47 | | - var later = false; |
48 | | - if (studio == null) { |
49 | | - later = await promptConfirm( |
50 | | - 'Android Studio is not installed. Do you want to install the full package (Flutter without Android Studio)?', |
51 | | - ); |
52 | | - stdout.write('\n'); |
53 | | - } |
54 | | - if (later) { |
55 | | - stdout.writeln( |
56 | | - 'This process might require downloading ~1.5 GB for the first time\n', |
57 | | - ); |
58 | | - await withOutAndroidStudio( |
59 | | - javaPath: javaPath, |
60 | | - androidPath: androidPath, |
61 | | - operatingSystem: operatingSystem, |
62 | | - ); |
63 | | - } else { |
64 | | - stdout.writeln( |
65 | | - 'This process might require downloading ~900 MB for the first time\n', |
66 | | - ); |
67 | | - } |
68 | | - await installFlutter( |
69 | | - operatingSystem: operatingSystem, |
70 | | - ); |
71 | | - if (studio != null) { |
72 | | - await androidStudioInstallExtensions( |
73 | | - studio: studio, |
74 | | - ); |
75 | | - } |
76 | | - if (vscodePath != null) { |
77 | | - await vscodeInstallExtensions(); |
78 | | - } |
79 | | - if (gitPath == null) { |
80 | | - await stdout.writeln( |
81 | | - '[GIT] (Optional) You might need git for versioning, install from https://git-scm.com/downloads.', |
82 | | - ); |
83 | | - } |
84 | | - stdout.write( |
85 | | - '\nPlease exit this window and open new Terminal or Command Prompt and run `flutter doctor -v`.\n', |
86 | | - ); |
| 34 | + await installFullPackage(); |
87 | 35 | } else { |
| 36 | + var dartPath = await which('dart'); |
88 | 37 | if (dartPath == null) { |
89 | 38 | var path = Directory(flutterPath).parent.path; |
90 | 39 | await setPathEnvironment( |
91 | 40 | title: 'DART', |
92 | | - newPath: '$path\\cache\\dart-sdk\\bin', |
| 41 | + newPath: '$path/cache/dart-sdk/bin', |
93 | 42 | ); |
94 | 43 | } |
95 | | - await run( |
96 | | - 'flutter', |
97 | | - ['upgrade'], |
98 | | - verbose: true, |
99 | | - ); |
| 44 | + await run('flutter', ['upgrade'], verbose: true); |
100 | 45 | } |
101 | 46 | showText(' FINISH '); |
102 | 47 | stdin.readLineSync(); |
103 | 48 | exit(0); |
104 | 49 | } catch (e, s) { |
105 | 50 | await errorLog(e, s); |
| 51 | + stdin.readLineSync(); |
| 52 | + exit(2); |
106 | 53 | } |
107 | 54 | } |
0 commit comments