io-ts-from-json-schema
Advanced tools
Comparing version 0.0.6-alpha3 to 0.0.6
@@ -55,3 +55,6 @@ #!/usr/bin/env node | ||
}) | ||
.option('importHashLength', { type: 'number', default: 7, hidden: true }) | ||
.option('importHashLength', { | ||
type: 'number', | ||
default: 0, | ||
}) | ||
.help().argv; | ||
@@ -408,14 +411,24 @@ var imports = argv.import.map(function (imp) { return imp.split('^'); }); | ||
} | ||
function importHash(str) { | ||
return crypto | ||
function importBaseName(filePath) { | ||
// eslint-disable-next-line | ||
var _a = __read(filePath.split("/").reverse(), 1), withoutPath = _a[0]; | ||
var _b = __read(withoutPath.split('.json'), 1), basefile = _b[0]; | ||
var typeName = typenameFromKebab(basefile); | ||
return typeName.concat('_'); | ||
} | ||
function importHashName(str) { | ||
if (argv.importHashLength === 0) { | ||
return ''; | ||
} | ||
var fullDigest = crypto | ||
.createHash(argv.importHashAlgorithm) | ||
.update(str) | ||
.digest('hex') | ||
.slice(0, argv.importHashLength); | ||
.digest('hex'); | ||
var shortDigest = fullDigest.slice(0, argv.importHashLength); | ||
return shortDigest.concat('_'); | ||
} | ||
function calculateImportName(filePath, refString) { | ||
// eslint-disable-next-line | ||
var _a = __read(filePath.split("/").reverse(), 1), withoutPath = _a[0]; | ||
var _b = __read(withoutPath.split('.json'), 1), basefile = _b[0]; | ||
return typenameFromKebab(basefile) + "_" + importHash(refString) + "_"; | ||
var baseName = importBaseName(filePath); | ||
var hashName = importHashName(refString); | ||
return baseName.concat(hashName); | ||
} | ||
@@ -422,0 +435,0 @@ function fromRef(refString) { |
{ | ||
"name": "io-ts-from-json-schema", | ||
"version": "0.0.6-alpha3", | ||
"version": "0.0.6", | ||
"description": "Iotsfjs is a static code generation utility used for converting json schema files into static TypeScript types and io-ts runtime validators.", | ||
@@ -5,0 +5,0 @@ "main": "lib/cli.js", |
36535
884