Skip to content

Commit 4c6fb44

Browse files
authored
Feature/5.0.0 (#19)
* chore: Update dependencies and upgrade Flutter to Dart 2.12.0 * chore: Update platform import for JS interop compatibility * chore: Update platform import for JS interop compatibility * chore: Update platform import for JS interop compatibility * chore: Update platform import for JS interop compatibility * Rename test file * chore: Update platform import for JS interop compatibility * Update example.png * Update example
1 parent 32dadab commit 4c6fb44

18 files changed

+1041
-426
lines changed

.github/workflows/checkout.yml

Lines changed: 100 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1-
name: Checkout
1+
name: CHECKOUT
22

33
on:
44
workflow_dispatch:
5-
push:
6-
branches:
7-
- "master"
8-
- "develop"
9-
- "feature/**"
10-
- "bugfix/**"
11-
- "hotfix/**"
12-
- "support/**"
13-
paths:
14-
- "lib/**.dart"
15-
- "test/**.dart"
16-
- "example/**.dart"
17-
- "pubspec.yaml"
5+
#push:
6+
# branches:
7+
# - "master"
8+
# - "develop"
9+
# - "feature/**"
10+
# - "bugfix/**"
11+
# - "hotfix/**"
12+
# - "support/**"
13+
# paths:
14+
# - ".github/workflows/*.yml"
15+
# - "lib/pubspec.yaml"
16+
# - "lib/**.dart"
17+
# - "test/**.dart"
18+
# - "example/**.dart"
1819
pull_request:
1920
branches:
2021
- "master"
@@ -24,68 +25,125 @@ on:
2425
- "hotfix/**"
2526
- "support/**"
2627
paths:
28+
- ".github/workflows/*.yml"
29+
- "lib/pubspec.yaml"
2730
- "lib/**.dart"
2831
- "test/**.dart"
2932
- "example/**.dart"
30-
- "pubspec.yaml"
3133

3234
jobs:
3335
checkout:
3436
name: "Checkout"
3537
runs-on: ubuntu-latest
36-
container:
37-
image: dart:beta
3838
defaults:
3939
run:
4040
working-directory: ./
41+
container:
42+
image: dart:stable
43+
env:
44+
pub-cache-name: pub
45+
threshold: 95
4146
timeout-minutes: 10
4247
steps:
4348
- name: 🚂 Get latest code
44-
uses: actions/checkout@v3
49+
id: checkout
50+
uses: actions/checkout@v4
4551
with:
46-
fetch-depth: 2
52+
sparse-checkout: |
53+
.github
54+
pubspec.yaml
55+
lib
56+
test
57+
analysis_options.yaml
58+
CHANGELOG.md
4759
48-
- name: 🚃 Cache pub modules
49-
uses: actions/cache@v2
50-
env:
51-
cache-name: cache-pub-package
60+
- name: 📤 Restore Pub modules
61+
id: cache-pub-restore
62+
uses: actions/cache/restore@v4
5263
with:
5364
path: |
54-
$PWD/.pub_cache/
55-
key: ${{ runner.os }}-pub-${{ env.cache-name }}-${{ hashFiles('**/pubspec.yaml') }}
65+
$HOME/.pub-cache
66+
key: ${{ runner.os }}-${{ env.pub-cache-name }}-${{ hashFiles('**/pubspec.yaml') }}
5667

57-
- name: 🗄️ Export pub cache directory
58-
run: export PUB_CACHE=$PWD/.pub_cache/
68+
- name: 🗄️ Export Pub cache directory
69+
id: export-pub-cache
70+
timeout-minutes: 1
71+
run: |
72+
export PUB_CACHE=$PWD/.pub_cache/
73+
export PATH="$PATH":"$HOME/.pub-cache/bin"
74+
echo "${HOME}/.pub-cache/bin" >> $GITHUB_PATH
5975
6076
- name: 👷 Install Dependencies
77+
id: install-dependencies
6178
timeout-minutes: 1
6279
run: |
63-
dart pub get
80+
apt-get update && apt-get install -y lcov
81+
dart pub global activate coverage
82+
dart pub get --no-example
83+
84+
- name: 📥 Save Pub modules
85+
id: cache-pub-save
86+
uses: actions/cache/save@v4
87+
with:
88+
path: |
89+
$HOME/.pub-cache
90+
key: ${{ runner.os }}-${{ env.pub-cache-name }}-${{ hashFiles('**/pubspec.yaml') }}
6491

6592
- name: 🔎 Check format
93+
id: check-format
6694
timeout-minutes: 1
67-
run: dart format --set-exit-if-changed -l 80 -o none .
95+
run: dart format --set-exit-if-changed -l 80 -o none lib/
6896

6997
- name: 📈 Check analyzer
98+
id: check-analyzer
7099
timeout-minutes: 1
71-
run: dart analyze --fatal-infos --fatal-warnings lib
100+
run: dart analyze --fatal-infos --fatal-warnings lib/
101+
102+
- name: 👀 Verify versions
103+
id: verify-versions
104+
timeout-minutes: 1
105+
run: |
106+
test -f pubspec.yaml && test -f CHANGELOG.md
107+
version_pubspec=$(grep '^version:' pubspec.yaml | awk '{print $2}' | sed 's/[^[:print:]]//g')
108+
test -n "$version_pubspec"
109+
echo "Version from pubspec.yaml: '$version_pubspec'"
110+
grep -q "# $version_pubspec" CHANGELOG.md || (echo "Version not found in CHANGELOG.md" >&2; exit 1)
72111
73112
#- name: Check with pana
74113
# run: dart pub global activate pana && pana --json --no-warning --line-length 80
114+
75115
- name: 🧪 Run tests
116+
id: run-tests
117+
timeout-minutes: 2
76118
run: |
77-
dart test --coverage=coverage \
78-
&& dart run coverage:format_coverage --lcov --in=coverage \
79-
--out=coverage/lcov.info --report-on=lib
119+
dart pub global run coverage:test_with_coverage -fb -o coverage -- \
120+
--platform vm --compiler=kernel --coverage=coverage \
121+
--reporter=github --file-reporter=json:coverage/tests.json \
122+
--timeout=10m --concurrency=12 --color \
123+
test/test.dart
80124
81-
- name: 📥 Upload coverage to Codecov
82-
uses: codecov/codecov-action@v2.1.0
83-
with:
84-
token: ${{ secrets.CODECOV_TOKEN }}
125+
- name: 🔍 Check coverage
126+
id: check-coverage
127+
timeout-minutes: 2
128+
run: |
129+
mv coverage/lcov.info coverage/lcov.base.info
130+
lcov --remove coverage/lcov.base.info '*.g.dart' -o coverage/lcov.info
131+
lcov --list coverage/lcov.info
132+
THRESHOLD=${{ env.threshold }}
133+
COVERAGE=$(lcov --summary coverage/lcov.info | grep -i 'lines\|Total:' | tail -n 1 | awk '{print $2}' | sed 's/%//')
134+
echo "Coverage is $COVERAGE%"
135+
echo $COVERAGE | awk '{if ($1 < 50) exit 1}'
136+
137+
- name: 🧹 Cleanup artifacts
138+
id: cleanup-artifacts
139+
if: always()
140+
timeout-minutes: 2
141+
run: |
142+
rm -rf ~/build
85143
86-
- name: 🧮 Check Code Coverage
87-
uses: VeryGoodOpenSource/very_good_coverage@v1.2.1
144+
- name: ✨ Upload coverage to Codecov
145+
id: upload-coverage
146+
timeout-minutes: 2
147+
uses: codecov/codecov-action@v4
88148
with:
89-
path: coverage/lcov.info
90-
min_coverage: 90
91-
#exclude: '**.g.dart **.freezed.dart'
149+
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos

.vscode/launch.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
55
"version": "0.2.0",
66
"configurations": [
7+
{
8+
"name": "Example",
9+
"request": "launch",
10+
"type": "dart",
11+
"program": "example/main.dart",
12+
"args": []
13+
},
714
// https://pub.dev/packages/test
815
// dart test test/ws_test.dart --color --platform=vm
916
{
@@ -54,4 +61,4 @@
5461
"args": []
5562
}
5663
]
57-
}
64+
}

CHANGELOG.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 5.0.0 - 2024-08-13
2+
3+
- Update dependencies
4+
- dart:html replaced with package:web
5+
- Enums replaced with sealed classes
6+
- Renamed getters
7+
18
## 4.0.2 - 2023-06-30
29

310
- Fix topics
@@ -54,15 +61,15 @@
5461

5562
### Changed
5663

57-
- Fix `kListOSWithCupertinoDesign` constant and `isCupertino` flag
64+
- Fix `kListOSWithCupertinoDesign` constant and `cupertino` flag
5865

5966
## 2.0.1 - 2020-09-06
6067

6168
### Added
6269

6370
- Add getters:
64-
- `isWeb` - Is a web-based applications
65-
- `isIO` - Is a I/O supporting for non-web applications
71+
- `isJS` - Is a web-based applications
72+
- `isVM` - Is a I/O supporting for non-web applications
6673

6774
## 2.0.0 - 2020-08-28
6875

@@ -114,9 +121,9 @@
114121
### Added
115122

116123
- Add new flags:
117-
- isDesktop
118-
- isMaterial
119-
- isCupertino
124+
- desktop
125+
- material
126+
- cupertino
120127

121128
## 1.0.1 - 2020-04-22
122129

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ get:
1111

1212
upgrade: get
1313
@echo "Upgrading dependencies"
14-
@flutter pub upgrade
14+
@dart pub upgrade
1515

1616
outdated:
1717
@echo "Outdated check"

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ Provides platform information such as:
3636

3737
- Host platform type
3838

39-
- io (vm, desktops, mobile, console)
40-
- web (html, js, browser)
39+
- vm (io, desktops, mobile, console, server)
40+
- js (web, html, browser)
4141

4242
- Operating system
4343

@@ -49,7 +49,7 @@ Provides platform information such as:
4949
- Android
5050
- Unknown
5151

52-
- Version (`<unknown>` if not available)
52+
- Version (`unknown` if not available)
5353

5454
- Locale string (`en` if not available)
5555

@@ -59,7 +59,7 @@ Provides platform information such as:
5959

6060
- Is a Web-based applications
6161

62-
- Is a I/O supporting for non-web applications
62+
- Is a VM supporting for non-web applications
6363

6464
- Is a mobile device (Android, iOS)
6565

@@ -108,10 +108,10 @@ You can use nested methods to compose more complex queries.
108108
[mobile] - is mobile device (Android, iOS)
109109
[desktop] - is desktop device (Windows, MacOS, Fuchsia)
110110

111-
##### IO or Web
111+
##### VM (IO) or JS (Web)
112112

113-
[web] - is web-based applications
114-
[io] - is I/O supporting for non-web applications
113+
[js] - is web-based applications
114+
[vm] - is I/O supporting for non-web applications
115115

116116
##### Build mode
117117

@@ -125,7 +125,7 @@ You can use nested methods to compose more complex queries.
125125
1. Operating System
126126
2. Design
127127
3. Mobile/Desktop
128-
4. IO/Web
128+
4. VM/JS
129129
5. Build mode
130130
6. Call [orElse] if any callback was not called
131131

analysis_options.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ analyzer:
1010
- 'web/**'
1111
# Build
1212
- 'build/**'
13-
# Generated code
14-
- 'lib/**/*.g.dart'
15-
- 'lib/generated_plugin_registrant.dart'
1613
# Assets
1714
- 'assets/**'
1815
# Mocks for test
@@ -61,12 +58,10 @@ linter:
6158
avoid_as: false
6259
avoid_redundant_argument_values: false
6360
comment_references: false # Unused because https://github.com/dart-lang/sdk/issues/36974
64-
flutter_style_todos: false
6561
prefer_double_quotes: false
6662
sort_constructors_first: false
6763
sort_unnamed_constructors_first: false
6864
use_key_in_widget_constructors: false
69-
avoid_web_libraries_in_flutter: false
7065
always_put_control_body_on_new_line: false
7166
#diagnostic_describe_all_properties: false # ???
7267

@@ -140,7 +135,6 @@ linter:
140135
unnecessary_string_escapes: true
141136
unnecessary_string_interpolations: true
142137
unsafe_html: true
143-
use_full_hex_values_for_flutter_colors: true
144138
use_raw_strings: true
145139
use_string_buffers: true
146140
valid_regexps: true

example.png

-111 KB
Loading

example/main.dart

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,30 @@ void main(List<String> args) {
99
print(platform.numberOfProcessors);
1010

1111
final design = platform.when<String?>(
12-
io: () => platform.when<String>(
12+
vm: () => platform.when<String>(
1313
material: () => 'Android or Fuchsia',
1414
cupertino: () => 'macOS or iOS',
1515
orElse: () => 'Windows or Linux',
1616
),
17-
web: () => 'Web',
17+
js: () => 'Web',
1818
);
1919
print(design);
2020

2121
final operatingSystem = switch (platform.operatingSystem) {
22-
OperatingSystem.android => 'Android',
23-
OperatingSystem.fuchsia => 'Fuchsia',
24-
OperatingSystem.iOS => 'iOS',
25-
OperatingSystem.linux => 'Linux',
26-
OperatingSystem.macOS => 'macOS',
27-
OperatingSystem.windows => 'Windows',
28-
OperatingSystem.unknown => 'Unknown',
22+
const OperatingSystem.android() => 'Android',
23+
const OperatingSystem.fuchsia() => 'Fuchsia',
24+
const OperatingSystem.iOS() => 'iOS',
25+
const OperatingSystem.linux() => 'Linux',
26+
const OperatingSystem.macOS() => 'macOS',
27+
const OperatingSystem.windows() => 'Windows',
28+
const OperatingSystem.unknown() || _ => 'Unknown',
2929
};
3030
print(operatingSystem);
3131

3232
final buildMode = switch (platform.buildMode) {
33-
BuildMode.debug => 'Debug',
34-
BuildMode.profile => 'Profile',
35-
BuildMode.release => 'Release',
33+
BuildMode$Debug _ => 'Debug',
34+
BuildMode$Profile _ => 'Profile',
35+
BuildMode$Release _ => 'Release',
3636
};
3737
print(buildMode);
3838
}

0 commit comments

Comments
 (0)