Browse Source

Merge pull request #978 from amber-smalltalk/include-grunt-init

Include grunt init
Nicolas Petton 10 years ago
parent
commit
fccaf20bae

+ 27 - 0
external/grunt-init-amber/README.md

@@ -0,0 +1,27 @@
+# grunt-init-amber
+
+> Create an [Amber Smalltalk](http://amber-lang.net) based application.
+
+
+## Installation
+Install [grunt-init](http://gruntjs.com/project-scaffolding) if you have not already done so.
+
+Place this template in your `~/.grunt-init/` directory after installing grunt-init.
+It is recommended to clone this template with git as follows:
+
+```
+git clone git://github.com/mkroehnert/grunt-init-amber.git ~/.grunt-init/amber
+```
+
+_Windows users, see [the grunt-init documentation](http://gruntjs.com/project-scaffolding) for the correct directory destination_
+
+## Usage
+
+At the command-line, cd into an empty directory, run this command and follow the prompts.
+
+```
+grunt-init amber
+```
+
+_Note that this template will generate files in the current directory,
+so be sure to change to a new directory first if you do not want to overwrite existing files._

+ 17 - 0
external/grunt-init-amber/package.json

@@ -0,0 +1,17 @@
+{
+  "name": "grunt-init-amber",
+  "version": "0.0.2",
+  "description": "grunt-init template for amber project",
+  "main": "template.js",
+  "scripts": {
+    "test": "echo \"Error: no test specified\" && exit 1"
+  },
+  "repository": {
+    "type": "git",
+    "url": "git://github.com/amber-smalltalk/amber.git"
+  },
+  "license": "MIT",
+  "bugs": {
+    "url": "https://github.com/amber-smalltalk/amber/issues?labels=grunt+template"
+  }
+}

+ 4 - 0
external/grunt-init-amber/rename.json

@@ -0,0 +1,4 @@
+{
+  "src/name.js": "src/{%= name %}.js",
+  "src/name.st": "src/{%= name %}.st"
+}

+ 2 - 0
external/grunt-init-amber/root/.gitignore

@@ -0,0 +1,2 @@
+/node_modules/
+/bower_components/

+ 21 - 0
external/grunt-init-amber/root/Gruntfile.js

@@ -0,0 +1,21 @@
+'use strict';
+
+module.exports = function(grunt) {
+
+  // Project configuration.
+  grunt.initConfig({
+    // Metadata.
+    pkg: grunt.file.readJSON('{%= amberjson %}'),
+    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',
+    // Task configuration.
+
+    // These plugins provide necessary tasks.
+    //grunt.loadNpmTasks('grunt-amberc');
+
+    // Default task.
+    //grunt.registerTask('default', ['']);
+};

+ 14 - 0
external/grunt-init-amber/root/README.md

@@ -0,0 +1,14 @@
+# {%= title || name %}
+
+{%= description %}
+
+## Getting Started
+
+Installing dependencies:
+
+```
+npm install
+```
+
+Open `index.html` in your browser and follow the instructions
+

+ 31 - 0
external/grunt-init-amber/root/index.html

@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+
+  <head>
+    <title>{%= title %}</title>
+    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
+    <meta name="author" content="{%= author_name %}" />
+    <script type='text/javascript' src='bower_components/amber/support/requirejs/require.min.js'></script>
+    <script type='text/javascript' src='bower_components/amber/support/amber.js'></script>
+  </head>
+
+  <body>
+    <script type='text/javascript'>
+      require.config({ paths: {
+          '{%= namespace %}': 'src' //mapping compiled .js files and smalltalk source files
+      }});
+      require([
+          'amber/devel',
+          '{%= namespace %}/{%= name %}'
+      ], function (smalltalk) {
+          //used for all new packages in IDE
+          smalltalk.initialize({
+            defaultAmdNamespace: "{%= namespace %}"
+          });
+      });
+    </script>
+    <button onclick="require('amber/helpers').globals.Browser._open()">legacy IDE</button>
+    <button onclick="require('amber/helpers').popupHelios()">Helios IDE</button>
+  </body>
+
+</html>

+ 7 - 0
external/grunt-init-amber/root/src/name.js

@@ -0,0 +1,7 @@
+define("{%= namespace %}/{%= name %}", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_vm/globals", "amber_core/Kernel-Objects"], function(smalltalk,nil,_st,globals){
+smalltalk.addPackage('{%= name %}');
+smalltalk.packages["{%= name %}"].transport = {"type":"amd","amdNamespace":"{%= namespace %}"};
+
+smalltalk.addClass('{%= name %}', globals.Object, [], '{%= name %}');
+
+});

+ 5 - 0
external/grunt-init-amber/root/src/name.st

@@ -0,0 +1,5 @@
+Smalltalk current createPackage: '{%= name %}'!
+Object subclass: #{%= name %}
+	instanceVariableNames: ''
+	package: '{%= name %}'!
+

+ 99 - 0
external/grunt-init-amber/template.js

@@ -0,0 +1,99 @@
+/*
+ * grunt-init-amber
+ * https://amber-lang.net/
+ *
+ * Copyright (c) 2013 Manfred Kroehnert, contributors
+ * Licensed under the MIT license.
+ */
+
+'use strict';
+
+// Basic template description.
+exports.description = 'Create a web application based on Amber Smalltalk.';
+
+// Template-specific notes to be displayed before question prompts.
+exports.notes = ' _Project title_ should be a human-readable title.';
+
+// Template-specific notes to be displayed after question prompts.
+exports.after = 'You should now install project dependencies with _bower install_.' +
+  ' Afterwards, start the development server with _./bower_components/amber/bin/amber serve_.' +
+  ' Your application is then accessible via _http://localhost:4000/_';
+
+// Any existing file or directory matching this wildcard will cause a warning.
+exports.warnOn = '*';
+
+// The actual init template.
+exports.template = function(grunt, init, done) {
+
+  init.process({type: 'amber'}, [
+    // Prompt for these values.
+    init.prompt('name', 'AmberApplication'),
+    init.prompt('title'),
+    init.prompt('description', 'Amber Application.'),
+    {
+      name: 'namespace',
+      message: 'The namespace used to store your Amber Packages.',
+    },
+    {
+      name: 'amber_version',
+      default: '>= 0.12.4',
+      message: 'The version of Amber to use. Must be >= 0.12.4',
+    },
+    init.prompt('version'),
+    init.prompt('repository'),
+    init.prompt('homepage'),
+    init.prompt('bugs'),
+    init.prompt('licenses', 'MIT'),
+    init.prompt('author_name'),
+    init.prompt('author_email'),
+    init.prompt('author_url')
+  ], function(err, props) {
+    // A few additional properties.
+    props.amberjson = props.name + '.amber.json';
+    props.dependencies = {'amber': '~0.10.0'};
+
+    props.keywords = ['Amber', 'Smalltalk'];
+
+    //props.devDependencies = {'amber': '~0.10.0'};
+    props.node_version = '>= 0.8.0';
+
+    // Files to copy (and process).
+    var files = init.filesToCopy(props);
+
+    // Add properly-named license files.
+    init.addLicenseFiles(files, props.licenses);
+
+    // Actually copy (and process) files.
+    init.copyAndProcess(files, props, {noProcess: 'libs/**'});
+
+    // Generate package.json file, used by npm and grunt.
+    //init.writePackageJSON('package.json', props);
+
+    // generate bower.json file
+    grunt.file.write('bower.json', JSON.stringify({
+
+        "name": props.name,
+        "description": props.description,
+        "version": props.version,
+        "authors": [
+            {
+                "name": props.author_name,
+                "email": props.author_email
+            }
+        ],
+        "homepage": props.homepage,
+        "main": props.main,
+        "keywords": props.keywords,
+        "license": props.licenses,
+        "private": false,
+        "dependencies": {
+            "amber": "~" + props.amber_version
+        }
+    }, null, 4));
+
+
+    // All done!
+    done();
+  });
+
+};