forked from geneontology/go-site
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
152 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
* Usage | ||
|
||
To get ready: | ||
|
||
: npm install | ||
|
||
Running: | ||
|
||
node ./fs-to-s3.js -b foo -d /tmp/node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
//// | ||
//// Take a filesystem path and convert it to a website in S3. | ||
//// | ||
//// TODO: S3 parts. | ||
//// | ||
//// Example usage: | ||
//// node ./fs-to-s3.js -b foo -d /tmp/node_modules/ | ||
//// | ||
|
||
var opts = require('minimist'); | ||
var fs = require("fs"); | ||
var us = require('underscore'); | ||
var find = require('findit'); | ||
var path = require('path'); | ||
|
||
// Aliases. | ||
var each = us.each; | ||
|
||
/// | ||
/// Incoming args. | ||
/// | ||
|
||
// Args from CLI. | ||
var argv = opts(process.argv.slice(2)); | ||
var bucket = null; | ||
var scan_dir = null; | ||
if( argv['b'] ){ bucket = argv['b']; } | ||
console.log('S3 bucket: ' + bucket); | ||
if( argv['d'] ){ scan_dir = argv['d']; } | ||
console.log('scan dir: ' + scan_dir); | ||
|
||
// Need args or die. | ||
if( ! bucket || ! scan_dir ){ | ||
process.exit(1); | ||
} | ||
|
||
/// | ||
/// Scanning events. | ||
/// | ||
|
||
var directories = []; | ||
var files = []; | ||
var directory_files = {}; // map of directorys to files | ||
|
||
var finder = find(scan_dir); | ||
|
||
finder.on('directory', function(dir, stat, stop){ | ||
//var base = path.basename(dir); | ||
|
||
// Just dirs. | ||
directories.push(dir); | ||
|
||
// Keep hash made. | ||
if( ! directory_files[dir] ){ | ||
directory_files[dir] = []; | ||
} | ||
|
||
// console.log('dir: ' + dir + '/'); | ||
}); | ||
|
||
finder.on('file', function(file, stat){ | ||
var dir = path.dirname(file); | ||
var base = path.basename(file); | ||
|
||
// console.log('file: ' + dir + ' ' + file); | ||
|
||
files.push(file); | ||
|
||
// | ||
if( ! directory_files[dir] ){ | ||
directory_files[dir] = []; | ||
} | ||
directory_files[dir].push(file); | ||
|
||
}); | ||
|
||
finder.on('link', function(link, stat){ | ||
console.log('skipping link: ' + link); | ||
}); | ||
|
||
// | ||
finder.on('end', function(){ | ||
|
||
// | ||
each(directory_files, function(files, dir){ | ||
|
||
console.log('TODO: makedir: ' + dir); | ||
|
||
// Order files. | ||
files = files.sort(); | ||
|
||
// Send the files. | ||
each(files, function(file){ | ||
console.log('TODO: send file: ' + file); | ||
}); | ||
}); | ||
|
||
// // | ||
// each(directories, function(dir){ | ||
// console.log('TODO: makedir: ' + dir); | ||
// }); | ||
|
||
// // | ||
// each(files, function(file){ | ||
// console.log('TODO: send file: ' + file); | ||
// }); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"name": "fs-to-s3", | ||
"version": "0.0.1", | ||
"description": "Filesystem to S3.", | ||
"keywords": [ | ||
"application", | ||
"gene ontology", | ||
"GO", | ||
"utility" | ||
], | ||
"author": { | ||
"name": "SJC", | ||
"email": "[email protected]", | ||
"url": "http://berkeleybop.org/" | ||
}, | ||
"homepage": "http://berkeleybop.org/", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/geneontology/go-exp" | ||
}, | ||
"engines": { | ||
"node": ">= 0.10.0", | ||
"npm": ">= 2.7.4" | ||
}, | ||
"bin": { | ||
"noctua-repl": "./fs-to-s3.js" | ||
}, | ||
"dependencies": { | ||
"findit": "~2.0.0", | ||
"underscore": "~1.8.3", | ||
"minimist": "~1.1.1" | ||
}, | ||
"devDependencies": { | ||
} | ||
} |