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

Feat publisher #34

Merged
merged 10 commits into from
Dec 28, 2013
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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
node_modules
bower_components
bower_components
dist
out
23 changes: 23 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"boss": true,
"browser": true,
"eqnull": true,
"expr": true,
"globalstrict": true,
"immed": true,
"laxbreak": true,
"loopfunc": true,
"newcap": true,
"noarg": true,
"noempty": true,
"nonew": true,
"quotmark": true,
"smarttabs": true,
"sub": true,
"trailing": true,
"undef": true,
"unused": true,
"globals": {
"angular": false
}
}
16 changes: 7 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@
language: node_js
node_js:
- '0.10'
- '0.8'
before_install:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- npm install -g bower grunt-cli
- npm install
- bower install
before_script: bower_components/angular-ui-docs/.travis/before_script.sh
- npm install -qg bower grunt-cli
- npm install -q
- bower install --force
- bower install --force
after_success:
- "./node_modules/angular-ui-publisher/travis/authentication.sh || exit 0"
- "grunt dist build:gh-pages publish:gh-pages build:bower publish:bower"
script: grunt
after_success: bower_components/angular-ui-docs/.travis/after_success.sh
branches:
only:
- master
env:
global:
- REPO="[email protected]:angular-ui/ui-map.git"
Expand Down
41 changes: 7 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,45 +98,18 @@ grunt
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`


### Watch
### Grunt Serve

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

```sh
grunt watch
grunt serve
```

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

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

```sh
grunt server
```

(you can force a test on this server with `grunt karma:unit:run`)


### Local Doc

The documentation is generated by bower and grunt. To build it run :

```sh
grunt build-doc
```
* `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`.

And then, launch a built-in web server on the angular-ui-docs bower module

```sh
cd bower_components/angular-ui-docs/
php -S localhost:8000
or
python -m SimpleHTTPServer
```

Then check your [http://localhost:8000/](http://localhost:8000/)

**Tips for fast development** : Inline everything

```sh
grunt build-doc && cd bower_components/angular-ui-docs/ && php -S localhost:8000 && cd ../..
```
* `grunt watch` : will automatically test your code and build your demo. You can demo generation with `grunt build:gh-pages`.
7 changes: 3 additions & 4 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@
],
"main": "./ui-map.js",
"dependencies": {
"angular": ">= 1.0.2",
"angular-ui-utils": "latest"
"angular": "1.x",
"angular-ui-utils": "0.x"
},
"devDependencies": {
"angular-mocks": ">= 1.0.2",
"angular-ui-docs": "angular-ui/angular-ui-docs"
"angular-mocks": "1.x"
}
}
8 changes: 6 additions & 2 deletions demo/demo.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
/* global console:false, google:false */
/*jshint unused:false */
'use strict';

function initCall() {
console.log("Google maps api initialized.");
angular.bootstrap(document.getElementById("map"), ['doc.ui-map']);
console.log('Google maps api initialized.');
angular.bootstrap(document.getElementById('map'), ['doc.ui-map']);
}

angular.module('doc.ui-map', ['ui.map', 'prettifyDirective'])
Expand Down
131 changes: 100 additions & 31 deletions gruntFile.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
'use strict';

module.exports = function (grunt) {

grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-conventional-changelog');
require('load-grunt-tasks')(grunt);

// Default task.
grunt.registerTask('default', ['jshint', 'karma:unit']);
grunt.registerTask('build-doc', ['uglify', 'copy']);
grunt.registerTask('server', ['karma:start']);
grunt.registerTask('serve', ['karma:continuous', 'dist', 'build:gh-pages', 'connect:continuous', 'watch']);
grunt.registerTask('dist', ['ngmin', 'uglify']);

// 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/angular-ui-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 All @@ -33,10 +49,10 @@ module.exports = function (grunt) {
' */',
''].join('\n'),
view: {
humaName: "UI.Map",
repoName: "ui-map",
demoHTML: grunt.file.read("demo/demo.html"),
demoJS: grunt.file.read("demo/demo.js"),
humaName: 'UI.Map',
repoName: 'ui-map',
demoHTML: grunt.file.read('demo/demo.html'),
demoJS: grunt.file.read('demo/demo.js'),
css: [
'assets/css/demos.css'
],
Expand All @@ -47,39 +63,92 @@ module.exports = function (grunt) {
]
}
},

watch: {
karma: {
files: ['ui-map.js', 'test/*.js'],
tasks: ['karma:unit:run'] //NOTE the :run flag
src: {
files: ['src/*'],
tasks: ['jshint:src', 'karma:unit:run', 'dist', 'build:gh-pages']
},
test: {
files: ['test/*.js'],
tasks: ['jshint:test', 'karma:unit:run']
},
demo: {
files: ['demo/*', 'publish.js'],
tasks: ['jshint', 'build:gh-pages']
},
livereload: {
files: ['out/built/gh-pages/**/*'],
options: { livereload: true }
}
},

karma: {
unit: testConfig('test/karma.conf.js'),
start: {configFile: 'test/karma.conf.js'}
server: {configFile: 'test/karma.conf.js'},
continuous: {configFile: 'test/karma.conf.js', background: true }
},
jshint: {
files: ['<%= meta.view.repoName %>.js', 'gruntFile.js', 'test/**/*Spec.js', 'demo/**/*.js'],

connect: {
options: {
curly: true,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
boss: true,
eqnull: true,
globals: {}
base : 'out/built/gh-pages',
open: true,
livereload: true
},
server: { options: { keepalive: true } },
continuous: { options: { keepalive: false } }
},

jshint: {
src: {
files:{ src : ['src/*.js', 'demo/**/*.js'] },
options: { jshintrc: '.jshintrc' }
},
test: {
files:{ src : [ 'test/*.spec.js', 'gruntFile.js'] },
options: grunt.util._.extend({}, grunt.file.readJSON('.jshintrc'), {
node: true,
globals: {
angular: false,
inject: false,
jQuery: false,

jasmine: false,
afterEach: false,
beforeEach: false,
ddescribe: false,
describe: false,
expect: false,
iit: false,
it: false,
spyOn: false,
xdescribe: false,
xit: false
}
})
}
},

uglify: {
options: {banner: '<%= meta.banner %>'},
build: {
files: {
'<%= dist %>/build/<%= meta.view.repoName %>.min.js': ['<%= meta.view.repoName %>.js']
}
expand: true,
cwd: 'dist',
src: ['*.js'],
ext: '.min.js',
dest: 'dist'
}
},

ngmin: {
main: {
expand: true,
cwd: 'src',
src: ['*.js'],
dest: 'dist'
}
},

copy: {
main: {
files: [
Expand Down
28 changes: 21 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,27 @@
"main": "./ui-map.js",
"dependencies": {},
"devDependencies": {
"grunt": "~0.4.1",
"grunt-karma": "~0.4.x",
"grunt-contrib-jshint": "~0.5.3",
"grunt-contrib-uglify": "~0.2.0",
"grunt-contrib-copy": "~0.4.1",
"grunt-contrib-watch": "~0.5.1",
"grunt-conventional-changelog": "~1.0.0"
"angular-ui-publisher": "1.x",
"grunt": "0.4.x",
"grunt-contrib-connect": "0.5.x",
"grunt-contrib-copy": "0.5.x",
"grunt-contrib-jshint": "0.8.x",
"grunt-contrib-uglify": "0.2.x",
"grunt-contrib-watch": "0.5.x",
"grunt-conventional-changelog": "1.x",
"grunt-karma": "0.6.x",
"grunt-ngmin": "0.0.x",
"karma": "0.10.x",
"karma-chrome-launcher": "0.1.x",
"karma-coffee-preprocessor": "0.1.x",
"karma-firefox-launcher": "0.1.x",
"karma-html2js-preprocessor": "0.1.x",
"karma-jasmine": "0.1.x",
"karma-phantomjs-launcher": "0.1.x",
"karma-requirejs": "0.2.x",
"karma-script-launcher": "0.1.x",
"load-grunt-tasks": "0.2.x",
"requirejs": "2.1.x"
},
"scripts": {},
"repository": {
Expand Down
22 changes: 22 additions & 0 deletions publish.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* jshint node:true */

'use strict';

var fs = require('fs');

module.exports = function() {

var js_dependencies =[
'https://rawgithub.com/angular-ui/ui-utils/master/modules/event/event.js',
'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&callback=initCall'
];

return {
humaName : 'UI.Map',
repoName : 'ui-map',
inlineHTML : fs.readFileSync(__dirname + '/demo/demo.html'),
inlineJS : fs.readFileSync(__dirname + '/demo/demo.js'),
css: ['demo/demo.css'],
js : js_dependencies.concat(['dist/ui-map.min.js'])
};
};
Loading