-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscripts.dart
125 lines (103 loc) · 3.05 KB
/
scripts.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
import 'dart:io';
Future<void> main() async {
const List<List<String>> commands = [
// ['flutter', 'clean'],
// ['flutter', 'pub', 'get'],
// ['dart', 'analyze'],
// ['flutter', 'pub', 'run', 'flutter_launcher_icons'],
// ['flutter', 'build', 'apk', '--release', '--obfuscate', '--split-debug-info=./build/symbols/apk'],
// ['flutter', 'build', 'appbundle', '--release', '--obfuscate', '--split-debug-info=./build/symbols/appbundle'],
];
for (var command in commands) {
await runCommand(command);
}
const String outputPath = 'build/output';
final Directory outputDir = Directory(outputPath);
if (!await outputDir.exists()) {
await outputDir.create(recursive: true);
}
for (var file in outputDir.listSync()) {
await file.delete();
}
const Map<String, String> pathFinaly = {
'build/app/outputs/flutter-apk/app-release.apk': 'app-release',
'build/app/outputs/bundle/release/app-release.aab': 'appbundle-release',
'build/symbols/apk/*': 'apk-symbols',
'build/symbols/appbundle/*': 'appbundle-symbols',
// 'build/app/intermediates/merged_native_libs/release/out/lib': 'native-symbols',
'build/app/intermediates/merged_native_libs/release/mergeReleaseNativeLibs/out/lib/*': 'native-symbols',
};
for (var i = 0; i < pathFinaly.length; i++) {
await zipFiles(
pathFinaly.keys.toList()[i],
pathFinaly.values.toList()[i],
outputPath,
);
}
}
Future<void> runCommand(List<String> command) async {
try {
stderr.write('Running: ${command.join(' ')}');
final process = await Process.start(
command.first,
command.sublist(1),
runInShell: true,
);
process.stdout.listen((data) {
stderr.add(data);
});
process.stderr.listen((data) {
stderr.add(data);
});
final exitCode = await process.exitCode;
if (exitCode != 0) {
stderr.write('Command failed with exit code $exitCode\n');
} else {
stderr.write('Command completed successfully.\n');
}
} catch (e) {
stderr.write('Error executing command: $e\n');
}
}
Future<void> zipFiles(
String inputPath, String outputFile, String outputPath) async {
final zipPath = '$outputPath/$outputFile.zip';
try {
final command = [
'powershell',
'-Command',
'Compress-Archive',
'-Path',
inputPath,
'-DestinationPath',
zipPath,
'-CompressionLevel',
'NoCompression'
];
final process = await Process.start(
command.first,
command.sublist(1),
runInShell: true,
);
process.stdout.listen((data) {
stderr.add(data);
});
process.stderr.listen((data) {
stderr.add(data);
});
final exitCode = await process.exitCode;
if (exitCode == 0) {
stderr.write('Path successfully zipped: $zipPath\n');
} else {
stderr.write('Failed to zip Path with exit code $exitCode\n');
}
} catch (e) {
stderr.write('Error while zipping Path: $e\n');
}
}
/*
git remote -v
git remote set-url origin https://github.com/
git remote -v
git push origin main
*/