Command renames and rename help. (#78)

This commit is contained in:
Michael Bleigh
2016-05-16 10:53:06 -07:00
parent 3064d826e9
commit cbe778eccc
11 changed files with 53 additions and 33 deletions

View File

@@ -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

View File

@@ -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`

View File

@@ -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 <path>')
module.exports = new Command('database:get <path>')
.description('fetch and print JSON data at the specified path')
.option('-o, --output <filename>', 'save output to the specified file')
.option('--pretty', 'pretty print response')
@@ -48,7 +48,7 @@ module.exports = new Command('data:get <path>')
.option('--start-at <val>', 'start results at <val> (based on specified ordering)')
.option('--end-at <val>', 'end results at <val> (based on specified ordering)')
.option('--equal-to <val>', 'restrict results to <val> (based on specified ordering)')
.before(requireDataAccess)
.before(requireDatabaseAccess)
.action(function(path, options) {
if (!_.startsWith(path, '/')) {
return utils.reject('Path must begin with /', {exit: 1});

View File

@@ -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 <path> [infile]')
module.exports = new Command('database:push <path> [infile]')
.description('add a new JSON object to a list of data in your Firebase')
.option('-d, --data <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});

View File

@@ -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 <path>')
module.exports = new Command('database:remove <path>')
.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});

View File

@@ -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 <path> [infile]')
module.exports = new Command('database:set <path> [infile]')
.description('store JSON data at the specified path via STDIN, arg, or file')
.option('-d, --data <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});

View File

@@ -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 <path> [infile]')
module.exports = new Command('database:update <path> [infile]')
.description('update some of the keys for the defined path in your Firebase')
.option('-d, --data <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});

View File

@@ -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)

View File

@@ -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) {

View File

@@ -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);