From caf4603cf8f74786350e879e687309ffd4acf2fc Mon Sep 17 00:00:00 2001 From: Felix Angelov Date: Thu, 5 Dec 2024 16:09:53 -0600 Subject: [PATCH] chore(shorebird_cli): v1.4.14 (#2656) --- RELEASE_NOTES.md | 6 +++ bin/internal/flutter.version | 2 +- .../commands/patch/ios_framework_patcher.dart | 22 +++++++- .../lib/src/commands/patch/ios_patcher.dart | 22 +++++++- .../lib/src/commands/patch/patch_command.dart | 23 +-------- packages/shorebird_cli/lib/src/version.dart | 2 +- packages/shorebird_cli/pubspec.yaml | 2 +- .../patch/ios_framework_patcher_test.dart | 51 ++++++++++++++++++- .../src/commands/patch/ios_patcher_test.dart | 51 ++++++++++++++++++- .../commands/patch/patch_command_test.dart | 4 +- 10 files changed, 152 insertions(+), 33 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 17f73ad2..b97d87da 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -6,6 +6,12 @@ cspell:words pubspec erickzanardo xcframeworks Cupertino codesign codecov rkisha This section contains past updates we've sent to customers. +## 1.4.14 (December 5, 2024) + +- 🍎 iOS linker improvements (improved class table sort) +- 🖥️ Prepare for MacOS support +- 🍄 Various dependency upgrades + ## 1.4.13 (November 20, 2024) - 🍎 Provide more build status updates for iOS release and patch diff --git a/bin/internal/flutter.version b/bin/internal/flutter.version index 341c45d4..cfc924f5 100644 --- a/bin/internal/flutter.version +++ b/bin/internal/flutter.version @@ -1 +1 @@ -4353ddb8f4354b28dc7ff4bc05c4c920c2eba999 +d8a5e38fdaf0564ea7ad65c762b33d00b3f3af63 diff --git a/packages/shorebird_cli/lib/src/commands/patch/ios_framework_patcher.dart b/packages/shorebird_cli/lib/src/commands/patch/ios_framework_patcher.dart index 44fd63c6..80c75164 100644 --- a/packages/shorebird_cli/lib/src/commands/patch/ios_framework_patcher.dart +++ b/packages/shorebird_cli/lib/src/commands/patch/ios_framework_patcher.dart @@ -42,6 +42,9 @@ class IosFrameworkPatcher extends Patcher { String get _patchClassTableLinkInfoFile => p.join(buildDirectory.path, 'ios', 'shorebird', 'App.ct.link'); + String get _patchClassTableLinkDebugInfoPath => + p.join(buildDirectory.path, 'ios', 'shorebird', 'App.class_table.json'); + String get _vmcodeOutputPath => p.join(buildDirectory.path, 'out.vmcode'); String get _appDillCopyPath => p.join(buildDirectory.path, 'app.dill'); @@ -165,6 +168,7 @@ class IosFrameworkPatcher extends Patcher { } File? releaseClassTableLinkInfoFile; + File? releaseClassTableLinkDebugInfoFile; if (supplementArtifact != null) { final tempDir = Directory.systemTemp.createTempSync(); await artifactManager.extractZip( @@ -172,11 +176,18 @@ class IosFrameworkPatcher extends Patcher { outputDirectory: tempDir, ); releaseClassTableLinkInfoFile = File(p.join(tempDir.path, 'App.ct.link')); - if (!releaseClassTableLinkInfoFile.existsSync()) { logger.err('Unable to find class table link info file'); throw ProcessExit(ExitCode.software.code); } + + releaseClassTableLinkDebugInfoFile = File( + p.join(tempDir.path, 'App.class_table.json'), + ); + if (!releaseClassTableLinkDebugInfoFile.existsSync()) { + logger.err('Unable to find class table link debug info file'); + throw ProcessExit(ExitCode.software.code); + } } unzipProgress.complete( @@ -202,18 +213,25 @@ class IosFrameworkPatcher extends Patcher { if (useLinker) { // If we're using a newer version of the linker, we need to also copy the // necessary class table link information alongside the snapshots. - if (releaseClassTableLinkInfoFile != null) { + if (releaseClassTableLinkInfoFile != null && + releaseClassTableLinkDebugInfoFile != null) { // Copy the release's class table link info file next to the release // snapshot so that it can be used to generate a patch. releaseClassTableLinkInfoFile.copySync( p.join(releaseArtifactFile.parent.path, 'App.ct.link'), ); + releaseClassTableLinkDebugInfoFile.copySync( + p.join(releaseArtifactFile.parent.path, 'App.class_table.json'), + ); // Copy the patch's class table link info file to the build directory // so that it can be used to generate a patch. File(_patchClassTableLinkInfoFile).copySync( p.join(buildDirectory.path, 'out.ct.link'), ); + File(_patchClassTableLinkDebugInfoPath).copySync( + p.join(buildDirectory.path, 'out.class_table.json'), + ); } await _runLinker( diff --git a/packages/shorebird_cli/lib/src/commands/patch/ios_patcher.dart b/packages/shorebird_cli/lib/src/commands/patch/ios_patcher.dart index bed946ea..8033246b 100644 --- a/packages/shorebird_cli/lib/src/commands/patch/ios_patcher.dart +++ b/packages/shorebird_cli/lib/src/commands/patch/ios_patcher.dart @@ -50,6 +50,9 @@ class IosPatcher extends Patcher { String get _patchClassTableLinkInfoPath => p.join(buildDirectory.path, 'ios', 'shorebird', 'App.ct.link'); + String get _patchClassTableLinkDebugInfoPath => + p.join(buildDirectory.path, 'ios', 'shorebird', 'App.class_table.json'); + String get _aotOutputPath => p.join(buildDirectory.path, 'out.aot'); String get _vmcodeOutputPath => p.join(buildDirectory.path, 'out.vmcode'); @@ -256,6 +259,7 @@ For more information see: ${supportedFlutterVersionsUrl.toLink()}''', } File? releaseClassTableLinkInfoFile; + File? releaseClassTableLinkDebugInfoFile; if (supplementArtifact != null) { final tempDir = Directory.systemTemp.createTempSync(); await artifactManager.extractZip( @@ -263,11 +267,18 @@ For more information see: ${supportedFlutterVersionsUrl.toLink()}''', outputDirectory: tempDir, ); releaseClassTableLinkInfoFile = File(p.join(tempDir.path, 'App.ct.link')); - if (!releaseClassTableLinkInfoFile.existsSync()) { logger.err('Unable to find class table link info file'); throw ProcessExit(ExitCode.software.code); } + + releaseClassTableLinkDebugInfoFile = File( + p.join(tempDir.path, 'App.class_table.json'), + ); + if (!releaseClassTableLinkDebugInfoFile.existsSync()) { + logger.err('Unable to find class table link debug info file'); + throw ProcessExit(ExitCode.software.code); + } } unzipProgress.complete(); @@ -291,18 +302,25 @@ For more information see: ${supportedFlutterVersionsUrl.toLink()}''', if (useLinker) { // If we're using a newer version of the linker, we need to also copy the // necessary class table link information alongside the snapshots. - if (releaseClassTableLinkInfoFile != null) { + if (releaseClassTableLinkInfoFile != null && + releaseClassTableLinkDebugInfoFile != null) { // Copy the release's class table link info file next to the release // snapshot so that it can be used to generate a patch. releaseClassTableLinkInfoFile.copySync( p.join(releaseArtifactFile.parent.path, 'App.ct.link'), ); + releaseClassTableLinkDebugInfoFile.copySync( + p.join(releaseArtifactFile.parent.path, 'App.class_table.json'), + ); // Copy the patch's class table link info file to the build directory // so that it can be used to generate a patch. File(_patchClassTableLinkInfoPath).copySync( p.join(buildDirectory.path, 'out.ct.link'), ); + File(_patchClassTableLinkDebugInfoPath).copySync( + p.join(buildDirectory.path, 'out.class_table.json'), + ); } final (:exitCode, :linkPercentage) = await _runLinker( diff --git a/packages/shorebird_cli/lib/src/commands/patch/patch_command.dart b/packages/shorebird_cli/lib/src/commands/patch/patch_command.dart index b2a162dc..cee7bc81 100644 --- a/packages/shorebird_cli/lib/src/commands/patch/patch_command.dart +++ b/packages/shorebird_cli/lib/src/commands/patch/patch_command.dart @@ -285,7 +285,7 @@ NOTE: this is ${styleBold.wrap('not')} recommended. Asset changes cannot be incl final supplementalArtifact = patcher.supplementaryReleaseArtifactArch != null - ? await codePushClientWrapper.getOptionalReleaseArtifact( + ? await codePushClientWrapper.maybeGetReleaseArtifact( appId: appId, releaseId: release.id, arch: patcher.supplementaryReleaseArtifactArch!, @@ -508,24 +508,3 @@ ${summary.join('\n')} return artifactFile; } } - -extension on CodePushClientWrapper { - Future getOptionalReleaseArtifact({ - required String appId, - required int releaseId, - required String arch, - required ReleasePlatform platform, - }) async { - try { - final artifact = await getReleaseArtifact( - appId: appId, - releaseId: releaseId, - arch: arch, - platform: platform, - ); - return artifact; - } on CodePushNotFoundException catch (_) { - return null; - } - } -} diff --git a/packages/shorebird_cli/lib/src/version.dart b/packages/shorebird_cli/lib/src/version.dart index c7a6cc61..e6499ad4 100644 --- a/packages/shorebird_cli/lib/src/version.dart +++ b/packages/shorebird_cli/lib/src/version.dart @@ -1,2 +1,2 @@ // Generated code. Do not modify. -const packageVersion = '1.4.13'; +const packageVersion = '1.4.14'; diff --git a/packages/shorebird_cli/pubspec.yaml b/packages/shorebird_cli/pubspec.yaml index a6bbe58a..90de5f79 100644 --- a/packages/shorebird_cli/pubspec.yaml +++ b/packages/shorebird_cli/pubspec.yaml @@ -1,6 +1,6 @@ name: shorebird_cli description: Command-line tool to interact with Shorebird's services. -version: 1.4.13 +version: 1.4.14 repository: https://github.com/shorebirdtech/shorebird publish_to: none diff --git a/packages/shorebird_cli/test/src/commands/patch/ios_framework_patcher_test.dart b/packages/shorebird_cli/test/src/commands/patch/ios_framework_patcher_test.dart index 74a38ef8..79583621 100644 --- a/packages/shorebird_cli/test/src/commands/patch/ios_framework_patcher_test.dart +++ b/packages/shorebird_cli/test/src/commands/patch/ios_framework_patcher_test.dart @@ -540,6 +540,15 @@ void main() { 'App.ct.link', ), ).createSync(recursive: true); + File( + p.join( + projectRoot.path, + 'build', + 'ios', + 'shorebird', + 'App.class_table.json', + ), + ).createSync(recursive: true); } setUp(() { @@ -886,7 +895,44 @@ void main() { }); }); - group('when class table link info is present', () { + group('when debug info is missing', () { + setUp(() { + when( + () => artifactManager.extractZip( + zipFile: supplementArtifactFile, + outputDirectory: any(named: 'outputDirectory'), + ), + ).thenAnswer((invocation) async { + final outDir = invocation.namedArguments[#outputDirectory] + as Directory; + File( + p.join(outDir.path, 'App.ct.link'), + ).createSync(recursive: true); + }); + }); + + test('exits with code 70', () async { + await expectLater( + () => runWithOverrides( + () => patcher.createPatchArtifacts( + appId: appId, + releaseId: releaseId, + releaseArtifact: releaseArtifactFile, + supplementArtifact: supplementArtifactFile, + ), + ), + exitsWithCode(ExitCode.software), + ); + + verify( + () => logger.err( + 'Unable to find class table link debug info file', + ), + ).called(1); + }); + }); + + group('when class table link info & debug info are present', () { setUp(() { when( () => artifactManager.extractZip( @@ -916,6 +962,9 @@ void main() { File( p.join(outDir.path, 'App.ct.link'), ).createSync(recursive: true); + File( + p.join(outDir.path, 'App.class_table.json'), + ).createSync(recursive: true); }); }); diff --git a/packages/shorebird_cli/test/src/commands/patch/ios_patcher_test.dart b/packages/shorebird_cli/test/src/commands/patch/ios_patcher_test.dart index 8bddd51a..cf98e026 100644 --- a/packages/shorebird_cli/test/src/commands/patch/ios_patcher_test.dart +++ b/packages/shorebird_cli/test/src/commands/patch/ios_patcher_test.dart @@ -865,6 +865,15 @@ For more information see: ${supportedFlutterVersionsUrl.toLink()}''', 'App.ct.link', ), ).createSync(recursive: true); + File( + p.join( + projectRoot.path, + 'build', + 'ios', + 'shorebird', + 'App.class_table.json', + ), + ).createSync(recursive: true); File( p.join(projectRoot.path, 'build', linkFileName), ).createSync(recursive: true); @@ -1320,7 +1329,7 @@ For more information see: ${supportedFlutterVersionsUrl.toLink()}''', }); }); - group('when class table link info is present', () { + group('when debug info is missing', () { setUp(() { when( () => artifactManager.extractZip( @@ -1336,6 +1345,46 @@ For more information see: ${supportedFlutterVersionsUrl.toLink()}''', }); }); + test('exits with code 70', () async { + await expectLater( + () => runWithOverrides( + () => patcher.createPatchArtifacts( + appId: appId, + releaseId: releaseId, + releaseArtifact: releaseArtifactFile, + supplementArtifact: supplementArtifactFile, + ), + ), + exitsWithCode(ExitCode.software), + ); + + verify( + () => logger.err( + 'Unable to find class table link debug info file', + ), + ).called(1); + }); + }); + + group('when class table link info & debug info are present', () { + setUp(() { + when( + () => artifactManager.extractZip( + zipFile: supplementArtifactFile, + outputDirectory: any(named: 'outputDirectory'), + ), + ).thenAnswer((invocation) async { + final outDir = invocation.namedArguments[#outputDirectory] + as Directory; + File( + p.join(outDir.path, 'App.ct.link'), + ).createSync(recursive: true); + File( + p.join(outDir.path, 'App.class_table.json'), + ).createSync(recursive: true); + }); + }); + test('returns linked patch artifact in patch bundle', () async { final patchBundle = await runWithOverrides( () => patcher.createPatchArtifacts( diff --git a/packages/shorebird_cli/test/src/commands/patch/patch_command_test.dart b/packages/shorebird_cli/test/src/commands/patch/patch_command_test.dart index fe7a9ddb..50bab732 100644 --- a/packages/shorebird_cli/test/src/commands/patch/patch_command_test.dart +++ b/packages/shorebird_cli/test/src/commands/patch/patch_command_test.dart @@ -236,7 +236,7 @@ void main() { ), ).thenAnswer((_) async => aabArtifact); when( - () => codePushClientWrapper.getReleaseArtifact( + () => codePushClientWrapper.maybeGetReleaseArtifact( appId: any(named: 'appId'), releaseId: any(named: 'releaseId'), arch: 'supplement', @@ -482,7 +482,7 @@ void main() { await runWithOverrides(() => command.createPatch(patcher)); verify( - () => codePushClientWrapper.getReleaseArtifact( + () => codePushClientWrapper.maybeGetReleaseArtifact( appId: appId, releaseId: release.id, arch: 'supplement',