-
-
Notifications
You must be signed in to change notification settings - Fork 1
fix(ci): disable line length rule for platform packages #8
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
Changes from all commits
cb6ef28
cba5e0b
4245cae
3f210ba
febc6be
acc8c9c
55ce6ff
7298a69
7e6a224
4ef195e
f606c65
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,5 +2,9 @@ include: package:very_good_analysis/analysis_options.yaml | |
|
|
||
| linter: | ||
| rules: | ||
| public_member_api_docs: true | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removing the |
||
| lines_longer_than_80_chars: false | ||
|
|
||
| analyzer: | ||
| errors: | ||
| # Ignore path dependency warning for monorepo development | ||
| invalid_dependency: ignore | ||
| 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This script has a few areas for improvement that make it brittle and hard to maintain:
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 # 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" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
publish_to: noneline is being removed here, but the newprepare_publish.shscript also handles its removal. To prevent accidental publishing from a development workspace, it's a common and safe practice to keeppublish_to: nonein the source-controlledpubspec.yamlfiles. The release script should be responsible for temporarily removing it before publishing. The script's final instruction to rungit checkout packages/*/pubspec.yamlalso suggests these changes should be temporary. I recommend restoring this line in all modifiedpubspec.yamlfiles.