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

Commit

Permalink
added basic support for Sketch Beta
Browse files Browse the repository at this point in the history
this will keep Sketch Beta plugins in sync with the App Store plugins
  • Loading branch information
shahruz committed May 21, 2014
1 parent 535831a commit 56b2dd2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
28 changes: 25 additions & 3 deletions Sketch Toolbox/Plugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#import "Plugin.h"
#import "SSZipArchive.h"

#define kSketchAppStorePluginPath [@"~/Library/Containers/com.bohemiancoding.sketch3/Data/Library/Application Support/com.bohemiancoding.sketch3/Plugins/" stringByExpandingTildeInPath]
#define kSketchBetaPluginPath [@"~/Library/Application Support/com.bohemiancoding.sketch3/Plugins/" stringByExpandingTildeInPath]

@implementation Plugin

@dynamic desc;
Expand All @@ -35,6 +38,12 @@ -(void)delete {
if (!self.isInstalled) return;
NSFileManager *fm = [NSFileManager defaultManager];
[fm removeItemAtPath:self.downloadPath error:nil];

if ([fm fileExistsAtPath:kSketchBetaPluginPath]) {
NSString *betaDownloadPath = [self.downloadPath stringByReplacingOccurrencesOfString:kSketchAppStorePluginPath withString:kSketchBetaPluginPath];
[fm removeItemAtPath:betaDownloadPath error:nil];
}

self.installed = [NSDate dateWithTimeIntervalSince1970:978307200];
self.downloadPath = @"";
[[NSManagedObjectContext MR_defaultContext] MR_saveToPersistentStoreAndWait];
Expand All @@ -58,10 +67,23 @@ -(void)download {
[SSZipArchive unzipFileAtPath:tmpPath toDestination:tmpOutputPath];
NSFileManager *fm = [NSFileManager defaultManager];
[fm removeItemAtPath:tmpPath error:nil];
NSString *outputPath = [[NSString stringWithFormat:@"~/Library/Containers/com.bohemiancoding.sketch3/Data/Library/Application Support/com.bohemiancoding.sketch3/Plugins/%@", self.displayName] stringByExpandingTildeInPath];
[fm moveItemAtPath:tmpContentsPath toPath:outputPath error:nil];

if ([fm fileExistsAtPath:kSketchBetaPluginPath]) {
NSString *outputPath = [NSString stringWithFormat:@"%@/%@", kSketchAppStorePluginPath, self.displayName];
[fm copyItemAtPath:tmpContentsPath toPath:outputPath error:nil];
self.downloadPath = outputPath;
}

if ([fm fileExistsAtPath:kSketchBetaPluginPath]) {
NSString *outputPath = [NSString stringWithFormat:@"%@/%@", kSketchBetaPluginPath, self.displayName];
[fm copyItemAtPath:tmpContentsPath toPath:outputPath error:nil];
}

[fm removeItemAtPath:tmpContentsPath error:nil];

NSLog(@"Finished downloading %@", self.name);
self.installed = [NSDate date];
self.downloadPath = outputPath;

[[NSManagedObjectContext MR_defaultContext] MR_saveToPersistentStoreAndWait];
[[NSNotificationCenter defaultCenter] postNotificationName:@"pluginStatusUpdated" object:nil];
}];
Expand Down
4 changes: 2 additions & 2 deletions Sketch Toolbox/Sketch Toolbox-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.0.3</string>
<string>0.0.4</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>3</string>
<string>4</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.graphics-design</string>
<key>LSMinimumSystemVersion</key>
Expand Down

0 comments on commit 56b2dd2

Please sign in to comment.