@@ -13,6 +13,7 @@ const {
1313 viewProject,
1414 listContributors,
1515 addContributor,
16+ removeContributor,
1617} = require ( './gitpo' )
1718
1819const {
@@ -23,7 +24,7 @@ const {
2324 CONTRIBUTORS ,
2425 CONTRIBUTORS_LIST ,
2526 CONTRIBUTORS_ADD ,
26- CONTRIBUTORS_DELETE ,
27+ CONTRIBUTORS_REMOVE ,
2728} = require ( './utils/konstants' )
2829
2930let languages = [ ]
@@ -33,7 +34,7 @@ inquirer
3334 {
3435 type : 'list' ,
3536 name : 'action' ,
36- message : 'What would you like to do' ,
37+ message : 'What would you like to do: ' ,
3738 choices : [
3839 { name : 'View Project Details' , value : PROJECT_VIEW } ,
3940 { name : 'Update Code (POEditor → GitHub)' , value : PROJECT_UPDATE } ,
@@ -46,61 +47,61 @@ inquirer
4647 when : ( { action } ) => action === CONTRIBUTORS ,
4748 type : 'list' ,
4849 name : 'action' ,
49- message : 'What would you like to do' ,
50+ message : 'What would you like to do: ' ,
5051 choices : [
5152 { name : 'List collaborators' , value : CONTRIBUTORS_LIST } ,
5253 { name : 'Add collaborator' , value : CONTRIBUTORS_ADD } ,
53- { name : 'Delete collaborator' , value : CONTRIBUTORS_DELETE } ,
54+ { name : 'Remove collaborator' , value : CONTRIBUTORS_REMOVE } ,
5455 ] ,
5556 } ,
5657 {
5758 when : ( { action } ) => action === CONTRIBUTORS_ADD ,
5859 type : 'input' ,
60+ name : 'fullname' ,
61+ message : 'Full Name:' ,
62+ } ,
63+ {
64+ when : ( { action } ) => [ CONTRIBUTORS_ADD , CONTRIBUTORS_REMOVE ] . includes ( action ) ,
65+ type : 'input' ,
5966 name : 'email' ,
6067 message : 'Email:' ,
6168 } ,
6269 {
63- when : ( { action } ) => action === CONTRIBUTORS_ADD ,
64- type : 'input' ,
65- name : 'fullname' ,
66- message : 'Full Name:' ,
70+ when : ( { action } ) => [ CONTRIBUTORS_ADD , CONTRIBUTORS_REMOVE ] . includes ( action ) ,
71+ type : 'checkbox' ,
72+ name : 'projects' ,
73+ message : 'Select project(s):' ,
74+ choices : async ( ) => {
75+ const projects = await listProjects ( )
76+ return projects . map ( ( { name, id : value } ) => ( { name, value } ) )
77+ } ,
6778 } ,
6879 {
6980 when : ( { action } ) => action === PROJECT_CLEAN ,
7081 type : 'input' ,
7182 name : 'file' ,
72- message : 'Where is the file to work on ?' ,
83+ message : 'Where is the file to work on?' ,
7384 } ,
7485 {
7586 when : ( { action } ) => action === PROJECT_CLEAN ,
7687 type : 'confirm' ,
7788 name : 'override' ,
78- message : 'Override existing file ? (if not, a file will be created next to the existing one)' ,
89+ message : 'Override existing file? (if not, a file will be created next to the existing one)' ,
7990 default : false ,
8091 } ,
8192 {
82- when : ( { action } ) => action !== PROJECT_CLEAN && action !== CONTRIBUTORS_LIST && action !== CONTRIBUTORS_ADD ,
93+ when : ( { action } ) => [ PROJECT_VIEW , PROJECT_UPDATE , PROJECT_TERMS ] . includes ( action ) ,
8394 type : 'list' ,
8495 name : 'project' ,
85- message : 'Select a project' ,
86- choices : async ( ) => {
87- const projects = await listProjects ( )
88- return projects . map ( ( { name, id : value } ) => ( { name, value } ) )
89- } ,
90- } ,
91- {
92- when : ( { action } ) => action === CONTRIBUTORS_ADD ,
93- type : 'checkbox' ,
94- name : 'projects' ,
95- message : 'Select project(s)' ,
96+ message : 'Select a project:' ,
9697 choices : async ( ) => {
9798 const projects = await listProjects ( )
9899 return projects . map ( ( { name, id : value } ) => ( { name, value } ) )
99100 } ,
100101 } ,
101102 {
102103 when : async ( { action, project, projects } ) => {
103- if ( [ PROJECT_UPDATE , CONTRIBUTORS_ADD ] . includes ( action ) ) {
104+ if ( [ PROJECT_UPDATE , CONTRIBUTORS_ADD , CONTRIBUTORS_REMOVE ] . includes ( action ) ) {
104105 if ( projects && ! project ) {
105106 project = projects [ 0 ] // NOTE: assuming all projects have the same language set here
106107 }
@@ -111,7 +112,7 @@ inquirer
111112 } ,
112113 type : 'checkbox' ,
113114 name : 'languages' ,
114- message : 'Select Language(s)' ,
115+ message : 'Select Language(s): ' ,
115116 choices : async ( ) => languages . map ( ( { name, code } ) => ( { name, value : code } ) ) ,
116117 } ,
117118 {
@@ -152,6 +153,9 @@ inquirer
152153 case CONTRIBUTORS_ADD :
153154 addContributor ( email , fullname , projects , languages ) . then ( ( ) => console . log ( 'Contributor added' ) )
154155 break
156+ case CONTRIBUTORS_REMOVE :
157+ removeContributor ( email , projects , languages ) . then ( ( ) => console . log ( 'Contributor removed' ) )
158+ break
155159 default :
156160 console . log ( 'Sorry, I did not get what it is that you want...' )
157161 }
0 commit comments