File tree 6 files changed +79
-5
lines changed
6 files changed +79
-5
lines changed Original file line number Diff line number Diff line change 7
7
## 0.2.x
8
8
9
9
* ` nscabinet.download `
10
-
10
+
11
+ ## 0.3.x
12
+
13
+ * CLI
Original file line number Diff line number Diff line change @@ -76,4 +76,22 @@ The following priority is taken for each parameter (using `_.extend`)
76
76
77
77
78
78
[ npm-url ] : https://npmjs.org/package/nscabinet
79
- [ npm-image ] : http://img.shields.io/npm/v/nscabinet.svg
79
+ [ npm-image ] : http://img.shields.io/npm/v/nscabinet.svg
80
+
81
+
82
+ ## CLI
83
+
84
+ npm install -g nscabinet
85
+
86
+ ``` bash
87
+ $ nscabinet u file.txt --rootpath /SuiteScripts/MyProject
88
+ $ nscabinet u file.txt -p /SuiteScripts/MyProject
89
+ $ nscabinet u file.txt
90
+ $ nscabinet d remote.txt --rootPath /Downloads
91
+ $ nscabinet d remote.txt -p /Downloads
92
+ $ nscabinet d remote.txt
93
+ ```
94
+
95
+ Takes in the same arguments (lowercased).
96
+
97
+ As usual, the arguments are defaulted from ` nsconfig.json ` .
Original file line number Diff line number Diff line change 7
7
"npm" : " >=2.1.5"
8
8
},
9
9
"main" : " src/nscabinet.js" ,
10
+ "bin" : {
11
+ "nscabinet" : " ./src/cli.js"
12
+ },
10
13
"scripts" : {
11
14
"test" : " mocha"
12
15
},
41
44
"osenv" : " ^0.1.3" ,
42
45
"request" : " ^2.64.0" ,
43
46
"through2" : " ^2.0.0" ,
44
- "vinyl-fs" : " ^2.1.1"
47
+ "vinyl-fs" : " ^2.1.1" ,
48
+ "yargs" : " ^3.26.0"
45
49
}
46
50
}
Original file line number Diff line number Diff line change @@ -13,6 +13,8 @@ var post = function (datain) {
13
13
14
14
//ROUTER
15
15
16
+ log ( datain )
17
+
16
18
switch ( datain . action ) {
17
19
case 'download' :
18
20
return download ( datain )
@@ -36,7 +38,7 @@ var upload = function(datain) {
36
38
file . setFolder ( info . folderid )
37
39
var r = JSON . stringify ( nlapiSubmitFile ( file ) )
38
40
nlapiLogExecution ( 'ERROR' , 'up!' , r )
39
- return { message : 'Uploaded to file id ' + r , fileid : Number ( r ) }
41
+ return { message : 'Uploaded ' + info . filename + ' to file id ' + r , fileid : Number ( r ) }
40
42
}
41
43
42
44
}
Original file line number Diff line number Diff line change
1
+ var yarr = require ( 'yargs' )
2
+ . usage ( 'Usage: nscabinet <command> <file> [options]' )
3
+ . command ( 'u' , 'Upload.' )
4
+ . command ( 'd' , 'Download.' )
5
+ . demand ( 1 )
6
+ . demand ( 2 )
7
+ //.describe('config','Point to a nsconfig.json file.')
8
+ . describe ( 'rootpath' , 'Netsuite origin path.' )
9
+ . alias ( 'rootpath' , 'p' )
10
+ . describe ( 'email' , 'Account email.' )
11
+ . describe ( 'password' , 'Account password.' )
12
+ . describe ( 'account' , 'Account id.' )
13
+ . describe ( 'realm' , '*.netsuite.com' )
14
+ . describe ( 'role' )
15
+ . describe ( 'script' , 'Script id.' )
16
+ . describe ( 'deployment' , 'Deployment id.' )
17
+ . argv
18
+
19
+ var cabinet = require ( './nscabinet.js' ) ,
20
+ vinylfs = require ( 'vinyl-fs' )
21
+
22
+ var action = yarr . _ [ 0 ] ,
23
+ file = yarr . _ [ 1 ]
24
+
25
+
26
+
27
+ var opts = { }
28
+
29
+ for ( var it in yarr ) {
30
+ if ( yarr [ it ] !== undefined ) opts [ it ] = yarr [ it ]
31
+ }
32
+ if ( opts . rootpath ) opts . rootPath = opts . rootpath
33
+
34
+ if ( action == 'u' ) {
35
+
36
+ vinylfs . src ( file ) . pipe ( cabinet ( opts ) )
37
+
38
+ } else if ( action == 'd' ) {
39
+
40
+ cabinet . download ( file , opts ) . pipe ( vinylfs . dest ( '.' ) )
41
+
42
+ }
43
+
44
+ process . on ( 'exit' , ( ) => { console . log ( '\n' ) } )
Original file line number Diff line number Diff line change @@ -73,6 +73,8 @@ out.download = (files,params) => {
73
73
contents : new Buffer ( file . contents , 'base64' )
74
74
} )
75
75
76
+ console . log ( `Got file ${ file . path } .` )
77
+
76
78
this . emit ( 'data' , vynFile )
77
79
78
80
} )
@@ -84,6 +86,7 @@ out.download = (files,params) => {
84
86
)
85
87
86
88
return request ( toRequest )
89
+ . pipe ( es . split ( ) )
87
90
. pipe ( es . parse ( ) )
88
91
. pipe ( emitter )
89
92
@@ -109,4 +112,4 @@ function requestOpts(params) {
109
112
}
110
113
}
111
114
112
- }
115
+ }
You can’t perform that action at this time.
0 commit comments