From 3add585ce6535d9234a2e0315187656f15f8d346 Mon Sep 17 00:00:00 2001 From: jwngr Date: Fri, 23 Jan 2015 15:51:05 -0800 Subject: [PATCH] Added gulp, Travis, a test framework, and made it Catapult-enabled --- .gitignore | 4 +- .travis.yml | 9 +++++ CHANGELOG.md | 39 ------------------- LICENSE | 21 +++++++++++ README.md | 72 ++++++++--------------------------- changelog.txt | 0 gulpfile.js | 65 ++++++++++++++++++++++++++++++++ package.json | 87 ++++++++++++++++++++++++++----------------- release.sh | 86 ------------------------------------------ test/api.spec.js | 10 +++++ test/app.spec.js | 10 +++++ test/auth.spec.js | 10 +++++ test/firebase.spec.js | 10 +++++ test/help.spec.js | 10 +++++ test/upload.spec.js | 10 +++++ 15 files changed, 226 insertions(+), 217 deletions(-) create mode 100644 .travis.yml delete mode 100644 CHANGELOG.md create mode 100644 LICENSE create mode 100644 changelog.txt create mode 100644 gulpfile.js delete mode 100755 release.sh create mode 100644 test/api.spec.js create mode 100644 test/app.spec.js create mode 100644 test/auth.spec.js create mode 100644 test/firebase.spec.js create mode 100644 test/help.spec.js create mode 100644 test/upload.spec.js diff --git a/.gitignore b/.gitignore index 4adf9dfe..06b2d980 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ -node_modules +coverage/ +node_modules/ + .DS_Store .idea *.iml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..863a37de --- /dev/null +++ b/.travis.yml @@ -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 diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index e2e5a5e2..00000000 --- a/CHANGELOG.md +++ /dev/null @@ -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 diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..b9b77e9b --- /dev/null +++ b/LICENSE @@ -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. diff --git a/README.md b/README.md index 94e33081..d28cd58f 100644 --- a/README.md +++ b/README.md @@ -1,85 +1,43 @@ # 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)](https://coveralls.io/r/firebase/firebase-tools) [![NPM version](https://badge.fury.io/js/firebase-tools.svg)](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 --help` shows more details for an individual command. +The command `firebase --help` lists the available commands and `firebase --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 - - 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 --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) diff --git a/changelog.txt b/changelog.txt new file mode 100644 index 00000000..e69de29b diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 00000000..03c741c4 --- /dev/null +++ b/gulpfile.js @@ -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']); diff --git a/package.json b/package.json index 5af1a8b1..d527d76a 100644 --- a/package.json +++ b/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 ", - "contributors": [ + "description": "Firebase command line tools", + "version": "0.0.0", + "author": "Firebase (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": [ { - "name": "Chris Raynor", - "email": "chris@firebase.com" - }, - { - "name": "Adam Putinski", - "email": "adam@firebase.com" - }, - { - "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" + } } diff --git a/release.sh b/release.sh deleted file mode 100755 index cc8d74b6..00000000 --- a/release.sh +++ /dev/null @@ -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 \ No newline at end of file diff --git a/test/api.spec.js b/test/api.spec.js new file mode 100644 index 00000000..2a612da4 --- /dev/null +++ b/test/api.spec.js @@ -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; + }); +}); diff --git a/test/app.spec.js b/test/app.spec.js new file mode 100644 index 00000000..a01f4873 --- /dev/null +++ b/test/app.spec.js @@ -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; + }); +}); diff --git a/test/auth.spec.js b/test/auth.spec.js new file mode 100644 index 00000000..973c015d --- /dev/null +++ b/test/auth.spec.js @@ -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; + }); +}); diff --git a/test/firebase.spec.js b/test/firebase.spec.js new file mode 100644 index 00000000..99b3f61c --- /dev/null +++ b/test/firebase.spec.js @@ -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; + }); +}); diff --git a/test/help.spec.js b/test/help.spec.js new file mode 100644 index 00000000..af40309f --- /dev/null +++ b/test/help.spec.js @@ -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; + }); +}); diff --git a/test/upload.spec.js b/test/upload.spec.js new file mode 100644 index 00000000..70c2d4b6 --- /dev/null +++ b/test/upload.spec.js @@ -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; + }); +});