dart_oss_licenses 0.5.0

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • new48

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.
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 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(),
   ];
 }

0.5.0

  • Public Release

Use this package as an executable

1. Install it

You can install the package from the command line:


$ pub global activate dart_oss_licenses

2. Use it

The package has the following executables:


$ dart-oss-licenses
Version Uploaded Documentation Archive
0.5.0 Dec 7, 2018 Go to the documentation of dart_oss_licenses 0.5.0 Download dart_oss_licenses 0.5.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
48
Learn more about scoring.

We analyzed this package on Dec 7, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.7

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in libraries.

Maintenance suggestions

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use dart_oss_licenses.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
html ^0.13.3+3 0.13.3+3
http ^0.12.0 0.12.0
meta ^1.1.6 1.1.6
tuple ^1.0.2 1.0.2
yaml ^2.1.15 2.1.15
Transitive dependencies
args 1.5.1
async 2.0.8
charcode 1.1.2
collection 1.14.11
csslib 0.14.6
http_parser 3.1.3
logging 0.11.3+2
matcher 0.12.4
path 1.6.2
quiver 2.0.1
source_span 1.4.1
stack_trace 1.9.3
string_scanner 1.0.4
typed_data 1.1.6
utf 0.9.0+5
Dev dependencies
test ^1.0.0