Skip to content

Commit 947aeac

Browse files
committed
updating
1 parent 27d3cad commit 947aeac

File tree

1 file changed

+305
-7
lines changed

1 file changed

+305
-7
lines changed

development-workflow.md

Lines changed: 305 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,6 @@ Alternatively, once you have the NativeScript project built, you can open open t
346346
347347
## HMR
348348
349-
- https://github.com/NativeScript/docs/tree/master/docs/tooling/testing/end-to-end-testing
350-
351349
## Testing
352350
353351
### End to End Testing
@@ -855,16 +853,16 @@ To use TestBed you have to alter your `karma.conf.js` to:
855853
The file `src/tests/setup.ts` should look like this for jasmine:
856854
857855
```typescript
858-
import 'nativescript-angular/zone-js/testing.jasmine'
859-
import { nsTestBedInit } from 'nativescript-angular/testing'
856+
import '@nativescript/angular/zone-js/testing.jasmine'
857+
import { nsTestBedInit } from '@nativescript/angular/testing'
860858
nsTestBedInit()
861859
```
862860
863861
or if using mocha:
864862
865863
```typescript
866-
import 'nativescript-angular/zone-js/testing.mocha'
867-
import { nsTestBedInit } from 'nativescript-angular/testing'
864+
import '@nativescript/angular/zone-js/testing.mocha'
865+
import { nsTestBedInit } from '@nativescript/angular'
868866
nsTestBedInit()
869867
```
870868
@@ -999,7 +997,307 @@ To integrate the NativeScript unit test runner into a continuous integration pro
999997
1000998
## Updating
1001999
1002-
- https://github.com/NativeScript/docs/tree/master/docs/releases
1000+
To upgrade a NativeScript application you need to upgrade several things: NativeScript CLI Tooling, the iOS and Android runtimes and the `@nativescript/core` module. In the steps below you will see how to do this.
1001+
1002+
#### Upgrading the NativeScript tools
1003+
1004+
The below command demonstrates how to upgrade your NativeScript tools known also as NativeScript CLI.
1005+
You should first upgrade your `ns` (or `nativescript`) command, so go to a command prompt or bash/terminal prompt and type:
1006+
1007+
```
1008+
npm install -g nativescript
1009+
```
1010+
1011+
This will automatically download needed files and will update your computer to the latest version of the NativeScript command line.
1012+
You can type `ns --version` to verify that the new version is installed.
1013+
1014+
#### Migrate an existing project to {N} 6.0
1015+
1016+
To migrate an existing NativeScript project to 6.0, you need just to run:
1017+
1018+
```node
1019+
ns migrate
1020+
```
1021+
1022+
This command will perform all the required updates of packages and changes in the project that are required to adjust a 6.0 project with the latest requirements.
1023+
1024+
> Note: The migrate command will update {N} core packages and the below-listed plugins to their 6.0 compatible version:
1025+
1026+
```
1027+
node-sass
1028+
typescript
1029+
less
1030+
nativescript-dev-sass
1031+
nativescript-dev-typescript
1032+
nativescript-dev-less
1033+
nativescript-camera
1034+
nativescript-geolocation
1035+
nativescript-imagepicker
1036+
nativescript-social-share
1037+
nativescript-ui-chart
1038+
nativescript-ui-dataform
1039+
nativescript-ui-gauge
1040+
nativescript-ui-listview
1041+
nativescript-ui-sidedrawer
1042+
nativescript-ui-calendar
1043+
nativescript-ui-autocomplete
1044+
nativescript-datetimepicker
1045+
kinvey-nativescript-sdk
1046+
nativescript-plugin-firebase
1047+
nativescript-vue
1048+
nativescript-permissions
1049+
nativescript-cardview
1050+
```
1051+
1052+
> Note: As soon as you find a problem with the core dependencies - please open an issue in the respective GitHub repository. If unsure, you can open it in the [nativescript/nativescript](https://github.com/nativescript/nativescript/issues) repository. If the problem is related to some of the external plugins, please contact the author by opening a new issue in the plugin's repository.
1053+
1054+
#### Upgrading the application
1055+
1056+
You should execute the **update** command in the root folder of your project to upgrade it with the latest versions of iOS/Android runtimes and cross-platform modules.
1057+
1058+
> The **update** command is introduced in version 2.4 of NativeScript CLI. You should update NativeScript CLI before using this command.
1059+
1060+
```node
1061+
ns update
1062+
```
1063+
1064+
In order to get the latest development release instead, pass **next** as argument:
1065+
1066+
```node
1067+
ns update next
1068+
```
1069+
1070+
You can also switch to specific version by passing it to the command:
1071+
1072+
```node
1073+
ns update 8.0.0
1074+
```
1075+
1076+
::: tip Note
1077+
The command `ns update` is updating the `@nativescript/core, `@nativescript/webpack`, and the runtimes (`@nativescript/android`and`@nativescript/ios`). The command is combining the next three commands in this article (`ns platform add`, `npm i @nativescript/core`and`npm i @nativescript/webpack --save-dev`).
1078+
1079+
After updating the `@nativescript/webpack`, we must update our `webpack.config.js` as well. To do that we can execute the `update-ns-webpack` automated script with the following line:
1080+
1081+
```node
1082+
./node_modules/.bin/update-ns-webpack --deps --configs
1083+
```
1084+
1085+
:::
1086+
1087+
::: warning Important
1088+
When using the `--configs` flag, any previous configuration will be overwritten and lost. Consider saving any custom code that you have introduced in your `webpack.config.js` and reapplying the code after using the `--configs` flag.
1089+
:::
1090+
1091+
#### Upgrading platforms
1092+
1093+
Follow those steps in order to get the latest versions of Android and/or iOS runtimes. Navigate to the root level folder where your project is, and then if you are working on a Android project, type:
1094+
1095+
```
1096+
ns platform remove android
1097+
ns platform add android
1098+
```
1099+
1100+
and/or (if you are working on a iOS version on a Mac):
1101+
1102+
```
1103+
ns platform remove ios
1104+
ns platform add ios
1105+
```
1106+
1107+
#### Upgrading @nativescript/core
1108+
1109+
The cross-platform modules are available as a npm package named [@nativescript/core](https://www.npmjs.com/package/@nativescript/core).
1110+
1111+
In order to use them in your project, you will have to explicitly install the package, for example (assuming you are still in your main app project folder from the steps above):
1112+
1113+
```
1114+
npm install @nativescript/core@latest --save
1115+
```
1116+
1117+
This installs the **@nativescript/core** package to the node_modules folder and adds it as a dependency to the package.json of the project.
1118+
1119+
::: warning Important
1120+
The `ns create` command will create a new project, add the **@nativescript/core** package as a dependency to its package.json and install it. So each new project you create will have the **@nativescript/core** package installed and you do not have to install it explicitly.
1121+
:::
1122+
1123+
Another place to find **@nativescript/core** package is [NativeScript Releases](https://github.com/NativeScript/NativeScript/releases/), where you can find a collection of the available @nativescript/core-\*.tgz packages for every release. You can download a selected release and install it by running: `npm install <path to @nativescript/core-*.tgz> --save`.
1124+
1125+
#### Upgrading Webpack
1126+
1127+
The Webpack plugin is available as a npm package named [@nativescript/webpack](https://www.npmjs.com/package/@nativescript/webpack). To use the plugin in your project, you should explicitly install the package as `devDependency`.The initial installation of the plugin will install all related development dependencies and will create the default `webpack.config.js` file. If the `webpack.config.js` file is already existing it won't be overwritten by the installation of `@nativescript/webpack`.
1128+
1129+
```node
1130+
npm i @nativescript/webpack --save-dev
1131+
```
1132+
1133+
::: tip Note
1134+
From NativeScript 6.0, all project should be webpack compatible.
1135+
:::
1136+
1137+
#### Updating Webpack version and configuration
1138+
1139+
When upgrading an existing version of the Webpack plugin, you should consider that the related development dependencies also have to be updated accordingly. To ease the process, the plugin provides an automated script for that purpose called `update-ns-webpack` located in `<project-folder>/node_modules/.bin` folder. The script comes with two flags:
1140+
1141+
- `--deps` - this flag will update all related development dependencies.
1142+
- `--configs` - this flag will update the default `webpack.config.js` file.
1143+
1144+
```node
1145+
npm i @nativescript/webpack@latest --save-dev
1146+
./node_modules/.bin/update-ns-webpack --deps --configs
1147+
```
1148+
1149+
::: tip Important
1150+
When using the `--configs` flag, any previous configuration will be overwritten and lost. Consider saving any custom code that you have introduced in your `webpack.config.js` and reapplying the code after using the `--configs` flag.
1151+
:::
1152+
1153+
#### Upgrading Angular dependencies
1154+
1155+
The Angular plugin is available as an npm package named [@nativescript/angular](https://www.npmjs.com/package/@nativescript/angular). To update the version of the plugin and the related dependency, the package should be explicitly installed, and the related Angular dependencies should be updated accordingly. To ease the update process, the plugin comes with an automated script `update-app-ng-deps` located in `<project-folder/node_modules/.bin>` folder.
1156+
1157+
```
1158+
npm i @nativescript/angular@latest --save
1159+
./node_modules/.bin/update-app-ng-deps
1160+
npm i
1161+
```
1162+
1163+
---
1164+
1165+
title: Running Latest Code
1166+
description: NativeScript Documentation - Running Latest Code
1167+
position: 40
1168+
slug: latest-code
1169+
previous_url: /running-latest
1170+
1171+
---
1172+
1173+
#### Running the Latest Code
1174+
1175+
Often when working with open-source projects, one needs functionality that has not yet passed the full release cycle, or even functionality that is not yet fully implemented. We know that many of you are experimenters and want to try the latest and greatest features of NativeScript. That is why we tried to make this process simple and easy to follow. There are two ways to get the latest development code for NativeScript:
1176+
1177+
- You can get it via npm.
1178+
- You can build the source code.
1179+
1180+
#### Getting the latest development version via npm
1181+
1182+
As an open-source project NativeScript keeps not only its source code but its build infrastructure open. That is why we choose [Travis CI](https://travis-ci.org/) for our nightly builds. Every commit in the master branch of all major NativeScript repos triggers a [Travis CI](https://travis-ci.org/) build which publishes an npm package that can be used directly. Follow those simple steps to get the latest development version of NativeScript:
1183+
1184+
- Uninstall any existing NativeScript versions:
1185+
1186+
```shell
1187+
npm uninstall -g nativescript
1188+
```
1189+
1190+
- Install the latest development version of NativeScript CLI:
1191+
1192+
```shell
1193+
npm install -g nativescript@next
1194+
```
1195+
1196+
- Edit the package.json file in your project and replace @nativescript/core, tns-android and tns-ios versions with `next`:
1197+
1198+
```json
1199+
{
1200+
"description": "NativeScript Application",
1201+
"dependencies": {
1202+
"@nativescript/core": "next"
1203+
},
1204+
"devDependencies": {
1205+
"@nativescript/android": "next",
1206+
"@nativescript/ios": "next"
1207+
}
1208+
}
1209+
```
1210+
1211+
Instead of editing the package.json file by hand, you could run the following commands:
1212+
1213+
```shell
1214+
tns platform add ios@next
1215+
tns platform add android@next
1216+
tns plugin add @nativescript/core@next
1217+
```
1218+
1219+
- Run the `npm install` command to update the node modules:
1220+
1221+
```shell
1222+
cd <your-project-folder>
1223+
npm install
1224+
```
1225+
1226+
You are now ready to use the latest development version of NativeScript.
1227+
1228+
#### Building the source code
1229+
1230+
##### Reasoning
1231+
1232+
Building the source code is essential when one wants to contribute to an open source project. The statement is applicable for NativeScript as well. According to the [Contribution Guidelines](https://github.com/NativeScript/NativeScript/blob/master/CONTRIBUTING.md), suggesting a fix involves testing the latest code.
1233+
1234+
#### Behind the curtains of running a NativeScript application
1235+
1236+
1. `npm install nativescript -g` : Node Package Manager (npm) downloads and installs the [NativeScript CLI](https://www.npmjs.com/package/nativescript).
1237+
2. `ns create [AppName]` : The NativeScript CLI downloads the [Hello-World template](https://www.npmjs.com/package/tns-template-hello-world) and unpacks it to a folder named after the app name you choose. At the same time, the CLI installs the [NativeScript cross-platform modules](https://www.npmjs.com/package/@nativescript/core). As a result, your application folder now contains an `app` folder, holding the files of your application ([source code](https://github.com/NativeScript/template-hello-world)) and a `node_modules` folder, having the cross-platform modules ([source code](https://github.com/NativeScript/NativeScript)).
1238+
3. `ns platform add android/ios` : The NativeScript CLI downloads the latest SemVer-compatible version of the specified runtime, unpacks it and applies transformations to the native (Android Studio or xCode) project (e.g., changes the project name).
1239+
4. `ns run android/ios` : The NativeScript CLI copies the files under the `app` folder to the `platforms/[android/ios]/.../app` folder following a specific logic so that these get used later by a native build tool (_gradle_/_xcode-build_). As a next step, the NativeScript CLI executes compilation, deployment and run commands of _gradle_ or _xcode-build_.
1240+
5. Any JavaScript code gets executed in a V8 or JavaScriptCore engine and embedded in the NativeScript runtimes. Each call to an actual native object gets marshalled via the runtimes to the underlying platform and vice-versa. The runtimes provide JavaScript handles to the native objects.
1241+
1242+
#### Contents of the NativeScript repo
1243+
1244+
The [NativeScript framework](https://github.com/NativeScript/NativeScript) is built using TypeScript. For that, one of the build steps is TypeScript compilation, which uses TypeScript declarations of the underlying native objects. These are really large files ([android17.d.ts](https://github.com/NativeScript/NativeScript/blob/master/android17.d.ts) and [ios.d.ts](https://github.com/NativeScript/NativeScript/blob/master/ios.d.ts)). The TypeScript compilation with these two files loaded in memory takes a lot of time. To save development time and have as quick and stable feature output, the NativeScript team decided to keep several important applications inside the same repository so that all of them get compiled in a single pass.
1245+
1246+
Having said that, each subfolder of the [apps](https://github.com/NativeScript/NativeScript/tree/master/apps) subfolder of the repo represents a single application.
1247+
1248+
#### Building the repo
1249+
1250+
When the repo gets built, it outputs a bunch of packages (stripping the version- and extension- part of the filename for clarity):
1251+
1252+
- @nativescript/core : the package, containing the core modules. It gets distributed via [npm](https://www.npmjs.com/package/@nativescript/core).
1253+
- tns-sample-\* : contains some test/demo applications the team uses internally for testing.
1254+
- tns-template-\* : has templates that will get used once we have the [template-selection functionality](https://github.com/NativeScript/nativescript-cli/issues/374) implemented in the command-line interface.
1255+
1256+
The repo gets built via the commands:
1257+
1258+
```shell
1259+
npm install -g grunt-cli
1260+
npm install
1261+
grunt
1262+
```
1263+
1264+
#### Using the latest
1265+
1266+
To use the latest:
1267+
1268+
- Build the repo.
1269+
- Navigate to your project folder.
1270+
- Delete the `@nativescript/core` folder from the `node_modules` subfolder of your project (i.e., `rm -rf node_modules/@nativescript/core` for Linux or `rd /S /Q node_modules\@nativescript/core`).
1271+
- Install the newly built package (`npm install [PATH-TO-NATIVESCRIPT-REPO/bin/dist/nativescript-core-x.x.x.tgz]`).
1272+
1273+
#### Handling internal breaking changes
1274+
1275+
It is possible that an internal breaking change gets introduced involving an update to both the runtimes and the modules. An internal breaking change would mean that the public API of the tns_modules does not get affected, but a work in progress change in the runtimes requires a change in the internal code of the tns_modules themselves.
1276+
1277+
When such a case happens, the [ios](https://github.com/NativeScript/ns-v8ios-runtime) and [android](https://github.com/NativeScript/android-runtime) runtimes must be built separately and updated via the CLI command of:
1278+
`tns platform update android/ios --frameworkPath=[Path-to-Runtime-Package]`
1279+
1280+
#### Building the runtimes
1281+
1282+
As the NativeScript framework gets distributed via npm, the runtimes are also packed as npm packages. For consistency reasons, the native builds (gradle/xcode-build) are wrapped by grunt builds that do the job.
1283+
1284+
#### Building the Android runtime
1285+
1286+
The [android runtime](https://github.com/NativeScript/android-runtime) depends on the [android-metadata-generator](https://github.com/NativeScript/android-metadata-generator).
1287+
1288+
Provided you have all the dependencies set, the easiest way to have the Android runtime built is to clone the two repos to a single folder so that the two are sibling folders, `cd` into the `android-runtime` folder and run:
1289+
1290+
```
1291+
gradle packar -PwidgetsPath=./widgets.jar
1292+
```
1293+
1294+
The resulting tns-android-x.x.x.tgz package will get created in the `dist` folder.
1295+
1296+
#### Building the iOS runtime
1297+
1298+
Follow the instructions on setting up the dependencies for building the [ios runtime](https://github.com/NativeScript/ns-v8ios-runtime) in the repository README and then run `grunt package`.
1299+
1300+
The build tns-ios-x.x.x.tgx package will get created in the `dist` folder.
10031301
10041302
## Choosing An Editor
10051303

0 commit comments

Comments
 (0)