Skip to content
This repository has been archived by the owner on Jan 24, 2019. It is now read-only.

Commit

Permalink
feat(publisher): add and config component-publisher system
Browse files Browse the repository at this point in the history
  • Loading branch information
douglasduteil committed Dec 26, 2013
1 parent 1836b40 commit 4cea7ea
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 19 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
bower_components/
node_modules/
out/
dist/

# don't track generated/copied html demo files
demo/*.html
44 changes: 26 additions & 18 deletions gruntFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,33 @@ module.exports = function (grunt) {
* Custom task to inline a generated file at a certain moment...
*/
grunt.registerTask('UGF', 'Use Generated Files.', function() {
initConfig.meta.view.demoHTML= grunt.file.read( grunt.template.process("<%= dist %>/demos.html"));
initConfig.meta.view.demoHTML= grunt.file.read(grunt.template.process("<%= dist %>/demos.html"));
});

// Default task.
grunt.registerTask('default', ['jshint', 'karma:unit']);
grunt.registerTask('build', ['concat:tmp', 'concat:modules', 'clean:rm_tmp', 'uglify']);
grunt.registerTask('build-doc', ['build', 'concat:html_doc', 'UGF', 'copy']);
grunt.registerTask('server', ['karma:start']);
grunt.registerTask('dist', ['concat:tmp', 'concat:modules', 'clean:rm_tmp', 'uglify', 'concat:html_doc', 'copy']);

// HACK TO ACCESS TO THE COMPONENT-PUBLISHER
function fakeTargetTask(prefix){
return function(){

if (this.args.length !== 1) return grunt.log.fail('Just give the name of the ' + prefix + ' you want like :\ngrunt ' + prefix + ':bower');

var done = this.async();
var spawn = require('child_process').spawn;
spawn('./node_modules/.bin/gulp', [ prefix, '--branch='+this.args[0] ].concat(grunt.option.flags()), {
cwd : './node_modules/component-publisher',
stdio: 'inherit'
}).on('close', done);
};
}

grunt.registerTask('build', fakeTargetTask('build'));
grunt.registerTask('publish', fakeTargetTask('publish'));
//

var testConfig = function(configFile, customOptions) {
var options = { configFile: configFile, singleRun: true };
Expand Down Expand Up @@ -67,25 +85,25 @@ module.exports = function (grunt) {
].join('\n '),
footer : '</div>'},
src: [ 'modules/**/demo/index.html'],
dest: '<%= dist %>/demos.html'
dest: 'demo/demos.html'
},
tmp: {
files: { 'tmp/dep.js': [ 'modules/**/*.js', '!modules/utils.js', '!modules/ie-shiv/*.js', '!modules/**/test/*.js']}
},
modules: {
options: {banner: '<%= meta.banner %>'},
files: {
'<%= meta.destName %>.js': ['tmp/dep.js', 'modules/utils.js'],
'<%= meta.destName %>-ieshiv.js' : ['modules/ie-shiv/*.js']
'dist/main/ui-utils.js': ['tmp/dep.js', 'modules/utils.js'],
'dist/main/ui-utils-ieshiv.js' : ['modules/ie-shiv/*.js']
}
}
},
uglify: {
options: {banner: '<%= meta.banner %>'},
build: {
files: {
'<%= meta.destName %>.min.js': ['<%= meta.destName %>.js'],
'<%= meta.destName %>-ieshiv.min.js': ['<%= meta.destName %>-ieshiv.js']
'dist/main/ui-utils.min.js': ['dist/main/ui-utils.js'],
'dist/main/ui-utils-ieshiv.min.js': ['dist/main/ui-utils-ieshiv.js']
}
}
},
Expand All @@ -110,18 +128,8 @@ module.exports = function (grunt) {
copy: {
main: {
files: [
{src: ['demo/demo.js'], dest: '<%= dist %>/core/demo.js', filter: 'isFile'},

// UI.Include needs a external html source.
{src: ['modules/include/demo/fragments.html'], dest: '<%= dist %>/assets/fragments.html', filter: 'isFile'}
]
},
template : {
options : {processContent : function(content){
return grunt.template.process(content);
}},
files: [
{src: ['<%= dist %>/.tmpl/index.tmpl'], dest: '<%= dist %>/index.html'}
{src: ['modules/include/demo/fragments.html'], dest: 'demo/fragments.html', filter: 'isFile'}
]
}
}
Expand Down
2 changes: 1 addition & 1 deletion modules/include/demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ <h3>Demo</h3>
<br/>
Fragment content <span ng-show="uiIncludeFragment">(<code>fragment="'{{uiIncludeFragment}}'"</code>)</span>:
<div class="well">
<ui-include src="'assets/fragments.html'" fragment="uiIncludeFragment" ng-show="uiIncludeFragment"></ui-include>
<ui-include src="'demo/fragments.html'" fragment="uiIncludeFragment" ng-show="uiIncludeFragment"></ui-include>
</div>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"homepage": "http://angular-ui.github.com",
"dependencies": {},
"devDependencies": {
"component-publisher": "git://github.com/douglasduteil/component-publisher",
"grunt": "~0.4.1",
"grunt-contrib-clean": "~0.4.1",
"grunt-contrib-concat": "~0.3.0",
Expand Down
45 changes: 45 additions & 0 deletions publish.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/* jshint node:true */

'use strict';

var fs = require('fs');

module.exports = function() {

//var modulesName = grunt.file.expand({ cwd: "modules" }, ["*","!utils.js"]);
var modulesName = fs.readdirSync(__dirname + '/modules');

function makingComponentData(memo, name){
if(name === 'utils.js') return memo;

memo[name] = {
fullName : 'angular-ui-' + name,
main : './ui-' + name + '.js',
src : name + '.js'
};

return memo;
}

return {
// gh-pages stuff
humaName : 'UI.Utils',
repoName : 'ui-utils',
inlineHTML : fs.readFileSync(__dirname + '/demo/demos.html'),
inlineJS : fs.readFileSync(__dirname + '/demo/demo.js'),
// gh-pages css dependencies
// css : []
// gh-pages js dependencies
js : ['dist/ui-utils.js'],


// HACK...
main_dist_dir: 'main',


// The sub-components
subcomponent : modulesName.reduce(makingComponentData, {}),
// HACK...
sub_dist_dir: 'sub'
};
};

0 comments on commit 4cea7ea

Please sign in to comment.