Skip to content

Commit

Permalink
Migrate archive script to package:web (#5456)
Browse files Browse the repository at this point in the history
Also updates dependencies and completes some cleanup.
  • Loading branch information
parlough authored Jan 9, 2024
1 parent df2d267 commit 78db38c
Show file tree
Hide file tree
Showing 9 changed files with 3,769 additions and 3,056 deletions.
6,532 changes: 3,605 additions & 2,927 deletions src/assets/js/get-dart/download_archive.dart.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions tool/get-dart/archive/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ dependencies:
dev_dependencies:
analysis_defaults:
path: ../../../site-shared/packages/analysis_defaults
build_runner: ^2.4.6
build_web_compilers: ^4.0.5
build_runner: ^2.4.7
build_web_compilers: ^4.0.8
13 changes: 7 additions & 6 deletions tool/get-dart/dart_sdk_archive/lib/src/generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ class SvnVersionGenerator {

Future<Map<String, String>> get svnVersions async {
final versionInfos = <String, VersionInfo>{};
await Future.wait([
await (
_loadVersionInfo(versionInfos, 'stable'),
_loadVersionInfo(versionInfos, 'beta'),
_loadVersionInfo(versionInfos, 'dev'),
]);
final result = <String, String>{};
versionInfos.forEach((revision, version) {
result[revision] = version.toString();
});
).wait;
final result = <String, String>{
for (final MapEntry(key: revision, value: version)
in versionInfos.entries)
revision: version.toString()
};
return result;
}

Expand Down
32 changes: 16 additions & 16 deletions tool/get-dart/dart_sdk_archive/lib/src/operating_system.dart
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
import 'dart:html';
import 'package:web/web.dart';

class OperatingSystem {
final class OperatingSystem {
static final OperatingSystem current =
[_chrome, _mac, _windows, _linux, _unix].firstWhere(
(system) => system._matchesNavigator(window.navigator),
orElse: () => OperatingSystem('Unknown', (n) => false),
(system) => window.navigator.appVersion.contains(system._navigatorName),
orElse: () => const OperatingSystem('Unknown', 'Unknown'),
);

final String name;
final bool Function(Navigator) _matchesNavigator;
final String _navigatorName;

OperatingSystem(this.name, this._matchesNavigator);
const OperatingSystem(this.name, this._navigatorName);

bool get isLinux => this == _linux;
bool get isMac => this == _mac;
bool get isUnix => this == _unix;
bool get isWindows => this == _windows;
}

final _linux = OperatingSystem(
const _linux = OperatingSystem(
'Linux',
'Linux',
(Navigator navigator) => navigator.appVersion.contains('Linux'),
);

final _mac = OperatingSystem(
const _mac = OperatingSystem(
'Mac',
'Mac',
(Navigator navigator) => navigator.appVersion.contains('Mac'),
);

final _unix = OperatingSystem(
const _unix = OperatingSystem(
'Unix',
(Navigator navigator) => navigator.appVersion.contains('X11'),
'X11',
);

final _windows = OperatingSystem(
const _windows = OperatingSystem(
'Windows',
(Navigator navigator) => navigator.appVersion.contains('Win'),
'Win',
);

final _chrome = OperatingSystem(
const _chrome = OperatingSystem(
'ChromeOS',
(Navigator navigator) => navigator.appVersion.contains('CrOS'),
'CrOS',
);
20 changes: 10 additions & 10 deletions tool/get-dart/dart_sdk_archive/lib/src/run_app.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'dart:async';
import 'dart:html';

import 'package:http/browser_client.dart';
import 'package:sdk_builds/sdk_builds.dart';
import 'package:web/web.dart';

import 'version_selector.dart';

Expand All @@ -12,25 +12,25 @@ Future<void> runApp() async {
final stableSelector = VersionSelector(
'stable',
client,
querySelector('#stable') as TableElement,
querySelector('#stable-versions') as SelectElement,
querySelector('#stable-os') as SelectElement,
document.getElementById('stable') as HTMLTableElement,
document.getElementById('stable-versions') as HTMLSelectElement,
document.getElementById('stable-os') as HTMLSelectElement,
);

final betaSelector = VersionSelector(
'beta',
client,
querySelector('#beta') as TableElement,
querySelector('#beta-versions') as SelectElement,
querySelector('#beta-os') as SelectElement,
document.getElementById('beta') as HTMLTableElement,
document.getElementById('beta-versions') as HTMLSelectElement,
document.getElementById('beta-os') as HTMLSelectElement,
);

final devSelector = VersionSelector(
'dev',
client,
querySelector('#dev') as TableElement,
querySelector('#dev-versions') as SelectElement,
querySelector('#dev-os') as SelectElement,
document.getElementById('dev') as HTMLTableElement,
document.getElementById('dev-versions') as HTMLSelectElement,
document.getElementById('dev-os') as HTMLSelectElement,
);

unawaited(stableSelector.init());
Expand Down
Loading

0 comments on commit 78db38c

Please sign in to comment.