File size: 1,885 Bytes
866079c
 
 
 
 
 
 
 
 
 
 
b0336a8
866079c
 
 
 
b0336a8
 
 
 
 
 
 
 
866079c
 
 
 
 
 
 
 
 
 
 
 
 
 
b0336a8
866079c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright 2014 The Flutter Authors. 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:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/convert.dart';
import 'package:flutter_tools/src/custom_devices/custom_device_config.dart';

void writeCustomDevicesConfigFile(
  Directory dir, {
  List<CustomDeviceConfig>? configs,
  dynamic json,
}) {
  dir.createSync(recursive: true);

  final File file = dir.childFile('.flutter_custom_devices.json');
  file.writeAsStringSync(
    jsonEncode(<String, dynamic>{
      'custom-devices':
          configs != null
              ? configs.map<dynamic>((CustomDeviceConfig c) => c.toJson()).toList()
              : json,
    }),
  );
}

final CustomDeviceConfig testConfig = CustomDeviceConfig(
  id: 'testid',
  label: 'testlabel',
  sdkNameAndVersion: 'testsdknameandversion',
  enabled: true,
  pingCommand: const <String>['testping'],
  pingSuccessRegex: RegExp('testpingsuccess'),
  postBuildCommand: const <String>['testpostbuild'],
  installCommand: const <String>['testinstall'],
  uninstallCommand: const <String>['testuninstall'],
  runDebugCommand: const <String>['testrundebug'],
  forwardPortCommand: const <String>['testforwardport'],
  forwardPortSuccessRegex: RegExp('testforwardportsuccess'),
);

const Map<String, dynamic> testConfigJson = <String, dynamic>{
  'id': 'testid',
  'label': 'testlabel',
  'sdkNameAndVersion': 'testsdknameandversion',
  'enabled': true,
  'ping': <String>['testping'],
  'pingSuccessRegex': 'testpingsuccess',
  'postBuild': <String>['testpostbuild'],
  'install': <String>['testinstall'],
  'uninstall': <String>['testuninstall'],
  'runDebug': <String>['testrundebug'],
  'forwardPort': <String>['testforwardport'],
  'forwardPortSuccessRegex': 'testforwardportsuccess',
};