Created
February 23, 2023 22:14
-
-
Save devoncarew/7e8c489b7c4df628fa9a306c0fd058e8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // 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:js_interop'; | |
| import 'package:js/js.dart'; | |
| @JS() | |
| external HttpClient get httpClient; | |
| @JS() | |
| // @staticInterop | |
| class HttpClient { | |
| external HttpClient(String userAgent, List handlers, Map requestOptions); | |
| } | |
| extension HttpClientExtension on HttpClient { | |
| // JSPromise<JSObject> | |
| external JSPromise getJson(JSString requestUrl); | |
| } |
This file contains hidden or 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
| Future<String?> latestPublishedVersion(String channel, String flavor) async { | |
| final url = 'https://storage.googleapis.com/dart-archive/channels/' | |
| '$channel/$flavor/latest/VERSION'; | |
| final http = HttpClient('setup-dart', [], { | |
| 'allowRedirects': true, | |
| 'maxRedirects': 3, | |
| 'allowRetries': true, | |
| 'maxRetries': 3, | |
| }); | |
| JSObject? result = await promiseToFuture(http.getJson(url)); | |
| return result == null ? null : getProperty(result, 'version'); | |
| } |
This file contains hidden or 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
| import * as core from '@actions/core'; | |
| import * as exec from '@actions/exec'; | |
| import * as httpClient from '@actions/http-client'; | |
| import * as toolCache from '@actions/tool-cache'; | |
| import * as fs from 'fs'; | |
| import * as module from 'module'; | |
| import * as os from 'os'; | |
| import * as process from 'process'; | |
| const require = module.createRequire(import.meta.url); | |
| // Setup properties for JS interop in Dart. | |
| globalThis.self = globalThis; | |
| globalThis.core = core; | |
| globalThis.exec = exec; | |
| globalThis.httpClient = httpClient; | |
| globalThis.toolCache = toolCache; | |
| globalThis.fs = fs; | |
| globalThis.os = os; | |
| globalThis.process = process; | |
| globalThis.location = { href: `file://${process.cwd()}/`} | |
| ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment