import 'dart:io';

class LocalData {
  static Map<String, dynamic> commonMap({String? workspace}) {
    return {
      'workspace': (workspace ?? Directory.current.path).replaceAll('\\', '/'),
      'jenkinsHome': '',
      'jenkinsUrl': '',
      'buildUrl': '',
      'jobUrl': '',
      'jobName': '',
      'gitCommit': '',
      'buildNumber': 0,
      'buildID': 0,
      'buildDisplayName': '',
      'gitBranch': '',
      'buildTag': '',
    };
  }
}

class FileData {
  static Map<String, dynamic>? get jenkinsMap => LocalData.commonMap();
}

class TestData {
  static String get buildYaml => '''
---
property:
  workspace: ${Directory.current.path}
  env: test

pipeline:
  id: main
  workflow:
  - exe: print-start
  - exe: set-value
  - exe: print-result

commands:
- command: Print
  id: print-start
  param:
    message: "test mode start"

- command: SetValue
  id: set-value
  param:
    values-string:
      buildResult: "ok"

- command: Print
  id: print-result
  param:
    message: "test mode done - result: <!property.buildResult>"
...
''';

  static Map<String, dynamic>? get jenkinsMap {
    final map = Map<String, dynamic>.from(FileData.jenkinsMap!);
    map['buildData'] = buildYaml;
    return map;
  }
}
