BWU Dart Archive Downloader makes it easy to download files like API docs,
Dartium or content-shell, Dartium for Android APK, Dart Eclipse plugin, or the
Dart SDK from http://gsdview.appspot.com/dart-archive/channels/
Its main purpose is to make maintenance tasks and automatic setup for continuous
integration (CI) as easy as possible.
To activate the command line tool globally use this command:
pub global activate bwu_dart_archive_downloader
Now you can call the command line tool using
pub global run bwu_dart_archive_downloader:darc ...
or if you have added the ~/.pub-cache/bin
directory to the PATH
environment
variable just:
darc
Download Dart SDK 1.5.2 from the command line:
darc down -v1.5.2
downloads dartsdk-linux-x64-release.zip
to the curent working directory.
Linux x64
is derived from my operating system, but can also be specified by
a parameter.
If you omit the -v...
parameter the latest version is downloaded.
Download chromedriver 1.5.2 from the command line:
darc down -adartium -fchromedriver -o_output -v1.5.2 -cstable/release -e -dxxx -t_extract
This results in two subdirectories in the current working directory
_output
_extract
_output
is the directory where the downloaded file
chromedriver-linux-x64-release.zip
is stored because of the -o
parameter.
_extract
is where the content of the ZIP file is extracted to as specified by
the -t
parameter.
Because we passed -dxxx
, the content (chromedriver-lucid64-full-stable-37942.0
from chromedriver-linux-x64-release.zip
) was extracted as _extract/xxx
which
now contains the file chromedriver
.
-cstable/release
can be omitted because it is the default, but it shows how to
select a specific channel.
Download a file from latest
using the API:
import 'dart:io' as io;
import 'package:bwu_dart_archive_downloader/bwu_dart_archive_downloader.dart';
main() async {
// create an instance of the downloader and specify the download directory.
final downloader = new DartArchiveDownloader(new io.Directory('temp'));
// specify the file to download
final file = new DartiumFile.contentShellZip(
Platform.getFromSystemPlatform(prefer64bit: true));
// build the uri for the download file.
final uri =
DownloadChannel.stableRelease.getUri(file);
// start the download
await downloader.downloadFile(uri);
}
Download a file from a specific release using the API:
final channel = DownloadChannel.stableRelease;
final downloader =
new DartArchiveDownloader(new io.Directory('temp/install'));
final version =
await downloader.findVersion(channel, new Version.parse('1.2.0'));
final uri = await channel.getUri(new SdkFile.dartSdk(
Platform.getFromSystemPlatform(prefer64bit: true)), version: version);
final file = await downloader.downloadFile(uri);
The dart_update
library provides functions to extract the downloaded archive.