Permalink
Browse files

Fix bugs introduced with unified nodes changes

  • Loading branch information...
1 parent e7ce8fd commit 7fc1442b3d45b29f513801afa1420804357e571d @scf2k scf2k committed Jan 25, 2013
Showing with 610 additions and 277 deletions.
  1. +1 −1 lib/make.js
  2. +0 −22 lib/nodes/block.js
  3. +37 −41 lib/nodes/build.js
  4. +262 −37 lib/nodes/bundle.js
  5. +2 −21 lib/nodes/create.js
  6. +13 −39 lib/nodes/decl.js
  7. +102 −3 lib/nodes/entity.js
  8. +18 −4 lib/nodes/file.js
  9. +35 −0 lib/nodes/itemcontainer.js
  10. +4 −3 lib/nodes/level.js
  11. +2 −1 lib/tech.js
  12. +5 −2 lib/util.js
  13. +13 −11 test/bem-make.js
  14. +1 −0 test/data/make/project/.bem/level.js
  15. +5 −0 test/data/make/project/.bem/levels/blocks.js
  16. +9 −2 test/data/make/project/.bem/make.js
  17. +1 −1 test/data/make/project/bem-bl
  18. +0 −1 test/data/make/project/blocks/.bem/level.js
  19. +1 −0 test/data/make/project/desktop.blocks/.bem/level.js
  20. 0 test/data/make/project/{blocks → desktop.blocks}/b-link/_color/b-link_color_green.css
  21. 0 test/data/make/project/{blocks → desktop.blocks}/b-link/_color/b-link_color_red.css
  22. 0 test/data/make/project/{blocks → desktop.blocks}/b-link/_pseudo/b-link_pseudo_yes.coffee
  23. 0 test/data/make/project/{blocks → desktop.blocks}/b-link/_pseudo/b-link_pseudo_yes.css
  24. 0 test/data/make/project/{blocks → desktop.blocks}/b-link/_togcolor/b-link_togcolor_yes.deps.js
  25. 0 test/data/make/project/{blocks → desktop.blocks}/b-link/_togcolor/b-link_togcolor_yes.js
  26. 0 test/data/make/project/{blocks → desktop.blocks}/b-page/b-page.deps.js
  27. +2 −2 test/data/make/project/{pages → desktop.bundles}/.bem/level.js
  28. 0 ...ke/{reference-result/pages → project/desktop.bundles}/client/__profile/client__profile.bemjson.js
  29. 0 test/data/make/project/{pages → desktop.bundles}/client/blocks/.bem/level.js
  30. 0 test/data/make/project/{pages → desktop.bundles}/client/blocks/b-page/b-page.deps.js
  31. 0 test/data/make/project/{pages → desktop.bundles}/client/blocks/b-page/b-page.js
  32. 0 test/data/make/{reference-result/pages → project/desktop.bundles}/client/client.bemjson.js
  33. 0 test/data/make/{reference-result/pages → project/desktop.bundles}/example/example.bemjson.js
  34. +32 −0 test/data/make/project/merged.bundles/.bem/level.js
  35. 0 test/data/make/{reference-result/pages-with-merged → project/merged.bundles}/page1/page1.bemdecl.js
  36. 0 test/data/make/{reference-result/pages-with-merged → project/merged.bundles}/page2/page2.bemdecl.js
  37. +0 −21 test/data/make/project/pages-with-merged/.bem/level.js
  38. 0 test/data/make/reference-result/.bem/cache/{pages → desktop.bundles}/client/client.bemhtml.meta.js
  39. +6 −0 test/data/make/reference-result/.bem/cache/desktop.bundles/client/client.css.meta.js
  40. +3 −3 test/data/make/reference-result/.bem/cache/{pages → desktop.bundles}/client/client.deps.js.meta.js
  41. +3 −3 test/data/make/reference-result/.bem/cache/{pages → desktop.bundles}/client/client.i18n.js.meta.js
  42. 0 test/data/make/reference-result/.bem/cache/{pages → desktop.bundles}/client/client.i18n.meta.js
  43. 0 test/data/make/reference-result/.bem/cache/{pages → desktop.bundles}/client/client.ie.css.meta.js
  44. 0 test/data/make/reference-result/.bem/cache/{pages → desktop.bundles}/example/example.bemhtml.meta.js
  45. +6 −0 test/data/make/reference-result/.bem/cache/desktop.bundles/example/example.css.meta.js
  46. +2 −2 test/data/make/reference-result/.bem/cache/{pages → desktop.bundles}/example/example.deps.js.meta.js
  47. +2 −2 test/data/make/reference-result/.bem/cache/{pages → desktop.bundles}/example/example.i18n.js.meta.js
  48. 0 test/data/make/reference-result/.bem/cache/{pages → desktop.bundles}/example/example.i18n.meta.js
  49. 0 test/data/make/reference-result/.bem/cache/{pages → desktop.bundles}/example/example.ie.css.meta.js
  50. +2 −2 ...make/reference-result/.bem/cache/{pages-with-merged → merged.bundles}/page1/page1.deps.js.meta.js
  51. +1 −1 ...make/reference-result/.bem/cache/{pages-with-merged → merged.bundles}/page2/page2.deps.js.meta.js
  52. +0 −6 test/data/make/reference-result/.bem/cache/pages/client/client.css.meta.js
  53. +0 −6 test/data/make/reference-result/.bem/cache/pages/example/example.css.meta.js
  54. 0 ...data/make/reference-result/{pages → desktop.bundles}/client/__profile/_client__profile.bemhtml.js
  55. 0 test/data/make/reference-result/{pages → desktop.bundles}/client/__profile/_client__profile.css
  56. 0 test/data/make/reference-result/{pages → desktop.bundles}/client/__profile/_client__profile.en.js
  57. 0 test/data/make/reference-result/{pages → desktop.bundles}/client/__profile/_client__profile.ie.css
  58. 0 test/data/make/reference-result/{pages → desktop.bundles}/client/__profile/_client__profile.js
  59. 0 test/data/make/reference-result/{pages → desktop.bundles}/client/__profile/_client__profile.ru.js
  60. 0 .../data/make/reference-result/{pages → desktop.bundles}/client/__profile/client__profile.bemdecl.js
  61. 0 .../data/make/reference-result/{pages → desktop.bundles}/client/__profile/client__profile.bemhtml.js
  62. 0 ...ke/{project/pages → reference-result/desktop.bundles}/client/__profile/client__profile.bemjson.js
  63. 0 test/data/make/reference-result/{pages → desktop.bundles}/client/__profile/client__profile.css
  64. 0 test/data/make/reference-result/{pages → desktop.bundles}/client/__profile/client__profile.deps.js
  65. 0 test/data/make/reference-result/{pages → desktop.bundles}/client/__profile/client__profile.en.js
  66. 0 test/data/make/reference-result/{pages → desktop.bundles}/client/__profile/client__profile.html
  67. 0 ...esult/{pages/example/example.i18n → desktop.bundles/client/__profile/client__profile.i18n}/all.js
  68. 0 test/data/make/reference-result/{pages → desktop.bundles}/client/__profile/client__profile.ie.css
  69. 0 test/data/make/reference-result/{pages → desktop.bundles}/client/__profile/client__profile.js
  70. 0 test/data/make/reference-result/{pages → desktop.bundles}/client/__profile/client__profile.ru.js
  71. 0 test/data/make/reference-result/{pages → desktop.bundles}/client/_client.bemhtml.js
  72. +6 −6 test/data/make/reference-result/{pages → desktop.bundles}/client/_client.css
  73. 0 test/data/make/reference-result/{pages → desktop.bundles}/client/_client.en.js
  74. +6 −6 test/data/make/reference-result/{pages → desktop.bundles}/client/_client.ie.css
  75. 0 test/data/make/reference-result/{pages → desktop.bundles}/client/_client.js
  76. 0 test/data/make/reference-result/{pages → desktop.bundles}/client/_client.ru.js
  77. 0 test/data/make/reference-result/{pages → desktop.bundles}/client/client.bemdecl.js
  78. 0 test/data/make/reference-result/{pages → desktop.bundles}/client/client.bemhtml.js
  79. 0 test/data/make/{project/pages → reference-result/desktop.bundles}/client/client.bemjson.js
  80. +4 −0 test/data/make/reference-result/desktop.bundles/client/client.css
  81. 0 test/data/make/reference-result/{pages → desktop.bundles}/client/client.deps.js
  82. +2 −2 test/data/make/reference-result/{pages → desktop.bundles}/client/client.en.js
  83. 0 test/data/make/reference-result/{pages → desktop.bundles}/client/client.html
  84. 0 test/data/make/reference-result/{pages → desktop.bundles}/client/client.i18n/all.js
  85. 0 test/data/make/reference-result/{pages → desktop.bundles}/client/client.ie.css
  86. 0 test/data/make/reference-result/{pages → desktop.bundles}/client/client.js
  87. +2 −2 test/data/make/reference-result/{pages → desktop.bundles}/client/client.ru.js
  88. 0 test/data/make/reference-result/{pages → desktop.bundles}/example/_example.bemhtml.js
  89. +6 −6 test/data/make/reference-result/{pages → desktop.bundles}/example/_example.css
  90. 0 test/data/make/reference-result/{pages → desktop.bundles}/example/_example.en.js
  91. +6 −6 test/data/make/reference-result/{pages → desktop.bundles}/example/_example.ie.css
  92. 0 test/data/make/reference-result/{pages → desktop.bundles}/example/_example.js
  93. 0 test/data/make/reference-result/{pages → desktop.bundles}/example/_example.ru.js
  94. 0 test/data/make/reference-result/{pages → desktop.bundles}/example/example.bemdecl.js
  95. 0 test/data/make/reference-result/{pages → desktop.bundles}/example/example.bemhtml.js
  96. 0 test/data/make/{project/pages → reference-result/desktop.bundles}/example/example.bemjson.js
  97. +4 −0 test/data/make/reference-result/desktop.bundles/example/example.css
  98. 0 test/data/make/reference-result/{pages → desktop.bundles}/example/example.deps.js
  99. +2 −2 test/data/make/reference-result/{pages → desktop.bundles}/example/example.en.js
  100. 0 test/data/make/reference-result/{pages → desktop.bundles}/example/example.html
  101. 0 ...esult/{pages/client/__profile/client__profile.i18n → desktop.bundles/example/example.i18n}/all.js
  102. 0 test/data/make/reference-result/{pages → desktop.bundles}/example/example.ie.css
  103. 0 test/data/make/reference-result/{pages → desktop.bundles}/example/example.js
  104. +2 −2 test/data/make/reference-result/{pages → desktop.bundles}/example/example.ru.js
  105. 0 test/data/make/reference-result/{pages-with-merged → merged.bundles}/merged/merged.deps.js
  106. 0 test/data/make/{project/pages-with-merged → reference-result/merged.bundles}/page1/page1.bemdecl.js
  107. 0 test/data/make/reference-result/{pages-with-merged → merged.bundles}/page1/page1.deps.js
  108. 0 test/data/make/{project/pages-with-merged → reference-result/merged.bundles}/page2/page2.bemdecl.js
  109. 0 test/data/make/reference-result/{pages-with-merged → merged.bundles}/page2/page2.deps.js
  110. +0 −4 test/data/make/reference-result/pages/client/client.css
  111. +0 −4 test/data/make/reference-result/pages/example/example.css
View
@@ -14,7 +14,7 @@ exports.DEFAULT_WORKERS = 10;
exports.APW = INHERIT(APW, {
- __constructor: function(opts) {
+ __constructor: function(arch, workers, opts) {
this.__base.apply(this, arguments);
this.root = opts.root;
},
View
@@ -29,19 +29,6 @@ registry.decl(BlockNodeName, MagicNode, {
make: function() {},
- getNodePrefix: function() {
-
- if (!this._nodePrefix) {
- this._nodePrefix = this.__self.createNodePrefix({
- root: this.root,
- level: this.level,
- item: this.item
- });
- }
- return this._nodePrefix;
-
- },
-
/**
* returns the path of the block`s level relative to the project root
* @return {*}
@@ -52,14 +39,5 @@ registry.decl(BlockNodeName, MagicNode, {
}, {
- createNodePrefix: function(o) {
-
- var level = typeof o.level === 'string'?
- createLevel(PATH.resolve(o.root, o.level)) :
- o.level;
-
- return PATH.relative(o.root, level.getByObj(o.item));
-
- }
});
View
@@ -171,12 +171,12 @@ registry.decl(BemBuildNodeName, EntityNode, {
};
worker.on('exit', function(code) {
- LOGGER.fdebug("Exit of bembuild worker for node '%s' with code %s", _this.output, code);
+ LOGGER.fdebug("Exit of bembuild worker for node '%s' with code %s", _this.getId(), code);
handler({ code: code });
});
worker.on('message', function(m) {
- LOGGER.fdebug("Message from bembuild worker for node '%s': %j", _this.output, m);
+ LOGGER.fdebug("Message from bembuild worker for node '%s': %j", _this.getId(), m);
handler(m);
});
@@ -187,13 +187,11 @@ registry.decl(BemBuildNodeName, EntityNode, {
readMeta: function() {
// we assume that getPath() for metanode returns one item array
- return this._readMeta(this.getMetaNode().getPath()[0]);
+ return this._readMeta(this.getMetaNode().getPaths()[0]);
},
_readMeta: function(path) {
- path = PATH.resolve(this.root, path);
-
var _this = this,
relativize = getPathRelativizer(this.root);
@@ -206,7 +204,6 @@ registry.decl(BemBuildNodeName, EntityNode, {
})
.fail(function() {
- console.log('fail %s', path);
return null;
});
@@ -233,34 +230,13 @@ registry.decl(BemBuildNodeName, EntityNode, {
},
/**
- * Get files minimum mtime in milliseconds or -1 in case of any file doesn't exist.
- *
- * @return {Promise * Number}
- */
- lastModified: function() {
-
- return Q.all(this.tech
- .getFiles()
- .map(function(path) {
-
- return QFS.lastModified(path)
- .fail(function() {
- return -1;
- });
-
- }))
- .spread(Math.min);
-
- },
-
- /**
* clean() implementation.
* @return {Promise * Undefined}
*/
clean: function() {
var _this = this;
- return Q.all(this.getFiles()
+ return Q.all(this.getPaths()
.map(function(path) {
return QFS.remove(path)
@@ -272,17 +248,31 @@ registry.decl(BemBuildNodeName, EntityNode, {
}));
},
+ // For compatibility with old code calling getFiles()
getFiles: function() {
- return this.tech.getPaths(this.output, Object.keys(this.tech.getBuildSuffixesMap()));
+ return this.getRelPaths();
+ },
+
+ getPaths: function() {
+ return this.rootLevel.resolveBemPath(this.resolved, Object.keys(this.tech.getBuildSuffixesMap()));
+ },
+
+ getRelPaths: function() {
+ return this.rootLevel.resolveBemRelPath(this.resolved, Object.keys(this.tech.getBuildSuffixesMap()));
},
getDependencies: function() {
+ var resolved = this.resolved.concat([]),
+ deps = this.tech.getDependencies().map(function(d) {
+
+ resolved[resolved.length-1] = U.extend({}, this.item, {tech: d});
+
+ return U.serializeBemPath(resolved);
- var deps = this.tech.getDependencies().map(function(d) {
- return this.level.getPath(this.output, d);
}, this);
deps.push(this.declPath);
+
return deps;
}
@@ -306,7 +296,8 @@ registry.decl(BemBuildMetaNodeName, BemBuildNodeName, {
*/
__constructor: function(o) {
this.__base(o);
- this.path = PATH.join('.bem', 'cache', this.path);
+ this.path = this.getRelPaths()[0];
+ this.absPath = PATH.resolve(this.root, this.path);
},
isValid: function() {
@@ -370,8 +361,8 @@ registry.decl(BemBuildMetaNodeName, BemBuildNodeName, {
return relativize(f);
});
- U.mkdirs(PATH.dirname(_this.getPath()));
- return QFS.write(_this.getPath()[0], '(' + JSON.stringify(paths, null, 4) + ')');
+ U.mkdirs(PATH.dirname(_this.absPath));
+ return QFS.write(_this.absPath, '(' + JSON.stringify(paths, null, 4) + ')');
});
@@ -416,7 +407,7 @@ registry.decl(BemBuildMetaNodeName, BemBuildNodeName, {
},
readMeta: function() {
- return this._readMeta(this.getPath()[0]);
+ return this._readMeta(this.absPath);
},
/**
@@ -426,8 +417,7 @@ registry.decl(BemBuildMetaNodeName, BemBuildNodeName, {
*/
lastModified: function() {
- // TODO: should really use link to GeneratedFileNode.prototype.lastModified() here
- return QFS.lastModified(this.getPath()[0])
+ return QFS.lastModified(this.absPath)
.fail(function() {
return -1;
});
@@ -442,7 +432,7 @@ registry.decl(BemBuildMetaNodeName, BemBuildNodeName, {
// TODO: should really use link to GeneratedFileNode.prototype.clean() here
var _this = this;
- return Q.all(this.getPath().map(function(p) {
+ return Q.all(this.getPaths().map(function(p) {
return QFS.remove(p)
.fail(function() {});
}))
@@ -455,10 +445,16 @@ registry.decl(BemBuildMetaNodeName, BemBuildNodeName, {
return [this.declPath];
},
- getPath: function() {
+ getRelPaths: function() {
return this.rootLevel.resolveBemRelPath(this.resolved).map(function(p) {
- return PATH.join(this.root, '.bem', 'cache', p);
- })
+ return PATH.join('.bem', 'cache', p);
+ }, this);
+ },
+
+ getPaths: function() {
+ return this.getRelPaths().map(function(p) {
+ return PATH.resolve(this.root, p);
+ }, this);
}
});
Oops, something went wrong.

0 comments on commit 7fc1442

Please sign in to comment.