Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

schema-typegen

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

schema-typegen - npm Package Compare versions

Comparing version 2.2.2 to 2.3.0

4

help.txt

@@ -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(',')

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc