Skip to content

Commit

Permalink
🎨 Add melos and support platform interface (#242)
Browse files Browse the repository at this point in the history
* 🎨 Add melos

* 🎨 Split platform interface

* πŸ› Fix iOS error

* πŸ’š For build iOS and android CI

* 🎨 Add ChangeLog/LICENSE/README for repos

* 🎨 common implement the main plugin

* πŸ“ Update XFile

* 🎨 Update melos config

* πŸ’š Update CI

* πŸ’š Update CI for publish

* πŸ’š Update CI
  • Loading branch information
CaiJingLong authored May 4, 2023
1 parent 06edaf8 commit 4f849a6
Show file tree
Hide file tree
Showing 196 changed files with 2,154 additions and 131 deletions.
27 changes: 22 additions & 5 deletions .github/workflows/publish_on_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,26 @@ jobs:
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Publish
uses: k-paxian/dart-package-publisher@master
- name: Install flutter
uses: subosito/flutter-action@v2
with:
credentialJson: ${{ secrets.CREDENTIAL_JSON }}
flutter: true
skipTests: true
flutter-version: '3.7.7'
channel: 'stable'
- run: flutter --version
- name: Install dependencies
run: flutter pub get
- name: Install melos
run: flutter pub global activate melos
- name: Get packages
run: |
melos bootstrap
melos run get
- name: Try to publish
run: melos publish --yes --dry-run
- name: Write token to local
run: |
mkdir -p ~/.config/dart
echo ${{ secrets.CREDENTIAL_JSON }} > ~/.config/dart/pub-credentials.json
- name: Publish to pub.dev
run: melos publish --yes --no-dry-run

27 changes: 23 additions & 4 deletions .github/workflows/runnable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,14 @@ jobs:
flutter --version
- name: Prepare dependencies
run: flutter pub get
- name: Analyse the repo
run: flutter analyze lib example/lib
- name: Get melos
run: dart pub global activate melos
- name: Init melos
run: |
melos bootstrap
melos run get
- name: Analyze
run: melos run analyze
test_iOS:
needs: analyze
name: Test iOS on ${{ matrix.os }}
Expand All @@ -52,7 +58,14 @@ jobs:
- run: dart --version
- run: flutter --version
- run: flutter pub get
- run: cd example; flutter build ios --no-codesign
- name: Get melos
run: dart pub global activate melos
- name: Init melos
run: |
melos bootstrap
melos run get
- name: Build iOS debug with melos
run: melos run try_build_ios

test_android:
needs: analyze
Expand All @@ -74,4 +87,10 @@ jobs:
- run: flutter --version
- run: flutter pub get
- run: sudo echo "y" | sudo $ANDROID_HOME/tools/bin/sdkmanager "ndk;21.4.7075529"
- run: cd example; flutter build apk --debug
- name: Get melos
run: dart pub global activate melos
- name: Init melos
run: |
melos bootstrap
melos run get
- run: melos run try_build_apk
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
!**/ios/**/default.pbxuser
!**/ios/**/default.perspectivev3
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
*.lock
.env
example/macos/Flutter/ephemeral/flutter_export_environment.sh

pubspec_overrides.yaml
16 changes: 16 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# CONTRIBUTING

Please submit changes to the main branch, and make sure your code is willing to comply with MIT style.

## About development

The repo is manage by [melos][], so you need to install it first.

```bash
dart pub global activate melos
```

Then you can run `melos bootstrap` to install all dependencies.

```bash
melos bootstrap
```

[melos]: https://melos.invertase.dev
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018 caijinglong
Copyright (c) 2023 FlutterCandies

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
39 changes: 39 additions & 0 deletions melos.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: flutter_image_compress
repository: https://github.com/fluttercandies/flutter_image_compress

packages:
- packages/**

scripts:
analyze:
exec: dart analyze .
get:
exec: flutter pub get
test:
exec: flutter test
format:
exec: dart format --set-exit-if-changed .
try_build_apk:
exec: flutter build apk --debug
packageFilters:
fileExists: lib/main.dart
try_build_ios:
exec: |
flutter pub get
flutter build ios --debug --no-codesign
packageFilters:
fileExists: lib/main.dart
cp_files:
exec: |
if [ -f "../../LICENSE" ]; then
cp ../../LICENSE LICENSE
fi
if [ -f "../../README.md" ]; then
cp ../../README.md README.md
fi
sdkPath: auto

command:
version:
releaseUrl: true
44 changes: 44 additions & 0 deletions migrate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Migrate document

## 1.x to 2.x

There are several changes

- The return value of `File` is now changed to the `XFile` type of [cross_file][], so you need to change the code to `XFile`.

1.0:

```dart
final File file = FlutterImageCompress.compressAndGetFile(
file.absolute.path,
targetPath,
quality: 90,
minWidth: 1024,
minHeight: 1024,
rotate: 90,
);
int length = file.lengthSync();
Uint8List buffer = file.readAsBytesSync();
```

2.0:

```dart
final XFile file = await FlutterImageCompress.compressAndGetFile(
file.absolute.path,
targetPath,
quality: 90,
minWidth: 1024,
minHeight: 1024,
rotate: 90,
);
int length = await file.length();
Uint8List buffer = await file.readAsBytes();
```

Other usage of `XFile` to see [document][xfile]

[cross_file]: https://pub.dev/packages/cross_file
[xfile]: https://pub.dev/documentation/cross_file/latest/cross_file/XFile-class.html
40 changes: 40 additions & 0 deletions packages/flutter_image_compress/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
.vscode/

# Flutter/Dart/Pub related
**/doc/api/
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/

# Exceptions to above rules.
!**/ios/**/default.mode1v3
!**/ios/**/default.mode2v3
!**/ios/**/default.pbxuser
!**/ios/**/default.perspectivev3
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
*.lock
.env
example/macos/Flutter/ephemeral/flutter_export_environment.sh
File renamed without changes.
21 changes: 21 additions & 0 deletions packages/flutter_image_compress/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 FlutterCandies

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading

0 comments on commit 4f849a6

Please sign in to comment.