From f14d5574444a5a1f412111e3bc871edb8362f44f Mon Sep 17 00:00:00 2001 From: Prasanna Anbazhagan Date: Sat, 20 Jan 2024 16:31:13 +0530 Subject: [PATCH] Add github action to deploy --- .github/workflows/dart.yml | 79 +++++++++++++------------------ lib/domain/models/investment.dart | 11 +++-- pubspec.lock | 74 ++++++++++++++++------------- pubspec.yaml | 22 ++++----- 4 files changed, 92 insertions(+), 94 deletions(-) diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index 6213850..a5c6d9d 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -1,57 +1,42 @@ -name: Build & deploy - +name: Flutter Web on: push: branches: - master - pull_request: - branches: - - master - jobs: build: - name: Build + name: Build Web + env: + my_secret: ${{secrets.commit_secret}} runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Install Flutter - uses: subosito/flutter-action@v1 - with: - flutter-version: '2.0.5' - - - name: Get dependencies - run: flutter pub get - - - name: Test project - run: flutter test - - - name: Build release project - run: flutter build web + - name: Checkout repository + uses: actions/checkout@v2 - - name: Upload production-ready build files - uses: actions/upload-artifact@v2 - with: - name: production-files - path: ./build/web - - deploy: - name: Deploy - needs: build - runs-on: ubuntu-latest - if: github.ref == 'refs/heads/master' - - steps: - - name: Download artifact - uses: actions/download-artifact@v2 - with: - name: production-files - path: ./build + - name: Setup Flutter + uses: subosito/flutter-action@v2 + with: + channel: 'stable' + flutter-version: '3.16.8' + + - name: Enable web + run: flutter config --enable-web + + - name: Get dependencies + run: flutter pub get + + - name: Build web + run: flutter build web --release - - name: Deploy to gh-pages - uses: peaceiris/actions-gh-pages@v3 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./build \ No newline at end of file + - name: Deploy to Github Pages + run: | + cd build/web + git init + git config --global user.email praslnx8@gmail.com + git config --global user.name praslnx8 + git status + git remote add origin https://${{secrets.commit_secret}}@github.com/wealth-wave/wealth_wave.git + git checkout -b gh-pages + git add --all + git commit -m "update" + git push origin gh-pages -f \ No newline at end of file diff --git a/lib/domain/models/investment.dart b/lib/domain/models/investment.dart index 496d1e8..de78ad9 100644 --- a/lib/domain/models/investment.dart +++ b/lib/domain/models/investment.dart @@ -73,12 +73,17 @@ class Investment { Future getValueOn( {required final DateTime date, bool considerFuturePayments = false}) async { + final maturityDate = this.maturityDate; + final futureDate = maturityDate != null && maturityDate.isBefore(date) + ? maturityDate + : date; + final payments = await getTransactions().then((transactions) => transactions .map((transaction) => transaction.toPayment()) .toList(growable: true)); if (considerFuturePayments) { getSips().then((sips) => Future.wait(sips.map((sip) => sip - .getFuturePayment(till: date) + .getFuturePayment(till: futureDate) .then((futurePayments) => payments.addAll(futurePayments))))); } @@ -90,12 +95,12 @@ class Investment { payments: payments, value: value, valueUpdatedOn: valueUpdatedOn); return _irrCalculator.calculateValueOnIRR( irr: irr, - futureDate: date, + futureDate: futureDate, currentValue: value, currentValueUpdatedOn: valueUpdatedOn); } else if (irr != null) { return _irrCalculator.calculateFutureValueOnIRR( - payments: payments, irr: irr, date: date); + payments: payments, irr: irr, date: futureDate); } else { throw Exception('Value and IRR are null'); } diff --git a/pubspec.lock b/pubspec.lock index cfda62a..43fbd0b 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -85,10 +85,10 @@ packages: dependency: "direct dev" description: name: build_runner - sha256: "67d591d602906ef9201caf93452495ad1812bea2074f04e25dbd7c133785821b" + sha256: "581bacf68f89ec8792f5e5a0b2c4decd1c948e97ce659dc783688c8a88fbec21" url: "https://pub.dev" source: hosted - version: "2.4.7" + version: "2.4.8" build_runner_core: dependency: transitive description: @@ -157,18 +157,18 @@ packages: dependency: transitive description: name: code_builder - sha256: feee43a5c05e7b3199bb375a86430b8ada1b04104f2923d0e03cc01ca87b6d84 + sha256: f692079e25e7869c14132d39f223f8eec9830eb76131925143b2129c4bb01b37 url: "https://pub.dev" source: hosted - version: "4.9.0" + version: "4.10.0" collection: dependency: transitive description: name: collection - sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c" + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a url: "https://pub.dev" source: hosted - version: "1.17.1" + version: "1.18.0" convert: dependency: transitive description: @@ -205,18 +205,18 @@ packages: dependency: "direct main" description: name: drift - sha256: e27a96acab5686c5b4ae38fbe8a05e76c37411bd15ae35497dac9c404111b5ec + sha256: b50a8342c6ddf05be53bda1d246404cbad101b64dc73e8d6d1ac1090d119b4e2 url: "https://pub.dev" source: hosted - version: "2.14.0" + version: "2.15.0" drift_dev: dependency: "direct dev" description: name: drift_dev - sha256: "50c14b8248d133d36b41c1b08ceed138be869b5b98ccaf3af16c9b88c7adc54e" + sha256: c037d9431b6f8dc633652b1469e5f53aaec6e4eb405ed29dd232fa888ef10d88 url: "https://pub.dev" source: hosted - version: "2.14.1" + version: "2.15.0" ffi: dependency: transitive description: @@ -298,10 +298,10 @@ packages: dependency: "direct main" description: name: intl - sha256: "910f85bce16fb5c6f614e117efa303e85a1731bb0081edf3604a2ae6e9a3cc91" + sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf url: "https://pub.dev" source: hosted - version: "0.17.0" + version: "0.19.0" io: dependency: transitive description: @@ -362,18 +362,18 @@ packages: dependency: transitive description: name: material_color_utilities - sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 + sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" url: "https://pub.dev" source: hosted - version: "0.2.0" + version: "0.5.0" meta: dependency: transitive description: name: meta - sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" + sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e url: "https://pub.dev" source: hosted - version: "1.9.1" + version: "1.10.0" mime: dependency: transitive description: @@ -418,10 +418,10 @@ packages: dependency: "direct main" description: name: path_provider - sha256: a1aa8aaa2542a6bc57e381f132af822420216c80d4781f7aa085ca3229208aaa + sha256: b27217933eeeba8ff24845c34003b003b2b22151de3c908d0e679e8fe1aa078b url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.1.2" path_provider_android: dependency: transitive description: @@ -434,10 +434,10 @@ packages: dependency: transitive description: name: path_provider_foundation - sha256: "19314d595120f82aca0ba62787d58dde2cc6b5df7d2f0daf72489e38d1b57f2d" + sha256: "5a7999be66e000916500be4f15a3633ebceb8302719b47b9cc49ce924125350f" url: "https://pub.dev" source: hosted - version: "2.3.1" + version: "2.3.2" path_provider_linux: dependency: transitive description: @@ -450,10 +450,10 @@ packages: dependency: transitive description: name: path_provider_platform_interface - sha256: "94b1e0dd80970c1ce43d5d4e050a9918fce4f4a775e6142424c30a29a363265c" + sha256: "88f5779f72ba699763fa3a3b06aa4bf6de76c8e5de842cf6f29e2e06476c2334" url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.1.2" path_provider_windows: dependency: transitive description: @@ -591,26 +591,26 @@ packages: dependency: transitive description: name: sqlite3 - sha256: db65233e6b99e99b2548932f55a987961bc06d82a31a0665451fa0b4fff4c3fb + sha256: c4a4c5a4b2a32e2d0f6837b33d7c91a67903891a5b7dbe706cf4b1f6b0c798c5 url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.3.0" sqlite3_flutter_libs: dependency: "direct main" description: name: sqlite3_flutter_libs - sha256: "3e3583b77cf888a68eae2e49ee4f025f66b86623ef0d83c297c8d903daa14871" + sha256: "90963b515721d6a71e96f438175cf43c979493ed14822860a300b69694c74eb6" url: "https://pub.dev" source: hosted - version: "0.5.18" + version: "0.5.19+1" sqlparser: dependency: transitive description: name: sqlparser - sha256: "877fcefabb725d120e31f54fa669a98c002db0feeaca6cea5354543f03b5e906" + sha256: dc384bb1f56d1384ce078edb5ff8247976abdab79d0c83e437210c85f06ecb61 url: "https://pub.dev" source: hosted - version: "0.33.0" + version: "0.34.0" stack_trace: dependency: transitive description: @@ -655,10 +655,10 @@ packages: dependency: "direct dev" description: name: test - sha256: "3d028996109ad5c253674c7f347822fb994a087614d6f353e6039704b4661ff2" + sha256: "694c108e13c6b35b15fcb0f8f03eddf8373f93b044c9497b5e81ce09f7381bda" url: "https://pub.dev" source: hosted - version: "1.25.0" + version: "1.25.1" test_api: dependency: transitive description: @@ -715,6 +715,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.1.0" + web: + dependency: transitive + description: + name: web + sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152 + url: "https://pub.dev" + source: hosted + version: "0.3.0" web_socket_channel: dependency: transitive description: @@ -735,10 +743,10 @@ packages: dependency: transitive description: name: win32 - sha256: "350a11abd2d1d97e0cc7a28a81b781c08002aa2864d9e3f192ca0ffa18b06ed3" + sha256: "464f5674532865248444b4c3daca12bd9bf2d7c47f759ce2617986e7229494a8" url: "https://pub.dev" source: hosted - version: "5.0.9" + version: "5.2.0" xdg_directories: dependency: transitive description: @@ -756,5 +764,5 @@ packages: source: hosted version: "3.1.2" sdks: - dart: ">=3.0.6 <4.0.0" + dart: "3.2.5" flutter: ">=3.10.0" diff --git a/pubspec.yaml b/pubspec.yaml index 09c9b0e..d949892 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -10,19 +10,19 @@ dependencies: flutter: sdk: flutter json_annotation: ^4.8.1 - logger: ^2.0.2+1 - drift: ^2.14.0 - sqlite3_flutter_libs: ^0.5.0 - path_provider: ^2.0.0 - path: ^1.8.3 - intl: ^0.17.0 - provider: ^6.1.1 + logger: 2.0.2+1 + drift: 2.15.0 + sqlite3_flutter_libs: 0.5.19+1 + path_provider: 2.1.2 + path: 1.9.0 + intl: 0.19.0 + provider: 6.1.1 dev_dependencies: - flutter_lints: ^3.0.1 - drift_dev: ^2.14.0 - build_runner: '>2.3.0 <4.0.0' - test: ^1.24.9 + flutter_lints: 3.0.1 + drift_dev: 2.15.0 + build_runner: 2.4.8 + test: 1.25.1 flutter: uses-material-design: true