mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
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
This commit is contained in:
@@ -1,59 +1,91 @@
|
||||
Development Workflow
|
||||
====================
|
||||
|
||||
## Full build
|
||||
This will create all deliverables from the NativeScript repo in the `bin/dist/*.tgz` folder:
|
||||
The repository contains several packages and apps:
|
||||
- `tns-platform-declarations` - Android and iOS native APIs supported in JavaScript
|
||||
- `tns-core-modules` - Core ui, io and sensor modules
|
||||
- `apps` - UI app used for manual testing and automation
|
||||
- `tests` - Unit tests for the `tns-core-modules`
|
||||
|
||||
Working with the repo is organized with npm scripts,
|
||||
go and read through the `scripts` section in the [package.json](./package.json).
|
||||
|
||||
Managing dependencies:
|
||||
- `tns-core-modules` depends on:
|
||||
- `tns-platform-declarations`
|
||||
- `apps` depends on:
|
||||
- `tns-platform-declarations`
|
||||
- `tns-core-modules`
|
||||
- `tests` depends on:
|
||||
- `tns-platform-declarations`
|
||||
- `tns-core-modules`
|
||||
|
||||
> NOTE: `tns-core-modules` depends on `tns-core-modules-widgets`,
|
||||
this dependency contains native code and is rarely modified so for now it remains outside this repo.
|
||||
|
||||
## Manage Dependencies
|
||||
Get devDependencies by:
|
||||
```bash
|
||||
npm install
|
||||
```
|
||||
|
||||
Setting up the environment for work we use [`npm link`](https://docs.npmjs.com/cli/link).
|
||||
The dependencies in the repo are `npm link`-ed (~synlinked) using the following script:
|
||||
```bash
|
||||
npm run setup
|
||||
```
|
||||
|
||||
## TypeScript
|
||||
The following commands are commonly used to compile the `tns-core-modules`:
|
||||
```bash
|
||||
# Full tsc with type checking ~22.2s.
|
||||
tsc -p tns-core-modules
|
||||
|
||||
# Fast tsc ~11.2s.
|
||||
tsc -p tns-core-modules --skipLibCheck
|
||||
|
||||
# Fast watcher, ~4s. on save
|
||||
tsc -p tns-core-modules --skipLibCheck -w
|
||||
```
|
||||
|
||||
Compiling the modules, tests and apps has also npm scripts:
|
||||
```
|
||||
npm run dev-tsc-tns-core-modules
|
||||
npm run dev-tsc-tests
|
||||
npm run dev-tsc-apps
|
||||
```
|
||||
|
||||
The modules have `typescript` as devDependency so you should also be able to use locally installed TypeScript compiler from node_modules:
|
||||
```
|
||||
./node_modules/.bin/tsc -p tns-core-modules
|
||||
```
|
||||
|
||||
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:
|
||||
```
|
||||
npm run tsc
|
||||
```
|
||||
|
||||
## Tests
|
||||
The test app is an ordinary NativeScript app that logs the test results as it go.
|
||||
To run the test app:
|
||||
```
|
||||
# Once after npm install
|
||||
npm run setup
|
||||
|
||||
# After changes in the modules
|
||||
tsc -p tns-core-modules
|
||||
# After changes in the tests
|
||||
tsc -p tests
|
||||
|
||||
tns run ios --path tests
|
||||
tns run android --path tests
|
||||
```
|
||||
|
||||
## Platform declarations
|
||||
To update the platform declarations you can run:
|
||||
```
|
||||
npm install
|
||||
grunt
|
||||
```
|
||||
|
||||
## Using tns-core-modules from source in app
|
||||
This will register the location of the `tns-core-modules` sources as symlink in your npm:
|
||||
```
|
||||
cd tns-core-modules
|
||||
npm link
|
||||
```
|
||||
|
||||
To rebuild the JavaScript of the `tns-core-modules`, in the root of the NativeScript repo:
|
||||
```
|
||||
# this will update tns-core-modules.d.ts references with new .d.ts files
|
||||
grunt generate-tns-core-modules-dev-dts
|
||||
# this will rebuild the TS to JS
|
||||
tsc
|
||||
```
|
||||
|
||||
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:
|
||||
```
|
||||
npm link tns-core-modules
|
||||
```
|
||||
You should be able to debug the App in VSCode, breakpoints in the `node_modules/tns-core-modules` TypeScript files should work.
|
||||
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.
|
||||
|
||||
## Running mobile unit tests
|
||||
There is `tests` folder with regular NativeScript application that runs tests on the `tns-core-modules`.
|
||||
To run them (see Using tns-core-modules from source in app):
|
||||
```
|
||||
npm install
|
||||
grunt generate-tns-core-modules-dev-dts
|
||||
tsc
|
||||
|
||||
cd tns-core-modules
|
||||
npm link
|
||||
cd ..
|
||||
|
||||
cd tests
|
||||
npm link tns-core-modules
|
||||
cd ..
|
||||
|
||||
tns run [ios|android] --path tests
|
||||
```
|
||||
|
||||
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:
|
||||
```
|
||||
# optionally, if you have added new .d.ts files
|
||||
grunt generate-tns-core-modules-dev-dts
|
||||
|
||||
tsc
|
||||
tns run [ios|android] --path tests
|
||||
npm run dev-declarations
|
||||
```
|
||||
This script will update the iOS declarations. Android tools are not integrated yet.
|
||||
The declarations are generated from the test app and will include the native code from tns-core-modules-widgets.
|
||||
Reference in New Issue
Block a user