Skip to content

Commit

Permalink
Added notice and env var for blocked storage_url (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
leoafarias authored Jul 27, 2020
1 parent f7df8bf commit c8ac35b
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 1.1.5

- Added message with notice and fix if Flutter releases URL is blocked in your country.

## 1.1.4

- Nested FVM config look up, to be used on monorepo projects, or nested directories.
Expand Down
6 changes: 3 additions & 3 deletions coverage_badge.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion lib/exceptions.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:fvm/flutter/flutter_releases.dart';
import 'package:fvm/utils/logger.dart';

/// Logs error for verbose output
Expand Down Expand Up @@ -80,7 +81,9 @@ class ExceptionMissingChannelVersion implements Exception {

/// Could not fetch Flutter releases
class ExceptionCouldNotFetchReleases implements Exception {
final message = 'Could not fetch Flutter releases.';
final message =
'''Failed to retrieve the Flutter SDK from: ${getReleasesUrl()}\n Fvm will use the value set on env FLUTTER_STORAGE_BASE_URL to check versions.\nif you're located in China, please see this page:
https://flutter.dev/community/china''';

/// Constructor
ExceptionCouldNotFetchReleases();
Expand Down
8 changes: 7 additions & 1 deletion lib/flutter/flutter_releases.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@ import 'dart:io';
import 'package:fvm/exceptions.dart';
import 'package:http/http.dart' as http;

const STORAGE_BASE_URL = 'https://storage.googleapis.com';

/// Gets platform specific release URL
String getReleasesUrl({String platform}) {
platform ??= Platform.operatingSystem;
return 'https://storage.googleapis.com/flutter_infra/releases/releases_$platform.json';
final envVars = Platform.environment;

var storageUrl = envVars['FLUTTER_STORAGE_BASE_URL'] ?? STORAGE_BASE_URL;

return '$storageUrl/flutter_infra/releases/releases_$platform.json';
}

FlutterReleases cacheReleasesRes;
Expand Down
2 changes: 1 addition & 1 deletion lib/flutter/flutter_tools.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'dart:io';
import 'package:fvm/constants.dart';
import 'package:fvm/exceptions.dart';
import 'package:fvm/flutter/flutter_releases.dart';

import 'package:fvm/utils/git.dart';

import 'package:fvm/utils/helpers.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/src/version.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: fvm
description: A simple cli to manage Flutter SDK versions per project. Support channels, releases, and local cache for fast switching between versions.
version: 1.1.4
version: 1.1.5
homepage: https://github.com/leoafarias/fvm

environment:
Expand Down

0 comments on commit c8ac35b

Please sign in to comment.