├── app └── .gitkeep ├── vendor └── .gitkeep ├── tests ├── unit │ └── .gitkeep ├── dummy │ ├── app │ │ ├── helpers │ │ │ └── .gitkeep │ │ ├── models │ │ │ └── .gitkeep │ │ ├── routes │ │ │ └── .gitkeep │ │ ├── styles │ │ │ └── app.css │ │ ├── components │ │ │ └── .gitkeep │ │ ├── controllers │ │ │ └── .gitkeep │ │ ├── templates │ │ │ ├── components │ │ │ │ └── .gitkeep │ │ │ └── application.hbs │ │ ├── router.js │ │ ├── app.js │ │ └── index.html │ ├── public │ │ ├── robots.txt │ │ └── crossdomain.xml │ └── config │ │ └── environment.js ├── test-helper.js ├── helpers │ ├── resolver.js │ └── start-app.js ├── .jshintrc └── index.html ├── .watchmanconfig ├── .bowerrc ├── blueprints └── lambda-package │ ├── package.json │ └── handler.js ├── config ├── environment.js └── ember-try.js ├── lib ├── commands │ ├── provision.js │ ├── index.js │ ├── deploy.js │ └── build.js ├── tasks │ └── build.js └── models │ └── fastboot-package.js ├── .npmignore ├── index.js ├── testem.json ├── .ember-cli ├── .gitignore ├── bower.json ├── ember-cli-build.js ├── .jshintrc ├── .editorconfig ├── .travis.yml ├── LICENSE.md ├── README.md └── package.json /app/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vendor/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/unit/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/dummy/app/helpers/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/dummy/app/models/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/dummy/app/routes/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/dummy/app/styles/app.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/dummy/app/components/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/dummy/app/controllers/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/dummy/app/templates/components/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.watchmanconfig: -------------------------------------------------------------------------------- 1 | { 2 | "ignore_dirs": ["tmp"] 3 | } 4 | -------------------------------------------------------------------------------- /.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "bower_components", 3 | "analytics": false 4 | } 5 | -------------------------------------------------------------------------------- /tests/dummy/public/robots.txt: -------------------------------------------------------------------------------- 1 | # http://www.robotstxt.org 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /tests/dummy/app/templates/application.hbs: -------------------------------------------------------------------------------- 1 |

Welcome to Ember

2 | 3 | {{outlet}} 4 | -------------------------------------------------------------------------------- /blueprints/lambda-package/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "ember-fastboot-server": "*" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /config/environment.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = function(/* environment, appConfig */) { 4 | return { }; 5 | }; 6 | -------------------------------------------------------------------------------- /tests/test-helper.js: -------------------------------------------------------------------------------- 1 | import resolver from './helpers/resolver'; 2 | import { 3 | setResolver 4 | } from 'ember-qunit'; 5 | 6 | setResolver(resolver); 7 | -------------------------------------------------------------------------------- /lib/commands/provision.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: 'lambda:provision', 3 | description: 'Provisions AWS for deploying Ember apps via FastBoot' 4 | }; 5 | -------------------------------------------------------------------------------- /lib/commands/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | "lambda:provision": require('./provision'), 3 | "lambda:deploy": require('./deploy'), 4 | "lambda:build": require('./build') 5 | }; 6 | -------------------------------------------------------------------------------- /lib/commands/deploy.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: 'lambda:deploy', 3 | description: 'Deploys the application to AWS', 4 | 5 | run: function() { 6 | console.log(arguments); 7 | } 8 | }; 9 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | bower_components/ 2 | tests/ 3 | tmp/ 4 | dist/ 5 | 6 | .bowerrc 7 | .editorconfig 8 | .ember-cli 9 | .travis.yml 10 | .npmignore 11 | **/.gitkeep 12 | bower.json 13 | ember-cli-build.js 14 | Brocfile.js 15 | testem.json 16 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | /* jshint node: true */ 2 | 'use strict'; 3 | 4 | var commands = require('./lib/commands'); 5 | 6 | module.exports = { 7 | name: 'ember-fastboot-lambda', 8 | includedCommands: function() { 9 | return commands; 10 | } 11 | }; 12 | -------------------------------------------------------------------------------- /testem.json: -------------------------------------------------------------------------------- 1 | { 2 | "framework": "qunit", 3 | "test_page": "tests/index.html?hidepassed", 4 | "disable_watching": true, 5 | "launch_in_ci": [ 6 | "PhantomJS" 7 | ], 8 | "launch_in_dev": [ 9 | "PhantomJS", 10 | "Chrome" 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /tests/dummy/app/router.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | import config from './config/environment'; 3 | 4 | var Router = Ember.Router.extend({ 5 | location: config.locationType 6 | }); 7 | 8 | Router.map(function() { 9 | }); 10 | 11 | export default Router; 12 | -------------------------------------------------------------------------------- /.ember-cli: -------------------------------------------------------------------------------- 1 | { 2 | /** 3 | Ember CLI sends analytics information by default. The data is completely 4 | anonymous, but there are times when you might want to disable this behavior. 5 | 6 | Setting `disableAnalytics` to true will prevent any data from being sent. 7 | */ 8 | "disableAnalytics": false 9 | } 10 | -------------------------------------------------------------------------------- /tests/helpers/resolver.js: -------------------------------------------------------------------------------- 1 | import Resolver from 'ember/resolver'; 2 | import config from '../../config/environment'; 3 | 4 | var resolver = Resolver.create(); 5 | 6 | resolver.namespace = { 7 | modulePrefix: config.modulePrefix, 8 | podModulePrefix: config.podModulePrefix 9 | }; 10 | 11 | export default resolver; 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /tmp 6 | 7 | # dependencies 8 | /node_modules 9 | /bower_components 10 | 11 | # misc 12 | /.sass-cache 13 | /connect.lock 14 | /coverage/* 15 | /libpeerconnection.log 16 | npm-debug.log 17 | testem.log 18 | -------------------------------------------------------------------------------- /lib/tasks/build.js: -------------------------------------------------------------------------------- 1 | var FastBootPackage = require('../models/fastboot-package'); 2 | var Task = require('ember-cli/lib/models/task'); 3 | 4 | module.exports = Task.extend({ 5 | run: function(/*commandOptions, rawArgs*/) { 6 | var fastBootPackage = new FastBootPackage({ 7 | ui: this.ui, 8 | project: this.project 9 | }); 10 | 11 | return fastBootPackage.buildZip(); 12 | } 13 | }); 14 | -------------------------------------------------------------------------------- /lib/commands/build.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: 'lambda:build', 3 | description: 'Builds the package to be deployed to Lambda', 4 | 5 | run: function(commandOptions) { 6 | var BuildTask = require('../tasks/build'); 7 | 8 | var buildTask = new BuildTask({ 9 | ui: this.ui, 10 | analytics: this.analytics, 11 | project: this.project 12 | }); 13 | 14 | return buildTask.run(commandOptions); 15 | } 16 | }; 17 | 18 | -------------------------------------------------------------------------------- /tests/dummy/app/app.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | import Resolver from 'ember/resolver'; 3 | import loadInitializers from 'ember/load-initializers'; 4 | import config from './config/environment'; 5 | 6 | var App; 7 | 8 | Ember.MODEL_FACTORY_INJECTIONS = true; 9 | 10 | App = Ember.Application.extend({ 11 | modulePrefix: config.modulePrefix, 12 | podModulePrefix: config.podModulePrefix, 13 | Resolver: Resolver 14 | }); 15 | 16 | loadInitializers(App, config.modulePrefix); 17 | 18 | export default App; 19 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ember-fastboot-lambda", 3 | "dependencies": { 4 | "ember": "1.13.7", 5 | "ember-cli-shims": "ember-cli/ember-cli-shims#0.0.3", 6 | "ember-cli-test-loader": "ember-cli-test-loader#0.1.3", 7 | "ember-data": "1.13.8", 8 | "ember-load-initializers": "ember-cli/ember-load-initializers#0.1.5", 9 | "ember-qunit": "0.4.9", 10 | "ember-qunit-notifications": "0.0.7", 11 | "ember-resolver": "~0.1.18", 12 | "jquery": "^1.11.3", 13 | "loader.js": "ember-cli/loader.js#3.2.1", 14 | "qunit": "~1.18.0" 15 | } 16 | } -------------------------------------------------------------------------------- /ember-cli-build.js: -------------------------------------------------------------------------------- 1 | /* global require, module */ 2 | var EmberApp = require('ember-cli/lib/broccoli/ember-addon'); 3 | 4 | module.exports = function(defaults) { 5 | var app = new EmberApp(defaults, { 6 | // Add options here 7 | }); 8 | 9 | /* 10 | This build file specifes the options for the dummy test app of this 11 | addon, located in `/tests/dummy` 12 | This build file does *not* influence how the addon or the app using it 13 | behave. You most likely want to be modifying `./index.js` or app's build file 14 | */ 15 | 16 | return app.toTree(); 17 | }; 18 | -------------------------------------------------------------------------------- /tests/helpers/start-app.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | import Application from '../../app'; 3 | import config from '../../config/environment'; 4 | 5 | export default function startApp(attrs) { 6 | var application; 7 | 8 | var attributes = Ember.merge({}, config.APP); 9 | attributes = Ember.merge(attributes, attrs); // use defaults, but you can override; 10 | 11 | Ember.run(function() { 12 | application = Application.create(attributes); 13 | application.setupForTesting(); 14 | application.injectTestHelpers(); 15 | }); 16 | 17 | return application; 18 | } 19 | -------------------------------------------------------------------------------- /blueprints/lambda-package/handler.js: -------------------------------------------------------------------------------- 1 | var EmberApp = require('ember-fastboot-server/ember-app'); 2 | var app = new EmberApp(); 3 | 4 | exports.handleRequest = function(event, context) { 5 | // The requested URL 6 | var path = event.path; 7 | 8 | app.visit(path) 9 | .then(success, failure) 10 | .finally(function() { 11 | debug("finished handling; url=%s", path); 12 | }); 13 | 14 | function success(result) { 15 | server.handleSuccess(res, path, result, startTime); 16 | } 17 | 18 | function failure(error) { 19 | server.handleFailure(res, path, error, startTime); 20 | } 21 | }; 22 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "predef": [ 3 | "document", 4 | "window", 5 | "-Promise" 6 | ], 7 | "node": true, 8 | "boss": true, 9 | "curly": true, 10 | "debug": false, 11 | "devel": true, 12 | "eqeqeq": true, 13 | "evil": true, 14 | "forin": false, 15 | "immed": false, 16 | "laxbreak": false, 17 | "newcap": true, 18 | "noarg": true, 19 | "noempty": false, 20 | "nonew": false, 21 | "nomen": false, 22 | "onevar": false, 23 | "plusplus": false, 24 | "regexp": false, 25 | "undef": true, 26 | "sub": true, 27 | "strict": false, 28 | "white": false, 29 | "eqnull": true, 30 | "esnext": true, 31 | "unused": true 32 | } 33 | -------------------------------------------------------------------------------- /tests/dummy/public/crossdomain.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 15 | 16 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | 8 | [*] 9 | end_of_line = lf 10 | charset = utf-8 11 | trim_trailing_whitespace = true 12 | insert_final_newline = true 13 | indent_style = space 14 | indent_size = 2 15 | 16 | [*.js] 17 | indent_style = space 18 | indent_size = 2 19 | 20 | [*.hbs] 21 | insert_final_newline = false 22 | indent_style = space 23 | indent_size = 2 24 | 25 | [*.css] 26 | indent_style = space 27 | indent_size = 2 28 | 29 | [*.html] 30 | indent_style = space 31 | indent_size = 2 32 | 33 | [*.{diff,md}] 34 | trim_trailing_whitespace = false 35 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | language: node_js 3 | node_js: 4 | - "0.12" 5 | 6 | sudo: false 7 | 8 | cache: 9 | directories: 10 | - node_modules 11 | 12 | env: 13 | - EMBER_TRY_SCENARIO=default 14 | - EMBER_TRY_SCENARIO=ember-release 15 | - EMBER_TRY_SCENARIO=ember-beta 16 | - EMBER_TRY_SCENARIO=ember-canary 17 | 18 | matrix: 19 | fast_finish: true 20 | allow_failures: 21 | - env: EMBER_TRY_SCENARIO=ember-canary 22 | 23 | before_install: 24 | - export PATH=/usr/local/phantomjs-2.0.0/bin:$PATH 25 | - "npm config set spin false" 26 | - "npm install -g npm@^2" 27 | 28 | install: 29 | - npm install -g bower 30 | - npm install 31 | - bower install 32 | 33 | script: 34 | - ember try $EMBER_TRY_SCENARIO test 35 | -------------------------------------------------------------------------------- /tests/dummy/app/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Dummy 7 | 8 | 9 | 10 | {{content-for 'head'}} 11 | 12 | 13 | 14 | 15 | {{content-for 'head-footer'}} 16 | 17 | 18 | {{content-for 'body'}} 19 | 20 | 21 | 22 | 23 | {{content-for 'body-footer'}} 24 | 25 | 26 | -------------------------------------------------------------------------------- /config/ember-try.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | scenarios: [ 3 | { 4 | name: 'default', 5 | dependencies: { } 6 | }, 7 | { 8 | name: 'ember-release', 9 | dependencies: { 10 | 'ember': 'components/ember#release' 11 | }, 12 | resolutions: { 13 | 'ember': 'release' 14 | } 15 | }, 16 | { 17 | name: 'ember-beta', 18 | dependencies: { 19 | 'ember': 'components/ember#beta' 20 | }, 21 | resolutions: { 22 | 'ember': 'beta' 23 | } 24 | }, 25 | { 26 | name: 'ember-canary', 27 | dependencies: { 28 | 'ember': 'components/ember#canary' 29 | }, 30 | resolutions: { 31 | 'ember': 'canary' 32 | } 33 | } 34 | ] 35 | }; 36 | -------------------------------------------------------------------------------- /tests/.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "predef": [ 3 | "document", 4 | "window", 5 | "location", 6 | "setTimeout", 7 | "$", 8 | "-Promise", 9 | "define", 10 | "console", 11 | "visit", 12 | "exists", 13 | "fillIn", 14 | "click", 15 | "keyEvent", 16 | "triggerEvent", 17 | "find", 18 | "findWithAssert", 19 | "wait", 20 | "DS", 21 | "andThen", 22 | "currentURL", 23 | "currentPath", 24 | "currentRouteName" 25 | ], 26 | "node": false, 27 | "browser": false, 28 | "boss": true, 29 | "curly": true, 30 | "debug": false, 31 | "devel": false, 32 | "eqeqeq": true, 33 | "evil": true, 34 | "forin": false, 35 | "immed": false, 36 | "laxbreak": false, 37 | "newcap": true, 38 | "noarg": true, 39 | "noempty": false, 40 | "nonew": false, 41 | "nomen": false, 42 | "onevar": false, 43 | "plusplus": false, 44 | "regexp": false, 45 | "undef": true, 46 | "sub": true, 47 | "strict": false, 48 | "white": false, 49 | "eqnull": true, 50 | "esnext": true, 51 | "unused": true 52 | } 53 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 4 | 5 | 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: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | 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. 10 | -------------------------------------------------------------------------------- /tests/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Dummy Tests 7 | 8 | 9 | 10 | {{content-for 'head'}} 11 | {{content-for 'test-head'}} 12 | 13 | 14 | 15 | 16 | 17 | {{content-for 'head-footer'}} 18 | {{content-for 'test-head-footer'}} 19 | 20 | 21 | 22 | {{content-for 'body'}} 23 | {{content-for 'test-body'}} 24 | 25 | 26 | 27 | 28 | 29 | 30 | {{content-for 'body-footer'}} 31 | {{content-for 'test-body-footer'}} 32 | 33 | 34 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Ember FastBoot Lambda 2 | 3 | This addon automates deploying your Ember application to [AWS 4 | Lambda][aws-lambda]. Lambda is Amazon's platform for running JavaScript 5 | code without provisioning or managing servers. 6 | 7 | Once deployed, your app will use FastBoot to render HTML on the server, 8 | as well as serving the JavaScript, CSS and other assets. 9 | 10 | [aws-lambda]: https://aws.amazon.com/lambda/ 11 | 12 | ### Required Steps 13 | 14 | 1. Automate provisioning AWS 15 | 2. Build browser build (default to production environment) 16 | 3. Build FastBoot build (default to production environment) 17 | 4. Upload browser assets to S3/CloudFront 18 | 5. Create FastBoot package 19 | 1. Create npm package 20 | 2. Install ember-fastboot-server 21 | 3. Build contextify/other native dependencies for Lambda 22 | (thaumaturgy?) 23 | 4. Configure build w/ correct asset URLs 24 | 25 | ### Open Questions 26 | 27 | Best practices for storing AWS credentials? 28 | Handling environments/targets? 29 | 30 | ## Installation 31 | 32 | * `ember install ember-fastboot-lambda` 33 | 34 | ## Provisioning AWS 35 | 36 | Provision AWS to run an Ember app via FastBoot by running: 37 | 38 | ```sh 39 | ember lambda:provision 40 | ``` 41 | 42 | You will be prompted for more information. 43 | -------------------------------------------------------------------------------- /tests/dummy/config/environment.js: -------------------------------------------------------------------------------- 1 | /* jshint node: true */ 2 | 3 | module.exports = function(environment) { 4 | var ENV = { 5 | modulePrefix: 'dummy', 6 | environment: environment, 7 | baseURL: '/', 8 | locationType: 'auto', 9 | EmberENV: { 10 | FEATURES: { 11 | // Here you can enable experimental features on an ember canary build 12 | // e.g. 'with-controller': true 13 | } 14 | }, 15 | 16 | APP: { 17 | // Here you can pass flags/options to your application instance 18 | // when it is created 19 | } 20 | }; 21 | 22 | if (environment === 'development') { 23 | // ENV.APP.LOG_RESOLVER = true; 24 | // ENV.APP.LOG_ACTIVE_GENERATION = true; 25 | // ENV.APP.LOG_TRANSITIONS = true; 26 | // ENV.APP.LOG_TRANSITIONS_INTERNAL = true; 27 | // ENV.APP.LOG_VIEW_LOOKUPS = true; 28 | } 29 | 30 | if (environment === 'test') { 31 | // Testem prefers this... 32 | ENV.baseURL = '/'; 33 | ENV.locationType = 'none'; 34 | 35 | // keep test console output quieter 36 | ENV.APP.LOG_ACTIVE_GENERATION = false; 37 | ENV.APP.LOG_VIEW_LOOKUPS = false; 38 | 39 | ENV.APP.rootElement = '#ember-testing'; 40 | } 41 | 42 | if (environment === 'production') { 43 | 44 | } 45 | 46 | return ENV; 47 | }; 48 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ember-fastboot-lambda", 3 | "version": "0.0.0", 4 | "description": "The default blueprint for ember-cli addons.", 5 | "directories": { 6 | "doc": "doc", 7 | "test": "tests" 8 | }, 9 | "scripts": { 10 | "build": "ember build", 11 | "start": "ember server", 12 | "test": "ember try:testall" 13 | }, 14 | "repository": "ember-fastboot/ember-fastboot-lambda", 15 | "engines": { 16 | "node": ">= 0.10.0" 17 | }, 18 | "author": "", 19 | "license": "MIT", 20 | "devDependencies": { 21 | "broccoli-asset-rev": "^2.1.2", 22 | "ember-cli": "1.13.8", 23 | "ember-cli-app-version": "0.5.0", 24 | "ember-cli-content-security-policy": "0.4.0", 25 | "ember-cli-dependency-checker": "^1.0.1", 26 | "ember-cli-htmlbars": "0.7.9", 27 | "ember-cli-htmlbars-inline-precompile": "^0.2.0", 28 | "ember-cli-ic-ajax": "0.2.1", 29 | "ember-cli-inject-live-reload": "^1.3.1", 30 | "ember-cli-qunit": "^1.0.0", 31 | "ember-cli-release": "0.2.3", 32 | "ember-cli-sri": "^1.0.3", 33 | "ember-cli-uglify": "^1.2.0", 34 | "ember-data": "1.13.8", 35 | "ember-disable-proxy-controllers": "^1.0.0", 36 | "ember-export-application-global": "^1.0.3", 37 | "ember-disable-prototype-extensions": "^1.0.0", 38 | "ember-try": "0.0.6" 39 | }, 40 | "keywords": [ 41 | "ember-addon" 42 | ], 43 | "dependencies": { 44 | "chalk": "^1.1.1", 45 | "ember-cli-babel": "^5.1.3", 46 | "ember-cli-fastboot": "0.1.0", 47 | "fs-extra": "^0.24.0", 48 | "rsvp": "^3.1.0", 49 | "temp": "^0.8.3" 50 | }, 51 | "ember-addon": { 52 | "configPath": "tests/dummy/config" 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /lib/models/fastboot-package.js: -------------------------------------------------------------------------------- 1 | var denodeify = require('rsvp').denodeify; 2 | var temp = require('temp').track(); 3 | var fs = require('fs-extra'); 4 | var path = require('path'); 5 | var green = require('chalk').green; 6 | 7 | var createTemporaryDirectory = denodeify(temp.mkdir); 8 | var copy = denodeify(fs.copy); 9 | var ensureDirectory = denodeify(fs.ensureDir); 10 | var exec = denodeify(require('child_process').exec); 11 | 12 | var root = process.cwd(); 13 | 14 | function FastBootPackage(options) { 15 | this.ui = options.ui; 16 | this.project = options.project; 17 | this.tmpPath = null; 18 | this.tmpBlueprintPath = null; 19 | } 20 | 21 | FastBootPackage.prototype.buildZip = function() { 22 | var self = this; 23 | 24 | return this.createTemporaryDirectory() 25 | .then(function() { 26 | return self.copyBlueprint(); 27 | }) 28 | .then(function() { 29 | return self.installDependencies(); 30 | }) 31 | .then(function() { 32 | return self.zipBlueprint(); 33 | }) 34 | .then(function() { 35 | return self.copyZipToWorkingDirectory(); 36 | }); 37 | }; 38 | 39 | FastBootPackage.prototype.createTemporaryDirectory = function() { 40 | var ui = this.ui; 41 | var projectName = this.project.name(); 42 | var self = this; 43 | 44 | return createTemporaryDirectory('ember-fastboot-lambda') 45 | .catch(function(error) { 46 | ui.writeError("Unable to create temporary directory. " + error); 47 | }) 48 | .then(function(tmpPath) { 49 | self.tmpPath = tmpPath; 50 | self.tmpBlueprintPath = path.join(tmpPath, 'lambda-package'); 51 | self.outputPath = path.join(root, 'dist', projectName + '-lambda.zip'); 52 | }); 53 | }; 54 | 55 | FastBootPackage.prototype.copyBlueprint = function() { 56 | var blueprintPath = path.resolve(__dirname, '../../blueprints/lambda-package'); 57 | return copy(blueprintPath, this.tmpBlueprintPath); 58 | }; 59 | 60 | FastBootPackage.prototype.installDependencies = function() { 61 | return chdir(this.tmpBlueprintPath, function() { 62 | return exec('npm install'); 63 | }); 64 | }; 65 | 66 | FastBootPackage.prototype.zipBlueprint = function() { 67 | return chdir(this.tmpPath, function() { 68 | return exec('zip -r lambda-package.zip lambda-package'); 69 | }); 70 | }; 71 | 72 | FastBootPackage.prototype.copyZipToWorkingDirectory = function() { 73 | var zipPath = path.join(this.tmpPath, 'lambda-package.zip'); 74 | var outputPath = this.outputPath; 75 | var ui = this.ui; 76 | 77 | return ensureDirectory(path.dirname(outputPath)) 78 | .then(function() { 79 | return copy(zipPath, outputPath); 80 | }) 81 | .then(function() { 82 | ui.writeLine(green("Lambda deployment package saved to " + outputPath)); 83 | }); 84 | }; 85 | 86 | function chdir(dir, callback) { 87 | var cwd = process.cwd(); 88 | var returnValue; 89 | 90 | process.chdir(dir); 91 | returnValue = callback(); 92 | process.chdir(cwd); 93 | 94 | return returnValue; 95 | } 96 | 97 | module.exports = FastBootPackage; 98 | --------------------------------------------------------------------------------