|
1 | 1 | Development Workflow |
2 | 2 | ==================== |
3 | 3 |
|
4 | | -## Full build |
5 | | -This will create all deliverables from the NativeScript repo in the `bin/dist/*.tgz` folder: |
6 | | -``` |
| 4 | +The repository contains several packages and apps: |
| 5 | + - `tns-platform-declarations` - Android and iOS native APIs supported in JavaScript |
| 6 | + - `tns-core-modules` - Core ui, io and sensor modules |
| 7 | + - `apps` - UI app used for manual testing and automation |
| 8 | + - `tests` - Unit tests for the `tns-core-modules` |
| 9 | + |
| 10 | +Working with the repo is organized with npm scripts, |
| 11 | +go and read through the `scripts` section in the [package.json](./package.json). |
| 12 | + |
| 13 | +Managing dependencies: |
| 14 | + - `tns-core-modules` depends on: |
| 15 | + - `tns-platform-declarations` |
| 16 | + - `apps` depends on: |
| 17 | + - `tns-platform-declarations` |
| 18 | + - `tns-core-modules` |
| 19 | + - `tests` depends on: |
| 20 | + - `tns-platform-declarations` |
| 21 | + - `tns-core-modules` |
| 22 | + |
| 23 | +> NOTE: `tns-core-modules` depends on `tns-core-modules-widgets`, |
| 24 | +this dependency contains native code and is rarely modified so for now it remains outside this repo. |
| 25 | + |
| 26 | +## Manage Dependencies |
| 27 | +Get devDependencies by: |
| 28 | +```bash |
7 | 29 | npm install |
8 | | -grunt |
9 | 30 | ``` |
10 | 31 |
|
11 | | -## Using tns-core-modules from source in app |
12 | | -This will register the location of the `tns-core-modules` sources as symlink in your npm: |
| 32 | +Setting up the environment for work we use [`npm link`](https://docs.npmjs.com/cli/link). |
| 33 | +The dependencies in the repo are `npm link`-ed (~synlinked) using the following script: |
| 34 | +```bash |
| 35 | +npm run setup |
13 | 36 | ``` |
14 | | -cd tns-core-modules |
15 | | -npm link |
| 37 | + |
| 38 | +## TypeScript |
| 39 | +The following commands are commonly used to compile the `tns-core-modules`: |
| 40 | +```bash |
| 41 | +# Full tsc with type checking ~22.2s. |
| 42 | +tsc -p tns-core-modules |
| 43 | + |
| 44 | +# Fast tsc ~11.2s. |
| 45 | +tsc -p tns-core-modules --skipLibCheck |
| 46 | + |
| 47 | +# Fast watcher, ~4s. on save |
| 48 | +tsc -p tns-core-modules --skipLibCheck -w |
16 | 49 | ``` |
17 | 50 |
|
18 | | -To rebuild the JavaScript of the `tns-core-modules`, in the root of the NativeScript repo: |
| 51 | +Compiling the modules, tests and apps has also npm scripts: |
19 | 52 | ``` |
20 | | -# this will update tns-core-modules.d.ts references with new .d.ts files |
21 | | -grunt generate-tns-core-modules-dev-dts |
22 | | -# this will rebuild the TS to JS |
23 | | -tsc |
| 53 | +npm run dev-tsc-tns-core-modules |
| 54 | +npm run dev-tsc-tests |
| 55 | +npm run dev-tsc-apps |
24 | 56 | ``` |
25 | 57 |
|
26 | | -Then you can navigate to any NativeScript App and add the `tns-core-modules` from the NativeScript repo to the `node_modules/tns-core-modules` in the app with: |
| 58 | +The modules have `typescript` as devDependency so you should also be able to use locally installed TypeScript compiler from node_modules: |
27 | 59 | ``` |
28 | | -npm link tns-core-modules |
| 60 | +./node_modules/.bin/tsc -p tns-core-modules |
29 | 61 | ``` |
30 | | -You should be able to debug the App in VSCode, breakpoints in the `node_modules/tns-core-modules` TypeScript files should work. |
31 | | -Changes in the App's `node_modules/tns-core-modules` will edit the files in the NativeScript repo so you should be able to easily add changes to git. |
32 | 62 |
|
33 | | -## Running mobile unit tests |
34 | | -There is `tests` folder with regular NativeScript application that runs tests on the `tns-core-modules`. |
35 | | -To run them (see Using tns-core-modules from source in app): |
| 63 | +You can compile the typescript files in the `tns-core-modules`, `tns-platform-declarations`, `apps` and `tests` at once at the root of the repo: |
| 64 | +``` |
| 65 | +npm run tsc |
36 | 66 | ``` |
37 | | -npm install |
38 | | -grunt generate-tns-core-modules-dev-dts |
39 | | -tsc |
40 | 67 |
|
41 | | -cd tns-core-modules |
42 | | -npm link |
43 | | -cd .. |
| 68 | +## Tests |
| 69 | +The test app is an ordinary NativeScript app that logs the test results as it go. |
| 70 | +To run the test app: |
| 71 | +``` |
| 72 | +# Once after npm install |
| 73 | +npm run setup |
44 | 74 |
|
45 | | -cd tests |
46 | | -npm link tns-core-modules |
47 | | -cd .. |
| 75 | +# After changes in the modules |
| 76 | +tsc -p tns-core-modules |
| 77 | +# After changes in the tests |
| 78 | +tsc -p tests |
48 | 79 |
|
49 | | -tns run [ios|android] --path tests |
| 80 | +tns run ios --path tests |
| 81 | +tns run android --path tests |
50 | 82 | ``` |
51 | 83 |
|
52 | | -You can rapidly apply canges to the `tns-core-modules` and `tests`, and to run the tests, at the root of the NativeScript repo, execute: |
| 84 | +## Platform declarations |
| 85 | +To update the platform declarations you can run: |
53 | 86 | ``` |
54 | | -# optionally, if you have added new .d.ts files |
55 | | -grunt generate-tns-core-modules-dev-dts |
56 | | -
|
57 | | -tsc |
58 | | -tns run [ios|android] --path tests |
| 87 | +npm install |
| 88 | +npm run dev-declarations |
59 | 89 | ``` |
| 90 | +This script will update the iOS declarations. Android tools are not integrated yet. |
| 91 | +The declarations are generated from the test app and will include the native code from tns-core-modules-widgets. |
0 commit comments