Skip to content

Commit a775a63

Browse files
authored
Release/v0.0.1 dev.4 (#5)
- Optional automatic `minSdkLevel` check and update (Android) - Updated README - Updated CHANGELOG (uhm... sorry about that 😅)
1 parent 0d0d4df commit a775a63

19 files changed

+751
-38
lines changed

.github/workflows/brick_workflow.yml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,28 @@ name: Very Good Workflow
33
on:
44
pull_request:
55
paths:
6+
- ".github/workflows/brick_workflow.yaml"
67
- "hooks/**"
78
- "hooks/test/**"
8-
- "pubspec.yaml"
9+
- "hooks/pubspec.yaml"
910
push:
1011
branches:
1112
- main
1213
paths:
14+
- ".github/workflows/brick_workflow.yaml"
1315
- "hooks/**"
1416
- "hooks/test/**"
15-
- "pubspec.yaml"
17+
- "hooks/pubspec.yaml"
1618

1719
jobs:
18-
semantic-pull-request:
19-
uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/semantic_pull_request.yml@v1
20-
21-
build:
22-
uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/dart_package.yml@v1
23-
2420
ci:
2521
runs-on: ubuntu-latest
2622
defaults:
2723
run:
2824
working-directory: ./hooks
2925

3026
steps:
31-
- uses: actions/checkout@v2
27+
- uses: actions/checkout@v2.5.0
3228
- uses: dart-lang/setup-dart@v1
3329

3430
- name: Install Dependencies
@@ -43,7 +39,7 @@ jobs:
4339
- name: Run Tests
4440
run: |
4541
dart pub global activate coverage 1.3.0
46-
dart test --coverage=coverage && dart pub global run coverage:format_coverage --lcov --in=coverage --out=coverage/lcov.info --report-on=lib
42+
dart test --coverage=coverage && dart pub global run coverage:format_coverage --lcov --in=coverage --out=coverage/lcov.info
4743
4844
- name: Upload coverage to Codecov
49-
uses: codecov/codecov-action@v1
45+
uses: codecov/codecov-action@v3.1.1

CHANGELOG.md

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,34 @@
1-
# 0.1.0+1
1+
# 0.0.1-dev.1
22

3-
- TODO: Describe initial release.
3+
**🎉 Initial version of freerasp_brick 🎉**
4+
## ✨ Features
5+
- 🛠 Configuration generation
6+
- 🎯 Dependency check using `pub get`
7+
- 🔧 Fix apply using `dart fix`
8+
9+
# 0.0.1-dev.2
10+
## ✨ New Features
11+
- Automatic dependency fetching using `pub add`
12+
13+
## 🎯 Improvements
14+
- Unified CLI prompt design
15+
- Expanded README.md
16+
17+
## 🛠 Fixed issues
18+
- Typos in README.md
19+
20+
# 0.0.1-dev.3
21+
## 🎯 Improvements
22+
- GitHub actions
23+
- Code analysis
24+
25+
## 🛠 Fixed issues
26+
- Dynamic types
27+
28+
# 0.0.1-dev.4
29+
## ✨ New Features
30+
- Optional automatic `minSdkLevel` check and update (Android)
31+
32+
## 🎯 Improvements
33+
- Updated README
34+
- Updated CHANGELOG (uhm... sorry about that 😅)

README.md

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
1-
# freerasp_brick
1+
# freeRASP brick
22

33
<p align="center">
44
<a href="https://github.com/felangel/mason"><img src="https://img.shields.io/endpoint?url=https%3A%2F%2Ftinyurl.com%2Fmason-badge" alt="Powered by Mason"></a>
55
<a href="https://pub.dev/packages/freerasp"><img src="https://img.shields.io/badge/Supported%20freeRASP-%5E3.0.0-brightgreen" alt="Supported freeRASP"/></a>
6+
<a href="https://github.com/yardexx/freerasp_brick/actions/workflows/brick_workflow.yml"><img src="https://github.com/yardexx/freerasp_brick/actions/workflows/brick_workflow.yml/badge.svg?branch=master"/></a>
7+
<a href="https://codecov.io/gh/yardexx/freerasp_brick"><img src="https://codecov.io/gh/yardexx/freerasp_brick/branch/master/graph/badge.svg?token=300N5C20OB"/></a>
8+
<a href="https://pub.dev/packages/very_good_analysis"><img src="https://img.shields.io/badge/style-very_good_analysis-B22C89.svg" alt="style: very good analysis"></a>
69
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/license-MIT-purple.svg" alt="License: MIT"></a>
710
</p>
811

912
<p align="center">
10-
A brick for configuration generation and automatic setup for <a href="https://pub.dev/packages/freerasp">freeRASP</a>.
13+
A brick for <a href="https://pub.dev/packages/freerasp">freeRASP</a> to generate configuration code
14+
and automate necessary code checks.
1115
</p>
1216

13-
> 🚧 This brick is experimental and not stable! Changes to API reserved. 🚧
17+
> 🚧 This brick is experimental and not stable! Changes to API/file generation reserved.
18+
19+
> ⚠ This brick is supported for mason version `>=0.1.0-dev.40`.
1420
1521
## Overview
1622
Setting up freeRASP can be quite tedious and repetitive. freerasp_brick provides you error-prone
@@ -20,6 +26,7 @@ way to create configuration.
2026
- 🛠 Configuration generation
2127
- 🎯 Dependency check using `pub get`
2228
- 🔧 Fix apply using `dart fix`
29+
- 🤖 Android SDK level check and automatic update
2330

2431
## How to add ➕
2532
This brick is currently **NOT** available on [brickhub.dev](https://brickhub.dev/).
@@ -68,15 +75,21 @@ and provide it in `freerasp.g.dart`;
6875
| pre-gen |||
6976
| post-gen |||
7077

71-
## Getting started with [freeRASP][freerasp-pubdev]
78+
> ⚠ Brick can behave unexpectedly if pre-gen or post-gen hooks are disabled.
79+
80+
## Contribution 🤝
81+
For issues, bugs, or feature proposals feel free to [open issue](https://github.com/yardexx/freerasp_brick/issues)
82+
or [create PR](https://github.com/yardexx/freerasp_brick/pulls).
83+
84+
## Useful resources 📚
85+
If this is your first touch with freeRASP or Mason, please refer to resources to get started
86+
87+
### Getting started with [freeRASP][freerasp-pubdev] 🛡
7288
- [freeRASP on GitHub][freerasp-github]
7389
- [freeRASP website][freerasp-website]
7490
- [Medium article: freeRASP — In-App protection SDK and app security monitoring service][freerasp-medium]
7591

76-
## Getting started with [mason][mason-github] 🧱
77-
78-
If this is your first touch with mason, please refer to resources to get started:
79-
92+
### Getting started with [mason][mason-github] 🧱
8093
- [Mason on GitHub][mason-github]
8194
- [Official Mason Documentation][mason-docs]
8295
- [Code generation with Mason Blog][mason-blog]

brick.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
name: freerasp_brick
22
description: A brick for configuration generation and automatic setup for freeRASP.
33

4-
version: 0.0.1-dev.1
4+
version: 0.0.1-dev.4
55

66
environment:
7-
mason: ">=0.1.0-dev.26 <0.1.0"
7+
mason: ">=0.1.0-dev.40 <0.1.0"
88

99
vars:
1010
watcher_mail:

hooks/errors/errors.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export 'freerasp_brick_exception.dart';
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
class FreeRaspBrickException implements Exception {
2+
const FreeRaspBrickException({
3+
this.code = 'brick-failure',
4+
this.message,
5+
this.stackTrace,
6+
});
7+
8+
factory FreeRaspBrickException.wtf({
9+
StackTrace? stackTrace,
10+
String? message,
11+
}) {
12+
return FreeRaspBrickException(
13+
message: message ?? 'Unexpected error occurred.',
14+
stackTrace: stackTrace,
15+
);
16+
}
17+
18+
factory FreeRaspBrickException.gradleUpdateFailure({StackTrace? stackTrace}) {
19+
return FreeRaspBrickException(
20+
code: 'gradle-failure',
21+
message: 'Issue occurred during update of gradle file.',
22+
stackTrace: stackTrace,
23+
);
24+
}
25+
26+
final String code;
27+
final String? message;
28+
final StackTrace? stackTrace;
29+
}

hooks/extensions.dart

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// coverage:ignore-file
2+
import 'package:mason/mason.dart';
3+
4+
extension LoggerX on Logger {
5+
String masonPrompt(
6+
String? message, {
7+
Object? defaultValue,
8+
bool hidden = false,
9+
}) {
10+
return prompt(
11+
'${green.wrap('?')} ${message ?? ''}',
12+
defaultValue: defaultValue,
13+
hidden: hidden,
14+
);
15+
}
16+
17+
bool masonConfirm(
18+
String? message, {
19+
bool defaultValue = false,
20+
}) {
21+
return confirm(
22+
'${green.wrap('?')} ${message ?? ''}',
23+
defaultValue: defaultValue,
24+
);
25+
}
26+
}

hooks/post_gen.dart

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
// coverage:ignore-file
12
import 'dart:io';
23

34
import 'package:mason/mason.dart';
45

6+
import 'utils/gradle_updater.dart';
7+
58
const String androidBuild = 'build.gradle';
69
const String flutterBuild = 'lib';
710

@@ -11,6 +14,7 @@ Future<void> run(HookContext context) async {
1114
await _runPubAdd(logger);
1215
await _runPubGet(logger);
1316
await _runDartFix(logger);
17+
await _runGradleCheck(context);
1418
}
1519

1620
Future<void> _runPubAdd(Logger logger) async {
@@ -42,6 +46,26 @@ Future<void> _runDartFix(Logger logger) async {
4246
final progress = logger.progress('Running dart fix --apply');
4347
final result = await Process.run('dart', ['fix', '--apply']);
4448
return result.exitCode == 0
45-
? progress.complete('Fix applied.')
49+
? progress.complete('Fix applied')
4650
: progress.fail("Fix couldn't be applied");
4751
}
52+
53+
Future<void> _runGradleCheck(HookContext context) async {
54+
final progress = context.logger.progress('Checking build.gradle file');
55+
56+
if (!(context.vars['check_gradle'] as bool)) {
57+
progress.complete('Gradle check not required. Skipping...');
58+
return;
59+
}
60+
61+
try {
62+
final hasUpdated = gradleUpdate('android/app/build.gradle');
63+
progress.complete(
64+
hasUpdated
65+
? 'build.gradle successfully updated'
66+
: 'build.gradle already contains supported API level',
67+
);
68+
} catch (_) {
69+
progress.fail("Couldn't update build.gradle");
70+
}
71+
}

hooks/pre_gen.dart

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
// coverage:ignore-file
12
import 'package:mason/mason.dart';
23

4+
import 'extensions.dart';
5+
36
const defaultAppPackage = 'com.example.app';
47

58
void run(HookContext context) {
@@ -40,22 +43,14 @@ void parseAndroidData(HookContext context) {
4043

4144
final signingHash = logger.masonPrompt("What's app singing hash?");
4245

46+
final checkGradle = logger.masonConfirm(
47+
'Do you want to check and update API level (minSdkVersion)?',
48+
defaultValue: true,
49+
);
50+
4351
context.vars.addAll({
4452
'package_name': packageName,
4553
'signing_hash': signingHash,
54+
'check_gradle': checkGradle,
4655
});
4756
}
48-
49-
extension LoggerX on Logger {
50-
String masonPrompt(
51-
String? message, {
52-
Object? defaultValue,
53-
bool hidden = false,
54-
}) {
55-
return prompt(
56-
'${green.wrap('?')} ${message ?? ''}',
57-
defaultValue: defaultValue,
58-
hidden: hidden,
59-
);
60-
}
61-
}

hooks/pubspec.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ environment:
44
sdk: ">=2.12.0 <3.0.0"
55

66
dependencies:
7+
file: ^6.1.4
78
mason: ^0.1.0-dev
89

910
dev_dependencies:
11+
test: ^1.22.0
1012
very_good_analysis: ^3.1.0

0 commit comments

Comments
 (0)