From faca4e1300e5a73f28ed36fb4608dbd64ac077ed Mon Sep 17 00:00:00 2001 From: Karl-Philipp Wulfert Date: Mon, 14 Jan 2019 18:11:00 +0100 Subject: [PATCH] docs: enhance and fix readme --- README.md | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 08f0e849..32c98aaa 100644 --- a/README.md +++ b/README.md @@ -49,12 +49,12 @@ openstapps-core-tools src/core lib/schema ```typescript import {Validator} from '@openstapps/core-tools'; -import {SCDish} from '@openstapps/core'; +import {SCDish, SCThingType} from '@openstapps/core'; import {ValidatorResult} from 'jsonschema'; import {join} from 'path'; const objectToValidate: SCDish = { -type: 'Dish', +type: SCThingType.Dish, // more properties }; @@ -62,10 +62,10 @@ type: 'Dish', const validator = new Validator(); // make the validator read the schema files -validator.addSchemas(join('node_modules', '@openstapps', 'core', 'lib', 'schema')); - -// validate an object -const result: ValidatorResult = validator.validate(objectToValidate); +validator.addSchemas(join('node_modules', '@openstapps', 'core', 'lib', 'schema')).then(() => { + // validate an object + const result: ValidatorResult = validator.validate(objectToValidate, 'SCDish'); +}); ``` #### Using validateFiles function @@ -114,13 +114,13 @@ where: Command with the example arguments is then for example: ```shell -node_modules/.bin/openstapps-validate lib/schema src/test/resources +node_modules/.bin/openstapps-core-tools lib/schema src/test/resources ``` Inside of a script in `package.json` or if the npm package is installed globally, the tool `openstapps-validate` can be called without its local path (`node_modules/.bin`): ```shell -openstapps-validate lib/schema src/test/resources report.html +openstapps-core-tools lib/schema src/test/resources report.html ``` ## Generate documentation for routes @@ -132,3 +132,11 @@ The generator relies on dynamic imports and must therefore be run this way. ```shell node --require ts-node/register node_modules/@openstapps/core-tools/src/cli.ts routes PATH/TO/ROUTES.md ``` + +## Pack definitions and implementations + +To pack all the different files into two distribution files - one for definitions/one for implementations - use the following command: + +```shell +openstapps-core-tools pack +```