@@ -56,6 +56,7 @@ export function parseArgumentsIntoOptions(rawArgs) {
5656 appName : args [ '--app-name' ] ,
5757 db : args [ '--db' ] ,
5858 useNpm : args [ '--use-npm' ] ,
59+ includePrismaMigrations : args [ '--include-prisma-migrations' ] ,
5960 } ;
6061}
6162
@@ -93,12 +94,27 @@ export async function promptForMissingOptions(options) {
9394 } ) ;
9495 }
9596
97+ if ( ! options . includePrismaMigrations ) {
98+ questions . push ( {
99+ type : 'select' ,
100+ name : 'includePrismaMigrations' ,
101+ message : 'Include Prisma migrations? >' ,
102+ choices : [
103+ { name : 'Yes' , value : true } ,
104+ { name : 'No' , value : false } ,
105+ ] ,
106+ default : true ,
107+ } ) ;
108+
109+ }
110+
96111 const answers = await inquirer . prompt ( questions ) ;
97112 return {
98113 ...options ,
99114 appName : options . appName || answers . appName ,
100115 db : options . db || answers . db ,
101116 useNpm : options . useNpm || answers . useNpm ,
117+ includePrismaMigrations : options . includePrismaMigrations || answers . includePrismaMigrations ,
102118 } ;
103119}
104120
@@ -246,7 +262,7 @@ async function scaffoldProject(ctx, options, cwd) {
246262 await fse . copy ( sourceAssetsDir , targetAssetsDir ) ;
247263
248264 // Write templated files
249- await writeTemplateFiles ( dirname , projectDir , options . useNpm , {
265+ await writeTemplateFiles ( dirname , projectDir , options . useNpm , options . includePrismaMigrations , {
250266 dbUrl : connectionString . toString ( ) ,
251267 dbUrlProd : connectionStringProd ,
252268 prismaDbUrl,
@@ -274,7 +290,7 @@ function getPackageManagerTemplateData(useNpm, nodeMajor) {
274290 } ;
275291}
276292
277- async function writeTemplateFiles ( dirname , cwd , useNpm , options ) {
293+ async function writeTemplateFiles ( dirname , cwd , useNpm , includePrismaMigrations , options ) {
278294 const {
279295 dbUrl, prismaDbUrl, appName, provider, nodeMajor,
280296 dbUrlProd, prismaDbUrlProd, sqliteFile
@@ -288,17 +304,6 @@ async function writeTemplateFiles(dirname, cwd, useNpm, options) {
288304 dest : 'tsconfig.json' ,
289305 data : { } ,
290306 } ,
291- {
292- src : 'schema.prisma.hbs' ,
293- dest : 'schema.prisma' ,
294- data : { provider } ,
295- condition : Boolean ( prismaDbUrl ) , // only create if prismaDbUrl is truthy
296- } ,
297- {
298- src : 'prisma.config.ts.hbs' ,
299- dest : 'prisma.config.ts' ,
300- data : { } ,
301- } ,
302307 {
303308 src : 'index.ts.hbs' ,
304309 dest : 'index.ts' ,
@@ -393,6 +398,7 @@ async function writeTemplateFiles(dirname, cwd, useNpm, options) {
393398 data : {
394399 appName,
395400 adminforthVersion : adminforthVersion ,
401+ includePrismaMigrations,
396402 } ,
397403 } ,
398404 {
@@ -417,6 +423,22 @@ async function writeTemplateFiles(dirname, cwd, useNpm, options) {
417423 )
418424 }
419425
426+ if ( includePrismaMigrations ) {
427+ templateTasks . push (
428+ {
429+ src : 'schema.prisma.hbs' ,
430+ dest : 'schema.prisma' ,
431+ data : { provider } ,
432+ condition : Boolean ( prismaDbUrl ) , // only create if prismaDbUrl is truthy
433+ } ,
434+ {
435+ src : 'prisma.config.ts.hbs' ,
436+ dest : 'prisma.config.ts' ,
437+ data : { } ,
438+ } ,
439+ )
440+ }
441+
420442 for ( const task of templateTasks ) {
421443 // If a condition is specified and false, skip this file
422444 if ( task . condition === false ) continue ;
0 commit comments