pubspec_extract 1.3.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 64

Pubspec Extract #

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

Buy Me A Coffee

Usage with build_runner #

In your pubspec.yaml, add the following:

builders:
    pubspec_extract:

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

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

void main() {
  print(pubspec.name);
  print(pubspec.description);
  print(pubspec.version);
}

Usage as a command line tool #

In your pubspec.yaml, add the following:

dev_dependencies:
    pubspec_extract:

then if you are using Flutter, run:

flutter pub run pubspec_extract

or

pub run pubspec_extract

Install the command-line tool globally #

run:

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:

pub global run pubspec_extract

Changelog #

1.3.1 #

  • Ignore public_member_api_docs
  • Fix Analysis warnings

1.3.0 #

  • Fix variables with non-alpha-numeric characters
  • Add more command-line options

1.2.0 #

  • Remove < > from authors' email address

1.1.0 #

  • Wrap the result in a class
  • Add more fields
  • Generic yaml extraction
  • Add help on executable

1.0.3 #

  • Fix dependencies
  • Remove trim() from string conversion
  • Declare executable pubspec_extract

1.0.2 #

  • Add command-line tool

1.0.1 #

  • Rename the package main entry point
  • Add example
  • Fix issue with empty authors list
  • Fix dependencies

1.0.0 #

  • First version

example/README.md

Example main.dart #

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

void main() {
  print(pubspec.name);
  print(pubspec.description);
  print(pubspec.version);
}

Use this package as an executable

1. Install it

You can install the package from the command line:


$ pub global activate pubspec_extract

2. Use it

The package has the following executables:


$ pubspec_extract

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  pubspec_extract: ^1.3.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:pubspec_extract/pubspec_extract.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
28
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
64
Learn more about scoring.

We analyzed this package on Jul 14, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.15

Analysis suggestions

Package not compatible with runtime flutter-web on Web

Because:

  • package:pubspec_extract/pubspec_extract.dart that imports:
  • package:dart_style/dart_style.dart that imports:
  • package:dart_style/src/exceptions.dart that imports:
  • package:analyzer/error/error.dart that imports:
  • package:analyzer/src/generated/source.dart that imports:
  • package:analyzer/src/generated/source_io.dart that imports:
  • package:analyzer/src/generated/java_io.dart that imports:
  • dart:io

Package not compatible with runtime js

Because:

  • package:pubspec_extract/pubspec_extract.dart that imports:
  • package:dart_style/dart_style.dart that imports:
  • package:dart_style/src/exceptions.dart that imports:
  • package:analyzer/error/error.dart that imports:
  • package:analyzer/src/generated/source.dart that imports:
  • package:analyzer/src/generated/source_io.dart that imports:
  • package:analyzer/src/generated/java_io.dart that imports:
  • dart:io

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.0 <3.0.0
args ^1.5.0 1.6.0
build ^1.1.5 1.3.0
dart_style ^1.2.9 1.3.6
logging ^0.11.0 0.11.4
path ^1.6.0 1.7.0
pub_semver ^1.4.0 1.4.4
yaml ^2.1.16 2.2.1
Transitive dependencies
_fe_analyzer_shared 5.0.0
analyzer 0.39.13
async 2.4.2
charcode 1.1.3
collection 1.14.13 1.15.0-nullsafety
convert 2.1.1
crypto 2.1.5
csslib 0.16.1
glob 1.2.0
html 0.14.0+3
js 0.6.2
meta 1.2.2 1.3.0-nullsafety
node_interop 1.1.1
node_io 1.1.1
package_config 1.9.3
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.2.0 1.3.0-nullsafety
watcher 0.9.7+15
Dev dependencies
pedantic ^1.8.0 1.9.2
test ^1.9.0