File tree Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change 1
1
#!/usr/bin/env node
2
2
const yargs = require ( 'yargs' ) ;
3
3
const fs = require ( 'fs' ) ;
4
+ const fetch = require ( 'node-fetch' ) ;
4
5
5
6
const argv = yargs
6
7
. option ( 'graph' , {
@@ -89,16 +90,29 @@ const argv = yargs
89
90
}
90
91
)
91
92
. command (
92
- 'download <dir>' ,
93
- 'Export your Roam database to a selected directory.' ,
93
+ 'export <dir> [exporturl] ' ,
94
+ 'Export your Roam database to a selected directory. If URL is provided, then the concent will be sent by POST request to the specified URL. ' ,
94
95
( ) => { } ,
95
96
( argv ) => {
96
97
const RoamPrivateApi = require ( '../' ) ;
97
98
const api = new RoamPrivateApi ( argv . graph , argv . email , argv . password , {
98
99
headless : ! argv . debug ,
99
100
folder : argv [ 'dir' ]
100
101
} ) ;
101
- api . getExportData ( argv [ 'removezip' ] ) . then ( data => console . log ( 'Downloaded' ) ) ;
102
+ let promises = api . getExportData ( argv [ 'removezip' ] ) ;
103
+ promises . then ( data => console . log ( 'Downloaded' ) ) ;
104
+ if ( argv [ 'exporturl' ] ) {
105
+ promises . then ( data => fetch ( argv [ 'exporturl' ] , {
106
+ method : 'post' ,
107
+ body : JSON . stringify ( {
108
+ graphContent : data ,
109
+ graphName : api . graph
110
+ } ) ,
111
+ headers : { 'Content-Type' : 'application/json' }
112
+ } ) )
113
+ . catch ( err => console . log ( err ) )
114
+ . then ( ( ) => console . log ( "Uploaded to export url." ) )
115
+ }
102
116
}
103
117
)
104
118
. help ( )
You can’t perform that action at this time.
0 commit comments