This repository has been archived by the owner on Oct 28, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit be4ddb3
Showing
9 changed files
with
148 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*.js | ||
node_modules | ||
*.swp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
*.coffee | ||
todo | ||
.git* | ||
.project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
language: node_js | ||
node_js: | ||
- "0.10" | ||
- "0.8" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Make Express opiniated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"indentation" : { | ||
"value" : 4, | ||
"level" : "error" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
} |