diff --git a/.github/ISSUE_TEMPLATE/coverage.md b/.github/ISSUE_TEMPLATE/coverage.md new file mode 100644 index 000000000..d0b0fb704 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/coverage.md @@ -0,0 +1,5 @@ +--- +name: "package:coverage" +about: "Create a bug or file a feature request against package:coverage." +labels: "package:coverage" +--- diff --git a/.github/workflows/oauth2.yml b/.github/workflows/oauth2.yml index 820dd1a4c..da3883df2 100644 --- a/.github/workflows/oauth2.yml +++ b/.github/workflows/oauth2.yml @@ -29,7 +29,7 @@ jobs: strategy: fail-fast: false matrix: - sdk: [3.0.0, dev] + sdk: [dev] steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 @@ -62,7 +62,7 @@ jobs: matrix: # Add macos-latest and/or windows-latest if relevant for this package. os: [ubuntu-latest] - sdk: [stable, beta] + sdk: [3.4, dev] steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 diff --git a/pkgs/cli_config/lib/src/config.dart b/pkgs/cli_config/lib/src/config.dart index 631202939..85e2c0c4e 100644 --- a/pkgs/cli_config/lib/src/config.dart +++ b/pkgs/cli_config/lib/src/config.dart @@ -82,7 +82,7 @@ class Config { /// Constructs a config by parsing the three sources. /// - /// If provided, [commandLineDefines] must be a list of '='. + /// If provided, [commandLineDefines] must be a list of `=`. /// /// If provided, [workingDirectory] is used to resolves paths inside /// [commandLineDefines]. @@ -120,7 +120,7 @@ class Config { /// Constructs a config by parsing the three sources. /// - /// If provided, [commandLineDefines] must be a list of '='. + /// If provided, [commandLineDefines] must be a list of `=`. /// /// If provided, [workingDirectory] is used to resolves paths inside /// [commandLineDefines]. diff --git a/pkgs/coverage/pubspec.yaml b/pkgs/coverage/pubspec.yaml index fe0f0060b..c0f26bfcd 100644 --- a/pkgs/coverage/pubspec.yaml +++ b/pkgs/coverage/pubspec.yaml @@ -20,7 +20,7 @@ dev_dependencies: benchmark_harness: ^2.2.0 build_runner: ^2.3.1 dart_flutter_team_lints: ^3.0.0 - mockito: ^5.4.1 + mockito: ^5.4.4 test: ^1.24.7 test_descriptor: ^2.0.0 test_process: ^2.0.0 diff --git a/pkgs/coverage/test/collect_coverage_mock_test.mocks.dart b/pkgs/coverage/test/collect_coverage_mock_test.mocks.dart index efdb26046..86f596af0 100644 --- a/pkgs/coverage/test/collect_coverage_mock_test.mocks.dart +++ b/pkgs/coverage/test/collect_coverage_mock_test.mocks.dart @@ -1,4 +1,4 @@ -// Mocks generated by Mockito 5.4.2 from annotations +// Mocks generated by Mockito 5.4.4 from annotations // in coverage/test/collect_coverage_mock_test.dart. // Do not manually edit this file. @@ -6,12 +6,15 @@ import 'dart:async' as _i3; import 'package:mockito/mockito.dart' as _i1; +import 'package:mockito/src/dummies.dart' as _i4; import 'package:vm_service/src/vm_service.dart' as _i2; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values // ignore_for_file: avoid_setters_without_getters // ignore_for_file: comment_references +// ignore_for_file: deprecated_member_use +// ignore_for_file: deprecated_member_use_from_same_package // ignore_for_file: implementation_imports // ignore_for_file: invalid_use_of_visible_for_testing_member // ignore_for_file: prefer_const_constructors @@ -39,8 +42,8 @@ class _FakeSuccess_1 extends _i1.SmartFake implements _i2.Success { ); } -class _FakeResponse_2 extends _i1.SmartFake implements _i2.Response { - _FakeResponse_2( +class _FakeIdZone_2 extends _i1.SmartFake implements _i2.IdZone { + _FakeIdZone_2( Object parent, Invocation parentInvocation, ) : super( @@ -49,9 +52,19 @@ class _FakeResponse_2 extends _i1.SmartFake implements _i2.Response { ); } -class _FakeAllocationProfile_3 extends _i1.SmartFake +class _FakeResponse_3 extends _i1.SmartFake implements _i2.Response { + _FakeResponse_3( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeAllocationProfile_4 extends _i1.SmartFake implements _i2.AllocationProfile { - _FakeAllocationProfile_3( + _FakeAllocationProfile_4( Object parent, Invocation parentInvocation, ) : super( @@ -60,8 +73,8 @@ class _FakeAllocationProfile_3 extends _i1.SmartFake ); } -class _FakeCpuSamples_4 extends _i1.SmartFake implements _i2.CpuSamples { - _FakeCpuSamples_4( +class _FakeCpuSamples_5 extends _i1.SmartFake implements _i2.CpuSamples { + _FakeCpuSamples_5( Object parent, Invocation parentInvocation, ) : super( @@ -70,8 +83,8 @@ class _FakeCpuSamples_4 extends _i1.SmartFake implements _i2.CpuSamples { ); } -class _FakeClassList_5 extends _i1.SmartFake implements _i2.ClassList { - _FakeClassList_5( +class _FakeClassList_6 extends _i1.SmartFake implements _i2.ClassList { + _FakeClassList_6( Object parent, Invocation parentInvocation, ) : super( @@ -80,8 +93,8 @@ class _FakeClassList_5 extends _i1.SmartFake implements _i2.ClassList { ); } -class _FakeFlagList_6 extends _i1.SmartFake implements _i2.FlagList { - _FakeFlagList_6( +class _FakeFlagList_7 extends _i1.SmartFake implements _i2.FlagList { + _FakeFlagList_7( Object parent, Invocation parentInvocation, ) : super( @@ -90,9 +103,9 @@ class _FakeFlagList_6 extends _i1.SmartFake implements _i2.FlagList { ); } -class _FakeInboundReferences_7 extends _i1.SmartFake +class _FakeInboundReferences_8 extends _i1.SmartFake implements _i2.InboundReferences { - _FakeInboundReferences_7( + _FakeInboundReferences_8( Object parent, Invocation parentInvocation, ) : super( @@ -101,8 +114,8 @@ class _FakeInboundReferences_7 extends _i1.SmartFake ); } -class _FakeInstanceSet_8 extends _i1.SmartFake implements _i2.InstanceSet { - _FakeInstanceSet_8( +class _FakeInstanceSet_9 extends _i1.SmartFake implements _i2.InstanceSet { + _FakeInstanceSet_9( Object parent, Invocation parentInvocation, ) : super( @@ -111,8 +124,8 @@ class _FakeInstanceSet_8 extends _i1.SmartFake implements _i2.InstanceSet { ); } -class _FakeInstanceRef_9 extends _i1.SmartFake implements _i2.InstanceRef { - _FakeInstanceRef_9( +class _FakeInstanceRef_10 extends _i1.SmartFake implements _i2.InstanceRef { + _FakeInstanceRef_10( Object parent, Invocation parentInvocation, ) : super( @@ -121,8 +134,8 @@ class _FakeInstanceRef_9 extends _i1.SmartFake implements _i2.InstanceRef { ); } -class _FakeIsolate_10 extends _i1.SmartFake implements _i2.Isolate { - _FakeIsolate_10( +class _FakeIsolate_11 extends _i1.SmartFake implements _i2.Isolate { + _FakeIsolate_11( Object parent, Invocation parentInvocation, ) : super( @@ -131,8 +144,8 @@ class _FakeIsolate_10 extends _i1.SmartFake implements _i2.Isolate { ); } -class _FakeIsolateGroup_11 extends _i1.SmartFake implements _i2.IsolateGroup { - _FakeIsolateGroup_11( +class _FakeIsolateGroup_12 extends _i1.SmartFake implements _i2.IsolateGroup { + _FakeIsolateGroup_12( Object parent, Invocation parentInvocation, ) : super( @@ -141,8 +154,8 @@ class _FakeIsolateGroup_11 extends _i1.SmartFake implements _i2.IsolateGroup { ); } -class _FakeEvent_12 extends _i1.SmartFake implements _i2.Event { - _FakeEvent_12( +class _FakeEvent_13 extends _i1.SmartFake implements _i2.Event { + _FakeEvent_13( Object parent, Invocation parentInvocation, ) : super( @@ -151,8 +164,8 @@ class _FakeEvent_12 extends _i1.SmartFake implements _i2.Event { ); } -class _FakeMemoryUsage_13 extends _i1.SmartFake implements _i2.MemoryUsage { - _FakeMemoryUsage_13( +class _FakeMemoryUsage_14 extends _i1.SmartFake implements _i2.MemoryUsage { + _FakeMemoryUsage_14( Object parent, Invocation parentInvocation, ) : super( @@ -161,8 +174,8 @@ class _FakeMemoryUsage_13 extends _i1.SmartFake implements _i2.MemoryUsage { ); } -class _FakeScriptList_14 extends _i1.SmartFake implements _i2.ScriptList { - _FakeScriptList_14( +class _FakeScriptList_15 extends _i1.SmartFake implements _i2.ScriptList { + _FakeScriptList_15( Object parent, Invocation parentInvocation, ) : super( @@ -171,8 +184,8 @@ class _FakeScriptList_14 extends _i1.SmartFake implements _i2.ScriptList { ); } -class _FakeObj_15 extends _i1.SmartFake implements _i2.Obj { - _FakeObj_15( +class _FakeObj_16 extends _i1.SmartFake implements _i2.Obj { + _FakeObj_16( Object parent, Invocation parentInvocation, ) : super( @@ -181,9 +194,9 @@ class _FakeObj_15 extends _i1.SmartFake implements _i2.Obj { ); } -class _FakePerfettoCpuSamples_16 extends _i1.SmartFake +class _FakePerfettoCpuSamples_17 extends _i1.SmartFake implements _i2.PerfettoCpuSamples { - _FakePerfettoCpuSamples_16( + _FakePerfettoCpuSamples_17( Object parent, Invocation parentInvocation, ) : super( @@ -192,9 +205,9 @@ class _FakePerfettoCpuSamples_16 extends _i1.SmartFake ); } -class _FakePerfettoTimeline_17 extends _i1.SmartFake +class _FakePerfettoTimeline_18 extends _i1.SmartFake implements _i2.PerfettoTimeline { - _FakePerfettoTimeline_17( + _FakePerfettoTimeline_18( Object parent, Invocation parentInvocation, ) : super( @@ -203,8 +216,8 @@ class _FakePerfettoTimeline_17 extends _i1.SmartFake ); } -class _FakePortList_18 extends _i1.SmartFake implements _i2.PortList { - _FakePortList_18( +class _FakePortList_19 extends _i1.SmartFake implements _i2.PortList { + _FakePortList_19( Object parent, Invocation parentInvocation, ) : super( @@ -213,8 +226,8 @@ class _FakePortList_18 extends _i1.SmartFake implements _i2.PortList { ); } -class _FakeRetainingPath_19 extends _i1.SmartFake implements _i2.RetainingPath { - _FakeRetainingPath_19( +class _FakeRetainingPath_20 extends _i1.SmartFake implements _i2.RetainingPath { + _FakeRetainingPath_20( Object parent, Invocation parentInvocation, ) : super( @@ -223,9 +236,9 @@ class _FakeRetainingPath_19 extends _i1.SmartFake implements _i2.RetainingPath { ); } -class _FakeProcessMemoryUsage_20 extends _i1.SmartFake +class _FakeProcessMemoryUsage_21 extends _i1.SmartFake implements _i2.ProcessMemoryUsage { - _FakeProcessMemoryUsage_20( + _FakeProcessMemoryUsage_21( Object parent, Invocation parentInvocation, ) : super( @@ -234,8 +247,8 @@ class _FakeProcessMemoryUsage_20 extends _i1.SmartFake ); } -class _FakeStack_21 extends _i1.SmartFake implements _i2.Stack { - _FakeStack_21( +class _FakeStack_22 extends _i1.SmartFake implements _i2.Stack { + _FakeStack_22( Object parent, Invocation parentInvocation, ) : super( @@ -244,8 +257,8 @@ class _FakeStack_21 extends _i1.SmartFake implements _i2.Stack { ); } -class _FakeProtocolList_22 extends _i1.SmartFake implements _i2.ProtocolList { - _FakeProtocolList_22( +class _FakeProtocolList_23 extends _i1.SmartFake implements _i2.ProtocolList { + _FakeProtocolList_23( Object parent, Invocation parentInvocation, ) : super( @@ -254,8 +267,8 @@ class _FakeProtocolList_22 extends _i1.SmartFake implements _i2.ProtocolList { ); } -class _FakeSourceReport_23 extends _i1.SmartFake implements _i2.SourceReport { - _FakeSourceReport_23( +class _FakeSourceReport_24 extends _i1.SmartFake implements _i2.SourceReport { + _FakeSourceReport_24( Object parent, Invocation parentInvocation, ) : super( @@ -264,8 +277,8 @@ class _FakeSourceReport_23 extends _i1.SmartFake implements _i2.SourceReport { ); } -class _FakeVersion_24 extends _i1.SmartFake implements _i2.Version { - _FakeVersion_24( +class _FakeVersion_25 extends _i1.SmartFake implements _i2.Version { + _FakeVersion_25( Object parent, Invocation parentInvocation, ) : super( @@ -274,8 +287,8 @@ class _FakeVersion_24 extends _i1.SmartFake implements _i2.Version { ); } -class _FakeVM_25 extends _i1.SmartFake implements _i2.VM { - _FakeVM_25( +class _FakeVM_26 extends _i1.SmartFake implements _i2.VM { + _FakeVM_26( Object parent, Invocation parentInvocation, ) : super( @@ -284,8 +297,8 @@ class _FakeVM_25 extends _i1.SmartFake implements _i2.VM { ); } -class _FakeTimeline_26 extends _i1.SmartFake implements _i2.Timeline { - _FakeTimeline_26( +class _FakeTimeline_27 extends _i1.SmartFake implements _i2.Timeline { + _FakeTimeline_27( Object parent, Invocation parentInvocation, ) : super( @@ -294,8 +307,8 @@ class _FakeTimeline_26 extends _i1.SmartFake implements _i2.Timeline { ); } -class _FakeTimelineFlags_27 extends _i1.SmartFake implements _i2.TimelineFlags { - _FakeTimelineFlags_27( +class _FakeTimelineFlags_28 extends _i1.SmartFake implements _i2.TimelineFlags { + _FakeTimelineFlags_28( Object parent, Invocation parentInvocation, ) : super( @@ -304,8 +317,8 @@ class _FakeTimelineFlags_27 extends _i1.SmartFake implements _i2.TimelineFlags { ); } -class _FakeTimestamp_28 extends _i1.SmartFake implements _i2.Timestamp { - _FakeTimestamp_28( +class _FakeTimestamp_29 extends _i1.SmartFake implements _i2.Timestamp { + _FakeTimestamp_29( Object parent, Invocation parentInvocation, ) : super( @@ -314,8 +327,8 @@ class _FakeTimestamp_28 extends _i1.SmartFake implements _i2.Timestamp { ); } -class _FakeUriList_29 extends _i1.SmartFake implements _i2.UriList { - _FakeUriList_29( +class _FakeUriList_30 extends _i1.SmartFake implements _i2.UriList { + _FakeUriList_30( Object parent, Invocation parentInvocation, ) : super( @@ -324,8 +337,18 @@ class _FakeUriList_29 extends _i1.SmartFake implements _i2.UriList { ); } -class _FakeReloadReport_30 extends _i1.SmartFake implements _i2.ReloadReport { - _FakeReloadReport_30( +class _FakeReloadReport_31 extends _i1.SmartFake implements _i2.ReloadReport { + _FakeReloadReport_31( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeFuture_32 extends _i1.SmartFake implements _i3.Future { + _FakeFuture_32( Object parent, Invocation parentInvocation, ) : super( @@ -342,6 +365,24 @@ class MockVmService extends _i1.Mock implements _i2.VmService { _i1.throwOnMissingStub(this); } + @override + _i3.Stream get onSend => (super.noSuchMethod( + Invocation.getter(#onSend), + returnValue: _i3.Stream.empty(), + ) as _i3.Stream); + + @override + _i3.Stream get onReceive => (super.noSuchMethod( + Invocation.getter(#onReceive), + returnValue: _i3.Stream.empty(), + ) as _i3.Stream); + + @override + _i3.Future get onDone => (super.noSuchMethod( + Invocation.getter(#onDone), + returnValue: _i3.Future.value(), + ) as _i3.Future); + @override _i3.Stream<_i2.Event> get onVMEvent => (super.noSuchMethod( Invocation.getter(#onVMEvent), @@ -414,24 +455,6 @@ class MockVmService extends _i1.Mock implements _i2.VmService { returnValue: _i3.Stream<_i2.Event>.empty(), ) as _i3.Stream<_i2.Event>); - @override - _i3.Stream get onSend => (super.noSuchMethod( - Invocation.getter(#onSend), - returnValue: _i3.Stream.empty(), - ) as _i3.Stream); - - @override - _i3.Stream get onReceive => (super.noSuchMethod( - Invocation.getter(#onReceive), - returnValue: _i3.Stream.empty(), - ) as _i3.Stream); - - @override - _i3.Future get onDone => (super.noSuchMethod( - Invocation.getter(#onDone), - returnValue: _i3.Future.value(), - ) as _i3.Future); - @override _i3.Stream<_i2.Event> onEvent(String? streamId) => (super.noSuchMethod( Invocation.method( @@ -559,6 +582,87 @@ class MockVmService extends _i1.Mock implements _i2.VmService { )), ) as _i3.Future<_i2.Success>); + @override + _i3.Future<_i2.IdZone> createIdZone( + String? isolateId, + String? backingBufferKind, + String? idAssignmentPolicy, { + int? capacity, + }) => + (super.noSuchMethod( + Invocation.method( + #createIdZone, + [ + isolateId, + backingBufferKind, + idAssignmentPolicy, + ], + {#capacity: capacity}, + ), + returnValue: _i3.Future<_i2.IdZone>.value(_FakeIdZone_2( + this, + Invocation.method( + #createIdZone, + [ + isolateId, + backingBufferKind, + idAssignmentPolicy, + ], + {#capacity: capacity}, + ), + )), + ) as _i3.Future<_i2.IdZone>); + + @override + _i3.Future<_i2.Success> deleteIdZone( + String? isolateId, + String? idZoneId, + ) => + (super.noSuchMethod( + Invocation.method( + #deleteIdZone, + [ + isolateId, + idZoneId, + ], + ), + returnValue: _i3.Future<_i2.Success>.value(_FakeSuccess_1( + this, + Invocation.method( + #deleteIdZone, + [ + isolateId, + idZoneId, + ], + ), + )), + ) as _i3.Future<_i2.Success>); + + @override + _i3.Future<_i2.Success> invalidateIdZone( + String? isolateId, + String? idZoneId, + ) => + (super.noSuchMethod( + Invocation.method( + #invalidateIdZone, + [ + isolateId, + idZoneId, + ], + ), + returnValue: _i3.Future<_i2.Success>.value(_FakeSuccess_1( + this, + Invocation.method( + #invalidateIdZone, + [ + isolateId, + idZoneId, + ], + ), + )), + ) as _i3.Future<_i2.Success>); + @override _i3.Future<_i2.Response> invoke( String? isolateId, @@ -566,6 +670,7 @@ class MockVmService extends _i1.Mock implements _i2.VmService { String? selector, List? argumentIds, { bool? disableBreakpoints, + String? idZoneId, }) => (super.noSuchMethod( Invocation.method( @@ -576,9 +681,12 @@ class MockVmService extends _i1.Mock implements _i2.VmService { selector, argumentIds, ], - {#disableBreakpoints: disableBreakpoints}, + { + #disableBreakpoints: disableBreakpoints, + #idZoneId: idZoneId, + }, ), - returnValue: _i3.Future<_i2.Response>.value(_FakeResponse_2( + returnValue: _i3.Future<_i2.Response>.value(_FakeResponse_3( this, Invocation.method( #invoke, @@ -588,7 +696,10 @@ class MockVmService extends _i1.Mock implements _i2.VmService { selector, argumentIds, ], - {#disableBreakpoints: disableBreakpoints}, + { + #disableBreakpoints: disableBreakpoints, + #idZoneId: idZoneId, + }, ), )), ) as _i3.Future<_i2.Response>); @@ -600,6 +711,7 @@ class MockVmService extends _i1.Mock implements _i2.VmService { String? expression, { Map? scope, bool? disableBreakpoints, + String? idZoneId, }) => (super.noSuchMethod( Invocation.method( @@ -612,9 +724,10 @@ class MockVmService extends _i1.Mock implements _i2.VmService { { #scope: scope, #disableBreakpoints: disableBreakpoints, + #idZoneId: idZoneId, }, ), - returnValue: _i3.Future<_i2.Response>.value(_FakeResponse_2( + returnValue: _i3.Future<_i2.Response>.value(_FakeResponse_3( this, Invocation.method( #evaluate, @@ -626,6 +739,7 @@ class MockVmService extends _i1.Mock implements _i2.VmService { { #scope: scope, #disableBreakpoints: disableBreakpoints, + #idZoneId: idZoneId, }, ), )), @@ -638,6 +752,7 @@ class MockVmService extends _i1.Mock implements _i2.VmService { String? expression, { Map? scope, bool? disableBreakpoints, + String? idZoneId, }) => (super.noSuchMethod( Invocation.method( @@ -650,9 +765,10 @@ class MockVmService extends _i1.Mock implements _i2.VmService { { #scope: scope, #disableBreakpoints: disableBreakpoints, + #idZoneId: idZoneId, }, ), - returnValue: _i3.Future<_i2.Response>.value(_FakeResponse_2( + returnValue: _i3.Future<_i2.Response>.value(_FakeResponse_3( this, Invocation.method( #evaluateInFrame, @@ -664,6 +780,7 @@ class MockVmService extends _i1.Mock implements _i2.VmService { { #scope: scope, #disableBreakpoints: disableBreakpoints, + #idZoneId: idZoneId, }, ), )), @@ -685,7 +802,7 @@ class MockVmService extends _i1.Mock implements _i2.VmService { }, ), returnValue: - _i3.Future<_i2.AllocationProfile>.value(_FakeAllocationProfile_3( + _i3.Future<_i2.AllocationProfile>.value(_FakeAllocationProfile_4( this, Invocation.method( #getAllocationProfile, @@ -715,7 +832,7 @@ class MockVmService extends _i1.Mock implements _i2.VmService { #classId: classId, }, ), - returnValue: _i3.Future<_i2.CpuSamples>.value(_FakeCpuSamples_4( + returnValue: _i3.Future<_i2.CpuSamples>.value(_FakeCpuSamples_5( this, Invocation.method( #getAllocationTraces, @@ -736,7 +853,7 @@ class MockVmService extends _i1.Mock implements _i2.VmService { #getClassList, [isolateId], ), - returnValue: _i3.Future<_i2.ClassList>.value(_FakeClassList_5( + returnValue: _i3.Future<_i2.ClassList>.value(_FakeClassList_6( this, Invocation.method( #getClassList, @@ -760,7 +877,7 @@ class MockVmService extends _i1.Mock implements _i2.VmService { timeExtentMicros, ], ), - returnValue: _i3.Future<_i2.CpuSamples>.value(_FakeCpuSamples_4( + returnValue: _i3.Future<_i2.CpuSamples>.value(_FakeCpuSamples_5( this, Invocation.method( #getCpuSamples, @@ -779,7 +896,7 @@ class MockVmService extends _i1.Mock implements _i2.VmService { #getFlagList, [], ), - returnValue: _i3.Future<_i2.FlagList>.value(_FakeFlagList_6( + returnValue: _i3.Future<_i2.FlagList>.value(_FakeFlagList_7( this, Invocation.method( #getFlagList, @@ -792,8 +909,9 @@ class MockVmService extends _i1.Mock implements _i2.VmService { _i3.Future<_i2.InboundReferences> getInboundReferences( String? isolateId, String? targetId, - int? limit, - ) => + int? limit, { + String? idZoneId, + }) => (super.noSuchMethod( Invocation.method( #getInboundReferences, @@ -802,9 +920,10 @@ class MockVmService extends _i1.Mock implements _i2.VmService { targetId, limit, ], + {#idZoneId: idZoneId}, ), returnValue: - _i3.Future<_i2.InboundReferences>.value(_FakeInboundReferences_7( + _i3.Future<_i2.InboundReferences>.value(_FakeInboundReferences_8( this, Invocation.method( #getInboundReferences, @@ -813,6 +932,7 @@ class MockVmService extends _i1.Mock implements _i2.VmService { targetId, limit, ], + {#idZoneId: idZoneId}, ), )), ) as _i3.Future<_i2.InboundReferences>); @@ -824,6 +944,7 @@ class MockVmService extends _i1.Mock implements _i2.VmService { int? limit, { bool? includeSubclasses, bool? includeImplementers, + String? idZoneId, }) => (super.noSuchMethod( Invocation.method( @@ -836,9 +957,10 @@ class MockVmService extends _i1.Mock implements _i2.VmService { { #includeSubclasses: includeSubclasses, #includeImplementers: includeImplementers, + #idZoneId: idZoneId, }, ), - returnValue: _i3.Future<_i2.InstanceSet>.value(_FakeInstanceSet_8( + returnValue: _i3.Future<_i2.InstanceSet>.value(_FakeInstanceSet_9( this, Invocation.method( #getInstances, @@ -850,6 +972,7 @@ class MockVmService extends _i1.Mock implements _i2.VmService { { #includeSubclasses: includeSubclasses, #includeImplementers: includeImplementers, + #idZoneId: idZoneId, }, ), )), @@ -861,6 +984,7 @@ class MockVmService extends _i1.Mock implements _i2.VmService { String? objectId, { bool? includeSubclasses, bool? includeImplementers, + String? idZoneId, }) => (super.noSuchMethod( Invocation.method( @@ -872,9 +996,10 @@ class MockVmService extends _i1.Mock implements _i2.VmService { { #includeSubclasses: includeSubclasses, #includeImplementers: includeImplementers, + #idZoneId: idZoneId, }, ), - returnValue: _i3.Future<_i2.InstanceRef>.value(_FakeInstanceRef_9( + returnValue: _i3.Future<_i2.InstanceRef>.value(_FakeInstanceRef_10( this, Invocation.method( #getInstancesAsList, @@ -885,6 +1010,7 @@ class MockVmService extends _i1.Mock implements _i2.VmService { { #includeSubclasses: includeSubclasses, #includeImplementers: includeImplementers, + #idZoneId: idZoneId, }, ), )), @@ -896,7 +1022,7 @@ class MockVmService extends _i1.Mock implements _i2.VmService { #getIsolate, [isolateId], ), - returnValue: _i3.Future<_i2.Isolate>.value(_FakeIsolate_10( + returnValue: _i3.Future<_i2.Isolate>.value(_FakeIsolate_11( this, Invocation.method( #getIsolate, @@ -912,7 +1038,7 @@ class MockVmService extends _i1.Mock implements _i2.VmService { #getIsolateGroup, [isolateGroupId], ), - returnValue: _i3.Future<_i2.IsolateGroup>.value(_FakeIsolateGroup_11( + returnValue: _i3.Future<_i2.IsolateGroup>.value(_FakeIsolateGroup_12( this, Invocation.method( #getIsolateGroup, @@ -928,7 +1054,7 @@ class MockVmService extends _i1.Mock implements _i2.VmService { #getIsolatePauseEvent, [isolateId], ), - returnValue: _i3.Future<_i2.Event>.value(_FakeEvent_12( + returnValue: _i3.Future<_i2.Event>.value(_FakeEvent_13( this, Invocation.method( #getIsolatePauseEvent, @@ -944,7 +1070,7 @@ class MockVmService extends _i1.Mock implements _i2.VmService { #getMemoryUsage, [isolateId], ), - returnValue: _i3.Future<_i2.MemoryUsage>.value(_FakeMemoryUsage_13( + returnValue: _i3.Future<_i2.MemoryUsage>.value(_FakeMemoryUsage_14( this, Invocation.method( #getMemoryUsage, @@ -961,7 +1087,7 @@ class MockVmService extends _i1.Mock implements _i2.VmService { #getIsolateGroupMemoryUsage, [isolateGroupId], ), - returnValue: _i3.Future<_i2.MemoryUsage>.value(_FakeMemoryUsage_13( + returnValue: _i3.Future<_i2.MemoryUsage>.value(_FakeMemoryUsage_14( this, Invocation.method( #getIsolateGroupMemoryUsage, @@ -977,7 +1103,7 @@ class MockVmService extends _i1.Mock implements _i2.VmService { #getScripts, [isolateId], ), - returnValue: _i3.Future<_i2.ScriptList>.value(_FakeScriptList_14( + returnValue: _i3.Future<_i2.ScriptList>.value(_FakeScriptList_15( this, Invocation.method( #getScripts, @@ -992,6 +1118,7 @@ class MockVmService extends _i1.Mock implements _i2.VmService { String? objectId, { int? offset, int? count, + String? idZoneId, }) => (super.noSuchMethod( Invocation.method( @@ -1003,9 +1130,10 @@ class MockVmService extends _i1.Mock implements _i2.VmService { { #offset: offset, #count: count, + #idZoneId: idZoneId, }, ), - returnValue: _i3.Future<_i2.Obj>.value(_FakeObj_15( + returnValue: _i3.Future<_i2.Obj>.value(_FakeObj_16( this, Invocation.method( #getObject, @@ -1016,6 +1144,7 @@ class MockVmService extends _i1.Mock implements _i2.VmService { { #offset: offset, #count: count, + #idZoneId: idZoneId, }, ), )), @@ -1037,7 +1166,7 @@ class MockVmService extends _i1.Mock implements _i2.VmService { }, ), returnValue: - _i3.Future<_i2.PerfettoCpuSamples>.value(_FakePerfettoCpuSamples_16( + _i3.Future<_i2.PerfettoCpuSamples>.value(_FakePerfettoCpuSamples_17( this, Invocation.method( #getPerfettoCpuSamples, @@ -1065,7 +1194,7 @@ class MockVmService extends _i1.Mock implements _i2.VmService { }, ), returnValue: - _i3.Future<_i2.PerfettoTimeline>.value(_FakePerfettoTimeline_17( + _i3.Future<_i2.PerfettoTimeline>.value(_FakePerfettoTimeline_18( this, Invocation.method( #getPerfettoVMTimeline, @@ -1084,7 +1213,7 @@ class MockVmService extends _i1.Mock implements _i2.VmService { #getPorts, [isolateId], ), - returnValue: _i3.Future<_i2.PortList>.value(_FakePortList_18( + returnValue: _i3.Future<_i2.PortList>.value(_FakePortList_19( this, Invocation.method( #getPorts, @@ -1097,8 +1226,9 @@ class MockVmService extends _i1.Mock implements _i2.VmService { _i3.Future<_i2.RetainingPath> getRetainingPath( String? isolateId, String? targetId, - int? limit, - ) => + int? limit, { + String? idZoneId, + }) => (super.noSuchMethod( Invocation.method( #getRetainingPath, @@ -1107,8 +1237,9 @@ class MockVmService extends _i1.Mock implements _i2.VmService { targetId, limit, ], + {#idZoneId: idZoneId}, ), - returnValue: _i3.Future<_i2.RetainingPath>.value(_FakeRetainingPath_19( + returnValue: _i3.Future<_i2.RetainingPath>.value(_FakeRetainingPath_20( this, Invocation.method( #getRetainingPath, @@ -1117,6 +1248,7 @@ class MockVmService extends _i1.Mock implements _i2.VmService { targetId, limit, ], + {#idZoneId: idZoneId}, ), )), ) as _i3.Future<_i2.RetainingPath>); @@ -1129,7 +1261,7 @@ class MockVmService extends _i1.Mock implements _i2.VmService { [], ), returnValue: - _i3.Future<_i2.ProcessMemoryUsage>.value(_FakeProcessMemoryUsage_20( + _i3.Future<_i2.ProcessMemoryUsage>.value(_FakeProcessMemoryUsage_21( this, Invocation.method( #getProcessMemoryUsage, @@ -1142,19 +1274,26 @@ class MockVmService extends _i1.Mock implements _i2.VmService { _i3.Future<_i2.Stack> getStack( String? isolateId, { int? limit, + String? idZoneId, }) => (super.noSuchMethod( Invocation.method( #getStack, [isolateId], - {#limit: limit}, + { + #limit: limit, + #idZoneId: idZoneId, + }, ), - returnValue: _i3.Future<_i2.Stack>.value(_FakeStack_21( + returnValue: _i3.Future<_i2.Stack>.value(_FakeStack_22( this, Invocation.method( #getStack, [isolateId], - {#limit: limit}, + { + #limit: limit, + #idZoneId: idZoneId, + }, ), )), ) as _i3.Future<_i2.Stack>); @@ -1165,7 +1304,7 @@ class MockVmService extends _i1.Mock implements _i2.VmService { #getSupportedProtocols, [], ), - returnValue: _i3.Future<_i2.ProtocolList>.value(_FakeProtocolList_22( + returnValue: _i3.Future<_i2.ProtocolList>.value(_FakeProtocolList_23( this, Invocation.method( #getSupportedProtocols, @@ -1203,7 +1342,7 @@ class MockVmService extends _i1.Mock implements _i2.VmService { #librariesAlreadyCompiled: librariesAlreadyCompiled, }, ), - returnValue: _i3.Future<_i2.SourceReport>.value(_FakeSourceReport_23( + returnValue: _i3.Future<_i2.SourceReport>.value(_FakeSourceReport_24( this, Invocation.method( #getSourceReport, @@ -1230,7 +1369,7 @@ class MockVmService extends _i1.Mock implements _i2.VmService { #getVersion, [], ), - returnValue: _i3.Future<_i2.Version>.value(_FakeVersion_24( + returnValue: _i3.Future<_i2.Version>.value(_FakeVersion_25( this, Invocation.method( #getVersion, @@ -1245,7 +1384,7 @@ class MockVmService extends _i1.Mock implements _i2.VmService { #getVM, [], ), - returnValue: _i3.Future<_i2.VM>.value(_FakeVM_25( + returnValue: _i3.Future<_i2.VM>.value(_FakeVM_26( this, Invocation.method( #getVM, @@ -1268,7 +1407,7 @@ class MockVmService extends _i1.Mock implements _i2.VmService { #timeExtentMicros: timeExtentMicros, }, ), - returnValue: _i3.Future<_i2.Timeline>.value(_FakeTimeline_26( + returnValue: _i3.Future<_i2.Timeline>.value(_FakeTimeline_27( this, Invocation.method( #getVMTimeline, @@ -1287,7 +1426,7 @@ class MockVmService extends _i1.Mock implements _i2.VmService { #getVMTimelineFlags, [], ), - returnValue: _i3.Future<_i2.TimelineFlags>.value(_FakeTimelineFlags_27( + returnValue: _i3.Future<_i2.TimelineFlags>.value(_FakeTimelineFlags_28( this, Invocation.method( #getVMTimelineFlags, @@ -1302,7 +1441,7 @@ class MockVmService extends _i1.Mock implements _i2.VmService { #getVMTimelineMicros, [], ), - returnValue: _i3.Future<_i2.Timestamp>.value(_FakeTimestamp_28( + returnValue: _i3.Future<_i2.Timestamp>.value(_FakeTimestamp_29( this, Invocation.method( #getVMTimelineMicros, @@ -1356,7 +1495,7 @@ class MockVmService extends _i1.Mock implements _i2.VmService { ], {#local: local}, ), - returnValue: _i3.Future<_i2.UriList>.value(_FakeUriList_29( + returnValue: _i3.Future<_i2.UriList>.value(_FakeUriList_30( this, Invocation.method( #lookupResolvedPackageUris, @@ -1382,7 +1521,7 @@ class MockVmService extends _i1.Mock implements _i2.VmService { uris, ], ), - returnValue: _i3.Future<_i2.UriList>.value(_FakeUriList_29( + returnValue: _i3.Future<_i2.UriList>.value(_FakeUriList_30( this, Invocation.method( #lookupPackageUris, @@ -1438,7 +1577,7 @@ class MockVmService extends _i1.Mock implements _i2.VmService { #packagesUri: packagesUri, }, ), - returnValue: _i3.Future<_i2.ReloadReport>.value(_FakeReloadReport_30( + returnValue: _i3.Future<_i2.ReloadReport>.value(_FakeReloadReport_31( this, Invocation.method( #reloadSources, @@ -1616,7 +1755,7 @@ class MockVmService extends _i1.Mock implements _i2.VmService { value, ], ), - returnValue: _i3.Future<_i2.Response>.value(_FakeResponse_2( + returnValue: _i3.Future<_i2.Response>.value(_FakeResponse_3( this, Invocation.method( #setFlag, @@ -1801,7 +1940,7 @@ class MockVmService extends _i1.Mock implements _i2.VmService { #args: args, }, ), - returnValue: _i3.Future<_i2.Response>.value(_FakeResponse_2( + returnValue: _i3.Future<_i2.Response>.value(_FakeResponse_3( this, Invocation.method( #callMethod, @@ -1829,7 +1968,7 @@ class MockVmService extends _i1.Mock implements _i2.VmService { #args: args, }, ), - returnValue: _i3.Future<_i2.Response>.value(_FakeResponse_2( + returnValue: _i3.Future<_i2.Response>.value(_FakeResponse_3( this, Invocation.method( #callServiceExtension, @@ -1852,6 +1991,44 @@ class MockVmService extends _i1.Mock implements _i2.VmService { returnValueForMissingStub: _i3.Future.value(), ) as _i3.Future); + @override + _i3.Future wrapFuture( + String? name, + _i3.Future? future, + ) => + (super.noSuchMethod( + Invocation.method( + #wrapFuture, + [ + name, + future, + ], + ), + returnValue: _i4.ifNotNull( + _i4.dummyValueOrNull( + this, + Invocation.method( + #wrapFuture, + [ + name, + future, + ], + ), + ), + (T v) => _i3.Future.value(v), + ) ?? + _FakeFuture_32( + this, + Invocation.method( + #wrapFuture, + [ + name, + future, + ], + ), + ), + ) as _i3.Future); + @override void registerServiceCallback( String? service, diff --git a/pkgs/extension_discovery/CHANGELOG.md b/pkgs/extension_discovery/CHANGELOG.md index e9ad79c26..f35371ea5 100644 --- a/pkgs/extension_discovery/CHANGELOG.md +++ b/pkgs/extension_discovery/CHANGELOG.md @@ -1,7 +1,9 @@ -## 2.0.1-wip +## 2.1.0 - Require Dart 3.4. - Update to the latest version of `package:dart_flutter_team_lints`. +- Add `findPackageConfig()` allowing for automatic discovery of the + packageConfig based on a package directory. ## 2.0.0 diff --git a/pkgs/extension_discovery/lib/extension_discovery.dart b/pkgs/extension_discovery/lib/extension_discovery.dart index 197ae6d71..662435ac3 100644 --- a/pkgs/extension_discovery/lib/extension_discovery.dart +++ b/pkgs/extension_discovery/lib/extension_discovery.dart @@ -14,7 +14,7 @@ import 'src/package_config.dart'; import 'src/registry.dart'; import 'src/yaml_config_format.dart'; -export 'src/package_config.dart' show PackageConfigException; +export 'src/package_config.dart' show PackageConfigException, findPackageConfig; /// Information about an extension for target package. final class Extension { @@ -60,8 +60,8 @@ final class Extension { /// * [bool] (`true` or `false`), /// * [String], /// * [num] ([int] or [double]), - /// * [List], and, - /// * [Map]. + /// * `List`, and, + /// * `Map`. final Map config; Extension._({ @@ -101,7 +101,7 @@ final class Extension { /// ### Caching results /// /// When [useCache] is `true` then the detected extensions will be cached -/// in `.dart_tool/extension_discovery/.yaml`. +/// in `.dart_tool/extension_discovery/.json`. /// This function will compare modification timestamps of /// `.dart_tool/package_config.json` with the cache file, before reusing cached /// results. diff --git a/pkgs/extension_discovery/lib/src/package_config.dart b/pkgs/extension_discovery/lib/src/package_config.dart index 478da8e56..f2eaffc4e 100644 --- a/pkgs/extension_discovery/lib/src/package_config.dart +++ b/pkgs/extension_discovery/lib/src/package_config.dart @@ -8,6 +8,36 @@ import 'expect_json.dart'; typedef PackageConfigEntry = ({String name, Uri rootUri, Uri packageUri}); typedef PackageConfig = List; +/// Searches in [packageDir] and all directories above for a +/// `.dart_tool/package_config.json` file. Returns the Uri of that file if +/// found. +/// +/// Returns `null` if no file was found. +Uri? findPackageConfig(Uri packageDir) { + if (!packageDir.isScheme('file')) { + throw ArgumentError( + 'Expected [packageDir] to be a file URI, got $packageDir', + ); + } + if (!packageDir.path.endsWith('/')) { + packageDir = packageDir.replace(path: '${packageDir.path}/'); + } + while (true) { + final packageConfigCandidate = + packageDir.resolve('.dart_tool/package_config.json'); + try { + if (File.fromUri(packageConfigCandidate).existsSync()) { + return packageConfigCandidate; + } + } on IOException { + return null; // if we get a permission error, etc, we return null + } + final next = packageDir.resolve('..'); + if (next == packageDir) return null; + packageDir = next; + } +} + /// Load list of packages and associated URIs from the /// `.dart_tool/package_config.json` file in [packageConfigFile]. Future loadPackageConfig( diff --git a/pkgs/extension_discovery/lib/src/yaml_config_format.dart b/pkgs/extension_discovery/lib/src/yaml_config_format.dart index 53da6d3d8..a28b31b33 100644 --- a/pkgs/extension_discovery/lib/src/yaml_config_format.dart +++ b/pkgs/extension_discovery/lib/src/yaml_config_format.dart @@ -38,8 +38,8 @@ import 'package:yaml/yaml.dart' /// * [bool] (`true` or `false`), /// * [String], /// * [num] ([int] or [double]), -/// * [List], and, -/// * [Map]. +/// * `List`, and, +/// * `Map`. Map parseYamlFromConfigFile(String yamlString) { final visited = {}; Object? toPlainType(YamlNode n) { diff --git a/pkgs/extension_discovery/pubspec.yaml b/pkgs/extension_discovery/pubspec.yaml index 88571cbbc..05acdbd0b 100644 --- a/pkgs/extension_discovery/pubspec.yaml +++ b/pkgs/extension_discovery/pubspec.yaml @@ -1,7 +1,7 @@ name: extension_discovery description: >- A convention and utilities for package extension discovery. -version: 2.0.1-wip +version: 2.1.0 repository: https://github.com/dart-lang/tools/tree/main/pkgs/extension_discovery environment: diff --git a/pkgs/extension_discovery/test/package_config_test.dart b/pkgs/extension_discovery/test/package_config_test.dart index 343ab540f..83c6c4df0 100644 --- a/pkgs/extension_discovery/test/package_config_test.dart +++ b/pkgs/extension_discovery/test/package_config_test.dart @@ -159,4 +159,34 @@ void main() { throwsA(isA()), ); }); + + test('`findPackageConfig()`', () async { + await d.dir('workspace', [ + d.dir('.dart_tool', [ + d.file('package_config.json'), + ]), + d.dir('myapp', []) + ]).create(); + + expect( + findPackageConfig(d.fileUri('workspace')), + d.fileUri('workspace/.dart_tool/package_config.json'), + ); + expect( + findPackageConfig(d.fileUri('workspace/')), + d.fileUri('workspace/.dart_tool/package_config.json'), + ); + expect( + findPackageConfig(d.fileUri('workspace/myapp')), + d.fileUri('workspace/.dart_tool/package_config.json'), + ); + expect( + findPackageConfig(d.fileUri('.')), + isNull, + ); + expect( + findPackageConfig(d.fileUri('foo')), + isNull, + ); + }); } diff --git a/pkgs/extension_discovery/test/test_descriptor.dart b/pkgs/extension_discovery/test/test_descriptor.dart index e0dc4a779..0bd4a63a7 100644 --- a/pkgs/extension_discovery/test/test_descriptor.dart +++ b/pkgs/extension_discovery/test/test_descriptor.dart @@ -53,4 +53,4 @@ Future dart([ } Future dartPubGet(String folder) async => - await dart('pub', 'get', '-C', d.path('myapp')); + await dart('pub', 'get', '-C', folder); diff --git a/pkgs/mime/CHANGELOG.md b/pkgs/mime/CHANGELOG.md index 50f243306..fd5a24905 100644 --- a/pkgs/mime/CHANGELOG.md +++ b/pkgs/mime/CHANGELOG.md @@ -1,3 +1,8 @@ +## 2.0.0 + +* **[Breaking]** `extensionFromMime(String mimeType)` returns `null` instead of `mimeType` for an unknown mime type. +* Update `extensionFromMime` to return a default extension when a MIME type maps to multiple extensions. + ## 1.0.6 * Add `topics` section to `pubspec.yaml`. diff --git a/pkgs/mime/CONTRIBUTING.md b/pkgs/mime/CONTRIBUTING.md index 6f5e0ea67..463063ae4 100644 --- a/pkgs/mime/CONTRIBUTING.md +++ b/pkgs/mime/CONTRIBUTING.md @@ -31,3 +31,7 @@ All files in the project must start with the following header. Contributions made by corporations are covered by a different agreement than the one above, the [Software Grant and Corporate Contributor License Agreement](https://developers.google.com/open-source/cla/corporate). + +### Adding an extension / MIME type mapping +If a MIME type ends up with multiple extensions, it is recommended to define a +preferred extension in `_defaultMimeTypeMap` in [extension.dart](lib/src/extension.dart). \ No newline at end of file diff --git a/pkgs/mime/README.md b/pkgs/mime/README.md index 8a814150c..da06de62b 100644 --- a/pkgs/mime/README.md +++ b/pkgs/mime/README.md @@ -57,3 +57,14 @@ request .map((part) => part.fold(0, (p, d) => p + d)) .listen((length) => print('Part with length $length')); ``` + +## Determining file extension by MIME type + +The top level function `extensionFromMime` can be used to determine the +file extension of a given MIME type. + +```dart +print(extensionFromMime('text/html')); // Prints "html". +print(extensionFromMime('image/jpeg')); // Prints "jpg". +print(extensionFromMime('application/pdf')); // Prints "pdf". +``` diff --git a/pkgs/mime/lib/mime.dart b/pkgs/mime/lib/mime.dart index f2c446403..cb450981f 100644 --- a/pkgs/mime/lib/mime.dart +++ b/pkgs/mime/lib/mime.dart @@ -9,6 +9,7 @@ /// [Internet media type](http://en.wikipedia.org/wiki/Internet_media_type). library; +export 'src/extension.dart'; export 'src/mime_multipart_transformer.dart'; export 'src/mime_shared.dart'; export 'src/mime_type.dart'; diff --git a/pkgs/mime/lib/src/bound_multipart_stream.dart b/pkgs/mime/lib/src/bound_multipart_stream.dart index 0830a610e..03b213be4 100644 --- a/pkgs/mime/lib/src/bound_multipart_stream.dart +++ b/pkgs/mime/lib/src/bound_multipart_stream.dart @@ -348,7 +348,6 @@ class BoundMultipartStream { default: // Should be unreachable. assert(false); - break; } // Move to the next byte. diff --git a/pkgs/mime/lib/src/extension.dart b/pkgs/mime/lib/src/extension.dart new file mode 100644 index 000000000..293449a0e --- /dev/null +++ b/pkgs/mime/lib/src/extension.dart @@ -0,0 +1,55 @@ +// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'default_extension_map.dart'; + +/// Default extension for recognized MIME types. +/// +/// Is the inverse of [defaultExtensionMap], and where that +/// map has multiple extensions which map to the same +/// MIME type, this map maps that MIME type to a *default* +/// extension. +/// +/// Used by [extensionFromMime]. +final Map _defaultMimeTypeMap = { + for (var entry in defaultExtensionMap.entries) entry.value: entry.key, + 'application/msword': 'doc', + 'application/vnd.ms-excel': 'xls', + 'application/vnd.ms-powerpoint': 'ppt', + 'application/x-debian-package': 'deb', + 'application/xhtml+xml': 'xhtml', + 'application/xml': 'xml', + 'audio/x-aiff': 'aif', + 'audio/midi': 'mid', + 'audio/mp4': 'm4a', + 'audio/ogg': 'ogg', + 'image/jpeg': 'jpg', + 'image/tiff': 'tif', + 'image/svg+xml': 'svg', + 'model/vrml': 'vrml', + 'text/calendar': 'ics', + 'text/html': 'html', + 'text/javascript': 'js', + 'text/markdown': 'md', + 'text/plain': 'txt', + 'text/sgml': 'sgml', + 'text/x-asm': 'asm', + 'text/x-c': 'c', + 'text/x-pascal': 'pas', + 'video/mp4': 'mp4', + 'video/mpeg': 'mpg', + 'video/quicktime': 'mov', + 'video/x-matroska': 'mkv', +}; + +/// The default file extension for a given MIME type. +/// +/// If [mimeType] has multiple associated extensions, +/// the returned string is one of those, chosen as the default +/// extension for that MIME type. +/// +/// Returns `null` if [mimeType] is not a recognized and +/// supported MIME type. +String? extensionFromMime(String mimeType) => + _defaultMimeTypeMap[mimeType.toLowerCase()]; diff --git a/pkgs/mime/lib/src/mime_type.dart b/pkgs/mime/lib/src/mime_type.dart index 03121c97b..9cf9194a1 100644 --- a/pkgs/mime/lib/src/mime_type.dart +++ b/pkgs/mime/lib/src/mime_type.dart @@ -23,20 +23,6 @@ int get defaultMagicNumbersMaxLength => _globalResolver.magicNumbersMaxLength; String? lookupMimeType(String path, {List? headerBytes}) => _globalResolver.lookup(path, headerBytes: headerBytes); -/// Returns the extension for the given MIME type. -/// -/// If there are multiple extensions for [mime], return the first occurrence in -/// the map. If there are no extensions for [mime], return [mime]. -String extensionFromMime(String mime) { - mime = mime.toLowerCase(); - for (final entry in defaultExtensionMap.entries) { - if (defaultExtensionMap[entry.key] == mime) { - return entry.key; - } - } - return mime; -} - /// MIME-type resolver class, used to customize the lookup of mime-types. class MimeTypeResolver { final Map _extensionMap = {}; diff --git a/pkgs/mime/pubspec.yaml b/pkgs/mime/pubspec.yaml index 8d3c49823..41b384208 100644 --- a/pkgs/mime/pubspec.yaml +++ b/pkgs/mime/pubspec.yaml @@ -1,5 +1,5 @@ name: mime -version: 1.0.6 +version: 2.0.0 description: >- Utilities for handling media (MIME) types, including determining a type from a file extension and file contents. diff --git a/pkgs/mime/test/extension_test.dart b/pkgs/mime/test/extension_test.dart new file mode 100644 index 000000000..40dae6df5 --- /dev/null +++ b/pkgs/mime/test/extension_test.dart @@ -0,0 +1,33 @@ +// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:mime/mime.dart'; +import 'package:test/test.dart'; + +void main() { + test('valid-mime-type', () { + expect(extensionFromMime('text/x-dart'), equals('dart')); + expect(extensionFromMime('text/javascript'), equals('js')); + expect(extensionFromMime('application/java-archive'), equals('jar')); + expect(extensionFromMime('application/json'), equals('json')); + expect(extensionFromMime('application/pdf'), equals('pdf')); + expect(extensionFromMime('application/vnd.ms-excel'), equals('xls')); + expect(extensionFromMime('application/xhtml+xml'), equals('xhtml')); + expect(extensionFromMime('image/jpeg'), equals('jpg')); + expect(extensionFromMime('image/png'), equals('png')); + expect(extensionFromMime('text/css'), equals('css')); + expect(extensionFromMime('text/html'), equals('html')); + expect(extensionFromMime('text/plain'), equals('txt')); + expect(extensionFromMime('text/x-c'), equals('c')); + }); + + test('invalid-mime-type', () { + expect(extensionFromMime('invalid-mime-type'), isNull); + expect(extensionFromMime('invalid/mime/type'), isNull); + }); + + test('unknown-mime-type', () { + expect(extensionFromMime('application/to-be-invented'), isNull); + }); +} diff --git a/pkgs/mime/test/mime_type_test.dart b/pkgs/mime/test/mime_type_test.dart index f7388ff34..23cb34af3 100644 --- a/pkgs/mime/test/mime_type_test.dart +++ b/pkgs/mime/test/mime_type_test.dart @@ -317,22 +317,4 @@ void main() { expect(initialMagicNumbersMaxLength, actualMaxBytes); }); - - group('extensionFromMime', () { - test('returns match for mime with single extension', () { - expect(extensionFromMime('application/json'), equals('json')); - expect(extensionFromMime('application/java-archive'), equals('jar')); - }); - - test('returns first match for mime with multiple extensions', () { - expect(extensionFromMime('text/html'), equals('htm')); - expect(extensionFromMime('application/x-cbr'), equals('cb7')); - }); - - test('returns inputted string for unrecognized mime', () { - expect( - extensionFromMime('unrecognized_mime'), equals('unrecognized_mime')); - expect(extensionFromMime('i/am/not/a/mime'), equals('i/am/not/a/mime')); - }); - }); } diff --git a/pkgs/oauth2/CHANGELOG.md b/pkgs/oauth2/CHANGELOG.md index 33d927e25..ff39de3fb 100644 --- a/pkgs/oauth2/CHANGELOG.md +++ b/pkgs/oauth2/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.0.4-wip + +* Require Dart 3.4 + ## 2.0.3 * Require `package:http` v1.0.0 diff --git a/pkgs/oauth2/analysis_options.yaml b/pkgs/oauth2/analysis_options.yaml index 68d2a49af..e21412ca6 100644 --- a/pkgs/oauth2/analysis_options.yaml +++ b/pkgs/oauth2/analysis_options.yaml @@ -10,34 +10,14 @@ analyzer: linter: rules: - - always_declare_return_types - - avoid_catching_errors - - avoid_dynamic_calls - avoid_private_typedef_functions - avoid_unused_constructor_parameters - avoid_void_async - cancel_subscriptions - - directives_ordering - literal_only_boolean_expressions - no_adjacent_strings_in_list - no_runtimeType_toString - - omit_local_variable_types - - only_throw_errors - package_api_docs - - prefer_asserts_in_initializer_lists - - prefer_const_constructors - prefer_const_declarations - - prefer_relative_imports - - prefer_single_quotes - - sort_pub_dependencies - - test_types_in_equals - - throw_in_finally - - type_annotate_public_apis - - unawaited_futures - unnecessary_await_in_return - - unnecessary_lambdas - - unnecessary_parenthesis - - unnecessary_statements - - use_is_even_rather_than_modulo - use_string_buffers - - use_super_parameters diff --git a/pkgs/oauth2/pubspec.yaml b/pkgs/oauth2/pubspec.yaml index 9c89b7bd4..75ded1874 100644 --- a/pkgs/oauth2/pubspec.yaml +++ b/pkgs/oauth2/pubspec.yaml @@ -1,5 +1,5 @@ name: oauth2 -version: 2.0.3 +version: 2.0.4-wip description: >- A client library for authenticating with a remote service via OAuth2 on behalf of a user, and making authorized HTTP requests with the user's @@ -7,7 +7,7 @@ description: >- repository: https://github.com/dart-lang/tools/tree/main/pkgs/oauth2 environment: - sdk: ^3.0.0 + sdk: ^3.4.0 dependencies: collection: ^1.15.0 @@ -16,5 +16,5 @@ dependencies: http_parser: ^4.0.0 dev_dependencies: - dart_flutter_team_lints: ^2.0.0 + dart_flutter_team_lints: ^3.0.0 test: ^1.16.0 diff --git a/pkgs/source_map_stack_trace/CHANGELOG.md b/pkgs/source_map_stack_trace/CHANGELOG.md index 64300db63..00c66d9cc 100644 --- a/pkgs/source_map_stack_trace/CHANGELOG.md +++ b/pkgs/source_map_stack_trace/CHANGELOG.md @@ -1,3 +1,5 @@ +## 2.1.3-wip + ## 2.1.2 * Require Dart 3.3.0 diff --git a/pkgs/source_map_stack_trace/pubspec.yaml b/pkgs/source_map_stack_trace/pubspec.yaml index ecd579ae2..d4b8c3aa6 100644 --- a/pkgs/source_map_stack_trace/pubspec.yaml +++ b/pkgs/source_map_stack_trace/pubspec.yaml @@ -1,5 +1,5 @@ name: source_map_stack_trace -version: 2.1.2 +version: 2.1.3-wip description: A package for applying source maps to stack traces. repository: https://github.com/dart-lang/tools/tree/main/pkgs/source_map_stack_trace @@ -12,6 +12,6 @@ dependencies: stack_trace: ^1.10.0 dev_dependencies: - dart_flutter_team_lints: ^2.0.0 + dart_flutter_team_lints: ^3.0.0 source_span: ^1.8.0 test: ^1.16.0 diff --git a/pkgs/unified_analytics/CHANGELOG.md b/pkgs/unified_analytics/CHANGELOG.md index 0a53660bf..80d889fe6 100644 --- a/pkgs/unified_analytics/CHANGELOG.md +++ b/pkgs/unified_analytics/CHANGELOG.md @@ -1,6 +1,13 @@ -## 6.1.3-wip +## 6.1.4-wip + +- Fix formatting and remove dependency on `package:intl`. +- Remove direct usage of `package:path` in favor of `package:file`. + +## 6.1.3 - Require Dart 3.4. +- Added `isWasm` parameter to the `Event.devtoolsEvent` constructor. +- Added an optional parameter `data` to the `Event.exception` constructor. ## 6.1.2 diff --git a/pkgs/unified_analytics/example/serving_surveys.dart b/pkgs/unified_analytics/example/serving_surveys.dart index cff96ce0f..d56339efd 100644 --- a/pkgs/unified_analytics/example/serving_surveys.dart +++ b/pkgs/unified_analytics/example/serving_surveys.dart @@ -5,7 +5,6 @@ import 'package:clock/clock.dart'; import 'package:file/file.dart'; import 'package:file/memory.dart'; -import 'package:path/path.dart' as p; import 'package:unified_analytics/src/constants.dart'; import 'package:unified_analytics/src/enums.dart'; @@ -54,11 +53,9 @@ void main() async { fs: fs, platform: DevicePlatform.macos, surveyHandler: FakeSurveyHandler.fromList( - dismissedSurveyFile: fs.file(p.join( - home.path, - kDartToolDirectoryName, - kDismissedSurveyFileName, - )), + dismissedSurveyFile: home + .childDirectory(kDartToolDirectoryName) + .childFile(kDismissedSurveyFileName), initializedSurveys: [ Survey( uniqueId: 'uniqueId', diff --git a/pkgs/unified_analytics/lib/src/analytics.dart b/pkgs/unified_analytics/lib/src/analytics.dart index e0f3de962..cc8b4bc11 100644 --- a/pkgs/unified_analytics/lib/src/analytics.dart +++ b/pkgs/unified_analytics/lib/src/analytics.dart @@ -8,9 +8,7 @@ import 'package:file/file.dart'; import 'package:file/local.dart'; import 'package:file/memory.dart'; import 'package:http/http.dart'; -import 'package:intl/date_symbol_data_local.dart'; import 'package:meta/meta.dart'; -import 'package:path/path.dart' as p; import 'asserts.dart'; import 'config_handler.dart'; @@ -79,7 +77,7 @@ abstract class Analytics { apiSecret: kGoogleAnalyticsApiSecret, ); - final firstRun = runInitialization(homeDirectory: homeDirectory, fs: fs); + final firstRun = runInitialization(homeDirectory: homeDirectory); return AnalyticsImpl( tool: tool, @@ -92,11 +90,9 @@ abstract class Analytics { fs: fs, gaClient: gaClient, surveyHandler: SurveyHandler( - dismissedSurveyFile: fs.file(p.join( - homeDirectory.path, - kDartToolDirectoryName, - kDismissedSurveyFileName, - )), + dismissedSurveyFile: homeDirectory + .childDirectory(kDartToolDirectoryName) + .childFile(kDismissedSurveyFileName), ), enableAsserts: enableAsserts, clientIde: clientIde, @@ -158,7 +154,7 @@ abstract class Analytics { apiSecret: kTestApiSecret, ); - final firstRun = runInitialization(homeDirectory: homeDirectory, fs: fs); + final firstRun = runInitialization(homeDirectory: homeDirectory); return AnalyticsImpl( tool: tool, @@ -171,11 +167,9 @@ abstract class Analytics { fs: fs, gaClient: gaClient, surveyHandler: SurveyHandler( - dismissedSurveyFile: fs.file(p.join( - homeDirectory.path, - kDartToolDirectoryName, - kDismissedSurveyFileName, - )), + dismissedSurveyFile: homeDirectory + .childDirectory(kDartToolDirectoryName) + .childFile(kDismissedSurveyFileName), ), enableAsserts: enableAsserts, clientIde: clientIde, @@ -308,7 +302,7 @@ abstract class Analytics { String toolsMessage = kToolsMessage, bool enableAsserts = true, }) { - final firstRun = runInitialization(homeDirectory: homeDirectory, fs: fs); + final firstRun = runInitialization(homeDirectory: homeDirectory); return FakeAnalytics._( tool: tool, @@ -321,11 +315,9 @@ abstract class Analytics { fs: fs, surveyHandler: surveyHandler ?? FakeSurveyHandler.fromList( - dismissedSurveyFile: fs.file(p.join( - homeDirectory.path, - kDartToolDirectoryName, - kDismissedSurveyFileName, - )), + dismissedSurveyFile: homeDirectory + .childDirectory(kDartToolDirectoryName) + .childFile(kDismissedSurveyFileName), initializedSurveys: [], ), gaClient: gaClient ?? const FakeGAClient(), @@ -396,17 +388,13 @@ class AnalyticsImpl implements Analytics { }) : _gaClient = gaClient, _surveyHandler = surveyHandler, _enableAsserts = enableAsserts, - _clientIdFile = fs.file(p.join( - homeDirectory.path, - kDartToolDirectoryName, - kClientIdFileName, - )), + _clientIdFile = homeDirectory + .childDirectory(kDartToolDirectoryName) + .childFile(kClientIdFileName), _userProperty = UserProperty( - sessionFile: fs.file(p.join( - homeDirectory.path, - kDartToolDirectoryName, - kSessionFileName, - )), + sessionFile: homeDirectory + .childDirectory(kDartToolDirectoryName) + .childFile(kSessionFileName), flutterChannel: flutterChannel, host: platform.label, flutterVersion: flutterVersion, @@ -421,25 +409,16 @@ class AnalyticsImpl implements Analytics { enabledFeatures: enabledFeatures, ), _configHandler = ConfigHandler( - fs: fs, homeDirectory: homeDirectory, - configFile: fs.file(p.join( - homeDirectory.path, - kDartToolDirectoryName, - kConfigFileName, - )), + configFile: homeDirectory + .childDirectory(kDartToolDirectoryName) + .childFile(kConfigFileName), ), _logHandler = LogHandler( - logFile: fs.file(p.join( - homeDirectory.path, - kDartToolDirectoryName, - kLogFileName, - )), + logFile: homeDirectory + .childDirectory(kDartToolDirectoryName) + .childFile(kLogFileName), ) { - // Initialize date formatting for `package:intl` within constructor - // so clients using this package won't need to - initializeDateFormatting(); - // This initializer class will let the instance know // if it was the first run; if it is, nothing will be sent // on the first run diff --git a/pkgs/unified_analytics/lib/src/config_handler.dart b/pkgs/unified_analytics/lib/src/config_handler.dart index ea6f51ff6..8db46603b 100644 --- a/pkgs/unified_analytics/lib/src/config_handler.dart +++ b/pkgs/unified_analytics/lib/src/config_handler.dart @@ -5,11 +5,9 @@ import 'dart:convert'; import 'package:clock/clock.dart'; +import 'package:convert/convert.dart'; import 'package:file/file.dart'; -import 'package:intl/intl.dart'; -import 'package:path/path.dart' as p; -import 'constants.dart'; import 'initializer.dart'; import 'utils.dart'; @@ -33,7 +31,6 @@ class ConfigHandler { RegExp(telemetryFlagPattern, multiLine: true); static RegExp toolRegex = RegExp(toolPattern, multiLine: true); - final FileSystem fs; final Directory homeDirectory; final File configFile; @@ -45,7 +42,6 @@ class ConfigHandler { bool _telemetryEnabled = true; ConfigHandler({ - required this.fs, required this.homeDirectory, required this.configFile, }) : configFileLastModified = configFile.lastModifiedSync() { @@ -176,12 +172,7 @@ class ConfigHandler { /// [parsedTools] map and trigger parsing the config again. void resetConfig() { createConfigFile( - configFile: fs.file(p.join( - homeDirectory.path, - kDartToolDirectoryName, - kConfigFileName, - )), - fs: fs, + configFile: configFile, homeDirectory: homeDirectory, ); parsedTools.clear(); @@ -226,7 +217,7 @@ class ToolInfo { @override String toString() { return json.encode({ - 'lastRun': DateFormat('yyyy-MM-dd').format(lastRun), + 'lastRun': FixedDateTimeFormatter('YYYY-MM-DD').encode(lastRun), 'versionNumber': versionNumber, }); } diff --git a/pkgs/unified_analytics/lib/src/constants.dart b/pkgs/unified_analytics/lib/src/constants.dart index 42b9952f8..fefa5413b 100644 --- a/pkgs/unified_analytics/lib/src/constants.dart +++ b/pkgs/unified_analytics/lib/src/constants.dart @@ -87,7 +87,7 @@ const int kMaxLogFileSize = 25 * (1 << 20); const String kLogFileName = 'dart-flutter-telemetry.log'; /// The current version of the package, should be in line with pubspec version. -const String kPackageVersion = '6.1.3-wip'; +const String kPackageVersion = '6.1.4-wip'; /// The minimum length for a session. const int kSessionDurationMinutes = 30; diff --git a/pkgs/unified_analytics/lib/src/event.dart b/pkgs/unified_analytics/lib/src/event.dart index 8a720a245..0713a3816 100644 --- a/pkgs/unified_analytics/lib/src/event.dart +++ b/pkgs/unified_analytics/lib/src/event.dart @@ -378,6 +378,7 @@ final class Event { String? isExternalBuild, String? isEmbedded, String? ideLaunchedFeature, + String? isWasm, // PerformanceScreenMetrics int? uiDurationMicros, @@ -419,6 +420,7 @@ final class Event { if (isEmbedded != null) 'isEmbedded': isEmbedded, if (ideLaunchedFeature != null) 'ideLaunchedFeature': ideLaunchedFeature, + if (isWasm != null) 'isWasm': isWasm, // PerformanceScreenMetrics if (uiDurationMicros != null) 'uiDurationMicros': uiDurationMicros, @@ -480,9 +482,15 @@ final class Event { /// exception that we want to log. /// /// [exception] - string representation of the exception that occured. - Event.exception({required String exception}) - : eventName = DashEvent.exception, - eventData = {'exception': exception}; + /// [data] - optional structured data to include with the exception event. + Event.exception({ + required String exception, + Map data = const {}, + }) : eventName = DashEvent.exception, + eventData = { + 'exception': exception, + ...data, + }; /// Event that is emitted from the flutter tool when a build invocation /// has been run by the user. diff --git a/pkgs/unified_analytics/lib/src/initializer.dart b/pkgs/unified_analytics/lib/src/initializer.dart index 650388ba3..131968b88 100644 --- a/pkgs/unified_analytics/lib/src/initializer.dart +++ b/pkgs/unified_analytics/lib/src/initializer.dart @@ -4,7 +4,6 @@ import 'package:clock/clock.dart'; import 'package:file/file.dart'; -import 'package:path/path.dart' as p; import 'constants.dart'; import 'utils.dart'; @@ -22,14 +21,13 @@ void createClientIdFile({required File clientIdFile}) { void createConfigFile({ required File configFile, required Directory homeDirectory, - required FileSystem fs, }) { configFile.createSync(recursive: true); // If the user was previously opted out, then we will // replace the line that assumes automatic opt in with // an opt out from the start - if (legacyOptOut(fs: fs, home: homeDirectory)) { + if (legacyOptOut(homeDirectory: homeDirectory)) { configFile.writeAsStringSync( kConfigString.replaceAll('reporting=1', 'reporting=0')); } else { @@ -75,47 +73,43 @@ DateTime createSessionFile({required File sessionFile}) { /// - Dismissed survey JSON file bool runInitialization({ required Directory homeDirectory, - required FileSystem fs, }) { var firstRun = false; + final dartToolDirectory = + homeDirectory.childDirectory(kDartToolDirectoryName); // When the config file doesn't exist, initialize it with the default tools - // and the current date - final configFile = fs.file( - p.join(homeDirectory.path, kDartToolDirectoryName, kConfigFileName)); + // and the current date. + final configFile = dartToolDirectory.childFile(kConfigFileName); if (!configFile.existsSync()) { firstRun = true; createConfigFile( configFile: configFile, - fs: fs, homeDirectory: homeDirectory, ); } - // Begin initialization checks for the client id - final clientFile = fs.file( - p.join(homeDirectory.path, kDartToolDirectoryName, kClientIdFileName)); + // Begin initialization checks for the client id. + final clientFile = dartToolDirectory.childFile(kClientIdFileName); if (!clientFile.existsSync()) { createClientIdFile(clientIdFile: clientFile); } - // Begin initialization checks for the session file - final sessionFile = fs.file( - p.join(homeDirectory.path, kDartToolDirectoryName, kSessionFileName)); + // Begin initialization checks for the session file. + final sessionFile = dartToolDirectory.childFile(kSessionFileName); if (!sessionFile.existsSync()) { createSessionFile(sessionFile: sessionFile); } - // Begin initialization checks for the log file to persist events locally - final logFile = - fs.file(p.join(homeDirectory.path, kDartToolDirectoryName, kLogFileName)); + // Begin initialization checks for the log file to persist events locally. + final logFile = dartToolDirectory.childFile(kLogFileName); if (!logFile.existsSync()) { createLogFile(logFile: logFile); } - // Begin initialization checks for the dismissed survey file - final dismissedSurveyFile = fs.file(p.join( - homeDirectory.path, kDartToolDirectoryName, kDismissedSurveyFileName)); + // Begin initialization checks for the dismissed survey file. + final dismissedSurveyFile = + dartToolDirectory.childFile(kDismissedSurveyFileName); if (!dismissedSurveyFile.existsSync()) { createDismissedSurveyFile(dismissedSurveyFile: dismissedSurveyFile); } diff --git a/pkgs/unified_analytics/lib/src/utils.dart b/pkgs/unified_analytics/lib/src/utils.dart index 2bd0c79ed..41848a204 100644 --- a/pkgs/unified_analytics/lib/src/utils.dart +++ b/pkgs/unified_analytics/lib/src/utils.dart @@ -7,9 +7,8 @@ import 'dart:io' as io; import 'dart:math' show Random; import 'package:clock/clock.dart'; +import 'package:convert/convert.dart'; import 'package:file/file.dart'; -import 'package:intl/intl.dart'; -import 'package:path/path.dart' as p; import 'enums.dart'; import 'event.dart'; @@ -21,7 +20,7 @@ import 'user_property.dart'; /// yyyy-MM-dd (2023-01-09) /// ``` String get dateStamp { - return DateFormat('yyyy-MM-dd').format(clock.now()); + return FixedDateTimeFormatter('YYYY-MM-DD').encode(clock.now()); } /// Reads in a directory and returns `true` if write permissions are enabled. @@ -146,30 +145,32 @@ Directory? getHomeDirectory(FileSystem fs) { /// } /// } /// ``` -bool legacyOptOut({required FileSystem fs, required Directory home}) { +bool legacyOptOut({required Directory homeDirectory}) { // List of Maps for each of the config file, `key` refers to the // key in the json file that indicates if the user has been opted // out or not final legacyConfigFiles = [ - { - 'tool': DashTool.dartTool, - 'file': fs.file(p.join(home.path, '.dart', 'dartdev.json')), - 'key': 'enabled', - }, - { - 'tool': DashTool.flutterTool, - 'file': fs.file(p.join(home.path, '.flutter')), - 'key': 'enabled', - }, - { - 'tool': DashTool.devtools, - 'file': fs.file(p.join(home.path, '.flutter-devtools', '.devtools')), - 'key': 'analyticsEnabled', - }, + ( + tool: DashTool.dartTool, + file: homeDirectory.childDirectory('.dart').childFile('dartdev.json'), + key: 'enabled', + ), + ( + tool: DashTool.flutterTool, + file: homeDirectory.childFile('.flutter'), + key: 'enabled', + ), + ( + tool: DashTool.devtools, + file: homeDirectory + .childDirectory('.flutter-devtools') + .childFile('.devtools'), + key: 'analyticsEnabled', + ), ]; for (final legacyConfigObj in legacyConfigFiles) { - final legacyFile = legacyConfigObj['file']! as File; - final lookupKey = legacyConfigObj['key']! as String; + final legacyFile = legacyConfigObj.file; + final lookupKey = legacyConfigObj.key; if (legacyFile.existsSync()) { try { diff --git a/pkgs/unified_analytics/pubspec.yaml b/pkgs/unified_analytics/pubspec.yaml index 3e7065cfd..34cb046d0 100644 --- a/pkgs/unified_analytics/pubspec.yaml +++ b/pkgs/unified_analytics/pubspec.yaml @@ -2,9 +2,11 @@ name: unified_analytics description: >- A package for logging analytics for all Dart and Flutter related tooling to Google Analytics. +# LINT.IfChange # When updating this, keep the version consistent with the changelog and the # value in lib/src/constants.dart. -version: 6.1.3-wip +version: 6.1.4-wip +# LINT.ThenChange(lib/src/constants.dart) repository: https://github.com/dart-lang/tools/tree/main/pkgs/unified_analytics environment: @@ -12,11 +14,10 @@ environment: dependencies: clock: ^1.1.1 + convert: ^3.1.1 file: '>=6.1.4 <8.0.0' http: '>=0.13.5 <2.0.0' - intl: '>=0.18.0 <0.20.0' meta: ^1.9.0 - path: ^1.8.0 dev_dependencies: dart_flutter_team_lints: ^3.0.0 diff --git a/pkgs/unified_analytics/test/event_test.dart b/pkgs/unified_analytics/test/event_test.dart index 0a6167f4e..a9538e885 100644 --- a/pkgs/unified_analytics/test/event_test.dart +++ b/pkgs/unified_analytics/test/event_test.dart @@ -5,7 +5,6 @@ import 'dart:mirrors'; import 'package:test/test.dart'; - import 'package:unified_analytics/src/enums.dart'; import 'package:unified_analytics/unified_analytics.dart'; @@ -429,14 +428,19 @@ void main() { }); test('Event.exception constructed', () { - Event generateEvent() => Event.exception(exception: 'exception'); + Event generateEvent() => Event.exception( + exception: 'exception', + data: {'foo': 'bar', 'baz': 1}, + ); final constructedEvent = generateEvent(); expect(generateEvent, returnsNormally); expect(constructedEvent.eventName, DashEvent.exception); expect(constructedEvent.eventData['exception'], 'exception'); - expect(constructedEvent.eventData.length, 1); + expect(constructedEvent.eventData['foo'], 'bar'); + expect(constructedEvent.eventData['baz'], 1); + expect(constructedEvent.eventData.length, 3); }); test('Event.timing constructed', () { @@ -570,6 +574,7 @@ void main() { isExternalBuild: 'isExternalBuild', isEmbedded: 'isEmbedded', ideLaunchedFeature: 'ideLaunchedFeature', + isWasm: 'true', uiDurationMicros: 123, rasterDurationMicros: 123, shaderCompilationDurationMicros: 123, @@ -603,6 +608,8 @@ void main() { expect(constructedEvent.eventData['isEmbedded'], 'isEmbedded'); expect( constructedEvent.eventData['ideLaunchedFeature'], 'ideLaunchedFeature'); + expect(constructedEvent.eventData['isWasm'], 'true'); + expect(constructedEvent.eventData['uiDurationMicros'], 123); expect(constructedEvent.eventData['rasterDurationMicros'], 123); expect(constructedEvent.eventData['shaderCompilationDurationMicros'], 123); @@ -615,7 +622,7 @@ void main() { expect(constructedEvent.eventData['rootSetCount'], 123); expect(constructedEvent.eventData['rowCount'], 123); expect(constructedEvent.eventData['inspectorTreeControllerId'], 123); - expect(constructedEvent.eventData.length, 27); + expect(constructedEvent.eventData.length, 28); }); test('Confirm all constructors were checked', () { @@ -623,7 +630,9 @@ void main() { for (final declaration in reflectClass(Event).declarations.keys) { // Count public constructors but omit private constructors if (declaration.toString().contains('Event.') && - !declaration.toString().contains('Event._')) constructorCount++; + !declaration.toString().contains('Event._')) { + constructorCount++; + } } // Change this integer below if your PR either adds or removes diff --git a/pkgs/unified_analytics/test/events_with_fake_test.dart b/pkgs/unified_analytics/test/events_with_fake_test.dart index b67908864..9794275ac 100644 --- a/pkgs/unified_analytics/test/events_with_fake_test.dart +++ b/pkgs/unified_analytics/test/events_with_fake_test.dart @@ -5,7 +5,6 @@ import 'package:clock/clock.dart'; import 'package:file/file.dart'; import 'package:file/memory.dart'; -import 'package:path/path.dart' as p; import 'package:test/test.dart'; import 'package:unified_analytics/src/constants.dart'; @@ -52,11 +51,9 @@ void main() { setUp(() async { fs = MemoryFileSystem.test(style: FileSystemStyle.posix); homeDirectory = fs.directory('home'); - dismissedSurveyFile = fs.file(p.join( - homeDirectory.path, - kDartToolDirectoryName, - kDismissedSurveyFileName, - )); + dismissedSurveyFile = homeDirectory + .childDirectory(kDartToolDirectoryName) + .childFile(kDismissedSurveyFileName); final initialAnalytics = Analytics.fake( tool: DashTool.flutterTool, diff --git a/pkgs/unified_analytics/test/log_handler_test.dart b/pkgs/unified_analytics/test/log_handler_test.dart index 05fb466d8..db14d96ce 100644 --- a/pkgs/unified_analytics/test/log_handler_test.dart +++ b/pkgs/unified_analytics/test/log_handler_test.dart @@ -6,7 +6,6 @@ import 'dart:convert'; import 'package:file/file.dart'; import 'package:file/memory.dart'; -import 'package:path/path.dart' as p; import 'package:test/fake.dart'; import 'package:test/test.dart'; @@ -27,11 +26,9 @@ void main() { setUp(() { fs = MemoryFileSystem.test(style: FileSystemStyle.posix); homeDirectory = fs.directory('home'); - logFile = fs.file(p.join( - homeDirectory.path, - kDartToolDirectoryName, - kLogFileName, - )); + logFile = homeDirectory + .childDirectory(kDartToolDirectoryName) + .childFile(kLogFileName); // Create the initialization analytics instance to onboard the tool final initializationAnalytics = Analytics.fake( diff --git a/pkgs/unified_analytics/test/survey_handler_test.dart b/pkgs/unified_analytics/test/survey_handler_test.dart index 1ba6fa48f..3d8c8dd6c 100644 --- a/pkgs/unified_analytics/test/survey_handler_test.dart +++ b/pkgs/unified_analytics/test/survey_handler_test.dart @@ -7,7 +7,6 @@ import 'dart:convert'; import 'package:clock/clock.dart'; import 'package:file/file.dart'; import 'package:file/memory.dart'; -import 'package:path/path.dart' as p; import 'package:test/test.dart'; import 'package:unified_analytics/src/constants.dart'; @@ -274,20 +273,16 @@ void main() { // Write the client ID file out so that we don't get // a randomly assigned id for this test generated within // the analytics constructor - clientIdFile = fs.file(p.join( - homeDirectory.path, - kDartToolDirectoryName, - kClientIdFileName, - )); + clientIdFile = homeDirectory + .childDirectory(kDartToolDirectoryName) + .childFile(kClientIdFileName); clientIdFile.createSync(recursive: true); clientIdFile.writeAsStringSync('string1'); // Assign the json file that will hold the persisted surveys - dismissedSurveyFile = fs.file(p.join( - homeDirectory.path, - kDartToolDirectoryName, - kDismissedSurveyFileName, - )); + dismissedSurveyFile = homeDirectory + .childDirectory(kDartToolDirectoryName) + .childFile(kDismissedSurveyFileName); // Setup two tools to be onboarded with this package so // that we can simulate two different tools interacting with