Giter Site home page Giter Site logo

dfs's Introduction

DFS - Dart Flutter Scripts

Warning: everything is WIP.

A collection of useful scripts for dart or flutter projects.

The scripts can be executed in the working directory of any dart or flutter project.

Installation:

Until the package is published to pub.dev, it can be installed as follow:

[~] dart pub global activate --source git https://github.com/osaxma/dfs.git

To run any script:

[~/path/to/project] dfs <script-command>

Note: each script will only work in the current working directory (i.e. one cannot pass a path to a different directory -- at least for now).

Each <script-command> is shown below under the available scripts.

Available Scripts

  • Find Unused Packages (status: MVP)

    Area: project hygien
    command: find-unused-packages
    alias: fup

    Description:
    with the help of dart's analyzer and pubspec packages, the script inpset both the pubspec.yaml file and all dart files within lib to find any unused dependencies.

    Sample Output:

    [~/cwd] dfs find-unused-packages
        The following packages are not used anywhere in the lib directory. If they are used
        elsewhere (e.g. /test), consider moving them to `dev_dependencies` in `pubspec.yaml`
            - code_builder
            - dart_style
            - logging
    

  • Find Unused Top Level Declaration (status: MVP)

    Area: project hygiene
    command: find-unused-top-level
    alias: futl

    Finds unused top-level elements (classes, typedefs, getters, setters, functions and fields). This useful for dart/flutter projects that are not packages.

    Sample output

    [~/cwd]$ dart run bin/dfs.dart futl
        finding unused top level declarations...  
        The following top level declarations are not used anywhere 
            - /cwd/lib/src/version.dart:7:7
            - /cwd/lib/src/common/ast_utils.dart:7:9

  • Generate Data Classes (status: MVP)

    Area: utility
    command: generate-data-classes
    alias: gdc

    Generate the following for an existing class (in place):

    • copyWith method.
    • serialization methods (toMap/toJson) and desirialization factories (fromMap/fromJson).
    • Equality (operator ==) and hashcode.

    See how the data looks like before and after running the script at:


    The input data is read by parsing the Abstract Syntax Tree (AST) using the analyzer package, and then the data class is built using the code builder package.

Ideas for future scripts

  • Change Project Name (status: TBD)

    Area: pain
    command: TBD
    alias: TBD

    This is mainly for Flutter, and especially for multiplatform code where the name has to be changed in various places.


  • Run Script (status: TBD)

    Area: utility
    command: run
    alias: N/A

    [~/cwd] dfs run <script> 
    

    Where <script> is defined in pubspec.yaml

        script:
            build: flutter pub run build_runner build --delete-conflicting-outputs
            data: dfs generate-data-classes --endsWith="_data.dart" --directory="lib"

  • Get Packages For All (status: TBD)

    Area: utility
    command: TBD
    alias: TBD

    [~/cwd] dfs get packages --all
    

    Or

    [~/cwd] dfs get all
    

    Run dart pub get or flutter packages get for all packages within a monorepo or a repo with multiple packages.

dfs's People

Contributors

lukepighetti avatar osaxma avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.