run method
Executes the initialization command to set up the project.
This method performs the following tasks:
- Creates necessary distribution directories
- Validates required development tools
- Sets up platform-specific configurations
- Generates initial configuration files
- Downloads metadata for Android publishing
The initialization process includes:
- Directory structure creation for Android and iOS (macOS only)
- Tool validation for Flutter, Firebase, Git, Fastlane, and compression tools
- Fastlane configuration setup
- Google Play Console metadata download
Implementation
@override
Future? run() async {
final initialized = <String, bool>{};
String configFilePath =
globalResults?['config'] as String? ?? 'distribution.yaml';
_logWelcome();
_checkPubspecFile();
await _createDirectory(
path.join("distribution", "android", "output"),
initialized,
"android_directory",
);
if (Platform.isMacOS) {
await _createDirectory(
path.join("distribution", "ios", "output"),
initialized,
"ios_directory",
);
}
if (!(argResults!['skip-tools'] as bool)) {
await _checkTool(
"flutter",
"Flutter",
initialized,
args: ['--version'],
).catchError((_) => -1);
await _checkTool(
"firebase",
"Firebase",
initialized,
).catchError((_) => -1);
await _checkTool(
"git",
"Git",
initialized,
args: ['--version'],
).catchError((_) => -1);
await CompressFiles.checkTools().then((value) {
if (!value) {
logger.logWarning(
"Compress tool is not installed, some features may not work as expected.",
);
} else {
logger.logSuccess('Compress tool is installed.');
initialized["compress_tool"] = true;
}
});
await _checkTool(
"fastlane",
"Fastlane",
initialized,
args: ['actions'],
).catchError((_) => -1).then((value) async {
if (value == 0) {
await _validateFastlaneJson(initialized).then((value) async {
if (value == 0) return await _downloadAndroidMetaData();
});
} else {
if (Platform.isWindows) {
logger.logWarning(
'Tips : In Windows, you can install fastlane using "gem install fastlane", make sure you have Ruby installed.',
);
} else if (Platform.isLinux) {
logger.logWarning(
'Tips : In Linux, you can install fastlane using "sudo gem install fastlane", make sure you have Ruby installed.',
);
} else if (Platform.isMacOS) {
logger.logWarning(
'Tips : In MacOS, you can install fastlane using "sudo gem install fastlane", make sure you have Ruby installed.',
);
}
initialized["fastlane_json"] = false;
}
});
if (Platform.isMacOS) {
await _checkTool(
"xcrun",
"XCRun",
initialized,
args: ["altool", "-h"],
).catchError((_) => -1);
}
}
final yaml = File(configFilePath);
if (!yaml.existsSync()) {
yaml.writeAsString(yamlEncode(structures), flush: true);
}
return;
}