From cbe778ecccc9ae68b02f537e3dbb1e407057c59c Mon Sep 17 00:00:00 2001 From: Michael Bleigh Date: Mon, 16 May 2016 10:53:06 -0700 Subject: [PATCH] Command renames and rename help. (#78) --- README.md | 19 ++++++++++++------- changelog.txt | 2 ++ commands/{data-get.js => database-get.js} | 6 +++--- commands/{data-push.js => database-push.js} | 6 +++--- .../{data-remove.js => database-remove.js} | 6 +++--- commands/{data-set.js => database-set.js} | 6 +++--- .../{data-update.js => database-update.js} | 6 +++--- ...{disable-hosting.js => hosting-disable.js} | 2 +- commands/index.js | 16 ++++++++-------- index.js | 17 +++++++++++++++-- ...DataAccess.js => requireDatabaseAccess.js} | 0 11 files changed, 53 insertions(+), 33 deletions(-) rename commands/{data-get.js => database-get.js} (95%) rename commands/{data-push.js => database-push.js} (92%) rename commands/{data-remove.js => database-remove.js} (91%) rename commands/{data-set.js => database-set.js} (93%) rename commands/{data-update.js => database-update.js} (93%) rename commands/{disable-hosting.js => hosting-disable.js} (96%) rename lib/{requireDataAccess.js => requireDatabaseAccess.js} (100%) diff --git a/README.md b/README.md index ad3b09ca..adacca5f 100644 --- a/README.md +++ b/README.md @@ -59,17 +59,22 @@ Command | Description ------- | ----------- **deploy** | Deploys your Firebase project. Relies on `firebase.json` configuration and your local project folder. **serve** | Start a local web server with your Firebase Hosting configuration. Relies on `firebase.json`. -**disable:hosting** | Stop serving Firebase Hosting traffic for the active project. A "Site Not Found" message will be displayed at your project's Hosting URL after running this command. -### Data Commands +### Database Commands Command | Description ------- | ----------- -**data:get** | Fetch data from the current project's database and display it as JSON. Supports querying on indexed data. -**data:set** | Replace all data at a specified location in the current project's database. Takes input from file, STDIN, or command-line argument. -**data:update** | Perform a partial update at a specified location in the current project's database. Takes input from file, STDIN, or command-line argument. -**data:push** | Push new data to a list at a specified location in the current project's database. Takes input from file, STDIN, or command-line argument. -**data:remove** | Delete all data at a specified location in the current project's database. +**database:get** | Fetch data from the current project's database and display it as JSON. Supports querying on indexed data. +**database:set** | Replace all data at a specified location in the current project's database. Takes input from file, STDIN, or command-line argument. +**database:update** | Perform a partial update at a specified location in the current project's database. Takes input from file, STDIN, or command-line argument. +**database:push** | Push new data to a list at a specified location in the current project's database. Takes input from file, STDIN, or command-line argument. +**database:remove** | Delete all data at a specified location in the current project's database. + +### Hosting Commands + +Command | Description +------- | ----------- +**hosting:disable** | Stop serving Firebase Hosting traffic for the active project. A "Site Not Found" message will be displayed at your project's Hosting URL after running this command. ## Using with CI Systems diff --git a/changelog.txt b/changelog.txt index ba4cd655..8035bc21 100644 --- a/changelog.txt +++ b/changelog.txt @@ -2,6 +2,8 @@ important - Version 3.0+ is only compatible with projects created in or imported changed - The Firebase CLI now uses direct Google OAuth2 login. All users must re-authenticate. changed - The `-f`/`--firebase` option has been renamed to `-P`/`--project` and refers to project id, not instance name. changed - The `firebase deploy:*` commands have been replaced with `firebase deploy --only *` with a list of features. +changed - The `firebase data:*` commands have been renamed to `firebase database:*` commands. +changed - The `firebase disable:hosting` command has been renamed to `firebase hosting:disable`. changed - `firebase init` now initializes multiple features and can be re-run in an existing project directory. changed - `firebase open` no longer just opens Hosting site, now provides a selection of useful project URLs. changed - `firebase prefs:token` is removed in favor of `firebase login:ci` diff --git a/commands/data-get.js b/commands/database-get.js similarity index 95% rename from commands/data-get.js rename to commands/database-get.js index 07d8b076..04fa6880 100644 --- a/commands/data-get.js +++ b/commands/database-get.js @@ -1,7 +1,7 @@ 'use strict'; var Command = require('../lib/command'); -var requireDataAccess = require('../lib/requireDataAccess'); +var requireDatabaseAccess = require('../lib/requireDatabaseAccess'); var request = require('request'); var api = require('../lib/api'); var responseToError = require('../lib/responseToError'); @@ -34,7 +34,7 @@ var _applyStringOpts = function(dest, src, keys, jsonKeys) { }); }; -module.exports = new Command('data:get ') +module.exports = new Command('database:get ') .description('fetch and print JSON data at the specified path') .option('-o, --output ', 'save output to the specified file') .option('--pretty', 'pretty print response') @@ -48,7 +48,7 @@ module.exports = new Command('data:get ') .option('--start-at ', 'start results at (based on specified ordering)') .option('--end-at ', 'end results at (based on specified ordering)') .option('--equal-to ', 'restrict results to (based on specified ordering)') - .before(requireDataAccess) + .before(requireDatabaseAccess) .action(function(path, options) { if (!_.startsWith(path, '/')) { return utils.reject('Path must begin with /', {exit: 1}); diff --git a/commands/data-push.js b/commands/database-push.js similarity index 92% rename from commands/data-push.js rename to commands/database-push.js index 279628c4..0f6deb8d 100644 --- a/commands/data-push.js +++ b/commands/database-push.js @@ -1,7 +1,7 @@ 'use strict'; var Command = require('../lib/command'); -var requireDataAccess = require('../lib/requireDataAccess'); +var requireDatabaseAccess = require('../lib/requireDatabaseAccess'); var request = require('request'); var api = require('../lib/api'); var responseToError = require('../lib/responseToError'); @@ -15,10 +15,10 @@ var fs = require('fs'); var Firebase = require('firebase'); var _ = require('lodash'); -module.exports = new Command('data:push [infile]') +module.exports = new Command('database:push [infile]') .description('add a new JSON object to a list of data in your Firebase') .option('-d, --data ', 'specify escaped JSON directly') - .before(requireDataAccess) + .before(requireDatabaseAccess) .action(function(path, infile, options) { if (!_.startsWith(path, '/')) { return utils.reject('Path must begin with /', {exit: 1}); diff --git a/commands/data-remove.js b/commands/database-remove.js similarity index 91% rename from commands/data-remove.js rename to commands/database-remove.js index a63e1d99..4bb588f3 100644 --- a/commands/data-remove.js +++ b/commands/database-remove.js @@ -1,7 +1,7 @@ 'use strict'; var Command = require('../lib/command'); -var requireDataAccess = require('../lib/requireDataAccess'); +var requireDatabaseAccess = require('../lib/requireDatabaseAccess'); var request = require('request'); var api = require('../lib/api'); var responseToError = require('../lib/responseToError'); @@ -13,10 +13,10 @@ var prompt = require('../lib/prompt'); var chalk = require('chalk'); var _ = require('lodash'); -module.exports = new Command('data:remove ') +module.exports = new Command('database:remove ') .description('remove data from your Firebase at the specified path') .option('-y, --confirm', 'pass this option to bypass confirmation prompt') - .before(requireDataAccess) + .before(requireDatabaseAccess) .action(function(path, options) { if (!_.startsWith(path, '/')) { return utils.reject('Path must begin with /', {exit: 1}); diff --git a/commands/data-set.js b/commands/database-set.js similarity index 93% rename from commands/data-set.js rename to commands/database-set.js index faa67fec..2275faf3 100644 --- a/commands/data-set.js +++ b/commands/database-set.js @@ -1,7 +1,7 @@ 'use strict'; var Command = require('../lib/command'); -var requireDataAccess = require('../lib/requireDataAccess'); +var requireDatabaseAccess = require('../lib/requireDatabaseAccess'); var request = require('request'); var api = require('../lib/api'); var responseToError = require('../lib/responseToError'); @@ -15,11 +15,11 @@ var fs = require('fs'); var prompt = require('../lib/prompt'); var _ = require('lodash'); -module.exports = new Command('data:set [infile]') +module.exports = new Command('database:set [infile]') .description('store JSON data at the specified path via STDIN, arg, or file') .option('-d, --data ', 'specify escaped JSON directly') .option('-y, --confirm', 'pass this option to bypass confirmation prompt') - .before(requireDataAccess) + .before(requireDatabaseAccess) .action(function(path, infile, options) { if (!_.startsWith(path, '/')) { return utils.reject('Path must begin with /', {exit: 1}); diff --git a/commands/data-update.js b/commands/database-update.js similarity index 93% rename from commands/data-update.js rename to commands/database-update.js index f87e5c84..b1345a54 100644 --- a/commands/data-update.js +++ b/commands/database-update.js @@ -1,7 +1,7 @@ 'use strict'; var Command = require('../lib/command'); -var requireDataAccess = require('../lib/requireDataAccess'); +var requireDatabaseAccess = require('../lib/requireDatabaseAccess'); var request = require('request'); var api = require('../lib/api'); var responseToError = require('../lib/responseToError'); @@ -15,11 +15,11 @@ var fs = require('fs'); var prompt = require('../lib/prompt'); var _ = require('lodash'); -module.exports = new Command('data:update [infile]') +module.exports = new Command('database:update [infile]') .description('update some of the keys for the defined path in your Firebase') .option('-d, --data ', 'specify escaped JSON directly') .option('-y, --confirm', 'pass this option to bypass confirmation prompt') - .before(requireDataAccess) + .before(requireDatabaseAccess) .action(function(path, infile, options) { if (!_.startsWith(path, '/')) { return utils.reject('Path must begin with /', {exit: 1}); diff --git a/commands/disable-hosting.js b/commands/hosting-disable.js similarity index 96% rename from commands/disable-hosting.js rename to commands/hosting-disable.js index 9fced95f..158606a8 100644 --- a/commands/disable-hosting.js +++ b/commands/hosting-disable.js @@ -8,7 +8,7 @@ var prompt = require('../lib/prompt'); var chalk = require('chalk'); var RSVP = require('rsvp'); -module.exports = new Command('disable:hosting') +module.exports = new Command('hosting:disable') .description('stop serving web traffic to your Firebase Hosting site') .option('-y, --confirm', 'skip confirmation') .before(requireAccess) diff --git a/commands/index.js b/commands/index.js index dbcaa84e..6ef4f89d 100644 --- a/commands/index.js +++ b/commands/index.js @@ -9,18 +9,18 @@ module.exports = function(client) { return cmd.runner(); }; - client.data = { - get: loadCommand('data-get'), - push: loadCommand('data-push'), - set: loadCommand('data-set'), - remove: loadCommand('data-remove'), - update: loadCommand('data-update') + client.database = { + get: loadCommand('database-get'), + push: loadCommand('database-push'), + set: loadCommand('database-set'), + remove: loadCommand('database-remove'), + update: loadCommand('database-update') }; client.deploy = loadCommand('deploy'); - client.disable = { - hosting: loadCommand('disable-hosting') + client.hosting = { + disable: loadCommand('hosting-disable') }; if (previews.functions) { diff --git a/index.js b/index.js index 40bb65ac..2a26dc43 100644 --- a/index.js +++ b/index.js @@ -36,15 +36,28 @@ var commandNames = program.commands.map(function(cmd) { return cmd._name; }); +var RENAMED_COMMANDS = { + 'delete-site': 'hosting:disable', + 'disable:hosting': 'hosting:disable', + 'data:get': 'database:get', + 'data:push': 'database:push', + 'data:remove': 'database:remove', + 'data:set': 'database:set', + 'data:update': 'database:update', + 'deploy:hosting': 'deploy --only hosting', + 'deploy:database': 'deploy --only database', + 'prefs:token': 'login:ci' +}; + program.action(function(cmd, cmd2) { logger.error( chalk.bold.red('Error:'), chalk.bold(cmd), 'is not a Firebase command' ); - if (cmd === 'delete-site') { + if (RENAMED_COMMANDS[cmd]) { logger.error(); - logger.error(chalk.bold('delete-site') + ' has been renamed, please run', chalk.bold('firebase disable:hosting'), 'instead'); + logger.error(chalk.bold(cmd) + ' has been renamed, please run', chalk.bold('firebase ' + RENAMED_COMMANDS[cmd]), 'instead'); } else { var suggestion = didYouMean(cmd, commandNames); suggestion = suggestion || didYouMean([cmd, cmd2].join(':'), commandNames); diff --git a/lib/requireDataAccess.js b/lib/requireDatabaseAccess.js similarity index 100% rename from lib/requireDataAccess.js rename to lib/requireDatabaseAccess.js