소스 검색

setting right for multiple users

Benoit Sida 4 년 전
부모
커밋
7eef4fdbb0
2개의 변경된 파일26개의 추가작업 그리고 41개의 파일을 삭제
  1. 22
    14
      blih.js
  2. 4
    27
      package.json

+ 22
- 14
blih.js 파일 보기

59
 	}
59
 	}
60
 
60
 
61
 	token_calc() {
61
 	token_calc() {
62
-		return crypto.createHash('sha512').update(prompt(`${this._user}'s password: `, {echo: '*'}) || process.exit(1)).digest('hex');
62
+		return crypto.createHash('sha512').update(prompt(`${this._user}'s password: `, {echo: ''}) || process.exit(1)).digest('hex');
63
 	}
63
 	}
64
 }
64
 }
65
 
65
 
81
 		Usage: ${process.argv[1]} [options] repository command ...
81
 		Usage: ${process.argv[1]} [options] repository command ...
82
 		
82
 		
83
 		Commands:
83
 		Commands:
84
-		    create repo\t\tCreate a repository named "repo"
85
-		    info repo\t\t\tGet the repository metadata
86
-		    getacl repo\t\tGet the acls set for the repository
87
-		    list\t\t\tList the repositories created
88
-		    setacl repo user [acl]\tSet (or remove) an acl for "user" on "repo"
89
-		    \t\t\t\tACL format:
90
-		    \t\t\t\t\tr for read
91
-		    \t\t\t\t\tw for write
92
-		    \t\t\t\t\ta for admin
84
+		    create repo\t\t\tCreate a repository named "repo"
85
+		    info repo\t\t\t\tGet the repository metadata
86
+		    getacl repo\t\t\tGet the acls set for the repository
87
+		    list\t\t\t\tList the repositories created
88
+		    setacl repo user [user...] [acl]\tSet (or remove) an acl for each "user" on "repo"
89
+		    \t\t\t\t\tACL format:
90
+		    \t\t\t\t\t\tr for read
91
+		    \t\t\t\t\t\tw for write
92
+		    \t\t\t\t\t\ta for admin
93
 		`;
93
 		`;
94
 		this.usage_message = '\n  ' + this.usage_message.substr(3).replace(/\n\t\t/g, '\n  ');
94
 		this.usage_message = '\n  ' + this.usage_message.substr(3).replace(/\n\t\t/g, '\n  ');
95
 	}
95
 	}
138
 		if (params.length < 2)
138
 		if (params.length < 2)
139
 			return this.usage();
139
 			return this.usage();
140
 		const blih = new Blih(this.options);
140
 		const blih = new Blih(this.options);
141
-		blih.request({ path: `/repository/${params[0]}/acls`, method:'POST', data: {
142
-			user: params[1],
143
-			acl: params[2] || ''
144
-		}});
141
+		const repo = params.shift();
142
+		const rights = params.pop();
143
+		var users = params;
144
+		for (let user of users) {
145
+			blih.request({ 
146
+				path: `/repository/${repo}/acls`,
147
+				method:'POST', data: {
148
+					user: user,
149
+					acl: rights || ''
150
+				}
151
+			});
152
+		}
145
 	}
153
 	}
146
 
154
 
147
 	getacl(params) {
155
 	getacl(params) {

+ 4
- 27
package.json 파일 보기

2
   "name": "glih",
2
   "name": "glih",
3
   "version": "1.0.0",
3
   "version": "1.0.0",
4
   "description": "javascript version of epitech's blih utility",
4
   "description": "javascript version of epitech's blih utility",
5
-  "main": "main.js",
6
-  "scripts": {
7
-    "glih": "blih.js",
8
-    "watch": "webpack --progress --watch",
9
-    "build": "webpack --optimize-minimize -p",
10
-    "run": "electron ."
11
-  },
12
-  "bin": {
13
-    "glih": "blih.js"
14
-  },
5
+  "bin": "./blih.js",
15
   "repository": {
6
   "repository": {
16
     "type": "git",
7
     "type": "git",
17
     "url": "ssh://git@git.coldiary.eu:10022/coldiary/Glih.git"
8
     "url": "ssh://git@git.coldiary.eu:10022/coldiary/Glih.git"
20
   "license": "ISC",
11
   "license": "ISC",
21
   "dependencies": {
12
   "dependencies": {
22
     "commander": "^2.9.0",
13
     "commander": "^2.9.0",
23
-    "json-stable-stringify": "^1.0.1",
24
-    "material-ui": "^0.16.0",
25
     "prompt-sync": "^4.1.4",
14
     "prompt-sync": "^4.1.4",
26
-    "react": "^15.3.2",
27
-    "react-dom": "^15.3.2",
28
-    "react-tap-event-plugin": "^1.0.0",
29
-    "request": "^2.75.0",
30
-    "utf8": "^2.1.1"
31
-  },
32
-  "devDependencies": {
33
-    "babel-preset-es2015": "^6.16.0",
34
-    "babel-preset-react": "^6.16.0"
35
-  },
36
-  "babel": {
37
-    "presets": [
38
-      "es2015",
39
-      "react"
40
-    ]
15
+    "utf8": "^2.1.1",
16
+    "json-stable-stringify": "^1.0.1",
17
+    "request": "^2.75.0"
41
   }
18
   }
42
 }
19
 }