2022-04-06 13:28:42 -04:00
import path from 'path' ;
2023-05-08 15:49:28 -04:00
import os from 'os' ;
2022-04-06 13:28:42 -04:00
function getPathQuestions ( packageType ) {
return [
{
type : 'input' ,
name : 'name' ,
message : `What is the name of your ${ packageType } ?` ,
2023-05-08 15:49:28 -04:00
validate : input => {
2022-04-06 13:28:42 -04:00
if ( ! input ) {
return 'Please enter a name' ;
}
return true ;
},
default : `my- ${ packageType } ` ,
},
{
type : 'input' ,
name : 'baseDir' ,
2023-05-08 15:49:28 -04:00
message : `What is the target path to create your ${ packageType } (we recommend you do not use the OHIF ${ packageType } folder (./ ${ packageType } s) unless you are developing a core ${ packageType } ):` ,
validate : input => {
2022-04-06 13:28:42 -04:00
if ( ! input ) {
console . log ( 'Please provide a valid target directory path' );
return ;
}
return true ;
},
filter : ( input , answers ) => {
2023-05-08 15:49:28 -04:00
// Replace ~ with the user's home directory
const expandedPath = input . replace ( /^~(?=$|\/|\\)/ , os . homedir ());
// Resolve the path to an absolute path
const resolvedPath = path . resolve ( expandedPath , answers . name );
return resolvedPath ;
2022-04-06 13:28:42 -04:00
},
},
{
type : 'confirm' ,
name : 'confirm' ,
message : `Please confirm the above path for generating the ${ packageType } folder:` ,
},
];
}
function getRepoQuestions ( packageType ) {
return [
{
type : 'confirm' ,
name : 'gitRepository' ,
message : 'Should it be a git repository?' ,
2023-05-08 15:49:28 -04:00
default : false ,
2022-04-06 13:28:42 -04:00
},
{
type : 'confirm' ,
name : 'prettier' ,
message : 'Should it follow same prettier rules as OHIF?' ,
},
{
type : 'input' ,
name : 'version' ,
message : `What is the version of your ${ packageType } ?` ,
default : '0.0.1' ,
},
{
type : 'input' ,
name : 'description' ,
message : `What is the description of your ${ packageType } ?` ,
default : '' ,
},
{
type : 'input' ,
name : 'author' ,
message : `Who is the author of your ${ packageType } ?` ,
default : '' ,
},
{
type : 'input' ,
name : 'email' ,
message : 'What is your email address?' ,
default : '' ,
},
{
type : 'input' ,
name : 'license' ,
message : `What is the license of your ${ packageType } ?` ,
default : 'MIT' ,
},
];
}
export { getPathQuestions , getRepoQuestions };