pubspec_version_hook 0.1.0 copy "pubspec_version_hook: ^0.1.0" to clipboard
pubspec_version_hook: ^0.1.0 copied to clipboard

A Dart build hook utility to automatically sync the version in pubspec.yaml to a Dart source file.

pubspec_version_hook #

A Dart build hook utility (powered by Dart Native Assets) to automatically synchronize the version defined in pubspec.yaml to a Dart source file during the build process.

Usage #

  1. Add pubspec_version_hook as a dependency in your pubspec.yaml:

    dependencies:
      hooks: ^2.0.0
      pubspec_version_hook: ^0.1.0
    
  2. Create a build hook at hook/build.dart in your package:

    import 'package:hooks/hooks.dart';
    import 'package:pubspec_version_hook/pubspec_version_hook.dart';
    
    void main(List<String> args) async {
      await build(args, (input, output) async {
        await syncPubspecVersion(input, output);
      });
    }
    

By default, this will read the version string from your pubspec.yaml and output it to lib/src/version.dart as a constant named packageVersion.

You can customize the output path and variable name:

await syncPubspecVersion(
  input,
  output,
  outputRelativePath: 'lib/version.g.dart',
  variableName: 'myCustomVersionConst',
);
0
likes
140
points
13
downloads

Documentation

API reference

Publisher

verified publisheropenci.org

Weekly Downloads

A Dart build hook utility to automatically sync the version in pubspec.yaml to a Dart source file.

License

Apache-2.0 (license)

Dependencies

hooks

More

Packages that depend on pubspec_version_hook