-
Notifications
You must be signed in to change notification settings - Fork 227
Typescript workflow
Each SDK package has its own folder that follows the same convention:
-
devdoccontains our requirement documents that list what we expect from each class/API. It's more of a technical specification detailing expectations and tests than API documentation. Each requirement is identified by a tag and the corresponding tag can be found both in code and docs, in order to quickly locate an implementation detail. -
srccontains the Typescript code -
testcontains the Javascript test code. For now, we're keeping our javascript tests because it's what most of our customers use but we will consider moving the tests to Typescript too in the future. -
libcontains the generated Javascript code, the generated Typescript declaration files and during development the generated .map files. This folder shall not be checked in.
NPM packages ship basically the content of the lib folder as well as entrypoints and metadata files. Meaning only the Javascript code and .d.ts files find their way to the package.
Because the full implementation of a feature can span across multiple packages, it is necessary to be able to "link" packages together, meaning relying on edited files on the local hard drive instead of files downloaded from NPM packages in the node_modules folder.
To make it easier to link packages together, we've created the dev_setup.(sh|cmd) scripts in the /build folder. These will create the proper links between all packages, install all dependencies, and transpile the typescript code into javascript so that you're ready to write code and debug as soon as it's done.
As of writing this, we haven't adopted gulp/grunt and therefore rely on npm scripts described in package.json files. All packages come with the same scripts:
-
lintwill run the code linter,tslintin our case. We do not lint the generated javascript code. All packages share the sametslint.jsonfile located at the root of the repository. -
buildwill run the Typescript compiler, without any command line options, relying exclusively on atsconfig.jsonfile for each package. -
alltestswill run all tests including integration tests with the defaultmochareporter -
alltests-minwill run all tests including integration tests with the minimalmochareporter, printing ony one character per test. -
unittestswill run only unit tests with the defaultmochareporter -
unittests-minwill run only unit tests with the minimalmochareporter, printing ony one character per test. -
ciwill run the linter, compiler and all tests, with minimalmochareports, then will check code coverage numbers.
- Create a local copy of the repository and cd into it
$ git clone https://github.com/azure/azure-iot-sdk-node
$ cd azure-iot-sdk-node
- Create links between all packages
$ .\build\dev_setup.cmd
or
$ ./build/dev_setup.sh
- Change some code in the typescript files
- Build/Lint your code changes
$ npm -s run build
$ npm -s run lint
- Assuming you've now fixed all errors, run the tests
$ npm -s run ci
If all tests pass, code review/pull request and checking your stuff in are in order.
This is all detailed here