fast 0.3.2

  • Readme
  • Changelog
  • Installing
  • new42

FAST CLI #

Build Status codecov pub package

An incredible command line interface for Flutter.

With this CLI, you can create your custom templates and define how your project will start.

The generated directories and files are defined from the outside in, that is, the users define the templates, the CLI only creates them.

That way you are not forced to use the project structure set by someone else and you can easily modify templates already created.

Features #

  • Templates generator
  • Aplication Scaffold generator
  • Snippet generator for Visual Studio Code
  • Custom commands
  • Standard line commands (Some commands already included in the CLI)
    • install (Add a package to the project dependencies)

Table Of Contents #

Template generator example #

Template example: #

First we define the files that are generated. In this example, the '@Name' tag will be replaced by the '--name' argument when the file is generated.

file: @name_page.dart

import 'package:flutter/material.dart';

class @NamePage extends StatefulWidget {
  @override
  _@NamePageState createState() => _@NamePageState();
}

class _@NamePageState extends State<@NamePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        child: Text("Hello"),
      ),
    );
  }
}

In the same folder as the file above we have the yaml file that defines how the template should be created.

file: template.yaml

#Yaml file for configuring the template.
#The template name
name: page
#The template description
description: Create_flutter_page.
#Path where files should be sent
to: lib/ui/pages/@name
#Arguments to be passed when executing this template
# You can define as many arguments as you want.
args:
  - name
# - other1
# - other2
# - other3

Running the template #

Run this command so that your template is generated.

fast <template_name> <templates_arg1, templates_arg2, templates_arg3....>

example: run on cmd: fast page --name home

Result #

You will now have the following file in the path lib/ui/pages/home

import 'package:flutter/material.dart';

class HomePage extends StatefulWidget {
  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        child: Text("Hello"),
      ),
    );
  }
}

Snippets generator #

A command to generate snippets for the VC Code based on the template files. Reuse the code inserted in the template files to generate snippets for Visual Studio Code.

Example #

First we create the template file and template.yaml. And then set a snippe to be generated.

file: @name_page.dart

import 'package:flutter/material.dart';

class @NamePage extends StatefulWidget {
  @override
  _@NamePageState createState() => _@NamePageState();
}

class _@NamePageState extends State<@NamePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        child: Text("Hello"),
      ),
    );
  }
}

file: template.yaml


name: page
description: Create_flutter_page.
to: lib/ui/pages/@name
# You can define as many arguments as you want.
args:
  - name

# Set up a list of snippests.
snippets:
  # The file containing the snippet code to be generated
  # Reuse the code inserted in one of the template files to generate a VC Code snippets.
  - file: '@name_page.dart'
    prefix: page
    #File lines that will not be included in the snippet.
    excluded:
      - 0
      - 1
# It is possible to create snippests for each template file.
# - file: '@name_other1.dart'
#    prefix: other1
#    excluded:
#      - 0
# - file: '@name_other2.dart'
#    prefix: other2
#    excluded:
#      - 0   

Generate snippests #

Run the command below to generate the snippets.

fast snippets

Result #

It will be possible to use the generated snippet.

alt-text

Scaffold generator example #

Scaffold example: #

file: scaffold.yaml

# The scaffold name.
name: sample
description: A sample scaffold.
author: Pedro Bissonho <pedro.bissonho@gmail.com>

# The folder structure that will be generated inside the 'lib' folder.
structure:
  - ui:
    - pages
    - shared 
    - themes
  - data:
    - models
    - repositorys
  - blocs
# The folder structure that will be generated inside the 'test' folder.
test_structure:
  - ui:
  - data:
  - fixtures:

# The standard dependencies that the project will have.
# Your project will start with all these dependencies.
# If the version is not informed, the version will be configured as the last version available in Dart Pub.
dependencies: 
  koin: 
  flutter_bloc: 

# The standard dev_dependencies that the project will have.
dev_dependencies:
  koin_test:  

Create a APP with the sample scaffold #

Run this command for your application to be created.

fast create --name <app_name> --scafoold <scafoold_name>

run on cmd:

fast create --name myapp --scafoold sample

Result #

An application created with structure and dependencies selects no sample of scaffolding.

alt text

Commands example #

Commands YAML example: #

file: commands.yaml

commands:
  runner: flutter build runner build
  push: git push origin master
  mkdir: mkdir myFolder

Running a command #

fast run <command_name>

example:

fast run runner

Installation #

Install #

Install this package globally. To do this, you must have the Dart SDK installed and configured See the guide referring to the installation of packages globally if you have any doubts on how to do it.

run on cmd: pub global activate fast

Config #

Before using the CLI, it is necessary to configure where your templates, commands and scaffolds are. If these paths are not defined, the CLI will not work correctly, because by default the CLI does not come with resources, it is necessary to create new ones or use resources already created by the community.

In the resources repository you can download a set of resources already created.

Configure the path of the templates that will be used by the CLI.

fast config templates <templates_path>

fast config scaffolds <scaffolds_path>

fast config commands <commands_yaml_file_path>

example

fast config templates /home/pedro/Documentos/fast_resources/templates/

fast config scaffolds /home/pedro/Documentos/fast_resources/scaffolds/

fast config commands /home/pedro/Documentos/fast_resources/

alt-text

License #

license.

0.3.2 #

  • Fixed an error when using the create command in Windows.
  • Fixed an error when using the snippets command in Windows.
  • Updated readme

0.3.0 #

  • Updated readme
  • Improved commands information messages
  • Improved error handler
  • Added snippets generator
  • Setup command rethought.
  • Added the ability to add sub folders to the template
  • Internal improvements

0.1.3 #

  • Updated readme
  • Improved create command information messages
  • Fix setup command erro

0.1.1 #

  • Fix the command 'fast config scaffolds'

0.1.0 #

  • Initial version

Use this package as an executable

1. Install it

You can install the package from the command line:


$ pub global activate fast

2. Use it

The package has the following executables:


$ fast

Use this package as a library

1. Depend on it

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


dependencies:
  fast: ^0.3.2

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:fast/fast.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
60
Overall:
Weighted score of the above. [more]
42
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.13

Analysis suggestions

Package not compatible with runtime flutter-web on web

Because of the import of dart:io via the import chain package:fast/fast.dartpackage:fast/commands/flutter/create_template.dartpackage:fast/commands/command_base.dartpackage:fast/logger.dartpackage:logger/logger.dartdart:io

Package not compatible with runtime web

Because of the import of dart:io via the import chain package:fast/fast.dartpackage:fast/commands/flutter/create_template.dartpackage:fast/commands/command_base.dartpackage:fast/logger.dartpackage:logger/logger.dartdart:io

Health suggestions

Fix lib/core/directory/directory.dart. (-1 points)

Analysis of lib/core/directory/directory.dart reported 2 hints:

line 63 col 34: This function has a return type of 'Future<List

line 77 col 34: This function has a return type of 'Future<List

Fix lib/actions/creater_flutter_action.dart. (-0.50 points)

Analysis of lib/actions/creater_flutter_action.dart reported 1 hint:

line 18 col 8: Unused import: 'package:path/path.dart'.

Format lib/actions/run_command.dart.

Run dartfmt to format lib/actions/run_command.dart.

Fix additional 6 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/actions/setup_action.dart (Run dartfmt to format lib/actions/setup_action.dart.)
  • lib/actions/setup_yaml.dart (Run dartfmt to format lib/actions/setup_yaml.dart.)
  • lib/commands/flutter/unistall_package.dart (Run dartfmt to format lib/commands/flutter/unistall_package.dart.)
  • lib/replacer.dart (Run dartfmt to format lib/replacer.dart.)
  • lib/services/packages_service.dart (Run dartfmt to format lib/services/packages_service.dart.)
  • lib/snippet_manager.dart (Run dartfmt to format lib/snippet_manager.dart.)

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (logger).

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and fast.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.2 <3.0.0
args ^1.5.2 1.6.0
flunt_dart ^0.4.0 0.4.0
http ^0.12.1 0.12.1
json2yaml ^1.0.1 1.0.1
logger ^0.7.0+2 0.7.0+2 0.9.1
path ^1.6.4 1.7.0
plain_optional ^0.1.3 0.1.3
process_run ^0.10.3 0.10.10+2
pubspec_yaml ^2.0.1 2.0.1
yaml ^2.2.1 2.2.1
Transitive dependencies
charcode 1.1.3
collection 1.14.13
functional_data 0.3.0
http_parser 3.1.4
io 0.3.4
meta 1.1.8
pub_semver 1.4.4
source_span 1.7.0
string_scanner 1.0.5
sum_types 0.2.1+2
term_glyph 1.1.0
typed_data 1.2.0
Dev dependencies
pedantic ^1.9.0 1.9.0 1.9.1
test ^1.14.4
test_coverage ^0.4.1