|
1 | 1 | import * as path from "path";
|
| 2 | +import * as temp from "temp"; |
2 | 3 |
|
3 | 4 | export class LiveSyncProvider implements ILiveSyncProvider {
|
4 | 5 | constructor(private $androidLiveSyncServiceLocator: {factory: Function},
|
5 | 6 | private $iosLiveSyncServiceLocator: {factory: Function},
|
6 | 7 | private $platformService: IPlatformService,
|
7 | 8 | private $platformsData: IPlatformsData,
|
8 |
| - private $logger: ILogger) { } |
| 9 | + private $logger: ILogger, |
| 10 | + private $childProcess: IChildProcess) { } |
9 | 11 |
|
10 | 12 | private static FAST_SYNC_FILE_EXTENSIONS = [".css", ".xml"];
|
11 | 13 |
|
@@ -54,5 +56,25 @@ export class LiveSyncProvider implements ILiveSyncProvider {
|
54 | 56 | let fastSyncFileExtensions = LiveSyncProvider.FAST_SYNC_FILE_EXTENSIONS.concat(platformData.fastLivesyncFileExtensions);
|
55 | 57 | return _.contains(fastSyncFileExtensions, path.extname(filePath));
|
56 | 58 | }
|
| 59 | + |
| 60 | + public transferFiles(deviceAppData: Mobile.IDeviceAppData, localToDevicePaths: Mobile.ILocalToDevicePathData[], projectFilesPath: string, isFullSync: boolean): IFuture<void> { |
| 61 | + return (() => { |
| 62 | + if (deviceAppData.platform.toLowerCase() === "android" || !deviceAppData.deviceSyncZipPath || !isFullSync) { |
| 63 | + deviceAppData.device.fileSystem.transferFiles(deviceAppData, localToDevicePaths).wait(); |
| 64 | + } else { |
| 65 | + temp.track(); |
| 66 | + let tempZip = temp.path({prefix: "sync", suffix: ".zip"}); |
| 67 | + this.$logger.trace("Creating zip file: " + tempZip); |
| 68 | + this.$childProcess.spawnFromEvent("zip", [ "-r", "-0", tempZip, "app" ], "close", { cwd: path.dirname(projectFilesPath) }).wait(); |
| 69 | + |
| 70 | + deviceAppData.device.fileSystem.transferFiles(deviceAppData, [{ |
| 71 | + getLocalPath: () => tempZip, |
| 72 | + getDevicePath: () => deviceAppData.deviceSyncZipPath, |
| 73 | + getRelativeToProjectBasePath: () => "../sync.zip", |
| 74 | + deviceProjectRootPath: deviceAppData.deviceProjectRootPath |
| 75 | + }]).wait(); |
| 76 | + } |
| 77 | + }).future<void>()(); |
| 78 | + } |
57 | 79 | }
|
58 | 80 | $injector.register("liveSyncProvider", LiveSyncProvider);
|
0 commit comments