pubspec_extract 2.0.5 copy "pubspec_extract: ^2.0.5" to clipboard
pubspec_extract: ^2.0.5 copied to clipboard

Extracts Dart pubspec.yaml file and generate pubspec.dart at build time

Pubspec Extract #

Extracts Dart pubspec.yaml file and generate pubspec.dart at build time.

Buy Me A Coffee

Usage as a command line tool #

Add the pubspec_extract dev dependency

dart pub add --dev pubspec_extract

then run:

dart run pubspec_extract

Install the command-line tool globally #

run:

dart pub global activate pubspec_extract

the executable will be compiled and available at $HOME/.pub-cache/bin or %APPDATA%\Pub\Cache\bin. You can run it using:

dart pub global run pubspec_extract

Usage with build_runner #

Add the build_runner dev dependency

dart pub add --dev build_runner

Build the pubspec.dart file

dart run build_runner build

Builder options are configured in your pubspec.yaml:

pubspec_extract:
  class_name: Pubspec
  source: pubspec.yaml
  destination: lib/pubspec.dart
  format: true
  map_list: false

Usage #

Then in your application, you can import pubspec.dart:

import 'pubspec.dart'; // May not exist but it's okay!

void main() {
  print(Pubspec.name);
  print(Pubspec.description);
  print(Pubspec.version);
}
14
likes
140
pub points
62%
popularity

Publisher

verified publishernfet.net

Extracts Dart pubspec.yaml file and generate pubspec.dart at build time

Repository (GitHub)
View/report issues
Contributing

Documentation

API reference

License

Apache-2.0 (LICENSE)

Dependencies

args, build, dart_style, logging, path, pub_semver, yaml

More

Packages that depend on pubspec_extract