@goldstack/utils-json-to-ts 0.3.36 → 0.4.0

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
@@ -1,5 +1,5 @@
1
- # JSON to TS Utilities
2
-
3
- This library contains a simple wrapper around [json-schema-to-typescript](https://www.npmjs.com/package/json-schema-to-typescript) for use in Goldstack templates.
4
-
5
- This approach is deprecated in favour of generating JSON schema from TypeScript.
1
+ # JSON to TS Utilities
2
+
3
+ This library contains a simple wrapper around [json-schema-to-typescript](https://www.npmjs.com/package/json-schema-to-typescript) for use in Goldstack templates.
4
+
5
+ This approach is deprecated in favour of generating JSON schema from TypeScript.
package/bin/jsontots CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
2
-
3
- // eslint-disable-next-line @typescript-eslint/no-var-requires
4
- require('./../dist/src/utilsJsonToTs.js').run(process.argv);
1
+ #!/usr/bin/env node
2
+
3
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
4
+ require('./../dist/src/utilsJsonToTs.js').run(process.argv);
@@ -1,2 +1,2 @@
1
- export declare const run: (args: string[]) => Promise<void>;
1
+ export declare const run: (args: string[]) => Promise<void>;
2
2
  //# sourceMappingURL=utilsJsonToTs.d.ts.map
@@ -1,46 +1,46 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.run = void 0;
7
- const json_schema_to_typescript_1 = require("json-schema-to-typescript");
8
- const utils_sh_1 = require("@goldstack/utils-sh");
9
- const fs_1 = __importDefault(require("fs"));
10
- const path_1 = __importDefault(require("path"));
11
- const replace_ext_1 = __importDefault(require("replace-ext"));
12
- const processSchema = async (jsonSource, dest, options) => {
13
- let bannerComment = undefined;
14
- const tsHeader = (0, replace_ext_1.default)(jsonSource, '.head.ts');
15
- if (fs_1.default.existsSync(tsHeader)) {
16
- bannerComment = (0, utils_sh_1.read)(tsHeader);
17
- }
18
- const res = await (0, json_schema_to_typescript_1.compileFromFile)(jsonSource, {
19
- style: {
20
- bracketSpacing: true,
21
- printWidth: 120,
22
- semi: true,
23
- singleQuote: true,
24
- tabWidth: 2,
25
- trailingComma: 'es5',
26
- useTabs: false,
27
- },
28
- bannerComment,
29
- ...options,
30
- });
31
- const newName = path_1.default.parse(path_1.default.basename(jsonSource)).name;
32
- (0, utils_sh_1.mkdir)('-p', dest);
33
- (0, utils_sh_1.write)(res, dest + newName + '.ts');
34
- };
35
- const run = async (args) => {
36
- const files = (0, utils_sh_1.globSync)('./src/schemas/*.json');
37
- const declareExternallyReferenced = args.length >= 3 && args[2] === '--declareExternallyReferenced';
38
- files.forEach(async (file) => {
39
- await processSchema(file, './src/generated/', {
40
- declareExternallyReferenced,
41
- });
42
- console.log('Processed: ' + file);
43
- });
44
- };
45
- exports.run = run;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.run = void 0;
7
+ const json_schema_to_typescript_1 = require("json-schema-to-typescript");
8
+ const utils_sh_1 = require("@goldstack/utils-sh");
9
+ const fs_1 = __importDefault(require("fs"));
10
+ const path_1 = __importDefault(require("path"));
11
+ const replace_ext_1 = __importDefault(require("replace-ext"));
12
+ const processSchema = async (jsonSource, dest, options) => {
13
+ let bannerComment = undefined;
14
+ const tsHeader = (0, replace_ext_1.default)(jsonSource, '.head.ts');
15
+ if (fs_1.default.existsSync(tsHeader)) {
16
+ bannerComment = (0, utils_sh_1.read)(tsHeader);
17
+ }
18
+ const res = await (0, json_schema_to_typescript_1.compileFromFile)(jsonSource, {
19
+ style: {
20
+ bracketSpacing: true,
21
+ printWidth: 120,
22
+ semi: true,
23
+ singleQuote: true,
24
+ tabWidth: 2,
25
+ trailingComma: 'es5',
26
+ useTabs: false,
27
+ },
28
+ bannerComment,
29
+ ...options,
30
+ });
31
+ const newName = path_1.default.parse(path_1.default.basename(jsonSource)).name;
32
+ (0, utils_sh_1.mkdir)('-p', dest);
33
+ (0, utils_sh_1.write)(res, dest + newName + '.ts');
34
+ };
35
+ const run = async (args) => {
36
+ const files = (0, utils_sh_1.globSync)('./src/schemas/*.json');
37
+ const declareExternallyReferenced = args.length >= 3 && args[2] === '--declareExternallyReferenced';
38
+ files.forEach(async (file) => {
39
+ await processSchema(file, './src/generated/', {
40
+ declareExternallyReferenced,
41
+ });
42
+ console.log('Processed: ' + file);
43
+ });
44
+ };
45
+ exports.run = run;
46
46
  //# sourceMappingURL=utilsJsonToTs.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goldstack/utils-json-to-ts",
3
- "version": "0.3.36",
3
+ "version": "0.4.0",
4
4
  "description": "Utility to convert JSON schema into TypeScript interfaces.",
5
5
  "keywords": [
6
6
  "goldstack",
@@ -38,13 +38,13 @@
38
38
  "version:apply:force": "yarn version $@ && yarn version apply"
39
39
  },
40
40
  "dependencies": {
41
- "@goldstack/utils-log": "0.2.17",
42
- "@goldstack/utils-sh": "0.4.35",
41
+ "@goldstack/utils-log": "0.3.0",
42
+ "@goldstack/utils-sh": "0.5.0",
43
43
  "json-schema-to-typescript": "^9.1.1",
44
44
  "replace-ext": "^2.0.0"
45
45
  },
46
46
  "devDependencies": {
47
- "@goldstack/utils-git": "0.1.37",
47
+ "@goldstack/utils-git": "0.2.0",
48
48
  "@types/jest": "^28.1.8",
49
49
  "@types/node": "^18.7.13",
50
50
  "@types/replace-ext": "^0.0.27",