Permalink
Browse files

Removed builder class which was not clearly defined anyway.

Command line file deals with coordinating separate parts now.
Updated component tests to deal with several regressions.
  • Loading branch information...
mosen
mosen committed Oct 17, 2011
1 parent b49bd10 commit 9924f8f36d03fb0371e361e8445616e6207dd5c6
Showing with 110 additions and 174 deletions.
  1. +25 −5 bin/cli.js
  2. +0 −155 lib/builder.js
  3. +11 −1 lib/buildspec.js
  4. +43 −3 lib/component.js
  5. +13 −10 lib/queues.js
  6. +18 −0 test/component.test.js
View
@@ -9,8 +9,11 @@ var path = require('path'),
fs = require('fs'),
util = require('util'),
events = require('events'),
- component = require('../lib/component.js'),
- Builder = require('../lib/builder.js').Builder;
+ Queue = require('buildy/lib/queue').Queue,
+ Buildy = require('buildy').Buildy,
+ Component = require('../lib/component.js').Component,
+ queues = require('../lib/queues.js');
+// Builder = require('../lib/builder.js').Builder;
var buildFileName = "build.json";
@@ -89,9 +92,10 @@ if (buildDirs.length === 0) {
path.exists(buildFilePath, function(exists) {
if (exists) {
- var buildComponent = component.Component(buildFilePath);
- var builder = new Builder(buildComponent);
- builder.run();
+ var c = Component(buildFilePath);
+// var builder = new Builder(buildComponent);
+// builder.run();
+ build(c);
} else {
console.log('Couldnt find a build file at ' + buildFilePath + ', skipping...');
}
@@ -100,6 +104,22 @@ if (buildDirs.length === 0) {
}
}
+function build(component) {
+ var taskQueues = [];
+
+ taskQueues.push(queues._createSourceQueue(component));
+
+ if (component.skinnable) {
+ taskQueues.push(queues._createSkinsQueue(component));
+ taskQueues.push(queues._createAssetsQueue(component));
+ }
+ //taskQueues.push(queues._createDocsQueue(component));
+
+ taskQueues.forEach(function each_queue(moduleQueue) {
+ var worker = new Buildy();
+ moduleQueue.run(worker);
+ }, this);
+}
// Modified from vowsjs
//
View
@@ -1,155 +0,0 @@
-"use strict";
-
-var Queue = require('buildy/lib/queue').Queue,
- Buildy = require('buildy').Buildy,
- path = require('path'),
- module_path = __dirname;
-
-/**
- * The builder wraps several yui specific task chains, taking a component object and then
- * executing these chains against the object.
- *
- * @class Builder
- * @constructor
- * @param component {Component} component object.
- */
-function Builder(component) {
- this._component = component;
-
- this._buildy = new Buildy();
- this._taskQueues = [];
-
- var jsQueue = new Queue('build source:' + this._component._config.name);
- this._createSourceQueue(jsQueue);
- this._taskQueues.push(jsQueue);
-
- if (this._component._config.details.skinnable === true) {
- var cssQueue = new Queue('build assets:' + this._component._config.name);
- this._createSkinQueue(cssQueue);
- this._taskQueues.push(cssQueue);
-
- var assetsQueue = new Queue('copy extra assets:' + this._component._config.name);
- this._createAssetsQueue(assetsQueue);
- this._taskQueues.push(assetsQueue);
- }
-}
-
-Builder.prototype = {
-
- _template : path.resolve(path.join(module_path, '/../templates/moduletemplate.handlebars')),
-
- _component : null,
-
- _taskQueues : null,
-
- _buildy : null,
-
-// _createSourceQueue : function(q) {
-// var component = this._component,
-// filename_debug = component.getFilename('debug'),
-// filename_core = component.getFilename('core'),
-// filename_min = component.getFilename('min'),
-// module_template = this._template,
-// component_name = component._config.name,
-// component_ver = component._config.version,
-// component_detail= component.getAllDetailsString();
-//
-// console.log('Building component: ' + component_name + ' v' + component_ver);
-// //console.log(component_detail);
-// console.log('Outputting files:');
-// console.log("\tdebug: " + filename_debug);
-// console.log("\tcore: " + filename_core);
-// console.log("\tmin: " + filename_min);
-// console.log("Builder output follows...");
-//
-// q.task('files', component.getSourceFiles()) // all of these synchronous
-// .task('concat')
-// .task('jslint')
-// .task('template', {
-// templateFile: module_template,
-// model: {
-// yuivar : 'Y',
-// component : component._config.name,
-// version : component._config.version,
-// details : component.getAllDetailsString()
-// }
-// })
-// .task('fork', {
-// 'debug code' : function(b) {
-// this.task('write', { name: filename_debug })
-// .task('log')
-// .run(b);
-// },
-// 'core code' : function(b) {
-// this.task('replace', {
-// regex: '^.*?(?:logger|Y.log).*?(?:;|\\).*;|(?:\r?\n.*?)*?\\).*;).*;?.*?\r?\n',
-// replace: '',
-// flags: 'mg'
-// })
-// .task('fork', {
-// 'write core' : function(b) {
-// this.task('write', {
-// name: filename_core
-// })
-// .run(b);
-// },
-// 'minified code' : function(b) {
-// this.task('minify')
-// .task('write', {
-// name: filename_min
-// })
-// .run(b);
-// }
-// }).run(b);
-// }
-// });
-// },
-//
-// _createSkinQueue : function(q) {
-// var component = this._component,
-// filename_skin = component.getSkinFilename('sam'),
-// filename_core = component.getSkinCoreFilename(),
-// filename_min_out = component.getSkinFilename('sam', true);
-//
-// console.log('Outputting files:');
-// console.log("\tmin: " + filename_min_out);
-//
-// q.task('files', [filename_skin, filename_core])
-// .task('concat')
-// .task('csslint')
-// .task('cssminify')
-// .task('write', {
-// name: filename_min_out
-// });
-// },
-//
-// _createAssetsQueue : function(q) {
-// var component = this._component,
-// assets_source = component.getAssetsDir(),
-// assets_dest = component.getAssetsDir(true);
-//
-// console.log('Copying assets:');
-// console.log("\tfrom: " + assets_source);
-// console.log("\tto: " + assets_dest);
-//
-// q.task('copy', {
-// src: [
-// assets_source + '/*'
-// ],
-// dest: assets_dest,
-// recursive: true,
-// excludes: [
-// path.join(component._baseDir, 'assets/skins/')
-// ]
-// });
-// },
-
- run : function() {
- this._taskQueues.forEach(function(q) {
- var worker = Buildy.factory(Buildy.TYPES.STRING, '');
- q.run(worker);
- }, this);
- }
-};
-
-exports.Builder = Builder;
View
@@ -20,7 +20,17 @@ exports.defaultSpec = {
sourceFiles : ["component.js"],
buildDir : "../build",
assetsDir : "assets",
- tools : {},
+ tools : {
+ template : {
+ yuivar : "Y",
+ module_template : "../templates/moduletemplate.handlebars"
+ },
+ replace : {
+ regex: '^.*?(?:logger|Y.log).*?(?:;|\\).*;|(?:\r?\n.*?)*?\\).*;).*;?.*?\r?\n',
+ replace: '',
+ flags: 'mg'
+ }
+ },
details : {
use : null,
supersedes : null,
View
@@ -3,7 +3,7 @@
* YUI component build specification object
*/
var path = require('path'),
- buildspec = require('buildspec');
+ buildspec = require('./buildspec.js');
/**
* Component - wraps the build specification (build.json) and provides convenience
@@ -66,6 +66,12 @@ Component.prototype._getBuildFileName = function(type) {
}
};
+Component.prototype._getAssetsDirectory = function(isBuildFile) {
+ return path.join(this._sourceDir,
+ (!isBuildFile || this._buildSpec.buildDir),
+ this._buildSpec.assetsDir);
+};
+
/**
* Get the skin source/build filename for a given skin.
*
@@ -76,14 +82,16 @@ Component.prototype._getBuildFileName = function(type) {
* @protected
*/
Component.prototype._getSkinFilename = function(name, isBuildFile) {
+ var cssSuffix = isBuildFile ? '' : '-skin';
name = name || 'sam';
+
return path.join(this._sourceDir,
(!isBuildFile || this._buildSpec.buildDir),
this._buildSpec.assetsDir,
- 'names',
+ 'skins',
name,
- this._buildSpec.name + '-name.css');
+ this._buildSpec.name + cssSuffix + '.css');
};
/**
@@ -149,6 +157,11 @@ Component.prototype._initFileNames = function() {
build : this._getSkinFilename('sam', true)
};
+ this._assets = {
+ source : this._getAssetsDirectory(false),
+ build : this._getAssetsDirectory(true)
+ };
+
};
// Details with these names are treated as javascript arrays in the output template.
@@ -157,15 +170,37 @@ Component.prototype._arrayDetails = ['use', 'supersedes', 'requires', 'optional'
// es5 properties
var ATTRS = {
+ /**
+ * @property skinnable
+ * @type Boolean
+ */
+ skinnable : {
+ get : function() {
+ return this._buildSpec.details.skinnable;
+ }
+ },
+
+ /**
+ * @property assets
+ * @type Object
+ */
+ assets : {
+ get : function() {
+ return this._assets;
+ }
+ },
+
/**
* @property sourcedir
+ * @type String
*/
sourcedir : {
get : function() { return this._sourceDir; }
},
/**
* @property name
+ * @type String
*/
component : {
get : function() { return this._buildSpec.name; },
@@ -174,6 +209,7 @@ var ATTRS = {
/**
* @property sourcefiles
+ * @type Array
*/
sourcefiles : {
get : function() {
@@ -190,6 +226,7 @@ var ATTRS = {
/**
* @property buildfiles
+ * @type Array
*/
buildfiles : {
get : function() { return this._buildFiles; }
@@ -198,13 +235,15 @@ var ATTRS = {
/**
* @property skins
+ * @type Object
*/
skins : {
get : function() { return this._skins; }
},
/**
* @property version
+ * @type String
*/
version : {
get : function() {
@@ -217,6 +256,7 @@ var ATTRS = {
/**
* @property details
+ * @type String
*/
details : {
get : function() {
Oops, something went wrong.

0 comments on commit 9924f8f

Please sign in to comment.