Skip to content

Commit

Permalink
Merge pull request #158 from vineetchoudhary/develop
Browse files Browse the repository at this point in the history
Fixed command line args issue for keep same link
  • Loading branch information
vineetchoudhary authored Jan 14, 2019
2 parents 39f73a6 + c81def5 commit 4da188d
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 36 deletions.
2 changes: 1 addition & 1 deletion AppBox.xcodeproj/xcshareddata/xcschemes/AppBox.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
</BuildableProductRunnable>
<CommandLineArguments>
<CommandLineArgument
argument = "ipa=/Users/vineetchoudhary/Desktop/IPAs/PayloadIpad10.0.ipa [email protected],[email protected] message=&apos;Hello there!!&apos;"
argument = "ipa=/Volumes/LongTime/ProjectWorking/fastlane-plugin-appbox/AppBox-Fastlane-Demo-Project/AppBox-Fastlane-Demo.ipa [email protected],[email protected] message=&apos;Hello there!!&apos; keepsamelink=true"
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
Expand Down
8 changes: 4 additions & 4 deletions AppBox/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ -(BOOL)application:(NSApplication *)sender openFile:(NSString *)filename{

-(void)openFileWithPath:(NSString *)filePath{
if (self.isReadyToBuild) {
[self addSessionLog:@"AppBox is ready to use open file."];
[ABLog log:@"AppBox is ready to use."];
[[NSNotificationCenter defaultCenter] postNotificationName:abUseOpenFilesNotification object:filePath];
} else {
[[NSNotificationCenter defaultCenter] addObserverForName:abAppBoxReadyToUseNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull note) {
[self addSessionLog:@"AppBox is ready to use open file. [Block]"];
[ABLog log:@"AppBox is ready to use. [Block]"];
[[NSNotificationCenter defaultCenter] postNotificationName:abUseOpenFilesNotification object:filePath];
}];
}
Expand Down Expand Up @@ -180,11 +180,11 @@ -(void)handleProjectAtPath:(NSString *)projectPath {
-(void)handleIPAAtPath:(NSString *)ipaPath {
XCProject *project = [CIProjectBuilder xcProjectWithIPAPath:ipaPath];
if (self.isReadyToBuild) {
[self addSessionLog:@"AppBox is ready to build."];
[self addSessionLog:@"AppBox is ready to upload IPA."];
[[NSNotificationCenter defaultCenter] postNotificationName:abBuildRepoNotification object:project];
} else {
[[NSNotificationCenter defaultCenter] addObserverForName:abAppBoxReadyToUseNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull note) {
[self addSessionLog:@"AppBox is ready to build. [Block]"];
[self addSessionLog:@"AppBox is ready to upload IPA. [Block]"];
[[NSNotificationCenter defaultCenter] postNotificationName:abBuildRepoNotification object:project];
}];
}
Expand Down
49 changes: 31 additions & 18 deletions AppBox/Common/CIProjectBuilder/CIProjectBuilder.m
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,16 @@ + (XCProject *)xcProjectWithRepoPath:(NSString *)repoPath andSettingFilePath:(NS
project.teamId = [projectRawSetting valueForKey: RepoTeamIdKey];
}

//Dropbox keep same link
if ([projectRawSetting.allKeys containsObject:RepoKeepSameLinkKey]) {
project.keepSameLink = [projectRawSetting valueForKey:RepoKeepSameLinkKey];
}

//Dropbox folder name
if ([projectRawSetting.allKeys containsObject:RepoDropboxFolderNameKey]) {
project.keepSameLink = [projectRawSetting valueForKey:RepoKeepSameLinkKey];
NSString *bundlePath = [projectRawSetting valueForKey:RepoDropboxFolderNameKey];
bundlePath = [bundlePath stringByReplacingOccurrencesOfString:@" " withString:abEmptyString];
project.bundleDirectory = [NSURL URLWithString:bundlePath];
}

//xcode version
Expand Down Expand Up @@ -149,6 +156,10 @@ + (void)setProjectSettingFromProject:(XCProject *)repoProject toProject:(XCProje
[project setTeamId: [team valueForKey:abTeamId]];
}

[project setKeepSameLink:repoProject.keepSameLink];
[project setBundleDirectory:repoProject.bundleDirectory];
[project setIsKeepSameLinkEnabled:repoProject.keepSameLink.boolValue];

[project setItcUserName:repoProject.itcUserName];
[project setItcPasswod:repoProject.itcPasswod];

Expand Down Expand Up @@ -198,10 +209,10 @@ +(void)setCommonArgumentsToProject:(XCProject *)project {
NSArray *components = [argument componentsSeparatedByString:abArgsScheme];
[ABLog log:@"Scheme Components = %@",components];
if (components.count == 2) {
[[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Changing project scheme to %@ from %@", [components lastObject], project.selectedSchemes]];
[[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Changing project scheme to \"%@\" from \"%@\"", [components lastObject], project.selectedSchemes]];
project.selectedSchemes = [components lastObject];
} else {
[[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Invalid Scheme Argument %@",arguments]];
[[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Invalid Scheme Argument \"%@\"",arguments]];
exit(abExitCodeForInvalidCommand);
}
}
Expand All @@ -211,10 +222,10 @@ +(void)setCommonArgumentsToProject:(XCProject *)project {
NSArray *components = [argument componentsSeparatedByString:abArgsBuildType];
[ABLog log:@"BuildType Components = %@",components];
if (components.count == 2) {
[[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Changing project build type to %@ from %@", [components lastObject], project.buildType]];
[[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Changing project build type to \"%@\" from \"%@\"", [components lastObject], project.buildType]];
project.buildType = [components lastObject];
} else {
[[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Invalid BuildType Argument %@",arguments]];
[[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Invalid BuildType Argument \"%@\"",arguments]];
exit(abExitCodeForInvalidCommand);
}
}
Expand All @@ -224,10 +235,10 @@ +(void)setCommonArgumentsToProject:(XCProject *)project {
NSArray *components = [argument componentsSeparatedByString:abArgsTeamId];
[ABLog log:@"TeamId Components = %@",components];
if (components.count == 2) {
[[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Changing project TeamId to %@ from %@", [components lastObject], project.teamId]];
[[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Changing project TeamId to \"%@\" from \"%@\"", [components lastObject], project.teamId]];
project.teamId = [components lastObject];
} else {
[[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Invalid TeamId Argument %@",arguments]];
[[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Invalid TeamId Argument \"%@\"",arguments]];
exit(abExitCodeForInvalidCommand);
}
}
Expand All @@ -237,10 +248,10 @@ +(void)setCommonArgumentsToProject:(XCProject *)project {
NSArray *components = [argument componentsSeparatedByString:abArgsEmails];
[ABLog log:@"Email Components = %@", components];
if (components.count == 2) {
[[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Changing project Emails to %@ from %@", [components lastObject], project.emails]];
[[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Changing project Emails to \"%@\" from \"%@\"", [components lastObject], project.emails]];
project.emails = [components lastObject];
} else {
[[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Invalid Emails Argument %@",arguments]];
[[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Invalid Emails Argument \"%@\"",arguments]];
exit(abExitCodeForInvalidCommand);
}
}
Expand All @@ -250,23 +261,23 @@ +(void)setCommonArgumentsToProject:(XCProject *)project {
NSArray *components = [argument componentsSeparatedByString:abArgsPersonalMessage];
[ABLog log:@"Personal Message Components = %@", components];
if (components.count == 2) {
[[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Changing project personal message to %@ from %@", [components lastObject], project.personalMessage]];
[[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Changing project personal message to \"%@\" from \"%@\"", [components lastObject], project.personalMessage]];
project.personalMessage = [components lastObject];
} else {
[[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Invalid Personal Message Argument %@",arguments]];
[[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Invalid Personal Message Argument \"%@\"",arguments]];
exit(abExitCodeForInvalidCommand);
}
}

//Project Personal Messages
//Project Keep Same Link
else if ([argument containsString:abArgsKeepSameLink]) {
NSArray *components = [argument componentsSeparatedByString:abArgsKeepSameLink];
[ABLog log:@"Keep Same Links Components = %@", components];
if (components.count == 2) {
[[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Changing project personal message to %@ from %@", [components lastObject], project.personalMessage]];
project.keepSameLink = [[components lastObject] isEqualToString:@"0"] ? @0 : @1;
[[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Changing Keep Same Link to \"%@\" from \"%@\"", [components lastObject], project.keepSameLink]];
project.keepSameLink = ([[components lastObject] isEqualToString:@"0"] || ((BOOL)[[components lastObject] boolValue]) == NO) ? @0 : @1;
} else {
[[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Invalid Personal Message Argument %@",arguments]];
[[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Invalid Keep Same Link Argument \"%@\"",arguments]];
exit(abExitCodeForInvalidCommand);
}
}
Expand All @@ -276,10 +287,12 @@ +(void)setCommonArgumentsToProject:(XCProject *)project {
NSArray *components = [argument componentsSeparatedByString:abArgsDropBoxFolderName];
[ABLog log:@"Dropbox folder Components = %@", components];
if (components.count == 2) {
[[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Changing Dropbox folder name to %@ from %@", [components lastObject], project.personalMessage]];
//project.db = [components lastObject];
[[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Changing Dropbox folder name to \"%@\" from \"%@\"", [components lastObject], project.personalMessage]];
NSString *bundlePath = [NSString stringWithFormat:@"/%@",[components lastObject]];
bundlePath = [bundlePath stringByReplacingOccurrencesOfString:@" " withString:abEmptyString];
project.bundleDirectory = [NSURL URLWithString:bundlePath];
} else {
[[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Invalid Dropbox Folder Name Argument %@",arguments]];
[[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Invalid Dropbox Folder Name Argument \"%@\"",arguments]];
exit(abExitCodeForInvalidCommand);
}
}
Expand Down
10 changes: 5 additions & 5 deletions AppBox/Common/UploadManager/UploadManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ -(void)uploadIPAFile:(NSURL *)ipaFileURL{
}

//get info.plist
[[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Final Info.plist path = %@",infoPlistPath]];
[ABLog log:@"Final Info.plist path = %@",infoPlistPath];
[self.project setIpaInfoPlist: [NSDictionary dictionaryWithContentsOfFile:[NSTemporaryDirectory() stringByAppendingPathComponent:infoPlistPath]]];

//show error if info.plist is nil or invalid
Expand Down Expand Up @@ -501,7 +501,7 @@ -(void)dbUploadFile:(NSString *)file to:(NSString *)path mode:(DBFILESWriteMode
//Track response with result and error
setResponseBlock:^(DBFILESFileMetadata * _Nullable response, DBFILESUploadError * _Nullable routeError, DBRequestError * _Nullable error) {
if (response) {
[[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Uploaded file metadata = %@", response]];
[ABLog log:@"Uploaded file metadata = %@", response];

//AppInfo.json file uploaded and creating shared url
if(self.dbFileType == DBFileTypeJson){
Expand Down Expand Up @@ -647,15 +647,15 @@ -(void)handleSharedURLResult:(NSString *)url{
//if same link enable load appinfo.json otherwise Create short shareable url of manifest
else if (self.dbFileType == DBFileTypeManifest){
NSString *shareableLink = [url substringToIndex:url.length-5];
[[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Manifest Sharable link - %@",shareableLink]];
[ABLog log:@"Manifest Sharable link - %@",shareableLink];
self.project.manifestFileSharableURL = [NSURL URLWithString:shareableLink];
if(self.project.isKeepSameLinkEnabled){
//Download previously uploaded appinfo
DBFILESListRevisionsMode *revisionMode = [[DBFILESListRevisionsMode alloc] initWithPath];
[[[DBClientsManager authorizedClient].filesRoutes listRevisions:self.project.dbAppInfoJSONFullPath.absoluteString mode:revisionMode limit:@1] setResponseBlock:^(DBFILESListRevisionsResult * _Nullable response, DBFILESListRevisionsError * _Nullable routeError, DBRequestError * _Nullable error) {
//check there is any rev available
if (response && response.isDeleted.boolValue == NO && response.entries.count > 0){
[[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Loaded Meta Data %@",response]];
[ABLog log:@"Loaded Meta Data %@",response];
self.project.uniqueLinkJsonMetaData = [response.entries firstObject];
}

Expand All @@ -670,7 +670,7 @@ -(void)handleSharedURLResult:(NSString *)url{
//create app info file short sharable url
else if (self.dbFileType == DBFileTypeJson){
NSString *shareableLink = [url substringToIndex:url.length-5];
[[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"APPInfo Sharable link - %@",shareableLink]];
[ABLog log:@"APPInfo Sharable link - %@",shareableLink];
self.project.uniquelinkShareableURL = [NSURL URLWithString:shareableLink];
NSMutableDictionary *dictUniqueFile = [[self getUniqueJsonDict] mutableCopy];
[dictUniqueFile setObject:shareableLink forKey:UNIQUE_LINK_SHARED];
Expand Down
4 changes: 2 additions & 2 deletions AppBox/Common/XcodeHandler/XCHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ +(void)getXCodePathWithCompletion:(void (^) (NSString *xcodePath, NSString *appl
+(NSString *)checkXCodePath:(NSString *)xcodePath {
xcodePath = [xcodePath stringByRemovingPercentEncoding];
if ([[NSFileManager defaultManager] fileExistsAtPath:xcodePath]){
[[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"XCode = %@", xcodePath]];
[ABLog log:@"XCode = %@", xcodePath];
return xcodePath;
}else{
return nil;
Expand All @@ -38,7 +38,7 @@ +(NSString *)checkXCodePath:(NSString *)xcodePath {
+(NSString *)checkALPath:(NSString *)xcodePath {
NSString *alPath = [[xcodePath stringByAppendingPathComponent:abApplicationLoaderALToolLocation] stringByRemovingPercentEncoding];
if ([[NSFileManager defaultManager] fileExistsAtPath:alPath]){
[[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Application Loader = %@", alPath]];
[ABLog log:@"Application Loader = %@", alPath];
return alPath;
} else {
return nil;
Expand Down
2 changes: 1 addition & 1 deletion AppBox/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>2.7.1</string>
<string>2.7.2</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
Expand Down
4 changes: 2 additions & 2 deletions AppBox/Model/ProjectModel/XCProject.m
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ -(void)createManifestWithIPAURL:(NSURL *)ipaURL completion:(void(^)(NSURL *manif
NSMutableDictionary *manifestDict = [[NSMutableDictionary alloc] init];
[manifestDict setValue:[NSArray arrayWithObjects:mainItemDict, nil] forKey:@"items"];

[[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"\n\n======\nManifest\n======\n\n %@",manifestDict]];
[ABLog log:@"\n\n======\nManifest\n======\n\n %@",manifestDict];

NSString *manifestPath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"manifest.plist"];
if ([manifestDict writeToFile:manifestPath atomically:YES]){
[[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Menifest File Created and Saved at %@", manifestPath]];
[ABLog log:@"Menifest File Created and Saved at %@", manifestPath];
dispatch_async(dispatch_get_main_queue(), ^{
completion([NSURL fileURLWithPath:manifestPath]);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,10 @@ - (void)initIPAUploadProcessForURL:(NSURL *)ipaURL {
[buttonSendMail setState:NSOnState];
}
[project setIpaFullPath:ipaURL];
[selectedFilePath setURL:ipaURL]; 
[selectedFilePath setURL:ipaURL];
[textFieldEmail setStringValue:project.emails];
[textFieldMessage setStringValue:project.personalMessage];
[buttonUniqueLink setState:project.keepSameLink.boolValue ? NSOnState : NSOffState];
[self actionButtonTapped:buttonAction];
}

Expand Down
4 changes: 2 additions & 2 deletions AppBox/ViewController/MenuHandler/NSApplication+MenuHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ - (void)updateDropboxUsage{
[self updateDropboxUsageFileButton];

//log space usage
[[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Used Space : %@MB", usage]];
[[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Available Space : %@MB", allocated]];
[[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"DropBox Used Space : %@MB", usage]];
[[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"DropBox Available Space : %@MB", allocated]];

//check if dopbox running out of space
if ((allocated.integerValue - usage.integerValue) < abDropboxOutOfSpaceWarningSize){
Expand Down

0 comments on commit 4da188d

Please sign in to comment.