Browse Source

Modernize Amber infrastructure.

Get on par w/ scaffolding 0.22.5.
Herby Vojčík 5 years ago
parent
commit
39ffbc0a67
8 changed files with 144 additions and 95 deletions
  1. 3 3
      .gitignore
  2. 47 23
      Gruntfile.js
  3. 19 19
      LICENSE-MIT
  4. 17 12
      bower.json
  5. 0 7
      config-node.js
  6. 5 0
      es6-promise.amd.json
  7. 19 12
      index.html
  8. 34 19
      package.json

+ 3 - 3
.gitignore

@@ -1,7 +1,7 @@
 /node_modules/
 /bower_components/
-/my/
 
 /test_runner.js
-config.js
-the.js
+
+/config.js
+/the.js

+ 47 - 23
Gruntfile.js

@@ -1,21 +1,43 @@
 'use strict';
 
-module.exports = function (grunt) {
-    var path = require('path'),
-        helpers = require('amber-dev/lib/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.
@@ -28,7 +50,7 @@ module.exports = function (grunt) {
         // task configuration
         amberc: {
             options: {
-                amber_dir: path.join(__dirname, "bower_components", "amber"),
+                amber_dir: findAmberPath(['../..', '../amber/lang', 'bower_components/amber']),
                 configFile: "config.js"
             },
             all: {
@@ -51,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"
                 }
             },
@@ -66,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"
                 }
@@ -78,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,
@@ -98,10 +124,8 @@ module.exports = function (grunt) {
             }
         },
 
-        execute: {
-            test_runner: {
-                src: ['test_runner.js']
-            }
+        exec: {
+            test_runner: 'node test_runner.js'
         },
 
         clean: {

+ 19 - 19
LICENSE-MIT

@@ -1,22 +1,22 @@
-The MIT License (MIT)
+Copyright (c) 2015, 2018 Herby Vojčík
 
-Copyright (c) 2015 Amber
+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:
 
-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:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-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.
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
 
+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.

+ 17 - 12
bower.json

@@ -1,17 +1,6 @@
 {
   "name": "amber-contrib-jquery",
-  "homepage": "https://lolg.it/amber/amber-contrib-jquery",
   "description": "Amber Smalltalk wrapper around jQuery",
-  "main": "local.amd.json",
-  "moduleType": [
-    "amd"
-  ],
-  "keywords": [
-    "amber",
-    "smalltalk",
-    "jquery"
-  ],
-  "license": "MIT",
   "ignore": [
     "**/.*",
     "node_modules",
@@ -21,14 +10,30 @@
     "test",
     "tests"
   ],
+  "authors": [
+    {
+      "name": "Herby Vojčík",
+      "email": "herby@mailbox.sk"
+    }
+  ],
+  "homepage": "https://lolg.it/amber/amber-contrib-jquery",
+  "keywords": [
+    "amber",
+    "smalltalk",
+    "jquery"
+  ],
+  "license": [
+    "MIT"
+  ],
   "private": false,
   "dependencies": {
     "amber": ">=0.19.0",
     "jquery": ">=1.7.0"
   },
   "devDependencies": {
-    "amber-ide-starter-dialog": "^0.1.0",
+    "amber": ">=0.19.2",
     "amber-contrib-legacy": ">=0.5.0",
+    "amber-ide-starter-dialog": "^0.1.0",
     "helios": ">=0.8.0"
   }
 }

+ 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"]
+  }
+}

+ 19 - 12
index.html

@@ -1,22 +1,29 @@
 <!DOCTYPE html>
 <html>
 
-  <head>
+<head>
     <title>Amber Smalltalk wrapper around jQuery</title>
-    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
+    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
+    <meta name="author" content="Herby Vojčík"/>
     <script type='text/javascript' src='the.js'></script>
-  </head>
+</head>
 
-  <body>
-  <script type='text/javascript'>
-      require(['app'], function (amber) {
-          amber.initialize({
+<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': "amber/jquery"
-          });
-          require(["amber-ide-starter-dialog"], function (dlg) { dlg.start(); });
-      });
-  </script>
-  </body>
+        });
+    }).then(function () {
+        require(["amber-ide-starter-dialog"], function (dlg) {
+            dlg.start();
+        });
+    });
+</script>
+</body>
 
 </html>

+ 34 - 19
package.json

@@ -1,34 +1,49 @@
 {
   "name": "amber-contrib-jquery",
-  "version": "0.4.1",
+  "title": "Amber Smalltalk wrapper around jQuery",
   "description": "Amber Smalltalk wrapper around jQuery",
-  "main": "local.amd.json",
-  "scripts": {
-    "test": "grunt test"
+  "version": "0.4.1",
+  "homepage": "https://lolg.it/amber/amber-contrib-jquery",
+  "author": {
+    "name": "Herby Vojčík",
+    "email": "herby@mailbox.sk"
   },
   "repository": {
     "type": "git",
     "url": "https://lolg.it/amber/amber-contrib-jquery.git"
   },
-  "keywords": [
-    "amber",
-    "smalltalk",
-    "jquery"
-  ],
-  "license": "MIT",
   "bugs": {
     "url": "https://lolg.it/amber/amber-contrib-jquery/issues"
   },
-  "homepage": "https://lolg.it/amber/amber-contrib-jquery",
+  "licenses": [
+    {
+      "type": "MIT",
+      "url": "https://lolg.it/amber/amber-contrib-jquery/src/master/LICENSE"
+    }
+  ],
   "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.0",
-    "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",
+    "smalltalk",
+    "jquery"
+  ]
 }