Browse Source

Bring up to date.

Herby Vojčík 5 years ago
parent
commit
4147aa14c8
13 changed files with 399 additions and 430 deletions
  1. 4 2
      .gitignore
  2. 90 38
      Gruntfile.js
  3. 23 23
      LICENSE-MIT
  4. 21 26
      README.md
  5. 1 1
      deploy.js
  6. 1 1
      devel.js
  7. 5 0
      es6-promise.amd.json
  8. 22 16
      index.html
  9. 1 1
      local.amd.json
  10. 28 18
      package.json
  11. 180 294
      src/ProfStef.js
  12. 15 10
      src/ProfStef.st
  13. 8 0
      testing.js

+ 4 - 2
.gitignore

@@ -1,4 +1,6 @@
-node_modules/
-bower_components/
+/node_modules/
+
+/test_runner.js
+
 /config.js
 /config.js
 /the.js
 /the.js

+ 90 - 38
Gruntfile.js

@@ -1,70 +1,122 @@
 'use strict';
 'use strict';
 
 
-// File is generated by 
-//     amber init
-//
-// Test code was removed manually.
-
 module.exports = function (grunt) {
 module.exports = function (grunt) {
-    var path = require('path');
-
     // These plugins provide necessary tasks.
     // These plugins provide necessary tasks.
+    grunt.loadNpmTasks('grunt-contrib-clean');
     grunt.loadNpmTasks('grunt-contrib-requirejs');
     grunt.loadNpmTasks('grunt-contrib-requirejs');
-    grunt.loadNpmTasks('amber-dev');
+    grunt.loadNpmTasks('grunt-exec');
+    grunt.loadNpmTasks('@ambers/sdk');
+
+    var path = require('path'),
+        helpers = require('@ambers/sdk').helpers;
 
 
     // Default task.
     // Default task.
-    grunt.registerTask('default', ['amberc:all']);
+    grunt.registerTask('default', ['amdconfig:app', 'amberc:all']);
+    grunt.registerTask('test', ['amdconfig:app', 'requirejs:test_runner', 'exec:test_runner', 'clean:test_runner']);
     grunt.registerTask('devel', ['amdconfig:app', 'requirejs:devel']);
     grunt.registerTask('devel', ['amdconfig:app', 'requirejs:devel']);
     grunt.registerTask('deploy', ['amdconfig:app', 'requirejs:deploy']);
     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.
     // Project configuration.
     grunt.initConfig({
     grunt.initConfig({
         // Metadata.
         // Metadata.
         // pkg: grunt.file.readJSON(''),
         // pkg: grunt.file.readJSON(''),
         banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
         banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
-            '<%= grunt.template.today("yyyy-mm-dd") %>\n' +
-            '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
-            '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
-            ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n',
+        '<%= grunt.template.today("yyyy-mm-dd") %>\n' +
+        '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
+        '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
+        ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n',
         // task configuration
         // task configuration
         amberc: {
         amberc: {
             options: {
             options: {
-                amber_dir: path.join(__dirname, "bower_components", "amber"),
-                library_dirs: ['src'],
-                closure_jar: ''
+                amber_dir: path.join(__dirname, "node_modules", "@ambers", "lang"),
+                configFile: "config.js"
             },
             },
             all: {
             all: {
                 src: [
                 src: [
                     'src/TrySmalltalk.st', // list all sources in dependency order
                     'src/TrySmalltalk.st', // list all sources in dependency order
+                    // list all tests in dependency order
                 ],
                 ],
-                amd_namespace: 'amber-trysmalltalk',
-                libraries: ['Web']
+                amd_namespace: 'profstef',
+                libraries: ['amber_core/SUnit', 'amber/web/Web']
             }
             }
         },
         },
 
 
         amdconfig: {app: {dest: 'config.js'}},
         amdconfig: {app: {dest: 'config.js'}},
 
 
         requirejs: {
         requirejs: {
-            deploy: {options: {
-                mainConfigFile: "config.js",
-                onBuildWrite: function (moduleName, path, contents) {
-                    return moduleName === "config" ? contents + "\nrequire.config({map:{'*':{app:'deploy'}}});" : contents;
-                },
-                pragmas: {
-                    excludeIdeData: true,
-                    excludeDebugContexts: true
-                },
-                include: ['config', 'node_modules/requirejs/require', 'deploy'],
-                out: "the.js"
-            }},
-            devel: {options: {
-                mainConfigFile: "config.js",
-                onBuildWrite: function (moduleName, path, contents) {
-                    return moduleName === "config" ? contents + "\nrequire.config({map:{'*':{app:'devel'}}});" : contents;
-                },
-                include: ['config', 'node_modules/requirejs/require'],
-                out: "the.js"
-            }}
+            options: {
+                useStrict: true
+            },
+            deploy: {
+                options: {
+                    mainConfigFile: "config.js",
+                    rawText: {
+                        "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', 'amber/lazypack', '__app__'],
+                    optimize: "uglify2",
+                    out: "the.js"
+                }
+            },
+            devel: {
+                options: {
+                    mainConfigFile: "config.js",
+                    rawText: {
+                        "app": '(' + polyfillThenPromiseApp + '());',
+                        "__app__": 'define(["devel", "amber_core/Platform-Browser"],function(x){return x});'
+                    },
+                    include: ['config', 'node_modules/requirejs/require', 'app', '__app__'],
+                    exclude: ['devel'],
+                    out: "the.js"
+                }
+            },
+            test_runner: {
+                options: {
+                    mainConfigFile: "config.js",
+                    rawText: {
+                        "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: ['app', 'amber/lazypack', '__app__'],
+                    insertRequire: ['app'],
+                    optimize: "none",
+                    wrap: helpers.nodeWrapperWithShebang,
+                    out: "test_runner.js"
+                }
+            }
+        },
+
+        exec: {
+            test_runner: 'node test_runner.js'
+        },
+
+        clean: {
+            test_runner: ['test_runner.js']
         }
         }
     });
     });
 
 

+ 23 - 23
LICENSE-MIT

@@ -1,23 +1,23 @@
-The MIT License (MIT)
-
-Copyright (C) 2011-2014 Nicolas Petton <petton.nicolas@gmail.com>
-Copyright (C) 2011-2014 Amber contributors https://github.com/amber-smalltalk/amber/contributors
-Copyright (C) 2011-2014 Amber contributors https://github.com/amber-smalltalk/trysmalltalk/contributors
-
-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.
+Copyright (C) 2011-2014 Nicolas Petton <petton.nicolas@gmail.com>
+Copyright (C) 2011-2019 Amber contributors
+
+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.

+ 21 - 26
README.md

@@ -1,41 +1,36 @@
-# TrySmalltalk
+# Prof Stef
 
 
-Tutorial to learn Smalltalk, on-line here http://amber-smalltalk.github.io/trysmalltalk/
+Smalltalk tutorial "Prof Stef" for Amber
 
 
+## Getting Started
 
 
-This project is an [Amber Smalltalk](http://amber-lang.net/)  example. Amber may run in a web browser or as a command line program.
-
-
-Tools needed
-------------
-
-1. A web browser with reasonably good support for HTML5 canvas.
-2. git, on Windows [Git for Windows](msysgit.github.io)
-3. [nodejs](http://www.nodejs.org/). This will give you the node package manager `npm` as well.
-4. A global install of the [`amber-cli`](http://amber-lang.net/) [npm](http://npmjs.org/) package
-5. A global install of the [`bower`](http://bower.io/) client side package manager in order to install the dependencies
-6. A global install of the [`grunt-cli`](http://gruntjs.com/) task runner which is used as the command line build system 
-
-The `amber`, `bower` and `grunt-cli` packages can be installed with the following command:
+Install Amber and create an Amber project,
+as shown in [Amber Instructions](https://lolg.it/amber/amber#prerequisites).
 
 
-    npm install --global amber-cli bower grunt-cli
+## Use ProfStef as a library in a client project
 
 
-or as short form:
+If not already present, create a client project
+in an empty directory with `amber init`.
 
 
-    npm i -g amber-cli bower grunt-cli
-    
+In a client project, run
 
 
-Reference: http://docs.amber-lang.net/js-glossary.html
+```sh
+npm install @ambers/prof-stef --save
+grunt devel
+amber serve
+```
 
 
+Go to `http://localhost:4000/` in your browser and
+in all packages that use ProfStef,
+add `'profstef/ProfStef'` to the package imports,
+save the change and commit the package. Reload.
 
 
-## Getting Started
+## Contributing
 
 
-Bring project alive (for example after `git clone`):
+To bring project alive (for example after `git clone`):
 
 
 ```sh
 ```sh
-npm install
-bower install
-grunt devel
+npm run init
 ```
 ```
 
 
 Developing the project (after brought alive):
 Developing the project (after brought alive):

+ 1 - 1
deploy.js

@@ -2,7 +2,7 @@ define([
     'amber/lang',
     'amber/lang',
     // --- packages to be deployed begin here ---
     // --- packages to be deployed begin here ---
     'amber/legacy/IDE',
     'amber/legacy/IDE',
-    'amber-trysmalltalk/TrySmalltalk'
+    'profstef/ProfStef'
     // --- packages to be deployed end here ---
     // --- packages to be deployed end here ---
 ], function (amber) {
 ], function (amber) {
     return amber;
     return amber;

+ 1 - 1
devel.js

@@ -1,6 +1,6 @@
 define([
 define([
+    './testing',
     'amber/devel',
     'amber/devel',
-    './deploy'
     // --- packages used only during development begin here ---
     // --- packages used only during development begin here ---
     // --- packages used only during development end here ---
     // --- packages used only during development end here ---
 ], function (amber) {
 ], function (amber) {

+ 5 - 0
es6-promise.amd.json

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

+ 22 - 16
index.html

@@ -1,24 +1,30 @@
 <!DOCTYPE html>
 <!DOCTYPE html>
 <html>
 <html>
 
 
-  <head>
-    <title>TrySmalltalk</title>
-    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
-    <meta name="author" content="hhzl" />
+<head>
+    <title>Prof Stef</title>
+    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
+    <meta name="author" content=""/>
     <script type='text/javascript' src='the.js'></script>
     <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
             //used for all new packages in IDE
-            'transport.defaultAmdNamespace': "amber-trysmalltalk"
-          });
-          require(["amber-ide-starter-dialog"], function (dlg) { dlg.start(); });
-          amber.globals.TrySmalltalkWidget._open();   // Trysmalltalk._start();
-      });
-  </script>
-  </body>
+            'transport.defaultAmdNamespace': "profstef"
+        }).then(function () {
+            require(["amber-ide-starter-dialog"], function (dlg) {
+                dlg.start();
+            });
+            amber.globals.ProfStef._start();
+        });
+    });
+</script>
+</body>
 
 
 </html>
 </html>

+ 1 - 1
local.amd.json

@@ -1,5 +1,5 @@
 {
 {
     "paths": {
     "paths": {
-        "amber-trysmalltalk": "src"
+        "profstef": "src"
     }
     }
 }
 }

+ 28 - 18
package.json

@@ -1,37 +1,47 @@
 {
 {
-  "name": "trysmalltalk",
-  "title": "TrySmalltalk",
-  "description": "Tutorial to learn Smalltalk",
-  "version": "0.1.2",
-  "homepage": "https://github.com/amber-smalltalk/trysmalltalk",
-  "author": {
-    "name": "",
-    "email": ""
-  },
+  "name": "@ambers/prof-stef",
+  "title": "Prof Stef",
+  "description": "Smalltalk tutorial \"Prof Stef\" for Amber",
+  "version": "0.2.0",
+  "homepage": "https://amber-lang.net/learn.html",
+  "author": {},
   "repository": {
   "repository": {
     "type": "git",
     "type": "git",
-    "url": "https://github.com/amber-smalltalk/trysmalltalk"
+    "url": "https://lolg.it/amber/prof-stef.git"
   },
   },
   "bugs": {
   "bugs": {
-    "url": "https://github.com/amber-smalltalk/trysmalltalk/issues"
+    "url": "https://lolg.it/amber/prof-stef/issues"
   },
   },
   "licenses": [
   "licenses": [
     {
     {
       "type": "MIT",
       "type": "MIT",
-      "url": "https://github.com/amber-smalltalk/trysmalltalk/blob/master/LICENSE-MIT"
+      "url": "https://lolg.it/amber/prof-stef/raw/master/LICENSE-MIT"
     }
     }
   ],
   ],
   "engines": {
   "engines": {
-    "node": ">= 0.8.0"
+    "node": ">=4.0.0"
   },
   },
   "scripts": {
   "scripts": {
-    "test": "echo \"Error: no test specified\" && exit 1"
+    "reset": "npm run clean && npm run init",
+    "clean": "(rm -rf node_modules || rd /s/q node_modules)",
+    "init": "npm install && grunt default devel",
+    "test": "grunt test"
+  },
+  "dependencies": {
+    "@ambers/contrib-legacy": "^0.7.1",
+    "@ambers/contrib-web": "^0.6.2",
+    "@ambers/lang": "^0.22.2",
+    "es6-promise": "^4.2.4"
   },
   },
   "devDependencies": {
   "devDependencies": {
-    "amber-dev": "^0.3.0",
-    "grunt": "^0.4.5",
-    "grunt-contrib-requirejs": "^0.4.4",
-    "requirejs": "^2.1.15"
+    "@ambers/ide-starter-modal": "^0.2.0",
+    "@ambers/sdk": "^0.10.7",
+    "@ambers/helios": "^0.10.0",
+    "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": [
   "keywords": [
     "Amber",
     "Amber",

File diff suppressed because it is too large
+ 180 - 294
src/ProfStef.js


+ 15 - 10
src/TrySmalltalk.st → src/ProfStef.st

@@ -1,7 +1,7 @@
-Smalltalk createPackage: 'TrySmalltalk'!
+Smalltalk createPackage: 'ProfStef'!
 Object subclass: #AbstractTutorial
 Object subclass: #AbstractTutorial
 	instanceVariableNames: ''
 	instanceVariableNames: ''
-	package: 'TrySmalltalk'!
+	package: 'ProfStef'!
 !AbstractTutorial commentStamp!
 !AbstractTutorial commentStamp!
 Parent class of all ProfStef tutorials.
 Parent class of all ProfStef tutorials.
 
 
@@ -56,7 +56,7 @@ welcome
 
 
 AbstractTutorial subclass: #SmalltalkSyntaxTutorial
 AbstractTutorial subclass: #SmalltalkSyntaxTutorial
 	instanceVariableNames: ''
 	instanceVariableNames: ''
-	package: 'TrySmalltalk'!
+	package: 'ProfStef'!
 !SmalltalkSyntaxTutorial commentStamp!
 !SmalltalkSyntaxTutorial commentStamp!
 The default ProfStef tutorial to learn Smalltalk syntax!
 The default ProfStef tutorial to learn Smalltalk syntax!
 
 
@@ -674,16 +674,15 @@ Take a look at the source code of the method #and: of the class Boolean:"
 
 
 "Here''s all the methods I implement:"
 "Here''s all the methods I implement:"
 
 
-ProfStef methodDictionary.
+ProfStef class methodDictionary.
 
 
 "Let''s create a new method to go to the next lesson:"
 "Let''s create a new method to go to the next lesson:"
 
 
 |newMethod|
 |newMethod|
 newMethod := Compiler new
 newMethod := Compiler new
 	install: ''goToNextLesson ProfStef next.''
 	install: ''goToNextLesson ProfStef next.''
-	forClass: ProfStef
+	forClass: ProfStef class
 	protocol: ''navigation''.
 	protocol: ''navigation''.
-ProfStef class addCompiledMethod: newMethod
 
 
 "Wow!! I can''t wait to use my new method!!"
 "Wow!! I can''t wait to use my new method!!"
 
 
@@ -735,7 +734,7 @@ ProfStef next.'
 
 
 Object subclass: #Lesson
 Object subclass: #Lesson
 	instanceVariableNames: 'title contents'
 	instanceVariableNames: 'title contents'
-	package: 'TrySmalltalk'!
+	package: 'ProfStef'!
 
 
 !Lesson methodsFor: 'accessing'!
 !Lesson methodsFor: 'accessing'!
 
 
@@ -765,7 +764,7 @@ title: aTitle contents: someContents
 
 
 Object subclass: #ProfStef
 Object subclass: #ProfStef
 	instanceVariableNames: 'tutorialPlayer widget'
 	instanceVariableNames: 'tutorialPlayer widget'
-	package: 'TrySmalltalk'!
+	package: 'ProfStef'!
 !ProfStef commentStamp!
 !ProfStef commentStamp!
 A ProfStef is the Smalltalk teacher. To start the tutorial, evaluate:
 A ProfStef is the Smalltalk teacher. To start the tutorial, evaluate:
 ProfStef go.
 ProfStef go.
@@ -851,9 +850,15 @@ previous
 	^ self default previous.
 	^ self default previous.
 ! !
 ! !
 
 
+!ProfStef class methodsFor: 'startup'!
+
+start
+	^ TrySmalltalkWidget open
+! !
+
 Widget subclass: #TrySmalltalkWidget
 Widget subclass: #TrySmalltalkWidget
 	instanceVariableNames: 'workspace contents header'
 	instanceVariableNames: 'workspace contents header'
-	package: 'TrySmalltalk'!
+	package: 'ProfStef'!
 
 
 !TrySmalltalkWidget methodsFor: 'accessing'!
 !TrySmalltalkWidget methodsFor: 'accessing'!
 
 
@@ -910,7 +915,7 @@ open
 
 
 Object subclass: #TutorialPlayer
 Object subclass: #TutorialPlayer
 	instanceVariableNames: 'tutorialPosition tutorial'
 	instanceVariableNames: 'tutorialPosition tutorial'
-	package: 'TrySmalltalk'!
+	package: 'ProfStef'!
 !TutorialPlayer commentStamp!
 !TutorialPlayer commentStamp!
 I can navigate through an AbstractTutorial subclass. With #next and #previous you can go forward and backward through the tutorial.!
 I can navigate through an AbstractTutorial subclass. With #next and #previous you can go forward and backward through the tutorial.!
 
 

+ 8 - 0
testing.js

@@ -0,0 +1,8 @@
+define([
+    './deploy',
+    'amber_core/SUnit',
+    // --- packages used only during automated testing begin here ---
+    // --- packages used only during automated testing end here ---
+], function (amber) {
+    return amber;
+});

Some files were not shown because too many files changed in this diff