From 611518f790cb06c58d8fa881180a0774907d3ff1 Mon Sep 17 00:00:00 2001 From: lollipopkit Date: Sat, 10 Dec 2022 23:14:55 +0800 Subject: [PATCH] opt. for `docker` & `apt` --- .vscode/settings.json | 5 +- ios/Runner.xcodeproj/project.pbxproj | 12 +- lib/core/extension/ssh_client.dart | 35 +++ lib/core/extension/stringx.dart | 5 + lib/data/provider/apt.dart | 103 +++---- lib/data/provider/docker.dart | 134 ++++++--- lib/data/res/build_data.dart | 6 +- lib/data/res/error.dart | 28 ++ lib/data/store/docker.dart | 11 + lib/data/store/setting.dart | 2 +- lib/generated/intl/messages_en.dart | 11 + lib/generated/intl/messages_zh.dart | 9 + lib/generated/l10n.dart | 60 ++++ lib/l10n/intl_en.arb | 8 +- lib/l10n/intl_zh.arb | 8 +- lib/locator.dart | 5 + lib/view/page/apt.dart | 91 +++--- lib/view/page/docker.dart | 265 ++++++++++++++---- lib/view/page/server/detail.dart | 2 +- macos/Podfile.lock | 34 +++ macos/Runner.xcodeproj/project.pbxproj | 62 +++- .../contents.xcworkspacedata | 3 + 22 files changed, 686 insertions(+), 213 deletions(-) create mode 100644 lib/core/extension/ssh_client.dart create mode 100644 lib/data/res/error.dart create mode 100644 lib/data/store/docker.dart create mode 100644 macos/Podfile.lock diff --git a/.vscode/settings.json b/.vscode/settings.json index 42786741..40492eed 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,8 +1,9 @@ { + "dart.flutterSdkPath": ".fvm", "files.watcherExclude": { - "**/.fvm": true + ".fvm": true }, "search.exclude": { - "**/.fvm": true + ".fvm": true } } \ No newline at end of file diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index f7178f73..f93f3b09 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -354,7 +354,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; - CURRENT_PROJECT_VERSION = 165; + CURRENT_PROJECT_VERSION = 166; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; @@ -362,7 +362,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.165; + MARKETING_VERSION = 1.0.166; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -484,7 +484,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; - CURRENT_PROJECT_VERSION = 165; + CURRENT_PROJECT_VERSION = 166; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; @@ -492,7 +492,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.165; + MARKETING_VERSION = 1.0.166; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -508,7 +508,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; - CURRENT_PROJECT_VERSION = 165; + CURRENT_PROJECT_VERSION = 166; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; @@ -516,7 +516,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.165; + MARKETING_VERSION = 1.0.166; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; diff --git a/lib/core/extension/ssh_client.dart b/lib/core/extension/ssh_client.dart new file mode 100644 index 00000000..54ad23d8 --- /dev/null +++ b/lib/core/extension/ssh_client.dart @@ -0,0 +1,35 @@ +import 'dart:async'; + +import 'package:dartssh2/dartssh2.dart'; +import 'package:flutter/foundation.dart'; +import 'package:toolbox/core/extension/uint8list.dart'; + +typedef OnStd = void Function(String data, StreamSink sink); +typedef OnStdin = void Function(StreamSink sink); + +typedef PwdRequestFunc = Future Function(); +final pwdRequestWithUserReg = RegExp(r'\[sudo\] password for (.+):'); + +extension SSHClientX on SSHClient { + Future exec(String cmd, + {OnStd? onStderr, OnStd? onStdout, OnStdin? stdin}) async { + final session = await execute(cmd); + + if (onStderr != null) { + await for (final data in session.stderr) { + onStderr(data.string, session.stdin); + } + } + if (onStdout != null) { + await for (final data in session.stdout) { + onStdout(data.string, session.stdin); + } + } + if (stdin != null) { + stdin(session.stdin); + } + + session.close(); + return session.exitCode; + } +} diff --git a/lib/core/extension/stringx.dart b/lib/core/extension/stringx.dart index 0490c422..99d72129 100644 --- a/lib/core/extension/stringx.dart +++ b/lib/core/extension/stringx.dart @@ -1,3 +1,6 @@ +import 'dart:convert'; + +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:toolbox/data/model/distribution.dart'; @@ -60,4 +63,6 @@ extension StringX on String { } String get withLangExport => 'export LANG=en_US.UTF-8 && $this'; + + Uint8List get uint8List => Uint8List.fromList(utf8.encode(this)); } diff --git a/lib/data/provider/apt.dart b/lib/data/provider/apt.dart index 15d8803e..67ced9be 100644 --- a/lib/data/provider/apt.dart +++ b/lib/data/provider/apt.dart @@ -1,19 +1,15 @@ import 'dart:async'; -import 'dart:convert'; import 'dart:typed_data'; import 'package:dartssh2/dartssh2.dart'; import 'package:logging/logging.dart'; +import 'package:toolbox/core/extension/ssh_client.dart'; import 'package:toolbox/core/extension/stringx.dart'; import 'package:toolbox/core/extension/uint8list.dart'; import 'package:toolbox/core/provider_base.dart'; import 'package:toolbox/data/model/apt/upgrade_pkg_info.dart'; import 'package:toolbox/data/model/distribution.dart'; -typedef PwdRequestFunc = Future Function( - int triedTimes, String? userName); -final pwdRequestWithUserReg = RegExp(r'\[sudo\] password for (.+):'); - class AptProvider extends BusyProvider { final logger = Logger('AptProvider'); @@ -29,45 +25,37 @@ class AptProvider extends BusyProvider { String? upgradeLog; String? updateLog; String lastLog = ''; - int triedTimes = 0; bool isRequestingPwd = false; AptProvider(); - Future init(SSHClient client, Distribution dist, Function() onUpgrade, - Function() onUpdate, PwdRequestFunc onPasswordRequest) async { + Future init( + SSHClient client, + Distribution dist, + Function() onUpgrade, + Function() onUpdate, + PwdRequestFunc onPasswordRequest, + String user) async { this.client = client; this.dist = dist; this.onUpgrade = onUpgrade; this.onPasswordRequest = onPasswordRequest; - whoami = (await client.run('whoami').string).trim(); + whoami = user; } bool get isSU => whoami == 'root'; void clear() { - client = null; - dist = null; - upgradeable = null; - error = null; - upgradeLog = null; - updateLog = whoami = null; - onUpgrade = null; - onUpdate = null; - onPasswordRequest = null; - triedTimes = 0; + client = dist = updateLog = upgradeLog = upgradeable = + error = whoami = onUpdate = onUpgrade = onPasswordRequest = null; isRequestingPwd = false; } Future refreshInstalled() async { - if (client == null) { - error = 'No client'; - return; - } - final result = await _update(); - getUpgradeableList(result); - try {} catch (e) { + try { + getUpgradeableList(result); + } catch (e) { error = '[Server Raw]:\n$result\n[App Error]:\n$e'; } finally { notifyListeners(); @@ -100,32 +88,27 @@ class AptProvider extends BusyProvider { upgradeable = list.map((e) => UpgradePkgInfo(e, dist!)).toList(); } - Future _update() async { + Future _update() async { switch (dist) { case Distribution.rehl: - return await client?.run(_wrap('yum check-update')).string ?? ''; + return await client?.run(_wrap('yum check-update')).string; default: - final session = await client!.execute(_wrap('apt update')); - session.stderr.listen((event) => _onPwd(event, session.stdin)); - session.stdout.listen((event) { - updateLog = (updateLog ?? '') + event.string; - notifyListeners(); - onUpdate ?? () {}(); - }); - await session.done; + await client!.exec( + _wrap('apt update'), + onStderr: _onPwd, + onStdout: (data, sink) { + updateLog = (updateLog ?? '') + data; + notifyListeners(); + onUpdate!(); + }, + ); return await client - ?.run('apt list --upgradeable'.withLangExport) - .string ?? - ''; + ?.run('apt list --upgradeable'.withLangExport) + .string; } } Future upgrade() async { - if (client == null) { - error = 'No client'; - return; - } - final upgradeCmd = () { switch (dist) { case Distribution.rehl: @@ -135,38 +118,34 @@ class AptProvider extends BusyProvider { } }(); - final session = await client!.execute(_wrap(upgradeCmd)); - session.stderr.listen((e) => _onPwd(e, session.stdin)); - - session.stdout.listen((data) async { - final log = data.string; - if (lastLog == log.trim()) return; - upgradeLog = (upgradeLog ?? '') + log; - lastLog = log.trim(); - notifyListeners(); - onUpgrade!(); - }); + await client!.exec( + _wrap(upgradeCmd), + onStderr: (data, sink) => _onPwd(data, sink), + onStdout: (log, sink) { + if (lastLog == log.trim()) return; + upgradeLog = (upgradeLog ?? '') + log; + lastLog = log.trim(); + notifyListeners(); + onUpgrade!(); + }, + ); upgradeLog = null; - await session.done; refreshInstalled(); } - Future _onPwd(Uint8List e, StreamSink stdin) async { + Future _onPwd(String event, StreamSink stdin) async { if (isRequestingPwd) return; isRequestingPwd = true; - final event = e.string; if (event.contains('[sudo] password for ')) { final user = pwdRequestWithUserReg.firstMatch(event)?.group(1); logger.info('sudo password request for $user'); - triedTimes++; - final pwd = - await (onPasswordRequest ?? (_, __) async => '')(triedTimes, user); + final pwd = await onPasswordRequest!(); if (pwd.isEmpty) { logger.info('sudo password request cancelled'); return; } - stdin.add(Uint8List.fromList(utf8.encode('$pwd\n'))); + stdin.add('$pwd\n'.uint8List); } isRequestingPwd = false; } diff --git a/lib/data/provider/docker.dart b/lib/data/provider/docker.dart index f34e89ec..e687828a 100644 --- a/lib/data/provider/docker.dart +++ b/lib/data/provider/docker.dart @@ -1,13 +1,24 @@ +import 'dart:async'; +import 'dart:typed_data'; + import 'package:dartssh2/dartssh2.dart'; +import 'package:logging/logging.dart'; +import 'package:toolbox/core/extension/ssh_client.dart'; import 'package:toolbox/core/extension/stringx.dart'; import 'package:toolbox/core/extension/uint8list.dart'; import 'package:toolbox/core/provider_base.dart'; import 'package:toolbox/data/model/docker/ps.dart'; +import 'package:toolbox/data/res/error.dart'; +import 'package:toolbox/data/store/docker.dart'; +import 'package:toolbox/locator.dart'; final _dockerNotFound = RegExp(r'command not found|Unknown command'); final _versionReg = RegExp(r'(Version:)\s+([0-9]+\.[0-9]+\.[0-9]+)'); final _editionReg = RegExp(r'(Client:)\s+(.+-.+)'); -final _userIdReg = RegExp(r'.+:(\d+:\d+):.+'); + +const _dockerPS = 'docker ps -a'; + +final _logger = Logger('DockerProvider'); class DockerProvider extends BusyProvider { SSHClient? client; @@ -15,82 +26,125 @@ class DockerProvider extends BusyProvider { List? items; String? version; String? edition; - String? error; + DockerErr? error; + PwdRequestFunc? onPwdReq; + String? hostId; + String? runLog; + bool isRequestingPwd = false; - void init(SSHClient client, String userName) { + void init(SSHClient client, String userName, PwdRequestFunc onPwdReq, + String hostId) { this.client = client; this.userName = userName; + this.onPwdReq = onPwdReq; + this.hostId = hostId; } void clear() { - client = null; - userName = null; - error = null; - items = null; - version = null; - edition = null; + client = userName = error = items = version = edition = onPwdReq = null; + isRequestingPwd = false; + hostId = runLog = null; } Future refresh() async { - if (client == null) { - error = 'no client'; - notifyListeners(); - return; - } - final verRaw = await client!.run('docker version'.withLangExport).string; if (verRaw.contains(_dockerNotFound)) { - error = 'docker not found'; + error = DockerErr(type: DockerErrType.notInstalled); notifyListeners(); return; } - version = _versionReg.firstMatch(verRaw)?.group(2); - edition = _editionReg.firstMatch(verRaw)?.group(2); - - final passwd = await client!.run('cat /etc/passwd | grep $userName').string; - final userId = _userIdReg.firstMatch(passwd)?.group(1)?.split(':').first; + try { + version = _versionReg.firstMatch(verRaw)?.group(2); + edition = _editionReg.firstMatch(verRaw)?.group(2); + } catch (e) { + rethrow; + } try { - final cmd = 'docker ps -a'.withLangExport; - final raw = await () async { - final raw = await client!.run(cmd).string; - if (raw.contains('permission denied')) { - return await client! - .run( - 'export DOCKER_HOST=unix:///run/user/${userId ?? 1000}/docker.sock && $cmd') - .string; + // judge whether to use DOCKER_HOST / sudo + final dockerHost = locator().getDockerHost(hostId!); + final cmd = () { + if (dockerHost == null || dockerHost.isEmpty) { + return 'sudo -S $_dockerPS'.withLangExport; } - return raw; + return 'export DOCKER_HOST=$dockerHost && $_dockerPS'.withLangExport; }(); + + // run docker ps + var raw = ''; + await client!.exec( + cmd, + onStderr: _onPwd, + onStdout: (data, _) => raw = '$raw$data', + ); + + // parse result final lines = raw.split('\n'); lines.removeAt(0); lines.removeWhere((element) => element.isEmpty); items = lines.map((e) => DockerPsItem.fromRawString(e)).toList(); } catch (e) { - error = e.toString(); + error = DockerErr(type: DockerErrType.unknown, message: e.toString()); rethrow; } finally { notifyListeners(); } } + Future _onPwd(String event, StreamSink stdin) async { + if (isRequestingPwd) return; + isRequestingPwd = true; + if (event.contains('[sudo] password for ')) { + _logger.info('sudo password request for $userName'); + final pwd = await onPwdReq!(); + if (pwd.isEmpty) { + _logger.info('sudo password request cancelled'); + return; + } + stdin.add('$pwd\n'.uint8List); + } + isRequestingPwd = false; + } + Future _do(String id, String cmd) async { setBusyState(); - if (client == null) { - error = 'no client'; - setBusyState(false); - return false; - } - final result = await client!.run(cmd).string; + final result = await client!.run('$cmd $id').string; await refresh(); setBusyState(false); return result.contains(id); } - Future stop(String id) async => await _do(id, 'docker stop $id'); + Future stop(String id) async => await _do(id, 'docker stop'); - Future start(String id) async => await _do(id, 'docker start $id'); + Future start(String id) async => await _do(id, 'docker start'); - Future delete(String id) async => await _do(id, 'docker rm $id'); + Future delete(String id) async => await _do(id, 'docker rm'); + + Future run(String cmd) async { + if (!cmd.startsWith('docker ')) { + return DockerErr(type: DockerErrType.cmdNoPrefix); + } + setBusyState(); + + final errs = []; + final code = await client!.exec( + cmd, + onStderr: (data, _) => errs.add(data), + onStdout: (data, _) { + runLog = '$runLog$data'; + notifyListeners(); + }, + ); + + runLog = null; + + if (errs.isNotEmpty || code != 0) { + setBusyState(false); + return DockerErr(type: DockerErrType.unknown, message: errs.join('\n')); + } + await refresh(); + setBusyState(false); + return null; + } } diff --git a/lib/data/res/build_data.dart b/lib/data/res/build_data.dart index 1217175f..25a95fe3 100644 --- a/lib/data/res/build_data.dart +++ b/lib/data/res/build_data.dart @@ -2,9 +2,9 @@ class BuildData { static const String name = "ServerBox"; - static const int build = 165; + static const int build = 166; static const String engine = "Flutter 3.3.9 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision b8f7f1f986 (12 days ago) • 2022-11-23 06:43:51 +0900\nEngine • revision 8f2221fbef\nTools • Dart 2.18.5 • DevTools 2.15.0\n"; - static const String buildAt = "2022-12-04 21:41:26.055331"; - static const int modifications = 1; + static const String buildAt = "2022-12-04 21:57:10.591121"; + static const int modifications = 2; } diff --git a/lib/data/res/error.dart b/lib/data/res/error.dart new file mode 100644 index 00000000..d3cacdb3 --- /dev/null +++ b/lib/data/res/error.dart @@ -0,0 +1,28 @@ +enum ErrFrom { + unknown, + apt, + docker, + sftp, + ssh, +} + +abstract class Err { + final ErrFrom from; + final T type; + final String? message; + + Err({required this.from, required this.type, this.message}); +} + +enum DockerErrType { + unknown, + noClient, + notInstalled, + invalidVersion, + cmdNoPrefix +} + +class DockerErr extends Err { + DockerErr({required DockerErrType type, String? message}) + : super(from: ErrFrom.docker, type: type, message: message); +} diff --git a/lib/data/store/docker.dart b/lib/data/store/docker.dart new file mode 100644 index 00000000..b7986ef6 --- /dev/null +++ b/lib/data/store/docker.dart @@ -0,0 +1,11 @@ +import 'package:toolbox/core/persistant_store.dart'; + +class DockerStore extends PersistentStore { + String? getDockerHost(String id) { + return box.get(id); + } + + void setDockerHost(String id, String host) { + box.put(id, host); + } +} diff --git a/lib/data/store/setting.dart b/lib/data/store/setting.dart index 3e0426ba..d8f816a1 100644 --- a/lib/data/store/setting.dart +++ b/lib/data/store/setting.dart @@ -5,7 +5,7 @@ class SettingStore extends PersistentStore { StoreProperty get primaryColor => property('primaryColor', defaultValue: Colors.deepPurpleAccent.value); StoreProperty get serverStatusUpdateInterval => - property('serverStatusUpdateInterval', defaultValue: 2); + property('serverStatusUpdateInterval', defaultValue: 5); StoreProperty get launchPage => property('launchPage', defaultValue: 0); StoreProperty get storeVersion => diff --git a/lib/generated/intl/messages_en.dart b/lib/generated/intl/messages_en.dart index 7a26ba14..3bb2cd2f 100644 --- a/lib/generated/intl/messages_en.dart +++ b/lib/generated/intl/messages_en.dart @@ -81,6 +81,7 @@ class MessageLookup extends MessageLookupByLibrary { "clear": MessageLookupByLibrary.simpleMessage("Clear"), "clickSee": MessageLookupByLibrary.simpleMessage("Click here"), "close": MessageLookupByLibrary.simpleMessage("Close"), + "cmd": MessageLookupByLibrary.simpleMessage("Command"), "containerStatus": MessageLookupByLibrary.simpleMessage("Container status"), "convert": MessageLookupByLibrary.simpleMessage("Convert"), @@ -94,6 +95,14 @@ class MessageLookup extends MessageLookupByLibrary { "delete": MessageLookupByLibrary.simpleMessage("Delete"), "disconnected": MessageLookupByLibrary.simpleMessage("Disconnected"), "dl2Local": m0, + "dockerCmdPrefixErr": MessageLookupByLibrary.simpleMessage( + "Please make sure that the docker command prefix is correct."), + "dockerEditHost": + MessageLookupByLibrary.simpleMessage("Edit DOCKER_HOST"), + "dockerEmptyRunningItems": MessageLookupByLibrary.simpleMessage( + "No running container. \nIt may be that the env DOCKER_HOST is not read correctly. You can found it by running `echo \$DOCKER_HOST` in terminal."), + "dockerNotInstalled": + MessageLookupByLibrary.simpleMessage("Docker not installed"), "dockerStatusRunningAndStoppedFmt": m1, "dockerStatusRunningFmt": m2, "download": MessageLookupByLibrary.simpleMessage("Download"), @@ -128,6 +137,8 @@ class MessageLookup extends MessageLookupByLibrary { "installDockerWithUrl": MessageLookupByLibrary.simpleMessage( "Please https://docs.docker.com/engine/install docker first."), "invalidJson": MessageLookupByLibrary.simpleMessage("Invalid JSON"), + "invalidVersion": + MessageLookupByLibrary.simpleMessage("Invalid version"), "invalidVersionHelp": m6, "keepForeground": MessageLookupByLibrary.simpleMessage("Keep app foreground!"), diff --git a/lib/generated/intl/messages_zh.dart b/lib/generated/intl/messages_zh.dart index 54da935f..6a6cf89b 100644 --- a/lib/generated/intl/messages_zh.dart +++ b/lib/generated/intl/messages_zh.dart @@ -76,6 +76,7 @@ class MessageLookup extends MessageLookupByLibrary { "clear": MessageLookupByLibrary.simpleMessage("清除"), "clickSee": MessageLookupByLibrary.simpleMessage("点击查看"), "close": MessageLookupByLibrary.simpleMessage("关闭"), + "cmd": MessageLookupByLibrary.simpleMessage("命令"), "containerStatus": MessageLookupByLibrary.simpleMessage("容器状态"), "convert": MessageLookupByLibrary.simpleMessage("转换"), "copy": MessageLookupByLibrary.simpleMessage("复制到剪切板"), @@ -88,6 +89,13 @@ class MessageLookup extends MessageLookupByLibrary { "delete": MessageLookupByLibrary.simpleMessage("删除"), "disconnected": MessageLookupByLibrary.simpleMessage("连接断开"), "dl2Local": m0, + "dockerCmdPrefixErr": + MessageLookupByLibrary.simpleMessage("命令前缀错误,没有以 `docker` 开头"), + "dockerEditHost": + MessageLookupByLibrary.simpleMessage("编辑 DOCKER_HOST"), + "dockerEmptyRunningItems": MessageLookupByLibrary.simpleMessage( + "没有正在运行的容器。\n这可能是因为环境变量 DOCKER_HOST 没有被正确读取。你可以通过在终端内运行 `echo \$DOCKER_HOST` 来获取。"), + "dockerNotInstalled": MessageLookupByLibrary.simpleMessage("Docker未安装"), "dockerStatusRunningAndStoppedFmt": m1, "dockerStatusRunningFmt": m2, "download": MessageLookupByLibrary.simpleMessage("下载"), @@ -116,6 +124,7 @@ class MessageLookup extends MessageLookupByLibrary { "installDockerWithUrl": MessageLookupByLibrary.simpleMessage( "请先 https://docs.docker.com/engine/install docker"), "invalidJson": MessageLookupByLibrary.simpleMessage("无效的json,存在格式问题"), + "invalidVersion": MessageLookupByLibrary.simpleMessage("不支持的版本"), "invalidVersionHelp": m6, "keepForeground": MessageLookupByLibrary.simpleMessage("请保持应用处于前台!"), "keyAuth": MessageLookupByLibrary.simpleMessage("公钥认证"), diff --git a/lib/generated/l10n.dart b/lib/generated/l10n.dart index c5eee321..67f603c9 100644 --- a/lib/generated/l10n.dart +++ b/lib/generated/l10n.dart @@ -1350,6 +1350,66 @@ class S { args: [], ); } + + /// `Docker not installed` + String get dockerNotInstalled { + return Intl.message( + 'Docker not installed', + name: 'dockerNotInstalled', + desc: '', + args: [], + ); + } + + /// `Invalid version` + String get invalidVersion { + return Intl.message( + 'Invalid version', + name: 'invalidVersion', + desc: '', + args: [], + ); + } + + /// `Command` + String get cmd { + return Intl.message( + 'Command', + name: 'cmd', + desc: '', + args: [], + ); + } + + /// `No running container. \nIt may be that the env DOCKER_HOST is not read correctly. You can found it by running 'echo $DOCKER_HOST' in terminal.` + String get dockerEmptyRunningItems { + return Intl.message( + 'No running container. \nIt may be that the env DOCKER_HOST is not read correctly. You can found it by running `echo \$DOCKER_HOST` in terminal.', + name: 'dockerEmptyRunningItems', + desc: '', + args: [], + ); + } + + /// `Edit DOCKER_HOST` + String get dockerEditHost { + return Intl.message( + 'Edit DOCKER_HOST', + name: 'dockerEditHost', + desc: '', + args: [], + ); + } + + /// `Please make sure that the docker command prefix is correct.` + String get dockerCmdPrefixErr { + return Intl.message( + 'Please make sure that the docker command prefix is correct.', + name: 'dockerCmdPrefixErr', + desc: '', + args: [], + ); + } } class AppLocalizationDelegate extends LocalizationsDelegate { diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb index 6f1f8b9d..414a396a 100644 --- a/lib/l10n/intl_en.arb +++ b/lib/l10n/intl_en.arb @@ -128,5 +128,11 @@ "feedback": "Feedback", "feedbackOnGithub": "If you have any questions, please feedback on Github.", "update": "Update", - "inputDomainHere": "Input Domain here" + "inputDomainHere": "Input Domain here", + "dockerNotInstalled": "Docker not installed", + "invalidVersion": "Invalid version", + "cmd": "Command", + "dockerEmptyRunningItems": "No running container. \nIt may be that the env DOCKER_HOST is not read correctly. You can found it by running `echo $DOCKER_HOST` in terminal.", + "dockerEditHost": "Edit DOCKER_HOST", + "dockerCmdPrefixErr": "Please make sure that the docker command prefix is correct." } \ No newline at end of file diff --git a/lib/l10n/intl_zh.arb b/lib/l10n/intl_zh.arb index e34d751c..cdd473a4 100644 --- a/lib/l10n/intl_zh.arb +++ b/lib/l10n/intl_zh.arb @@ -128,5 +128,11 @@ "feedback": "反馈", "feedbackOnGithub": "如果你有任何问题,请在GitHub反馈", "update": "更新", - "inputDomainHere": "在这里输入域名" + "inputDomainHere": "在这里输入域名", + "dockerNotInstalled": "Docker未安装", + "invalidVersion": "不支持的版本", + "cmd": "命令", + "dockerEmptyRunningItems": "没有正在运行的容器。\n这可能是因为环境变量 DOCKER_HOST 没有被正确读取。你可以通过在终端内运行 `echo $DOCKER_HOST` 来获取。", + "dockerEditHost": "编辑 DOCKER_HOST", + "dockerCmdPrefixErr": "命令前缀错误,没有以 `docker` 开头" } \ No newline at end of file diff --git a/lib/locator.dart b/lib/locator.dart index f5a7f09d..1768a279 100644 --- a/lib/locator.dart +++ b/lib/locator.dart @@ -8,6 +8,7 @@ import 'package:toolbox/data/provider/server.dart'; import 'package:toolbox/data/provider/sftp_download.dart'; import 'package:toolbox/data/provider/snippet.dart'; import 'package:toolbox/data/service/app.dart'; +import 'package:toolbox/data/store/docker.dart'; import 'package:toolbox/data/store/private_key.dart'; import 'package:toolbox/data/store/server.dart'; import 'package:toolbox/data/store/setting.dart'; @@ -46,6 +47,10 @@ Future setupLocatorForStores() async { final snippet = SnippetStore(); await snippet.init(boxName: 'snippet'); locator.registerSingleton(snippet); + + final docker = DockerStore(); + await docker.init(boxName: 'docker'); + locator.registerSingleton(docker); } Future setupLocator() async { diff --git a/lib/view/page/apt.dart b/lib/view/page/apt.dart index 13ddbb76..459a8384 100644 --- a/lib/view/page/apt.dart +++ b/lib/view/page/apt.dart @@ -58,61 +58,60 @@ class _AptManagePageState extends State return; } - // ignore: prefer_function_declarations_over_variables - Function onSubmitted = () { - if (textController.text == '') { - showRoundDialog(context, s.attention, Text(s.fieldMustNotEmpty), [ - TextButton( - onPressed: () => Navigator.of(context).pop(), child: Text(s.ok)), - ]); - return; - } - Navigator.of(context).pop(); - }; - - // ignore: prefer_function_declarations_over_variables - PwdRequestFunc onPwdRequest = (triedTimes, user) async { - if (!mounted) return ''; - await showRoundDialog( - context, - triedTimes == 3 ? s.lastTry : (user ?? s.unknown), - TextField( - controller: textController, - keyboardType: TextInputType.visiblePassword, - obscureText: true, - onSubmitted: (_) => onSubmitted(), - decoration: InputDecoration( - labelText: s.pwd, - ), - ), - [ - TextButton( - onPressed: () { - Navigator.of(context).pop(); - Navigator.of(context).pop(); - }, - child: Text(s.cancel)), - TextButton( - onPressed: () => onSubmitted(), - child: Text( - s.ok, - style: const TextStyle(color: Colors.red), - )), - ]); - return textController.text.trim(); - }; - _aptProvider.init( si.client!, si.status.sysVer.dist, () => scrollController.jumpTo(scrollController.position.maxScrollExtent), () => scrollControllerUpdate - .jumpTo(scrollControllerUpdate.positions.last.maxScrollExtent), - onPwdRequest); + .jumpTo(scrollController.position.maxScrollExtent), + onPwdRequest, + widget.spi.user); _aptProvider.refreshInstalled(); } + void onSubmitted() { + if (textController.text == '') { + showRoundDialog(context, s.attention, Text(s.fieldMustNotEmpty), [ + TextButton( + onPressed: () => Navigator.of(context).pop(), child: Text(s.ok)), + ]); + return; + } + Navigator.of(context).pop(); + } + + Future onPwdRequest() async { + if (!mounted) return ''; + await showRoundDialog( + context, + widget.spi.user, + TextField( + controller: textController, + keyboardType: TextInputType.visiblePassword, + obscureText: true, + onSubmitted: (_) => onSubmitted(), + decoration: InputDecoration( + labelText: s.pwd, + ), + ), + [ + TextButton( + onPressed: () { + Navigator.of(context).pop(); + Navigator.of(context).pop(); + }, + child: Text(s.cancel)), + TextButton( + onPressed: () => onSubmitted(), + child: Text( + s.ok, + style: const TextStyle(color: Colors.red), + )), + ]); + return textController.text.trim(); + } + @override Widget build(BuildContext context) { return Scaffold( diff --git a/lib/view/page/docker.dart b/lib/view/page/docker.dart index f378f8b0..77c820ae 100644 --- a/lib/view/page/docker.dart +++ b/lib/view/page/docker.dart @@ -6,7 +6,9 @@ import 'package:toolbox/data/model/docker/ps.dart'; import 'package:toolbox/data/model/server/server_private_info.dart'; import 'package:toolbox/data/provider/docker.dart'; import 'package:toolbox/data/provider/server.dart'; +import 'package:toolbox/data/res/error.dart'; import 'package:toolbox/data/res/url.dart'; +import 'package:toolbox/data/store/docker.dart'; import 'package:toolbox/generated/l10n.dart'; import 'package:toolbox/locator.dart'; import 'package:toolbox/view/widget/center_loading.dart'; @@ -25,6 +27,7 @@ class DockerManagePage extends StatefulWidget { class _DockerManagePageState extends State { final _docker = locator(); final greyTextStyle = const TextStyle(color: Colors.grey); + final textController = TextEditingController(); late S s; @override @@ -51,69 +54,233 @@ class _DockerManagePageState extends State { Navigator.of(context).pop(); return; } - _docker.init(client, widget.spi.user); + _docker.init(client, widget.spi.user, onPwdRequest, widget.spi.id); } @override Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - centerTitle: true, - title: TwoLineText(up: 'Docker', down: widget.spi.name), - ), - body: _buildMain(), - ); - } - - Widget _buildMain() { return Consumer(builder: (_, docker, __) { - final running = docker.items; - if (docker.error != null && running == null) { - return SizedBox.expand( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - const Icon( - Icons.error, - size: 37, - ), - const SizedBox(height: 27), - Text(docker.error!), - const SizedBox(height: 27), - Padding( - padding: const EdgeInsets.all(17), - child: _buildSolution(docker.error!), - ) - ], - ), - ); - } - if (running == null) { - _docker.refresh(); - return centerLoading; - } - return ListView( - padding: const EdgeInsets.all(7), - children: [ - _buildVersion( - docker.edition ?? s.unknown, docker.version ?? s.unknown), - _buildPsItems(running, docker) - ].map((e) => RoundRectCard(e)).toList(), + return Scaffold( + appBar: AppBar( + centerTitle: true, + title: TwoLineText(up: 'Docker', down: widget.spi.name), + actions: [ + IconButton( + onPressed: () => docker.refresh(), + icon: const Icon(Icons.refresh)) + ], + ), + body: _buildMain(docker), + floatingActionButton: _buildFAB(docker), ); }); } - Widget _buildSolution(String err) { - switch (err) { - case 'docker not found': + Widget _buildFAB(DockerProvider docker) { + final c = TextEditingController(); + return FloatingActionButton( + onPressed: () { + showRoundDialog( + context, + s.cmd, + TextField( + keyboardType: TextInputType.multiline, + maxLines: 7, + controller: c, + autocorrect: false, + ), + [ + TextButton( + onPressed: () => Navigator.of(context).pop(), + child: Text(s.cancel), + ), + TextButton( + onPressed: () async { + Navigator.of(context).pop(); + final result = await docker.run(c.text.trim()); + if (result != null) { + showSnackBar( + context, Text(getErrMsg(result) ?? s.unknownError)); + } + }, + child: Text(s.run), + ) + ], + ); + }, + child: const Icon(Icons.code), + ); + } + + String? getErrMsg(DockerErr err) { + switch (err.type) { + case DockerErrType.cmdNoPrefix: + return s.dockerCmdPrefixErr; + default: + return null; + } + } + + void onSubmitted() { + if (textController.text == '') { + showRoundDialog(context, s.attention, Text(s.fieldMustNotEmpty), [ + TextButton( + onPressed: () => Navigator.of(context).pop(), child: Text(s.ok)), + ]); + return; + } + Navigator.of(context).pop(); + } + + Future onPwdRequest() async { + if (!mounted) return ''; + await showRoundDialog( + context, + widget.spi.user, + TextField( + controller: textController, + keyboardType: TextInputType.visiblePassword, + obscureText: true, + onSubmitted: (_) => onSubmitted(), + decoration: InputDecoration( + labelText: s.pwd, + ), + ), + [ + TextButton( + onPressed: () { + Navigator.of(context).pop(); + Navigator.of(context).pop(); + }, + child: Text(s.cancel)), + TextButton( + onPressed: () => onSubmitted(), + child: Text( + s.ok, + style: const TextStyle(color: Colors.red), + )), + ]); + return textController.text.trim(); + } + + Widget _buildMain(DockerProvider docker) { + final running = docker.items; + if (docker.error != null && running == null) { + return SizedBox.expand( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + const Icon( + Icons.error, + size: 37, + ), + const SizedBox(height: 27), + _buildErr(docker.error!), + const SizedBox(height: 27), + Padding( + padding: const EdgeInsets.all(17), + child: _buildSolution(docker.error!), + ) + ], + ), + ); + } + if (running == null) { + _docker.refresh(); + return centerLoading; + } + + return ListView( + padding: const EdgeInsets.all(7), + children: [ + _buildVersion(docker.edition ?? s.unknown, docker.version ?? s.unknown), + _buildPsItems(running, docker), + _buildEditHost(running, docker), + _buildRunLog(docker), + ].map((e) => RoundRectCard(e)).toList(), + ); + } + + Widget _buildRunLog(DockerProvider docker) { + if (docker.runLog == null) return const SizedBox(); + return Padding( + padding: const EdgeInsets.all(17), + child: Text(docker.runLog!, maxLines: 1,), + ); + } + + Widget _buildEditHost(List running, DockerProvider docker) { + if (running.isEmpty) { + return Padding( + padding: const EdgeInsets.fromLTRB(17, 17, 17, 0), + child: Column( + children: [ + Text( + s.dockerEmptyRunningItems, + textAlign: TextAlign.center, + ), + TextButton( + onPressed: () => _showEditHostDialog(docker), + child: Text(s.dockerEditHost)) + ], + ), + ); + } + return const SizedBox(); + } + + Future _showEditHostDialog(DockerProvider docker) async { + await showRoundDialog( + context, + s.dockerEditHost, + TextField( + maxLines: 1, + autocorrect: false, + controller: + TextEditingController(text: 'unix:///run/user/1000/docker.sock'), + onSubmitted: (value) { + locator().setDockerHost(widget.spi.id, value.trim()); + docker.refresh(); + Navigator.of(context).pop(); + }, + ), + [ + TextButton( + onPressed: () => Navigator.of(context).pop(), + child: Text(s.cancel)), + ], + ); + } + + Widget _buildErr(DockerErr err) { + var errStr = ''; + switch (err.type) { + case DockerErrType.noClient: + errStr = s.noClient; + break; + case DockerErrType.notInstalled: + errStr = s.dockerNotInstalled; + break; + case DockerErrType.invalidVersion: + errStr = s.invalidVersion; + break; + default: + errStr = err.message ?? s.unknown; + } + return Text(errStr); + } + + Widget _buildSolution(DockerErr err) { + switch (err.type) { + case DockerErrType.notInstalled: return UrlText( text: s.installDockerWithUrl, replace: s.install, ); - case 'no client': + case DockerErrType.noClient: return Text(s.waitConnection); - case 'invalid version': + case DockerErrType.invalidVersion: return UrlText( text: s.invalidVersionHelp(issueUrl), replace: 'Github', diff --git a/lib/view/page/server/detail.dart b/lib/view/page/server/detail.dart index d5fe5ab4..56c2bd1a 100644 --- a/lib/view/page/server/detail.dart +++ b/lib/view/page/server/detail.dart @@ -51,7 +51,7 @@ class _ServerDetailPageState extends State body: ListView( padding: const EdgeInsets.all(13), children: [ - SizedBox(height: _media.size.height * 0.03), + SizedBox(height: _media.size.height * 0.01), _buildLinuxIcon(si.status.sysVer), SizedBox(height: _media.size.height * 0.03), _buildUpTimeAndSys(si.status), diff --git a/macos/Podfile.lock b/macos/Podfile.lock new file mode 100644 index 00000000..0725c138 --- /dev/null +++ b/macos/Podfile.lock @@ -0,0 +1,34 @@ +PODS: + - FlutterMacOS (1.0.0) + - path_provider_macos (0.0.1): + - FlutterMacOS + - share_plus_macos (0.0.1): + - FlutterMacOS + - url_launcher_macos (0.0.1): + - FlutterMacOS + +DEPENDENCIES: + - FlutterMacOS (from `Flutter/ephemeral`) + - path_provider_macos (from `Flutter/ephemeral/.symlinks/plugins/path_provider_macos/macos`) + - share_plus_macos (from `Flutter/ephemeral/.symlinks/plugins/share_plus_macos/macos`) + - url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`) + +EXTERNAL SOURCES: + FlutterMacOS: + :path: Flutter/ephemeral + path_provider_macos: + :path: Flutter/ephemeral/.symlinks/plugins/path_provider_macos/macos + share_plus_macos: + :path: Flutter/ephemeral/.symlinks/plugins/share_plus_macos/macos + url_launcher_macos: + :path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos + +SPEC CHECKSUMS: + FlutterMacOS: ae6af50a8ea7d6103d888583d46bd8328a7e9811 + path_provider_macos: 3c0c3b4b0d4a76d2bf989a913c2de869c5641a19 + share_plus_macos: 853ee48e7dce06b633998ca0735d482dd671ade4 + url_launcher_macos: 597e05b8e514239626bcf4a850fcf9ef5c856ec3 + +PODFILE CHECKSUM: 6eac6b3292e5142cfc23bdeb71848a40ec51c14c + +COCOAPODS: 1.11.3 diff --git a/macos/Runner.xcodeproj/project.pbxproj b/macos/Runner.xcodeproj/project.pbxproj index b1d03489..35a06817 100644 --- a/macos/Runner.xcodeproj/project.pbxproj +++ b/macos/Runner.xcodeproj/project.pbxproj @@ -26,6 +26,7 @@ 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; + C86960F09D66BFB9F9EAF159 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 12CD422E1FDAE58EFAA39492 /* Pods_Runner.framework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -52,9 +53,10 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 12CD422E1FDAE58EFAA39492 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; }; 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = ""; }; - 33CC10ED2044A3C60003C045 /* server_box.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "server_box.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 33CC10ED2044A3C60003C045 /* server_box.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = server_box.app; sourceTree = BUILT_PRODUCTS_DIR; }; 33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = ""; }; 33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; @@ -66,8 +68,11 @@ 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; }; 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; + 62CF3F38CCFA54DE5E957523 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; + B6755FBA95AAD9208D08281D /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; + E8756DDE15E6B592B0279207 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -75,12 +80,24 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + C86960F09D66BFB9F9EAF159 /* Pods_Runner.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 14E85A356189F50B8E9FC339 /* Pods */ = { + isa = PBXGroup; + children = ( + E8756DDE15E6B592B0279207 /* Pods-Runner.debug.xcconfig */, + B6755FBA95AAD9208D08281D /* Pods-Runner.release.xcconfig */, + 62CF3F38CCFA54DE5E957523 /* Pods-Runner.profile.xcconfig */, + ); + name = Pods; + path = Pods; + sourceTree = ""; + }; 33BA886A226E78AF003329D5 /* Configs */ = { isa = PBXGroup; children = ( @@ -99,6 +116,7 @@ 33CEB47122A05771004F2AC0 /* Flutter */, 33CC10EE2044A3C60003C045 /* Products */, D73912EC22F37F3D000D13A0 /* Frameworks */, + 14E85A356189F50B8E9FC339 /* Pods */, ); sourceTree = ""; }; @@ -148,6 +166,7 @@ D73912EC22F37F3D000D13A0 /* Frameworks */ = { isa = PBXGroup; children = ( + 12CD422E1FDAE58EFAA39492 /* Pods_Runner.framework */, ); name = Frameworks; sourceTree = ""; @@ -159,11 +178,13 @@ isa = PBXNativeTarget; buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */; buildPhases = ( + 59089466276869E3A7766664 /* [CP] Check Pods Manifest.lock */, 33CC10E92044A3C60003C045 /* Sources */, 33CC10EA2044A3C60003C045 /* Frameworks */, 33CC10EB2044A3C60003C045 /* Resources */, 33CC110E2044A8840003C045 /* Bundle Framework */, 3399D490228B24CF009A79C7 /* ShellScript */, + 4365C365EEF06532F9E082D0 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -270,6 +291,45 @@ shellPath = /bin/sh; shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire"; }; + 4365C365EEF06532F9E082D0 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + 59089466276869E3A7766664 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ diff --git a/macos/Runner.xcworkspace/contents.xcworkspacedata b/macos/Runner.xcworkspace/contents.xcworkspacedata index 1d526a16..21a3cc14 100644 --- a/macos/Runner.xcworkspace/contents.xcworkspacedata +++ b/macos/Runner.xcworkspace/contents.xcworkspacedata @@ -4,4 +4,7 @@ + +