Skip to content

Commit

Permalink
refactor: remove local fork of yamlicious (#345)
Browse files Browse the repository at this point in the history
YAML is a superset of JSON and what we need to write as YAML it is never visible to users.
We can just write JSON instead and get rid of this dependency.
  • Loading branch information
blaugold committed Jul 5, 2022
1 parent 200450c commit 64a15b8
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 115 deletions.
2 changes: 1 addition & 1 deletion packages/melos/lib/src/commands/bootstrap.dart
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ Future<void> _generateTemporaryProjects(MelosWorkspace workspace) async {

const header = '# Generated file - do not commit this file.';
final generatedPubspecYamlString =
'$header\n${toYamlString(pubspec.toJson())}';
'$header\n${prettyEncodeJson(pubspec.toJson())}';

await writeTextFileAsync(
utils.pubspecPathForDirectory(packageTemporaryPath),
Expand Down
1 change: 0 additions & 1 deletion packages/melos/lib/src/commands/runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import '../package.dart';
import '../scripts.dart';
import '../workspace.dart';
import '../workspace_configs.dart';
import '../yamlicious/yaml_writer.dart';

part 'bootstrap.dart';
part 'clean.dart';
Expand Down
4 changes: 4 additions & 0 deletions packages/melos/lib/src/common/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -514,3 +514,7 @@ extension Utf8StreamUtils on Stream<List<int>> {
}).join('\n');
}
}

// Encodes a [value] as a JSON string with indentation.
String prettyEncodeJson(Object? value) =>
const JsonEncoder.withIndent(' ').convert(value);
2 changes: 1 addition & 1 deletion packages/melos/lib/src/workspace_configs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ You must have one of the following to be a valid Melos workspace:
ide.hashCode ^
commands.hashCode;

Map<Object?, Object> toJson() {
Map<String, Object> toJson() {
return {
'name': name,
'path': path,
Expand Down
3 changes: 0 additions & 3 deletions packages/melos/lib/src/yamlicious/README.md

This file was deleted.

107 changes: 0 additions & 107 deletions packages/melos/lib/src/yamlicious/yaml_writer.dart

This file was deleted.

4 changes: 2 additions & 2 deletions packages/melos/test/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:http/http.dart' as http;
import 'package:melos/melos.dart';
import 'package:melos/src/common/io.dart';
import 'package:melos/src/common/platform.dart';
import 'package:melos/src/yamlicious/yaml_writer.dart';
import 'package:melos/src/common/utils.dart';
import 'package:mockito/mockito.dart';
import 'package:path/path.dart';
import 'package:pub_semver/pub_semver.dart';
Expand Down Expand Up @@ -83,7 +83,7 @@ Directory createTemporaryWorkspaceDirectory({
: dir;
final config = (configBuilder(path)..validatePhysicalWorkspace()).toJson();

writeTextFile(join(path, 'melos.yaml'), toYamlString(config));
writeTextFile(join(path, 'melos.yaml'), prettyEncodeJson(config));

return Directory(dir);
}
Expand Down

0 comments on commit 64a15b8

Please sign in to comment.