-
-
Notifications
You must be signed in to change notification settings - Fork 197
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
Playground #3853
Conversation
DimitarTachev
left a comment
There was a problem hiding this 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 |
There was a problem hiding this comment.
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!!!"); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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!!"); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?
e88c5e4 to
349c445
Compare
|
run ci |
lib/commands/command-base.ts
Outdated
| @@ -0,0 +1,34 @@ | |||
| export abstract class CommandBase implements ICommandBase { | |||
There was a problem hiding this comment.
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
| */ | ||
| timeout: string; | ||
|
|
||
| syncToPreviewApp?: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JSDocs here
lib/definitions/livesync.d.ts
Outdated
| * @returns {string} The build output directory. | ||
| */ | ||
| getOutputDirectory?(options: IOutputDirectoryOptions): string; | ||
| syncToPreviewApp?: boolean; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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'); |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.`));1ecdfdc to
0310ef0
Compare
41ba075 to
0310ef0
Compare
`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.
a61d739 to
f847c8b
Compare
…r sync to preview app
…y configured and "Sync to Playground" option is selected
…IValidatePlatformOutput
… and "Sync to Playground" option is selected
Fix "cannot read property .toLowerCase of undefined" error
…endencies and show warnings
…ipt-dev-webpack plugin
f847c8b to
b7d42d7
Compare
|
run ci |
`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.
`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.
PR Checklist
Implements: #3813
Rel: NativeScript/nativescript-dev-webpack#649