|  | @@ -1,32 +1,43 @@
 | 
	
		
			
				|  |  |  'use strict';
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  var fs = require('fs'),
 | 
	
		
			
				|  |  | -    path = require('path');
 | 
	
		
			
				|  |  | +    path = require('path'),
 | 
	
		
			
				|  |  | +    helpers = require('@ambers/sdk').helpers;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  function findAmberPath(options) {
 | 
	
		
			
				|  |  |      var result;
 | 
	
		
			
				|  |  |      options.some(function (x) {
 | 
	
		
			
				|  |  |          var candidate = path.join(__dirname, x);
 | 
	
		
			
				|  |  | -        return fs.existsSync(path.join(candidate, 'support/boot.js')) && (result = candidate);
 | 
	
		
			
				|  |  | +        return (
 | 
	
		
			
				|  |  | +            fs.existsSync(path.join(candidate, 'support/boot.js')) ||
 | 
	
		
			
				|  |  | +            fs.existsSync(path.join(candidate, 'base/boot.js'))
 | 
	
		
			
				|  |  | +        ) && (result = candidate);
 | 
	
		
			
				|  |  |      });
 | 
	
		
			
				|  |  |      return result;
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  module.exports = function (grunt) {
 | 
	
		
			
				|  |  | -    var helpers = require('amber-dev').helpers;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |      // These plugins provide necessary tasks.
 | 
	
		
			
				|  |  |      grunt.loadNpmTasks('grunt-contrib-clean');
 | 
	
		
			
				|  |  |      grunt.loadNpmTasks('grunt-contrib-requirejs');
 | 
	
		
			
				|  |  | -    grunt.loadNpmTasks('grunt-execute');
 | 
	
		
			
				|  |  | -    grunt.loadNpmTasks('amber-dev');
 | 
	
		
			
				|  |  | +    grunt.loadNpmTasks('grunt-exec');
 | 
	
		
			
				|  |  | +    grunt.loadNpmTasks('@ambers/sdk');
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      // Default task.
 | 
	
		
			
				|  |  |      grunt.registerTask('default', ['amdconfig:app', 'amberc:all']);
 | 
	
		
			
				|  |  | -    grunt.registerTask('test', ['amdconfig:app', 'requirejs:test_runner', 'execute:test_runner', 'clean:test_runner']);
 | 
	
		
			
				|  |  | +    grunt.registerTask('test', ['amdconfig:app', 'requirejs:test_runner', 'exec:test_runner', 'clean:test_runner']);
 | 
	
		
			
				|  |  |      grunt.registerTask('devel', ['amdconfig:app', 'requirejs:devel']);
 | 
	
		
			
				|  |  |      grunt.registerTask('deploy', ['amdconfig:app', 'requirejs:deploy']);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    var polyfillThenPromiseApp = function () {
 | 
	
		
			
				|  |  | +        define(["require", "amber/es6-promise"], function (require, promiseLib) {
 | 
	
		
			
				|  |  | +            promiseLib.polyfill();
 | 
	
		
			
				|  |  | +            return new Promise(function (resolve, reject) {
 | 
	
		
			
				|  |  | +                require(["__app__"], resolve, reject);
 | 
	
		
			
				|  |  | +            });
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +    };
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      // Project configuration.
 | 
	
		
			
				|  |  |      grunt.initConfig({
 | 
	
		
			
				|  |  |          // Metadata.
 | 
	
	
		
			
				|  | @@ -39,7 +50,7 @@ module.exports = function (grunt) {
 | 
	
		
			
				|  |  |          // task configuration
 | 
	
		
			
				|  |  |          amberc: {
 | 
	
		
			
				|  |  |              options: {
 | 
	
		
			
				|  |  | -                amber_dir: findAmberPath(['../..', 'bower_components/amber']),
 | 
	
		
			
				|  |  | +                amber_dir: findAmberPath(['../..', '../amber/lang', 'bower_components/amber']),
 | 
	
		
			
				|  |  |                  configFile: "config.js"
 | 
	
		
			
				|  |  |              },
 | 
	
		
			
				|  |  |              all: {
 | 
	
	
		
			
				|  | @@ -62,14 +73,15 @@ module.exports = function (grunt) {
 | 
	
		
			
				|  |  |                  options: {
 | 
	
		
			
				|  |  |                      mainConfigFile: "config.js",
 | 
	
		
			
				|  |  |                      rawText: {
 | 
	
		
			
				|  |  | -                        "amber/Platform": '/*stub*/',
 | 
	
		
			
				|  |  | -                        "app": 'define(["deploy"],function(x){return x});define("amber/Platform",["amber_core/Platform-Browser"],{});'
 | 
	
		
			
				|  |  | +                        "app": '(' + polyfillThenPromiseApp + '());',
 | 
	
		
			
				|  |  | +                        "__app__": 'define(["deploy", "amber_core/Platform-Browser"],function(x){return x});'
 | 
	
		
			
				|  |  |                      },
 | 
	
		
			
				|  |  |                      pragmas: {
 | 
	
		
			
				|  |  |                          excludeIdeData: true,
 | 
	
		
			
				|  |  |                          excludeDebugContexts: true
 | 
	
		
			
				|  |  |                      },
 | 
	
		
			
				|  |  | -                    include: ['config', 'node_modules/requirejs/require', 'app'],
 | 
	
		
			
				|  |  | +                    include: ['config', 'node_modules/requirejs/require', 'app', 'amber/lazypack', '__app__'],
 | 
	
		
			
				|  |  | +                    optimize: "uglify2",
 | 
	
		
			
				|  |  |                      out: "the.js"
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              },
 | 
	
	
		
			
				|  | @@ -77,10 +89,10 @@ module.exports = function (grunt) {
 | 
	
		
			
				|  |  |                  options: {
 | 
	
		
			
				|  |  |                      mainConfigFile: "config.js",
 | 
	
		
			
				|  |  |                      rawText: {
 | 
	
		
			
				|  |  | -                        "amber/Platform": '/*stub*/',
 | 
	
		
			
				|  |  | -                        "app": 'define(["devel"],function(x){return x});define("amber/Platform",["amber_core/Platform-Browser"],{});'
 | 
	
		
			
				|  |  | +                        "app": '(' + polyfillThenPromiseApp + '());',
 | 
	
		
			
				|  |  | +                        "__app__": 'define(["devel", "amber_core/Platform-Browser"],function(x){return x});'
 | 
	
		
			
				|  |  |                      },
 | 
	
		
			
				|  |  | -                    include: ['config', 'node_modules/requirejs/require', 'app'],
 | 
	
		
			
				|  |  | +                    include: ['config', 'node_modules/requirejs/require', 'app', '__app__'],
 | 
	
		
			
				|  |  |                      exclude: ['devel'],
 | 
	
		
			
				|  |  |                      out: "the.js"
 | 
	
		
			
				|  |  |                  }
 | 
	
	
		
			
				|  | @@ -89,18 +101,21 @@ module.exports = function (grunt) {
 | 
	
		
			
				|  |  |                  options: {
 | 
	
		
			
				|  |  |                      mainConfigFile: "config.js",
 | 
	
		
			
				|  |  |                      rawText: {
 | 
	
		
			
				|  |  | -                        "app": "(" + function () {
 | 
	
		
			
				|  |  | -                            define(["testing", "amber_devkit/NodeTestRunner"], function (amber) {
 | 
	
		
			
				|  |  | -                                amber.initialize();
 | 
	
		
			
				|  |  | -                                amber.globals.NodeTestRunner._main();
 | 
	
		
			
				|  |  | +                        "jquery": "/* do not load in node test runner */",
 | 
	
		
			
				|  |  | +                        "__app__": "(" + function () {
 | 
	
		
			
				|  |  | +                            define(["testing", "amber_core/Platform-Node", "amber_devkit/NodeTestRunner"], function (amber) {
 | 
	
		
			
				|  |  | +                                amber.initialize().then(function () {
 | 
	
		
			
				|  |  | +                                    amber.globals.NodeTestRunner._main();
 | 
	
		
			
				|  |  | +                                });
 | 
	
		
			
				|  |  |                              });
 | 
	
		
			
				|  |  | -                        } + "());"
 | 
	
		
			
				|  |  | +                        } + "());",
 | 
	
		
			
				|  |  | +                        "app": "(" + polyfillThenPromiseApp + "());"
 | 
	
		
			
				|  |  |                      },
 | 
	
		
			
				|  |  |                      paths: {"amber_devkit": helpers.libPath},
 | 
	
		
			
				|  |  |                      pragmas: {
 | 
	
		
			
				|  |  |                          excludeIdeData: true
 | 
	
		
			
				|  |  |                      },
 | 
	
		
			
				|  |  | -                    include: ['config-node', 'app'],
 | 
	
		
			
				|  |  | +                    include: ['app', 'amber/lazypack', '__app__'],
 | 
	
		
			
				|  |  |                      insertRequire: ['app'],
 | 
	
		
			
				|  |  |                      optimize: "none",
 | 
	
		
			
				|  |  |                      wrap: helpers.nodeWrapperWithShebang,
 | 
	
	
		
			
				|  | @@ -109,10 +124,8 @@ module.exports = function (grunt) {
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          },
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        execute: {
 | 
	
		
			
				|  |  | -            test_runner: {
 | 
	
		
			
				|  |  | -                src: ['test_runner.js']
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | +        exec: {
 | 
	
		
			
				|  |  | +            test_runner: 'node test_runner.js'
 | 
	
		
			
				|  |  |          },
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          clean: {
 |