Skip to content

chore: merge release in master #4204

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 33 commits into from
Dec 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
2b9bd70
fix: plugin create doesn't always clean up folder if execution fails
KristianDD Nov 19, 2018
57b1631
test: add tests for plugin dir removal
KristianDD Nov 19, 2018
123206b
Merge pull request #4144 from NativeScript/kddimitrov/handle-plugin-c…
KristianDD Nov 19, 2018
655687c
fix(preview-api): raise deviceLost event after timeout of 5 seconds
Fatme Nov 19, 2018
9acce54
chore: fix unit tests
Fatme Nov 20, 2018
1d28878
chore: fix PR comments
Fatme Nov 20, 2018
edc3486
chore: add additional tests
Fatme Nov 20, 2018
bdaf3ea
fix: reset devices list when stopLiveSync method is called
Fatme Nov 20, 2018
8248829
Merge pull request #4150 from NativeScript/fatme/device-lost-after-ti…
Nov 21, 2018
b2f87bf
Merge pull request #4158 from NativeScript/fatme/reset-devices-on-sto…
Nov 21, 2018
3bfa2de
fix: reset deviceLostTimer after clearing the device's timeout
Fatme Nov 21, 2018
e068886
Merge pull request #4161 from NativeScript/fatme/reset-device-lost-timer
Nov 21, 2018
83577ed
feat(preview-api): emit previewAppLiveSyncError when some error is th…
Fatme Nov 22, 2018
f0d2f8a
docs: add docs for `deviceFound`, `deviceLost` and `deviceLogData` ev…
Fatme Nov 20, 2018
5b09642
docs: add docs for `liveSyncToPreviewApp` method in `PublicAPI.md`
Fatme Nov 21, 2018
2eba830
docs: add docs for previewQrCodeService in `PublicApi.md`
Fatme Nov 21, 2018
384df58
chore: remove unneeded empty lines
Fatme Nov 22, 2018
52d7a4f
Merge pull request #4168 from NativeScript/fatme/public-api
Nov 22, 2018
3bc3814
Merge pull request #4167 from NativeScript/fatme/preview-app-livesync…
Nov 22, 2018
91f9b8f
fix: execute correctly local build after cloud build from sidekick
Fatme Nov 27, 2018
252d701
Merge pull request #4175 from NativeScript/fatme/fix-local-build-afte…
Nov 27, 2018
c3e2950
chore: changelog for 5.0.2 release
Fatme Nov 29, 2018
e470e25
Merge pull request #4184 from NativeScript/fatme/changelog-5.0.2
Nov 29, 2018
6e280c4
Retry sporadically stuck requests/responses
TsvetanMilanov Nov 29, 2018
d1162f5
fix: update nativescript-preview-sdk version to 0.3.1 and cli's versi…
Fatme Nov 30, 2018
1242a7b
Cleanup the timers and intervals in the http-client when the process …
TsvetanMilanov Nov 30, 2018
9609814
Cleanup the req/res streams
TsvetanMilanov Nov 30, 2018
66862e1
Merge pull request #4187 from NativeScript/milanov/retry-stuck-http-reqs
TsvetanMilanov Nov 30, 2018
442ac7c
Merge pull request #4189 from NativeScript/fatme/release-5.0.3
Dec 3, 2018
9da376b
chore: add changelog for 5.0.3 release
Fatme Dec 4, 2018
c8f1ee9
Merge pull request #4196 from NativeScript/fatme/changelog-5.0.3
Dec 4, 2018
94b1f9a
Merge 'origin/release' into master
rosen-vladimirov Dec 5, 2018
6871814
chore: fix unit test
Fatme Dec 5, 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
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
NativeScript CLI Changelog
================
5.0.3 (2018, December 4)
==
### Fixed
* [Fixed #4186](https://github.com/NativeScript/nativescript-cli/issues/4186): Fix stuck http requests/responses
* [Fixed #4189](https://github.com/NativeScript/nativescript-cli/pull/4189): API: Fix "Cannot read property 'removeListener' of undefined" error on second stop of livesync to preview app


5.0.2 (2018, November 29)
==
### Implemented
* [Implemented #4167](https://github.com/NativeScript/nativescript-cli/pull/4167): API: Expose previewAppLiveSyncError event when some error is thrown while livesyncing to preview app

### Fixed
* [Fixed #3962](https://github.com/NativeScript/nativescript-cli/issues/3962): If command 'tns plugin create .. ' failed , directory with plugin repository name must be deleted
* [Fixed #4053](https://github.com/NativeScript/nativescript-cli/issues/4053): Update Nativescript cli setup scripts to use android sdk 28
* [Fixed #4077](https://github.com/NativeScript/nativescript-cli/issues/4077): Platform add with framework path and custom version breaks run with "--bundle"
* [Fixed #4129](https://github.com/NativeScript/nativescript-cli/issues/4129): tns preview doesn't sync changes when download 2 Playground projects
* [Fixed #4135](https://github.com/NativeScript/nativescript-cli/issues/4135): Too many TypeScript "Watching for file changes" messages in console during build
* [Fixed #4158](https://github.com/NativeScript/nativescript-cli/pull/4158): API: reset devices list when stopLiveSync method is called
* [Fixed #4161](https://github.com/NativeScript/nativescript-cli/pull/4161): API: raise deviceLost event after timeout of 5 seconds


5.0.1 (2018, November 14)
==
Expand Down
78 changes: 78 additions & 0 deletions PublicAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const tns = require("nativescript");
* [debug](#debug)
* [liveSyncService](#livesyncservice)
* [liveSync](#livesync)
* [liveSyncToPreviewApp](#livesynctopreviewapp)
* [stopLiveSync](#stopLiveSync)
* [enableDebugging](#enableDebugging)
* [attachDebugger](#attachDebugger)
Expand All @@ -59,6 +60,12 @@ const tns = require("nativescript");
* [startEmulator](#startemulator)
* [deviceEmitter](#deviceemitter)
* [events](#deviceemitterevents)
* [previewDevicesService](#previewdevicesservice)
* [deviceFound](#devicefound)
* [deviceLost](#devicelost)
* [deviceLog](#devicelog)
* [previewQrCodeService](#previewqrcodeservice)
* [getPlaygroundAppQrCode](#getplaygroundappqrcode)

## Module projectService

Expand Down Expand Up @@ -779,6 +786,33 @@ tns.liveSyncService.liveSync([ androidDeviceDescriptor, iOSDeviceDescriptor ], l
});
```

### liveSyncToPreviewApp
Starts a LiveSync operation to the Preview app. After scanning the QR code with the scanner provided in the NativeScript Playground app, the app will be launched on a device through the Preview app. Additionally, any changes made to the project will be automatically synchronized with the deployed app.

* Definition
```TypeScript
/**
* Starts LiveSync operation by producting a QR code and starting watcher.
* @param {IPreviewAppLiveSyncData} liveSyncData Describes the LiveSync operation - for which project directory is the operation and other settings.
* @returns {Promise<IQrCodeImageData>}
*/
liveSyncToPreviewApp(liveSyncData: IPreviewAppLiveSyncData): Promise<IQrCodeImageData>;
```

* Usage:
```JavaScript
const liveSyncData = {
projectDir,
bundle: false,
useHotModuleReload: false,
env: { }
};
tns.liveSyncService.liveSyncToPreviewApp(liveSyncData)
.then(qrCodeImageData => {
console.log("The qrCodeImageData is: " + qrCodeImageData);
});
```

### stopLiveSync
Stops LiveSync operation. In case deviceIdentifires are passed, the operation will be stopped only for these devices.

Expand Down Expand Up @@ -1352,6 +1386,50 @@ tns.deviceEmitter.on("emulatorImageLost", (emulatorImageInfo) => {
```
`emulatorImageInfo` is of type [Moble.IDeviceInfo](https://github.com/telerik/mobile-cli-lib/blob/61cdaaaf7533394afbbe84dd4eee355072ade2de/definitions/mobile.d.ts#L9-L86).

## previewDevicesService
The `previewDevicesService` module allows interaction with preview devices. You can get a list of the connected preview devices and logs from specified device.

### previewDevicesEmitterEvents

* `deviceFound` - Raised when the QR code is scanned with any device. The callback function will receive one argument - `device`.
Sample usage:
```JavaScript
tns.previewDevicesService.on("deviceFound", device => {
console.log("Attached device with identifier: " + device.id);
});
```

* `deviceLost` - Raised when the Preview app is stopped on a specified device. The callback function will receive one argument - `device`.
Sample usage:
```JavaScript
tns.previewDevicesService.on("deviceLost", device => {
console.log("Detached device with identifier: " + device.id);
});
```

* `deviceLog` - Raised when the app deployed in Preview app reports any information. The event is raised for any device that reports data. The callback function has two arguments - `device` and `message`. <br/><br/>
Sample usage:
```JavaScript
tns.previewDevicesService.on("deviceLogData", (device, message) => {
console.log("Device " + device.id + " reports: " + message);
});
```

## previewQrCodeService
The `previewQrCodeService` exposes methods for getting information about the QR of the Playground app and deployed app in Preview app.

### getPlaygroundAppQrCode
Returns information used to generate the QR code of the Playground app.

* Usage:
```TypeScript
tns.previewQrCodeService.getPlaygroundAppQrCode()
.then(result => {
console.log("QR code data for iOS platform: " + result.ios);
console.log("QR code data for Android platform: " + result.android);
});
```

## How to add a new method to Public API
CLI is designed as command line tool and when it is used as a library, it does not give you access to all of the methods. This is mainly implementation detail. Most of the CLI's code is created to work in command line, not as a library, so before adding method to public API, most probably it will require some modification.
For example the `$options` injected module contains information about all `--` options passed on the terminal. When the CLI is used as a library, the options are not populated. Before adding method to public API, make sure its implementation does not rely on `$options`.
Expand Down
23 changes: 16 additions & 7 deletions lib/commands/plugin/create-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export class CreatePluginCommand implements ICommand {
public allowedParameters: ICommandParameter[] = [];
public userMessage = "What is your GitHub username?\n(will be used to update the Github URLs in the plugin's package.json)";
public nameMessage = "What will be the name of your plugin?\n(use lowercase characters and dashes only)";
public pathAlreadyExistsMessageTemplate = "Path already exists and is not empty %s";
constructor(private $options: IOptions,
private $errors: IErrors,
private $terminalSpinnerService: ITerminalSpinnerService,
Expand All @@ -22,8 +23,17 @@ export class CreatePluginCommand implements ICommand {
const selectedPath = path.resolve(pathToProject || ".");
const projectDir = path.join(selectedPath, pluginRepoName);

await this.downloadPackage(selectedTemplate, projectDir);
await this.setupSeed(projectDir, pluginRepoName);
// Must be out of try catch block, because will throw error if folder alredy exists and we don't want to delete it.
this.ensurePackageDir(projectDir);

try {
await this.downloadPackage(selectedTemplate, projectDir);
await this.setupSeed(projectDir, pluginRepoName);
} catch (err) {
// The call to this.ensurePackageDir() above will throw error if folder alredy exists, so it is safe to delete here.
this.$fs.deleteDirectory(projectDir);
throw err;
}

this.$logger.printMarkdown("Solution for `%s` was successfully created.", pluginRepoName);
}
Expand Down Expand Up @@ -66,13 +76,15 @@ export class CreatePluginCommand implements ICommand {
}
}

private async downloadPackage(selectedTemplate: string, projectDir: string): Promise<void> {
private ensurePackageDir(projectDir: string): void {
this.$fs.createDirectory(projectDir);

if (this.$fs.exists(projectDir) && !this.$fs.isEmptyDir(projectDir)) {
this.$errors.fail("Path already exists and is not empty %s", projectDir);
this.$errors.fail(this.pathAlreadyExistsMessageTemplate, projectDir);
}
}

private async downloadPackage(selectedTemplate: string, projectDir: string): Promise<void> {
if (selectedTemplate) {
this.$logger.printMarkdown("Make sure your custom template is compatible with the Plugin Seed at https://github.com/NativeScript/nativescript-plugin-seed/");
} else {
Expand All @@ -84,9 +96,6 @@ export class CreatePluginCommand implements ICommand {
try {
spinner.start();
await this.$pacoteService.extractPackage(packageToInstall, projectDir);
} catch (err) {
this.$fs.deleteDirectory(projectDir);
throw err;
} finally {
spinner.stop();
}
Expand Down
4 changes: 3 additions & 1 deletion lib/common/declarations.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,10 @@ declare module Server {
interface IRequestResponseData {
statusCode: number;
headers: { [index: string]: any };
complete: boolean;
pipe(destination: any, options?: { end?: boolean; }): IRequestResponseData;
on(event: string, listener: Function): void;
destroy(error?: Error): void;
}
}

Expand Down Expand Up @@ -744,7 +746,7 @@ interface IAnalyticsSettingsService {
* Gets information for projects that are exported from playground
* @param projectDir Project directory path
*/
getPlaygroundInfo(projectDir?: string): Promise<IPlaygroundInfo>;
getPlaygroundInfo(projectDir?: string): Promise<IPlaygroundInfo>;
}

/**
Expand Down
Loading