Skip to content
This repository has been archived by the owner on Nov 3, 2020. It is now read-only.

Commit

Permalink
Improve the onboarding/wording when overwriting a rubygems cocoapods …
Browse files Browse the repository at this point in the history
…install - fixes #179
  • Loading branch information
orta committed Apr 16, 2016
1 parent f5867c7 commit a2dcd30
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 14 deletions.
9 changes: 5 additions & 4 deletions app/CocoaPods/Base.lproj/CPHomeWindowController.xib
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,10 @@
</connections>
</button>
<textField wantsLayer="YES" horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="8mn-Z8-QE9">
<rect key="frame" x="39" y="15" width="167" height="19"/>
<shadow key="shadow" blurRadius="3">
<color key="color" red="0.43529411764705883" green="0.0" blue="0.035294117647058823" alpha="0.49807326858108109" colorSpace="calibratedRGB"/>
<rect key="frame" x="39" y="8" width="167" height="26"/>
<shadow key="shadow" blurRadius="4">
<size key="offset" width="0.0" height="2"/>
<color key="color" red="0.43529411764705883" green="0.0" blue="0.035294117647058823" alpha="0.80239125844594594" colorSpace="calibratedRGB"/>
</shadow>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="center" title="0.38.2" id="J6B-uz-TYN">
<font key="font" size="16" name=".HelveticaNeueDeskInterface-Regular"/>
Expand Down Expand Up @@ -295,7 +296,7 @@ This means you get access to the whole command-line API, not just what the Cocoa
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="VUM-hf-i6h">
<rect key="frame" x="26" y="418" width="218" height="40"/>
<rect key="frame" x="26" y="418" width="247" height="40"/>
<textFieldCell key="cell" controlSize="mini" sendsActionOnEndEditing="YES" id="eXV-TB-vrj">
<font key="font" metaFont="system" size="14"/>
<string key="title">Do you want to Install the
Expand Down
28 changes: 25 additions & 3 deletions app/CocoaPods/CLI Integrations/CPCLIToolInstallationController.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ - (BOOL)shouldInstallBinstubIfNecessary;
return NO;
}

return [self binstubAlreadyExists];
return ![self binstubAlreadyExists];
}


Expand Down Expand Up @@ -180,11 +180,16 @@ - (BOOL)promptIfOverwriting
return YES;
}

BOOL isRubyGemsVersion = [self currentBinStubComesFromRubygems];

NSAlert *alert = [NSAlert new];
alert.alertStyle = NSCriticalAlertStyle;
NSString *formatString = NSLocalizedString(@"INSTALL_CLI_WARNING_MESSAGE_TEXT", nil);
alert.messageText = [NSString stringWithFormat:formatString, self.destinationURL.path];
alert.informativeText = NSLocalizedString(@"INSTALL_CLI_WARNING_INFORMATIVE_TEXT", nil);

NSString *information = isRubyGemsVersion ? @"INSTALL_CLI_FROM_GEM_INFORMATIVE_TEXT" : @"INSTALL_CLI_WARNING_INFORMATIVE_TEXT";
alert.informativeText = NSLocalizedString(information, nil);

[alert addButtonWithTitle:NSLocalizedString(@"INSTALL_CLI_WARNING_OVERWRITE", nil)];
[alert addButtonWithTitle:NSLocalizedString(@"CANCEL", nil)];

Expand All @@ -199,6 +204,19 @@ - (NSURL *)binstubSourceURL;
return [NSURL fileURLWithPathComponents:@[ bundlePath, @"Contents", @"Helpers", @"pod" ]];
}

- (BOOL)currentBinStubComesFromRubygems
{
NSError *error = nil;
NSString *contents = [NSString stringWithContentsOfURL:self.destinationURL encoding:NSUTF16StringEncoding error:&error];
if (error) {
NSLog(@"Error looking at BinStub: %@", error);
return NO;
}

NSString *message = @"generated by RubyGems.";
return [contents containsString:message];
}

- (BOOL)binstubAlreadyExists;
{
return access([self.destinationURL.path UTF8String], F_OK) == 0;
Expand Down Expand Up @@ -256,7 +274,11 @@ - (BOOL)installBinstubToAccessibleDestination;
NSError *error = nil;
NSURL *sourceURL = self.binstubSourceURL;
NSFileManager *fileManager = [NSFileManager defaultManager];
[fileManager removeItemAtURL:self.destinationURL error:&error];

if ([fileManager fileExistsAtPath:self.destinationURL.path]) {
[fileManager removeItemAtURL:self.destinationURL error:&error];
}

BOOL succeeded = [fileManager copyItemAtURL:sourceURL toURL:self.destinationURL error:&error];
if (error) {
NSLog(@"Failed to copy source `%@` (%@)", sourceURL.path, error);
Expand Down
13 changes: 6 additions & 7 deletions app/CocoaPods/Supporting Files/Localizable.strings
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
"INSTALL_CLI_MESSAGE_TEXT" = "Do you wish to install the CocoaPods Command-Line Tool?";
"UPDATE_CLI_MESSAGE_TEXT" = "Do you wish to update the CocoaPods Command-Line Tool?";

"INSTALL_CLI_INFORMATIVE_TEXT" = "If you wish to use CocoaPods from the Terminal, a “%@” tool can be installed which will allow you easy access to the CocoaPods installation contained inside this application.\n\nThis is not needed for the application to function normally and can always be installed at a later time by using the menu item found under the application menu.";
"INSTALL_CLI_MESSAGE_TEXT" = "Do you want to install the CocoaPods Command-Line Tool?";
"UPDATE_CLI_MESSAGE_TEXT" = "Do you want to update the CocoaPods Command-Line Tool?";

"INSTALL_CLI_ALTERNATE_DESTINATION" = "Install to Alternate Destination…";
"INSTALL_CLI" = "Install to “%@”";

"INSTALL_CLI_WARNING_MESSAGE_TEXT" = "You already have a “%@” tool installed. Are you sure you want to overwrite it?";
"INSTALL_CLI_WARNING_INFORMATIVE_TEXT" = "The tool was likely installed from the Terminal by running the “gem install cocoapods” command. If you wish to keep that installation intact, be sure to choose an alternate filename or directory (preferably in your Terminal PATH) for this tool.\n\nNote that you can always revert by running the aforementioned Terminal command again.";
"INSTALL_CLI_WARNING_MESSAGE_TEXT" = "You already have `pod` at “%@”. Are you sure you want to overwrite it?";
"INSTALL_CLI_FROM_GEM_INFORMATIVE_TEXT" = "Your `pod` command was installed via `gem install cocoapods`.\n\nClicking install will replace that version with the `pod` command hosted inside this app.\n\nNote that you can always revert back by running the Terminal commands again.";
"INSTALL_CLI_WARNING_INFORMATIVE_TEXT" = "The tool was likely installed from the Terminal by running the “gem install cocoapods” command. \n\nIf you wish to keep that installation intact, be sure to choose an alternate filename or directory (preferably in your Terminal PATH) for this tool.\n\nNote that you can always revert by running the aforementioned Terminal command again.";
"INSTALL_CLI_WARNING_OVERWRITE" = "Overwrite";

"WORKSPACE_GENERATED_NOTIFICATION_TITLE" = "Pod Workspace Ready";
Expand All @@ -30,7 +29,7 @@
"PODFILE_WINDOW_NEWER_LOCKFILE_ERROR_BUTTON_TITTLE" = "Check For Updates";

"MAIN_WINDOW_TITLE" = "Welcome to CocoaPods";
"MAIN_WINDOW_OPEN_GUIDES_BUTTON_TITLE" = "Get started...";
"MAIN_WINDOW_OPEN_GUIDES_BUTTON_TITLE" = "Get started with CocoaPods";
"MAIN_WINDOW_OPEN_SEARCH_BUTTON_TITLE" = "Search for Pods";
"MAIN_WINDOW_CHANGELOG_BUTTON_TITLE" = "What's New?";
"MAIN_WINDOW_OPEN_DOCUMENT_BUTTON_TITLE" = "Open an existing Podfile";

0 comments on commit a2dcd30

Please sign in to comment.