+359
| [](http://travis-ci.org/kmalakoff/easy-bake) | ||
| ```` | ||
| ,--. ,--. | ||
| ,---. ,--,--. ,---.,--. ,--.,-----.| |-. ,--,--.| |,-. ,---. | ||
| | .-. :' ,-. |( .-' \ ' / '-----'| .-. '' ,-. || /| .-. : | ||
| \ --.\ '-' |.-' `) \ ' | `-' |\ '-' || \ \\ --. | ||
| `----' `--`--'`----'.-' / `---' `--`--'`--'`--'`----' | ||
| `---' | ||
| ```` | ||
| EasyBake provides Coffeescript config file-based Cakefile helpers for common CoffeeScript library packaging functionality (build & joining, headless testing, etc). | ||
| Commands Supplied by EasyBake | ||
| ----------------------- | ||
| - **bake postinstall**: runs postinstall steps like copying dependent client scripts to vendor directory, etc. | ||
| - **bake clean**: cleans the project of all compiled files | ||
| - **bake build**: performs a single build | ||
| - **bake watch**: automatically scans for and builds the project when changes are detected | ||
| - **bake test**: runs tests (you might need to install phantomjs: http://phantomjs.org/ or if you use homebrew: 'brew install phantomjs') | ||
| - **bake publish_git**: cleans, builds, tests and if successful, runs git commands to add, commit, and push the project. | ||
| - **bake publish_npm**: cleans, builds, tests and if successful, runs git commands to add, commit, and push the project to node registry. | ||
| - **bake publish_nuget**: cleans, builds, tests and if successful, runs git commands to add, commit, and push the project to NuGet Gallery. | ||
| - **bake publish_all**: cleans, builds, tests and if successful, runs git commands to add, commit, and push the project to all relevant repositories. | ||
| Command Options: | ||
| ----------------------- | ||
| For example: 'bake test -c -w' will first clean your project, build it, run your tests, and re-build and re-run your tests when source files change | ||
| Some common options: | ||
| - **-c**/**--clean** (build, watch, test): cleans the project before running a command | ||
| - **-p'**/**'--preview** (all): display all of the commands that will be run (without running them!) | ||
| - **-f'**/**'--force** (publish): overwrite the existing repository version (if possible) | ||
| To see all of the options for each command, just run 'bake command_name --help'. | ||
| Sample Config File | ||
| ----------------------- | ||
| Here is an example of a CoffeeScript config file (JavaScript is also supported): | ||
| ``` | ||
| module.exports = | ||
| library: | ||
| files: 'src/easy-bake.coffee' | ||
| lib_test_runners: | ||
| output: '../../lib/test_runners' | ||
| directories: 'src/test_runners' | ||
| tests: | ||
| _build | ||
| output: 'build' | ||
| bare: true | ||
| directories: 'test/easy-bake_core' | ||
| _test: | ||
| command: 'nodeunit' | ||
| files: '**/*.js' | ||
| ``` | ||
| ###Directories vs Files | ||
| Because CoffeeScript will retain the file hierarchy if an output directory is given, easy-bake allows you to flatten the hierarchy or to preserve it using directories + files vs directories-only. | ||
| For example, because directories are only specified in this case, the full directory structure will be preserved when the CoffeeScripts are compiled: | ||
| ``` | ||
| my_set_hierarchical: | ||
| output: '../js' | ||
| directories: 'my_directory' | ||
| ``` | ||
| Whereas, by specifying the files, you can compile them all into the output directory: | ||
| ``` | ||
| my_set_flat: | ||
| output: '../js' | ||
| directories: 'my_directory' | ||
| files: '**/*.coffee' | ||
| ``` | ||
| So if the hierarchy is like: | ||
| ``` | ||
| - my_directory | ||
| - sub_directory | ||
| - file1.coffee | ||
| - app.coffee | ||
| ``` | ||
| The results would be as follows for my_set_hierarchical: | ||
| ``` | ||
| - js | ||
| - sub_directory | ||
| - file1.js | ||
| - app.js | ||
| - my_directory | ||
| - sub_directory | ||
| - file1.coffee | ||
| - app.coffee | ||
| ``` | ||
| and for my_set_flat: | ||
| ``` | ||
| - js | ||
| - app.js | ||
| - file1.js | ||
| - my_directory | ||
| - sub_directory | ||
| - file1.coffee | ||
| - app.coffee | ||
| ``` | ||
| ###Relative Directories | ||
| All output directories are relative to a set's directory. | ||
| For example, the output directory in this example is resolved to be the same directory as the CoffeeScript config file root because 'src/test_runners' is two directories down the hierarchy: | ||
| ``` | ||
| lib_test_runners: | ||
| output: '../../lib/test_runners' | ||
| directories: 'src/test_runners' | ||
| ``` | ||
| Whereas, the output in this case will be in a new folder under 'test/easy-bake_core' (output to 'test/easy-bake_core/build'): | ||
| ``` | ||
| tests: | ||
| _build | ||
| output: 'build' | ||
| bare: true | ||
| directories: 'test/easy-bake_core' | ||
| ``` | ||
| Project Configuration | ||
| ----------------------- | ||
| It is best to preinstall a specific version of easy-bake in your package.json (to lock a specific version until the configuration format is locked at a major release): | ||
| ``` | ||
| "scripts": { | ||
| "postinstall": "bake postinstall" | ||
| }, | ||
| "devDependencies": { | ||
| "coffee-script": ">=1.3.3", | ||
| "easy-bake": "0.1.6" | ||
| }, | ||
| ``` | ||
| Install it: | ||
| ``` | ||
| npm install | ||
| ``` | ||
| Add a Bakefile.coffee or Bakefile.js to your root directory like: | ||
| ``` | ||
| module.exports = | ||
| library: | ||
| files: 'src/easy-bake.coffee' | ||
| ``` | ||
| And run it: | ||
| ``` | ||
| bake build | ||
| ``` | ||
| ###Known Issues | ||
| 1. if commands like bake, mbundle, or uglify give you errors, make sure 'node_modules/.bin' and 'node_modules/easy-bake/node_modules/.bin' are added to your PATH. For example in zsh, just add the following to ~/.zshrc: | ||
| ``` | ||
| export PATH=node_modules/.bin:node_modules/easy-bake/node_modules/.bin:$PATH | ||
| ``` | ||
| And that's it! You will have access to the following bake commands and options in your projects... | ||
| Testing | ||
| ----------------------- | ||
| If you are using TravisCI, you should add something like this to your project.json file: | ||
| ``` | ||
| "scripts": { | ||
| "postinstall": "bake postinstall", | ||
| "clean": "bake clean", | ||
| "build": "bake build", | ||
| "watch": "bake watch", | ||
| "test": "bake test -c" | ||
| }, | ||
| ``` | ||
| and a .travis.yaml to your project root file like: | ||
| ``` | ||
| language: node_js | ||
| node_js: | ||
| - 0.7 # development version of 0.8, may be unstable | ||
| before_script: | ||
| - "export PATH=node_modules/.bin:node_modules/easy-bake/node_modules/.bin:$PATH" | ||
| - "export DISPLAY=:99.0" | ||
| - "sh -e /etc/init.d/xvfb start" | ||
| ``` | ||
| and add test options to the set you want to test: | ||
| ``` | ||
| some_testing_group: | ||
| output: 'build' | ||
| directories: [ | ||
| 'test/some_tests' | ||
| 'test/some_more_tests' | ||
| ] | ||
| _test: | ||
| command: 'phantomjs' | ||
| runner: 'phantomjs-qunit-runner.js' | ||
| args: [60000] | ||
| files: '**/*.html' | ||
| ``` | ||
| ###Testing With PhantomJS | ||
| You will need to install phantom yourself since there is no npm package for it. Look here for the instructions: http://phantomjs.org/ or if you use homebrew: 'brew install phantomjs' | ||
| ``` | ||
| some_testing_group: | ||
| ... | ||
| _test: | ||
| command: 'phantomjs' | ||
| runner: 'phantomjs-qunit-runner.js' | ||
| files: '**/*.html' | ||
| ``` | ||
| **Note:** currently the library only has a test-runner for phantomjs-qunit-runner.js and phantomjs-jasmine-runner.js. Feel free to add more and to submit a pull request. | ||
| ###Testing With NodeUnit | ||
| Just include it as a development dependency to your package.json: | ||
| ``` | ||
| "devDependencies": { | ||
| "coffee-script": ">=1.3.3", | ||
| "nodeunit": "latest" | ||
| }, | ||
| ``` | ||
| ``` | ||
| some_testing_group: | ||
| ... | ||
| _test: | ||
| command: 'nodeunit' | ||
| files: '**/*.js' | ||
| ``` | ||
| ###Post Install | ||
| You can add commands to run after npm install. For example, you can copy and rename a file from a node module into a vendor directory: | ||
| ``` | ||
| _postinstall: | ||
| commands: [ | ||
| 'cp underscore vendor/underscore-latest.js' | ||
| ] | ||
| ``` | ||
| ###Publishing | ||
| Publishing to npm registry and NuGet Gallery are currently supported. | ||
| Using a post _build command, you should copy your files into the directories as follows: | ||
| ``` | ||
| - project_root | ||
| - package.json (for building) | ||
| - packages | ||
| - npm | ||
| - package.json (for distribution) | ||
| - your files | ||
| - nuget | ||
| - package.nuspec | ||
| - Content | ||
| - Scripts | ||
| - your files | ||
| ``` | ||
| The reason for this multiple layered structure is so you can separate your building environment (as project_root) from your distribution packages, which for example, may not require all of postinstall and build steps. | ||
| #NPM | ||
| Set up an account on npm registry: http://search.npmjs.org/ | ||
| #NuGet | ||
| Currently, NuGet has only been tested on Mac using Mono. If anyone would like to test and update on Windows or Linux, please submit a pull request. | ||
| Also, NuGet doesn't seem to handle removing and reinstalling packages from the command line so you might need to still perform some manual steps. | ||
| *Installation* | ||
| - Download and install mono: http://www.go-mono.com/mono-downloads/download.html | ||
| - Get easy-bake using 'npm install' (you need to list it in your package.json file) | ||
| - Register on NuGet Gallery: https://nuget.org | ||
| - Set up your API key. Get your key from your profile in NuGet (show your API key on your account page: https://nuget.org/account) and run 'node_modules/easy-bake/bin/nuget setApiKey YOUR_SECRET_KEY' | ||
| *Known Issues* | ||
| - If your package has never been created on Nuget Gallery, the first time, you may need to upload it manually: https://nuget.org/packages. | ||
| - Your package may not be deleted when using the --force option. You may need to go to the Gallery website and delete it. | ||
| - Your package may not be public after a push. You may need to go to the package page on the Gallery website and 'change its listing settings' | ||
| Release Notes | ||
| ----------------------- | ||
| ### 0.1.6 | ||
| - moved from cake commands to bake commands. Was: 'cake -c test' now: 'bake test -c' | ||
| - introduced convention of Bakefile.coffee or Bakefile.js for configuration | ||
| - removed options scoping | ||
| ### 0.1.5 | ||
| - added NuGet publishing support (requires Mono on Mac) - see above section "Publishing to NuGet" | ||
| - added publish_all command to publish to all locations | ||
| - renamed publish commands to: publish_git. publish_npm | ||
| - removed no_files_ok option | ||
| - made a test with clean automatically add a build option. Was: 'cake -c -b test' now: 'cake -c test' | ||
| ### 0.1.4 | ||
| - removed modes block and used _reserved} convention instead to reduce verbosity (means instead of {modes: test: options} -> {_test: options}) | ||
| - renamed postinstall to _postinstall using _{reserved} convention | ||
| ### 0.1.3 | ||
| - refactored functionality and spun off module-bundler project (and reversed arguments order of _publish) | ||
| - made dependent on a previous version of easy-bake | ||
| - allow an object + current working directory (cwd) instead of a filename to be used | ||
| Building the library | ||
| ----------------------- | ||
| ###Installing: | ||
| 1. install node.js: http://nodejs.org | ||
| 2. install node packages: 'npm install' | ||
| ###Commands: | ||
| Easy-bake uses easy-bake! Just use the above commands... |
+41
-7
| // Generated by CoffeeScript 1.3.3 | ||
| (function() { | ||
| var RUNNERS_ROOT, TEST_DEFAULT_TIMEOUT, coffeescript, eb, fs, path, print, spawn, timeLog, _, _base, _ref; | ||
| var INTERNAL_MODES, INTERNAL_SETS, MAX_MESSAGE_LENGTH, RUNNERS_ROOT, TEST_DEFAULT_TIMEOUT, coffeescript, eb, existsSync, fs, path, print, spawn, timeLog, _, _base, _ref; | ||
| fs = require('fs'); | ||
| path = require('path'); | ||
| existsSync = fs.existsSync || path.existsSync; | ||
| MAX_MESSAGE_LENGTH = 128; | ||
| timeLog = function(message) { | ||
@@ -17,6 +25,2 @@ return console.log("" + ((new Date).toLocaleTimeString()) + " - " + message); | ||
| fs = require('fs'); | ||
| path = require('path'); | ||
| coffeescript = require('coffee-script'); | ||
@@ -34,2 +38,6 @@ | ||
| INTERNAL_SETS = ['_postinstall']; | ||
| INTERNAL_MODES = ['_build', '_test']; | ||
| eb = this.eb = typeof exports !== 'undefined' ? exports : {}; | ||
@@ -77,6 +85,32 @@ | ||
| } | ||
| this._validateConfig(); | ||
| } | ||
| Oven.prototype._validateConfig = function() { | ||
| var mode_name, set, set_name, _ref1, _results; | ||
| if (!_.size(this.config)) { | ||
| console.log("warning: an empty config file was loaded: " + config_pathed_filename); | ||
| } | ||
| } | ||
| _ref1 = this.config; | ||
| _results = []; | ||
| for (set_name in _ref1) { | ||
| set = _ref1[set_name]; | ||
| if (set_name.startsWith('_') && !_.contains(INTERNAL_SETS, set_name)) { | ||
| console.log("warning: set name '" + set_name + "' is not a recognized internal set. It will be skipped."); | ||
| } | ||
| _results.push((function() { | ||
| var _results1; | ||
| _results1 = []; | ||
| for (mode_name in set) { | ||
| if (mode_name.startsWith('_') && !_.contains(INTERNAL_MODES, mode_name)) { | ||
| _results1.push(console.log("warning: mode name '" + mode_name + "' is not a recognized internal mode. It will be skipped.")); | ||
| } else { | ||
| _results1.push(void 0); | ||
| } | ||
| } | ||
| return _results1; | ||
| })()); | ||
| } | ||
| return _results; | ||
| }; | ||
@@ -295,3 +329,3 @@ Oven.prototype.postinstall = function(options, callback) { | ||
| file_groups = eb.utils.getOptionsFileGroups(set_options, this.config_dir, options); | ||
| if (set_options.runner && !path.existsSync(set_options.runner)) { | ||
| if (set_options.runner && !existsSync(set_options.runner)) { | ||
| set_options.runner = "" + RUNNERS_ROOT + "/" + set_options.runner; | ||
@@ -298,0 +332,0 @@ easy_bake_runner_used = true; |
+190
-139
| // Generated by CoffeeScript 1.3.3 | ||
| (function() { | ||
| var eb, et, fs, globber, mb, path, spawn, timeLog, uglifyjs, wrench, _; | ||
| var MAX_MESSAGE_LENGTH, eb, et, existsSync, fs, globber, mb, path, spawn, timeLog, uglifyjs, wrench, _; | ||
| fs = require('fs'); | ||
| path = require('path'); | ||
| existsSync = fs.existsSync || path.existsSync; | ||
| MAX_MESSAGE_LENGTH = 128; | ||
| timeLog = function(message) { | ||
@@ -114,6 +122,2 @@ return console.log("" + ((new Date).toLocaleTimeString()) + " - " + message); | ||
| fs = require('fs'); | ||
| path = require('path'); | ||
| _ = require('underscore'); | ||
@@ -156,3 +160,9 @@ | ||
| spawned.stderr.on('data', function(data) { | ||
| return process.stderr.write(data.toString()); | ||
| var message; | ||
| message = data.toString(); | ||
| if (message.search('is now called') >= 0) { | ||
| return; | ||
| } | ||
| process.stderr.write(message); | ||
| return typeof callback === "function" ? callback(1, this) : void 0; | ||
| }); | ||
@@ -166,3 +176,3 @@ spawned.stdout.on('data', function(data) { | ||
| if (!options.silent) { | ||
| timeLog("command succeeded '" + _this.command + " " + (eb.utils.relativeArguments(_this.args, _this.command_options.cwd).join(' ')) + "'"); | ||
| timeLog("command succeeded '" + _this.command + "'"); | ||
| } | ||
@@ -199,3 +209,3 @@ } else { | ||
| } | ||
| if (!path.existsSync(this.target())) { | ||
| if (!existsSync(this.target())) { | ||
| if (typeof callback === "function") { | ||
@@ -242,2 +252,12 @@ callback(0, this); | ||
| Copy.prototype.isRecursive = function() { | ||
| var index; | ||
| return (index = _.indexOf(this.args, '-r')) >= 0; | ||
| }; | ||
| Copy.prototype.isVersioned = function() { | ||
| var index; | ||
| return (index = _.indexOf(this.args, '-v')) >= 0; | ||
| }; | ||
| Copy.prototype.source = function() { | ||
@@ -248,7 +268,28 @@ return this.args[this.args.length - 2]; | ||
| Copy.prototype.target = function() { | ||
| return this.args[this.args.length - 1]; | ||
| var package_desc, package_desc_path, source_dir, target; | ||
| target = this.args[this.args.length - 1]; | ||
| if (this.isVersioned()) { | ||
| source_dir = path.dirname(this.source()); | ||
| package_desc_path = path.join(source_dir, 'package.json'); | ||
| if (!existsSync(package_desc_path)) { | ||
| console.log("no package.json found for publish_npm: " + (package_desc_path.replace(this.config_dir, ''))); | ||
| if (typeof callback === "function") { | ||
| callback(1); | ||
| } | ||
| return; | ||
| } | ||
| package_desc = require(package_desc_path); | ||
| if (target.endsWith('.min.js')) { | ||
| target = target.replace(/.min.js$/, "-" + package_desc.version + ".min.js"); | ||
| } else if (target.endsWith('-min.js')) { | ||
| target = target.replace(/-min.js$/, "-" + package_desc.version + "-min.js"); | ||
| } else { | ||
| target = target.replace(/.js$/, "-" + package_desc.version + ".js"); | ||
| } | ||
| } | ||
| return target; | ||
| }; | ||
| Copy.prototype.run = function(options, callback) { | ||
| var target_dir; | ||
| var source, target, target_dir; | ||
| if (options == null) { | ||
@@ -266,5 +307,14 @@ options = {}; | ||
| } | ||
| source = this.source(); | ||
| if (!existsSync(source)) { | ||
| console.log("command failed: cp " + (eb.utils.relativeArguments(this.args, this.command_options.cwd).join(' ')) + ". Source doesn't exist"); | ||
| if (typeof callback === "function") { | ||
| callback(1); | ||
| } | ||
| return; | ||
| } | ||
| target = this.target(); | ||
| try { | ||
| target_dir = path.dirname(this.target()); | ||
| if (!path.existsSync(target_dir)) { | ||
| target_dir = path.dirname(target); | ||
| if (!existsSync(target_dir)) { | ||
| wrench.mkdirSyncRecursive(target_dir, 0x1ff); | ||
@@ -277,11 +327,11 @@ } | ||
| } | ||
| if (this.args[0] === '-r') { | ||
| wrench.copyDirSyncRecursive(this.source(), this.target(), { | ||
| if (this.isRecursive()) { | ||
| wrench.copyDirSyncRecursive(source, target, { | ||
| preserve: true | ||
| }); | ||
| } else { | ||
| fs.writeFileSync(this.target(), fs.readFileSync(this.source(), 'utf8'), 'utf8'); | ||
| fs.writeFileSync(target, fs.readFileSync(source, 'utf8'), 'utf8'); | ||
| } | ||
| if (!options.silent) { | ||
| timeLog("copied " + (eb.utils.relativePath(this.target(), this.command_options.cwd))); | ||
| timeLog("copied " + (eb.utils.relativePath(target, this.command_options.cwd))); | ||
| } | ||
@@ -313,2 +363,20 @@ return typeof callback === "function" ? callback(0, this) : void 0; | ||
| Coffee.prototype.sourceFiles = function() { | ||
| var index, source_files; | ||
| source_files = _.clone(this.args); | ||
| if ((index = _.indexOf(source_files, '-w')) >= 0) { | ||
| source_files.splice(index, 1); | ||
| } | ||
| if ((index = _.indexOf(source_files, '-o')) >= 0) { | ||
| source_files.splice(index, 2); | ||
| } | ||
| if ((index = _.indexOf(source_files, '-j')) >= 0) { | ||
| source_files.splice(index, 2); | ||
| } | ||
| if ((index = _.indexOf(source_files, '-c')) >= 0) { | ||
| source_files.splice(index, 1); | ||
| } | ||
| return source_files; | ||
| }; | ||
| Coffee.prototype.targetDirectory = function() { | ||
@@ -351,3 +419,3 @@ var index; | ||
| Coffee.prototype.run = function(options, callback) { | ||
| var notify, spawned, | ||
| var args, compile, cwd, notify, watchDirectory, watchFile, watchFiles, watch_index, watch_list, watchers, | ||
| _this = this; | ||
@@ -366,6 +434,2 @@ if (options == null) { | ||
| } | ||
| spawned = spawn('coffee', this.args, eb.utils.extractCWD(this.command_options)); | ||
| spawned.stderr.on('data', function(data) { | ||
| return process.stderr.write(data.toString()); | ||
| }); | ||
| notify = function(code) { | ||
@@ -393,7 +457,9 @@ var build_directory, output_directory, output_names, pathed_build_name, post_build_queue, source_name, _i, _len; | ||
| timeLog("failed to compile " + (eb.utils.relativePath(pathed_build_name, _this.targetDirectory())) + " .... error code: " + code); | ||
| if (typeof callback === "function") { | ||
| callback(code, _this); | ||
| } | ||
| return; | ||
| } | ||
| if (_this.isCompressed()) { | ||
| post_build_queue.push(new eb.command.UglifyJS(['-o', eb.utils.compressedName(pathed_build_name), pathed_build_name], { | ||
| cwd: _this.targetDirectory() | ||
| })); | ||
| post_build_queue.push(new eb.command.RunCommand('uglifyjs', ['-o', eb.utils.compressedName(pathed_build_name), pathed_build_name], null)); | ||
| } | ||
@@ -415,11 +481,89 @@ } | ||
| }; | ||
| if (options.watch) { | ||
| return spawned.stdout.on('data', function(data) { | ||
| return notify(0); | ||
| watch_index = _.indexOf(this.args, '-w'); | ||
| if (watch_index >= 0) { | ||
| args = _.clone(this.args); | ||
| args.splice(watch_index, 1); | ||
| watch_list = this.sourceFiles(); | ||
| watchers = {}; | ||
| } else { | ||
| args = this.args; | ||
| } | ||
| cwd = eb.utils.extractCWD(this.command_options); | ||
| watchFile = function(file) { | ||
| var stats; | ||
| if (watchers[file]) { | ||
| watchers[file].close(); | ||
| } | ||
| stats = fs.statSync(file); | ||
| return watchers[file] = fs.watch(file, function() { | ||
| var now_stats; | ||
| now_stats = fs.statSync(file); | ||
| if (stats.mtime.getTime() === now_stats.mtime.getTime()) { | ||
| return; | ||
| } | ||
| stats = now_stats; | ||
| return compile(); | ||
| }); | ||
| } else { | ||
| }; | ||
| watchFiles = function(files) { | ||
| var file, source, watcher, _i, _len, _results; | ||
| for (source in watchers) { | ||
| watcher = watchers[source]; | ||
| watcher.close(); | ||
| } | ||
| watchers = {}; | ||
| _results = []; | ||
| for (_i = 0, _len = files.length; _i < _len; _i++) { | ||
| file = files[_i]; | ||
| try { | ||
| _results.push(watchFile(file)); | ||
| } catch (e) { | ||
| if (e.code !== 'ENOENT') { | ||
| throw e; | ||
| } | ||
| _results.push(process.stderr.write("coffee: " + (file.replace(this.command_options.cwd, '')) + " doesn't exist. Skipping")); | ||
| } | ||
| } | ||
| return _results; | ||
| }; | ||
| watchDirectory = function(directory) { | ||
| var update; | ||
| update = function() { | ||
| watch_list = []; | ||
| globber.glob("" + directory + "/**/*.coffee").forEach(function(pathed_file) { | ||
| return watch_list.push(pathed_file); | ||
| }); | ||
| return watchFiles(watch_list); | ||
| }; | ||
| fs.watch(directory, update); | ||
| return update(); | ||
| }; | ||
| compile = function() { | ||
| var errors, spawned; | ||
| errors = false; | ||
| spawned = spawn('coffee', args, cwd); | ||
| spawned.stderr.on('data', function(data) { | ||
| var message; | ||
| message = data.toString(); | ||
| if (message.search('is now called') >= 0) { | ||
| return; | ||
| } | ||
| if (errors) { | ||
| return; | ||
| } | ||
| errors = true; | ||
| return process.stderr.write(message); | ||
| }); | ||
| return spawned.on('exit', function(code) { | ||
| return notify(code); | ||
| }); | ||
| }; | ||
| if (watch_list) { | ||
| if (watch_list.length === 1 && fs.statSync(watch_list[0]).isDirectory()) { | ||
| watchDirectory(watch_list[0]); | ||
| } else { | ||
| watchFiles(watch_list); | ||
| } | ||
| } | ||
| return compile(); | ||
| }; | ||
@@ -431,58 +575,2 @@ | ||
| eb.command.UglifyJS = (function() { | ||
| function UglifyJS(args, command_options) { | ||
| if (args == null) { | ||
| args = []; | ||
| } | ||
| this.command_options = command_options != null ? command_options : {}; | ||
| this.args = eb.utils.resolveArguments(args, this.command_options.cwd); | ||
| } | ||
| UglifyJS.prototype.outputName = function() { | ||
| var index; | ||
| if ((index = _.indexOf(this.args, '-o')) >= 0) { | ||
| return "" + this.args[index + 1]; | ||
| } else { | ||
| return ''; | ||
| } | ||
| }; | ||
| UglifyJS.prototype.run = function(options, callback) { | ||
| var ast, header, header_index, scoped_command, src; | ||
| if (options == null) { | ||
| options = {}; | ||
| } | ||
| scoped_command = 'node_modules/.bin/uglifyjs'; | ||
| if (options.preview || options.verbose) { | ||
| console.log("" + scoped_command + " " + (eb.utils.relativeArguments(this.args, this.command_options.cwd).join(' '))); | ||
| if (options.preview) { | ||
| if (typeof callback === "function") { | ||
| callback(0, this); | ||
| } | ||
| return; | ||
| } | ||
| } | ||
| try { | ||
| src = fs.readFileSync(this.args[2], 'utf8'); | ||
| header = (header_index = src.indexOf('*/')) > 0 ? src.substr(0, header_index + 2) : ''; | ||
| ast = uglifyjs.parser.parse(src); | ||
| ast = uglifyjs.uglify.ast_mangle(ast); | ||
| ast = uglifyjs.uglify.ast_squeeze(ast); | ||
| src = header + uglifyjs.uglify.gen_code(ast) + ';'; | ||
| fs.writeFileSync(this.args[1], src, 'utf8'); | ||
| if (!options.silent) { | ||
| timeLog("compressed " + (eb.utils.relativePath(this.outputName(), this.command_options.cwd))); | ||
| } | ||
| return typeof callback === "function" ? callback(0, this) : void 0; | ||
| } catch (e) { | ||
| timeLog("failed to minify " + (eb.utils.relativePath(this.outputName(), this.command_options.cwd)) + " .... error code: " + e.code); | ||
| return typeof callback === "function" ? callback(e.code, this) : void 0; | ||
| } | ||
| }; | ||
| return UglifyJS; | ||
| })(); | ||
| eb.command.RunTest = (function() { | ||
@@ -529,2 +617,6 @@ | ||
| } | ||
| if (this.command === 'nodeunit') { | ||
| scoped_args.unshift('machineout'); | ||
| scoped_args.unshift('--reporter'); | ||
| } | ||
| if (options.preview || options.verbose) { | ||
@@ -540,2 +632,10 @@ console.log("" + scoped_command + " " + (scoped_args.join(' '))); | ||
| spawned = spawn(scoped_command, scoped_args); | ||
| spawned.stdout.on('data', function(data) { | ||
| var message; | ||
| message = data.toString(); | ||
| if (message.length > MAX_MESSAGE_LENGTH) { | ||
| message = "" + (message.slice(0, MAX_MESSAGE_LENGTH)) + " ...[MORE]\n"; | ||
| } | ||
| return process.stdout.write("*test: " + message); | ||
| }); | ||
| return spawned.on('exit', function(code) { | ||
@@ -601,51 +701,2 @@ _this.exit_code = code; | ||
| eb.command.ModuleBundle = (function() { | ||
| function ModuleBundle(args, command_options) { | ||
| if (args == null) { | ||
| args = []; | ||
| } | ||
| this.command_options = command_options != null ? command_options : {}; | ||
| this.args = eb.utils.resolveArguments(args, this.command_options.cwd); | ||
| } | ||
| ModuleBundle.prototype.run = function(options, callback) { | ||
| var filename, scoped_command, _i, _len, _ref; | ||
| if (options == null) { | ||
| options = {}; | ||
| } | ||
| scoped_command = 'node_modules/easy-bake/node_modules/.bin/mbundle'; | ||
| if (options.preview || options.verbose) { | ||
| console.log("" + scoped_command + " " + (eb.utils.relativeArguments(this.args, this.command_options.cwd).join(' '))); | ||
| if (options.preview) { | ||
| if (typeof callback === "function") { | ||
| callback(0, this); | ||
| } | ||
| return; | ||
| } | ||
| } | ||
| try { | ||
| _ref = this.args; | ||
| for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
| filename = _ref[_i]; | ||
| if (mb.writeBundlesSync(filename, { | ||
| cwd: this.command_options.cwd | ||
| })) { | ||
| if (!options.silent) { | ||
| timeLog("bundled " + filename); | ||
| } | ||
| } else { | ||
| if (!options.silent) { | ||
| timeLog("failed to bundle " + filename); | ||
| } | ||
| } | ||
| } | ||
| return typeof callback === "function" ? callback(0, this) : void 0; | ||
| } catch (_error) {} | ||
| }; | ||
| return ModuleBundle; | ||
| })(); | ||
| eb.command.PublishGit = (function() { | ||
@@ -690,7 +741,7 @@ | ||
| package_path = path.join(this.command_options.cwd, 'packages', 'npm'); | ||
| if (!path.existsSync(package_path)) { | ||
| if (!existsSync(package_path)) { | ||
| package_path = this.config_dir; | ||
| } | ||
| package_desc_path = path.join(package_path, 'package.json'); | ||
| if (!path.existsSync(package_desc_path)) { | ||
| if (!existsSync(package_desc_path)) { | ||
| console.log("no package.json found for publish_npm: " + (package_desc_path.replace(this.config_dir, ''))); | ||
@@ -710,3 +761,3 @@ if (typeof callback === "function") { | ||
| } | ||
| if (!path.existsSync(path.join(package_path, package_desc.main))) { | ||
| if (!existsSync(path.join(package_path, package_desc.main))) { | ||
| console.log("skipping publish_npm for: " + package_desc_path + " (main file missing...do you need to build it?)"); | ||
@@ -751,3 +802,3 @@ if (typeof callback === "function") { | ||
| package_path = path.join(this.command_options.cwd, 'packages', 'nuget'); | ||
| if (!path.existsSync(package_path)) { | ||
| if (!existsSync(package_path)) { | ||
| if (typeof callback === "function") { | ||
@@ -759,3 +810,3 @@ callback(0); | ||
| package_desc_path = path.join(package_path, 'package.nuspec'); | ||
| if (!path.existsSync(package_desc_path)) { | ||
| if (!existsSync(package_desc_path)) { | ||
| console.log("no package.nuspec found for publishNuGet: " + (package_desc_path.replace(this.config_dir, ''))); | ||
@@ -796,3 +847,3 @@ if (typeof callback === "function") { | ||
| pathed_filename = pathed_filename.replace(/\\/g, '\/'); | ||
| if (!path.existsSync(pathed_filename)) { | ||
| if (!existsSync(pathed_filename)) { | ||
| console.log("skipping publish_npm for: " + package_desc_path + " (main file missing...do you need to build it?)"); | ||
@@ -799,0 +850,0 @@ if (typeof callback === "function") { |
| // Generated by CoffeeScript 1.3.3 | ||
| (function() { | ||
| var KNOWN_SYSTEM_FILES, eb, fs, globber, mb, path, _; | ||
| var KNOWN_SYSTEM_FILES, eb, existsSync, fs, globber, mb, path, _; | ||
@@ -9,2 +9,4 @@ fs = require('fs'); | ||
| existsSync = fs.existsSync || path.existsSync; | ||
| _ = require('underscore'); | ||
@@ -63,6 +65,2 @@ | ||
| }))); | ||
| } else if (command_name === 'mbundle') { | ||
| _results.push(queue.push(new eb.command.ModuleBundle(command_args, { | ||
| cwd: cwd | ||
| }))); | ||
| } else { | ||
@@ -97,3 +95,3 @@ _results.push(queue.push(new eb.command.RunCommand(command_name, command_args, { | ||
| }); | ||
| if (!path.existsSync(directory)) { | ||
| if (!existsSync(directory)) { | ||
| console.log("warning: directory is missing " + unpathed_dir); | ||
@@ -100,0 +98,0 @@ continue; |
+2
-2
| { | ||
| "author" : {"name": "Kevin Malakoff", "url": "https://github.com/kmalakoff"}, | ||
| "name" : "easy-bake", | ||
| "description" : "EasyBake provide YAML-based Cakefile helpers for common CoffeeScript library packaging functionality", | ||
| "description" : "EasyBake provides an efficient environment for CoffeeScript library developers: CoffeeScript/Javascript-based configuration files (no coding needed), workflow (build, watch, clean, preview) tests (QUnit, Jasime, NodeUnit, server-side emulation with ModuleBundler), publishing (git, npm, NuGet). Replace your Cakefile with a Bakefile today!", | ||
| "keywords" : ["easybake", "easy-bake", "coffeescript", "library", "build", "packaging", "package", "utility", "util"], | ||
@@ -30,3 +30,3 @@ | ||
| }, | ||
| "version" : "0.1.6-pre" | ||
| "version" : "0.1.6" | ||
| } |
Sorry, the diff of this file is not supported yet
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
693387
1.99%10
11.11%1577
5.56%1
-50%359
Infinity%15
25%