Permalink
Browse files

* recompile to js and link package to it

  • Loading branch information...
1 parent 84a827e commit ffde88a935b88bbdad9d7e58696e63b7f27bab1a @Meettya committed Mar 17, 2013
Showing with 1,298 additions and 14 deletions.
  1. +25 −0 Cakefile
  2. +4 −0 History.md
  3. +2 −2 README.md
  4. +1 −1 README_ru.md
  5. +15 −0 cake_dep/colorizer.coffee
  6. +50 −0 cake_dep/command.coffee
  7. +117 −0 lib/app.js
  8. +252 −0 lib/bundle_processor.js
  9. +164 −0 lib/di_container.js
  10. +185 −0 lib/file_processor.js
  11. +346 −0 lib/gatherer.js
  12. +125 −0 lib/packer.js
  13. +12 −11 package.json
View
@@ -0,0 +1,25 @@
+###
+New Cakefile with good organization
+###
+
+path = require 'path'
+fs = require 'fs'
+
+root_path = path.dirname fs.realpathSync __filename
+
+paths =
+ cake_dep : 'cake_dep'
+ src_dir : 'src'
+ lib_dir : 'lib'
+
+# extend path with root
+for own key, value of paths
+ paths[key] = path.join root_path, value
+ null
+
+# add commands
+commands = require path.join paths.cake_dep, 'command'
+
+task 'build', 'build coffee to js', build = (cb) ->
+ commands.build_coffee cb, paths.src_dir, paths.lib_dir, /\.coffee$/
+
View
@@ -1,3 +1,7 @@
+## 0.2.9 / 2013/03-17 06:45 PM
+
+ - Re-compile to js (sorry, I forgot) and link to it
+
## 0.2.7 / 2013/03-17 02:00 PM
- Add Handlebars example, update docs, add test
View
@@ -3,7 +3,7 @@
YA ComonJS to browser packer tool, well-suited for tiny widgets by small overhead and big app by module replacement, node-environment emulations and multi-exports.
-## what supported?
+## what in a box?
- `.js` - just put it to bundle as is
- `.json` - wrap in `module.exports` as node do it on `require('file.json')`
@@ -17,7 +17,7 @@ This possibility almost exists - **clinch** from 0.2.5 have API for third party
More info and example - below at description of method `registerProcessor()`
-For additional example - see [using Handelbars](https://github.com/Meettya/clinch/wiki/Handlebars-template-engine-support)- yap, now [Hadlebars](http://handlebarsjs.com/) supported as add-on.
+For additional example - see [using Handelbars](https://github.com/Meettya/clinch/wiki/Handlebars-template-engine-support) - yap, now [Hadlebars](http://handlebarsjs.com/) supported as add-on.
### More about .jade
View
@@ -6,7 +6,7 @@
Он отлично продходит для больших приложений благодаря возможности подмены кода модулей, эмуляции глобальных node-переменых и реализации экспорта нескольких объектов сразу.
-## что поддерживается?
+## что в коробке?
- `.js` - просто упаковывается в бандл как есть
- `.json` - заворачивается в `module.exports` как node и делает при `require('file.json')`
@@ -0,0 +1,15 @@
+###
+Add some color to console output
+###
+
+module.exports = require('colors').setTheme
+ input: 'grey'
+ verbose: 'cyan'
+ prompt: 'grey'
+ info: 'green'
+ data: 'grey'
+ help: 'cyan'
+ warn: 'magenta'
+ out: 'yellow'
+ debug: 'blue'
+ error: 'red'
@@ -0,0 +1,50 @@
+###
+This is command library
+
+to wipe out Cakefile from realization
+###
+
+path = require 'path'
+fs = require 'fs'
+{spawn, exec} = require 'child_process'
+
+# add color to console
+module.exports = require './colorizer'
+
+###
+Just proc extender
+###
+proc_extender = (cb, proc) =>
+ proc.stderr.on 'data', (buffer) -> console.log "#{buffer}".error
+ # proc.stdout.on 'data', (buffer) -> console.log "#{buffer}".info
+ proc.on 'exit', (status) ->
+ process.exit(1) if status != 0
+ cb() if typeof cb is 'function'
+ null
+
+# Run a CoffeeScript through our node/coffee interpreter.
+run_coffee = (args, cb) =>
+ proc_extender cb, spawn 'node', ['./node_modules/.bin/coffee'].concat args
+
+###
+Generate array of files from directory, selected on filter as RegExp
+###
+make_files_list = (in_dir, filter_re) ->
+ for file in fs.readdirSync in_dir when file.match filter_re
+ path.join in_dir, file
+
+###
+CoffeeScript-to-JavaScript builder
+###
+build_coffee = (cb, source_dir, result_dir, filter) ->
+ files = make_files_list source_dir, filter
+ run_coffee ['-c', '-o', result_dir].concat(files), ->
+ console.log ' -> build done'.info
+ cb() if typeof cb is 'function'
+ null
+
+
+module.exports =
+ build_coffee : build_coffee
+
+
View
@@ -0,0 +1,117 @@
+// Generated by CoffeeScript 1.4.0
+
+/*
+This is main entry point for Clinch - API and setting here
+*/
+
+
+(function() {
+ var Clinch, DIContainer, _;
+
+ _ = require('lodash');
+
+ DIContainer = require("./di_container");
+
+ Clinch = (function() {
+
+ function Clinch(_options_) {
+ this._options_ = _options_ != null ? _options_ : {};
+ this._do_logging_ = (this._options_.log != null) && this._options_.log === true && ((typeof console !== "undefined" && console !== null ? console.log : void 0) != null) ? true : false;
+ this._dic_obj_ = new DIContainer();
+ this._configureComponents();
+ }
+
+ /*
+ This method create browser package with given configuration
+ actually its just proxy all to packer
+ */
+
+
+ Clinch.prototype.buldPackage = function(package_name, package_config, main_cb) {
+ var packer;
+ packer = this._dic_obj_.getComponent('Packer');
+ return packer.buldPackage(package_name, package_config, main_cb);
+ };
+
+ /*
+ This method force flush cache
+ */
+
+
+ Clinch.prototype.flushCache = function() {
+ var gatherer;
+ gatherer = this._dic_obj_.getComponent('Gatherer');
+ return gatherer.resetCaches();
+ };
+
+ /*
+ This method add third party file processor to Clinch
+ */
+
+
+ Clinch.prototype.registerProcessor = function(file_extention, processor_fn) {
+ var processor_obj;
+ if (!_.isString(file_extention)) {
+ throw TypeError("file extention must be a String but get |" + file_extention + "|");
+ }
+ if (!_.isFunction(processor_fn)) {
+ throw TypeError("processor must be a Function but get |" + processor_fn + "|");
+ }
+ processor_obj = {};
+ processor_obj[file_extention] = processor_fn;
+ return this._dic_obj_.addComponentsSettings('FileProcessor', 'third_party_compilers', processor_obj);
+ };
+
+ /*
+ This internal method used to configure components in DiC
+ */
+
+
+ Clinch.prototype._configureComponents = function() {
+ var jade, log, packer_settings, setting_name, _i, _len, _ref;
+ log = !!this._options_.log;
+ /*
+ set jade compiler settings for jade.compile()
+ jade =
+ pretty : on
+ self : on
+ compileDebug : off
+ */
+
+ if (jade = this._options_.jade) {
+ this._dic_obj_.setComponentsSettings({
+ FileProcessor: {
+ jade: jade,
+ log: log
+ }
+ });
+ }
+ /*
+ set packer settings
+ strict : on
+ inject : on
+ */
+
+ packer_settings = {
+ log: log
+ };
+ _ref = ['strict', 'inject'];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ setting_name = _ref[_i];
+ if (this._options_[setting_name] != null) {
+ packer_settings[setting_name] = this._options_[setting_name];
+ }
+ }
+ this._dic_obj_.setComponentsSettings({
+ Packer: packer_settings
+ });
+ return null;
+ };
+
+ return Clinch;
+
+ })();
+
+ module.exports = Clinch;
+
+}).call(this);
Oops, something went wrong. Retry.

0 comments on commit ffde88a

Please sign in to comment.