Skip to content

Commit 2992039

Browse files
committed
Move platform .d.ts-es to separate plugin folder
Add dev-setup to figure out links Update development workflow Update package.json and dts-ios Update the iOS declarations grunt is now fine
1 parent af3fcfb commit 2992039

File tree

145 files changed

+13889
-2642
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

145 files changed

+13889
-2642
lines changed

DevelopmentWorkflow.md

Lines changed: 68 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,91 @@
11
Development Workflow
22
====================
33

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
729
npm install
8-
grunt
930
```
1031

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
1336
```
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
1649
```
1750

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:
1952
```
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
2456
```
2557

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:
2759
```
28-
npm link tns-core-modules
60+
./node_modules/.bin/tsc -p tns-core-modules
2961
```
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.
3262

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
3666
```
37-
npm install
38-
grunt generate-tns-core-modules-dev-dts
39-
tsc
4067

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
4474
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
4879
49-
tns run [ios|android] --path tests
80+
tns run ios --path tests
81+
tns run android --path tests
5082
```
5183

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:
5386
```
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
5989
```
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.

apps/app/ui-tests-app/pages/console.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ export function pageLoaded() {
5757
console.warn("warn");
5858
console.error("error");
5959

60-
console.assert(0 === 1, "%d not equals %d", 0, 1);
61-
console.assert(1 === 1, "1 equals 1");
60+
console.assert(false, "%d not equals %d", 0, 1);
61+
console.assert(true, "1 equals 1");
6262

6363
if (app.android) {
6464
console.dump(true);

apps/references.d.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
/// <reference path="../tns-core-modules/tns-core-modules.d.ts" /> Needed for autocompletion and compilation.
2-
/// <reference path="../tns-core-modules/android17.d.ts" /> Needed for autocompletion and compilation.
3-
/// <reference path="../tns-core-modules/org.nativescript.widgets.d.ts" /> Needed for autocompletion and compilation.
4-
/// <reference path="../tns-core-modules/declarations.android.d.ts" /> Needed for autocompletion and compilation.
1+
/// <reference path="../tns-platform-declarations/android.d.ts" />
2+
/// <reference path="../tns-platform-declarations/ios.d.ts" />
3+
4+
/// <reference path="../tns-core-modules/tns-core-modules.d.ts" />
5+
/// <reference path="../tns-core-modules/lib.core.d.ts" />
6+
/// <reference path="../tns-core-modules/lib.dom.d.ts" />
7+
8+
/// <reference path="../tns-core-modules/ui/styling/css-selector-parser.d.ts" />

build/platform-declarations/.gitignore

Lines changed: 0 additions & 4 deletions
This file was deleted.

build/platform-declarations/gruntfile.js

Lines changed: 0 additions & 163 deletions
This file was deleted.

0 commit comments

Comments
 (0)