From e60052fc08a33b44dd622c566674915f825d510a Mon Sep 17 00:00:00 2001 From: Florent Vilmart Date: Sat, 5 Mar 2016 14:06:37 -0500 Subject: [PATCH] Adds distribution with built package --- .gitignore | 3 ++- Parse-Dashboard/index.js | 5 +++++ README.md | 13 ++++++++++++- bin/parse-dashboard | 2 ++ gulpfile.js | 28 ++++++++++++++++++++++++++++ package.json | 21 +++++++++++++++++---- 6 files changed, 66 insertions(+), 6 deletions(-) create mode 100755 bin/parse-dashboard create mode 100644 gulpfile.js diff --git a/.gitignore b/.gitignore index 52338b057b..32266548b6 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,8 @@ node_modules/ bundles/ PIG/bundles/ Parse-Dashboard/public/bundles/ - +Parse-Dashboard/parse-dashboard-config.json +dist/ npm-debug.log // vim .swp diff --git a/Parse-Dashboard/index.js b/Parse-Dashboard/index.js index d5644ca4a7..ed2b10959c 100644 --- a/Parse-Dashboard/index.js +++ b/Parse-Dashboard/index.js @@ -33,6 +33,11 @@ app.use(express.static(path.join(__dirname,'public'))); app.get('/parse-dashboard-config.json', function(req, res) { jsonFile(configFile) .then(config => { + config.data.apps.forEach((app) => { + if (!app.appName) { + return res.send({ success: false, error: 'An application is misconfigured, appName is required' }); + } + }); var response = {apps: config.data.apps}; var users = config.data.users; //If they provide auth when their config has no users, ignore the auth diff --git a/README.md b/README.md index 1df8064cf3..6cb3e8555e 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,16 @@ If you are not familiar with Docker, ``--port 8080`` with be passed in as argume ## Deploying in production +For production deployments, it's recommended to use the npm package + +1. Create a folder for your project +2. run `$ npm init` +3. Create your dashboard.json in the root ot your project +4. run `$ npm install --save parse-dashboard` +5. add a start script in your package.json `"start": "parse-dashboard --config ./dahsboard.json"`  +6. run `$ npm start` + + If you're deploying to a provider like Heroku, or Google App Engine, the SSL endpoint is terminated early and handled by the provider and you may encounter this error `Parse Dashboard can only be remotely accessed via HTTPS`. :warning: :warning: Before going further, make sure your server **cannot** be reachable via **HTTP**. See the provider documentation for force HTTPS connections to your deployment. @@ -114,11 +124,12 @@ To start your server use: `$ npm start` - Optionally you can use the command line arguments: `$ npm start -- --config path/to/config.json --port 8080 --allowInsecureHTTP=1` +Or update you start script with the accoring configuration. + All paramters are optional and their default values are: diff --git a/bin/parse-dashboard b/bin/parse-dashboard new file mode 100755 index 0000000000..79eb70c64a --- /dev/null +++ b/bin/parse-dashboard @@ -0,0 +1,2 @@ +#!/usr/bin/env node +require('../dist/Parse-Dashboard'); diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000000..bee4b01ddd --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,28 @@ +var gulp = require('gulp'); +var webpack = require('webpack'); +var webpackConfig = require("./webpack/production.config"); + +var dist = './dist/Parse-Dashboard'; +var bundlesDir = './production/bundles'; + +gulp.task('webpack', function(callback) { + // run webpack + webpack(webpackConfig, function(err, stats) { + if(err) throw new gutil.PluginError('webpack', err); + callback(); + }); +}); + +gulp.task('bundles', ['webpack'], function(){ + gulp.src([bundlesDir + '/dashboard.bundle.js', bundlesDir + '/sprites.svg']) + .pipe(gulp.dest(dist + '/public/bundles/')); +}) + +gulp.task('static', ['bundles'], function() { + gulp.src(['./Parse-Dashboard/**/*', // all files + '!./Parse-Dashboard/*.json', // but the config + '!./Parse-Dashboard/public/bundles/*']) // but the bundles + .pipe(gulp.dest(dist)); +}); + +gulp.task('default', ['static', 'bundles']); diff --git a/package.json b/package.json index 43dc7dbc90..96b8d07314 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,15 @@ { - "private": true, + "name": "parse-dashboard", + "description": "The parse dashboard", + "version": "2.0.0", + "repository": { + "type": "git", + "url": "https://github.com/ParsePlatform/parse-dashboard" + }, + "license": "LicenseRef-LICENSE", + "files": [ + "dist" + ], "dependencies": { "babel-runtime": "~5.8.25", "basic-auth": "^1.0.3", @@ -22,6 +32,7 @@ "babel-loader": "~5.3.0", "babel-plugin-remove-proptypes": "~1.0.0", "css-loader": "~0.18.0", + "gulp": "^3.9.1", "http-server": "~0.8.5", "immutable-devtools": "~0.0.4", "jest-cli": "^0.7.1", @@ -40,9 +51,11 @@ "build": "NODE_ENV=production webpack --config webpack/production.config.js && webpack --config webpack/PIG.config.js", "test": "NODE_PATH=./node_modules jest", "generate": "node scripts/generate.js", - "preinstall": "git update-index --skip-worktree Parse-Dashboard/parse-dashboard-config.json", - "prestart": "webpack --config webpack/build.config.js --progress", - "start": "node ./Parse-Dashboard/index.js" + "prepublish": "gulp", + "start": "node ./dist/Parse-Dashboard/index.js" + }, + "bin": { + "parse-dashboard": "./bin/parse-dashboard" }, "engines": { "node": ">=4.3"