Browse Source

Modernize Amber infrastructure.

Get on par w/ scaffolding 0.22.5.
Herby Vojčík 2 years ago
parent
commit
dc3f7edd0d
8 changed files with 95 additions and 57 deletions
  1. 46 24
      Gruntfile.js
  2. 1 1
      LICENSE-MIT
  3. 1 0
      bower.json
  4. 0 2
      config-browser.js
  5. 0 7
      config-node.js
  6. 5 0
      es6-promise.amd.json
  7. 23 15
      index.html
  8. 19 8
      package.json

+ 46 - 24
Gruntfile.js

@@ -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) {
     // 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.
@@ -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: {

+ 1 - 1
LICENSE-MIT

@@ -1,4 +1,4 @@
-Copyright (c) 2015 - 2017 Herbert Vojčík
+Copyright (c) 2015 - 2018 Herbert Vojčík
 
 Permission is hereby granted, free of charge, to any person
 obtaining a copy of this software and associated documentation

+ 1 - 0
bower.json

@@ -29,6 +29,7 @@
     "amber": ">=0.19.0"
   },
   "devDependencies": {
+    "amber": ">=0.19.2",
     "amber-contrib-legacy": ">=0.5.0",
     "amber-ide-starter-dialog": "^0.1.0",
     "helios": ">=0.8.0"

+ 0 - 2
config-browser.js

@@ -1,2 +0,0 @@
-define("amber/Platform", ["amber_core/Platform-Browser"], {});
-define("amber/compatibility", ["amber/browser-compatibility"], {});

+ 0 - 7
config-node.js

@@ -1,7 +0,0 @@
-// This file is used to make additional changes
-// when building an app to run in node.js.
-// Free to edit. You can break tests (cli test runner uses
-// this to build itself - it is a node executable).
-define("amber/Platform", ["amber_core/Platform-Node"], {});
-define("amber/compatibility", ["amber/node-compatibility"], {});
-define("jquery", {});

+ 5 - 0
es6-promise.amd.json

@@ -0,0 +1,5 @@
+{
+  "paths": {
+    "amber/es6-promise": ["./es6-promise", "./dist/es6-promise", "./promise"]
+  }
+}

+ 23 - 15
index.html

@@ -1,23 +1,31 @@
 <!DOCTYPE html>
 <html>
 
-  <head>
+<head>
     <title>Lite mite wrapping basic DOM for Amber Smalltalk</title>
-    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
-    <meta name="author" content="Herbert Vojčík" />
+    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
+    <meta name="author" content="Herbert Vojčík"/>
     <script type='text/javascript' src='the.js'></script>
-  </head>
+</head>
 
-  <body>
-  <script type='text/javascript'>
-      require(['app'], function (amber) {
-          amber.initialize({
-            //used for all new packages in IDE
-            'transport.defaultAmdNamespace': "domite"
-          });
-          require(["amber-ide-starter-dialog"], function (dlg) { dlg.start(); });
-      });
-  </script>
-  </body>
+<body>
+<script type='text/javascript'>
+    var global = typeof global === "undefined" ? window : global || window;
+    new Promise(function (resolve, reject) {
+        require(['app'], resolve, reject);
+    })
+        .then(function (amber) {
+            return amber.initialize({
+                //used for all new packages in IDE
+                'transport.defaultAmdNamespace': "domite"
+            });
+        })
+        .then(function () {
+            require(["amber-ide-starter-dialog"], function (dlg) {
+                dlg.start();
+            });
+        });
+</script>
+</body>
 
 </html>

+ 19 - 8
package.json

@@ -15,20 +15,31 @@
   "bugs": {
     "url": "https://lolg.it/herby/domite/issues"
   },
-  "license": "MIT",
+  "licenses": [
+    {
+      "type": "MIT",
+      "url": "https://lolg.it/herby/domite/src/master/LICENSE-MIT"
+    }
+  ],
   "engines": {
-    "node": "0.10.x || 0.12.x || >=4.0.0"
+    "node": ">=4.0.0"
   },
   "scripts": {
+    "reset": "npm run clean && npm run init",
+    "clean": "(rm -rf bower_components || rd /s/q bower_components) && (rm -rf node_modules || rd /s/q node_modules)",
+    "init": "npm install && bower install && grunt default devel",
     "test": "grunt test"
   },
+  "dependencies": {
+    "es6-promise": "^4.2.4"
+  },
   "devDependencies": {
-    "amber-dev": "^0.8.7",
-    "grunt": "^0.4.5",
-    "grunt-contrib-clean": "^0.6.0",
-    "grunt-contrib-requirejs": "^0.4.4",
-    "grunt-execute": "^0.2.2",
-    "requirejs": "^2.1.15"
+    "@ambers/sdk": "^0.10.7",
+    "grunt": "^1.0.3",
+    "grunt-contrib-clean": "^1.1.0",
+    "grunt-contrib-requirejs": "^1.0.0",
+    "grunt-exec": "^3.0.0",
+    "requirejs": "^2.3.5"
   },
   "keywords": [
     "Amber",