Skip to content

Commit bd9bc87

Browse files
Merge pull request #3848 from NativeScript/vladimirov/merge-rel-master
chore: merge release in master
2 parents 9dd6f20 + be85c3f commit bd9bc87

14 files changed

+403
-43
lines changed

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
11
NativeScript CLI Changelog
22
================
33

4+
4.2.3 (2018, August 27)
5+
==
6+
7+
### Fixed
8+
* [Fixed #3840](https://github.com/NativeScript/nativescript-cli/issues/3840): Unable to reconnect to iOS Simulator when debugging
9+
* [Fixed #3824](https://github.com/NativeScript/nativescript-cli/issues/3824): `tns create` command not using proxy set with `tns proxy set`
10+
11+
12+
4.2.2 (2018, August 17)
13+
==
14+
15+
### Fixed
16+
* [Fixed #3818](https://github.com/NativeScript/nativescript-cli/issues/3818): Unable to start application on Android device with a custom activity containing capital letters
17+
* [Fixed #3820](https://github.com/NativeScript/nativescript-cli/issues/3820): A command help is shown on native build error
18+
* [Fixed #3821](https://github.com/NativeScript/nativescript-cli/issues/3821): [Sporadic] Unable to start iOS debugger from VSCode extension
19+
20+
421
4.2.1 (2018, August 10)
522
==
623

lib/definitions/ios-debugger-port-service.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ interface IIOSDebuggerPortService {
1717
* Gets iOS debugger port for specified deviceId and appId
1818
* @param {IIOSDebuggerPortInputData} data - Describes deviceId and appId
1919
*/
20-
getPort(data: IIOSDebuggerPortInputData): Promise<number>;
20+
getPort(data: IIOSDebuggerPortInputData, debugOptions?: IDebugOptions): Promise<number>;
2121
/**
2222
* Attaches on DEBUGGER_PORT_FOUND event and STARTING_IOS_APPLICATION events
2323
* In case when DEBUGGER_PORT_FOUND event is emitted, stores the port and clears the timeout if such.

lib/definitions/pacote-service.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ declare global {
1818
extractPackage(packageName: string, destinationDirectory: string, options?: IPacoteExtractOptions): Promise<void>;
1919
}
2020

21-
interface IPacoteBaseOptions {
21+
interface IPacoteBaseOptions extends IProxySettingsBase {
2222
/**
2323
* The path to npm cache
2424
*/

lib/device-sockets/ios/socket-proxy-factory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export class SocketProxyFactory extends EventEmitter implements ISocketProxyFact
9090
this.$logger.info("Frontend client connected.");
9191
let _socket;
9292
try {
93-
_socket = await factory();
93+
_socket = await helpers.connectEventuallyUntilTimeout(factory, 10000);
9494
} catch (err) {
9595
err.deviceIdentifier = deviceIdentifier;
9696
this.$logger.trace(err);

lib/services/android-project-service.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -701,11 +701,17 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
701701
const childProcessOpts = opts.childProcessOpts || {};
702702
childProcessOpts.cwd = childProcessOpts.cwd || projectRoot;
703703
childProcessOpts.stdio = childProcessOpts.stdio || "inherit";
704+
let commandResult;
705+
try {
706+
commandResult = await this.spawn(gradlew,
707+
gradleArgs,
708+
childProcessOpts,
709+
spawnFromEventOptions);
710+
} catch (err) {
711+
this.$errors.failWithoutHelp(err.message);
712+
}
704713

705-
return await this.spawn(gradlew,
706-
gradleArgs,
707-
childProcessOpts,
708-
spawnFromEventOptions);
714+
return commandResult;
709715
}
710716
}
711717

lib/services/ios-debug-service.ts

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ export class IOSDebugService extends DebugServiceBase implements IPlatformDebugS
202202
// the VSCode Ext starts `tns debug ios --no-client` to start/attach to debug sessions
203203
// check if --no-client is passed - default to opening a tcp socket (versus Chrome DevTools (websocket))
204204
if ((debugOptions.inspector || !debugOptions.client) && this.$hostInfo.isDarwin) {
205-
this._socketProxy = await this.$socketProxyFactory.createTCPSocketProxy(this.getSocketFactory(debugData, device));
205+
this._socketProxy = await this.$socketProxyFactory.createTCPSocketProxy(this.getSocketFactory(device, debugData, debugOptions));
206206
await this.openAppInspector(this._socketProxy.address(), debugData, debugOptions);
207207
return null;
208208
} else {
@@ -211,7 +211,7 @@ export class IOSDebugService extends DebugServiceBase implements IPlatformDebugS
211211
}
212212

213213
const deviceIdentifier = device ? device.deviceInfo.identifier : debugData.deviceIdentifier;
214-
this._socketProxy = await this.$socketProxyFactory.createWebSocketProxy(this.getSocketFactory(debugData, device), deviceIdentifier);
214+
this._socketProxy = await this.$socketProxyFactory.createWebSocketProxy(this.getSocketFactory(device, debugData, debugOptions), deviceIdentifier);
215215
return this.getChromeDebugUrl(debugOptions, this._socketProxy.options.port);
216216
}
217217
}
@@ -230,15 +230,24 @@ export class IOSDebugService extends DebugServiceBase implements IPlatformDebugS
230230
}
231231
}
232232

233-
private getSocketFactory(debugData: IDebugData, device?: Mobile.IiOSDevice): () => Promise<net.Socket> {
233+
private getSocketFactory(device: Mobile.IiOSDevice, debugData: IDebugData, debugOptions: IDebugOptions): () => Promise<net.Socket> {
234+
let pendingExecution: Promise<net.Socket> = null;
234235
const factory = async () => {
235-
const port = await this.$iOSDebuggerPortService.getPort({ projectDir: debugData.projectDir, deviceId: debugData.deviceIdentifier, appId: debugData.applicationIdentifier });
236-
if (!port) {
237-
this.$errors.fail("NativeScript debugger was not able to get inspector socket port.");
236+
if (!pendingExecution) {
237+
const func = async () => {
238+
const port = await this.$iOSDebuggerPortService.getPort({ projectDir: debugData.projectDir, deviceId: debugData.deviceIdentifier, appId: debugData.applicationIdentifier }, debugOptions);
239+
if (!port) {
240+
this.$errors.fail("NativeScript debugger was not able to get inspector socket port.");
241+
}
242+
const socket = device ? await device.connectToPort(port) : net.connect(port);
243+
this._sockets.push(socket);
244+
pendingExecution = null;
245+
return socket;
246+
};
247+
pendingExecution = func();
238248
}
239-
const socket = device ? await device.connectToPort(port) : net.connect(port);
240-
this._sockets.push(socket);
241-
return socket;
249+
250+
return pendingExecution;
242251
};
243252

244253
factory.bind(this);

lib/services/ios-debugger-port-service.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,16 @@ export class IOSDebuggerPortService implements IIOSDebuggerPortService {
1414
private $projectDataService: IProjectDataService,
1515
private $logger: ILogger) { }
1616

17-
public getPort(data: IIOSDebuggerPortInputData): Promise<number> {
17+
public getPort(data: IIOSDebuggerPortInputData, debugOptions?: IDebugOptions): Promise<number> {
1818
return new Promise((resolve, reject) => {
1919
if (!this.canStartLookingForDebuggerPort(data)) {
2020
resolve(IOSDebuggerPortService.DEFAULT_PORT);
2121
return;
2222
}
2323

2424
const key = `${data.deviceId}${data.appId}`;
25-
let retryCount: number = 10;
25+
const timeout = this.getTimeout(debugOptions);
26+
let retryCount = Math.max(timeout * 1000 / 500, 10);
2627

2728
const interval = setInterval(() => {
2829
let port = this.getPortByKey(key);

lib/services/ios-project-service.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
5757
private $plistParser: IPlistParser,
5858
private $sysInfo: ISysInfo,
5959
private $xCConfigService: XCConfigService) {
60-
super($fs, $projectDataService);
60+
super($fs, $projectDataService);
6161
}
6262

6363
private _platformsDirCache: string = null;
@@ -442,11 +442,19 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
442442
localArgs.push("-quiet");
443443
this.$logger.info("Xcode build...");
444444
}
445-
return this.$childProcess.spawnFromEvent("xcodebuild",
446-
localArgs,
447-
"exit",
448-
{ stdio: stdio || "inherit", cwd },
449-
{ emitOptions: { eventName: constants.BUILD_OUTPUT_EVENT_NAME }, throwError: true });
445+
446+
let commandResult;
447+
try {
448+
commandResult = await this.$childProcess.spawnFromEvent("xcodebuild",
449+
localArgs,
450+
"exit",
451+
{ stdio: stdio || "inherit", cwd },
452+
{ emitOptions: { eventName: constants.BUILD_OUTPUT_EVENT_NAME }, throwError: true });
453+
} catch (err) {
454+
this.$errors.failWithoutHelp(err.message);
455+
}
456+
457+
return commandResult;
450458
}
451459

452460
private async setupSigningFromTeam(projectRoot: string, projectData: IProjectData, teamId: string) {
@@ -1112,7 +1120,7 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
11121120
private async prepareNativeSourceCode(pluginName: string, pluginPlatformsFolderPath: string, projectData: IProjectData): Promise<void> {
11131121
const project = this.createPbxProj(projectData);
11141122
const group = this.getRootGroup(pluginName, pluginPlatformsFolderPath);
1115-
project.addPbxGroup(group.files, group.name, group.path, null, {isMain:true});
1123+
project.addPbxGroup(group.files, group.name, group.path, null, { isMain: true });
11161124
project.addToHeaderSearchPaths(group.path);
11171125
this.savePbxProj(project, projectData);
11181126
}

lib/services/livesync/android-livesync-tool.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,10 @@ export class AndroidLivesyncTool implements IAndroidLivesyncTool {
313313
const connectionTimer = setTimeout(() => {
314314
if (!isConnected) {
315315
isConnected = true;
316+
if (this.pendingConnectionData && this.pendingConnectionData.socketTimer) {
317+
clearTimeout(this.pendingConnectionData.socketTimer);
318+
}
319+
316320
reject(lastKnownError || new Error("Socket connection timeouted."));
317321
this.pendingConnectionData = null;
318322
}

0 commit comments

Comments
 (0)