This folder contains best practices, guides and some utils for Dart which are very useful with SurfGen
@MbIXjkee TODO
By the bash script ExportModelsGenerator you can create a file, which will export all DTO (or whatever you want).
This script has 2 arguments:
- Path to directory with files which should be exported in umbrella
- Path to Umbrella file
How it works
- Script remove file by Ubrella path (by second arg)
- Script reads all files in directory (by first arg)
- Script extract
filename.ext
from filepathes in the directory - Script create new umbrella (by second arg)
- Script removes file by Umbrella path (by second arg)
- Script reads all files in directory (by first arg)
- Script extracts
filename.ext
from filepathes in the directory - Script exclude all files with patter
filename.g.dart
- Script creates new umbrella (by second arg)
- Script writes each
filename.ext
with templateexport 'filename.ext';
to umbrella
For example lets assume that we have
ExportModelsGenerator.sh
src
├── services
| └─...
└── models
├── model1.dart
├── model2.dart
├── model3.dart
└── model4.dart
So we can automatically generate file like
export 'model1.dart';
export 'model2.dart';
export 'model3.dart';
export 'model4.dart';
Just by command `sh ExportModelsGenerator.sh src/mdoels /src/models/Umbrella.dart
And then we can import
all models by this file
So you can generate different umrellas by this script
Even so, you can create a wrapper
on surfgen
Simple example:
# cmd args
config=$1
pathToApi=$2
name=$3
exporterPath=$4
pathToUmbrella=$5
# generate code
./surfgen generate -c $config $pathToApi $name
# execute post-gen scripts
sh ExportModelsGenerator.sh $exporterPath $pathToUmbrella
and call it
sh surfgen.sh .surfgen.generator.yaml spec/auth/api.yaml auth src/mdoels /src/models/Umbrella.dart