Skip to content
This repository was archived by the owner on May 25, 2019. It is now read-only.

Commit 1b79d7c

Browse files
committed
Merge pull request #33 from douglasduteil/ft-publisher
feat(publisher): use the Angular UI Publisher
2 parents 7d4c80c + 941c1e1 commit 1b79d7c

File tree

11 files changed

+195
-113
lines changed

11 files changed

+195
-113
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
bower_components/
22
node_modules/
3+
out/
4+
dist/

.jshintrc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"boss": true,
3+
"browser": true,
4+
"eqnull": true,
5+
"expr": true,
6+
"globalstrict": true,
7+
"immed": true,
8+
"laxbreak": true,
9+
"loopfunc": true,
10+
"newcap": true,
11+
"noarg": true,
12+
"noempty": true,
13+
"nonew": true,
14+
"quotmark": true,
15+
"smarttabs": true,
16+
"sub": true,
17+
"trailing": true,
18+
"undef": true,
19+
"unused": true,
20+
"globals": {
21+
"angular": false
22+
}
23+
}

.travis.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
---
22
language: node_js
33
node_js:
4-
- '0.8'
4+
- '0.10'
55
before_install:
66
- export DISPLAY=:99.0
77
- sh -e /etc/init.d/xvfb start
8-
- npm install -g bower grunt-cli
9-
- npm install
8+
- npm install -qg bower grunt-cli
9+
- npm install -q
1010
- bower install --force
1111
- bower install --force
12-
before_script: ./bower_components/angular-ui-docs/.travis/before_script.sh
13-
after_success: ./bower_components/angular-ui-docs/.travis/after_success.sh
14-
branches:
15-
only:
16-
- master
12+
after_success:
13+
- "./node_modules/angular-ui-publisher/travis/authentication.sh || exit 0"
14+
- "grunt dist build:gh-pages publish:gh-pages build:bower publish:bower"
1715
script: grunt
1816
env:
1917
global:

bower.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
},
2727
"devDependencies": {
2828
"angular-mocks": ">=1.0.x",
29-
"angular-ui-bootstrap-bower": "~0.5.0",
30-
"angular-ui-docs": "angular-ui/angular-ui-docs"
29+
"angular-ui-bootstrap-bower": "~0.5.0"
3130
}
3231
}

demo/demo.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
angular.module('doc.ui-codeMirror', ['ui.codemirror', 'prettifyDirective', 'ui.bootstrap', 'plunker' ])
24
.controller('CodemirrorCtrl', ['$scope', function ($scope) {
35

@@ -14,7 +16,7 @@ angular.module('doc.ui-codeMirror', ['ui.codemirror', 'prettifyDirective', 'ui.b
1416

1517
// HACK to have the codemirror instance in the scope...
1618
$scope.modeChanged = function () {
17-
_cm.setOption("mode", $scope.mode.toLowerCase());
19+
_cm.setOption('mode', $scope.mode.toLowerCase());
1820
};
1921

2022
}
@@ -29,4 +31,4 @@ angular.module('doc.ui-codeMirror', ['ui.codemirror', 'prettifyDirective', 'ui.b
2931
'// Javascript code in here.\n' +
3032
'function foo(msg) {\n\tvar r = Math.random();\n\treturn "" + r + " : " + msg;\n}';
3133

32-
}]);
34+
}]);

gruntFile.js

Lines changed: 74 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,38 @@
11
module.exports = function (grunt) {
22
'use strict';
33

4-
var _ = grunt.util._;
5-
64
require('load-grunt-tasks')(grunt);
75

86
// Default task.
97
grunt.registerTask('default', ['jshint', 'karma:unit']);
108
grunt.registerTask('serve', ['connect:continuous', 'karma:continuous', 'watch']);
11-
grunt.registerTask('build-doc', ['uglify', 'copy']);
9+
grunt.registerTask('dist', ['ngmin', 'uglify']);
10+
11+
// HACK TO ACCESS TO THE COMPONENT-PUBLISHER
12+
function fakeTargetTask(prefix){
13+
return function(){
14+
15+
if (this.args.length !== 1) return grunt.log.fail('Just give the name of the ' + prefix + ' you want like :\ngrunt ' + prefix + ':bower');
16+
17+
var done = this.async();
18+
var spawn = require('child_process').spawn;
19+
spawn('./node_modules/.bin/gulp', [ prefix, '--branch='+this.args[0] ].concat(grunt.option.flags()), {
20+
cwd : './node_modules/angular-ui-publisher',
21+
stdio: 'inherit'
22+
}).on('close', done);
23+
};
24+
}
25+
26+
grunt.registerTask('build', fakeTargetTask('build'));
27+
grunt.registerTask('publish', fakeTargetTask('publish'));
28+
//
1229

1330
var testConfig = function (configFile, customOptions) {
1431
var options = { configFile: configFile, singleRun: true };
1532
var travisOptions = process.env.TRAVIS && { browsers: [ 'Firefox', 'PhantomJS'], reporters: ['dots'] };
1633
return grunt.util._.extend(options, customOptions, travisOptions);
1734
};
1835

19-
var js_dependencies =[
20-
'<%= bower %>/angular-ui-bootstrap-bower/ui-bootstrap-tpls.min.js',
21-
'<%= bower %>/codemirror/lib/codemirror.js',
22-
'<%= bower %>/codemirror/mode/scheme/scheme.js',
23-
'<%= bower %>/codemirror/mode/javascript/javascript.js',
24-
'<%= bower %>/codemirror/mode/xml/xml.js',
25-
];
26-
27-
var css_dependencies = [
28-
'<%= bower %>/codemirror/lib/codemirror.css',
29-
'<%= bower %>/codemirror/theme/twilight.css'
30-
];
31-
3236
// Project configuration.
3337
grunt.initConfig({
3438
bower: 'bower_components',
@@ -41,26 +45,24 @@ module.exports = function (grunt) {
4145
' * @link <%= pkg.homepage %>',
4246
' * @license <%= pkg.license %>',
4347
' */',
44-
''].join('\n'),
45-
view : {
46-
humaName : 'UI CodeMirror',
47-
repoName : 'ui-codemirror',
48-
demoHTML : grunt.file.read('demo/demo.html'),
49-
demoJS : grunt.file.read('demo/demo.js'),
50-
css: css_dependencies.concat(['assets/css/demo.css']),
51-
js : js_dependencies.concat(['build/ui-codemirror.min.js'])
52-
}
48+
''].join('\n')
5349
},
50+
5451
watch: {
52+
src: {
53+
files: ['src/*'],
54+
tasks: ['jshint:src', 'karma:unit:run', 'dist', 'build:gh-pages']
55+
},
5556
test: {
56-
files: ['<%= meta.view.repoName %>.js', 'test/*.js'],
57-
tasks: ['jshint', 'karma:unit:run']
57+
files: ['test/*.js'],
58+
tasks: ['jshint:test', 'karma:unit:run']
5859
},
5960
demo: {
60-
files: ['demo/*', '<%= meta.view.repoName %>.js'],
61-
tasks: ['uglify', 'copy']
61+
files: ['demo/*', 'publish.js'],
62+
tasks: ['jshint', 'build:gh-pages']
6263
}
6364
},
65+
6466
karma: {
6567
unit: testConfig('test/karma.conf.js'),
6668
server: {configFile: 'test/karma.conf.js'},
@@ -69,58 +71,66 @@ module.exports = function (grunt) {
6971

7072
connect: {
7173
options: {
72-
base : '<%= dist %>',
74+
base : 'out/built/gh-pages',
7375
port: grunt.option('port') || '8000',
7476
hostname: grunt.option('host') || 'localhost',
75-
open : true
77+
open: 'http://<%= connect.options.hostname %>:<%= connect.options.port %>',
78+
livereload: grunt.option('port') || '8000'
7679
},
7780
server: { options: { keepalive: true } },
7881
continuous: { options: { keepalive: false } }
7982
},
8083

81-
jshint:{
82-
all:['<%= meta.view.repoName %>.js', 'gruntFile.js','test/*.js', 'demo/*.js'],
83-
options:{
84-
curly:true,
85-
eqeqeq:true,
86-
immed:true,
87-
latedef:true,
88-
newcap:true,
89-
noarg:true,
90-
sub:true,
91-
boss:true,
92-
eqnull:true,
93-
globals:{}
84+
jshint: {
85+
src: {
86+
files:{ src : ['src/*.js', 'demo/**/*.js'] },
87+
options: { jshintrc: '.jshintrc' }
88+
},
89+
test: {
90+
files:{ src : [ 'test/*.spec.js', 'publish.js', 'gruntFile.js'] },
91+
options: grunt.util._.extend({}, grunt.file.readJSON('.jshintrc'), {
92+
node: true,
93+
globals: {
94+
angular: false,
95+
inject: false,
96+
jQuery: false,
97+
98+
jasmine: false,
99+
afterEach: false,
100+
beforeEach: false,
101+
ddescribe: false,
102+
describe: false,
103+
expect: false,
104+
iit: false,
105+
it: false,
106+
spyOn: false,
107+
xdescribe: false,
108+
xit: false
109+
}
110+
})
94111
}
95112
},
113+
96114
uglify: {
97115
options: {banner: '<%= meta.banner %>'},
98116
build: {
99-
files: {
100-
'<%= dist %>/build/<%= meta.view.repoName %>.min.js': ['<%= meta.view.repoName %>.js']
101-
}
117+
expand: true,
118+
cwd: 'dist',
119+
src: ['*.js'],
120+
ext: '.min.js',
121+
dest: 'dist'
102122
}
103123
},
104-
copy: {
124+
125+
ngmin: {
105126
main: {
106-
files: [
107-
{src: ['<%= meta.view.repoName %>.js'], dest: '<%= dist %>/build/<%= meta.view.repoName %>.js', filter: 'isFile'}
108-
]
109-
},
110-
template : {
111-
options : {processContent : function(content){
112-
return grunt.template.process(content);
113-
}},
114-
files: [
115-
{src: ['<%= dist %>/.tmpl/index.tmpl'], dest: '<%= dist %>/index.html'},
116-
{src: ['demo/demo.css'], dest: '<%= dist %>/assets/css/demo.css'}
117-
]
118-
.concat(
119-
_.map(js_dependencies.concat(css_dependencies), function (f) {
120-
return {src: [f], dest: '<%= dist %>/' + f, filter: 'isFile'};
121-
}))
127+
expand: true,
128+
cwd: 'src',
129+
src: ['*.js'],
130+
dest: 'dist'
122131
}
123132
},
133+
124134
changelog: {
125135
options: {
126136
dest: 'CHANGELOG.md'

package.json

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,27 @@
88
"main": "./ui-codemirror.js",
99
"dependencies": {},
1010
"devDependencies": {
11-
"grunt": "~0.4.1",
12-
"grunt-karma": "~0.7.1",
11+
"angular-ui-publisher": "~1.x",
12+
"grunt": "~0.4.2",
13+
"grunt-contrib-connect": "~0.5.0",
14+
"grunt-contrib-copy": "~0.4.1",
1315
"grunt-contrib-jshint": "~0.7.2",
1416
"grunt-contrib-uglify": "~0.2.7",
1517
"grunt-contrib-watch": "~0.5.3",
16-
"grunt-contrib-copy": "~0.4.1",
17-
"grunt-contrib-connect": "~0.5.0",
18-
"load-grunt-tasks": "~0.2.0",
1918
"grunt-conventional-changelog": "~1.0.0",
20-
"grunt-bump": "0.0.11"
19+
"grunt-karma": "~0.6.2",
20+
"grunt-ngmin": "0.0.3",
21+
"karma": "~0.10.8",
22+
"karma-chrome-launcher": "~0.1.1",
23+
"karma-coffee-preprocessor": "~0.1.1",
24+
"karma-firefox-launcher": "~0.1.2",
25+
"karma-html2js-preprocessor": "~0.1.0",
26+
"karma-jasmine": "~0.1.4",
27+
"karma-phantomjs-launcher": "~0.1.1",
28+
"karma-requirejs": "~0.2.0",
29+
"karma-script-launcher": "~0.1.0",
30+
"load-grunt-tasks": "~0.2.0",
31+
"requirejs": "~2.1.9"
2132
},
2233
"scripts": {},
2334
"repository": {

publish.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/* jshint node:true */
2+
3+
'use strict';
4+
5+
var fs = require('fs');
6+
var path = require('path');
7+
8+
module.exports = function() {
9+
10+
var js_dependencies =[
11+
'bower_components/angular-ui-bootstrap-bower/ui-bootstrap-tpls.min.js',
12+
'bower_components/codemirror/lib/codemirror.js',
13+
'bower_components/codemirror/mode/scheme/scheme.js',
14+
'bower_components/codemirror/mode/javascript/javascript.js',
15+
'bower_components/codemirror/mode/xml/xml.js',
16+
];
17+
18+
var css_dependencies = [
19+
'bower_components/codemirror/lib/codemirror.css',
20+
'bower_components/codemirror/theme/twilight.css'
21+
];
22+
23+
function putThemInVendorDir (filepath) {
24+
return 'vendor/' + path.basename(filepath);
25+
}
26+
27+
return {
28+
humaName : 'UI.CodeMirror',
29+
repoName : 'ui-codemirror',
30+
inlineHTML : fs.readFileSync(__dirname + '/demo/demo.html'),
31+
inlineJS : fs.readFileSync(__dirname + '/demo/demo.js'),
32+
css: css_dependencies.map(putThemInVendorDir),
33+
js : js_dependencies.map(putThemInVendorDir).concat(['dist/ui-codemirror.js']),
34+
tocopy : css_dependencies.concat(js_dependencies)
35+
};
36+
};

0 commit comments

Comments
 (0)