Skip to content

Playground #3853

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
Sep 14, 2018
Merged

Playground #3853

merged 43 commits into from
Sep 14, 2018

Conversation

Fatme
Copy link
Contributor

@Fatme Fatme commented Aug 30, 2018

PR Checklist

Implements: #3813
Rel: NativeScript/nativescript-dev-webpack#649

@Fatme Fatme changed the title Feature/playground Playground Aug 30, 2018
Copy link
Contributor

@DimitarTachev DimitarTachev left a comment

Choose a reason for hiding this comment

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

Nice tests!

event: PreviewSdkEventNames.CHANGE_EVENT_NAME,
file: path.relative(platformsAppFolderPath, file),
fileContents: this.$fs.readText(file),
binary: false
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we should pass true for the images here

this.$logger.info(`LOG from device ${deviceName}: ${log}`);
},
onRestartMessage: () => {
console.log("ON RESTART MESSAGE!!!");
Copy link
Contributor

Choose a reason for hiding this comment

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

remove

private getCallbacks(): SdkCallbacks {
return {
onLogSdkMessage: (log: string) => {
this.$logger.trace("onLogSdkMessage!!!", log);
Copy link
Contributor

Choose a reason for hiding this comment

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

set a better message here

console.log("ON RESTART MESSAGE!!!");
},
onUncaughtErrorMessage: () => {
this.$errors.failWithoutHelp("UncaughtErrorMessage while preview app!!");
Copy link
Contributor

Choose a reason for hiding this comment

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

we could also think about a better message here

try {
qrcode.generate(url);
} catch (err) {
this.$logger.trace(`Failed to generate QR code for ${url}`, err);
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe this should be info?

@Fatme Fatme added this to the 5.0.0 milestone Sep 3, 2018
@Fatme
Copy link
Contributor Author

Fatme commented Sep 4, 2018

run ci

@@ -0,0 +1,34 @@
export abstract class CommandBase implements ICommandBase {
Copy link
Contributor

Choose a reason for hiding this comment

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

You can rename this to ValidatePlatformCommandBase and do not implement ICommandBase

@@ -165,6 +165,8 @@ interface ILiveSyncInfo extends IProjectDir, IEnvOptions, IBundle, IRelease, IOp
* If not provided, defaults to 10seconds.
*/
timeout: string;

syncToPreviewApp?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

JSDocs here

@@ -524,6 +526,7 @@ interface ILiveSyncCommandHelperAdditionalOptions extends IBuildPlatformAction,
* @returns {string} The build output directory.
*/
getOutputDirectory?(options: IOutputDirectoryOptions): string;
syncToPreviewApp?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

You can extract an interface:

interface IHasSyncToPreviewAppOption {
    syncToPreviewApp?: boolean;
}

And extend both ILiveSyncCommandHelperAdditionalOptions and ILiveSyncInfo interfaces

}

public async canExecute(args: string[]): Promise<boolean> {
return true;
Copy link
Contributor

Choose a reason for hiding this comment

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

this will allow the execution of the command even if you write tns preview someargs. In case the command does not accept args, just remove the canExecute method


if (filePayload.binary) {
const bitmap = <string>this.$fs.readFile(file);
const base64 = new Buffer(bitmap).toString('base64');
Copy link
Contributor

Choose a reason for hiding this comment

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

new Buffer is deprecated, we should use Buffer.from or maybe this.$fs.readFile(file, { encoding: "base64" })


private showWarningsForNativeFiles(files: string[]): void {
if (files && files.length) {
for (const file of files) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of using if and for, you can use _.each - it handles cases where even undefined is passed

Copy link
Contributor

Choose a reason for hiding this comment

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

Or you can do:

_.filter(files, file => file.indexOf(APP_RESOURCES_FOLDER_NAME) > -1)
   .forEach(file => this.$logger.warn(`Unable to apply changes from ${APP_RESOURCES_FOLDER_NAME} folder. You need to build your application in order to make changes in ${APP_RESOURCES_FOLDER_NAME} folder.`));

@Fatme Fatme force-pushed the feature/playground branch 2 times, most recently from 1ecdfdc to 0310ef0 Compare September 12, 2018 09:49
sis0k0 pushed a commit to NativeScript/nativescript-dev-webpack that referenced this pull request Sep 13, 2018
`tns preview` command works without platform argument, so {N} CLI needs to start iOS webpack process when QR code is scanned with iOS device and android webpack process when QR code is scanned with Android device. Actually we need to have two separate webpack processes simultaneously. In order to do that we need to persist webpack process per platform.

When `tns preview --bundle` command is executed and QR code is scanned for example with Android device, {N} CLI starts a webpack process in watch mode for Android platform. If the webpack process for Android is already started, {N} CLI doesn't do anything. In order to archive the above things, a new hook is introduced - "before-preview-sync". This hook is used only from `tns preview` command.

## PR Checklist

- [x] The PR title follows our guidelines: https://github.com/NativeScript/NativeScript/blob/master/CONTRIBUTING.md#commit-messages.
- [ ] There is an issue for the bug/feature this PR is for. To avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it.
- [ ] You have signed the [CLA].
- [ ] All existing tests are passing: https://github.com/NativeScript/nativescript-dev-webpack/blob/master/CONTRIBUTING.md#testing-locally-by-running-e2e-tests
- [ ] Tests for the changes are included.

## What is the current behavior?
When `tns run --bundle` command is executed, the following error message is shown: "Bundling doesn't work with multiple platforms. Please specify platform to the run command."

## What is the new behavior?
When `tns run --bundle` command is executed and for example the user has connected both iOS and Android devices, two webpack processes are started (one for Android and one for iOS). When the user makes some change in code, the changes are applied both on iOS and Android devices.
NOTE: When a platform specific file is changed - for example `myfile.ios.js` only iOS webpack is started and the changes are applied only on iOS devices.
When for example some iOS device is disconnected, we check if there are more connected iOS devices. If no more iOS devices are connected, we stopped the webpack process for iOS platform. We did it by adding an event handler for "liveSyncStopped" event.

Implements: #457
Rel: NativeScript/nativescript-cli#3853
 
BREAKING CHANGES:
The breaking changes are only for commands for which no platform argument is provided.
@Fatme Fatme force-pushed the feature/playground branch from a61d739 to f847c8b Compare September 14, 2018 08:10
@Fatme Fatme force-pushed the feature/playground branch from f847c8b to b7d42d7 Compare September 14, 2018 08:14
@miroslavaivanova
Copy link
Contributor

run ci

@Fatme Fatme merged commit 3a783e1 into master Sep 14, 2018
@Fatme Fatme deleted the feature/playground branch September 14, 2018 12:16
sis0k0 pushed a commit to NativeScript/nativescript-dev-webpack that referenced this pull request Sep 27, 2018
`tns preview` command works without platform argument, so {N} CLI needs to start iOS webpack process when QR code is scanned with iOS device and android webpack process when QR code is scanned with Android device. Actually we need to have two separate webpack processes simultaneously. In order to do that we need to persist webpack process per platform.

When `tns preview --bundle` command is executed and QR code is scanned for example with Android device, {N} CLI starts a webpack process in watch mode for Android platform. If the webpack process for Android is already started, {N} CLI doesn't do anything. In order to archive the above things, a new hook is introduced - "before-preview-sync". This hook is used only from `tns preview` command.

## PR Checklist

- [x] The PR title follows our guidelines: https://github.com/NativeScript/NativeScript/blob/master/CONTRIBUTING.md#commit-messages.
- [ ] There is an issue for the bug/feature this PR is for. To avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it.
- [ ] You have signed the [CLA].
- [ ] All existing tests are passing: https://github.com/NativeScript/nativescript-dev-webpack/blob/master/CONTRIBUTING.md#testing-locally-by-running-e2e-tests
- [ ] Tests for the changes are included.

## What is the current behavior?
When `tns run --bundle` command is executed, the following error message is shown: "Bundling doesn't work with multiple platforms. Please specify platform to the run command."

## What is the new behavior?
When `tns run --bundle` command is executed and for example the user has connected both iOS and Android devices, two webpack processes are started (one for Android and one for iOS). When the user makes some change in code, the changes are applied both on iOS and Android devices.
NOTE: When a platform specific file is changed - for example `myfile.ios.js` only iOS webpack is started and the changes are applied only on iOS devices.
When for example some iOS device is disconnected, we check if there are more connected iOS devices. If no more iOS devices are connected, we stopped the webpack process for iOS platform. We did it by adding an event handler for "liveSyncStopped" event.

Implements: #457
Rel: NativeScript/nativescript-cli#3853
 
BREAKING CHANGES:
The breaking changes are only for commands for which no platform argument is provided.
sis0k0 pushed a commit to NativeScript/nativescript-dev-webpack that referenced this pull request Sep 28, 2018
`tns preview` command works without platform argument, so {N} CLI needs to start iOS webpack process when QR code is scanned with iOS device and android webpack process when QR code is scanned with Android device. Actually we need to have two separate webpack processes simultaneously. In order to do that we need to persist webpack process per platform.

When `tns preview --bundle` command is executed and QR code is scanned for example with Android device, {N} CLI starts a webpack process in watch mode for Android platform. If the webpack process for Android is already started, {N} CLI doesn't do anything. In order to archive the above things, a new hook is introduced - "before-preview-sync". This hook is used only from `tns preview` command.

## PR Checklist

- [x] The PR title follows our guidelines: https://github.com/NativeScript/NativeScript/blob/master/CONTRIBUTING.md#commit-messages.
- [ ] There is an issue for the bug/feature this PR is for. To avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it.
- [ ] You have signed the [CLA].
- [ ] All existing tests are passing: https://github.com/NativeScript/nativescript-dev-webpack/blob/master/CONTRIBUTING.md#testing-locally-by-running-e2e-tests
- [ ] Tests for the changes are included.

## What is the current behavior?
When `tns run --bundle` command is executed, the following error message is shown: "Bundling doesn't work with multiple platforms. Please specify platform to the run command."

## What is the new behavior?
When `tns run --bundle` command is executed and for example the user has connected both iOS and Android devices, two webpack processes are started (one for Android and one for iOS). When the user makes some change in code, the changes are applied both on iOS and Android devices.
NOTE: When a platform specific file is changed - for example `myfile.ios.js` only iOS webpack is started and the changes are applied only on iOS devices.
When for example some iOS device is disconnected, we check if there are more connected iOS devices. If no more iOS devices are connected, we stopped the webpack process for iOS platform. We did it by adding an event handler for "liveSyncStopped" event.

Implements: #457
Rel: NativeScript/nativescript-cli#3853
 
BREAKING CHANGES:
The breaking changes are only for commands for which no platform argument is provided.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants