diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..08a4c71 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.js +node_modules +*.swp diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..b43bff9 --- /dev/null +++ b/.npmignore @@ -0,0 +1,4 @@ +*.coffee +todo +.git* +.project diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..c92eb9f --- /dev/null +++ b/.travis.yml @@ -0,0 +1,4 @@ +language: node_js +node_js: + - "0.10" + - "0.8" diff --git a/Cakefile b/Cakefile new file mode 100644 index 0000000..a8ca7e5 --- /dev/null +++ b/Cakefile @@ -0,0 +1,30 @@ +fs = require 'fs' +{exec} = require 'child_process' + +task 'tests', 'run tests through mocha', -> + console.log "Run tests with Mocha..." + command = "mocha tests.coffee --reporter spec " + command += "--compilers coffee:coffee-script --colors" + exec command, (err, stdout, stderr) -> + console.log stdout + if err + console.log "Running mocha caught exception: \n" + err + process.exit 1 + else + process.exit 0 + +task "build", "", -> + console.log "Compile main file..." + command = "coffee -c main.coffee" + exec command, (err, stdout, stderr) -> + if err + console.log "Running coffee-script compiler caught exception: \n" + err + else + console.log "Compilation succeeded." + + console.log stdout + +task "lint", "Run coffeelint on source files", -> + command = "coffeelint -f coffeelint.json main.coffee" + exec command, (err, stdout, stderr) -> + console.log stdout diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..36d2269 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +Copyright 2012 Cozy Cloud (contact@cozycloud.cc)) + +This project is free software released under the MIT/X11 license: + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..0545526 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +Make Express opiniated diff --git a/coffeelint.json b/coffeelint.json new file mode 100644 index 0000000..aaf045b --- /dev/null +++ b/coffeelint.json @@ -0,0 +1,6 @@ +{ + "indentation" : { + "value" : 4, + "level" : "error" + } +} diff --git a/main.coffee b/main.coffee new file mode 100644 index 0000000..eb14ba6 --- /dev/null +++ b/main.coffee @@ -0,0 +1,39 @@ +async = require 'async' + +_loadModels = (root, requests) -> + models = [] + for docType, docRequests of requests + models[docType] = require "#{root}/models/#{docType}" + models + + +_getRequestCreator = (root, models, docType, requestName, request) -> + (cb) -> + console.log "#{docType} - #{requestName} request creation..." + models[docType].defineRequest requestName, request, (err) -> + if err then console.log "... fail" + else console.log "... ok" + cb err + +_loadRequestCreators = (root, models, requests) -> + requestsToSave = [] + for docType, docRequests of requests + for requestName, docRequest of docRequests + requestsToSave.push( + _getRequestCreator(root, models, docType, \ + requestName, docRequest)) + requestsToSave + +module.exports = (root, app, callback) -> + requests = require "#{root}/models/requests" + models = _loadModels root, requests + requestsToSave = _loadRequestCreators root, models, requests + + async.series requestsToSave, (err) -> + if err and err.code isnt 'EEXIST' + console.log "A request creation failed, abandon." + console.log err + callback err if callback? + else + console.log "All requests have been created" + callback() if callback? diff --git a/package.json b/package.json new file mode 100644 index 0000000..5bf9132 --- /dev/null +++ b/package.json @@ -0,0 +1,40 @@ +{ + "name": "americano-cozy", + "version": "0.1.0", + "description": "Americanp helpers to build Cozy applications faster", + "main": "./main.js", + "dependencies": { + "async": "*" + }, + "devDependencies": { + "coffee-script": "*", + "chai": "*", + "mocha": "*" + }, + "optionalDependencies": {}, + "scripts": { + "prepublish": "cake build", + "test": "cake tests" + }, + "keywords": [ + "plugin" + ], + "licenses": [ + { + "type": "MIT", + "url": "https://github.com/frankrousseau/americano-cozy/blob/master/LICENSE" + } + ], + "bugs": { + "url": "https://github.com/frankrousseau/americano/issues" + }, + "author": "Frank R", + "contributors": [], + "engines": { + "node": "*" + }, + "repository": { + "type": "git", + "url": "https://github.com/frankrousseau/americano-cozy.git" + } +}