Skip to content

Commit

Permalink
Merge pull request #24 from bamlab/fix-filenames-for-windows
Browse files Browse the repository at this point in the history
Fix filenames for windows
  • Loading branch information
MaximeRougieux committed Apr 2, 2024
2 parents 130b485 + 7be2a65 commit c8559b1
Show file tree
Hide file tree
Showing 27 changed files with 72 additions and 5 deletions.
37 changes: 37 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,40 @@
## 0.5.0

**Breaking changes**

* Remove the semi colon in golden file names to support using the package on a Windows machine.

This is a breaking change for users who have generated golden files with the previous version of the library. The golden file names will now be `preview/${windowConfig.name}-${name.snakeCase}$localSuffix.png` instead of `preview/${windowConfig.name}:${name.snakeCase}$localSuffix.png`.

To resolve this, you can either rename the golden files manually or regenerate them.

To ease the migration, we provide a script that will rename your goldens files to the new format:
```bash
#!/bin/bash

# Function to rename files in directories named "preview"
rename_files_in_preview() {
# Find directories named "preview"
find . -type d -name "preview" | while read -r dir; do
echo "Processing directory: $dir"
# Find files within these directories
find "$dir" -type f | while read -r file; do
# New filename by replacing ':' with '-'
new_name=$(echo "$file" | sed 's/:/-/g')
if [ "$file" != "$new_name" ]; then
mv "$file" "$new_name"
echo "Renamed $file to $new_name"
fi
done
done
}

# Call the function
rename_files_in_preview()
```

You can add the script in a `.sh` file and run it from your project root directory.

## 0.4.1

* fix: Update broken link on README.md
Expand Down
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,36 @@ void main() {
}
```

## Migration to 0.5.x
The 0.5.0 version introduces a new default file name for goldens that doesn't use characters unsupported by Windows file system.

To ease the migration, we provide a script that will rename your goldens files to the new format:
```bash
#!/bin/bash

# Function to rename files in directories named "preview"
rename_files_in_preview() {
# Find directories named "preview"
find . -type d -name "preview" | while read -r dir; do
echo "Processing directory: $dir"
# Find files within these directories
find "$dir" -type f | while read -r file; do
# New filename by replacing ':' with '-'
new_name=$(echo "$file" | sed 's/:/-/g')
if [ "$file" != "$new_name" ]; then
mv "$file" "$new_name"
echo "Renamed $file to $new_name"
fi
done
done
}

# Call the function
rename_files_in_preview()
```

You can add the script in a `.sh` file and run it from your project root directory.

## Additional information

This package is still in early stage of development.
Expand Down
2 changes: 1 addition & 1 deletion example/multi_packages_app/app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages:
path: "../../.."
relative: true
source: path
version: "0.4.1"
version: "0.5.0"
async:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion example/multi_packages_app/theme/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages:
path: "../../.."
relative: true
source: path
version: "0.4.1"
version: "0.5.0"
async:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion example/simple_app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages:
path: "../.."
relative: true
source: path
version: "0.4.1"
version: "0.5.0"
async:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion lib/src/adaptive/adaptive_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ extension Adaptive on WidgetTester {
// Find by its type except if the widget's unique key was given.
byKey != null ? find.byKey(byKey) : find.byType(AdaptiveWrapper),
matchesGoldenFile(
'preview/${windowConfig.name}:${name.snakeCase}$localSuffix.png',
'preview/${windowConfig.name}-${name.snakeCase}$localSuffix.png',
),
);
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: adaptive_test
description: >-
A Flutter package to generate adaptive golden files during widget tests.
version: 0.4.1
version: 0.5.0
homepage: https://github.com/bamlab/adaptive_test
repository: https://github.com/bamlab/adaptive_test

Expand Down

0 comments on commit c8559b1

Please sign in to comment.