|
@@ -1,21 +1,43 @@
|
|
|
'use strict';
|
|
|
|
|
|
-module.exports = function (grunt) {
|
|
|
- var path = require('path'),
|
|
|
- helpers = require('amber-dev').helpers;
|
|
|
+var fs = require('fs'),
|
|
|
+ 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')) ||
|
|
|
+ fs.existsSync(path.join(candidate, 'base/boot.js'))
|
|
|
+ ) && (result = candidate);
|
|
|
+ });
|
|
|
+ return result;
|
|
|
+}
|
|
|
|
|
|
+module.exports = function (grunt) {
|
|
|
|
|
|
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');
|
|
|
|
|
|
|
|
|
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);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
|
|
|
grunt.initConfig({
|
|
|
|
|
@@ -51,15 +73,15 @@ module.exports = function (grunt) {
|
|
|
options: {
|
|
|
mainConfigFile: "config.js",
|
|
|
rawText: {
|
|
|
- "amber/compatibility": '/*stub*/',
|
|
|
- "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', 'config-browser', 'node_modules/requirejs/require', 'app'],
|
|
|
+ include: ['config', 'node_modules/requirejs/require', 'app', 'amber/lazypack', '__app__'],
|
|
|
+ optimize: "uglify2",
|
|
|
out: "the.js"
|
|
|
}
|
|
|
},
|
|
@@ -67,11 +89,10 @@ module.exports = function (grunt) {
|
|
|
options: {
|
|
|
mainConfigFile: "config.js",
|
|
|
rawText: {
|
|
|
- "amber/compatibility": '/*stub*/',
|
|
|
- "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', 'config-browser', 'node_modules/requirejs/require', 'app'],
|
|
|
+ include: ['config', 'node_modules/requirejs/require', 'app', '__app__'],
|
|
|
exclude: ['devel'],
|
|
|
out: "the.js"
|
|
|
}
|
|
@@ -80,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,
|
|
@@ -100,10 +124,8 @@ module.exports = function (grunt) {
|
|
|
}
|
|
|
},
|
|
|
|
|
|
- execute: {
|
|
|
- test_runner: {
|
|
|
- src: ['test_runner.js']
|
|
|
- }
|
|
|
+ exec: {
|
|
|
+ test_runner: 'node test_runner.js'
|
|
|
},
|
|
|
|
|
|
clean: {
|