pubm 0.0.2-alpha copy "pubm: ^0.0.2-alpha" to clipboard
pubm: ^0.0.2-alpha copied to clipboard

A Dart command line tool to help with managing pubspec dependencies.

Overview #

PUBM, short for Pubspec Manager, is a Dart-Command Line tool created to manage multiple versions of pubspec.yaml files in a single project. This tool helps in merging multiple pubspec.yaml files into a single pubspec.yaml file as per the selected flavor.

📋 Installation #

To install the pubm package, add it as a new dev dependency in your pubspec.yaml file. Run the following command in your terminal:

PS c:\src\flutter_project> dart pub add --dev pubm

For Flutter projects, use:

PS c:\src\flutter_project> flutter pub add --dev pubm

📋 Usage #

To manage different versions of pubspec.yaml files, create a new file for each flavor with the name pubspec_<flavor>.yaml. When the following command is executed, the pubspec.yaml file is updated with the contents of the pubspec_<flavor>.yaml file. This can be used to update, change, or add dependencies and their respective versions, as well as Flutter fonts.

PS c:\src\flutter_project> dart run pubm:manage -f <flavor>

Use the -v flag to print detailed logs (verbose logs) in the console.console.

PS c:\src\flutter_project> dart run pubm:manage -f <flavor> -v

📋 Example: pubpsec_dev.yaml #

Here's an example of a flavor-specific pubspec.yaml file for a 'dev' flavor:

description: dev version of pubspec.yaml
version: 0.0.1-dev

dependencies:
  example_dependency: 
   path: example/dependency

dev_dependencies:
  lints: ^2.1.1
  

flutter:
  fonts:
    - family: font1
      fonts:
        - asset: dev/font1/700.ttf
          weight: 700
        - asset: dev/font1/600.ttf
          weight: 600
        - asset: dev/font1/500.ttf
          weight: 500
        - asset: dev/font1/400.ttf
          weight: 400
    - family: font2
      fonts:
        - asset: dev/font2/700.ttf
          weight: 700
        - asset: dev/font2/600.ttf
          weight: 600
        - asset: dev/font2/500.ttf
          weight: 500
        - asset: dev/font2/400.ttf
          weight: 400

The above values present in the pubspec_

📋 Example: pubspec.yaml #

Here's an example of the main pubspec.yaml file:

name: pubm
description: Actual description
version: 0.0.1

environment:
  sdk: ^3.0.0

dependencies:
  cupertino_icons: ^1.0.2

flutter:
  uses-material-design: true
  generate: true
  fonts:
    - family: font1
      fonts:
        - asset: actual/font1/700.ttf
          weight: 700
        - asset: actual/font1/600.ttf
          weight: 600
        - asset: actual/font1/500.ttf
          weight: 500
        - asset: actual/font1/400.ttf
          weight: 400
    - family: font2
      fonts:
        - asset: actual/font2/700.ttf
          weight: 700
        - asset: actual/font2/600.ttf
          weight: 600
        - asset: actual/font2/500.ttf
          weight: 500
        - asset: actual/font2/400.ttf
          weight: 400

After running the below command, the output pubspec.yaml file will be as follows:

Command:
dart run pubm:manage -f dev
Output
name: pubm
description: dev version of pubspec.yaml
version: 0.0.1-dev

environment:
  sdk: ^3.0.0

dependencies:
  # normal dependencies
  cupertino_icons: ^1.0.2
  # path related dependencies
  example_dependency: 
   path: example/dependency

dev_dependencies:
  # normal dev_dependencies
  lints: ^2.1.1

flutter:
  uses-material-design: true
  generate: true
  fonts:
    - family: font1
      fonts:
        - asset: dev/font1/700.ttf
          weight: 700
        - asset: dev/font1/600.ttf
          weight: 600
        - asset: dev/font1/500.ttf
          weight: 500
        - asset: dev/font1/400.ttf
          weight: 400
    - family: font2
      fonts:
        - asset: dev/font2/700.ttf
          weight: 700
        - asset: dev/font2/600.ttf
          weight: 600
        - asset: dev/font2/500.ttf
          weight: 500
        - asset: dev/font2/400.ttf
          weight: 400

By default, this tool also sorts the dependencies and dev_dependencies in alphabetical order by category. The categories are as follows:

  1. git related dependencies
  2. path related dependencies
  3. normal dependencies
  4. hosted dependencies
  5. sdk dependencies

Support #

This plugin is free to use and currently in its early stages of development. We plan to add many more features soon. Please visit the Github Project to know about the upcoming feature and fixes. If you encounter any issues or would like additional features, please raise an issue in the GitHub repository.

Feel free to contribute to this project by creating a pull request with a clear description of your changes.

If this plugin was useful to you, helped you in any way, saved you a lot of time, or you just want to support the project, I would be very grateful if you buy me a cup of coffee. Your support helps maintain and improve this project.

Buy Me A Coffee