From c0cc7028b5d51e5c6f3795562bcc237fdd49b726 Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Sun, 27 Jul 2014 00:44:46 +0800 Subject: [PATCH] first commit --- .gitignore | 16 ++++++ .jshintignore | 4 ++ .jshintrc | 95 +++++++++++++++++++++++++++++++++++ .npmignore | 8 +++ .travis.yml | 5 ++ AUTHORS | 0 LICENSE.txt | 21 ++++++++ Makefile | 51 +++++++++++++++++++ README.md | 60 ++++++++++++++++++++++ index.js | 1 + lib/npm-user-service.js | 17 +++++++ package.json | 44 ++++++++++++++++ test/npm-user-service.test.js | 22 ++++++++ 13 files changed, 344 insertions(+) create mode 100644 .gitignore create mode 100644 .jshintignore create mode 100644 .jshintrc create mode 100644 .npmignore create mode 100644 .travis.yml create mode 100644 AUTHORS create mode 100644 LICENSE.txt create mode 100644 Makefile create mode 100644 README.md create mode 100644 index.js create mode 100644 lib/npm-user-service.js create mode 100644 package.json create mode 100644 test/npm-user-service.test.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c0a6490 --- /dev/null +++ b/.gitignore @@ -0,0 +1,16 @@ +coverage.html +*.seed +*.log +*.csv +*.dat +*.out +*.pid +*.gz + +pids +logs +results + +node_modules +npm-debug.log +coverage/ diff --git a/.jshintignore b/.jshintignore new file mode 100644 index 0000000..63c6333 --- /dev/null +++ b/.jshintignore @@ -0,0 +1,4 @@ +node_modules/ +coverage/ +.tmp/ +.git/ diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..5988707 --- /dev/null +++ b/.jshintrc @@ -0,0 +1,95 @@ +{ + // JSHint Default Configuration File (as on JSHint website) + // See http://jshint.com/docs/ for more details + + "maxerr" : 50, // {int} Maximum error before stopping + + // Enforcing + "bitwise" : true, // true: Prohibit bitwise operators (&, |, ^, etc.) + "camelcase" : false, // true: Identifiers must be in camelCase + "curly" : true, // true: Require {} for every new block or scope + "eqeqeq" : true, // true: Require triple equals (===) for comparison + "forin" : false, // true: Require filtering for..in loops with obj.hasOwnProperty() + "immed" : false, // true: Require immediate invocations to be wrapped in parens e.g. `(function () { } ());` + "indent" : false, // {int} Number of spaces to use for indentation + "latedef" : false, // true: Require variables/functions to be defined before being used + "newcap" : false, // true: Require capitalization of all constructor functions e.g. `new F()` + "noarg" : true, // true: Prohibit use of `arguments.caller` and `arguments.callee` + "noempty" : true, // true: Prohibit use of empty blocks + "nonew" : false, // true: Prohibit use of constructors for side-effects (without assignment) + "plusplus" : false, // true: Prohibit use of `++` & `--` + "quotmark" : false, // Quotation mark consistency: + // false : do nothing (default) + // true : ensure whatever is used is consistent + // "single" : require single quotes + // "double" : require double quotes + "undef" : true, // true: Require all non-global variables to be declared (prevents global leaks) + "unused" : false, // true: Require all defined variables be used + "strict" : true, // true: Requires all functions run in ES5 Strict Mode + "trailing" : false, // true: Prohibit trailing whitespaces + "maxparams" : false, // {int} Max number of formal params allowed per function + "maxdepth" : false, // {int} Max depth of nested blocks (within functions) + "maxstatements" : false, // {int} Max number statements per function + "maxcomplexity" : false, // {int} Max cyclomatic complexity per function + "maxlen" : false, // {int} Max number of characters per line + + // Relaxing + "asi" : false, // true: Tolerate Automatic Semicolon Insertion (no semicolons) + "boss" : true, // true: Tolerate assignments where comparisons would be expected + "debug" : false, // true: Allow debugger statements e.g. browser breakpoints. + "eqnull" : false, // true: Tolerate use of `== null` + "es5" : false, // true: Allow ES5 syntax (ex: getters and setters) + "esnext" : true, // true: Allow ES.next (ES6) syntax (ex: `const`) + "moz" : false, // true: Allow Mozilla specific syntax (extends and overrides esnext features) + // (ex: `for each`, multiple try/catch, function expression…) + "evil" : false, // true: Tolerate use of `eval` and `new Function()` + "expr" : true, // true: Tolerate `ExpressionStatement` as Programs + "funcscope" : false, // true: Tolerate defining variables inside control statements" + "globalstrict" : false, // true: Allow global "use strict" (also enables 'strict') + "iterator" : false, // true: Tolerate using the `__iterator__` property + "lastsemic" : false, // true: Tolerate omitting a semicolon for the last statement of a 1-line block + "laxbreak" : true, // true: Tolerate possibly unsafe line breakings + "laxcomma" : false, // true: Tolerate comma-first style coding + "loopfunc" : false, // true: Tolerate functions being defined in loops + "multistr" : true, // true: Tolerate multi-line strings + "proto" : false, // true: Tolerate using the `__proto__` property + "scripturl" : false, // true: Tolerate script-targeted URLs + "smarttabs" : false, // true: Tolerate mixed tabs/spaces when used for alignment + "shadow" : true, // true: Allows re-define variables later in code e.g. `var x=1; x=2;` + "sub" : false, // true: Tolerate using `[]` notation when it can still be expressed in dot notation + "supernew" : false, // true: Tolerate `new function () { ... };` and `new Object;` + "validthis" : false, // true: Tolerate using this in a non-constructor function + + // Environments + "browser" : true, // Web Browser (window, document, etc) + "couch" : false, // CouchDB + "devel" : true, // Development/debugging (alert, confirm, etc) + "dojo" : false, // Dojo Toolkit + "jquery" : false, // jQuery + "mootools" : false, // MooTools + "node" : true, // Node.js + "nonstandard" : false, // Widely adopted globals (escape, unescape, etc) + "prototypejs" : false, // Prototype and Scriptaculous + "rhino" : false, // Rhino + "worker" : false, // Web Workers + "wsh" : false, // Windows Scripting Host + "yui" : false, // Yahoo User Interface + "noyield" : true, // allow generators without a yield + + // Legacy + "nomen" : false, // true: Prohibit dangling `_` in variables + "onevar" : false, // true: Allow only one `var` statement per function + "passfail" : false, // true: Stop on first error + "white" : false, // true: Check against strict whitespace and indentation rules + + // Custom Globals + "globals" : { // additional predefined global variables + // mocha + "describe": true, + "it": true, + "before": true, + "afterEach": true, + "beforeEach": true, + "after": true + } +} diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..3ea0ef2 --- /dev/null +++ b/.npmignore @@ -0,0 +1,8 @@ +test/ +Makefile +.travis.yml +logo.png +.jshintignore +.jshintrc +.gitingore +coverage/ diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..7364872 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,5 @@ +language: node_js +node_js: + - '0.11' +script: "make test-travis" +after_script: "npm install coveralls@2 && cat ./coverage/lcov.info | coveralls" diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..e69de29 diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..186a552 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,21 @@ +This software is licensed under the MIT License. + +Copyright (c) 2014 fengmk2 and other contributors + +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/Makefile b/Makefile new file mode 100644 index 0000000..ca847ed --- /dev/null +++ b/Makefile @@ -0,0 +1,51 @@ +TESTS = test/*.test.js +REPORTER = spec +TIMEOUT = 1000 +MOCHA_OPTS = + +install: + @npm install --registry=https://registry.npm.taobao.org --disturl=https://npm.taobao.org/dist + +jshint: install + @./node_modules/.bin/jshint . + +test: install + @NODE_ENV=test ./node_modules/.bin/mocha \ + --harmony \ + --reporter $(REPORTER) \ + --timeout $(TIMEOUT) \ + $(MOCHA_OPTS) \ + $(TESTS) + +test-cov cov: install + @NODE_ENV=test node --harmony \ + node_modules/.bin/istanbul cover --preserve-comments \ + ./node_modules/.bin/_mocha \ + -- \ + --reporter $(REPORTER) \ + --timeout $(TIMEOUT) \ + $(MOCHA_OPTS) \ + $(TESTS) + @./node_modules/.bin/cov coverage + +test-travis: install + @NODE_ENV=test node --harmony \ + node_modules/.bin/istanbul cover --preserve-comments \ + ./node_modules/.bin/_mocha \ + --report lcovonly \ + -- \ + --reporter dot \ + --timeout $(TIMEOUT) \ + $(MOCHA_OPTS) \ + $(TESTS) + +test-all: install jshint test cov + +autod: install + @./node_modules/.bin/autod -w --prefix "~" + @$(MAKE) install + +contributors: install + @./node_modules/.bin/contributors -f plain -o AUTHORS + +.PHONY: test diff --git a/README.md b/README.md new file mode 100644 index 0000000..288bc54 --- /dev/null +++ b/README.md @@ -0,0 +1,60 @@ +npm-user-service +======= + +[![NPM version][npm-image]][npm-url] +[![build status][travis-image]][travis-url] +[![Test coverage][coveralls-image]][coveralls-url] +[![Gittip][gittip-image]][gittip-url] +[![David deps][david-image]][david-url] + +[npm-image]: https://img.shields.io/npm/v/npm-user-service.svg?style=flat +[npm-url]: https://npmjs.org/package/npm-user-service +[travis-image]: https://img.shields.io/travis/cnpm/npm-user-service.svg?style=flat +[travis-url]: https://travis-ci.org/cnpm/npm-user-service +[coveralls-image]: https://img.shields.io/coveralls/cnpm/npm-user-service.svg?style=flat +[coveralls-url]: https://coveralls.io/r/cnpm/npm-user-service?branch=master +[gittip-image]: https://img.shields.io/gittip/fengmk2.svg?style=flat +[gittip-url]: https://www.gittip.com/fengmk2/ +[david-image]: https://img.shields.io/david/cnpm/npm-user-service.svg?style=flat +[david-url]: https://david-dm.org/cnpm/npm-user-service + +npm user service for [cnpmjs.org](https://github.com/cnpm/cnpmjs.org/wiki/Use-Your-Own-User-Authorization) + +## Install + +```bash +$ npm install npm-user-service --save +``` + +## Usage + +```js +var NpmUserService = require('npm-user-service'); + +config.userService = new NpmUserService(); +``` + +## License + +(The MIT License) + +Copyright (c) 2014 fengmk2 <fengmk2@gmail.com> and other contributors + +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/index.js b/index.js new file mode 100644 index 0000000..fdc8572 --- /dev/null +++ b/index.js @@ -0,0 +1 @@ +module.exports = require('./lib/npm-user-service'); \ No newline at end of file diff --git a/lib/npm-user-service.js b/lib/npm-user-service.js new file mode 100644 index 0000000..e3ac0a1 --- /dev/null +++ b/lib/npm-user-service.js @@ -0,0 +1,17 @@ +/**! + * npm-user-service - lib/npm-user-service.js + * + * Copyright(c) 2014 fengmk2 and other contributors. + * MIT Licensed + * + * Authors: + * fengmk2 (http://fengmk2.github.com) + */ + +"use strict"; + +/** + * Module dependencies. + */ + +var varname = require('modulename'); diff --git a/package.json b/package.json new file mode 100644 index 0000000..a8e11a4 --- /dev/null +++ b/package.json @@ -0,0 +1,44 @@ +{ + "name": "npm-user-service", + "version": "0.0.0", + "description": "npm user service for cnpmjs.org", + "main": "index.js", + "scripts": { + "test": "make test-all" + }, + "config": { + "cov": { + "threshold": 100 + } + }, + "dependencies": { + + }, + "devDependencies": { + "autod": "*", + "contributors": "*", + "should": "*", + "jshint": "*", + "cov": "*", + "istanbul-harmony": "*", + "mocha": "*" + }, + "homepage": "https://github.com/cnpm/npm-user-service", + "repository": { + "type": "git", + "url": "git://github.com/cnpm/npm-user-service.git", + "web": "https://github.com/cnpm/npm-user-service" + }, + "bugs": { + "url": "https://github.com/cnpm/npm-user-service/issues", + "email": "fengmk2@gmail.com" + }, + "keywords": [ + "npm-user-service", "user-service", "cnpm" + ], + "engines": { + "node": ">= 0.10.0" + }, + "author": "fengmk2 (http://fengmk2.github.com)", + "license": "MIT" +} diff --git a/test/npm-user-service.test.js b/test/npm-user-service.test.js new file mode 100644 index 0000000..b028942 --- /dev/null +++ b/test/npm-user-service.test.js @@ -0,0 +1,22 @@ +/**! + * npm-user-service - test/npm-user-service.test.js + * + * Copyright(c) 2014 fengmk2 and other contributors. + * MIT Licensed + * + * Authors: + * fengmk2 (http://fengmk2.github.com) + */ + +"use strict"; + +/** + * Module dependencies. + */ + +var should = require('should'); +var npm-user-service = require('../'); + +describe('npm-user-service.test.js', function () { + +});