-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(shorebird_cli): Add support for updater_tools (#2124)
- Loading branch information
1 parent
ac17716
commit 1d64dcb
Showing
24 changed files
with
562 additions
and
141 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -578,4 +578,4 @@ packages: | |
source: hosted | ||
version: "3.1.2" | ||
sdks: | ||
dart: ">=3.4.0-256.0.dev <4.0.0" | ||
dart: ">=3.4.0 <4.0.0" |
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 |
---|---|---|
|
@@ -570,4 +570,4 @@ packages: | |
source: hosted | ||
version: "3.1.2" | ||
sdks: | ||
dart: ">=3.4.0-256.0.dev <4.0.0" | ||
dart: ">=3.4.0 <4.0.0" |
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
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
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
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
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
65 changes: 65 additions & 0 deletions
65
packages/shorebird_cli/lib/src/executables/updater_tools.dart
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,65 @@ | ||
import 'package:mason_logger/mason_logger.dart'; | ||
import 'package:scoped_deps/scoped_deps.dart'; | ||
import 'package:shorebird_cli/src/executables/patch_executable.dart'; | ||
import 'package:shorebird_cli/src/shorebird_artifacts.dart'; | ||
import 'package:shorebird_cli/src/shorebird_env.dart'; | ||
import 'package:shorebird_cli/src/shorebird_process.dart'; | ||
import 'package:shorebird_cli/src/third_party/flutter_tools/lib/flutter_tools.dart'; | ||
|
||
/// A reference to a [UpdaterTools] instance. | ||
final updaterToolsRef = create(UpdaterTools.new); | ||
|
||
/// The [UpdaterTools] instance available in the current zone. | ||
UpdaterTools get updaterTools => read(updaterToolsRef); | ||
|
||
class UpdaterTools { | ||
/// Path to the updater tools .dill file. | ||
String get path => shorebirdArtifacts.getArtifactPath( | ||
artifact: ShorebirdArtifact.updaterTools, | ||
); | ||
|
||
Future<ShorebirdProcessResult> _exec( | ||
List<String> command, { | ||
String? workingDirectory, | ||
}) async { | ||
// local engine versions use .dart and we distribute aot-tools as a .dill | ||
return process.run( | ||
shorebirdEnv.dartBinaryFile.path, | ||
['run', path, ...command], | ||
workingDirectory: workingDirectory, | ||
); | ||
} | ||
|
||
/// Create a binary diff between a release artifact and a patch artifact. | ||
Future<void> createDiff({ | ||
required File releaseArtifact, | ||
required File patchArtifact, | ||
required File outputFile, | ||
}) async { | ||
if (!releaseArtifact.existsSync()) { | ||
throw FileSystemException( | ||
'Release artifact does not exist', | ||
releaseArtifact.path, | ||
); | ||
} | ||
|
||
if (!patchArtifact.existsSync()) { | ||
throw FileSystemException( | ||
'Patch artifact does not exist', | ||
patchArtifact.path, | ||
); | ||
} | ||
|
||
final result = await _exec([ | ||
'diff', | ||
'--release=${releaseArtifact.path}', | ||
'--patch=${patchArtifact.path}', | ||
'--patch-executable=${patchExecutable.path}', | ||
'--output=${outputFile.path}', | ||
]); | ||
|
||
if (result.exitCode != ExitCode.success.code) { | ||
throw Exception('Failed to create diff: ${result.stderr}'); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.