update:i18n
This commit is contained in:
parent
9604563a22
commit
b49e59b45c
yoyo-getfastmirror
config.configcoverage_badge.svg
lib
i18n.dart
pubspec.yamli18n
src
@ -1,165 +0,0 @@
|
|||||||
###################################################################
|
|
||||||
# CONFIGURATION OPTIONS
|
|
||||||
###################################################################
|
|
||||||
# Every item has a default value besides MIRRORS (which is unset).
|
|
||||||
|
|
||||||
# Use aptitude, apt-get, or apt?
|
|
||||||
# Note that apt-get is used as a fallback for outputting the
|
|
||||||
# package URI list for e.g. aptitude, which can't do this
|
|
||||||
# Optionally add the FULLPATH to apt-get or apt-rpm or aptitude
|
|
||||||
# e.g. /usr/bin/aptitude
|
|
||||||
#
|
|
||||||
# Default: apt-get
|
|
||||||
#
|
|
||||||
_APTMGR=apt
|
|
||||||
|
|
||||||
if grep -Eqi "linuxmint" /etc/os-release;then
|
|
||||||
_APTMGR=apt-get
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -x "$(command -v oyo)" ]; then
|
|
||||||
_APTMGR=apt-get
|
|
||||||
fi
|
|
||||||
|
|
||||||
####
|
|
||||||
#
|
|
||||||
# UOS sources auth config
|
|
||||||
#
|
|
||||||
#
|
|
||||||
if grep -Eqi "UnionTech" /etc/issue || grep -Eq "UnionTech" /etc/*-release;then
|
|
||||||
AUTH_UOS_USER="uos-https://license.chinauos.com-apt"
|
|
||||||
AUTH_UOS_PASSWD="`cat /etc/apt/auth.conf.d/uos.conf | grep home-packages.chinauos.com`"
|
|
||||||
AUTH_UOS_PASSWD=`echo ${AUTH_UOS_PASSWD#*password }`
|
|
||||||
|
|
||||||
fi
|
|
||||||
##### UOS自动读取账号密码以实现使用aptss来加速下载
|
|
||||||
|
|
||||||
# Enable DOWNLOADBEFORE to suppress apt-fast confirmation dialog and download
|
|
||||||
# packages directly.
|
|
||||||
#
|
|
||||||
# Default: dialog enabled
|
|
||||||
#
|
|
||||||
DOWNLOADBEFORE=true
|
|
||||||
|
|
||||||
|
|
||||||
# Choose mirror list to speed up downloads from same archive. To select some
|
|
||||||
# mirrors take a look at your distribution's archive mirror lists.
|
|
||||||
# Debian: http://www.debian.org/mirror/list
|
|
||||||
# Ubuntu: https://launchpad.net/ubuntu/+archivemirrors
|
|
||||||
#
|
|
||||||
# It is required to add mirrors in the sources.list to this array as well, so
|
|
||||||
# apt-fast can destinguish between different distributions.
|
|
||||||
#
|
|
||||||
# Examples:
|
|
||||||
#
|
|
||||||
# Different distributions (as in operating systems):
|
|
||||||
#
|
|
||||||
# sources.list:
|
|
||||||
# deb http://deb.debian.org/debian/ unstable main non-free contrib
|
|
||||||
# deb http://de.archive.ubuntu.com/ubuntu/ bionic main universe
|
|
||||||
#
|
|
||||||
# apt-fast.conf:
|
|
||||||
# MIRRORS=( 'http://deb.debian.org/debian','http://ftp.debian.org/debian,http://ftp2.de.debian.org/debian,http://ftp.de.debian.org/debian,ftp://ftp.uni-kl.de/debian'
|
|
||||||
# 'http://archive.ubuntu.com/ubuntu,http://de.archive.ubuntu.com/ubuntu,http://ftp.halifax.rwth-aachen.de/ubuntu,http://ftp.uni-kl.de/pub/linux/ubuntu,http://mirror.informatik.uni-mannheim.de/pub/linux/distributions/ubuntu/' )
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# Single distribution:
|
|
||||||
#
|
|
||||||
# sources.list:
|
|
||||||
# deb http://fr.archive.ubuntu.com/ubuntu/ bionic main
|
|
||||||
# deb http://fr.archive.ubuntu.com/ubuntu/ artful main
|
|
||||||
#
|
|
||||||
# apt-fast.conf:
|
|
||||||
# MIRRORS=( 'http://fr.archive.ubuntu.com/ubuntu,http://bouyguestelecom.ubuntu.lafibre.info/ubuntu,http://mirror.ovh.net/ubuntu,http://ubuntu-archive.mirrors.proxad.net/ubuntu' )
|
|
||||||
#
|
|
||||||
# Default: disabled
|
|
||||||
#
|
|
||||||
MIRRORS=( 'https://code.gitlink.org.cn/yoyo-os/packages/raw/branch/master, https://packages.yzzi.icu/, http://mirror2.inuyasha.love/yoyo, https://yoyo-os.github.io/packages' )
|
|
||||||
|
|
||||||
|
|
||||||
# Maximum number of connections
|
|
||||||
# You can use this value in _DOWNLOADER command. Escape with ${}: ${_MAXNUM}
|
|
||||||
#
|
|
||||||
# Default: 5
|
|
||||||
#
|
|
||||||
_MAXNUM=16
|
|
||||||
|
|
||||||
|
|
||||||
# Maximum number of connections per server
|
|
||||||
# Default: 10
|
|
||||||
#
|
|
||||||
_MAXCONPERSRV=1
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Split size i.e. size of each piece
|
|
||||||
# Possible Values: 1M-1024M
|
|
||||||
#
|
|
||||||
_MINSPLITSZ=1M
|
|
||||||
|
|
||||||
|
|
||||||
# Piece selection algorithm to use
|
|
||||||
# Available values are: default, inorder, geom
|
|
||||||
# default: selects piece so that it reduces the number of establishing connection, reasonable for most cases
|
|
||||||
# inorder: selects pieces in sequential order starting from first piece
|
|
||||||
# geom: selects piece which has minimum index like inorder, but it exponentially increasingly keeps space from previously selected pieces
|
|
||||||
#
|
|
||||||
_PIECEALGO=default
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Downloadmanager listfile
|
|
||||||
# You can use this value in _DOWNLOADER command. Escape with ${}: ${DLLIST}
|
|
||||||
#
|
|
||||||
# Default: /tmp/apt-fast.list
|
|
||||||
#
|
|
||||||
DLLIST='/tmp/apt-fast.list'
|
|
||||||
|
|
||||||
|
|
||||||
# Download command to use. Temporary download list is designed for aria2. But
|
|
||||||
# you can choose another download command or download manager. It has to
|
|
||||||
# support following input file syntax (\t is tab character):
|
|
||||||
#
|
|
||||||
# # Comment
|
|
||||||
# MIRROR1\tMIRROR2\tMIRROR3...
|
|
||||||
# out=FILENAME1
|
|
||||||
# MIRROR1\tMIRROR2\tMIRROR3...
|
|
||||||
# out=FILENAME2
|
|
||||||
# ...
|
|
||||||
#
|
|
||||||
# Examples:
|
|
||||||
# aria2c with a proxy (set username, proxy, ip and password!)
|
|
||||||
# _DOWNLOADER='aria2c --no-conf -c -j ${_MAXNUM} -x ${_MAXCONPERSRV} -s ${_SPLITCON} --min-split-size=${_MINSPLITSZ} --stream-piece-selector=${_PIECEALGO} --http-proxy=http://username:password@proxy_ip:proxy_port -i ${DLLIST}'
|
|
||||||
#
|
|
||||||
# Default: _DOWNLOADER='aria2c --no-conf -c -j ${_MAXNUM} -x ${_MAXCONPERSRV} -s ${_SPLITCON} --min-split-size=${_MINSPLITSZ} --stream-piece-selector=${_PIECEALGO} -i ${DLLIST} --connect-timeout=600 --timeout=600 -m0'
|
|
||||||
#
|
|
||||||
_DOWNLOADER='aria2c --no-conf -c -j ${_MAXNUM} -x ${_MAXCONPERSRV} --min-split-size=${_MINSPLITSZ} --stream-piece-selector=${_PIECEALGO} -i ${DLLIST} --connect-timeout=600 --timeout=600 -m0 --http-user ${AUTH_UOS_USER} --http-passwd ${AUTH_UOS_PASSWD}'
|
|
||||||
|
|
||||||
|
|
||||||
# Download temp folder for Downloadmanager
|
|
||||||
# example /tmp/apt-fast. Standard is /var/cache/apt-fast
|
|
||||||
#
|
|
||||||
# Default: /var/cache/apt/apt-fast
|
|
||||||
#
|
|
||||||
DLDIR='/var/cache/apt/apt-fast'
|
|
||||||
|
|
||||||
|
|
||||||
# APT archives cache directory
|
|
||||||
#
|
|
||||||
# Default /var/cache/apt/archives
|
|
||||||
# (APT configuration items Dir::Cache and Dir::Cache::archives)
|
|
||||||
#
|
|
||||||
APTCACHE='/var/cache/apt/archives'
|
|
||||||
|
|
||||||
|
|
||||||
# apt-fast colors
|
|
||||||
# Colors are disabled when not using a terminal.
|
|
||||||
#
|
|
||||||
# Default colors are:
|
|
||||||
# cGreen='\e[0;32m'
|
|
||||||
# cRed='\e[0;31m'
|
|
||||||
# cBlue='\e[0;34m'
|
|
||||||
# endColor='\e[0m'
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="102" height="20">
|
|
||||||
<linearGradient id="b" x2="0" y2="100%">
|
|
||||||
<stop offset="0" stop-color="#bbb" stop-opacity=".1" />
|
|
||||||
<stop offset="1" stop-opacity=".1" />
|
|
||||||
</linearGradient>
|
|
||||||
<clipPath id="a">
|
|
||||||
<rect width="102" height="20" rx="3" fill="#fff" />
|
|
||||||
</clipPath>
|
|
||||||
<g clip-path="url(#a)">
|
|
||||||
<path fill="#555" d="M0 0h59v20H0z" />
|
|
||||||
<path fill="#44cc11" d="M59 0h43v20H59z" />
|
|
||||||
<path fill="url(#b)" d="M0 0h102v20H0z" />
|
|
||||||
</g>
|
|
||||||
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="110">
|
|
||||||
<text x="305" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="490">coverage</text>
|
|
||||||
<text x="305" y="140" transform="scale(.1)" textLength="490">coverage</text>
|
|
||||||
<text x="795" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="330">100%</text>
|
|
||||||
<text x="795" y="140" transform="scale(.1)" textLength="330">100%</text>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
Before (image error) Size: 1.1 KiB |
40
yoyo-getfastmirror/lib/i18n.dart
Normal file
40
yoyo-getfastmirror/lib/i18n.dart
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
// ignore_for_file: avoid_dynamic_calls
|
||||||
|
|
||||||
|
import 'dart:io';
|
||||||
|
import 'package:yoyo_get_fast_mirror/i18n/lang.i18n.dart';
|
||||||
|
import 'package:yoyo_get_fast_mirror/i18n/lang_zh-CN.i18n.dart';
|
||||||
|
|
||||||
|
final local = Platform.environment['LANG'] == 'zh_CN.utf8';
|
||||||
|
final lang = local ? zhCN : enUS;
|
||||||
|
|
||||||
|
class Error {
|
||||||
|
static String network =
|
||||||
|
lang['GetfastmirroCommand']['Error']['NetWork'] as String;
|
||||||
|
static String generateConfig =
|
||||||
|
lang['GetfastmirroCommand']['Error']['GenerateConfig'] as String;
|
||||||
|
}
|
||||||
|
|
||||||
|
class GetfastmirroCommand {
|
||||||
|
static String description =
|
||||||
|
lang['GetfastmirroCommand']['Description'] as String;
|
||||||
|
static String flagOnlyTestHlep =
|
||||||
|
lang['GetfastmirroCommand']['FlagOnlyTestHlep'] as String;
|
||||||
|
static String runOutPut = lang['GetfastmirroCommand']['RunOutPut'] as String;
|
||||||
|
static String writting = lang['GetfastmirroCommand']['Writting'] as String;
|
||||||
|
static String done = lang['GetfastmirroCommand']['Done'] as String;
|
||||||
|
static String speedTest = lang['GetfastmirroCommand']['SpeedTest'] as String;
|
||||||
|
static String speedResult =
|
||||||
|
lang['GetfastmirroCommand']['SpeedResult'] as String;
|
||||||
|
static Error error = Error();
|
||||||
|
}
|
||||||
|
|
||||||
|
class Lang {
|
||||||
|
static String description = lang['Description'] as String;
|
||||||
|
static String flagVersionHlep =lang['FlagVersionHlep'] as String;
|
||||||
|
static String flagVerboseHlep =lang['FlagVerboseHlep'] as String;
|
||||||
|
static String argumentinformation =lang['Argumentinformation'] as String;
|
||||||
|
static String topLevelOptions =lang['TopLevelOptions'] as String;
|
||||||
|
static String command =lang['Command'] as String;
|
||||||
|
static String commandOptions =lang['CommandOptions'] as String;
|
||||||
|
static GetfastmirroCommand getfastmirroCommand = GetfastmirroCommand();
|
||||||
|
}
|
23
yoyo-getfastmirror/lib/i18n/lang.i18n.dart
Normal file
23
yoyo-getfastmirror/lib/i18n/lang.i18n.dart
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
Map<dynamic,dynamic> enUS = {
|
||||||
|
'Description': 'A Very Good aptss created by Yoyo.',
|
||||||
|
'FlagVersionHlep': 'Print the current version.',
|
||||||
|
'FlagVerboseHlep': 'Noisy logging, including all shell commands executed.',
|
||||||
|
'Argumentinformation': 'Argument information:',
|
||||||
|
'TopLevelOptions': ' Top level options:',
|
||||||
|
'Command': ' Command:',
|
||||||
|
'CommandOptions': ' Command options:',
|
||||||
|
'GetfastmirroCommand': {
|
||||||
|
'Description': 'Get fastest mirror and generate config file for oyo',
|
||||||
|
'FlagOnlyTestHlep': "Only test mirrors' speed",
|
||||||
|
'RunOutPut':
|
||||||
|
'Get the fastest mirror which will be write into source file\nAnd generate a config file for oyo',
|
||||||
|
'Error': {
|
||||||
|
'NetWork': 'NetWork Error',
|
||||||
|
'GenerateConfig': 'Generate Config File Error'
|
||||||
|
},
|
||||||
|
'Writting': 'Writting',
|
||||||
|
'Done': 'Done',
|
||||||
|
'SpeedTest': 'Speed Test......',
|
||||||
|
'SpeedResult': 'Speed Result:'
|
||||||
|
}
|
||||||
|
};
|
19
yoyo-getfastmirror/lib/i18n/lang_zh-CN.i18n.dart
Normal file
19
yoyo-getfastmirror/lib/i18n/lang_zh-CN.i18n.dart
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
Map<dynamic,dynamic> zhCN = {
|
||||||
|
'Description': '一个Yoyo OS定制版aptss配置器',
|
||||||
|
'FlagVersionHlep': '打印当前cli的版本',
|
||||||
|
'FlagVerboseHlep': '啰嗦模式',
|
||||||
|
'Argumentinformation': '参数信息:',
|
||||||
|
'TopLevelOptions': ' 顶级选项:',
|
||||||
|
'Command': ' 命令:',
|
||||||
|
'CommandOptions': ' 命令选项:',
|
||||||
|
'GetfastmirroCommand': {
|
||||||
|
'Description': '切换最快的镜像源并为oyo生成配置文件',
|
||||||
|
'FlagOnlyTestHlep': '只测试镜像源速度,不生成配置',
|
||||||
|
'RunOutPut': '切换最快的镜像源并为oyo生成配置文件',
|
||||||
|
'Error': {'NetWork': '网络错误', 'GenerateConfig': '生成文件失败'},
|
||||||
|
'Writting': '写入中',
|
||||||
|
'Done': '完成',
|
||||||
|
'SpeedTest': '速度测试中......',
|
||||||
|
'SpeedResult': '测速结果:'
|
||||||
|
}
|
||||||
|
};
|
@ -1,12 +1,13 @@
|
|||||||
import 'package:args/args.dart';
|
import 'package:args/args.dart';
|
||||||
import 'package:args/command_runner.dart';
|
import 'package:args/command_runner.dart';
|
||||||
import 'package:mason_logger/mason_logger.dart';
|
import 'package:mason_logger/mason_logger.dart';
|
||||||
|
import 'package:yoyo_get_fast_mirror/i18n.dart';
|
||||||
import 'package:yoyo_get_fast_mirror/src/commands/commands.dart';
|
import 'package:yoyo_get_fast_mirror/src/commands/commands.dart';
|
||||||
import 'package:yoyo_get_fast_mirror/src/version.dart';
|
import 'package:yoyo_get_fast_mirror/src/version.dart';
|
||||||
|
|
||||||
const executableName = 'yoyo-getfastmirror';
|
const executableName = 'yoyo-getfastmirror';
|
||||||
const packageName = 'yoyo_get_fast_mirror';
|
const packageName = 'yoyo_get_fast_mirror';
|
||||||
const description = 'A Very Good aptss created by Yoyo.';
|
final description = Lang.description;
|
||||||
|
|
||||||
class YoyoGetFastMirrorCommandRunner extends CommandRunner<int> {
|
class YoyoGetFastMirrorCommandRunner extends CommandRunner<int> {
|
||||||
/// {@macro yoyo_get_fast_mirror_command_runner}
|
/// {@macro yoyo_get_fast_mirror_command_runner}
|
||||||
@ -20,15 +21,15 @@ class YoyoGetFastMirrorCommandRunner extends CommandRunner<int> {
|
|||||||
'version',
|
'version',
|
||||||
abbr: 'v',
|
abbr: 'v',
|
||||||
negatable: false,
|
negatable: false,
|
||||||
help: 'Print the current version.',
|
help: Lang.flagVersionHlep,
|
||||||
)
|
)
|
||||||
..addFlag(
|
..addFlag(
|
||||||
'verbose',
|
'verbose',
|
||||||
help: 'Noisy logging, including all shell commands executed.',
|
help: Lang.flagVerboseHlep,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Add sub commands
|
// Add sub commands
|
||||||
addCommand(GetfastmirroCommand(logger: _logger));
|
addCommand(GetfastmirrorCommand(logger: _logger));
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -67,8 +68,8 @@ class YoyoGetFastMirrorCommandRunner extends CommandRunner<int> {
|
|||||||
@override
|
@override
|
||||||
Future<int?> runCommand(ArgResults topLevelResults) async {
|
Future<int?> runCommand(ArgResults topLevelResults) async {
|
||||||
_logger
|
_logger
|
||||||
..detail('Argument information:')
|
..detail(Lang.argumentinformation)
|
||||||
..detail(' Top level options:');
|
..detail(Lang.topLevelOptions);
|
||||||
for (final option in topLevelResults.options) {
|
for (final option in topLevelResults.options) {
|
||||||
if (topLevelResults.wasParsed(option)) {
|
if (topLevelResults.wasParsed(option)) {
|
||||||
_logger.detail(' - $option: ${topLevelResults[option]}');
|
_logger.detail(' - $option: ${topLevelResults[option]}');
|
||||||
@ -77,8 +78,8 @@ class YoyoGetFastMirrorCommandRunner extends CommandRunner<int> {
|
|||||||
if (topLevelResults.command != null) {
|
if (topLevelResults.command != null) {
|
||||||
final commandResult = topLevelResults.command!;
|
final commandResult = topLevelResults.command!;
|
||||||
_logger
|
_logger
|
||||||
..detail(' Command: ${commandResult.name}')
|
..detail('${Lang.command} ${commandResult.name}')
|
||||||
..detail(' Command options:');
|
..detail(Lang.commandOptions);
|
||||||
for (final option in commandResult.options) {
|
for (final option in commandResult.options) {
|
||||||
if (commandResult.wasParsed(option)) {
|
if (commandResult.wasParsed(option)) {
|
||||||
_logger.detail(' - $option: ${commandResult[option]}');
|
_logger.detail(' - $option: ${commandResult[option]}');
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
import 'package:args/command_runner.dart';
|
import 'package:args/command_runner.dart';
|
||||||
import 'package:mason_logger/mason_logger.dart';
|
import 'package:mason_logger/mason_logger.dart';
|
||||||
import 'package:yoyo_get_fast_mirror/src/commands/modules/getfastmirro/getfastmirror.dart';
|
import 'package:yoyo_get_fast_mirror/i18n.dart';
|
||||||
|
import 'package:yoyo_get_fast_mirror/src/commands/modules/getfastmirror/getfastmirror.dart';
|
||||||
|
|
||||||
class GetfastmirroCommand extends Command<int> {
|
class GetfastmirrorCommand extends Command<int> {
|
||||||
GetfastmirroCommand({
|
GetfastmirrorCommand({
|
||||||
required Logger logger,
|
required Logger logger,
|
||||||
}) : _logger = logger {
|
}) : _logger = logger {
|
||||||
argParser.addFlag(
|
argParser.addFlag(
|
||||||
'only-test',
|
'only-test',
|
||||||
abbr: 'o',
|
abbr: 'o',
|
||||||
help: "Only test mirrors' speed",
|
help: GetfastmirroCommand.flagOnlyTestHlep,
|
||||||
negatable: false,
|
negatable: false,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get description =>
|
String get description => GetfastmirroCommand.description;
|
||||||
'Get fastest mirror and generate config file for oyo';
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get name => 'getfastmirror';
|
String get name => 'getfastmirror';
|
||||||
@ -25,10 +25,7 @@ class GetfastmirroCommand extends Command<int> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Future<int> run() async {
|
Future<int> run() async {
|
||||||
final output = lightBlue.wrap('''
|
final output = lightBlue.wrap(GetfastmirroCommand.runOutPut);
|
||||||
Get the fastest mirror which will be write into source file
|
|
||||||
And generate a config file for oyo
|
|
||||||
''');
|
|
||||||
_logger.info(output);
|
_logger.info(output);
|
||||||
final onlyTest = argResults?['only-test'] == true;
|
final onlyTest = argResults?['only-test'] == true;
|
||||||
final commandResult = await getFastMirror(onlyTest: onlyTest);
|
final commandResult = await getFastMirror(onlyTest: onlyTest);
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
import 'package:mason_logger/mason_logger.dart';
|
import 'package:mason_logger/mason_logger.dart';
|
||||||
import 'package:yoyo_get_fast_mirror/src/commands/modules/getfastmirro/Ubuntu/ubuntu_get_mirro_list.dart';
|
import 'package:yoyo_get_fast_mirror/src/commands/modules/getfastmirror/Ubuntu/ubuntu_get_mirro_list.dart';
|
||||||
import 'package:yoyo_get_fast_mirror/src/commands/modules/getfastmirro/Yoyo/yoyo_get_mirro_list.dart';
|
import 'package:yoyo_get_fast_mirror/src/commands/modules/getfastmirror/Yoyo/yoyo_get_mirro_list.dart';
|
||||||
import 'package:yoyo_get_fast_mirror/src/commands/modules/getfastmirro/Yoyo/yoyo_is_exist.dart';
|
import 'package:yoyo_get_fast_mirror/src/commands/modules/getfastmirror/Yoyo/yoyo_is_exist.dart';
|
||||||
import 'package:yoyo_get_fast_mirror/src/commands/modules/getfastmirro/utils/generate_apt_fast_config_file.dart';
|
import 'package:yoyo_get_fast_mirror/src/commands/modules/getfastmirror/utils/generate_apt_fast_config_file.dart';
|
||||||
import 'package:yoyo_get_fast_mirror/src/commands/modules/getfastmirro/utils/network_test.dart';
|
import 'package:yoyo_get_fast_mirror/src/commands/modules/getfastmirror/utils/network_test.dart';
|
||||||
import 'package:yoyo_get_fast_mirror/src/commands/modules/getfastmirro/utils/test_mirro_speed.dart';
|
import 'package:yoyo_get_fast_mirror/src/commands/modules/getfastmirror/utils/test_mirro_speed.dart';
|
||||||
import 'package:yoyo_get_fast_mirror/src/commands/modules/getfastmirro/utils/write_mirror_into_file.dart';
|
import 'package:yoyo_get_fast_mirror/src/commands/modules/getfastmirror/utils/write_mirror_into_file.dart';
|
||||||
|
import 'package:yoyo_get_fast_mirror/i18n.dart';
|
||||||
|
|
||||||
final Map<String, dynamic> status = {};
|
final Map<String, dynamic> status = {};
|
||||||
final Logger _logger = Logger();
|
final Logger _logger = Logger();
|
||||||
@ -17,7 +18,7 @@ Future<Map<String, dynamic>> getFastMirror({bool onlyTest = false}) async {
|
|||||||
//首先测试网络链接
|
//首先测试网络链接
|
||||||
if (!await networkTest()) {
|
if (!await networkTest()) {
|
||||||
status['success'] = false;
|
status['success'] = false;
|
||||||
status['msg'] = 'NetWork Error';
|
status['msg'] = Error.network;
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
// 如果 yoyo-os.list 存在,获取Yoyo镜像地址
|
// 如果 yoyo-os.list 存在,获取Yoyo镜像地址
|
||||||
@ -45,7 +46,7 @@ Future<Map<String, dynamic>> getFastMirror({bool onlyTest = false}) async {
|
|||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
status['success'] = false;
|
status['success'] = false;
|
||||||
status['msg'] = 'Generate Config File Error';
|
status['msg'] = Error.generateConfig;
|
||||||
return status;
|
return status;
|
||||||
} finally {
|
} finally {
|
||||||
status['success'] = true;
|
status['success'] = true;
|
@ -1,5 +1,5 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'package:yoyo_get_fast_mirror/src/commands/modules/getfastmirro/utils/apt_fast_config_template.dart';
|
import 'package:yoyo_get_fast_mirror/src/commands/modules/getfastmirror/utils/apt_fast_config_template.dart';
|
||||||
|
|
||||||
final tmpDir = Directory.systemTemp.path;
|
final tmpDir = Directory.systemTemp.path;
|
||||||
final String filePath = '$tmpDir/oyo/apt-fast.conf';
|
final String filePath = '$tmpDir/oyo/apt-fast.conf';
|
@ -3,15 +3,16 @@ import 'dart:collection';
|
|||||||
import 'package:cli_spinner/cli_spinner.dart';
|
import 'package:cli_spinner/cli_spinner.dart';
|
||||||
import 'package:dart_ping/dart_ping.dart';
|
import 'package:dart_ping/dart_ping.dart';
|
||||||
import 'package:mason_logger/mason_logger.dart';
|
import 'package:mason_logger/mason_logger.dart';
|
||||||
|
import 'package:yoyo_get_fast_mirror/i18n.dart';
|
||||||
|
|
||||||
Logger _logger = Logger();
|
Logger _logger = Logger();
|
||||||
final speedResult = lightGreen.wrap('Speed Result:');
|
final speedResult = lightGreen.wrap(GetfastmirroCommand.speedResult);
|
||||||
|
|
||||||
Future<List<Map<String, String>>> testMirroSpeed(
|
Future<List<Map<String, String>>> testMirroSpeed(
|
||||||
List<String> mirrorList,
|
List<String> mirrorList,
|
||||||
) async {
|
) async {
|
||||||
final spinner =
|
final spinner =
|
||||||
Spinner.type('Speed Test ......', SpinnerType.boxCircle)..start();
|
Spinner.type(GetfastmirroCommand.speedTest, SpinnerType.boxCircle)..start();
|
||||||
final testResult = <Map<String, String>>[];
|
final testResult = <Map<String, String>>[];
|
||||||
final logMsg = StringBuffer()..write(speedResult);
|
final logMsg = StringBuffer()..write(speedResult);
|
||||||
for (final element in mirrorList) {
|
for (final element in mirrorList) {
|
@ -1,7 +1,8 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'package:mason_logger/mason_logger.dart';
|
import 'package:mason_logger/mason_logger.dart';
|
||||||
|
import 'package:yoyo_get_fast_mirror/i18n.dart';
|
||||||
|
|
||||||
final done = lightGreen.wrap('Done');
|
final done = lightGreen.wrap(GetfastmirroCommand.done);
|
||||||
final Logger _logger = Logger();
|
final Logger _logger = Logger();
|
||||||
RegExp urlReg = RegExp(
|
RegExp urlReg = RegExp(
|
||||||
r'\b(([\w-]+://?|www[.])[^\s()<>]+(?:[\w\d]+|([^[:punct:]\s]|/)))',
|
r'\b(([\w-]+://?|www[.])[^\s()<>]+(?:[\w\d]+|([^[:punct:]\s]|/)))',
|
||||||
@ -9,7 +10,7 @@ RegExp urlReg = RegExp(
|
|||||||
|
|
||||||
///mirror 镜像源网址
|
///mirror 镜像源网址
|
||||||
void writeMirrorIntoFile(String mirror, String path) {
|
void writeMirrorIntoFile(String mirror, String path) {
|
||||||
final writting = lightYellow.wrap('Writting $path');
|
final writting = lightYellow.wrap('${GetfastmirroCommand.writting} $path');
|
||||||
final file = File(path);
|
final file = File(path);
|
||||||
var fileContent = file.readAsStringSync();
|
var fileContent = file.readAsStringSync();
|
||||||
final url = urlReg.allMatches(fileContent);
|
final url = urlReg.allMatches(fileContent);
|
@ -1 +1 @@
|
|||||||
const packageVersion = '2023.1.31';
|
const packageVersion = '2023.1.31-2';
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
name: yoyo_get_fast_mirror
|
name: yoyo_get_fast_mirror
|
||||||
description: A Very Good Project created by Very Good CLI.
|
description: A Very Good Project created by Very Good CLI.
|
||||||
version: 0.0.1
|
version: 2023.1.31-2
|
||||||
publish_to: none
|
publish_to: none
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user