-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
1,347 additions
and
0 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,95 @@ | ||
### https://raw.github.com/github/gitignore/45dca6a85905883a6459208e249822068f652ac3/Dart.gitignore | ||
|
||
# See https://www.dartlang.org/guides/libraries/private-files | ||
|
||
# Files and directories created by pub | ||
.dart_tool/ | ||
.packages | ||
build/ | ||
# If you're building an application, you may want to check-in your pubspec.lock | ||
pubspec.lock | ||
|
||
# Directory created by dartdoc | ||
# If you don't generate documentation locally you can remove this line. | ||
doc/api/ | ||
|
||
# Avoid committing generated Javascript files: | ||
*.dart.js | ||
*.info.json # Produced by the --dump-info flag. | ||
*.js # When generated by dart2js. Don't specify *.js if your | ||
# project includes source files written in JavaScript. | ||
*.js_ | ||
*.js.deps | ||
*.js.map | ||
|
||
|
||
### https://raw.github.com/github/gitignore/45dca6a85905883a6459208e249822068f652ac3/Global/JetBrains.gitignore | ||
|
||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm | ||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 | ||
|
||
# User-specific stuff | ||
.idea/**/workspace.xml | ||
.idea/**/tasks.xml | ||
.idea/**/usage.statistics.xml | ||
.idea/**/dictionaries | ||
.idea/**/shelf | ||
|
||
# Generated files | ||
.idea/**/contentModel.xml | ||
|
||
# Sensitive or high-churn files | ||
.idea/**/dataSources/ | ||
.idea/**/dataSources.ids | ||
.idea/**/dataSources.local.xml | ||
.idea/**/sqlDataSources.xml | ||
.idea/**/dynamic.xml | ||
.idea/**/uiDesigner.xml | ||
.idea/**/dbnavigator.xml | ||
|
||
# Gradle | ||
.idea/**/gradle.xml | ||
.idea/**/libraries | ||
|
||
# Gradle and Maven with auto-import | ||
# When using Gradle or Maven with auto-import, you should exclude module files, | ||
# since they will be recreated, and may cause churn. Uncomment if using | ||
# auto-import. | ||
# .idea/modules.xml | ||
# .idea/*.iml | ||
# .idea/modules | ||
|
||
# CMake | ||
cmake-build-*/ | ||
|
||
# Mongo Explorer plugin | ||
.idea/**/mongoSettings.xml | ||
|
||
# File-based project format | ||
*.iws | ||
|
||
# IntelliJ | ||
out/ | ||
|
||
# mpeltonen/sbt-idea plugin | ||
.idea_modules/ | ||
|
||
# JIRA plugin | ||
atlassian-ide-plugin.xml | ||
|
||
# Cursive Clojure plugin | ||
.idea/replstate.xml | ||
|
||
# Crashlytics plugin (for Android Studio and IntelliJ) | ||
com_crashlytics_export_strings.xml | ||
crashlytics.properties | ||
crashlytics-build.properties | ||
fabric.properties | ||
|
||
# Editor-based Rest Client | ||
.idea/httpRequests | ||
|
||
# Android studio 3.1+ serialized cache file | ||
.idea/caches/build_file_checksums.ser | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 @@ | ||
## 0.5.0 | ||
|
||
- Public 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,203 @@ | ||
# dart_oss_licenses | ||
|
||
CLI tool that generate OSS license list of dart used in your project. | ||
|
||
|
||
# Getting Started | ||
|
||
install Dart SDK. | ||
|
||
For example, if you are using homebrew with mac. | ||
|
||
``` | ||
$ brew tap dart-lang/dart | ||
$ brew install dart | ||
``` | ||
|
||
inatall dart-oss-licenses. | ||
|
||
``` | ||
$ pub global activate dart-oss-licenses | ||
``` | ||
|
||
run in your project root (exists pubspec.lock). | ||
But you have task to do before that. | ||
|
||
``` | ||
$ cd <your project root> | ||
$ dart-oss-licenses | ||
``` | ||
|
||
## For ios | ||
|
||
In ios, it is realized with settings.bundle. So make it. | ||
|
||
On Menu of Xcode | ||
__File__ -> __New__ -> __File...__ -> Select __Settings.bundle__ -> Next -> __Create__ as ```<Project>/ios/Runner/Settings.bundle``` | ||
|
||
Then Rewrite Root.plist as follows. | ||
|
||
``` | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>PreferenceSpecifiers</key> | ||
<array> | ||
<dict> | ||
<key>Type</key> | ||
<string>PSChildPaneSpecifier</string> | ||
<key>Title</key> | ||
<string>Licenses</string> | ||
<key>File</key> | ||
<string>com.ko2ic.dart-oss-licenses</string> | ||
</dict> | ||
</array> | ||
<key>StringsTable</key> | ||
<string>Root</string> | ||
</dict> | ||
</plist> | ||
``` | ||
|
||
en.lproj/Root.strings | ||
|
||
``` | ||
"Licenses" = "Licenses"; | ||
``` | ||
|
||
By doing this, the above command will succeed. | ||
|
||
### Application Code | ||
|
||
In order to transition from the application, write the following. | ||
|
||
``` | ||
@UIApplicationMain | ||
@objc class AppDelegate: FlutterAppDelegate { | ||
private var _result: FlutterResult? | ||
override func application( | ||
_ application: UIApplication, | ||
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]? | ||
) -> Bool { | ||
let controller: FlutterViewController = window?.rootViewController as! FlutterViewController | ||
let channel = FlutterMethodChannel(name: "sample/platform", | ||
binaryMessenger: controller) | ||
channel.setMethodCallHandler({ | ||
(call: FlutterMethodCall, result: @escaping FlutterResult) -> Void in | ||
switch call.method { | ||
case "toOssLicense": | ||
if let url = URL(string: UIApplicationOpenSettingsURLString) { | ||
if #available(iOS 10.0, *) { | ||
UIApplication.shared.open(url, options: [:], completionHandler: nil) | ||
} else { | ||
UIApplication.shared.openURL(url) | ||
} | ||
} | ||
default: | ||
result(FlutterMethodNotImplemented) | ||
break | ||
} | ||
}) | ||
GeneratedPluginRegistrant.register(with: self) | ||
return super.application(application, didFinishLaunchingWithOptions: launchOptions) | ||
} | ||
} | ||
``` | ||
|
||
### For OSS used in native | ||
|
||
dart_oss_licenses supports dart's OSS only. | ||
So native needs to use another tool for ios. | ||
|
||
The recommendation is [LicensePlist](https://github.com/mono0926/LicensePlist). | ||
It also supports CocoaPods, Carthage and Manual(Git SubModule, direct sources and so on). | ||
|
||
Merge results of dart_oss_licenses and LicensePlist. | ||
|
||
## For Android | ||
|
||
Currently, only [AboutLibraries](https://github.com/mikepenz/AboutLibraries) is supported. | ||
|
||
Run command then generated in ```/android/app/src/main/res/values/license_strings.xml```. | ||
|
||
If it already exists, generated in ```/android/app/src/main/res/values/license_strings.xml.temp```. | ||
|
||
Since license_strings.xml is not perfect in some cases, you need to complete it yourself. | ||
|
||
If the tool fails to acquire information, it is written ```TODO```, so you can search for it and fix it. | ||
|
||
### Application Code | ||
|
||
android/app/build.gradle | ||
|
||
``` | ||
dependencies { | ||
implementation "com.mikepenz:aboutlibraries:6.1.1" | ||
``` | ||
|
||
Replace <package name> with the command outputted ```Succeeded Package List```. | ||
|
||
``` | ||
class MainActivity() : FlutterActivity() { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
GeneratedPluginRegistrant.registerWith(this) | ||
MethodChannel( | ||
flutterView, | ||
"sample/platform" | ||
).setMethodCallHandler { call: MethodCall, result: MethodChannel.Result -> | ||
when (call.method) { | ||
"toOssLicense" -> { | ||
LibsBuilder() | ||
.withActivityStyle(Libs.ActivityStyle.LIGHT_DARK_TOOLBAR) | ||
.withActivityTitle("Licenses") | ||
.withLicenseShown(true) | ||
.withLibraries( | ||
<package name> | ||
) | ||
//start the activity | ||
.start(this) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
## Dart | ||
|
||
Finally you can complete the following method with ui. | ||
|
||
``` | ||
static const platform = const MethodChannel('sample/platform'); | ||
Future<void> toOssLicense() { | ||
return platform.invokeMethod('toOssLicense', {}); | ||
} | ||
``` | ||
|
||
# Contributing | ||
|
||
Anything, such as corresponding to other formats, is happy. Please feel free Pull Request. | ||
|
||
## How to create other format | ||
|
||
Please refer to ```formats``` package and implement the ```FormatHoldable``` interface. | ||
|
||
then add a instance in ```formats/format_kind.dart```. | ||
|
||
``` | ||
List<FormatHoldable> instanceAllFormats() { | ||
return [ | ||
AboutLibrariesFormat(), | ||
SettingsBundlePlistFormat(), | ||
+ SomethingFormat(), | ||
]; | ||
} | ||
``` | ||
|
||
|
||
|
Oops, something went wrong.