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

Commit 30bbd0e

Browse files
committed
Merge pull request #34 from douglasduteil/feat-publisher
feat: use angular-ui-publisher
2 parents 64058a8 + c75650b commit 30bbd0e

11 files changed

+253
-133
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
node_modules
2-
bower_components
2+
bower_components
3+
dist
4+
out

.jshintrc

+23
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

+7-9
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,17 @@
22
language: node_js
33
node_js:
44
- '0.10'
5-
- '0.8'
65
before_install:
76
- export DISPLAY=:99.0
87
- sh -e /etc/init.d/xvfb start
9-
- npm install -g bower grunt-cli
10-
- npm install
11-
- bower install
12-
before_script: bower_components/angular-ui-docs/.travis/before_script.sh
8+
- npm install -qg bower grunt-cli
9+
- npm install -q
10+
- bower install --force
11+
- bower install --force
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"
1315
script: grunt
14-
after_success: bower_components/angular-ui-docs/.travis/after_success.sh
15-
branches:
16-
only:
17-
- master
1816
env:
1917
global:
2018
- REPO="[email protected]:angular-ui/ui-map.git"

README.md

+7-34
Original file line numberDiff line numberDiff line change
@@ -98,45 +98,18 @@ grunt
9898
The karma task will try to open Firefox and Chrome as browser in which to run the tests. Make sure this is available or change the configuration in `test\karma.conf.js`
9999

100100

101-
### Watch
101+
### Grunt Serve
102102

103-
You can watch files change for your tests with
103+
We have one task to serve them all !
104104

105105
```sh
106-
grunt watch
106+
grunt serve
107107
```
108108

109-
Make sure to have a Karma server available with it.
109+
It's equal to run separately:
110110

111+
* `grunt connect:server` : giving you a development server at [http://127.0.0.1:8000/](http://127.0.0.1:8000/).
111112

112-
```sh
113-
grunt server
114-
```
115-
116-
(you can force a test on this server with `grunt karma:unit:run`)
117-
118-
119-
### Local Doc
120-
121-
The documentation is generated by bower and grunt. To build it run :
122-
123-
```sh
124-
grunt build-doc
125-
```
113+
* `grunt karma:server` : giving you a Karma server to run tests (at [http://localhost:9876/](http://localhost:9876/) by default). You can force a test on this server with `grunt karma:unit:run`.
126114

127-
And then, launch a built-in web server on the angular-ui-docs bower module
128-
129-
```sh
130-
cd bower_components/angular-ui-docs/
131-
php -S localhost:8000
132-
or
133-
python -m SimpleHTTPServer
134-
```
135-
136-
Then check your [http://localhost:8000/](http://localhost:8000/)
137-
138-
**Tips for fast development** : Inline everything
139-
140-
```sh
141-
grunt build-doc && cd bower_components/angular-ui-docs/ && php -S localhost:8000 && cd ../..
142-
```
115+
* `grunt watch` : will automatically test your code and build your demo. You can demo generation with `grunt build:gh-pages`.

bower.json

+3-4
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@
1010
],
1111
"main": "./ui-map.js",
1212
"dependencies": {
13-
"angular": ">= 1.0.2",
14-
"angular-ui-utils": "latest"
13+
"angular": "1.x",
14+
"angular-ui-utils": "0.x"
1515
},
1616
"devDependencies": {
17-
"angular-mocks": ">= 1.0.2",
18-
"angular-ui-docs": "angular-ui/angular-ui-docs"
17+
"angular-mocks": "1.x"
1918
}
2019
}

demo/demo.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
/* global console:false, google:false */
2+
/*jshint unused:false */
3+
'use strict';
4+
15
function initCall() {
2-
console.log("Google maps api initialized.");
3-
angular.bootstrap(document.getElementById("map"), ['doc.ui-map']);
6+
console.log('Google maps api initialized.');
7+
angular.bootstrap(document.getElementById('map'), ['doc.ui-map']);
48
}
59

610
angular.module('doc.ui-map', ['ui.map', 'prettifyDirective'])

gruntFile.js

+100-31
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,32 @@
1+
'use strict';
2+
13
module.exports = function (grunt) {
24

3-
grunt.loadNpmTasks('grunt-karma');
4-
grunt.loadNpmTasks('grunt-contrib-jshint');
5-
grunt.loadNpmTasks('grunt-contrib-uglify');
6-
grunt.loadNpmTasks('grunt-contrib-copy');
7-
grunt.loadNpmTasks('grunt-contrib-watch');
8-
grunt.loadNpmTasks('grunt-conventional-changelog');
5+
require('load-grunt-tasks')(grunt);
96

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

1531
var testConfig = function (configFile, customOptions) {
1632
var options = { configFile: configFile, singleRun: true };
@@ -33,10 +49,10 @@ module.exports = function (grunt) {
3349
' */',
3450
''].join('\n'),
3551
view: {
36-
humaName: "UI.Map",
37-
repoName: "ui-map",
38-
demoHTML: grunt.file.read("demo/demo.html"),
39-
demoJS: grunt.file.read("demo/demo.js"),
52+
humaName: 'UI.Map',
53+
repoName: 'ui-map',
54+
demoHTML: grunt.file.read('demo/demo.html'),
55+
demoJS: grunt.file.read('demo/demo.js'),
4056
css: [
4157
'assets/css/demos.css'
4258
],
@@ -47,39 +63,92 @@ module.exports = function (grunt) {
4763
]
4864
}
4965
},
66+
5067
watch: {
51-
karma: {
52-
files: ['ui-map.js', 'test/*.js'],
53-
tasks: ['karma:unit:run'] //NOTE the :run flag
68+
src: {
69+
files: ['src/*'],
70+
tasks: ['jshint:src', 'karma:unit:run', 'dist', 'build:gh-pages']
71+
},
72+
test: {
73+
files: ['test/*.js'],
74+
tasks: ['jshint:test', 'karma:unit:run']
75+
},
76+
demo: {
77+
files: ['demo/*', 'publish.js'],
78+
tasks: ['jshint', 'build:gh-pages']
79+
},
80+
livereload: {
81+
files: ['out/built/gh-pages/**/*'],
82+
options: { livereload: true }
5483
}
5584
},
85+
5686
karma: {
5787
unit: testConfig('test/karma.conf.js'),
58-
start: {configFile: 'test/karma.conf.js'}
88+
server: {configFile: 'test/karma.conf.js'},
89+
continuous: {configFile: 'test/karma.conf.js', background: true }
5990
},
60-
jshint: {
61-
files: ['<%= meta.view.repoName %>.js', 'gruntFile.js', 'test/**/*Spec.js', 'demo/**/*.js'],
91+
92+
connect: {
6293
options: {
63-
curly: true,
64-
eqeqeq: true,
65-
immed: true,
66-
latedef: true,
67-
newcap: true,
68-
noarg: true,
69-
sub: true,
70-
boss: true,
71-
eqnull: true,
72-
globals: {}
94+
base : 'out/built/gh-pages',
95+
open: true,
96+
livereload: true
97+
},
98+
server: { options: { keepalive: true } },
99+
continuous: { options: { keepalive: false } }
100+
},
101+
102+
jshint: {
103+
src: {
104+
files:{ src : ['src/*.js', 'demo/**/*.js'] },
105+
options: { jshintrc: '.jshintrc' }
106+
},
107+
test: {
108+
files:{ src : [ 'test/*.spec.js', 'gruntFile.js'] },
109+
options: grunt.util._.extend({}, grunt.file.readJSON('.jshintrc'), {
110+
node: true,
111+
globals: {
112+
angular: false,
113+
inject: false,
114+
jQuery: false,
115+
116+
jasmine: false,
117+
afterEach: false,
118+
beforeEach: false,
119+
ddescribe: false,
120+
describe: false,
121+
expect: false,
122+
iit: false,
123+
it: false,
124+
spyOn: false,
125+
xdescribe: false,
126+
xit: false
127+
}
128+
})
73129
}
74130
},
131+
75132
uglify: {
76133
options: {banner: '<%= meta.banner %>'},
77134
build: {
78-
files: {
79-
'<%= dist %>/build/<%= meta.view.repoName %>.min.js': ['<%= meta.view.repoName %>.js']
80-
}
135+
expand: true,
136+
cwd: 'dist',
137+
src: ['*.js'],
138+
ext: '.min.js',
139+
dest: 'dist'
140+
}
141+
},
142+
143+
ngmin: {
144+
main: {
145+
expand: true,
146+
cwd: 'src',
147+
src: ['*.js'],
148+
dest: 'dist'
81149
}
82150
},
151+
83152
copy: {
84153
main: {
85154
files: [

package.json

+21-7
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,27 @@
88
"main": "./ui-map.js",
99
"dependencies": {},
1010
"devDependencies": {
11-
"grunt": "~0.4.1",
12-
"grunt-karma": "~0.4.x",
13-
"grunt-contrib-jshint": "~0.5.3",
14-
"grunt-contrib-uglify": "~0.2.0",
15-
"grunt-contrib-copy": "~0.4.1",
16-
"grunt-contrib-watch": "~0.5.1",
17-
"grunt-conventional-changelog": "~1.0.0"
11+
"angular-ui-publisher": "1.x",
12+
"grunt": "0.4.x",
13+
"grunt-contrib-connect": "0.5.x",
14+
"grunt-contrib-copy": "0.5.x",
15+
"grunt-contrib-jshint": "0.8.x",
16+
"grunt-contrib-uglify": "0.2.x",
17+
"grunt-contrib-watch": "0.5.x",
18+
"grunt-conventional-changelog": "1.x",
19+
"grunt-karma": "0.6.x",
20+
"grunt-ngmin": "0.0.x",
21+
"karma": "0.10.x",
22+
"karma-chrome-launcher": "0.1.x",
23+
"karma-coffee-preprocessor": "0.1.x",
24+
"karma-firefox-launcher": "0.1.x",
25+
"karma-html2js-preprocessor": "0.1.x",
26+
"karma-jasmine": "0.1.x",
27+
"karma-phantomjs-launcher": "0.1.x",
28+
"karma-requirejs": "0.2.x",
29+
"karma-script-launcher": "0.1.x",
30+
"load-grunt-tasks": "0.2.x",
31+
"requirejs": "2.1.x"
1832
},
1933
"scripts": {},
2034
"repository": {

publish.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/* jshint node:true */
2+
3+
'use strict';
4+
5+
var fs = require('fs');
6+
7+
module.exports = function() {
8+
9+
var js_dependencies =[
10+
'https://rawgithub.com/angular-ui/ui-utils/master/modules/event/event.js',
11+
'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&callback=initCall'
12+
];
13+
14+
return {
15+
humaName : 'UI.Map',
16+
repoName : 'ui-map',
17+
inlineHTML : fs.readFileSync(__dirname + '/demo/demo.html'),
18+
inlineJS : fs.readFileSync(__dirname + '/demo/demo.js'),
19+
css: ['demo/demo.css'],
20+
js : js_dependencies.concat(['dist/ui-map.min.js'])
21+
};
22+
};

0 commit comments

Comments
 (0)