Browse Source

grunt works with browserify

Jason Chen 12 years ago
parent
commit
bb071b891f
10 changed files with 92 additions and 85 deletions
  1. 3 2
      .gitignore
  2. 65 0
      Gruntfile.coffee
  3. 0 0
      build/scribe.all.min.js
  4. 0 0
      build/scribe.min.js
  5. 0 63
      grunt.js
  6. 1 1
      lib/scribe-rails/version.rb
  7. 7 3
      package.json
  8. 0 1
      src
  9. 10 11
      src/constants.coffee
  10. 6 4
      src/debug.coffee

+ 3 - 2
.gitignore

@@ -1,3 +1,4 @@
-bin/
-node_modules/
+build
+bin
+node_modules
 coverage.html

+ 65 - 0
Gruntfile.coffee

@@ -0,0 +1,65 @@
+module.exports = (grunt) ->
+
+  grunt.loadNpmTasks 'grunt-coffeeify'
+  grunt.loadNpmTasks 'grunt-contrib-coffee'
+  grunt.loadNpmTasks 'grunt-contrib-copy'
+  grunt.loadNpmTasks 'grunt-contrib-concat'
+
+  # Project configuration.
+  grunt.initConfig
+    meta:
+      version: '0.2.0'
+
+    coffee:
+      multi:
+        expand: true
+        dest: 'bin/'
+        src: ['src/*.coffee', 'demo/scripts/*.coffee']
+        ext: '.js'
+      single:
+        files: [
+          { dest: 'bin/tests/scripts/fuzzer.js', src: 'tests/scripts/fuzzer.coffee' }
+          { dest: 'bin/tests/scripts/unit.js', src: 'tests/scripts/unit/*.coffee' }
+        ]
+
+    coffeeify: 
+      options:
+        verbose: true
+        requires: ['tandem-core']
+      files:
+        { dest: 'bin/src/scribe.js', src: ['src/scribe.coffee'] }
+          
+    concat:
+      options:
+        banner: 
+          '/*! Stypi Editor - v<%= meta.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' +
+          ' *  https://www.stypi.com/\n' +
+          ' *  Copyright (c) <%= grunt.template.today("yyyy") %>\n' +
+          ' *  Jason Chen, Salesforce.com\n' +
+          ' */\n\n'
+      'bin/src/scribe.js': [
+        'vendor/assets/javascripts/rangy/*.js',
+        'vendor/assets/javascripts/linked_list.js',
+        'bin/src/scribe.js'
+      ]
+      'bin/src/scribe.all.js': [
+        'node_modules/underscore/underscore.js',
+        'vendor/assets/javascripts/rangy/*.js',
+        'vendor/assets/javascripts/eventemitter2.js',
+        'vendor/assets/javascripts/linked_list.js',
+        'bin/src/scribe.js'
+      ]
+    
+    copy:
+      'bin/demo/scripts/dropkick.js': 'demo/scripts/dropkick.js'
+      'bin/demo/images/': 'demo/images/*.png'
+      'bin/lib/chai.js': 'node_modules/chai/chai.js'
+      'bin/lib/mocha.css': 'node_modules/mocha/mocha.css'
+      'bin/lib/mocha.js': 'node_modules/mocha/mocha.js'
+      'bin/lib/underscore.js': 'node_modules/underscore/underscore.js'
+      'bin/lib/rangy/': 'vendor/assets/javascripts/rangy/*.js'
+      'bin/lib/': 'vendor/assets/javascripts/*.js'
+      'bin/tests/lib/': 'tests/lib/*.js'
+
+  # Default task.
+  grunt.registerTask 'default', ['coffee', 'coffeeify', 'concat', 'copy']

File diff suppressed because it is too large
+ 0 - 0
build/scribe.all.min.js


File diff suppressed because it is too large
+ 0 - 0
build/scribe.min.js


+ 0 - 63
grunt.js

@@ -1,63 +0,0 @@
-/*global module:false*/
-module.exports = function(grunt) {
-
-  grunt.loadNpmTasks('grunt-contrib-coffee');
-  grunt.loadNpmTasks('grunt-contrib-copy');
-
-  // Project configuration.
-  grunt.initConfig({
-    meta: {
-      version: '0.1.6',
-      banner: 
-        '/*! Stypi Editor - v<%= meta.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' +
-        ' *  https://www.stypi.com/\n' +
-        ' *  Copyright (c) <%= grunt.template.today("yyyy") %>\n' +
-        ' *  Jason Chen, Salesforce.com\n' +
-        ' */'
-    },
-    coffee: {
-      'bin/demo/scripts/*.js': 'demo/scripts/*.coffee',
-      'bin/src/*.js': 'src/*.coffee',
-      'bin/src/modules/*.js': 'src/modules/*.coffee',
-      'bin/src/scribe.js': ['src/*.coffee', 'src/modules/*.coffee'],
-      'bin/tests/scripts/fuzzer.js': 'tests/scripts/fuzzer.coffee',
-      'bin/tests/scripts/unit.js': 'tests/scripts/unit/*.coffee'
-    },
-    concat: {
-      'bin/src/scribe.js': [
-        '<banner:meta.banner>',
-        'vendor/assets/javascripts/rangy/*.js',
-        'vendor/assets/javascripts/linked_list.js',
-        'bin/src/scribe.js'
-      ],
-      'bin/src/scribe.all.js': [
-        '<banner:meta.banner>',
-        'node_modules/underscore/underscore.js',
-        'vendor/assets/javascripts/rangy/*.js',
-        'vendor/assets/javascripts/eventemitter2.js',
-        'vendor/assets/javascripts/linked_list.js',
-        'vendor/assets/javascripts/tandem-core.js',
-        'bin/src/scribe.js'
-      ]
-    },
-    copy: {
-      'bin/demo/scripts/dropkick.js': 'demo/scripts/dropkick.js',
-      'bin/demo/images/': 'demo/images/*.png',
-      'bin/lib/chai.js': 'node_modules/chai/chai.js',
-      'bin/lib/mocha.css': 'node_modules/mocha/mocha.css',
-      'bin/lib/mocha.js': 'node_modules/mocha/mocha.js',
-      'bin/lib/underscore.js': 'node_modules/underscore/underscore.js',
-      'bin/lib/rangy/': 'vendor/assets/javascripts/rangy/*.js',
-      'bin/lib/': 'vendor/assets/javascripts/*.js',
-      'bin/tests/lib/': 'tests/lib/*.js'
-    },
-    min: {
-      'build/scribe.min.js': 'bin/src/scribe.js',
-      'build/scribe.all.min.js': 'bin/src/scribe.all.js'
-    }
-  });
-
-  // Default task.
-  grunt.registerTask('default', 'coffee concat copy min');
-  grunt.registerTask('dev', 'coffee concat copy')
-};

+ 1 - 1
lib/scribe-rails/version.rb

@@ -1,5 +1,5 @@
 module Scribe
   module Rails
-    VERSION = "0.1.6"
+    VERSION = "0.2.0"
   end
 end

+ 7 - 3
package.json

@@ -1,15 +1,19 @@
 {
   "name": "scribe",
-  "version": "0.1.6",
+  "version": "0.2.0",
   "dependencies": {
+    "tandem"    : "git+ssh://git@github.com:stypi/tandem-core.git#v0.1.2",
     "underscore": "1.4.x"
   },
   "devDependencies": {
     "chai": "1.5.x",
     "coffee-script": "1.6.x",
     "commander": "1.1.x",
-    "grunt-contrib-coffee": "0.3.x",
-    "grunt-contrib-copy": "0.3.x",
+    "grunt": "0.4.x",
+    "grunt-coffeeify": "0.1.x",
+    "grunt-contrib-coffee": "0.6.x",
+    "grunt-contrib-concat": "0.1.x",
+    "grunt-contrib-copy": "0.4.x",
     "jade": "0.28.x",
     "mocha": "1.8.x",
     "mocha-phantomjs": "2.0.x",

+ 0 - 1
src

@@ -1 +0,0 @@
-vendor/assets/javascripts/scribe

+ 10 - 11
vendor/assets/javascripts/scribe/constants.coffee → src/constants.coffee

@@ -1,7 +1,7 @@
+Scribe = require('./scribe')
 # Arrays must be alphabetized, so we can use binary search
 
-ScribeConstants =
-
+Scribe.Constants =
   DEFAULT_LEAF_FORMATS:
     'background' : 'white'
     'color'      : 'black'
@@ -87,22 +87,21 @@ ScribeConstants =
     EXTERNAL: 'ext'
   
 
-ScribeConstants.SPAN_FORMATS =
-  'background' : ScribeConstants.FONT_BACKGROUNDS
-  'color'      : ScribeConstants.FONT_COLORS
-  'family'     : ScribeConstants.FONT_FAMILIES
-  'size'       : ScribeConstants.FONT_SIZES
+Scribe.Constants.SPAN_FORMATS =
+  'background' : Scribe.Constants.FONT_BACKGROUNDS
+  'color'      : Scribe.Constants.FONT_COLORS
+  'family'     : Scribe.Constants.FONT_FAMILIES
+  'size'       : Scribe.Constants.FONT_SIZES
 
 # Array of possbile values mostly for consistency with SPAN_FORMATS, not actually used in codebase
-ScribeConstants.TAG_FORMATS =
+Scribe.Constants.TAG_FORMATS =
   'bold'      : [true, false]
   'italic'    : [true, false]
   'link'      : [true, false]     # Link value could actually also be any string representing the href
   'strike'    : [true, false]
   'underline' : [true, false]
 
-ScribeConstants.LEAF_FORMATS = _.extend({}, ScribeConstants.SPAN_FORMATS, ScribeConstants.TAG_FORMATS)
+Scribe.Constants.LEAF_FORMATS = _.extend({}, Scribe.Constants.SPAN_FORMATS, Scribe.Constants.TAG_FORMATS)
 
 
-window.Scribe or= {}
-window.Scribe.Constants = ScribeConstants
+module.exports = Scribe

+ 6 - 4
vendor/assets/javascripts/scribe/debug.coffee → src/debug.coffee

@@ -1,4 +1,7 @@
-ScribeDebug = 
+Scribe = require('./scribe')
+
+
+Scribe.Debug = 
   getEditor: (editor) ->
     editor ||= Scribe.Editor.editors[0]
     return if _.isNumber(editor) then Scribe.Editor.editors[editor] else editor
@@ -75,7 +78,7 @@ ScribeDebug =
         console.error "doc.lines and nodesByLine differ in length", lines, nodesByLine
         return false
       return false if _.any(lines, (line, index) =>
-        calculatedLength = _.reduce(line.node.childNodes, ((length, node) -> Scribe.Utils.getNodeLength(node) + length), 0)
+        calculatedLength = _.reduce(line.node.childNodes, ((length, node) -> Utils.getNodeLength(node) + length), 0)
         calculatedLength += 1 if line.trailingNewline
         if line.length != calculatedLength
           console.error line, line.length, calculatedLength, 'differ in length'
@@ -153,5 +156,4 @@ ScribeDebug =
       ).join('')
 
 
-window.Scribe or= {}
-window.Scribe.Debug = ScribeDebug
+module.exports = Scribe

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