Permalink
Browse files

settings in package.json, example

  • Loading branch information...
1 parent b835305 commit 262cca2d709d6349ea010118a84b7cb7e9ecdde1 @jgallen23 committed Feb 20, 2012
View
@@ -1,3 +1,3 @@
.DS_Store
-node_modules
+/node_modules/
.coverage_data
View
@@ -1,10 +1,11 @@
v0.0.3:
- - figure out how to handle AMD modules (aug) @done(2012-02-19)
- - --verify (run in vm context) @done(2012-02-19)
+ - option to no-wrap if amd already set (aug) @done(2012-02-20)
- Cs set up examples as unit tests
- create history.md
- test on node 0.4
- update docs for package.json integration
+ - figure out how to handle AMD modules (aug) @done(2012-02-19)
+ - --verify (run in vm context) @done(2012-02-19)
- sketch out flow @done(2012-02-18)
- refactor file library @done(2012-02-19)
- refactor library to be chainable (don't pass in index file) @done(2012-02-19)
@@ -13,14 +14,18 @@ v0.0.3:
- a config file that can be checked into repo (or set in package.json) to let clientside know how to build @done(2012-02-18)
- overview of what each class does @done(2012-02-18)
- need library or should file be able to handle everything? @done(2012-02-18)
+ - Client side examples. Look at browserify @done(2012-02-19)
- some way to shim server requires (requires('request')) @done(2012-02-18)
- finish unit tests @done(2012-02-18)
- deptree @done(2012-02-18)
- library @done(2012-02-18)
- file @done(2012-02-18)
- wrap @done(2012-02-18)
Future:
- - Client side examples. Look at browserify
+ - update unit tests
+ - read package.json for dependencies
+ - extract
+ - --stats to show filesize (lint?)
- think about full middleware (replace require, module.exports)
- clientside object - be able to turn off require check, module.exports if browser compatible version already exists
- file don't require library, but can be set
View
@@ -7,7 +7,8 @@ var wrap = require('./wrap');
var lastId = 0;
var defaults = {
- prefix: 'cs'
+ prefix: 'cs',
+ modify: true
};
var File = function(filename, options) {
@@ -16,7 +17,11 @@ var File = function(filename, options) {
filename = null;
}
this.options = aug({}, defaults, options);
- this.generateId();
+ if (this.options.id) {
+ this.id = this.options.id
+ } else {
+ this.generateId();
+ }
if (filename) {
this.filename = filename;
this.dirname = path.dirname(filename);
@@ -85,13 +90,15 @@ File.prototype._parse = function() {
};
File.prototype.build = function() {
- //TODO get burrito working
- //regex
- //this.replaceRequires();
- this.replaceModuleExports();
- //burrito
- //this.parse();
- this.wrap();
+ if (this.options.modify) {
+ //TODO get burrito working
+ //regex
+ //this.replaceRequires();
+ this.replaceModuleExports();
+ //burrito
+ //this.parse();
+ this.wrap();
+ }
return this.source;
};
View
@@ -10,11 +10,13 @@ var Library = function(options) {
var defaults = {
name: 'moduleName',
shim: {},
- files: {}
+ files: {},
+ settings: {}
};
this.meta = aug({}, defaults, options);
this.depTree = new DepTree();
this.shims = {};
+ this.settings = {};
if (this.meta.main) {
this.meta.main = path.resolve(this.meta.main);
@@ -26,6 +28,7 @@ var Library = function(options) {
this.dirname = process.cwd();
}
+ this.processSettings();
this.processShims();
//must be after process shims
@@ -39,13 +42,20 @@ Library.prototype.addFile = function(filename, key) {
key = key || filename;
var f = this.meta.files[key];
if (!f) {
- f = new File(filename);
+ f = new File(filename, this.settings[key]);
this.meta.files[key] = f;
this.addDependencies(f);
}
return f;
};
+Library.prototype.processSettings = function() {
+ for (var key in this.meta.settings) {
+ var filepath = resolve(key, this.dirname);
+ this.settings[filepath] = this.meta.settings[key];
+ }
+};
+
Library.prototype.processShims = function() {
for (var key in this.meta.shim) {
var filepath = this.meta.shim[key];
View
@@ -1,6 +1,6 @@
module.exports = function(variableName, source, returns) {
if (!returns) returns = 'exports';
- var start = 'var '+variableName+' = (function(exports, module) {\n';
- var end = '\nreturn '+returns+';\n})({}, true);';
+ var start = 'var '+variableName+' = (function(exports) {\n';
+ var end = '\nreturn '+returns+';\n})({});';
return start + source + end;
};
@@ -1,12 +0,0 @@
-<html>
- <head>
- <title></title>
- <script src="out.js"></script>
- <script>
- console.log(aug);
- console.log(aug({ test: 1}, {test: 2, test2: 3}));
- </script>
- </head>
- <body>
- </body>
-</html>
@@ -1,27 +0,0 @@
-var aug = (function(exports, module) {
-var cs0 = (function(exports, module) {
-!function (name, definition) {
- if (typeof module != 'undefined' && exports) exports = definition();
- else if (typeof define == 'function' && typeof define.amd == 'object') define(definition);
- else this[name] = definition();
-}('aug', function() {
-
-var aug = function __aug() {
- var args = Array.prototype.slice.call(arguments);
- var org = args.shift();
- for (var i = 0, c = args.length; i < c; i++) {
- var prop = args[i];
- for (var name in prop) {
- org[name] = prop[name];
- }
- }
- return org;
-};
-
-return aug;
-});
-
-return exports;
-})({}, true);
-return cs0;
-})({}, true);
@@ -0,0 +1,2 @@
+all:
+ @../../../bin/clientside > dist/awesomecalc.js
@@ -0,0 +1,59 @@
+var AwesomeCalc = (function(exports) {
+var cs1 = (function(exports) {
+
+exports.add = function(num1, num2) {
+ return num1 + num2;
+}
+
+return exports;
+})({});
+/*!
+ * aug.js - A javascript library to extend existing objects and prototypes
+ * v0.0.1
+ * https://github.com/jgallen23/aug
+ * copyright JGA 2011
+ * MIT License
+ */
+
+!function (name, definition) {
+ if (typeof module != 'undefined' && module.exports) module.exports = definition();
+ else if (typeof define == 'function' && typeof define.amd == 'object') define(definition);
+ else this[name] = definition();
+}('aug', function() {
+
+var aug = function __aug() {
+ var args = Array.prototype.slice.call(arguments);
+ var org = args.shift();
+ for (var i = 0, c = args.length; i < c; i++) {
+ var prop = args[i];
+ for (var name in prop) {
+ org[name] = prop[name];
+ }
+ }
+ return org;
+};
+
+return aug;
+});
+
+var cs0 = (function(exports) {
+var calc = cs1;
+var aug = window.aug;
+
+var Calculator = function(options) {
+ var defaults = {
+ debug: false
+ }
+ this.options = aug({}, defaults, options);
+}
+
+Calculator.prototype.add = function(num1, num2) {
+ return calc.add(num1, num2);
+}
+
+exports = Calculator;
+
+return exports;
+})({});
+return cs0;
+})({});
@@ -0,0 +1,15 @@
+var calc = require('calc');
+var aug = require('aug');
+
+var Calculator = function(options) {
+ var defaults = {
+ debug: false
+ }
+ this.options = aug({}, defaults, options);
+}
+
+Calculator.prototype.add = function(num1, num2) {
+ return calc.add(num1, num2);
+}
+
+module.exports = Calculator;
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
@@ -0,0 +1,12 @@
+{
+ "name": "awesomeCalc",
+ "clientside": {
+ "name": "AwesomeCalc",
+ "settings": {
+ "aug": {
+ "modify": false,
+ "id": "window.aug"
+ }
+ }
+ }
+}
@@ -0,0 +1,12 @@
+<html>
+ <head>
+ <title></title>
+ <script src="../dist/awesomecalc.js"></script>
+ <script>
+ var calc = new AwesomeCalc();
+ console.log(calc.add(1, 2));
+ </script>
+ </head>
+ <body>
+ </body>
+</html>

0 comments on commit 262cca2

Please sign in to comment.