Skip to content

Commit

Permalink
📝 prepare for version 0.4.0
Browse files Browse the repository at this point in the history
Signed-off-by: birjuvachhani <[email protected]>
  • Loading branch information
BirjuVachhani committed Mar 28, 2020
1 parent f77755c commit b270413
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 7 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 0.4.0

- Spider now allows to specify multiple paths to generate dart
references under a single class.
- Spider now generates test cases for dart references to make sure that
the file is present in the project.

## 0.3.6

- Fixed issue of creating references for files like `.DS_Store`
Expand Down
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,41 @@ 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.

## Multi-path configuration

From Spider `v0.4.0`, multiple paths can be specified for a single group
to collect references from multiple directories and generate all the
references under single dart class.

#### Example
```yaml
groups:
- paths:
- assets/images
- assets/more_images/
class_name: Images
package: res
types: [ .png, .jpg, .jpeg, .webp, .webm, .bmp ]
```

By using `paths`, multiple source directories can be specified. Above
example will generate references from `assets/images` and
`assets/more_images/` under a single dart class named `Images`.

## Generating Tests

Spider `v0.4.0` adds support for generating test cases for generated
dart references to make sure that the asset file is present in the
project. These tests can also be run on CI servers. To enable tests
generation, specify `generate_tests` flag in `spider.yaml` or
`spider.json` configuration file as shown below.

```yaml
generate_tests: true
```
This flag will indicate spider to generate tests for all the generated
dart references.

## Enable Verbose Logging

Spider prefers not to overwhelm terminal with verbose logs that are
Expand Down
10 changes: 5 additions & 5 deletions lib/src/dart_class_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class DartClassGenerator {
verbose(
'Asset - ${path.basename(file.path)} is ${valid ? 'selected' : 'not selected'}');
return valid;
}).toList();
})?.toList();

if (files.isEmpty) {
info('Directory $dir does not contain any assets!');
Expand Down Expand Up @@ -148,8 +148,8 @@ class DartClassGenerator {
assetName: Formatter.formatName(name),
assetPath: Formatter.formatPath(properties[name]));
})
.toList()
.join();
?.toList()
?.join();

verbose('Constructing dart class for ${group.className}');
final content =
Expand All @@ -168,8 +168,8 @@ class DartClassGenerator {
final tests = properties.keys
.map<String>(
(key) => getTestCase(group.className, Formatter.formatName(key)))
.toList()
.join();
?.toList()
?.join();
verbose('generating test dart code');
final content = getTestClass(
project: projectName,
Expand Down
2 changes: 1 addition & 1 deletion lib/src/spider_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class SpiderConfiguration {
data['generate_tests'] = generateTests;
data['project_name'] = projectName;
if (groups != null) {
data['groups'] = groups.map((v) => v.toJson()).toList();
data['groups'] = groups.map((v) => v.toJson())?.toList();
}
return data;
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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.6
version: 0.4.0
homepage: https://github.com/BirjuVachhani/spider

environment:
Expand Down

0 comments on commit b270413

Please sign in to comment.