Skip to content

Commit

Permalink
chore: Revert "feat(shorebird_cli): Add support for updater_tools" (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanoltman authored May 20, 2024
1 parent 1d64dcb commit c24adec
Show file tree
Hide file tree
Showing 24 changed files with 141 additions and 562 deletions.
2 changes: 1 addition & 1 deletion packages/artifact_proxy/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -578,4 +578,4 @@ packages:
source: hosted
version: "3.1.2"
sdks:
dart: ">=3.4.0 <4.0.0"
dart: ">=3.4.0-256.0.dev <4.0.0"
2 changes: 1 addition & 1 deletion packages/discord_gcp_alerts/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -570,4 +570,4 @@ packages:
source: hosted
version: "3.1.2"
sdks:
dart: ">=3.4.0 <4.0.0"
dart: ">=3.4.0-256.0.dev <4.0.0"
1 change: 0 additions & 1 deletion packages/shorebird_cli/bin/shorebird.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ Future<void> main(List<String> args) async {
shorebirdToolsRef,
shorebirdValidatorRef,
shorebirdVersionRef,
updaterToolsRef,
xcodeBuildRef,
},
),
Expand Down
36 changes: 14 additions & 22 deletions packages/shorebird_cli/lib/src/artifact_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,41 +21,33 @@ class ArtifactManager {
/// Generates a binary diff between two files and returns the path to the
/// output diff file.
Future<String> createDiff({
required File releaseArtifact,
required File patchArtifact,
required String releaseArtifactPath,
required String patchArtifactPath,
}) async {
if (!releaseArtifact.existsSync()) {
if (!File(releaseArtifactPath).existsSync()) {
throw FileSystemException(
'Release artifact does not exist',
releaseArtifact.path,
releaseArtifactPath,
);
}

if (!patchArtifact.existsSync()) {
if (!File(patchArtifactPath).existsSync()) {
throw FileSystemException(
'Patch artifact does not exist',
patchArtifact.path,
patchArtifactPath,
);
}

final tempDir = await Directory.systemTemp.createTemp();
final outputFile = File(p.join(tempDir.path, 'diff.patch'));
final updaterToolsFile = File(updaterTools.path);
if (updaterToolsFile.existsSync()) {
await updaterTools.createDiff(
releaseArtifact: releaseArtifact,
patchArtifact: patchArtifact,
outputFile: outputFile,
);
} else {
await patchExecutable.run(
releaseArtifactPath: releaseArtifact.path,
patchArtifactPath: patchArtifact.path,
diffPath: outputFile.path,
);
}
final diffPath = p.join(tempDir.path, 'diff.patch');

await patchExecutable.run(
releaseArtifactPath: releaseArtifactPath,
patchArtifactPath: patchArtifactPath,
diffPath: diffPath,
);

return outputFile.path;
return diffPath;
}

/// Downloads the file at the given [uri] to a temporary directory and returns
Expand Down
32 changes: 0 additions & 32 deletions packages/shorebird_cli/lib/src/cache.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ class Cache {
registerArtifact(BundleToolArtifact(cache: this, platform: platform));
registerArtifact(AotToolsDillArtifact(cache: this, platform: platform));
registerArtifact(AotToolsExeArtifact(cache: this, platform: platform));
registerArtifact(UpdaterToolsArtifact(cache: this, platform: platform));
}

void registerArtifact(CachedArtifact artifact) => _artifacts.add(artifact);
Expand Down Expand Up @@ -298,34 +297,3 @@ class BundleToolArtifact extends CachedArtifact {
return 'https://github.com/google/bundletool/releases/download/1.15.6/bundletool-all-1.15.6.jar';
}
}

/// {@template updater_tools_artifact}
/// Tools used to package patch artifacts for use by the Updater.
/// {@endtemplate}
class UpdaterToolsArtifact extends CachedArtifact {
/// {@macro updater_tools_artifact}
UpdaterToolsArtifact({required super.cache, required super.platform});

@override
String get name => 'updater-tools.dill';

@override
bool get isExecutable => false;

/// Updater tools was introduced in release 1.1.7.
// TODO(bryanoltman): add engine rev and flutter version once this is nailed down
@override
bool get required => false;

@override
Directory get location => Directory(
p.join(
cache.getArtifactDirectory(name).path,
shorebirdEnv.shorebirdEngineRevision,
),
);

@override
String get storageUrl =>
'${cache.storageBaseUrl}/${cache.storageBucket}/shorebird/${shorebirdEnv.shorebirdEngineRevision}/$name';
}
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ class AarPatcher extends Patcher {
final hash = sha256.convert(await patchArtifact.readAsBytes()).toString();
try {
final diffPath = await artifactManager.createDiff(
releaseArtifact: File(releaseArtifactPath.value),
patchArtifact: patchArtifact,
releaseArtifactPath: releaseArtifactPath.value,
patchArtifactPath: artifactPath,
);
patchArtifactBundles[arch] = PatchArtifactBundle(
arch: arch.arch,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ Looked in:
final hash = sha256.convert(await patchArtifact.readAsBytes()).toString();
try {
final diffPath = await artifactManager.createDiff(
releaseArtifact: File(releaseArtifactPath.value),
patchArtifact: patchArtifact,
releaseArtifactPath: releaseArtifactPath.value,
patchArtifactPath: patchArtifactPath,
);
patchArtifactBundles[releaseArtifactPath.key] = PatchArtifactBundle(
arch: arch.arch,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ class IosFrameworkPatcher extends Patcher {

patchFile = File(
await artifactManager.createDiff(
releaseArtifact: patchBaseFile,
patchArtifact: patchBuildFile,
releaseArtifactPath: patchBaseFile.path,
patchArtifactPath: patchBuildFile.path,
),
);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ class IosPatcher extends Patcher {

patchFile = File(
await artifactManager.createDiff(
releaseArtifact: patchBaseFile,
patchArtifact: patchBuildFile,
releaseArtifactPath: patchBaseFile.path,
patchArtifactPath: patchBuildFile.path,
),
);
} else {
Expand Down
2 changes: 1 addition & 1 deletion packages/shorebird_cli/lib/src/executables/aot_tools.dart
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class AotTools {
workingDirectory: workingDirectory,
);

if (result.exitCode != ExitCode.success.code) {
if (result.exitCode != 0) {
throw Exception('Failed to link: ${result.stderr}');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ export 'ios_deploy.dart';
export 'java.dart';
export 'patch_executable.dart';
export 'shorebird_tools.dart';
export 'updater_tools.dart';
export 'xcodebuild.dart';
12 changes: 5 additions & 7 deletions packages/shorebird_cli/lib/src/executables/patch_executable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,22 @@ class PatchFailedException implements Exception {
///
/// Throws [PatchFailedException] if the patch command exits with non-zero code.
class PatchExecutable {
/// The path to the `patch` executable.
String get path => p.join(
cache.getArtifactDirectory('patch').path,
'patch',
);

Future<void> run({
required String releaseArtifactPath,
required String patchArtifactPath,
required String diffPath,
}) async {
final diffExecutable = p.join(
cache.getArtifactDirectory('patch').path,
'patch',
);
final diffArguments = [
releaseArtifactPath,
patchArtifactPath,
diffPath,
];

final result = await process.run(path, diffArguments);
final result = await process.run(diffExecutable, diffArguments);

if (result.exitCode != ExitCode.success.code) {
throw PatchFailedException(
Expand Down
65 changes: 0 additions & 65 deletions packages/shorebird_cli/lib/src/executables/updater_tools.dart

This file was deleted.

30 changes: 0 additions & 30 deletions packages/shorebird_cli/lib/src/shorebird_artifacts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ enum ShorebirdArtifact {

/// The gen_snapshot executable.
genSnapshot,

/// The updater_tools kernel file.
updaterTools,
}

/// A reference to a [ShorebirdArtifacts] instance.
Expand Down Expand Up @@ -57,8 +54,6 @@ class ShorebirdCachedArtifacts implements ShorebirdArtifacts {
return _aotToolsFile.path;
case ShorebirdArtifact.genSnapshot:
return _genSnapshotFile.path;
case ShorebirdArtifact.updaterTools:
return _updaterToolsFile.path;
}
}

Expand Down Expand Up @@ -113,16 +108,6 @@ class ShorebirdCachedArtifacts implements ShorebirdArtifacts {
),
);
}

File get _updaterToolsFile {
return File(
p.join(
cache.getArtifactDirectory('updater-tools').path,
shorebirdEnv.shorebirdEngineRevision,
'updater-tools.dill',
),
);
}
}

/// {@template shorebird_local_engine_artifacts}
Expand All @@ -141,8 +126,6 @@ class ShorebirdLocalEngineArtifacts implements ShorebirdArtifacts {
return _aotToolsFile.path;
case ShorebirdArtifact.genSnapshot:
return _genSnapshotFile.path;
case ShorebirdArtifact.updaterTools:
return _updaterToolsFile.path;
}
}

Expand Down Expand Up @@ -183,17 +166,4 @@ class ShorebirdLocalEngineArtifacts implements ShorebirdArtifacts {
),
);
}

File get _updaterToolsFile {
return File(
p.join(
engineConfig.localEngineSrcPath!,
'third_party',
'updater',
'updater_tools',
'bin',
'updater_tools.dart',
),
);
}
}
4 changes: 2 additions & 2 deletions packages/shorebird_cli/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -561,10 +561,10 @@ packages:
dependency: "direct main"
description:
name: scoped_deps
sha256: bc54cece4fed785157dc53b7554d31107f574897f4b2d1196db905a38c084e31
sha256: "7416a9026f3b457dda634a8e83c8e47d7ece33bef360ffba114c2d89255166ae"
url: "https://pub.dev"
source: hosted
version: "0.1.0+2"
version: "0.1.0+1"
shelf:
dependency: transitive
description:
Expand Down
Loading

0 comments on commit c24adec

Please sign in to comment.