mirror of
https://github.com/zhigang1992/firebase-tools.git
synced 2026-01-12 17:22:36 +08:00
Added gulp, Travis, a test framework, and made it Catapult-enabled
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,4 +1,6 @@
|
||||
node_modules
|
||||
coverage/
|
||||
node_modules/
|
||||
|
||||
.DS_Store
|
||||
.idea
|
||||
*.iml
|
||||
|
||||
9
.travis.yml
Normal file
9
.travis.yml
Normal file
@@ -0,0 +1,9 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- '0.10'
|
||||
install:
|
||||
- npm install
|
||||
script:
|
||||
- npm run travis
|
||||
after_script:
|
||||
- cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js
|
||||
39
CHANGELOG.md
39
CHANGELOG.md
@@ -1,39 +0,0 @@
|
||||
## v1.1.4
|
||||
- Fixing wrong error message when incorrect password entered
|
||||
|
||||
## v1.1.3
|
||||
- Fixes progress bar so it doesn't stick at 100% at the end of long uploads
|
||||
- Improves error messaging on login / token validation if the CLI version is out of date
|
||||
|
||||
## v1.1.2
|
||||
- Adds client-side validation of new advanced features with better error messaging
|
||||
|
||||
## v1.1.1
|
||||
- Adds a brief description of each template inline when running `firebase bootstrap`
|
||||
|
||||
## v1.1.0
|
||||
- Supports new advanced features parameters in the `firebase.json` to allow greater customization of hosting parameters
|
||||
- improves default "ignore" rules to specify any dot file, regardless of whether in a sub-directory
|
||||
|
||||
- - -
|
||||
|
||||
## v1.0.6
|
||||
- Adds `-s` functionality to all commands for silent mode while scripting - commands will error with non-zero status code instead of waiting for prompt if not enough information supplied
|
||||
- `delete-site` command as a convenience method for removing a site from hosting. Site shows up as 'Site Not Found' as if never deployed to
|
||||
|
||||
## v1.0.5
|
||||
- Gracefully handles error caused by symlinks in public directory until [isaacs/fstream#16](https://github.com/isaacs/fstream/pull/16) fix
|
||||
|
||||
## v1.0.4
|
||||
- NPM artifact fix
|
||||
|
||||
## v1.0.3
|
||||
- Allows command line params in `firebase deploy` to override `firebase.json` settings
|
||||
|
||||
## v1.0.2
|
||||
- Enforces node 0.10.x and above after shown not to work on previous versions
|
||||
|
||||
## v1.0.1
|
||||
- Fixes bug with `firebase bootstrap` on windows
|
||||
- Adds 'ignore' to `firebase.json` to allow files to be ignored on deploy
|
||||
- Prioritizes `--email` and `--password` command line arguments over current auth token if both passed
|
||||
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Firebase
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
72
README.md
72
README.md
@@ -1,85 +1,43 @@
|
||||
# firebase-tools
|
||||
|
||||
[](https://travis-ci.org/firebase/firebase-tools)
|
||||
[](https://coveralls.io/r/firebase/firebase-tools)
|
||||
[](http://badge.fury.io/js/firebase-tools)
|
||||
|
||||
These are the Firebase Command Line (CLI) Tools. They can be used to:
|
||||
|
||||
* 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
|
||||
```
|
||||
|
||||
This will provide you with the globally accessible `firebase` command.
|
||||
|
||||
|
||||
## 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)
|
||||
|
||||
0
changelog.txt
Normal file
0
changelog.txt
Normal file
65
gulpfile.js
Normal file
65
gulpfile.js
Normal file
@@ -0,0 +1,65 @@
|
||||
/**************/
|
||||
/* REQUIRES */
|
||||
/**************/
|
||||
var gulp = require('gulp');
|
||||
|
||||
// File I/O
|
||||
var exit = require('gulp-exit');
|
||||
var jshint = require('gulp-jshint');
|
||||
|
||||
// Testing
|
||||
var mocha = require('gulp-mocha');
|
||||
var istanbul = require('gulp-istanbul');
|
||||
|
||||
|
||||
/****************/
|
||||
/* FILE PATHS */
|
||||
/****************/
|
||||
var paths = {
|
||||
js: [
|
||||
'lib/*.js'
|
||||
],
|
||||
|
||||
tests: [
|
||||
'test/*.spec.js'
|
||||
]
|
||||
};
|
||||
|
||||
|
||||
/***********/
|
||||
/* TASKS */
|
||||
/***********/
|
||||
// Lints the JavaScript files
|
||||
gulp.task('lint', function() {
|
||||
return gulp.src(paths.js)
|
||||
.pipe(jshint())
|
||||
.pipe(jshint.reporter('jshint-stylish'))
|
||||
.pipe(jshint.reporter('fail'))
|
||||
.on('error', function(error) {
|
||||
throw error;
|
||||
});
|
||||
});
|
||||
|
||||
// Runs the Mocha test suite
|
||||
gulp.task('test', function() {
|
||||
return gulp.src(paths.js)
|
||||
.pipe(istanbul())
|
||||
.pipe(istanbul.hookRequire())
|
||||
.on('finish', function () {
|
||||
gulp.src(paths.tests)
|
||||
.pipe(mocha({
|
||||
reporter: 'spec',
|
||||
timeout: 5000
|
||||
}))
|
||||
.pipe(istanbul.writeReports())
|
||||
.pipe(exit());
|
||||
});
|
||||
});
|
||||
|
||||
// Reruns the linter every time a JavaScript file changes
|
||||
gulp.task('watch', function() {
|
||||
gulp.watch(paths.js, ['lint']);
|
||||
});
|
||||
|
||||
// Default task
|
||||
gulp.task('default', ['lint', 'test']);
|
||||
83
package.json
83
package.json
@@ -1,36 +1,48 @@
|
||||
{
|
||||
"name": "firebase-tools",
|
||||
"preferGlobal": true,
|
||||
"version": "1.1.4",
|
||||
"description": "The Firebase Command Line Tools",
|
||||
"keywords": [
|
||||
"firebase",
|
||||
"hosting",
|
||||
"ssl",
|
||||
"cdn",
|
||||
"cli",
|
||||
"synchronization",
|
||||
"real-time",
|
||||
"websockets",
|
||||
"cloud"
|
||||
],
|
||||
"author": "Firebase <support@firebase.com>",
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Chris Raynor",
|
||||
"email": "chris@firebase.com"
|
||||
"description": "Firebase command line tools",
|
||||
"version": "0.0.0",
|
||||
"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"
|
||||
},
|
||||
{
|
||||
"name": "Adam Putinski",
|
||||
"email": "adam@firebase.com"
|
||||
"bugs": {
|
||||
"url": "https://github.com/firebase/firebase-tools/issues"
|
||||
},
|
||||
"licenses": [
|
||||
{
|
||||
"name": "Rob DiMarco",
|
||||
"email": "rob@firebase.com"
|
||||
"type": "MIT",
|
||||
"url": "http://firebase.mit-license.org/"
|
||||
}
|
||||
],
|
||||
"repository": "https://github.com/firebase/firebase-tools.git",
|
||||
"homepage": "https://github.com/firebase/firebase-tools",
|
||||
"keywords": [
|
||||
"cdn",
|
||||
"cli",
|
||||
"ssl",
|
||||
"cloud",
|
||||
"hosting",
|
||||
"firebase",
|
||||
"realtime",
|
||||
"websockets",
|
||||
"synchronization"
|
||||
],
|
||||
"preferGlobal": true,
|
||||
"bin": {
|
||||
"firebase": "./bin/firebase"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"engineStrict": true,
|
||||
"files": [
|
||||
"bin/**",
|
||||
"lib/**",
|
||||
"LICENSE",
|
||||
"README.md",
|
||||
"package.json"
|
||||
],
|
||||
"dependencies": {
|
||||
"optimist": "0.6.x",
|
||||
"prompt": "0.2.x",
|
||||
@@ -44,11 +56,18 @@
|
||||
"when": "3.1.0",
|
||||
"chalk": "~0.4.0"
|
||||
},
|
||||
"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"
|
||||
}
|
||||
}
|
||||
|
||||
86
release.sh
86
release.sh
@@ -1,86 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Get the version number that is being released
|
||||
while [[ -z $VERSION ]]
|
||||
do
|
||||
read -p "What version of firebase-tools are we releasing? " VERSION
|
||||
done
|
||||
echo
|
||||
|
||||
# Ensure the changelog has been updated for the newest version
|
||||
CHANGELOG_VERSION="$(head -1 CHANGELOG.md | awk -F 'v' '{print $2}')"
|
||||
if [[ $VERSION != $CHANGELOG_VERSION ]]; then
|
||||
echo "Error: Most recent version in changelog (${CHANGELOG_VERSION}) does not match version you are releasing (${VERSION})."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure the version number in the package.json is correct
|
||||
NPM_VERSION=$(grep "version" package.json | head -1 | awk -F '"' '{print $4}')
|
||||
if [[ $VERSION != $NPM_VERSION ]]; then
|
||||
echo "Error: npm version specified in package.json (${NPM_VERSION}) does not match version you are releasing (${VERSION})."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure the checked out branch is master
|
||||
CHECKED_OUT_BRANCH="$(git branch | grep "*" | awk -F ' ' '{print $2}')"
|
||||
if [[ $CHECKED_OUT_BRANCH != "master" ]]; then
|
||||
echo "Error: Your firebase-tools repo is not on the master branch."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Pull any changes to the firebase-tools repo
|
||||
git pull origin master
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo "Error: Failed to do git pull from firebase-tools repo."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create a git tag for the new version
|
||||
LAST_GIT_TAG="$(git tag --list | tail -1 | awk -F 'v' '{print $2}')"
|
||||
if [[ $VERSION != $LAST_GIT_TAG ]]; then
|
||||
git tag v$VERSION
|
||||
git push --tags
|
||||
|
||||
echo "*** Last commit tagged as v${VERSION} ***"
|
||||
echo
|
||||
else
|
||||
echo "Error: git tag v${VERSION} already exists. Make sure you are not releasing an already-released version."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Publish the new version to npm
|
||||
npm publish
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo "!!! Error publishing to npm! You must do this manually by running 'npm publish'. !!!"
|
||||
exit 1
|
||||
else
|
||||
echo "*** v${VERSION} published to npm as firebase-tools ***"
|
||||
echo
|
||||
fi
|
||||
|
||||
sed -i.bak s/\"firebase-tools\"/\"firebase-cli\"/g package.json
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo "Error: Failed to replace firebase-tools with firebase-cli in the package.json."
|
||||
exit 1
|
||||
fi
|
||||
rm package.json.bak
|
||||
|
||||
# Publish the alternative version to npm
|
||||
npm publish
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo "!!! Error publishing to npm! You must do this manually by running 'npm publish'. !!!"
|
||||
exit 1
|
||||
else
|
||||
echo "*** v${VERSION} published to npm as firebase-cli ***"
|
||||
echo
|
||||
fi
|
||||
|
||||
git checkout -- package.json
|
||||
|
||||
echo "Manual steps remaining:"
|
||||
echo " 1) Update the release notes for firebase-tools version ${VERSION} on GitHub"
|
||||
echo " 2) Update all firebase-tools version numbers specified in firebase-website to ${VERSION}"
|
||||
echo " 3) Tweet @FirebaseRelease: 'v${VERSION} of @Firebase tools CLI is available: https://www.npmjs.org/package/firebase-tools Changelog: https://github.com/firebase/firebase-tools/blob/master/CHANGELOG.md'"
|
||||
echo
|
||||
echo "Done! Woot!"
|
||||
echo
|
||||
10
test/api.spec.js
Normal file
10
test/api.spec.js
Normal file
@@ -0,0 +1,10 @@
|
||||
var chai = require('chai'),
|
||||
expect = chai.expect;
|
||||
|
||||
var api = require('../lib/api');
|
||||
|
||||
describe('api', function() {
|
||||
it('should have a test suite', function() {
|
||||
expect(true).to.be.true;
|
||||
});
|
||||
});
|
||||
10
test/app.spec.js
Normal file
10
test/app.spec.js
Normal file
@@ -0,0 +1,10 @@
|
||||
var chai = require('chai'),
|
||||
expect = chai.expect;
|
||||
|
||||
var app = require('../lib/app');
|
||||
|
||||
describe('app', function() {
|
||||
it('should have a test suite', function() {
|
||||
expect(true).to.be.true;
|
||||
});
|
||||
});
|
||||
10
test/auth.spec.js
Normal file
10
test/auth.spec.js
Normal file
@@ -0,0 +1,10 @@
|
||||
var chai = require('chai'),
|
||||
expect = chai.expect;
|
||||
|
||||
var auth = require('../lib/auth');
|
||||
|
||||
describe('auth', function() {
|
||||
it('should have a test suite', function() {
|
||||
expect(true).to.be.true;
|
||||
});
|
||||
});
|
||||
10
test/firebase.spec.js
Normal file
10
test/firebase.spec.js
Normal file
@@ -0,0 +1,10 @@
|
||||
var chai = require('chai'),
|
||||
expect = chai.expect;
|
||||
|
||||
var firebase = require('../lib/firebase');
|
||||
|
||||
describe('firebase', function() {
|
||||
it('should have a test suite', function() {
|
||||
expect(true).to.be.true;
|
||||
});
|
||||
});
|
||||
10
test/help.spec.js
Normal file
10
test/help.spec.js
Normal file
@@ -0,0 +1,10 @@
|
||||
var chai = require('chai'),
|
||||
expect = chai.expect;
|
||||
|
||||
var help = require('../lib/help');
|
||||
|
||||
describe('help', function() {
|
||||
it('should have a test suite', function() {
|
||||
expect(true).to.be.true;
|
||||
});
|
||||
});
|
||||
10
test/upload.spec.js
Normal file
10
test/upload.spec.js
Normal file
@@ -0,0 +1,10 @@
|
||||
var chai = require('chai'),
|
||||
expect = chai.expect;
|
||||
|
||||
var upload = require('../lib/upload');
|
||||
|
||||
describe('upload', function() {
|
||||
it('should have a test suite', function() {
|
||||
expect(true).to.be.true;
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user