flutter_oss_licenses

Creator: coderz1093

Last updated:

Add to Cart

Description:

flutter oss licenses

flutter_oss_licenses #
Introduction #
flutter_oss_licenses is a tool to generate detail and better OSS license list using pubspec.yaml/lock files.
Unlike the package name, it still runs with pure Dart environment :)
Installing #
Adding the package name to dev_dependencies; not to dependencies because the package does nothing on runtime.
dev_dependencies:
flutter_oss_licenses: ^3.0.2
copied to clipboard
Generate oss_licenses.dart #
Before executing the command, you must update your pubspec.lock using pub get (or pub upgrade if you want).
flutter pub get
copied to clipboard
And then, the following command generates oss_licenses.dart on the project's lib/ directory:
flutter pub run flutter_oss_licenses:generate.dart
copied to clipboard
The following fragment is just a part of generated lib/oss_licenses.dart:
const allDependencies = <Package>[
_args,
_collection,
_dart_pubspec_licenses,
_flutter_lints,
_json_annotation,
_lints,
_meta,
_path,
_source_span,
_string_scanner,
_term_glyph,
_yaml
];

/// Direct `dependencies`.
const dependencies = <Package>[
_args,
_dart_pubspec_licenses,
_meta,
_path,
_yaml
];

/// Direct `dev_dependencies`.
const devDependencies = <Package>[
_flutter_lints
];

/// Package license definition.
class Package {
/// Package name
final String name;
/// Description
final String description;
/// Website URL
final String? homepage;
/// Repository URL
final String? repository;
/// Authors
final List<String> authors;
/// Version
final String version;
/// License
final String? license;
/// Whether the license is in markdown format or not (plain text).
final bool isMarkdown;
/// Whether the package is included in the SDK or not.
final bool isSdk;
/// Direct dependencies
final List<Package> dependencies;

const Package({
required this.name,
required this.description,
this.homepage,
this.repository,
required this.authors,
required this.version,
this.license,
required this.isMarkdown,
required this.isSdk,
required this.dependencies,
});
}

...

/// dart_pubspec_licenses 3.0.1
const _dart_pubspec_licenses = Package(
name: 'dart_pubspec_licenses',
description: 'A library to make it easy to extract OSS license information from Dart packages using pubspec.yaml',
homepage: 'https://github.com/espresso3389/flutter_oss_licenses/tree/master/packages/dart_pubspec_licenses',
repository: 'https://github.com/espresso3389/flutter_oss_licenses',
authors: [],
version: '3.0.1',
license: '''MIT License

Copyright (c) 2019 Takashi Kawasaki

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.''',
isMarkdown: false,
isSdk: false,
dependencies: [PackageRef('yaml'), PackageRef('path'), PackageRef('json_annotation')]
);

...

copied to clipboard
The Package class here is defined inside the same file but it's almost identical to dart_pubspec_licenses's Package class except it does not have directory and packageYaml fields.
For a full generated sample, see example code's oss_licenses.dart.
Command line options #
The following command line generates JSON file instead of dart file:
flutter pub run flutter_oss_licenses:generate.dart -o licenses.json --json
copied to clipboard
The following table lists the acceptable options:



Option
Abbr.
Description




--output OUTPUT_FILE_PATH
-o
Specify output file path. If the file extension is .json, --json option is implied anyway. The default output file path depends on the --json flag:with --json: PROJECT_ROOT/assets/oss_licenses.jsonwithout --json: PROJECT_ROOT/lib/oss_licenses.dart


--project-root PROJECT_ROOT
-p
Explicitly specify project root directory that contains pubspec.lock.


--json
-j
Generate JSON file rather than dart file.


--help
-h
Show the help.



Environment variables #
The bin/generated.dart uses one or two environment variable(s) depending on your use case:

PUB_CACHE is used to determine package directory.
FLUTTER_ROOT is for Flutter projects only. If not set, Flutter SDK dependencies are simply ignored and not listed.

They are normally set by dart run or flutter pub run.
Reporting issues #
Report any bugs on the project's issues.
URLs #

Project page on GitHub
Flutter package

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.