Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify and package for npm. #88

Closed
wants to merge 11 commits into from
Closed
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
2 changes: 1 addition & 1 deletion .bowerrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"directory": "sqwidget/lib"
"directory": "lib"
}
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.DS_Store
node_modules/
config.js

# temporary!
compiled/**/*.*
lib/
dist/
compiled/
sqwidget.js
5 changes: 5 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
npm-debug.log
node_modules
src
test
compiled
72 changes: 32 additions & 40 deletions Gruntfile.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ module.exports = (grunt) ->
grunt.loadNpmTasks 'grunt-contrib-coffee'
grunt.loadNpmTasks 'grunt-contrib-clean'
grunt.loadNpmTasks 'grunt-contrib-watch'
grunt.loadNpmTasks('grunt-contrib-connect')
grunt.loadNpmTasks('grunt-contrib-copy')
grunt.loadNpmTasks('grunt-contrib-requirejs')
grunt.loadNpmTasks('grunt-karma')

grunt.initConfig

clean:
all:
src: [ "compiled" ]
src: [ "compiled", "dist" ]

connect:
publisher:
Expand All @@ -21,21 +25,10 @@ module.exports = (grunt) ->
port: 8001
base: 'sqwidget'

widgets:
options:
middleware: (connect, options) -> [
(req, res, next) ->
res.setHeader('Access-Control-Allow-Origin', '*')
next()
connect.static(options.base)
]
port: 8002
base: 'widgets'

coffee:
tests:
expand: true
cwd: 'sqwidget/tests',
cwd: 'tests',
src: '**/*.coffee'
dest: 'compiled/tests/js'
ext: '.js'
Expand All @@ -46,49 +39,48 @@ module.exports = (grunt) ->

sqwidget:
expand: true
cwd: 'sqwidget/app',
cwd: 'src',
src: '**/*.coffee'
dest: 'compiled/sqwidget/js'
dest: 'compiled/js'
ext: '.js'
options:
sourceRoot: '../../../app'
bare: true
sourceMap: true

widgets:
expand: true
cwd: 'widgets/',
src: '**/*.coffee'
dest: 'compiled/widgets/js'
ext: '.js'
options:
bare: true
sourceMap: true
sourceMap: false

karma:
integration:
configFile: 'config/karma.conf.js',
configFile: 'karma.conf.js',

watch:
sqwidget:
files: ["sqwidget/app/**/*.coffee"]
tasks: ["build"]

widgets:
files: ["widgets/**/*.coffee"]
files: ["src/**/*.coffee"]
tasks: ["build"]

karma:
files: ["sqwidget/**/*.coffee", "sqwidget/tests/**/*.coffee"]
files: ["src/**/*.coffee", "tests/**/*.coffee"]
tasks: ["build", "karma"]

grunt.loadNpmTasks('grunt-contrib-coffee')
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-connect')
grunt.loadNpmTasks('grunt-contrib-copy')
grunt.loadNpmTasks('grunt-karma')
requirejs:
sqwidget:
options:
name: "sqwidget"
optimize: 'none'
baseUrl: "compiled/js",
mainConfigFile: "compiled/js/sqwidget.js",
out: "sqwidget.js"

grunt.registerTask "build", [ "coffee" ]
grunt.registerTask "test", [ "clean", "build", "karma", "watch:karma" ]
test:
options:
name: "index"
findNestedDependencies: true
optimize: 'none'
baseUrl: "widgets/test/js",
mainConfigFile: "widgets/test/js/index.js",
out: "dist/test.js"

grunt.registerTask "build", [ "coffee", "requirejs" ]
grunt.registerTask "dist", [ "coffee", "requirejs" ]
grunt.registerTask "test", [ "clean", "build", "karma" ]
grunt.registerTask "default", [ "clean", "build", "connect", "watch" ]

21 changes: 21 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
PATH := ./node_modules/.bin:${PATH}

.PHONY : init bower build test dist publish

init: bower
npm install

build:
grunt build

test:
grunt test

bower:
bower install

dist:
grunt dist

publish: dist
npm publish
File renamed without changes.
11 changes: 5 additions & 6 deletions config/karma.conf.js → karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = function(config) {
// set pre-processors to empty since karma has stupid defaults
preprocessors: { },
// base path, that will be used to resolve files and exclude
basePath: '../',
basePath: '.',

// frameworks to use
frameworks: ['mocha', 'requirejs'],
Expand All @@ -15,11 +15,10 @@ module.exports = function(config) {
files: [
'compiled/tests/js/test-main.js',
{pattern: 'node_modules/karma-chai-plugins/node_modules/chai/chai.js', included: false},
{pattern: 'compiled/js/**/*.js', included: false},
{pattern: 'compiled/tests/js/spec/**/*.js', included: false},
{pattern: 'compiled/tests/js/spec/**/*.js', included: false},
{pattern: 'compiled/sqwidget/js/**/*.js', included: false},
{pattern: 'widgets/**', included: false, watch: true},
{pattern: 'sqwidget/lib/**/*.js', included: false, watched: false},
{pattern: 'lib/**/*.js', included: false, watched: false},
{pattern: 'dist/**/*.js', included: false, watched: false},
],

// list of files to exclude
Expand Down Expand Up @@ -53,7 +52,7 @@ module.exports = function(config) {
browsers: [
//'Chrome',
//,'Firefox'
'PhantomJS'
'Chrome'
],

// If browser does not capture in given timeout [ms], kill it
Expand Down
24 changes: 20 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
{
"name": "pa-widgets",
"title": "Widgets for Press Association",
"version": "2.0.0",
"name": "sqwidget",
"title": "Sqwidget",
"version": "2.0.3",
"contributors": [
"Adhip Gupta <[email protected]>",
"Simon Elliott <[email protected]>"
],
"main": "sqwidget.js",
"files": ["sqwidget.js"],
"engines": {
"node": ">= 0.8.0"
},
"repository": {
"type": "git",
"url": "http://github.com/premagasar/sqwidget"
},
"bugs": {
"url": "http://github.com/premagasar/sqwidget/issues"
},
"dependencies": {},
"devDependencies": {
"grunt": "latest",
"grunt-contrib-connect": "latest",
"grunt-contrib-clean": "latest",
"grunt-contrib-requirejs": "~0.4.1",
"grunt-contrib-coffee": "latest",
"grunt-contrib-livereload": "latest",
"grunt-contrib-watch": "~0.5.3",
"grunt-contrib-copy": "~0.4.1",
"karma-script-launcher": "~0.1.0",
Expand All @@ -27,5 +38,10 @@
"karma-mocha": "~0.1.0",
"karma-sinon": "0.0.1",
"karma-chai-plugins": "~0.1.3"
},
"scripts": {
"prepublish": "make dist",
"build": "make build",
"test": "make test"
}
}
Loading