Skip to content

Commit

Permalink
simplify sqwidget layout to be more suitable for module
Browse files Browse the repository at this point in the history
  • Loading branch information
purge committed Oct 2, 2013
1 parent 52f1fea commit 737d79f
Show file tree
Hide file tree
Showing 26 changed files with 90 additions and 238 deletions.
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"
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.DS_Store
node_modules/
config.js
lib/

# temporary!
dist/
Expand Down
49 changes: 11 additions & 38 deletions Gruntfile.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ 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-karma')


grunt.initConfig

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,29 @@ 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

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')

grunt.registerTask "build", [ "coffee" ]
grunt.registerTask "test", [ "clean", "build", "karma", "watch:karma" ]
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.
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: 'widgets/test/**/*.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
14 changes: 10 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
{
"name": "pa-widgets",
"title": "Widgets for Press Association",
"name": "sqwidget",
"title": "Sqwidget",
"version": "2.0.0",
"contributors": [
"Adhip Gupta <[email protected]>",
"Simon Elliott <[email protected]>"
],
"main": "compiled/js/sqwidget.js",
"engines": {
"node": ">= 0.8.0"
},
"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 +30,8 @@
"karma-mocha": "~0.1.0",
"karma-sinon": "0.0.1",
"karma-chai-plugins": "~0.1.3"
}
},
"scripts": {
"test": "make test"
},
}
24 changes: 0 additions & 24 deletions sqwidget/app/component/resources.coffee

This file was deleted.

1 change: 0 additions & 1 deletion sqwidget/compiled

This file was deleted.

2 changes: 0 additions & 2 deletions sqwidget/lib/.gitignore

This file was deleted.

27 changes: 0 additions & 27 deletions sqwidget/tests/test-main.coffee

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
define ['underscore','backbone'], (_, Backbone) ->
define ['underscore', 'backbone'], (_, Backbone) ->

class SqwidgetCore
constructor: () ->
Expand Down
6 changes: 0 additions & 6 deletions sqwidget/app/widget.coffee → src/sqwidget.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@ requirejs.config
paths:
jquery: '../../lib/jquery/jquery'
underscore: '../../lib/underscore-amd/underscore'
backbone: '../../lib/backbone-amd/backbone'
Ractive: '../../lib/ractive/Ractive'
text: '../../lib/requirejs-text/text',
rv: '../../lib/requirejs-ractive/rv',
normalize: '../../lib/normalize-css/normalize'
config: '../../config'

# The module that is loaded first
requirejs [
Expand Down
2 changes: 1 addition & 1 deletion sqwidget/tests/spec/core.coffee → tests/spec/core.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ define ['chai', 'jquery', 'component/core'], (chai, $, Core) ->
assert.ok "Triggered event"
assert.equal(src.html(),
'<div>TEST</div>'
'Rendered Ractive view correctly'
'Rendered correctly'
)
done()

23 changes: 23 additions & 0 deletions tests/test-main.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
tests = []

for file of window.__karma__.files
if /spec\//.test(file)
tests.push(file)


requirejs.config
baseUrl: "/base/compiled/js/"
paths:
chai: '../../node_modules/karma-chai-plugins/node_modules/chai/chai'
jquery: '../../lib/jquery/jquery'
underscore: '../../lib/underscore-amd/underscore'
backbone: '../../lib/backbone-amd/backbone'

deps: tests
callback: ->
#set the URI for the example widgets to the karma server port
window.__karma__.start()

#list all your unit files here
#require ["angular", "angularMocks", "/compiled/js/test/unit.js"], ->
#window.__karma__.start()
6 changes: 0 additions & 6 deletions widgets/hello-world/css/app.css

This file was deleted.

1 change: 0 additions & 1 deletion widgets/hello-world/js

This file was deleted.

29 changes: 0 additions & 29 deletions widgets/hello-world/src/index.coffee

This file was deleted.

1 change: 0 additions & 1 deletion widgets/pa-olympics-api/js

This file was deleted.

Loading

0 comments on commit 737d79f

Please sign in to comment.