diff --git a/CHANGELOG.md b/CHANGELOG.md index dbbeea8c5f..59a079ef84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,84 @@ NativeScript CLI Changelog ================ +6.0.2 (2019, July 22) +== +* [Fixed #4885](https://github.com/NativeScript/nativescript-cli/issues/4885): `migrate` and `update` commands are failing where everything is up-to-date +* [Fixed #4887](https://github.com/NativeScript/nativescript-cli/pull/4887): Include forgotten Angular dependency from the code-sharing apps +* [Fixed #4888](https://github.com/NativeScript/nativescript-cli/pull/4888): Sidekick: multiple errors in Sidekick + +6.0.1 (2019, July 18) +== +* [Fixed #4814](https://github.com/NativeScript/nativescript-cli/issues/4814): Missing `yargs-parser` dependency +* [Fixed #4846](https://github.com/NativeScript/nativescript-cli/issues/4846): Xcode running on devices crashes with error `Unable to create file *.hot-update.json` +* [Fixed #4871](https://github.com/NativeScript/nativescript-cli/pull/4871): Issues when stopping the LiveSync process +* [Fixed #4872](https://github.com/NativeScript/nativescript-cli/pull/4872): Sidekick: debug operation fails on iOS when Developer Disk Image is not installed on device +* [Fixed #4873](https://github.com/NativeScript/nativescript-cli/issues/4873): `tns migrate` should update `nativescript-vue-template-compiler` +* [Fixed #4874](https://github.com/NativeScript/nativescript-cli/issues/4874): After `tns migrate` preview/build/run commands fail with `ERROR in The Angular Compiler requires TypeScript >=3.1.1 and <3.3.0 but 3.4.5 was found instead.` +* [Fixed #4876](https://github.com/NativeScript/nativescript-cli/issues/4876):`tns migrate` does not update @ngtools/webpack +* [Fixed #4878](https://github.com/NativeScript/nativescript-cli/issues/4878): `tns migrate` does not update @angular/animations +* [Fixed #4879](https://github.com/NativeScript/nativescript-cli/issues/4879): `--platform-template` option is still shown in CLI's help + +6.0.0 (2019, July 17) +== + +### Breaking changes + +* Applications can be build only with bundle workflow - in previous versions there were two ways to build your application - `bundle` and `legacy` workflow. With this release CLI allows building your app only in case you are using the bundle workflow. More information is available [in this blopost](https://www.nativescript.org/blog/the-future-of-building-nativescript-apps) +* With older CLI versions you were able to run `tns debug android` and continue debugging after the command exits. In this release, when CLI exits, it clears all used resources, so you will not be able to continue the debug session. More information is available in [this issue](https://github.com/NativeScript/nativescript-cli/issues/4219) for more information. +* `--syncAllFiles` option is not supported anymore - this option was added to force CLI to watch all files in `node_modules`. In 6.0 this is the default and only behavior - webpack watches all required files and CLI watches the `platforms` directories and `package.json` files of the plugins added as dependencies of the application. +* Drop support for Xcode versions below 10 - new features for iOS require the latest Xcode versions, so we decided to require at least Xcode 10 for building the applications +* Drop support for Node.js below 8 - Node.js 8 does not support [these version anymore](https://github.com/nodejs/Release) and so does our CLI. In case you are using such Node.js version, CLI will not allow you to execute any command, so you should upgrade to latest LTS version. +* `--platformTemplate` option has been deleted. More information can be found in [this issue](https://github.com/NativeScript/nativescript-cli/issues/4867). +* `tns init` command has been deleted +* `tns clean app` command has been deleted +* Improved plugin development workflow may require changes in your daily work when creating plugins. More information can be found in [this issue](https://github.com/NativeScript/nativescript-cli/issues/4865) +* When you pass `--release`, CLI will switch webpack in production mode. More information can be found in [this issue](https://github.com/NativeScript/nativescript-cli/issues/4497) +* CLI now forces sourceMap generation by default when building in debug mode. You can disable them by passing `--env.sourceMap false`. souceMaps are disabled by default in release builds, you can enable them by passing `--env.sourceMap`. + +### New +* [Implemented #2368](https://github.com/NativeScript/nativescript-cli/issues/2368): Compiling in other path (dist), no in same path (src/app) +* [Implemented #2417](https://github.com/NativeScript/nativescript-cli/issues/2417): Show TypeScript line numbers in stack traces +* [Implemented #2776](https://github.com/NativeScript/nativescript-cli/issues/2776): Add ability to ignore files from final package when build in release +* [Implemented #3378](https://github.com/NativeScript/nativescript-cli/issues/3378): Running app with locally installed plugin should transpile the plugin's TypeScript files +* [Implemented #4497](https://github.com/NativeScript/nativescript-cli/issues/4497): Ability to detect within webpack if app is being built for release +* [Implemented #4604](https://github.com/NativeScript/nativescript-cli/issues/4604): Logs and errors from devices always point to bundle/vendor files +* [Implemented #4646](https://github.com/NativeScript/nativescript-cli/issues/4646): Introduce command (`tns migrate`) to migrate old project to 6.0.0 requirements +* [Implemented #4648](https://github.com/NativeScript/nativescript-cli/issues/4648): Drop support for Node.js < 8 +* [Implemented #4649](https://github.com/NativeScript/nativescript-cli/issues/4649): Deprecate support for Node.js < 10 +* [Implemented #4650](https://github.com/NativeScript/nativescript-cli/issues/4650): Add official support for Node.js 12 +* [Implemented #4651](https://github.com/NativeScript/nativescript-cli/issues/4651): Add drawer navigation prompt when vue flavor is selected on `tns create` +* [Implemented #4667](https://github.com/NativeScript/nativescript-cli/issues/4667): Support yarn hoisted packages in a workspace context +* [Implemented #4692](https://github.com/NativeScript/nativescript-cli/issues/4692): CLI should watch package.json files in the application +* [Implemented #4731](https://github.com/NativeScript/nativescript-cli/issues/4731): Drop support for Xcode < 10 +* [Implemented #4863](https://github.com/NativeScript/nativescript-cli/issues/4863): Delete `tns init` command +* [Implemented #4863](https://github.com/NativeScript/nativescript-cli/issues/4863): Delete `tns clean app` command +* [Implemented #4865](https://github.com/NativeScript/nativescript-cli/issues/4865): Improve plugin development workflow +* [Implemented #4867](https://github.com/NativeScript/nativescript-cli/issues/4867): Delete `--platformTemplate` option + +### Fixed +* [Fixed #2739](https://github.com/NativeScript/nativescript-cli/issues/2739): Unit test runner do not work in --watch mode +* [Fixed #2963](https://github.com/NativeScript/nativescript-cli/issues/2963): Confusing messages on preparing plugin +* [Fixed #3028](https://github.com/NativeScript/nativescript-cli/issues/3028): Local dependency brakes build +* [Fixed #3146](https://github.com/NativeScript/nativescript-cli/issues/3146): `tns run ios` shows "No reachable hosts" after running unit tests +* [Fixed #3351](https://github.com/NativeScript/nativescript-cli/issues/3351): If you delete the whole css data or the css file itself the changes are not going to be applied to the app +* [Fixed #3546](https://github.com/NativeScript/nativescript-cli/issues/3546): Your project have installed babel-traverse version null but Android platform requires version ^6.4.5 +* [Fixed #3568](https://github.com/NativeScript/nativescript-cli/issues/3568): EXPORT FAILED fse.node has conflicting provisioning settings +* [Fixed #3630](https://github.com/NativeScript/nativescript-cli/issues/3630): cp: copyFileSync: could not write to dest file (code=EPERM) +* [Fixed #3767](https://github.com/NativeScript/nativescript-cli/issues/3767): Exception when delete a file from `/platforms/android` +* [Fixed #3849](https://github.com/NativeScript/nativescript-cli/issues/3849): The livesync check if a file has modifications doesn't work as expected +* [Fixed #4219](https://github.com/NativeScript/nativescript-cli/issues/4219): Android debugging is leaking the debug session +* [Fixed #4239](https://github.com/NativeScript/nativescript-cli/issues/4239): Copy `App_Resources` directly to `platforms/.../res` (Android) or `platforms/.../Resources` (iOS) instead of copying them with Webpack +* [Fixed #4264 ](https://github.com/NativeScript/nativescript-cli/issues/4264 ): When using `--syncAllFiles` on Android frequently crashes with error +* [Fixed #4480](https://github.com/NativeScript/nativescript-cli/issues/4480): [TypeScript & Vue project] When using `--bundle` changes made to a platform specific file in `node_modules` does not start a new build process +* [Fixed #4500](https://github.com/NativeScript/nativescript-cli/issues/4500): Changes to `.js` files located in `node_modules` causes the `livesync` to take upto 30 sec +* [Fixed #4513](https://github.com/NativeScript/nativescript-cli/issues/4513): Error when building for Android and using `bcryptjs` +* [Fixed #4607](https://github.com/NativeScript/nativescript-cli/issues/4607): Image replacement is not respected during tns run with hmr +* [Fixed #4647](https://github.com/NativeScript/nativescript-cli/issues/4647): CLI's checkForChanges method should not check all `node_modules` +* [Fixed #4658](https://github.com/NativeScript/nativescript-cli/issues/4658): [iOS] tns preview is including tns-core-modules in vendor.js +* [Fixed #4770](https://github.com/NativeScript/nativescript-cli/issues/4770): Incorrect execution of hooks where there is unresolved injected dependency + + 5.4.2 (2019, June 19) == diff --git a/docs/man_pages/general/migrate.md b/docs/man_pages/general/migrate.md index b33a19f87a..fb8ca8e235 100644 --- a/docs/man_pages/general/migrate.md +++ b/docs/man_pages/general/migrate.md @@ -15,7 +15,7 @@ The following folders will be removed: **"hooks"**, **"platforms"** and **"node_ The **"nativescript-dev-sass"** and **"nativescript-dev-typescript"** dependencies will be replaced with **"node-sass"** and **"typescript"** respectively. The **"nativescript-dev-less"** dependency will be removed, but to enable LESS CSS support the user should follow the steps in this<% if(isConsole) { %> feature request: https://github.com/NativeScript/nativescript-dev-webpack/issues/967.<% } %><% if(isHtml) { %> [feature request](https://github.com/NativeScript/nativescript-dev-webpack/issues/967).<% } %> -The following dependencies will be updated if needed: +The following dependencies will be updated if needed: * tns-core-modules * tns-core-modules-widgets * tns-platform-declarations @@ -37,6 +37,22 @@ The following dependencies will be updated if needed: * kinvey-nativescript-sdk * nativescript-plugin-firebase * nativescript-vue +* nativescript-vue-template-compiler +* nativescript-angular +* @angular/animiations +* @angular/platform-browser-dynamic +* @angular/common +* @angular/compiler +* @angular/compiler-cli +* @angular/core +* @angular/forms +* @angular/http +* @angular/platform-browser +* @angular/router +* @ngtools/webpack +* @angular-devkit/build-angular +* rxjs +* zone.js * nativescript-unit-test-runner * karma-webpack * karma-jasmine diff --git a/docs/man_pages/index.md b/docs/man_pages/index.md index 0d86ade439..50996a387f 100644 --- a/docs/man_pages/index.md +++ b/docs/man_pages/index.md @@ -29,7 +29,6 @@ Command | Description ---|--- [create](project/creation/create.html) | Creates a new project for native development with NativeScript. [preview](project/testing/preview.html) | Generates a QR code that can be scanned by the NativeScript PlayGround app. -[init](project/creation/init.html) | Initializes an existing project for native development with NativeScript. [platform add ``](project/configuration/platform-add.html) | Configures the current project to target the selected platform. [platform list](project/configuration/platform.html) | Lists all platforms that the project currently targets. [platform remove ``](project/configuration/platform-remove.html) | Removes the selected platform from the platforms that the project currently targets. This operation deletes all platform-specific files and subdirectories from your project. diff --git a/docs/man_pages/lib-management/plugin-add.md b/docs/man_pages/lib-management/plugin-add.md index 400b8706ee..5aac7e8a0b 100644 --- a/docs/man_pages/lib-management/plugin-add.md +++ b/docs/man_pages/lib-management/plugin-add.md @@ -8,7 +8,7 @@ position: 1 ### Description <% if(isConsole) { %>Installs the specified plugin and any packages that it depends on.<% } %> -<% if(isHtml) { %>Installs the specified plugin and its dependencies in the local `node_modules` folder, adds it to the `dependencies` section in `package.json`, and prepares the plugin for all installed platforms. If you have not configured any platforms for the project, the NativeScript CLI will prepare the plugin when you add a platform. For more information about working with plugins, see [NativeScript Plugins](https://github.com/NativeScript/nativescript-cli/blob/master/PLUGINS.md).<% } %> +<% if(isHtml) { %>Installs the specified plugin and its dependencies in the local `node_modules` folder, adds it to the `dependencies` section in `package.json`, and prepares the plugin for all installed platforms. If you have not configured any platforms for the project, the NativeScript CLI will prepare the plugin when you add a platform.<% } %> ### Commands diff --git a/docs/man_pages/lib-management/plugin-create.md b/docs/man_pages/lib-management/plugin-create.md index b267887ade..d574329b1f 100644 --- a/docs/man_pages/lib-management/plugin-create.md +++ b/docs/man_pages/lib-management/plugin-create.md @@ -10,9 +10,12 @@ position: 1 Creates a new project for NativeScript plugin development. The project uses the [NativeScript Plugin Seed](https://github.com/NativeScript/nativescript-plugin-seed) as a base and contains the following directories: * `src` - source code of the plugin -* `demo` - simple NativeScript application used to test and show plugin features * `publish` - shell scripts used to build and pack the plugin source code and publish it in [NPM](https://www.npmjs.com/) +The command will also propose you to setup demo applications and if you accept them, it will create the following additional directories: +* `demo` - simple NativeScript application used to test and show plugin features +* `demo-angular` - simple Angular application used to test and show plugin features + The project is setup for easy commit in Github, which is why the command will ask you for your Github username. <% if(isHtml) { %>Before starting to code your first plugin, you can visit the NativeScript documentation page for [building plugins](https://docs.nativescript.org/plugins/building-plugins#step-2-set-up-a-development-workflow) or the [plugin seed repository](https://github.com/NativeScript/nativescript-plugin-seed/blob/master/README.md).<% } %> diff --git a/docs/man_pages/lib-management/plugin-remove.md b/docs/man_pages/lib-management/plugin-remove.md index b00e19e3bd..543e695878 100644 --- a/docs/man_pages/lib-management/plugin-remove.md +++ b/docs/man_pages/lib-management/plugin-remove.md @@ -8,7 +8,7 @@ position: 4 ### Description <% if(isConsole) { %>Uninstalls a plugin by its name.<% } %> -<% if(isHtml) { %>Removes the specified plugin and its dependencies from the local `node_modules` folder and the `dependencies` section in `package.json`. This operation does not remove the plugin from the installed platforms and you need to run `$ tns prepare` to finish uninstalling the plugin. For more information about working with plugins, see [NativeScript Plugins](https://github.com/NativeScript/nativescript-cli/blob/master/PLUGINS.md).<% } %> +<% if(isHtml) { %>Removes the specified plugin and its dependencies from the local `node_modules` folder and the `dependencies` section in `package.json`. This operation does not remove the plugin from the installed platforms and you need to run `$ tns prepare` to finish uninstalling the plugin.<% } %> ### Commands diff --git a/docs/man_pages/lib-management/plugin-update.md b/docs/man_pages/lib-management/plugin-update.md index 9ba3a5f9dc..05607ba5f5 100644 --- a/docs/man_pages/lib-management/plugin-update.md +++ b/docs/man_pages/lib-management/plugin-update.md @@ -8,7 +8,7 @@ position: 7 ### Description <% if(isConsole) { %>Uninstalls and installs the specified plugin(s) and any packages that it depends on.<% } %> -<% if(isHtml) { %>Uninstalls and installs the specified plugin(s) and its dependencies in the local `node_modules` folder, adds it to the `dependencies` section in `package.json`, and prepares the plugin(s) for all installed platforms. If you have not configured any platforms for the project, the NativeScript CLI will prepare the plugin(s) when you add a platform. For more information about working with plugins, see [NativeScript Plugins](https://github.com/NativeScript/nativescript-cli/blob/master/PLUGINS.md).<% } %> +<% if(isHtml) { %>Uninstalls and installs the specified plugin(s) and its dependencies in the local `node_modules` folder, adds it to the `dependencies` section in `package.json`, and prepares the plugin(s) for all installed platforms. If you have not configured any platforms for the project, the NativeScript CLI will prepare the plugin(s) when you add a platform.<% } %> ### Commands diff --git a/docs/man_pages/project/configuration/platform-add.md b/docs/man_pages/project/configuration/platform-add.md index fb5b23281c..08d68a6520 100644 --- a/docs/man_pages/project/configuration/platform-add.md +++ b/docs/man_pages/project/configuration/platform-add.md @@ -13,17 +13,14 @@ Configures the current project to target the selected platform. <% if(isHtml) { Usage | Synopsis ------|------- -Android latest runtime | `$ tns platform add android [--framework-path ] [--symlink] [--sdk ] [--platform-template ]` -Android selected runtime | `$ tns platform add android[@] [--framework-path ] [--symlink] [--sdk ] [--platform-template ]` -<% if (isMacOS) { %>iOS latest runtime | `$ tns platform add ios [--framework-path ] [--symlink]` -iOS selected runtime | `$ tns platform add ios[@] [--framework-path ] [--symlink] [--platform-template ]`<% } %> +Android latest runtime | `$ tns platform add android [--framework-path ]` +Android selected runtime | `$ tns platform add android[@] [--framework-path ] ` +<% if (isMacOS) { %>iOS latest runtime | `$ tns platform add ios [--framework-path ]` +iOS selected runtime | `$ tns platform add ios[@] [--framework-path ] `<% } %> ### Options -* `--framework-path` - Sets the path to a NativeScript runtime for the specified platform that you want to use instead of the default runtime. If `--symlink` is specified, `` is the complete path to a valid npm package or a directory that contains a NativeScript runtime for the selected platform and must point to directory in which the runtime is already extracted. If `--symlink` is not specified, `` must point to a valid npm package. -* `--symlink` - Creates a symlink to a NativeScript runtime for the specified platform that you want to use instead of the default runtime. If `--frameworkPath` is specified, creates a symlink to the specified directory. If `--frameworkPath` is not specified, creates a symlink to platform runtime installed with your current version of NativeScript. -* `--sdk` - Sets the target Android SDK for the project. `` is a valid Android API level. For example: 17, 19, MNC.<% if(isHtml) { %> For a complete list of the Android API levels and their corresponding Android versions, click [here](http://developer.android.com/guide/topics/manifest/uses-sdk-element.html#platform).<% } %> -* `--platform-template` - Sets the platform template that will be used for the native application. `` is a valid npm package, path to directory, .tgz or GitHub URL that contains a native Android or iOS template. +* `--framework-path` - Sets the path to a NativeScript runtime for the specified platform that you want to use instead of the default runtime. `` must point to a valid npm package. ### Arguments diff --git a/docs/man_pages/project/configuration/prepare.md b/docs/man_pages/project/configuration/prepare.md index 99f8efe46b..b68a662d79 100644 --- a/docs/man_pages/project/configuration/prepare.md +++ b/docs/man_pages/project/configuration/prepare.md @@ -7,8 +7,13 @@ position: 7 ### Description -Copies common and relevant platform-specific content from the `app` directory to the subdirectory for the selected target platform -in the `platforms` directory. This lets you build the project with the SDK for the selected platform. <% if(isMacOS) { %>You must specify the target platform for which you want to prepare your project.<% } %> +Starts a Webpack compilation and prepares the app's `App_Resources` and the plugins `platforms` directories. The output is generated in a subdirectory for the selected target platform in the `platforms` directory. This lets you build the project for the selected platform. <% if(isMacOS) { %>You must specify the target platform for which you want to prepare your project.<% } %> + +When running this command the HMR (Hot Module Replacement) is not enabled by default. In case you want to enable HMR, you can pass `--hmr` flag. + +<% if(isHtml) { %> +> NOTE: When passing `--release` CLI will disable HMR. +<% } %> ### Commands @@ -21,6 +26,11 @@ Usage | Synopsis * `android` - Prepares your project for an Android build. * `ios` - Prepares your project for an iOS build.<% } %> +### Options + +* `--hmr` - Enables the hot module replacement (HMR) feature. +* `--force` - If set, skips the application compatibility checks and forces `npm i` to ensure all dependencies are installed. Otherwise, the command will check the application compatibility with the current CLI version and could fail requiring `tns migrate`. + <% if(isHtml) { %> ### Command Limitations diff --git a/docs/man_pages/project/creation/create.md b/docs/man_pages/project/creation/create.md index 1bc0a7ecf9..1f920a84c7 100644 --- a/docs/man_pages/project/creation/create.md +++ b/docs/man_pages/project/creation/create.md @@ -58,6 +58,5 @@ Template | Command Command | Description ----------|---------- -[init](init.html) | Initializes a project for development. The command prompts you to provide your project configuration interactively and uses the information to create a new package.json file or update the existing one. [install](/lib-management/install.html) | Installs all platforms and dependencies described in the `package.json` file in the current directory. <% } %> diff --git a/docs/man_pages/project/testing/build-android.md b/docs/man_pages/project/testing/build-android.md index a68d6e2543..ad054ea51f 100644 --- a/docs/man_pages/project/testing/build-android.md +++ b/docs/man_pages/project/testing/build-android.md @@ -13,11 +13,11 @@ Builds the project for Android and produces an APK that you can manually deploy Usage | Synopsis ---|--- -General | `$ tns build android [--compileSdk ] [--key-store-path --key-store-password --key-store-alias --key-store-alias-password ] [--release] [--static-bindings] [--copy-to ] [--bundle [] [--env.*]] [--aab]` +General | `$ tns build android [--compileSdk ] [--key-store-path --key-store-password --key-store-alias --key-store-alias-password ] [--release] [--static-bindings] [--copy-to ] [--env.*]] [--aab]` ### Options -* `--compileSdk` - Sets the Android SDK that will be used to build the project. `` is a valid Android API level. For example: 22, 23.<% if(isHtml) { %> For a complete list of the Android API levels and their corresponding Android versions, click [here](http://developer.android.com/guide/topics/manifest/uses-sdk-element.html#platform).<% } %> +* `--compileSdk` - Sets the Android SDK that will be used to build the project. `` is a valid Android API level. For example: 28, 29. The minimum supported SDK is 28. <% if(isHtml) { %> For a complete list of the Android API levels and their corresponding Android versions, click [here](http://developer.android.com/guide/topics/manifest/uses-sdk-element.html#platform).<% } %> * `--clean` - If set, forces the complete rebuild of the native application. * `--release` - If set, produces a release build. Otherwise, produces a debug build. When set, you must also specify the `--key-store-*` options. * `--key-store-path` - Specifies the file path to the keystore file (P12) which you want to use to code sign your APK. You can use the `--key-store-*` options along with `--release` to produce a signed release build. You need to specify all `--key-store-*` options. @@ -25,7 +25,6 @@ General | `$ tns build android [--compileSdk ] [--key-store-path ] [--key-store-path diff --git a/docs/man_pages/project/testing/build-ios.md b/docs/man_pages/project/testing/build-ios.md index 6eeaa0f4f0..f782c96c97 100644 --- a/docs/man_pages/project/testing/build-ios.md +++ b/docs/man_pages/project/testing/build-ios.md @@ -17,7 +17,7 @@ Builds the project for iOS and produces an `APP` or `IPA` that you can manually Usage | Synopsis ---|--- -General | `$ tns build ios [--for-device] [--release] [--copy-to ] [--provision []] [--bundle [] [--env.*]]` +General | `$ tns build ios [--for-device] [--release] [--copy-to ] [--provision []] [--env.*]]` ### Options @@ -27,7 +27,6 @@ General | `$ tns build ios [--for-device] [--release] [--copy-to ] [- * `--copy-to` - Specifies the file path where the built `.ipa` will be copied. If it points to a non-existent directory path, it will be created. If the specified value is existing directory, the original file name will be used. * `--team-id` - If used without parameter, lists all team names and ids. If used with team name or id, it will switch to automatic signing mode and configure the .xcodeproj file of your app. In this case .xcconfig should not contain any provisioning/team id flags. This team id will be further used for codesigning the app. For Xcode 9.0+, xcodebuild will be allowed to update and modify automatically managed provisioning profiles. * `--provision` - If used without parameter, lists all eligible provisioning profiles. If used with UUID or name of your provisioning profile, it will switch to manual signing mode and configure the .xcodeproj file of your app. In this case xcconfig should not contain any provisioning/team id flags. This provisioning profile will be further used for codesigning the app. -* `--bundle` - Specifies that the `webpack` bundler will be used to bundle the application. * `--env.*` - Specifies additional flags that the bundler may process. May be passed multiple times. Supported additional flags: * `--env.aot` - creates Ahead-Of-Time build (Angular only). * `--env.snapshot`- creates [Snapshot](https://docs.nativescript.org/performance-optimizations/bundling-with-webpack#v8-heap-snapshot) (only for release builds on Mac OS & for Android). @@ -35,6 +34,7 @@ General | `$ tns build ios [--for-device] [--release] [--copy-to ] [- * `--env.report` - creates a Webpack report inside a `report` folder in the root folder. * `--env.sourceMap` - creates inline source maps (useful for debbuging bundled app). * `--env.hiddenSourceMap` - creates sources maps in the root folder (useful for Crashlytics usage with bundled app in release). +* `--force` - If set, skips the application compatibility checks and forces `npm i` to ensure all dependencies are installed. Otherwise, the command will check the application compatibility with the current CLI version and could fail requiring `tns migrate`. <% } %> diff --git a/docs/man_pages/project/testing/build.md b/docs/man_pages/project/testing/build.md index ca58867483..eada1e13b0 100644 --- a/docs/man_pages/project/testing/build.md +++ b/docs/man_pages/project/testing/build.md @@ -9,6 +9,12 @@ position: 3 Builds the project for Android <% if(isMacOS) { %>or iOS <% } %>and produces an application package that you can manually deploy on a device or native emulator. <% if(isMacOS) { %>You must specify the target platform for which you want to build your project.<% } %> +When running this command the HMR (Hot Module Replacement) is not enabled by default. In case you want to enable HMR, you can pass `--hmr` flag. + +<% if(isHtml) { %> +> NOTE: When passing `--release` CLI will disable HMR. +<% } %> + ### Commands Usage | Synopsis @@ -20,15 +26,12 @@ Usage | Synopsis * `android` - Build the project for Android and produces an `APK` that you can manually deploy on a device or in the native emulator. * `ios` - Build the project for iOS and produces an `APP` or `IPA` that you can manually deploy in the iOS Simulator or on a device.<% } %> -<% if(isHtml) { %> - ### Options * `--justlaunch` - If set, does not print the application output in the console. -* `--release` - If set, produces a release build. Otherwise, produces a debug build. +* `--release` -If set, produces a release build by running webpack in production mode and native build in release mode. Otherwise, produces a debug build. * `--device` - Specifies a connected device/emulator to start and run the app. `` is the index or `Device Identifier` of the target device as listed by the `$ tns device --available-devices` command. -* `--bundle` - Specifies that the `webpack` bundler will be used to bundle the application. -* `--hmr` - (Beta) Enables the hot module replacement (HMR) feature. HMR depends on `webpack` and adding the `--hmr` flag to the command will automatically enable the `--bundle` option as well. <% if(isConsole) { %> The HMR feature is currently in Beta. For more information about the current development state and any known issues, please check the relevant GitHub issue: https://github.com/NativeScript/NativeScript/issues/6398.<% } %> +* `--hmr` - Enables the hot module replacement (HMR) feature. * `--env.*` - Specifies additional flags that the bundler may process. May be passed multiple times. Supported additional flags: * `--env.aot` - creates Ahead-Of-Time build (Angular only). * `--env.snapshot`- creates [Snapshot](https://docs.nativescript.org/performance-optimizations/bundling-with-webpack#v8-heap-snapshot) (only for release builds on Mac OS & for Android). @@ -36,8 +39,9 @@ Usage | Synopsis * `--env.report` - creates a Webpack report inside a `report` folder in the root folder. * `--env.sourceMap` - creates inline source maps (useful for debbuging bundled app). * `--env.hiddenSourceMap` - creates sources maps in the root folder (useful for Crashlytics usage with bundled app in release). -* `--syncAllFiles` - Watches all production dependencies inside node_modules for changes. Triggers project rebuild if necessary! +* `--force` - If set, skips the application compatibility checks and forces `npm i` to ensure all dependencies are installed. Otherwise, the command will check the application compatibility with the current CLI version and could fail requiring `tns migrate`. +<% if(isHtml) { %> ### Related Commands diff --git a/docs/man_pages/project/testing/debug-android.md b/docs/man_pages/project/testing/debug-android.md index 2553e63ace..5aeae09a3d 100644 --- a/docs/man_pages/project/testing/debug-android.md +++ b/docs/man_pages/project/testing/debug-android.md @@ -9,8 +9,6 @@ position: 4 Initiates a debugging session for your project on a connected Android device or Android emulator. When necessary, the command will prepare, build, deploy and launch the app before starting the debug session. While debugging, the output from the application is printed in the console and any changes made to your code are synchronizes with the deployed app. -To enable Hot Module Replacement (HMR) in Angular projects, follow the steps outlined in [the HMR documentation section](https://docs.nativescript.org/performance-optimizations/bundling-with-webpack#hot-module-replacement). - ### Commands Usage | Synopsis @@ -30,14 +28,11 @@ Attach the debug tools to a running app in the native emulator | `$ tns debug an * `--timeout` - Sets the number of seconds that the NativeScript CLI will wait for the emulator/device to boot. If not set, the default timeout is 90 seconds. * `--no-watch` - If set, changes in your code will not be reflected during the execution of this command. * `--clean` - If set, forces the complete rebuild of the native application. -* `--bundle` - Specifies that the `webpack` bundler will be used to bundle the application. -* `--hmr` - Enables the hot module replacement (HMR) feature. HMR depends on `webpack` and adding the `--hmr` flag to the command will automatically enable the `--bundle` option as well.<% if(isConsole) { %> For more information about the current development state and any known issues, please check the relevant GitHub issue: https://github.com/NativeScript/NativeScript/issues/6398.<% } %> -* `--syncAllFiles` - Watches all production dependencies inside node_modules for changes. Triggers project rebuild if necessary! +* `--no-hmr` - Disables Hot Module Replacement (HMR). In this case, when a change in the code is applied, CLI will transfer the modified files and restart the application. +* `--force` - If set, skips the application compatibility checks and forces `npm i` to ensure all dependencies are installed. Otherwise, the command will check the application compatibility with the current CLI version and could fail requiring `tns migrate`. <% if(isHtml) { %> ->Note: For more information about HMR, the current development state and any known issues, please check the relevant GitHub issue: https://github.com/NativeScript/NativeScript/issues/6398. - ### Command Limitations * You must have Google Chrome installed on your machine. diff --git a/docs/man_pages/project/testing/debug-ios.md b/docs/man_pages/project/testing/debug-ios.md index 99efd2064e..0b1a8ffa0a 100644 --- a/docs/man_pages/project/testing/debug-ios.md +++ b/docs/man_pages/project/testing/debug-ios.md @@ -13,8 +13,6 @@ Initiates a debugging session for your project on a connected iOS device or in t <% if((isConsole && isMacOS) || isHtml) { %> <% if(isHtml) { %>> <% } %>IMPORTANT: Before building for iOS device, verify that you have configured a valid pair of certificate and provisioning profile on your macOS system. <% if(isHtml) { %>For more information, see the [Code Signing](https://developer.apple.com/support/code-signing/) and [Maintain Signing Assets](https://help.apple.com/xcode/mac/current/#/dev3a05256b8) sections from the Apple Developer documentation.<% } %> -To enable Hot Module Replacement (HMR) in Angular projects, follow the steps outlined in this wiki: https://github.com/NativeScript/nativescript-angular/wiki/HMR. - ### Commands Usage | Synopsis @@ -35,17 +33,14 @@ Attach the debug tools to a running app in the iOS simulator | `$ tns debug ios * `--timeout` - Sets the number of seconds that NativeScript CLI will wait to find the inspector socket port from device's logs. If not set, the default timeout is 10 seconds. * `--no-watch` - If set, changes in your code will not be reflected during the execution of this command. * `--clean` - If set, forces the complete rebuild of the native application. -* `--bundle` - Specifies that the `webpack` bundler will be used to bundle the application. -* `--hmr` - (Beta) Enables the hot module replacement (HMR) feature. HMR depends on `webpack` and adding the `--hmr` flag to the command will automatically enable the `--bundle` option as well. <% if(isConsole) { %> The HMR feature is currently in Beta. For more information about the current development state and any known issues, please check the relevant GitHub issue: https://github.com/NativeScript/NativeScript/issues/6398.<% } %> +* `--no-hmr` - Disables Hot Module Replacement (HMR). In this case, when a change in the code is applied, CLI will transfer the modified files and restart the application. * `--chrome` - Deprecated - default behavior uses '--chrome' implicitly. Allows debugging in Chrome Developer Tools. If set, Safari Web Inspector is not started and debugging is attached to Chrome Developer Tools. * `--inspector` - If set, the developer tools in the Safari Web Inspector are used for debugging the application. -* `--syncAllFiles` - Watches all production dependencies inside node_modules for changes. Triggers project rebuild if necessary! +* `--force` - If set, skips the application compatibility checks and forces `npm i` to ensure all dependencies are installed. Otherwise, the command will check the application compatibility with the current CLI version and could fail requiring `tns migrate`. <% } %> <% if(isHtml) { %> ->Note: Hot Module Replacement (HMR) is currently in Beta. For more information about the current development state and any known issues, please check the relevant GitHub issue: https://github.com/NativeScript/NativeScript/issues/6398. - ### Command Limitations * You can run `$ tns debug ios` only on macOS systems. diff --git a/docs/man_pages/project/testing/debug.md b/docs/man_pages/project/testing/debug.md index 40e1bb37d7..c37a49c4e6 100644 --- a/docs/man_pages/project/testing/debug.md +++ b/docs/man_pages/project/testing/debug.md @@ -9,6 +9,28 @@ position: 6 Initiates a debugging session for your project on a connected device or native emulator. <% if(isMacOS) { %>You must specify the target platform on which you want to debug.<% } %> When necessary, the command will prepare, build, deploy and launch the app before starting the debug session. While debugging, the output from the application is printed in the console and any changes made to your code are synchronized on all connected devices or running emulators. +<% if(isHtml) { %> +#### How file changes are handled +With HMR (Hot Module Replacement): +* Changes in `.js`, `.ts`, `.less`, `.sass` and other file types that are accepted will cause a refresh of the application. +* Changes in `App_Resources` will cause a rebuild of the application. +* Changes in any `package.json` file inside the project will cause a rebuild of the application. +* Changes in `node_modules/somePlugin` if accepted will cause a refresh of the application. +* Changes in `node_modules/somePlugin/platforms` will cause a rebuild of the application. +* Changes in `node_modules/somePlugin/package.json` file will cause a rebuild of the application. +* Changes that are not accepted and HMR fails will cause a restart of the native application. + +With **no** HMR: +* Changes in `.js`, `.ts`, `.less`, `.sass` and other file types will cause a restart of the native application. +* Changes in `App_Resources` will cause a rebuild of the application. +* Changes in any `package.json` file inside the project will cause a rebuild of the application. +* Changes in `node_modules/somePlugin` will cause a restart of the native application. +* Changes in `node_modules/somePlugin/platforms` will cause a rebuild of the application. +* Changes in `node_modules/somePlugin/package.json` file will cause a rebuild of the application. + +When running this command with `--debug-brk` any file change will cause a restart of the native application (HMR is disabled). Changes in `App_Resources` and `node_modules/somePlugin/platforms` will cause a rebuild of the application. +<% } %> + ### Commands Usage | Synopsis diff --git a/docs/man_pages/project/testing/preview.md b/docs/man_pages/project/testing/preview.md index 8ab4fa79dc..1d3a5268c8 100644 --- a/docs/man_pages/project/testing/preview.md +++ b/docs/man_pages/project/testing/preview.md @@ -15,8 +15,6 @@ To scan the QR code and deploy your app on a device, you need to have the Native After scanning the QR code with the scanner provided in the NativeScript Playground app, your app will be launched on your device through the Preview app. Additionally, any changes made to your project will be automatically synchronized with the deployed app. -To enable Hot Module Replacement (HMR) in Angular projects, follow the steps outlined in this wiki: https://github.com/NativeScript/nativescript-angular/wiki/HMR. - ### Commands Usage | Synopsis @@ -25,15 +23,11 @@ Generates a QR code that can be scanned by the NativeScript PlayGround app | `tn ### Options -* `--bundle` - (Beta) Specifies that the `webpack` bundler will be used to bundle the application.<% if(isConsole) { %> The support for webpack in preview is currently in Beta. Please, do not hesitate to report any problems that you experience with the feature by opening a new issue in the NativeScript CLI repository: https://github.com/NativeScript/nativescript-cli/issues/new/choose.<% } %> -* `--hmr` - (Beta) Enables the hot module replacement (HMR) feature. HMR depends on `webpack` and adding the `--hmr` flag to the command will automatically enable the `--bundle` option as well.<% if(isConsole) { %> The HMR feature is currently in Beta. For more information about the current development state and any known issues, please check the relevant GitHub issue: https://github.com/NativeScript/NativeScript/issues/6398.<% } %> +* `--no-hmr` - Disables Hot Module Replacement (HMR). In this case, when a change in the code is applied, CLI will transfer the modified files and restart the application. +* `--force` - If set, skips the application compatibility checks and forces `npm i` to ensure all dependencies are installed. Otherwise, the command will check the application compatibility with the current CLI version and could fail requiring `tns migrate`. <% if(isHtml) { %> ->Note: Hot Module Replacement (HMR) is currently in Beta. For more information about the current development state and any known issues, please check the relevant GitHub issue: https://github.com/NativeScript/NativeScript/issues/6398. - ->Note: Webpack support for the `tns preview` command is currently in Beta. Please, do not hesitate to report any problems that you experience with the feature by opening a new issue in the NativeScript CLI repository: https://github.com/NativeScript/nativescript-cli/issues/new/choose. - ### Command Limitations * The Preview app comes with a predefined set of NativeScript plugins. If your app utilizes a plugin that is not present in the Preview app, you will see a warning message and your app might not work as expected. diff --git a/docs/man_pages/project/testing/run-android.md b/docs/man_pages/project/testing/run-android.md index 2026e0b4da..7572159672 100644 --- a/docs/man_pages/project/testing/run-android.md +++ b/docs/man_pages/project/testing/run-android.md @@ -9,15 +9,17 @@ position: 10 Runs your project on a connected Android device or Android emulator, if configured. This is shorthand for prepare, build and deploy. While your app is running, prints the output from the application in the console and watches for changes in your code. Once a change is detected, it synchronizes the change with all selected devices and restarts/refreshes the application. -To enable Hot Module Replacement (HMR) in Angular projects, follow the steps outlined in this wiki: https://github.com/NativeScript/nativescript-angular/wiki/HMR. +<% if(isHtml) { %> +When running this command without passing `--release` flag, the HMR (Hot Module Replacement) is enabled by default. In case you want to disable HMR, you can pass `--no-hmr` flag. When `--release` is passed, CLI disables HMR. +<% } %> ### Commands Usage | Synopsis ---|--- -Run on all connected devices and running emulators | `$ tns run android [--key-store-path --key-store-password --key-store-alias --key-store-alias-password ] [--release] [--justlaunch] [--bundle [] [--env.*]]` -Run on a selected connected device or running emulator. Will start emulator with specified `Device Identifier`, if not already running. | `$ tns run android --device [--key-store-path --key-store-password --key-store-alias --key-store-alias-password ] [--release] [--justlaunch] [--bundle [] [--env.*]]` -Start a default emulator if none are running, or run application on all connected emulators. | `$ tns run android --emulator [--key-store-path --key-store-password --key-store-alias --key-store-alias-password ] [--release] [--justlaunch] [--bundle [] [--env.*]]` +Run on all connected devices and running emulators | `$ tns run android [--key-store-path --key-store-password --key-store-alias --key-store-alias-password ] [--release] [--justlaunch] [--env.*]]` +Run on a selected connected device or running emulator. Will start emulator with specified `Device Identifier`, if not already running. | `$ tns run android --device [--key-store-path --key-store-password --key-store-alias --key-store-alias-password ] [--release] [--justlaunch] [--env.*]]` +Start a default emulator if none are running, or run application on all connected emulators. | `$ tns run android --emulator [--key-store-path --key-store-password --key-store-alias --key-store-alias-password ] [--release] [--justlaunch] [--env.*]]` ### Options @@ -26,13 +28,12 @@ Start a default emulator if none are running, or run application on all connecte * `--justlaunch` - If set, does not print the application output in the console. * `--clean` - If set, forces the complete rebuild of the native application. * `--no-watch` - If set, changes in your code will not be reflected during the execution of this command. -* `--release` - If set, produces a release build. Otherwise, produces a debug build. When set, you must also specify the `--key-store-*` options. +* `--release` - If set, produces a release build by running webpack in production mode and native build in release mode. Otherwise, produces a debug build. When set, you must also specify the --key-store-* options. * `--key-store-path` - Specifies the file path to the keystore file (P12) which you want to use to code sign your APK. You can use the `--key-store-*` options along with `--release` to produce a signed release build. You need to specify all `--key-store-*` options. * `--key-store-password` - Provides the password for the keystore file specified with `--key-store-path`. You can use the `--key-store-*` options along with `--release` to produce a signed release build. You need to specify all `--key-store-*` options. * `--key-store-alias` - Provides the alias for the keystore file specified with `--key-store-path`. You can use the `--key-store-*` options along with `--release` to produce a signed release build. You need to specify all `--key-store-*` options. * `--key-store-alias-password` - Provides the password for the alias specified with `--key-store-alias-password`. You can use the `--key-store-*` options along with `--release` to produce a signed release build. You need to specify all `--key-store-*` options. -* `--bundle` - Specifies that the `webpack` bundler will be used to bundle the application. -* `--hmr` - (Beta) Enables the hot module replacement (HMR) feature. HMR depends on `webpack` and adding the `--hmr` flag to the command will automatically enable the `--bundle` option as well. <% if(isConsole) { %> The HMR feature is currently in Beta. For more information about the current development state and any known issues, please check the relevant GitHub issue: https://github.com/NativeScript/NativeScript/issues/6398.<% } %> +* `--no-hmr` - Disables Hot Module Replacement (HMR). In this case, when a change in the code is applied, CLI will transfer the modified files and restart the application. * `--env.*` - Specifies additional flags that the bundler may process. May be passed multiple times. * `--env.aot` - creates Ahead-Of-Time build (Angular only). * `--env.snapshot`- creates [Snapshot](https://docs.nativescript.org/performance-optimizations/bundling-with-webpack#v8-heap-snapshot) (only for release builds on Mac OS & for Android). @@ -40,12 +41,10 @@ Start a default emulator if none are running, or run application on all connecte * `--env.report` - creates a Webpack report inside a `report` folder in the root folder. * `--env.sourceMap` - creates inline source maps (useful for debbuging bundled app). * `--env.hiddenSourceMap` - creates sources maps in the root folder (useful for Crashlytics usage with bundled app in release). -* `--syncAllFiles` - Watches all production dependencies inside node_modules for changes. Triggers project rebuild if necessary! +* `--force` - If set, skips the application compatibility checks and forces `npm i` to ensure all dependencies are installed. Otherwise, the command will check the application compatibility with the current CLI version and could fail requiring `tns migrate`. <% if(isHtml) { %> ->Note: Hot Module Replacement (HMR) is currently in Beta. For more information about the current development state and any known issues, please check the relevant GitHub issue: https://github.com/NativeScript/NativeScript/issues/6398. - ### Prerequisites Before running your app in the Android emulator from the Android SDK, verify that your system meets the following requirements. diff --git a/docs/man_pages/project/testing/run-ios.md b/docs/man_pages/project/testing/run-ios.md index 997464e95e..343c0e7395 100644 --- a/docs/man_pages/project/testing/run-ios.md +++ b/docs/man_pages/project/testing/run-ios.md @@ -13,15 +13,17 @@ Runs your project on a connected iOS device or in the iOS Simulator, if configur <% if((isConsole && isMacOS) || isHtml) { %> <% if(isHtml) { %>> <% } %>IMPORTANT: Before building for iOS device, verify that you have configured a valid pair of certificate and provisioning profile on your macOS system. <% if(isHtml) { %>For more information, see the [Code Signing](https://developer.apple.com/support/code-signing/) and [Maintain Signing Assets](https://help.apple.com/xcode/mac/current/#/dev3a05256b8) sections from the Apple Developer documentation.<% } %> -To enable Hot Module Replacement (HMR) in Angular projects, follow the steps outlined in this wiki: https://github.com/NativeScript/nativescript-angular/wiki/HMR. +<% if(isHtml) { %> +When running this command without passing `--release` flag, the HMR (Hot Module Replacement) is enabled by default. In case you want to disable HMR, you can pass `--no-hmr` flag. When `--release` is passed, CLI disables HMR. +<% } %> ### Commands Usage | Synopsis ---|--- -Run on all connected devices | `$ tns run ios [--release] [--justlaunch] [--bundle [] [--env.*]]` -Run on a selected connected device. Will start simulator with specified `Device Identifier`, if not already running. | `$ tns run ios [--device ] [--release] [--justlaunch] [--bundle [] [--env.*]]` -Start an emulator and run the app inside it | `$ tns run ios --emulator [--release] [--bundle [] [--env.*]]` +Run on all connected devices | `$ tns run ios [--release] [--justlaunch] [--env.*]]` +Run on a selected connected device. Will start simulator with specified `Device Identifier`, if not already running. | `$ tns run ios [--device ] [--release] [--justlaunch] [--env.*]]` +Start an emulator and run the app inside it | `$ tns run ios --emulator [--release] [--env.*]]` Start an emulator with specified device name and sdk | `$ tns run ios [--device ] [--sdk ]` Start an emulator with specified device identifier and sdk | `$ tns run ios [--device ] [--sdk ]` @@ -33,9 +35,8 @@ Start an emulator with specified device identifier and sdk | `$ tns run ios [--d * `--justlaunch` - If set, does not print the application output in the console. * `--clean` - If set, forces the complete rebuild of the native application. * `--no-watch` - If set, changes in your code will not be reflected during the execution of this command. -* `--release` - If set, produces a release build. Otherwise, produces a debug build. -* `--bundle` - Specifies that the `webpack` bundler will be used to bundle the application. -* `--hmr` - (Beta) Enables the hot module replacement (HMR) feature. HMR depends on `webpack` and adding the `--hmr` flag to the command will automatically enable the `--bundle` option as well. <% if(isConsole) { %> The HMR feature is currently in Beta. For more information about the current development state and any known issues, please check the relevant GitHub issue: https://github.com/NativeScript/NativeScript/issues/6398.<% } %> +* `--release` - If set, produces a release build by running webpack in production mode and native build in release mode. Otherwise, produces a debug build. +* `--no-hmr` - Disables Hot Module Replacement (HMR). In this case, when a change in the code is applied, CLI will transfer the modified files and restart the application. * `--env.*` - Specifies additional flags that the bundler may process. May be passed multiple times. * `--env.aot` - creates Ahead-Of-Time build (Angular only). * `--env.snapshot`- creates [Snapshot](https://docs.nativescript.org/performance-optimizations/bundling-with-webpack#v8-heap-snapshot) (only for release builds on Mac OS & for Android). @@ -43,13 +44,11 @@ Start an emulator with specified device identifier and sdk | `$ tns run ios [--d * `--env.report` - creates a Webpack report inside a `report` folder in the root folder. * `--env.sourceMap` - creates inline source maps (useful for debbuging bundled app). * `--env.hiddenSourceMap` - creates sources maps in the root folder (useful for Crashlytics usage with bundled app in release). -* `--syncAllFiles` - Watches all production dependencies inside node_modules for changes. Triggers project rebuild if necessary! +* `--force` - If set, skips the application compatibility checks and forces `npm i` to ensure all dependencies are installed. Otherwise, the command will check the application compatibility with the current CLI version and could fail requiring `tns migrate`. <% } %> <% if(isHtml) { %> ->Note: Hot Module Replacement (HMR) is currently in Beta. For more information about the current development state and any known issues, please check the relevant GitHub issue: https://github.com/NativeScript/NativeScript/issues/6398. - ### Prerequisites Before running the iOS Simulator, verify that your system meets the following requirements. diff --git a/docs/man_pages/project/testing/run.md b/docs/man_pages/project/testing/run.md index ed555af37f..87e87ea5eb 100644 --- a/docs/man_pages/project/testing/run.md +++ b/docs/man_pages/project/testing/run.md @@ -9,21 +9,42 @@ position: 12 Runs your project on all connected devices or in native emulators for the selected platform.<% if(isConsole && (isLinux || isWindows)) { %>The command will work with all currently running Android devices and emulators.<% } %> The command will prepare, build and deploy the app when necessary. By default listens for changes in your code, synchronizes those changes and refreshes all selected devices. +<% if(isHtml) { %> +When running this command without passing `--release` flag, the HMR (Hot Module Replacement) is enabled by default. In case you want to disable HMR, you can pass `--no-hmr` flag. When `--release` is passed, CLI disables HMR. + +#### How file changes are handled +With HMR (Hot Module Replacement): +* Changes in `.js`, `.ts`, `.less`, `.sass` and other file types that are accepted will cause a refresh of the application. +* Changes in `App_Resources` will cause a rebuild of the application. +* Changes in any `package.json` file inside the project will cause a rebuild of the application. +* Changes in `node_modules/somePlugin` if accepted will cause a refresh of the application. +* Changes in `node_modules/somePlugin/platforms` will cause a rebuild of the application. +* Changes in `node_modules/somePlugin/package.json` file will cause a rebuild of the application. +* Changes that are not accepted and HMR fails will cause a restart of the native application. + +With **no** HMR: +* Changes in `.js`, `.ts`, `.less`, `.sass` and other file types will cause a restart of the native application. +* Changes in `App_Resources` will cause a rebuild of the application. +* Changes in any `package.json` file inside the project will cause a rebuild of the application. +* Changes in `node_modules/somePlugin` will cause a restart of the native application. +* Changes in `node_modules/somePlugin/platforms` will cause a rebuild of the application. +* Changes in `node_modules/somePlugin/package.json` file will cause a rebuild of the application. +<% } %> + ### Commands Usage | Synopsis ---|--- Run on all connected devices | `$ tns run [--release] [--justlaunch]` Run on a selected connected device or running emulator. Will start emulator with specified `Device Identifier`, if not already running. | `$ tns run --device [--release] [--justlaunch]` -<% if((isConsole && isMacOS) || isHtml) { %>Run on all connected devices of the speficied `Platform` | `$ tns run [--release] [--justlaunch]`<% } %> +<% if((isConsole && isMacOS) || isHtml) { %>Run on all connected devices of the specified `Platform` | `$ tns run [--release] [--justlaunch]`<% } %> ### Options * `--justlaunch` - If set, does not print the application output in the console. -* `--release` - If set, produces a release build. Otherwise, produces a debug build. +* `--release` - If set, produces a release build by running webpack in production mode and native build in release mode. Otherwise, produces a debug build. * `--device` - Specifies a connected device/emulator to start and run the app. `` is the index or `Device Identifier` of the target device as listed by the `$ tns device --available-devices` command. -* `--bundle` - Specifies that the `webpack` bundler will be used to bundle the application. -* `--hmr` - (Beta) Enables the hot module replacement (HMR) feature. HMR depends on `webpack` and adding the `--hmr` flag to the command will automatically enable the `--bundle` option as well. <% if(isConsole) { %> The HMR feature is currently in Beta. For more information about the current development state and any known issues, please check the relevant GitHub issue: https://github.com/NativeScript/NativeScript/issues/6398.<% } %> +* `--no-hmr` - Disables Hot Module Replacement (HMR). In this case, when a change in the code is applied, CLI will transfer the modified files and restart the application. * `--env.*` - Specifies additional flags that the bundler may process. May be passed multiple times. Supported additional flags: * `--env.aot` - creates Ahead-Of-Time build (Angular only). * `--env.snapshot`- creates [Snapshot](https://docs.nativescript.org/performance-optimizations/bundling-with-webpack#v8-heap-snapshot) (only for release builds on Mac OS & for Android). @@ -31,7 +52,7 @@ Run on a selected connected device or running emulator. Will start emulator with * `--env.report` - creates a Webpack report inside a `report` folder in the root folder. * `--env.sourceMap` - creates inline source maps (useful for debbuging bundled app). * `--env.hiddenSourceMap` - creates sources maps in the root folder (useful for Crashlytics usage with bundled app in release). -* `--syncAllFiles` - Watches all production dependencies inside node_modules for changes. Triggers project rebuild if necessary! +* `--force` - If set, skips the application compatibility checks and forces `npm i` to ensure all dependencies are installed. Otherwise, the command will check the application compatibility with the current CLI version and could fail requiring `tns migrate`. <% if((isConsole && isMacOS) || isHtml) { %>### Arguments @@ -43,8 +64,6 @@ Run on a selected connected device or running emulator. Will start emulator with <% if(isHtml) { %> ->Note: Hot Module Replacement (HMR) is currently in Beta. For more information about the current development state and any known issues, please check the relevant GitHub issue: https://github.com/NativeScript/NativeScript/issues/6398. - ### Command Limitations * The command will work with all connected devices and running emulators on macOS. On Windows and Linux the command will work with Android devices only. diff --git a/docs/man_pages/project/testing/test-android.md b/docs/man_pages/project/testing/test-android.md index 21b301f4b2..2c5e984959 100644 --- a/docs/man_pages/project/testing/test-android.md +++ b/docs/man_pages/project/testing/test-android.md @@ -21,6 +21,7 @@ Run tests on a selected device | `$ tns test android --device [--wat * `--watch` - If set, when you save changes to the project, changes are automatically synchronized to the connected device and tests are re-run. * `--device` - Specifies the serial number or the index of the connected device on which to run the tests. To list all connected devices, grouped by platform, run `$ tns device`. `` is the device index or identifier as listed by the `$ tns device` command. * `--debug-brk` - Runs the tests under the debugger. The debugger will break just before your tests are executed, so you have a chance to place breakpoints. +* `--force` - If set, skips the application compatibility checks and forces `npm i` to ensure all dependencies are installed. Otherwise, the command will check the application compatibility with the current CLI version and could fail requiring `tns migrate`. <% if(isHtml) { %> diff --git a/docs/man_pages/project/testing/test-ios.md b/docs/man_pages/project/testing/test-ios.md index 32efa9a325..727a69d669 100644 --- a/docs/man_pages/project/testing/test-ios.md +++ b/docs/man_pages/project/testing/test-ios.md @@ -27,6 +27,7 @@ Run tests in the iOS Simulator | `$ tns test ios --emulator [--watch] [--debug-b * `--device` - Specifies the serial number or the index of the connected device on which you want to run tests. To list all connected devices, grouped by platform, run `$ tns device`. You cannot set `--device` and `--emulator` simultaneously. `` is the device index or identifier as listed by the `$ tns device` command. * `--emulator` - Runs tests on the iOS Simulator. You cannot set `--device` and `--emulator` simultaneously. * `--debug-brk` - Runs the tests under the debugger. The debugger will break just before your tests are executed, so you have a chance to place breakpoints. +* `--force` - If set, skips the application compatibility checks and forces `npm i` to ensure all dependencies are installed. Otherwise, the command will check the application compatibility with the current CLI version and could fail requiring `tns migrate`. <% } %> diff --git a/docs/man_pages/project/testing/test.md b/docs/man_pages/project/testing/test.md index c09a07f54d..59edac7c60 100644 --- a/docs/man_pages/project/testing/test.md +++ b/docs/man_pages/project/testing/test.md @@ -9,6 +9,16 @@ position: 23 Runs unit tests on the selected mobile platform.<% if(isConsole) { %> Your project must already be configured for unit testing by running `$ tns test init`.<% } %> +<% if(isHtml) { %> +#### How file changes are handled +* Changes in `.js`, `.ts`, `.less`, `.sass` and other file types will cause a restart of the native application. +* Changes in `App_Resources` will cause a rebuild of the application. +* Changes in any `package.json` file inside the project will cause a rebuild of the application. +* Changes in `node_modules/somePlugin` will cause a restart of the native application. +* Changes in `node_modules/somePlugin/platforms` will cause a rebuild of the application. +* Changes in `node_modules/somePlugin/package.json` file will cause a rebuild of the application. +<% } %> + ### Commands Usage | Synopsis diff --git a/lib/commands/migrate.ts b/lib/commands/migrate.ts index e40cfd8651..9f22b42972 100644 --- a/lib/commands/migrate.ts +++ b/lib/commands/migrate.ts @@ -5,28 +5,25 @@ export class MigrateCommand implements ICommand { private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants, private $migrateController: IMigrateController, private $projectData: IProjectData, - private $errors: IErrors) { + private $logger: ILogger) { this.$projectData.initializeProjectData(); } public async execute(args: string[]): Promise { - await this.$migrateController.migrate({ - projectDir: this.$projectData.projectDir, - platforms: [this.$devicePlatformsConstants.Android, this.$devicePlatformsConstants.iOS] - }); - } - - public async canExecute(args: string[]): Promise { const shouldMigrateResult = await this.$migrateController.shouldMigrate({ projectDir: this.$projectData.projectDir, platforms: [this.$devicePlatformsConstants.Android, this.$devicePlatformsConstants.iOS] }); if (!shouldMigrateResult) { - this.$errors.failWithoutHelp('Project is compatible with NativeScript "v6.0.0". To get the latest NativesScript packages execute "tns update".'); + this.$logger.printMarkdown('__Project is compatible with NativeScript "v6.0.0". To get the latest NativeScript packages execute "tns update".__'); + return; } - return true; + await this.$migrateController.migrate({ + projectDir: this.$projectData.projectDir, + platforms: [this.$devicePlatformsConstants.Android, this.$devicePlatformsConstants.iOS] + }); } } diff --git a/lib/commands/update.ts b/lib/commands/update.ts index 0dddf6a07f..28b8ee1302 100644 --- a/lib/commands/update.ts +++ b/lib/commands/update.ts @@ -9,11 +9,17 @@ export class UpdateCommand implements ICommand { private $migrateController: IMigrateController, private $options: IOptions, private $errors: IErrors, + private $logger: ILogger, private $projectData: IProjectData) { this.$projectData.initializeProjectData(); } public async execute(args: string[]): Promise { + if (!await this.$updateController.shouldUpdate({ projectDir: this.$projectData.projectDir, version: args[0] })) { + this.$logger.printMarkdown(`__${UpdateCommand.PROJECT_UP_TO_DATE_MESSAGE}__`); + return; + } + await this.$updateController.update({ projectDir: this.$projectData.projectDir, version: args[0], frameworkPath: this.$options.frameworkPath }); } @@ -27,10 +33,6 @@ export class UpdateCommand implements ICommand { this.$errors.failWithoutHelp(UpdateCommand.SHOULD_MIGRATE_PROJECT_MESSAGE); } - if (!await this.$updateController.shouldUpdate({ projectDir: this.$projectData.projectDir, version: args[0] })) { - this.$errors.failWithoutHelp(UpdateCommand.PROJECT_UP_TO_DATE_MESSAGE); - } - return args.length < 2 && this.$projectData.projectDir !== ""; } } diff --git a/lib/common/definitions/yargs.d.ts b/lib/common/definitions/yargs.d.ts deleted file mode 100644 index aafee6b841..0000000000 --- a/lib/common/definitions/yargs.d.ts +++ /dev/null @@ -1,100 +0,0 @@ -// Type definitions for yargs -// Project: https://github.com/chevex/yargs -// Definitions by: Martin Poelstra -// Definitions: https://github.com/borisyankov/DefinitelyTyped - -declare module "yargs" { - - module yargs { - interface Argv { - argv: any; - (...args: any[]): any; - parse(...args: any[]): any; - - alias(shortName: string, longName: string): Argv; - alias(aliases: { [shortName: string]: string }): Argv; - alias(aliases: { [shortName: string]: string[] }): Argv; - - default(key: string, value: any): Argv; - default(defaults: { [key: string]: any}): Argv; - - demand(key: string, msg: string): Argv; - demand(key: string, required?: boolean): Argv; - demand(keys: string[], msg: string): Argv; - demand(keys: string[], required?: boolean): Argv; - demand(positionals: number, required?: boolean): Argv; - demand(positionals: number, msg: string): Argv; - - require(key: string, msg: string): Argv; - require(key: string, required: boolean): Argv; - require(keys: number[], msg: string): Argv; - require(keys: number[], required: boolean): Argv; - require(positionals: number, required: boolean): Argv; - require(positionals: number, msg: string): Argv; - - required(key: string, msg: string): Argv; - required(key: string, required: boolean): Argv; - required(keys: number[], msg: string): Argv; - required(keys: number[], required: boolean): Argv; - required(positionals: number, required: boolean): Argv; - required(positionals: number, msg: string): Argv; - - requiresArg(key: string): Argv; - requiresArg(keys: string[]): Argv; - - describe(key: string, description: string): Argv; - describe(descriptions: { [key: string]: string }): Argv; - - option(key: string, options: IDashedOption): Argv; - option(options: { [key: string]: IDashedOption }): Argv; - options(key: string, options: IDashedOption): Argv; - options(options: { [key: string]: IDashedOption }): Argv; - - usage(message: string, options?: { [key: string]: IDashedOption }): Argv; - usage(options?: { [key: string]: IDashedOption }): Argv; - - example(command: string, description: string): Argv; - - check(func: (argv: { [key: string]: any }, aliases: { [alias: string]: string }) => boolean): Argv; - check(func: (argv: { [key: string]: any }, aliases: { [alias: string]: string }) => string): Argv; - - boolean(key: string): Argv; - boolean(keys: string[]): Argv; - - string(key: string): Argv; - string(keys: string[]): Argv; - - config(key: string): Argv; - config(keys: string[]): Argv; - - wrap(columns: number): Argv; - - strict(): Argv; - - help(): string; - help(option: string, description?: string): Argv; - - version(version: string, option?: string, description?: string): Argv; - - showHelpOnFail(enable: boolean, message?: string): Argv; - - showHelp(func?: (message: string) => any): Argv; - - /* Undocumented */ - - normalize(key: string): Argv; - normalize(keys: string[]): Argv; - - implies(key: string, value: string): Argv; - implies(implies: { [key: string]: string }): Argv; - - count(key: string): Argv; - count(keys: string[]): Argv; - - fail(func: (msg: string) => any): void; - } - } - - var yargs: yargs.Argv; - export = yargs; -} \ No newline at end of file diff --git a/lib/common/services/commands-service.ts b/lib/common/services/commands-service.ts index b4bb6566d0..5b2bd90d5d 100644 --- a/lib/common/services/commands-service.ts +++ b/lib/common/services/commands-service.ts @@ -27,8 +27,7 @@ export class CommandsService implements ICommandsService { private $staticConfig: Config.IStaticConfig, private $helpService: IHelpService, private $extensibilityService: IExtensibilityService, - private $optionsTracker: IOptionsTracker, - private $projectDataService: IProjectDataService) { + private $optionsTracker: IOptionsTracker) { } public allCommands(opts: { includeDevCommands: boolean }): string[] { @@ -106,15 +105,8 @@ export class CommandsService implements ICommandsService { private async tryExecuteCommandAction(commandName: string, commandArguments: string[]): Promise { const command = this.$injector.resolveCommand(commandName); if (!command || !command.isHierarchicalCommand) { - let projectData = null; - try { - projectData = this.$projectDataService.getProjectData(); - } catch (err) { - this.$logger.trace(`Error while trying to get project data. More info: ${err}`); - } - const dashedOptions = command ? command.dashedOptions : null; - this.$options.validateOptions(dashedOptions, projectData); + this.$options.validateOptions(dashedOptions); } return this.canExecuteCommand(commandName, commandArguments); diff --git a/lib/controllers/migrate-controller.ts b/lib/controllers/migrate-controller.ts index 49c00bcd52..838eeffb68 100644 --- a/lib/controllers/migrate-controller.ts +++ b/lib/controllers/migrate-controller.ts @@ -54,7 +54,7 @@ Running this command will ${MigrateController.COMMON_MIGRATE_MESSAGE}`; { packageName: "nativescript-dev-sass", isDev: true, replaceWith: "node-sass" }, { packageName: "nativescript-dev-typescript", isDev: true, replaceWith: MigrateController.typescriptPackageName }, { packageName: "nativescript-dev-less", isDev: true, shouldRemove: true, warning: "LESS CSS is not supported out of the box. In order to enable it, follow the steps in this feature request: https://github.com/NativeScript/nativescript-dev-webpack/issues/967" }, - { packageName: constants.WEBPACK_PLUGIN_NAME, isDev: true, shouldAddIfMissing: true, verifiedVersion: "1.0.0" }, + { packageName: constants.WEBPACK_PLUGIN_NAME, isDev: true, shouldAddIfMissing: true, verifiedVersion: "1.0.1" }, { packageName: "nativescript-camera", verifiedVersion: "4.5.0" }, { packageName: "nativescript-geolocation", verifiedVersion: "5.1.0" }, { packageName: "nativescript-imagepicker", verifiedVersion: "6.2.0" }, @@ -69,19 +69,36 @@ Running this command will ${MigrateController.COMMON_MIGRATE_MESSAGE}`; { packageName: "nativescript-datetimepicker", verifiedVersion: "1.1.0" }, { packageName: "kinvey-nativescript-sdk", verifiedVersion: "4.2.1" }, { packageName: "nativescript-plugin-firebase", verifiedVersion: "9.0.2" }, - { packageName: "nativescript-vue", verifiedVersion: "2.3.0" }, + { + packageName: "nativescript-vue", verifiedVersion: "2.3.0", + shouldMigrateAction: async (projectData: IProjectData, allowInvalidVersions: boolean) => { + const dependency = { packageName: "nativescript-vue", verifiedVersion: "2.3.0", isDev: false }; + const result = this.hasDependency(dependency, projectData) && await this.shouldMigrateDependencyVersion(dependency, projectData, allowInvalidVersions); + return result; + }, + migrateAction: this.migrateNativeScriptVue.bind(this) + }, + { + packageName: "nativescript-angular", verifiedVersion: "8.0.2", + shouldMigrateAction: async (projectData: IProjectData, allowInvalidVersions: boolean) => { + const dependency = { packageName: "nativescript-angular", verifiedVersion: "8.0.2", isDev: false }; + const result = this.hasDependency(dependency, projectData) && await this.shouldMigrateDependencyVersion(dependency, projectData, allowInvalidVersions); + return result; + }, + migrateAction: this.migrateNativeScriptAngular.bind(this) + }, { packageName: "nativescript-permissions", verifiedVersion: "1.3.0" }, { packageName: "nativescript-cardview", verifiedVersion: "3.2.0" }, { - packageName: "nativescript-unit-test-runner", verifiedVersion: "0.6.4", + packageName: "nativescript-unit-test-runner", verifiedVersion: "0.7.0", shouldMigrateAction: async (projectData: IProjectData, allowInvalidVersions: boolean) => { - const dependency = { packageName: "nativescript-unit-test-runner", verifiedVersion: "0.6.4", isDev: false }; + const dependency = { packageName: "nativescript-unit-test-runner", verifiedVersion: "0.7.0", isDev: false }; const result = this.hasDependency(dependency, projectData) && await this.shouldMigrateDependencyVersion(dependency, projectData, allowInvalidVersions); return result; }, migrateAction: this.migrateUnitTestRunner.bind(this) }, - { packageName: MigrateController.typescriptPackageName, isDev: true, getVerifiedVersion: this.getAngularTypeScriptVersion.bind(this) }, + { packageName: MigrateController.typescriptPackageName, isDev: true, verifiedVersion: "3.4.5" }, { packageName: "nativescript-localize", verifiedVersion: "4.2.0" }, { packageName: "nativescript-dev-babel", verifiedVersion: "0.2.1" }, { packageName: "nativescript-nfc", verifiedVersion: "4.0.1" } @@ -90,7 +107,7 @@ Running this command will ${MigrateController.COMMON_MIGRATE_MESSAGE}`; get verifiedPlatformVersions(): IDictionary { return { [this.$devicePlatformsConstants.Android.toLowerCase()]: "6.0.0", - [this.$devicePlatformsConstants.iOS.toLowerCase()]: "6.0.0" + [this.$devicePlatformsConstants.iOS.toLowerCase()]: "6.0.1" }; } @@ -179,31 +196,6 @@ Running this command will ${MigrateController.COMMON_MIGRATE_MESSAGE}`; } } - private async getAngularTypeScriptVersion(projectData: IProjectData): Promise { - let verifiedVersion = "3.4.1"; - try { - const ngcPackageName = "@angular/compiler-cli"; - // e.g. ~8.0.0 - let ngcVersion = projectData.dependencies[ngcPackageName] || projectData.devDependencies[ngcPackageName]; - if (ngcVersion) { - // e.g. 8.0.3 - ngcVersion = await this.$packageInstallationManager.maxSatisfyingVersion(ngcPackageName, ngcVersion); - const ngcManifest = await this.getPackageManifest(ngcPackageName, ngcVersion); - // e.g. >=3.4 <3.5 - verifiedVersion = (ngcManifest && ngcManifest.peerDependencies && - ngcManifest.peerDependencies[MigrateController.typescriptPackageName]) || verifiedVersion; - - // e.g. 3.4.4 - verifiedVersion = await this.$packageInstallationManager.maxSatisfyingVersion( - MigrateController.typescriptPackageName, verifiedVersion); - } - } catch (error) { - this.$logger.warn(`Unable to determine the TypeScript version based on the Angular packages. Error is: '${error}'.`); - } - - return verifiedVersion; - } - private async migrateOldAndroidAppResources(projectData: IProjectData, backupDir: string) { const appResourcesPath = projectData.getAppResourcesDirectoryPath(); if (!this.$androidResourcesMigrationService.hasMigrated(appResourcesPath)) { @@ -329,42 +321,32 @@ Running this command will ${MigrateController.COMMON_MIGRATE_MESSAGE}`; this.$errors.failWithoutHelp("Failed to find replacement dependency."); } - const replacementDepVersion = await this.getDependencyVerifiedVersion(replacementDep, projectData); this.$logger.info(`Replacing '${dependency.packageName}' with '${replacementDep.packageName}'.`); - this.$pluginsService.addToPackageJson(replacementDep.packageName, replacementDepVersion, replacementDep.isDev, projectData.projectDir); + this.$pluginsService.addToPackageJson(replacementDep.packageName, replacementDep.verifiedVersion, replacementDep.isDev, projectData.projectDir); } return; } - const dependencyVersion = await this.getDependencyVerifiedVersion(dependency, projectData); if (hasDependency && await this.shouldMigrateDependencyVersion(dependency, projectData, allowInvalidVersions)) { - this.$logger.info(`Updating '${dependency.packageName}' to compatible version '${dependencyVersion}'`); - this.$pluginsService.addToPackageJson(dependency.packageName, dependencyVersion, dependency.isDev, projectData.projectDir); + this.$logger.info(`Updating '${dependency.packageName}' to compatible version '${dependency.verifiedVersion}'`); + this.$pluginsService.addToPackageJson(dependency.packageName, dependency.verifiedVersion, dependency.isDev, projectData.projectDir); return; } if (!hasDependency && dependency.shouldAddIfMissing) { - this.$logger.info(`Adding '${dependency.packageName}' with version '${dependencyVersion}'`); - this.$pluginsService.addToPackageJson(dependency.packageName, dependencyVersion, dependency.isDev, projectData.projectDir); + this.$logger.info(`Adding '${dependency.packageName}' with version '${dependency.verifiedVersion}'`); + this.$pluginsService.addToPackageJson(dependency.packageName, dependency.verifiedVersion, dependency.isDev, projectData.projectDir); } } - private async getDependencyVerifiedVersion(dependency: IMigrationDependency, projectData: IProjectData): Promise { - if (!dependency.verifiedVersion && dependency.getVerifiedVersion) { - dependency.verifiedVersion = await dependency.getVerifiedVersion(projectData); - } - - return dependency.verifiedVersion; - } - private async shouldMigrateDependencyVersion(dependency: IMigrationDependency, projectData: IProjectData, allowInvalidVersions: boolean): Promise { const devDependencies = projectData.devDependencies || {}; const dependencies = projectData.dependencies || {}; const packageName = dependency.packageName; const referencedVersion = dependencies[packageName] || devDependencies[packageName]; const installedVersion = await this.getMaxDependencyVersion(dependency.packageName, referencedVersion); - const requiredVersion = await this.getDependencyVerifiedVersion(dependency, projectData); + const requiredVersion = dependency.verifiedVersion; return this.isOutdatedVersion(installedVersion, requiredVersion, allowInvalidVersions); } @@ -410,6 +392,35 @@ Running this command will ${MigrateController.COMMON_MIGRATE_MESSAGE}`; return dependencies; } + + private async migrateNativeScriptAngular(): Promise { + const dependencies = [ + { packageName: "@angular/platform-browser-dynamic", verifiedVersion: "8.0.0", shouldAddIfMissing: true }, + { packageName: "@angular/common", verifiedVersion: "8.0.0", shouldAddIfMissing: true }, + { packageName: "@angular/compiler", verifiedVersion: "8.0.0", shouldAddIfMissing: true }, + { packageName: "@angular/core", verifiedVersion: "8.0.0", shouldAddIfMissing: true }, + { packageName: "@angular/forms", verifiedVersion: "8.0.0", shouldAddIfMissing: true }, + { packageName: "@angular/http", verifiedVersion: "8.0.0-beta.10", shouldAddIfMissing: true }, + { packageName: "@angular/platform-browser", verifiedVersion: "8.0.0", shouldAddIfMissing: true }, + { packageName: "@angular/router", verifiedVersion: "8.0.0", shouldAddIfMissing: true }, + { packageName: "rxjs", verifiedVersion: "6.3.3", shouldAddIfMissing: true }, + { packageName: "zone.js", verifiedVersion: "0.9.1", shouldAddIfMissing: true }, + { packageName: "@angular/animations", verifiedVersion: "8.0.0" }, + { packageName: "@angular/compiler-cli", verifiedVersion: "8.0.0", isDev: true }, + { packageName: "@ngtools/webpack", verifiedVersion: "8.0.0", isDev: true }, + { packageName: "@angular-devkit/build-angular", verifiedVersion: "0.800.3", isDev: true } + ]; + + return dependencies; + } + + private async migrateNativeScriptVue(): Promise { + const dependencies = [ + { packageName: "nativescript-vue-template-compiler", verifiedVersion: "2.3.0", isDev: true } + ]; + + return dependencies; + } } $injector.register("migrateController", MigrateController); diff --git a/lib/controllers/prepare-controller.ts b/lib/controllers/prepare-controller.ts index 86c871027d..9d6a85195d 100644 --- a/lib/controllers/prepare-controller.ts +++ b/lib/controllers/prepare-controller.ts @@ -14,6 +14,7 @@ export class PrepareController extends EventEmitter { private watchersData: IDictionary> = {}; private isInitialPrepareReady = false; private persistedData: IFilesChangeEventData[] = []; + private webpackCompilerHandler: any = null; constructor( private $platformController: IPlatformController, @@ -46,7 +47,8 @@ export class PrepareController extends EventEmitter { } if (this.watchersData && this.watchersData[projectDir] && this.watchersData[projectDir][platformLowerCase] && this.watchersData[projectDir][platformLowerCase].hasWebpackCompilerProcess) { - await this.$webpackCompilerService.stopWebpackCompiler(platform); + await this.$webpackCompilerService.stopWebpackCompiler(platformLowerCase); + this.$webpackCompilerService.removeListener(WEBPACK_COMPILATION_COMPLETE, this.webpackCompilerHandler); this.watchersData[projectDir][platformLowerCase].hasWebpackCompilerProcess = false; } } @@ -110,11 +112,14 @@ export class PrepareController extends EventEmitter { private async startJSWatcherWithPrepare(platformData: IPlatformData, projectData: IProjectData, prepareData: IPrepareData): Promise { if (!this.watchersData[projectData.projectDir][platformData.platformNameLowerCase].hasWebpackCompilerProcess) { - this.$webpackCompilerService.on(WEBPACK_COMPILATION_COMPLETE, data => { + const handler = (data: any) => { if (data.platform.toLowerCase() === platformData.platformNameLowerCase) { this.emitPrepareEvent({ ...data, hasNativeChanges: false }); } - }); + }; + + this.webpackCompilerHandler = handler.bind(this); + this.$webpackCompilerService.on(WEBPACK_COMPILATION_COMPLETE, this.webpackCompilerHandler); this.watchersData[projectData.projectDir][platformData.platformNameLowerCase].hasWebpackCompilerProcess = true; await this.$webpackCompilerService.compileWithWatch(platformData, projectData, prepareData); @@ -122,7 +127,7 @@ export class PrepareController extends EventEmitter { } private async startNativeWatcherWithPrepare(platformData: IPlatformData, projectData: IProjectData, prepareData: IPrepareData): Promise { - if ((prepareData.nativePrepare && prepareData.nativePrepare.skipNativePrepare) || this.watchersData[projectData.projectDir][platformData.platformNameLowerCase].nativeFilesWatcher) { + if (this.watchersData[projectData.projectDir][platformData.platformNameLowerCase].nativeFilesWatcher) { return false; } diff --git a/lib/controllers/preview-app-controller.ts b/lib/controllers/preview-app-controller.ts index bedfde8326..b53ca164e3 100644 --- a/lib/controllers/preview-app-controller.ts +++ b/lib/controllers/preview-app-controller.ts @@ -15,10 +15,12 @@ export class PreviewAppController extends EventEmitter implements IPreviewAppCon constructor( private $analyticsService: IAnalyticsService, + private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants, private $errors: IErrors, private $hmrStatusService: IHmrStatusService, private $logger: ILogger, public $hooksService: IHooksService, + private $pluginsService: IPluginsService, private $prepareController: PrepareController, private $previewAppFilesService: IPreviewAppFilesService, private $previewAppPluginsService: IPreviewAppPluginsService, @@ -38,16 +40,22 @@ export class PreviewAppController extends EventEmitter implements IPreviewAppCon return result; } - public async stopPreview(): Promise { + public async stopPreview(data: IProjectDir): Promise { this.$previewSdkService.stop(); this.$previewDevicesService.updateConnectedDevices([]); + + await this.$prepareController.stopWatchers(data.projectDir, this.$devicePlatformsConstants.Android); + await this.$prepareController.stopWatchers(data.projectDir, this.$devicePlatformsConstants.iOS); + if (this.prepareReadyEventHandler) { - this.removeListener(PREPARE_READY_EVENT_NAME, this.prepareReadyEventHandler); + this.$prepareController.removeListener(PREPARE_READY_EVENT_NAME, this.prepareReadyEventHandler); this.prepareReadyEventHandler = null; } } private async previewCore(data: IPreviewAppLiveSyncData): Promise { + const projectData = this.$projectDataService.getProjectData(data.projectDir); + await this.$pluginsService.ensureAllDependenciesAreInstalled(projectData); await this.$previewSdkService.initialize(data.projectDir, async (device: Device) => { try { if (!device) { @@ -71,7 +79,6 @@ export class PreviewAppController extends EventEmitter implements IPreviewAppCon }); } - const projectData = this.$projectDataService.getProjectData(data.projectDir); await this.$hooksService.executeBeforeHooks("preview-sync", { hookArgs: { ...data, platform: device.platform, projectData } }); if (data.useHotModuleReload) { @@ -81,10 +88,12 @@ export class PreviewAppController extends EventEmitter implements IPreviewAppCon await this.$previewAppPluginsService.comparePluginsOnDevice(data, device); if (!this.prepareReadyEventHandler) { - this.prepareReadyEventHandler = async (currentPrepareData: IFilesChangeEventData) => { + const handler = async (currentPrepareData: IFilesChangeEventData) => { await this.handlePrepareReadyEvent(data, currentPrepareData); }; - this.$prepareController.on(PREPARE_READY_EVENT_NAME, this.prepareReadyEventHandler.bind(this)); + + this.prepareReadyEventHandler = handler.bind(this); + this.$prepareController.on(PREPARE_READY_EVENT_NAME, this.prepareReadyEventHandler); } data.env = data.env || {}; diff --git a/lib/controllers/run-controller.ts b/lib/controllers/run-controller.ts index 259a44b99f..d6cc35912e 100644 --- a/lib/controllers/run-controller.ts +++ b/lib/controllers/run-controller.ts @@ -51,7 +51,7 @@ export class RunController extends EventEmitter implements IRunController { } if (!this.prepareReadyEventHandler) { - this.prepareReadyEventHandler = async (data: IFilesChangeEventData) => { + const handler = async (data: IFilesChangeEventData) => { if (data.hasNativeChanges) { const platformData = this.$platformsDataService.getPlatformData(data.platform, projectData); const prepareData = this.$prepareDataService.getPrepareData(liveSyncInfo.projectDir, data.platform, { ...liveSyncInfo, watch: !liveSyncInfo.skipWatcher }); @@ -63,7 +63,9 @@ export class RunController extends EventEmitter implements IRunController { await this.syncChangedDataOnDevices(data, projectData, liveSyncInfo); } }; - this.$prepareController.on(PREPARE_READY_EVENT_NAME, this.prepareReadyEventHandler.bind(this)); + + this.prepareReadyEventHandler = handler.bind(this); + this.$prepareController.on(PREPARE_READY_EVENT_NAME, this.prepareReadyEventHandler); } await this.syncInitialDataOnDevices(projectData, liveSyncInfo, deviceDescriptorsForInitialSync); @@ -113,7 +115,7 @@ export class RunController extends EventEmitter implements IRunController { liveSyncProcessInfo.deviceDescriptors = []; if (this.prepareReadyEventHandler) { - this.removeListener(PREPARE_READY_EVENT_NAME, this.prepareReadyEventHandler); + this.$prepareController.removeListener(PREPARE_READY_EVENT_NAME, this.prepareReadyEventHandler); this.prepareReadyEventHandler = null; } @@ -141,10 +143,10 @@ export class RunController extends EventEmitter implements IRunController { return this.$liveSyncProcessDataService.getDeviceDescriptors(data.projectDir); } - protected async refreshApplication(projectData: IProjectData, liveSyncResultInfo: ILiveSyncResultInfo, filesChangeEventData: IFilesChangeEventData, deviceDescriptor: ILiveSyncDeviceDescriptor, settings?: IRefreshApplicationSettings): Promise { + protected async refreshApplication(projectData: IProjectData, liveSyncResultInfo: ILiveSyncResultInfo, filesChangeEventData: IFilesChangeEventData, deviceDescriptor: ILiveSyncDeviceDescriptor): Promise { const result = deviceDescriptor.debuggingEnabled ? - await this.refreshApplicationWithDebug(projectData, liveSyncResultInfo, filesChangeEventData, deviceDescriptor, settings) : - await this.refreshApplicationWithoutDebug(projectData, liveSyncResultInfo, filesChangeEventData, deviceDescriptor, settings); + await this.refreshApplicationWithDebug(projectData, liveSyncResultInfo, filesChangeEventData, deviceDescriptor) : + await this.refreshApplicationWithoutDebug(projectData, liveSyncResultInfo, filesChangeEventData, deviceDescriptor); const device = liveSyncResultInfo.deviceAppData.device; @@ -159,12 +161,12 @@ export class RunController extends EventEmitter implements IRunController { return result; } - protected async refreshApplicationWithDebug(projectData: IProjectData, liveSyncResultInfo: ILiveSyncResultInfo, filesChangeEventData: IFilesChangeEventData, deviceDescriptor: ILiveSyncDeviceDescriptor, settings?: IRefreshApplicationSettings): Promise { + protected async refreshApplicationWithDebug(projectData: IProjectData, liveSyncResultInfo: ILiveSyncResultInfo, filesChangeEventData: IFilesChangeEventData, deviceDescriptor: ILiveSyncDeviceDescriptor): Promise { const debugOptions = deviceDescriptor.debugOptions || {}; liveSyncResultInfo.waitForDebugger = !!debugOptions.debugBrk; - const refreshInfo = await this.refreshApplicationWithoutDebug(projectData, liveSyncResultInfo, filesChangeEventData, deviceDescriptor, settings); + const refreshInfo = await this.refreshApplicationWithoutDebug(projectData, liveSyncResultInfo, filesChangeEventData, deviceDescriptor, { shouldSkipEmitLiveSyncNotification: true, shouldCheckDeveloperDiscImage: true }); // we do not stop the application when debugBrk is false, so we need to attach, instead of launch // if we try to send the launch request, the debugger port will not be printed and the command will timeout @@ -330,6 +332,8 @@ export class RunController extends EventEmitter implements IRunController { applicationIdentifier: projectData.projectIdentifiers[device.deviceInfo.platform.toLowerCase()], error: err, }); + + await this.stop({ projectDir: projectData.projectDir, deviceIdentifiers: [device.deviceInfo.identifier], stopOptions: { shouldAwaitAllActions: false }}); } }; @@ -375,7 +379,7 @@ export class RunController extends EventEmitter implements IRunController { await this.$deviceInstallAppService.installOnDevice(device, deviceDescriptor.buildData, rebuiltInformation[platformData.platformNameLowerCase].packageFilePath); await platformLiveSyncService.syncAfterInstall(device, watchInfo); - await platformLiveSyncService.restartApplication(projectData, { deviceAppData, modifiedFilesData: [], isFullSync: false, useHotModuleReload: liveSyncInfo.useHotModuleReload }); + await this.refreshApplication(projectData, { deviceAppData, modifiedFilesData: [], isFullSync: false, useHotModuleReload: liveSyncInfo.useHotModuleReload }, data, deviceDescriptor); } else { const isInHMRMode = liveSyncInfo.useHotModuleReload && data.hmrData && data.hmrData.hash; if (isInHMRMode) { @@ -408,7 +412,7 @@ export class RunController extends EventEmitter implements IRunController { error: err, }); - await this.stop({ projectDir: projectData.projectDir, deviceIdentifiers: [device.deviceInfo.identifier] }); + await this.stop({ projectDir: projectData.projectDir, deviceIdentifiers: [device.deviceInfo.identifier], stopOptions: { shouldAwaitAllActions: false } }); } }; diff --git a/lib/definitions/migrate.d.ts b/lib/definitions/migrate.d.ts index 1931d4fc88..81ce7da475 100644 --- a/lib/definitions/migrate.d.ts +++ b/lib/definitions/migrate.d.ts @@ -19,7 +19,6 @@ interface IMigrationDependency extends IDependency { replaceWith?: string; warning?: string; verifiedVersion?: string; - getVerifiedVersion?: (projectData: IProjectData) => Promise; shouldAddIfMissing?: boolean; shouldMigrateAction?: (projectData: IProjectData, allowInvalidVersions: boolean) => Promise; migrateAction?: (projectData: IProjectData, migrationBackupDirPath: string) => Promise; diff --git a/lib/definitions/preview-app-livesync.d.ts b/lib/definitions/preview-app-livesync.d.ts index 414b4cffe7..6c8f125aed 100644 --- a/lib/definitions/preview-app-livesync.d.ts +++ b/lib/definitions/preview-app-livesync.d.ts @@ -77,6 +77,6 @@ declare global { interface IPreviewAppController { startPreview(data: IPreviewAppLiveSyncData): Promise; - stopPreview(): Promise; + stopPreview(data: IProjectDir): Promise; } } \ No newline at end of file diff --git a/lib/options.ts b/lib/options.ts index f370b093ef..4c9d1fa83f 100644 --- a/lib/options.ts +++ b/lib/options.ts @@ -6,7 +6,6 @@ export class Options { private static NONDASHED_OPTION_REGEX = /(.+?)[-]([a-zA-Z])(.*)/; private optionsWhiteList = ["ui", "recursive", "reporter", "require", "timeout", "_", "$0"]; // These options shouldn't be validated - public argv: IYargArgv; private globalOptions: IDictionary = { log: { type: OptionType.String, hasSensitiveValue: false }, verbose: { type: OptionType.Boolean, alias: "v", hasSensitiveValue: false }, @@ -19,24 +18,24 @@ export class Options { _: { type: OptionType.String, hasSensitiveValue: false } }; + private initialArgv: yargs.Arguments; + public argv: yargs.Arguments; public options: IDictionary; - public setupOptions(projectData: IProjectData, commandSpecificDashedOptions?: IDictionary): void { + public setupOptions(commandSpecificDashedOptions?: IDictionary): void { if (commandSpecificDashedOptions) { _.extend(this.options, commandSpecificDashedOptions); this.setArgv(); } - if (this.argv.release && this.argv.hmr) { + this.argv.bundle = "webpack"; + + // Check if the user has explicitly provide --hmr and --release options from command line + if (this.initialArgv.release && this.initialArgv.hmr) { this.$errors.failWithoutHelp("The options --release and --hmr cannot be used simultaneously."); } - this.argv.bundle = "webpack"; - - const parsed = require("yargs-parser")(process.argv.slice(2), { 'boolean-negation': false }); - // --no-hmr -> hmr: false or --hmr false -> hmr: 'false' - const noHmr = parsed && (parsed.hmr === false || parsed.hmr === 'false'); - if (!noHmr) { + if (this.argv.hmr) { this.argv.hmr = !this.argv.release; } @@ -111,7 +110,7 @@ export class Options { pluginName: { type: OptionType.String, hasSensitiveValue: false }, includeTypeScriptDemo: { type: OptionType.String, hasSensitiveValue: false }, includeAngularDemo: { type: OptionType.String, hasSensitiveValue: false }, - hmr: { type: OptionType.Boolean, hasSensitiveValue: false }, + hmr: { type: OptionType.Boolean, hasSensitiveValue: false, default: true }, collection: { type: OptionType.String, alias: "c", hasSensitiveValue: false }, json: { type: OptionType.Boolean, hasSensitiveValue: false }, avd: { type: OptionType.String, hasSensitiveValue: true }, @@ -159,8 +158,8 @@ export class Options { return this.argv[optionName]; } - public validateOptions(commandSpecificDashedOptions?: IDictionary, projectData?: IProjectData): void { - this.setupOptions(projectData, commandSpecificDashedOptions); + public validateOptions(commandSpecificDashedOptions?: IDictionary): void { + this.setupOptions(commandSpecificDashedOptions); const parsed = Object.create(null); // DO NOT REMOVE { } as when they are missing and some of the option values is false, the each stops as it thinks we have set "return false". _.each(_.keys(this.argv), optionName => { @@ -251,12 +250,14 @@ export class Options { opts[this.getDashedOptionName(key)] = value; }); - this.argv = yargs(process.argv.slice(2)).options(opts).argv; + const parsed = yargs(process.argv.slice(2)); + this.initialArgv = parsed.argv; + this.argv = parsed.options(opts).argv; // For backwards compatibility // Previously profileDir had a default option and calling `this.$options.profileDir` always returned valid result. // Now the profileDir should be used from $settingsService, but ensure the `this.$options.profileDir` returns the same value. - this.$settingsService.setSettings({ profileDir: this.argv.profileDir }); + this.$settingsService.setSettings({ profileDir: this.argv.profileDir }); this.argv.profileDir = this.argv["profile-dir"] = this.$settingsService.getProfileDir(); // if justlaunch is set, it takes precedence over the --watch flag and the default true value diff --git a/lib/services/webpack/webpack-compiler-service.ts b/lib/services/webpack/webpack-compiler-service.ts index 58110df109..6a6fbcb94a 100644 --- a/lib/services/webpack/webpack-compiler-service.ts +++ b/lib/services/webpack/webpack-compiler-service.ts @@ -1,5 +1,6 @@ import * as path from "path"; import * as child_process from "child_process"; +import * as semver from "semver"; import { EventEmitter } from "events"; import { performanceLog } from "../../common/decorators"; import { WEBPACK_COMPILATION_COMPLETE } from "../../constants"; @@ -71,6 +72,7 @@ export class WebpackCompilerService extends EventEmitter implements IWebpackComp childProcess.on("error", (err) => { this.$logger.trace(`Unable to start webpack process in watch mode. Error is: ${err}`); + delete this.webpackProcesses[platformData.platformNameLowerCase]; reject(err); }); @@ -81,6 +83,7 @@ export class WebpackCompilerService extends EventEmitter implements IWebpackComp this.$logger.trace(`Webpack process exited with code ${exitCode} when we expected it to be long living with watch.`); const error = new Error(`Executing webpack failed with exit code ${exitCode}.`); error.code = exitCode; + delete this.webpackProcesses[platformData.platformNameLowerCase]; reject(error); }); }); @@ -96,12 +99,14 @@ export class WebpackCompilerService extends EventEmitter implements IWebpackComp const childProcess = await this.startWebpackProcess(platformData, projectData, prepareData); childProcess.on("error", (err) => { this.$logger.trace(`Unable to start webpack process in non-watch mode. Error is: ${err}`); + delete this.webpackProcesses[platformData.platformNameLowerCase]; reject(err); }); childProcess.on("close", async (arg: any) => { await this.$cleanupService.removeKillProcess(childProcess.pid.toString()); + delete this.webpackProcesses[platformData.platformNameLowerCase]; const exitCode = typeof arg === "number" ? arg : arg && arg.code; if (exitCode === 0) { resolve(); @@ -130,8 +135,10 @@ export class WebpackCompilerService extends EventEmitter implements IWebpackComp private async startWebpackProcess(platformData: IPlatformData, projectData: IProjectData, prepareData: IPrepareData): Promise { const envData = this.buildEnvData(platformData.platformNameLowerCase, projectData, prepareData); const envParams = this.buildEnvCommandLineParams(envData, platformData, prepareData); + const additionalNodeArgs = semver.major(process.version) <= 8 ? ["--harmony"] : []; const args = [ + ...additionalNodeArgs, path.join(projectData.projectDir, "node_modules", "webpack", "bin", "webpack.js"), "--preserve-symlinks", `--config=${path.join(projectData.projectDir, "webpack.config.js")}`, @@ -170,8 +177,9 @@ export class WebpackCompilerService extends EventEmitter implements IWebpackComp appResourcesPath && { appResourcesPath }, ); - envData.verbose = this.$logger.isVerbose(); - envData.production = prepareData.release; + envData.verbose = envData.verbose || this.$logger.isVerbose(); + envData.production = envData.production || prepareData.release; + if (prepareData.env && (prepareData.env.sourceMap === false || prepareData.env.sourceMap === 'false')) { delete envData.sourceMap; } else if (!prepareData.release) { diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 5c7e81c9fc..07aa7df832 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -1,6 +1,6 @@ { "name": "nativescript", - "version": "6.0.0", + "version": "6.1.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -405,6 +405,21 @@ "@types/node": "*" } }, + "@types/yargs": { + "version": "13.0.0", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-13.0.0.tgz", + "integrity": "sha512-hY0o+kcz9M6kH32NUeb6VURghqMuCVkiUx+8Btsqhj4Hhov/hVGUx9DmBJeIkzlp1uAQK4wngQBCjqWdUUkFyA==", + "dev": true, + "requires": { + "@types/yargs-parser": "*" + } + }, + "@types/yargs-parser": { + "version": "13.0.0", + "resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-13.0.0.tgz", + "integrity": "sha512-wBlsw+8n21e6eTd4yVv8YD/E3xq0O6nNnJIquutAsFGE7EyMKz7W6RNT6BRu1SmdgmlCZ9tb0X+j+D6HGr8pZw==", + "dev": true + }, "abbrev": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", @@ -8298,4 +8313,4 @@ "integrity": "sha512-99p+ohUBZ2Es0AXrw/tpazMcJ0/acpdQXr0UPrVWF0p7i8XiOYvjiXTdwXUVCTPopBGCSDtWBzOoYNPtF3z/8w==" } } -} +} \ No newline at end of file diff --git a/package.json b/package.json index aeac11d9b9..9b934c7cfb 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nativescript", "preferGlobal": true, - "version": "6.0.0", + "version": "6.1.0", "author": "Telerik ", "description": "Command-line interface for building NativeScript projects", "bin": { @@ -115,6 +115,7 @@ "@types/universal-analytics": "0.4.1", "@types/ws": "4.0.1", "@types/xml2js": "0.4.3", + "@types/yargs": "13.0.0", "chai": "4.0.2", "chai-as-promised": "7.0.0", "grunt": "1.0.1", @@ -138,4 +139,4 @@ "engines": { "node": ">=10.0.0 <13.0.0" } -} +} \ No newline at end of file diff --git a/test/controllers/run-controller.ts b/test/controllers/run-controller.ts index e33fbc4688..6b0c200278 100644 --- a/test/controllers/run-controller.ts +++ b/test/controllers/run-controller.ts @@ -96,7 +96,8 @@ function createTestInjector() { prepareData = currentPrepareData; return { platform: prepareData.platform, hasNativeChanges: false }; }, - on: () => ({}) + on: () => ({}), + removeListener: (): void => undefined }); injector.register("prepareNativePlatformService", {}); injector.register("projectChangesService", {}); diff --git a/test/options.ts b/test/options.ts index e45bdbcb9d..92363d685d 100644 --- a/test/options.ts +++ b/test/options.ts @@ -286,6 +286,45 @@ describe("options", () => { assert.deepEqual(actualError, testCase.expectedError); }); }); + + describe("hmr option", () => { + const testCases = [{ + name: "should set hmr to true by default", + expectedHmrValue: true + }, { + name: "should set hmr to false when --no-hmr is provided", + args: ["--no-hmr"], + expectedHmrValue: false + }, { + name: "should set hmr to false when provided through dashed options from command", + commandSpecificDashedOptions: { + hmr: { type: OptionType.Boolean, default: false, hasSensitiveValue: false }, + }, + expectedHmrValue: false + }, { + name: "should set hmr to false by default when --release option is provided", + args: ["--release"], + expectedHmrValue: false + }, { + name: "should set hmr to false by default when --debug-brk option is provided", + args: ["--debugBrk"], + expectedHmrValue: false + }]; + + _.each(testCases, testCase => { + it(testCase.name, () => { + (testCase.args || []).forEach(arg => process.argv.push(arg)); + + const options: any = createOptions(testInjector); + options.setupOptions(testCase.commandSpecificDashedOptions); + + assert.equal(testCase.expectedHmrValue, options.argv.hmr); + assert.isFalse(isExecutionStopped); + + (testCase.args || []).forEach(arg => process.argv.pop()); + }); + }); + }); }); }); diff --git a/test/services/playground/preview-app-livesync-service.ts b/test/services/playground/preview-app-livesync-service.ts index a93d4a7562..105789a1ab 100644 --- a/test/services/playground/preview-app-livesync-service.ts +++ b/test/services/playground/preview-app-livesync-service.ts @@ -184,6 +184,9 @@ function createTestInjector(options?: { executeBeforeHooks: () => ({}), executeAfterHooks: () => ({}) }); + injector.register("pluginsService", { + ensureAllDependenciesAreInstalled: () => { return Promise.resolve(); } + }); return injector; }