spade-packager 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +2 -0
- data/.gitmodules +6 -0
- data/bin/spadepkg +8 -0
- data/lib/libgems_ext.rb +8 -0
- data/lib/libgems_ext/config_file.rb +33 -0
- data/lib/libgems_ext/dependency_installer.rb +150 -0
- data/lib/libgems_ext/installer.rb +39 -0
- data/lib/libgems_ext/libgems.rb +39 -0
- data/lib/libgems_ext/spec_fetcher.rb +11 -0
- data/lib/spade-packager.rb +1 -0
- data/lib/spade/packager.rb +18 -0
- data/lib/spade/packager/cli.rb +9 -0
- data/lib/spade/packager/cli/base.rb +196 -0
- data/lib/spade/packager/cli/owner.rb +46 -0
- data/lib/spade/packager/cli/project_generator.rb +117 -0
- data/lib/spade/packager/credentials.rb +38 -0
- data/lib/spade/packager/local.rb +50 -0
- data/lib/spade/packager/package.rb +160 -0
- data/lib/spade/packager/remote.rb +98 -0
- data/lib/spade/packager/repository.rb +18 -0
- data/lib/spade/packager/version.rb +5 -0
- data/packages/coffee-script/.gitignore +8 -0
- data/packages/coffee-script/.npmignore +11 -0
- data/packages/coffee-script/Cakefile +229 -0
- data/packages/coffee-script/LICENSE +22 -0
- data/packages/coffee-script/README +47 -0
- data/packages/coffee-script/Rakefile +78 -0
- data/packages/coffee-script/bin/cake +7 -0
- data/packages/coffee-script/bin/coffee +7 -0
- data/packages/coffee-script/documentation/coffee/aliases.coffee +11 -0
- data/packages/coffee-script/documentation/coffee/array_comprehensions.coffee +2 -0
- data/packages/coffee-script/documentation/coffee/block_comment.coffee +6 -0
- data/packages/coffee-script/documentation/coffee/cake_tasks.coffee +9 -0
- data/packages/coffee-script/documentation/coffee/classes.coffee +25 -0
- data/packages/coffee-script/documentation/coffee/comparisons.coffee +5 -0
- data/packages/coffee-script/documentation/coffee/conditionals.coffee +13 -0
- data/packages/coffee-script/documentation/coffee/default_args.coffee +8 -0
- data/packages/coffee-script/documentation/coffee/do.coffee +4 -0
- data/packages/coffee-script/documentation/coffee/embedded.coffee +5 -0
- data/packages/coffee-script/documentation/coffee/existence.coffee +10 -0
- data/packages/coffee-script/documentation/coffee/expressions.coffee +9 -0
- data/packages/coffee-script/documentation/coffee/expressions_assignment.coffee +3 -0
- data/packages/coffee-script/documentation/coffee/expressions_comprehension.coffee +3 -0
- data/packages/coffee-script/documentation/coffee/expressions_try.coffee +7 -0
- data/packages/coffee-script/documentation/coffee/fat_arrow.coffee +6 -0
- data/packages/coffee-script/documentation/coffee/functions.coffee +2 -0
- data/packages/coffee-script/documentation/coffee/heredocs.coffee +7 -0
- data/packages/coffee-script/documentation/coffee/heregexes.coffee +11 -0
- data/packages/coffee-script/documentation/coffee/interpolation.coffee +6 -0
- data/packages/coffee-script/documentation/coffee/multiple_return_values.coffee +7 -0
- data/packages/coffee-script/documentation/coffee/object_comprehensions.coffee +4 -0
- data/packages/coffee-script/documentation/coffee/object_extraction.coffee +13 -0
- data/packages/coffee-script/documentation/coffee/objects_and_arrays.coffee +19 -0
- data/packages/coffee-script/documentation/coffee/objects_reserved.coffee +5 -0
- data/packages/coffee-script/documentation/coffee/overview.coffee +28 -0
- data/packages/coffee-script/documentation/coffee/parallel_assignment.coffee +6 -0
- data/packages/coffee-script/documentation/coffee/patterns_and_splats.coffee +7 -0
- data/packages/coffee-script/documentation/coffee/prototypes.coffee +3 -0
- data/packages/coffee-script/documentation/coffee/range_comprehensions.coffee +2 -0
- data/packages/coffee-script/documentation/coffee/scope.coffee +5 -0
- data/packages/coffee-script/documentation/coffee/slices.coffee +7 -0
- data/packages/coffee-script/documentation/coffee/soaks.coffee +1 -0
- data/packages/coffee-script/documentation/coffee/splats.coffee +27 -0
- data/packages/coffee-script/documentation/coffee/splices.coffee +5 -0
- data/packages/coffee-script/documentation/coffee/strings.coffee +8 -0
- data/packages/coffee-script/documentation/coffee/switch.coffee +10 -0
- data/packages/coffee-script/documentation/coffee/try.coffee +8 -0
- data/packages/coffee-script/documentation/coffee/while.coffee +10 -0
- data/packages/coffee-script/documentation/css/docs.css +374 -0
- data/packages/coffee-script/documentation/css/idle.css +64 -0
- data/packages/coffee-script/documentation/docs/browser.html +25 -0
- data/packages/coffee-script/documentation/docs/cake.html +43 -0
- data/packages/coffee-script/documentation/docs/coffee-script.html +51 -0
- data/packages/coffee-script/documentation/docs/command.html +161 -0
- data/packages/coffee-script/documentation/docs/docco.css +186 -0
- data/packages/coffee-script/documentation/docs/grammar.html +399 -0
- data/packages/coffee-script/documentation/docs/helpers.html +31 -0
- data/packages/coffee-script/documentation/docs/index.html +3 -0
- data/packages/coffee-script/documentation/docs/lexer.html +490 -0
- data/packages/coffee-script/documentation/docs/nodes.html +1338 -0
- data/packages/coffee-script/documentation/docs/optparse.html +78 -0
- data/packages/coffee-script/documentation/docs/repl.html +24 -0
- data/packages/coffee-script/documentation/docs/rewriter.html +251 -0
- data/packages/coffee-script/documentation/docs/scope.html +54 -0
- data/packages/coffee-script/documentation/docs/underscore.html +295 -0
- data/packages/coffee-script/documentation/images/background.png +0 -0
- data/packages/coffee-script/documentation/images/banding.png +0 -0
- data/packages/coffee-script/documentation/images/button_bg.png +0 -0
- data/packages/coffee-script/documentation/images/button_bg_dark.gif +0 -0
- data/packages/coffee-script/documentation/images/button_bg_green.gif +0 -0
- data/packages/coffee-script/documentation/images/favicon.ico +0 -0
- data/packages/coffee-script/documentation/images/logo.png +0 -0
- data/packages/coffee-script/documentation/images/screenshadow.png +0 -0
- data/packages/coffee-script/documentation/index.html.erb +1607 -0
- data/packages/coffee-script/documentation/js/aliases.js +17 -0
- data/packages/coffee-script/documentation/js/array_comprehensions.js +6 -0
- data/packages/coffee-script/documentation/js/block_comment.js +4 -0
- data/packages/coffee-script/documentation/js/cake_tasks.js +10 -0
- data/packages/coffee-script/documentation/js/classes.js +44 -0
- data/packages/coffee-script/documentation/js/comparisons.js +3 -0
- data/packages/coffee-script/documentation/js/conditionals.js +12 -0
- data/packages/coffee-script/documentation/js/default_args.js +7 -0
- data/packages/coffee-script/documentation/js/do.js +10 -0
- data/packages/coffee-script/documentation/js/embedded.js +4 -0
- data/packages/coffee-script/documentation/js/existence.js +6 -0
- data/packages/coffee-script/documentation/js/expressions.js +15 -0
- data/packages/coffee-script/documentation/js/expressions_assignment.js +2 -0
- data/packages/coffee-script/documentation/js/expressions_comprehension.js +9 -0
- data/packages/coffee-script/documentation/js/expressions_try.js +7 -0
- data/packages/coffee-script/documentation/js/fat_arrow.js +9 -0
- data/packages/coffee-script/documentation/js/functions.js +7 -0
- data/packages/coffee-script/documentation/js/heredocs.js +2 -0
- data/packages/coffee-script/documentation/js/heregexes.js +2 -0
- data/packages/coffee-script/documentation/js/interpolation.js +4 -0
- data/packages/coffee-script/documentation/js/multiple_return_values.js +5 -0
- data/packages/coffee-script/documentation/js/object_comprehensions.js +15 -0
- data/packages/coffee-script/documentation/js/object_extraction.js +10 -0
- data/packages/coffee-script/documentation/js/objects_and_arrays.js +17 -0
- data/packages/coffee-script/documentation/js/objects_reserved.js +4 -0
- data/packages/coffee-script/documentation/js/overview.js +35 -0
- data/packages/coffee-script/documentation/js/parallel_assignment.js +4 -0
- data/packages/coffee-script/documentation/js/patterns_and_splats.js +4 -0
- data/packages/coffee-script/documentation/js/prototypes.js +3 -0
- data/packages/coffee-script/documentation/js/range_comprehensions.js +9 -0
- data/packages/coffee-script/documentation/js/scope.js +8 -0
- data/packages/coffee-script/documentation/js/slices.js +4 -0
- data/packages/coffee-script/documentation/js/soaks.js +2 -0
- data/packages/coffee-script/documentation/js/splats.js +15 -0
- data/packages/coffee-script/documentation/js/splices.js +3 -0
- data/packages/coffee-script/documentation/js/strings.js +2 -0
- data/packages/coffee-script/documentation/js/switch.js +23 -0
- data/packages/coffee-script/documentation/js/try.js +8 -0
- data/packages/coffee-script/documentation/js/while.js +18 -0
- data/packages/coffee-script/documentation/vendor/jquery-1.4.2.js +6240 -0
- data/packages/coffee-script/examples/beautiful_code/binary_search.coffee +16 -0
- data/packages/coffee-script/examples/beautiful_code/quicksort_runtime.coffee +13 -0
- data/packages/coffee-script/examples/beautiful_code/regular_expression_matcher.coffee +34 -0
- data/packages/coffee-script/examples/blocks.coffee +54 -0
- data/packages/coffee-script/examples/code.coffee +167 -0
- data/packages/coffee-script/examples/computer_science/README +4 -0
- data/packages/coffee-script/examples/computer_science/binary_search.coffee +25 -0
- data/packages/coffee-script/examples/computer_science/bubble_sort.coffee +11 -0
- data/packages/coffee-script/examples/computer_science/linked_list.coffee +108 -0
- data/packages/coffee-script/examples/computer_science/luhn_algorithm.coffee +36 -0
- data/packages/coffee-script/examples/computer_science/merge_sort.coffee +19 -0
- data/packages/coffee-script/examples/computer_science/selection_sort.coffee +23 -0
- data/packages/coffee-script/examples/poignant.coffee +181 -0
- data/packages/coffee-script/examples/potion.coffee +206 -0
- data/packages/coffee-script/examples/underscore.coffee +682 -0
- data/packages/coffee-script/examples/web_server.coffee +12 -0
- data/packages/coffee-script/extras/EXTRAS +7 -0
- data/packages/coffee-script/extras/coffee-script.js +8 -0
- data/packages/coffee-script/extras/jsl.conf +44 -0
- data/packages/coffee-script/index.html +2515 -0
- data/packages/coffee-script/lib/browser.js +52 -0
- data/packages/coffee-script/lib/cake.js +76 -0
- data/packages/coffee-script/lib/coffee-script.js +82 -0
- data/packages/coffee-script/lib/command.js +263 -0
- data/packages/coffee-script/lib/grammar.js +581 -0
- data/packages/coffee-script/lib/helpers.js +66 -0
- data/packages/coffee-script/lib/index.js +8 -0
- data/packages/coffee-script/lib/lexer.js +633 -0
- data/packages/coffee-script/lib/nodes.js +2165 -0
- data/packages/coffee-script/lib/optparse.js +111 -0
- data/packages/coffee-script/lib/parser.js +649 -0
- data/packages/coffee-script/lib/repl.js +42 -0
- data/packages/coffee-script/lib/rewriter.js +353 -0
- data/packages/coffee-script/lib/scope.js +120 -0
- data/packages/coffee-script/lib/spade-format.js +45 -0
- data/packages/coffee-script/package.json +26 -0
- data/packages/coffee-script/src/browser.coffee +43 -0
- data/packages/coffee-script/src/cake.coffee +69 -0
- data/packages/coffee-script/src/coffee-script.coffee +92 -0
- data/packages/coffee-script/src/command.coffee +214 -0
- data/packages/coffee-script/src/grammar.coffee +590 -0
- data/packages/coffee-script/src/helpers.coffee +56 -0
- data/packages/coffee-script/src/index.coffee +2 -0
- data/packages/coffee-script/src/lexer.coffee +653 -0
- data/packages/coffee-script/src/nodes.coffee +1754 -0
- data/packages/coffee-script/src/optparse.coffee +99 -0
- data/packages/coffee-script/src/repl.coffee +42 -0
- data/packages/coffee-script/src/rewriter.coffee +326 -0
- data/packages/coffee-script/src/scope.coffee +94 -0
- data/packages/coffee-script/test/arguments.coffee +127 -0
- data/packages/coffee-script/test/assignment.coffee +98 -0
- data/packages/coffee-script/test/break.coffee +18 -0
- data/packages/coffee-script/test/comments.coffee +201 -0
- data/packages/coffee-script/test/conditionals.coffee +181 -0
- data/packages/coffee-script/test/exception_handling.coffee +90 -0
- data/packages/coffee-script/test/helpers.coffee +96 -0
- data/packages/coffee-script/test/importing.coffee +18 -0
- data/packages/coffee-script/test/operators.coffee +225 -0
- data/packages/coffee-script/test/ranges_slices_and_splices.coffee +186 -0
- data/packages/coffee-script/test/regular_expressions.coffee +56 -0
- data/packages/coffee-script/test/test.html +123 -0
- data/packages/coffee-script/test/test_chaining.coffee +77 -0
- data/packages/coffee-script/test/test_classes.coffee +372 -0
- data/packages/coffee-script/test/test_compilation.coffee +26 -0
- data/packages/coffee-script/test/test_comprehensions.coffee +318 -0
- data/packages/coffee-script/test/test_existence.coffee +165 -0
- data/packages/coffee-script/test/test_functions.coffee +379 -0
- data/packages/coffee-script/test/test_heredocs.coffee +111 -0
- data/packages/coffee-script/test/test_literals.coffee +270 -0
- data/packages/coffee-script/test/test_option_parser.coffee +27 -0
- data/packages/coffee-script/test/test_pattern_matching.coffee +162 -0
- data/packages/coffee-script/test/test_returns.coffee +63 -0
- data/packages/coffee-script/test/test_splats.coffee +102 -0
- data/packages/coffee-script/test/test_strings.coffee +118 -0
- data/packages/coffee-script/test/test_switch.coffee +103 -0
- data/packages/coffee-script/test/test_while.coffee +71 -0
- data/packages/ivory/LICENSE.txt +1 -0
- data/packages/ivory/README.md +19 -0
- data/packages/ivory/lib/buffer.js +111 -0
- data/packages/ivory/lib/events.js +137 -0
- data/packages/ivory/lib/fs.js +266 -0
- data/packages/ivory/lib/main.js +13 -0
- data/packages/ivory/lib/path.js +158 -0
- data/packages/ivory/lib/ruby/buffer.rb +145 -0
- data/packages/ivory/lib/ruby/constants.rb +585 -0
- data/packages/ivory/lib/ruby/events.rb +32 -0
- data/packages/ivory/lib/ruby/fs.rb +245 -0
- data/packages/ivory/lib/ruby/process.rb +28 -0
- data/packages/ivory/lib/stream.js +115 -0
- data/packages/ivory/lib/util.js +414 -0
- data/packages/ivory/package.json +11 -0
- data/packages/ivory/spade-boot.js +78 -0
- data/packages/jquery/main.js +7179 -0
- data/packages/jquery/package.json +10 -0
- data/packages/json/lib/main.js +14 -0
- data/packages/json/package.json +8 -0
- data/packages/lproj/README.md +77 -0
- data/packages/lproj/examples/demo-app/en.lproj/localized.strings +2 -0
- data/packages/lproj/examples/demo-app/fr.lproj/localized.strings +3 -0
- data/packages/lproj/examples/demo-app/index.html +8 -0
- data/packages/lproj/examples/demo-app/lib/main.js +7 -0
- data/packages/lproj/examples/demo-app/package.json +9 -0
- data/packages/lproj/lib/main.js +78 -0
- data/packages/lproj/lib/strings-format.js +6 -0
- data/packages/lproj/package.json +9 -0
- data/packages/optparse/README.md +161 -0
- data/packages/optparse/TODO +1 -0
- data/packages/optparse/examples/browser-test.html +75 -0
- data/packages/optparse/examples/nodejs-test.js +90 -0
- data/packages/optparse/lib/optparse.js +309 -0
- data/packages/optparse/package.json +13 -0
- data/packages/optparse/seed.yml +5 -0
- data/packages/text/lib/main.js +8 -0
- data/packages/text/package.json +9 -0
- data/packages/web-file/README.md +7 -0
- data/packages/web-file/lib/errors.js +32 -0
- data/packages/web-file/lib/file-reader.js +10 -0
- data/packages/web-file/lib/file-system.js +234 -0
- data/packages/web-file/lib/file-writer.js +10 -0
- data/packages/web-file/lib/file.js +9 -0
- data/packages/web-file/lib/main.js +34 -0
- data/packages/web-file/lib/platform.js +25 -0
- data/packages/web-file/lib/ruby/file.rb +252 -0
- data/packages/web-file/lib/ruby/file_reader.rb +69 -0
- data/packages/web-file/lib/ruby/file_system.rb +134 -0
- data/packages/web-file/lib/ruby/file_writer.rb +78 -0
- data/packages/web-file/package.json +12 -0
- data/packages/web-typed-array/README.md +7 -0
- data/packages/web-typed-array/lib/array-buffer-view.js +9 -0
- data/packages/web-typed-array/lib/array-buffer.js +7 -0
- data/packages/web-typed-array/lib/main.js +33 -0
- data/packages/web-typed-array/lib/platform.js +20 -0
- data/packages/web-typed-array/lib/ruby/array_buffer.rb +31 -0
- data/packages/web-typed-array/lib/ruby/array_buffer_view.rb +130 -0
- data/packages/web-typed-array/lib/ruby/typed_array.rb +133 -0
- data/packages/web-typed-array/lib/typed-array.js +26 -0
- data/packages/web-typed-array/package.json +9 -0
- data/spade-packager.gemspec +39 -0
- data/spec/cli/build_spec.rb +57 -0
- data/spec/cli/install_spec.rb +119 -0
- data/spec/cli/installed_spec.rb +55 -0
- data/spec/cli/list_spec.rb +74 -0
- data/spec/cli/login_spec.rb +75 -0
- data/spec/cli/new_spec.rb +5 -0
- data/spec/cli/owner_spec.rb +114 -0
- data/spec/cli/push_spec.rb +73 -0
- data/spec/cli/uninstall_spec.rb +58 -0
- data/spec/cli/unpack_spec.rb +72 -0
- data/spec/cli/unyank_spec.rb +73 -0
- data/spec/cli/yank_spec.rb +73 -0
- data/spec/credentials_spec.rb +23 -0
- data/spec/fixtures/badrake-0.8.7.spd +0 -0
- data/spec/fixtures/builder-3.0.0.spd +0 -0
- data/spec/fixtures/bundler-1.1.pre.spd +0 -0
- data/spec/fixtures/coffee-1.0.1.pre.spd +0 -0
- data/spec/fixtures/core-test-0.4.3.spd +0 -0
- data/spec/fixtures/core-test/bin/cot +3 -0
- data/spec/fixtures/core-test/lib/main.js +1 -0
- data/spec/fixtures/core-test/resources/runner.css +0 -0
- data/spec/fixtures/core-test/tests/test.js +1 -0
- data/spec/fixtures/highline-1.6.1.spd +0 -0
- data/spec/fixtures/ivory-0.0.1.spd +0 -0
- data/spec/fixtures/jquery-1.4.3.spd +0 -0
- data/spec/fixtures/optparse-1.0.1.spd +0 -0
- data/spec/fixtures/package.json +30 -0
- data/spec/fixtures/rake-0.8.6.spd +0 -0
- data/spec/fixtures/rake-0.8.7.spd +0 -0
- data/spec/gauntlet_spec.rb +27 -0
- data/spec/package_spec.rb +267 -0
- data/spec/spec_helper.rb +32 -0
- data/spec/support/cli.rb +103 -0
- data/spec/support/fake.rb +48 -0
- data/spec/support/fake_gem_server.rb +67 -0
- data/spec/support/fake_gemcutter.rb +50 -0
- data/spec/support/matchers.rb +32 -0
- data/spec/support/path.rb +61 -0
- data/templates/project/LICENSE +19 -0
- data/templates/project/README.md +21 -0
- data/templates/project/lib/main.js +9 -0
- data/templates/project/project.json +31 -0
- data/templates/project/tests/main-test.js +8 -0
- metadata +484 -0
@@ -0,0 +1,52 @@
|
|
1
|
+
(function() {
|
2
|
+
var CoffeeScript, runScripts;
|
3
|
+
CoffeeScript = require('./coffee-script');
|
4
|
+
CoffeeScript.require = require;
|
5
|
+
CoffeeScript.eval = function(code, options) {
|
6
|
+
return eval(CoffeeScript.compile(code, options));
|
7
|
+
};
|
8
|
+
CoffeeScript.run = function(code, options) {
|
9
|
+
if (options == null) {
|
10
|
+
options = {};
|
11
|
+
}
|
12
|
+
options.bare = true;
|
13
|
+
return Function(CoffeeScript.compile(code, options))();
|
14
|
+
};
|
15
|
+
if (typeof window == "undefined" || window === null) {
|
16
|
+
return;
|
17
|
+
}
|
18
|
+
CoffeeScript.load = function(url, options) {
|
19
|
+
var xhr;
|
20
|
+
xhr = new (window.ActiveXObject || XMLHttpRequest)('Microsoft.XMLHTTP');
|
21
|
+
xhr.open('GET', url, true);
|
22
|
+
if ('overrideMimeType' in xhr) {
|
23
|
+
xhr.overrideMimeType('text/plain');
|
24
|
+
}
|
25
|
+
xhr.onreadystatechange = function() {
|
26
|
+
if (xhr.readyState === 4) {
|
27
|
+
return CoffeeScript.run(xhr.responseText, options);
|
28
|
+
}
|
29
|
+
};
|
30
|
+
return xhr.send(null);
|
31
|
+
};
|
32
|
+
runScripts = function() {
|
33
|
+
var script, _i, _len, _ref;
|
34
|
+
_ref = document.getElementsByTagName('script');
|
35
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
36
|
+
script = _ref[_i];
|
37
|
+
if (script.type === 'text/coffeescript') {
|
38
|
+
if (script.src) {
|
39
|
+
CoffeeScript.load(script.src);
|
40
|
+
} else {
|
41
|
+
CoffeeScript.run(script.innerHTML);
|
42
|
+
}
|
43
|
+
}
|
44
|
+
}
|
45
|
+
return null;
|
46
|
+
};
|
47
|
+
if (window.addEventListener) {
|
48
|
+
addEventListener('DOMContentLoaded', runScripts, false);
|
49
|
+
} else {
|
50
|
+
attachEvent('onload', runScripts);
|
51
|
+
}
|
52
|
+
}).call(this);
|
@@ -0,0 +1,76 @@
|
|
1
|
+
(function() {
|
2
|
+
var CoffeeScript, fs, helpers, missingTask, oparse, options, optparse, path, printTasks, switches, tasks;
|
3
|
+
fs = require('fs');
|
4
|
+
path = require('path');
|
5
|
+
helpers = require('./helpers');
|
6
|
+
optparse = require('./optparse');
|
7
|
+
CoffeeScript = require('./coffee-script');
|
8
|
+
tasks = {};
|
9
|
+
options = {};
|
10
|
+
switches = [];
|
11
|
+
oparse = null;
|
12
|
+
helpers.extend(global, {
|
13
|
+
task: function(name, description, action) {
|
14
|
+
var _ref;
|
15
|
+
if (!action) {
|
16
|
+
_ref = [description, action], action = _ref[0], description = _ref[1];
|
17
|
+
}
|
18
|
+
return tasks[name] = {
|
19
|
+
name: name,
|
20
|
+
description: description,
|
21
|
+
action: action
|
22
|
+
};
|
23
|
+
},
|
24
|
+
option: function(letter, flag, description) {
|
25
|
+
return switches.push([letter, flag, description]);
|
26
|
+
},
|
27
|
+
invoke: function(name) {
|
28
|
+
if (!tasks[name]) {
|
29
|
+
missingTask(name);
|
30
|
+
}
|
31
|
+
return tasks[name].action(options);
|
32
|
+
}
|
33
|
+
});
|
34
|
+
exports.run = function() {
|
35
|
+
return path.exists('Cakefile', function(exists) {
|
36
|
+
var arg, args, _i, _len, _ref, _results;
|
37
|
+
if (!exists) {
|
38
|
+
throw new Error("Cakefile not found in " + (process.cwd()));
|
39
|
+
}
|
40
|
+
args = process.argv.slice(2);
|
41
|
+
CoffeeScript.run(fs.readFileSync('Cakefile').toString(), {
|
42
|
+
fileName: 'Cakefile'
|
43
|
+
});
|
44
|
+
oparse = new optparse.OptionParser(switches);
|
45
|
+
if (!args.length) {
|
46
|
+
return printTasks();
|
47
|
+
}
|
48
|
+
options = oparse.parse(args);
|
49
|
+
_ref = options.arguments;
|
50
|
+
_results = [];
|
51
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
52
|
+
arg = _ref[_i];
|
53
|
+
_results.push(invoke(arg));
|
54
|
+
}
|
55
|
+
return _results;
|
56
|
+
});
|
57
|
+
};
|
58
|
+
printTasks = function() {
|
59
|
+
var desc, name, spaces, task;
|
60
|
+
console.log('');
|
61
|
+
for (name in tasks) {
|
62
|
+
task = tasks[name];
|
63
|
+
spaces = 20 - name.length;
|
64
|
+
spaces = spaces > 0 ? Array(spaces + 1).join(' ') : '';
|
65
|
+
desc = task.description ? "# " + task.description : '';
|
66
|
+
console.log("cake " + name + spaces + " " + desc);
|
67
|
+
}
|
68
|
+
if (switches.length) {
|
69
|
+
return console.log(oparse.help());
|
70
|
+
}
|
71
|
+
};
|
72
|
+
missingTask = function(task) {
|
73
|
+
console.log("No such task: \"" + task + "\"");
|
74
|
+
return process.exit(1);
|
75
|
+
};
|
76
|
+
}).call(this);
|
@@ -0,0 +1,82 @@
|
|
1
|
+
(function() {
|
2
|
+
var Lexer, RESERVED, compile, fs, lexer, parser, path, _ref;
|
3
|
+
fs = require('fs');
|
4
|
+
path = require('path');
|
5
|
+
_ref = require('./lexer'), Lexer = _ref.Lexer, RESERVED = _ref.RESERVED;
|
6
|
+
parser = require('./parser').parser;
|
7
|
+
if (require.extensions) {
|
8
|
+
require.extensions['.coffee'] = function(module, filename) {
|
9
|
+
var content;
|
10
|
+
content = compile(fs.readFileSync(filename, 'utf8'));
|
11
|
+
return module._compile(content, filename);
|
12
|
+
};
|
13
|
+
} else if (require.registerExtension) {
|
14
|
+
require.registerExtension('.coffee', function(content) {
|
15
|
+
return compile(content);
|
16
|
+
});
|
17
|
+
}
|
18
|
+
exports.VERSION = '1.0.1-pre';
|
19
|
+
exports.RESERVED = RESERVED;
|
20
|
+
exports.helpers = require('./helpers');
|
21
|
+
exports.compile = compile = function(code, options) {
|
22
|
+
if (options == null) {
|
23
|
+
options = {};
|
24
|
+
}
|
25
|
+
try {
|
26
|
+
return (parser.parse(lexer.tokenize(code))).compile(options);
|
27
|
+
} catch (err) {
|
28
|
+
if (options.fileName) {
|
29
|
+
err.message = "In " + options.fileName + ", " + err.message;
|
30
|
+
}
|
31
|
+
throw err;
|
32
|
+
}
|
33
|
+
};
|
34
|
+
exports.tokens = function(code, options) {
|
35
|
+
return lexer.tokenize(code, options);
|
36
|
+
};
|
37
|
+
exports.nodes = function(source, options) {
|
38
|
+
if (typeof source === 'string') {
|
39
|
+
return parser.parse(lexer.tokenize(source, options));
|
40
|
+
} else {
|
41
|
+
return parser.parse(source);
|
42
|
+
}
|
43
|
+
};
|
44
|
+
exports.run = function(code, options) {
|
45
|
+
var root;
|
46
|
+
root = module;
|
47
|
+
while (root.parent) {
|
48
|
+
root = root.parent;
|
49
|
+
}
|
50
|
+
root.filename = fs.realpathSync(options.fileName || '.');
|
51
|
+
if (root.moduleCache) {
|
52
|
+
root.moduleCache = {};
|
53
|
+
}
|
54
|
+
if (path.extname(root.filename) !== '.coffee' || require.extensions) {
|
55
|
+
return root._compile(compile(code, options), root.filename);
|
56
|
+
} else {
|
57
|
+
return root._compile(code, root.filename);
|
58
|
+
}
|
59
|
+
};
|
60
|
+
exports.eval = function(code, options) {
|
61
|
+
var __dirname, __filename;
|
62
|
+
__filename = options.fileName;
|
63
|
+
__dirname = path.dirname(__filename);
|
64
|
+
return eval(compile(code, options));
|
65
|
+
};
|
66
|
+
lexer = new Lexer;
|
67
|
+
parser.lexer = {
|
68
|
+
lex: function() {
|
69
|
+
var tag, _ref;
|
70
|
+
_ref = this.tokens[this.pos++] || [''], tag = _ref[0], this.yytext = _ref[1], this.yylineno = _ref[2];
|
71
|
+
return tag;
|
72
|
+
},
|
73
|
+
setInput: function(tokens) {
|
74
|
+
this.tokens = tokens;
|
75
|
+
return this.pos = 0;
|
76
|
+
},
|
77
|
+
upcomingInput: function() {
|
78
|
+
return "";
|
79
|
+
}
|
80
|
+
};
|
81
|
+
parser.yy = require('./nodes');
|
82
|
+
}).call(this);
|
@@ -0,0 +1,263 @@
|
|
1
|
+
(function() {
|
2
|
+
var BANNER, CoffeeScript, EventEmitter, SWITCHES, compileJoin, compileOptions, compileScript, compileScripts, compileStdio, contents, exec, forkNode, fs, helpers, lint, optionParser, optparse, opts, parseOptions, path, printLine, printTokens, printWarn, sources, spawn, usage, util, version, watch, writeJs, _ref;
|
3
|
+
fs = require('fs');
|
4
|
+
path = require('path');
|
5
|
+
util = require('util');
|
6
|
+
helpers = require('./helpers');
|
7
|
+
optparse = require('./optparse');
|
8
|
+
CoffeeScript = require('./coffee-script');
|
9
|
+
_ref = require('child_process'), spawn = _ref.spawn, exec = _ref.exec;
|
10
|
+
EventEmitter = require('events').EventEmitter;
|
11
|
+
helpers.extend(CoffeeScript, new EventEmitter);
|
12
|
+
printLine = function(line) {
|
13
|
+
return process.stdout.write(line + '\n');
|
14
|
+
};
|
15
|
+
printWarn = function(line) {
|
16
|
+
return process.binding('stdio').writeError(line + '\n');
|
17
|
+
};
|
18
|
+
BANNER = 'Usage: coffee [options] path/to/script.coffee';
|
19
|
+
SWITCHES = [['-c', '--compile', 'compile to JavaScript and save as .js files'], ['-i', '--interactive', 'run an interactive CoffeeScript REPL'], ['-o', '--output [DIR]', 'set the directory for compiled JavaScript'], ['-j', '--join', 'concatenate the scripts before compiling'], ['-w', '--watch', 'watch scripts for changes, and recompile'], ['-p', '--print', 'print the compiled JavaScript to stdout'], ['-l', '--lint', 'pipe the compiled JavaScript through JSLint'], ['-s', '--stdio', 'listen for and compile scripts over stdio'], ['-e', '--eval', 'compile a string from the command line'], ['-r', '--require [FILE*]', 'require a library before executing your script'], ['-b', '--bare', 'compile without the top-level function wrapper'], ['-t', '--tokens', 'print the tokens that the lexer produces'], ['-n', '--nodes', 'print the parse tree that Jison produces'], ['--nodejs [ARGS]', 'pass options through to the "node" binary'], ['-v', '--version', 'display CoffeeScript version'], ['-h', '--help', 'display this help message']];
|
20
|
+
opts = {};
|
21
|
+
sources = [];
|
22
|
+
contents = [];
|
23
|
+
optionParser = null;
|
24
|
+
exports.run = function() {
|
25
|
+
parseOptions();
|
26
|
+
if (opts.nodejs) {
|
27
|
+
return forkNode();
|
28
|
+
}
|
29
|
+
if (opts.help) {
|
30
|
+
return usage();
|
31
|
+
}
|
32
|
+
if (opts.version) {
|
33
|
+
return version();
|
34
|
+
}
|
35
|
+
if (opts.interactive) {
|
36
|
+
return require('./repl');
|
37
|
+
}
|
38
|
+
if (opts.stdio) {
|
39
|
+
return compileStdio();
|
40
|
+
}
|
41
|
+
if (opts.eval) {
|
42
|
+
return compileScript(null, sources[0]);
|
43
|
+
}
|
44
|
+
if (!sources.length) {
|
45
|
+
return require('./repl');
|
46
|
+
}
|
47
|
+
if (opts.run) {
|
48
|
+
opts.literals = sources.splice(1).concat(opts.literals);
|
49
|
+
}
|
50
|
+
process.ARGV = process.argv = process.argv.slice(0, 2).concat(opts.literals);
|
51
|
+
return compileScripts();
|
52
|
+
};
|
53
|
+
compileScripts = function() {
|
54
|
+
var base, compile, source, _i, _len, _results;
|
55
|
+
_results = [];
|
56
|
+
for (_i = 0, _len = sources.length; _i < _len; _i++) {
|
57
|
+
source = sources[_i];
|
58
|
+
base = path.join(source);
|
59
|
+
compile = function(source, topLevel) {
|
60
|
+
return path.exists(source, function(exists) {
|
61
|
+
if (!exists) {
|
62
|
+
throw new Error("File not found: " + source);
|
63
|
+
}
|
64
|
+
return fs.stat(source, function(err, stats) {
|
65
|
+
if (stats.isDirectory()) {
|
66
|
+
return fs.readdir(source, function(err, files) {
|
67
|
+
var file, _i, _len, _results;
|
68
|
+
_results = [];
|
69
|
+
for (_i = 0, _len = files.length; _i < _len; _i++) {
|
70
|
+
file = files[_i];
|
71
|
+
_results.push(compile(path.join(source, file)));
|
72
|
+
}
|
73
|
+
return _results;
|
74
|
+
});
|
75
|
+
} else if (topLevel || path.extname(source) === '.coffee') {
|
76
|
+
fs.readFile(source, function(err, code) {
|
77
|
+
if (opts.join) {
|
78
|
+
contents[sources.indexOf(source)] = code.toString();
|
79
|
+
if (helpers.compact(contents).length === sources.length) {
|
80
|
+
return compileJoin();
|
81
|
+
}
|
82
|
+
} else {
|
83
|
+
return compileScript(source, code.toString(), base);
|
84
|
+
}
|
85
|
+
});
|
86
|
+
if (opts.watch && !opts.join) {
|
87
|
+
return watch(source, base);
|
88
|
+
}
|
89
|
+
}
|
90
|
+
});
|
91
|
+
});
|
92
|
+
};
|
93
|
+
_results.push(compile(source, true));
|
94
|
+
}
|
95
|
+
return _results;
|
96
|
+
};
|
97
|
+
compileScript = function(file, input, base) {
|
98
|
+
var o, options, req, t, task, _i, _len, _ref;
|
99
|
+
o = opts;
|
100
|
+
options = compileOptions(file);
|
101
|
+
if (o.require) {
|
102
|
+
_ref = o.require;
|
103
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
104
|
+
req = _ref[_i];
|
105
|
+
require(helpers.starts(req, '.') ? fs.realpathSync(req) : req);
|
106
|
+
}
|
107
|
+
}
|
108
|
+
try {
|
109
|
+
t = task = {
|
110
|
+
file: file,
|
111
|
+
input: input,
|
112
|
+
options: options
|
113
|
+
};
|
114
|
+
CoffeeScript.emit('compile', task);
|
115
|
+
if (o.tokens) {
|
116
|
+
return printTokens(CoffeeScript.tokens(t.input));
|
117
|
+
} else if (o.nodes) {
|
118
|
+
return printLine(CoffeeScript.nodes(t.input).toString().trim());
|
119
|
+
} else if (o.run) {
|
120
|
+
return CoffeeScript.run(t.input, t.options);
|
121
|
+
} else {
|
122
|
+
t.output = CoffeeScript.compile(t.input, t.options);
|
123
|
+
CoffeeScript.emit('success', task);
|
124
|
+
if (o.print) {
|
125
|
+
return printLine(t.output.trim());
|
126
|
+
} else if (o.compile) {
|
127
|
+
return writeJs(t.file, t.output, base);
|
128
|
+
} else if (o.lint) {
|
129
|
+
return lint(t.file, t.output);
|
130
|
+
}
|
131
|
+
}
|
132
|
+
} catch (err) {
|
133
|
+
CoffeeScript.emit('failure', err, task);
|
134
|
+
if (CoffeeScript.listeners('failure').length) {
|
135
|
+
return;
|
136
|
+
}
|
137
|
+
if (o.watch) {
|
138
|
+
return printLine(err.message);
|
139
|
+
}
|
140
|
+
printWarn(err.stack);
|
141
|
+
return process.exit(1);
|
142
|
+
}
|
143
|
+
};
|
144
|
+
compileStdio = function() {
|
145
|
+
var code, stdin;
|
146
|
+
code = '';
|
147
|
+
stdin = process.openStdin();
|
148
|
+
stdin.on('data', function(buffer) {
|
149
|
+
if (buffer) {
|
150
|
+
return code += buffer.toString();
|
151
|
+
}
|
152
|
+
});
|
153
|
+
return stdin.on('end', function() {
|
154
|
+
return compileScript(null, code);
|
155
|
+
});
|
156
|
+
};
|
157
|
+
compileJoin = function() {
|
158
|
+
var code;
|
159
|
+
code = contents.join('\n');
|
160
|
+
return compileScript("concatenation", code, "concatenation");
|
161
|
+
};
|
162
|
+
watch = function(source, base) {
|
163
|
+
return fs.watchFile(source, {
|
164
|
+
persistent: true,
|
165
|
+
interval: 500
|
166
|
+
}, function(curr, prev) {
|
167
|
+
if (curr.size === prev.size && curr.mtime.getTime() === prev.mtime.getTime()) {
|
168
|
+
return;
|
169
|
+
}
|
170
|
+
return fs.readFile(source, function(err, code) {
|
171
|
+
if (err) {
|
172
|
+
throw err;
|
173
|
+
}
|
174
|
+
return compileScript(source, code.toString(), base);
|
175
|
+
});
|
176
|
+
});
|
177
|
+
};
|
178
|
+
writeJs = function(source, js, base) {
|
179
|
+
var baseDir, compile, dir, filename, jsPath, srcDir;
|
180
|
+
filename = path.basename(source, path.extname(source)) + '.js';
|
181
|
+
srcDir = path.dirname(source);
|
182
|
+
baseDir = base === '.' ? srcDir : srcDir.substring(base.length);
|
183
|
+
dir = opts.output ? path.join(opts.output, baseDir) : srcDir;
|
184
|
+
jsPath = path.join(dir, filename);
|
185
|
+
compile = function() {
|
186
|
+
if (js.length <= 0) {
|
187
|
+
js = ' ';
|
188
|
+
}
|
189
|
+
return fs.writeFile(jsPath, js, function(err) {
|
190
|
+
if (err) {
|
191
|
+
return printLine(err.message);
|
192
|
+
} else if (opts.compile && opts.watch) {
|
193
|
+
return util.log("compiled " + source);
|
194
|
+
}
|
195
|
+
});
|
196
|
+
};
|
197
|
+
return path.exists(dir, function(exists) {
|
198
|
+
if (exists) {
|
199
|
+
return compile();
|
200
|
+
} else {
|
201
|
+
return exec("mkdir -p " + dir, compile);
|
202
|
+
}
|
203
|
+
});
|
204
|
+
};
|
205
|
+
lint = function(file, js) {
|
206
|
+
var conf, jsl, printIt;
|
207
|
+
printIt = function(buffer) {
|
208
|
+
return printLine(file + ':\t' + buffer.toString().trim());
|
209
|
+
};
|
210
|
+
conf = __dirname + '/../extras/jsl.conf';
|
211
|
+
jsl = spawn('jsl', ['-nologo', '-stdin', '-conf', conf]);
|
212
|
+
jsl.stdout.on('data', printIt);
|
213
|
+
jsl.stderr.on('data', printIt);
|
214
|
+
jsl.stdin.write(js);
|
215
|
+
return jsl.stdin.end();
|
216
|
+
};
|
217
|
+
printTokens = function(tokens) {
|
218
|
+
var strings, tag, token, value;
|
219
|
+
strings = (function() {
|
220
|
+
var _i, _len, _ref, _results;
|
221
|
+
_results = [];
|
222
|
+
for (_i = 0, _len = tokens.length; _i < _len; _i++) {
|
223
|
+
token = tokens[_i];
|
224
|
+
_ref = [token[0], token[1].toString().replace(/\n/, '\\n')], tag = _ref[0], value = _ref[1];
|
225
|
+
_results.push("[" + tag + " " + value + "]");
|
226
|
+
}
|
227
|
+
return _results;
|
228
|
+
})();
|
229
|
+
return printLine(strings.join(' '));
|
230
|
+
};
|
231
|
+
parseOptions = function() {
|
232
|
+
var o;
|
233
|
+
optionParser = new optparse.OptionParser(SWITCHES, BANNER);
|
234
|
+
o = opts = optionParser.parse(process.argv.slice(2));
|
235
|
+
o.compile || (o.compile = !!o.output);
|
236
|
+
o.run = !(o.compile || o.print || o.lint);
|
237
|
+
o.print = !!(o.print || (o.eval || o.stdio && o.compile));
|
238
|
+
return sources = o.arguments;
|
239
|
+
};
|
240
|
+
compileOptions = function(fileName) {
|
241
|
+
return {
|
242
|
+
fileName: fileName,
|
243
|
+
bare: opts.bare
|
244
|
+
};
|
245
|
+
};
|
246
|
+
forkNode = function() {
|
247
|
+
var args, nodeArgs;
|
248
|
+
nodeArgs = opts.nodejs.split(/\s+/);
|
249
|
+
args = process.argv.slice(1);
|
250
|
+
args.splice(args.indexOf('--nodejs'), 2);
|
251
|
+
return spawn(process.execPath, nodeArgs.concat(args), {
|
252
|
+
cwd: process.cwd(),
|
253
|
+
env: process.env,
|
254
|
+
customFds: [0, 1, 2]
|
255
|
+
});
|
256
|
+
};
|
257
|
+
usage = function() {
|
258
|
+
return printLine((new optparse.OptionParser(SWITCHES, BANNER)).help());
|
259
|
+
};
|
260
|
+
version = function() {
|
261
|
+
return printLine("CoffeeScript version " + CoffeeScript.VERSION);
|
262
|
+
};
|
263
|
+
}).call(this);
|