json-schema-to-typescript
Advanced tools
Comparing version 4.2.1 to 4.3.0
@@ -106,5 +106,5 @@ #!/usr/bin/env node | ||
function printHelp() { | ||
var pkg = require('../package.json'); | ||
var pkg = require('../../package.json'); | ||
process.stdout.write("\n" + pkg.name + " " + pkg.version + "\nUsage: json2ts [--input, -i] [IN_FILE] [--output, -o] [OUT_FILE]\n\nWith no IN_FILE, or when IN_FILE is -, read standard input.\nWith no OUT_FILE and when IN_FILE is specified, create .d.ts file in the same directory.\nWith no OUT_FILE nor IN_FILE, write to standard output.\n"); | ||
} | ||
//# sourceMappingURL=cli.js.map |
@@ -11,2 +11,3 @@ "use strict"; | ||
return [ | ||
options.bannerComment, | ||
declareNamedTypes(ast, options), | ||
@@ -13,0 +14,0 @@ declareNamedInterfaces(ast, options, ast.standaloneName), |
import { JSONSchema4 } from 'json-schema'; | ||
export { EnumJSONSchema, JSONSchema, NamedEnumJSONSchema } from './types/JSONSchema'; | ||
export interface Options { | ||
bannerComment: string; | ||
cwd: string; | ||
@@ -5,0 +6,0 @@ declareReferenced: boolean; |
@@ -67,2 +67,3 @@ "use strict"; | ||
exports.DEFAULT_OPTIONS = { | ||
bannerComment: "/**\n* This file was automatically generated by json-schema-to-typescript.\n* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,\n* and run json-schema-to-typescript to regenerate this file.\n*/", | ||
cwd: process.cwd(), | ||
@@ -69,0 +70,0 @@ declareReferenced: true, |
import { JSONSchema, NormalizedJSONSchema } from './types/JSONSchema'; | ||
export declare function normalize(schema: JSONSchema, filename: string): NormalizedJSONSchema; | ||
export declare function normalize(schema: JSONSchema, filename?: string): NormalizedJSONSchema; |
@@ -12,3 +12,3 @@ export declare function Try<T>(fn: () => T, err: (e: Error) => any): T; | ||
*/ | ||
export declare function justName(filename: string): string; | ||
export declare function justName(filename?: string): string; | ||
/** | ||
@@ -15,0 +15,0 @@ * Avoid appending "js" to top-level unnamed schemas |
@@ -39,2 +39,3 @@ "use strict"; | ||
function justName(filename) { | ||
if (filename === void 0) { filename = ''; } | ||
return stripExtension(path_1.basename(filename)); | ||
@@ -41,0 +42,0 @@ } |
{ | ||
"name": "json-schema-to-typescript", | ||
"version": "4.2.1", | ||
"version": "4.3.0", | ||
"description": "compile json schema to typescript typings", | ||
@@ -5,0 +5,0 @@ "main": "dist/src/index.js", |
@@ -59,3 +59,3 @@ #!/usr/bin/env node | ||
function printHelp() { | ||
const pkg = require('../package.json') | ||
const pkg = require('../../package.json') | ||
@@ -62,0 +62,0 @@ process.stdout.write( |
@@ -9,2 +9,3 @@ import { whiteBright } from 'cli-color' | ||
return [ | ||
options.bannerComment, | ||
declareNamedTypes(ast, options), | ||
@@ -11,0 +12,0 @@ declareNamedInterfaces(ast, options, ast.standaloneName!), |
@@ -16,2 +16,3 @@ import { readFileSync } from 'fs' | ||
export interface Options { | ||
bannerComment: string, | ||
cwd: string | ||
@@ -28,2 +29,7 @@ declareReferenced: boolean | ||
export const DEFAULT_OPTIONS: Options = { | ||
bannerComment: `/** | ||
* This file was automatically generated by json-schema-to-typescript. | ||
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, | ||
* and run json-schema-to-typescript to regenerate this file. | ||
*/`, | ||
cwd: process.cwd(), | ||
@@ -30,0 +36,0 @@ declareReferenced: true, |
@@ -7,3 +7,3 @@ import { whiteBright } from 'cli-color' | ||
type Rule = (schema: JSONSchema, rootSchema: JSONSchema, fileName: string) => JSONSchema | ||
type Rule = (schema: JSONSchema, rootSchema: JSONSchema, fileName?: string) => JSONSchema | ||
const rules = new Map<string, Rule>() | ||
@@ -47,3 +47,3 @@ | ||
export function normalize(schema: JSONSchema, filename: string): NormalizedJSONSchema { | ||
export function normalize(schema: JSONSchema, filename?: string): NormalizedJSONSchema { | ||
let _schema = cloneDeep(schema) as NormalizedJSONSchema | ||
@@ -50,0 +50,0 @@ rules.forEach((rule, key) => { |
@@ -38,3 +38,3 @@ import { whiteBright } from 'cli-color' | ||
*/ | ||
export function justName(filename: string): string { | ||
export function justName(filename = ''): string { | ||
return stripExtension(basename(filename)) | ||
@@ -41,0 +41,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
2
0
1262623
47
36462