Browse Source

initial template version

Manfred Kroehnert 11 years ago
parent
commit
47e2410a15
10 changed files with 177 additions and 3 deletions
  1. 28 3
      README.md
  2. 5 0
      rename.json
  3. 1 0
      root/.gitignore
  4. 21 0
      root/Gruntfile.js
  5. 14 0
      root/README.md
  6. 25 0
      root/index.html
  7. 4 0
      root/js/name.deploy.js
  8. 4 0
      root/js/name.js
  9. 5 0
      root/st/name.st
  10. 70 0
      template.js

+ 28 - 3
README.md

@@ -1,4 +1,29 @@
-grunt-init-amber
-================
+# grunt-init-amber
 
-Template for initializing an Amber application with `grunt-init amber`
+> Create an [Amber Smalltalk][] based application.
+
+[Amber Smalltalk]: http://amber-smalltalk.net
+[grunt-init]: http://gruntjs.com/project-scaffolding
+
+
+## Installation
+Install [grunt-init][] 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 documentation][grunt-init] for the correct destination directory path)_
+
+## 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._

+ 5 - 0
rename.json

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

+ 1 - 0
root/.gitignore

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

+ 21 - 0
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
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
+

+ 25 - 0
root/index.html

@@ -0,0 +1,25 @@
+<!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='node_modules/amber/js/amber.js'></script>
+  </head>
+
+  <body>
+    <script type='text/javascript'>
+      loadAmber({
+          packages: ['{%= name %}'],
+          packageHome: './',
+          ready: function() {
+              $(function() {
+                  smalltalk.Browser._open();
+              });
+          }
+      });
+    </script>
+  </body>
+</html>
+

+ 4 - 0
root/js/name.deploy.js

@@ -0,0 +1,4 @@
+smalltalk.addPackage('{%= name %}');
+smalltalk.addClass('{%= name %}', smalltalk.Object, [], '{%= name %}');
+
+

+ 4 - 0
root/js/name.js

@@ -0,0 +1,4 @@
+smalltalk.addPackage('{%= name %}');
+smalltalk.addClass('{%= name %}', smalltalk.Object, [], '{%= name %}');
+
+

+ 5 - 0
root/st/name.st

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

+ 70 - 0
template.js

@@ -0,0 +1,70 @@
+/*
+ * 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 an Amber Smalltalk based application.';
+
+// 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 _npm install_.' +
+  ' After that, you may execute project tasks with _grunt_.' +
+  ' Fmore information about installing and configuring Grunt, please see ' +
+  'the Getting Started guide:' +
+  '\n\n' +
+  'http://gruntjs.com/getting-started';
+
+// 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', 'AmberApp'),
+    init.prompt('title'),
+    init.prompt('description', 'Amber Application.'),
+    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'];
+
+    //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);
+
+    // All done!
+    done();
+  });
+
+};