1- import arg from "arg" ;
2- import inquirer from "inquirer" ;
1+ const arg = require ( "arg" ) ;
2+ const inquirer = require ( "inquirer" ) ;
33const schema = require ( "./main" ) ;
44
55// export var schemaDetails = {};
66function parseArgumentsIntoOptions ( rawArgs ) {
77 const args = arg (
88 {
99 "--typescript" : Boolean ,
10- "--mongoose" : Boolean ,
1110 "--filepath" : String ,
1211 // Aliases
1312 "-t" : "--typescript" ,
@@ -19,15 +18,13 @@ function parseArgumentsIntoOptions(rawArgs) {
1918 ) ;
2019 return {
2120 language : args [ "--typescript" ] || undefined ,
22- mongoose : args [ "--mongoose" ] || false ,
2321 filePath : args [ "--filepath" ] || "/" ,
2422 } ;
2523}
2624
2725async function promptForMissingOptions ( options ) {
2826 const defaultOptions = {
2927 language : "Javascript" ,
30- mongoose : false ,
3128 schema : "default" ,
3229 } ;
3330 // if (options.skipPrompts) {
@@ -48,15 +45,6 @@ async function promptForMissingOptions(options) {
4845 } ) ;
4946 }
5047
51- if ( ! options . mongoose ) {
52- questions . push ( {
53- type : "confirm" ,
54- name : "mongoose" ,
55- message : "Do you want to have it in mongoose?" ,
56- default : defaultOptions . mongoose ,
57- } ) ;
58- }
59-
6048 questions . push ( {
6149 type : "input" ,
6250 name : "schema" ,
@@ -73,7 +61,7 @@ async function promptForMissingOptions(options) {
7361 } ;
7462}
7563
76- export async function promptForSchemaObject ( ) {
64+ async function promptForSchemaObject ( ) {
7765 console . log ( ) ;
7866 const defaultOptions = {
7967 name : "default" ,
@@ -122,9 +110,8 @@ export async function promptForSchemaObject() {
122110 } ;
123111}
124112
125- export async function cli ( args ) {
113+ async function cli ( args ) {
126114 var options = parseArgumentsIntoOptions ( args ) ;
127- // Initial Inputs
128115 options = await promptForMissingOptions ( options ) ;
129116
130117 const { schemaKeys } = await inquirer . prompt ( {
@@ -146,10 +133,7 @@ export async function cli(args) {
146133 schemaKeys,
147134 } ;
148135
149- // schemaDetails = {
150- // options,
151- // schemaKeyValues,
152- // };
153-
154- await schema . createSchema ( options , schemaKeyValues ) ;
136+ await schema ( options , schemaKeyValues ) ;
155137}
138+
139+ module . exports = cli ;
0 commit comments