Skip to content

Commit

Permalink
Initial build passing lint
Browse files Browse the repository at this point in the history
  • Loading branch information
avoidwork committed Dec 18, 2015
1 parent 5b4e432 commit f56ad44
Show file tree
Hide file tree
Showing 22 changed files with 1,836 additions and 3,102 deletions.
18 changes: 9 additions & 9 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"env": {
"browser": true,
"node": true,
"es6": true
"es6": true,
"amd": true
},
"ecmaFeatures": {
"jsx": true,
Expand All @@ -32,7 +33,7 @@
"func-names": [0],
"func-style": [0, "declaration"],
"generator-star-spacing": [2, "after"],
"global-strict": [2, "always"],
"strict": [2, "always"],
"guard-for-in": [0],
"handle-callback-err": [0],
"key-spacing": [2, { "beforeColon": false, "afterColon": true }],
Expand Down Expand Up @@ -63,7 +64,6 @@
"no-duplicate-case": [2],
"no-else-return": [0],
"no-empty": [2],
"no-empty-class": [2],
"no-empty-label": [2],
"no-eq-null": [0],
"no-eval": [2],
Expand All @@ -73,7 +73,7 @@
"no-extra-boolean-cast": [2],
"no-extra-parens": [0],
"no-extra-semi": [1],
"no-extra-strict": [2],
"no-empty-character-class": [2],
"no-fallthrough": [2],
"no-floating-decimal": [2],
"no-func-assign": [2],
Expand All @@ -93,7 +93,7 @@
"no-multi-spaces": [2],
"no-multi-str": [2],
"no-multiple-empty-lines": [2, { "max": 2 }],
"no-native-reassign": [1],
"no-native-reassign": [0],
"no-negated-in-lhs": [2],
"no-nested-ternary": [0],
"no-new": [2],
Expand All @@ -104,7 +104,7 @@
"no-obj-calls": [2],
"no-octal": [2],
"no-octal-escape": [2],
"no-param-reassign": [2],
"no-param-reassign": [0],
"no-path-concat": [0],
"no-plusplus": [0],
"no-process-env": [0],
Expand All @@ -120,7 +120,7 @@
"no-sequences": [2],
"no-shadow": [2],
"no-shadow-restricted-names": [2],
"no-space-before-semi": [2],
"semi-spacing": [2],
"no-spaced-func": [2],
"no-sparse-arrays": [2],
"no-sync": [0],
Expand All @@ -138,7 +138,7 @@
"no-void": [0],
"no-warning-comments": [0, { "terms": ["todo", "fixme", "xxx"], "location": "start" }],
"no-with": [2],
"no-wrap-func": [2],
"no-extra-parens": [2],
"one-var": [0],
"operator-assignment": [0, "always"],
"operator-linebreak": [2, "after"],
Expand Down Expand Up @@ -173,4 +173,4 @@
"wrap-regex": [2],
"yoda": [2, "never", { "exceptRange": true }]
}
}
}
80 changes: 16 additions & 64 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,65 +1,22 @@
module.exports = function (grunt) {
grunt.initConfig({
pkg : grunt.file.readJSON("package.json"),
concat : {
options : {
banner : "/**\n" +
" * <%= pkg.description %>\n" +
" *\n" +
" * @author <%= pkg.author.name %> <<%= pkg.author.email %>>\n" +
" * @copyright <%= grunt.template.today('yyyy') %> <%= pkg.author.name %>\n" +
" * @license <%= pkg.license %>\n" +
" * @link <%= pkg.homepage %>\n" +
" * @module <%= pkg.name %>\n" +
" * @version <%= pkg.version %>\n" +
" */\n"
},
dist : {
src : [
"src/intro.js",
"src/regex.js",
"src/sanitize.js",
"src/renderers.js",
"src/error.js",
"src/zuul.js",
"src/auth.js",
"src/bootstrap.js",
"src/clone.js",
"src/hypermedia.js",
"src/keymaster.js",
"src/prepare.js",
"src/rate.js",
"src/response.js",
"src/constructor.js",
"src/factory.js",
"src/outro.js"
],
dest : "lib/<%= pkg.name %>.es6.js"
}
},
babel: {
options: {
sourceMap: false
sourceMap: false,
presets: ["babel-preset-es2015"]
},
dist: {
files: {
"lib/<%= pkg.name %>.js": "lib/<%= pkg.name %>.es6.js"
}
files: [{
expand: true,
cwd: 'src',
src: ['*.js'],
dest: 'lib',
ext: '.js'
}]
}
},
eslint: {
target: ["lib/<%= pkg.name %>.es6.js"]
},
jsdoc : {
dist : {
src: ["lib/<%= pkg.name %>.js", "README.md"],
options: {
destination : "doc",
template : "node_modules/ink-docstrap/template",
configure : "docstrap.json",
"private" : false
}
}
target: ["src/*.js"]
},
mochaTest : {
options: {
Expand Down Expand Up @@ -110,20 +67,15 @@ module.exports = function (grunt) {
});

// tasks
grunt.loadNpmTasks("grunt-babel");
grunt.loadNpmTasks("grunt-eslint");
grunt.loadNpmTasks("grunt-mocha-test");
grunt.loadNpmTasks("grunt-nsp");
grunt.loadNpmTasks("grunt-sed");
grunt.loadNpmTasks("grunt-jsdoc");
grunt.loadNpmTasks("grunt-contrib-concat");
grunt.loadNpmTasks("grunt-contrib-watch");
grunt.loadNpmTasks("grunt-contrib-sass");
grunt.loadNpmTasks("grunt-mocha-test");
grunt.loadNpmTasks("grunt-nsp-package");
grunt.loadNpmTasks("grunt-babel");
grunt.loadNpmTasks("grunt-eslint");

// aliases
grunt.registerTask("build", ["concat", "sed", "sass", "babel"]);
grunt.registerTask("test", ["eslint", "mochaTest"]);
grunt.registerTask("default", ["build", "test"]);
grunt.registerTask("validate", "validate-package");
grunt.registerTask("package", ["validate", "default", "jsdoc"]);
grunt.registerTask("test", ["eslint", "mochaTest", "nsp"]);
grunt.registerTask("default", ["sass", "eslint", "babel", "mochaTest", "nsp"]);
};
5 changes: 4 additions & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@
"hsts": null,
"xssProtection": null
},
"serializers": [
"tenso"
],
"maxBytes": 1048576,
"port": 8000,
"routes": {},
Expand All @@ -101,4 +104,4 @@
"override": null
},
"title": "Tensō Browsable API"
}
}
34 changes: 34 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"use strict";

var fs = require("fs"),
path = require("path"),
root = path.join(__dirname, ".."),
cfg = require(path.join(root, "config.json")),
Tenso = require(path.join(__dirname, "tenso.js")),
utility = require(path.join(__dirname, "utility.js"));

function factory(arg) {
var hostname = arg ? arg.hostname || "localhost" : "localhost",
vhosts = {},
config = arg ? utility.merge(utility.clone(cfg), arg) : utility.clone(cfg),
obj = undefined;

if (!config.port) {
console.error("Invalid configuration");
process.exit(1);
}

vhosts[hostname] = "www";
config.root = root;
config.vhosts = vhosts;
config.default = hostname;
config.template = fs.readFileSync(path.join(config.root, "template.html"), { encoding: "utf8" });
obj = new Tenso();
obj.hostname = hostname;

return utility.bootstrap(obj, config);
}

factory.version = "{{VERSION}}";

module.exports = factory;
Loading

0 comments on commit f56ad44

Please sign in to comment.