firebase-import
Advanced tools
Comparing version 1.1.2 to 1.1.3
@@ -13,3 +13,3 @@ #!/usr/bin/env node | ||
// Keep ~50 writes outstanding at a time (this increases throughput, so we're not delayed by server round-trips). | ||
var OUTSTANDING_WRITE_COUNT = 50; | ||
var OUTSTANDING_WRITE_COUNT = 50; | ||
@@ -20,3 +20,3 @@ var argv = require('optimist') | ||
.demand('firebase_url') | ||
.describe('firebase_url', 'Firebase URL (e.g. https://test.firebaseio.com/dest/path).') | ||
.describe('firebase_url', 'Firebase database URL (e.g. https://test.firebaseio.com/dest/path).') | ||
.alias('f', 'firebase_url') | ||
@@ -27,3 +27,3 @@ | ||
.alias('j', 'json') | ||
.boolean('merge') | ||
@@ -36,3 +36,3 @@ .describe('merge', 'Write the top-level children without overwriting the whole parent.') | ||
.describe('auth', 'Specify an auth token to use (e.g. your Firebase Secret).') | ||
.describe('auth', 'Specify an auth token to use (or your Firebase Secret).') | ||
.alias('a', 'auth') | ||
@@ -101,3 +101,3 @@ | ||
} | ||
console.log('Preparing JSON for import... (may take a minute)'); | ||
@@ -146,3 +146,3 @@ var chunks = createChunks(ref, json, splitTopLevel); | ||
} | ||
var value = json; | ||
@@ -197,4 +197,7 @@ if (jsonIsObject && ('.value' in json)) { | ||
this.chunks = chunks; | ||
this.bar = new ProgressBar('Importing [:bar] :percent (:current/:total)', | ||
{ width: 50, total: chunks.length, incomplete: ' ' }); | ||
if (process.stdout.isTTY) { | ||
this.bar = new ProgressBar('Importing [:bar] :percent (:current/:total)', { width: 50, total: chunks.length, incomplete: ' ' }); | ||
} else { | ||
console.log('Importing... (may take a while)'); | ||
} | ||
} | ||
@@ -204,3 +207,3 @@ | ||
this.onComplete = onComplete; | ||
for(var i = 0; i < OUTSTANDING_WRITE_COUNT && i < this.chunks.length; i++) { | ||
@@ -215,13 +218,15 @@ this.uploadNext(); | ||
this.next++; | ||
var self = this; | ||
var onComplete = function(error) { | ||
if (error) { | ||
if (error) { | ||
console.log('Error uploading to ' + self.chunks[i].ref.toString() + ': ' + util.inspect(json)); | ||
console.error(error); | ||
throw error; | ||
throw error; | ||
} | ||
self.bar.tick(); | ||
if (process.stdout.isTTY && self.bar) { | ||
self.bar.tick(); | ||
} | ||
if (chunkNum === self.chunks.length - 1) { | ||
@@ -228,0 +233,0 @@ self.onComplete(); |
{ | ||
"name": "firebase-import", | ||
"description": "npm config for Firebase Import", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"dependencies": { | ||
@@ -6,0 +6,0 @@ "firebase": "~1.0.15", |
# Firebase-Import | ||
Firebase-import is a helper utility for importing large JSON files into [Firebase](https://www.firebase.com/). It | ||
Firebase-import is a helper utility for importing large JSON files into your [Firebase](https://www.firebase.com/) database. It | ||
breaks the JSON into smaller chunks and uploads them individually through the Firebase API. | ||
To import files bigger than 250MB, use [Firebase Streaming Import](https://github.com/firebase/firebase-streaming-import). | ||
## Installing | ||
@@ -22,3 +24,3 @@ | ||
Options: | ||
--firebase_url, -f Firebase URL (e.g. https://test.firebaseio.com/dest/path). [required] | ||
--firebase_url, -f Firebase database URL (e.g. https://test.firebaseio.com/dest/path). [required] | ||
--json, -j The JSON file to import. [required] | ||
@@ -25,0 +27,0 @@ --merge, -m Write the top-level children without overwriting the whole parent. [boolean] |
9902
6
203
55