Skip to content

chore: merge release in master #3848

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 23 commits into from
Aug 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
bcfb903
fix: stop showing the command help on native build error
Aug 10, 2018
d07c8ae
Respect timeout option when getting debugger port
Fatme Aug 13, 2018
0c9d3e6
Fix unit tests
Fatme Aug 13, 2018
5feb88f
Merge pull request #3817 from NativeScript/fatme/debug-timeout-option
Aug 14, 2018
12c81d8
Merge pull request #3814 from NativeScript/tachev/fix-build-help
Aug 14, 2018
e8c06ab
fix: fix the activity regex in order to match activities with capital…
Aug 14, 2018
2072e10
Update common lib
Fatme Aug 15, 2018
6a63e61
Merge pull request #3819 from NativeScript/tachev/fix-app-start
Aug 15, 2018
d3a805f
Bump version to 4.2.2 and add changelog
Fatme Aug 15, 2018
a3ebf5d
Merge pull request #3822 from NativeScript/fatme/4.2.2
Aug 15, 2018
bf75573
fix: clear the socket timer on timeout (avoid `Cannot set property 's…
Aug 22, 2018
7fe76e5
Merge pull request #3835 from NativeScript/tachev/fix-socket-error
Aug 22, 2018
86c1557
fix: pacote does not respect CLI's proxy configuration
rosen-vladimirov Aug 21, 2018
9b5b6ca
Merge pull request #3831 from NativeScript/vladimirov/fix-pacote-proxy
rosen-vladimirov Aug 23, 2018
71b0a4e
Bump version to 4.2.3
Fatme Aug 23, 2018
6a7dda1
Fix connect to port
Fatme Aug 23, 2018
c2d261a
Merge pull request #3837 from NativeScript/fatme/fix-ios-emulator-deb…
Aug 23, 2018
d15fb00
Fix `tns debug ios --inspector`
Fatme Aug 24, 2018
d97f6dc
Merge pull request #3842 from NativeScript/fatme/fix-inspector
Aug 24, 2018
69c19e3
Update CHANGELOG.md
miroslavaivanova Aug 27, 2018
ffbceb6
Merge pull request #3847 from NativeScript/miroslavaivanova-patch-1-1
miroslavaivanova Aug 27, 2018
ab9f6be
chore: merge branch 'release' into vladimirov/merge-rel-master
rosen-vladimirov Aug 28, 2018
be85c3f
chore: update to latest common lib
rosen-vladimirov Aug 28, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
NativeScript CLI Changelog
================

4.2.3 (2018, August 27)
==

### Fixed
* [Fixed #3840](https://github.com/NativeScript/nativescript-cli/issues/3840): Unable to reconnect to iOS Simulator when debugging
* [Fixed #3824](https://github.com/NativeScript/nativescript-cli/issues/3824): `tns create` command not using proxy set with `tns proxy set`


4.2.2 (2018, August 17)
==

### Fixed
* [Fixed #3818](https://github.com/NativeScript/nativescript-cli/issues/3818): Unable to start application on Android device with a custom activity containing capital letters
* [Fixed #3820](https://github.com/NativeScript/nativescript-cli/issues/3820): A command help is shown on native build error
* [Fixed #3821](https://github.com/NativeScript/nativescript-cli/issues/3821): [Sporadic] Unable to start iOS debugger from VSCode extension


4.2.1 (2018, August 10)
==

Expand Down
2 changes: 1 addition & 1 deletion lib/definitions/ios-debugger-port-service.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface IIOSDebuggerPortService {
* Gets iOS debugger port for specified deviceId and appId
* @param {IIOSDebuggerPortInputData} data - Describes deviceId and appId
*/
getPort(data: IIOSDebuggerPortInputData): Promise<number>;
getPort(data: IIOSDebuggerPortInputData, debugOptions?: IDebugOptions): Promise<number>;
/**
* Attaches on DEBUGGER_PORT_FOUND event and STARTING_IOS_APPLICATION events
* In case when DEBUGGER_PORT_FOUND event is emitted, stores the port and clears the timeout if such.
Expand Down
2 changes: 1 addition & 1 deletion lib/definitions/pacote-service.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ declare global {
extractPackage(packageName: string, destinationDirectory: string, options?: IPacoteExtractOptions): Promise<void>;
}

interface IPacoteBaseOptions {
interface IPacoteBaseOptions extends IProxySettingsBase {
/**
* The path to npm cache
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/device-sockets/ios/socket-proxy-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export class SocketProxyFactory extends EventEmitter implements ISocketProxyFact
this.$logger.info("Frontend client connected.");
let _socket;
try {
_socket = await factory();
_socket = await helpers.connectEventuallyUntilTimeout(factory, 10000);
} catch (err) {
err.deviceIdentifier = deviceIdentifier;
this.$logger.trace(err);
Expand Down
14 changes: 10 additions & 4 deletions lib/services/android-project-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -701,11 +701,17 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
const childProcessOpts = opts.childProcessOpts || {};
childProcessOpts.cwd = childProcessOpts.cwd || projectRoot;
childProcessOpts.stdio = childProcessOpts.stdio || "inherit";
let commandResult;
try {
commandResult = await this.spawn(gradlew,
gradleArgs,
childProcessOpts,
spawnFromEventOptions);
} catch (err) {
this.$errors.failWithoutHelp(err.message);
}

return await this.spawn(gradlew,
gradleArgs,
childProcessOpts,
spawnFromEventOptions);
return commandResult;
}
}

Expand Down
27 changes: 18 additions & 9 deletions lib/services/ios-debug-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ export class IOSDebugService extends DebugServiceBase implements IPlatformDebugS
// the VSCode Ext starts `tns debug ios --no-client` to start/attach to debug sessions
// check if --no-client is passed - default to opening a tcp socket (versus Chrome DevTools (websocket))
if ((debugOptions.inspector || !debugOptions.client) && this.$hostInfo.isDarwin) {
this._socketProxy = await this.$socketProxyFactory.createTCPSocketProxy(this.getSocketFactory(debugData, device));
this._socketProxy = await this.$socketProxyFactory.createTCPSocketProxy(this.getSocketFactory(device, debugData, debugOptions));
await this.openAppInspector(this._socketProxy.address(), debugData, debugOptions);
return null;
} else {
Expand All @@ -211,7 +211,7 @@ export class IOSDebugService extends DebugServiceBase implements IPlatformDebugS
}

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

private getSocketFactory(debugData: IDebugData, device?: Mobile.IiOSDevice): () => Promise<net.Socket> {
private getSocketFactory(device: Mobile.IiOSDevice, debugData: IDebugData, debugOptions: IDebugOptions): () => Promise<net.Socket> {
let pendingExecution: Promise<net.Socket> = null;
const factory = async () => {
const port = await this.$iOSDebuggerPortService.getPort({ projectDir: debugData.projectDir, deviceId: debugData.deviceIdentifier, appId: debugData.applicationIdentifier });
if (!port) {
this.$errors.fail("NativeScript debugger was not able to get inspector socket port.");
if (!pendingExecution) {
const func = async () => {
const port = await this.$iOSDebuggerPortService.getPort({ projectDir: debugData.projectDir, deviceId: debugData.deviceIdentifier, appId: debugData.applicationIdentifier }, debugOptions);
if (!port) {
this.$errors.fail("NativeScript debugger was not able to get inspector socket port.");
}
const socket = device ? await device.connectToPort(port) : net.connect(port);
this._sockets.push(socket);
pendingExecution = null;
return socket;
};
pendingExecution = func();
}
const socket = device ? await device.connectToPort(port) : net.connect(port);
this._sockets.push(socket);
return socket;

return pendingExecution;
};

factory.bind(this);
Expand Down
5 changes: 3 additions & 2 deletions lib/services/ios-debugger-port-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@ export class IOSDebuggerPortService implements IIOSDebuggerPortService {
private $projectDataService: IProjectDataService,
private $logger: ILogger) { }

public getPort(data: IIOSDebuggerPortInputData): Promise<number> {
public getPort(data: IIOSDebuggerPortInputData, debugOptions?: IDebugOptions): Promise<number> {
return new Promise((resolve, reject) => {
if (!this.canStartLookingForDebuggerPort(data)) {
resolve(IOSDebuggerPortService.DEFAULT_PORT);
return;
}

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

const interval = setInterval(() => {
let port = this.getPortByKey(key);
Expand Down
22 changes: 15 additions & 7 deletions lib/services/ios-project-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
private $plistParser: IPlistParser,
private $sysInfo: ISysInfo,
private $xCConfigService: XCConfigService) {
super($fs, $projectDataService);
super($fs, $projectDataService);
}

private _platformsDirCache: string = null;
Expand Down Expand Up @@ -442,11 +442,19 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
localArgs.push("-quiet");
this.$logger.info("Xcode build...");
}
return this.$childProcess.spawnFromEvent("xcodebuild",
localArgs,
"exit",
{ stdio: stdio || "inherit", cwd },
{ emitOptions: { eventName: constants.BUILD_OUTPUT_EVENT_NAME }, throwError: true });

let commandResult;
try {
commandResult = await this.$childProcess.spawnFromEvent("xcodebuild",
localArgs,
"exit",
{ stdio: stdio || "inherit", cwd },
{ emitOptions: { eventName: constants.BUILD_OUTPUT_EVENT_NAME }, throwError: true });
} catch (err) {
this.$errors.failWithoutHelp(err.message);
}

return commandResult;
}

private async setupSigningFromTeam(projectRoot: string, projectData: IProjectData, teamId: string) {
Expand Down Expand Up @@ -1112,7 +1120,7 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
private async prepareNativeSourceCode(pluginName: string, pluginPlatformsFolderPath: string, projectData: IProjectData): Promise<void> {
const project = this.createPbxProj(projectData);
const group = this.getRootGroup(pluginName, pluginPlatformsFolderPath);
project.addPbxGroup(group.files, group.name, group.path, null, {isMain:true});
project.addPbxGroup(group.files, group.name, group.path, null, { isMain: true });
project.addToHeaderSearchPaths(group.path);
this.savePbxProj(project, projectData);
}
Expand Down
4 changes: 4 additions & 0 deletions lib/services/livesync/android-livesync-tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,10 @@ export class AndroidLivesyncTool implements IAndroidLivesyncTool {
const connectionTimer = setTimeout(() => {
if (!isConnected) {
isConnected = true;
if (this.pendingConnectionData && this.pendingConnectionData.socketTimer) {
clearTimeout(this.pendingConnectionData.socketTimer);
}

reject(lastKnownError || new Error("Socket connection timeouted."));
this.pendingConnectionData = null;
}
Expand Down
60 changes: 45 additions & 15 deletions lib/services/pacote-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,78 @@ import * as path from "path";

export class PacoteService implements IPacoteService {
constructor(private $fs: IFileSystem,
private $npm: INodePackageManager) { }
private $npm: INodePackageManager,
private $proxyService: IProxyService,
private $logger: ILogger) { }

public async manifest(packageName: string, options?: IPacoteManifestOptions): Promise<any> {
// In case `tns create myapp --template https://github.com/NativeScript/template-hello-world.git` command is executed, pacote module throws an error if cache option is not provided.
const cache = await this.$npm.getCachePath();
const manifestOptions = { cache };
this.$logger.trace(`Calling pacoteService.manifest for packageName: '${packageName}' and options: ${options}`);
const manifestOptions: IPacoteBaseOptions = await this.getPacoteBaseOptions();
if (options) {
_.extend(manifestOptions, options);
}

if (this.$fs.exists(packageName)) {
packageName = path.resolve(packageName);
}

packageName = this.getRealPackageName(packageName);
this.$logger.trace(`Calling pacote.manifest for packageName: ${packageName} and options: ${JSON.stringify(manifestOptions, null, 2)}`);
return pacote.manifest(packageName, manifestOptions);
}

public async extractPackage(packageName: string, destinationDirectory: string, options?: IPacoteExtractOptions): Promise<void> {
// strip: Remove the specified number of leading path elements. Pathnames with fewer elements will be silently skipped. More info: https://github.com/npm/node-tar/blob/e89c4d37519b1c20133a9f49d5f6b85fa34c203b/README.md
// C: Create an archive
this.$logger.trace(`Calling pacoteService.extractPackage for packageName: '${packageName}', destinationDir: '${destinationDirectory}' and options: ${options}`);
const extractOptions = { strip: 1, C: destinationDirectory };
if (options) {
_.extend(extractOptions, options);
}

if (this.$fs.exists(packageName)) {
packageName = path.resolve(packageName);
}
packageName = this.getRealPackageName(packageName);
const pacoteOptions = await this.getPacoteBaseOptions();

const cache = await this.$npm.getCachePath();
return new Promise<void>((resolve, reject) => {
const source = pacote.tarball.stream(packageName, { cache });
this.$logger.trace(`Calling pacoteService.extractPackage for packageName: '${packageName}', destinationDir: '${destinationDirectory}' and options: ${options}`);

const source = pacote.tarball.stream(packageName, pacoteOptions);
source.on("error", (err: Error) => {
this.$logger.trace(`Error in source while trying to extract stream from ${packageName}. Error is ${err}`);
reject(err);
});

this.$logger.trace(`Creating extract tar stream with options: ${JSON.stringify(extractOptions, null, 2)}`);
const destination = tar.x(extractOptions);
source.pipe(destination);

destination.on("error", (err: Error) => reject(err));
destination.on("finish", () => resolve());
destination.on("error", (err: Error) => {
this.$logger.trace(`Error in destination while trying to extract stream from ${packageName}. Error is ${err}`);
reject(err);
});

destination.on("finish", () => {
this.$logger.trace(`Successfully extracted '${packageName}' to ${destinationDirectory}`);
resolve();
});
});
}

private async getPacoteBaseOptions(): Promise<IPacoteBaseOptions> {
// In case `tns create myapp --template https://github.com/NativeScript/template-hello-world.git` command is executed, pacote module throws an error if cache option is not provided.
const cache = await this.$npm.getCachePath();
const pacoteOptions = { cache };
const proxySettings = await this.$proxyService.getCache();
if (proxySettings) {
_.extend(pacoteOptions, proxySettings);
}

return pacoteOptions;
}

private getRealPackageName(packageName: string): string {
if (this.$fs.exists(packageName)) {
this.$logger.trace(`Will resolve the full path to package ${packageName}.`);
packageName = path.resolve(packageName);
}

return packageName;
}
}
$injector.register("pacoteService", PacoteService);
3 changes: 3 additions & 0 deletions test/project-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ class ProjectIntegrationTest {
executeAfterHooks: async (commandName: string, hookArguments?: IDictionary<any>): Promise<void> => undefined
});
this.testInjector.register("pacoteService", PacoteService);
this.testInjector.register("proxyService", {
getCache: async (): Promise<IProxySettings> => null
});
}
}

Expand Down
4 changes: 2 additions & 2 deletions test/services/ios-debugger-port-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ describe("iOSDebuggerPortService", () => {
}

const promise = iOSDebuggerPortService.getPort({ deviceId: deviceId, appId: appId, projectDir: mockProjectDirObj.projectDir });
clock.tick(10000);
clock.tick(20000);
const port = await promise;
assert.deepEqual(port, testCase.emittedPort);
});
Expand All @@ -171,7 +171,7 @@ describe("iOSDebuggerPortService", () => {
}

const promise = iOSDebuggerPortService.getPort({ deviceId: deviceId, appId: appId, projectDir: mockProjectDirObj.projectDir });
clock.tick(10000);
clock.tick(20000);
const port = await promise;
assert.deepEqual(port, testCase.emittedPort);
});
Expand Down
Loading