瀏覽代碼

Replace Rakefile with Jakefile and add compression using UglifyJS

tags/0.5.2-vsc
Sahab Yazdani 14 年之前
父節點
當前提交
aac5e75e4b
共有 14 個檔案被更改,包括 127 行新增74 行删除
  1. +2
    -5
      .gitignore
  2. +1
    -1
      CHANGES.md
  3. +110
    -0
      Jakefile
  4. +0
    -58
      Rakefile
  5. +7
    -0
      THANKS.md
  6. +0
    -8
      lib/package.json
  7. +6
    -2
      mustache-commonjs/package.json
  8. +0
    -0
      mustache-dojox/mustache.js.tpl.post
  9. +0
    -0
      mustache-dojox/mustache.js.tpl.pre
  10. +0
    -0
      mustache-jquery/mustache.js.tpl.post
  11. +0
    -0
      mustache-jquery/mustache.js.tpl.pre
  12. +0
    -0
      mustache-requirejs/mustache.js.tpl.post
  13. +0
    -0
      mustache-requirejs/mustache.js.tpl.pre
  14. +1
    -0
      mustache.min.js

+ 2
- 5
.gitignore 查看文件

@@ -1,5 +1,2 @@
runner.js
jquery.mustache.js
dojox
yui3
commonjs.mustache.js
packages/**
support/**

+ 1
- 1
CHANGES.md 查看文件

@@ -1,6 +1,6 @@
# mustache.js Changes # mustache.js Changes


## 0.5.1-vsc
## 0.5.1-vcs


* Added Dot Notation Support * Added Dot Notation Support




+ 110
- 0
Jakefile 查看文件

@@ -0,0 +1,110 @@
var fs = require('fs'),
sys = require('sys'),
util = require('util'),
uglify = require('uglify-js');

function copyFile(src, dst, cb) {
function copy(err) {
var is, os;

if (!err) {
return cb(new Error("File " + dst + " exists."));
}

fs.stat(src, function (err) {
if (err) {
return cb(err);
}
is = fs.createReadStream(src);
os = fs.createWriteStream(dst);
util.pump(is, os, cb);
});
}

fs.stat(dst, copy);
}
function makeDirectoryIfNotExists(path) {
try {
var stats = fs.statSync(path);
if (!stats.isDirectory()) {
fs.mkdirSync(path, 0);
}
} catch (e) {
fs.mkdirSync(path, 0);
}
}

desc('Obfuscation and Compression');
task('minify', function() {
var all = fs.readFileSync('mustache.js').toString(),
out = fs.openSync('mustache.min.js', 'w+'),
ast = uglify.parser.parse(all);

ast = uglify.uglify.ast_mangle(ast);
ast = uglify.uglify.ast_squeeze(ast);

fs.writeSync(out, uglify.uglify.gen_code(ast));
});

task('package', function() {
function package(id, location) {
var files = [
, 'mustache.js'
];

files.unshift('mustache-' + id + '/mustache.js.tpl.pre');
files.push('mustache-' + id + '/mustache.js.tpl.post');

var all = '';
files.forEach(function(file, i) {
all += fs.readFileSync(file).toString();
all += '\n';
});
var outPath;
if (location) {
makeDirectoryIfNotExists('packages/' + id);
if (location === true) {
outPath = 'packages/' + id + '/mustache.js';
} else {
outPath = 'packages/' + id + '/' + location + '/mustache.js';
makeDirectoryIfNotExists('packages/' + id + '/' + location);
}
} else {
outPath = 'packages/' + id + '.mustache.js';
}
var out = fs.openSync(outPath, 'w+');
fs.writeSync(out, all);
}
var params = Array.prototype.slice.call(arguments);
makeDirectoryIfNotExists('packages');
for (var i = 0, n = params.length; i<n; ++i) {
switch (params[i].toLowerCase()) {
case 'jquery':
package('jquery');
break;
case 'commonjs':
package('commonjs', true);
copyFile('mustache-commonjs/package.json', 'packages/commonjs/package.json');
break;
case 'dojox':
package('dojox', 'string');
break;
case 'yui3':
package('yui3', 'mustache');
break;
case 'requirejs':
package('requirejs');
break;
default:
break;
}
}
});

+ 0
- 58
Rakefile 查看文件

@@ -1,58 +0,0 @@
require 'rake'
require 'spec/rake/spectask'

task :default => :spec

Spec::Rake::SpecTask.new(:spec) do |t|
#t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
t.spec_files = FileList['test/*_spec.rb']
end

desc "Run all specs"
task :spec

def templated_build(name, opts={})
# Create a rule that uses the .tmpl.{pre,post} stuff to make a final,
# wrapped, output file.
# There is some extra complexity because Dojo and YUI3 use different
# template files and final locations.
short = name.downcase
source = "mustache-#{short}"
dependencies = ["mustache.js"] + Dir.glob("#{source}/*.tpl.*")

desc "Package for #{name}"
task short.to_sym => dependencies do
target_js = opts[:location] ? "mustache.js" : "#{short}.mustache.js"

puts "Packaging for #{name}"
sh "mkdir -p #{opts[:location]}" if opts[:location]
sh "cat #{source}/#{target_js}.tpl.pre mustache.js \
#{source}/#{target_js}.tpl.post > #{opts[:location] || '.'}/#{target_js}"

# extra
if opts[:extra]
sh "sed -e 's/{{version}}/#{version}/' #{source}/#{opts[:extra]} \
> #{opts[:location]}/#{opts[:extra]}"
end

puts "Done, see #{opts[:location] || '.'}/#{target_js}"

end
end

templated_build "CommonJS", :location => "lib", :extra => "package.json"
templated_build "jQuery"
templated_build "Dojo", :location => "dojox/string"
templated_build "YUI3", :location => "yui3/mustache"
templated_build "requirejs"


def version
File.read("mustache.js").match('version: "([^\"]+)",$')[1]
end


desc "Remove temporary files."
task :clean do
sh "git clean -fdx"
end

+ 7
- 0
THANKS.md 查看文件

@@ -2,6 +2,8 @@


Mustache.js wouldn't kick ass if it weren't for these fine souls: Mustache.js wouldn't kick ass if it weren't for these fine souls:


## janl (mainline) Branch:

* Chris Wanstrath / defunkt * Chris Wanstrath / defunkt
* Alexander Lang / langalex * Alexander Lang / langalex
* Sebastian Cohnen / tisba * Sebastian Cohnen / tisba
@@ -18,3 +20,8 @@ Mustache.js wouldn't kick ass if it weren't for these fine souls:
* Jason Smith / jhs * Jason Smith / jhs
* Aaron Gibralter / agibralter * Aaron Gibralter / agibralter
* Ross Boucher / boucher * Ross Boucher / boucher

## doodad Branch:

* Gregory Jacobs / gjslick

+ 0
- 8
lib/package.json 查看文件

@@ -1,8 +0,0 @@
{
"name": "mustache",
"author": "http://mustache.github.com/",
"description": "{{ mustache }} in JavaScript — Logic-less templates.",
"keywords": ["template"],
"version": "0.3.1-dev",
"main": "./mustache"
}

+ 6
- 2
mustache-commonjs/package.json 查看文件

@@ -1,7 +1,11 @@
{ {
"name": "mustache", "name": "mustache",
"author": "http://mustache.github.com/",
"author": "Vastardis Capital Services",
"contributors": [
"Mustache <http://mustache.github.com>"
],
"description": "{{ mustache }} in JavaScript — Logic-less templates.", "description": "{{ mustache }} in JavaScript — Logic-less templates.",
"keywords": ["template"], "keywords": ["template"],
"version": "{{version}}"
"version": "0.5.1-vsc",
"main": "./mustache"
} }

mustache-dojo/mustache.js.tpl.post → mustache-dojox/mustache.js.tpl.post 查看文件


mustache-dojo/mustache.js.tpl.pre → mustache-dojox/mustache.js.tpl.pre 查看文件


mustache-jquery/jquery.mustache.js.tpl.post → mustache-jquery/mustache.js.tpl.post 查看文件


mustache-jquery/jquery.mustache.js.tpl.pre → mustache-jquery/mustache.js.tpl.pre 查看文件


mustache-requirejs/requirejs.mustache.js.tpl.post → mustache-requirejs/mustache.js.tpl.post 查看文件


mustache-requirejs/requirejs.mustache.js.tpl.pre → mustache-requirejs/mustache.js.tpl.pre 查看文件


+ 1
- 0
mustache.min.js
文件差異過大導致無法顯示
查看文件


Loading…
取消
儲存