Skip to content

Reimplement livesync #2883

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 43 commits into from
Jun 15, 2017
Merged

Reimplement livesync #2883

merged 43 commits into from
Jun 15, 2017

Conversation

Mitko-Kerezov
Copy link
Contributor

@Mitko-Kerezov Mitko-Kerezov commented Jun 8, 2017

  • Flatten livesync infrastructure
  • Expose livesync as a method for when CLI is require()-d
  • Emit events during livesync
  • Add tns run command that will be executed on all available devices (iOS and Android on macOS, Android on all other OSes).

Merge after telerik/mobile-cli-lib#974

Ping @rosen-vladimirov @TsvetanMilanov

@dtopuzov
Copy link
Contributor

dtopuzov commented Jun 8, 2017

Current implementation restart the app on each css and xml change, we need to fix it.

@dtopuzov
Copy link
Contributor

run ci

debugData.pathToAppPackage = this.$platformService.lastOutputPath(this.debugService.platform, buildConfig, projectData);

this.printDebugInformation(await this.debugService.debug<string[]>(debugData, debugOptions));
// TODO: Fix this call
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

already fixed

@@ -114,29 +132,37 @@ export class DebugIOSCommand extends DebugPlatformCommand {
super.printDebugInformation(information);
}
}

public platform = "iOS";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use a constant here

return await super.canExecute(args) && await this.$platformService.validateOptions(this.$options.provision, this.$projectData, this.$platformsData.availablePlatforms.Android);
}

public platform = "Android";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use a constant here

useLiveEdit?: boolean;
}

interface ILatestAppPackageInstalledSettings {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interface should be IDictionary<IDictionary<boolean>>

@@ -75,7 +75,7 @@ export class SocketProxyFactory extends EventEmitter implements ISocketProxyFact

public async createWebSocketProxy(factory: () => Promise<net.Socket>): Promise<ws.Server> {
// NOTE: We will try to provide command line options to select ports, at least on the localhost.
const localPort = await this.$net.getAvailablePortInRange(8080);
const localPort = await this.$net.getFreePort();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it didn't work with multiple iOS devices. For some reason the second device's socket connection could not be established due to an EADDRINUSE error.
It did work for Android however but I decided it was not worth the research at the time - we don't actually lose anything with this change other than the fact that every debug session will be on a random port rather than the first being on 8080, the second on 8081 and so on.

}

private async startWatcher(projectData: IProjectData,
liveSyncData: ILiveSyncInfo): Promise<void> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be moved on the line above


if (liveSyncInfo.filesToRemove.length) {
const filePaths = liveSyncInfo.filesToRemove;
let platformData = this.$platformsData.getPlatformData(device.deviceInfo.platform, projectData);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const

}

if (existingFiles.length) {
let platformData = this.$platformsData.getPlatformData(device.deviceInfo.platform, projectData);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const


const mappedFiles = _.map(filePaths, filePath => this.$projectFilesProvider.mapFilePath(filePath, device.deviceInfo.platform, projectData));
const projectFilesPath = path.join(platformData.appDestinationDirectoryPath, APP_FOLDER_NAME);
let localToDevicePaths = await this.$projectFilesManager.createLocalToDevicePaths(deviceAppData, projectFilesPath, mappedFiles, []);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const

@@ -545,8 +554,9 @@ export class PlatformService extends EventEmitter implements IPlatformService {
}

private async getDeviceBuildInfoFilePath(device: Mobile.IDevice, projectData: IProjectData): Promise<string> {
let deviceAppData = this.$deviceAppDataFactory.create(projectData.projectId, device.deviceInfo.platform, device);
let deviceRootPath = path.dirname(await deviceAppData.getDeviceProjectRootPath());
// let deviceAppData = this.$deviceAppDataFactory.create(projectData.projectId, device.deviceInfo.platform, device);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commented code 😃

@dtopuzov
Copy link
Contributor

👍 After green builds.

@NativeScript NativeScript deleted a comment from rosen-vladimirov Jun 12, 2017
TsvetanMilanov and others added 15 commits June 13, 2017 17:32
Expose
* saveBuildInfoFile - method which should be used in cloud builds
* livesyncService - which can be used to perform livesync with require-d tns
In case the app is not installed on a device when `tns run <platform>` is started, each change reinstalls the application.
The problem is in the "isApplicationInstalled" check which was relying on the result of the first execution (when the app has not been installed).
Fix this by always checking if the app is installed.
@Mitko-Kerezov Mitko-Kerezov force-pushed the vladimirov/new-livesync branch from 74a5f07 to c6127ea Compare June 13, 2017 14:33
@rosen-vladimirov rosen-vladimirov force-pushed the vladimirov/new-livesync branch from 9ba0f87 to 083f3f6 Compare June 14, 2017 10:44
We need to explicitly skip this step on Windows due to lack of tooling that is properly licensed.
@nadyaA nadyaA force-pushed the vladimirov/new-livesync branch from 083f3f6 to f32f243 Compare June 14, 2017 14:47
@rosen-vladimirov rosen-vladimirov merged commit ea88148 into master Jun 15, 2017
@rosen-vladimirov rosen-vladimirov deleted the vladimirov/new-livesync branch June 15, 2017 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants