| 
									
										
										
										
											2019-06-20 15:45:14 +02:00
										 |  |  | 'use strict'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const commander = require('commander'); | 
					
						
							| 
									
										
										
										
											2020-09-04 16:01:03 +02:00
										 |  |  | const generateNewApp = require('strapi-generate-new'); | 
					
						
							| 
									
										
										
										
											2020-10-27 11:27:17 +01:00
										 |  |  | const packageJson = require('./package.json'); | 
					
						
							| 
									
										
										
										
											2019-06-20 15:45:14 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | const program = new commander.Command(packageJson.name); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | let projectName; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | program | 
					
						
							|  |  |  |   .version(packageJson.version) | 
					
						
							|  |  |  |   .arguments('<directory>') | 
					
						
							| 
									
										
										
										
											2019-07-08 09:20:34 +02:00
										 |  |  |   .option('--no-run', 'Do not start the application after it is created') | 
					
						
							| 
									
										
										
										
											2020-08-27 10:53:38 +02:00
										 |  |  |   .option('--use-npm', 'Force usage of npm instead of yarn to create the project') | 
					
						
							| 
									
										
										
										
											2019-06-20 15:45:14 +02:00
										 |  |  |   .option('--debug', 'Display database connection error') | 
					
						
							|  |  |  |   .option('--quickstart', 'Quickstart app creation') | 
					
						
							|  |  |  |   .option('--dbclient <dbclient>', 'Database client') | 
					
						
							|  |  |  |   .option('--dbhost <dbhost>', 'Database host') | 
					
						
							|  |  |  |   .option('--dbsrv <dbsrv>', 'Database srv') | 
					
						
							|  |  |  |   .option('--dbport <dbport>', 'Database port') | 
					
						
							|  |  |  |   .option('--dbname <dbname>', 'Database name') | 
					
						
							|  |  |  |   .option('--dbusername <dbusername>', 'Database username') | 
					
						
							|  |  |  |   .option('--dbpassword <dbpassword>', 'Database password') | 
					
						
							|  |  |  |   .option('--dbssl <dbssl>', 'Database SSL') | 
					
						
							|  |  |  |   .option('--dbauth <dbauth>', 'Authentication Database') | 
					
						
							|  |  |  |   .option('--dbfile <dbfile>', 'Database file path for sqlite') | 
					
						
							|  |  |  |   .option('--dbforce', 'Overwrite database content if any') | 
					
						
							| 
									
										
										
										
											2020-08-27 10:53:38 +02:00
										 |  |  |   .option('--template <templateurl>', 'Specify a Strapi template') | 
					
						
							| 
									
										
										
										
											2019-06-20 15:45:14 +02:00
										 |  |  |   .description('create a new application') | 
					
						
							|  |  |  |   .action(directory => { | 
					
						
							|  |  |  |     projectName = directory; | 
					
						
							|  |  |  |   }) | 
					
						
							|  |  |  |   .parse(process.argv); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if (projectName === undefined) { | 
					
						
							|  |  |  |   console.error('Please specify the <directory> of your project'); | 
					
						
							| 
									
										
										
										
											2020-01-24 15:39:14 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |   // eslint-disable-next-line no-process-exit
 | 
					
						
							| 
									
										
										
										
											2019-06-20 15:45:14 +02:00
										 |  |  |   process.exit(1); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-27 08:54:11 +02:00
										 |  |  | generateNewApp(projectName, program).then(() => { | 
					
						
							|  |  |  |   if (process.platform === 'win32') { | 
					
						
							|  |  |  |     process.exit(0); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | }); |