-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(config-generation): Added hooks
- Loading branch information
Showing
2 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:mason/mason.dart'; | ||
|
||
const String androidBuild = 'build.gradle'; | ||
const String flutterBuild = 'lib'; | ||
|
||
void run(HookContext context) async { | ||
final logger = context.logger; | ||
|
||
await _runPub(logger); | ||
await _runDartFix(logger); | ||
} | ||
|
||
Future<void> _runPub(Logger logger) async { | ||
final progress = logger.progress('Running dart pub get'); | ||
final result = await Process.run('dart', ['pub', 'get']); | ||
return result.exitCode == 0 | ||
? progress.complete('Pub get run successfully') | ||
: progress.fail('Pub get failed. Please handle dependency manually.'); | ||
} | ||
|
||
Future<void> _runDartFix(Logger logger) async { | ||
final progress = logger.progress('Running dart fix --apply'); | ||
final result = await Process.run('dart', ['fix', '--apply']); | ||
return result.exitCode == 0 | ||
? progress.complete('Fix applied.') | ||
: progress.fail('Fix couldn\'t be applied'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import 'package:mason/mason.dart'; | ||
|
||
const defaultAppPackage = 'com.example.app'; | ||
|
||
void run(HookContext context) { | ||
final isAndroid = context.vars['android']; | ||
final isIOS = context.vars['ios']; | ||
|
||
if (isAndroid) parseAndroidData(context); | ||
|
||
if (isIOS) parseCupertinoData(context); | ||
} | ||
|
||
void parseCupertinoData(HookContext context) { | ||
final logger = context.logger; | ||
|
||
final bundleId = | ||
logger.prompt("What's app bundle ID?", defaultValue: defaultAppPackage); | ||
final teamId = | ||
logger.prompt("What's app team ID?", defaultValue: defaultAppPackage); | ||
|
||
context.vars.addAll({ | ||
'bundle_id': bundleId, | ||
'team_id': teamId, | ||
}); | ||
} | ||
|
||
void parseAndroidData(HookContext context) { | ||
final logger = context.logger; | ||
|
||
final packageName = logger.prompt("What's app package name?", | ||
defaultValue: defaultAppPackage); | ||
final signingHash = logger.prompt("What's app singing hash?"); | ||
|
||
context.vars.addAll({ | ||
'package_name': packageName, | ||
'signing_hash': signingHash, | ||
}); | ||
} |