Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
706819d
initial commit
JeevanGeek Oct 4, 2022
021224b
add bricks for flutter starter
JeevanGeek Oct 4, 2022
9e541b9
add cli for flutter starter
JeevanGeek Oct 4, 2022
fb77cf7
add api service option
JeevanGeek Oct 6, 2022
e5c5354
update brick template
JeevanGeek Oct 7, 2022
b90f171
add interactive cli
JeevanGeek Oct 7, 2022
22a3f19
update template
JeevanGeek Oct 10, 2022
b61c29e
handle exceptions
JeevanGeek Oct 10, 2022
0ac72e8
update readme
JeevanGeek Oct 10, 2022
f5d0bf4
update readme
JeevanGeek Oct 11, 2022
109b59b
add flag for test cases
JeevanGeek Oct 11, 2022
839ba61
setup cli
JeevanGeek Oct 11, 2022
2b6bdf0
update brick path
JeevanGeek Oct 11, 2022
93ea8be
update cli: generating project from git
JeevanGeek Oct 17, 2022
c20b51a
update readme
JeevanGeek Oct 17, 2022
788aab3
Merge pull request #3 from GeekyAnts/cli
geekruchika Oct 17, 2022
67cec6f
add license and changelog
JeevanGeek Oct 18, 2022
88b84e8
Merge pull request #4 from GeekyAnts/deploy
geekruchika Oct 18, 2022
ce178ea
fix pub points
JeevanGeek Oct 20, 2022
6a38340
Merge pull request #5 from GeekyAnts/pub-score
geekruchika Oct 20, 2022
d7ad0d8
add riverpod state management
JeevanGeek Oct 21, 2022
5a44fc9
update readme and changelog
JeevanGeek Oct 21, 2022
9a24c3b
Merge pull request #6 from GeekyAnts/state-management
geekruchika Oct 21, 2022
6c884e9
add command to upgrade project
JeevanGeek Oct 25, 2022
c72545a
add steps and path
JeevanGeek Oct 28, 2022
7d051ef
Merge pull request #8 from GeekyAnts/steps
geekruchika Nov 2, 2022
65c8e8e
Merge pull request #7 from GeekyAnts/project-upgrade
geekruchika Nov 2, 2022
21ce698
fix: test case issue
JeevanGeek Nov 2, 2022
f11007b
update readme and changelog
JeevanGeek Nov 2, 2022
54a1a95
Merge pull request #9 from GeekyAnts/deploy
geekruchika Nov 2, 2022
3eab7ea
add graphql api service
JeevanGeek Nov 4, 2022
bb58df2
update readme and changelog
JeevanGeek Nov 7, 2022
416a32f
Merge pull request #10 from GeekyAnts/graphql
geekruchika Nov 18, 2022
c43bec3
Merge pull request #11 from GeekyAnts/deploy
geekruchika Nov 18, 2022
f243ddc
upgrade project to dart 3.0
JeevanGeek Jun 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.dart_tool/
.packages
build/
pubspec.lock
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# 0.0.1-dev.4

- Added graphql api service.

# 0.0.1-dev.3

- Added project upgrade command.
- Added output-directory path option.

# 0.0.1-dev.2

- Add support for riverpod.

# 0.0.1-dev.1

- Initial development release.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 GeekyAnts

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
186 changes: 121 additions & 65 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,92 +1,148 @@
# flutter-starter-cli
# Flutter Starter CLI

The `Flutter Starter CLI` is a very useful tool that provides commands for the ease of setting up a Flutter project from scratch.

## Introduction

## Getting started
`Flutter Starter CLI` is written in the Dart programming language.\
While working with the Flutter projects we have to write the same repetitive code multiple times but using this CLI, we can create a Flutter template on the fly.\
Also, the basic structure of all the tests in Flutter is the same. So this CLI also provides a basic starter pack for the Flutter test as well.

To make it easy for you to get started with GitLab, here's a list of recommended next steps.
Out of the box, `Flutter Starter CLI` includes:-

Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
- ✅ **State Management**
- BLoC - BLoC is a popular design/architectural pattern that is used to separate the logic from the UI.
- RiverPod - A state-management library that catches programming errors at compile time and ensures that the code is testable.
- ✅ **API-Services**
- Dio - A powerful HTTP client for Dart, which supports Interceptors, Global configuration, FormData, Request Cancellation, File downloading, Timeout etc.
- Http - A composable, Future-based library for making HTTP requests.
- Graphql - A standalone GraphQL client for Flutter, bringing all the features from a modern GraphQL client to one easy to use package.
- ✅ **Basic Setup**
- Themes - Themes are used to share colors and font styles throughout an app.
- Localization - The project provides support for multiple languages like English, Spanish and French.
- Routing - Go_Router is used to provide a convenient, URL-based API for navigating between different screens.
- ✅ **Testing**
- Unit - A unit test tests a single function, method, or class.
- Widget - A widget test tests a single widget.
- Integration - An integration test tests a complete app or a large part of an app.

## Add your files
## Dependencies

- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
Currently, the `Flutter Starter CLI` depends on the following packages:-

```
cd existing_repo
git remote add origin https://git.geekyants.com/ruchika/flutter-starter-cli.git
git branch -M main
git push -uf origin main
```

## Integrate with your tools

- [ ] [Set up project integrations](https://git.geekyants.com/ruchika/flutter-starter-cli/-/settings/integrations)

## Collaborate with your team
| Package | Version | Description |
| ------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------- |
| args | 2.3.1 | Parses raw command-line arguments into a set of options and values. |
| mason_logger | 0.2.2 | Simple logging library for CLI requests. |
| path | 1.8.2 | The path package provides common operations for manipulating paths: joining, splitting, normalizing, etc. |
| pub_updater | 0.2.2 | A Dart package which enables checking whether packages are up to date and supports updating them. |
| flutter_lints | 2.0.1 | This package contains a recommended set of lints for Flutter apps, packages, and plugins to encourage good coding practices. |

- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
## Getting Started

## Test and Deploy
Activate globally via:

Use the built-in continuous integration in GitLab.

- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)

***

# Editing this README
```sh
dart pub global activate flutter_starter_cli
```

When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
## Usage

## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
In the root of your application, run the following commands:

## Name
Choose a self-explaining name for your project.
```sh
# Show CLI version
$ flutter_starter_cli --version
```

## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
```sh
# Show usage help
$ flutter_starter_cli --help
```

## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
```sh
# To create project
$ flutter_starter_cli create

## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
# Then follow instructions
```

## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
```sh
# Shorthand to create project
$ flutter_starter_cli create <project_name> --state=<state_management> --api=<api_service> -g -t

## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
# Available API services (dio, http, graphql)
# Available State management (bloc, riverpod)
```

## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
```sh
# To upgrade project
$ flutter_starter_cli project upgrade
```

## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
## Complete Usage

The complete usage of the create command with options and flags.

```sh
➜ ~ flutter_starter_cli create
Creates a new flutter starter project.

Usage: flutter_starter_cli create <project_name>
-h, --help Print this usage information.
--desc The description for the project.
(defaults to "A New Flutter Project.")
--org The organization for the project.
(defaults to "com.example")
-p, --path The directory path for the project.
-s, --state The state management for the project.
[bloc, riverpod]
-a, --api The API service for the project.
[dio, http, graphql]
-t, --[no-]test Setup Test Cases.
-g, --[no-]git Initialize Git Repository.

Run "flutter_starter_cli help" to see global options.
```

## Contributing
State if you are open to contributions and what your requirements are for accepting them.
## Directory Structure

For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
The complete structure of the newly created project directory looks like this:

You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
```
.
├── android
├── assets
├── integration_test
├── ios
└── lib
├── api_sdk
├── config
├── l10n
├── routes
├── screens
├── shared
├── themes
├── utils
├── widgets
├── app.dart
├── common_export.dart
├── main.dart
├── linux
├── macos
├── test
├── web
├── windows
├── .gitignore
├── analysis_options.yaml
├── l10n.yaml
├── pubspec.lock
├── pubspec.yaml
└── README.md
```

## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
## Demo

## License
For open source projects, say how it is licensed.
A demo video to illustrate how to use the `Flutter_Starter_CLI`

## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
![demo](./flutter-starter-cli.gif)
1 change: 1 addition & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include: package:flutter_lints/flutter.yaml
12 changes: 12 additions & 0 deletions bin/flutter_starter_cli.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import 'dart:io';

import 'package:flutter_starter_cli/src/command_runner.dart';

Future<void> main(List<String> args) async {
await _flushThenExit(await FlutterStarterCliCommandRunner().run(args));
}

Future<void> _flushThenExit(int status) {
return Future.wait<void>([stdout.close(), stderr.close()])
.then<void>((_) => exit(status));
}
9 changes: 9 additions & 0 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Example

```sh
# Activate cli
dart pub global activate flutter_starter_cli

# See usage
flutter_starter_cli --help
```
Binary file added flutter-starter-cli.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions lib/flutter_starter_cli.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/// ```sh
/// # Activate cli
/// dart pub global activate flutter_starter_cli
///
/// # See usage
/// flutter_starter_cli --help
/// ```
library flutter_starter_cli;
105 changes: 105 additions & 0 deletions lib/src/cli/actions.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import 'dart:io';

import 'package:flutter_starter_cli/src/cli/cli.dart';
import 'package:flutter_starter_cli/src/utils.dart';

class Actions {
static Future<void> _addStep(message) async {
Status.start('Adding $message...');
await Future.delayed(const Duration(seconds: 1));
Status.complete('$message Added!!!');
}

static Future<void> createProject(String path, String state) async {
Status.start('Project Creating...');
try {
await Cli.cloneProject(path, state);
Status.complete('Project Created!!!');
} catch (_) {
Status.fail('Project Creation Failed!!!');
}
}

static Future<void> generateFiles(
String path,
String name,
String desc,
String org,
String api,
bool test,
) async {
Status.start('Running Basic Setup...');
try {
await Cli.removeFiles(path, api, test);
Status.complete('Basic Setup Completed!!!');
} catch (_) {
Status.fail('Setup Failed.');
}
await Future.wait(
Directory(path)
.listSync(recursive: true)
.whereType<File>()
.map((_) async {
var file = _;
try {
final contents = await file.readAsString();
file = await file.writeAsString(contents
.replaceAll('flutter_starter', name)
.replaceAll('Flutter Starter', name)
.replaceAll('A new Flutter project.', desc)
.replaceAll('com.example', org)
.replaceAll(
'api_sdk/dio_api_sdk.dart', 'api_sdk/${api}_api_sdk.dart'));
} catch (_) {}
}),
);
await _addStep('State Management');
await _addStep('API Service');
await _addStep('Localization');
await _addStep('Routes');
await _addStep('Themes');
if (test) await _addStep('Test Cases');
}

static Future<void> setupPackages(String path, String api, bool test) async {
Status.start('Adding Dependencies...');
try {
await Cli.removePackages(path, api, test);
Status.complete('Dependencies Added!!!');
} catch (_) {
Status.fail('Pub Add Failed.');
}
}

static Future<void> getPackages(String path) async {
Status.start('Running Pub Get...');
try {
await Cli.getPackages(path);
Status.complete('Pub Get Completed!!!');
} catch (_) {
Status.fail('Pub Get Failed.');
}
}

static Future<void> initializeGit(String path, bool git) async {
if (git) {
Status.start('Initialize Git...');
try {
await Cli.initializeGit(path);
Status.complete('Git Initialized!!!');
} catch (_) {
Status.fail('Git Not Installed.');
}
}
}

static Future<void> upgradeProject(String path, bool major) async {
Status.start('Upgrading Project...');
try {
await Cli.upgradeProject(path, major);
Status.complete('Project Upgraded!!!');
} catch (_) {
Status.fail('Project Upgrade Failed.');
}
}
}
Loading