Commit 85b2b869 authored by xster's avatar xster Committed by GitHub

CocoaPods flow step 3 - don't automatically pod setup (#9703)

* Don’t automatically pod setup if the user never did it

* fix/add test

* rename getters
parent 7fb6646c
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
import 'dart:async'; import 'dart:async';
import '../base/common.dart';
import '../base/file_system.dart';
import '../base/io.dart'; import '../base/io.dart';
import '../base/os.dart'; import '../base/os.dart';
import '../base/platform.dart'; import '../base/platform.dart';
...@@ -60,7 +62,7 @@ class IOSWorkflow extends DoctorValidator implements Workflow { ...@@ -60,7 +62,7 @@ class IOSWorkflow extends DoctorValidator implements Workflow {
} }
} }
bool get cocoaPodsInstalledAndMeetsVersionCheck { bool get isCocoaPodsInstalledAndMeetsVersionCheck {
if (!hasCocoaPods) if (!hasCocoaPods)
return false; return false;
try { try {
...@@ -71,6 +73,13 @@ class IOSWorkflow extends DoctorValidator implements Workflow { ...@@ -71,6 +73,13 @@ class IOSWorkflow extends DoctorValidator implements Workflow {
} }
} }
/// Whether CocoaPods ran 'pod setup' once where the costly pods' specs are cloned.
bool get isCocoaPodsInitialized {
return fs.isDirectorySync(
fs.path.join(homeDirPath, '.cocoapods', 'repos', 'master')
);
}
@override @override
Future<ValidationResult> validate() async { Future<ValidationResult> validate() async {
final List<ValidationMessage> messages = <ValidationMessage>[]; final List<ValidationMessage> messages = <ValidationMessage>[];
...@@ -175,8 +184,19 @@ class IOSWorkflow extends DoctorValidator implements Workflow { ...@@ -175,8 +184,19 @@ class IOSWorkflow extends DoctorValidator implements Workflow {
)); ));
} }
} }
if (cocoaPodsInstalledAndMeetsVersionCheck) { if (isCocoaPodsInstalledAndMeetsVersionCheck) {
messages.add(new ValidationMessage('CocoaPods version $cocoaPodsVersionText')); if (isCocoaPodsInitialized) {
messages.add(new ValidationMessage('CocoaPods version $cocoaPodsVersionText'));
} else {
brewStatus = ValidationType.partial;
messages.add(new ValidationMessage.error(
'CocoaPods installed but not initialized.\n'
'$noCocoaPodsConsequence\n'
'To initialize CocoaPods, run:\n'
' pod setup\n'
'once to finalize CocoaPods\' installation.'
));
}
} else { } else {
brewStatus = ValidationType.partial; brewStatus = ValidationType.partial;
if (!hasCocoaPods) { if (!hasCocoaPods) {
......
...@@ -348,9 +348,8 @@ bool _checkXcodeVersion() { ...@@ -348,9 +348,8 @@ bool _checkXcodeVersion() {
} }
final String noCocoaPodsConsequence = ''' final String noCocoaPodsConsequence = '''
CocoaPods is used to retrieve the iOS platform side's plugin code that responds to your CocoaPods is used to retrieve the iOS platform side's plugin code that responds to your plugin usage on the Dart side.
plugin usage on the Dart side. Without resolving iOS dependencies with CocoaPods, plugins will not work on iOS.
Without resolving iOS dependencies with CocoaPods, plugins will not work on iOS.
For more info, see https://flutter.io/platform-plugins'''; For more info, see https://flutter.io/platform-plugins''';
final String cocoaPodsInstallInstructions = ''' final String cocoaPodsInstallInstructions = '''
...@@ -365,7 +364,7 @@ final String cocoaPodsUpgradeInstructions = ''' ...@@ -365,7 +364,7 @@ final String cocoaPodsUpgradeInstructions = '''
Future<Null> _runPodInstall(Directory bundle, String engineDirectory) async { Future<Null> _runPodInstall(Directory bundle, String engineDirectory) async {
if (fs.file(fs.path.join(bundle.path, 'Podfile')).existsSync()) { if (fs.file(fs.path.join(bundle.path, 'Podfile')).existsSync()) {
if (!doctor.iosWorkflow.cocoaPodsInstalledAndMeetsVersionCheck) { if (!doctor.iosWorkflow.isCocoaPodsInstalledAndMeetsVersionCheck) {
final String minimumVersion = doctor.iosWorkflow.cocoaPodsMinimumVersion; final String minimumVersion = doctor.iosWorkflow.cocoaPodsMinimumVersion;
printError( printError(
'Warning: CocoaPods version $minimumVersion or greater not installed. Skipping pod install.\n' 'Warning: CocoaPods version $minimumVersion or greater not installed. Skipping pod install.\n'
...@@ -375,6 +374,16 @@ Future<Null> _runPodInstall(Directory bundle, String engineDirectory) async { ...@@ -375,6 +374,16 @@ Future<Null> _runPodInstall(Directory bundle, String engineDirectory) async {
); );
return; return;
} }
if (!doctor.iosWorkflow.isCocoaPodsInitialized) {
printError(
'Warning: CocoaPods installed but not initialized. Skipping pod install.\n'
'$noCocoaPodsConsequence\n'
'To initialize CocoaPods, run:\n'
' pod setup\n'
'once to finalize CocoaPods\' installation.'
);
return;
}
try { try {
final Status status = logger.startProgress('Running pod install...', expectSlowOperation: true); final Status status = logger.startProgress('Running pod install...', expectSlowOperation: true);
await runCheckedAsync( await runCheckedAsync(
......
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart'; import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/doctor.dart'; import 'package:flutter_tools/src/doctor.dart';
import 'package:flutter_tools/src/ios/ios_workflow.dart'; import 'package:flutter_tools/src/ios/ios_workflow.dart';
...@@ -16,10 +19,12 @@ void main() { ...@@ -16,10 +19,12 @@ void main() {
group('iOS Workflow validation', () { group('iOS Workflow validation', () {
MockXcode xcode; MockXcode xcode;
MockProcessManager processManager; MockProcessManager processManager;
FileSystem fs;
setUp(() { setUp(() {
xcode = new MockXcode(); xcode = new MockXcode();
processManager = new MockProcessManager(); processManager = new MockProcessManager();
fs = new MemoryFileSystem();
}); });
testUsingContext('Emit missing status when nothing is installed', () async { testUsingContext('Emit missing status when nothing is installed', () async {
...@@ -143,6 +148,26 @@ void main() { ...@@ -143,6 +148,26 @@ void main() {
expect(result.type, ValidationType.partial); expect(result.type, ValidationType.partial);
}, overrides: <Type, Generator>{ Xcode: () => xcode }); }, overrides: <Type, Generator>{ Xcode: () => xcode });
testUsingContext('Emits partial status when CocoaPods is not initialized', () async {
when(xcode.isInstalled).thenReturn(true);
when(xcode.xcodeVersionText)
.thenReturn('Xcode 8.2.1\nBuild version 8C1002\n');
when(xcode.isInstalledAndMeetsVersionCheck).thenReturn(true);
when(xcode.eulaSigned).thenReturn(true);
when(processManager.runSync(argThat(contains('idevice_id'))))
.thenReturn(exitsHappy);
when(processManager.run(argThat(contains('idevice_id')), workingDirectory: any, environment: any))
.thenReturn(exitsHappy);
final ValidationResult result = await new IOSWorkflowTestTarget().validate();
expect(result.type, ValidationType.partial);
}, overrides: <Type, Generator>{
FileSystem: () => fs,
Xcode: () => xcode,
ProcessManager: () => processManager,
});
testUsingContext('Succeeds when all checks pass', () async { testUsingContext('Succeeds when all checks pass', () async {
when(xcode.isInstalled).thenReturn(true); when(xcode.isInstalled).thenReturn(true);
when(xcode.xcodeVersionText) when(xcode.xcodeVersionText)
...@@ -155,9 +180,12 @@ void main() { ...@@ -155,9 +180,12 @@ void main() {
when(processManager.run(argThat(contains('idevice_id')), workingDirectory: any, environment: any)) when(processManager.run(argThat(contains('idevice_id')), workingDirectory: any, environment: any))
.thenReturn(exitsHappy); .thenReturn(exitsHappy);
ensureDirectoryExists(fs.path.join(homeDirPath, '.cocoapods', 'repos', 'master', 'README.md'));
final ValidationResult result = await new IOSWorkflowTestTarget().validate(); final ValidationResult result = await new IOSWorkflowTestTarget().validate();
expect(result.type, ValidationType.installed); expect(result.type, ValidationType.installed);
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FileSystem: () => fs,
Xcode: () => xcode, Xcode: () => xcode,
ProcessManager: () => processManager, ProcessManager: () => processManager,
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment