ts-runtime-validation 1.2.0 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -16,6 +16,15 @@ This is a code generator that is designed to run as a yarn / npm script. By defa
16
16
 
17
17
  The helper file assumes you have [ajv-validator](https://github.com/ajv-validator/ajv) peer dependency installed. Since this is only a code generation tool this package can be installed as a dev dependency.
18
18
 
19
+ ## Installation
20
+
21
+ ```bash
22
+ # yarn
23
+ yarn add --dev ts-runtime-validation
24
+ # npm
25
+ npm install --dev ts-runtime-validation
26
+ ```
27
+
19
28
  ## CLI usage
20
29
 
21
30
  Ensure your project files containing the schemas you want to validate end with the prefix `.jsonschema.ts`
@@ -32,6 +41,21 @@ Options:
32
41
  -h, --help display help for command
33
42
  ```
34
43
 
44
+ ## npm script usage
45
+
46
+ The intended use for ts-runtime-validation is as a npm script. Here it can also be tweaked to watch (eg. using nodemon)
47
+
48
+ ```json
49
+ {
50
+ "scripts": {
51
+ "generate-types": "ts-runtime-validation"
52
+ },
53
+ "devDependencies": {
54
+ "ts-runtime-validation": "^1.2.0"
55
+ }
56
+ }
57
+ ```
58
+
35
59
  ## Example usage of generated ts type validation
36
60
 
37
61
  ```typescript
package/dist/index.js CHANGED
@@ -8,11 +8,12 @@ const defaultRootPath = "./src";
8
8
  const defaultOutputFolder = "./.ts-runtime-validation";
9
9
  commander_1.program.option("--glob", `Glob file path of typescript files to generate ts-interface -> json-schema validations - default: ${defaultGlobPattern}`, defaultGlobPattern);
10
10
  commander_1.program.option("--rootPath", `RootPath of source - default: ${defaultRootPath}`, defaultRootPath);
11
- commander_1.program.option("--output", `Validation schema + typescript interface output directory (relative to root path) - default: ${defaultOutputFolder}`, defaultOutputFolder);
11
+ commander_1.program.option("--output <outputFolder>", `Validation schema + typescript interface output directory (relative to root path) - default: ${defaultOutputFolder}`, defaultOutputFolder);
12
12
  commander_1.program.option("--no-helpers", "Only generate JSON schema without typescript helper files", true);
13
13
  commander_1.program.option("--additionalProperties", "Allow additional properties to pass validation", false);
14
14
  commander_1.program.parse();
15
15
  const options = commander_1.program.opts();
16
+ console.log(options);
16
17
  const generator = new SchemaGenerator_1.SchemaGenerator(options);
17
18
  generator.Generate();
18
19
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAEA,uDAAoD;AACpD,yCAAoC;AAEpC,MAAM,kBAAkB,GAAG,uBAAuB,CAAC;AAEnD,MAAM,eAAe,GAAG,OAAO,CAAC;AAChC,MAAM,mBAAmB,GAAG,0BAA0B,CAAC;AAUvD,mBAAO,CAAC,MAAM,CACV,QAAQ,EACR,qGAAqG,kBAAkB,EAAE,EACzH,kBAAkB,CACrB,CAAC;AACF,mBAAO,CAAC,MAAM,CAAC,YAAY,EAAE,iCAAiC,eAAe,EAAE,EAAE,eAAe,CAAC,CAAC;AAClG,mBAAO,CAAC,MAAM,CACV,UAAU,EACV,gGAAgG,mBAAmB,EAAE,EACrH,mBAAmB,CACtB,CAAC;AACF,mBAAO,CAAC,MAAM,CAAC,cAAc,EAAE,2DAA2D,EAAE,IAAI,CAAC,CAAC;AAClG,mBAAO,CAAC,MAAM,CAAC,wBAAwB,EAAE,gDAAgD,EAAE,KAAK,CAAC,CAAC;AAElG,mBAAO,CAAC,KAAK,EAAE,CAAC;AAEhB,MAAM,OAAO,GAAG,mBAAO,CAAC,IAAI,EAAmB,CAAC;AAEhD,MAAM,SAAS,GAAG,IAAI,iCAAe,CAAC,OAAO,CAAC,CAAC;AAC/C,SAAS,CAAC,QAAQ,EAAE,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAEA,uDAAoD;AACpD,yCAAoC;AAEpC,MAAM,kBAAkB,GAAG,uBAAuB,CAAC;AAEnD,MAAM,eAAe,GAAG,OAAO,CAAC;AAChC,MAAM,mBAAmB,GAAG,0BAA0B,CAAC;AAUvD,mBAAO,CAAC,MAAM,CACV,QAAQ,EACR,qGAAqG,kBAAkB,EAAE,EACzH,kBAAkB,CACrB,CAAC;AACF,mBAAO,CAAC,MAAM,CAAC,YAAY,EAAE,iCAAiC,eAAe,EAAE,EAAE,eAAe,CAAC,CAAC;AAClG,mBAAO,CAAC,MAAM,CACV,yBAAyB,EACzB,gGAAgG,mBAAmB,EAAE,EACrH,mBAAmB,CACtB,CAAC;AACF,mBAAO,CAAC,MAAM,CAAC,cAAc,EAAE,2DAA2D,EAAE,IAAI,CAAC,CAAC;AAClG,mBAAO,CAAC,MAAM,CAAC,wBAAwB,EAAE,gDAAgD,EAAE,KAAK,CAAC,CAAC;AAElG,mBAAO,CAAC,KAAK,EAAE,CAAC;AAEhB,MAAM,OAAO,GAAG,mBAAO,CAAC,IAAI,EAAmB,CAAC;AAChD,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AAErB,MAAM,SAAS,GAAG,IAAI,iCAAe,CAAC,OAAO,CAAC,CAAC;AAC/C,SAAS,CAAC,QAAQ,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-runtime-validation",
3
- "version": "1.2.0",
3
+ "version": "1.2.3",
4
4
  "author": "Matthew Duong <thegalah@gmail.com>",
5
5
  "license": "MIT",
6
6
  "dependencies": {
package/src/index.ts CHANGED
@@ -23,7 +23,7 @@ program.option(
23
23
  );
24
24
  program.option("--rootPath", `RootPath of source - default: ${defaultRootPath}`, defaultRootPath);
25
25
  program.option(
26
- "--output",
26
+ "--output <outputFolder>",
27
27
  `Validation schema + typescript interface output directory (relative to root path) - default: ${defaultOutputFolder}`,
28
28
  defaultOutputFolder
29
29
  );
@@ -33,6 +33,7 @@ program.option("--additionalProperties", "Allow additional properties to pass va
33
33
  program.parse();
34
34
 
35
35
  const options = program.opts<ICommandOptions>();
36
+ console.log(options);
36
37
 
37
38
  const generator = new SchemaGenerator(options);
38
39
  generator.Generate();