firebase-tools
Advanced tools
Comparing version 1.1.4 to 1.1.5
@@ -16,3 +16,3 @@ var request = require('request'), | ||
if ((typeof(data) === 'undefined') || !data) { | ||
var data = {}; | ||
data = {}; | ||
} | ||
@@ -59,3 +59,5 @@ | ||
method: 'PUT', | ||
json: true, | ||
headers: { | ||
'Content-Type': 'application/json' | ||
}, | ||
body: rules | ||
@@ -67,3 +69,3 @@ }, function(err, response, body) { | ||
} | ||
setTimeout(callback, 0, response.statusCode, body); | ||
setTimeout(callback, 0, response.statusCode, body && JSON.parse(body)); | ||
}); | ||
@@ -73,54 +75,22 @@ } | ||
function initApi() { | ||
if (typeof(process.env['FIREBASE_ADMIN_URL']) !== 'undefined') { | ||
function possiblyOverride(apiVariable, envVariable) { | ||
if (typeof(process.env[envVariable]) !== 'undefined') { | ||
var urlParts = null; | ||
try { | ||
var urlParts = url.parse(process.env['FIREBASE_ADMIN_URL']); | ||
urlParts = url.parse(process.env[envVariable]); | ||
} catch (err) { | ||
var urlParts = null; | ||
urlParts = null; | ||
} | ||
if (urlParts) { | ||
api.adminUrl = process.env['FIREBASE_ADMIN_URL']; | ||
api[apiVariable] = process.env[envVariable]; | ||
} | ||
} | ||
if (typeof(process.env['FIREBASE_REALTIME_URL']) !== 'undefined') { | ||
try { | ||
var urlParts = url.parse(process.env['FIREBASE_REALTIME_URL']); | ||
} catch (err) { | ||
var urlParts = null; | ||
} | ||
if (urlParts) { | ||
api.realtimeUrl = process.env['FIREBASE_REALTIME_URL']; | ||
} | ||
} | ||
if (typeof(process.env['FIREBASE_UPLOAD_URL']) !== 'undefined') { | ||
try { | ||
var urlParts = url.parse(process.env['FIREBASE_UPLOAD_URL']); | ||
} catch (err) { | ||
var urlParts = null; | ||
} | ||
if (urlParts) { | ||
api.uploadUrl = process.env['FIREBASE_UPLOAD_URL']; | ||
} | ||
} | ||
if (typeof(process.env['FIREBASE_HOSTING_URL']) !== 'undefined') { | ||
try { | ||
var urlParts = url.parse(process.env['FIREBASE_HOSTING_URL']); | ||
} catch (err) { | ||
var urlParts = null; | ||
} | ||
if (urlParts) { | ||
api.hostingUrl = process.env['FIREBASE_HOSTING_URL']; | ||
} | ||
} | ||
} | ||
initApi(); | ||
possiblyOverride('adminUrl', 'FIREBASE_ADMIN_URL'); | ||
possiblyOverride('hostingUrl', 'FIREBASE_HOSTING_URL'); | ||
possiblyOverride('realtimeUrl', 'FIREBASE_REALTIME_URL'); | ||
possiblyOverride('uploadUrl', 'FIREBASE_UPLOAD_URL'); | ||
module.exports = api; |
256
lib/app.js
@@ -17,3 +17,2 @@ var request = require('request'), | ||
chalk = require('chalk'), | ||
temp = require('temp'), | ||
_when = require('when'); | ||
@@ -26,4 +25,2 @@ | ||
temp.track(); | ||
function getPrompt(argv, schema, onComplete, index, results) { | ||
@@ -68,3 +65,3 @@ if (!Array.isArray(schema)) { | ||
function(statusCode, response) { | ||
if (response.error) { | ||
if (statusCode !== 200 || response.error) { | ||
console.log(chalk.red('Security Rules Error') + ' - ' + | ||
@@ -125,5 +122,5 @@ response.error.replace(/\n$/, '')); | ||
error = 'Redirect rule: ' + JSON.stringify(redirect) + ' Must be an object.'; | ||
} else if (!redirect.source || typeof redirect.source !== 'string' || redirect.source.length == 0) { | ||
} else if (!redirect.source || typeof redirect.source !== 'string' || redirect.source.length === 0) { | ||
error = 'Redirect rule: ' + JSON.stringify(redirect) + ' Must contain a "source" attribute that\'s a non-empty string.'; | ||
} else if (!redirect.destination || typeof redirect.destination !== 'string' || redirect.destination.length == 0) { | ||
} else if (!redirect.destination || typeof redirect.destination !== 'string' || redirect.destination.length === 0) { | ||
error = 'Redirect rule: ' + JSON.stringify(redirect) + ' Must contain a "destination" attribute that\'s a non-empty string.'; | ||
@@ -159,5 +156,5 @@ } else if (!/^(\/[^\s]*|https?:\/\/[^\s]+)$/.test(redirect.destination)) { | ||
error = 'Rewrite rule: ' + JSON.stringify(rewrite) + ' Must be an object.'; | ||
} else if (!rewrite.source || typeof rewrite.source !== 'string' || rewrite.source.length == 0) { | ||
} else if (!rewrite.source || typeof rewrite.source !== 'string' || rewrite.source.length === 0) { | ||
error = 'Rewrite rule: ' + JSON.stringify(rewrite) + ' Must contain a "source" attribute that\'s a non-empty string.'; | ||
} else if (!rewrite.destination || typeof rewrite.destination !== 'string' || rewrite.destination.length == 0) { | ||
} else if (!rewrite.destination || typeof rewrite.destination !== 'string' || rewrite.destination.length === 0) { | ||
error = 'Rewrite rule: ' + JSON.stringify(rewrite) + ' Must contain a "destination" attribute that\'s a non-empty string.'; | ||
@@ -207,8 +204,8 @@ } else if (!/^\/[^\s]*[^\/\s]$/.test(rewrite.destination)) { | ||
error = 'Header: ' + JSON.stringify(individualHeader) + ' Must be an object'; | ||
} else if (!individualHeader['key'] || typeof individualHeader['key'] !== 'string' || individualHeader['key'].length === 0) { | ||
} else if (!individualHeader.key || typeof individualHeader.key !== 'string' || individualHeader.key.length === 0) { | ||
error = 'Header: ' + JSON.stringify(individualHeader) + ' Must contain a "key" field that\'s one of: "' + supportedHeaders.join('", "') + '"'; | ||
} else if (!individualHeader['value'] || typeof individualHeader['value'] !== 'string' || individualHeader['value'].length === 0) { | ||
} else if (!individualHeader.value || typeof individualHeader.value !== 'string' || individualHeader.value.length === 0) { | ||
error = 'Header: ' + JSON.stringify(individualHeader) + ' Must contain a "value" field that\'s a non-empty string.'; | ||
} else if (supportedHeaders.indexOf(individualHeader['key']) < 0) { | ||
error = 'Header key: "' + individualHeader['key'] + '" is not supported. Supported keys are: "' + supportedHeaders.join('", "') + '"'; | ||
} else if (supportedHeaders.indexOf(individualHeader.key) < 0) { | ||
error = 'Header key: "' + individualHeader.key + '" is not supported. Supported keys are: "' + supportedHeaders.join('", "') + '"'; | ||
} else if (Object.keys(individualHeader).length > 2) { | ||
@@ -234,2 +231,21 @@ error = 'Header: ' + JSON.stringify(individualHeader) + ' Must not contain any keys other than "key" or "value".'; | ||
function handleFailedDeploy(defaultError) { | ||
return function(err) { | ||
if (err) { | ||
var detailedMessage = chalk.red('Deploy Error') + ' - '; | ||
if (typeof(err.message) !== 'undefined') { | ||
detailedMessage += err.message + ' '; | ||
} | ||
if (typeof(err.details) !== 'undefined') { | ||
detailedMessage += err.details; | ||
} | ||
if (detailedMessage.length === 0) { | ||
detailedMessage = defaultError; | ||
} | ||
console.log(detailedMessage); | ||
process.exit(1); | ||
} | ||
}; | ||
} | ||
function uploadSite(settings, directoryRef, argv) { | ||
@@ -279,10 +295,4 @@ return function() { | ||
upload.send(settings.firebase, settings['public'], settings.ignore, directoryRef.name(), message, function(err, directory) { | ||
if (err) { | ||
console.log(chalk.red('Deploy Error') + ' - Couldn\'t upload app'); | ||
console.log(err); | ||
process.exit(1); | ||
} | ||
}); | ||
} | ||
upload.send(settings.firebase, settings.public, settings.ignore, directoryRef.key(), message, handleFailedDeploy('Couldn\'t upload site')); | ||
}; | ||
} | ||
@@ -311,2 +321,12 @@ | ||
function mkDirs(filePath) { | ||
var filePathParts = filePath.split(path.sep); | ||
for (var i = 1; i < filePathParts.length; i++) { | ||
var folderPath = filePathParts.slice(0, i).join(path.sep); | ||
if (!fs.existsSync(folderPath)) { | ||
fs.mkdirSync(folderPath); | ||
} | ||
} | ||
} | ||
module.exports = { | ||
@@ -373,7 +393,7 @@ init: function(argv) { | ||
getPrompt(argv, schema, function(results) { | ||
if (path.relative('.', results['public']).match(/^\./)) { | ||
if (path.relative('.', results.public).match(/^\./)) { | ||
console.log(chalk.red('init cancelled - the public directory must be within the current working directory')); | ||
process.exit(1); | ||
} | ||
if (!fs.existsSync(results['public'])) { | ||
if (!fs.existsSync(results.public)) { | ||
console.log(chalk.red('init cancelled - the directory you entered does not exist')); | ||
@@ -383,5 +403,5 @@ process.exit(1); | ||
var settings = { | ||
firebase: results.firebase, | ||
'public': results['public'], | ||
'ignore': defaultSettings['ignore'] | ||
'firebase': results.firebase, | ||
'public': results.public, | ||
'ignore': defaultSettings.ignore | ||
}; | ||
@@ -462,4 +482,4 @@ console.log('Initializing app into current directory...'); | ||
} | ||
for (var i = 0; i < templateList.length; i++) { | ||
var key = templateList[i], | ||
for (var j = 0; j < templateList.length; j++) { | ||
var key = templateList[j], | ||
template = supportedTemplates[key]; | ||
@@ -469,3 +489,3 @@ var output = chalk.bold(key); | ||
var spacingString = ''; | ||
for (var j = longestTemplateLength; j > key.length; j--) { | ||
for (var k = longestTemplateLength; k > key.length; k--) { | ||
spacingString += ' '; | ||
@@ -490,3 +510,2 @@ } | ||
var projectDir = path.resolve(dir); | ||
var tempDir = temp.mkdirSync(); | ||
if (fs.existsSync(projectDir)) { | ||
@@ -505,91 +524,94 @@ var i = 1; | ||
var templateRoot = (supportedTemplates[results.template].templateRoot || '/').replace(/\//g, path.sep); | ||
if (templateRoot && templateRoot[0] !== path.sep) { | ||
templateRoot = path.sep + templateRoot; | ||
if (templateRoot.length > 0 && templateRoot[0] === path.sep) { | ||
templateRoot = templateRoot.slice(1); | ||
} | ||
if (templateRoot.length > 1 && templateRoot.slice(-1) !== path.sep) { | ||
templateRoot += path.sep; | ||
} | ||
console.log('Downloading and unpacking template...'); | ||
var gunzip = zlib.createGunzip(); | ||
var untar = tar.Extract({ | ||
path: tempDir, | ||
strip: 1, | ||
filter: function(entry) { | ||
if (!templateRoot) { | ||
return true; | ||
} else { | ||
return (entry.path === tempDir) || (entry.path.indexOf(tempDir + templateRoot) === 0); | ||
var untar = tar.Parse(); | ||
var outStandingFiles = 1; | ||
function fileFinished() { | ||
outStandingFiles -= 1; | ||
if (outStandingFiles <= 0) { | ||
var configFiles = supportedTemplates[results.template].configFiles || []; | ||
for (var i = 0; i < configFiles.length; i++) { | ||
var config = path.join( | ||
projectDir, | ||
configFiles[i] | ||
); | ||
try { | ||
var data = fs.readFileSync(config, 'utf8'), | ||
realtimeHost = api.realtimeUrl.replace(/\/\//, '//' + firebase + '.'); | ||
var replaced = data.replace( | ||
new RegExp(supportedTemplates[results.template].configRegex, 'g'), | ||
realtimeHost | ||
); | ||
fs.writeFileSync(config, replaced); | ||
} catch (err) { | ||
console.log(chalk.red('Initialization Error') + ' - Couldn\'t update template with project settings'); | ||
process.exit(1); | ||
} | ||
} | ||
} | ||
}); | ||
try { | ||
request(supportedTemplates[results.template].tarball).pipe(gunzip).pipe(untar); | ||
} catch (err) { | ||
console.log(chalk.red('Download Error') + ' - Could not download ' + | ||
'template'); | ||
process.exit(1); | ||
} | ||
console.log('Writing firebase.json settings file...'); | ||
var settings = { | ||
'firebase': firebase, | ||
'public': defaultSettings.public, | ||
'ignore': defaultSettings.ignore | ||
}; | ||
var caughtFinishedEvent = false; | ||
untar.on('end', function() { | ||
if (caughtFinishedEvent) return; | ||
caughtFinishedEvent = true; | ||
if (supportedTemplates[results.template].settings) { | ||
if (supportedTemplates[results.template].settings.public) { | ||
settings.public = supportedTemplates[results.template].settings.public; | ||
} | ||
if (supportedTemplates[results.template].settings.rules) { | ||
settings.rules = supportedTemplates[results.template].settings.rules; | ||
} | ||
if (supportedTemplates[results.template].settings.ignore) { | ||
settings.ignore = supportedTemplates[results.template].settings.ignore; | ||
} | ||
} | ||
try { | ||
fs.renameSync(tempDir + templateRoot, projectDir); | ||
} catch (err) { | ||
console.log(chalk.red('Installation Error') + ' - Couldn\'t relocate project assets'); | ||
process.exit(1); | ||
} | ||
var configFiles = supportedTemplates[results.template].configFiles || []; | ||
for (var i = 0; i < configFiles.length; i++) { | ||
var config = path.join( | ||
projectDir, | ||
configFiles[i] | ||
); | ||
var settingsJSON = JSON.stringify(settings, null, 2) + '\n'; | ||
var settingsFile = path.join(projectDir, 'firebase.json'); | ||
try { | ||
var data = fs.readFileSync(config, 'utf8'), | ||
realtimeHost = api.realtimeUrl.replace(/\/\//, '//' + firebase + '.'); | ||
var replaced = data.replace( | ||
new RegExp(supportedTemplates[results.template].configRegex, 'g'), | ||
realtimeHost | ||
); | ||
fs.writeFileSync(config, replaced); | ||
fs.writeFileSync(settingsFile, settingsJSON); | ||
} catch (err) { | ||
console.log(chalk.red('Initialization Error') + ' - Couldn\'t update template with project settings'); | ||
console.log(chalk.red('Filesystem Error') + ' - Could not save settings file'); | ||
process.exit(1); | ||
} | ||
console.log(chalk.green('Successfully added template')); | ||
console.log('To deploy: %s then %s', chalk.bold(util.format('cd %s', results.directory + path.sep)), chalk.bold('firebase deploy')); | ||
} | ||
} | ||
console.log('Writing firebase.json settings file...'); | ||
var settings = { | ||
'firebase': firebase, | ||
'public': defaultSettings['public'], | ||
'ignore': defaultSettings['ignore'] | ||
}; | ||
var extraction = request(supportedTemplates[results.template].tarball).pipe(gunzip).pipe(untar); | ||
if (supportedTemplates[results.template].settings) { | ||
if (supportedTemplates[results.template].settings['public']) { | ||
settings.public = supportedTemplates[results.template].settings['public']; | ||
extraction.on('error', function(err) { | ||
console.log(chalk.red('Download Error') + ' - Could not download ' + | ||
'template'); | ||
process.exit(1); | ||
}); | ||
extraction.on('entry', function(entry) { | ||
if (entry.type === 'File') { | ||
var key = path.normalize(entry.path).split(path.sep).slice(1).join(path.sep); | ||
var pattern = new RegExp('^' + templateRoot.replace(/\\/g, '\\\\') + '(.+)$'); | ||
var match = key.match(pattern); | ||
if (match && match.length > 1) { | ||
outStandingFiles += 1; | ||
var outputPath = dir + path.sep + match[1]; | ||
mkDirs(outputPath); | ||
entry.pipe(fs.createWriteStream(outputPath)).on('finish', fileFinished); | ||
} | ||
if (supportedTemplates[results.template].settings['rules']) { | ||
settings.rules = supportedTemplates[results.template].settings['rules']; | ||
} | ||
if (supportedTemplates[results.template].settings['ignore']) { | ||
settings.ignore = supportedTemplates[results.template].settings['ignore']; | ||
} | ||
} | ||
}); | ||
var settingsJSON = JSON.stringify(settings, null, 2) + '\n'; | ||
var settingsFile = path.join(projectDir, 'firebase.json'); | ||
try { | ||
fs.writeFileSync(settingsFile, settingsJSON); | ||
} catch (err) { | ||
console.log(chalk.red('Filesystem Error') + ' - Could not save settings file'); | ||
process.exit(1); | ||
} | ||
console.log(chalk.green('Successfully added template')); | ||
console.log('To deploy: %s then %s', chalk.bold(util.format('cd %s', results.directory + path.sep)), chalk.bold('firebase deploy')); | ||
}); | ||
extraction.on('end', fileFinished); | ||
}); | ||
@@ -640,3 +662,3 @@ }, function(error) { | ||
} | ||
if (path.relative('.', settings['public']).match(/^\.\./)) { | ||
if (path.relative('.', settings.public).match(/^\.\./)) { | ||
console.log(chalk.red('Public Directory Error') + ' - public directory' + | ||
@@ -646,3 +668,3 @@ ' must be within current working directory'); | ||
} | ||
if (!fs.existsSync(settings['public'])) { | ||
if (!fs.existsSync(settings.public)) { | ||
console.log(chalk.red('Public Directory Error') + ' - Public directory ' + | ||
@@ -661,3 +683,3 @@ 'does not exist'); | ||
var firebaseRef = new Firebase(api.realtimeUrl.replace(/\/\//, '//firebase.')); | ||
firebaseRef.auth(tokens.firebaseToken, function(error, result) { | ||
firebaseRef.authWithCustomToken(tokens.firebaseToken, function(error, result) { | ||
if (error) { | ||
@@ -700,3 +722,3 @@ console.log('Firebase authentication failed!'); | ||
var firebaseRef = new Firebase(api.realtimeUrl.replace(/\/\//, '//firebase.')); | ||
firebaseRef.auth(tokens.firebaseToken, function(error, result) { | ||
firebaseRef.authWithCustomToken(tokens.firebaseToken, function(error, result) { | ||
if (error) { | ||
@@ -711,24 +733,8 @@ console.log('Firebase authentication failed!'); | ||
.push(); | ||
var bar = null; | ||
var total = 0; | ||
directoryRef.on('value', function(snapshot) { | ||
var status = snapshot.child('status').val(); | ||
if (status === 'deploying') { | ||
if (!bar && snapshot.hasChild('fileCount')) { | ||
total = snapshot.child('fileCount').val(); | ||
bar = new ProgressBar(chalk.yellow('progress: :percent'), { | ||
total: total | ||
}); | ||
} | ||
if (bar) { | ||
var uploadedCount = snapshot.hasChild('uploadedCount') ? snapshot.child('uploadedCount').val() : 0; | ||
bar.update(uploadedCount / total); | ||
} | ||
} else if (status === 'removed') { | ||
if (status === 'removed') { | ||
console.log(chalk.green('Sucessfully removed')); | ||
process.exit(0); | ||
} else if (status === 'failed') { | ||
if (bar) { | ||
bar.terminate(); | ||
} | ||
var message = chalk.red('Deploy Failed'); | ||
@@ -748,9 +754,3 @@ if (snapshot.hasChild('statusMessage')) { | ||
upload.deleteSite(settings.firebase, directoryRef.name(), message, function(err, directory) { | ||
if (err) { | ||
console.log(chalk.red('Deploy Error') + ' - Couldn\'t upload app'); | ||
console.log(err); | ||
process.exit(1); | ||
} | ||
}); | ||
upload.deleteSite(settings.firebase, directoryRef.key(), message, handleFailedDeploy('Couldn\'t delete site')); | ||
}); | ||
@@ -757,0 +757,0 @@ }); |
@@ -190,4 +190,4 @@ var prompt = require('prompt'), | ||
fs.unlinkSync(that.configFile); | ||
} catch (err) { | ||
setTimeout(callback, 0, err); | ||
} catch (e) { | ||
setTimeout(callback, 0, e); | ||
return; | ||
@@ -194,0 +194,0 @@ } |
@@ -7,15 +7,15 @@ var request = require('request'), | ||
zlib = require('zlib'), | ||
temp = require('temp'), | ||
fs = require('fs'), | ||
path = require('path'), | ||
chalk = require('chalk'); | ||
chalk = require('chalk'), | ||
util = require('util'), | ||
stream = require('stream'); | ||
temp.track(); | ||
module.exports = { | ||
send: function(firebase, publicDir, ignoreRules, pushId, message, callback) { | ||
var writeStream = temp.createWriteStream({ suffix: '.tar.gz' }), | ||
filename = writeStream.path, | ||
fileCount = 0, | ||
var fileCount = 0, | ||
buffers = [], | ||
tarballSize = 0, | ||
foundIndex = false, | ||
zipStream = zlib.createGzip(), | ||
indexPath = path.resolve(path.join(publicDir, 'index.html')); | ||
@@ -46,7 +46,31 @@ | ||
process.exit(1); | ||
}).pipe(tar.Pack()) | ||
.pipe(zlib.createGzip()) | ||
.pipe(writeStream); | ||
}); | ||
writeStream.once('finish', function() { | ||
reader.pipe(tar.Pack()) | ||
.pipe(zipStream); | ||
zipStream.on('data', function(chunk) { | ||
buffers.push(chunk); | ||
tarballSize += chunk.length; | ||
}); | ||
zipStream.on('end', function() { | ||
var BufferStream = function(buffers, options) { | ||
this.buffers = buffers.reverse(); | ||
stream.Readable.call(this, options); | ||
}; | ||
util.inherits(BufferStream, stream.Readable); | ||
BufferStream.prototype._read = function() { | ||
if (this.buffers.length > 0) { | ||
this.push(this.buffers.pop()); | ||
} else { | ||
this.push(null); | ||
} | ||
}; | ||
var bufferStream = new BufferStream(buffers); | ||
if (fileCount === 0) { | ||
@@ -66,3 +90,2 @@ console.log(chalk.yellow('Public Directory Warning') + ' - Public ' + | ||
var url = api.uploadUrl + '/upload/' + firebase + '?' + params.join('&'); | ||
var readStream = fs.createReadStream(filename); | ||
@@ -73,44 +96,29 @@ var r = request.put({ | ||
}, function(err, response, body) { | ||
fs.unlink(filename); | ||
var failed = (err || !body || !body.success); | ||
setTimeout(callback, 0, failed, body ? body.directory : undefined); | ||
var failed = (err || !body || body.error); | ||
setTimeout(callback, 0, failed, body && body.directory); | ||
}); | ||
var form = r.form(); | ||
form.append('site', readStream); | ||
form.append('site', bufferStream, { | ||
filename: 'site.tar.gz', | ||
contentType: 'application/x-gzip', | ||
knownLength: tarballSize | ||
}); | ||
}); | ||
}, | ||
deleteSite: function(firebase, pushId, message, callback) { | ||
var writeStream = temp.createWriteStream({ suffix: '.tar.gz' }), | ||
filename = writeStream.path, | ||
publicDir = temp.mkdirSync(); | ||
var params = ['id=' + encodeURIComponent(pushId), 'token=' + auth.token]; | ||
if (message) { | ||
params.push('message=' + encodeURIComponent(message)); | ||
} | ||
var url = api.uploadUrl + '/upload/' + firebase + '?' + params.join('&'); | ||
console.log('Preparing to delete site...'); | ||
fstreamIgnore({ | ||
path: publicDir, | ||
type: 'Directory' | ||
}).pipe(tar.Pack()) | ||
.pipe(zlib.createGzip()) | ||
.pipe(writeStream); | ||
writeStream.once('finish', function() { | ||
var params = ['id=' + encodeURIComponent(pushId), 'fileCount=0', 'token=' + auth.token]; | ||
if (message) { | ||
params.push('message=' + encodeURIComponent(message)); | ||
} | ||
var url = api.uploadUrl + '/upload/' + firebase + '?' + params.join('&'); | ||
var readStream = fs.createReadStream(filename); | ||
var r = request.put({ | ||
url: url, | ||
json: true | ||
}, function(err, response, body) { | ||
fs.unlink(filename); | ||
var failed = (err || !body || !body.success); | ||
setTimeout(callback, 0, failed, body ? body.directory : undefined); | ||
}); | ||
var form = r.form(); | ||
form.append('site', readStream); | ||
var r = request({ | ||
url: url, | ||
method: 'DELETE', | ||
json: true | ||
}, function(err, response, body) { | ||
var failed = (err || !body || body.error); | ||
setTimeout(callback, 0, failed, body && body.directory); | ||
}); | ||
} | ||
}; |
{ | ||
"name": "firebase-tools", | ||
"preferGlobal": true, | ||
"version": "1.1.4", | ||
"description": "The Firebase Command Line Tools", | ||
"description": "Firebase command line tools", | ||
"version": "1.1.5", | ||
"author": "Firebase <support@firebase.com> (https://www.firebase.com/)", | ||
"homepage": "https://github.com/firebase/firebase-tools/", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/firebase/firebase-tools.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/firebase/firebase-tools/issues" | ||
}, | ||
"licenses": [ | ||
{ | ||
"type": "MIT", | ||
"url": "http://firebase.mit-license.org/" | ||
} | ||
], | ||
"keywords": [ | ||
"firebase", | ||
"hosting", | ||
"ssl", | ||
"cdn", | ||
"cli", | ||
"synchronization", | ||
"real-time", | ||
"ssl", | ||
"cloud", | ||
"hosting", | ||
"firebase", | ||
"realtime", | ||
"websockets", | ||
"cloud" | ||
"synchronization" | ||
], | ||
"author": "Firebase <support@firebase.com>", | ||
"contributors": [ | ||
{ | ||
"name": "Chris Raynor", | ||
"email": "chris@firebase.com" | ||
}, | ||
{ | ||
"name": "Adam Putinski", | ||
"email": "adam@firebase.com" | ||
}, | ||
{ | ||
"name": "Rob DiMarco", | ||
"email": "rob@firebase.com" | ||
} | ||
"preferGlobal": true, | ||
"bin": { | ||
"firebase": "./bin/firebase" | ||
}, | ||
"engines": { | ||
"node": ">=0.10.0" | ||
}, | ||
"engineStrict": true, | ||
"files": [ | ||
"bin/**", | ||
"lib/**", | ||
"LICENSE", | ||
"README.md", | ||
"package.json" | ||
], | ||
"repository": "https://github.com/firebase/firebase-tools.git", | ||
"homepage": "https://github.com/firebase/firebase-tools", | ||
"dependencies": { | ||
"chalk": "0.5.x", | ||
"firebase": "2.1.x", | ||
"fstream-ignore": "1.0.x", | ||
"open": "0.0.x", | ||
"optimist": "0.6.x", | ||
"progress": "1.1.x", | ||
"prompt": "0.2.x", | ||
"tar": "0.1.x", | ||
"open": "0.0.x", | ||
"request": "2.34.x", | ||
"fstream-ignore": "0.0.x", | ||
"temp": "0.6.x", | ||
"firebase": "~1.0.11", | ||
"progress": "~1.1.5", | ||
"when": "3.1.0", | ||
"chalk": "~0.4.0" | ||
"request": "2.51.x", | ||
"tar": "1.0.x", | ||
"when": "3.6.x" | ||
}, | ||
"bin": { | ||
"firebase": "./bin/firebase" | ||
"devDependencies": { | ||
"chai": "^1.10.0", | ||
"coveralls": "2.11.2", | ||
"gulp": "3.8.10", | ||
"gulp-exit": "0.0.2", | ||
"gulp-istanbul": "0.5.0", | ||
"gulp-jshint": "1.9.0", | ||
"gulp-mocha": "2.0.0", | ||
"jshint-stylish": "1.0.0" | ||
}, | ||
"engines": { | ||
"node": ">=0.10.0" | ||
}, | ||
"engineStrict": true | ||
"scripts": { | ||
"test": "gulp test", | ||
"travis": "gulp" | ||
} | ||
} |
# firebase-tools | ||
[![Build Status](https://travis-ci.org/firebase/firebase-tools.svg?branch=master)](https://travis-ci.org/firebase/firebase-tools) | ||
[![Coverage Status](https://img.shields.io/coveralls/firebase/firebase-tools.svg?branch=master&style=flat)](https://coveralls.io/r/firebase/firebase-tools) | ||
[![NPM version](https://badge.fury.io/js/firebase-tools.svg)](http://badge.fury.io/js/firebase-tools) | ||
@@ -8,15 +10,18 @@ | ||
* Administer your Firebase account | ||
* Interact with [Firebase Hosting](https://www.firebase.com/hosting.html), our product to host your HTML, JS, CSS, images, etc. | ||
* Interact with [Firebase Hosting](https://www.firebase.com/hosting.html), our product to host your | ||
static HTML, JS, CSS, images, etc. | ||
To get started with the Firebase CLI, [read through our hosting quickstart guide](https://www.firebase.com/docs/hosting.html). | ||
## Installation | ||
To install the Firebase CLI, you first need to [sign up for a Firebase account](https://www.firebase.com/signup/). | ||
Then you need to install [Node.js](http://nodejs.org/) and [npm](https://npmjs.org/). | ||
Note that installing Node.js should install npm as well. | ||
Once npm is installed, get the Firebase CLI by running the following shell command: | ||
Then you need to install [Node.js](http://nodejs.org/) and [npm](https://npmjs.org/). Note that | ||
installing Node.js should install npm as well. | ||
```shell | ||
Once npm is installed, get the Firebase CLI by running the following command: | ||
```bash | ||
npm install -g firebase-tools | ||
@@ -27,61 +32,14 @@ ``` | ||
## Commands | ||
The command `firebase --help` lists the available commands and | ||
`firebase <command> --help` shows more details for an individual command. | ||
The command `firebase --help` lists the available commands and `firebase <command> --help` shows | ||
more details for an individual command. | ||
Here is the output of running `firebase --help`: | ||
You can get more information about the available commands in our | ||
[command line documentation](https://www.firebase.com/docs/hosting/command-line-tool.html). | ||
```shell | ||
Usage: firebase <command> | ||
Available commands are: | ||
bootstrap | ||
Creates a new Firebase powered app from a prebuilt template to quickly | ||
get a project up and running. This creates a new folder and prompts | ||
you through all the required settings. | ||
deploy | ||
Deploys the current app to Firebase Hosting and creates your subdomain on | ||
firebaseapp.com if it doesn't exist already. | ||
init | ||
Initializes an existing Firebase app in the current directory and prompts | ||
you through configuring it for firebaseapp.com. | ||
open | ||
Opens the URL of the current Firebase app in a browser. | ||
list | ||
Lists the Firebases available to the currently logged in user. | ||
delete-site | ||
Deletes the current app from Firebase Hosting and displays a | ||
'Site not Found' page as if the site had never been deployed to. | ||
login | ||
Logs the user into Firebase. All commands that require login will prompt | ||
you if you're not currently logged in. | ||
logout | ||
Logs the user out of Firebase. | ||
-h, --help | ||
Shows this help screen. Use `firebase <command> --help` for more | ||
detailed help instructions. | ||
-v, --version | ||
Displays the current version. | ||
-s, --silent | ||
Silent mode for scripting - commands will error with non-zero status code | ||
instead of waiting for prompt if not enough information supplied. | ||
``` | ||
## Credit | ||
Inspired by [Luke Vivier](https://github.com/lvivier/)'s Firebase command line tools. | ||
## License | ||
[MIT](http://firebase.mit-license.org) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 4 instances in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No License Found
License(Experimental) License information could not be found.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
10
0
0
9
66105
8
10
1474
44
+ Addedansi-regex@0.2.1(transitive)
+ Addedansi-styles@1.1.0(transitive)
+ Addedbl@0.9.5(transitive)
+ Addedcaseless@0.8.0(transitive)
+ Addedchalk@0.5.1(transitive)
+ Addedcore-util-is@1.0.3(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedfirebase@2.1.2(transitive)
+ Addedform-data@0.2.0(transitive)
+ Addedfstream@1.0.12(transitive)
+ Addedfstream-ignore@1.0.5(transitive)
+ Addedgraceful-fs@4.2.11(transitive)
+ Addedhas-ansi@0.1.0(transitive)
+ Addedhawk@1.1.1(transitive)
+ Addedisarray@0.0.1(transitive)
+ Addedmime-db@1.12.0(transitive)
+ Addedmime-types@1.0.22.0.14(transitive)
+ Addedoauth-sign@0.5.0(transitive)
+ Addedqs@2.3.3(transitive)
+ Addedreadable-stream@1.0.34(transitive)
+ Addedrequest@2.51.0(transitive)
+ Addedstring_decoder@0.10.31(transitive)
+ Addedstringstream@0.0.6(transitive)
+ Addedstrip-ansi@0.3.0(transitive)
+ Addedsupports-color@0.2.0(transitive)
+ Addedtar@1.0.3(transitive)
+ Addedtunnel-agent@0.4.3(transitive)
+ Addedwhen@3.6.4(transitive)
- Removedtemp@0.6.x
- Removedansi-styles@1.0.0(transitive)
- Removedchalk@0.4.0(transitive)
- Removedfirebase@1.0.24(transitive)
- Removedform-data@0.1.4(transitive)
- Removedfstream@0.1.31(transitive)
- Removedfstream-ignore@0.0.10(transitive)
- Removedgraceful-fs@1.2.33.0.12(transitive)
- Removedhas-color@0.1.7(transitive)
- Removedhawk@1.0.0(transitive)
- Removedlru-cache@2.7.3(transitive)
- Removedmime@1.2.11(transitive)
- Removedminimatch@0.3.0(transitive)
- Removednatives@1.1.6(transitive)
- Removedoauth-sign@0.3.0(transitive)
- Removedosenv@0.0.3(transitive)
- Removedqs@0.6.6(transitive)
- Removedrequest@2.34.0(transitive)
- Removedrimraf@2.1.4(transitive)
- Removedsigmund@1.0.1(transitive)
- Removedstrip-ansi@0.1.1(transitive)
- Removedtar@0.1.20(transitive)
- Removedtemp@0.6.0(transitive)
- Removedtunnel-agent@0.3.0(transitive)
- Removedwhen@3.1.0(transitive)
Updatedchalk@0.5.x
Updatedfirebase@2.1.x
Updatedfstream-ignore@1.0.x
Updatedprogress@1.1.x
Updatedrequest@2.51.x
Updatedtar@1.0.x
Updatedwhen@3.6.x