Skip to content
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![Build Status](https://github.com/mathtechstudio/local-storage-cache/actions/workflows/code-integration.yml/badge.svg)](https://github.com/mathtechstudio/local-storage-cache/actions/workflows/code-integration.yml)
[![Code Coverage](https://codecov.io/gh/mathtechstudio/local-storage-cache/graph/badge.svg)](https://codecov.io/gh/mathtechstudio/local-storage-cache)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
![Platforms](https://img.shields.io/badge/platforms-Android%20%7C%20iOS%20%7C%20macOS%20%7C%20Windows-informational)
![Platforms](https://img.shields.io/badge/platforms-Android%20%7C%20iOS%20%7C%20macOS%20%7C%20Windows%20%7C%20Linux%20%7C%20Web-informational)

A comprehensive Flutter package for local storage and caching with advanced features including encryption, multi-space architecture, automatic schema migration, and high-performance query capabilities. Supports Android, iOS, macOS, Windows, Linux, and Web.

Expand Down
2 changes: 2 additions & 0 deletions packages/local_storage_cache/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ analyzer:
await_only_futures: info
unawaited_futures: info
use_of_void_result: ignore
# Ignore path dependency warning for monorepo development
invalid_dependency: ignore

exclude:
- '**/*.g.dart'
Expand Down
1 change: 0 additions & 1 deletion packages/local_storage_cache/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: local_storage_cache
description: A comprehensive Flutter package for managing local storage and caching with advanced features like encryption, TTL, multi-space architecture, and more.
version: 2.0.0
publish_to: none
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The publish_to: none line is being removed here, but the new prepare_publish.sh script also handles its removal. To prevent accidental publishing from a development workspace, it's a common and safe practice to keep publish_to: none in the source-controlled pubspec.yaml files. The release script should be responsible for temporarily removing it before publishing. The script's final instruction to run git checkout packages/*/pubspec.yaml also suggests these changes should be temporary. I recommend restoring this line in all modified pubspec.yaml files.

homepage: https://github.com/mathtechstudio/local-storage-cache
repository: https://github.com/mathtechstudio/local-storage-cache

Expand Down
2 changes: 1 addition & 1 deletion packages/local_storage_cache_android/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ This implementation uses Android Keystore for secure key storage, providing hard

## License

MIT License - see LICENSE file for details.
MIT License - see [LICENSE](LICENSE) file for details.
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@ include: package:very_good_analysis/analysis_options.yaml

linter:
rules:
public_member_api_docs: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Removing the public_member_api_docs: true rule lowers the bar for API documentation. For a library, especially a platform implementation, having comprehensive documentation for all public members is a best practice that greatly helps consumers of the package. Was this removal intentional? If not, I'd recommend re-instating it. This comment also applies to the other platform packages where this rule was removed.

lines_longer_than_80_chars: false

analyzer:
errors:
# Ignore path dependency warning for monorepo development
invalid_dependency: ignore
1 change: 0 additions & 1 deletion packages/local_storage_cache_android/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: local_storage_cache_android
description: Android implementation of the local_storage_cache plugin.
version: 2.0.0
publish_to: none
homepage: https://github.com/mathtechstudio/local-storage-cache

resolution: workspace
Expand Down
2 changes: 1 addition & 1 deletion packages/local_storage_cache_ios/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ This implementation uses iOS Keychain for secure key storage, providing hardware

## License

MIT License - see LICENSE file for details.
MIT License - see [LICENSE](LICENSE) file for details.
6 changes: 5 additions & 1 deletion packages/local_storage_cache_ios/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@ include: package:very_good_analysis/analysis_options.yaml

linter:
rules:
public_member_api_docs: true
lines_longer_than_80_chars: false

analyzer:
errors:
# Ignore path dependency warning for monorepo development
invalid_dependency: ignore
1 change: 0 additions & 1 deletion packages/local_storage_cache_ios/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: local_storage_cache_ios
description: iOS implementation of the local_storage_cache plugin.
version: 2.0.0
publish_to: none
homepage: https://github.com/mathtechstudio/local-storage-cache

resolution: workspace
Expand Down
2 changes: 1 addition & 1 deletion packages/local_storage_cache_linux/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ Biometric authentication is not currently supported on Linux. This feature may b

## License

MIT License - see LICENSE file for details.
MIT License - see [LICENSE](LICENSE) file for details.
6 changes: 5 additions & 1 deletion packages/local_storage_cache_linux/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@ include: package:very_good_analysis/analysis_options.yaml

linter:
rules:
public_member_api_docs: true
lines_longer_than_80_chars: false

analyzer:
errors:
# Ignore path dependency warning for monorepo development
invalid_dependency: ignore
1 change: 0 additions & 1 deletion packages/local_storage_cache_linux/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: local_storage_cache_linux
description: Linux implementation of the local_storage_cache plugin.
version: 2.0.0
publish_to: none
homepage: https://github.com/mathtechstudio/local-storage-cache

resolution: workspace
Expand Down
2 changes: 1 addition & 1 deletion packages/local_storage_cache_macos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ This implementation uses macOS Keychain for secure key storage, providing system

## License

MIT License - see LICENSE file for details.
MIT License - see [LICENSE](LICENSE) file for details.
6 changes: 5 additions & 1 deletion packages/local_storage_cache_macos/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@ include: package:very_good_analysis/analysis_options.yaml

linter:
rules:
public_member_api_docs: true
lines_longer_than_80_chars: false

analyzer:
errors:
# Ignore path dependency warning for monorepo development
invalid_dependency: ignore
1 change: 0 additions & 1 deletion packages/local_storage_cache_macos/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: local_storage_cache_macos
description: macOS implementation of the local_storage_cache plugin.
version: 2.0.0
publish_to: none
homepage: https://github.com/mathtechstudio/local-storage-cache

resolution: workspace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ The platform interface defines methods for:

## License

MIT License - see LICENSE file for details.
MIT License - see [LICENSE](LICENSE) file for details.
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@ include: package:very_good_analysis/analysis_options.yaml

linter:
rules:
public_member_api_docs: true
lines_longer_than_80_chars: false

analyzer:
errors:
# Ignore path dependency warning for monorepo development
invalid_dependency: ignore
2 changes: 1 addition & 1 deletion packages/local_storage_cache_web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ The implementation uses `package:web` with `dart:js_interop`, following Flutter'

## License

MIT License - see LICENSE file for details.
MIT License - see [LICENSE](LICENSE) file for details.
6 changes: 5 additions & 1 deletion packages/local_storage_cache_web/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@ include: package:very_good_analysis/analysis_options.yaml

linter:
rules:
public_member_api_docs: true
lines_longer_than_80_chars: false

analyzer:
errors:
# Ignore path dependency warning for monorepo development
invalid_dependency: ignore
1 change: 0 additions & 1 deletion packages/local_storage_cache_web/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: local_storage_cache_web
description: Web implementation of the local_storage_cache plugin.
version: 2.0.0
publish_to: none
homepage: https://github.com/mathtechstudio/local-storage-cache

resolution: workspace
Expand Down
2 changes: 1 addition & 1 deletion packages/local_storage_cache_windows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ Biometric authentication is not currently supported on Windows. This feature may

## License

MIT License - see LICENSE file for details.
MIT License - see [LICENSE](LICENSE) file for details.
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@ include: package:very_good_analysis/analysis_options.yaml

linter:
rules:
public_member_api_docs: true
lines_longer_than_80_chars: false

analyzer:
errors:
# Ignore path dependency warning for monorepo development
invalid_dependency: ignore
1 change: 0 additions & 1 deletion packages/local_storage_cache_windows/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: local_storage_cache_windows
description: Windows implementation of the local_storage_cache plugin.
version: 2.0.0
publish_to: none
homepage: https://github.com/mathtechstudio/local-storage-cache

resolution: workspace
Expand Down
61 changes: 61 additions & 0 deletions scripts/prepare_publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/bin/bash
# Script to prepare packages for publishing to pub.dev
# This converts workspace dependencies to hosted dependencies

set -e

echo "🔄 Preparing packages for publishing..."

# Function to update pubspec.yaml for publishing
update_pubspec() {
local package=$1
local pubspec="packages/$package/pubspec.yaml"

echo " 📦 Updating $package..."

# Remove 'resolution: workspace' line
sed -i.bak '/^resolution: workspace$/d' "$pubspec"

# Remove 'publish_to: none' line if exists
sed -i.bak '/^publish_to: none$/d' "$pubspec"

# Replace path dependency with hosted
sed -i.bak 's|local_storage_cache_platform_interface:$|local_storage_cache_platform_interface: ^2.0.0|' "$pubspec"
sed -i.bak '/path: \.\.\/local_storage_cache_platform_interface/d' "$pubspec"

# Remove backup file
rm -f "$pubspec.bak"
}

# Update all platform packages
update_pubspec "local_storage_cache_android"
update_pubspec "local_storage_cache_ios"
update_pubspec "local_storage_cache_macos"
update_pubspec "local_storage_cache_windows"
update_pubspec "local_storage_cache_linux"
update_pubspec "local_storage_cache_web"

# Update main package
echo " 📦 Updating local_storage_cache..."
sed -i.bak '/^resolution: workspace$/d' "packages/local_storage_cache/pubspec.yaml"
sed -i.bak '/^publish_to: none$/d' "packages/local_storage_cache/pubspec.yaml"
sed -i.bak 's|local_storage_cache_platform_interface:$|local_storage_cache_platform_interface: ^2.0.0|' "packages/local_storage_cache/pubspec.yaml"
sed -i.bak '/path: \.\.\/local_storage_cache_platform_interface/d' "packages/local_storage_cache/pubspec.yaml"
rm -f "packages/local_storage_cache/pubspec.yaml.bak"

# Update platform interface
echo " 📦 Updating local_storage_cache_platform_interface..."
sed -i.bak '/^resolution: workspace$/d' "packages/local_storage_cache_platform_interface/pubspec.yaml"
sed -i.bak '/^publish_to: none$/d' "packages/local_storage_cache_platform_interface/pubspec.yaml"
rm -f "packages/local_storage_cache_platform_interface/pubspec.yaml.bak"
Comment on lines +9 to +50
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

This script has a few areas for improvement that make it brittle and hard to maintain:

  1. Buggy sed command: The sed command on line 23 to replace the path dependency is incorrect. It doesn't account for leading whitespace and would fail to match. The two separate sed commands could also lead to an invalid pubspec.yaml state during processing.
  2. Hardcoded version: The version ^2.0.0 is hardcoded. This is fragile and will require manual updates whenever the local_storage_cache_platform_interface package version changes.
  3. Code duplication: The logic to update local_storage_cache and local_storage_cache_platform_interface (lines 38-50) is a repetition of the logic inside the update_pubspec function.

I'd suggest refactoring the script to address these points by making it more robust and maintainable. The suggestion below makes the script DRY, dynamically determines the package version, and correctly performs the pubspec.yaml modifications.

# Get platform interface version dynamically
PLATFORM_VERSION=$(grep '^version:' packages/local_storage_cache_platform_interface/pubspec.yaml | awk '{print $2}')
if [ -z "$PLATFORM_VERSION" ]; then
  echo "❌ Could not determine platform interface version." >&2
  exit 1
fi

# Function to update pubspec.yaml for publishing
update_pubspec() {
  local package=$1
  local pubspec="packages/$package/pubspec.yaml"

  echo "  📦 Updating $package..."

  # Remove 'resolution: workspace' line
  sed -i.bak '/^resolution: workspace$/d' "$pubspec"

  # Remove 'publish_to: none' line if exists
  sed -i.bak '/^publish_to: none$/d' "$pubspec"

  # Replace path dependency with hosted, if it exists
  if grep -q "path: ../local_storage_cache_platform_interface" "$pubspec"; then
    # Use a multi-line sed command to replace the dependency block atomically
    sed -i.bak -e "/local_storage_cache_platform_interface:/ { N; s,:\\n\\s*path: \\.\\./local_storage_cache_platform_interface,: ^$PLATFORM_VERSION,; }" "$pubspec"
  fi

  # Remove backup file
  rm -f "$pubspec.bak"
}

# Update all packages by iterating over a list
PACKAGES=(
  "local_storage_cache_android"
  "local_storage_cache_ios"
  "local_storage_cache_macos"
  "local_storage_cache_windows"
  "local_storage_cache_linux"
  "local_storage_cache_web"
  "local_storage_cache"
  "local_storage_cache_platform_interface"
)

for package in "${PACKAGES[@]}"; do
  update_pubspec "$package"
done


echo "✅ All packages prepared for publishing!"
echo ""
echo "📋 Next steps:"
echo " 1. Review changes: git diff"
echo " 2. Publish platform_interface first"
echo " 3. Publish platform implementations"
echo " 4. Publish main package last"
echo ""
echo "⚠️ Remember to restore workspace mode after publishing!"
echo " Run: git checkout packages/*/pubspec.yaml"
Loading