setup method

dynamic setup(
  1. bool updateUnity
)

Implementation

setup(bool updateUnity) {
  workspace = env('WORKSPACE');
  iosHookUrl = env('IOS_HOOK_URL');
  androidHookUrl = env('ANDROID_HOOK_URL');
  appStoreConnectApiKeyId = env('APP_STORE_CONNECT_API_KEY_ID');
  appStoreConnectApiIssuerId = env('APP_STORE_CONNECT_API_ISSUER_ID');
  appStoreConnectApiKeyFilepath = env('APP_STORE_CONNECT_API_KEY_FILEPATH');
  appIdentifier = env('APP_IDENTIFIER');
  appId = env('APP_ID');
  pgyerApiKey = env('PGYER_API_KEY');
  if (updateUnity) {
    final unityWorkspace = env('UNITY_WORKSPACE');
    final iosUnityPath = env('IOS_UNITY_PATH');
    final androidUnityPath = env('ANDROID_UNITY_PATH');
    final unityEnginePath = env('UNITY_ENGINE_PATH');
    unityEnvironment = UnityEnvironment(
      unityWorkspace: unityWorkspace,
      iosUnityPath: iosUnityPath,
      androidUnityPath: androidUnityPath,
      unityEnginePath: unityEnginePath,
    );
  }

  buildName = env('BUILD_NAME');
  dingdingIosHookUrl = env('DINGDING_IOS_HOOK_URL');
  dingdingAndroidHookUrl = env('DINGDING_ANDROID_HOOK_URL');
  branch = env('BRANCH').replaceFirst('origin/', '');

  appwriteEnvironment = AppwriteEnvironment(
    endPoint: env('APPWRITE_ENDPOINT'),
    projectId: env('APPWRITE_PROJECT_ID'),
    apiKey: env('APPWRITE_API_KEY'),
    databaseId: env('APPWRITE_DATABASE_ID'),
    collectionId: env('APPWRITE_COLLECTION_ID'),
  );

  umengPushEnvironment = UmengPushEnvironment(
    umengAppKey: env('UMENG_APPKEY'),
    umengMessageSecret: env('UMENG_MESSAGE_SECRET'),
    umengChannel: env('UMENG_CHANNEL'),
  );
  final customBuildNumber = JSON(env('BUILD_NUMBER', false)).intValue;

  int formatterBuildNumber(String buildNumber) {
    if (buildNumber.length <= 10) return JSON(buildNumber).intValue;
    return JSON(buildNumber.substring(0, 10)).intValue;
  }

  if (customBuildNumber > 0) {
    buildNumber = formatterBuildNumber(customBuildNumber.toString());
  } else {
    buildNumber = formatterBuildNumber(
        DateTime.now().millisecondsSinceEpoch.toString());
  }
  forceBuild = env('FORCE_BUILD') == 'true';
  unityBranchName = env('UNITY_BRANCH_NAME');
  upload = env('UPLOAD') == 'true';
  sendLog = env('SEND_LOG') == 'true';

  flutterLastCommitHash = env('FLUTTER_LAST_COMMIT_HASH', false);
  unityLastCommitHash = env('UNITY_LAST_COMMIT_HASH', false);

  androidChannel = env('androidChannel');

  sentryEnvironment = SentryEnvironment(
    project: env('SENTRY_PROJECT'),
    org: env('SENTRY_ORG'),
    authToken: env('SENTRY_AUTH_TOKEN'),
    url: env('SENTRY_URL'),
    release: '$buildName($buildNumber)',
    dist: '$buildNumber',
  );
}