-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[infra] script to change deps to path dependencies (#817)
This PR adds a script that rewrites pubspecs to use path dependencies between the `native_*` packages in this repo. This might be too strict if we ever need to breaking changes across multiple packages, in that case we can temporarily disable this. Closes: #80
- Loading branch information
Showing
4 changed files
with
90 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Please keep consistent with .pubignore. | ||
|
||
# https://dart.dev/guides/libraries/private-files | ||
# Created by `dart pub` | ||
.dart_tool/ | ||
|
||
# Avoid committing pubspec.lock for library packages; see | ||
# https://dart.dev/guides/libraries/private-files#pubspeclock. | ||
pubspec.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// 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 'dart:io'; | ||
|
||
import 'package:glob/glob.dart'; | ||
import 'package:glob/list_local_fs.dart'; | ||
import 'package:yaml_edit/yaml_edit.dart'; | ||
import 'package:yaml/yaml.dart'; | ||
|
||
void main(List<String> args) { | ||
final root = Platform.script.resolve('../../'); | ||
final glob = Glob('**pubspec.yaml'); | ||
final files = glob.listSync(root: root.toFilePath()).whereType<File>(); | ||
for (final file in files) { | ||
final yamlEditor = YamlEditor(file.readAsStringSync()); | ||
final yaml = yamlEditor.parseAt([]); | ||
if (yaml is! YamlMap) { | ||
continue; | ||
} | ||
final dependencies = yaml['dependencies']; | ||
if (dependencies is! YamlMap) { | ||
continue; | ||
} | ||
for (final package in dependencies.keys) { | ||
if (!packagesToPin.contains(package)) { | ||
continue; | ||
} | ||
yamlEditor.update( | ||
['dependencies', package], | ||
{ | ||
// Some packages contain full test projects that are copied in unit | ||
// tests. So, use absolute paths. | ||
'path': | ||
root.resolve('pkgs/$package/').toFilePath().replaceAll(r'\', '/'), | ||
}, | ||
); | ||
} | ||
if (yamlEditor.edits.isEmpty) { | ||
continue; | ||
} | ||
yamlEditor.update(['publish_to'], 'none'); | ||
file.writeAsStringSync(yamlEditor.toString()); | ||
} | ||
} | ||
|
||
const packagesToPin = { | ||
'native_assets_builder', | ||
'native_assets_cli', | ||
'native_toolchain_c', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: tools_for_dart_lang_native | ||
description: >- | ||
Some helper scripts for https://github.com/dart-lang/native. | ||
version: 0.1.0 | ||
repository: https://github.com/dart-lang/native/tree/main/pkgs/native_assets_builder | ||
|
||
publish_to: none | ||
|
||
environment: | ||
sdk: '>=3.0.0 <4.0.0' | ||
|
||
dependencies: | ||
glob: ^2.1.2 | ||
yaml_edit: ^2.1.1 |