Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix filenames for windows #24

Merged
merged 5 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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.
T-moz marked this conversation as resolved.
Show resolved Hide resolved

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