Skip to content

Commit

Permalink
release/v0.0.1 dev.5 (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
yardexx authored Dec 18, 2022
1 parent 25f345d commit 199b6e2
Show file tree
Hide file tree
Showing 16 changed files with 524 additions and 16 deletions.
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,15 @@

## 🎯 Improvements
- Updated README
- Updated CHANGELOG (uhm... sorry about that 😅)
- Updated CHANGELOG (uhm... sorry about that 😅)

# 0.0.1-dev.5
## ✨ New Features
- Optional automatic iOS script insertion in Runner.xcscheme - experimental (iOS)

## 🎯 Improvements
- Updated README

## 🛠 Fixed issues
- Fixed incorrect `mason` version in `brick.yaml`
- Specified explicit `mason` version to `>=0.1.0-dev.39` in `pubspec.yaml`
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ way to create configuration.
- 🎯 Dependency check using `pub get`
- 🔧 Fix apply using `dart fix`
- 🤖 Android SDK level check and automatic update
- 🍎 iOS script insertion in Runner.xcscheme (Experimental)

## How to add ➕
This brick is currently **NOT** available on [brickhub.dev](https://brickhub.dev/).
Expand Down
4 changes: 2 additions & 2 deletions brick.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: freerasp_brick
description: A brick for configuration generation and automatic setup for freeRASP.

version: 0.0.1-dev.4
version: 0.0.1-dev.5

environment:
mason: ">=0.1.0-dev.40 <0.1.0"
mason: ">=0.1.0-dev.39 <0.1.0"

vars:
watcher_mail:
Expand Down
19 changes: 17 additions & 2 deletions hooks/errors/freerasp_brick_exception.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,25 @@ class FreeRaspBrickException implements Exception {
);
}

factory FreeRaspBrickException.gradleUpdateFailure({StackTrace? stackTrace}) {
factory FreeRaspBrickException.gradleUpdateFailure({
String? message,
StackTrace? stackTrace,
}) {
return FreeRaspBrickException(
code: 'gradle-failure',
message: 'Issue occurred during update of gradle file.',
message: message ?? 'Issue occurred during update of gradle file.',
stackTrace: stackTrace,
);
}

factory FreeRaspBrickException.schemeUpdateFailure({
String? message,
StackTrace? stackTrace,
}) {
return FreeRaspBrickException(
code: 'xcscheme-failure',
message:
message ?? 'Issue occurred during update of Runner.xcscheme file.',
stackTrace: stackTrace,
);
}
Expand Down
25 changes: 21 additions & 4 deletions hooks/post_gen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ import 'dart:io';

import 'package:mason/mason.dart';

import 'utils/gradle_updater.dart';
import 'utils/utils.dart';

const String androidBuild = 'build.gradle';
const String flutterBuild = 'lib';

Future<void> run(HookContext context) async {
final logger = context.logger;

await _runPubAdd(logger);
await _runPubGet(logger);
await _runDartFix(logger);
await _runGradleCheck(context);
await _runSchemeCheck(context);
}

Future<void> _runPubAdd(Logger logger) async {
Expand Down Expand Up @@ -53,13 +53,13 @@ Future<void> _runDartFix(Logger logger) async {
Future<void> _runGradleCheck(HookContext context) async {
final progress = context.logger.progress('Checking build.gradle file');

if (!(context.vars['check_gradle'] as bool)) {
if (!(context.vars['update_gradle'] as bool)) {
progress.complete('Gradle check not required. Skipping...');
return;
}

try {
final hasUpdated = gradleUpdate('android/app/build.gradle');
final hasUpdated = GradleUpdater.update('android/app/build.gradle');
progress.complete(
hasUpdated
? 'build.gradle successfully updated'
Expand All @@ -69,3 +69,20 @@ Future<void> _runGradleCheck(HookContext context) async {
progress.fail("Couldn't update build.gradle");
}
}

Future<void> _runSchemeCheck(HookContext context) async {
final progress = context.logger.progress('Checking xcscheme file');

if (!(context.vars['update_scheme'] as bool)) {
progress.complete('Xcscheme check not required. Skipping...');
return;
}

try {
SchemeUpdater.update(
'ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme',
);
} catch (e) {
progress.fail("Couldn't update xcscheme");
}
}
10 changes: 8 additions & 2 deletions hooks/pre_gen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,15 @@ void parseCupertinoData(HookContext context) {
defaultValue: defaultAppPackage,
);

final updateScheme = logger.masonConfirm(
'Do you want to update Runner.xcscheme?',
defaultValue: true,
);

context.vars.addAll({
'bundle_id': bundleId,
'team_id': teamId,
'update_scheme': updateScheme,
});
}

Expand All @@ -43,14 +49,14 @@ void parseAndroidData(HookContext context) {

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

final checkGradle = logger.masonConfirm(
final updateGradle = logger.masonConfirm(
'Do you want to check and update API level (minSdkVersion)?',
defaultValue: true,
);

context.vars.addAll({
'package_name': packageName,
'signing_hash': signingHash,
'check_gradle': checkGradle,
'update_gradle': updateGradle,
});
}
2 changes: 1 addition & 1 deletion hooks/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ environment:

dependencies:
file: ^6.1.4
mason: ^0.1.0-dev
mason: ^0.1.0-dev.39

dev_dependencies:
test: ^1.22.0
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
const missingBuildActionEntries = '''
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
BuildableName = "Runner.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
BuildableName = "Runner.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Profile"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
BuildableName = "Runner.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
''';
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
const containsPreActions = '''
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<PreActions>
<ExecutionAction
ActionType = "Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction">
<ActionContent
title = "Run Script"
scriptText = "echo &quot;Hello&quot;">
</ActionContent>
</ExecutionAction>
</PreActions>
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
BuildableName = "Runner.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
BuildableName = "Runner.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
BuildableName = "Runner.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Profile"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
BuildableName = "Runner.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
''';
Loading

0 comments on commit 199b6e2

Please sign in to comment.