Skip to content

Commit

Permalink
Release 2.1.2
Browse files Browse the repository at this point in the history
Fixes #69 and #36: define a custom set of variables for both Android and iOS for each flavor
  • Loading branch information
AngeloAvv authored Jan 2, 2022
1 parent 2bec7a7 commit c84e4e4
Show file tree
Hide file tree
Showing 31 changed files with 522 additions and 62 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## 2.1.2
* Added resValues directive to declare resValues in build.gradle for each flavor (Android)
* Added variables directive to declare variables in xcconfig for each flavor (iOS)
* Bumped dependencies

## 2.1.1
* Added icon directive to generate icons for your flavors
* Added icon directive to generate icons for each flavor
* Bumped dependencies

## 2.1.0
Expand Down
74 changes: 72 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ A flutter utility to easily create flavors in your flutter application
![Dart CI](https://github.com/AngeloAvv/flutter_flavorizr/workflows/Dart%20CI/badge.svg)
[![Star on GitHub](https://img.shields.io/github/stars/AngeloAvv/flutter_flavorizr.svg?style=flat&logo=github&colorB=deeppink&label=stars)](https://github.com/AngeloAvv/flutter_flavorizr)
[![License: MIT](https://img.shields.io/badge/license-MIT-purple.svg)](https://opensource.org/licenses/MIT)

If you want to support this project,

[!["Buy Me A Coffee"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/angeloavv)

## Getting Started
Expand Down Expand Up @@ -41,7 +44,7 @@ in your [pubspec.yaml](https://dart.dev/tools/pub/pubspec):

```
dev_dependencies:
flutter_flavorizr: ^2.1.1
flutter_flavorizr: ^2.1.2
```

You can install packages from the command line:
Expand Down Expand Up @@ -101,7 +104,7 @@ flavorizr:
| app | Object | | true | An object describing the general capabilities of an app |
| flavors | Array | | true | An array of items. Each of them describes a flavor configuration |
| [instructions](#available-instructions) | Array | | false | An array of instructions to customize the flavorizr process |
| assetsUrl | String | https://github.com/AngeloAvv/flutter_flavorizr/releases/download/v2.1.1/assets.zip | false | A string containing the URL of the zip assets file. The default points to the current release |
| assetsUrl | String | https://github.com/AngeloAvv/flutter_flavorizr/releases/download/v2.1.2/assets.zip | false | A string containing the URL of the zip assets file. The default points to the current release |
| ide | String | | false | The IDE in which the app is being developed. Currently only `vscode` or `idea` |

##### <a href="#available-instructions">Available instructions</a>
Expand Down Expand Up @@ -155,6 +158,7 @@ flavorizr:
|:--------------------|:-------|:--------|:---------|:-------------------------------------------------------------------|
| applicationId | String | | true | The applicationId of the Android App |
| firebase | Object | | false | An object which contains a Firebase configuration |
| resValues | Array | | false | An array which contains a set of resValues configurations |
| generateDummyAssets | bool | true | false | True if you want to generate dummy assets (icon set, strings, etc) |
| icon | String | | false | The icon path for this android flavor |

Expand All @@ -165,6 +169,7 @@ flavorizr:
| bundleId | String | | true | The bundleId of the iOS App |
| buildSettings | Dictionary | {} | false | A flavor-specific XCode build configuration dictionary [XCode Build Settings](https://xcodebuildsettings.com) |
| firebase | Object | | false | An object which contains a Firebase configuration |
| variables | Array | | false | An array which contains a set of variables configurations |
| generateDummyAssets | bool | true | false | True if you want to generate dummy assets (xcassets, etc) |
| icon | String | | false | The icon path for this iOS flavor |

Expand All @@ -174,6 +179,71 @@ flavorizr:
|:-------|:-------|:--------|:---------|:--------------------------------------------------------------------------------------------------------------------|
| config | String | | false | The path to the Firebase configuration file (google-services.json for Android and GoogleService-Info.plist for iOS) |

#### resValue (for Android)

| key | type | default | required | description |
|:------|:-------|:--------|:---------|:-----------------------------------------------------------------------------------------------------------------------------------------|
| type | String | | true | The type of the [resValue](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/variant/ResValue) variable |
| value | String | | true | The value of the resValue variable |

```
flavorizr:
app:
android:
flavorDimensions: "flavor-type"
ios:
flavors:
apple:
app:
name: "Apple App"
android:
applicationId: "com.example.apple"
resValues:
variable_one:
type: "string"
value: "example variable one"
variable_two:
type: "string"
value: "example variable two"
ios:
bundleId: "com.example.apple"
```

#### variable (for iOS)

| key | type | default | required | description |
|:-------|:-------|:--------|:---------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| target | String | | false | The type of the [target](https://medium.com/geekculture/what-are-debug-and-release-modes-in-xcode-how-to-check-app-is-running-in-debug-mode-8dadad6a3428) (Debug, Release, Profile). Do not specify a target if you want to apply it to all of them. |
| value | String | | true | The value of the variable |

```
flavorizr:
app:
android:
flavorDimensions: "flavor-type"
ios:
flavors:
apple:
app:
name: "Apple App"
android:
applicationId: "com.example.apple"
ios:
bundleId: "com.example.apple"
variables:
VARIABLE_ONE:
value: "variable1"
VARIABLE_TWO:
target: "Debug"
value: "variable2"
```

## Usage

When you finished defining the flavorizr configuration, you can proceed by running the script with:
Expand Down
6 changes: 3 additions & 3 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ packages:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
version: "2.1.0"
characters:
dependency: transitive
description:
Expand Down Expand Up @@ -96,7 +96,7 @@ packages:
path: ".."
relative: true
source: path
version: "2.1.1"
version: "2.1.2"
flutter_test:
dependency: "direct dev"
description: flutter
Expand Down Expand Up @@ -183,7 +183,7 @@ packages:
name: stream_channel
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
version: "2.1.0"
string_scanner:
dependency: transitive
description:
Expand Down
25 changes: 25 additions & 0 deletions lib/parser/models/enums.dart
Original file line number Diff line number Diff line change
@@ -1 +1,26 @@
/*
* Copyright (c) 2022 MyLittleSuite
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/

enum IDE { idea, vscode }
2 changes: 1 addition & 1 deletion lib/parser/models/flavorizr.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Flavorizr {

@JsonKey(
defaultValue:
'https://github.com/AngeloAvv/flutter_flavorizr/releases/download/v2.1.1/assets.zip')
'https://github.com/AngeloAvv/flutter_flavorizr/releases/download/v2.1.2/assets.zip')
final String assetsUrl;

@JsonKey()
Expand Down
2 changes: 1 addition & 1 deletion lib/parser/models/flavorizr.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions lib/parser/models/flavors/android.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* OTHER DEALINGS IN THE SOFTWARE.
*/

import 'package:flutter_flavorizr/parser/models/flavors/android/res_value.dart';
import 'package:flutter_flavorizr/parser/models/flavors/commons/os.dart';
import 'package:flutter_flavorizr/parser/models/flavors/google/firebase/firebase.dart';
import 'package:json_annotation/json_annotation.dart';
Expand All @@ -34,8 +35,12 @@ class Android extends OS {
@JsonKey(required: true, disallowNullValue: true)
final String applicationId;

@JsonKey(disallowNullValue: true, defaultValue: {})
final Map<String, ResValue> resValues;

Android({
required this.applicationId,
this.resValues = const {},
bool generateDummyAssets = true,
Firebase? firebase,
String? icon,
Expand Down
12 changes: 11 additions & 1 deletion lib/parser/models/flavors/android.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions lib/parser/models/flavors/android/res_value.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import 'package:json_annotation/json_annotation.dart';

part 'res_value.g.dart';

@JsonSerializable(anyMap: true, createToJson: false)
class ResValue {
@JsonKey(required: true, disallowNullValue: true)
final String type;

@JsonKey(required: true, disallowNullValue: true)
final String value;

const ResValue({
required this.type,
required this.value,
});

factory ResValue.fromJson(Map<String, dynamic> json) =>
_$ResValueFromJson(json);
}
19 changes: 19 additions & 0 deletions lib/parser/models/flavors/android/res_value.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions lib/parser/models/flavors/ios.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import 'package:flutter_flavorizr/parser/mixins/build_settings_mixin.dart';
import 'package:flutter_flavorizr/parser/models/flavors/commons/os.dart';
import 'package:flutter_flavorizr/parser/models/flavors/google/firebase/firebase.dart';
import 'package:flutter_flavorizr/parser/models/flavors/ios/variable.dart';
import 'package:json_annotation/json_annotation.dart';

part 'ios.g.dart';
Expand All @@ -35,8 +36,12 @@ class IOS extends OS with BuildSettingsMixin {
@JsonKey(required: true, disallowNullValue: true)
final String bundleId;

@JsonKey(disallowNullValue: true, defaultValue: {})
final Map<String, Variable> variables;

IOS({
required this.bundleId,
this.variables = const {},
Map<String, dynamic> buildSettings = const {},
bool generateDummyAssets = true,
Firebase? firebase,
Expand Down
7 changes: 6 additions & 1 deletion lib/parser/models/flavors/ios.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions lib/parser/models/flavors/ios/enums.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (c) 2022 MyLittleSuite
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/

enum Target { Debug, Profile, Release }
46 changes: 46 additions & 0 deletions lib/parser/models/flavors/ios/variable.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright (c) 2022 MyLittleSuite
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/

import 'package:flutter_flavorizr/parser/models/flavors/ios/enums.dart';
import 'package:json_annotation/json_annotation.dart';

part 'variable.g.dart';

@JsonSerializable(anyMap: true, createToJson: false)
class Variable {
@JsonKey(disallowNullValue: true)
final Target? target;

@JsonKey(required: true, disallowNullValue: true)
final String value;

const Variable({
required this.value,
this.target,
});

factory Variable.fromJson(Map<String, dynamic> json) =>
_$VariableFromJson(json);
}
Loading

0 comments on commit c84e4e4

Please sign in to comment.