schema-typegen
Advanced tools
Comparing version 2.2.2 to 2.3.0
@@ -20,3 +20,3 @@ Usage: schema-typegen [opts] connection_string | ||
Use type definitions instead of interfaces in generated output. Default: false. | ||
--noSemi | ||
--no-semicolons | ||
Omit semicolons in generated types. Default: false. | ||
@@ -27,2 +27,4 @@ --ssl | ||
Use optionals "?" instead of null. Default: false. | ||
--pascal-enums | ||
Transform enum keys to pascal case. Default: false. | ||
-v/--version | ||
@@ -29,0 +31,0 @@ Print the version number. |
'use strict' | ||
function toPascalCase (value) { | ||
const replaced = value.replace(/((_|-|\s)\w)/g, (token) => token[1].toUpperCase()) | ||
return replaced.charAt(0).toUpperCase() + replaced.slice(1) | ||
let replaced = value.replace(/((_|-|\s)\w)/g, (token) => token[1].toUpperCase()) | ||
replaced = replaced.charAt(0).toUpperCase() + replaced.slice(1) | ||
replaced = replaced.replace(/_|-|\s/g, '') | ||
return replaced | ||
} | ||
@@ -15,4 +17,12 @@ | ||
function formatEnumName (opts, name) { | ||
if (opts.pascalEnums) { | ||
return toPascalCase(name) | ||
} | ||
return formatName(name) | ||
} | ||
function semicolon (opts) { | ||
return opts.noSemi ? '' : ';' | ||
return opts.semicolons ? ';' : '' | ||
} | ||
@@ -85,3 +95,3 @@ | ||
entry.values.forEach(value => { | ||
enumType += ` ${formatName(value)} = '${value}',\n` | ||
enumType += ` ${formatEnumName(opts, value)} = '${value}',\n` | ||
}) | ||
@@ -88,0 +98,0 @@ |
{ | ||
"name": "schema-typegen", | ||
"version": "2.2.2", | ||
"version": "2.3.0", | ||
"description": "Generate TypeScript type definitions from database schema", | ||
@@ -5,0 +5,0 @@ "main": "schema-typegen.js", |
@@ -51,3 +51,3 @@ <h1 align="center">Welcome to schema-typegen 👋</h1> | ||
Use type definitions instead of interfaces in generated output. Default: false. | ||
--noSemi | ||
--no-semicolons | ||
Omit semicolons in generated types. Default: false. | ||
@@ -58,2 +58,4 @@ --ssl | ||
Use optionals "?" instead of null. Default: false. | ||
--pascal-enums | ||
Transform enum keys to pascal case. Default: false. | ||
-v/--version | ||
@@ -60,0 +62,0 @@ Print the version number. |
@@ -16,4 +16,6 @@ #! /usr/bin/env node | ||
noSemi: false, | ||
semicolons: true, | ||
type: false, | ||
optionals: false, | ||
pascalEnums: false, | ||
schema: 'public', | ||
@@ -27,3 +29,3 @@ output: undefined, | ||
const argv = minimist(argvs, { | ||
boolean: ['type', 'noSemi', 'version', 'optionals', 'ssl'], | ||
boolean: ['type', 'noSemi', 'semicolons', 'version', 'optionals', 'ssl', 'pascal-enums'], | ||
alias: { | ||
@@ -36,3 +38,4 @@ suffix: 'f', | ||
version: 'v', | ||
header: 'h' | ||
header: 'h', | ||
pascalEnums: 'pascal-enums' | ||
}, | ||
@@ -42,2 +45,6 @@ default: defaultOpts | ||
if (argv.noSemi) { | ||
argv.semicolons = false | ||
} | ||
argv.connection = argv._[0] | ||
@@ -44,0 +51,0 @@ argv.exclude = argv.exclude.split(',') |
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
13941
227
126