Permalink
Browse files

Part of the default-arch is moved to standalone node (SeedNode) (close

…#87)

Libraries utilize the same build initialization as project - it's possible to build blocks levels within libraries (close #52)
  • Loading branch information...
1 parent 5d3c94c commit 85217935162d4c85f88d41ce36532c1f840599e7 @scf2k scf2k committed Oct 12, 2012
Showing with 431 additions and 222 deletions.
  1. +4 −1 lib/base-server.js
  2. +31 −97 lib/default-arch.js
  3. +22 −12 lib/make.js
  4. +154 −2 lib/nodes/block.js
  5. +5 −97 lib/nodes/bundle.js
  6. +1 −4 lib/nodes/level.js
  7. +11 −6 lib/nodes/lib.js
  8. +188 −0 lib/nodes/seed.js
  9. +15 −3 test/nodes-lib.js
View
@@ -156,7 +156,10 @@ exports.Server = INHERIT({
// try to find node in arch
LOGGER.fverbose('*** searching for node "%s"', relPath);
- return runner.findNode(relPath)
+ return runner.process('build*')
+ .then(function() {
+ return runner.findNode(relPath);
+ })
.fail(function(err) {
if (typeof err === 'string') {
LOGGER.fverbose('*** node not found "%s"', relPath);
View
@@ -7,8 +7,8 @@ var INHERIT = require('inherit'),
registry = require('./nodesregistry'),
node = require('./nodes/node'),
- levelNodes = require('./nodes/level'),
libNodes = require('./nodes/lib'),
+ seed = require('./nodes/seed'),
ArchName = exports.ArchName = 'Arch';
@@ -24,9 +24,6 @@ registry.decl('Arch', {
this.opts = opts;
},
- bundlesLevelsRegexp: /^(pages.*|bundles.*)/i,
- blocksLevelsRegexp: /^(blocks.*)/i,
-
libraries: {},
getLibraries: function() {
@@ -50,28 +47,19 @@ registry.decl('Arch', {
];
},
- function(common, libs) {
- LOGGER.silly("Going to run createBlocksLevelsNodes()");
- return [
- common,
- libs,
- Q.call(_this.createBlocksLevelsNodes, _this, common, libs)
- ];
- },
+ function(common, libs){
+ LOGGER.silly("Adding build seed node");
- function(common, libs, blocks){
- LOGGER.silly("Going to run createBundlesLevelsNodes()");
- return [
- common,
- libs,
- blocks,
- Q.call(_this.createBundlesLevelsNodes, _this, common, (libs || []).concat(blocks))
- ];
- },
+ var node = new (registry.getNodeClass(seed.SeedNodeName))({
+ root: _this.root,
+ name: 'build',
+ deps: libs
+ });
+
+ _this.arch.setNode(node)
+ .addParents(node, common);
- function(common, libs, blocks, bundles) {
- LOGGER.silly("Going to run createCustomNodes()");
- return Q.call(_this.createCustomNodes, _this, common, libs, blocks, bundles);
+ return node;
})
.then(function() {
@@ -86,97 +74,43 @@ registry.decl('Arch', {
});
},
- createCustomNodes: function(common, libs, blocks, bundles) {
+ createCustomNodes: function(common, libs, seed) {
// stub
},
createCommonNodes: function() {
- var build = new node.Node('build'),
- all = new node.Node('all');
- this.arch
- .setNode(all)
- .setNode(build, all.getId());
+ var all = new node.Node('all');
+ this.arch.setNode(all);
+ return all.getId();
- return build.getId();
},
createBlockLibrariesNodes: function(parent) {
- var libs = this.getLibraries();
- return Object.keys(libs).map(function(l) {
+ var libs = this.getLibraries(),
+ libsNode = new (registry.getNodeClass(node.NodeName))('libs');
- var lib = libs[l],
- libNodeClass = U.toUpperCaseFirst(lib.type) + libNodes.LibraryNodeName,
- libNode = new (registry.getNodeClass(libNodeClass))(U.extend({}, lib, {
+ this.arch.setNode(
+ libsNode,
+ parent,
+ Object.keys(libs).map(function(l) {
+
+ var lib = libs[l],
+ libNodeClass = U.toUpperCaseFirst(lib.type) + libNodes.LibraryNodeName,
+ libNode = new (registry.getNodeClass(libNodeClass))(U.extend({}, lib, {
root: this.root,
target: l
}));
- this.arch.setNode(libNode, parent);
- return libNode.getId();
-
- }, this);
+ this.arch.setNode(libNode);
- },
-
- createBlocksLevelsNodes: function(parent, children) {
+ return libNode.getId();
- return this.createLevelsNodes(
- this.getBlocksLevels(this.root),
- levelNodes.LevelNode,
- parent,
- children);
-
- },
-
- createBundlesLevelsNodes: function(parent, children) {
-
- return this.createLevelsNodes(
- this.getBundlesLevels(this.root),
- levelNodes.BundlesLevelNode,
- parent,
- children);
-
- },
-
- createLevelsNodes: function(levels, nodeClass, parent, children) {
-
- var _this = this;
-
- return Q.when(levels)
- .then(function(levels) {
-
- return levels.map(function(level) {
- var node = new nodeClass({
- root: _this.root,
- level: level
- });
-
- _this.arch.setNode(node, parent, children);
-
- return node.getId();
- });
-
- });
-
- },
-
- getBlocksLevels: function(from) {
- return this.getLevels(from, this.blocksLevelsRegexp);
- },
-
- getBundlesLevels: function(from) {
- return this.getLevels(from, this.bundlesLevelsRegexp);
- },
-
- getLevels: function(from, mask) {
-
- return U.getDirsAsync(from)
- .invoke('filter', function(dir) {
- return dir.match(mask);
- });
+ }, this)
+ );
+ return libsNode.getId();
}
});
View
@@ -23,18 +23,28 @@ exports.APW = INHERIT(APW, {
return t.replace(re, '');
});
- var _this = this,
- foundNodes = targets.map(function(t) {
- return _this.findNode(t);
- });
- return Q.all(foundNodes)
- .fail(function(err) {
- if (typeof err === 'string') return;
- return Q.reject(err);
- })
- .then(function() {
- return _this.process(targets);
- });
+ var build = Q.resolve(),
+ _this = this;
+
+ if (this.arch.hasNode('build*')) {
+ build = this.process('build*');
+ }
+
+ return build.then(function() {
+
+ var foundNodes = targets.map(function(t) {
+ return _this.findNode(t);
+ });
+
+ return Q.all(foundNodes)
+ .fail(function(err) {
+ if (typeof err === 'string') return;
+ return Q.reject(err);
+ })
+ .then(function() {
+ return _this.process(targets);
+ });
+ })
},
// TODO: move node introspection logic to the node in arch
Oops, something went wrong.

0 comments on commit 8521793

Please sign in to comment.