Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added a brunch sample #73

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .jshintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
appengine/bower/public/bower_components/**
appengine/brunch/app/**
appengine/brunch/public/**
appengine/kraken/public/components/**
appengine/parse-server/cloud/main.js
appengine/sails/config/**
Expand All @@ -8,4 +10,4 @@ appengine/sails/api/responses/**
appengine/webpack/dist/**
functions/**
**/node_modules/**
coverage/
coverage/
3 changes: 2 additions & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
"strict": true,
"trailing": true,
"undef": true,
"unused": true
"unused": true,
"esversion": 6
}
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ cache:
directories:
- appengine/analytics/node_modules/
- appengine/bower/node_modules/
- appengine/brunch/node_modules/
- appengine/cloudsql/node_modules/
- appengine/datastore/node_modules/
- appengine/disk/node_modules/
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ __Databases__
__Tools__

- gcloud-node - [Source code][gcloud_1] | [Documentation][gcloud_2]
- Brunch - [Source code][brunch_1] | [Documentation][brunch_2]
- Bower - [Source code][bower_1] | [App Engine Tutorial][bower_2] | [Documentation][bower_3]
- Grunt - [Source code][grunt_1] | [App Engine Tutorial][grunt_2] | [Live demo][grunt_3] | [Documentation][grunt_4]
- Mailgun - [Source code][mailgun_1] | [App Engine Tutorial][mailgun_2] | [Documentation][mailgun_3]
Expand Down Expand Up @@ -224,6 +225,9 @@ See [LICENSE](https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/ma
[gcloud_1]: https://github.com/GoogleCloudPlatform/gcloud-node
[gcloud_2]: https://googlecloudplatform.github.io/gcloud-node/#/

[brunch_1]: https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/appengine/brunch
[brunch_2]: http://brunch.io

[bower_1]: https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/appengine/bower
[bower_2]: https://cloud.google.com/nodejs/resources/tools/bower
[bower_3]: http://bower.io/
Expand Down
26 changes: 26 additions & 0 deletions appengine/brunch/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Numerous always-ignore extensions
*.diff
*.err
*.orig
*.log
*.rej
*.swo
*.swp
*.vi
*~
*.sass-cache

# OS or Editor folders
.DS_Store
.cache
.project
.settings
.tmproj
nbproject
Thumbs.db

# NPM packages folder.
node_modules/

# Brunch output folder.
public/
30 changes: 30 additions & 0 deletions appengine/brunch/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Brunch with ES6 running on Google App Engine.

This sample demonstrates how to use [Brunch](http://brunch.io) on
[Google App Engine Managed VMs](https://cloud.google.com/appengine).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed


For more information about getting started with Brunch, see the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind adding a "Bunch is thing that does stuff" sentence? Just for level setting?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, no problem.

[Getting Started with Brunch Guide](https://github.com/brunch/brunch-guide/blob/master/content/en/chapter02-getting-started.md) .

You can also view the [live demo](https://alien-lattice-123714.appspot.com) and read the full [Brunch documentation](https://github.com/brunch/brunch-guide).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great for now, but FYI we typically run these under one project we have at Google. Those VMs cost you money after the free trial runs out :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know if you want me to change or remove the link, I don't mind keeping it up.


## Setup
Add the necessary modules in your `package.json`:
```sh
$ npm install --save-dev express body-parser morgan
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jmdobry do you know if devDependenices are working? Last time I tried, they weren't :(

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I know, they aren't.

See appengine/grunt/package.json

```

## Running locally
Refer to the [appengine/README.md](../README.md) file for instructions on
running and deploying.

To support custom web servers an `app.js` file was added.
```sh
$ npm start
```
Will bypass the `brunch-config.js` file and use settings provided in the `app.js` file.

```sh
$ brunch watch --server
```
Will use settings provided in the `brunch-config.js` file.
22 changes: 22 additions & 0 deletions appengine/brunch/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2015-2016, Google, Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

var startServer = require('./brunch-server');
startServer(process.env.PORT || 8080, '/', function() {
var server = this;
var port = server.address().port;
console.log('App listening at http://localhost:%s', port);
console.log('Press Ctrl+C to quit.');
});
20 changes: 20 additions & 0 deletions appengine/brunch/app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2015-2016, Google, Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# [START app_yaml]
runtime: nodejs
vm: true

skip_files:
- ^(.*/)?.*/node_modules/.*$
# [END app_yaml]
1 change: 1 addition & 0 deletions appengine/brunch/app/assets/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!DOCTYPE html><head><meta charset="utf-8"><meta name="viewport" content="initial-scale=1.0, user-scalable=no"><!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323--><meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi"><title>Brunch with ES6</title><script src="/libraries.js"></script><script src="/app.js"></script><script>require('application').init();</script></head><body><div id="app"><h1>Hello World!</h1></div></body>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you format this?

4 changes: 4 additions & 0 deletions appengine/brunch/app/initialize.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
document.addEventListener('DOMContentLoaded', () => {
// do your setup here
console.log('Initialized app');
});
14 changes: 14 additions & 0 deletions appengine/brunch/app/views/index.jade
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
doctype html
head
meta(charset='utf-8')
meta(name='viewport', content='initial-scale=1.0, user-scalable=no')
// WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323
meta(name='viewport', content='user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi')
title Brunch with ES6 running on Google App Engine
script(src='/vendor.js')
script(src='/app.js')
script.
require('initialize');
body
#app
h1 Hello World!
24 changes: 24 additions & 0 deletions appengine/brunch/brunch-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module.exports = {
files: {
javascripts: {
joinTo: {
'vendor.js': /^(?!app)/,
'app.js': /^app/
}
},
stylesheets: {
joinTo: 'app.css'
}
},

plugins: {
babel: {
presets: ['es2015']
}
},
server: {
run: true,
base: '/',
port: 8080
}
};
22 changes: 22 additions & 0 deletions appengine/brunch/brunch-server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict';

var express = require('express');
var http = require('http');
var Path = require('path');

module.exports = function startServer(port, path, callback) {
var app = express();
var server = http.createServer(app);

app.use(express.static(Path.join(__dirname, path)));

app.set('views', Path.join(__dirname, 'app/views'));
app.set('view engine', 'jade');

app.get('/', function(req, res) {
res.render('index');
});

server.listen(port, callback);

};
29 changes: 29 additions & 0 deletions appengine/brunch/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "appengine-brunch",
"description": "An example of Brunch with ES6 running on Google App Engine.",
"version": "0.0.1",
"private": true,
"license": "Apache Version 2.0",
"author": "Google Inc.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nah, give yourself credit

"engines": {
"node": "~4.2"
},
"scripts": {
"start": "node app.js",
"watch": "brunch watch --server",
"deploy": "gcloud preview app deploy",
"prod": "brunch build --production"
},
"dependencies": {
"auto-reload-brunch": "^2.0.0",
"babel-brunch": "~6.0.0",
"babel-preset-es2015": "~6.3.13",
"brunch": "^2.4.0",
"clean-css-brunch": "^2.0.0",
"css-brunch": "^2.0.0",
"express": "^4.13.4",
"jade": "^1.11.0",
"javascript-brunch": "^2.0.0",
"uglify-js-brunch": "^2.0.0"
}
}
7 changes: 7 additions & 0 deletions test/appengine/all.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ var sampleTests = [
args: ['server.js'],
msg: 'Express.js + Bower on Google App Engine.'
},
{
dir: 'brunch',
cmd: 'node',
args: ['app.js'],
msg: 'Brunch with ES6 running on Google App Engine.',
TRAVIS: true
},
{
dir: 'cloudsql',
cmd: 'node',
Expand Down