8000 Fixed: Changes in package.json are not livesynced · NativeScript/nativescript-cli@958fbd9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 958fbd9

Browse files
author
Tsvetan Raikov
committed
Fixed: Changes in package.json are not livesynced
Implemented pt redictable livesync Implement run command to use livesync project changes info as a service
1 parent 7f5844e commit 958fbd9

32 files changed

+846
-548
lines changed

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
{
88
"type": "node",
99
"request": "launch",
10-
"cwd": "${workspaceRoot}/scratch",
10+
"cwd": "${workspaceRoot}",
1111
"sourceMaps": true,
1212
"name": "Launch CLI (Node 6+)",
1313
"program": "${workspaceRoot}/lib/nativescript-cli.js",

lib/bootstrap.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,9 @@ $injector.requireCommand("platform|clean", "./commands/platform-clean");
104104

105105
$injector.requireCommand("livesync", "./commands/livesync");
106106
$injector.require("usbLiveSyncService", "./services/livesync/livesync-service"); // The name is used in https://github.com/NativeScript/nativescript-dev-typescript
107-
$injector.require("iosPlatformLiveSyncServiceLocator", "./services/livesync/ios-platform-livesync-service");
108107
$injector.require("iosLiveSyncServiceLocator", "./services/livesync/ios-device-livesync-service");
109-
$injector.require("androidPlatformLiveSyncServiceLocator", "./services/livesync/android-platform-livesync-service");
110108
$injector.require("androidLiveSyncServiceLocator", "./services/livesync/android-device-livesync-service");
109+
$injector.require("platformLiveSyncService", "./services/livesync/platform-livesync-service");
111110

112111
$injector.require("sysInfo", "./sys-info");
113112

@@ -123,3 +122,4 @@ $injector.requireCommand("post-install-cli", "./commands/post-install");
123122
$injector.requireCommand("update", "./commands/update");
124123

125124
$injector.require("iOSLogFilter", "./services/ios-log-filter");
125+
$injector.require("projectChangesService", "./services/project-changes-service");

lib/commands/appstore-upload.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,12 @@ export class PublishIOS implements ICommand {
6565
};
6666
this.$logger.info("Building .ipa with the selected mobile provision and/or certificate.");
6767
// This is not very correct as if we build multiple targets we will try to sign all of them using the signing identity here.
68-
this.$platformService.buildPlatform(platform, iOSBuildConfig, true).wait();
68+
this.$platformService.preparePlatform(platform).wait();
69+
this.$platformService.buildPlatform(platform, iOSBuildConfig).wait();
6970
ipaFilePath = this.$platformService.lastOutputPath(platform, { isForDevice: iOSBuildConfig.buildForDevice });
7071
} else {
7172
this.$logger.info("No .ipa, mobile provision or certificate set. Perfect! Now we'll build .xcarchive and let Xcode pick the distribution certificate and provisioning profile for you when exporting .ipa for AppStore submission.");
72-
this.$platformService.preparePlatform(platform, true).wait();
73+
this.$platformService.preparePlatform(platform).wait();
7374

7475
let platformData = this.$platformsData.getPlatformData(platform);
7576
let iOSProjectService = <IOSProjectService>platformData.platformProjectService;

lib/commands/build.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ export class BuildCommandBase {
55
executeCore(args: string[]): IFuture<void> {
66
return (() => {
77
let platform = args[0].toLowerCase();
8-
this.$platformService.buildPlatform(platform, null, true).wait();
8+
this.$platformService.preparePlatform(platform).wait();
9+
this.$options.clean = true;
10+
this.$platformService.buildPlatform(platform).wait();
911
if(this.$options.copyTo) {
1012
this.$platformService.copyLastOutput(platform, this.$options.copyTo, {isForDevice: this.$options.forDevice});
1113
}

lib/commands/debug.ts

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,32 @@
77
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
88
private $config: IConfiguration,
99
private $usbLiveSyncService: ILiveSyncService,
10+
private $platformService: IPlatformService,
1011
protected $options: IOptions) { }
1112

1213
execute(args: string[]): IFuture<void> {
13-
14-
if (this.$options.watch) {
15-
this.$options.rebuild = false;
14+
if (this.$options.start) {
15+
return this.debugService.debug();
1616
}
1717

18-
if (!this.$options.rebuild && !this.$options.start) {
19-
this.$config.debugLivesync = true;
20-
let applicationReloadAction = (deviceAppData: Mobile.IDeviceAppData, localToDevicePaths: Mobile.ILocalToDevicePathData[]): IFuture<void> => {
21-
return (() => {
22-
let projectData: IProjectData = this.$injector.resolve("projectData");
23-
24-
this.debugService.debugStop().wait();
18+
this.$platformService.deployPlatform(this.$devicesService.platform).wait();
19+
this.$config.debugLivesync = true;
20+
let applicationReloadAction = (deviceAppData: Mobile.IDeviceAppData): IFuture<void> => {
21+
return (() => {
22+
let projectData: IProjectData = this.$injector.resolve("projectData");
2523

26-
let applicationId = deviceAppData.appIdentifier;
27-
if (deviceAppData.device.isEmulator && deviceAppData.platform.toLowerCase() === this.$devicePlatformsConstants.iOS.toLowerCase()) {
28-
applicationId = projectData.projectName;
29-
}
30-
deviceAppData.device.applicationManager.stopApplication(applicationId).wait();
24+
this.debugService.debugStop().wait();
3125

32-
this.debugService.debug().wait();
33-
}).future<void>()();
34-
};
26+
let applicationId = deviceAppData.appIdentifier;
27+
if (deviceAppData.device.isEmulator && deviceAppData.platform.toLowerCase() === this.$devicePlatformsConstants.iOS.toLowerCase()) {
28+
applicationId = projectData.projectName;
29+
}
30+
deviceAppData.device.applicationManager.stopApplication(applicationId).wait();
3531

36-
return this.$usbLiveSyncService.liveSync(this.$devicesService.platform, applicationReloadAction);
37-
}
38-
return this.debugService.debug();
32+
this.debugService.debug().wait();
33+
}).future<void>()();
34+
};
35+
return this.$usbLiveSyncService.liveSync(this.$devicesService.platform, applicationReloadAction);
3936
}
4037

4138
allowedParameters: ICommandParameter[] = [];
@@ -69,8 +66,9 @@ export class DebugIOSCommand extends DebugPlatformCommand {
6966
$devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
7067
$config: IConfiguration,
7168
$usbLiveSyncService: ILiveSyncService,
69+
$platformService: IPlatformService,
7270
$options: IOptions) {
73-
super($iOSDebugService, $devicesService, $injector, $logger, $childProcess, $devicePlatformsConstants, $config, $usbLiveSyncService, $options);
71+
super($iOSDebugService, $devicesService, $injector, $logger, $childProcess, $devicePlatformsConstants, $config, $usbLiveSyncService, $platformService, $options);
7472
}
7573
}
7674
$injector.registerCommand("debug|ios", DebugIOSCommand);
@@ -84,8 +82,9 @@ export class DebugAndroidCommand extends DebugPlatformCommand {
8482
$devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
8583
$config: IConfiguration,
8684
$usbLiveSyncService: ILiveSyncService,
85+
$platformService: IPlatformService,
8786
$options: IOptions) {
88-
super($androidDebugService, $devicesService, $injector, $logger, $childProcess, $devicePlatformsConstants, $config, $usbLiveSyncService, $options);
87+
super($androidDebugService, $devicesService, $injector, $logger, $childProcess, $devicePlatformsConstants, $config, $usbLiveSyncService, $platformService, $options);
8988
}
9089
}
9190
$injector.registerCommand("debug|android", DebugAndroidCommand);

lib/commands/deploy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export class DeployOnDeviceCommand implements ICommand {
66
private $mobileHelper: Mobile.IMobileHelper) { }
77

88
execute(args: string[]): IFuture<void> {
9-
return this.$platformService.deployPlatform(args[0]);
9+
return this.$platformService.deployPlatform(args[0], true);
1010
}
1111

1212
public canExecute(args: string[]): IFuture<boolean> {

lib/commands/livesync.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ export class LivesyncCommand implements ICommand {
33
private $usbLiveSyncService: ILiveSyncService,
44
private $mobileHelper: Mobile.IMobileHelper,
55
private $options: IOptions,
6+
private $platformService: IPlatformService,
67
private $errors: IErrors) { }
78

89
public execute(args: string[]): IFuture<void> {
10+
this.$platformService.deployPlatform(args[0]).wait();
911
return this.$usbLiveSyncService.liveSync(args[0]);
1012
}
1113

lib/commands/prepare.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export class PrepareCommand implements ICommand {
55

66
execute(args: string[]): IFuture<void> {
77
return (() => {
8-
this.$platformService.preparePlatform(args[0], true).wait();
8+
this.$platformService.preparePlatform(args[0]).wait();
99
}).future<void>()();
1010
}
1111

lib/commands/run.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ export class RunCommandBase {
44
protected $options: IOptions) { }
55

66
public executeCore(args: string[]): IFuture<void> {
7-
if (this.$options.watch) {
8-
this.$platformService.deployPlatform(args[0]).wait();
9-
return this.$usbLiveSyncService.liveSync(args[0]);
10-
} else {
7+
this.$platformService.deployPlatform(args[0]).wait();
8+
if (this.$options.release) {
119
return this.$platformService.runPlatform(args[0]);
1210
}
11+
return this.$usbLiveSyncService.liveSync(args[0]);
1312
}
1413
}
1514

lib/declarations.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,13 @@ interface IOpener {
5151
}
5252

5353
interface ILiveSyncService {
54-
liveSync(platform: string, applicationReloadAction?: (deviceAppData: Mobile.IDeviceAppData, localToDevicePaths: Mobile.ILocalToDevicePathData[]) => IFuture<void>): IFuture<void>;
55-
forceExecuteFullSync: boolean;
54+
liveSync(platform: string, applicationReloadAction?: (deviceAppData: Mobile.IDeviceAppData) => IFuture<void>): IFuture<void>;
5655
}
5756

5857
interface IPlatformLiveSyncService {
5958
fullSync(postAction?: (deviceAppData: Mobile.IDeviceAppData, localToDevicePaths: Mobile.ILocalToDevicePathData[]) => IFuture<void>): IFuture<void>;
6059
partialSync(event: string, filePath: string, dispatcher: IFutureDispatcher, afterFileSyncAction: (deviceAppData: Mobile.IDeviceAppData, localToDevicePaths: Mobile.ILocalToDevicePathData[]) => IFuture<void>): void;
61-
refreshApplication(deviceAppData: Mobile.IDeviceAppData, localToDevicePaths: Mobile.ILocalToDevicePathData[]): IFuture<void>;
60+
refreshApplication(deviceAppData: Mobile.IDeviceAppData, localToDevicePaths: Mobile.ILocalToDevicePathData[], isFullSync: boolean): IFuture<void>;
6261
}
6362

6463
interface IOptions extends ICommonOptions {
@@ -93,10 +92,10 @@ interface IOptions extends ICommonOptions {
9392
sdk: string;
9493
tnsModulesVersion: string;
9594
teamId: string;
96-
rebuild: boolean;
9795
syncAllFiles: boolean;
9896
liveEdit: boolean;
9997
chrome: boolean;
98+
clean: boolean;
10099
}
101100

102101
interface IInitService {

0 commit comments

Comments
 (0)
0