This repository was archived by the owner on Jan 31, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +67
-29
lines changed Expand file tree Collapse file tree 5 files changed +67
-29
lines changed Original file line number Diff line number Diff line change 9
9
10
10
import { execSync } from "child_process" ;
11
11
import fs from "fs" ;
12
- import path , { basename } from "path" ;
13
12
import inquirer from "inquirer" ;
13
+ import path , { basename } from "path" ;
14
14
import "./lib/programOptions.js" ;
15
- import { databaseType } from "./lib/prompt/db.js" ;
15
+ import { databaseConfirmQuestion } from "./lib/prompt/db.js" ;
16
16
import { languageType } from "./lib/questions.js" ;
17
17
18
18
export const options = {
19
19
language_type : "" ,
20
+ database : true ,
20
21
database_type : "" ,
21
22
orm_type : "" ,
22
23
auth : false ,
@@ -144,7 +145,7 @@ function main() {
144
145
process . exit ( 0 ) ;
145
146
}
146
147
options . language_type = answer . language_type ;
147
- databaseType ( ) ;
148
+ databaseConfirmQuestion ( ) ;
148
149
} )
149
150
. catch ( ( error ) => {
150
151
if ( error . isTtyError ) {
Original file line number Diff line number Diff line change 1
- import inquirer from ' inquirer'
2
- import { mongodbOrm } from ' ../../orm/mongoDB .js' ;
3
- import { ormType } from ' ../../orm/orm.js' ;
4
- import { options } from ' ../../index.js' ;
5
- import { databaseQuestion } from '../questions .js' ;
1
+ import inquirer from " inquirer" ;
2
+ import { options } from " ../../index .js" ;
3
+ import { dbQuestion } from " ../questions.js" ;
4
+ import { repoConditions } from " ../repoConditions.js" ;
5
+ import { databaseType } from "./dbType .js" ;
6
6
7
- export const databaseType = ( ) => {
8
- inquirer . prompt (
9
- databaseQuestion
10
- ) . then ( answer => {
11
- if ( answer . database_type === 'MongoDB' ) {
12
- options . database_type = answer . database_type
13
- mongodbOrm ( )
14
- } else if ( answer . database_type === 'MySQL' ) {
15
- options . database_type = answer . database_type
16
- ormType ( )
17
- }
18
- else {
19
- options . database_type = answer . database_type
20
- ormType ( )
21
- }
7
+ export const databaseConfirmQuestion = ( ) => {
8
+ inquirer
9
+ . prompt ( dbQuestion )
10
+ . then ( ( answer ) => {
11
+ if ( answer . dbQuestion === true ) {
12
+ databaseType ( ) ;
13
+ } else if ( answer . dbQuestion === false ) {
14
+ options . database = answer . dbQuestion ;
15
+ repoConditions ( ) ;
16
+ }
22
17
} )
23
- . catch ( ( error ) => {
24
- if ( error . isTtyError ) {
25
- } else {
26
- }
27
- } ) ;
28
- }
18
+ . catch ( ( error ) => {
19
+ if ( error . isTtyError ) {
20
+ } else {
21
+ }
22
+ } ) ;
23
+ } ;
Original file line number Diff line number Diff line change
1
+ import inquirer from 'inquirer'
2
+ import { mongodbOrm } from '../../orm/mongoDB.js' ;
3
+ import { ormType } from '../../orm/orm.js' ;
4
+ import { options } from '../../index.js' ;
5
+ import { databaseQuestion } from '../questions.js' ;
6
+
7
+ export const databaseType = ( ) => {
8
+ inquirer . prompt (
9
+ databaseQuestion
10
+ ) . then ( answer => {
11
+ if ( answer . database_type === 'MongoDB' ) {
12
+ options . database_type = answer . database_type
13
+ mongodbOrm ( )
14
+ } else if ( answer . database_type === 'MySQL' ) {
15
+ options . database_type = answer . database_type
16
+ ormType ( )
17
+ }
18
+ else {
19
+ options . database_type = answer . database_type
20
+ ormType ( )
21
+ }
22
+ } )
23
+ . catch ( ( error ) => {
24
+ if ( error . isTtyError ) {
25
+ } else {
26
+ }
27
+ } ) ;
28
+ }
Original file line number Diff line number Diff line change @@ -6,6 +6,14 @@ export const languageType = {
6
6
default : "JavaScript" ,
7
7
}
8
8
9
+ export const dbQuestion = [
10
+ {
11
+ type : "confirm" ,
12
+ name : "dbQuestion" ,
13
+ message : "Do you need database?" ,
14
+ } ,
15
+ ]
16
+
9
17
export const databaseQuestion = [
10
18
{
11
19
type : "list" ,
Original file line number Diff line number Diff line change @@ -4,6 +4,12 @@ export const repoConditions = () => {
4
4
switch ( true ) {
5
5
// JavaScript for NoAuth
6
6
7
+ // NoDB
8
+ case options . language_type === "JavaScript" &&
9
+ options . database === false :
10
+ cloneRepo ( projectName , "JS-NoDB-Template" ) ;
11
+ break ;
12
+
7
13
// MongoDB
8
14
case options . language_type === "JavaScript" &&
9
15
options . database_type === "MongoDB" &&
You can’t perform that action at this time.
0 commit comments