diff --git a/CHANGELOG.md b/CHANGELOG.md index 3255939..d04512c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 0.3.1 + +- Fix version command. +- Formatted outputs and added more verbose logs. +- Added config validation before processing assets. + ## 0.3.0 - Add support for categorization by file types. diff --git a/README.md b/README.md index b2bb27f..ec8b29a 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,8 @@ # Spider A small dart library to generate Assets dart code from assets folder. -It generates dart class with static const variables in it which can be used to reference -the assets safely anywhere in the flutter app. +It generates dart class with static const variables in it which can +be used to reference the assets safely anywhere in the flutter app. ### Example @@ -30,12 +30,15 @@ class Assets { } ``` -This method allows no error scope for string typos. Also, it provides auto-complete -in the IDE which comes very handy when you have large amount of assets. +This method allows no error scope for string typos. Also, it provides +auto-complete in the IDE which comes very handy when you have +large amount of assets. ## Installation -This is package is an independent library that is not linked to your project. So there's no need to add it to your flutter project as it works as a global command line tool for all of your projects. +This is package is an independent library that is not linked to your +project. So there's no need to add it to your flutter project as it +works as a global command line tool for all of your projects. ```shell pub global activate spider @@ -49,76 +52,39 @@ spider --help ## Usage -### Using default configuration -By default, Spider will look for assets in 'assets' folder and will generate Dart -class with name `Assets` in 'lib/res/assets.dart' file. - -#### Default Configs -```yaml -path: assets -class_name: Assets -package: res -``` - -### Categorizing by File Extension - -By default, Spider allows any file to be referenced in the dart code. but you can change that -behavior. You can specify which files you want to be referenced. - -```yaml -path: assets -class_name: Assets -package: res -types: [ jpg, png, jpeg, webp, bmp, gif ] -``` - -### Use Prefix -You can use prefixes for names of the generated dart references. Prefixes will be -attached to the formatted reference names. - -```yaml -path: assets -class_name: Assets -package: res -prefix: ic -``` - -##### Output - -```dart -class Assets { - static const String icCamera = 'assets/camera.png'; - static const String icLocation = 'assets/location.png'; -} -``` - -### Customize Configuration -To use custom configurations, Spider searches for a yaml file named 'spider.yaml' or 'spider.yml' in the -root directory of the flutter project. see default configs block for information on available configurations. - #### Create Configuration File -Spider provides a very easy and straight forward way to create a configuration file. -Execute following command and it will create a configuration file with default configurations in it. +Spider provides a very easy and straight forward way to create +a configuration file. +Execute following command and it will create a configuration file +with default configurations in it. ```shell spider create ``` -Now you can modify available configurations and Spider will use those configs when generating dart code. +Now you can modify available configurations and Spider will use +those configs when generating dart code. #### Use JSON config file -Though above command creates `YAML` format for config file, spider also supports `JSON` format for config file. Use this command to create `JSON` config file instead of `YAML`. +Though above command creates `YAML` format for config file, spider +also supports `JSON` format for config file. Use this command to +create `JSON` config file instead of `YAML`. ```shell spider create --json ``` -No matter which config format you use, `JSON` or `YAML`, spider automatically detects it and uses it for code generation. +No matter which config format you use, `JSON` or `YAML`, spider +automatically detects it and uses it for code generation. -see help for more information: -```shell -spider create --help +Here's the default configuration that will be in the config file: + +```yaml +groups: + - path: assets/images + class_name: Images + package: res ``` ### Generate Code @@ -130,7 +96,8 @@ spider build ``` ### Watch Directory -Spider can also watch given directory for changes in files and rebuild dart code automatically. Use following command to watch for changes: +Spider can also watch given directory for changes in files and rebuild +dart code automatically. Use following command to watch for changes: ```shell spider build --watch @@ -141,11 +108,54 @@ see help for more information: spider build --help ``` +### Categorizing by File Extension + +By default, Spider allows any file to be referenced in the dart code. +but you can change that behavior. You can specify which files you want to be referenced. + +```yaml +path: assets +class_name: Assets +package: res +types: [ jpg, png, jpeg, webp, bmp, gif ] +``` + +### Use Prefix +You can use prefixes for names of the generated dart references. +Prefixes will be attached to the formatted reference names. + +```yaml +path: assets +class_name: Assets +package: res +prefix: ic +``` + +##### Output + +```dart +class Assets { + static const String icCamera = 'assets/camera.png'; + static const String icLocation = 'assets/location.png'; +} +``` + +### Customize Configuration +To use custom configurations, Spider searches for a yaml file named +'spider.yaml' or 'spider.yml' in the +root directory of the flutter project. see default configs block for +information on available configurations. + ## Advanced Configuration -Spider provides supports for multiple configurations and classifications. If you wanna group your assets by module, type or anything, you can do that using `groups` in spider. +Spider provides supports for multiple configurations and classifications. +If you wanna group your assets by module, type or anything, you can do +that using `groups` in spider. ### Example -Suppose you have both vector(SVGs) and raster images in your project and you want to me classified separately so that you can use them with separate classes. You can use groups here. Keep your vector and raster images in separate folder and specify them in the config file. +Suppose you have both vector(SVGs) and raster images in your project +and you want to me classified separately so that you can use them with +separate classes. You can use groups here. Keep your vector and raster +images in separate folder and specify them in the config file. `spider.yaml` ```yaml @@ -158,9 +168,14 @@ groups: package: res ``` -Here, first item in the list indicates to group assets of `assets/images` folder under class named `Images` and the second one indicates to group assets of `assets/vectors` directory under class named `Svgs`. +Here, first item in the list indicates to group assets of +`assets/images` folder under class named `Images` and the second +one indicates to group assets of `assets/vectors` directory under +class named `Svgs`. -So when you refer to `Images` class, auto-complete suggests raster images only and you know that you can use them with `AssetImage` and other one with vector rendering library. +So when you refer to `Images` class, auto-complete suggests raster +images only and you know that you can use them with `AssetImage` and +other one with vector rendering library. ## License ``` diff --git a/lib/src/version.dart b/lib/src/version.dart index 6956fe2..35a3412 100644 --- a/lib/src/version.dart +++ b/lib/src/version.dart @@ -1,2 +1,2 @@ // Generated code. Do not modify. -const packageVersion = '0.3.0'; +const packageVersion = '0.3.1'; diff --git a/pubspec.yaml b/pubspec.yaml index 341934d..c9ad4f1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: spider description: A small dart command-line tool for generating dart references of assets from the assets folder. -version: 0.3.0 +version: 0.3.1 homepage: https://github.com/BirjuVachhani/spider environment: