Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions bit-docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ var _ = require("lodash");
var tags = require("./tags/tags");

var mergeOnto = function(prop, dest, source){
if(!dest[prop]) {
dest[prop] = [];
}
if(source[prop]) {
dest[prop] = dest[prop].concat(source[prop])
dest[prop] = dest[prop].concat(source[prop]);
}
};

Expand All @@ -30,12 +33,13 @@ module.exports = function(bitDocs){
siteConfig.html = {
dependencies: {},
static: [],
templates: []
templates: [],
staticDist: []
};
}
var html = siteConfig.html;
_.assign(html.dependencies, htmlConfig.dependencies || {});

mergeOnto("staticDist", html, htmlConfig);
mergeOnto("static", html, htmlConfig);
mergeOnto("templates", html, htmlConfig);
});
Expand Down
72 changes: 52 additions & 20 deletions build/build_test.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
require("./make_default_helpers_test");

var getRenderer = require('./get_renderer'),
getPartials = require('./get_partials'),
build = require("./build"),
assert = require('assert'),
Q = require('q'),
path = require('path'),
rmdir = require('rimraf'),
fs = require('fs');
var getRenderer = require('./get_renderer');
var getPartials = require('./get_partials');
var build = require("./build");
var assert = require('assert');
var Q = require('q');
var path = require('path');
var rmdir = require('rimraf');
var fs = require('fs');
var read = Q.denodeify(fs.readFile);

describe("documentjs/lib/generators/html/build",function(){

Expand Down Expand Up @@ -105,21 +106,52 @@ describe("documentjs/lib/generators/html/build",function(){

});

it("builds the static dist", function(done){
it("builds the static dist", function(){
this.timeout(120000);
build.staticDist({
return build.staticDist({
forceBuild: true,
html: {dependencies: {"can-component": "3.0.0-pre.9"}}
}).then(function(result){
fs.readFile(path.join(__dirname, "..", result.distFolder, "bundles","bit-docs-site","static.js"), function(err, res){
if(err) {
done(err);
} else {
assert.ok(/can-component/.test(res), "got static.js with component");
done();
html: {
dependencies: {
"can-component": "3.0.0-pre.9"
}
});
}, done);
}
}).then(function(result){
return read(path.join(__dirname, "..", result.distFolder, "bundles","bit-docs-site","static.js"));
}).then(function(res){
assert.ok(/can-component/.test(res), "got static.js with component");
});
});

it("copy absolute staticDist folders to static dist", function(){
this.timeout(120000);
return build.staticDist({
forceBuild: true,
html: {
staticDist: [
path.join(__dirname, '..', 'test-static-dist')
]
},
}).then(function(result){
return read(path.join(__dirname, "..", result.distFolder, "test.css"));
}).then(function(res){
assert.ok(/#TestID/.test(res), "got test.css file");
});
});

it("copy relative staticDist folders to static dist", function(){
this.timeout(120000);
return build.staticDist({
forceBuild: true,
html: {
staticDist: [
'./test-static-dist'
]
},
}).then(function(result){
return read(path.join(__dirname, "..", result.distFolder, "test.css"));
}).then(function(res){
assert.ok(/#TestID/.test(res), "got test.css file");
});
});

it("makes linked content",function(done){
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bit-docs-generate-html",
"version": "0.6.0",
"version": "0.6.0-pre.1",
"description": "Generates an HTML site with mustache templates",
"main": "index.js",
"scripts": {
Expand Down
52 changes: 22 additions & 30 deletions site/default/static/build.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,34 @@

var stealTools = require("steal-tools"),
fsx = require('../../../../fs_extras'),
Q = require('q'),
path = require("path");

var stealTools = require("steal-tools");
var fsx = require('../../../../fs_extras');
var Q = require('q');
var path = require("path");

module.exports = function(options, folders){

var copyDir = function(name){
return fsx.mkdirs( path.join(folders.dist,name) ).then(function(){
return fsx.mkdirs(path.join(folders.dist,name)).then(function(){
return fsx.exists(path.join(folders.build,name)).then(function(exists){
if(exists) {
return fsx.copy( path.join(folders.build,name), path.join(folders.dist,name) );
return fsx.copy(path.join(folders.build,name), path.join(folders.dist,name));
}
});
});
};

var staticDistPromises = [];
if(options.html && options.html.staticDist){
options.html.staticDist.forEach(function(dist){
if(!path.isAbsolute(dist)){
dist = path.join(process.cwd(), dist);
}
staticDistPromises.push(fsx.copyFrom(dist, folders.dist));
});
}

if(options.devBuild) {
// copy all dependencies
var promise = Q.all([
fsx.copy(path.join(folders.build), path.join(folders.dist) )
]);
staticDistPromises.push(fsx.copy(path.join(folders.build), path.join(folders.dist)));
// copy everything and steal.js
return promise;
return Q.all(staticDistPromises);
} else {

// run steal-tools and then copy things
Expand All @@ -38,24 +44,10 @@ module.exports = function(options, folders){
if(options.debug) {
console.log("BUILD: Copying build to dist.");
}
return fsx.copy(path.join(folders.build, "dist"), path.join(folders.dist) );
// copy everything to DIST
/*return Q.all([
fsx.mkdirs( path.join(folders.dist,"bundles") ).then(function(){
return fsx.copy(path.join(folders.build,"bundles"), path.join(folders.dist,"bundles") );
}),
fsx.copyFrom(path.join( require.resolve("steal"), "..", "steal.production.js"), path.join(folders.dist,"steal.production.js") ),
fsx.copy( path.join(folders.build,"html5shiv.js"), path.join(folders.dist,"html5shiv.js")),

copyDir("fonts"),

copyDir("img"),
copyDir("templates")
]);*/

staticDistPromises.push(fsx.copy(path.join(folders.build, "dist"), path.join(folders.dist)));

return Q.all(staticDistPromises);
});
}



};
3 changes: 3 additions & 0 deletions test-static-dist/test.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#TestID {
display: block;
}