From 8a4b97ea2017cc079571daec46542f76189836b1 Mon Sep 17 00:00:00 2001 From: Jonas Termansen Date: Wed, 13 Sep 2023 18:50:21 +0200 Subject: [PATCH] Support renaming the be channel to main. (#102) * Support renaming the be channel to main. This change automatically detects when the main channel pops into existence and starts using the latest version of it instead. The forward compatibility will be removed once the channel has been renamed. Bug: b/270022609 * recompile action * Add changelog entry for the be -> main rename. * update todo and rev changelog version --------- Co-authored-by: Devon Carew --- CHANGELOG.md | 4 +- dist/main.cjs | 141 ++++++++++++++++++++------------------------------ dist/sig.txt | 2 +- lib/main.dart | 12 +++-- 4 files changed, 69 insertions(+), 90 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c0fd55e..f0f6e8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,10 @@ -## v1.5.1-dev +## v1.5.1 * No longer test the `setup-dart` action on pre-2.12 SDKs. * Upgrade JS interop code to use extension types (the new name for inline classes). +* The upcoming rename of the `be` channel to `main` is now supported with + forward compatibility that switches when the rename happens. ## v1.5.0 diff --git a/dist/main.cjs b/dist/main.cjs index 9270ce7..9d03a72 100644 --- a/dist/main.cjs +++ b/dist/main.cjs @@ -1,4 +1,4 @@ -// Generated by dart2js (NullSafetyMode.sound, csp, deferred-serialization, intern-composite-values), the Dart to JavaScript compiler version: 3.2.0-92.0.dev. +// Generated by dart2js (NullSafetyMode.sound, csp, intern-composite-values), the Dart to JavaScript compiler version: 3.2.0-140.0.dev. // The code supports the following hooks: // dartPrint(message): // if this function is defined it is called instead of the Dart [print] @@ -581,7 +581,7 @@ return error; }, _unwrapNonDartException(ex) { - var message, number, ieErrorCode, t1, nsme, notClosure, nullCall, nullLiteralCall, undefCall, undefLiteralCall, nullProperty, undefProperty, undefLiteralProperty, match, _null = null; + var message, number, ieErrorCode, nsme, notClosure, nullCall, nullLiteralCall, undefCall, undefLiteralCall, nullProperty, undefProperty, undefLiteralProperty, match; if (!("message" in ex)) return ex; message = ex.message; @@ -591,11 +591,11 @@ if ((B.JSInt_methods._shrOtherPositive$1(number, 16) & 8191) === 10) switch (ieErrorCode) { case 438: - return A.saveStackTrace(ex, A.JsNoSuchMethodError$(A.S(message) + " (Error " + ieErrorCode + ")", _null)); + return A.saveStackTrace(ex, A.JsNoSuchMethodError$(A.S(message) + " (Error " + ieErrorCode + ")", null)); case 445: case 5007: - t1 = A.S(message); - return A.saveStackTrace(ex, new A.NullError(t1 + " (Error " + ieErrorCode + ")", _null)); + A.S(message); + return A.saveStackTrace(ex, new A.NullError()); } } if (ex instanceof TypeError) { @@ -617,41 +617,9 @@ if (match != null) { match.method = "call"; return A.saveStackTrace(ex, A.JsNoSuchMethodError$(A._asString(message), match)); - } else { - match = nullCall.matchTypeError$1(message); - if (match == null) { - match = nullLiteralCall.matchTypeError$1(message); - if (match == null) { - match = undefCall.matchTypeError$1(message); - if (match == null) { - match = undefLiteralCall.matchTypeError$1(message); - if (match == null) { - match = nullProperty.matchTypeError$1(message); - if (match == null) { - match = nullLiteralCall.matchTypeError$1(message); - if (match == null) { - match = undefProperty.matchTypeError$1(message); - if (match == null) { - match = undefLiteralProperty.matchTypeError$1(message); - t1 = match != null; - } else - t1 = true; - } else - t1 = true; - } else - t1 = true; - } else - t1 = true; - } else - t1 = true; - } else - t1 = true; - } else - t1 = true; - if (t1) { - A._asString(message); - return A.saveStackTrace(ex, new A.NullError(message, match == null ? _null : match.method)); - } + } else if (nullCall.matchTypeError$1(message) != null || nullLiteralCall.matchTypeError$1(message) != null || undefCall.matchTypeError$1(message) != null || undefLiteralCall.matchTypeError$1(message) != null || nullProperty.matchTypeError$1(message) != null || nullLiteralCall.matchTypeError$1(message) != null || undefProperty.matchTypeError$1(message) != null || undefLiteralProperty.matchTypeError$1(message) != null) { + A._asString(message); + return A.saveStackTrace(ex, new A.NullError()); } } return A.saveStackTrace(ex, new A.UnknownJsTypeError(typeof message == "string" ? message : "")); @@ -666,7 +634,7 @@ } return null; }(ex); - return A.saveStackTrace(ex, new A.ArgumentError(false, _null, _null, typeof message == "string" ? message.replace(/^RangeError:\s*/, "") : message)); + return A.saveStackTrace(ex, new A.ArgumentError(false, null, null, typeof message == "string" ? message.replace(/^RangeError:\s*/, "") : message)); } if (typeof InternalError == "function" && ex instanceof InternalError) if (typeof message == "string" && message === "too much recursion") @@ -1241,9 +1209,7 @@ _._method = t4; _._receiver = t5; }, - NullError: function NullError(t0, t1) { - this.__js_helper$_message = t0; - this._method = t1; + NullError: function NullError() { }, JsNoSuchMethodError: function JsNoSuchMethodError(t0, t1, t2) { this.__js_helper$_message = t0; @@ -1636,7 +1602,7 @@ return A.createRuntimeType(A._Universe_eval(init.typeUniverse, recipe, false)); }, _installSpecializedIsTest(object) { - var t1, unstarred, isFn, $name, predicate, testRti = this; + var t1, unstarred, unstarredKind, isFn, $name, predicate, testRti = this; if (testRti === type$.Object) return A._finishIsFn(testRti, object, A._isObject); if (!A.isStrongTopType(testRti)) @@ -1654,8 +1620,8 @@ if (t1 === 1) return A._finishIsFn(testRti, object, A._isNever); unstarred = t1 === 6 ? testRti._primary : testRti; - t1 = unstarred._kind; - if (t1 === 8) + unstarredKind = unstarred._kind; + if (unstarredKind === 8) return A._finishIsFn(testRti, object, A._isFutureOr); if (unstarred === type$.int) isFn = A._isInt; @@ -1667,7 +1633,7 @@ isFn = unstarred === type$.bool ? A._isBool : null; if (isFn != null) return A._finishIsFn(testRti, object, isFn); - if (t1 === 9) { + if (unstarredKind === 9) { $name = unstarred._primary; if (unstarred._rest.every(A.isTopType)) { testRti._specializedTestResource = "$is" + $name; @@ -1675,7 +1641,7 @@ return A._finishIsFn(testRti, object, A._isListTestViaProperty); return A._finishIsFn(testRti, object, A._isTestViaProperty); } - } else if (t1 === 11) { + } else if (unstarredKind === 11) { predicate = A.createRecordTypePredicate(unstarred._primary, unstarred._rest); return A._finishIsFn(testRti, object, predicate == null ? A._isNever : predicate); } @@ -5422,7 +5388,7 @@ main$body(args) { var $async$goto = 0, $async$completer = A._makeAsyncAwaitCompleter(type$.dynamic), - $async$returnValue, $async$handler = 2, $async$currentError, sdk, flavor, raw, os, architecture, version, channel, url, toolName, sdkPath, archivePath, extractedFolder, pubCache, error, t1, t2, t3, t4, versionFilePath, exception, $async$exception; + $async$returnValue, $async$handler = 2, $async$currentError, sdk, flavor, raw, os, architecture, version, channel, url, toolName, sdkPath, archivePath, extractedFolder, pubCache, error, t1, t2, exception, t3, t4, versionFilePath, $async$exception, $async$exception1; var $async$main = A._wrapJsFunctionForAsync(function($async$errorCode, $async$result) { if ($async$errorCode === 1) { $async$currentError = $async$result; @@ -5485,24 +5451,32 @@ break; case 14: // then + $async$handler = 18; + channel = "main"; + $async$goto = 21; + return A._asyncAwait(A.latestPublishedVersion(channel, flavor), $async$main); + case 21: + // returning from await. + $async$handler = 4; + // goto after finally + $async$goto = 20; + break; + case 18: + // catch + $async$handler = 17; + $async$exception = $async$currentError; channel = "be"; - $async$goto = A.boolConversionCheck(raw) ? 17 : 19; + // goto after finally + $async$goto = 20; break; case 17: - // then - $async$result = "latest"; - // goto join - $async$goto = 18; + // uncaught + // goto catch + $async$goto = 4; break; - case 19: - // else - $async$goto = 20; - return A._asyncAwait(A.latestPublishedVersion(channel, flavor), $async$main); case 20: - // returning from await. - case 18: - // join - version = $async$result; + // after finally + version = "latest"; // goto join $async$goto = 15; break; @@ -5528,35 +5502,35 @@ url = string$.https_ + A.S(channel) + "/" + A.S(flavor) + "/" + A.S(version) + "/sdk/dartsdk-" + A.S(os) + "-" + A.S(architecture) + "-release.zip"; toolName = A.boolConversionCheck(raw) ? "dart_raw" : "dart"; sdkPath = !A.boolConversionCheck(raw) ? A._asString(t2._as(t1.toolCache).find(toolName, version, architecture)) : ""; - $async$goto = J.get$length$asx(sdkPath) !== 0 ? 21 : 23; + $async$goto = J.get$length$asx(sdkPath) !== 0 ? 22 : 24; break; - case 21: + case 22: // then t2._as(t1.core).info("Using cached sdk from " + A.S(sdkPath) + "."); // goto join - $async$goto = 22; + $async$goto = 23; break; - case 23: + case 24: // else t2._as(t1.core).info(A.S(url) + " ..."); t3 = type$.String; - $async$goto = 24; + $async$goto = 25; return A._asyncAwait(A.promiseToFuture(t2._as(t2._as(t1.toolCache).downloadTool(url)), t3), $async$main); - case 24: + case 25: // returning from await. archivePath = $async$result; - $async$goto = 25; + $async$goto = 26; return A._asyncAwait(A.promiseToFuture(t2._as(t2._as(t1.toolCache).extractZip(archivePath)), t3), $async$main); - case 25: + case 26: // returning from await. extractedFolder = $async$result; extractedFolder = A.join(extractedFolder, "dart-sdk"); - $async$goto = 26; + $async$goto = 27; return A._asyncAwait(A.promiseToFuture(t2._as(t2._as(t1.toolCache).cacheDir(extractedFolder, toolName, version, architecture)), t3), $async$main); - case 26: + case 27: // returning from await. sdkPath = $async$result; - case 22: + case 23: // join t3 = t2._as(t1.process); t4 = J.$eq$(os, "windows") ? "USERPROFILE" : "HOME"; @@ -5567,9 +5541,9 @@ t2._as(t1.core).addPath(A.join(sdkPath, "bin")); t2._as(t1.core).exportVariable("PUB_CACHE", pubCache); t2._as(t1.core).addPath(A.join(pubCache, "bin")); - $async$goto = 27; + $async$goto = 28; return A._asyncAwait(A.createPubOIDCToken(), $async$main); - case 27: + case 28: // returning from await. if (A.boolConversionCheck(raw)) { t3 = t2._as(t1.core); @@ -5577,9 +5551,9 @@ t3.setOutput("dart-version", B.JSString_methods.trim$0(A._asString(t2._as(t1.fs).readFileSync(versionFilePath, "utf8")))); } else t2._as(t1.core).setOutput("dart-version", version); - $async$goto = 28; + $async$goto = 29; return A._asyncAwait(A.promiseToFuture(t2._as(t2._as(t1.exec).exec("dart", A._setArrayType(["--version"], type$.JSArray_String))), type$.dynamic), $async$main); - case 28: + case 29: // returning from await. $async$handler = 2; // goto after finally @@ -5588,8 +5562,8 @@ case 4: // catch $async$handler = 3; - $async$exception = $async$currentError; - error = A.unwrapException($async$exception); + $async$exception1 = $async$currentError; + error = A.unwrapException($async$exception1); t1 = self; type$.JSObject._as(t1.core).setFailed(A.S(error)); // goto after finally @@ -6589,10 +6563,7 @@ }; A.NullError.prototype = { toString$0(_) { - var t1 = this._method; - if (t1 == null) - return "NoSuchMethodError: " + this.__js_helper$_message; - return "NoSuchMethodError: method not found: '" + t1 + "' on null"; + return "Null check operator used on a null value"; } }; A.JsNoSuchMethodError.prototype = { @@ -7289,7 +7260,7 @@ t1 = this.$ti; t1._bind$1($E)._eval$1("1/(2)")._as(f); result = new A._Future($.Zone__current, $E._eval$1("_Future<0>")); - this._addListener$1(new A._FutureListener(result, 3, f, onError, t1._eval$1("@<1>")._bind$1($E)._eval$1("_FutureListener<1,2>"))); + this._addListener$1(new A._FutureListener(result, 19, f, onError, t1._eval$1("@<1>")._bind$1($E)._eval$1("_FutureListener<1,2>"))); return result; }, _setErrorObject$1(error) { diff --git a/dist/sig.txt b/dist/sig.txt index ce282a6..e470ffc 100644 --- a/dist/sig.txt +++ b/dist/sig.txt @@ -1 +1 @@ -F5AD5D9AC7CB46475A2BB056581E63C4 +C101968925A261FBCDF2AFA30D38A662 diff --git a/lib/main.dart b/lib/main.dart index d39946e..3ea6982 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -51,9 +51,15 @@ void main(List args) async { version = raw ? 'latest' : (await latestPublishedVersion(channel, flavor)); } else if (sdk == 'main') { - channel = 'be'; - version = - raw ? 'latest' : (await latestPublishedVersion(channel, flavor)); + // Check for `main` first and fall back to `be`. This handles the channel + // rename from `be` to `main` (also tracked as b/299435467). + try { + channel = 'main'; + await latestPublishedVersion(channel, flavor); + } catch (_) { + channel = 'be'; + } + version = 'latest'; } else { version = sdk;