-
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.
@ F maybe must split to flutter impl
- Loading branch information
1 parent
1c8219d
commit 945a27c
Showing
85 changed files
with
1,838 additions
and
110 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,84 @@ | ||
// ignore_for_file: avoid_print | ||
|
||
import 'dart:io'; | ||
|
||
import 'package:approval_tests/src/widget/src/common.dart'; | ||
import 'package:approval_tests/src/widget/src/git_diffs.dart'; | ||
|
||
void main() async { | ||
final searchDirectory = Directory.current; | ||
|
||
final List<Future<void>> tasks = []; | ||
|
||
/// Recursively search for current files | ||
await for (final file in searchDirectory.list(recursive: true)) { | ||
if (file.path.endsWith('.unapproved.txt')) { | ||
final reviewFile = file; | ||
final approvedFileName = file.path.replaceAll('.unapproved.txt', '.approved.txt'); | ||
final approvedFile = File(approvedFileName); | ||
|
||
if (approvedFile.existsSync()) { | ||
tasks.add(processFile(approvedFile, reviewFile)); | ||
} | ||
} | ||
} | ||
|
||
await Future.wait(tasks); | ||
|
||
print('Review process completed.'); | ||
} | ||
|
||
/// Check of the files are different using "git diff" | ||
Future<void> processFile(File approvedFile, FileSystemEntity reviewFile) async { | ||
final resultString = gitDiffFiles(approvedFile, reviewFile); | ||
|
||
if (resultString.isNotEmpty || resultString.isNotEmpty) { | ||
final String fileNameWithoutExtension = approvedFile.path.split('/').last.split('.').first; | ||
printGitDiffs(fileNameWithoutExtension, resultString); | ||
|
||
String? firstCharacter; | ||
|
||
do { | ||
stdout.write('Accept changes? (y/N/[v]iew): '); | ||
final response = stdin.readLineSync()?.trim().toLowerCase(); | ||
|
||
if (response == null || response.isEmpty) { | ||
firstCharacter = null; | ||
} else { | ||
firstCharacter = response[0]; | ||
} | ||
|
||
if (firstCharacter == 'y') { | ||
await approvedFile.delete(); | ||
await reviewFile.rename(approvedFile.path); | ||
print('Approval test approved'); | ||
} else if (firstCharacter == 'v') { | ||
if (isCodeCommandAvailable()) { | ||
final approvedFilename = approvedFile.path; | ||
final reviewFilename = reviewFile.path; | ||
|
||
print("Executing 'code --diff $approvedFilename $reviewFilename'"); | ||
final processResult = Process.runSync('code', ['--diff', approvedFilename, reviewFilename]); | ||
print('processResult: ${processResult.toString()}'); | ||
} else { | ||
print(''' | ||
$topBar | ||
To enable the 'v' command, your system must be configured to run VSCode from the command line: | ||
0. Install VSCode (if you haven't already) | ||
1. Open Visual Studio Code. | ||
2. Open the Command Palette by pressing Cmd + Shift + P. | ||
3. Type ‘Shell Command’ into the Command Palette and look for the option ‘Install ‘code’ command in PATH’. | ||
4. Select it and it should install the necessary scripts so that you can use code from the terminal. | ||
$bottomBar'''); | ||
} | ||
} else { | ||
print('Approval test rejected'); | ||
} | ||
} while (firstCharacter == 'v'); | ||
} | ||
} | ||
|
||
bool isCodeCommandAvailable() { | ||
final result = Process.runSync('which', ['code']); | ||
return result.exitCode == 0; | ||
} |
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,3 @@ | ||
# https://dart.dev/guides/libraries/private-files | ||
# Created by `dart pub` | ||
.dart_tool/ |
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,3 @@ | ||
## 1.0.0 | ||
|
||
- Initial version. |
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,2 @@ | ||
A sample command-line application with an entrypoint in `bin/`, library code | ||
in `lib/`, and example unit test in `test/`. |
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,30 @@ | ||
# This file configures the static analysis results for your project (errors, | ||
# warnings, and lints). | ||
# | ||
# This enables the 'recommended' set of lints from `package:lints`. | ||
# This set helps identify many issues that may lead to problems when running | ||
# or consuming Dart code, and enforces writing Dart using a single, idiomatic | ||
# style and format. | ||
# | ||
# If you want a smaller set of lints you can change this to specify | ||
# 'package:lints/core.yaml'. These are just the most critical lints | ||
# (the recommended set includes the core lints). | ||
# The core lints are also what is used by pub.dev for scoring packages. | ||
|
||
include: package:lints/recommended.yaml | ||
|
||
# Uncomment the following section to specify additional rules. | ||
|
||
# linter: | ||
# rules: | ||
# - camel_case_types | ||
|
||
# analyzer: | ||
# exclude: | ||
# - path/to/excluded/files/** | ||
|
||
# For more information about the core and recommended set of lints, see | ||
# https://dart.dev/go/core-lints | ||
|
||
# For additional information about configuring this file, see | ||
# https://dart.dev/guides/language/analysis-options |
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,5 @@ | ||
import 'package:dart_application/dart_application.dart' as dart_application; | ||
|
||
void main(List<String> arguments) { | ||
print('Fizz Buzz for 5: ${dart_application.fizzBuzz(5)}!'); | ||
} |
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 @@ | ||
/// Fizz Buzz kata implementation | ||
List<String> fizzBuzz(int n) { | ||
final List<String> result = []; | ||
|
||
for (int i = 1; i <= n; i++) { | ||
// If the current number (`i`) is divisible by both 3 and 5 (or equivalently 15), | ||
// add the string "FizzBuzz" to the `result` list. | ||
if (i % 15 == 0) { | ||
result.add("FizzBuzz"); | ||
|
||
// Else, if the current number (`i`) is only divisible by 3, | ||
// add the string "Fizz" to the `result` list. | ||
} else if (i % 3 == 0) { | ||
result.add("Fizz"); | ||
|
||
// Else, if the current number (`i`) is only divisible by 5, | ||
// add the string "Buzz" to the `result` list. | ||
} else if (i % 5 == 0) { | ||
result.add("Buzz"); | ||
|
||
// If the current number (`i`) is neither divisible by 3 nor 5, | ||
// add the string representation of that number to the `result` list. | ||
} else { | ||
result.add(i.toString()); | ||
} | ||
} | ||
|
||
return result; | ||
} |
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,16 @@ | ||
name: dart_application | ||
description: A sample command-line application. | ||
version: 1.0.0 | ||
publish_to: 'none' | ||
|
||
environment: | ||
sdk: ^3.4.0 | ||
|
||
# Add regular dependencies here. | ||
dependencies: | ||
approval_tests: | ||
path: ../../ | ||
|
||
dev_dependencies: | ||
lints: ^3.0.0 | ||
test: ^1.24.0 |
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,18 @@ | ||
import 'package:approval_tests/approval_tests.dart'; | ||
import 'package:dart_application/dart_application.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
group('Fizz Buzz', () { | ||
test("verify combinations", () { | ||
Approvals.verifyAll( | ||
[3, 5, 15], | ||
options: const Options( | ||
reporter: DiffReporter(), | ||
deleteReceivedFile: true, | ||
), | ||
processor: (items) => fizzBuzz(items).toString(), | ||
); | ||
}); | ||
}); | ||
} |
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,43 @@ | ||
# Miscellaneous | ||
*.class | ||
*.log | ||
*.pyc | ||
*.swp | ||
.DS_Store | ||
.atom/ | ||
.buildlog/ | ||
.history | ||
.svn/ | ||
migrate_working_dir/ | ||
|
||
# IntelliJ related | ||
*.iml | ||
*.ipr | ||
*.iws | ||
.idea/ | ||
|
||
# The .vscode folder contains launch configuration and tasks you configure in | ||
# VS Code which you may wish to be included in version control, so this line | ||
# is commented out by default. | ||
#.vscode/ | ||
|
||
# Flutter/Dart/Pub related | ||
**/doc/api/ | ||
**/ios/Flutter/.last_build_id | ||
.dart_tool/ | ||
.flutter-plugins | ||
.flutter-plugins-dependencies | ||
.pub-cache/ | ||
.pub/ | ||
/build/ | ||
|
||
# Symbolication related | ||
app.*.symbols | ||
|
||
# Obfuscation related | ||
app.*.map.json | ||
|
||
# Android Studio will place build artifacts here | ||
/android/app/debug | ||
/android/app/profile | ||
/android/app/release |
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,45 @@ | ||
# This file tracks properties of this Flutter project. | ||
# Used by Flutter tool to assess capabilities and perform upgrades etc. | ||
# | ||
# This file should be version controlled and should not be manually edited. | ||
|
||
version: | ||
revision: "761747bfc538b5af34aa0d3fac380f1bc331ec49" | ||
channel: "stable" | ||
|
||
project_type: app | ||
|
||
# Tracks metadata for the flutter migrate command | ||
migration: | ||
platforms: | ||
- platform: root | ||
create_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49 | ||
base_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49 | ||
- platform: android | ||
create_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49 | ||
base_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49 | ||
- platform: ios | ||
create_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49 | ||
base_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49 | ||
- platform: linux | ||
create_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49 | ||
base_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49 | ||
- platform: macos | ||
create_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49 | ||
base_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49 | ||
- platform: web | ||
create_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49 | ||
base_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49 | ||
- platform: windows | ||
create_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49 | ||
base_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49 | ||
|
||
# User provided section | ||
|
||
# List of Local paths (relative to this file) that should be | ||
# ignored by the migrate tool. | ||
# | ||
# Files that are not part of the templates will be ignored by default. | ||
unmanaged_files: | ||
- 'lib/main.dart' | ||
- 'ios/Runner.xcodeproj/project.pbxproj' |
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,3 @@ | ||
# example_project | ||
|
||
A new Flutter project. |
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 @@ | ||
include: package:flutter_lints/flutter.yaml |
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,13 @@ | ||
gradle-wrapper.jar | ||
/.gradle | ||
/captures/ | ||
/gradlew | ||
/gradlew.bat | ||
/local.properties | ||
GeneratedPluginRegistrant.java | ||
|
||
# Remember to never publicly share your keystore. | ||
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app | ||
key.properties | ||
**/*.keystore | ||
**/*.jks |
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,58 @@ | ||
plugins { | ||
id "com.android.application" | ||
id "kotlin-android" | ||
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. | ||
id "dev.flutter.flutter-gradle-plugin" | ||
} | ||
|
||
def localProperties = new Properties() | ||
def localPropertiesFile = rootProject.file("local.properties") | ||
if (localPropertiesFile.exists()) { | ||
localPropertiesFile.withReader("UTF-8") { reader -> | ||
localProperties.load(reader) | ||
} | ||
} | ||
|
||
def flutterVersionCode = localProperties.getProperty("flutter.versionCode") | ||
if (flutterVersionCode == null) { | ||
flutterVersionCode = "1" | ||
} | ||
|
||
def flutterVersionName = localProperties.getProperty("flutter.versionName") | ||
if (flutterVersionName == null) { | ||
flutterVersionName = "1.0" | ||
} | ||
|
||
android { | ||
namespace = "com.example.example_project" | ||
compileSdk = flutter.compileSdkVersion | ||
ndkVersion = flutter.ndkVersion | ||
|
||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
} | ||
|
||
defaultConfig { | ||
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). | ||
applicationId = "com.example.example_project" | ||
// You can update the following values to match your application needs. | ||
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. | ||
minSdk = flutter.minSdkVersion | ||
targetSdk = flutter.targetSdkVersion | ||
versionCode = flutterVersionCode.toInteger() | ||
versionName = flutterVersionName | ||
} | ||
|
||
buildTypes { | ||
release { | ||
// TODO: Add your own signing config for the release build. | ||
// Signing with the debug keys for now, so `flutter run --release` works. | ||
signingConfig = signingConfigs.debug | ||
} | ||
} | ||
} | ||
|
||
flutter { | ||
source = "../.." | ||
} |
7 changes: 7 additions & 0 deletions
7
example/flutter_project/android/app/src/debug/AndroidManifest.xml
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,7 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<!-- The INTERNET permission is required for development. Specifically, | ||
the Flutter tool needs it to communicate with the running application | ||
to allow setting breakpoints, to provide hot reload, etc. | ||
--> | ||
<uses-permission android:name="android.permission.INTERNET"/> | ||
</manifest> |
Oops, something went wrong.