Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
PUBLIC
/
surfer-okd
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 69bfad0e
authored
Apr 19, 2017
by
Johannes Zellner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP
1 parent
6a1e16e6
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
97 additions
and
4 deletions
cli/actions.js
npm-shrinkwrap.json
package.json
cli/actions.js
View file @
69bfad0
...
...
@@ -11,6 +11,8 @@ var superagent = require('superagent'),
readlineSync
=
require
(
'readline-sync'
),
safe
=
require
(
'safetydance'
),
async
=
require
(
'async'
),
ProgressBar
=
require
(
'progress'
),
ProgressStream
=
require
(
'progress-stream'
),
fs
=
require
(
'fs'
),
request
=
require
(
'request'
),
url
=
require
(
'url'
),
...
...
@@ -138,18 +140,47 @@ function put(filePath, otherFilePaths, options) {
relativeFilePath
=
path
.
basename
(
file
);
}
var
stat
=
safe
.
fs
.
statSync
(
file
);
if
(
!
stat
)
return
callback
(
safe
.
error
);
var
bar
=
new
ProgressBar
(
'[:bar] :percent: :etas'
,
{
complete
:
'='
,
incomplete
:
' '
,
width
:
100
,
total
:
parseInt
(
stat
.
size
),
stream
:
process
.
stdout
});
var
destinationPath
=
(
destination
?
'/'
+
destination
:
''
)
+
'/'
+
relativeFilePath
;
console
.
log
(
'Uploading file %s -> %s'
,
relativeFilePath
.
cyan
,
destinationPath
.
cyan
);
superagent
.
post
(
config
.
server
()
+
API
+
destinationPath
).
query
(
gQuery
).
attach
(
'file'
,
file
).
end
(
function
(
error
,
result
)
{
if
(
result
&&
result
.
statusCode
===
403
)
return
callback
(
new
Error
(
'Upload destination '
+
destinationPath
+
' not allowed'
));
if
(
result
&&
result
.
statusCode
!==
201
)
return
callback
(
new
Error
(
'Error uploading file: '
+
result
.
statusCode
));
if
(
error
)
return
callback
(
error
);
var
readStream
=
fs
.
createReadStream
(
file
);
var
progress
=
new
ProgressStream
({
time
:
50
});
progress
.
on
(
'progress'
,
function
(
p
)
{
bar
.
update
(
p
.
percentage
/
100
);
/* bar.tick(p.transferred - bar.curr); */
});
// progress.on('progress', function (p) { console.log(p.percentage); });
progress
.
setLength
(
stat
.
size
);
// superagent.post(config.server() + API + destinationPath).query(gQuery).attach('file', file).end(function (error, result) {
var
postStream
=
superagent
.
post
(
config
.
server
()
+
API
+
destinationPath
).
query
(
gQuery
);
readStream
.
pipe
(
progress
).
pipe
(
postStream
);
readStream
.
on
(
'error'
,
function
(
error
)
{
console
.
error
(
'Read error:'
,
error
);
});
postStream
.
on
(
'error'
,
function
(
error
)
{
console
.
error
(
'Post error:'
,
error
);
});
postStream
.
on
(
'end'
,
function
()
{
console
.
log
(
'Uploaded to '
+
config
.
server
()
+
destinationPath
);
callback
(
null
);
});
// postStream.end(function (error, result) {
// if (result && result.statusCode === 403) return callback(new Error('Upload destination ' + destinationPath + ' not allowed'));
// if (result && result.statusCode !== 201) return callback(new Error('Error uploading file: ' + result.statusCode));
// if (error) return callback(error);
//
// console.log('Uploaded to ' + config.server() + destinationPath);
//
// callback(null);
// });
},
function
(
error
)
{
if
(
error
)
{
console
.
log
(
'Failed to put file.'
,
error
.
message
.
red
);
...
...
npm-shrinkwrap.json
View file @
69bfad0
...
...
@@ -124,6 +124,11 @@
}
}
},
"buffer-shims"
:
{
"version"
:
"1.0.0"
,
"from"
:
"buffer-shims@>=1.0.0 <1.1.0"
,
"resolved"
:
"https://registry.npmjs.org/buffer-shims/-/buffer-shims-1.0.0.tgz"
},
"colors"
:
{
"version"
:
"1.1.2"
,
"from"
:
"colors@>=1.1.2 <2.0.0"
,
...
...
@@ -281,6 +286,11 @@
}
}
},
"core-util-is"
:
{
"version"
:
"1.0.2"
,
"from"
:
"core-util-is@>=1.0.0 <1.1.0"
,
"resolved"
:
"https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz"
},
"debug"
:
{
"version"
:
"2.2.0"
,
"from"
:
"debug@>=2.2.0 <3.0.0"
,
...
...
@@ -806,6 +816,11 @@
"from"
:
"inherits@2.0.3"
,
"resolved"
:
"https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz"
},
"isarray"
:
{
"version"
:
"1.0.0"
,
"from"
:
"isarray@>=1.0.0 <1.1.0"
,
"resolved"
:
"https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz"
},
"mime-db"
:
{
"version"
:
"1.26.0"
,
"from"
:
"mime-db@>=1.26.0 <1.27.0"
,
...
...
@@ -1031,6 +1046,26 @@
"from"
:
"passport-strategy@>=1.0.0 <2.0.0"
,
"resolved"
:
"https://registry.npmjs.org/passport-strategy/-/passport-strategy-1.0.0.tgz"
},
"process-nextick-args"
:
{
"version"
:
"1.0.7"
,
"from"
:
"process-nextick-args@>=1.0.6 <1.1.0"
,
"resolved"
:
"https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz"
},
"progress"
:
{
"version"
:
"2.0.0"
,
"from"
:
"progress@latest"
,
"resolved"
:
"https://registry.npmjs.org/progress/-/progress-2.0.0.tgz"
},
"progress-stream"
:
{
"version"
:
"2.0.0"
,
"from"
:
"progress-stream@latest"
,
"resolved"
:
"https://registry.npmjs.org/progress-stream/-/progress-stream-2.0.0.tgz"
},
"readable-stream"
:
{
"version"
:
"2.2.9"
,
"from"
:
"readable-stream@>=2.1.5 <3.0.0"
,
"resolved"
:
"https://registry.npmjs.org/readable-stream/-/readable-stream-2.2.9.tgz"
},
"readline-sync"
:
{
"version"
:
"1.4.6"
,
"from"
:
"readline-sync@latest"
,
...
...
@@ -1450,11 +1485,21 @@
"from"
:
"setprototypeof@1.0.2"
,
"resolved"
:
"https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.2.tgz"
},
"speedometer"
:
{
"version"
:
"1.0.0"
,
"from"
:
"speedometer@>=1.0.0 <1.1.0"
,
"resolved"
:
"https://registry.npmjs.org/speedometer/-/speedometer-1.0.0.tgz"
},
"statuses"
:
{
"version"
:
"1.3.1"
,
"from"
:
"statuses@>=1.3.1 <2.0.0"
,
"resolved"
:
"https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz"
},
"string_decoder"
:
{
"version"
:
"1.0.0"
,
"from"
:
"string_decoder@>=1.0.0 <1.1.0"
,
"resolved"
:
"https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.0.tgz"
},
"superagent"
:
{
"version"
:
"1.8.1"
,
"from"
:
"superagent@>=1.7.2 <2.0.0"
,
...
...
@@ -1560,15 +1605,30 @@
}
}
},
"through2"
:
{
"version"
:
"2.0.3"
,
"from"
:
"through2@>=2.0.3 <2.1.0"
,
"resolved"
:
"https://registry.npmjs.org/through2/-/through2-2.0.3.tgz"
},
"underscore"
:
{
"version"
:
"1.8.3"
,
"from"
:
"underscore@>=1.8.3 <2.0.0"
,
"resolved"
:
"http://registry.npmjs.org/underscore/-/underscore-1.8.3.tgz"
},
"util-deprecate"
:
{
"version"
:
"1.0.2"
,
"from"
:
"util-deprecate@>=1.0.1 <1.1.0"
,
"resolved"
:
"https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz"
},
"uuid"
:
{
"version"
:
"3.0.1"
,
"from"
:
"uuid@latest"
,
"resolved"
:
"https://registry.npmjs.org/uuid/-/uuid-3.0.1.tgz"
},
"xtend"
:
{
"version"
:
"4.0.1"
,
"from"
:
"xtend@>=4.0.1 <4.1.0"
,
"resolved"
:
"https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz"
}
}
}
package.json
View file @
69bfad0
...
...
@@ -39,6 +39,8 @@
"passport"
:
"^0.2.2"
,
"passport-http-bearer"
:
"^1.0.1"
,
"passport-ldapjs"
:
"^1.0.2"
,
"progress"
:
"^2.0.0"
,
"progress-stream"
:
"^2.0.0"
,
"readline-sync"
:
"^1.4.6"
,
"redis"
:
"^2.6.5"
,
"request"
:
"^2.69.0"
,
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment