diff --git a/src/_data/mirrors.yml b/src/_data/mirrors.yml new file mode 100644 index 00000000000..c47295aa0cd --- /dev/null +++ b/src/_data/mirrors.yml @@ -0,0 +1,22 @@ +- group: 'China Flutter User Group' + mirror: 'flutter-io.cn' + urls: + pubhosted: 'https://pub.flutter-io.cn' + flutterstorage: 'https://storage.flutter-io.cn' + issues: 'https://github.com/cfug/flutter.cn/issues/new/choose' + group: https://github.com/cfug +- group: 'Shanghai Jiao Tong University *nix User Group' + mirror: 'mirror.sjtu.edu.cn' + urls: + pubhosted: 'https://mirror.sjtu.edu.cn/flutter-infra' + flutterstorage: 'https://mirror.sjtu.edu.cn' + issues: 'https://github.com/sjtug/mirror-requests' + group: https://github.com/sjtug +- group: 'Tsinghua University TUNA Association' + mirror: 'mirrors.tuna.tsinghua.edu.cn' + urls: + pubhosted: 'https://mirrors.tuna.tsinghua.edu.cn/dart-pub' + flutterstorage: 'https://mirrors.tuna.tsinghua.edu.cn/flutter' + issues: 'https://github.com/tuna/issues' + group: https://tuna.moe + diff --git a/src/_includes/docs/china-notice-cn.md b/src/_includes/docs/china-notice-cn.md new file mode 100644 index 00000000000..69b0262b44a --- /dev/null +++ b/src/_includes/docs/china-notice-cn.md @@ -0,0 +1,6 @@ +{{site.alert.secondary}} + 如果你正在中国的网络环境下配置 Flutter, + 请参考 [在中国网络环境下使用 Flutter][] 文档. +{{site.alert.end}} + +[在中国网络环境下使用 Flutter]: https://flutter.cn/community/china \ No newline at end of file diff --git a/src/_includes/docs/china-notice.md b/src/_includes/docs/china-notice.md index fa00ac6c114..cf99bd7f3ab 100644 --- a/src/_includes/docs/china-notice.md +++ b/src/_includes/docs/china-notice.md @@ -1,5 +1,5 @@ {{site.alert.important}} - If you're in China, read [Using Flutter in China][]. + If you develop apps in China, check out [using Flutter in China][]. {{site.alert.end}} -[Using Flutter in China]: {{site.url}}/community/china \ No newline at end of file +[using Flutter in China]: {{site.url}}/community/china diff --git a/src/assets/js/main.js b/src/assets/js/main.js index 2e9ad3fcc64..4b422cc9f1f 100644 --- a/src/assets/js/main.js +++ b/src/assets/js/main.js @@ -20,9 +20,10 @@ document.addEventListener("DOMContentLoaded", function(_) { setupTabs($('#vscode-to-vs-setup'), 'dev.flutter.debug.vscode-to-vs'); setupTabs($('#add-to-app-android'), 'dev.flutter.add-to-app.android'); setupTabs($('#add-to-app-android-deps'), 'dev.flutter.add-to-app.android.deps'); - - setupTabs($('#ios-versions'), 'dev.flutter.ios-versions'); + setupTabs($('#china-os-tabs'), 'dev.flutter.china-os'); + setupTabs($('#china-os-dl-tabs'), 'dev.flutter.china-os-dl'); + setupTabs($('#china-os-pub-tabs'), 'dev.flutter.china-os-pub'); prettyPrint(); }); diff --git a/src/community/china.md b/src/community/china.md deleted file mode 100644 index 9432c1ffe9b..00000000000 --- a/src/community/china.md +++ /dev/null @@ -1,79 +0,0 @@ ---- -title: Using Flutter in China -description: Where to find a version of the Flutter site that is localized to Simplified Chinese. -toc: true ---- - -{% assign path = 'flutter_infra_release/releases/stable/windows/flutter_windows_3.3.0-stable.zip' -%} - -The Flutter community has made a Simplified Chinese version -of the Flutter website available at -[https://flutter.cn](https://flutter.cn), -maintained by [The China Flutter User Group (CFUG)][]. - -If you'd like to install Flutter using an -[installation bundle]({{site.url}}/release/archive), -you can replace the domain of the original URL with a trusted mirror -to speed it up. For example: - -* Original URL:
- [`https://storage.googleapis.com/{{path}}`](https://storage.googleapis.com/{{path}}) - -* Mirrored URL:
- [`https://storage.flutter-io.cn/{{path}}`](https://storage.flutter-io.cn/{{path}}) - -You must also set two environment variables to upgrade Flutter and use the pub -package repository in China. Instructions are below. - -{{site.alert.important}} - Use mirror sites only if you _trust_ the provider. - The Flutter team cannot verify their reliability or security. -{{site.alert.end}} - -## Configuring Flutter to use a mirror site - -If you're installing or using Flutter in China, -it might be helpful to use a trustworthy local -mirror site that hosts Flutter's dependencies. -To instruct the Flutter tool to use an alternate storage location, -you need to set two environment variables, `PUB_HOSTED_URL` and -`FLUTTER_STORAGE_BASE_URL`, before running the `flutter` command. - -Taking macOS or Linux as an example, here are the first few steps in -the setup process for using a mirror site. Run the following in a Bash -shell from the directory where you wish to store your local Flutter clone: - -```terminal -$ export PUB_HOSTED_URL=https://pub.flutter-io.cn -$ export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn -$ git clone -b dev {{site.repo.flutter}}.git -$ export PATH="$PWD/flutter/bin:$PATH" -$ cd ./flutter -$ flutter doctor -``` - -After these steps, you should be able to continue -[setting up Flutter]({{site.url}}/get-started/editor) normally. -From here on, packages fetched by `flutter pub get` are -downloaded from `flutter-io.cn` in any shell where `PUB_HOSTED_URL` -and `FLUTTER_STORAGE_BASE_URL` are set. - -The `flutter-io.cn` server is a provisional mirror for Flutter -dependencies and packages maintained by [The China Flutter User Group (CFUG)][]. -The Flutter team cannot guarantee long-term availability of this service. -You're free to use other mirrors if they become available. -If you're interested in setting up your own mirror in China, -contact [flutter-dev@googlegroups.com](mailto:flutter-dev@googlegroups.com) -for assistance. - -If you're running into issues that only occur when using the `flutter-io.cn` server, -consider reporting the issue to -[the issue tracker (镜像问题)](https://github.com/cfug/flutter.cn/issues/new/choose). - -## Community-run mirror sites - -* Shanghai Jiao Tong University Linux User Group - * `FLUTTER_STORAGE_BASE_URL`: [https://mirror.sjtu.edu.cn/](https://mirror.sjtu.edu.cn) - * `PUB_HOSTED_URL`: [https://mirror.sjtu.edu.cn/dart-pub/](https://mirror.sjtu.edu.cn/dart-pub) - -[The China Flutter User Group (CFUG)]: https://github.com/cfug diff --git a/src/community/china/_download-urls.md b/src/community/china/_download-urls.md new file mode 100644 index 00000000000..16893d7a5b1 --- /dev/null +++ b/src/community/china/_download-urls.md @@ -0,0 +1,35 @@ + +{% assign id = include.ref-os | downcase -%} +{% assign mainpath = include.filepath -%} +{%- case id %} +{% when 'windows','macos' %} +{%- assign file-format = 'zip' %} +{% else %} +{%- assign file-format = 'tar.xz' %} +{% endcase %} +{%- if id == 'chromeos' %} +{% assign plat = 'linux' %} +{%- else %} +{% assign plat = id %} +{% endif %} +{% capture filepath -%}{{mainpath | replace: "opsys", plat}}{{file-format}} {% endcapture -%} + + +
+ +To download the {{include.ref-os}} 3.13 version of the Flutter SDK, +you would change the original URL from: + +```terminal +https://storage.googleapis.com/{{filepath}} +``` + +to the mirror URL: + +```terminal +https://storage.flutter-io.cn/{{filepath}} +``` + +
diff --git a/src/community/china/_os-settings.md b/src/community/china/_os-settings.md new file mode 100644 index 00000000000..61345246f23 --- /dev/null +++ b/src/community/china/_os-settings.md @@ -0,0 +1,124 @@ +{% assign id = include.ref-os | downcase -%} +{% assign jsonurl = 'https://storage.googleapis.com/flutter_infra_release/releases/releases_{{id}}.json' %} +{% assign os = include.ref-os -%} +{% assign sdk = include.sdk -%} + +{% if id == 'windows' -%} + {% assign shell = 'Powershell' -%} + {% assign prompt = 'C:\>' -%} + {% assign comtoset = '$env:' -%} + {% assign installdirsuggestion = '`%USERPROFILE%\dev`' %} + {% capture envvarset -%}{{prompt}} {{comtoset}}{% endcapture -%} + {% capture setpath -%}{{envvarset}}PATH = $pwd.PATH + "/flutter/bin",$env:PATH -join ";"{% endcapture -%} + {% capture newdir -%}{{prompt}} New-Item -Path '{{installdirsuggestion}}' -ItemType Directory{% endcapture -%} + {% capture unzip -%} {{prompt}} Extract-Archive:{% endcapture -%} + {% capture permaddexample -%} +$newPath = $pwd.PATH + "/flutter/bin",$env:PATH -join ";" +[System.Environment]::SetEnvironmentVariable('Path',$newPath,User) +[System.Environment]::SetEnvironmentVariable('PUB_HOSTED_URL','https://pub.flutter-io.cn',User) +[System.Environment]::SetEnvironmentVariable('FLUTTER_STORAGE_BASE_URL','https://storage.flutter-io.cn',User) + {% endcapture -%} +{% else -%} + {% assign shell = 'your terminal' -%} + {% assign prompt = '$' -%} + {% assign comtoset = 'export ' -%} + {% assign installdirsuggestion = '`~/dev`' %} + {% capture envvarset -%}{{prompt}} {{comtoset}}{% endcapture -%} + {% capture setpath -%}{{envvarset}}PATH="$PWD/flutter/bin:$PATH"{% endcapture -%} + {% capture newdir -%}{{prompt}} mkdir ~/dev{% endcapture -%} + {% if id == 'macos' %} + {% capture unzip -%} {{prompt}} unzip{% endcapture -%} + {% else %} + {% capture unzip -%} {{prompt}} tar -xf{% endcapture -%} + {% endif %} + {% capture permaddexample -%} +cat <> ~/.zprofile +{{envvarset}}PUB_HOSTED_URL="https://pub.flutter-io.cn" +{{envvarset}}FLUTTER_STORAGE_BASE_URL="https://storage.flutter-io.cn" +{{setpath}} +EOT + {% endcapture -%} +{% endif -%} +{%- case id %} + {% when 'windows','macos' %} + {%- assign file-format = 'zip' %} + {%- assign download-os = id %} + {% when 'linux','chromeos' %} + {%- assign download-os = 'linux' %} + {%- assign file-format = 'tar.xz' %} +{% endcase %} + +
+ +This procedure requires using {{shell}}. + +1. Open a new window in {{shell}} to prepare running scripts. + +1. Set `PUB_HOSTED_URL` to your mirror site. + + ```terminal + {{envvarset}}PUB_HOSTED_URL="https://pub.flutter-io.cn" + ``` + +1. Set `FLUTTER_STORAGE_BASE_URL` to your mirror site. + + ```terminal + {{envvarset}}FLUTTER_STORAGE_BASE_URL="https://storage.flutter-io.cn" + ``` + +1. Download the Flutter archive from your mirror site. + In your preferred browser, go to + [Flutter SDK archive](https://flutter.cn/docs/release/archive?tab={{id}}). + +1. Create a folder where you can install Flutter. then change into it. + + Consider a path like {{installdirsuggestion}}. + + ```terminal + {{newdir}}; cd {{installdirsuggestion}} + ``` + +1. Extract the the SDK from the {{file-format}} archive file. + + This example assumes you downloaded the {{os}} version of the Flutter SDK. + + ```terminal + {{unzip}} {{sdk | replace: "opsys", download-os}}{{file-format}} + ``` + +1. Add Flutter to your `PATH` environment variable. + + ```terminal + {{setpath}} + ``` + +1. Run Flutter Doctor to verify your installation. + + ```terminal + {{prompt}} flutter doctor + ``` + +1. Return to the [setting up Flutter]({{site.url}}/get-started/editor) + guide and continue from that procedure. + +From this example, `flutter pub get` fetches packages from `flutter-io.cn`, +in any terminal where you set `PUB_HOSTED_URL` and `FLUTTER_STORAGE_BASE_URL`. + +Any environment variables set using `{{comtoset}}` in this procedure +only apply to the current window. + +To set these values on a permanent basis, +{% if id == 'windows' -%} +set the enviroment variables as in the following example: +{% else -%} +append those three `export` commands to the `*rc` or `*profile` +file that your preferred shell uses. This would resemble the following: +{% endif -%} + +```terminal +{{permaddexample}} +``` + +
diff --git a/src/community/china/_pub-settings.md b/src/community/china/_pub-settings.md new file mode 100644 index 00000000000..6f6cbe6240e --- /dev/null +++ b/src/community/china/_pub-settings.md @@ -0,0 +1,44 @@ + +{% assign id = include.os | downcase -%} + +
+ +1. Configure a proxy. + To configure a proxy, check out the [Dart documentation on proxies][]. + + {% comment %} + From https://github.com/flutter/website/issues/2556#issuecomment-481566476 + {% endcomment %} + +1. Verify that your `PUB_HOSTED_URL` environment variable is either unset + or empty. + + {% if id == 'windows' -%} + + ```terminal + {{prompt}} echo $env:PUB_HOSTED_URL + ``` + + If this command returns any value, unset it. + + ```terminal + {{prompt}} Remove-Item $env:PUB_HOSTED_URL + ``` + + {% else -%} + + ```terminal + {{prompt}} echo $PUB_HOSTED_URL + ``` + + If this command returns any value, unset it. + + ```terminal + {{prompt}} unset $PUB_HOSTED_URL + ``` + + {% endif %} + +
diff --git a/src/community/china/index.md b/src/community/china/index.md new file mode 100644 index 00000000000..0183531e879 --- /dev/null +++ b/src/community/china/index.md @@ -0,0 +1,175 @@ +--- +title: Using Flutter in China +description: How to use, access, and learn about Flutter in China. +toc: true +os-list: [Windows, macOS, Linux, ChromeOS] +--- + +{% assign flutter-sdk = 'flutter_opsys_v3.13.0-stable.' %} +{% capture sdk-path -%}flutter_infra_release/releases/stable/opsys/{{flutter-sdk}}{%- endcapture %} + +{% include docs/china-notice-cn.md %} + +To speed the download and installation of Flutter in China, +consider using a [mirror site][] or _mirror_. + +{{site.alert.important}} + Use mirror sites _only_ if you _trust_ the provider. + The Flutter team can't verify their reliability or security. +{{site.alert.end}} + +[mirror site]: https://en.wikipedia.org/wiki/Mirror_site + +## Use a Flutter mirror site + +The [China Flutter User Group][] (CFUG) maintains a Simplified Chinese +Flutter website [https://flutter.cn](https://flutter.cn) and a mirror. +Other mirrors can be found at the [end of this guide](#known-trusted-community-run-mirror-sites). + +### Configure your machine to use a mirror site + +To install or use Flutter in China, use a trustworthy Flutter mirror. +This requires setting two environment variables on your machine. + +_All examples that follow presume that you are using the CFUG mirror._ + +To set your machine to use a mirror site: + +{% comment %} Nav tabs {% endcomment -%} + + +{% comment %} Tab panes {% endcomment -%} +
+{% for os in page.os-list %} +{% include_relative _os-settings.md ref-os=os sdk=flutter-sdk %} +{% endfor -%} +
+ +### Download Flutter archives based on a mirror site + +To download Flutter from the [SDK archive][] from a mirror, +replace `storage.googleapis.com` with the URL of your trusted mirror. +Use your mirror site in the browser or in other applications +like IDM or Thunder. +This should improve download speed. + +[SDK archive]: {{site.url}}/release/archive + +The following example shows how to change the URL for Flutter's download site +from Google's archive to CFUG's mirror. + +{% comment %} Nav tabs {% endcomment -%} + + +{% comment %} Tab panes {% endcomment -%} +
+{% for os in page.os-list %} +{% include_relative _download-urls.md ref-os=os filepath=sdk-path %} +{% endfor -%} +
+ +{{site.alert.note}} + Not every mirror supports downloading artifacts using their direct URL. +{{site.alert.end}} + +## Configure your machine to publish your package + +To publish your packages to `pub.dev`, +you need to be able to access both Google Auth and the `pub.dev` site. + +{% comment %} +From https://github.com/flutter/website/pull/9338#discussion_r1328077020 +{% endcomment %} + +To enable access to `pub.dev`: + +{% comment %} Nav tabs {% endcomment -%} + + +{% comment %} Tab panes {% endcomment -%} +
+{% include_relative _pub-settings.md os="Windows" filepath=path %} +{% include_relative _pub-settings.md os="macOS" filepath=path %} +{% include_relative _pub-settings.md os="Linux" filepath=path %} +{% include_relative _pub-settings.md os="ChromeOS" filepath=path %} +
+ +To learn more about publishing packages, check out the +[Dart documentation on publishing packages][]. + +[Dart documentation on proxies]: {{site.dart-site}}/tools/pub/troubleshoot#pub-get-fails-from-behind-a-corporate-firewall + +[Dart documentation on publishing packages]: {{site.dart-site}}/tools/pub/publishing + +## Known, trusted community-run mirror sites + +The Flutter team can't guarantee long-term availability of any mirrors. +You can use other mirrors if they become available. + +{% for mirror in site.data.mirrors %} + +
+ +### {{mirror.group}} + +[{{mirror.group}}][] maintains the `{{mirror.mirror}}` mirror. +It includes the Flutter SDK and pub packages. + +#### Configure your machine to use this mirror +{:.no_toc} + +To set your machine to use this mirror, use these commands. + +On macOS, Linux, or ChromeOS: + +```terminal +export PUB_HOSTED_URL={{mirror.urls.pubhosted}}; +export FLUTTER_STORAGE_BASE_URL={{mirror.urls.flutterstorage}} +``` + +On Windows: + +```terminal +$env:PUB_HOSTED_URL="{{mirror.urls.pubhosted}}"; +$env:FLUTTER_STORAGE_BASE_URL="{{mirror.urls.flutterstorage}}" +``` + +#### Get support for this mirror +{:.no_toc} + +If you're running into issues that only occur when +using the `{{mirror.mirror}}` mirror, report the issue to their +[issue tracker]({{mirror.urls.issues}}). + +{% endfor %} + +{% for mirror in site.data.mirrors %} +[{{mirror.group}}]: {{mirror.urls.group}} +{% endfor %} + +## Offer to host a new mirror site + +If you're interested in setting up your own mirror, +contact [flutter-dev@googlegroups.com](mailto:flutter-dev@googlegroups.com) +for assistance.