diff --git a/node_modules/array-find-index/index.js b/node_modules/array-find-index/index.js new file mode 100644 index 0000000000000..e2dcd9a09c2bb --- /dev/null +++ b/node_modules/array-find-index/index.js @@ -0,0 +1,25 @@ +'use strict'; +module.exports = function (arr, predicate, ctx) { + if (typeof Array.prototype.findIndex === 'function') { + return arr.findIndex(predicate, ctx); + } + + if (typeof predicate !== 'function') { + throw new TypeError('predicate must be a function'); + } + + var list = Object(arr); + var len = list.length; + + if (len === 0) { + return -1; + } + + for (var i = 0; i < len; i++) { + if (predicate.call(ctx, list[i], i, list)) { + return i; + } + } + + return -1; +}; diff --git a/node_modules/array-find-index/license b/node_modules/array-find-index/license new file mode 100644 index 0000000000000..654d0bfe94343 --- /dev/null +++ b/node_modules/array-find-index/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +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/node_modules/array-find-index/package.json b/node_modules/array-find-index/package.json new file mode 100644 index 0000000000000..5c210da93e245 --- /dev/null +++ b/node_modules/array-find-index/package.json @@ -0,0 +1,71 @@ +{ + "_args": [ + [ + "array-find-index@1.0.2", + "/Users/zkat/Documents/code/work/npm" + ] + ], + "_development": true, + "_from": "array-find-index@1.0.2", + "_id": "array-find-index@1.0.2", + "_inBundle": false, + "_integrity": "sha1-3wEKoSh+Fku9pvlyOwqWoexBh6E=", + "_location": "/array-find-index", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "array-find-index@1.0.2", + "name": "array-find-index", + "escapedName": "array-find-index", + "rawSpec": "1.0.2", + "saveSpec": null, + "fetchSpec": "1.0.2" + }, + "_requiredBy": [ + "/spdx-compare" + ], + "_resolved": "https://registry.npmjs.org/array-find-index/-/array-find-index-1.0.2.tgz", + "_spec": "1.0.2", + "_where": "/Users/zkat/Documents/code/work/npm", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/sindresorhus/array-find-index/issues" + }, + "description": "ES2015 `Array#findIndex()` ponyfill", + "devDependencies": { + "ava": "*", + "xo": "*" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "homepage": "https://github.com/sindresorhus/array-find-index#readme", + "keywords": [ + "es2015", + "ponyfill", + "polyfill", + "shim", + "find", + "index", + "findindex", + "array" + ], + "license": "MIT", + "name": "array-find-index", + "repository": { + "type": "git", + "url": "git+https://github.com/sindresorhus/array-find-index.git" + }, + "scripts": { + "test": "xo && ava" + }, + "version": "1.0.2" +} diff --git a/node_modules/array-find-index/readme.md b/node_modules/array-find-index/readme.md new file mode 100644 index 0000000000000..31663411c3120 --- /dev/null +++ b/node_modules/array-find-index/readme.md @@ -0,0 +1,30 @@ +# array-find-index [![Build Status](https://travis-ci.org/sindresorhus/array-find-index.svg?branch=master)](https://travis-ci.org/sindresorhus/array-find-index) + +> ES2015 [`Array#findIndex()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex) [ponyfill](https://ponyfill.com) + + +## Install + +``` +$ npm install --save array-find-index +``` + + +## Usage + +```js +const arrayFindIndex = require('array-find-index'); + +arrayFindIndex(['rainbow', 'unicorn', 'pony'], x => x === 'unicorn'); +//=> 1 +``` + + +## API + +Same as `Array#findIndex()`, but with the input array as the first argument. + + +## License + +MIT © [Sindre Sorhus](https://sindresorhus.com) diff --git a/node_modules/docopt/.editorconfig b/node_modules/docopt/.editorconfig new file mode 100644 index 0000000000000..2ac4f2e33f757 --- /dev/null +++ b/node_modules/docopt/.editorconfig @@ -0,0 +1,11 @@ +# editorconfig.org + +root = true + +[package.json] +indent_style = space +indent_size = 2 + +[*.coffee] +indent_style = space +indent_size = 4 diff --git a/node_modules/docopt/.npmignore b/node_modules/docopt/.npmignore new file mode 100644 index 0000000000000..5bdd25d6992d3 --- /dev/null +++ b/node_modules/docopt/.npmignore @@ -0,0 +1,2 @@ +language_agnostic_tests +examples diff --git a/node_modules/docopt/.travis.yml b/node_modules/docopt/.travis.yml new file mode 100644 index 0000000000000..32c3c455c3206 --- /dev/null +++ b/node_modules/docopt/.travis.yml @@ -0,0 +1,12 @@ +language: node_js +sudo: false +node_js: + - "0.12" + - "0.11" + - "0.10" + - "iojs" +script: + - npm run test + - npm run lint +notifications: + email: false diff --git a/node_modules/docopt/LICENSE-MIT b/node_modules/docopt/LICENSE-MIT new file mode 100644 index 0000000000000..a063aa7b8cdf5 --- /dev/null +++ b/node_modules/docopt/LICENSE-MIT @@ -0,0 +1,20 @@ +Copyright (c) 2012 Vladimir Keleshev, + Andrew Kassen, + +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/node_modules/docopt/README.md b/node_modules/docopt/README.md new file mode 100644 index 0000000000000..bbcf584dbf69d --- /dev/null +++ b/node_modules/docopt/README.md @@ -0,0 +1,99 @@ +`docopt` – a command line option parser that will make you smile [![Build Status](https://travis-ci.org/stuartcarnie/docopt.coffee.svg)](https://travis-ci.org/stuartcarnie/docopt.coffee) +=============================================================== + +> [docopt](http://docopt.org) is a language for description of command-line +> interfaces. This is `docopt` implementation in CoffeeScript, that could +> be used for server-side CoffeeScript and JavaScript programs. + +Isn't it awesome how modern command-line arguments parsers generate +help message based on your code?! + +**Hell no!** You know what's awesome? When the option parser *is* generated +based on the help message that you write yourself! This way you don't need to +write this stupid repeatable parser-code, and instead can write a beautiful +help message (the way you want it!), which adds readability to your code. + +Now you can write an awesome, readable, clean, DRY code like *this*: + +```coffeescript +doc = """ +Usage: + quick_example.coffee tcp [--timeout=] + quick_example.coffee serial [--baud=9600] [--timeout=] + quick_example.coffee -h | --help | --version + +""" +{docopt} = require '../docopt' + +console.log docopt(doc, version: '0.1.1rc') +``` + +Hell yeah! The option parser is generated based on `doc` string above, that you +pass to the `docopt` function. + + + +API `{docopt} = require 'docopt'` +--------------------------------- + +### `options = docopt(doc, {argv: process.argv[2..], help: true, version: null, options_first: false, exit: true})` + +`docopt` takes 1 required argument, and 3 optional keyword arguments: + +* `doc` (required) should be a string with the help message, written according +to rules of the [docopt language](http://docopt.org). Here's a quick example: + + ```bash + Usage: your_program [options] + + -h --help Show this. + -v --verbose Print more text. + --quiet Print less text. + -o FILE Specify output file [default: ./test.txt]. + ``` + +* `argv` is an optional argument vector. It defaults to the arguments passed +to your program (`process.argv[2..]`). You can also supply it with an array +of strings, as with `process.argv`. For example: `['--verbose', '-o', 'hai.txt']`. + +* `help` (default:`true`) specifies whether the parser should automatically +print the help message (supplied as `doc`) in case `-h` or `--help` options +are encountered. After showing the usage-message, the program will terminate. +If you want to handle `-h` or `--help` options manually (the same as other options), +set `help=false`. + +* `version` (default:`null`) is an optional argument that specifies the +version of your program. If supplied, then, if the parser encounters +`--version` option, it will print the supplied version and terminate. +`version` could be any printable object, but most likely a string, +e.g. `'2.1.0rc1'`. + +* `options_first`, by default `false`. If set to `true` will +disallow mixing options and positional argument. I.e. after first +positional argument, all arguments will be interpreted as positional +even if the look like options. This can be used for strict +compatibility with POSIX, or if you want to dispatch your arguments +to other programs. + +* `exit`, by default `true`. If set to `false` will +cause docopt to throw exceptions instead of printing the error to console and terminating the application. +This flag is mainly for testing purposes. + +**Note:** Although `docopt` automatically handles `-h`, `--help` and `--version` options, +you still need to mention them in the options description (`doc`) for your users to +know about them. + +The **return** value is an `Object` with properties (giving long options precedence), +like this: + +```javascript +{'--timeout': '10', + '--baud': '4800', + '--version': false, + '--help': false, + '-h': false, + serial: true, + tcp: false, + '': false, + '': '/dev/ttyr01'} +``` diff --git a/node_modules/docopt/coffeelint.json b/node_modules/docopt/coffeelint.json new file mode 100644 index 0000000000000..99eba698119ec --- /dev/null +++ b/node_modules/docopt/coffeelint.json @@ -0,0 +1,120 @@ +{ + "arrow_spacing": { + "level": "ignore" + }, + "braces_spacing": { + "level": "ignore", + "spaces": 0 + }, + "camel_case_classes": { + "level": "error" + }, + "coffeescript_error": { + "level": "error" + }, + "colon_assignment_spacing": { + "level": "ignore", + "spacing": { + "left": 0, + "right": 0 + } + }, + "cyclomatic_complexity": { + "value": 10, + "level": "ignore" + }, + "duplicate_key": { + "level": "error" + }, + "empty_constructor_needs_parens": { + "level": "ignore" + }, + "ensure_comprehensions": { + "level": "warn" + }, + "indentation": { + "value": 4, + "level": "error" + }, + "line_endings": { + "level": "ignore", + "value": "unix" + }, + "max_line_length": { + "value": 80, + "level": "ignore", + "limitComments": true + }, + "missing_fat_arrows": { + "level": "ignore" + }, + "newlines_after_classes": { + "value": 3, + "level": "ignore" + }, + "no_backticks": { + "level": "error" + }, + "no_debugger": { + "level": "warn" + }, + "no_empty_functions": { + "level": "ignore" + }, + "no_empty_param_list": { + "level": "ignore" + }, + "no_implicit_braces": { + "level": "ignore", + "strict": true + }, + "no_implicit_parens": { + "strict": true, + "level": "ignore" + }, + "no_interpolation_in_single_quotes": { + "level": "ignore" + }, + "no_plusplus": { + "level": "ignore" + }, + "no_stand_alone_at": { + "level": "ignore" + }, + "no_tabs": { + "level": "error" + }, + "no_throwing_strings": { + "level": "error" + }, + "no_trailing_semicolons": { + "level": "error" + }, + "no_trailing_whitespace": { + "level": "error", + "allowed_in_comments": false, + "allowed_in_empty_lines": true + }, + "no_unnecessary_double_quotes": { + "level": "ignore" + }, + "no_unnecessary_fat_arrows": { + "level": "warn" + }, + "non_empty_constructor_needs_parens": { + "level": "ignore" + }, + "prefer_english_operator": { + "level": "ignore", + "doubleNotLevel": "ignore" + }, + "space_operators": { + "level": "ignore" + }, + "spacing_after_comma": { + "level": "ignore" + }, + "transform_messes_up_line_numbers": { + "level": "warn" + } +} diff --git a/node_modules/docopt/docopt.coffee b/node_modules/docopt/docopt.coffee new file mode 100644 index 0000000000000..89aceea17c876 --- /dev/null +++ b/node_modules/docopt/docopt.coffee @@ -0,0 +1,588 @@ +print = -> console.log [].join.call arguments, ' ' + +enumerate = (array) -> + i = 0 + ([i++, item] for item in array) + +any = (array) -> + return true in array + +zip = (args...) -> + lengthArray = (arr.length for arr in args) + length = Math.min(lengthArray...) + for i in [0...length] + arr[i] for arr in args + +String::partition = (separator) -> + self = this + if self.indexOf(separator) >= 0 + parts = self.split(separator) + return [parts[0], separator, parts.slice(1).join(separator)] + else + return [String(self), '', ''] + +String::startsWith = (searchString, position) -> + position = position || 0 + return this.lastIndexOf(searchString, position) == position + +String::endsWith = (searchString, position) -> + subjectString = this.toString() + if (position == undefined || position > subjectString.length) + position = subjectString.length + position -= searchString.length + lastIndex = subjectString.indexOf(searchString, position) + return lastIndex != -1 && lastIndex == position + +String::_split = -> + this.trim().split(/\s+/).filter (i) -> i != '' + +String::isUpper = -> + /^[A-Z]+$/g.exec(this) + +Number.isInteger = Number.isInteger || (value) -> + return typeof value == "number" && + isFinite(value) && + Math.floor(value) == value + +class DocoptLanguageError extends Error + constructor: (@message) -> + super @message + +class DocoptExit extends Error + constructor: (@message) -> + super @message + +class Pattern extends Object + + fix: -> + @fix_identities() + @fix_repeating_arguments() + @ + + fix_identities: (uniq=null) -> + """Make pattern-tree tips point to same object if they are equal.""" + + if not @hasOwnProperty 'children' then return @ + if uniq is null + [uniq, flat] = [{}, @flat()] + uniq[k] = k for k in flat + + for [i, c] in enumerate(@children) + if not c.hasOwnProperty 'children' + console.assert(uniq.hasOwnProperty(c)) + @children[i] = uniq[c] + else + c.fix_identities uniq + @ + + fix_repeating_arguments: -> + """Fix elements that should accumulate/increment values.""" + + either = (child.children for child in transform(@).children) + for mycase in either + counts = {} + for c in mycase + counts[c] = (if counts[c] then counts[c] else 0) + 1 + for e in (child for child in mycase when counts[child] > 1) + if e.constructor is Argument or e.constructor is Option and e.argcount + if e.value is null + e.value = [] + else if e.value.constructor isnt Array + e.value = e.value._split() + if e.constructor is Command or e.constructor is Option and e.argcount == 0 + e.value = 0 + @ + + +transform = (pattern) -> + """Expand pattern into an (almost) equivalent one, but with single Either. + + Example: ((-a | -b) (-c | -d)) => (-a -c | -a -d | -b -c | -b -d) + Quirks: [-a] => (-a), (-a...) => (-a -a) + + """ + result = [] + groups = [[pattern]] + while groups.length + children = groups.shift() + parents = [Required, Optional, OptionsShortcut, Either, OneOrMore] + if (any((t in (children.map (c) -> c.constructor)) for t in parents)) + child = (c for c in children when c.constructor in parents)[0] + index = children.indexOf(child) + if index >= 0 + children.splice(index, 1) + if child.constructor is Either + for c in child.children + groups.push([c].concat children) + else if child.constructor is OneOrMore + groups.push((child.children.concat(child.children)).concat children) + else + groups.push(child.children.concat children) + else + result.push(children) + + return new Either(new Required e for e in result) + + +class LeafPattern extends Pattern + """Leaf/terminal node of a pattern tree.""" + + constructor: (@name, @value=null) -> + + toString: -> "#{@.constructor.name}(#{@name}, #{@value})" + + flat: (types=[]) -> + types = if types instanceof Array then types else [types] + if not types.length or @.constructor in types + return [@] + else return [] + + match: (left, collected=null) -> + collected = [] if collected is null + [pos, match] = @.singleMatch left + if match is null + return [false, left, collected] + left_ = left.slice(0, pos).concat(left.slice(pos + 1)) + same_name = (a for a in collected when a.name == @.name) + if Number.isInteger(@value) or @value instanceof Array + if Number.isInteger(@value) + increment = 1 + else + increment = if typeof match.value == 'string' then [match.value] else match.value + if not same_name.length + match.value = increment + return [true, left_, collected.concat(match)] + if Number.isInteger(@value) + same_name[0].value += increment + else + same_name[0].value = [].concat(same_name[0].value, increment) + return [true, left_, collected] + return [true, left_, collected.concat(match)] + + +class BranchPattern extends Pattern + """Branch/inner node of a pattern tree.""" + + constructor: (children) -> + @children = if children instanceof Array then children else [children] + + toString: -> "#{@.constructor.name}(#{(a for a in @children).join(', ')})" + + flat: (types=[]) -> + types = if types instanceof Array then types else [types] + if @.constructor in types then return [@] + return (child.flat(types) for child in @children when child instanceof Pattern).reduce(((pv, cv) -> return [].concat pv, cv), []) + + +class Argument extends LeafPattern + + singleMatch: (left) -> + for [n, pattern] in enumerate(left) + if pattern.constructor is Argument + return [n, new Argument(@name, pattern.value)] + return [null, null] + + @parse: (source) -> + name = /(<\S*?>)/ig.exec(source)[1] + value = /\[default:\s+(.*)\]/ig.exec(source) + return new Argument(name, if value then value[1] else null) + + +class Command extends Argument + + constructor: (@name, @value=false) -> + + singleMatch: (left) -> + for [n, pattern] in enumerate(left) + if pattern.constructor is Argument + if pattern.value == @name + return [n, new Command(@name, true)] + else + break + return [null, null] + +class Option extends LeafPattern + + constructor: (@short=null, @long=null, @argcount=0, value=false) -> + console.assert(@argcount in [0,1]) + @value = if value is false and @argcount > 0 then null else value + @name = @long or @short + + toString: -> "Option(#{@short}, #{@long}, #{@argcount}, #{@value})" + + @parse: (option_description) -> + [short, long, argcount, value] = [null, null, 0, false] + [options, _, description] = option_description.trim().partition(' ') + options = options.replace /,|=/g, ' ' + for s in options._split() # split on spaces + if s.startsWith('--') + long = s + else if s.startsWith('-') + short = s + else + argcount = 1 + if argcount > 0 + matched = /\[default:\s+(.*)\]/ig.exec(description) + value = if matched then matched[1] else null + new Option short, long, argcount, value + + singleMatch: (left) -> + for [n, pattern] in enumerate(left) + if @name == pattern.name + return [n, pattern] + return [null, null] + + +class Required extends BranchPattern + + match: (left, collected=null) -> + collected = [] if collected is null + l = left #copy(left) + c = collected #copy(collected) + for p in @children + [matched, l, c] = p.match(l, c) + if not matched + return [false, left, collected] + [true, l, c] + + +class Optional extends BranchPattern + + match: (left, collected=null) -> + collected = [] if collected is null + #left = copy(left) + for p in @children + [m, left, collected] = p.match(left, collected) + [true, left, collected] + + +class OptionsShortcut extends Optional + """Marker/placeholder for [options] shortcut.""" + + +class OneOrMore extends BranchPattern + + match: (left, collected=null) -> + console.assert(@children.length == 1) + collected = [] if collected is null + l = left #copy(left) + c = collected #copy(collected) + l_ = [] + matched = true + times = 0 + while matched + # could it be that something didn't match but changed l or c? + [matched, l, c] = @children[0].match(l, c) + times += if matched then 1 else 0 + if l_.join(', ') == l.join(', ') then break + l_ = l #copy(l) + if times >= 1 then return [true, l, c] + [false, left, collected] + + +class Either extends BranchPattern + + match: (left, collected=null) -> + collected = [] if collected is null + outcomes = [] + for p in @children + outcome = p.match(left, collected) + if outcome[0] then outcomes.push(outcome) + if outcomes.length > 0 + outcomes.sort((a,b) -> + if a[1].length > b[1].length + 1 + else if a[1].length < b[1].length + -1 + else + 0) + return outcomes[0] + [false, left, collected] + + +# same as Tokens in python +class Tokens extends Array + + constructor: (source, @error=DocoptExit) -> + stream = if source.constructor is String then source._split() else source + @push.apply @, stream + + move: -> if @.length then [].shift.apply(@) else null + + current: -> if @.length then @[0] else null + + @from_pattern: (source) -> + source = source.replace(/([\[\]\(\)\|]|\.\.\.)/g, ' $1 ') + source = (s for s in source.split(/\s+|(\S*<.*?>)/) when s) + return new Tokens source, DocoptLanguageError + + +parse_section = (name, source) -> + matches = source.match new RegExp('^([^\n]*' + name + '[^\n]*\n?(?:[ \t].*?(?:\n|$))*)', 'igm') + if matches + return (s.trim() for s in matches) + return [] + + +parse_shorts = (tokens, options) -> + """shorts ::= '-' ( chars )* [ [ ' ' ] chars ] ;""" + token = tokens.move() + console.assert token.startsWith('-') and not token.startsWith('--') + left = token.replace(/^-+/g, '') + parsed = [] + while left != '' + [short, left] = ['-' + left[0], left[1..]] + similar = (o for o in options when o.short == short) + if similar.length > 1 + throw new tokens.error("#{short} is specified ambiguously #{similar.length} times") + else if similar.length < 1 + o = new Option(short, null, 0) + options.push(o) + if tokens.error is DocoptExit + o = new Option(short, null, 0, true) + else # why copying is necessary here? + o = new Option(short, similar[0].long, similar[0].argcount, similar[0].value) + value = null + if o.argcount != 0 + if left == '' + if tokens.current() in [null, '--'] + throw new tokens.error("#{short} requires argument") + value = tokens.move() + else + value = left + left = '' + if tokens.error is DocoptExit + o.value = if value isnt null then value else true + parsed.push(o) + return parsed + + +parse_long = (tokens, options) -> + """long ::= '--' chars [ ( ' ' | '=' ) chars ] ;""" + [long, eq, value] = tokens.move().partition('=') + console.assert long.startsWith('--') + value = null if (eq == value and value == '') + similar = (o for o in options when o.long == long) + if tokens.error is DocoptExit and similar.length == 0 # if no exact match + similar = (o for o in options when o.long and o.long.startsWith(long)) + if similar.length > 1 # might be simply specified ambiguously 2+ times? + longs = (o.long for o in similar).join(', ') + throw new tokens.error("#{long} is not a unique prefix: #{longs}?") + else if similar.length < 1 + argcount = if (eq == '=') then 1 else 0 + o = new Option(null, long, argcount) + options.push(o) + if tokens.error is DocoptExit + o = new Option(null, long, argcount, if argcount > 0 then value else true) + else + o = new Option(similar[0].short, similar[0].long, similar[0].argcount, similar[0].value) + if o.argcount == 0 + if value isnt null + throw new tokens.error("#{o.long} must not have an argument") + else + if value is null + if tokens.current() in [null, '--'] + throw new tokens.error("#{o.long} requires argument") + value = tokens.move() + if tokens.error is DocoptExit + o.value = if value isnt null then value else true + return [o] + + +parse_pattern = (source, options) -> + tokens = Tokens.from_pattern source + result = parse_expr tokens, options + if tokens.current() isnt null + throw new tokens.error 'unexpected ending: ' + (tokens.join ' ') + new Required result + + +parse_expr = (tokens, options) -> + """expr ::= seq ( '|' seq )* ;""" + seq = parse_seq tokens, options + + if tokens.current() != '|' + return seq + + result = if seq.length > 1 then [new Required seq] else seq + while tokens.current() is '|' + tokens.move() + seq = parse_seq tokens, options + result = result.concat(if seq.length > 1 then [new Required seq] else seq) + + return if result.length > 1 then [new Either result] else result + + +parse_seq = (tokens, options) -> + """seq ::= ( atom [ '...' ] )* ;""" + + result = [] + while tokens.current() not in [null, ']', ')', '|'] + atom = parse_atom tokens, options + if tokens.current() is '...' + atom = [new OneOrMore atom] + tokens.move() + result = result.concat atom + return result + + +parse_atom = (tokens, options) -> + """atom ::= '(' expr ')' | '[' expr ']' | 'options' + | long | shorts | argument | command ; + """ + + token = tokens.current() + result = [] + if token in '([' + tokens.move() + [matching, patternType] = {'(': [')', Required], '[': [']', Optional]}[token] + result = new patternType parse_expr(tokens, options) + if tokens.move() != matching + throw new tokens.error "Unmatched '"+token+"'" + return [result] + else if token is 'options' + tokens.move() + return [new OptionsShortcut] + else if token.startsWith('--') and token != '--' + return parse_long tokens, options + else if token.startsWith('-') and token not in ['-', '--'] + return parse_shorts(tokens, options) + else if token.startsWith('<') and token.endsWith('>') or token.isUpper() + return [new Argument(tokens.move())] + else + [new Command tokens.move()] + + +parse_argv = (tokens, options, options_first=false) -> + """Parse command-line argument vector. + If options_first: + argv ::= [ long | shorts ]* [ argument ]* [ '--' [ argument ]* ] ; + else: + argv ::= [ long | shorts | argument ]* [ '--' [ argument ]* ] ; + """ + parsed = [] + while tokens.current() isnt null + if tokens.current() == '--' + return parsed.concat(new Argument(null, v) for v in tokens) + else if tokens.current().startsWith('--') + parsed = parsed.concat(parse_long(tokens, options)) + else if tokens.current().startsWith('-') and tokens.current() != '-' + parsed = parsed.concat(parse_shorts(tokens, options)) + else if options_first + return parsed.concat(new Argument(null, v) for v in tokens) + else + parsed.push(new Argument(null, tokens.move())) + return parsed + +parse_defaults = (doc) -> + defaults = [] + for s in parse_section('options:', doc) + # FIXME corner case "bla: options: --foo" + [_, _, s] = s.partition(':') # get rid of "options:" + split = ('\n' + s).split(new RegExp('\\n[ \\t]*(-\\S+?)')).slice(1) + odd = (v for v in split by 2) + even = (v for v in split[1..] by 2) + split = (s1 + s2 for [s1, s2] in zip(odd, even)) + options = (Option.parse(s) for s in split when s.startsWith('-')) + defaults.push.apply(defaults, options) + return defaults + +formal_usage = (section) -> + [_, _, section] = section.partition ':' # drop "usage:" + pu = section._split() + return '( ' + ((if s == pu[0] then ') | (' else s) for s in pu[1..]).join(' ') + ' )' + +extras = (help, version, options, doc) -> + if help and any((o.name in ['--help', '-h']) and o.value for o in options) + return doc.replace /^\s*|\s*$/, '' + if version and any((o.name == '--version') and o.value for o in options) + return version + return "" + +class Dict extends Object + + constructor: (pairs) -> + @[key] = value for [key, value] in pairs + + toObject: () -> + dict = {} + dict[name] = @[name] for name in Object.keys(@).sort() + return dict + +docopt = (doc, kwargs={}) -> + allowedargs = ['argv', 'name', 'help', 'version', 'options_first', 'exit'] + throw new Error "unrecognized argument to docopt: " for arg of kwargs \ + when arg not in allowedargs + + argv = if kwargs.argv is undefined \ + then process.argv[2..] else kwargs.argv + name = if kwargs.name is undefined \ + then null else kwargs.name + help = if kwargs.help is undefined \ + then true else kwargs.help + version = if kwargs.version is undefined \ + then null else kwargs.version + options_first = if kwargs.options_first is undefined \ + then false else kwargs.options_first + exit = if kwargs.exit is undefined \ + then true else kwargs.exit + + try + usage_sections = parse_section 'usage:', doc + if usage_sections.length == 0 + throw new DocoptLanguageError '"usage:" (case-insensitive) not found.' + if usage_sections.length > 1 + throw new DocoptLanguageError 'More than one "usage:" (case-insensitive).' + DocoptExit.usage = usage_sections[0] + + options = parse_defaults doc + pattern = parse_pattern formal_usage(DocoptExit.usage), options + + argv = parse_argv new Tokens(argv), options, options_first + pattern_options = pattern.flat(Option) + for options_shortcut in pattern.flat(OptionsShortcut) + doc_options = parse_defaults(doc) + pattern_options_strings = (i.toString() for i in pattern_options) + options_shortcut.children = doc_options.filter((item) -> return item.toString() not in pattern_options_strings) + + output = extras help, version, argv, doc + if output + if exit + print output + process.exit() + else + throw new Error output + [matched, left, collected] = pattern.fix().match argv + if matched and left.length is 0 # better message if left? + return new Dict([a.name, a.value] for a in ([].concat pattern.flat(), collected)).toObject() + throw new DocoptExit DocoptExit.usage + catch e + if (!exit) + throw e + else + print e.message if e.message + process.exit(1) + +module.exports = + docopt : docopt + DocoptLanguageError : DocoptLanguageError + DocoptExit : DocoptExit + Option : Option + Argument : Argument + Command : Command + Required : Required + OptionsShortcut : OptionsShortcut + Either : Either + Optional : Optional + Pattern : Pattern + OneOrMore : OneOrMore + Tokens : Tokens + Dict : Dict + transform : transform + formal_usage : formal_usage + parse_section : parse_section + parse_defaults: parse_defaults + parse_pattern: parse_pattern + parse_long : parse_long + parse_shorts : parse_shorts + parse_argv : parse_argv diff --git a/node_modules/docopt/docopt.js b/node_modules/docopt/docopt.js new file mode 100644 index 0000000000000..9f302f9c0e194 --- /dev/null +++ b/node_modules/docopt/docopt.js @@ -0,0 +1,1202 @@ +// Generated by CoffeeScript 1.9.1 +(function() { + var Argument, BranchPattern, Command, Dict, DocoptExit, DocoptLanguageError, Either, LeafPattern, OneOrMore, Option, Optional, OptionsShortcut, Pattern, Required, Tokens, any, docopt, enumerate, extras, formal_usage, parse_argv, parse_atom, parse_defaults, parse_expr, parse_long, parse_pattern, parse_section, parse_seq, parse_shorts, print, transform, zip, + indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }, + slice = [].slice, + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; + + print = function() { + return console.log([].join.call(arguments, ' ')); + }; + + enumerate = function(array) { + var i, item, j, len, results; + i = 0; + results = []; + for (j = 0, len = array.length; j < len; j++) { + item = array[j]; + results.push([i++, item]); + } + return results; + }; + + any = function(array) { + return indexOf.call(array, true) >= 0; + }; + + zip = function() { + var args, arr, i, j, length, lengthArray, ref, results; + args = 1 <= arguments.length ? slice.call(arguments, 0) : []; + lengthArray = (function() { + var j, len, results; + results = []; + for (j = 0, len = args.length; j < len; j++) { + arr = args[j]; + results.push(arr.length); + } + return results; + })(); + length = Math.min.apply(Math, lengthArray); + results = []; + for (i = j = 0, ref = length; 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) { + results.push((function() { + var len, q, results1; + results1 = []; + for (q = 0, len = args.length; q < len; q++) { + arr = args[q]; + results1.push(arr[i]); + } + return results1; + })()); + } + return results; + }; + + String.prototype.partition = function(separator) { + var parts, self; + self = this; + if (self.indexOf(separator) >= 0) { + parts = self.split(separator); + return [parts[0], separator, parts.slice(1).join(separator)]; + } else { + return [String(self), '', '']; + } + }; + + String.prototype.startsWith = function(searchString, position) { + position = position || 0; + return this.lastIndexOf(searchString, position) === position; + }; + + String.prototype.endsWith = function(searchString, position) { + var lastIndex, subjectString; + subjectString = this.toString(); + if (position === void 0 || position > subjectString.length) { + position = subjectString.length; + } + position -= searchString.length; + lastIndex = subjectString.indexOf(searchString, position); + return lastIndex !== -1 && lastIndex === position; + }; + + String.prototype._split = function() { + return this.trim().split(/\s+/).filter(function(i) { + return i !== ''; + }); + }; + + String.prototype.isUpper = function() { + return /^[A-Z]+$/g.exec(this); + }; + + Number.isInteger = Number.isInteger || function(value) { + return typeof value === "number" && isFinite(value) && Math.floor(value) === value; + }; + + DocoptLanguageError = (function(superClass) { + extend(DocoptLanguageError, superClass); + + function DocoptLanguageError(message) { + this.message = message; + DocoptLanguageError.__super__.constructor.call(this, this.message); + } + + return DocoptLanguageError; + + })(Error); + + DocoptExit = (function(superClass) { + extend(DocoptExit, superClass); + + function DocoptExit(message) { + this.message = message; + DocoptExit.__super__.constructor.call(this, this.message); + } + + return DocoptExit; + + })(Error); + + Pattern = (function(superClass) { + extend(Pattern, superClass); + + function Pattern() { + return Pattern.__super__.constructor.apply(this, arguments); + } + + Pattern.prototype.fix = function() { + this.fix_identities(); + this.fix_repeating_arguments(); + return this; + }; + + Pattern.prototype.fix_identities = function(uniq) { + var c, flat, i, j, k, len, len1, q, ref, ref1, ref2; + if (uniq == null) { + uniq = null; + } + "Make pattern-tree tips point to same object if they are equal."; + if (!this.hasOwnProperty('children')) { + return this; + } + if (uniq === null) { + ref = [{}, this.flat()], uniq = ref[0], flat = ref[1]; + for (j = 0, len = flat.length; j < len; j++) { + k = flat[j]; + uniq[k] = k; + } + } + ref1 = enumerate(this.children); + for (q = 0, len1 = ref1.length; q < len1; q++) { + ref2 = ref1[q], i = ref2[0], c = ref2[1]; + if (!c.hasOwnProperty('children')) { + console.assert(uniq.hasOwnProperty(c)); + this.children[i] = uniq[c]; + } else { + c.fix_identities(uniq); + } + } + return this; + }; + + Pattern.prototype.fix_repeating_arguments = function() { + "Fix elements that should accumulate/increment values."; + var c, child, counts, e, either, j, len, len1, len2, mycase, q, r, ref; + either = (function() { + var j, len, ref, results; + ref = transform(this).children; + results = []; + for (j = 0, len = ref.length; j < len; j++) { + child = ref[j]; + results.push(child.children); + } + return results; + }).call(this); + for (j = 0, len = either.length; j < len; j++) { + mycase = either[j]; + counts = {}; + for (q = 0, len1 = mycase.length; q < len1; q++) { + c = mycase[q]; + counts[c] = (counts[c] ? counts[c] : 0) + 1; + } + ref = (function() { + var len2, results, u; + results = []; + for (u = 0, len2 = mycase.length; u < len2; u++) { + child = mycase[u]; + if (counts[child] > 1) { + results.push(child); + } + } + return results; + })(); + for (r = 0, len2 = ref.length; r < len2; r++) { + e = ref[r]; + if (e.constructor === Argument || e.constructor === Option && e.argcount) { + if (e.value === null) { + e.value = []; + } else if (e.value.constructor !== Array) { + e.value = e.value._split(); + } + } + if (e.constructor === Command || e.constructor === Option && e.argcount === 0) { + e.value = 0; + } + } + } + return this; + }; + + return Pattern; + + })(Object); + + transform = function(pattern) { + "Expand pattern into an (almost) equivalent one, but with single Either.\n\nExample: ((-a | -b) (-c | -d)) => (-a -c | -a -d | -b -c | -b -d)\nQuirks: [-a] => (-a), (-a...) => (-a -a)\n"; + var c, child, children, e, groups, index, j, len, parents, ref, result, t; + result = []; + groups = [[pattern]]; + while (groups.length) { + children = groups.shift(); + parents = [Required, Optional, OptionsShortcut, Either, OneOrMore]; + if (any((function() { + var j, len, results; + results = []; + for (j = 0, len = parents.length; j < len; j++) { + t = parents[j]; + results.push(indexOf.call(children.map(function(c) { + return c.constructor; + }), t) >= 0); + } + return results; + })())) { + child = ((function() { + var j, len, ref, results; + results = []; + for (j = 0, len = children.length; j < len; j++) { + c = children[j]; + if (ref = c.constructor, indexOf.call(parents, ref) >= 0) { + results.push(c); + } + } + return results; + })())[0]; + index = children.indexOf(child); + if (index >= 0) { + children.splice(index, 1); + } + if (child.constructor === Either) { + ref = child.children; + for (j = 0, len = ref.length; j < len; j++) { + c = ref[j]; + groups.push([c].concat(children)); + } + } else if (child.constructor === OneOrMore) { + groups.push((child.children.concat(child.children)).concat(children)); + } else { + groups.push(child.children.concat(children)); + } + } else { + result.push(children); + } + } + return new Either((function() { + var len1, q, results; + results = []; + for (q = 0, len1 = result.length; q < len1; q++) { + e = result[q]; + results.push(new Required(e)); + } + return results; + })()); + }; + + LeafPattern = (function(superClass) { + "Leaf/terminal node of a pattern tree."; + extend(LeafPattern, superClass); + + function LeafPattern(name1, value1) { + this.name = name1; + this.value = value1 != null ? value1 : null; + } + + LeafPattern.prototype.toString = function() { + return this.constructor.name + "(" + this.name + ", " + this.value + ")"; + }; + + LeafPattern.prototype.flat = function(types) { + var ref; + if (types == null) { + types = []; + } + types = types instanceof Array ? types : [types]; + if (!types.length || (ref = this.constructor, indexOf.call(types, ref) >= 0)) { + return [this]; + } else { + return []; + } + }; + + LeafPattern.prototype.match = function(left, collected) { + var a, increment, left_, match, pos, ref, same_name; + if (collected == null) { + collected = null; + } + if (collected === null) { + collected = []; + } + ref = this.singleMatch(left), pos = ref[0], match = ref[1]; + if (match === null) { + return [false, left, collected]; + } + left_ = left.slice(0, pos).concat(left.slice(pos + 1)); + same_name = (function() { + var j, len, results; + results = []; + for (j = 0, len = collected.length; j < len; j++) { + a = collected[j]; + if (a.name === this.name) { + results.push(a); + } + } + return results; + }).call(this); + if (Number.isInteger(this.value) || this.value instanceof Array) { + if (Number.isInteger(this.value)) { + increment = 1; + } else { + increment = typeof match.value === 'string' ? [match.value] : match.value; + } + if (!same_name.length) { + match.value = increment; + return [true, left_, collected.concat(match)]; + } + if (Number.isInteger(this.value)) { + same_name[0].value += increment; + } else { + same_name[0].value = [].concat(same_name[0].value, increment); + } + return [true, left_, collected]; + } + return [true, left_, collected.concat(match)]; + }; + + return LeafPattern; + + })(Pattern); + + BranchPattern = (function(superClass) { + "Branch/inner node of a pattern tree."; + extend(BranchPattern, superClass); + + function BranchPattern(children) { + this.children = children instanceof Array ? children : [children]; + } + + BranchPattern.prototype.toString = function() { + var a; + return this.constructor.name + "(" + (((function() { + var j, len, ref, results; + ref = this.children; + results = []; + for (j = 0, len = ref.length; j < len; j++) { + a = ref[j]; + results.push(a); + } + return results; + }).call(this)).join(', ')) + ")"; + }; + + BranchPattern.prototype.flat = function(types) { + var child, ref; + if (types == null) { + types = []; + } + types = types instanceof Array ? types : [types]; + if (ref = this.constructor, indexOf.call(types, ref) >= 0) { + return [this]; + } + return ((function() { + var j, len, ref1, results; + ref1 = this.children; + results = []; + for (j = 0, len = ref1.length; j < len; j++) { + child = ref1[j]; + if (child instanceof Pattern) { + results.push(child.flat(types)); + } + } + return results; + }).call(this)).reduce((function(pv, cv) { + return [].concat(pv, cv); + }), []); + }; + + return BranchPattern; + + })(Pattern); + + Argument = (function(superClass) { + extend(Argument, superClass); + + function Argument() { + return Argument.__super__.constructor.apply(this, arguments); + } + + Argument.prototype.singleMatch = function(left) { + var j, len, n, pattern, ref, ref1; + ref = enumerate(left); + for (j = 0, len = ref.length; j < len; j++) { + ref1 = ref[j], n = ref1[0], pattern = ref1[1]; + if (pattern.constructor === Argument) { + return [n, new Argument(this.name, pattern.value)]; + } + } + return [null, null]; + }; + + Argument.parse = function(source) { + var name, value; + name = /(<\S*?>)/ig.exec(source)[1]; + value = /\[default:\s+(.*)\]/ig.exec(source); + return new Argument(name, value ? value[1] : null); + }; + + return Argument; + + })(LeafPattern); + + Command = (function(superClass) { + extend(Command, superClass); + + function Command(name1, value1) { + this.name = name1; + this.value = value1 != null ? value1 : false; + } + + Command.prototype.singleMatch = function(left) { + var j, len, n, pattern, ref, ref1; + ref = enumerate(left); + for (j = 0, len = ref.length; j < len; j++) { + ref1 = ref[j], n = ref1[0], pattern = ref1[1]; + if (pattern.constructor === Argument) { + if (pattern.value === this.name) { + return [n, new Command(this.name, true)]; + } else { + break; + } + } + } + return [null, null]; + }; + + return Command; + + })(Argument); + + Option = (function(superClass) { + extend(Option, superClass); + + function Option(short1, long1, argcount1, value) { + var ref; + this.short = short1 != null ? short1 : null; + this.long = long1 != null ? long1 : null; + this.argcount = argcount1 != null ? argcount1 : 0; + if (value == null) { + value = false; + } + console.assert((ref = this.argcount) === 0 || ref === 1); + this.value = value === false && this.argcount > 0 ? null : value; + this.name = this.long || this.short; + } + + Option.prototype.toString = function() { + return "Option(" + this.short + ", " + this.long + ", " + this.argcount + ", " + this.value + ")"; + }; + + Option.parse = function(option_description) { + var _, argcount, description, j, len, long, matched, options, ref, ref1, ref2, s, short, value; + ref = [null, null, 0, false], short = ref[0], long = ref[1], argcount = ref[2], value = ref[3]; + ref1 = option_description.trim().partition(' '), options = ref1[0], _ = ref1[1], description = ref1[2]; + options = options.replace(/,|=/g, ' '); + ref2 = options._split(); + for (j = 0, len = ref2.length; j < len; j++) { + s = ref2[j]; + if (s.startsWith('--')) { + long = s; + } else if (s.startsWith('-')) { + short = s; + } else { + argcount = 1; + } + } + if (argcount > 0) { + matched = /\[default:\s+(.*)\]/ig.exec(description); + value = matched ? matched[1] : null; + } + return new Option(short, long, argcount, value); + }; + + Option.prototype.singleMatch = function(left) { + var j, len, n, pattern, ref, ref1; + ref = enumerate(left); + for (j = 0, len = ref.length; j < len; j++) { + ref1 = ref[j], n = ref1[0], pattern = ref1[1]; + if (this.name === pattern.name) { + return [n, pattern]; + } + } + return [null, null]; + }; + + return Option; + + })(LeafPattern); + + Required = (function(superClass) { + extend(Required, superClass); + + function Required() { + return Required.__super__.constructor.apply(this, arguments); + } + + Required.prototype.match = function(left, collected) { + var c, j, l, len, matched, p, ref, ref1; + if (collected == null) { + collected = null; + } + if (collected === null) { + collected = []; + } + l = left; + c = collected; + ref = this.children; + for (j = 0, len = ref.length; j < len; j++) { + p = ref[j]; + ref1 = p.match(l, c), matched = ref1[0], l = ref1[1], c = ref1[2]; + if (!matched) { + return [false, left, collected]; + } + } + return [true, l, c]; + }; + + return Required; + + })(BranchPattern); + + Optional = (function(superClass) { + extend(Optional, superClass); + + function Optional() { + return Optional.__super__.constructor.apply(this, arguments); + } + + Optional.prototype.match = function(left, collected) { + var j, len, m, p, ref, ref1; + if (collected == null) { + collected = null; + } + if (collected === null) { + collected = []; + } + ref = this.children; + for (j = 0, len = ref.length; j < len; j++) { + p = ref[j]; + ref1 = p.match(left, collected), m = ref1[0], left = ref1[1], collected = ref1[2]; + } + return [true, left, collected]; + }; + + return Optional; + + })(BranchPattern); + + OptionsShortcut = (function(superClass) { + "Marker/placeholder for [options] shortcut."; + extend(OptionsShortcut, superClass); + + function OptionsShortcut() { + return OptionsShortcut.__super__.constructor.apply(this, arguments); + } + + return OptionsShortcut; + + })(Optional); + + OneOrMore = (function(superClass) { + extend(OneOrMore, superClass); + + function OneOrMore() { + return OneOrMore.__super__.constructor.apply(this, arguments); + } + + OneOrMore.prototype.match = function(left, collected) { + var c, l, l_, matched, ref, times; + if (collected == null) { + collected = null; + } + console.assert(this.children.length === 1); + if (collected === null) { + collected = []; + } + l = left; + c = collected; + l_ = []; + matched = true; + times = 0; + while (matched) { + ref = this.children[0].match(l, c), matched = ref[0], l = ref[1], c = ref[2]; + times += matched ? 1 : 0; + if (l_.join(', ') === l.join(', ')) { + break; + } + l_ = l; + } + if (times >= 1) { + return [true, l, c]; + } + return [false, left, collected]; + }; + + return OneOrMore; + + })(BranchPattern); + + Either = (function(superClass) { + extend(Either, superClass); + + function Either() { + return Either.__super__.constructor.apply(this, arguments); + } + + Either.prototype.match = function(left, collected) { + var j, len, outcome, outcomes, p, ref; + if (collected == null) { + collected = null; + } + if (collected === null) { + collected = []; + } + outcomes = []; + ref = this.children; + for (j = 0, len = ref.length; j < len; j++) { + p = ref[j]; + outcome = p.match(left, collected); + if (outcome[0]) { + outcomes.push(outcome); + } + } + if (outcomes.length > 0) { + outcomes.sort(function(a, b) { + if (a[1].length > b[1].length) { + return 1; + } else if (a[1].length < b[1].length) { + return -1; + } else { + return 0; + } + }); + return outcomes[0]; + } + return [false, left, collected]; + }; + + return Either; + + })(BranchPattern); + + Tokens = (function(superClass) { + extend(Tokens, superClass); + + function Tokens(source, error) { + var stream; + this.error = error != null ? error : DocoptExit; + stream = source.constructor === String ? source._split() : source; + this.push.apply(this, stream); + } + + Tokens.prototype.move = function() { + if (this.length) { + return [].shift.apply(this); + } else { + return null; + } + }; + + Tokens.prototype.current = function() { + if (this.length) { + return this[0]; + } else { + return null; + } + }; + + Tokens.from_pattern = function(source) { + var s; + source = source.replace(/([\[\]\(\)\|]|\.\.\.)/g, ' $1 '); + source = (function() { + var j, len, ref, results; + ref = source.split(/\s+|(\S*<.*?>)/); + results = []; + for (j = 0, len = ref.length; j < len; j++) { + s = ref[j]; + if (s) { + results.push(s); + } + } + return results; + })(); + return new Tokens(source, DocoptLanguageError); + }; + + return Tokens; + + })(Array); + + parse_section = function(name, source) { + var matches, s; + matches = source.match(new RegExp('^([^\n]*' + name + '[^\n]*\n?(?:[ \t].*?(?:\n|$))*)', 'igm')); + if (matches) { + return (function() { + var j, len, results; + results = []; + for (j = 0, len = matches.length; j < len; j++) { + s = matches[j]; + results.push(s.trim()); + } + return results; + })(); + } + return []; + }; + + parse_shorts = function(tokens, options) { + "shorts ::= '-' ( chars )* [ [ ' ' ] chars ] ;"; + var left, o, parsed, ref, ref1, short, similar, token, value; + token = tokens.move(); + console.assert(token.startsWith('-') && !token.startsWith('--')); + left = token.replace(/^-+/g, ''); + parsed = []; + while (left !== '') { + ref = ['-' + left[0], left.slice(1)], short = ref[0], left = ref[1]; + similar = (function() { + var j, len, results; + results = []; + for (j = 0, len = options.length; j < len; j++) { + o = options[j]; + if (o.short === short) { + results.push(o); + } + } + return results; + })(); + if (similar.length > 1) { + throw new tokens.error(short + " is specified ambiguously " + similar.length + " times"); + } else if (similar.length < 1) { + o = new Option(short, null, 0); + options.push(o); + if (tokens.error === DocoptExit) { + o = new Option(short, null, 0, true); + } + } else { + o = new Option(short, similar[0].long, similar[0].argcount, similar[0].value); + value = null; + if (o.argcount !== 0) { + if (left === '') { + if ((ref1 = tokens.current()) === null || ref1 === '--') { + throw new tokens.error(short + " requires argument"); + } + value = tokens.move(); + } else { + value = left; + left = ''; + } + } + if (tokens.error === DocoptExit) { + o.value = value !== null ? value : true; + } + } + parsed.push(o); + } + return parsed; + }; + + parse_long = function(tokens, options) { + "long ::= '--' chars [ ( ' ' | '=' ) chars ] ;"; + var argcount, eq, long, longs, o, ref, ref1, similar, value; + ref = tokens.move().partition('='), long = ref[0], eq = ref[1], value = ref[2]; + console.assert(long.startsWith('--')); + if (eq === value && value === '') { + value = null; + } + similar = (function() { + var j, len, results; + results = []; + for (j = 0, len = options.length; j < len; j++) { + o = options[j]; + if (o.long === long) { + results.push(o); + } + } + return results; + })(); + if (tokens.error === DocoptExit && similar.length === 0) { + similar = (function() { + var j, len, results; + results = []; + for (j = 0, len = options.length; j < len; j++) { + o = options[j]; + if (o.long && o.long.startsWith(long)) { + results.push(o); + } + } + return results; + })(); + } + if (similar.length > 1) { + longs = ((function() { + var j, len, results; + results = []; + for (j = 0, len = similar.length; j < len; j++) { + o = similar[j]; + results.push(o.long); + } + return results; + })()).join(', '); + throw new tokens.error(long + " is not a unique prefix: " + longs + "?"); + } else if (similar.length < 1) { + argcount = eq === '=' ? 1 : 0; + o = new Option(null, long, argcount); + options.push(o); + if (tokens.error === DocoptExit) { + o = new Option(null, long, argcount, argcount > 0 ? value : true); + } + } else { + o = new Option(similar[0].short, similar[0].long, similar[0].argcount, similar[0].value); + if (o.argcount === 0) { + if (value !== null) { + throw new tokens.error(o.long + " must not have an argument"); + } + } else { + if (value === null) { + if ((ref1 = tokens.current()) === null || ref1 === '--') { + throw new tokens.error(o.long + " requires argument"); + } + value = tokens.move(); + } + } + if (tokens.error === DocoptExit) { + o.value = value !== null ? value : true; + } + } + return [o]; + }; + + parse_pattern = function(source, options) { + var result, tokens; + tokens = Tokens.from_pattern(source); + result = parse_expr(tokens, options); + if (tokens.current() !== null) { + throw new tokens.error('unexpected ending: ' + (tokens.join(' '))); + } + return new Required(result); + }; + + parse_expr = function(tokens, options) { + "expr ::= seq ( '|' seq )* ;"; + var result, seq; + seq = parse_seq(tokens, options); + if (tokens.current() !== '|') { + return seq; + } + result = seq.length > 1 ? [new Required(seq)] : seq; + while (tokens.current() === '|') { + tokens.move(); + seq = parse_seq(tokens, options); + result = result.concat(seq.length > 1 ? [new Required(seq)] : seq); + } + if (result.length > 1) { + return [new Either(result)]; + } else { + return result; + } + }; + + parse_seq = function(tokens, options) { + "seq ::= ( atom [ '...' ] )* ;"; + var atom, ref, result; + result = []; + while ((ref = tokens.current()) !== null && ref !== ']' && ref !== ')' && ref !== '|') { + atom = parse_atom(tokens, options); + if (tokens.current() === '...') { + atom = [new OneOrMore(atom)]; + tokens.move(); + } + result = result.concat(atom); + } + return result; + }; + + parse_atom = function(tokens, options) { + "atom ::= '(' expr ')' | '[' expr ']' | 'options'\n| long | shorts | argument | command ;"; + var matching, patternType, ref, result, token; + token = tokens.current(); + result = []; + if (indexOf.call('([', token) >= 0) { + tokens.move(); + ref = { + '(': [')', Required], + '[': [']', Optional] + }[token], matching = ref[0], patternType = ref[1]; + result = new patternType(parse_expr(tokens, options)); + if (tokens.move() !== matching) { + throw new tokens.error("Unmatched '" + token + "'"); + } + return [result]; + } else if (token === 'options') { + tokens.move(); + return [new OptionsShortcut]; + } else if (token.startsWith('--') && token !== '--') { + return parse_long(tokens, options); + } else if (token.startsWith('-') && (token !== '-' && token !== '--')) { + return parse_shorts(tokens, options); + } else if (token.startsWith('<') && token.endsWith('>') || token.isUpper()) { + return [new Argument(tokens.move())]; + } else { + return [new Command(tokens.move())]; + } + }; + + parse_argv = function(tokens, options, options_first) { + var parsed, v; + if (options_first == null) { + options_first = false; + } + "Parse command-line argument vector.\nIf options_first:\n argv ::= [ long | shorts ]* [ argument ]* [ '--' [ argument ]* ] ;\nelse:\n argv ::= [ long | shorts | argument ]* [ '--' [ argument ]* ] ;"; + parsed = []; + while (tokens.current() !== null) { + if (tokens.current() === '--') { + return parsed.concat((function() { + var j, len, results; + results = []; + for (j = 0, len = tokens.length; j < len; j++) { + v = tokens[j]; + results.push(new Argument(null, v)); + } + return results; + })()); + } else if (tokens.current().startsWith('--')) { + parsed = parsed.concat(parse_long(tokens, options)); + } else if (tokens.current().startsWith('-') && tokens.current() !== '-') { + parsed = parsed.concat(parse_shorts(tokens, options)); + } else if (options_first) { + return parsed.concat((function() { + var j, len, results; + results = []; + for (j = 0, len = tokens.length; j < len; j++) { + v = tokens[j]; + results.push(new Argument(null, v)); + } + return results; + })()); + } else { + parsed.push(new Argument(null, tokens.move())); + } + } + return parsed; + }; + + parse_defaults = function(doc) { + var _, defaults, even, j, len, odd, options, ref, ref1, s, s1, s2, split, v; + defaults = []; + ref = parse_section('options:', doc); + for (j = 0, len = ref.length; j < len; j++) { + s = ref[j]; + ref1 = s.partition(':'), _ = ref1[0], _ = ref1[1], s = ref1[2]; + split = ('\n' + s).split(new RegExp('\\n[ \\t]*(-\\S+?)')).slice(1); + odd = (function() { + var len1, q, results; + results = []; + for (q = 0, len1 = split.length; q < len1; q += 2) { + v = split[q]; + results.push(v); + } + return results; + })(); + even = (function() { + var len1, q, ref2, results; + ref2 = split.slice(1); + results = []; + for (q = 0, len1 = ref2.length; q < len1; q += 2) { + v = ref2[q]; + results.push(v); + } + return results; + })(); + split = (function() { + var len1, q, ref2, ref3, results; + ref2 = zip(odd, even); + results = []; + for (q = 0, len1 = ref2.length; q < len1; q++) { + ref3 = ref2[q], s1 = ref3[0], s2 = ref3[1]; + results.push(s1 + s2); + } + return results; + })(); + options = (function() { + var len1, q, results; + results = []; + for (q = 0, len1 = split.length; q < len1; q++) { + s = split[q]; + if (s.startsWith('-')) { + results.push(Option.parse(s)); + } + } + return results; + })(); + defaults.push.apply(defaults, options); + } + return defaults; + }; + + formal_usage = function(section) { + var _, pu, ref, s; + ref = section.partition(':'), _ = ref[0], _ = ref[1], section = ref[2]; + pu = section._split(); + return '( ' + ((function() { + var j, len, ref1, results; + ref1 = pu.slice(1); + results = []; + for (j = 0, len = ref1.length; j < len; j++) { + s = ref1[j]; + results.push(s === pu[0] ? ') | (' : s); + } + return results; + })()).join(' ') + ' )'; + }; + + extras = function(help, version, options, doc) { + var o; + if (help && any((function() { + var j, len, ref, results; + results = []; + for (j = 0, len = options.length; j < len; j++) { + o = options[j]; + results.push(((ref = o.name) === '--help' || ref === '-h') && o.value); + } + return results; + })())) { + return doc.replace(/^\s*|\s*$/, ''); + } + if (version && any((function() { + var j, len, results; + results = []; + for (j = 0, len = options.length; j < len; j++) { + o = options[j]; + results.push((o.name === '--version') && o.value); + } + return results; + })())) { + return version; + } + return ""; + }; + + Dict = (function(superClass) { + extend(Dict, superClass); + + function Dict(pairs) { + var j, key, len, ref, value; + for (j = 0, len = pairs.length; j < len; j++) { + ref = pairs[j], key = ref[0], value = ref[1]; + this[key] = value; + } + } + + Dict.prototype.toObject = function() { + var dict, j, len, name, ref; + dict = {}; + ref = Object.keys(this).sort(); + for (j = 0, len = ref.length; j < len; j++) { + name = ref[j]; + dict[name] = this[name]; + } + return dict; + }; + + return Dict; + + })(Object); + + docopt = function(doc, kwargs) { + var a, allowedargs, arg, argv, collected, doc_options, e, exit, help, i, j, left, len, matched, name, options, options_first, options_shortcut, output, pattern, pattern_options, pattern_options_strings, ref, ref1, usage_sections, version; + if (kwargs == null) { + kwargs = {}; + } + allowedargs = ['argv', 'name', 'help', 'version', 'options_first', 'exit']; + for (arg in kwargs) { + if (indexOf.call(allowedargs, arg) < 0) { + throw new Error("unrecognized argument to docopt: "); + } + } + argv = kwargs.argv === void 0 ? process.argv.slice(2) : kwargs.argv; + name = kwargs.name === void 0 ? null : kwargs.name; + help = kwargs.help === void 0 ? true : kwargs.help; + version = kwargs.version === void 0 ? null : kwargs.version; + options_first = kwargs.options_first === void 0 ? false : kwargs.options_first; + exit = kwargs.exit === void 0 ? true : kwargs.exit; + try { + usage_sections = parse_section('usage:', doc); + if (usage_sections.length === 0) { + throw new DocoptLanguageError('"usage:" (case-insensitive) not found.'); + } + if (usage_sections.length > 1) { + throw new DocoptLanguageError('More than one "usage:" (case-insensitive).'); + } + DocoptExit.usage = usage_sections[0]; + options = parse_defaults(doc); + pattern = parse_pattern(formal_usage(DocoptExit.usage), options); + argv = parse_argv(new Tokens(argv), options, options_first); + pattern_options = pattern.flat(Option); + ref = pattern.flat(OptionsShortcut); + for (j = 0, len = ref.length; j < len; j++) { + options_shortcut = ref[j]; + doc_options = parse_defaults(doc); + pattern_options_strings = (function() { + var len1, q, results; + results = []; + for (q = 0, len1 = pattern_options.length; q < len1; q++) { + i = pattern_options[q]; + results.push(i.toString()); + } + return results; + })(); + options_shortcut.children = doc_options.filter(function(item) { + var ref1; + return ref1 = item.toString(), indexOf.call(pattern_options_strings, ref1) < 0; + }); + } + output = extras(help, version, argv, doc); + if (output) { + if (exit) { + print(output); + process.exit(); + } else { + throw new Error(output); + } + } + ref1 = pattern.fix().match(argv), matched = ref1[0], left = ref1[1], collected = ref1[2]; + if (matched && left.length === 0) { + return new Dict((function() { + var len1, q, ref2, results; + ref2 = [].concat(pattern.flat(), collected); + results = []; + for (q = 0, len1 = ref2.length; q < len1; q++) { + a = ref2[q]; + results.push([a.name, a.value]); + } + return results; + })()).toObject(); + } + throw new DocoptExit(DocoptExit.usage); + } catch (_error) { + e = _error; + if (!exit) { + throw e; + } else { + if (e.message) { + print(e.message); + } + return process.exit(1); + } + } + }; + + module.exports = { + docopt: docopt, + DocoptLanguageError: DocoptLanguageError, + DocoptExit: DocoptExit, + Option: Option, + Argument: Argument, + Command: Command, + Required: Required, + OptionsShortcut: OptionsShortcut, + Either: Either, + Optional: Optional, + Pattern: Pattern, + OneOrMore: OneOrMore, + Tokens: Tokens, + Dict: Dict, + transform: transform, + formal_usage: formal_usage, + parse_section: parse_section, + parse_defaults: parse_defaults, + parse_pattern: parse_pattern, + parse_long: parse_long, + parse_shorts: parse_shorts, + parse_argv: parse_argv + }; + +}).call(this); diff --git a/node_modules/docopt/package.json b/node_modules/docopt/package.json new file mode 100644 index 0000000000000..e2104dc5c4abe --- /dev/null +++ b/node_modules/docopt/package.json @@ -0,0 +1,88 @@ +{ + "_args": [ + [ + "docopt@0.6.2", + "/Users/zkat/Documents/code/work/npm" + ] + ], + "_development": true, + "_from": "docopt@0.6.2", + "_id": "docopt@0.6.2", + "_inBundle": false, + "_integrity": "sha1-so6eIiDaXsSffqW7JKR3h0Be6xE=", + "_location": "/docopt", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "docopt@0.6.2", + "name": "docopt", + "escapedName": "docopt", + "rawSpec": "0.6.2", + "saveSpec": null, + "fetchSpec": "0.6.2" + }, + "_requiredBy": [ + "/licensee" + ], + "_resolved": "https://registry.npmjs.org/docopt/-/docopt-0.6.2.tgz", + "_spec": "0.6.2", + "_where": "/Users/zkat/Documents/code/work/npm", + "author": { + "name": "Vladimir Keleshev", + "email": "vladimir@keleshev.com" + }, + "bugs": { + "url": "https://github.com/scarnie/docopt.coffee/issues" + }, + "contributors": [ + { + "name": "Andrew Kassen", + "email": "atkassen@berkeley.edu" + }, + { + "name": "Vladimir Keleshev", + "email": "vladimir@keleshev.com" + }, + { + "name": "Stuart Carnie", + "email": "stuart.carnie@gmail.com" + }, + { + "name": "Matthias Rolke", + "email": "mr.amtrack@gmail.com" + } + ], + "description": "a command line option parser that will make you smile", + "devDependencies": { + "chai": "^2.2.0", + "coffee-script": "^1.9.1", + "coffeelint": "^1.9.2", + "mocha": "^2.2.1" + }, + "engines": { + "node": ">=0.10.0" + }, + "homepage": "https://github.com/scarnie/docopt.coffee#readme", + "keywords": [ + "command", + "options", + "argument", + "args", + "cli", + "commandline" + ], + "licenses": "MIT", + "main": "docopt.js", + "name": "docopt", + "repository": { + "type": "git", + "url": "git://github.com/scarnie/docopt.coffee.git" + }, + "scripts": { + "lint": "coffeelint docopt.coffee test/*.coffee", + "prepublish": "coffee -c docopt.coffee", + "test": "mocha --compilers coffee:coffee-script/register" + }, + "version": "0.6.2" +} diff --git a/node_modules/docopt/test/test.coffee b/node_modules/docopt/test/test.coffee new file mode 100644 index 0000000000000..12c45e322df43 --- /dev/null +++ b/node_modules/docopt/test/test.coffee @@ -0,0 +1,736 @@ +chai = require 'chai' +assert = chai.assert +docopt = require '../docopt.coffee' + +describe "test.coffee", -> + + it "test_pattern_flat", -> + assert.deepEqual( + new docopt.Required([new docopt.OneOrMore([new docopt.Argument('N')]), new docopt.Option('-a'), new docopt.Argument('M')]).flat() + [new docopt.Argument('N'), new docopt.Option('-a'), new docopt.Argument('M')] + ) + assert.deepEqual( + new docopt.Required([new docopt.Optional([new docopt.OptionsShortcut([])]), new docopt.Optional([new docopt.Option('-a', null)])]).flat(docopt.OptionsShortcut) + [new docopt.OptionsShortcut([])] + ) + + + it "test_option", -> + assert.deepEqual new docopt.Option.parse('-h'), new docopt.Option('-h', null) + assert.deepEqual new docopt.Option.parse('--help'), new docopt.Option(null, '--help') + assert.deepEqual new docopt.Option.parse('-h --help'), new docopt.Option('-h', '--help') + assert.deepEqual new docopt.Option.parse('-h, --help'), new docopt.Option('-h', '--help') + + assert.deepEqual new docopt.Option.parse('-h TOPIC'), new docopt.Option('-h', null, 1) + assert.deepEqual new docopt.Option.parse('--help TOPIC'), new docopt.Option(null, '--help', 1) + assert.deepEqual new docopt.Option.parse('-h TOPIC --help TOPIC'), new docopt.Option('-h', '--help', 1) + assert.deepEqual new docopt.Option.parse('-h TOPIC, --help TOPIC'), new docopt.Option('-h', '--help', 1) + assert.deepEqual new docopt.Option.parse('-h TOPIC, --help=TOPIC'), new docopt.Option('-h', '--help', 1) + + assert.deepEqual new docopt.Option.parse('-h Description...'), new docopt.Option('-h', null) + assert.deepEqual new docopt.Option.parse('-h --help Description...'), new docopt.Option('-h', '--help') + assert.deepEqual new docopt.Option.parse('-h TOPIC Description...'), new docopt.Option('-h', null, 1) + + assert.deepEqual new docopt.Option.parse(' -h'), new docopt.Option('-h', null) + + assert.deepEqual( + new docopt.Option.parse('-h TOPIC Descripton... [default: 2]') + new docopt.Option('-h', null, 1, '2') + ) + assert.deepEqual( + new docopt.Option.parse('-h TOPIC Descripton... [default: topic-1]') + new docopt.Option('-h', null, 1, 'topic-1') + ) + assert.deepEqual( + new docopt.Option.parse('--help=TOPIC ... [default: 3.14]') + new docopt.Option(null, '--help', 1, '3.14') + ) + assert.deepEqual( + new docopt.Option.parse('-h, --help=DIR ... [default: ./]') + new docopt.Option('-h', '--help', 1, "./") + ) + assert.deepEqual( + new docopt.Option.parse('-h TOPIC Descripton... [dEfAuLt: 2]') + new docopt.Option('-h', null, 1, '2') + ) + + + it "test_option_name", -> + assert.deepEqual new docopt.Option('-h', null).name, '-h' + assert.deepEqual new docopt.Option('-h', '--help').name, '--help' + assert.deepEqual new docopt.Option(null, '--help').name, '--help' + + + it "test_commands", -> + assert.deepEqual docopt.docopt('Usage: prog add', {argv: 'add', exit: false}), {'add': true} + assert.deepEqual docopt.docopt('Usage: prog [add]', {argv: '', exit: false}), {'add': false} + assert.deepEqual docopt.docopt('Usage: prog [add]', {argv: 'add', exit: false}), {'add': true} + assert.deepEqual docopt.docopt('Usage: prog (add|rm)', {argv: 'add', exit: false}), {'add': true, 'rm': false} + assert.deepEqual docopt.docopt('Usage: prog (add|rm)', {argv: 'rm', exit: false}), {'add': false, 'rm': true} + assert.deepEqual docopt.docopt('Usage: prog a b', {argv: 'a b', exit: false}), {'a': true, 'b': true} + assert.throws( + () -> + docopt.docopt('Usage: prog a b', {argv: 'b a', exit: false}) + , + docopt.DocoptExit + ) + + + it "test_formal_usage", -> + doc = """ + Usage: prog [-hv] ARG + prog N M + + prog is a program.""" + [usage] = docopt.parse_section('usage:', doc) + assert.deepEqual usage, "Usage: prog [-hv] ARG\n prog N M" + assert.deepEqual docopt.formal_usage(usage), "( [-hv] ARG ) | ( N M )" + + + it "test_parse_argv", -> + o = [new docopt.Option('-h'), new docopt.Option('-v', '--verbose'), new docopt.Option('-f', '--file', 1)] + TS = (s) -> new docopt.Tokens(s, docopt.DocoptExit) + assert.deepEqual docopt.parse_argv(TS(''), o), [] + assert.deepEqual docopt.parse_argv(TS('-h'), o), [new docopt.Option('-h', null, 0, true)] + assert.deepEqual( + docopt.parse_argv(TS('-h --verbose'), o) + [new docopt.Option('-h', null, 0, true), new docopt.Option('-v', '--verbose', 0, true)] + ) + assert.deepEqual( + docopt.parse_argv(TS('-h --file f.txt'), o) + [new docopt.Option('-h', null, 0, true), new docopt.Option('-f', '--file', 1, 'f.txt')] + ) + assert.deepEqual( + docopt.parse_argv(TS('-h --file f.txt arg'), o) + [new docopt.Option('-h', null, 0, true), new docopt.Option('-f', '--file', 1, 'f.txt'), new docopt.Argument(null, 'arg')] + ) + assert.deepEqual( + docopt.parse_argv(TS('-h --file f.txt arg arg2'), o) + [new docopt.Option('-h', null, 0, true), new docopt.Option('-f', '--file', 1, 'f.txt'), new docopt.Argument(null, 'arg'), new docopt.Argument(null, 'arg2')] + ) + assert.deepEqual( + docopt.parse_argv(TS('-h arg -- -v'), o) + [new docopt.Option('-h', null, 0, true), new docopt.Argument(null, 'arg'), new docopt.Argument(null, '--'), new docopt.Argument(null, '-v')] + ) + + it "test_parse_pattern", -> + o = [new docopt.Option('-h'), new docopt.Option('-v', '--verbose'), new docopt.Option('-f', '--file', 1)] + assert.deepEqual( + docopt.parse_pattern('[ -h ]', o) + new docopt.Required([new docopt.Optional([new docopt.Option('-h')])]) + ) + assert.deepEqual( + docopt.parse_pattern('[ ARG ... ]', o) + new docopt.Required([new docopt.Optional([new docopt.OneOrMore([new docopt.Argument('ARG')])])]) + ) + assert.deepEqual( + docopt.parse_pattern('[ -h | -v ]', o) + new docopt.Required([new docopt.Optional([new docopt.Either([new docopt.Option('-h'), new docopt.Option('-v', '--verbose')])])]) + ) + assert.deepEqual( + docopt.parse_pattern('( -h | -v [ --file ] )', o), + new docopt.Required([new docopt.Required(new docopt.Either([new docopt.Option('-h'), new docopt.Required([new docopt.Option('-v', '--verbose'), new docopt.Optional([new docopt.Option('-f', '--file', 1, null)])])]))]) + ) + assert.deepEqual( + docopt.parse_pattern('(-h|-v[--file=]N...)', o), + new docopt.Required([new docopt.Required([new docopt.Either([new docopt.Option('-h'), new docopt.Required([new docopt.Option('-v', '--verbose'), new docopt.Optional([new docopt.Option('-f', '--file', 1, null)]), new docopt.OneOrMore([new docopt.Argument('N')])])])])]) + ) + assert.deepEqual( + docopt.parse_pattern('(N [M | (K | L)] | O P)', []), + new docopt.Required([new docopt.Required([new docopt.Either([new docopt.Required([new docopt.Argument('N'), new docopt.Optional([new docopt.Either([new docopt.Argument('M'), new docopt.Required([new docopt.Either([new docopt.Argument('K'), new docopt.Argument('L')])])])])]), new docopt.Required([new docopt.Argument('O'), new docopt.Argument('P')])])])]) + ) + assert.deepEqual( + docopt.parse_pattern('[ -h ] [N]', o), + new docopt.Required([new docopt.Optional([new docopt.Option('-h')]), new docopt.Optional([new docopt.Argument('N')])]) + ) + assert.deepEqual( + docopt.parse_pattern('[options]', o), + new docopt.Required([new docopt.Optional([new docopt.OptionsShortcut()])]) + ) + assert.deepEqual( + docopt.parse_pattern('[options] A', o), + new docopt.Required([new docopt.Optional([new docopt.OptionsShortcut()]), new docopt.Argument('A')]) + ) + assert.deepEqual( + docopt.parse_pattern('-v [options]', o), + new docopt.Required([new docopt.Option('-v', '--verbose'), new docopt.Optional([new docopt.OptionsShortcut()])]) + ) + assert.deepEqual docopt.parse_pattern('ADD', o), new docopt.Required([new docopt.Argument('ADD')]) + assert.deepEqual docopt.parse_pattern('', o), new docopt.Required([new docopt.Argument('')]) + assert.deepEqual docopt.parse_pattern('add', o), new docopt.Required([new docopt.Command('add')]) + + + it "test_option_match", -> + assert.deepEqual new docopt.Option('-a').match([new docopt.Option('-a', null, 0, true)]), [true, [], [new docopt.Option('-a', null, 0, true)]] + assert.deepEqual new docopt.Option('-a').match([new docopt.Option('-x')]), [false, [new docopt.Option('-x')], []] + assert.deepEqual new docopt.Option('-a').match([new docopt.Argument('N')]), [false, [new docopt.Argument('N')], []] + assert.deepEqual( + new docopt.Option('-a').match([new docopt.Option('-x'), new docopt.Option('-a'), new docopt.Argument('N')]), + [true, [new docopt.Option('-x'), new docopt.Argument('N')], [new docopt.Option('-a')]] + ) + assert.deepEqual( + new docopt.Option('-a').match([new docopt.Option('-a', null, 0, true), new docopt.Option('-a')]), + [true, [new docopt.Option('-a')], [new docopt.Option('-a', null, 0, true)]] + ) + + + it "test_argument_match", -> + assert.deepEqual new docopt.Argument('N').match([new docopt.Argument(null, 9)]), [true, [], [new docopt.Argument('N', 9)]] + assert.deepEqual new docopt.Argument('N').match([new docopt.Option('-x')]), [false, [new docopt.Option('-x')], []] + assert.deepEqual( + new docopt.Argument('N').match([new docopt.Option('-x'), new docopt.Option('-a'), new docopt.Argument(null, 5)]) + [true, [new docopt.Option('-x'), new docopt.Option('-a')], [new docopt.Argument('N', 5)]] + ) + assert.deepEqual( + new docopt.Argument('N').match([new docopt.Argument(null, 9), new docopt.Argument(null, 0)]) + [true, [new docopt.Argument(null, 0)], [new docopt.Argument('N', 9)]] + ) + + + it "test_command_match", -> + assert.deepEqual( + new docopt.Command('c').match([new docopt.Argument(null, 'c')]) + [true, [], [new docopt.Command('c', true)]] + ) + assert.deepEqual new docopt.Command('c').match([new docopt.Option('-x')]), [false, [new docopt.Option('-x')], []] + assert.deepEqual( + new docopt.Command('c').match([new docopt.Option('-x'), new docopt.Option('-a'), new docopt.Argument(null, 'c')]) + [true, [new docopt.Option('-x'), new docopt.Option('-a')], [new docopt.Command('c', true)]] + ) + assert.deepEqual( + new docopt.Either([new docopt.Command('add', false), new docopt.Command('rm', false)]).match([new docopt.Argument(null, 'rm')]) + [true, [], [new docopt.Command('rm', true)]] + ) + + + it "test_optional_match", -> + assert.deepEqual( + new docopt.Optional([new docopt.Option('-a')]).match([new docopt.Option('-a')]) + [true, [], [new docopt.Option('-a')]] + ) + assert.deepEqual new docopt.Optional([new docopt.Option('-a')]).match([]), [true, [], []] + assert.deepEqual( + new docopt.Optional([new docopt.Option('-a')]).match([new docopt.Option('-x')]), + [true, [new docopt.Option('-x')], []] + ) + assert.deepEqual( + new docopt.Optional([new docopt.Option('-a'), new docopt.Option('-b')]).match([new docopt.Option('-a')]), + [true, [], [new docopt.Option('-a')]] + ) + assert.deepEqual( + new docopt.Optional([new docopt.Option('-a'), new docopt.Option('-b')]).match([new docopt.Option('-b')]), + [true, [], [new docopt.Option('-b')]] + ) + assert.deepEqual( + new docopt.Optional([new docopt.Option('-a'), new docopt.Option('-b')]).match([new docopt.Option('-x')]), + [true, [new docopt.Option('-x')], []] + ) + assert.deepEqual( + new docopt.Optional([new docopt.Argument('N')]).match([new docopt.Argument(null, 9)]), + [true, [], [new docopt.Argument('N', 9)]] + ) + assert.deepEqual( + new docopt.Optional([new docopt.Option('-a'), new docopt.Option('-b')]).match([new docopt.Option('-b'), new docopt.Option('-x'), new docopt.Option('-a')]), + [true, [new docopt.Option('-x')], [new docopt.Option('-a'), new docopt.Option('-b')]] + ) + + + it "test_required_match", -> + assert.deepEqual( + new docopt.Required([new docopt.Option('-a')]).match([new docopt.Option('-a')]) + [true, [], [new docopt.Option('-a')]] + ) + assert.deepEqual new docopt.Required([new docopt.Option('-a')]).match([]), [false, [], []] + assert.deepEqual( + new docopt.Required([new docopt.Option('-a')]).match([new docopt.Option('-x')]) + [false, [new docopt.Option('-x')], []] + ) + assert.deepEqual( + new docopt.Required([new docopt.Option('-a'), new docopt.Option('-b')]).match([new docopt.Option('-a')]) + [false, [new docopt.Option('-a')], []] + ) + + + it "test_either_match", -> + assert.deepEqual( + new docopt.Either([new docopt.Option('-a'), new docopt.Option('-b')]).match([new docopt.Option('-a')]) + [true, [], [new docopt.Option('-a')]] + ) + assert.deepEqual( + new docopt.Either([new docopt.Option('-a'), new docopt.Option('-b')]).match([new docopt.Option('-a'), new docopt.Option('-b')]), + [true, [new docopt.Option('-b')], [new docopt.Option('-a')]] + ) + assert.deepEqual( + new docopt.Either([new docopt.Option('-a'), new docopt.Option('-b')]).match([new docopt.Option('-x')]), + [false, [new docopt.Option('-x')], []] + ) + assert.deepEqual( + new docopt.Either([new docopt.Option('-a'), new docopt.Option('-b'), new docopt.Option('-c')]).match([new docopt.Option('-x'), new docopt.Option('-b')]), + [true, [new docopt.Option('-x')], [new docopt.Option('-b')]] + ) + assert.deepEqual( + new docopt.Either([new docopt.Argument('M'), new docopt.Required([new docopt.Argument('N'), new docopt.Argument('M')])]).match( [new docopt.Argument(null, 1), new docopt.Argument(null, 2)]), + [true, [], [new docopt.Argument('N', 1), new docopt.Argument('M', 2)]] + ) + + + it "test_one_or_more_match", -> + assert.deepEqual( + new docopt.OneOrMore([new docopt.Argument('N')]).match([new docopt.Argument(null, 9)]) + [true, [], [new docopt.Argument('N', 9)]] + ) + assert.deepEqual new docopt.OneOrMore([new docopt.Argument('N')]).match([]), [false, [], []] + assert.deepEqual( + new docopt.OneOrMore([new docopt.Argument('N')]).match([new docopt.Option('-x')]), + [false, [new docopt.Option('-x')], []] + ) + assert.deepEqual( + new docopt.OneOrMore([new docopt.Argument('N')]).match([new docopt.Argument(null, 9), new docopt.Argument(null, 8)]), + [true, [], [new docopt.Argument('N', 9), new docopt.Argument('N', 8)]] + ) + assert.deepEqual( + new docopt.OneOrMore([new docopt.Argument('N')]).match([new docopt.Argument(null, 9), new docopt.Option('-x'), new docopt.Argument(null, 8)]), + [true, [new docopt.Option('-x')], [new docopt.Argument('N', 9), new docopt.Argument('N', 8)]] + ) + assert.deepEqual( + new docopt.OneOrMore([new docopt.Option('-a')]).match([new docopt.Option('-a'), new docopt.Argument(null, 8), new docopt.Option('-a')]), + [true, [new docopt.Argument(null, 8)], [new docopt.Option('-a'), new docopt.Option('-a')]] + ) + assert.deepEqual( + new docopt.OneOrMore([new docopt.Option('-a')]).match([new docopt.Argument(null, 8), new docopt.Option('-x')]), + [false, [new docopt.Argument(null, 8), new docopt.Option('-x')], []] + ) + assert.deepEqual( + new docopt.OneOrMore([new docopt.Required([new docopt.Option('-a'), new docopt.Argument('N')])]).match([new docopt.Option('-a'), new docopt.Argument(null, 1), new docopt.Option('-x'), new docopt.Option('-a'), new docopt.Argument(null, 2)]), + [true, [new docopt.Option('-x')], [new docopt.Option('-a'), new docopt.Argument('N', 1), new docopt.Option('-a'), new docopt.Argument('N', 2)]] + ) + assert.deepEqual( + new docopt.OneOrMore([new docopt.Optional([new docopt.Argument('N')])]).match([new docopt.Argument(null, 9)]), + [true, [], [new docopt.Argument('N', 9)]] + ) + + + it "test_list_argument_match", -> + assert.deepEqual( + new docopt.Required([new docopt.Argument('N'), new docopt.Argument('N')]).fix().match([new docopt.Argument(null, '1'), new docopt.Argument(null, '2')]) + [true, [], [new docopt.Argument('N', ['1', '2'])]] + ) + assert.deepEqual( + new docopt.OneOrMore([new docopt.Argument('N')]).fix().match([new docopt.Argument(null, '1'), new docopt.Argument(null, '2'), new docopt.Argument(null, '3')]) + [true, [], [new docopt.Argument('N', ['1', '2', '3'])]] + ) + assert.deepEqual( + new docopt.Required([new docopt.Argument('N'), new docopt.OneOrMore([new docopt.Argument('N')])]).fix().match([new docopt.Argument(null, '1'), new docopt.Argument(null, '2'), new docopt.Argument(null, '3')]) + [true, [], [new docopt.Argument('N', ['1', '2', '3'])]] + ) + assert.deepEqual( + new docopt.Required([new docopt.Argument('N'), new docopt.Required([new docopt.Argument('N')])]).fix().match([new docopt.Argument(null, '1'), new docopt.Argument(null, '2')]), + [true, [], [new docopt.Argument('N', ['1', '2'])]] + ) + + + it "test_basic_pattern_matching", -> + # ( -a N [ -x Z ] ) + pattern = new docopt.Required([new docopt.Option('-a'), new docopt.Argument('N'), new docopt.Optional([new docopt.Option('-x'), new docopt.Argument('Z')])]) + # -a N + assert.deepEqual( + pattern.match([new docopt.Option('-a'), new docopt.Argument(null, 9)]), + [true, [], [new docopt.Option('-a'), new docopt.Argument('N', 9)]] + ) + # -a -x N Z + assert.deepEqual( + pattern.match([new docopt.Option('-a'), new docopt.Option('-x'), new docopt.Argument(null, 9), new docopt.Argument(null, 5)]), + [true, [], [new docopt.Option('-a'), new docopt.Argument('N', 9), new docopt.Option('-x'), new docopt.Argument('Z', 5)]] + ) + # -x N Z # BZZ! + assert.deepEqual( + pattern.match([new docopt.Option('-x'), new docopt.Argument(null, 9), new docopt.Argument(null, 5)]), + [false, [new docopt.Option('-x'), new docopt.Argument(null, 9), new docopt.Argument(null, 5)], []] + ) + + + it "test_pattern_either", -> + assert.deepEqual docopt.transform(new docopt.Option('-a')), new docopt.Either([new docopt.Required([new docopt.Option('-a')])]) + assert.deepEqual docopt.transform(new docopt.Argument('A')), new docopt.Either([new docopt.Required([new docopt.Argument('A')])]) + assert.deepEqual( + docopt.transform(new docopt.Required([new docopt.Either([new docopt.Option('-a'), new docopt.Option('-b')]), new docopt.Option('-c')])) + new docopt.Either([new docopt.Required([new docopt.Option('-a'), new docopt.Option('-c')]), new docopt.Required([new docopt.Option('-b'), new docopt.Option('-c')])]) + ) + assert.deepEqual( + docopt.transform(new docopt.Optional([new docopt.Option('-a'), new docopt.Either([new docopt.Option('-b'), new docopt.Option('-c')])])) + new docopt.Either([new docopt.Required([new docopt.Option('-b'), new docopt.Option('-a')]), new docopt.Required([new docopt.Option('-c'), new docopt.Option('-a')])]) + ) + assert.deepEqual( + docopt.transform(new docopt.Either([new docopt.Option('-x'), new docopt.Either([new docopt.Option('-y'), new docopt.Option('-z')])])) + new docopt.Either([new docopt.Required([new docopt.Option('-x')]), new docopt.Required([new docopt.Option('-y')]), new docopt.Required([new docopt.Option('-z')])]) + ) + assert.deepEqual( + docopt.transform(new docopt.OneOrMore([new docopt.Argument('N'), new docopt.Argument('M')])) + new docopt.Either([new docopt.Required([new docopt.Argument('N'), new docopt.Argument('M'), new docopt.Argument('N'), new docopt.Argument('M')])]) + ) + + + it "test_pattern_fix_repeating_arguments", -> + assert.deepEqual new docopt.Option('-a').fix_repeating_arguments(), new docopt.Option('-a') + assert.deepEqual new docopt.Argument('N', null).fix_repeating_arguments(), new docopt.Argument('N', null) + assert.deepEqual( + new docopt.Required([new docopt.Argument('N'), new docopt.Argument('N')]).fix_repeating_arguments() + new docopt.Required([new docopt.Argument('N', []), new docopt.Argument('N', [])]) + ) + assert.deepEqual( + new docopt.Either([new docopt.Argument('N'), new docopt.OneOrMore([new docopt.Argument('N')])]).fix() + new docopt.Either([new docopt.Argument('N', []), new docopt.OneOrMore([new docopt.Argument('N', [])])]) + ) + + + # it "test_set", -> + # assert.deepEqual new docopt.Argument('N'), new docopt.Argument('N') + # assert.deepEqual new Set([new docopt.Argument('N'), new docopt.Argument('N')]), new Set([new docopt.Argument('N')]) + + + it "test_pattern_fix_identities_1", -> + pattern = new docopt.Required([new docopt.Argument('N'), new docopt.Argument('N')]) + assert.deepEqual pattern.children[0], pattern.children[1] + assert.notEqual pattern.children[0], pattern.children[1] + pattern.fix_identities() + assert.equal pattern.children[0], pattern.children[1] + + + it "test_pattern_fix_identities_2", -> + pattern = new docopt.Required([new docopt.Optional([new docopt.Argument('X'), new docopt.Argument('N')]), new docopt.Argument('N')]) + assert.deepEqual pattern.children[0].children[1], pattern.children[1] + assert.notEqual pattern.children[0].children[1], pattern.children[1] + pattern.fix_identities() + assert.equal pattern.children[0].children[1], pattern.children[1] + + + it "test_long_options_error_handling", -> + assert.throws( + () -> + docopt.docopt('Usage: prog', {argv: '--non-existent', exit: false}) + , + docopt.DocoptExit + ) + assert.throws( + () -> + docopt.docopt('Usage: prog [--version --verbose]\nOptions: --version\n --verbose', {argv: '--ver', exit: false}) + , + docopt.DocoptExit + ) + assert.throws( + () -> + docopt.docopt('Usage: prog --long\nOptions: --long ARG', {argv: '', exit: false}) + , + docopt.DocoptLanguageError + ) + assert.throws( + () -> + docopt.docopt('Usage: prog --long ARG\nOptions: --long ARG', {argv: '--long', exit: false}) + , + docopt.DocoptExit + ) + assert.throws( + () -> + docopt.docopt('Usage: prog --long=ARG\nOptions: --long', {argv: '', exit: false}) + , + docopt.DocoptLanguageError + ) + assert.throws( + () -> + docopt.docopt('Usage: prog --long\nOptions: --long', {argv: '--long=ARG', exit: false}) + , + docopt.DocoptExit + ) + + + it "test_short_options_error_handling", -> + assert.throws( + () -> + docopt.docopt('Usage: prog -x\nOptions: -x this\n -x that', {argv: '', exit: false}) + , + docopt.DocoptLanguageError + ) + assert.throws( + () -> + docopt.docopt('Usage: prog', {argv: '-x', exit: false}) + , + docopt.DocoptExit + ) + assert.throws( + () -> + docopt.docopt('Usage: prog -o\nOptions: -o ARG', {argv: '', exit: false}) + , + docopt.DocoptLanguageError + ) + assert.throws( + () -> + docopt.docopt('Usage: prog -o ARG\nOptions: -o ARG', {argv: '-o', exit: false}) + , + docopt.DocoptExit + ) + + + it "test_matching_paren", -> + assert.throws( + () -> + docopt.docopt('Usage: prog [a [b]', {argv: '', exit: false}) + , + docopt.DocoptLanguageError + ) + assert.throws( + () -> + docopt.docopt('Usage: prog [a [b] ] c )', {argv: '', exit: false}) + , + docopt.DocoptLanguageError + ) + + + it "test_allow_double_dash", -> + assert.deepEqual( + docopt.docopt('usage: prog [-o] [--] \nkptions: -o', {argv: '-- -o', exit: false}), + {'-o': false, '': '-o', '--': true} + ) + assert.deepEqual( + docopt.docopt('usage: prog [-o] [--] \nkptions: -o', {argv: '-o 1', exit: false}), + {'-o': true, '': '1', '--': false} + ) + assert.throws( + () -> + docopt.docopt('usage: prog [-o] \nOptions:-o', {argv: '-- -o', exit: false}) + , + docopt.DocoptExit # "--" is not allowed; FIXME? + ) + + + it "test_docopt", -> + doc = '''Usage: prog [-v] A + + Options: -v Be verbose.''' + assert.deepEqual docopt.docopt(doc, {argv: 'arg', exit: false}), {'-v': false, 'A': 'arg'} + assert.deepEqual docopt.docopt(doc, {argv: '-v arg', exit: false}), {'-v': true, 'A': 'arg'} + + doc = """Usage: prog [-vqr] [FILE] + prog INPUT OUTPUT + prog --help + + Options: + -v print status messages + -q report only file names + -r show all occurrences of the same error + --help + + """ + assert.deepEqual( + docopt.docopt(doc, {argv: '-v file.py', exit: false}) + {'-v': true, '-q': false, '-r': false, '--help': false, 'FILE': 'file.py', 'INPUT': null, 'OUTPUT': null} + ) + assert.deepEqual( + docopt.docopt(doc, {argv: '-v', exit: false}) + {'-v': true, '-q': false, '-r': false, '--help': false, 'FILE': null, 'INPUT': null, 'OUTPUT': null} + ) + assert.throws( + () -> + docopt.docopt(doc, {argv: '-v input.py output.py', exit: false}) + , + docopt.DocoptExit + ) + assert.throws( + () -> + docopt.docopt(doc, {argv: '--fake', exit: false}) + , + docopt.DocoptExit + ) + assert.throws( + () -> + docopt.docopt(doc, {argv: '--hel', exit: false}) + , + Error + ) + + + it "test_language_errors", -> + assert.throws( + () -> + docopt.docopt('no usage with colon here', {argv: '', exit: false}) + , + docopt.DocoptLanguageError + ) + assert.throws( + () -> + docopt.docopt('usage: here \n\n and again usage: here', {argv: '', exit: false}) + , + docopt.DocoptLanguageError + ) + + + it "test_issue_40", -> + assert.throws( + () -> + docopt.docopt('usage: prog --help-commands | --help', {argv: '--help', exit: false}) + , + Error + ) + assert.deepEqual( + docopt.docopt('usage: prog --aabb | --aa', {argv: '--aa', exit: false}), + {'--aabb': false, '--aa': true} + ) + + + # it "test_issue34_unicode_strings", -> + # try: + # assert.deepEqual docopt.docopt(eval("u'usage: prog [-o ]'"), ''), + # {'-o': false, '': null} + # except SyntaxError: + # pass # Python 3 + + + it "test_count_multiple_flags", -> + assert.deepEqual docopt.docopt('usage: prog [-v]', {argv: '-v', exit: false}), {'-v': true} + assert.deepEqual docopt.docopt('usage: prog [-vv]', {argv: '', exit: false}), {'-v': 0} + assert.deepEqual docopt.docopt('usage: prog [-vv]', {argv: '-v', exit: false}), {'-v': 1} + assert.deepEqual docopt.docopt('usage: prog [-vv]', {argv: '-vv', exit: false}), {'-v': 2} + assert.throws( + () -> + docopt.docopt('usage: prog [-vv]', {argv: '-vvv', exit: false}) + , + docopt.DocoptExit + ) + assert.deepEqual docopt.docopt('usage: prog [-v | -vv | -vvv]', {argv: '-vvv', exit: false}), {'-v': 3} + assert.deepEqual docopt.docopt('usage: prog -v...', {argv: '-vvvvvv', exit: false}), {'-v': 6} + assert.deepEqual docopt.docopt('usage: prog [--ver --ver]', {argv: '--ver --ver', exit: false}), {'--ver': 2} + + + it "test_any_options_parameter", -> + assert.throws( + () -> + docopt.docopt('usage: prog [options]', {argv: '-foo --bar --spam=eggs', exit: false}) + , + docopt.DocoptExit + ) + assert.throws( + () -> + docopt.docopt('usage: prog [options]', {argv: '--foo --bar --bar', exit: false}) + , + docopt.DocoptExit + ) + assert.throws( + () -> + docopt.docopt('usage: prog [options]', {argv: '--bar --bar --bar -ffff', exit: false}) + , + docopt.DocoptExit + ) + assert.throws( + () -> + docopt.docopt('usage: prog [options]', {argv: '--long=arg --long=another', exit: false}) + , + docopt.DocoptExit + ) + + + it "test_default_value_for_positional_arguments", -> + doc = """Usage: prog [--data=...]\n + Options:\n\t-d --data= Input data [default: x] + """ + a = docopt.docopt(doc, {argv: '', exit: false}) + assert.deepEqual a, {'--data': ['x']} + doc = """Usage: prog [--data=...]\n + Options:\n\t-d --data= Input data [default: x y] + """ + a = docopt.docopt(doc, {argv: '', exit: false}) + assert.deepEqual a, {'--data': ['x', 'y']} + doc = """Usage: prog [--data=...]\n + Options:\n\t-d --data= Input data [default: x y] + """ + a = docopt.docopt(doc, {argv: '--data=this', exit: false}) + assert.deepEqual a, {'--data': ['this']} + + + it "test_issue_59", -> + assert.deepEqual docopt.docopt('usage: prog --long=', {argv: '--long=', exit: false}), {'--long': ''} + assert.deepEqual docopt.docopt('usage: prog -l \nOptions: -l ', {argv: ['-l', ''], exit: false}), {'-l': ''} + + + it "test_options_first", -> + assert.deepEqual( + docopt.docopt('usage: prog [--opt] [...]', {argv: '--opt this that', exit: false}) + {'--opt': true, '': ['this', 'that']} + ) + assert.deepEqual( + docopt.docopt('usage: prog [--opt] [...]', {argv: 'this that --opt', exit: false}) + {'--opt': true, '': ['this', 'that']} + ) + assert.deepEqual( + docopt.docopt('usage: prog [--opt] [...]', {argv: 'this that --opt', exit: false, options_first: true}) + {'--opt': false, '': ['this', 'that', '--opt']} + ) + + + it "test_issue_68_options_shortcut_does_not_include_options_in_usage_pattern", -> + args = docopt.docopt('usage: prog [-ab] [options]\nOptions: -x\n -y', {argv: '-ax', exit: false}) + # Need to use `is` (not `==`) since we want to make sure + # that they are not 1/0, but strictly true/false: + assert.equal args['-a'], true + assert.equal args['-b'], false + assert.equal args['-x'], true + assert.equal args['-y'], false + + + it "test_issue_65_evaluate_argv_when_called_not_when_imported", -> + process.argv = ['node', 'prog', '-a'] + assert.deepEqual docopt.docopt('usage: prog [-ab]', {exit: false}), {'-a': true, '-b': false} + process.argv = ['node', 'prog', '-b'] + assert.deepEqual docopt.docopt('usage: prog [-ab]', {exit: false}), {'-a': false, '-b': true} + + + it "test_issue_71_double_dash_is_not_a_valid_option_argument", -> + assert.throws( + () -> + docopt.docopt('usage: prog [--log=LEVEL] [--] ...', {argv: '--log -- 1 2', exit: false}) + , + docopt.DocoptExit + ) + assert.throws( + () -> + docopt.docopt('''usage: prog [-l LEVEL] [--] ... + Options: -l LEVEL''', {argv: '-l -- 1 2', exit: false}) + , + docopt.DocoptExit + ) + + usage = '''usage: this + + usage:hai + usage: this that + + usage: foo + bar + + PROGRAM USAGE: + foo + bar + usage: + \ttoo + \ttar + Usage: eggs spam + BAZZ + usage: pit stop''' + + it "test_parse_section", -> + assert.deepEqual docopt.parse_section('usage:', 'foo bar fizz buzz'), [] + assert.deepEqual docopt.parse_section('usage:', 'usage: prog'), ['usage: prog'] + assert.deepEqual docopt.parse_section('usage:', 'usage: -x\n -y'), ['usage: -x\n -y'] + assert.deepEqual docopt.parse_section('usage:', usage), [ + 'usage: this', + 'usage:hai', + 'usage: this that', + 'usage: foo\n bar', + 'PROGRAM USAGE:\n foo\n bar', + 'usage:\n\ttoo\n\ttar', + 'Usage: eggs spam', + 'usage: pit stop', + ] + + + it "test_issue_126_defaults_not_parsed_correctly_when_tabs", -> + section = 'Options:\n\t--foo= [default: bar]' + assert.deepEqual docopt.parse_defaults(section), [new docopt.Option(null, '--foo', 1, 'bar')] diff --git a/node_modules/docopt/test/testcases.coffee b/node_modules/docopt/test/testcases.coffee new file mode 100644 index 0000000000000..05b006d63b447 --- /dev/null +++ b/node_modules/docopt/test/testcases.coffee @@ -0,0 +1,63 @@ +assert = require 'assert' +path = require 'path' +fs = require 'fs' +docopt = require '../docopt.coffee' + +partition = (text, delimiter) -> + parts = text.split delimiter + return [parts[0], delimiter, parts[1..].join(delimiter)] + +load_test_cases = () -> + testcases_path = path.resolve './test/testcases.docopt' + if fs.existsSync testcases_path + try + return fs.readFileSync(testcases_path).toString() + catch err + return console.error "Could not read ./test/testcases.docopt file" + else + return console.error "./test/testcases.docopt not exists" + +parse_test = (raw) -> + raw = raw.replace(/#.*/gm, '').trim() + if (raw.indexOf '"""') is 0 + raw = raw[3..] + + tests = [] + for fixture in raw.split('r"""') + name = '' + [doc, _, body] = partition fixture, '"""' + cases = [] + for mycase in body.split('$')[1..] + [argv, _, expect] = partition mycase.trim(), '\n' + expect = JSON.parse(expect) + [prog, _, argv] = partition argv.trim(), ' ' + cases.push([prog, argv, expect]) + tests.push [name, doc, cases] + return tests + +collect = () -> + index = 1 + collected = [] + testcases = load_test_cases() + for [name, doc, cases] in parse_test testcases + name = 'testcases.docopt' + for mycase in cases + collected.push [[name, index], doc, mycase] + index++ + return collected + + +describe 'testcases.coffee', -> + collected = collect() + collected.forEach (c) -> + [test_file, index] = c[0] + doc = c[1] + [prog, argv, expected] = c[2] + it "testcase #{index} `#{[prog, argv].join(' ')}`", -> + try + result = docopt.docopt(doc, {name: prog, argv: argv, exit: false}) + catch e + if e.constructor is docopt.DocoptExit + result = 'user-error' + finally + assert.deepEqual result, expected diff --git a/node_modules/docopt/test/testcases.docopt b/node_modules/docopt/test/testcases.docopt new file mode 100644 index 0000000000000..efe9a07f608eb --- /dev/null +++ b/node_modules/docopt/test/testcases.docopt @@ -0,0 +1,957 @@ +r"""Usage: prog + +""" +$ prog +{} + +$ prog --xxx +"user-error" + + +r"""Usage: prog [options] + +Options: -a All. + +""" +$ prog +{"-a": false} + +$ prog -a +{"-a": true} + +$ prog -x +"user-error" + + +r"""Usage: prog [options] + +Options: --all All. + +""" +$ prog +{"--all": false} + +$ prog --all +{"--all": true} + +$ prog --xxx +"user-error" + + +r"""Usage: prog [options] + +Options: -v, --verbose Verbose. + +""" +$ prog --verbose +{"--verbose": true} + +$ prog --ver +{"--verbose": true} + +$ prog -v +{"--verbose": true} + + +r"""Usage: prog [options] + +Options: -p PATH + +""" +$ prog -p home/ +{"-p": "home/"} + +$ prog -phome/ +{"-p": "home/"} + +$ prog -p +"user-error" + + +r"""Usage: prog [options] + +Options: --path + +""" +$ prog --path home/ +{"--path": "home/"} + +$ prog --path=home/ +{"--path": "home/"} + +$ prog --pa home/ +{"--path": "home/"} + +$ prog --pa=home/ +{"--path": "home/"} + +$ prog --path +"user-error" + + +r"""Usage: prog [options] + +Options: -p PATH, --path= Path to files. + +""" +$ prog -proot +{"--path": "root"} + + +r"""Usage: prog [options] + +Options: -p --path PATH Path to files. + +""" +$ prog -p root +{"--path": "root"} + +$ prog --path root +{"--path": "root"} + + +r"""Usage: prog [options] + +Options: + -p PATH Path to files [default: ./] + +""" +$ prog +{"-p": "./"} + +$ prog -phome +{"-p": "home"} + + +r"""UsAgE: prog [options] + +OpTiOnS: --path= Path to files + [dEfAuLt: /root] + +""" +$ prog +{"--path": "/root"} + +$ prog --path=home +{"--path": "home"} + + +r"""usage: prog [options] + +options: + -a Add + -r Remote + -m Message + +""" +$ prog -a -r -m Hello +{"-a": true, + "-r": true, + "-m": "Hello"} + +$ prog -armyourass +{"-a": true, + "-r": true, + "-m": "yourass"} + +$ prog -a -r +{"-a": true, + "-r": true, + "-m": null} + + +r"""Usage: prog [options] + +Options: --version + --verbose + +""" +$ prog --version +{"--version": true, + "--verbose": false} + +$ prog --verbose +{"--version": false, + "--verbose": true} + +$ prog --ver +"user-error" + +$ prog --verb +{"--version": false, + "--verbose": true} + + +r"""usage: prog [-a -r -m ] + +options: + -a Add + -r Remote + -m Message + +""" +$ prog -armyourass +{"-a": true, + "-r": true, + "-m": "yourass"} + + +r"""usage: prog [-armmsg] + +options: -a Add + -r Remote + -m Message + +""" +$ prog -a -r -m Hello +{"-a": true, + "-r": true, + "-m": "Hello"} + + +r"""usage: prog -a -b + +options: + -a + -b + +""" +$ prog -a -b +{"-a": true, "-b": true} + +$ prog -b -a +{"-a": true, "-b": true} + +$ prog -a +"user-error" + +$ prog +"user-error" + + +r"""usage: prog (-a -b) + +options: -a + -b + +""" +$ prog -a -b +{"-a": true, "-b": true} + +$ prog -b -a +{"-a": true, "-b": true} + +$ prog -a +"user-error" + +$ prog +"user-error" + + +r"""usage: prog [-a] -b + +options: -a + -b + +""" +$ prog -a -b +{"-a": true, "-b": true} + +$ prog -b -a +{"-a": true, "-b": true} + +$ prog -a +"user-error" + +$ prog -b +{"-a": false, "-b": true} + +$ prog +"user-error" + + +r"""usage: prog [(-a -b)] + +options: -a + -b + +""" +$ prog -a -b +{"-a": true, "-b": true} + +$ prog -b -a +{"-a": true, "-b": true} + +$ prog -a +"user-error" + +$ prog -b +"user-error" + +$ prog +{"-a": false, "-b": false} + + +r"""usage: prog (-a|-b) + +options: -a + -b + +""" +$ prog -a -b +"user-error" + +$ prog +"user-error" + +$ prog -a +{"-a": true, "-b": false} + +$ prog -b +{"-a": false, "-b": true} + + +r"""usage: prog [ -a | -b ] + +options: -a + -b + +""" +$ prog -a -b +"user-error" + +$ prog +{"-a": false, "-b": false} + +$ prog -a +{"-a": true, "-b": false} + +$ prog -b +{"-a": false, "-b": true} + + +r"""usage: prog """ +$ prog 10 +{"": "10"} + +$ prog 10 20 +"user-error" + +$ prog +"user-error" + + +r"""usage: prog []""" +$ prog 10 +{"": "10"} + +$ prog 10 20 +"user-error" + +$ prog +{"": null} + + +r"""usage: prog """ +$ prog 10 20 40 +{"": "10", "": "20", "": "40"} + +$ prog 10 20 +"user-error" + +$ prog +"user-error" + + +r"""usage: prog [ ]""" +$ prog 10 20 40 +{"": "10", "": "20", "": "40"} + +$ prog 10 20 +{"": "10", "": "20", "": null} + +$ prog +"user-error" + + +r"""usage: prog [ | ]""" +$ prog 10 20 40 +"user-error" + +$ prog 20 40 +{"": null, "": "20", "": "40"} + +$ prog +{"": null, "": null, "": null} + + +r"""usage: prog ( --all | ) + +options: + --all + +""" +$ prog 10 --all +{"": "10", "--all": true, "": null} + +$ prog 10 +{"": null, "--all": false, "": "10"} + +$ prog +"user-error" + + +r"""usage: prog [ ]""" +$ prog 10 20 +{"": ["10", "20"]} + +$ prog 10 +{"": ["10"]} + +$ prog +{"": []} + + +r"""usage: prog [( )]""" +$ prog 10 20 +{"": ["10", "20"]} + +$ prog 10 +"user-error" + +$ prog +{"": []} + + +r"""usage: prog NAME...""" +$ prog 10 20 +{"NAME": ["10", "20"]} + +$ prog 10 +{"NAME": ["10"]} + +$ prog +"user-error" + + +r"""usage: prog [NAME]...""" +$ prog 10 20 +{"NAME": ["10", "20"]} + +$ prog 10 +{"NAME": ["10"]} + +$ prog +{"NAME": []} + + +r"""usage: prog [NAME...]""" +$ prog 10 20 +{"NAME": ["10", "20"]} + +$ prog 10 +{"NAME": ["10"]} + +$ prog +{"NAME": []} + + +r"""usage: prog [NAME [NAME ...]]""" +$ prog 10 20 +{"NAME": ["10", "20"]} + +$ prog 10 +{"NAME": ["10"]} + +$ prog +{"NAME": []} + + +r"""usage: prog (NAME | --foo NAME) + +options: --foo + +""" +$ prog 10 +{"NAME": "10", "--foo": false} + +$ prog --foo 10 +{"NAME": "10", "--foo": true} + +$ prog --foo=10 +"user-error" + + +r"""usage: prog (NAME | --foo) [--bar | NAME] + +options: --foo +options: --bar + +""" +$ prog 10 +{"NAME": ["10"], "--foo": false, "--bar": false} + +$ prog 10 20 +{"NAME": ["10", "20"], "--foo": false, "--bar": false} + +$ prog --foo --bar +{"NAME": [], "--foo": true, "--bar": true} + + +r"""Naval Fate. + +Usage: + prog ship new ... + prog ship [] move [--speed=] + prog ship shoot + prog mine (set|remove) [--moored|--drifting] + prog -h | --help + prog --version + +Options: + -h --help Show this screen. + --version Show version. + --speed= Speed in knots [default: 10]. + --moored Mored (anchored) mine. + --drifting Drifting mine. + +""" +$ prog ship Guardian move 150 300 --speed=20 +{"--drifting": false, + "--help": false, + "--moored": false, + "--speed": "20", + "--version": false, + "": ["Guardian"], + "": "150", + "": "300", + "mine": false, + "move": true, + "new": false, + "remove": false, + "set": false, + "ship": true, + "shoot": false} + + +r"""usage: prog --hello""" +$ prog --hello +{"--hello": true} + + +r"""usage: prog [--hello=]""" +$ prog +{"--hello": null} + +$ prog --hello wrld +{"--hello": "wrld"} + + +r"""usage: prog [-o]""" +$ prog +{"-o": false} + +$ prog -o +{"-o": true} + + +r"""usage: prog [-opr]""" +$ prog -op +{"-o": true, "-p": true, "-r": false} + + +r"""usage: prog --aabb | --aa""" +$ prog --aa +{"--aabb": false, "--aa": true} + +$ prog --a +"user-error" # not a unique prefix + +# +# Counting number of flags +# + +r"""Usage: prog -v""" +$ prog -v +{"-v": true} + + +r"""Usage: prog [-v -v]""" +$ prog +{"-v": 0} + +$ prog -v +{"-v": 1} + +$ prog -vv +{"-v": 2} + + +r"""Usage: prog -v ...""" +$ prog +"user-error" + +$ prog -v +{"-v": 1} + +$ prog -vv +{"-v": 2} + +$ prog -vvvvvv +{"-v": 6} + + +r"""Usage: prog [-v | -vv | -vvv] + +This one is probably most readable user-friednly variant. + +""" +$ prog +{"-v": 0} + +$ prog -v +{"-v": 1} + +$ prog -vv +{"-v": 2} + +$ prog -vvvv +"user-error" + + +r"""usage: prog [--ver --ver]""" +$ prog --ver --ver +{"--ver": 2} + + +# +# Counting commands +# + +r"""usage: prog [go]""" +$ prog go +{"go": true} + + +r"""usage: prog [go go]""" +$ prog +{"go": 0} + +$ prog go +{"go": 1} + +$ prog go go +{"go": 2} + +$ prog go go go +"user-error" + +r"""usage: prog go...""" +$ prog go go go go go +{"go": 5} + +# +# [options] does not include options from usage-pattern +# +r"""usage: prog [options] [-a] + +options: -a + -b +""" +$ prog -a +{"-a": true, "-b": false} + +$ prog -aa +"user-error" + +# +# Test [options] shourtcut +# + +r"""Usage: prog [options] A +Options: + -q Be quiet + -v Be verbose. + +""" +$ prog arg +{"A": "arg", "-v": false, "-q": false} + +$ prog -v arg +{"A": "arg", "-v": true, "-q": false} + +$ prog -q arg +{"A": "arg", "-v": false, "-q": true} + +# +# Test single dash +# + +r"""usage: prog [-]""" + +$ prog - +{"-": true} + +$ prog +{"-": false} + +# +# If argument is repeated, its value should always be a list +# + +r"""usage: prog [NAME [NAME ...]]""" + +$ prog a b +{"NAME": ["a", "b"]} + +$ prog +{"NAME": []} + +# +# Option's argument defaults to null/None +# + +r"""usage: prog [options] +options: + -a Add + -m Message + +""" +$ prog -a +{"-m": null, "-a": true} + +# +# Test options without description +# + +r"""usage: prog --hello""" +$ prog --hello +{"--hello": true} + +r"""usage: prog [--hello=]""" +$ prog +{"--hello": null} + +$ prog --hello wrld +{"--hello": "wrld"} + +r"""usage: prog [-o]""" +$ prog +{"-o": false} + +$ prog -o +{"-o": true} + +r"""usage: prog [-opr]""" +$ prog -op +{"-o": true, "-p": true, "-r": false} + +r"""usage: git [-v | --verbose]""" +$ prog -v +{"-v": true, "--verbose": false} + +r"""usage: git remote [-v | --verbose]""" +$ prog remote -v +{"remote": true, "-v": true, "--verbose": false} + +# +# Test empty usage pattern +# + +r"""usage: prog""" +$ prog +{} + +r"""usage: prog + prog +""" +$ prog 1 2 +{"": "1", "": "2"} + +$ prog +{"": null, "": null} + +r"""usage: prog + prog +""" +$ prog +{"": null, "": null} + +# +# Option's argument should not capture default value from usage pattern +# + +r"""usage: prog [--file=]""" +$ prog +{"--file": null} + +r"""usage: prog [--file=] + +options: --file + +""" +$ prog +{"--file": null} + +r"""Usage: prog [-a ] + +Options: -a, --address TCP address [default: localhost:6283]. + +""" +$ prog +{"--address": "localhost:6283"} + +# +# If option with argument could be repeated, +# its arguments should be accumulated into a list +# + +r"""usage: prog --long= ...""" + +$ prog --long one +{"--long": ["one"]} + +$ prog --long one --long two +{"--long": ["one", "two"]} + +# +# Test multiple elements repeated at once +# + +r"""usage: prog (go --speed=)...""" +$ prog go left --speed=5 go right --speed=9 +{"go": 2, "": ["left", "right"], "--speed": ["5", "9"]} + +# +# Required options should work with option shortcut +# + +r"""usage: prog [options] -a + +options: -a + +""" +$ prog -a +{"-a": true} + +# +# If option could be repeated its defaults should be split into a list +# + +r"""usage: prog [-o ]... + +options: -o [default: x] + +""" +$ prog -o this -o that +{"-o": ["this", "that"]} + +$ prog +{"-o": ["x"]} + +r"""usage: prog [-o ]... + +options: -o [default: x y] + +""" +$ prog -o this +{"-o": ["this"]} + +$ prog +{"-o": ["x", "y"]} + +# +# Test stacked option's argument +# + +r"""usage: prog -pPATH + +options: -p PATH + +""" +$ prog -pHOME +{"-p": "HOME"} + +# +# Issue 56: Repeated mutually exclusive args give nested lists sometimes +# + +r"""Usage: foo (--xx=x|--yy=y)...""" +$ prog --xx=1 --yy=2 +{"--xx": ["1"], "--yy": ["2"]} + +# +# POSIXly correct tokenization +# + +r"""usage: prog []""" +$ prog f.txt +{"": "f.txt"} + +r"""usage: prog [--input=]...""" +$ prog --input a.txt --input=b.txt +{"--input": ["a.txt", "b.txt"]} + +# +# Issue 85: `[options]` shourtcut with multiple subcommands +# + +r"""usage: prog good [options] + prog fail [options] + +options: --loglevel=N + +""" +$ prog fail --loglevel 5 +{"--loglevel": "5", "fail": true, "good": false} + +# +# Usage-section syntax +# + +r"""usage:prog --foo""" +$ prog --foo +{"--foo": true} + +r"""PROGRAM USAGE: prog --foo""" +$ prog --foo +{"--foo": true} + +r"""Usage: prog --foo + prog --bar +NOT PART OF SECTION""" +$ prog --foo +{"--foo": true, "--bar": false} + +r"""Usage: + prog --foo + prog --bar + +NOT PART OF SECTION""" +$ prog --foo +{"--foo": true, "--bar": false} + +r"""Usage: + prog --foo + prog --bar +NOT PART OF SECTION""" +$ prog --foo +{"--foo": true, "--bar": false} + +# +# Options-section syntax +# + +r"""Usage: prog [options] + +global options: --foo +local options: --baz + --bar +other options: + --egg + --spam +-not-an-option- + +""" +$ prog --baz --egg +{"--foo": false, "--baz": true, "--bar": false, "--egg": true, "--spam": false} diff --git a/node_modules/fs-access/index.js b/node_modules/fs-access/index.js new file mode 100644 index 0000000000000..094537a455d7b --- /dev/null +++ b/node_modules/fs-access/index.js @@ -0,0 +1,41 @@ +'use strict'; +var fs = require('fs'); +var nullCheck = require('null-check'); + +var access = module.exports = function (pth, mode, cb) { + if (typeof pth !== 'string') { + throw new TypeError('path must be a string'); + } + + if (typeof mode === 'function') { + cb = mode; + mode = access.F_OK; + } else if (typeof cb !== 'function') { + throw new TypeError('callback must be a function'); + } + + if (!nullCheck(pth, cb)) { + return; + } + + mode = mode | 0; + + if (mode === access.F_OK) { + fs.stat(pth, cb); + } +}; + +access.sync = function (pth, mode) { + nullCheck(pth); + + mode = mode === undefined ? access.F_OK : mode | 0; + + if (mode === access.F_OK) { + fs.statSync(pth); + } +}; + +access.F_OK = 0; +access.R_OK = 4; +access.W_OK = 2; +access.X_OK = 1; diff --git a/node_modules/fs-access/license b/node_modules/fs-access/license new file mode 100644 index 0000000000000..654d0bfe94343 --- /dev/null +++ b/node_modules/fs-access/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +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/node_modules/fs-access/package.json b/node_modules/fs-access/package.json new file mode 100644 index 0000000000000..f98df6784e423 --- /dev/null +++ b/node_modules/fs-access/package.json @@ -0,0 +1,78 @@ +{ + "_args": [ + [ + "fs-access@1.0.1", + "/Users/zkat/Documents/code/work/npm" + ] + ], + "_development": true, + "_from": "fs-access@1.0.1", + "_id": "fs-access@1.0.1", + "_inBundle": false, + "_integrity": "sha1-1qh/JiJxzv6+wwxVNAf7mV2od3o=", + "_location": "/fs-access", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "fs-access@1.0.1", + "name": "fs-access", + "escapedName": "fs-access", + "rawSpec": "1.0.1", + "saveSpec": null, + "fetchSpec": "1.0.1" + }, + "_requiredBy": [ + "/licensee" + ], + "_resolved": "https://registry.npmjs.org/fs-access/-/fs-access-1.0.1.tgz", + "_spec": "1.0.1", + "_where": "/Users/zkat/Documents/code/work/npm", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/sindresorhus/fs-access/issues" + }, + "dependencies": { + "null-check": "^1.0.0" + }, + "description": "Node.js 0.12 fs.access() & fs.accessSync() ponyfill", + "devDependencies": { + "os-tmpdir": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "homepage": "https://github.com/sindresorhus/fs-access#readme", + "keywords": [ + "built-in", + "core", + "ponyfill", + "polyfill", + "shim", + "fs", + "access", + "stat", + "mode", + "permission", + "user", + "process", + "check" + ], + "license": "MIT", + "name": "fs-access", + "repository": { + "type": "git", + "url": "git+https://github.com/sindresorhus/fs-access.git" + }, + "scripts": { + "test": "node test.js" + }, + "version": "1.0.1" +} diff --git a/node_modules/fs-access/readme.md b/node_modules/fs-access/readme.md new file mode 100644 index 0000000000000..89e96e750bacc --- /dev/null +++ b/node_modules/fs-access/readme.md @@ -0,0 +1,51 @@ +# fs-access [![Build Status](https://travis-ci.org/sindresorhus/fs-access.svg?branch=master)](https://travis-ci.org/sindresorhus/fs-access) + +> Node.js 0.12 [`fs.access()`](https://nodejs.org/api/fs.html#fs_fs_access_path_mode_callback) & [`fs.accessSync()`](https://nodejs.org/api/fs.html#fs_fs_accesssync_path_mode) [ponyfill](https://ponyfill.com) + + +## Install + +``` +$ npm install --save fs-access +``` + + +## Usage + +```js +var fsAccess = require('fs-access'); + +fsAccess('unicorn.txt', function (err) { + if (err) { + console.error('no access'); + return; + } + + console.log('access'); +}); +``` + +```js +var fsAccess = require('fs-access'); + +try { + fsAccess.sync('unicorn.txt'); + console.log('access'); +} catch (err) { + console.error('no access'); +} +``` + + +## API + +See the [`fs.access()` & `fs.accessSync()` docs](https://nodejs.org/api/fs.html#fs_fs_access_path_mode_callback). + +Mode flags are on the `fsAccess` instance instead of `fs`. + +Only the `F_OK` mode is supported for now. [Help welcome for additional modes.](https://github.com/sindresorhus/fs-access/issues/1) + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/node_modules/json-parse-errback/LICENSE b/node_modules/json-parse-errback/LICENSE new file mode 100644 index 0000000000000..2966484fe8b7d --- /dev/null +++ b/node_modules/json-parse-errback/LICENSE @@ -0,0 +1,24 @@ +SPDX:MIT + +MIT License + +Copyright (c) 2016 Kyle E. Mitchell + +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/node_modules/json-parse-errback/README.md b/node_modules/json-parse-errback/README.md new file mode 100644 index 0000000000000..bddd4cee61bba --- /dev/null +++ b/node_modules/json-parse-errback/README.md @@ -0,0 +1,13 @@ +```javascript +module.exports = function (input, callback) { + var result + try { + result = JSON.parse(input) + } catch (error) { + return callback(error) + } + callback(null, result) +} +``` + +"That's all, folks!" diff --git a/node_modules/json-parse-errback/index.js b/node_modules/json-parse-errback/index.js new file mode 100644 index 0000000000000..2dfd5cb1f7d18 --- /dev/null +++ b/node_modules/json-parse-errback/index.js @@ -0,0 +1,13 @@ +module.exports = function (input, callback) { + var result + try { + result = JSON.parse(input) + } catch (error) { + return callback(error) + } + callback(null, result) +} + + + + diff --git a/node_modules/json-parse-errback/package.json b/node_modules/json-parse-errback/package.json new file mode 100644 index 0000000000000..141509a6fbc01 --- /dev/null +++ b/node_modules/json-parse-errback/package.json @@ -0,0 +1,59 @@ +{ + "_args": [ + [ + "json-parse-errback@2.0.1", + "/Users/zkat/Documents/code/work/npm" + ] + ], + "_development": true, + "_from": "json-parse-errback@2.0.1", + "_id": "json-parse-errback@2.0.1", + "_inBundle": false, + "_integrity": "sha1-x6nCvjqFWzQvgqv8ibyFk1tYhPo=", + "_location": "/json-parse-errback", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "json-parse-errback@2.0.1", + "name": "json-parse-errback", + "escapedName": "json-parse-errback", + "rawSpec": "2.0.1", + "saveSpec": null, + "fetchSpec": "2.0.1" + }, + "_requiredBy": [ + "/licensee" + ], + "_resolved": "https://registry.npmjs.org/json-parse-errback/-/json-parse-errback-2.0.1.tgz", + "_spec": "2.0.1", + "_where": "/Users/zkat/Documents/code/work/npm", + "author": { + "name": "Kyle E. Mitchell", + "email": "kyle@kemitchell.com", + "url": "https://kemitchell.com/" + }, + "bugs": { + "url": "https://github.com/kemitchell/json-parse-errback.js/issues" + }, + "description": "parse(input, function(error, object) { ... })", + "devDependencies": { + "defence-cli": "^1.0.5" + }, + "files": [ + "LICENSE", + "README.md", + "index.js" + ], + "homepage": "https://github.com/kemitchell/json-parse-errback.js#readme", + "license": "MIT", + "name": "json-parse-errback", + "repository": { + "type": "git", + "url": "git+https://github.com/kemitchell/json-parse-errback.js.git" + }, + "scripts": { + "prepublish": "defence < README.md > index.js" + }, + "version": "2.0.1" +} diff --git a/node_modules/libnpm/node_modules/libnpmhook/CHANGELOG.md b/node_modules/libnpm/node_modules/libnpmhook/CHANGELOG.md new file mode 100644 index 0000000000000..251d1f996dbba --- /dev/null +++ b/node_modules/libnpm/node_modules/libnpmhook/CHANGELOG.md @@ -0,0 +1,96 @@ +# Change Log + +All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. + + +## [5.0.2](https://github.com/npm/libnpmhook/compare/v5.0.1...v5.0.2) (2018-08-24) + + + + +## [5.0.1](https://github.com/npm/libnpmhook/compare/v5.0.0...v5.0.1) (2018-08-23) + + +### Bug Fixes + +* **deps:** move JSONStream to prod deps ([bb63594](https://github.com/npm/libnpmhook/commit/bb63594)) + + + + +# [5.0.0](https://github.com/npm/libnpmhook/compare/v4.0.1...v5.0.0) (2018-08-21) + + +### Features + +* **api:** overhauled API ([46b271b](https://github.com/npm/libnpmhook/commit/46b271b)) + + +### BREAKING CHANGES + +* **api:** the API for ls() has changed, and rm() no longer errors on 404 + + + + +## [4.0.1](https://github.com/npm/libnpmhook/compare/v4.0.0...v4.0.1) (2018-04-09) + + + + +# [4.0.0](https://github.com/npm/libnpmhook/compare/v3.0.1...v4.0.0) (2018-04-08) + + +### meta + +* drop support for node 4 and 7 ([f2a301e](https://github.com/npm/libnpmhook/commit/f2a301e)) + + +### BREAKING CHANGES + +* node@4 and node@7 are no longer supported + + + + +## [3.0.1](https://github.com/npm/libnpmhook/compare/v3.0.0...v3.0.1) (2018-04-08) + + + + +# [3.0.0](https://github.com/npm/libnpmhook/compare/v2.0.1...v3.0.0) (2018-04-04) + + +### add + +* guess type based on name ([9418224](https://github.com/npm/libnpmhook/commit/9418224)) + + +### BREAKING CHANGES + +* hook type is now based on name prefix + + + + +## [2.0.1](https://github.com/npm/libnpmhook/compare/v2.0.0...v2.0.1) (2018-03-16) + + +### Bug Fixes + +* **urls:** was hitting the wrong URL endpoints ([10171a9](https://github.com/npm/libnpmhook/commit/10171a9)) + + + + +# [2.0.0](https://github.com/npm/libnpmhook/compare/v1.0.0...v2.0.0) (2018-03-16) + + + + +# 1.0.0 (2018-03-16) + + +### Features + +* **api:** baseline working api ([122658e](https://github.com/npm/npm-hooks/commit/122658e)) diff --git a/node_modules/libnpm/node_modules/libnpmhook/LICENSE.md b/node_modules/libnpm/node_modules/libnpmhook/LICENSE.md new file mode 100644 index 0000000000000..8d28acf866d93 --- /dev/null +++ b/node_modules/libnpm/node_modules/libnpmhook/LICENSE.md @@ -0,0 +1,16 @@ +ISC License + +Copyright (c) npm, Inc. + +Permission to use, copy, modify, and/or distribute this software for +any purpose with or without fee is hereby granted, provided that the +above copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE COPYRIGHT HOLDER DISCLAIMS +ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR +CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS +OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE +USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/node_modules/libnpm/node_modules/libnpmhook/README.md b/node_modules/libnpm/node_modules/libnpmhook/README.md new file mode 100644 index 0000000000000..9a13d055317a5 --- /dev/null +++ b/node_modules/libnpm/node_modules/libnpmhook/README.md @@ -0,0 +1,267 @@ +# libnpmhook [![npm version](https://img.shields.io/npm/v/libnpmhook.svg)](https://npm.im/libnpmhook) [![license](https://img.shields.io/npm/l/libnpmhook.svg)](https://npm.im/libnpmhook) [![Travis](https://img.shields.io/travis/npm/libnpmhook.svg)](https://travis-ci.org/npm/libnpmhook) [![AppVeyor](https://ci.appveyor.com/api/projects/status/github/zkat/libnpmhook?svg=true)](https://ci.appveyor.com/project/zkat/libnpmhook) [![Coverage Status](https://coveralls.io/repos/github/npm/libnpmhook/badge.svg?branch=latest)](https://coveralls.io/github/npm/libnpmhook?branch=latest) + +[`libnpmhook`](https://github.com/npm/libnpmhook) is a Node.js library for +programmatically managing the npm registry's server-side hooks. + +For a more general introduction to managing hooks, see [the introductory blog +post](https://blog.npmjs.org/post/145260155635/introducing-hooks-get-notifications-of-npm). + +## Example + +```js +const hooks = require('libnpmhook') + +console.log(await hooks.ls('mypkg', {token: 'deadbeef'})) +// array of hook objects on `mypkg`. +``` + +## Install + +`$ npm install libnpmhook` + +## Table of Contents + +* [Example](#example) +* [Install](#install) +* [API](#api) + * [hook opts](#opts) + * [`add()`](#add) + * [`rm()`](#rm) + * [`ls()`](#ls) + * [`ls.stream()`](#ls-stream) + * [`update()`](#update) + +### API + +#### `opts` for `libnpmhook` commands + +`libnpmhook` uses [`npm-registry-fetch`](https://npm.im/npm-registry-fetch). +All options are passed through directly to that library, so please refer to [its +own `opts` +documentation](https://www.npmjs.com/package/npm-registry-fetch#fetch-options) +for options that can be passed in. + +A couple of options of note for those in a hurry: + +* `opts.token` - can be passed in and will be used as the authentication token for the registry. For other ways to pass in auth details, see the n-r-f docs. +* `opts.otp` - certain operations will require an OTP token to be passed in. If a `libnpmhook` command fails with `err.code === EOTP`, please retry the request with `{otp: <2fa token>}` +* `opts.Promise` - If you pass this in, the Promises returned by `libnpmhook` commands will use this Promise class instead. For example: `{Promise: require('bluebird')}` + +#### `> hooks.add(name, endpoint, secret, [opts]) -> Promise` + +`name` is the name of the package, org, or user/org scope to watch. The type is +determined by the name syntax: `'@foo/bar'` and `'foo'` are treated as packages, +`@foo` is treated as a scope, and `~user` is treated as an org name or scope. +Each type will attach to different events. + +The `endpoint` should be a fully-qualified http URL for the endpoint the hook +will send its payload to when it fires. `secret` is a shared secret that the +hook will send to that endpoint to verify that it's actually coming from the +registry hook. + +The returned Promise resolves to the full hook object that was created, +including its generated `id`. + +See also: [`POST +/v1/hooks/hook`](https://github.com/npm/registry/blob/master/docs/hooks/endpoints.md#post-v1hookshook) + +##### Example + +```javascript +await hooks.add('~zkat', 'https://zkat.tech/api/added', 'supersekrit', { + token: 'myregistrytoken', + otp: '694207' +}) + +=> + +{ id: '16f7xoal', + username: 'zkat', + name: 'zkat', + endpoint: 'https://zkat.tech/api/added', + secret: 'supersekrit', + type: 'owner', + created: '2018-08-21T20:05:25.125Z', + updated: '2018-08-21T20:05:25.125Z', + deleted: false, + delivered: false, + last_delivery: null, + response_code: 0, + status: 'active' } +``` + +#### `> hooks.find(id, [opts]) -> Promise` + +Returns the hook identified by `id`. + +The returned Promise resolves to the full hook object that was found, or error +with `err.code` of `'E404'` if it didn't exist. + +See also: [`GET +/v1/hooks/hook/:id`](https://github.com/npm/registry/blob/master/docs/hooks/endpoints.md#get-v1hookshookid) + +##### Example + +```javascript +await hooks.find('16f7xoal', {token: 'myregistrytoken'}) + +=> + +{ id: '16f7xoal', + username: 'zkat', + name: 'zkat', + endpoint: 'https://zkat.tech/api/added', + secret: 'supersekrit', + type: 'owner', + created: '2018-08-21T20:05:25.125Z', + updated: '2018-08-21T20:05:25.125Z', + deleted: false, + delivered: false, + last_delivery: null, + response_code: 0, + status: 'active' } +``` + +#### `> hooks.rm(id, [opts]) -> Promise` + +Removes the hook identified by `id`. + +The returned Promise resolves to the full hook object that was removed, if it +existed, or `null` if no such hook was there (instead of erroring). + +See also: [`DELETE +/v1/hooks/hook/:id`](https://github.com/npm/registry/blob/master/docs/hooks/endpoints.md#delete-v1hookshookid) + +##### Example + +```javascript +await hooks.rm('16f7xoal', { + token: 'myregistrytoken', + otp: '694207' +}) + +=> + +{ id: '16f7xoal', + username: 'zkat', + name: 'zkat', + endpoint: 'https://zkat.tech/api/added', + secret: 'supersekrit', + type: 'owner', + created: '2018-08-21T20:05:25.125Z', + updated: '2018-08-21T20:05:25.125Z', + deleted: true, + delivered: false, + last_delivery: null, + response_code: 0, + status: 'active' } + +// Repeat it... +await hooks.rm('16f7xoal', { + token: 'myregistrytoken', + otp: '694207' +}) + +=> null +``` + +#### `> hooks.update(id, endpoint, secret, [opts]) -> Promise` + +The `id` should be a hook ID from a previously-created hook. + +The `endpoint` should be a fully-qualified http URL for the endpoint the hook +will send its payload to when it fires. `secret` is a shared secret that the +hook will send to that endpoint to verify that it's actually coming from the +registry hook. + +The returned Promise resolves to the full hook object that was updated, if it +existed. Otherwise, it will error with an `'E404'` error code. + +See also: [`PUT +/v1/hooks/hook/:id`](https://github.com/npm/registry/blob/master/docs/hooks/endpoints.md#put-v1hookshookid) + +##### Example + +```javascript +await hooks.update('16fxoal', 'https://zkat.tech/api/other', 'newsekrit', { + token: 'myregistrytoken', + otp: '694207' +}) + +=> + +{ id: '16f7xoal', + username: 'zkat', + name: 'zkat', + endpoint: 'https://zkat.tech/api/other', + secret: 'newsekrit', + type: 'owner', + created: '2018-08-21T20:05:25.125Z', + updated: '2018-08-21T20:14:41.964Z', + deleted: false, + delivered: false, + last_delivery: null, + response_code: 0, + status: 'active' } +``` + +#### `> hooks.ls([opts]) -> Promise` + +Resolves to an array of hook objects associated with the account you're +authenticated as. + +Results can be further filtered with three values that can be passed in through +`opts`: + +* `opts.package` - filter results by package name +* `opts.limit` - maximum number of hooks to return +* `opts.offset` - pagination offset for results (use with `opts.limit`) + +See also: + * [`hooks.ls.stream()`](#ls-stream) + * [`GET +/v1/hooks`](https://github.com/npm/registry/blob/master/docs/hooks/endpoints.md#get-v1hooks) + +##### Example + +```javascript +await hooks.ls({token: 'myregistrytoken'}) + +=> +[ + { id: '16f7xoal', ... }, + { id: 'wnyf98a1', ... }, + ... +] +``` + +#### `> hooks.ls.stream([opts]) -> Stream` + +Returns a stream of hook objects associated with the account you're +authenticated as. The returned stream is a valid `Symbol.asyncIterator` on +`node@>=10`. + +Results can be further filtered with three values that can be passed in through +`opts`: + +* `opts.package` - filter results by package name +* `opts.limit` - maximum number of hooks to return +* `opts.offset` - pagination offset for results (use with `opts.limit`) + +See also: + * [`hooks.ls()`](#ls) + * [`GET +/v1/hooks`](https://github.com/npm/registry/blob/master/docs/hooks/endpoints.md#get-v1hooks) + +##### Example + +```javascript +for await (let hook of hooks.ls.stream({token: 'myregistrytoken'})) { + console.log('found hook:', hook.id) +} + +=> +// outputs: +// found hook: 16f7xoal +// found hook: wnyf98a1 +``` diff --git a/node_modules/libnpm/node_modules/libnpmhook/index.js b/node_modules/libnpm/node_modules/libnpmhook/index.js new file mode 100644 index 0000000000000..b489294951dd0 --- /dev/null +++ b/node_modules/libnpm/node_modules/libnpmhook/index.js @@ -0,0 +1,80 @@ +'use strict' + +const fetch = require('npm-registry-fetch') +const figgyPudding = require('figgy-pudding') +const getStream = require('get-stream') +const validate = require('aproba') + +const HooksConfig = figgyPudding({ + package: {}, + limit: {}, + offset: {}, + Promise: {default: () => Promise} +}) + +const eu = encodeURIComponent +const cmd = module.exports = {} +cmd.add = (name, endpoint, secret, opts) => { + opts = HooksConfig(opts) + validate('SSSO', [name, endpoint, secret, opts]) + let type = 'package' + if (name.match(/^@[^/]+$/)) { + type = 'scope' + } + if (name[0] === '~') { + type = 'owner' + name = name.substr(1) + } + return fetch.json('/-/npm/v1/hooks/hook', opts.concat({ + method: 'POST', + body: { type, name, endpoint, secret } + })) +} + +cmd.rm = (id, opts) => { + opts = HooksConfig(opts) + validate('SO', [id, opts]) + return fetch.json(`/-/npm/v1/hooks/hook/${eu(id)}`, opts.concat({ + method: 'DELETE' + }, opts)).catch(err => { + if (err.code === 'E404') { + return null + } else { + throw err + } + }) +} + +cmd.update = (id, endpoint, secret, opts) => { + opts = HooksConfig(opts) + validate('SSSO', [id, endpoint, secret, opts]) + return fetch.json(`/-/npm/v1/hooks/hook/${eu(id)}`, opts.concat({ + method: 'PUT', + body: {endpoint, secret} + }, opts)) +} + +cmd.find = (id, opts) => { + opts = HooksConfig(opts) + validate('SO', [id, opts]) + return fetch.json(`/-/npm/v1/hooks/hook/${eu(id)}`, opts) +} + +cmd.ls = (opts) => { + return getStream.array(cmd.ls.stream(opts)) +} + +cmd.ls.stream = (opts) => { + opts = HooksConfig(opts) + const {package: pkg, limit, offset} = opts + validate('S|Z', [pkg]) + validate('N|Z', [limit]) + validate('N|Z', [offset]) + return fetch.json.stream('/-/npm/v1/hooks', 'objects.*', opts.concat({ + query: { + package: pkg, + limit, + offset + } + })) +} diff --git a/node_modules/libnpm/node_modules/libnpmhook/package.json b/node_modules/libnpm/node_modules/libnpmhook/package.json new file mode 100644 index 0000000000000..5dd638e56c571 --- /dev/null +++ b/node_modules/libnpm/node_modules/libnpmhook/package.json @@ -0,0 +1,80 @@ +{ + "_args": [ + [ + "libnpmhook@5.0.2", + "/Users/zkat/Documents/code/work/npm" + ] + ], + "_from": "libnpmhook@5.0.2", + "_id": "libnpmhook@5.0.2", + "_inBundle": false, + "_integrity": "sha512-vLenmdFWhRfnnZiNFPNMog6CK7Ujofy2TWiM2CrpZUjBRIhHkJeDaAbJdYCT6W4lcHtyrJR8yXW8KFyq6UAp1g==", + "_location": "/libnpm/libnpmhook", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "libnpmhook@5.0.2", + "name": "libnpmhook", + "escapedName": "libnpmhook", + "rawSpec": "5.0.2", + "saveSpec": null, + "fetchSpec": "5.0.2" + }, + "_requiredBy": [ + "/libnpm" + ], + "_resolved": "https://registry.npmjs.org/libnpmhook/-/libnpmhook-5.0.2.tgz", + "_spec": "5.0.2", + "_where": "/Users/zkat/Documents/code/work/npm", + "author": { + "name": "Kat Marchán", + "email": "kzm@sykosomatic.org" + }, + "bugs": { + "url": "https://github.com/npm/libnpmhook/issues" + }, + "dependencies": { + "aproba": "^2.0.0", + "figgy-pudding": "^3.4.1", + "get-stream": "^4.0.0", + "npm-registry-fetch": "^3.8.0" + }, + "description": "programmatic API for managing npm registry hooks", + "devDependencies": { + "nock": "^9.6.1", + "standard": "^11.0.1", + "standard-version": "^4.4.0", + "tap": "^12.0.1", + "weallbehave": "^1.2.0", + "weallcontribute": "^1.0.8" + }, + "files": [ + "*.js", + "lib" + ], + "homepage": "https://github.com/npm/libnpmhook#readme", + "keywords": [ + "npm", + "hooks", + "registry", + "npm api" + ], + "license": "ISC", + "main": "index.js", + "name": "libnpmhook", + "repository": { + "type": "git", + "url": "git+https://github.com/npm/libnpmhook.git" + }, + "scripts": { + "postrelease": "npm publish && git push --follow-tags", + "prerelease": "npm t", + "pretest": "standard", + "release": "standard-version -s", + "test": "tap -J --100 --coverage test/*.js", + "update-coc": "weallbehave -o . && git add CODE_OF_CONDUCT.md && git commit -m 'docs(coc): updated CODE_OF_CONDUCT.md'", + "update-contrib": "weallcontribute -o . && git add CONTRIBUTING.md && git commit -m 'docs(contributing): updated CONTRIBUTING.md'" + }, + "version": "5.0.2" +} diff --git a/node_modules/libnpm/node_modules/libnpmaccess/.travis.yml b/node_modules/libnpmaccess/.travis.yml similarity index 100% rename from node_modules/libnpm/node_modules/libnpmaccess/.travis.yml rename to node_modules/libnpmaccess/.travis.yml diff --git a/node_modules/libnpm/node_modules/libnpmaccess/CHANGELOG.md b/node_modules/libnpmaccess/CHANGELOG.md similarity index 100% rename from node_modules/libnpm/node_modules/libnpmaccess/CHANGELOG.md rename to node_modules/libnpmaccess/CHANGELOG.md diff --git a/node_modules/libnpm/node_modules/libnpmaccess/CODE_OF_CONDUCT.md b/node_modules/libnpmaccess/CODE_OF_CONDUCT.md similarity index 100% rename from node_modules/libnpm/node_modules/libnpmaccess/CODE_OF_CONDUCT.md rename to node_modules/libnpmaccess/CODE_OF_CONDUCT.md diff --git a/node_modules/libnpm/node_modules/libnpmaccess/CONTRIBUTING.md b/node_modules/libnpmaccess/CONTRIBUTING.md similarity index 100% rename from node_modules/libnpm/node_modules/libnpmaccess/CONTRIBUTING.md rename to node_modules/libnpmaccess/CONTRIBUTING.md diff --git a/node_modules/libnpm/node_modules/libnpmaccess/LICENSE b/node_modules/libnpmaccess/LICENSE similarity index 100% rename from node_modules/libnpm/node_modules/libnpmaccess/LICENSE rename to node_modules/libnpmaccess/LICENSE diff --git a/node_modules/libnpm/node_modules/libnpmaccess/PULL_REQUEST_TEMPLATE b/node_modules/libnpmaccess/PULL_REQUEST_TEMPLATE similarity index 100% rename from node_modules/libnpm/node_modules/libnpmaccess/PULL_REQUEST_TEMPLATE rename to node_modules/libnpmaccess/PULL_REQUEST_TEMPLATE diff --git a/node_modules/libnpm/node_modules/libnpmaccess/README.md b/node_modules/libnpmaccess/README.md similarity index 100% rename from node_modules/libnpm/node_modules/libnpmaccess/README.md rename to node_modules/libnpmaccess/README.md diff --git a/node_modules/libnpm/node_modules/libnpmaccess/appveyor.yml b/node_modules/libnpmaccess/appveyor.yml similarity index 100% rename from node_modules/libnpm/node_modules/libnpmaccess/appveyor.yml rename to node_modules/libnpmaccess/appveyor.yml diff --git a/node_modules/libnpm/node_modules/libnpmaccess/index.js b/node_modules/libnpmaccess/index.js similarity index 100% rename from node_modules/libnpm/node_modules/libnpmaccess/index.js rename to node_modules/libnpmaccess/index.js diff --git a/node_modules/libnpmaccess/node_modules/aproba/CHANGELOG.md b/node_modules/libnpmaccess/node_modules/aproba/CHANGELOG.md new file mode 100644 index 0000000000000..bab30ecb7e625 --- /dev/null +++ b/node_modules/libnpmaccess/node_modules/aproba/CHANGELOG.md @@ -0,0 +1,4 @@ +2.0.0 + * Drop support for 0.10 and 0.12. They haven't been in travis but still, + since we _know_ we'll break with them now it's only polite to do a + major bump. diff --git a/node_modules/libnpmaccess/node_modules/aproba/LICENSE b/node_modules/libnpmaccess/node_modules/aproba/LICENSE new file mode 100644 index 0000000000000..f4be44d881b2d --- /dev/null +++ b/node_modules/libnpmaccess/node_modules/aproba/LICENSE @@ -0,0 +1,14 @@ +Copyright (c) 2015, Rebecca Turner + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + diff --git a/node_modules/libnpmaccess/node_modules/aproba/README.md b/node_modules/libnpmaccess/node_modules/aproba/README.md new file mode 100644 index 0000000000000..0bfc594c56a37 --- /dev/null +++ b/node_modules/libnpmaccess/node_modules/aproba/README.md @@ -0,0 +1,94 @@ +aproba +====== + +A ridiculously light-weight function argument validator + +``` +var validate = require("aproba") + +function myfunc(a, b, c) { + // `a` must be a string, `b` a number, `c` a function + validate('SNF', arguments) // [a,b,c] is also valid +} + +myfunc('test', 23, function () {}) // ok +myfunc(123, 23, function () {}) // type error +myfunc('test', 23) // missing arg error +myfunc('test', 23, function () {}, true) // too many args error + +``` + +Valid types are: + +| type | description +| :--: | :---------- +| * | matches any type +| A | `Array.isArray` OR an `arguments` object +| S | typeof == string +| N | typeof == number +| F | typeof == function +| O | typeof == object and not type A and not type E +| B | typeof == boolean +| E | `instanceof Error` OR `null` **(special: see below)** +| Z | == `null` + +Validation failures throw one of three exception types, distinguished by a +`code` property of `EMISSINGARG`, `EINVALIDTYPE` or `ETOOMANYARGS`. + +If you pass in an invalid type then it will throw with a code of +`EUNKNOWNTYPE`. + +If an **error** argument is found and is not null then the remaining +arguments are optional. That is, if you say `ESO` then that's like using a +non-magical `E` in: `E|ESO|ZSO`. + +### But I have optional arguments?! + +You can provide more than one signature by separating them with pipes `|`. +If any signature matches the arguments then they'll be considered valid. + +So for example, say you wanted to write a signature for +`fs.createWriteStream`. The docs for it describe it thusly: + +``` +fs.createWriteStream(path[, options]) +``` + +This would be a signature of `SO|S`. That is, a string and and object, or +just a string. + +Now, if you read the full `fs` docs, you'll see that actually path can ALSO +be a buffer. And options can be a string, that is: +``` +path | +options | +``` + +To reproduce this you have to fully enumerate all of the possible +combinations and that implies a signature of `SO|SS|OO|OS|S|O`. The +awkwardness is a feature: It reminds you of the complexity you're adding to +your API when you do this sort of thing. + + +### Browser support + +This has no dependencies and should work in browsers, though you'll have +noisier stack traces. + +### Why this exists + +I wanted a very simple argument validator. It needed to do two things: + +1. Be more concise and easier to use than assertions + +2. Not encourage an infinite bikeshed of DSLs + +This is why types are specified by a single character and there's no such +thing as an optional argument. + +This is not intended to validate user data. This is specifically about +asserting the interface of your functions. + +If you need greater validation, I encourage you to write them by hand or +look elsewhere. + diff --git a/node_modules/libnpmaccess/node_modules/aproba/index.js b/node_modules/libnpmaccess/node_modules/aproba/index.js new file mode 100644 index 0000000000000..fd947481ba557 --- /dev/null +++ b/node_modules/libnpmaccess/node_modules/aproba/index.js @@ -0,0 +1,105 @@ +'use strict' +module.exports = validate + +function isArguments (thingy) { + return thingy != null && typeof thingy === 'object' && thingy.hasOwnProperty('callee') +} + +const types = { + '*': {label: 'any', check: () => true}, + A: {label: 'array', check: _ => Array.isArray(_) || isArguments(_)}, + S: {label: 'string', check: _ => typeof _ === 'string'}, + N: {label: 'number', check: _ => typeof _ === 'number'}, + F: {label: 'function', check: _ => typeof _ === 'function'}, + O: {label: 'object', check: _ => typeof _ === 'object' && _ != null && !types.A.check(_) && !types.E.check(_)}, + B: {label: 'boolean', check: _ => typeof _ === 'boolean'}, + E: {label: 'error', check: _ => _ instanceof Error}, + Z: {label: 'null', check: _ => _ == null} +} + +function addSchema (schema, arity) { + const group = arity[schema.length] = arity[schema.length] || [] + if (group.indexOf(schema) === -1) group.push(schema) +} + +function validate (rawSchemas, args) { + if (arguments.length !== 2) throw wrongNumberOfArgs(['SA'], arguments.length) + if (!rawSchemas) throw missingRequiredArg(0, 'rawSchemas') + if (!args) throw missingRequiredArg(1, 'args') + if (!types.S.check(rawSchemas)) throw invalidType(0, ['string'], rawSchemas) + if (!types.A.check(args)) throw invalidType(1, ['array'], args) + const schemas = rawSchemas.split('|') + const arity = {} + + schemas.forEach(schema => { + for (let ii = 0; ii < schema.length; ++ii) { + const type = schema[ii] + if (!types[type]) throw unknownType(ii, type) + } + if (/E.*E/.test(schema)) throw moreThanOneError(schema) + addSchema(schema, arity) + if (/E/.test(schema)) { + addSchema(schema.replace(/E.*$/, 'E'), arity) + addSchema(schema.replace(/E/, 'Z'), arity) + if (schema.length === 1) addSchema('', arity) + } + }) + let matching = arity[args.length] + if (!matching) { + throw wrongNumberOfArgs(Object.keys(arity), args.length) + } + for (let ii = 0; ii < args.length; ++ii) { + let newMatching = matching.filter(schema => { + const type = schema[ii] + const typeCheck = types[type].check + return typeCheck(args[ii]) + }) + if (!newMatching.length) { + const labels = matching.map(_ => types[_[ii]].label).filter(_ => _ != null) + throw invalidType(ii, labels, args[ii]) + } + matching = newMatching + } +} + +function missingRequiredArg (num) { + return newException('EMISSINGARG', 'Missing required argument #' + (num + 1)) +} + +function unknownType (num, type) { + return newException('EUNKNOWNTYPE', 'Unknown type ' + type + ' in argument #' + (num + 1)) +} + +function invalidType (num, expectedTypes, value) { + let valueType + Object.keys(types).forEach(typeCode => { + if (types[typeCode].check(value)) valueType = types[typeCode].label + }) + return newException('EINVALIDTYPE', 'Argument #' + (num + 1) + ': Expected ' + + englishList(expectedTypes) + ' but got ' + valueType) +} + +function englishList (list) { + return list.join(', ').replace(/, ([^,]+)$/, ' or $1') +} + +function wrongNumberOfArgs (expected, got) { + const english = englishList(expected) + const args = expected.every(ex => ex.length === 1) + ? 'argument' + : 'arguments' + return newException('EWRONGARGCOUNT', 'Expected ' + english + ' ' + args + ' but got ' + got) +} + +function moreThanOneError (schema) { + return newException('ETOOMANYERRORTYPES', + 'Only one error type per argument signature is allowed, more than one found in "' + schema + '"') +} + +function newException (code, msg) { + const err = new Error(msg) + err.code = code + /* istanbul ignore else */ + if (Error.captureStackTrace) Error.captureStackTrace(err, validate) + return err +} diff --git a/node_modules/libnpmaccess/node_modules/aproba/package.json b/node_modules/libnpmaccess/node_modules/aproba/package.json new file mode 100644 index 0000000000000..c184114b06849 --- /dev/null +++ b/node_modules/libnpmaccess/node_modules/aproba/package.json @@ -0,0 +1,66 @@ +{ + "_args": [ + [ + "aproba@2.0.0", + "/Users/zkat/Documents/code/work/npm" + ] + ], + "_from": "aproba@2.0.0", + "_id": "aproba@2.0.0", + "_inBundle": false, + "_integrity": "sha512-lYe4Gx7QT+MKGbDsA+Z+he/Wtef0BiwDOlK/XkBrdfsh9J/jPPXbX0tE9x9cl27Tmu5gg3QUbUrQYa/y+KOHPQ==", + "_location": "/libnpmaccess/aproba", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "aproba@2.0.0", + "name": "aproba", + "escapedName": "aproba", + "rawSpec": "2.0.0", + "saveSpec": null, + "fetchSpec": "2.0.0" + }, + "_requiredBy": [ + "/libnpmaccess" + ], + "_resolved": "https://registry.npmjs.org/aproba/-/aproba-2.0.0.tgz", + "_spec": "2.0.0", + "_where": "/Users/zkat/Documents/code/work/npm", + "author": { + "name": "Rebecca Turner", + "email": "me@re-becca.org" + }, + "bugs": { + "url": "https://github.com/iarna/aproba/issues" + }, + "dependencies": {}, + "description": "A ridiculously light-weight argument validator (now browser friendly)", + "devDependencies": { + "standard": "^11.0.1", + "tap": "^12.0.1" + }, + "directories": { + "test": "test" + }, + "files": [ + "index.js" + ], + "homepage": "https://github.com/iarna/aproba", + "keywords": [ + "argument", + "validate" + ], + "license": "ISC", + "main": "index.js", + "name": "aproba", + "repository": { + "type": "git", + "url": "git+https://github.com/iarna/aproba.git" + }, + "scripts": { + "pretest": "standard", + "test": "tap --100 -J test/*.js" + }, + "version": "2.0.0" +} diff --git a/node_modules/libnpm/node_modules/libnpmaccess/package.json b/node_modules/libnpmaccess/package.json similarity index 80% rename from node_modules/libnpm/node_modules/libnpmaccess/package.json rename to node_modules/libnpmaccess/package.json index 4b05fc4a6eaa1..1c8e049ef7a21 100644 --- a/node_modules/libnpm/node_modules/libnpmaccess/package.json +++ b/node_modules/libnpmaccess/package.json @@ -1,27 +1,32 @@ { - "_from": "libnpmaccess@^2.0.0", + "_args": [ + [ + "libnpmaccess@2.0.1", + "/Users/zkat/Documents/code/work/npm" + ] + ], + "_from": "libnpmaccess@2.0.1", "_id": "libnpmaccess@2.0.1", "_inBundle": false, "_integrity": "sha512-WJRlA7YGGCBK6zubJ8eajD7Wm6SaywiR0jnMjwp8QBwt1QxQOY+CCKpERw30opPkShjoesBLzQJ9Wf3MpXGR/A==", - "_location": "/libnpm/libnpmaccess", + "_location": "/libnpmaccess", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "libnpmaccess@^2.0.0", + "raw": "libnpmaccess@2.0.1", "name": "libnpmaccess", "escapedName": "libnpmaccess", - "rawSpec": "^2.0.0", + "rawSpec": "2.0.1", "saveSpec": null, - "fetchSpec": "^2.0.0" + "fetchSpec": "2.0.1" }, "_requiredBy": [ "/libnpm" ], "_resolved": "https://registry.npmjs.org/libnpmaccess/-/libnpmaccess-2.0.1.tgz", - "_shasum": "3b49b66ddc3c27c1f66fd7d70e77cebd74b84aa7", - "_spec": "libnpmaccess@^2.0.0", - "_where": "/Users/zkat/Documents/code/work/npm/node_modules/libnpm", + "_spec": "2.0.1", + "_where": "/Users/zkat/Documents/code/work/npm", "author": { "name": "Kat Marchán", "email": "kzm@zkat.tech" @@ -29,14 +34,12 @@ "bugs": { "url": "https://github.com/npm/libnpmaccess/issues" }, - "bundleDependencies": false, "dependencies": { "aproba": "^2.0.0", "get-stream": "^4.0.0", "npm-package-arg": "^6.1.0", "npm-registry-fetch": "^3.8.0" }, - "deprecated": false, "description": "programmatic library for `npm access` commands", "devDependencies": { "nock": "^9.6.1", diff --git a/node_modules/libnpm/node_modules/libnpmaccess/test/index.js b/node_modules/libnpmaccess/test/index.js similarity index 100% rename from node_modules/libnpm/node_modules/libnpmaccess/test/index.js rename to node_modules/libnpmaccess/test/index.js diff --git a/node_modules/libnpm/node_modules/libnpmaccess/test/util/tnock.js b/node_modules/libnpmaccess/test/util/tnock.js similarity index 100% rename from node_modules/libnpm/node_modules/libnpmaccess/test/util/tnock.js rename to node_modules/libnpmaccess/test/util/tnock.js diff --git a/node_modules/libnpmorg/CHANGELOG.md b/node_modules/libnpmorg/CHANGELOG.md new file mode 100644 index 0000000000000..03392b64cd91c --- /dev/null +++ b/node_modules/libnpmorg/CHANGELOG.md @@ -0,0 +1,11 @@ +# Change Log + +All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. + + +# 1.0.0 (2018-08-23) + + +### Features + +* **API:** implement org api ([731b9c6](https://github.com/npm/libnpmorg/commit/731b9c6)) diff --git a/node_modules/libnpmorg/CODE_OF_CONDUCT.md b/node_modules/libnpmorg/CODE_OF_CONDUCT.md new file mode 100644 index 0000000000000..aeb72f598dcb4 --- /dev/null +++ b/node_modules/libnpmorg/CODE_OF_CONDUCT.md @@ -0,0 +1,151 @@ +# Code of Conduct + +## When Something Happens + +If you see a Code of Conduct violation, follow these steps: + +1. Let the person know that what they did is not appropriate and ask them to stop and/or edit their message(s) or commits. +2. That person should immediately stop the behavior and correct the issue. +3. If this doesn’t happen, or if you're uncomfortable speaking up, [contact the maintainers](#contacting-maintainers). +4. As soon as available, a maintainer will look into the issue, and take [further action (see below)](#further-enforcement), starting with a warning, then temporary block, then long-term repo or organization ban. + +When reporting, please include any relevant details, links, screenshots, context, or other information that may be used to better understand and resolve the situation. + +**The maintainer team will prioritize the well-being and comfort of the recipients of the violation over the comfort of the violator.** See [some examples below](#enforcement-examples). + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as contributors and maintainers of this project pledge to making participation in our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, technical preferences, nationality, personal appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment include: + + * Using welcoming and inclusive language. + * Being respectful of differing viewpoints and experiences. + * Gracefully accepting constructive feedback. + * Focusing on what is best for the community. + * Showing empathy and kindness towards other community members. + * Encouraging and raising up your peers in the project so you can all bask in hacks and glory. + +Examples of unacceptable behavior by participants include: + + * The use of sexualized language or imagery and unwelcome sexual attention or advances, including when simulated online. The only exception to sexual topics is channels/spaces specifically for topics of sexual identity. + * Casual mention of slavery or indentured servitude and/or false comparisons of one's occupation or situation to slavery. Please consider using or asking about alternate terminology when referring to such metaphors in technology. + * Making light of/making mocking comments about trigger warnings and content warnings. + * Trolling, insulting/derogatory comments, and personal or political attacks. + * Public or private harassment, deliberate intimidation, or threats. + * Publishing others' private information, such as a physical or electronic address, without explicit permission. This includes any sort of "outing" of any aspect of someone's identity without their consent. + * Publishing private screenshots or quotes of interactions in the context of this project without all quoted users' *explicit* consent. + * Publishing of private communication that doesn't have to do with reporting harrassment. + * Any of the above even when [presented as "ironic" or "joking"](https://en.wikipedia.org/wiki/Hipster_racism). + * Any attempt to present "reverse-ism" versions of the above as violations. Examples of reverse-isms are "reverse racism", "reverse sexism", "heterophobia", and "cisphobia". + * Unsolicited explanations under the assumption that someone doesn't already know it. Ask before you teach! Don't assume what people's knowledge gaps are. + * [Feigning or exaggerating surprise](https://www.recurse.com/manual#no-feigned-surprise) when someone admits to not knowing something. + * "[Well-actuallies](https://www.recurse.com/manual#no-well-actuallys)" + * Other conduct which could reasonably be considered inappropriate in a professional or community setting. + +## Scope + +This Code of Conduct applies both within spaces involving this project and in other spaces involving community members. This includes the repository, its Pull Requests and Issue tracker, its Twitter community, private email communications in the context of the project, and any events where members of the project are participating, as well as adjacent communities and venues affecting the project's members. + +Depending on the violation, the maintainers may decide that violations of this code of conduct that have happened outside of the scope of the community may deem an individual unwelcome, and take appropriate action to maintain the comfort and safety of its members. + +### Other Community Standards + +As a project on GitHub, this project is additionally covered by the [GitHub Community Guidelines](https://help.github.com/articles/github-community-guidelines/). + +Additionally, as a project hosted on npm, is is covered by [npm, Inc's Code of Conduct](https://www.npmjs.com/policies/conduct). + +Enforcement of those guidelines after violations overlapping with the above are the responsibility of the entities, and enforcement may happen in any or all of the services/communities. + +## Maintainer Enforcement Process + +Once the maintainers get involved, they will follow a documented series of steps and do their best to preserve the well-being of project members. This section covers actual concrete steps. + +### Contacting Maintainers + +You may get in touch with the maintainer team through any of the following methods: + + * Through email: + * [kzm@zkat.tech](mailto:kzm@zkat.tech) (Kat Marchán) + + * Through Twitter: + * [@maybekatz](https://twitter.com/maybekatz) (Kat Marchán) + +### Further Enforcement + +If you've already followed the [initial enforcement steps](#enforcement), these are the steps maintainers will take for further enforcement, as needed: + + 1. Repeat the request to stop. + 2. If the person doubles down, they will have offending messages removed or edited by a maintainers given an official warning. The PR or Issue may be locked. + 3. If the behavior continues or is repeated later, the person will be blocked from participating for 24 hours. + 4. If the behavior continues or is repeated after the temporary block, a long-term (6-12mo) ban will be used. + +On top of this, maintainers may remove any offending messages, images, contributions, etc, as they deem necessary. + +Maintainers reserve full rights to skip any of these steps, at their discretion, if the violation is considered to be a serious and/or immediate threat to the health and well-being of members of the community. These include any threats, serious physical or verbal attacks, and other such behavior that would be completely unacceptable in any social setting that puts our members at risk. + +Members expelled from events or venues with any sort of paid attendance will not be refunded. + +### Who Watches the Watchers? + +Maintainers and other leaders who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. These may include anything from removal from the maintainer team to a permanent ban from the community. + +Additionally, as a project hosted on both GitHub and npm, [their own Codes of Conducts may be applied against maintainers of this project](#other-community-standards), externally of this project's procedures. + +### Enforcement Examples + +#### The Best Case + +The vast majority of situations work out like this. This interaction is common, and generally positive. + +> Alex: "Yeah I used X and it was really crazy!" + +> Patt (not a maintainer): "Hey, could you not use that word? What about 'ridiculous' instead?" + +> Alex: "oh sorry, sure." -> edits old comment to say "it was really confusing!" + +#### The Maintainer Case + +Sometimes, though, you need to get maintainers involved. Maintainers will do their best to resolve conflicts, but people who were harmed by something **will take priority**. + +> Patt: "Honestly, sometimes I just really hate using $library and anyone who uses it probably sucks at their job." + +> Alex: "Whoa there, could you dial it back a bit? There's a CoC thing about attacking folks' tech use like that." + +> Patt: "I'm not attacking anyone, what's your problem?" + +> Alex: "@maintainers hey uh. Can someone look at this issue? Patt is getting a bit aggro. I tried to nudge them about it, but nope." + +> KeeperOfCommitBits: (on issue) "Hey Patt, maintainer here. Could you tone it down? This sort of attack is really not okay in this space." + +> Patt: "Leave me alone I haven't said anything bad wtf is wrong with you." + +> KeeperOfCommitBits: (deletes user's comment), "@patt I mean it. Please refer to the CoC over at (URL to this CoC) if you have questions, but you can consider this an actual warning. I'd appreciate it if you reworded your messages in this thread, since they made folks there uncomfortable. Let's try and be kind, yeah?" + +> Patt: "@keeperofbits Okay sorry. I'm just frustrated and I'm kinda burnt out and I guess I got carried away. I'll DM Alex a note apologizing and edit my messages. Sorry for the trouble." + +> KeeperOfCommitBits: "@patt Thanks for that. I hear you on the stress. Burnout sucks :/. Have a good one!" + +#### The Nope Case + +> PepeTheFrog🐸: "Hi, I am a literal actual nazi and I think white supremacists are quite fashionable." + +> Patt: "NOOOOPE. OH NOPE NOPE." + +> Alex: "JFC NO. NOPE. @keeperofbits NOPE NOPE LOOK HERE" + +> KeeperOfCommitBits: "👀 Nope. NOPE NOPE NOPE. 🔥" + +> PepeTheFrog🐸 has been banned from all organization or user repositories belonging to KeeperOfCommitBits. + +## Attribution + +This Code of Conduct was generated using [WeAllJS Code of Conduct Generator](https://npm.im/weallbehave), which is based on the [WeAllJS Code of +Conduct](https://wealljs.org/code-of-conduct), which is itself based on +[Contributor Covenant](http://contributor-covenant.org), version 1.4, available +at +[http://contributor-covenant.org/version/1/4](http://contributor-covenant.org/version/1/4), +and the LGBTQ in Technology Slack [Code of +Conduct](http://lgbtq.technology/coc.html). diff --git a/node_modules/libnpmorg/CONTRIBUTING.md b/node_modules/libnpmorg/CONTRIBUTING.md new file mode 100644 index 0000000000000..eb4b58b03ef1a --- /dev/null +++ b/node_modules/libnpmorg/CONTRIBUTING.md @@ -0,0 +1,256 @@ +# Contributing + +## How do I... + +* [Use This Guide](#introduction)? +* Ask or Say Something? 🤔🐛😱 + * [Request Support](#request-support) + * [Report an Error or Bug](#report-an-error-or-bug) + * [Request a Feature](#request-a-feature) +* Make Something? 🤓👩🏽‍💻📜🍳 + * [Project Setup](#project-setup) + * [Contribute Documentation](#contribute-documentation) + * [Contribute Code](#contribute-code) +* Manage Something ✅🙆🏼💃👔 + * [Provide Support on Issues](#provide-support-on-issues) + * [Label Issues](#label-issues) + * [Clean Up Issues and PRs](#clean-up-issues-and-prs) + * [Review Pull Requests](#review-pull-requests) + * [Merge Pull Requests](#merge-pull-requests) + * [Tag a Release](#tag-a-release) + * [Join the Project Team](#join-the-project-team) +* Add a Guide Like This One [To My Project](#attribution)? 🤖😻👻 + +## Introduction + +Thank you so much for your interest in contributing!. All types of contributions are encouraged and valued. See the [table of contents](#toc) for different ways to help and details about how this project handles them!📝 + +Please make sure to read the relevant section before making your contribution! It will make it a lot easier for us maintainers to make the most of it and smooth out the experience for all involved. 💚 + +The [Project Team](#join-the-project-team) looks forward to your contributions. 🙌🏾✨ + +## Request Support + +If you have a question about this project, how to use it, or just need clarification about something: + +* Open an Issue at https://github.com/npm/libnpmorg/issues +* Provide as much context as you can about what you're running into. +* Provide project and platform versions (nodejs, npm, etc), depending on what seems relevant. If not, please be ready to provide that information if maintainers ask for it. + +Once it's filed: + +* The project team will [label the issue](#label-issues). +* Someone will try to have a response soon. +* If you or the maintainers don't respond to an issue for 30 days, the [issue will be closed](#clean-up-issues-and-prs). If you want to come back to it, reply (once, please), and we'll reopen the existing issue. Please avoid filing new issues as extensions of one you already made. + +## Report an Error or Bug + +If you run into an error or bug with the project: + +* Open an Issue at https://github.com/npm/libnpmorg/issues +* Include *reproduction steps* that someone else can follow to recreate the bug or error on their own. +* Provide project and platform versions (nodejs, npm, etc), depending on what seems relevant. If not, please be ready to provide that information if maintainers ask for it. + +Once it's filed: + +* The project team will [label the issue](#label-issues). +* A team member will try to reproduce the issue with your provided steps. If there are no repro steps or no obvious way to reproduce the issue, the team will ask you for those steps and mark the issue as `needs-repro`. Bugs with the `needs-repro` tag will not be addressed until they are reproduced. +* If the team is able to reproduce the issue, it will be marked `needs-fix`, as well as possibly other tags (such as `critical`), and the issue will be left to be [implemented by someone](#contribute-code). +* If you or the maintainers don't respond to an issue for 30 days, the [issue will be closed](#clean-up-issues-and-prs). If you want to come back to it, reply (once, please), and we'll reopen the existing issue. Please avoid filing new issues as extensions of one you already made. +* `critical` issues may be left open, depending on perceived immediacy and severity, even past the 30 day deadline. + +## Request a Feature + +If the project doesn't do something you need or want it to do: + +* Open an Issue at https://github.com/npm/libnpmorg/issues +* Provide as much context as you can about what you're running into. +* Please try and be clear about why existing features and alternatives would not work for you. + +Once it's filed: + +* The project team will [label the issue](#label-issues). +* The project team will evaluate the feature request, possibly asking you more questions to understand its purpose and any relevant requirements. If the issue is closed, the team will convey their reasoning and suggest an alternative path forward. +* If the feature request is accepted, it will be marked for implementation with `feature-accepted`, which can then be done by either by a core team member or by anyone in the community who wants to [contribute code](#contribute-code). + +Note: The team is unlikely to be able to accept every single feature request that is filed. Please understand if they need to say no. + +## Project Setup + +So you wanna contribute some code! That's great! This project uses GitHub Pull Requests to manage contributions, so [read up on how to fork a GitHub project and file a PR](https://guides.github.com/activities/forking) if you've never done it before. + +If this seems like a lot or you aren't able to do all this setup, you might also be able to [edit the files directly](https://help.github.com/articles/editing-files-in-another-user-s-repository/) without having to do any of this setup. Yes, [even code](#contribute-code). + +If you want to go the usual route and run the project locally, though: + +* [Install Node.js](https://nodejs.org/en/download/) +* [Fork the project](https://guides.github.com/activities/forking/#fork) + +Then in your terminal: +* `cd path/to/your/clone` +* `npm install` +* `npm test` + +And you should be ready to go! + +## Contribute Documentation + +Documentation is a super important, critical part of this project. Docs are how we keep track of what we're doing, how, and why. It's how we stay on the same page about our policies. And it's how we tell others everything they need in order to be able to use this project -- or contribute to it. So thank you in advance. + +Documentation contributions of any size are welcome! Feel free to file a PR even if you're just rewording a sentence to be more clear, or fixing a spelling mistake! + +To contribute documentation: + +* [Set up the project](#project-setup). +* Edit or add any relevant documentation. +* Make sure your changes are formatted correctly and consistently with the rest of the documentation. +* Re-read what you wrote, and run a spellchecker on it to make sure you didn't miss anything. +* In your commit message(s), begin the first line with `docs: `. For example: `docs: Adding a doc contrib section to CONTRIBUTING.md`. +* Write clear, concise commit message(s) using [conventional-changelog format](https://github.com/conventional-changelog/conventional-changelog-angular/blob/master/convention.md). Documentation commits should use `docs(): `. +* Go to https://github.com/npm/libnpmorg/pulls and open a new pull request with your changes. +* If your PR is connected to an open issue, add a line in your PR's description that says `Fixes: #123`, where `#123` is the number of the issue you're fixing. + +Once you've filed the PR: + +* One or more maintainers will use GitHub's review feature to review your PR. +* If the maintainer asks for any changes, edit your changes, push, and ask for another review. +* If the maintainer decides to pass on your PR, they will thank you for the contribution and explain why they won't be accepting the changes. That's ok! We still really appreciate you taking the time to do it, and we don't take that lightly. 💚 +* If your PR gets accepted, it will be marked as such, and merged into the `latest` branch soon after. Your contribution will be distributed to the masses next time the maintainers [tag a release](#tag-a-release) + +## Contribute Code + +We like code commits a lot! They're super handy, and they keep the project going and doing the work it needs to do to be useful to others. + +Code contributions of just about any size are acceptable! + +The main difference between code contributions and documentation contributions is that contributing code requires inclusion of relevant tests for the code being added or changed. Contributions without accompanying tests will be held off until a test is added, unless the maintainers consider the specific tests to be either impossible, or way too much of a burden for such a contribution. + +To contribute code: + +* [Set up the project](#project-setup). +* Make any necessary changes to the source code. +* Include any [additional documentation](#contribute-documentation) the changes might need. +* Write tests that verify that your contribution works as expected. +* Write clear, concise commit message(s) using [conventional-changelog format](https://github.com/conventional-changelog/conventional-changelog-angular/blob/master/convention.md). +* Dependency updates, additions, or removals must be in individual commits, and the message must use the format: `(deps): PKG@VERSION`, where `` is any of the usual `conventional-changelog` prefixes, at your discretion. +* Go to https://github.com/npm/libnpmorg/pulls and open a new pull request with your changes. +* If your PR is connected to an open issue, add a line in your PR's description that says `Fixes: #123`, where `#123` is the number of the issue you're fixing. + +Once you've filed the PR: + +* Barring special circumstances, maintainers will not review PRs until all checks pass (Travis, AppVeyor, etc). +* One or more maintainers will use GitHub's review feature to review your PR. +* If the maintainer asks for any changes, edit your changes, push, and ask for another review. Additional tags (such as `needs-tests`) will be added depending on the review. +* If the maintainer decides to pass on your PR, they will thank you for the contribution and explain why they won't be accepting the changes. That's ok! We still really appreciate you taking the time to do it, and we don't take that lightly. 💚 +* If your PR gets accepted, it will be marked as such, and merged into the `latest` branch soon after. Your contribution will be distributed to the masses next time the maintainers [tag a release](#tag-a-release) + +## Provide Support on Issues + +[Needs Collaborator](#join-the-project-team): none + +Helping out other users with their questions is a really awesome way of contributing to any community. It's not uncommon for most of the issues on an open source projects being support-related questions by users trying to understand something they ran into, or find their way around a known bug. + +Sometimes, the `support` label will be added to things that turn out to actually be other things, like bugs or feature requests. In that case, suss out the details with the person who filed the original issue, add a comment explaining what the bug is, and change the label from `support` to `bug` or `feature`. If you can't do this yourself, @mention a maintainer so they can do it. + +In order to help other folks out with their questions: + +* Go to the issue tracker and [filter open issues by the `support` label](https://github.com/npm/libnpmorg/issues?q=is%3Aopen+is%3Aissue+label%3Asupport). +* Read through the list until you find something that you're familiar enough with to give an answer to. +* Respond to the issue with whatever details are needed to clarify the question, or get more details about what's going on. +* Once the discussion wraps up and things are clarified, either close the issue, or ask the original issue filer (or a maintainer) to close it for you. + +Some notes on picking up support issues: + +* Avoid responding to issues you don't know you can answer accurately. +* As much as possible, try to refer to past issues with accepted answers. Link to them from your replies with the `#123` format. +* Be kind and patient with users -- often, folks who have run into confusing things might be upset or impatient. This is ok. Try to understand where they're coming from, and if you're too uncomfortable with the tone, feel free to stay away or withdraw from the issue. (note: if the user is outright hostile or is violating the CoC, [refer to the Code of Conduct](CODE_OF_CONDUCT.md) to resolve the conflict). + +## Label Issues + +[Needs Collaborator](#join-the-project-team): Issue Tracker + +One of the most important tasks in handling issues is labeling them usefully and accurately. All other tasks involving issues ultimately rely on the issue being classified in such a way that relevant parties looking to do their own tasks can find them quickly and easily. + +In order to label issues, [open up the list of unlabeled issues](https://github.com/npm/libnpmorg/issues?q=is%3Aopen+is%3Aissue+no%3Alabel) and, **from newest to oldest**, read through each one and apply issue labels according to the table below. If you're unsure about what label to apply, skip the issue and try the next one: don't feel obligated to label each and every issue yourself! + +Label | Apply When | Notes +--- | --- | --- +`bug` | Cases where the code (or documentation) is behaving in a way it wasn't intended to. | If something is happening that surprises the *user* but does not go against the way the code is designed, it should use the `enhancement` label. +`critical` | Added to `bug` issues if the problem described makes the code completely unusable in a common situation. | +`documentation` | Added to issues or pull requests that affect any of the documentation for the project. | Can be combined with other labels, such as `bug` or `enhancement`. +`duplicate` | Added to issues or PRs that refer to the exact same issue as another one that's been previously labeled. | Duplicate issues should be marked and closed right away, with a message referencing the issue it's a duplicate of (with `#123`) +`enhancement` | Added to [feature requests](#request-a-feature), PRs, or documentation issues that are purely additive: the code or docs currently work as expected, but a change is being requested or suggested. | +`help wanted` | Applied by [Committers](#join-the-project-team) to issues and PRs that they would like to get outside help for. Generally, this means it's lower priority for the maintainer team to itself implement, but that the community is encouraged to pick up if they so desire | Never applied on first-pass labeling. +`in-progress` | Applied by [Committers](#join-the-project-team) to PRs that are pending some work before they're ready for review. | The original PR submitter should @mention the team member that applied the label once the PR is complete. +`performance` | This issue or PR is directly related to improving performance. | +`refactor` | Added to issues or PRs that deal with cleaning up or modifying the project for the betterment of it. | +`starter` | Applied by [Committers](#join-the-project-team) to issues that they consider good introductions to the project for people who have not contributed before. These are not necessarily "easy", but rather focused around how much context is necessary in order to understand what needs to be done for this project in particular. | Existing project members are expected to stay away from these unless they increase in priority. +`support` | This issue is either asking a question about how to use the project, clarifying the reason for unexpected behavior, or possibly reporting a `bug` but does not have enough detail yet to determine whether it would count as such. | The label should be switched to `bug` if reliable reproduction steps are provided. Issues primarily with unintended configurations of a user's environment are not considered bugs, even if they cause crashes. +`tests` | This issue or PR either requests or adds primarily tests to the project. | If a PR is pending tests, that will be handled through the [PR review process](#review-pull-requests) +`wontfix` | Labelers may apply this label to issues that clearly have nothing at all to do with the project or are otherwise entirely outside of its scope/sphere of influence. [Committers](#join-the-project-team) may apply this label and close an issue or PR if they decide to pass on an otherwise relevant issue. | The issue or PR should be closed as soon as the label is applied, and a clear explanation provided of why the label was used. Contributors are free to contest the labeling, but the decision ultimately falls on committers as to whether to accept something or not. + +## Clean Up Issues and PRs + +[Needs Collaborator](#join-the-project-team): Issue Tracker + +Issues and PRs can go stale after a while. Maybe they're abandoned. Maybe the team will just plain not have time to address them any time soon. + +In these cases, they should be closed until they're brought up again or the interaction starts over. + +To clean up issues and PRs: + +* Search the issue tracker for issues or PRs, and add the term `updated:<=YYYY-MM-DD`, where the date is 30 days before today. +* Go through each issue *from oldest to newest*, and close them if **all of the following are true**: + * not opened by a maintainer + * not marked as `critical` + * not marked as `starter` or `help wanted` (these might stick around for a while, in general, as they're intended to be available) + * no explicit messages in the comments asking for it to be left open + * does not belong to a milestone +* Leave a message when closing saying "Cleaning up stale issue. Please reopen or ping us if and when you're ready to resume this. See https://github.com/npm/libnpmorg/blob/latest/CONTRIBUTING.md#clean-up-issues-and-prs for more details." + +## Review Pull Requests + +[Needs Collaborator](#join-the-project-team): Issue Tracker + +While anyone can comment on a PR, add feedback, etc, PRs are only *approved* by team members with Issue Tracker or higher permissions. + +PR reviews use [GitHub's own review feature](https://help.github.com/articles/about-pull-request-reviews/), which manages comments, approval, and review iteration. + +Some notes: + +* You may ask for minor changes ("nitpicks"), but consider whether they are really blockers to merging: try to err on the side of "approve, with comments". +* *ALL PULL REQUESTS* should be covered by a test: either by a previously-failing test, an existing test that covers the entire functionality of the submitted code, or new tests to verify any new/changed behavior. All tests must also pass and follow established conventions. Test coverage should not drop, unless the specific case is considered reasonable by maintainers. +* Please make sure you're familiar with the code or documentation being updated, unless it's a minor change (spellchecking, minor formatting, etc). You may @mention another project member who you think is better suited for the review, but still provide a non-approving review of your own. +* Be extra kind: people who submit code/doc contributions are putting themselves in a pretty vulnerable position, and have put time and care into what they've done (even if that's not obvious to you!) -- always respond with respect, be understanding, but don't feel like you need to sacrifice your standards for their sake, either. Just don't be a jerk about it? + +## Merge Pull Requests + +[Needs Collaborator](#join-the-project-team): Committer + +TBD - need to hash out a bit more of this process. + +## Tag A Release + +[Needs Collaborator](#join-the-project-team): Committer + +TBD - need to hash out a bit more of this process. The most important bit here is probably that all tests must pass, and tags must use [semver](https://semver.org). + +## Join the Project Team + +### Ways to Join + +There are many ways to contribute! Most of them don't require any official status unless otherwise noted. That said, there's a couple of positions that grant special repository abilities, and this section describes how they're granted and what they do. + +All of the below positions are granted based on the project team's needs, as well as their consensus opinion about whether they would like to work with the person and think that they would fit well into that position. The process is relatively informal, and it's likely that people who express interest in participating can just be granted the permissions they'd like. + +You can spot a collaborator on the repo by looking for the `[Collaborator]` or `[Owner]` tags next to their names. + +Permission | Description +--- | --- +Issue Tracker | Granted to contributors who express a strong interest in spending time on the project's issue tracker. These tasks are mainly [labeling issues](#label-issues), [cleaning up old ones](#clean-up-issues-and-prs), and [reviewing pull requests](#review-pull-requests), as well as all the usual things non-team-member contributors can do. Issue handlers should not merge pull requests, tag releases, or directly commit code themselves: that should still be done through the usual pull request process. Becoming an Issue Handler means the project team trusts you to understand enough of the team's process and context to implement it on the issue tracker. +Committer | Granted to contributors who want to handle the actual pull request merges, tagging new versions, etc. Committers should have a good level of familiarity with the codebase, and enough context to understand the implications of various changes, as well as a good sense of the will and expectations of the project team. +Admin/Owner | Granted to people ultimately responsible for the project, its community, etc. + +## Attribution + +This guide was generated using the WeAllJS `CONTRIBUTING.md` generator. [Make your own](https://npm.im/weallcontribute)! diff --git a/node_modules/libnpmorg/LICENSE b/node_modules/libnpmorg/LICENSE new file mode 100644 index 0000000000000..209e4477f39c1 --- /dev/null +++ b/node_modules/libnpmorg/LICENSE @@ -0,0 +1,13 @@ +Copyright npm, Inc + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/node_modules/libnpmorg/PULL_REQUEST_TEMPLATE b/node_modules/libnpmorg/PULL_REQUEST_TEMPLATE new file mode 100644 index 0000000000000..9471c6d325f7e --- /dev/null +++ b/node_modules/libnpmorg/PULL_REQUEST_TEMPLATE @@ -0,0 +1,7 @@ + diff --git a/node_modules/libnpmorg/README.md b/node_modules/libnpmorg/README.md new file mode 100644 index 0000000000000..6244794eda016 --- /dev/null +++ b/node_modules/libnpmorg/README.md @@ -0,0 +1,144 @@ +# libnpmorg [![npm version](https://img.shields.io/npm/v/libnpmorg.svg)](https://npm.im/libnpmorg) [![license](https://img.shields.io/npm/l/libnpmorg.svg)](https://npm.im/libnpmorg) [![Travis](https://img.shields.io/travis/npm/libnpmorg.svg)](https://travis-ci.org/npm/libnpmorg) [![AppVeyor](https://ci.appveyor.com/api/projects/status/github/zkat/libnpmorg?svg=true)](https://ci.appveyor.com/project/zkat/libnpmorg) [![Coverage Status](https://coveralls.io/repos/github/npm/libnpmorg/badge.svg?branch=latest)](https://coveralls.io/github/npm/libnpmorg?branch=latest) + +[`libnpmorg`](https://github.com/npm/libnpmorg) is a Node.js library for +programmatically accessing the [npm Org membership +API](https://github.com/npm/registry/blob/master/docs/orgs/memberships.md#membership-detail). + +## Example + +```js +const org = require('libnpmorg') + +console.log(await org.ls('myorg', {token: 'deadbeef'})) +=> +Roster { + zkat: 'developer', + iarna: 'admin', + isaacs: 'owner' +} +``` + +## Install + +`$ npm install libnpmorg` + +## Table of Contents + +* [Example](#example) +* [Install](#install) +* [API](#api) + * [hook opts](#opts) + * [`set()`](#set) + * [`rm()`](#rm) + * [`ls()`](#ls) + * [`ls.stream()`](#ls-stream) + +### API + +#### `opts` for `libnpmorg` commands + +`libnpmorg` uses [`npm-registry-fetch`](https://npm.im/npm-registry-fetch). +All options are passed through directly to that library, so please refer to [its +own `opts` +documentation](https://www.npmjs.com/package/npm-registry-fetch#fetch-options) +for options that can be passed in. + +A couple of options of note for those in a hurry: + +* `opts.token` - can be passed in and will be used as the authentication token for the registry. For other ways to pass in auth details, see the n-r-f docs. +* `opts.otp` - certain operations will require an OTP token to be passed in. If a `libnpmorg` command fails with `err.code === EOTP`, please retry the request with `{otp: <2fa token>}` +* `opts.Promise` - If you pass this in, the Promises returned by `libnpmorg` commands will use this Promise class instead. For example: `{Promise: require('bluebird')}` + +#### `> org.set(org, user, [role], [opts]) -> Promise` + +The returned Promise resolves to a [Membership +Detail](https://github.com/npm/registry/blob/master/docs/orgs/memberships.md#membership-detail) +object. + +The `role` is optional and should be one of `admin`, `owner`, or `developer`. +`developer` is the default if no `role` is provided. + +`org` and `user` must be scope names for the org name and user name +respectively. They can optionally be prefixed with `@`. + +See also: [`PUT +/-/org/:scope/user`](https://github.com/npm/registry/blob/master/docs/orgs/memberships.md#org-membership-replace) + +##### Example + +```javascript +await org.set('@myorg', '@myuser', 'admin', {token: 'deadbeef'}) +=> +MembershipDetail { + org: { + name: 'myorg', + size: 15 + }, + user: 'myuser', + role: 'admin' +} +``` + +#### `> org.rm(org, user, [opts]) -> Promise` + +The Promise resolves to `null` on success. + +`org` and `user` must be scope names for the org name and user name +respectively. They can optionally be prefixed with `@`. + +See also: [`DELETE +/-/org/:scope/user`](https://github.com/npm/registry/blob/master/docs/orgs/memberships.md#org-membership-delete) + +##### Example + +```javascript +await org.rm('myorg', 'myuser', {token: 'deadbeef'}) +``` + +#### `> org.ls(org, [opts]) -> Promise` + +The Promise resolves to a +[Roster](https://github.com/npm/registry/blob/master/docs/orgs/memberships.md#roster) +object. + +`org` must be a scope name for an org, and can be optionally prefixed with `@`. + +See also: [`GET +/-/org/:scope/user`](https://github.com/npm/registry/blob/master/docs/orgs/memberships.md#org-roster) + +##### Example + +```javascript +await org.ls('myorg', {token: 'deadbeef'}) +=> +Roster { + zkat: 'developer', + iarna: 'admin', + isaacs: 'owner' +} +``` + +#### `> org.ls.stream(org, [opts]) -> Stream` + +Returns a stream of entries for a +[Roster](https://github.com/npm/registry/blob/master/docs/orgs/memberships.md#roster), +with each emitted entry in `[key, value]` format. + +`org` must be a scope name for an org, and can be optionally prefixed with `@`. + +The returned stream is a valid `Symbol.asyncIterator`. + +See also: [`GET +/-/org/:scope/user`](https://github.com/npm/registry/blob/master/docs/orgs/memberships.md#org-roster) + +##### Example + +```javascript +for await (let [user, role] of org.ls.stream('myorg', {token: 'deadbeef'})) { + console.log(`user: ${user} (${role})`) +} +=> +user: zkat (developer) +user: iarna (admin) +user: isaacs (owner) +``` diff --git a/node_modules/libnpmorg/index.js b/node_modules/libnpmorg/index.js new file mode 100644 index 0000000000000..bff806aa583cf --- /dev/null +++ b/node_modules/libnpmorg/index.js @@ -0,0 +1,71 @@ +'use strict' + +const eu = encodeURIComponent +const fetch = require('npm-registry-fetch') +const figgyPudding = require('figgy-pudding') +const getStream = require('get-stream') +const validate = require('aproba') + +const OrgConfig = figgyPudding({ + Promise: {default: () => Promise} +}) + +// From https://github.com/npm/registry/blob/master/docs/orgs/memberships.md +const cmd = module.exports = {} + +class MembershipDetail {} +cmd.set = (org, user, role, opts) => { + if (typeof role === 'object' && !opts) { + opts = role + role = undefined + } + opts = OrgConfig(opts) + return new opts.Promise((resolve, reject) => { + validate('SSSO|SSZO', [org, user, role, opts]) + user = user.replace(/^@?/, '') + org = org.replace(/^@?/, '') + fetch.json(`/-/org/${eu(org)}/user`, opts.concat({ + method: 'PUT', + body: {user, role} + })).then(resolve, reject) + }).then(ret => Object.assign(new MembershipDetail(), ret)) +} + +cmd.rm = (org, user, opts) => { + opts = OrgConfig(opts) + return new opts.Promise((resolve, reject) => { + validate('SSO', [org, user, opts]) + user = user.replace(/^@?/, '') + org = org.replace(/^@?/, '') + fetch(`/-/org/${eu(org)}/user`, opts.concat({ + method: 'DELETE', + body: {user}, + ignoreBody: true + })).then(resolve, reject) + }).then(() => null) +} + +class Roster {} +cmd.ls = (org, opts) => { + opts = OrgConfig(opts) + return new opts.Promise((resolve, reject) => { + getStream.array(cmd.ls.stream(org, opts)).then(entries => { + const obj = {} + for (let [key, val] of entries) { + obj[key] = val + } + return obj + }).then(resolve, reject) + }).then(ret => Object.assign(new Roster(), ret)) +} + +cmd.ls.stream = (org, opts) => { + opts = OrgConfig(opts) + validate('SO', [org, opts]) + org = org.replace(/^@?/, '') + return fetch.json.stream(`/-/org/${eu(org)}/user`, '*', opts.concat({ + mapJson (value, [key]) { + return [key, value] + } + })) +} diff --git a/node_modules/libnpmorg/node_modules/aproba/CHANGELOG.md b/node_modules/libnpmorg/node_modules/aproba/CHANGELOG.md new file mode 100644 index 0000000000000..bab30ecb7e625 --- /dev/null +++ b/node_modules/libnpmorg/node_modules/aproba/CHANGELOG.md @@ -0,0 +1,4 @@ +2.0.0 + * Drop support for 0.10 and 0.12. They haven't been in travis but still, + since we _know_ we'll break with them now it's only polite to do a + major bump. diff --git a/node_modules/libnpmorg/node_modules/aproba/LICENSE b/node_modules/libnpmorg/node_modules/aproba/LICENSE new file mode 100644 index 0000000000000..f4be44d881b2d --- /dev/null +++ b/node_modules/libnpmorg/node_modules/aproba/LICENSE @@ -0,0 +1,14 @@ +Copyright (c) 2015, Rebecca Turner + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + diff --git a/node_modules/libnpmorg/node_modules/aproba/README.md b/node_modules/libnpmorg/node_modules/aproba/README.md new file mode 100644 index 0000000000000..0bfc594c56a37 --- /dev/null +++ b/node_modules/libnpmorg/node_modules/aproba/README.md @@ -0,0 +1,94 @@ +aproba +====== + +A ridiculously light-weight function argument validator + +``` +var validate = require("aproba") + +function myfunc(a, b, c) { + // `a` must be a string, `b` a number, `c` a function + validate('SNF', arguments) // [a,b,c] is also valid +} + +myfunc('test', 23, function () {}) // ok +myfunc(123, 23, function () {}) // type error +myfunc('test', 23) // missing arg error +myfunc('test', 23, function () {}, true) // too many args error + +``` + +Valid types are: + +| type | description +| :--: | :---------- +| * | matches any type +| A | `Array.isArray` OR an `arguments` object +| S | typeof == string +| N | typeof == number +| F | typeof == function +| O | typeof == object and not type A and not type E +| B | typeof == boolean +| E | `instanceof Error` OR `null` **(special: see below)** +| Z | == `null` + +Validation failures throw one of three exception types, distinguished by a +`code` property of `EMISSINGARG`, `EINVALIDTYPE` or `ETOOMANYARGS`. + +If you pass in an invalid type then it will throw with a code of +`EUNKNOWNTYPE`. + +If an **error** argument is found and is not null then the remaining +arguments are optional. That is, if you say `ESO` then that's like using a +non-magical `E` in: `E|ESO|ZSO`. + +### But I have optional arguments?! + +You can provide more than one signature by separating them with pipes `|`. +If any signature matches the arguments then they'll be considered valid. + +So for example, say you wanted to write a signature for +`fs.createWriteStream`. The docs for it describe it thusly: + +``` +fs.createWriteStream(path[, options]) +``` + +This would be a signature of `SO|S`. That is, a string and and object, or +just a string. + +Now, if you read the full `fs` docs, you'll see that actually path can ALSO +be a buffer. And options can be a string, that is: +``` +path | +options | +``` + +To reproduce this you have to fully enumerate all of the possible +combinations and that implies a signature of `SO|SS|OO|OS|S|O`. The +awkwardness is a feature: It reminds you of the complexity you're adding to +your API when you do this sort of thing. + + +### Browser support + +This has no dependencies and should work in browsers, though you'll have +noisier stack traces. + +### Why this exists + +I wanted a very simple argument validator. It needed to do two things: + +1. Be more concise and easier to use than assertions + +2. Not encourage an infinite bikeshed of DSLs + +This is why types are specified by a single character and there's no such +thing as an optional argument. + +This is not intended to validate user data. This is specifically about +asserting the interface of your functions. + +If you need greater validation, I encourage you to write them by hand or +look elsewhere. + diff --git a/node_modules/libnpmorg/node_modules/aproba/index.js b/node_modules/libnpmorg/node_modules/aproba/index.js new file mode 100644 index 0000000000000..fd947481ba557 --- /dev/null +++ b/node_modules/libnpmorg/node_modules/aproba/index.js @@ -0,0 +1,105 @@ +'use strict' +module.exports = validate + +function isArguments (thingy) { + return thingy != null && typeof thingy === 'object' && thingy.hasOwnProperty('callee') +} + +const types = { + '*': {label: 'any', check: () => true}, + A: {label: 'array', check: _ => Array.isArray(_) || isArguments(_)}, + S: {label: 'string', check: _ => typeof _ === 'string'}, + N: {label: 'number', check: _ => typeof _ === 'number'}, + F: {label: 'function', check: _ => typeof _ === 'function'}, + O: {label: 'object', check: _ => typeof _ === 'object' && _ != null && !types.A.check(_) && !types.E.check(_)}, + B: {label: 'boolean', check: _ => typeof _ === 'boolean'}, + E: {label: 'error', check: _ => _ instanceof Error}, + Z: {label: 'null', check: _ => _ == null} +} + +function addSchema (schema, arity) { + const group = arity[schema.length] = arity[schema.length] || [] + if (group.indexOf(schema) === -1) group.push(schema) +} + +function validate (rawSchemas, args) { + if (arguments.length !== 2) throw wrongNumberOfArgs(['SA'], arguments.length) + if (!rawSchemas) throw missingRequiredArg(0, 'rawSchemas') + if (!args) throw missingRequiredArg(1, 'args') + if (!types.S.check(rawSchemas)) throw invalidType(0, ['string'], rawSchemas) + if (!types.A.check(args)) throw invalidType(1, ['array'], args) + const schemas = rawSchemas.split('|') + const arity = {} + + schemas.forEach(schema => { + for (let ii = 0; ii < schema.length; ++ii) { + const type = schema[ii] + if (!types[type]) throw unknownType(ii, type) + } + if (/E.*E/.test(schema)) throw moreThanOneError(schema) + addSchema(schema, arity) + if (/E/.test(schema)) { + addSchema(schema.replace(/E.*$/, 'E'), arity) + addSchema(schema.replace(/E/, 'Z'), arity) + if (schema.length === 1) addSchema('', arity) + } + }) + let matching = arity[args.length] + if (!matching) { + throw wrongNumberOfArgs(Object.keys(arity), args.length) + } + for (let ii = 0; ii < args.length; ++ii) { + let newMatching = matching.filter(schema => { + const type = schema[ii] + const typeCheck = types[type].check + return typeCheck(args[ii]) + }) + if (!newMatching.length) { + const labels = matching.map(_ => types[_[ii]].label).filter(_ => _ != null) + throw invalidType(ii, labels, args[ii]) + } + matching = newMatching + } +} + +function missingRequiredArg (num) { + return newException('EMISSINGARG', 'Missing required argument #' + (num + 1)) +} + +function unknownType (num, type) { + return newException('EUNKNOWNTYPE', 'Unknown type ' + type + ' in argument #' + (num + 1)) +} + +function invalidType (num, expectedTypes, value) { + let valueType + Object.keys(types).forEach(typeCode => { + if (types[typeCode].check(value)) valueType = types[typeCode].label + }) + return newException('EINVALIDTYPE', 'Argument #' + (num + 1) + ': Expected ' + + englishList(expectedTypes) + ' but got ' + valueType) +} + +function englishList (list) { + return list.join(', ').replace(/, ([^,]+)$/, ' or $1') +} + +function wrongNumberOfArgs (expected, got) { + const english = englishList(expected) + const args = expected.every(ex => ex.length === 1) + ? 'argument' + : 'arguments' + return newException('EWRONGARGCOUNT', 'Expected ' + english + ' ' + args + ' but got ' + got) +} + +function moreThanOneError (schema) { + return newException('ETOOMANYERRORTYPES', + 'Only one error type per argument signature is allowed, more than one found in "' + schema + '"') +} + +function newException (code, msg) { + const err = new Error(msg) + err.code = code + /* istanbul ignore else */ + if (Error.captureStackTrace) Error.captureStackTrace(err, validate) + return err +} diff --git a/node_modules/libnpmorg/node_modules/aproba/package.json b/node_modules/libnpmorg/node_modules/aproba/package.json new file mode 100644 index 0000000000000..3268a9ec7f7e1 --- /dev/null +++ b/node_modules/libnpmorg/node_modules/aproba/package.json @@ -0,0 +1,66 @@ +{ + "_args": [ + [ + "aproba@2.0.0", + "/Users/zkat/Documents/code/work/npm" + ] + ], + "_from": "aproba@2.0.0", + "_id": "aproba@2.0.0", + "_inBundle": false, + "_integrity": "sha512-lYe4Gx7QT+MKGbDsA+Z+he/Wtef0BiwDOlK/XkBrdfsh9J/jPPXbX0tE9x9cl27Tmu5gg3QUbUrQYa/y+KOHPQ==", + "_location": "/libnpmorg/aproba", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "aproba@2.0.0", + "name": "aproba", + "escapedName": "aproba", + "rawSpec": "2.0.0", + "saveSpec": null, + "fetchSpec": "2.0.0" + }, + "_requiredBy": [ + "/libnpmorg" + ], + "_resolved": "https://registry.npmjs.org/aproba/-/aproba-2.0.0.tgz", + "_spec": "2.0.0", + "_where": "/Users/zkat/Documents/code/work/npm", + "author": { + "name": "Rebecca Turner", + "email": "me@re-becca.org" + }, + "bugs": { + "url": "https://github.com/iarna/aproba/issues" + }, + "dependencies": {}, + "description": "A ridiculously light-weight argument validator (now browser friendly)", + "devDependencies": { + "standard": "^11.0.1", + "tap": "^12.0.1" + }, + "directories": { + "test": "test" + }, + "files": [ + "index.js" + ], + "homepage": "https://github.com/iarna/aproba", + "keywords": [ + "argument", + "validate" + ], + "license": "ISC", + "main": "index.js", + "name": "aproba", + "repository": { + "type": "git", + "url": "git+https://github.com/iarna/aproba.git" + }, + "scripts": { + "pretest": "standard", + "test": "tap --100 -J test/*.js" + }, + "version": "2.0.0" +} diff --git a/node_modules/libnpmorg/package.json b/node_modules/libnpmorg/package.json new file mode 100644 index 0000000000000..3f1941298e192 --- /dev/null +++ b/node_modules/libnpmorg/package.json @@ -0,0 +1,77 @@ +{ + "_args": [ + [ + "libnpmorg@1.0.0", + "/Users/zkat/Documents/code/work/npm" + ] + ], + "_from": "libnpmorg@1.0.0", + "_id": "libnpmorg@1.0.0", + "_inBundle": false, + "_integrity": "sha512-o+4eVJBoDGMgRwh2lJY0a8pRV2c/tQM/SxlqXezjcAg26Qe9jigYVs+Xk0vvlYDWCDhP0g74J8UwWeAgsB7gGw==", + "_location": "/libnpmorg", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "libnpmorg@1.0.0", + "name": "libnpmorg", + "escapedName": "libnpmorg", + "rawSpec": "1.0.0", + "saveSpec": null, + "fetchSpec": "1.0.0" + }, + "_requiredBy": [ + "/libnpm" + ], + "_resolved": "https://registry.npmjs.org/libnpmorg/-/libnpmorg-1.0.0.tgz", + "_spec": "1.0.0", + "_where": "/Users/zkat/Documents/code/work/npm", + "author": { + "name": "Kat Marchán", + "email": "kzm@zkat.tech" + }, + "bugs": { + "url": "https://github.com/npm/libnpmorg/issues" + }, + "dependencies": { + "aproba": "^2.0.0", + "figgy-pudding": "^3.4.1", + "get-stream": "^4.0.0", + "npm-registry-fetch": "^3.8.0" + }, + "description": "Programmatic api for `npm org` commands", + "devDependencies": { + "nock": "^9.6.1", + "standard": "*", + "standard-version": "*", + "tap": "*", + "weallbehave": "*", + "weallcontribute": "*" + }, + "homepage": "https://npmjs.com/package/libnpmorg", + "keywords": [ + "libnpm", + "npm", + "package manager", + "api", + "orgs", + "teams" + ], + "license": "ISC", + "name": "libnpmorg", + "repository": { + "type": "git", + "url": "git+https://github.com/npm/libnpmorg.git" + }, + "scripts": { + "postrelease": "npm publish && git push --follow-tags", + "prerelease": "npm t", + "pretest": "standard", + "release": "standard-version -s", + "test": "tap -J --100 test/*.js", + "update-coc": "weallbehave -o . && git add CODE_OF_CONDUCT.md && git commit -m 'docs(coc): updated CODE_OF_CONDUCT.md'", + "update-contrib": "weallcontribute -o . && git add CONTRIBUTING.md && git commit -m 'docs(contributing): updated CONTRIBUTING.md'" + }, + "version": "1.0.0" +} diff --git a/node_modules/libnpmorg/test/index.js b/node_modules/libnpmorg/test/index.js new file mode 100644 index 0000000000000..f5e163a06a789 --- /dev/null +++ b/node_modules/libnpmorg/test/index.js @@ -0,0 +1,81 @@ +'use strict' + +const figgyPudding = require('figgy-pudding') +const getStream = require('get-stream') +const test = require('tap').test +const tnock = require('./util/tnock.js') + +const org = require('../index.js') + +const OPTS = figgyPudding({registry: {}})({ + registry: 'https://mock.reg/' +}) + +test('set', t => { + const memDeets = { + org: { + name: 'myorg', + size: 15 + }, + user: 'myuser', + role: 'admin' + } + tnock(t, OPTS.registry).put('/-/org/myorg/user', { + user: 'myuser', + role: 'admin' + }).reply(201, memDeets) + return org.set('myorg', 'myuser', 'admin', OPTS).then(res => { + t.deepEqual(res, memDeets, 'got a membership details object back') + }) +}) + +test('optional role for set', t => { + const memDeets = { + org: { + name: 'myorg', + size: 15 + }, + user: 'myuser', + role: 'developer' + } + tnock(t, OPTS.registry).put('/-/org/myorg/user', { + user: 'myuser' + }).reply(201, memDeets) + return org.set('myorg', 'myuser', OPTS).then(res => { + t.deepEqual(res, memDeets, 'got a membership details object back') + }) +}) + +test('rm', t => { + tnock(t, OPTS.registry).delete('/-/org/myorg/user', { + user: 'myuser' + }).reply(204) + return org.rm('myorg', 'myuser', OPTS).then(() => { + t.ok(true, 'request succeeded') + }) +}) + +test('ls', t => { + const roster = { + 'zkat': 'developer', + 'iarna': 'admin', + 'isaacs': 'owner' + } + tnock(t, OPTS.registry).get('/-/org/myorg/user').reply(200, roster) + return org.ls('myorg', OPTS).then(res => { + t.deepEqual(res, roster, 'got back a roster') + }) +}) + +test('ls stream', t => { + const roster = { + 'zkat': 'developer', + 'iarna': 'admin', + 'isaacs': 'owner' + } + const rosterArr = Object.keys(roster).map(k => [k, roster[k]]) + tnock(t, OPTS.registry).get('/-/org/myorg/user').reply(200, roster) + return getStream.array(org.ls.stream('myorg', OPTS)).then(res => { + t.deepEqual(res, rosterArr, 'got back a roster, in entries format') + }) +}) diff --git a/node_modules/libnpmorg/test/util/tnock.js b/node_modules/libnpmorg/test/util/tnock.js new file mode 100644 index 0000000000000..00b6e160e1019 --- /dev/null +++ b/node_modules/libnpmorg/test/util/tnock.js @@ -0,0 +1,12 @@ +'use strict' + +const nock = require('nock') + +module.exports = tnock +function tnock (t, host) { + const server = nock(host) + t.tearDown(function () { + server.done() + }) + return server +} diff --git a/node_modules/libnpmpublish/.travis.yml b/node_modules/libnpmpublish/.travis.yml new file mode 100644 index 0000000000000..db5ea8b018640 --- /dev/null +++ b/node_modules/libnpmpublish/.travis.yml @@ -0,0 +1,7 @@ +language: node_js +sudo: false +node_js: + - "10" + - "9" + - "8" + - "6" diff --git a/node_modules/libnpmpublish/CHANGELOG.md b/node_modules/libnpmpublish/CHANGELOG.md new file mode 100644 index 0000000000000..023ddc262c3ee --- /dev/null +++ b/node_modules/libnpmpublish/CHANGELOG.md @@ -0,0 +1,40 @@ +# Change Log + +All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. + + +# [1.1.0](https://github.com/npm/libnpmpublish/compare/v1.0.1...v1.1.0) (2018-08-31) + + +### Features + +* **publish:** add support for publishConfig on manifests ([161723b](https://github.com/npm/libnpmpublish/commit/161723b)) + + + + +## [1.0.1](https://github.com/npm/libnpmpublish/compare/v1.0.0...v1.0.1) (2018-08-31) + + +### Bug Fixes + +* **opts:** remove unused opts ([2837098](https://github.com/npm/libnpmpublish/commit/2837098)) + + + + +# 1.0.0 (2018-08-31) + + +### Bug Fixes + +* **api:** use opts.algorithms, return true on success ([80fe34b](https://github.com/npm/libnpmpublish/commit/80fe34b)) +* **publish:** first test pass w/ bugfixes ([74135c9](https://github.com/npm/libnpmpublish/commit/74135c9)) +* **publish:** full coverage test and related fixes ([b5a3446](https://github.com/npm/libnpmpublish/commit/b5a3446)) + + +### Features + +* **docs:** add README with api docs ([553c13d](https://github.com/npm/libnpmpublish/commit/553c13d)) +* **publish:** add initial publish support. tests tbd ([5b3fe94](https://github.com/npm/libnpmpublish/commit/5b3fe94)) +* **unpublish:** add new api with unpublish support ([1c9d594](https://github.com/npm/libnpmpublish/commit/1c9d594)) diff --git a/node_modules/libnpmpublish/CODE_OF_CONDUCT.md b/node_modules/libnpmpublish/CODE_OF_CONDUCT.md new file mode 100644 index 0000000000000..aeb72f598dcb4 --- /dev/null +++ b/node_modules/libnpmpublish/CODE_OF_CONDUCT.md @@ -0,0 +1,151 @@ +# Code of Conduct + +## When Something Happens + +If you see a Code of Conduct violation, follow these steps: + +1. Let the person know that what they did is not appropriate and ask them to stop and/or edit their message(s) or commits. +2. That person should immediately stop the behavior and correct the issue. +3. If this doesn’t happen, or if you're uncomfortable speaking up, [contact the maintainers](#contacting-maintainers). +4. As soon as available, a maintainer will look into the issue, and take [further action (see below)](#further-enforcement), starting with a warning, then temporary block, then long-term repo or organization ban. + +When reporting, please include any relevant details, links, screenshots, context, or other information that may be used to better understand and resolve the situation. + +**The maintainer team will prioritize the well-being and comfort of the recipients of the violation over the comfort of the violator.** See [some examples below](#enforcement-examples). + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as contributors and maintainers of this project pledge to making participation in our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, technical preferences, nationality, personal appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment include: + + * Using welcoming and inclusive language. + * Being respectful of differing viewpoints and experiences. + * Gracefully accepting constructive feedback. + * Focusing on what is best for the community. + * Showing empathy and kindness towards other community members. + * Encouraging and raising up your peers in the project so you can all bask in hacks and glory. + +Examples of unacceptable behavior by participants include: + + * The use of sexualized language or imagery and unwelcome sexual attention or advances, including when simulated online. The only exception to sexual topics is channels/spaces specifically for topics of sexual identity. + * Casual mention of slavery or indentured servitude and/or false comparisons of one's occupation or situation to slavery. Please consider using or asking about alternate terminology when referring to such metaphors in technology. + * Making light of/making mocking comments about trigger warnings and content warnings. + * Trolling, insulting/derogatory comments, and personal or political attacks. + * Public or private harassment, deliberate intimidation, or threats. + * Publishing others' private information, such as a physical or electronic address, without explicit permission. This includes any sort of "outing" of any aspect of someone's identity without their consent. + * Publishing private screenshots or quotes of interactions in the context of this project without all quoted users' *explicit* consent. + * Publishing of private communication that doesn't have to do with reporting harrassment. + * Any of the above even when [presented as "ironic" or "joking"](https://en.wikipedia.org/wiki/Hipster_racism). + * Any attempt to present "reverse-ism" versions of the above as violations. Examples of reverse-isms are "reverse racism", "reverse sexism", "heterophobia", and "cisphobia". + * Unsolicited explanations under the assumption that someone doesn't already know it. Ask before you teach! Don't assume what people's knowledge gaps are. + * [Feigning or exaggerating surprise](https://www.recurse.com/manual#no-feigned-surprise) when someone admits to not knowing something. + * "[Well-actuallies](https://www.recurse.com/manual#no-well-actuallys)" + * Other conduct which could reasonably be considered inappropriate in a professional or community setting. + +## Scope + +This Code of Conduct applies both within spaces involving this project and in other spaces involving community members. This includes the repository, its Pull Requests and Issue tracker, its Twitter community, private email communications in the context of the project, and any events where members of the project are participating, as well as adjacent communities and venues affecting the project's members. + +Depending on the violation, the maintainers may decide that violations of this code of conduct that have happened outside of the scope of the community may deem an individual unwelcome, and take appropriate action to maintain the comfort and safety of its members. + +### Other Community Standards + +As a project on GitHub, this project is additionally covered by the [GitHub Community Guidelines](https://help.github.com/articles/github-community-guidelines/). + +Additionally, as a project hosted on npm, is is covered by [npm, Inc's Code of Conduct](https://www.npmjs.com/policies/conduct). + +Enforcement of those guidelines after violations overlapping with the above are the responsibility of the entities, and enforcement may happen in any or all of the services/communities. + +## Maintainer Enforcement Process + +Once the maintainers get involved, they will follow a documented series of steps and do their best to preserve the well-being of project members. This section covers actual concrete steps. + +### Contacting Maintainers + +You may get in touch with the maintainer team through any of the following methods: + + * Through email: + * [kzm@zkat.tech](mailto:kzm@zkat.tech) (Kat Marchán) + + * Through Twitter: + * [@maybekatz](https://twitter.com/maybekatz) (Kat Marchán) + +### Further Enforcement + +If you've already followed the [initial enforcement steps](#enforcement), these are the steps maintainers will take for further enforcement, as needed: + + 1. Repeat the request to stop. + 2. If the person doubles down, they will have offending messages removed or edited by a maintainers given an official warning. The PR or Issue may be locked. + 3. If the behavior continues or is repeated later, the person will be blocked from participating for 24 hours. + 4. If the behavior continues or is repeated after the temporary block, a long-term (6-12mo) ban will be used. + +On top of this, maintainers may remove any offending messages, images, contributions, etc, as they deem necessary. + +Maintainers reserve full rights to skip any of these steps, at their discretion, if the violation is considered to be a serious and/or immediate threat to the health and well-being of members of the community. These include any threats, serious physical or verbal attacks, and other such behavior that would be completely unacceptable in any social setting that puts our members at risk. + +Members expelled from events or venues with any sort of paid attendance will not be refunded. + +### Who Watches the Watchers? + +Maintainers and other leaders who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. These may include anything from removal from the maintainer team to a permanent ban from the community. + +Additionally, as a project hosted on both GitHub and npm, [their own Codes of Conducts may be applied against maintainers of this project](#other-community-standards), externally of this project's procedures. + +### Enforcement Examples + +#### The Best Case + +The vast majority of situations work out like this. This interaction is common, and generally positive. + +> Alex: "Yeah I used X and it was really crazy!" + +> Patt (not a maintainer): "Hey, could you not use that word? What about 'ridiculous' instead?" + +> Alex: "oh sorry, sure." -> edits old comment to say "it was really confusing!" + +#### The Maintainer Case + +Sometimes, though, you need to get maintainers involved. Maintainers will do their best to resolve conflicts, but people who were harmed by something **will take priority**. + +> Patt: "Honestly, sometimes I just really hate using $library and anyone who uses it probably sucks at their job." + +> Alex: "Whoa there, could you dial it back a bit? There's a CoC thing about attacking folks' tech use like that." + +> Patt: "I'm not attacking anyone, what's your problem?" + +> Alex: "@maintainers hey uh. Can someone look at this issue? Patt is getting a bit aggro. I tried to nudge them about it, but nope." + +> KeeperOfCommitBits: (on issue) "Hey Patt, maintainer here. Could you tone it down? This sort of attack is really not okay in this space." + +> Patt: "Leave me alone I haven't said anything bad wtf is wrong with you." + +> KeeperOfCommitBits: (deletes user's comment), "@patt I mean it. Please refer to the CoC over at (URL to this CoC) if you have questions, but you can consider this an actual warning. I'd appreciate it if you reworded your messages in this thread, since they made folks there uncomfortable. Let's try and be kind, yeah?" + +> Patt: "@keeperofbits Okay sorry. I'm just frustrated and I'm kinda burnt out and I guess I got carried away. I'll DM Alex a note apologizing and edit my messages. Sorry for the trouble." + +> KeeperOfCommitBits: "@patt Thanks for that. I hear you on the stress. Burnout sucks :/. Have a good one!" + +#### The Nope Case + +> PepeTheFrog🐸: "Hi, I am a literal actual nazi and I think white supremacists are quite fashionable." + +> Patt: "NOOOOPE. OH NOPE NOPE." + +> Alex: "JFC NO. NOPE. @keeperofbits NOPE NOPE LOOK HERE" + +> KeeperOfCommitBits: "👀 Nope. NOPE NOPE NOPE. 🔥" + +> PepeTheFrog🐸 has been banned from all organization or user repositories belonging to KeeperOfCommitBits. + +## Attribution + +This Code of Conduct was generated using [WeAllJS Code of Conduct Generator](https://npm.im/weallbehave), which is based on the [WeAllJS Code of +Conduct](https://wealljs.org/code-of-conduct), which is itself based on +[Contributor Covenant](http://contributor-covenant.org), version 1.4, available +at +[http://contributor-covenant.org/version/1/4](http://contributor-covenant.org/version/1/4), +and the LGBTQ in Technology Slack [Code of +Conduct](http://lgbtq.technology/coc.html). diff --git a/node_modules/libnpmpublish/CONTRIBUTING.md b/node_modules/libnpmpublish/CONTRIBUTING.md new file mode 100644 index 0000000000000..780044ffcc0f3 --- /dev/null +++ b/node_modules/libnpmpublish/CONTRIBUTING.md @@ -0,0 +1,256 @@ +# Contributing + +## How do I... + +* [Use This Guide](#introduction)? +* Ask or Say Something? 🤔🐛😱 + * [Request Support](#request-support) + * [Report an Error or Bug](#report-an-error-or-bug) + * [Request a Feature](#request-a-feature) +* Make Something? 🤓👩🏽‍💻📜🍳 + * [Project Setup](#project-setup) + * [Contribute Documentation](#contribute-documentation) + * [Contribute Code](#contribute-code) +* Manage Something ✅🙆🏼💃👔 + * [Provide Support on Issues](#provide-support-on-issues) + * [Label Issues](#label-issues) + * [Clean Up Issues and PRs](#clean-up-issues-and-prs) + * [Review Pull Requests](#review-pull-requests) + * [Merge Pull Requests](#merge-pull-requests) + * [Tag a Release](#tag-a-release) + * [Join the Project Team](#join-the-project-team) +* Add a Guide Like This One [To My Project](#attribution)? 🤖😻👻 + +## Introduction + +Thank you so much for your interest in contributing!. All types of contributions are encouraged and valued. See the [table of contents](#toc) for different ways to help and details about how this project handles them!📝 + +Please make sure to read the relevant section before making your contribution! It will make it a lot easier for us maintainers to make the most of it and smooth out the experience for all involved. 💚 + +The [Project Team](#join-the-project-team) looks forward to your contributions. 🙌🏾✨ + +## Request Support + +If you have a question about this project, how to use it, or just need clarification about something: + +* Open an Issue at https://github.com/npm/libnpmpublish/issues +* Provide as much context as you can about what you're running into. +* Provide project and platform versions (nodejs, npm, etc), depending on what seems relevant. If not, please be ready to provide that information if maintainers ask for it. + +Once it's filed: + +* The project team will [label the issue](#label-issues). +* Someone will try to have a response soon. +* If you or the maintainers don't respond to an issue for 30 days, the [issue will be closed](#clean-up-issues-and-prs). If you want to come back to it, reply (once, please), and we'll reopen the existing issue. Please avoid filing new issues as extensions of one you already made. + +## Report an Error or Bug + +If you run into an error or bug with the project: + +* Open an Issue at https://github.com/npm/libnpmpublish/issues +* Include *reproduction steps* that someone else can follow to recreate the bug or error on their own. +* Provide project and platform versions (nodejs, npm, etc), depending on what seems relevant. If not, please be ready to provide that information if maintainers ask for it. + +Once it's filed: + +* The project team will [label the issue](#label-issues). +* A team member will try to reproduce the issue with your provided steps. If there are no repro steps or no obvious way to reproduce the issue, the team will ask you for those steps and mark the issue as `needs-repro`. Bugs with the `needs-repro` tag will not be addressed until they are reproduced. +* If the team is able to reproduce the issue, it will be marked `needs-fix`, as well as possibly other tags (such as `critical`), and the issue will be left to be [implemented by someone](#contribute-code). +* If you or the maintainers don't respond to an issue for 30 days, the [issue will be closed](#clean-up-issues-and-prs). If you want to come back to it, reply (once, please), and we'll reopen the existing issue. Please avoid filing new issues as extensions of one you already made. +* `critical` issues may be left open, depending on perceived immediacy and severity, even past the 30 day deadline. + +## Request a Feature + +If the project doesn't do something you need or want it to do: + +* Open an Issue at https://github.com/npm/libnpmpublish/issues +* Provide as much context as you can about what you're running into. +* Please try and be clear about why existing features and alternatives would not work for you. + +Once it's filed: + +* The project team will [label the issue](#label-issues). +* The project team will evaluate the feature request, possibly asking you more questions to understand its purpose and any relevant requirements. If the issue is closed, the team will convey their reasoning and suggest an alternative path forward. +* If the feature request is accepted, it will be marked for implementation with `feature-accepted`, which can then be done by either by a core team member or by anyone in the community who wants to [contribute code](#contribute-code). + +Note: The team is unlikely to be able to accept every single feature request that is filed. Please understand if they need to say no. + +## Project Setup + +So you wanna contribute some code! That's great! This project uses GitHub Pull Requests to manage contributions, so [read up on how to fork a GitHub project and file a PR](https://guides.github.com/activities/forking) if you've never done it before. + +If this seems like a lot or you aren't able to do all this setup, you might also be able to [edit the files directly](https://help.github.com/articles/editing-files-in-another-user-s-repository/) without having to do any of this setup. Yes, [even code](#contribute-code). + +If you want to go the usual route and run the project locally, though: + +* [Install Node.js](https://nodejs.org/en/download/) +* [Fork the project](https://guides.github.com/activities/forking/#fork) + +Then in your terminal: +* `cd path/to/your/clone` +* `npm install` +* `npm test` + +And you should be ready to go! + +## Contribute Documentation + +Documentation is a super important, critical part of this project. Docs are how we keep track of what we're doing, how, and why. It's how we stay on the same page about our policies. And it's how we tell others everything they need in order to be able to use this project -- or contribute to it. So thank you in advance. + +Documentation contributions of any size are welcome! Feel free to file a PR even if you're just rewording a sentence to be more clear, or fixing a spelling mistake! + +To contribute documentation: + +* [Set up the project](#project-setup). +* Edit or add any relevant documentation. +* Make sure your changes are formatted correctly and consistently with the rest of the documentation. +* Re-read what you wrote, and run a spellchecker on it to make sure you didn't miss anything. +* In your commit message(s), begin the first line with `docs: `. For example: `docs: Adding a doc contrib section to CONTRIBUTING.md`. +* Write clear, concise commit message(s) using [conventional-changelog format](https://github.com/conventional-changelog/conventional-changelog-angular/blob/master/convention.md). Documentation commits should use `docs(): `. +* Go to https://github.com/npm/libnpmpublish/pulls and open a new pull request with your changes. +* If your PR is connected to an open issue, add a line in your PR's description that says `Fixes: #123`, where `#123` is the number of the issue you're fixing. + +Once you've filed the PR: + +* One or more maintainers will use GitHub's review feature to review your PR. +* If the maintainer asks for any changes, edit your changes, push, and ask for another review. +* If the maintainer decides to pass on your PR, they will thank you for the contribution and explain why they won't be accepting the changes. That's ok! We still really appreciate you taking the time to do it, and we don't take that lightly. 💚 +* If your PR gets accepted, it will be marked as such, and merged into the `latest` branch soon after. Your contribution will be distributed to the masses next time the maintainers [tag a release](#tag-a-release) + +## Contribute Code + +We like code commits a lot! They're super handy, and they keep the project going and doing the work it needs to do to be useful to others. + +Code contributions of just about any size are acceptable! + +The main difference between code contributions and documentation contributions is that contributing code requires inclusion of relevant tests for the code being added or changed. Contributions without accompanying tests will be held off until a test is added, unless the maintainers consider the specific tests to be either impossible, or way too much of a burden for such a contribution. + +To contribute code: + +* [Set up the project](#project-setup). +* Make any necessary changes to the source code. +* Include any [additional documentation](#contribute-documentation) the changes might need. +* Write tests that verify that your contribution works as expected. +* Write clear, concise commit message(s) using [conventional-changelog format](https://github.com/conventional-changelog/conventional-changelog-angular/blob/master/convention.md). +* Dependency updates, additions, or removals must be in individual commits, and the message must use the format: `(deps): PKG@VERSION`, where `` is any of the usual `conventional-changelog` prefixes, at your discretion. +* Go to https://github.com/npm/libnpmpublish/pulls and open a new pull request with your changes. +* If your PR is connected to an open issue, add a line in your PR's description that says `Fixes: #123`, where `#123` is the number of the issue you're fixing. + +Once you've filed the PR: + +* Barring special circumstances, maintainers will not review PRs until all checks pass (Travis, AppVeyor, etc). +* One or more maintainers will use GitHub's review feature to review your PR. +* If the maintainer asks for any changes, edit your changes, push, and ask for another review. Additional tags (such as `needs-tests`) will be added depending on the review. +* If the maintainer decides to pass on your PR, they will thank you for the contribution and explain why they won't be accepting the changes. That's ok! We still really appreciate you taking the time to do it, and we don't take that lightly. 💚 +* If your PR gets accepted, it will be marked as such, and merged into the `latest` branch soon after. Your contribution will be distributed to the masses next time the maintainers [tag a release](#tag-a-release) + +## Provide Support on Issues + +[Needs Collaborator](#join-the-project-team): none + +Helping out other users with their questions is a really awesome way of contributing to any community. It's not uncommon for most of the issues on an open source projects being support-related questions by users trying to understand something they ran into, or find their way around a known bug. + +Sometimes, the `support` label will be added to things that turn out to actually be other things, like bugs or feature requests. In that case, suss out the details with the person who filed the original issue, add a comment explaining what the bug is, and change the label from `support` to `bug` or `feature`. If you can't do this yourself, @mention a maintainer so they can do it. + +In order to help other folks out with their questions: + +* Go to the issue tracker and [filter open issues by the `support` label](https://github.com/npm/libnpmpublish/issues?q=is%3Aopen+is%3Aissue+label%3Asupport). +* Read through the list until you find something that you're familiar enough with to give an answer to. +* Respond to the issue with whatever details are needed to clarify the question, or get more details about what's going on. +* Once the discussion wraps up and things are clarified, either close the issue, or ask the original issue filer (or a maintainer) to close it for you. + +Some notes on picking up support issues: + +* Avoid responding to issues you don't know you can answer accurately. +* As much as possible, try to refer to past issues with accepted answers. Link to them from your replies with the `#123` format. +* Be kind and patient with users -- often, folks who have run into confusing things might be upset or impatient. This is ok. Try to understand where they're coming from, and if you're too uncomfortable with the tone, feel free to stay away or withdraw from the issue. (note: if the user is outright hostile or is violating the CoC, [refer to the Code of Conduct](CODE_OF_CONDUCT.md) to resolve the conflict). + +## Label Issues + +[Needs Collaborator](#join-the-project-team): Issue Tracker + +One of the most important tasks in handling issues is labeling them usefully and accurately. All other tasks involving issues ultimately rely on the issue being classified in such a way that relevant parties looking to do their own tasks can find them quickly and easily. + +In order to label issues, [open up the list of unlabeled issues](https://github.com/npm/libnpmpublish/issues?q=is%3Aopen+is%3Aissue+no%3Alabel) and, **from newest to oldest**, read through each one and apply issue labels according to the table below. If you're unsure about what label to apply, skip the issue and try the next one: don't feel obligated to label each and every issue yourself! + +Label | Apply When | Notes +--- | --- | --- +`bug` | Cases where the code (or documentation) is behaving in a way it wasn't intended to. | If something is happening that surprises the *user* but does not go against the way the code is designed, it should use the `enhancement` label. +`critical` | Added to `bug` issues if the problem described makes the code completely unusable in a common situation. | +`documentation` | Added to issues or pull requests that affect any of the documentation for the project. | Can be combined with other labels, such as `bug` or `enhancement`. +`duplicate` | Added to issues or PRs that refer to the exact same issue as another one that's been previously labeled. | Duplicate issues should be marked and closed right away, with a message referencing the issue it's a duplicate of (with `#123`) +`enhancement` | Added to [feature requests](#request-a-feature), PRs, or documentation issues that are purely additive: the code or docs currently work as expected, but a change is being requested or suggested. | +`help wanted` | Applied by [Committers](#join-the-project-team) to issues and PRs that they would like to get outside help for. Generally, this means it's lower priority for the maintainer team to itself implement, but that the community is encouraged to pick up if they so desire | Never applied on first-pass labeling. +`in-progress` | Applied by [Committers](#join-the-project-team) to PRs that are pending some work before they're ready for review. | The original PR submitter should @mention the team member that applied the label once the PR is complete. +`performance` | This issue or PR is directly related to improving performance. | +`refactor` | Added to issues or PRs that deal with cleaning up or modifying the project for the betterment of it. | +`starter` | Applied by [Committers](#join-the-project-team) to issues that they consider good introductions to the project for people who have not contributed before. These are not necessarily "easy", but rather focused around how much context is necessary in order to understand what needs to be done for this project in particular. | Existing project members are expected to stay away from these unless they increase in priority. +`support` | This issue is either asking a question about how to use the project, clarifying the reason for unexpected behavior, or possibly reporting a `bug` but does not have enough detail yet to determine whether it would count as such. | The label should be switched to `bug` if reliable reproduction steps are provided. Issues primarily with unintended configurations of a user's environment are not considered bugs, even if they cause crashes. +`tests` | This issue or PR either requests or adds primarily tests to the project. | If a PR is pending tests, that will be handled through the [PR review process](#review-pull-requests) +`wontfix` | Labelers may apply this label to issues that clearly have nothing at all to do with the project or are otherwise entirely outside of its scope/sphere of influence. [Committers](#join-the-project-team) may apply this label and close an issue or PR if they decide to pass on an otherwise relevant issue. | The issue or PR should be closed as soon as the label is applied, and a clear explanation provided of why the label was used. Contributors are free to contest the labeling, but the decision ultimately falls on committers as to whether to accept something or not. + +## Clean Up Issues and PRs + +[Needs Collaborator](#join-the-project-team): Issue Tracker + +Issues and PRs can go stale after a while. Maybe they're abandoned. Maybe the team will just plain not have time to address them any time soon. + +In these cases, they should be closed until they're brought up again or the interaction starts over. + +To clean up issues and PRs: + +* Search the issue tracker for issues or PRs, and add the term `updated:<=YYYY-MM-DD`, where the date is 30 days before today. +* Go through each issue *from oldest to newest*, and close them if **all of the following are true**: + * not opened by a maintainer + * not marked as `critical` + * not marked as `starter` or `help wanted` (these might stick around for a while, in general, as they're intended to be available) + * no explicit messages in the comments asking for it to be left open + * does not belong to a milestone +* Leave a message when closing saying "Cleaning up stale issue. Please reopen or ping us if and when you're ready to resume this. See https://github.com/npm/libnpmpublish/blob/latest/CONTRIBUTING.md#clean-up-issues-and-prs for more details." + +## Review Pull Requests + +[Needs Collaborator](#join-the-project-team): Issue Tracker + +While anyone can comment on a PR, add feedback, etc, PRs are only *approved* by team members with Issue Tracker or higher permissions. + +PR reviews use [GitHub's own review feature](https://help.github.com/articles/about-pull-request-reviews/), which manages comments, approval, and review iteration. + +Some notes: + +* You may ask for minor changes ("nitpicks"), but consider whether they are really blockers to merging: try to err on the side of "approve, with comments". +* *ALL PULL REQUESTS* should be covered by a test: either by a previously-failing test, an existing test that covers the entire functionality of the submitted code, or new tests to verify any new/changed behavior. All tests must also pass and follow established conventions. Test coverage should not drop, unless the specific case is considered reasonable by maintainers. +* Please make sure you're familiar with the code or documentation being updated, unless it's a minor change (spellchecking, minor formatting, etc). You may @mention another project member who you think is better suited for the review, but still provide a non-approving review of your own. +* Be extra kind: people who submit code/doc contributions are putting themselves in a pretty vulnerable position, and have put time and care into what they've done (even if that's not obvious to you!) -- always respond with respect, be understanding, but don't feel like you need to sacrifice your standards for their sake, either. Just don't be a jerk about it? + +## Merge Pull Requests + +[Needs Collaborator](#join-the-project-team): Committer + +TBD - need to hash out a bit more of this process. + +## Tag A Release + +[Needs Collaborator](#join-the-project-team): Committer + +TBD - need to hash out a bit more of this process. The most important bit here is probably that all tests must pass, and tags must use [semver](https://semver.org). + +## Join the Project Team + +### Ways to Join + +There are many ways to contribute! Most of them don't require any official status unless otherwise noted. That said, there's a couple of positions that grant special repository abilities, and this section describes how they're granted and what they do. + +All of the below positions are granted based on the project team's needs, as well as their consensus opinion about whether they would like to work with the person and think that they would fit well into that position. The process is relatively informal, and it's likely that people who express interest in participating can just be granted the permissions they'd like. + +You can spot a collaborator on the repo by looking for the `[Collaborator]` or `[Owner]` tags next to their names. + +Permission | Description +--- | --- +Issue Tracker | Granted to contributors who express a strong interest in spending time on the project's issue tracker. These tasks are mainly [labeling issues](#label-issues), [cleaning up old ones](#clean-up-issues-and-prs), and [reviewing pull requests](#review-pull-requests), as well as all the usual things non-team-member contributors can do. Issue handlers should not merge pull requests, tag releases, or directly commit code themselves: that should still be done through the usual pull request process. Becoming an Issue Handler means the project team trusts you to understand enough of the team's process and context to implement it on the issue tracker. +Committer | Granted to contributors who want to handle the actual pull request merges, tagging new versions, etc. Committers should have a good level of familiarity with the codebase, and enough context to understand the implications of various changes, as well as a good sense of the will and expectations of the project team. +Admin/Owner | Granted to people ultimately responsible for the project, its community, etc. + +## Attribution + +This guide was generated using the WeAllJS `CONTRIBUTING.md` generator. [Make your own](https://npm.im/weallcontribute)! diff --git a/node_modules/libnpmpublish/LICENSE b/node_modules/libnpmpublish/LICENSE new file mode 100644 index 0000000000000..209e4477f39c1 --- /dev/null +++ b/node_modules/libnpmpublish/LICENSE @@ -0,0 +1,13 @@ +Copyright npm, Inc + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/node_modules/libnpmpublish/PULL_REQUEST_TEMPLATE b/node_modules/libnpmpublish/PULL_REQUEST_TEMPLATE new file mode 100644 index 0000000000000..9471c6d325f7e --- /dev/null +++ b/node_modules/libnpmpublish/PULL_REQUEST_TEMPLATE @@ -0,0 +1,7 @@ + diff --git a/node_modules/libnpmpublish/README.md b/node_modules/libnpmpublish/README.md new file mode 100644 index 0000000000000..b605bdc24e88b --- /dev/null +++ b/node_modules/libnpmpublish/README.md @@ -0,0 +1,111 @@ +# libnpmpublish [![npm version](https://img.shields.io/npm/v/libnpmpublish.svg)](https://npm.im/libnpmpublish) [![license](https://img.shields.io/npm/l/libnpmpublish.svg)](https://npm.im/libnpmpublish) [![Travis](https://img.shields.io/travis/npm/libnpmpublish.svg)](https://travis-ci.org/npm/libnpmpublish) [![AppVeyor](https://ci.appveyor.com/api/projects/status/github/zkat/libnpmpublish?svg=true)](https://ci.appveyor.com/project/zkat/libnpmpublish) [![Coverage Status](https://coveralls.io/repos/github/npm/libnpmpublish/badge.svg?branch=latest)](https://coveralls.io/github/npm/libnpmpublish?branch=latest) + +[`libnpmpublish`](https://github.com/npm/libnpmpublish) is a Node.js library for +programmatically publishing and unpublishing npm packages. It does not take care +of packing tarballs from source code, but once you have a tarball, it can take +care of putting it up on a nice registry for you. + +## Example + +```js +const search = require('libnpmpublish') + +``` + +## Install + +`$ npm install libnpmsearch` + +## Table of Contents + +* [Example](#example) +* [Install](#install) +* [API](#api) + * [publish/unpublish opts](#opts) + * [`search()`](#search) + * [`search.stream()`](#search-stream) + +### API + +#### `opts` for `libnpmpublish` commands + +`libnpmpublish` uses [`npm-registry-fetch`](https://npm.im/npm-registry-fetch). +Most options are passed through directly to that library, so please refer to +[its own `opts` +documentation](https://www.npmjs.com/package/npm-registry-fetch#fetch-options) +for options that can be passed in. + +A couple of options of note for those in a hurry: + +* `opts.token` - can be passed in and will be used as the authentication token for the registry. For other ways to pass in auth details, see the n-r-f docs. +* `opts.Promise` - If you pass this in, the Promises returned by `libnpmpublish` commands will use this Promise class instead. For example: `{Promise: require('bluebird')}` + +#### `> libpub.publish(pkgJson, tarData, [opts]) -> Promise` + +Publishes `tarData` to the appropriate configured registry. `pkgJson` should be +the parsed `package.json` for the package that is being published. + +`tarData` can be a Buffer, a base64-encoded string, or a binary stream of data. +Note that publishing itself can't be streamed, so the entire stream will be +consumed into RAM before publishing (and are thus limited in how big they can +be). + +Since `libnpmpublish` does not generate tarballs itself, one way to build your +own tarball for publishing is to do `npm pack` in the directory you wish to +pack. You can then `fs.createReadStream('my-proj-1.0.0.tgz')` and pass that to +`libnpmpublish`, along with `require('./package.json')`. + +`publish()` does its best to emulate legacy publish logic in the standard npm +client, and so should generally be compatible with any registry the npm CLI has +been able to publish to in the past. + +If `opts.npmVersion` is passed in, it will be used as the `_npmVersion` field in +the outgoing packument. It's recommended you add your own user agent string in +there! + +If `opts.algorithms` is passed in, it should be an array of hashing algorithms +to generate `integrity` hashes for. The default is `['sha512']`, which means you +end up with `dist.integrity = 'sha512-deadbeefbadc0ffee'`. Any algorithm +supported by your current node version is allowed -- npm clients that do not +support those algorithms will simply ignore the unsupported hashes. + +If `opts.access` is passed in, it must be one of `public` or `restricted`. +Unscoped packages cannot be `restricted`, and the registry may agree or disagree +with whether you're allowed to publish a restricted package. + +##### Example + +```javascript +const pkg = require('./dist/package.json') +const tarball = fs.createReadStream('./dist/pkg-1.0.1.tgz') +await libpub.publish(pkg, tarball, { + npmVersion: 'my-pub-script@1.0.2', + token: 'my-auth-token-here' +}) +// Package has been published to the npm registry. +``` + +#### `> libpub.unpublish(spec, [opts]) -> Promise` + +Unpublishes `spec` from the appropriate registry. The registry in question may +have its own limitations on unpublishing. + +`spec` should be either a string, or a valid +[`npm-package-arg`](https://npm.im/npm-package-arg) parsed spec object. For +legacy compatibility reasons, only `tag` and `version` specs will work as +expected. `range` specs will fail silently in most cases. + +##### Example + +```javascript +await libpub.unpublish('lodash', { token: 'i-am-the-worst'}) +// +// `lodash` has now been unpublished, along with all its versions, and the world +// devolves into utter chaos. +// +// That, or we all go home to our friends and/or family and have a nice time +// doing nothing having to do with programming or JavaScript and realize our +// lives are just so much happier now, and we just can't understand why we ever +// got so into this JavaScript thing but damn did it pay well. I guess you'll +// settle for gardening or something. +``` diff --git a/node_modules/libnpmpublish/appveyor.yml b/node_modules/libnpmpublish/appveyor.yml new file mode 100644 index 0000000000000..9cc64c58e02f9 --- /dev/null +++ b/node_modules/libnpmpublish/appveyor.yml @@ -0,0 +1,22 @@ +environment: + matrix: + - nodejs_version: "10" + - nodejs_version: "9" + - nodejs_version: "8" + - nodejs_version: "6" + +platform: + - x64 + +install: + - ps: Install-Product node $env:nodejs_version $env:platform + - npm config set spin false + - npm install + +test_script: + - npm test + +matrix: + fast_finish: true + +build: off diff --git a/node_modules/libnpmpublish/index.js b/node_modules/libnpmpublish/index.js new file mode 100644 index 0000000000000..38de9ece14e4e --- /dev/null +++ b/node_modules/libnpmpublish/index.js @@ -0,0 +1,4 @@ +module.exports = { + publish: require('./publish.js'), + unpublish: require('./unpublish.js') +} diff --git a/node_modules/libnpmpublish/node_modules/aproba/CHANGELOG.md b/node_modules/libnpmpublish/node_modules/aproba/CHANGELOG.md new file mode 100644 index 0000000000000..bab30ecb7e625 --- /dev/null +++ b/node_modules/libnpmpublish/node_modules/aproba/CHANGELOG.md @@ -0,0 +1,4 @@ +2.0.0 + * Drop support for 0.10 and 0.12. They haven't been in travis but still, + since we _know_ we'll break with them now it's only polite to do a + major bump. diff --git a/node_modules/libnpmpublish/node_modules/aproba/LICENSE b/node_modules/libnpmpublish/node_modules/aproba/LICENSE new file mode 100644 index 0000000000000..f4be44d881b2d --- /dev/null +++ b/node_modules/libnpmpublish/node_modules/aproba/LICENSE @@ -0,0 +1,14 @@ +Copyright (c) 2015, Rebecca Turner + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + diff --git a/node_modules/libnpmpublish/node_modules/aproba/README.md b/node_modules/libnpmpublish/node_modules/aproba/README.md new file mode 100644 index 0000000000000..0bfc594c56a37 --- /dev/null +++ b/node_modules/libnpmpublish/node_modules/aproba/README.md @@ -0,0 +1,94 @@ +aproba +====== + +A ridiculously light-weight function argument validator + +``` +var validate = require("aproba") + +function myfunc(a, b, c) { + // `a` must be a string, `b` a number, `c` a function + validate('SNF', arguments) // [a,b,c] is also valid +} + +myfunc('test', 23, function () {}) // ok +myfunc(123, 23, function () {}) // type error +myfunc('test', 23) // missing arg error +myfunc('test', 23, function () {}, true) // too many args error + +``` + +Valid types are: + +| type | description +| :--: | :---------- +| * | matches any type +| A | `Array.isArray` OR an `arguments` object +| S | typeof == string +| N | typeof == number +| F | typeof == function +| O | typeof == object and not type A and not type E +| B | typeof == boolean +| E | `instanceof Error` OR `null` **(special: see below)** +| Z | == `null` + +Validation failures throw one of three exception types, distinguished by a +`code` property of `EMISSINGARG`, `EINVALIDTYPE` or `ETOOMANYARGS`. + +If you pass in an invalid type then it will throw with a code of +`EUNKNOWNTYPE`. + +If an **error** argument is found and is not null then the remaining +arguments are optional. That is, if you say `ESO` then that's like using a +non-magical `E` in: `E|ESO|ZSO`. + +### But I have optional arguments?! + +You can provide more than one signature by separating them with pipes `|`. +If any signature matches the arguments then they'll be considered valid. + +So for example, say you wanted to write a signature for +`fs.createWriteStream`. The docs for it describe it thusly: + +``` +fs.createWriteStream(path[, options]) +``` + +This would be a signature of `SO|S`. That is, a string and and object, or +just a string. + +Now, if you read the full `fs` docs, you'll see that actually path can ALSO +be a buffer. And options can be a string, that is: +``` +path | +options | +``` + +To reproduce this you have to fully enumerate all of the possible +combinations and that implies a signature of `SO|SS|OO|OS|S|O`. The +awkwardness is a feature: It reminds you of the complexity you're adding to +your API when you do this sort of thing. + + +### Browser support + +This has no dependencies and should work in browsers, though you'll have +noisier stack traces. + +### Why this exists + +I wanted a very simple argument validator. It needed to do two things: + +1. Be more concise and easier to use than assertions + +2. Not encourage an infinite bikeshed of DSLs + +This is why types are specified by a single character and there's no such +thing as an optional argument. + +This is not intended to validate user data. This is specifically about +asserting the interface of your functions. + +If you need greater validation, I encourage you to write them by hand or +look elsewhere. + diff --git a/node_modules/libnpmpublish/node_modules/aproba/index.js b/node_modules/libnpmpublish/node_modules/aproba/index.js new file mode 100644 index 0000000000000..fd947481ba557 --- /dev/null +++ b/node_modules/libnpmpublish/node_modules/aproba/index.js @@ -0,0 +1,105 @@ +'use strict' +module.exports = validate + +function isArguments (thingy) { + return thingy != null && typeof thingy === 'object' && thingy.hasOwnProperty('callee') +} + +const types = { + '*': {label: 'any', check: () => true}, + A: {label: 'array', check: _ => Array.isArray(_) || isArguments(_)}, + S: {label: 'string', check: _ => typeof _ === 'string'}, + N: {label: 'number', check: _ => typeof _ === 'number'}, + F: {label: 'function', check: _ => typeof _ === 'function'}, + O: {label: 'object', check: _ => typeof _ === 'object' && _ != null && !types.A.check(_) && !types.E.check(_)}, + B: {label: 'boolean', check: _ => typeof _ === 'boolean'}, + E: {label: 'error', check: _ => _ instanceof Error}, + Z: {label: 'null', check: _ => _ == null} +} + +function addSchema (schema, arity) { + const group = arity[schema.length] = arity[schema.length] || [] + if (group.indexOf(schema) === -1) group.push(schema) +} + +function validate (rawSchemas, args) { + if (arguments.length !== 2) throw wrongNumberOfArgs(['SA'], arguments.length) + if (!rawSchemas) throw missingRequiredArg(0, 'rawSchemas') + if (!args) throw missingRequiredArg(1, 'args') + if (!types.S.check(rawSchemas)) throw invalidType(0, ['string'], rawSchemas) + if (!types.A.check(args)) throw invalidType(1, ['array'], args) + const schemas = rawSchemas.split('|') + const arity = {} + + schemas.forEach(schema => { + for (let ii = 0; ii < schema.length; ++ii) { + const type = schema[ii] + if (!types[type]) throw unknownType(ii, type) + } + if (/E.*E/.test(schema)) throw moreThanOneError(schema) + addSchema(schema, arity) + if (/E/.test(schema)) { + addSchema(schema.replace(/E.*$/, 'E'), arity) + addSchema(schema.replace(/E/, 'Z'), arity) + if (schema.length === 1) addSchema('', arity) + } + }) + let matching = arity[args.length] + if (!matching) { + throw wrongNumberOfArgs(Object.keys(arity), args.length) + } + for (let ii = 0; ii < args.length; ++ii) { + let newMatching = matching.filter(schema => { + const type = schema[ii] + const typeCheck = types[type].check + return typeCheck(args[ii]) + }) + if (!newMatching.length) { + const labels = matching.map(_ => types[_[ii]].label).filter(_ => _ != null) + throw invalidType(ii, labels, args[ii]) + } + matching = newMatching + } +} + +function missingRequiredArg (num) { + return newException('EMISSINGARG', 'Missing required argument #' + (num + 1)) +} + +function unknownType (num, type) { + return newException('EUNKNOWNTYPE', 'Unknown type ' + type + ' in argument #' + (num + 1)) +} + +function invalidType (num, expectedTypes, value) { + let valueType + Object.keys(types).forEach(typeCode => { + if (types[typeCode].check(value)) valueType = types[typeCode].label + }) + return newException('EINVALIDTYPE', 'Argument #' + (num + 1) + ': Expected ' + + englishList(expectedTypes) + ' but got ' + valueType) +} + +function englishList (list) { + return list.join(', ').replace(/, ([^,]+)$/, ' or $1') +} + +function wrongNumberOfArgs (expected, got) { + const english = englishList(expected) + const args = expected.every(ex => ex.length === 1) + ? 'argument' + : 'arguments' + return newException('EWRONGARGCOUNT', 'Expected ' + english + ' ' + args + ' but got ' + got) +} + +function moreThanOneError (schema) { + return newException('ETOOMANYERRORTYPES', + 'Only one error type per argument signature is allowed, more than one found in "' + schema + '"') +} + +function newException (code, msg) { + const err = new Error(msg) + err.code = code + /* istanbul ignore else */ + if (Error.captureStackTrace) Error.captureStackTrace(err, validate) + return err +} diff --git a/node_modules/libnpmpublish/node_modules/aproba/package.json b/node_modules/libnpmpublish/node_modules/aproba/package.json new file mode 100644 index 0000000000000..fcaab4f71e3d6 --- /dev/null +++ b/node_modules/libnpmpublish/node_modules/aproba/package.json @@ -0,0 +1,66 @@ +{ + "_args": [ + [ + "aproba@2.0.0", + "/Users/zkat/Documents/code/work/npm" + ] + ], + "_from": "aproba@2.0.0", + "_id": "aproba@2.0.0", + "_inBundle": false, + "_integrity": "sha512-lYe4Gx7QT+MKGbDsA+Z+he/Wtef0BiwDOlK/XkBrdfsh9J/jPPXbX0tE9x9cl27Tmu5gg3QUbUrQYa/y+KOHPQ==", + "_location": "/libnpmpublish/aproba", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "aproba@2.0.0", + "name": "aproba", + "escapedName": "aproba", + "rawSpec": "2.0.0", + "saveSpec": null, + "fetchSpec": "2.0.0" + }, + "_requiredBy": [ + "/libnpmpublish" + ], + "_resolved": "https://registry.npmjs.org/aproba/-/aproba-2.0.0.tgz", + "_spec": "2.0.0", + "_where": "/Users/zkat/Documents/code/work/npm", + "author": { + "name": "Rebecca Turner", + "email": "me@re-becca.org" + }, + "bugs": { + "url": "https://github.com/iarna/aproba/issues" + }, + "dependencies": {}, + "description": "A ridiculously light-weight argument validator (now browser friendly)", + "devDependencies": { + "standard": "^11.0.1", + "tap": "^12.0.1" + }, + "directories": { + "test": "test" + }, + "files": [ + "index.js" + ], + "homepage": "https://github.com/iarna/aproba", + "keywords": [ + "argument", + "validate" + ], + "license": "ISC", + "main": "index.js", + "name": "aproba", + "repository": { + "type": "git", + "url": "git+https://github.com/iarna/aproba.git" + }, + "scripts": { + "pretest": "standard", + "test": "tap --100 -J test/*.js" + }, + "version": "2.0.0" +} diff --git a/node_modules/libnpmpublish/package.json b/node_modules/libnpmpublish/package.json new file mode 100644 index 0000000000000..ab2817778410b --- /dev/null +++ b/node_modules/libnpmpublish/package.json @@ -0,0 +1,76 @@ +{ + "_args": [ + [ + "libnpmpublish@1.1.0", + "/Users/zkat/Documents/code/work/npm" + ] + ], + "_from": "libnpmpublish@1.1.0", + "_id": "libnpmpublish@1.1.0", + "_inBundle": false, + "_integrity": "sha512-mQ3LT2EWlpJ6Q8mgHTNqarQVCgcY32l6xadPVPMcjWLtVLz7II4WlWkzlbYg1nHGAf+xyABDwS+3aNUiRLkyaA==", + "_location": "/libnpmpublish", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "libnpmpublish@1.1.0", + "name": "libnpmpublish", + "escapedName": "libnpmpublish", + "rawSpec": "1.1.0", + "saveSpec": null, + "fetchSpec": "1.1.0" + }, + "_requiredBy": [ + "/libnpm" + ], + "_resolved": "https://registry.npmjs.org/libnpmpublish/-/libnpmpublish-1.1.0.tgz", + "_spec": "1.1.0", + "_where": "/Users/zkat/Documents/code/work/npm", + "author": { + "name": "Kat Marchán", + "email": "kzm@zkat.tech" + }, + "bugs": { + "url": "https://github.com/npm/libnpmpublish/issues" + }, + "dependencies": { + "aproba": "^2.0.0", + "figgy-pudding": "^3.5.1", + "get-stream": "^4.0.0", + "lodash.clonedeep": "^4.5.0", + "normalize-package-data": "^2.4.0", + "npm-package-arg": "^6.1.0", + "npm-registry-fetch": "^3.8.0", + "semver": "^5.5.1", + "ssri": "^6.0.1" + }, + "description": "Programmatic API for the bits behind npm publish and unpublish", + "devDependencies": { + "bluebird": "^3.5.1", + "nock": "^9.6.1", + "standard": "*", + "standard-version": "*", + "tap": "*", + "tar-stream": "^1.6.1", + "weallbehave": "*", + "weallcontribute": "*" + }, + "homepage": "https://npmjs.com/package/libnpmpublish", + "license": "ISC", + "name": "libnpmpublish", + "repository": { + "type": "git", + "url": "git+https://github.com/npm/libnpmpublish.git" + }, + "scripts": { + "postrelease": "npm publish && git push --follow-tags", + "prerelease": "npm t", + "pretest": "standard", + "release": "standard-version -s", + "test": "tap -J --100 test/*.js", + "update-coc": "weallbehave -o . && git add CODE_OF_CONDUCT.md && git commit -m 'docs(coc): updated CODE_OF_CONDUCT.md'", + "update-contrib": "weallcontribute -o . && git add CONTRIBUTING.md && git commit -m 'docs(contributing): updated CONTRIBUTING.md'" + }, + "version": "1.1.0" +} diff --git a/node_modules/libnpmpublish/publish.js b/node_modules/libnpmpublish/publish.js new file mode 100644 index 0000000000000..22e94b17e8f0b --- /dev/null +++ b/node_modules/libnpmpublish/publish.js @@ -0,0 +1,218 @@ +'use strict' + +const cloneDeep = require('lodash.clonedeep') +const figgyPudding = require('figgy-pudding') +const { fixer } = require('normalize-package-data') +const getStream = require('get-stream') +const npa = require('npm-package-arg') +const npmAuth = require('npm-registry-fetch/auth.js') +const npmFetch = require('npm-registry-fetch') +const semver = require('semver') +const ssri = require('ssri') +const url = require('url') +const validate = require('aproba') + +const PublishConfig = figgyPudding({ + access: {}, + algorithms: { default: ['sha512'] }, + npmVersion: {}, + tag: { default: 'latest' }, + Promise: { default: () => Promise } +}) + +module.exports = publish +function publish (manifest, tarball, opts) { + opts = PublishConfig(opts) + return new opts.Promise(resolve => resolve()).then(() => { + validate('OSO|OOO', [manifest, tarball, opts]) + if (manifest.private) { + throw Object.assign(new Error( + 'This package has been marked as private\n' + + "Remove the 'private' field from the package.json to publish it." + ), { code: 'EPRIVATE' }) + } + const spec = npa.resolve(manifest.name, manifest.version) + // NOTE: spec is used to pick the appropriate registry/auth combo. + opts = opts.concat(manifest.publishConfig, { spec }) + const reg = npmFetch.pickRegistry(spec, opts) + const auth = npmAuth(reg, opts) + const pubManifest = patchedManifest(spec, auth, manifest, opts) + + // registry-frontdoor cares about the access level, which is only + // configurable for scoped packages + if (!spec.scope && opts.access === 'restricted') { + throw Object.assign( + new Error("Can't restrict access to unscoped packages."), + { code: 'EUNSCOPED' } + ) + } + + return slurpTarball(tarball, opts).then(tardata => { + const metadata = buildMetadata( + spec, auth, reg, pubManifest, tardata, opts + ) + return npmFetch(spec.escapedName, opts.concat({ + method: 'PUT', + body: metadata, + ignoreBody: true + })).catch(err => { + if (err.code !== 'E409') { throw err } + return npmFetch.json(spec.escapedName, opts.concat({ + query: { write: true } + })).then( + current => patchMetadata(current, metadata, opts) + ).then(newMetadata => { + return npmFetch(spec.escapedName, opts.concat({ + method: 'PUT', + body: newMetadata, + ignoreBody: true + })) + }) + }) + }) + }).then(() => true) +} + +function patchedManifest (spec, auth, base, opts) { + const manifest = cloneDeep(base) + manifest._nodeVersion = process.versions.node + if (opts.npmVersion) { + manifest._npmVersion = opts.npmVersion + } + if (auth.username || auth.email) { + // NOTE: This is basically pointless, but reproduced because it's what + // legacy does: tl;dr `auth.username` and `auth.email` are going to be + // undefined in any auth situation that uses tokens instead of plain + // auth. I can only assume some registries out there decided that + // _npmUser would be of any use to them, but _npmUser in packuments + // currently gets filled in by the npm registry itself, based on auth + // information. + manifest._npmUser = { + username: auth.username, + email: auth.email + } + } + + fixer.fixNameField(manifest, { strict: true, allowLegacyCase: true }) + const version = semver.clean(manifest.version) + if (!version) { + throw Object.assign( + new Error('invalid semver: ' + manifest.version), + { code: 'EBADSEMVER' } + ) + } + manifest.version = version + return manifest +} + +function buildMetadata (spec, auth, registry, manifest, tardata, opts) { + const root = { + _id: manifest.name, + name: manifest.name, + description: manifest.description, + 'dist-tags': {}, + versions: {}, + readme: manifest.readme || '' + } + + if (opts.access) root.access = opts.access + + if (!auth.token) { + root.maintainers = [{ name: auth.username, email: auth.email }] + manifest.maintainers = JSON.parse(JSON.stringify(root.maintainers)) + } + + root.versions[ manifest.version ] = manifest + const tag = manifest.tag || opts.tag + root['dist-tags'][tag] = manifest.version + + const tbName = manifest.name + '-' + manifest.version + '.tgz' + const tbURI = manifest.name + '/-/' + tbName + const integrity = ssri.fromData(tardata, { + algorithms: [...new Set(['sha1'].concat(opts.algorithms))] + }) + + manifest._id = manifest.name + '@' + manifest.version + manifest.dist = manifest.dist || {} + // Don't bother having sha1 in the actual integrity field + manifest.dist.integrity = integrity['sha512'][0].toString() + // Legacy shasum support + manifest.dist.shasum = integrity['sha1'][0].hexDigest() + manifest.dist.tarball = url.resolve(registry, tbURI) + .replace(/^https:\/\//, 'http://') + + root._attachments = {} + root._attachments[ tbName ] = { + 'content_type': 'application/octet-stream', + 'data': tardata.toString('base64'), + 'length': tardata.length + } + + return root +} + +function patchMetadata (current, newData, opts) { + const curVers = Object.keys(current.versions || {}).map(v => { + return semver.clean(v, true) + }).concat(Object.keys(current.time || {}).map(v => { + if (semver.valid(v, true)) { return semver.clean(v, true) } + })).filter(v => v) + + const newVersion = Object.keys(newData.versions)[0] + + if (curVers.indexOf(newVersion) !== -1) { + throw ConflictError(newData.name, newData.version) + } + + current.versions = current.versions || {} + current.versions[newVersion] = newData.versions[newVersion] + for (var i in newData) { + switch (i) { + // objects that copy over the new stuffs + case 'dist-tags': + case 'versions': + case '_attachments': + for (var j in newData[i]) { + current[i] = current[i] || {} + current[i][j] = newData[i][j] + } + break + + // ignore these + case 'maintainers': + break + + // copy + default: + current[i] = newData[i] + } + } + const maint = newData.maintainers && JSON.parse(JSON.stringify(newData.maintainers)) + newData.versions[newVersion].maintainers = maint + return current +} + +function slurpTarball (tarSrc, opts) { + if (Buffer.isBuffer(tarSrc)) { + return opts.Promise.resolve(tarSrc) + } else if (typeof tarSrc === 'string') { + return opts.Promise.resolve(Buffer.from(tarSrc, 'base64')) + } else if (typeof tarSrc.pipe === 'function') { + return getStream.buffer(tarSrc) + } else { + return opts.Promise.reject(Object.assign( + new Error('invalid tarball argument. Must be a Buffer, a base64 string, or a binary stream'), { + code: 'EBADTAR' + })) + } +} + +function ConflictError (pkgid, version) { + return Object.assign(new Error( + `Cannot publish ${pkgid}@${version} over existing version.` + ), { + code: 'EPUBLISHCONFLICT', + pkgid, + version + }) +} diff --git a/node_modules/libnpmpublish/test/publish.js b/node_modules/libnpmpublish/test/publish.js new file mode 100644 index 0000000000000..1fe6892be24af --- /dev/null +++ b/node_modules/libnpmpublish/test/publish.js @@ -0,0 +1,919 @@ +'use strict' + +const crypto = require('crypto') +const cloneDeep = require('lodash.clonedeep') +const figgyPudding = require('figgy-pudding') +const mockTar = require('./util/mock-tarball.js') +const { PassThrough } = require('stream') +const ssri = require('ssri') +const { test } = require('tap') +const tnock = require('./util/tnock.js') + +const publish = require('../publish.js') + +const OPTS = figgyPudding({ registry: {} })({ + registry: 'https://mock.reg/' +}) + +const REG = OPTS.registry + +test('basic publish', t => { + const manifest = { + name: 'libnpmpublish', + version: '1.0.0', + description: 'some stuff' + } + return mockTar({ + 'package.json': JSON.stringify(manifest), + 'index.js': 'console.log("hello world")' + }).then(tarData => { + const shasum = crypto.createHash('sha1').update(tarData).digest('hex') + const integrity = ssri.fromData(tarData, { algorithms: ['sha512'] }) + const packument = { + name: 'libnpmpublish', + description: 'some stuff', + readme: '', + _id: 'libnpmpublish', + 'dist-tags': { + latest: '1.0.0' + }, + versions: { + '1.0.0': { + _id: 'libnpmpublish@1.0.0', + _nodeVersion: process.versions.node, + name: 'libnpmpublish', + version: '1.0.0', + description: 'some stuff', + dist: { + shasum, + integrity: integrity.toString(), + tarball: `http://mock.reg/libnpmpublish/-/libnpmpublish-1.0.0.tgz` + } + } + }, + _attachments: { + 'libnpmpublish-1.0.0.tgz': { + 'content_type': 'application/octet-stream', + data: tarData.toString('base64'), + length: tarData.length + } + } + } + const srv = tnock(t, REG) + srv.put('/libnpmpublish', body => { + t.deepEqual(body, packument, 'posted packument matches expectations') + return true + }, { + authorization: 'Bearer deadbeef' + }).reply(201, {}) + + return publish(manifest, tarData, OPTS.concat({ + token: 'deadbeef' + })).then(ret => { + t.ok(ret, 'publish succeeded') + }) + }) +}) + +test('scoped publish', t => { + const manifest = { + name: '@zkat/libnpmpublish', + version: '1.0.0', + description: 'some stuff' + } + return mockTar({ + 'package.json': JSON.stringify(manifest), + 'index.js': 'console.log("hello world")' + }).then(tarData => { + const shasum = crypto.createHash('sha1').update(tarData).digest('hex') + const integrity = ssri.fromData(tarData, { algorithms: ['sha512'] }) + const packument = { + name: '@zkat/libnpmpublish', + description: 'some stuff', + readme: '', + _id: '@zkat/libnpmpublish', + 'dist-tags': { + latest: '1.0.0' + }, + versions: { + '1.0.0': { + _id: '@zkat/libnpmpublish@1.0.0', + _nodeVersion: process.versions.node, + _npmVersion: '6.9.0', + name: '@zkat/libnpmpublish', + version: '1.0.0', + description: 'some stuff', + dist: { + shasum, + integrity: integrity.toString(), + tarball: `http://mock.reg/@zkat/libnpmpublish/-/@zkat/libnpmpublish-1.0.0.tgz` + } + } + }, + _attachments: { + '@zkat/libnpmpublish-1.0.0.tgz': { + 'content_type': 'application/octet-stream', + data: tarData.toString('base64'), + length: tarData.length + } + } + } + const srv = tnock(t, REG) + srv.put('/@zkat%2flibnpmpublish', body => { + t.deepEqual(body, packument, 'posted packument matches expectations') + return true + }, { + authorization: 'Bearer deadbeef' + }).reply(201, {}) + + return publish(manifest, tarData, OPTS.concat({ + npmVersion: '6.9.0', + token: 'deadbeef' + })).then(() => { + t.ok(true, 'publish succeeded') + }) + }) +}) + +test('retry after a conflict', t => { + const REV = '72-47f2986bfd8e8b55068b204588bbf484' + const manifest = { + name: 'libnpmpublish', + version: '1.0.0', + description: 'some stuff' + } + return mockTar({ + 'package.json': JSON.stringify(manifest), + 'index.js': 'console.log("hello world")' + }).then(tarData => { + const shasum = crypto.createHash('sha1').update(tarData).digest('hex') + const integrity = ssri.fromData(tarData, { algorithms: ['sha512'] }) + const basePackument = { + name: 'libnpmpublish', + description: 'some stuff', + readme: '', + _id: 'libnpmpublish', + 'dist-tags': {}, + versions: {}, + _attachments: {} + } + const currentPackument = cloneDeep(Object.assign({}, basePackument, { + time: { + modified: new Date().toISOString(), + created: new Date().toISOString(), + '1.0.1': new Date().toISOString() + }, + 'dist-tags': { latest: '1.0.1' }, + maintainers: [{ name: 'zkat', email: 'idk@idk.tech' }], + versions: { + '1.0.1': { + _id: 'libnpmpublish@1.0.1', + _nodeVersion: process.versions.node, + _npmVersion: '6.9.0', + name: 'libnpmpublish', + version: '1.0.1', + description: 'some stuff', + dist: { + shasum, + integrity: integrity.toString(), + tarball: `http://mock.reg/libnpmpublish/-/libnpmpublish-1.0.1.tgz` + } + } + }, + _attachments: { + 'libnpmpublish-1.0.1.tgz': { + 'content_type': 'application/octet-stream', + data: tarData.toString('base64'), + length: tarData.length + } + } + })) + const newPackument = cloneDeep(Object.assign({}, basePackument, { + 'dist-tags': { latest: '1.0.0' }, + maintainers: [{ name: 'other', email: 'other@idk.tech' }], + versions: { + '1.0.0': { + _id: 'libnpmpublish@1.0.0', + _nodeVersion: process.versions.node, + _npmVersion: '6.9.0', + _npmUser: { + username: 'other', + email: 'other@idk.tech' + }, + name: 'libnpmpublish', + version: '1.0.0', + description: 'some stuff', + maintainers: [{ name: 'other', email: 'other@idk.tech' }], + dist: { + shasum, + integrity: integrity.toString(), + tarball: `http://mock.reg/libnpmpublish/-/libnpmpublish-1.0.0.tgz` + } + } + }, + _attachments: { + 'libnpmpublish-1.0.0.tgz': { + 'content_type': 'application/octet-stream', + data: tarData.toString('base64'), + length: tarData.length + } + } + })) + const mergedPackument = cloneDeep(Object.assign({}, basePackument, { + time: currentPackument.time, + 'dist-tags': { latest: '1.0.0' }, + maintainers: currentPackument.maintainers, + versions: Object.assign({}, currentPackument.versions, newPackument.versions), + _attachments: Object.assign({}, currentPackument._attachments, newPackument._attachments) + })) + const srv = tnock(t, REG) + srv.put('/libnpmpublish', body => { + t.notOk(body._rev, 'no _rev in initial post') + t.deepEqual(body, newPackument, 'got conflicting packument') + return true + }).reply(409, { error: 'gimme _rev plz' }) + srv.get('/libnpmpublish?write=true').reply(200, Object.assign({ + _rev: REV + }, currentPackument)) + srv.put('/libnpmpublish', body => { + t.deepEqual(body, Object.assign({ + _rev: REV + }, mergedPackument), 'posted packument includes _rev and a merged version') + return true + }).reply(201, {}) + return publish(manifest, tarData, OPTS.concat({ + npmVersion: '6.9.0', + username: 'other', + email: 'other@idk.tech' + })).then(() => { + t.ok(true, 'publish succeeded') + }) + }) +}) + +test('retry after a conflict -- no versions on remote', t => { + const REV = '72-47f2986bfd8e8b55068b204588bbf484' + const manifest = { + name: 'libnpmpublish', + version: '1.0.0', + description: 'some stuff' + } + return mockTar({ + 'package.json': JSON.stringify(manifest), + 'index.js': 'console.log("hello world")' + }).then(tarData => { + const shasum = crypto.createHash('sha1').update(tarData).digest('hex') + const integrity = ssri.fromData(tarData, { algorithms: ['sha512'] }) + const basePackument = { + name: 'libnpmpublish', + description: 'some stuff', + readme: '', + _id: 'libnpmpublish' + } + const currentPackument = cloneDeep(Object.assign({}, basePackument, { + maintainers: [{ name: 'zkat', email: 'idk@idk.tech' }] + })) + const newPackument = cloneDeep(Object.assign({}, basePackument, { + 'dist-tags': { latest: '1.0.0' }, + maintainers: [{ name: 'other', email: 'other@idk.tech' }], + versions: { + '1.0.0': { + _id: 'libnpmpublish@1.0.0', + _nodeVersion: process.versions.node, + _npmVersion: '6.9.0', + _npmUser: { + username: 'other', + email: 'other@idk.tech' + }, + name: 'libnpmpublish', + version: '1.0.0', + description: 'some stuff', + maintainers: [{ name: 'other', email: 'other@idk.tech' }], + dist: { + shasum, + integrity: integrity.toString(), + tarball: `http://mock.reg/libnpmpublish/-/libnpmpublish-1.0.0.tgz` + } + } + }, + _attachments: { + 'libnpmpublish-1.0.0.tgz': { + 'content_type': 'application/octet-stream', + data: tarData.toString('base64'), + length: tarData.length + } + } + })) + const mergedPackument = cloneDeep(Object.assign({}, basePackument, { + 'dist-tags': { latest: '1.0.0' }, + maintainers: currentPackument.maintainers, + versions: Object.assign({}, currentPackument.versions, newPackument.versions), + _attachments: Object.assign({}, currentPackument._attachments, newPackument._attachments) + })) + const srv = tnock(t, REG) + srv.put('/libnpmpublish', body => { + t.notOk(body._rev, 'no _rev in initial post') + t.deepEqual(body, newPackument, 'got conflicting packument') + return true + }).reply(409, { error: 'gimme _rev plz' }) + srv.get('/libnpmpublish?write=true').reply(200, Object.assign({ + _rev: REV + }, currentPackument)) + srv.put('/libnpmpublish', body => { + t.deepEqual(body, Object.assign({ + _rev: REV + }, mergedPackument), 'posted packument includes _rev and a merged version') + return true + }).reply(201, {}) + return publish(manifest, tarData, OPTS.concat({ + npmVersion: '6.9.0', + username: 'other', + email: 'other@idk.tech' + })).then(() => { + t.ok(true, 'publish succeeded') + }) + }) +}) +test('version conflict', t => { + const REV = '72-47f2986bfd8e8b55068b204588bbf484' + const manifest = { + name: 'libnpmpublish', + version: '1.0.0', + description: 'some stuff' + } + return mockTar({ + 'package.json': JSON.stringify(manifest), + 'index.js': 'console.log("hello world")' + }).then(tarData => { + const shasum = crypto.createHash('sha1').update(tarData).digest('hex') + const integrity = ssri.fromData(tarData, { algorithms: ['sha512'] }) + const basePackument = { + name: 'libnpmpublish', + description: 'some stuff', + readme: '', + _id: 'libnpmpublish', + 'dist-tags': {}, + versions: {}, + _attachments: {} + } + const newPackument = cloneDeep(Object.assign({}, basePackument, { + 'dist-tags': { latest: '1.0.0' }, + versions: { + '1.0.0': { + _id: 'libnpmpublish@1.0.0', + _nodeVersion: process.versions.node, + _npmVersion: '6.9.0', + name: 'libnpmpublish', + version: '1.0.0', + description: 'some stuff', + dist: { + shasum, + integrity: integrity.toString(), + tarball: `http://mock.reg/libnpmpublish/-/libnpmpublish-1.0.0.tgz` + } + } + }, + _attachments: { + 'libnpmpublish-1.0.0.tgz': { + 'content_type': 'application/octet-stream', + data: tarData.toString('base64'), + length: tarData.length + } + } + })) + const srv = tnock(t, REG) + srv.put('/libnpmpublish', body => { + t.notOk(body._rev, 'no _rev in initial post') + t.deepEqual(body, newPackument, 'got conflicting packument') + return true + }).reply(409, { error: 'gimme _rev plz' }) + srv.get('/libnpmpublish?write=true').reply(200, Object.assign({ + _rev: REV + }, newPackument)) + return publish(manifest, tarData, OPTS.concat({ + npmVersion: '6.9.0', + token: 'deadbeef' + })).then( + () => { throw new Error('should not succeed') }, + err => { + t.equal(err.code, 'EPUBLISHCONFLICT', 'got publish conflict code') + } + ) + }) +}) + +test('publish with basic auth', t => { + const manifest = { + name: 'libnpmpublish', + version: '1.0.0', + description: 'some stuff' + } + return mockTar({ + 'package.json': JSON.stringify(manifest), + 'index.js': 'console.log("hello world")' + }).then(tarData => { + const shasum = crypto.createHash('sha1').update(tarData).digest('hex') + const integrity = ssri.fromData(tarData, { algorithms: ['sha512'] }) + const packument = { + name: 'libnpmpublish', + description: 'some stuff', + readme: '', + _id: 'libnpmpublish', + 'dist-tags': { + latest: '1.0.0' + }, + maintainers: [{ + name: 'zkat', + email: 'kat@example.tech' + }], + versions: { + '1.0.0': { + _id: 'libnpmpublish@1.0.0', + _nodeVersion: process.versions.node, + _npmVersion: '6.9.0', + _npmUser: { + username: 'zkat', + email: 'kat@example.tech' + }, + maintainers: [{ + name: 'zkat', + email: 'kat@example.tech' + }], + name: 'libnpmpublish', + version: '1.0.0', + description: 'some stuff', + dist: { + shasum, + integrity: integrity.toString(), + tarball: `http://mock.reg/libnpmpublish/-/libnpmpublish-1.0.0.tgz` + } + } + }, + _attachments: { + 'libnpmpublish-1.0.0.tgz': { + 'content_type': 'application/octet-stream', + data: tarData.toString('base64'), + length: tarData.length + } + } + } + const srv = tnock(t, REG) + srv.put('/libnpmpublish', body => { + t.deepEqual(body, packument, 'posted packument matches expectations') + return true + }, { + authorization: /^Basic / + }).reply(201, {}) + + return publish(manifest, tarData, OPTS.concat({ + npmVersion: '6.9.0', + username: 'zkat', + email: 'kat@example.tech' + })).then(() => { + t.ok(true, 'publish succeeded') + }) + }) +}) + +test('publish base64 string', t => { + const manifest = { + name: 'libnpmpublish', + version: '1.0.0', + description: 'some stuff' + } + return mockTar({ + 'package.json': JSON.stringify(manifest), + 'index.js': 'console.log("hello world")' + }).then(tarData => { + const shasum = crypto.createHash('sha1').update(tarData).digest('hex') + const integrity = ssri.fromData(tarData, { algorithms: ['sha512'] }) + const packument = { + name: 'libnpmpublish', + description: 'some stuff', + readme: '', + _id: 'libnpmpublish', + 'dist-tags': { + latest: '1.0.0' + }, + versions: { + '1.0.0': { + _id: 'libnpmpublish@1.0.0', + _nodeVersion: process.versions.node, + _npmVersion: '6.9.0', + name: 'libnpmpublish', + version: '1.0.0', + description: 'some stuff', + dist: { + shasum, + integrity: integrity.toString(), + tarball: `http://mock.reg/libnpmpublish/-/libnpmpublish-1.0.0.tgz` + } + } + }, + _attachments: { + 'libnpmpublish-1.0.0.tgz': { + 'content_type': 'application/octet-stream', + data: tarData.toString('base64'), + length: tarData.length + } + } + } + const srv = tnock(t, REG) + srv.put('/libnpmpublish', body => { + t.deepEqual(body, packument, 'posted packument matches expectations') + return true + }, { + authorization: 'Bearer deadbeef' + }).reply(201, {}) + + return publish(manifest, tarData.toString('base64'), OPTS.concat({ + npmVersion: '6.9.0', + token: 'deadbeef' + })).then(() => { + t.ok(true, 'publish succeeded') + }) + }) +}) + +test('publish tar stream', t => { + const manifest = { + name: 'libnpmpublish', + version: '1.0.0', + description: 'some stuff' + } + return mockTar({ + 'package.json': JSON.stringify(manifest), + 'index.js': 'console.log("hello world")' + }).then(tarData => { + const shasum = crypto.createHash('sha1').update(tarData).digest('hex') + const integrity = ssri.fromData(tarData, { algorithms: ['sha512'] }) + const packument = { + name: 'libnpmpublish', + description: 'some stuff', + readme: '', + _id: 'libnpmpublish', + 'dist-tags': { + latest: '1.0.0' + }, + versions: { + '1.0.0': { + _id: 'libnpmpublish@1.0.0', + _nodeVersion: process.versions.node, + _npmVersion: '6.9.0', + name: 'libnpmpublish', + version: '1.0.0', + description: 'some stuff', + dist: { + shasum, + integrity: integrity.toString(), + tarball: `http://mock.reg/libnpmpublish/-/libnpmpublish-1.0.0.tgz` + } + } + }, + _attachments: { + 'libnpmpublish-1.0.0.tgz': { + 'content_type': 'application/octet-stream', + data: tarData.toString('base64'), + length: tarData.length + } + } + } + const srv = tnock(t, REG) + srv.put('/libnpmpublish', body => { + t.deepEqual(body, packument, 'posted packument matches expectations') + return true + }, { + authorization: 'Bearer deadbeef' + }).reply(201, {}) + + const stream = new PassThrough() + setTimeout(() => stream.end(tarData), 0) + return publish(manifest, stream, OPTS.concat({ + npmVersion: '6.9.0', + token: 'deadbeef' + })).then(() => { + t.ok(true, 'publish succeeded') + }) + }) +}) + +test('refuse if package marked private', t => { + const manifest = { + name: 'libnpmpublish', + version: '1.0.0', + description: 'some stuff', + private: true + } + return mockTar({ + 'package.json': JSON.stringify(manifest), + 'index.js': 'console.log("hello world")' + }).then(tarData => { + return publish(manifest, tarData, OPTS.concat({ + npmVersion: '6.9.0', + token: 'deadbeef' + })).then( + () => { throw new Error('should not have succeeded') }, + err => { + t.equal(err.code, 'EPRIVATE', 'got correct error code') + } + ) + }) +}) + +test('publish includes access', t => { + const manifest = { + name: 'libnpmpublish', + version: '1.0.0', + description: 'some stuff' + } + return mockTar({ + 'package.json': JSON.stringify(manifest), + 'index.js': 'console.log("hello world")' + }).then(tarData => { + const shasum = crypto.createHash('sha1').update(tarData).digest('hex') + const integrity = ssri.fromData(tarData, { algorithms: ['sha512'] }) + const packument = { + name: 'libnpmpublish', + description: 'some stuff', + readme: '', + access: 'public', + _id: 'libnpmpublish', + 'dist-tags': { + latest: '1.0.0' + }, + versions: { + '1.0.0': { + _id: 'libnpmpublish@1.0.0', + _nodeVersion: process.versions.node, + name: 'libnpmpublish', + version: '1.0.0', + description: 'some stuff', + dist: { + shasum, + integrity: integrity.toString(), + tarball: `http://mock.reg/libnpmpublish/-/libnpmpublish-1.0.0.tgz` + } + } + }, + _attachments: { + 'libnpmpublish-1.0.0.tgz': { + 'content_type': 'application/octet-stream', + data: tarData.toString('base64'), + length: tarData.length + } + } + } + const srv = tnock(t, REG) + srv.put('/libnpmpublish', body => { + t.deepEqual(body, packument, 'posted packument matches expectations') + return true + }, { + authorization: 'Bearer deadbeef' + }).reply(201, {}) + + return publish(manifest, tarData, OPTS.concat({ + token: 'deadbeef', + access: 'public' + })).then(() => { + t.ok(true, 'publish succeeded') + }) + }) +}) + +test('refuse if package is unscoped plus `restricted` access', t => { + const manifest = { + name: 'libnpmpublish', + version: '1.0.0', + description: 'some stuff' + } + return mockTar({ + 'package.json': JSON.stringify(manifest), + 'index.js': 'console.log("hello world")' + }).then(tarData => { + return publish(manifest, tarData, OPTS.concat({ + npmVersion: '6.9.0', + access: 'restricted' + })).then( + () => { throw new Error('should not have succeeded') }, + err => { + t.equal(err.code, 'EUNSCOPED', 'got correct error code') + } + ) + }) +}) + +test('refuse if tarball is wrong type', t => { + const manifest = { + name: 'libnpmpublish', + version: '1.0.0', + description: 'some stuff' + } + return publish(manifest, { data: 42 }, OPTS.concat({ + npmVersion: '6.9.0', + token: 'deadbeef' + })).then( + () => { throw new Error('should not have succeeded') }, + err => { + t.equal(err.code, 'EBADTAR', 'got correct error code') + } + ) +}) + +test('refuse if bad semver on manifest', t => { + const manifest = { + name: 'libnpmpublish', + version: 'lmao', + description: 'some stuff' + } + return publish(manifest, 'deadbeef', OPTS).then( + () => { throw new Error('should not have succeeded') }, + err => { + t.equal(err.code, 'EBADSEMVER', 'got correct error code') + } + ) +}) + +test('other error code', t => { + const manifest = { + name: 'libnpmpublish', + version: '1.0.0', + description: 'some stuff' + } + return mockTar({ + 'package.json': JSON.stringify(manifest), + 'index.js': 'console.log("hello world")' + }).then(tarData => { + const shasum = crypto.createHash('sha1').update(tarData).digest('hex') + const integrity = ssri.fromData(tarData, { algorithms: ['sha512'] }) + const packument = { + name: 'libnpmpublish', + description: 'some stuff', + readme: '', + _id: 'libnpmpublish', + 'dist-tags': { + latest: '1.0.0' + }, + versions: { + '1.0.0': { + _id: 'libnpmpublish@1.0.0', + _nodeVersion: process.versions.node, + _npmVersion: '6.9.0', + name: 'libnpmpublish', + version: '1.0.0', + description: 'some stuff', + dist: { + shasum, + integrity: integrity.toString(), + tarball: `http://mock.reg/libnpmpublish/-/libnpmpublish-1.0.0.tgz` + } + } + }, + _attachments: { + 'libnpmpublish-1.0.0.tgz': { + 'content_type': 'application/octet-stream', + data: tarData.toString('base64'), + length: tarData.length + } + } + } + const srv = tnock(t, REG) + srv.put('/libnpmpublish', body => { + t.deepEqual(body, packument, 'posted packument matches expectations') + return true + }, { + authorization: 'Bearer deadbeef' + }).reply(500, { error: 'go away' }) + + return publish(manifest, tarData, OPTS.concat({ + npmVersion: '6.9.0', + token: 'deadbeef' + })).then( + () => { throw new Error('should not succeed') }, + err => { + t.match(err.message, /go away/, 'no retry on non-409') + } + ) + }) +}) + +test('publish includes access', t => { + const manifest = { + name: 'libnpmpublish', + version: '1.0.0', + description: 'some stuff' + } + return mockTar({ + 'package.json': JSON.stringify(manifest), + 'index.js': 'console.log("hello world")' + }).then(tarData => { + const shasum = crypto.createHash('sha1').update(tarData).digest('hex') + const integrity = ssri.fromData(tarData, { algorithms: ['sha512'] }) + const packument = { + name: 'libnpmpublish', + description: 'some stuff', + readme: '', + access: 'public', + _id: 'libnpmpublish', + 'dist-tags': { + latest: '1.0.0' + }, + versions: { + '1.0.0': { + _id: 'libnpmpublish@1.0.0', + _nodeVersion: process.versions.node, + name: 'libnpmpublish', + version: '1.0.0', + description: 'some stuff', + dist: { + shasum, + integrity: integrity.toString(), + tarball: `http://mock.reg/libnpmpublish/-/libnpmpublish-1.0.0.tgz` + } + } + }, + _attachments: { + 'libnpmpublish-1.0.0.tgz': { + 'content_type': 'application/octet-stream', + data: tarData.toString('base64'), + length: tarData.length + } + } + } + const srv = tnock(t, REG) + srv.put('/libnpmpublish', body => { + t.deepEqual(body, packument, 'posted packument matches expectations') + return true + }, { + authorization: 'Bearer deadbeef' + }).reply(201, {}) + + return publish(manifest, tarData, OPTS.concat({ + token: 'deadbeef', + access: 'public' + })).then(() => { + t.ok(true, 'publish succeeded') + }) + }) +}) + +test('publishConfig on manifest', t => { + const manifest = { + name: 'libnpmpublish', + version: '1.0.0', + description: 'some stuff', + publishConfig: { + registry: REG + } + } + return mockTar({ + 'package.json': JSON.stringify(manifest), + 'index.js': 'console.log("hello world")' + }).then(tarData => { + const shasum = crypto.createHash('sha1').update(tarData).digest('hex') + const integrity = ssri.fromData(tarData, { algorithms: ['sha512'] }) + const packument = { + name: 'libnpmpublish', + description: 'some stuff', + readme: '', + _id: 'libnpmpublish', + 'dist-tags': { + latest: '1.0.0' + }, + versions: { + '1.0.0': { + _id: 'libnpmpublish@1.0.0', + _nodeVersion: process.versions.node, + name: 'libnpmpublish', + version: '1.0.0', + description: 'some stuff', + dist: { + shasum, + integrity: integrity.toString(), + tarball: `http://mock.reg/libnpmpublish/-/libnpmpublish-1.0.0.tgz` + }, + publishConfig: { + registry: REG + } + } + }, + _attachments: { + 'libnpmpublish-1.0.0.tgz': { + 'content_type': 'application/octet-stream', + data: tarData.toString('base64'), + length: tarData.length + } + } + } + const srv = tnock(t, REG) + srv.put('/libnpmpublish', body => { + t.deepEqual(body, packument, 'posted packument matches expectations') + return true + }, { + authorization: 'Bearer deadbeef' + }).reply(201, {}) + + return publish(manifest, tarData, { token: 'deadbeef' }).then(ret => { + t.ok(ret, 'publish succeeded') + }) + }) +}) diff --git a/node_modules/libnpmpublish/test/unpublish.js b/node_modules/libnpmpublish/test/unpublish.js new file mode 100644 index 0000000000000..19ac464a3b732 --- /dev/null +++ b/node_modules/libnpmpublish/test/unpublish.js @@ -0,0 +1,249 @@ +'use strict' + +const figgyPudding = require('figgy-pudding') +const test = require('tap').test +const tnock = require('./util/tnock.js') + +const OPTS = figgyPudding({ registry: {} })({ + registry: 'https://mock.reg/' +}) + +const REG = OPTS.registry +const REV = '72-47f2986bfd8e8b55068b204588bbf484' +const unpub = require('../unpublish.js') + +test('basic test', t => { + const doc = { + _id: 'foo', + _rev: REV, + name: 'foo', + 'dist-tags': { + latest: '1.0.0' + }, + versions: { + '1.0.0': { + name: 'foo', + dist: { + tarball: `${REG}/foo/-/foo-1.0.0.tgz` + } + } + } + } + const srv = tnock(t, REG) + srv.get('/foo?write=true').reply(200, doc) + srv.delete(`/foo/-rev/${REV}`).reply(201) + return unpub('foo', OPTS).then(ret => { + t.ok(ret, 'foo was unpublished') + }) +}) + +test('scoped basic test', t => { + const doc = { + _id: '@foo/bar', + _rev: REV, + name: '@foo/bar', + 'dist-tags': { + latest: '1.0.0' + }, + versions: { + '1.0.0': { + name: '@foo/bar', + dist: { + tarball: `${REG}/@foo/bar/-/foo-1.0.0.tgz` + } + } + } + } + const srv = tnock(t, REG) + srv.get('/@foo%2fbar?write=true').reply(200, doc) + srv.delete(`/@foo%2fbar/-rev/${REV}`).reply(201) + return unpub('@foo/bar', OPTS).then(() => { + t.ok(true, 'foo was unpublished') + }) +}) + +test('unpublish specific, last version', t => { + const doc = { + _id: 'foo', + _rev: REV, + name: 'foo', + 'dist-tags': { + latest: '1.0.0' + }, + versions: { + '1.0.0': { + name: 'foo', + dist: { + tarball: `${REG}/foo/-/foo-1.0.0.tgz` + } + } + } + } + const srv = tnock(t, REG) + srv.get('/foo?write=true').reply(200, doc) + srv.delete(`/foo/-rev/${REV}`).reply(201) + return unpub('foo@1.0.0', OPTS).then(() => { + t.ok(true, 'foo was unpublished') + }) +}) + +test('unpublish specific version', t => { + const doc = { + _id: 'foo', + _rev: REV, + _revisions: [1, 2, 3], + _attachments: [1, 2, 3], + name: 'foo', + 'dist-tags': { + latest: '1.0.1' + }, + versions: { + '1.0.0': { + name: 'foo', + dist: { + tarball: `${REG}/foo/-/foo-1.0.0.tgz` + } + }, + '1.0.1': { + name: 'foo', + dist: { + tarball: `${REG}/foo/-/foo-1.0.1.tgz` + } + } + } + } + const postEdit = { + _id: 'foo', + _rev: REV, + name: 'foo', + 'dist-tags': { + latest: '1.0.0' + }, + versions: { + '1.0.0': { + name: 'foo', + dist: { + tarball: `${REG}/foo/-/foo-1.0.0.tgz` + } + } + } + } + + const srv = tnock(t, REG) + srv.get('/foo?write=true').reply(200, doc) + srv.put(`/foo/-rev/${REV}`, postEdit).reply(200) + srv.get('/foo?write=true').reply(200, postEdit) + srv.delete(`/foo/-/foo-1.0.1.tgz/-rev/${REV}`).reply(200) + return unpub('foo@1.0.1', OPTS).then(() => { + t.ok(true, 'foo was unpublished') + }) +}) + +test('404 considered a success', t => { + const srv = tnock(t, REG) + srv.get('/foo?write=true').reply(404) + return unpub('foo', OPTS).then(() => { + t.ok(true, 'foo was unpublished') + }) +}) + +test('non-404 errors', t => { + const srv = tnock(t, REG) + srv.get('/foo?write=true').reply(500) + return unpub('foo', OPTS).then( + () => { throw new Error('should not have succeeded') }, + err => { t.equal(err.code, 'E500', 'got right error from server') } + ) +}) + +test('packument with missing versions unpublishes whole thing', t => { + const doc = { + _id: 'foo', + _rev: REV, + name: 'foo', + 'dist-tags': { + latest: '1.0.0' + } + } + const srv = tnock(t, REG) + srv.get('/foo?write=true').reply(200, doc) + srv.delete(`/foo/-rev/${REV}`).reply(201) + return unpub('foo@1.0.0', OPTS).then(() => { + t.ok(true, 'foo was unpublished') + }) +}) + +test('packument with missing specific version assumed unpublished', t => { + const doc = { + _id: 'foo', + _rev: REV, + name: 'foo', + 'dist-tags': { + latest: '1.0.0' + }, + versions: { + '1.0.0': { + name: 'foo', + dist: { + tarball: `${REG}/foo/-/foo-1.0.0.tgz` + } + } + } + } + const srv = tnock(t, REG) + srv.get('/foo?write=true').reply(200, doc) + return unpub('foo@1.0.1', OPTS).then(() => { + t.ok(true, 'foo was unpublished') + }) +}) + +test('unpublish specific version without dist-tag update', t => { + const doc = { + _id: 'foo', + _rev: REV, + _revisions: [1, 2, 3], + _attachments: [1, 2, 3], + name: 'foo', + 'dist-tags': { + latest: '1.0.0' + }, + versions: { + '1.0.0': { + name: 'foo', + dist: { + tarball: `${REG}/foo/-/foo-1.0.0.tgz` + } + }, + '1.0.1': { + name: 'foo', + dist: { + tarball: `${REG}/foo/-/foo-1.0.1.tgz` + } + } + } + } + const postEdit = { + _id: 'foo', + _rev: REV, + name: 'foo', + 'dist-tags': { + latest: '1.0.0' + }, + versions: { + '1.0.0': { + name: 'foo', + dist: { + tarball: `${REG}/foo/-/foo-1.0.0.tgz` + } + } + } + } + const srv = tnock(t, REG) + srv.get('/foo?write=true').reply(200, doc) + srv.put(`/foo/-rev/${REV}`, postEdit).reply(200) + srv.get('/foo?write=true').reply(200, postEdit) + srv.delete(`/foo/-/foo-1.0.1.tgz/-rev/${REV}`).reply(200) + return unpub('foo@1.0.1', OPTS).then(() => { + t.ok(true, 'foo was unpublished') + }) +}) diff --git a/node_modules/libnpmpublish/test/util/mock-tarball.js b/node_modules/libnpmpublish/test/util/mock-tarball.js new file mode 100644 index 0000000000000..c6253cd218f5b --- /dev/null +++ b/node_modules/libnpmpublish/test/util/mock-tarball.js @@ -0,0 +1,47 @@ +'use strict' + +const BB = require('bluebird') + +const getStream = require('get-stream') +const tar = require('tar-stream') +const zlib = require('zlib') + +module.exports = makeTarball +function makeTarball (files, opts) { + opts = opts || {} + const pack = tar.pack() + Object.keys(files).forEach(function (filename) { + const entry = files[filename] + pack.entry({ + name: (opts.noPrefix ? '' : 'package/') + filename, + type: entry.type, + size: entry.size, + mode: entry.mode, + mtime: entry.mtime || new Date(0), + linkname: entry.linkname, + uid: entry.uid, + gid: entry.gid, + uname: entry.uname, + gname: entry.gname + }, typeof files[filename] === 'string' + ? files[filename] + : files[filename].data) + }) + pack.finalize() + return BB.try(() => { + if (opts.stream && opts.gzip) { + const gz = zlib.createGzip() + pack.on('error', err => gz.emit('error', err)).pipe(gz) + } else if (opts.stream) { + return pack + } else { + return getStream.buffer(pack).then(ret => { + if (opts.gzip) { + return BB.fromNode(cb => zlib.gzip(ret, cb)) + } else { + return ret + } + }) + } + }) +} diff --git a/node_modules/libnpmpublish/test/util/tnock.js b/node_modules/libnpmpublish/test/util/tnock.js new file mode 100644 index 0000000000000..00b6e160e1019 --- /dev/null +++ b/node_modules/libnpmpublish/test/util/tnock.js @@ -0,0 +1,12 @@ +'use strict' + +const nock = require('nock') + +module.exports = tnock +function tnock (t, host) { + const server = nock(host) + t.tearDown(function () { + server.done() + }) + return server +} diff --git a/node_modules/libnpmpublish/unpublish.js b/node_modules/libnpmpublish/unpublish.js new file mode 100644 index 0000000000000..d7d98243c6b09 --- /dev/null +++ b/node_modules/libnpmpublish/unpublish.js @@ -0,0 +1,86 @@ +'use strict' + +const figgyPudding = require('figgy-pudding') +const npa = require('npm-package-arg') +const npmFetch = require('npm-registry-fetch') +const semver = require('semver') +const url = require('url') + +const UnpublishConfig = figgyPudding({ + force: { default: false }, + Promise: { default: () => Promise } +}) + +module.exports = unpublish +function unpublish (spec, opts) { + opts = UnpublishConfig(opts) + return new opts.Promise(resolve => resolve()).then(() => { + spec = npa(spec) + // NOTE: spec is used to pick the appropriate registry/auth combo. + opts = opts.concat({ spec }) + const pkgUri = spec.escapedName + return npmFetch.json(pkgUri, opts.concat({ + query: { write: true } + })).then(pkg => { + if (!spec.rawSpec || spec.rawSpec === '*') { + return npmFetch(`${pkgUri}/-rev/${pkg._rev}`, opts.concat({ + method: 'DELETE', + ignoreBody: true + })) + } else { + const version = spec.rawSpec + const allVersions = pkg.versions || {} + const versionPublic = allVersions[version] + let dist + if (versionPublic) { + dist = allVersions[version].dist + } + delete allVersions[version] + // if it was the only version, then delete the whole package. + if (!Object.keys(allVersions).length) { + return npmFetch(`${pkgUri}/-rev/${pkg._rev}`, opts.concat({ + method: 'DELETE', + ignoreBody: true + })) + } else if (versionPublic) { + const latestVer = pkg['dist-tags'].latest + Object.keys(pkg['dist-tags']).forEach(tag => { + if (pkg['dist-tags'][tag] === version) { + delete pkg['dist-tags'][tag] + } + }) + + if (latestVer === version) { + pkg['dist-tags'].latest = Object.keys( + allVersions + ).sort(semver.compareLoose).pop() + } + + delete pkg._revisions + delete pkg._attachments + // Update packument with removed versions + return npmFetch(`${pkgUri}/-rev/${pkg._rev}`, opts.concat({ + method: 'PUT', + body: pkg, + ignoreBody: true + })).then(() => { + // Remove the tarball itself + return npmFetch.json(pkgUri, opts.concat({ + query: { write: true } + })).then(({ _rev, _id }) => { + const tarballUrl = url.parse(dist.tarball).pathname.substr(1) + return npmFetch(`${tarballUrl}/-rev/${_rev}`, opts.concat({ + method: 'DELETE', + ignoreBody: true + })) + }) + }) + } + } + }, err => { + if (err.code !== 'E404') { + throw err + } + }) + }).then(() => true) +} diff --git a/node_modules/libnpmsearch/CHANGELOG.md b/node_modules/libnpmsearch/CHANGELOG.md new file mode 100644 index 0000000000000..6ca044d3f48b4 --- /dev/null +++ b/node_modules/libnpmsearch/CHANGELOG.md @@ -0,0 +1,26 @@ +# Change Log + +All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. + + +# [2.0.0](https://github.com/npm/libnpmsearch/compare/v1.0.0...v2.0.0) (2018-08-28) + + +### Features + +* **opts:** added options for pagination, details, and sorting weights ([ff97eb5](https://github.com/npm/libnpmsearch/commit/ff97eb5)) + + +### BREAKING CHANGES + +* **opts:** this changes default requests and makes libnpmsearch return more complete data for individual packages, without null-defaulting + + + + +# 1.0.0 (2018-08-27) + + +### Features + +* **api:** got API working ([fe90008](https://github.com/npm/libnpmsearch/commit/fe90008)) diff --git a/node_modules/libnpmsearch/CODE_OF_CONDUCT.md b/node_modules/libnpmsearch/CODE_OF_CONDUCT.md new file mode 100644 index 0000000000000..aeb72f598dcb4 --- /dev/null +++ b/node_modules/libnpmsearch/CODE_OF_CONDUCT.md @@ -0,0 +1,151 @@ +# Code of Conduct + +## When Something Happens + +If you see a Code of Conduct violation, follow these steps: + +1. Let the person know that what they did is not appropriate and ask them to stop and/or edit their message(s) or commits. +2. That person should immediately stop the behavior and correct the issue. +3. If this doesn’t happen, or if you're uncomfortable speaking up, [contact the maintainers](#contacting-maintainers). +4. As soon as available, a maintainer will look into the issue, and take [further action (see below)](#further-enforcement), starting with a warning, then temporary block, then long-term repo or organization ban. + +When reporting, please include any relevant details, links, screenshots, context, or other information that may be used to better understand and resolve the situation. + +**The maintainer team will prioritize the well-being and comfort of the recipients of the violation over the comfort of the violator.** See [some examples below](#enforcement-examples). + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as contributors and maintainers of this project pledge to making participation in our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, technical preferences, nationality, personal appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment include: + + * Using welcoming and inclusive language. + * Being respectful of differing viewpoints and experiences. + * Gracefully accepting constructive feedback. + * Focusing on what is best for the community. + * Showing empathy and kindness towards other community members. + * Encouraging and raising up your peers in the project so you can all bask in hacks and glory. + +Examples of unacceptable behavior by participants include: + + * The use of sexualized language or imagery and unwelcome sexual attention or advances, including when simulated online. The only exception to sexual topics is channels/spaces specifically for topics of sexual identity. + * Casual mention of slavery or indentured servitude and/or false comparisons of one's occupation or situation to slavery. Please consider using or asking about alternate terminology when referring to such metaphors in technology. + * Making light of/making mocking comments about trigger warnings and content warnings. + * Trolling, insulting/derogatory comments, and personal or political attacks. + * Public or private harassment, deliberate intimidation, or threats. + * Publishing others' private information, such as a physical or electronic address, without explicit permission. This includes any sort of "outing" of any aspect of someone's identity without their consent. + * Publishing private screenshots or quotes of interactions in the context of this project without all quoted users' *explicit* consent. + * Publishing of private communication that doesn't have to do with reporting harrassment. + * Any of the above even when [presented as "ironic" or "joking"](https://en.wikipedia.org/wiki/Hipster_racism). + * Any attempt to present "reverse-ism" versions of the above as violations. Examples of reverse-isms are "reverse racism", "reverse sexism", "heterophobia", and "cisphobia". + * Unsolicited explanations under the assumption that someone doesn't already know it. Ask before you teach! Don't assume what people's knowledge gaps are. + * [Feigning or exaggerating surprise](https://www.recurse.com/manual#no-feigned-surprise) when someone admits to not knowing something. + * "[Well-actuallies](https://www.recurse.com/manual#no-well-actuallys)" + * Other conduct which could reasonably be considered inappropriate in a professional or community setting. + +## Scope + +This Code of Conduct applies both within spaces involving this project and in other spaces involving community members. This includes the repository, its Pull Requests and Issue tracker, its Twitter community, private email communications in the context of the project, and any events where members of the project are participating, as well as adjacent communities and venues affecting the project's members. + +Depending on the violation, the maintainers may decide that violations of this code of conduct that have happened outside of the scope of the community may deem an individual unwelcome, and take appropriate action to maintain the comfort and safety of its members. + +### Other Community Standards + +As a project on GitHub, this project is additionally covered by the [GitHub Community Guidelines](https://help.github.com/articles/github-community-guidelines/). + +Additionally, as a project hosted on npm, is is covered by [npm, Inc's Code of Conduct](https://www.npmjs.com/policies/conduct). + +Enforcement of those guidelines after violations overlapping with the above are the responsibility of the entities, and enforcement may happen in any or all of the services/communities. + +## Maintainer Enforcement Process + +Once the maintainers get involved, they will follow a documented series of steps and do their best to preserve the well-being of project members. This section covers actual concrete steps. + +### Contacting Maintainers + +You may get in touch with the maintainer team through any of the following methods: + + * Through email: + * [kzm@zkat.tech](mailto:kzm@zkat.tech) (Kat Marchán) + + * Through Twitter: + * [@maybekatz](https://twitter.com/maybekatz) (Kat Marchán) + +### Further Enforcement + +If you've already followed the [initial enforcement steps](#enforcement), these are the steps maintainers will take for further enforcement, as needed: + + 1. Repeat the request to stop. + 2. If the person doubles down, they will have offending messages removed or edited by a maintainers given an official warning. The PR or Issue may be locked. + 3. If the behavior continues or is repeated later, the person will be blocked from participating for 24 hours. + 4. If the behavior continues or is repeated after the temporary block, a long-term (6-12mo) ban will be used. + +On top of this, maintainers may remove any offending messages, images, contributions, etc, as they deem necessary. + +Maintainers reserve full rights to skip any of these steps, at their discretion, if the violation is considered to be a serious and/or immediate threat to the health and well-being of members of the community. These include any threats, serious physical or verbal attacks, and other such behavior that would be completely unacceptable in any social setting that puts our members at risk. + +Members expelled from events or venues with any sort of paid attendance will not be refunded. + +### Who Watches the Watchers? + +Maintainers and other leaders who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. These may include anything from removal from the maintainer team to a permanent ban from the community. + +Additionally, as a project hosted on both GitHub and npm, [their own Codes of Conducts may be applied against maintainers of this project](#other-community-standards), externally of this project's procedures. + +### Enforcement Examples + +#### The Best Case + +The vast majority of situations work out like this. This interaction is common, and generally positive. + +> Alex: "Yeah I used X and it was really crazy!" + +> Patt (not a maintainer): "Hey, could you not use that word? What about 'ridiculous' instead?" + +> Alex: "oh sorry, sure." -> edits old comment to say "it was really confusing!" + +#### The Maintainer Case + +Sometimes, though, you need to get maintainers involved. Maintainers will do their best to resolve conflicts, but people who were harmed by something **will take priority**. + +> Patt: "Honestly, sometimes I just really hate using $library and anyone who uses it probably sucks at their job." + +> Alex: "Whoa there, could you dial it back a bit? There's a CoC thing about attacking folks' tech use like that." + +> Patt: "I'm not attacking anyone, what's your problem?" + +> Alex: "@maintainers hey uh. Can someone look at this issue? Patt is getting a bit aggro. I tried to nudge them about it, but nope." + +> KeeperOfCommitBits: (on issue) "Hey Patt, maintainer here. Could you tone it down? This sort of attack is really not okay in this space." + +> Patt: "Leave me alone I haven't said anything bad wtf is wrong with you." + +> KeeperOfCommitBits: (deletes user's comment), "@patt I mean it. Please refer to the CoC over at (URL to this CoC) if you have questions, but you can consider this an actual warning. I'd appreciate it if you reworded your messages in this thread, since they made folks there uncomfortable. Let's try and be kind, yeah?" + +> Patt: "@keeperofbits Okay sorry. I'm just frustrated and I'm kinda burnt out and I guess I got carried away. I'll DM Alex a note apologizing and edit my messages. Sorry for the trouble." + +> KeeperOfCommitBits: "@patt Thanks for that. I hear you on the stress. Burnout sucks :/. Have a good one!" + +#### The Nope Case + +> PepeTheFrog🐸: "Hi, I am a literal actual nazi and I think white supremacists are quite fashionable." + +> Patt: "NOOOOPE. OH NOPE NOPE." + +> Alex: "JFC NO. NOPE. @keeperofbits NOPE NOPE LOOK HERE" + +> KeeperOfCommitBits: "👀 Nope. NOPE NOPE NOPE. 🔥" + +> PepeTheFrog🐸 has been banned from all organization or user repositories belonging to KeeperOfCommitBits. + +## Attribution + +This Code of Conduct was generated using [WeAllJS Code of Conduct Generator](https://npm.im/weallbehave), which is based on the [WeAllJS Code of +Conduct](https://wealljs.org/code-of-conduct), which is itself based on +[Contributor Covenant](http://contributor-covenant.org), version 1.4, available +at +[http://contributor-covenant.org/version/1/4](http://contributor-covenant.org/version/1/4), +and the LGBTQ in Technology Slack [Code of +Conduct](http://lgbtq.technology/coc.html). diff --git a/node_modules/libnpmsearch/CONTRIBUTING.md b/node_modules/libnpmsearch/CONTRIBUTING.md new file mode 100644 index 0000000000000..1a61601a16dba --- /dev/null +++ b/node_modules/libnpmsearch/CONTRIBUTING.md @@ -0,0 +1,256 @@ +# Contributing + +## How do I... + +* [Use This Guide](#introduction)? +* Ask or Say Something? 🤔🐛😱 + * [Request Support](#request-support) + * [Report an Error or Bug](#report-an-error-or-bug) + * [Request a Feature](#request-a-feature) +* Make Something? 🤓👩🏽‍💻📜🍳 + * [Project Setup](#project-setup) + * [Contribute Documentation](#contribute-documentation) + * [Contribute Code](#contribute-code) +* Manage Something ✅🙆🏼💃👔 + * [Provide Support on Issues](#provide-support-on-issues) + * [Label Issues](#label-issues) + * [Clean Up Issues and PRs](#clean-up-issues-and-prs) + * [Review Pull Requests](#review-pull-requests) + * [Merge Pull Requests](#merge-pull-requests) + * [Tag a Release](#tag-a-release) + * [Join the Project Team](#join-the-project-team) +* Add a Guide Like This One [To My Project](#attribution)? 🤖😻👻 + +## Introduction + +Thank you so much for your interest in contributing!. All types of contributions are encouraged and valued. See the [table of contents](#toc) for different ways to help and details about how this project handles them!📝 + +Please make sure to read the relevant section before making your contribution! It will make it a lot easier for us maintainers to make the most of it and smooth out the experience for all involved. 💚 + +The [Project Team](#join-the-project-team) looks forward to your contributions. 🙌🏾✨ + +## Request Support + +If you have a question about this project, how to use it, or just need clarification about something: + +* Open an Issue at https://github.com/npm/libnpmsearch/issues +* Provide as much context as you can about what you're running into. +* Provide project and platform versions (nodejs, npm, etc), depending on what seems relevant. If not, please be ready to provide that information if maintainers ask for it. + +Once it's filed: + +* The project team will [label the issue](#label-issues). +* Someone will try to have a response soon. +* If you or the maintainers don't respond to an issue for 30 days, the [issue will be closed](#clean-up-issues-and-prs). If you want to come back to it, reply (once, please), and we'll reopen the existing issue. Please avoid filing new issues as extensions of one you already made. + +## Report an Error or Bug + +If you run into an error or bug with the project: + +* Open an Issue at https://github.com/npm/libnpmsearch/issues +* Include *reproduction steps* that someone else can follow to recreate the bug or error on their own. +* Provide project and platform versions (nodejs, npm, etc), depending on what seems relevant. If not, please be ready to provide that information if maintainers ask for it. + +Once it's filed: + +* The project team will [label the issue](#label-issues). +* A team member will try to reproduce the issue with your provided steps. If there are no repro steps or no obvious way to reproduce the issue, the team will ask you for those steps and mark the issue as `needs-repro`. Bugs with the `needs-repro` tag will not be addressed until they are reproduced. +* If the team is able to reproduce the issue, it will be marked `needs-fix`, as well as possibly other tags (such as `critical`), and the issue will be left to be [implemented by someone](#contribute-code). +* If you or the maintainers don't respond to an issue for 30 days, the [issue will be closed](#clean-up-issues-and-prs). If you want to come back to it, reply (once, please), and we'll reopen the existing issue. Please avoid filing new issues as extensions of one you already made. +* `critical` issues may be left open, depending on perceived immediacy and severity, even past the 30 day deadline. + +## Request a Feature + +If the project doesn't do something you need or want it to do: + +* Open an Issue at https://github.com/npm/libnpmsearch/issues +* Provide as much context as you can about what you're running into. +* Please try and be clear about why existing features and alternatives would not work for you. + +Once it's filed: + +* The project team will [label the issue](#label-issues). +* The project team will evaluate the feature request, possibly asking you more questions to understand its purpose and any relevant requirements. If the issue is closed, the team will convey their reasoning and suggest an alternative path forward. +* If the feature request is accepted, it will be marked for implementation with `feature-accepted`, which can then be done by either by a core team member or by anyone in the community who wants to [contribute code](#contribute-code). + +Note: The team is unlikely to be able to accept every single feature request that is filed. Please understand if they need to say no. + +## Project Setup + +So you wanna contribute some code! That's great! This project uses GitHub Pull Requests to manage contributions, so [read up on how to fork a GitHub project and file a PR](https://guides.github.com/activities/forking) if you've never done it before. + +If this seems like a lot or you aren't able to do all this setup, you might also be able to [edit the files directly](https://help.github.com/articles/editing-files-in-another-user-s-repository/) without having to do any of this setup. Yes, [even code](#contribute-code). + +If you want to go the usual route and run the project locally, though: + +* [Install Node.js](https://nodejs.org/en/download/) +* [Fork the project](https://guides.github.com/activities/forking/#fork) + +Then in your terminal: +* `cd path/to/your/clone` +* `npm install` +* `npm test` + +And you should be ready to go! + +## Contribute Documentation + +Documentation is a super important, critical part of this project. Docs are how we keep track of what we're doing, how, and why. It's how we stay on the same page about our policies. And it's how we tell others everything they need in order to be able to use this project -- or contribute to it. So thank you in advance. + +Documentation contributions of any size are welcome! Feel free to file a PR even if you're just rewording a sentence to be more clear, or fixing a spelling mistake! + +To contribute documentation: + +* [Set up the project](#project-setup). +* Edit or add any relevant documentation. +* Make sure your changes are formatted correctly and consistently with the rest of the documentation. +* Re-read what you wrote, and run a spellchecker on it to make sure you didn't miss anything. +* In your commit message(s), begin the first line with `docs: `. For example: `docs: Adding a doc contrib section to CONTRIBUTING.md`. +* Write clear, concise commit message(s) using [conventional-changelog format](https://github.com/conventional-changelog/conventional-changelog-angular/blob/master/convention.md). Documentation commits should use `docs(): `. +* Go to https://github.com/npm/libnpmsearch/pulls and open a new pull request with your changes. +* If your PR is connected to an open issue, add a line in your PR's description that says `Fixes: #123`, where `#123` is the number of the issue you're fixing. + +Once you've filed the PR: + +* One or more maintainers will use GitHub's review feature to review your PR. +* If the maintainer asks for any changes, edit your changes, push, and ask for another review. +* If the maintainer decides to pass on your PR, they will thank you for the contribution and explain why they won't be accepting the changes. That's ok! We still really appreciate you taking the time to do it, and we don't take that lightly. 💚 +* If your PR gets accepted, it will be marked as such, and merged into the `latest` branch soon after. Your contribution will be distributed to the masses next time the maintainers [tag a release](#tag-a-release) + +## Contribute Code + +We like code commits a lot! They're super handy, and they keep the project going and doing the work it needs to do to be useful to others. + +Code contributions of just about any size are acceptable! + +The main difference between code contributions and documentation contributions is that contributing code requires inclusion of relevant tests for the code being added or changed. Contributions without accompanying tests will be held off until a test is added, unless the maintainers consider the specific tests to be either impossible, or way too much of a burden for such a contribution. + +To contribute code: + +* [Set up the project](#project-setup). +* Make any necessary changes to the source code. +* Include any [additional documentation](#contribute-documentation) the changes might need. +* Write tests that verify that your contribution works as expected. +* Write clear, concise commit message(s) using [conventional-changelog format](https://github.com/conventional-changelog/conventional-changelog-angular/blob/master/convention.md). +* Dependency updates, additions, or removals must be in individual commits, and the message must use the format: `(deps): PKG@VERSION`, where `` is any of the usual `conventional-changelog` prefixes, at your discretion. +* Go to https://github.com/npm/libnpmsearch/pulls and open a new pull request with your changes. +* If your PR is connected to an open issue, add a line in your PR's description that says `Fixes: #123`, where `#123` is the number of the issue you're fixing. + +Once you've filed the PR: + +* Barring special circumstances, maintainers will not review PRs until all checks pass (Travis, AppVeyor, etc). +* One or more maintainers will use GitHub's review feature to review your PR. +* If the maintainer asks for any changes, edit your changes, push, and ask for another review. Additional tags (such as `needs-tests`) will be added depending on the review. +* If the maintainer decides to pass on your PR, they will thank you for the contribution and explain why they won't be accepting the changes. That's ok! We still really appreciate you taking the time to do it, and we don't take that lightly. 💚 +* If your PR gets accepted, it will be marked as such, and merged into the `latest` branch soon after. Your contribution will be distributed to the masses next time the maintainers [tag a release](#tag-a-release) + +## Provide Support on Issues + +[Needs Collaborator](#join-the-project-team): none + +Helping out other users with their questions is a really awesome way of contributing to any community. It's not uncommon for most of the issues on an open source projects being support-related questions by users trying to understand something they ran into, or find their way around a known bug. + +Sometimes, the `support` label will be added to things that turn out to actually be other things, like bugs or feature requests. In that case, suss out the details with the person who filed the original issue, add a comment explaining what the bug is, and change the label from `support` to `bug` or `feature`. If you can't do this yourself, @mention a maintainer so they can do it. + +In order to help other folks out with their questions: + +* Go to the issue tracker and [filter open issues by the `support` label](https://github.com/npm/libnpmsearch/issues?q=is%3Aopen+is%3Aissue+label%3Asupport). +* Read through the list until you find something that you're familiar enough with to give an answer to. +* Respond to the issue with whatever details are needed to clarify the question, or get more details about what's going on. +* Once the discussion wraps up and things are clarified, either close the issue, or ask the original issue filer (or a maintainer) to close it for you. + +Some notes on picking up support issues: + +* Avoid responding to issues you don't know you can answer accurately. +* As much as possible, try to refer to past issues with accepted answers. Link to them from your replies with the `#123` format. +* Be kind and patient with users -- often, folks who have run into confusing things might be upset or impatient. This is ok. Try to understand where they're coming from, and if you're too uncomfortable with the tone, feel free to stay away or withdraw from the issue. (note: if the user is outright hostile or is violating the CoC, [refer to the Code of Conduct](CODE_OF_CONDUCT.md) to resolve the conflict). + +## Label Issues + +[Needs Collaborator](#join-the-project-team): Issue Tracker + +One of the most important tasks in handling issues is labeling them usefully and accurately. All other tasks involving issues ultimately rely on the issue being classified in such a way that relevant parties looking to do their own tasks can find them quickly and easily. + +In order to label issues, [open up the list of unlabeled issues](https://github.com/npm/libnpmsearch/issues?q=is%3Aopen+is%3Aissue+no%3Alabel) and, **from newest to oldest**, read through each one and apply issue labels according to the table below. If you're unsure about what label to apply, skip the issue and try the next one: don't feel obligated to label each and every issue yourself! + +Label | Apply When | Notes +--- | --- | --- +`bug` | Cases where the code (or documentation) is behaving in a way it wasn't intended to. | If something is happening that surprises the *user* but does not go against the way the code is designed, it should use the `enhancement` label. +`critical` | Added to `bug` issues if the problem described makes the code completely unusable in a common situation. | +`documentation` | Added to issues or pull requests that affect any of the documentation for the project. | Can be combined with other labels, such as `bug` or `enhancement`. +`duplicate` | Added to issues or PRs that refer to the exact same issue as another one that's been previously labeled. | Duplicate issues should be marked and closed right away, with a message referencing the issue it's a duplicate of (with `#123`) +`enhancement` | Added to [feature requests](#request-a-feature), PRs, or documentation issues that are purely additive: the code or docs currently work as expected, but a change is being requested or suggested. | +`help wanted` | Applied by [Committers](#join-the-project-team) to issues and PRs that they would like to get outside help for. Generally, this means it's lower priority for the maintainer team to itself implement, but that the community is encouraged to pick up if they so desire | Never applied on first-pass labeling. +`in-progress` | Applied by [Committers](#join-the-project-team) to PRs that are pending some work before they're ready for review. | The original PR submitter should @mention the team member that applied the label once the PR is complete. +`performance` | This issue or PR is directly related to improving performance. | +`refactor` | Added to issues or PRs that deal with cleaning up or modifying the project for the betterment of it. | +`starter` | Applied by [Committers](#join-the-project-team) to issues that they consider good introductions to the project for people who have not contributed before. These are not necessarily "easy", but rather focused around how much context is necessary in order to understand what needs to be done for this project in particular. | Existing project members are expected to stay away from these unless they increase in priority. +`support` | This issue is either asking a question about how to use the project, clarifying the reason for unexpected behavior, or possibly reporting a `bug` but does not have enough detail yet to determine whether it would count as such. | The label should be switched to `bug` if reliable reproduction steps are provided. Issues primarily with unintended configurations of a user's environment are not considered bugs, even if they cause crashes. +`tests` | This issue or PR either requests or adds primarily tests to the project. | If a PR is pending tests, that will be handled through the [PR review process](#review-pull-requests) +`wontfix` | Labelers may apply this label to issues that clearly have nothing at all to do with the project or are otherwise entirely outside of its scope/sphere of influence. [Committers](#join-the-project-team) may apply this label and close an issue or PR if they decide to pass on an otherwise relevant issue. | The issue or PR should be closed as soon as the label is applied, and a clear explanation provided of why the label was used. Contributors are free to contest the labeling, but the decision ultimately falls on committers as to whether to accept something or not. + +## Clean Up Issues and PRs + +[Needs Collaborator](#join-the-project-team): Issue Tracker + +Issues and PRs can go stale after a while. Maybe they're abandoned. Maybe the team will just plain not have time to address them any time soon. + +In these cases, they should be closed until they're brought up again or the interaction starts over. + +To clean up issues and PRs: + +* Search the issue tracker for issues or PRs, and add the term `updated:<=YYYY-MM-DD`, where the date is 30 days before today. +* Go through each issue *from oldest to newest*, and close them if **all of the following are true**: + * not opened by a maintainer + * not marked as `critical` + * not marked as `starter` or `help wanted` (these might stick around for a while, in general, as they're intended to be available) + * no explicit messages in the comments asking for it to be left open + * does not belong to a milestone +* Leave a message when closing saying "Cleaning up stale issue. Please reopen or ping us if and when you're ready to resume this. See https://github.com/npm/libnpmsearch/blob/latest/CONTRIBUTING.md#clean-up-issues-and-prs for more details." + +## Review Pull Requests + +[Needs Collaborator](#join-the-project-team): Issue Tracker + +While anyone can comment on a PR, add feedback, etc, PRs are only *approved* by team members with Issue Tracker or higher permissions. + +PR reviews use [GitHub's own review feature](https://help.github.com/articles/about-pull-request-reviews/), which manages comments, approval, and review iteration. + +Some notes: + +* You may ask for minor changes ("nitpicks"), but consider whether they are really blockers to merging: try to err on the side of "approve, with comments". +* *ALL PULL REQUESTS* should be covered by a test: either by a previously-failing test, an existing test that covers the entire functionality of the submitted code, or new tests to verify any new/changed behavior. All tests must also pass and follow established conventions. Test coverage should not drop, unless the specific case is considered reasonable by maintainers. +* Please make sure you're familiar with the code or documentation being updated, unless it's a minor change (spellchecking, minor formatting, etc). You may @mention another project member who you think is better suited for the review, but still provide a non-approving review of your own. +* Be extra kind: people who submit code/doc contributions are putting themselves in a pretty vulnerable position, and have put time and care into what they've done (even if that's not obvious to you!) -- always respond with respect, be understanding, but don't feel like you need to sacrifice your standards for their sake, either. Just don't be a jerk about it? + +## Merge Pull Requests + +[Needs Collaborator](#join-the-project-team): Committer + +TBD - need to hash out a bit more of this process. + +## Tag A Release + +[Needs Collaborator](#join-the-project-team): Committer + +TBD - need to hash out a bit more of this process. The most important bit here is probably that all tests must pass, and tags must use [semver](https://semver.org). + +## Join the Project Team + +### Ways to Join + +There are many ways to contribute! Most of them don't require any official status unless otherwise noted. That said, there's a couple of positions that grant special repository abilities, and this section describes how they're granted and what they do. + +All of the below positions are granted based on the project team's needs, as well as their consensus opinion about whether they would like to work with the person and think that they would fit well into that position. The process is relatively informal, and it's likely that people who express interest in participating can just be granted the permissions they'd like. + +You can spot a collaborator on the repo by looking for the `[Collaborator]` or `[Owner]` tags next to their names. + +Permission | Description +--- | --- +Issue Tracker | Granted to contributors who express a strong interest in spending time on the project's issue tracker. These tasks are mainly [labeling issues](#label-issues), [cleaning up old ones](#clean-up-issues-and-prs), and [reviewing pull requests](#review-pull-requests), as well as all the usual things non-team-member contributors can do. Issue handlers should not merge pull requests, tag releases, or directly commit code themselves: that should still be done through the usual pull request process. Becoming an Issue Handler means the project team trusts you to understand enough of the team's process and context to implement it on the issue tracker. +Committer | Granted to contributors who want to handle the actual pull request merges, tagging new versions, etc. Committers should have a good level of familiarity with the codebase, and enough context to understand the implications of various changes, as well as a good sense of the will and expectations of the project team. +Admin/Owner | Granted to people ultimately responsible for the project, its community, etc. + +## Attribution + +This guide was generated using the WeAllJS `CONTRIBUTING.md` generator. [Make your own](https://npm.im/weallcontribute)! diff --git a/node_modules/libnpmsearch/LICENSE b/node_modules/libnpmsearch/LICENSE new file mode 100644 index 0000000000000..209e4477f39c1 --- /dev/null +++ b/node_modules/libnpmsearch/LICENSE @@ -0,0 +1,13 @@ +Copyright npm, Inc + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/node_modules/libnpmsearch/PULL_REQUEST_TEMPLATE b/node_modules/libnpmsearch/PULL_REQUEST_TEMPLATE new file mode 100644 index 0000000000000..9471c6d325f7e --- /dev/null +++ b/node_modules/libnpmsearch/PULL_REQUEST_TEMPLATE @@ -0,0 +1,7 @@ + diff --git a/node_modules/libnpmsearch/README.md b/node_modules/libnpmsearch/README.md new file mode 100644 index 0000000000000..6617ddb89d115 --- /dev/null +++ b/node_modules/libnpmsearch/README.md @@ -0,0 +1,169 @@ +# libnpmsearch [![npm version](https://img.shields.io/npm/v/libnpmsearch.svg)](https://npm.im/libnpmsearch) [![license](https://img.shields.io/npm/l/libnpmsearch.svg)](https://npm.im/libnpmsearch) [![Travis](https://img.shields.io/travis/npm/libnpmsearch.svg)](https://travis-ci.org/npm/libnpmsearch) [![AppVeyor](https://ci.appveyor.com/api/projects/status/github/zkat/libnpmsearch?svg=true)](https://ci.appveyor.com/project/zkat/libnpmsearch) [![Coverage Status](https://coveralls.io/repos/github/npm/libnpmsearch/badge.svg?branch=latest)](https://coveralls.io/github/npm/libnpmsearch?branch=latest) + +[`libnpmsearch`](https://github.com/npm/libnpmsearch) is a Node.js library for +programmatically accessing the npm search endpoint. It does **not** support +legacy search through `/-/all`. + +## Example + +```js +const search = require('libnpmsearch') + +console.log(await search('libnpm')) +=> +[ + { + name: 'libnpm', + description: 'programmatic npm API', + ...etc + }, + { + name: 'libnpmsearch', + description: 'Programmatic API for searching in npm and compatible registries', + ...etc + }, + ...more +] +``` + +## Install + +`$ npm install libnpmsearch` + +## Table of Contents + +* [Example](#example) +* [Install](#install) +* [API](#api) + * [search opts](#opts) + * [`search()`](#search) + * [`search.stream()`](#search-stream) + +### API + +#### `opts` for `libnpmsearch` commands + +The following opts are used directly by `libnpmsearch` itself: + +* `opts.limit` - Number of results to limit the query to. Default: 20 +* `opts.offset` - Offset number for results. Used with `opts.limit` for pagination. Default: 0 +* `opts.detailed` - If true, returns an object with `package`, `score`, and `searchScore` fields, with `package` being what would usually be returned, and the other two containing details about how that package scored. Useful for UIs. Default: false +* `opts.sortBy` - Used as a shorthand to set `opts.quality`, `opts.maintenance`, and `opts.popularity` with values that prioritize each one. Should be one of `'optimal'`, `'quality'`, `'maintenance'`, or `'popularity'`. Default: `'optimal'` +* `opts.maintenance` - Decimal number between `0` and `1` that defines the weight of `maintenance` metrics when scoring and sorting packages. Default: `0.65` (same as `opts.sortBy: 'optimal'`) +* `opts.popularity` - Decimal number between `0` and `1` that defines the weight of `popularity` metrics when scoring and sorting packages. Default: `0.98` (same as `opts.sortBy: 'optimal'`) +* `opts.quality` - Decimal number between `0` and `1` that defines the weight of `quality` metrics when scoring and sorting packages. Default: `0.5` (same as `opts.sortBy: 'optimal'`) + +`libnpmsearch` uses [`npm-registry-fetch`](https://npm.im/npm-registry-fetch). +Most options are passed through directly to that library, so please refer to +[its own `opts` +documentation](https://www.npmjs.com/package/npm-registry-fetch#fetch-options) +for options that can be passed in. + +A couple of options of note for those in a hurry: + +* `opts.token` - can be passed in and will be used as the authentication token for the registry. For other ways to pass in auth details, see the n-r-f docs. +* `opts.Promise` - If you pass this in, the Promises returned by `libnpmsearch` commands will use this Promise class instead. For example: `{Promise: require('bluebird')}` + +#### `> search(query, [opts]) -> Promise` + +`query` must be either a String or an Array of search terms. + +If `opts.limit` is provided, it will be sent to the API to constrain the number +of returned results. You may receive more, or fewer results, at the endpoint's +discretion. + +The returned Promise resolved to an Array of search results with the following +format: + +```js +{ + name: String, + version: SemverString, + description: String || null, + maintainers: [ + { + username: String, + email: String + }, + ...etc + ] || null, + keywords: [String] || null, + date: Date || null +} +``` + +If `opts.limit` is provided, it will be sent to the API to constrain the number +of returned results. You may receive more, or fewer results, at the endpoint's +discretion. + +For streamed results, see [`search.stream`](#search-stream). + +##### Example + +```javascript +await search('libnpm') +=> +[ + { + name: 'libnpm', + description: 'programmatic npm API', + ...etc + }, + { + name: 'libnpmsearch', + description: 'Programmatic API for searching in npm and compatible registries', + ...etc + }, + ...more +] +``` + +#### `> search.stream(query, [opts]) -> Stream` + +`query` must be either a String or an Array of search terms. + +If `opts.limit` is provided, it will be sent to the API to constrain the number +of returned results. You may receive more, or fewer results, at the endpoint's +discretion. + +The returned Stream emits one entry per search result, with each entry having +the following format: + +```js +{ + name: String, + version: SemverString, + description: String || null, + maintainers: [ + { + username: String, + email: String + }, + ...etc + ] || null, + keywords: [String] || null, + date: Date || null +} +``` + +For getting results in one chunk, see [`search`](#search-stream). + +##### Example + +```javascript +search.stream('libnpm').on('data', console.log) +=> +// entry 1 +{ + name: 'libnpm', + description: 'programmatic npm API', + ...etc +} +// entry 2 +{ + name: 'libnpmsearch', + description: 'Programmatic API for searching in npm and compatible registries', + ...etc +} +// etc +``` diff --git a/node_modules/libnpmsearch/index.js b/node_modules/libnpmsearch/index.js new file mode 100644 index 0000000000000..b84cab150bea2 --- /dev/null +++ b/node_modules/libnpmsearch/index.js @@ -0,0 +1,79 @@ +'use strict' + +const figgyPudding = require('figgy-pudding') +const getStream = require('get-stream') +const npmFetch = require('npm-registry-fetch') + +const SearchOpts = figgyPudding({ + detailed: {default: false}, + limit: {default: 20}, + from: {default: 0}, + quality: {default: 0.65}, + popularity: {default: 0.98}, + maintenance: {default: 0.5}, + sortBy: {} +}) + +module.exports = search +function search (query, opts) { + return getStream.array(search.stream(query, opts)) +} +search.stream = searchStream +function searchStream (query, opts) { + opts = SearchOpts(opts) + switch (opts.sortBy) { + case 'optimal': { + opts = opts.concat({ + quality: 0.65, + popularity: 0.98, + maintenance: 0.5 + }) + break + } + case 'quality': { + opts = opts.concat({ + quality: 1, + popularity: 0, + maintenance: 0 + }) + break + } + case 'popularity': { + opts = opts.concat({ + quality: 0, + popularity: 1, + maintenance: 0 + }) + break + } + case 'maintenance': { + opts = opts.concat({ + quality: 0, + popularity: 0, + maintenance: 1 + }) + break + } + } + return npmFetch.json.stream('/-/v1/search', 'objects.*', + opts.concat({ + query: { + text: Array.isArray(query) ? query.join(' ') : query, + size: opts.limit, + quality: opts.quality, + popularity: opts.popularity, + maintenance: opts.maintenance + }, + mapJson (obj) { + if (obj.package.date) { + obj.package.date = new Date(obj.package.date) + } + if (opts.detailed) { + return obj + } else { + return obj.package + } + } + }) + ) +} diff --git a/node_modules/libnpmsearch/package.json b/node_modules/libnpmsearch/package.json new file mode 100644 index 0000000000000..50e74c7adbff3 --- /dev/null +++ b/node_modules/libnpmsearch/package.json @@ -0,0 +1,74 @@ +{ + "_args": [ + [ + "libnpmsearch@2.0.0", + "/Users/zkat/Documents/code/work/npm" + ] + ], + "_from": "libnpmsearch@2.0.0", + "_id": "libnpmsearch@2.0.0", + "_inBundle": false, + "_integrity": "sha512-vd+JWbTGzOSfiOc+72MU6y7WqmBXn49egCCrIXp27iE/88bX8EpG64ST1blWQI1bSMUr9l1AKPMVsqa2tS5KWA==", + "_location": "/libnpmsearch", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "libnpmsearch@2.0.0", + "name": "libnpmsearch", + "escapedName": "libnpmsearch", + "rawSpec": "2.0.0", + "saveSpec": null, + "fetchSpec": "2.0.0" + }, + "_requiredBy": [ + "/libnpm" + ], + "_resolved": "https://registry.npmjs.org/libnpmsearch/-/libnpmsearch-2.0.0.tgz", + "_spec": "2.0.0", + "_where": "/Users/zkat/Documents/code/work/npm", + "author": { + "name": "Kat Marchán", + "email": "kzm@zkat.tech" + }, + "bugs": { + "url": "https://github.com/npm/libnpmsearch/issues" + }, + "dependencies": { + "figgy-pudding": "^3.5.1", + "get-stream": "^4.0.0", + "npm-registry-fetch": "^3.8.0" + }, + "description": "Programmatic API for searching in npm and compatible registries.", + "devDependencies": { + "nock": "^9.6.1", + "standard": "*", + "standard-version": "*", + "tap": "*", + "weallbehave": "*", + "weallcontribute": "*" + }, + "homepage": "https://npmjs.com/package/libnpmsearch", + "keywords": [ + "npm", + "search", + "api", + "libnpm" + ], + "license": "ISC", + "name": "libnpmsearch", + "repository": { + "type": "git", + "url": "git+https://github.com/npm/libnpmsearch.git" + }, + "scripts": { + "postrelease": "npm publish && git push --follow-tags", + "prerelease": "npm t", + "pretest": "standard", + "release": "standard-version -s", + "test": "tap -J --100 test/*.js", + "update-coc": "weallbehave -o . && git add CODE_OF_CONDUCT.md && git commit -m 'docs(coc): updated CODE_OF_CONDUCT.md'", + "update-contrib": "weallcontribute -o . && git add CONTRIBUTING.md && git commit -m 'docs(contributing): updated CONTRIBUTING.md'" + }, + "version": "2.0.0" +} diff --git a/node_modules/libnpmsearch/test/index.js b/node_modules/libnpmsearch/test/index.js new file mode 100644 index 0000000000000..f926af6da8559 --- /dev/null +++ b/node_modules/libnpmsearch/test/index.js @@ -0,0 +1,268 @@ +'use strict' + +const figgyPudding = require('figgy-pudding') +const getStream = require('get-stream') +const qs = require('querystring') +const test = require('tap').test +const tnock = require('./util/tnock.js') + +const OPTS = figgyPudding({registry: {}})({ + registry: 'https://mock.reg/' +}) + +const REG = OPTS.registry +const search = require('../index.js') + +test('basic test', t => { + const query = qs.stringify({ + text: 'oo', + size: 20, + quality: 0.65, + popularity: 0.98, + maintenance: 0.5 + }) + tnock(t, REG).get(`/-/v1/search?${query}`).once().reply(200, { + objects: [ + { package: { name: 'cool', version: '1.0.0' } }, + { package: { name: 'foo', version: '2.0.0' } } + ] + }) + return search('oo', OPTS).then(results => { + t.similar(results, [{ + name: 'cool', + version: '1.0.0' + }, { + name: 'foo', + version: '2.0.0' + }], 'got back an array of search results') + }) +}) + +test('search.stream', t => { + const query = qs.stringify({ + text: 'oo', + size: 20, + quality: 0.65, + popularity: 0.98, + maintenance: 0.5 + }) + tnock(t, REG).get(`/-/v1/search?${query}`).once().reply(200, { + objects: [ + { package: { name: 'cool', version: '1.0.0', date: new Date().toISOString() } }, + { package: { name: 'foo', version: '2.0.0' } } + ] + }) + return getStream.array( + search.stream('oo', OPTS) + ).then(results => { + t.similar(results, [{ + name: 'cool', + version: '1.0.0' + }, { + name: 'foo', + version: '2.0.0' + }], 'has a stream-based API function with identical results') + }) +}) + +test('accepts a limit option', t => { + const query = qs.stringify({ + text: 'oo', + size: 3, + quality: 0.65, + popularity: 0.98, + maintenance: 0.5 + }) + tnock(t, REG).get(`/-/v1/search?${query}`).once().reply(200, { + objects: [ + { package: { name: 'cool', version: '1.0.0' } }, + { package: { name: 'cool', version: '1.0.0' } }, + { package: { name: 'cool', version: '1.0.0' } }, + { package: { name: 'cool', version: '1.0.0' } } + ] + }) + return search('oo', OPTS.concat({limit: 3})).then(results => { + t.equal(results.length, 4, 'returns more results if endpoint does so') + }) +}) + +test('accepts quality/mainenance/popularity options', t => { + const query = qs.stringify({ + text: 'oo', + size: 20, + quality: 1, + popularity: 2, + maintenance: 3 + }) + tnock(t, REG).get(`/-/v1/search?${query}`).once().reply(200, { + objects: [ + { package: { name: 'cool', version: '1.0.0' } }, + { package: { name: 'cool', version: '1.0.0' } }, + { package: { name: 'cool', version: '1.0.0' } }, + { package: { name: 'cool', version: '1.0.0' } } + ] + }) + return search('oo', OPTS.concat({ + quality: 1, + popularity: 2, + maintenance: 3 + })).then(results => { + t.equal(results.length, 4, 'returns more results if endpoint does so') + }) +}) + +test('sortBy: quality', t => { + const query = qs.stringify({ + text: 'oo', + size: 20, + quality: 1, + popularity: 0, + maintenance: 0 + }) + tnock(t, REG).get(`/-/v1/search?${query}`).once().reply(200, { + objects: [ + { package: { name: 'cool', version: '1.0.0' } }, + { package: { name: 'cool', version: '1.0.0' } }, + { package: { name: 'cool', version: '1.0.0' } }, + { package: { name: 'cool', version: '1.0.0' } } + ] + }) + return search('oo', OPTS.concat({ + sortBy: 'quality' + })).then(results => { + t.equal(results.length, 4, 'returns more results if endpoint does so') + }) +}) + +test('sortBy: popularity', t => { + const query = qs.stringify({ + text: 'oo', + size: 20, + quality: 0, + popularity: 1, + maintenance: 0 + }) + tnock(t, REG).get(`/-/v1/search?${query}`).once().reply(200, { + objects: [ + { package: { name: 'cool', version: '1.0.0' } }, + { package: { name: 'cool', version: '1.0.0' } }, + { package: { name: 'cool', version: '1.0.0' } }, + { package: { name: 'cool', version: '1.0.0' } } + ] + }) + return search('oo', OPTS.concat({ + sortBy: 'popularity' + })).then(results => { + t.equal(results.length, 4, 'returns more results if endpoint does so') + }) +}) + +test('sortBy: maintenance', t => { + const query = qs.stringify({ + text: 'oo', + size: 20, + quality: 0, + popularity: 0, + maintenance: 1 + }) + tnock(t, REG).get(`/-/v1/search?${query}`).once().reply(200, { + objects: [ + { package: { name: 'cool', version: '1.0.0' } }, + { package: { name: 'cool', version: '1.0.0' } }, + { package: { name: 'cool', version: '1.0.0' } }, + { package: { name: 'cool', version: '1.0.0' } } + ] + }) + return search('oo', OPTS.concat({ + sortBy: 'maintenance' + })).then(results => { + t.equal(results.length, 4, 'returns more results if endpoint does so') + }) +}) + +test('sortBy: optimal', t => { + const query = qs.stringify({ + text: 'oo', + size: 20, + quality: 0.65, + popularity: 0.98, + maintenance: 0.5 + }) + tnock(t, REG).get(`/-/v1/search?${query}`).once().reply(200, { + objects: [ + { package: { name: 'cool', version: '1.0.0' } }, + { package: { name: 'cool', version: '1.0.0' } }, + { package: { name: 'cool', version: '1.0.0' } }, + { package: { name: 'cool', version: '1.0.0' } } + ] + }) + return search('oo', OPTS.concat({ + sortBy: 'optimal' + })).then(results => { + t.equal(results.length, 4, 'returns more results if endpoint does so') + }) +}) + +test('detailed format', t => { + const query = qs.stringify({ + text: 'oo', + size: 20, + quality: 0, + popularity: 0, + maintenance: 1 + }) + const results = [ + { + package: { name: 'cool', version: '1.0.0' }, + score: { + final: 0.9237841281241451, + detail: { + quality: 0.9270640902288084, + popularity: 0.8484861649808381, + maintenance: 0.9962706951777409 + } + }, + searchScore: 100000.914 + }, + { + package: { name: 'ok', version: '2.0.0' }, + score: { + final: 0.9237841281451, + detail: { + quality: 0.9270602288084, + popularity: 0.8461649808381, + maintenance: 0.9706951777409 + } + }, + searchScore: 1000.91 + } + ] + tnock(t, REG).get(`/-/v1/search?${query}`).once().reply(200, { + objects: results + }) + return search('oo', OPTS.concat({ + sortBy: 'maintenance', + detailed: true + })).then(res => { + t.deepEqual(res, results, 'return full-format results with opts.detailed') + }) +}) + +test('space-separates and URI-encodes multiple search params', t => { + const query = qs.stringify({ + text: 'foo bar:baz quux?=', + size: 1, + quality: 1, + popularity: 2, + maintenance: 3 + }) + tnock(t, REG).get(`/-/v1/search?${query}`).reply(200, { objects: [] }) + return search(['foo', 'bar:baz', 'quux?='], OPTS.concat({ + limit: 1, + quality: 1, + popularity: 2, + maintenance: 3 + })).then( + () => t.ok(true, 'sent parameters correctly urlencoded') + ) +}) diff --git a/node_modules/libnpmsearch/test/util/tnock.js b/node_modules/libnpmsearch/test/util/tnock.js new file mode 100644 index 0000000000000..00b6e160e1019 --- /dev/null +++ b/node_modules/libnpmsearch/test/util/tnock.js @@ -0,0 +1,12 @@ +'use strict' + +const nock = require('nock') + +module.exports = tnock +function tnock (t, host) { + const server = nock(host) + t.tearDown(function () { + server.done() + }) + return server +} diff --git a/node_modules/libnpmteam/.travis.yml b/node_modules/libnpmteam/.travis.yml new file mode 100644 index 0000000000000..db5ea8b018640 --- /dev/null +++ b/node_modules/libnpmteam/.travis.yml @@ -0,0 +1,7 @@ +language: node_js +sudo: false +node_js: + - "10" + - "9" + - "8" + - "6" diff --git a/node_modules/libnpmteam/CHANGELOG.md b/node_modules/libnpmteam/CHANGELOG.md new file mode 100644 index 0000000000000..65a73146edb44 --- /dev/null +++ b/node_modules/libnpmteam/CHANGELOG.md @@ -0,0 +1,18 @@ +# Change Log + +All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. + + +## [1.0.1](https://github.com/npm/libnpmteam/compare/v1.0.0...v1.0.1) (2018-08-24) + + + + +# 1.0.0 (2018-08-22) + + +### Features + +* **api:** implement team api ([50dd0e1](https://github.com/npm/libnpmteam/commit/50dd0e1)) +* **docs:** add fully-documented readme ([b1370f3](https://github.com/npm/libnpmteam/commit/b1370f3)) +* **test:** test --100 ftw ([9d3bdc3](https://github.com/npm/libnpmteam/commit/9d3bdc3)) diff --git a/node_modules/libnpmteam/CODE_OF_CONDUCT.md b/node_modules/libnpmteam/CODE_OF_CONDUCT.md new file mode 100644 index 0000000000000..aeb72f598dcb4 --- /dev/null +++ b/node_modules/libnpmteam/CODE_OF_CONDUCT.md @@ -0,0 +1,151 @@ +# Code of Conduct + +## When Something Happens + +If you see a Code of Conduct violation, follow these steps: + +1. Let the person know that what they did is not appropriate and ask them to stop and/or edit their message(s) or commits. +2. That person should immediately stop the behavior and correct the issue. +3. If this doesn’t happen, or if you're uncomfortable speaking up, [contact the maintainers](#contacting-maintainers). +4. As soon as available, a maintainer will look into the issue, and take [further action (see below)](#further-enforcement), starting with a warning, then temporary block, then long-term repo or organization ban. + +When reporting, please include any relevant details, links, screenshots, context, or other information that may be used to better understand and resolve the situation. + +**The maintainer team will prioritize the well-being and comfort of the recipients of the violation over the comfort of the violator.** See [some examples below](#enforcement-examples). + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as contributors and maintainers of this project pledge to making participation in our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, technical preferences, nationality, personal appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment include: + + * Using welcoming and inclusive language. + * Being respectful of differing viewpoints and experiences. + * Gracefully accepting constructive feedback. + * Focusing on what is best for the community. + * Showing empathy and kindness towards other community members. + * Encouraging and raising up your peers in the project so you can all bask in hacks and glory. + +Examples of unacceptable behavior by participants include: + + * The use of sexualized language or imagery and unwelcome sexual attention or advances, including when simulated online. The only exception to sexual topics is channels/spaces specifically for topics of sexual identity. + * Casual mention of slavery or indentured servitude and/or false comparisons of one's occupation or situation to slavery. Please consider using or asking about alternate terminology when referring to such metaphors in technology. + * Making light of/making mocking comments about trigger warnings and content warnings. + * Trolling, insulting/derogatory comments, and personal or political attacks. + * Public or private harassment, deliberate intimidation, or threats. + * Publishing others' private information, such as a physical or electronic address, without explicit permission. This includes any sort of "outing" of any aspect of someone's identity without their consent. + * Publishing private screenshots or quotes of interactions in the context of this project without all quoted users' *explicit* consent. + * Publishing of private communication that doesn't have to do with reporting harrassment. + * Any of the above even when [presented as "ironic" or "joking"](https://en.wikipedia.org/wiki/Hipster_racism). + * Any attempt to present "reverse-ism" versions of the above as violations. Examples of reverse-isms are "reverse racism", "reverse sexism", "heterophobia", and "cisphobia". + * Unsolicited explanations under the assumption that someone doesn't already know it. Ask before you teach! Don't assume what people's knowledge gaps are. + * [Feigning or exaggerating surprise](https://www.recurse.com/manual#no-feigned-surprise) when someone admits to not knowing something. + * "[Well-actuallies](https://www.recurse.com/manual#no-well-actuallys)" + * Other conduct which could reasonably be considered inappropriate in a professional or community setting. + +## Scope + +This Code of Conduct applies both within spaces involving this project and in other spaces involving community members. This includes the repository, its Pull Requests and Issue tracker, its Twitter community, private email communications in the context of the project, and any events where members of the project are participating, as well as adjacent communities and venues affecting the project's members. + +Depending on the violation, the maintainers may decide that violations of this code of conduct that have happened outside of the scope of the community may deem an individual unwelcome, and take appropriate action to maintain the comfort and safety of its members. + +### Other Community Standards + +As a project on GitHub, this project is additionally covered by the [GitHub Community Guidelines](https://help.github.com/articles/github-community-guidelines/). + +Additionally, as a project hosted on npm, is is covered by [npm, Inc's Code of Conduct](https://www.npmjs.com/policies/conduct). + +Enforcement of those guidelines after violations overlapping with the above are the responsibility of the entities, and enforcement may happen in any or all of the services/communities. + +## Maintainer Enforcement Process + +Once the maintainers get involved, they will follow a documented series of steps and do their best to preserve the well-being of project members. This section covers actual concrete steps. + +### Contacting Maintainers + +You may get in touch with the maintainer team through any of the following methods: + + * Through email: + * [kzm@zkat.tech](mailto:kzm@zkat.tech) (Kat Marchán) + + * Through Twitter: + * [@maybekatz](https://twitter.com/maybekatz) (Kat Marchán) + +### Further Enforcement + +If you've already followed the [initial enforcement steps](#enforcement), these are the steps maintainers will take for further enforcement, as needed: + + 1. Repeat the request to stop. + 2. If the person doubles down, they will have offending messages removed or edited by a maintainers given an official warning. The PR or Issue may be locked. + 3. If the behavior continues or is repeated later, the person will be blocked from participating for 24 hours. + 4. If the behavior continues or is repeated after the temporary block, a long-term (6-12mo) ban will be used. + +On top of this, maintainers may remove any offending messages, images, contributions, etc, as they deem necessary. + +Maintainers reserve full rights to skip any of these steps, at their discretion, if the violation is considered to be a serious and/or immediate threat to the health and well-being of members of the community. These include any threats, serious physical or verbal attacks, and other such behavior that would be completely unacceptable in any social setting that puts our members at risk. + +Members expelled from events or venues with any sort of paid attendance will not be refunded. + +### Who Watches the Watchers? + +Maintainers and other leaders who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. These may include anything from removal from the maintainer team to a permanent ban from the community. + +Additionally, as a project hosted on both GitHub and npm, [their own Codes of Conducts may be applied against maintainers of this project](#other-community-standards), externally of this project's procedures. + +### Enforcement Examples + +#### The Best Case + +The vast majority of situations work out like this. This interaction is common, and generally positive. + +> Alex: "Yeah I used X and it was really crazy!" + +> Patt (not a maintainer): "Hey, could you not use that word? What about 'ridiculous' instead?" + +> Alex: "oh sorry, sure." -> edits old comment to say "it was really confusing!" + +#### The Maintainer Case + +Sometimes, though, you need to get maintainers involved. Maintainers will do their best to resolve conflicts, but people who were harmed by something **will take priority**. + +> Patt: "Honestly, sometimes I just really hate using $library and anyone who uses it probably sucks at their job." + +> Alex: "Whoa there, could you dial it back a bit? There's a CoC thing about attacking folks' tech use like that." + +> Patt: "I'm not attacking anyone, what's your problem?" + +> Alex: "@maintainers hey uh. Can someone look at this issue? Patt is getting a bit aggro. I tried to nudge them about it, but nope." + +> KeeperOfCommitBits: (on issue) "Hey Patt, maintainer here. Could you tone it down? This sort of attack is really not okay in this space." + +> Patt: "Leave me alone I haven't said anything bad wtf is wrong with you." + +> KeeperOfCommitBits: (deletes user's comment), "@patt I mean it. Please refer to the CoC over at (URL to this CoC) if you have questions, but you can consider this an actual warning. I'd appreciate it if you reworded your messages in this thread, since they made folks there uncomfortable. Let's try and be kind, yeah?" + +> Patt: "@keeperofbits Okay sorry. I'm just frustrated and I'm kinda burnt out and I guess I got carried away. I'll DM Alex a note apologizing and edit my messages. Sorry for the trouble." + +> KeeperOfCommitBits: "@patt Thanks for that. I hear you on the stress. Burnout sucks :/. Have a good one!" + +#### The Nope Case + +> PepeTheFrog🐸: "Hi, I am a literal actual nazi and I think white supremacists are quite fashionable." + +> Patt: "NOOOOPE. OH NOPE NOPE." + +> Alex: "JFC NO. NOPE. @keeperofbits NOPE NOPE LOOK HERE" + +> KeeperOfCommitBits: "👀 Nope. NOPE NOPE NOPE. 🔥" + +> PepeTheFrog🐸 has been banned from all organization or user repositories belonging to KeeperOfCommitBits. + +## Attribution + +This Code of Conduct was generated using [WeAllJS Code of Conduct Generator](https://npm.im/weallbehave), which is based on the [WeAllJS Code of +Conduct](https://wealljs.org/code-of-conduct), which is itself based on +[Contributor Covenant](http://contributor-covenant.org), version 1.4, available +at +[http://contributor-covenant.org/version/1/4](http://contributor-covenant.org/version/1/4), +and the LGBTQ in Technology Slack [Code of +Conduct](http://lgbtq.technology/coc.html). diff --git a/node_modules/libnpmteam/CONTRIBUTING.md b/node_modules/libnpmteam/CONTRIBUTING.md new file mode 100644 index 0000000000000..3fd40076caae8 --- /dev/null +++ b/node_modules/libnpmteam/CONTRIBUTING.md @@ -0,0 +1,256 @@ +# Contributing + +## How do I... + +* [Use This Guide](#introduction)? +* Ask or Say Something? 🤔🐛😱 + * [Request Support](#request-support) + * [Report an Error or Bug](#report-an-error-or-bug) + * [Request a Feature](#request-a-feature) +* Make Something? 🤓👩🏽‍💻📜🍳 + * [Project Setup](#project-setup) + * [Contribute Documentation](#contribute-documentation) + * [Contribute Code](#contribute-code) +* Manage Something ✅🙆🏼💃👔 + * [Provide Support on Issues](#provide-support-on-issues) + * [Label Issues](#label-issues) + * [Clean Up Issues and PRs](#clean-up-issues-and-prs) + * [Review Pull Requests](#review-pull-requests) + * [Merge Pull Requests](#merge-pull-requests) + * [Tag a Release](#tag-a-release) + * [Join the Project Team](#join-the-project-team) +* Add a Guide Like This One [To My Project](#attribution)? 🤖😻👻 + +## Introduction + +Thank you so much for your interest in contributing!. All types of contributions are encouraged and valued. See the [table of contents](#toc) for different ways to help and details about how this project handles them!📝 + +Please make sure to read the relevant section before making your contribution! It will make it a lot easier for us maintainers to make the most of it and smooth out the experience for all involved. 💚 + +The [Project Team](#join-the-project-team) looks forward to your contributions. 🙌🏾✨ + +## Request Support + +If you have a question about this project, how to use it, or just need clarification about something: + +* Open an Issue at https://github.com/npm/libnpmteam/issues +* Provide as much context as you can about what you're running into. +* Provide project and platform versions (nodejs, npm, etc), depending on what seems relevant. If not, please be ready to provide that information if maintainers ask for it. + +Once it's filed: + +* The project team will [label the issue](#label-issues). +* Someone will try to have a response soon. +* If you or the maintainers don't respond to an issue for 30 days, the [issue will be closed](#clean-up-issues-and-prs). If you want to come back to it, reply (once, please), and we'll reopen the existing issue. Please avoid filing new issues as extensions of one you already made. + +## Report an Error or Bug + +If you run into an error or bug with the project: + +* Open an Issue at https://github.com/npm/libnpmteam/issues +* Include *reproduction steps* that someone else can follow to recreate the bug or error on their own. +* Provide project and platform versions (nodejs, npm, etc), depending on what seems relevant. If not, please be ready to provide that information if maintainers ask for it. + +Once it's filed: + +* The project team will [label the issue](#label-issues). +* A team member will try to reproduce the issue with your provided steps. If there are no repro steps or no obvious way to reproduce the issue, the team will ask you for those steps and mark the issue as `needs-repro`. Bugs with the `needs-repro` tag will not be addressed until they are reproduced. +* If the team is able to reproduce the issue, it will be marked `needs-fix`, as well as possibly other tags (such as `critical`), and the issue will be left to be [implemented by someone](#contribute-code). +* If you or the maintainers don't respond to an issue for 30 days, the [issue will be closed](#clean-up-issues-and-prs). If you want to come back to it, reply (once, please), and we'll reopen the existing issue. Please avoid filing new issues as extensions of one you already made. +* `critical` issues may be left open, depending on perceived immediacy and severity, even past the 30 day deadline. + +## Request a Feature + +If the project doesn't do something you need or want it to do: + +* Open an Issue at https://github.com/npm/libnpmteam/issues +* Provide as much context as you can about what you're running into. +* Please try and be clear about why existing features and alternatives would not work for you. + +Once it's filed: + +* The project team will [label the issue](#label-issues). +* The project team will evaluate the feature request, possibly asking you more questions to understand its purpose and any relevant requirements. If the issue is closed, the team will convey their reasoning and suggest an alternative path forward. +* If the feature request is accepted, it will be marked for implementation with `feature-accepted`, which can then be done by either by a core team member or by anyone in the community who wants to [contribute code](#contribute-code). + +Note: The team is unlikely to be able to accept every single feature request that is filed. Please understand if they need to say no. + +## Project Setup + +So you wanna contribute some code! That's great! This project uses GitHub Pull Requests to manage contributions, so [read up on how to fork a GitHub project and file a PR](https://guides.github.com/activities/forking) if you've never done it before. + +If this seems like a lot or you aren't able to do all this setup, you might also be able to [edit the files directly](https://help.github.com/articles/editing-files-in-another-user-s-repository/) without having to do any of this setup. Yes, [even code](#contribute-code). + +If you want to go the usual route and run the project locally, though: + +* [Install Node.js](https://nodejs.org/en/download/) +* [Fork the project](https://guides.github.com/activities/forking/#fork) + +Then in your terminal: +* `cd path/to/your/clone` +* `npm install` +* `npm test` + +And you should be ready to go! + +## Contribute Documentation + +Documentation is a super important, critical part of this project. Docs are how we keep track of what we're doing, how, and why. It's how we stay on the same page about our policies. And it's how we tell others everything they need in order to be able to use this project -- or contribute to it. So thank you in advance. + +Documentation contributions of any size are welcome! Feel free to file a PR even if you're just rewording a sentence to be more clear, or fixing a spelling mistake! + +To contribute documentation: + +* [Set up the project](#project-setup). +* Edit or add any relevant documentation. +* Make sure your changes are formatted correctly and consistently with the rest of the documentation. +* Re-read what you wrote, and run a spellchecker on it to make sure you didn't miss anything. +* In your commit message(s), begin the first line with `docs: `. For example: `docs: Adding a doc contrib section to CONTRIBUTING.md`. +* Write clear, concise commit message(s) using [conventional-changelog format](https://github.com/conventional-changelog/conventional-changelog-angular/blob/master/convention.md). Documentation commits should use `docs(): `. +* Go to https://github.com/npm/libnpmteam/pulls and open a new pull request with your changes. +* If your PR is connected to an open issue, add a line in your PR's description that says `Fixes: #123`, where `#123` is the number of the issue you're fixing. + +Once you've filed the PR: + +* One or more maintainers will use GitHub's review feature to review your PR. +* If the maintainer asks for any changes, edit your changes, push, and ask for another review. +* If the maintainer decides to pass on your PR, they will thank you for the contribution and explain why they won't be accepting the changes. That's ok! We still really appreciate you taking the time to do it, and we don't take that lightly. 💚 +* If your PR gets accepted, it will be marked as such, and merged into the `latest` branch soon after. Your contribution will be distributed to the masses next time the maintainers [tag a release](#tag-a-release) + +## Contribute Code + +We like code commits a lot! They're super handy, and they keep the project going and doing the work it needs to do to be useful to others. + +Code contributions of just about any size are acceptable! + +The main difference between code contributions and documentation contributions is that contributing code requires inclusion of relevant tests for the code being added or changed. Contributions without accompanying tests will be held off until a test is added, unless the maintainers consider the specific tests to be either impossible, or way too much of a burden for such a contribution. + +To contribute code: + +* [Set up the project](#project-setup). +* Make any necessary changes to the source code. +* Include any [additional documentation](#contribute-documentation) the changes might need. +* Write tests that verify that your contribution works as expected. +* Write clear, concise commit message(s) using [conventional-changelog format](https://github.com/conventional-changelog/conventional-changelog-angular/blob/master/convention.md). +* Dependency updates, additions, or removals must be in individual commits, and the message must use the format: `(deps): PKG@VERSION`, where `` is any of the usual `conventional-changelog` prefixes, at your discretion. +* Go to https://github.com/npm/libnpmteam/pulls and open a new pull request with your changes. +* If your PR is connected to an open issue, add a line in your PR's description that says `Fixes: #123`, where `#123` is the number of the issue you're fixing. + +Once you've filed the PR: + +* Barring special circumstances, maintainers will not review PRs until all checks pass (Travis, AppVeyor, etc). +* One or more maintainers will use GitHub's review feature to review your PR. +* If the maintainer asks for any changes, edit your changes, push, and ask for another review. Additional tags (such as `needs-tests`) will be added depending on the review. +* If the maintainer decides to pass on your PR, they will thank you for the contribution and explain why they won't be accepting the changes. That's ok! We still really appreciate you taking the time to do it, and we don't take that lightly. 💚 +* If your PR gets accepted, it will be marked as such, and merged into the `latest` branch soon after. Your contribution will be distributed to the masses next time the maintainers [tag a release](#tag-a-release) + +## Provide Support on Issues + +[Needs Collaborator](#join-the-project-team): none + +Helping out other users with their questions is a really awesome way of contributing to any community. It's not uncommon for most of the issues on an open source projects being support-related questions by users trying to understand something they ran into, or find their way around a known bug. + +Sometimes, the `support` label will be added to things that turn out to actually be other things, like bugs or feature requests. In that case, suss out the details with the person who filed the original issue, add a comment explaining what the bug is, and change the label from `support` to `bug` or `feature`. If you can't do this yourself, @mention a maintainer so they can do it. + +In order to help other folks out with their questions: + +* Go to the issue tracker and [filter open issues by the `support` label](https://github.com/npm/libnpmteam/issues?q=is%3Aopen+is%3Aissue+label%3Asupport). +* Read through the list until you find something that you're familiar enough with to give an answer to. +* Respond to the issue with whatever details are needed to clarify the question, or get more details about what's going on. +* Once the discussion wraps up and things are clarified, either close the issue, or ask the original issue filer (or a maintainer) to close it for you. + +Some notes on picking up support issues: + +* Avoid responding to issues you don't know you can answer accurately. +* As much as possible, try to refer to past issues with accepted answers. Link to them from your replies with the `#123` format. +* Be kind and patient with users -- often, folks who have run into confusing things might be upset or impatient. This is ok. Try to understand where they're coming from, and if you're too uncomfortable with the tone, feel free to stay away or withdraw from the issue. (note: if the user is outright hostile or is violating the CoC, [refer to the Code of Conduct](CODE_OF_CONDUCT.md) to resolve the conflict). + +## Label Issues + +[Needs Collaborator](#join-the-project-team): Issue Tracker + +One of the most important tasks in handling issues is labeling them usefully and accurately. All other tasks involving issues ultimately rely on the issue being classified in such a way that relevant parties looking to do their own tasks can find them quickly and easily. + +In order to label issues, [open up the list of unlabeled issues](https://github.com/npm/libnpmteam/issues?q=is%3Aopen+is%3Aissue+no%3Alabel) and, **from newest to oldest**, read through each one and apply issue labels according to the table below. If you're unsure about what label to apply, skip the issue and try the next one: don't feel obligated to label each and every issue yourself! + +Label | Apply When | Notes +--- | --- | --- +`bug` | Cases where the code (or documentation) is behaving in a way it wasn't intended to. | If something is happening that surprises the *user* but does not go against the way the code is designed, it should use the `enhancement` label. +`critical` | Added to `bug` issues if the problem described makes the code completely unusable in a common situation. | +`documentation` | Added to issues or pull requests that affect any of the documentation for the project. | Can be combined with other labels, such as `bug` or `enhancement`. +`duplicate` | Added to issues or PRs that refer to the exact same issue as another one that's been previously labeled. | Duplicate issues should be marked and closed right away, with a message referencing the issue it's a duplicate of (with `#123`) +`enhancement` | Added to [feature requests](#request-a-feature), PRs, or documentation issues that are purely additive: the code or docs currently work as expected, but a change is being requested or suggested. | +`help wanted` | Applied by [Committers](#join-the-project-team) to issues and PRs that they would like to get outside help for. Generally, this means it's lower priority for the maintainer team to itself implement, but that the community is encouraged to pick up if they so desire | Never applied on first-pass labeling. +`in-progress` | Applied by [Committers](#join-the-project-team) to PRs that are pending some work before they're ready for review. | The original PR submitter should @mention the team member that applied the label once the PR is complete. +`performance` | This issue or PR is directly related to improving performance. | +`refactor` | Added to issues or PRs that deal with cleaning up or modifying the project for the betterment of it. | +`starter` | Applied by [Committers](#join-the-project-team) to issues that they consider good introductions to the project for people who have not contributed before. These are not necessarily "easy", but rather focused around how much context is necessary in order to understand what needs to be done for this project in particular. | Existing project members are expected to stay away from these unless they increase in priority. +`support` | This issue is either asking a question about how to use the project, clarifying the reason for unexpected behavior, or possibly reporting a `bug` but does not have enough detail yet to determine whether it would count as such. | The label should be switched to `bug` if reliable reproduction steps are provided. Issues primarily with unintended configurations of a user's environment are not considered bugs, even if they cause crashes. +`tests` | This issue or PR either requests or adds primarily tests to the project. | If a PR is pending tests, that will be handled through the [PR review process](#review-pull-requests) +`wontfix` | Labelers may apply this label to issues that clearly have nothing at all to do with the project or are otherwise entirely outside of its scope/sphere of influence. [Committers](#join-the-project-team) may apply this label and close an issue or PR if they decide to pass on an otherwise relevant issue. | The issue or PR should be closed as soon as the label is applied, and a clear explanation provided of why the label was used. Contributors are free to contest the labeling, but the decision ultimately falls on committers as to whether to accept something or not. + +## Clean Up Issues and PRs + +[Needs Collaborator](#join-the-project-team): Issue Tracker + +Issues and PRs can go stale after a while. Maybe they're abandoned. Maybe the team will just plain not have time to address them any time soon. + +In these cases, they should be closed until they're brought up again or the interaction starts over. + +To clean up issues and PRs: + +* Search the issue tracker for issues or PRs, and add the term `updated:<=YYYY-MM-DD`, where the date is 30 days before today. +* Go through each issue *from oldest to newest*, and close them if **all of the following are true**: + * not opened by a maintainer + * not marked as `critical` + * not marked as `starter` or `help wanted` (these might stick around for a while, in general, as they're intended to be available) + * no explicit messages in the comments asking for it to be left open + * does not belong to a milestone +* Leave a message when closing saying "Cleaning up stale issue. Please reopen or ping us if and when you're ready to resume this. See https://github.com/npm/libnpmteam/blob/latest/CONTRIBUTING.md#clean-up-issues-and-prs for more details." + +## Review Pull Requests + +[Needs Collaborator](#join-the-project-team): Issue Tracker + +While anyone can comment on a PR, add feedback, etc, PRs are only *approved* by team members with Issue Tracker or higher permissions. + +PR reviews use [GitHub's own review feature](https://help.github.com/articles/about-pull-request-reviews/), which manages comments, approval, and review iteration. + +Some notes: + +* You may ask for minor changes ("nitpicks"), but consider whether they are really blockers to merging: try to err on the side of "approve, with comments". +* *ALL PULL REQUESTS* should be covered by a test: either by a previously-failing test, an existing test that covers the entire functionality of the submitted code, or new tests to verify any new/changed behavior. All tests must also pass and follow established conventions. Test coverage should not drop, unless the specific case is considered reasonable by maintainers. +* Please make sure you're familiar with the code or documentation being updated, unless it's a minor change (spellchecking, minor formatting, etc). You may @mention another project member who you think is better suited for the review, but still provide a non-approving review of your own. +* Be extra kind: people who submit code/doc contributions are putting themselves in a pretty vulnerable position, and have put time and care into what they've done (even if that's not obvious to you!) -- always respond with respect, be understanding, but don't feel like you need to sacrifice your standards for their sake, either. Just don't be a jerk about it? + +## Merge Pull Requests + +[Needs Collaborator](#join-the-project-team): Committer + +TBD - need to hash out a bit more of this process. + +## Tag A Release + +[Needs Collaborator](#join-the-project-team): Committer + +TBD - need to hash out a bit more of this process. The most important bit here is probably that all tests must pass, and tags must use [semver](https://semver.org). + +## Join the Project Team + +### Ways to Join + +There are many ways to contribute! Most of them don't require any official status unless otherwise noted. That said, there's a couple of positions that grant special repository abilities, and this section describes how they're granted and what they do. + +All of the below positions are granted based on the project team's needs, as well as their consensus opinion about whether they would like to work with the person and think that they would fit well into that position. The process is relatively informal, and it's likely that people who express interest in participating can just be granted the permissions they'd like. + +You can spot a collaborator on the repo by looking for the `[Collaborator]` or `[Owner]` tags next to their names. + +Permission | Description +--- | --- +Issue Tracker | Granted to contributors who express a strong interest in spending time on the project's issue tracker. These tasks are mainly [labeling issues](#label-issues), [cleaning up old ones](#clean-up-issues-and-prs), and [reviewing pull requests](#review-pull-requests), as well as all the usual things non-team-member contributors can do. Issue handlers should not merge pull requests, tag releases, or directly commit code themselves: that should still be done through the usual pull request process. Becoming an Issue Handler means the project team trusts you to understand enough of the team's process and context to implement it on the issue tracker. +Committer | Granted to contributors who want to handle the actual pull request merges, tagging new versions, etc. Committers should have a good level of familiarity with the codebase, and enough context to understand the implications of various changes, as well as a good sense of the will and expectations of the project team. +Admin/Owner | Granted to people ultimately responsible for the project, its community, etc. + +## Attribution + +This guide was generated using the WeAllJS `CONTRIBUTING.md` generator. [Make your own](https://npm.im/weallcontribute)! diff --git a/node_modules/libnpmteam/LICENSE b/node_modules/libnpmteam/LICENSE new file mode 100644 index 0000000000000..209e4477f39c1 --- /dev/null +++ b/node_modules/libnpmteam/LICENSE @@ -0,0 +1,13 @@ +Copyright npm, Inc + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/node_modules/libnpmteam/PULL_REQUEST_TEMPLATE b/node_modules/libnpmteam/PULL_REQUEST_TEMPLATE new file mode 100644 index 0000000000000..9471c6d325f7e --- /dev/null +++ b/node_modules/libnpmteam/PULL_REQUEST_TEMPLATE @@ -0,0 +1,7 @@ + diff --git a/node_modules/libnpmteam/README.md b/node_modules/libnpmteam/README.md new file mode 100644 index 0000000000000..e0e771c7fac86 --- /dev/null +++ b/node_modules/libnpmteam/README.md @@ -0,0 +1,185 @@ +# libnpmteam [![npm version](https://img.shields.io/npm/v/libnpmteam.svg)](https://npm.im/libnpmteam) [![license](https://img.shields.io/npm/l/libnpmteam.svg)](https://npm.im/libnpmteam) [![Travis](https://img.shields.io/travis/npm/libnpmteam/latest.svg)](https://travis-ci.org/npm/libnpmteam) [![AppVeyor](https://img.shields.io/appveyor/ci/zkat/libnpmteam/latest.svg)](https://ci.appveyor.com/project/zkat/libnpmteam) [![Coverage Status](https://coveralls.io/repos/github/npm/libnpmteam/badge.svg?branch=latest)](https://coveralls.io/github/npm/libnpmteam?branch=latest) + +[`libnpmteam`](https://github.com/npm/libnpmteam) is a Node.js +library that provides programmatic access to the guts of the npm CLI's `npm +team` command and its various subcommands. + +## Example + +```javascript +const access = require('libnpmteam') + +// List all teams for the @npm org. +console.log(await team.lsTeams('npm')) +``` + +## Table of Contents + +* [Installing](#install) +* [Example](#example) +* [Contributing](#contributing) +* [API](#api) + * [team opts](#opts) + * [`create()`](#create) + * [`destroy()`](#destroy) + * [`add()`](#add) + * [`rm()`](#rm) + * [`lsTeams()`](#ls-teams) + * [`lsTeams.stream()`](#ls-teams-stream) + * [`lsUsers()`](#ls-users) + * [`lsUsers.stream()`](#ls-users-stream) + +### Install + +`$ npm install libnpmteam` + +### Contributing + +The npm team enthusiastically welcomes contributions and project participation! +There's a bunch of things you can do if you want to contribute! The [Contributor +Guide](CONTRIBUTING.md) has all the information you need for everything from +reporting bugs to contributing entire new features. Please don't hesitate to +jump in if you'd like to, or even ask us questions if something isn't clear. + +All participants and maintainers in this project are expected to follow [Code of +Conduct](CODE_OF_CONDUCT.md), and just generally be excellent to each other. + +Please refer to the [Changelog](CHANGELOG.md) for project history details, too. + +Happy hacking! + +### API + +#### `opts` for `libnpmteam` commands + +`libnpmteam` uses [`npm-registry-fetch`](https://npm.im/npm-registry-fetch). +All options are passed through directly to that library, so please refer to [its +own `opts` +documentation](https://www.npmjs.com/package/npm-registry-fetch#fetch-options) +for options that can be passed in. + +A couple of options of note for those in a hurry: + +* `opts.token` - can be passed in and will be used as the authentication token for the registry. For other ways to pass in auth details, see the n-r-f docs. +* `opts.otp` - certain operations will require an OTP token to be passed in. If a `libnpmteam` command fails with `err.code === EOTP`, please retry the request with `{otp: <2fa token>}` +* `opts.Promise` - If you pass this in, the Promises returned by `libnpmteam` commands will use this Promise class instead. For example: `{Promise: require('bluebird')}` + +#### `> team.create(team, [opts]) -> Promise` + +Creates a team named `team`. Team names use the format `@:`, with +the `@` being optional. + +Additionally, `opts.description` may be passed in to include a description. + +##### Example + +```javascript +await team.create('@npm:cli', {token: 'myregistrytoken'}) +// The @npm:cli team now exists. +``` + +#### `> team.destroy(team, [opts]) -> Promise` + +Destroys a team named `team`. Team names use the format `@:`, with +the `@` being optional. + +##### Example + +```javascript +await team.destroy('@npm:cli', {token: 'myregistrytoken'}) +// The @npm:cli team has been destroyed. +``` + +#### `> team.add(user, team, [opts]) -> Promise` + +Adds `user` to `team`. + +##### Example + +```javascript +await team.add('zkat', '@npm:cli', {token: 'myregistrytoken'}) +// @zkat now belongs to the @npm:cli team. +``` + +#### `> team.rm(user, team, [opts]) -> Promise` + +Removes `user` from `team`. + +##### Example + +```javascript +await team.rm('zkat', '@npm:cli', {token: 'myregistrytoken'}) +// @zkat is no longer part of the @npm:cli team. +``` + +#### `> team.lsTeams(scope, [opts]) -> Promise` + +Resolves to an array of team names belonging to `scope`. + +##### Example + +```javascript +await team.lsTeams('@npm', {token: 'myregistrytoken'}) +=> +[ + 'npm:cli', + 'npm:web', + 'npm:registry', + 'npm:developers' +] +``` + +#### `> team.lsTeams.stream(scope, [opts]) -> Stream` + +Returns a stream of teams belonging to `scope`. + +For a Promise-based version of these results, see [`team.lsTeams()`](#ls-teams). + +##### Example + +```javascript +for await (let team of team.lsTeams.stream('@npm', {token: 'myregistrytoken'})) { + console.log(team) +} + +// outputs +// npm:cli +// npm:web +// npm:registry +// npm:developers +``` + +#### `> team.lsUsers(team, [opts]) -> Promise` + +Resolves to an array of usernames belonging to `team`. + +For a streamed version of these results, see [`team.lsUsers.stream()`](#ls-users-stream). + +##### Example + +```javascript +await team.lsUsers('@npm:cli', {token: 'myregistrytoken'}) +=> +[ + 'iarna', + 'zkat' +] +``` + +#### `> team.lsUsers.stream(team, [opts]) -> Stream` + +Returns a stream of usernames belonging to `team`. + +For a Promise-based version of these results, see [`team.lsUsers()`](#ls-users). + +##### Example + +```javascript +for await (let user of team.lsUsers.stream('@npm:cli', {token: 'myregistrytoken'})) { + console.log(user) +} + +// outputs +// iarna +// zkat +``` diff --git a/node_modules/libnpmteam/appveyor.yml b/node_modules/libnpmteam/appveyor.yml new file mode 100644 index 0000000000000..9cc64c58e02f9 --- /dev/null +++ b/node_modules/libnpmteam/appveyor.yml @@ -0,0 +1,22 @@ +environment: + matrix: + - nodejs_version: "10" + - nodejs_version: "9" + - nodejs_version: "8" + - nodejs_version: "6" + +platform: + - x64 + +install: + - ps: Install-Product node $env:nodejs_version $env:platform + - npm config set spin false + - npm install + +test_script: + - npm test + +matrix: + fast_finish: true + +build: off diff --git a/node_modules/libnpmteam/index.js b/node_modules/libnpmteam/index.js new file mode 100644 index 0000000000000..c0bd0609aab25 --- /dev/null +++ b/node_modules/libnpmteam/index.js @@ -0,0 +1,106 @@ +'use strict' + +const eu = encodeURIComponent +const figgyPudding = require('figgy-pudding') +const getStream = require('get-stream') +const npmFetch = require('npm-registry-fetch') +const validate = require('aproba') + +const TeamConfig = figgyPudding({ + description: {}, + Promise: {default: () => Promise} +}) + +const cmd = module.exports = {} + +cmd.create = (entity, opts) => { + opts = TeamConfig(opts) + return pwrap(opts, () => { + const {scope, team} = splitEntity(entity) + validate('SSO', [scope, team, opts]) + return npmFetch.json(`/-/org/${eu(scope)}/team`, opts.concat({ + method: 'PUT', + scope, + body: {name: team, description: opts.description} + })) + }) +} + +cmd.destroy = (entity, opts) => { + opts = TeamConfig(opts) + return pwrap(opts, () => { + const {scope, team} = splitEntity(entity) + validate('SSO', [scope, team, opts]) + return npmFetch.json(`/-/team/${eu(scope)}/${eu(team)}`, opts.concat({ + method: 'DELETE', + scope + })) + }) +} + +cmd.add = (user, entity, opts) => { + opts = TeamConfig(opts) + return pwrap(opts, () => { + const {scope, team} = splitEntity(entity) + validate('SSO', [scope, team, opts]) + return npmFetch.json(`/-/team/${eu(scope)}/${eu(team)}/user`, opts.concat({ + method: 'PUT', + scope, + body: {user} + })) + }) +} + +cmd.rm = (user, entity, opts) => { + opts = TeamConfig(opts) + return pwrap(opts, () => { + const {scope, team} = splitEntity(entity) + validate('SSO', [scope, team, opts]) + return npmFetch.json(`/-/team/${eu(scope)}/${eu(team)}/user`, opts.concat({ + method: 'DELETE', + scope, + body: {user} + })) + }) +} + +cmd.lsTeams = (scope, opts) => { + opts = TeamConfig(opts) + return pwrap(opts, () => getStream.array(cmd.lsTeams.stream(scope, opts))) +} +cmd.lsTeams.stream = (scope, opts) => { + opts = TeamConfig(opts) + validate('SO', [scope, opts]) + return npmFetch.json.stream(`/-/org/${eu(scope)}/team`, '.*', opts.concat({ + query: {format: 'cli'} + })) +} + +cmd.lsUsers = (entity, opts) => { + opts = TeamConfig(opts) + return pwrap(opts, () => getStream.array(cmd.lsUsers.stream(entity, opts))) +} +cmd.lsUsers.stream = (entity, opts) => { + opts = TeamConfig(opts) + const {scope, team} = splitEntity(entity) + validate('SSO', [scope, team, opts]) + const uri = `/-/team/${eu(scope)}/${eu(team)}/user` + return npmFetch.json.stream(uri, '.*', opts.concat({ + query: {format: 'cli'} + })) +} + +cmd.edit = () => { + throw new Error('edit is not implemented yet') +} + +function splitEntity (entity = '') { + let [, scope, team] = entity.match(/^@?([^:]+):(.*)$/) || [] + return {scope, team} +} + +function pwrap (opts, fn) { + return new opts.Promise((resolve, reject) => { + fn().then(resolve, reject) + }) +} diff --git a/node_modules/libnpmteam/node_modules/aproba/CHANGELOG.md b/node_modules/libnpmteam/node_modules/aproba/CHANGELOG.md new file mode 100644 index 0000000000000..bab30ecb7e625 --- /dev/null +++ b/node_modules/libnpmteam/node_modules/aproba/CHANGELOG.md @@ -0,0 +1,4 @@ +2.0.0 + * Drop support for 0.10 and 0.12. They haven't been in travis but still, + since we _know_ we'll break with them now it's only polite to do a + major bump. diff --git a/node_modules/libnpmteam/node_modules/aproba/LICENSE b/node_modules/libnpmteam/node_modules/aproba/LICENSE new file mode 100644 index 0000000000000..f4be44d881b2d --- /dev/null +++ b/node_modules/libnpmteam/node_modules/aproba/LICENSE @@ -0,0 +1,14 @@ +Copyright (c) 2015, Rebecca Turner + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + diff --git a/node_modules/libnpmteam/node_modules/aproba/README.md b/node_modules/libnpmteam/node_modules/aproba/README.md new file mode 100644 index 0000000000000..0bfc594c56a37 --- /dev/null +++ b/node_modules/libnpmteam/node_modules/aproba/README.md @@ -0,0 +1,94 @@ +aproba +====== + +A ridiculously light-weight function argument validator + +``` +var validate = require("aproba") + +function myfunc(a, b, c) { + // `a` must be a string, `b` a number, `c` a function + validate('SNF', arguments) // [a,b,c] is also valid +} + +myfunc('test', 23, function () {}) // ok +myfunc(123, 23, function () {}) // type error +myfunc('test', 23) // missing arg error +myfunc('test', 23, function () {}, true) // too many args error + +``` + +Valid types are: + +| type | description +| :--: | :---------- +| * | matches any type +| A | `Array.isArray` OR an `arguments` object +| S | typeof == string +| N | typeof == number +| F | typeof == function +| O | typeof == object and not type A and not type E +| B | typeof == boolean +| E | `instanceof Error` OR `null` **(special: see below)** +| Z | == `null` + +Validation failures throw one of three exception types, distinguished by a +`code` property of `EMISSINGARG`, `EINVALIDTYPE` or `ETOOMANYARGS`. + +If you pass in an invalid type then it will throw with a code of +`EUNKNOWNTYPE`. + +If an **error** argument is found and is not null then the remaining +arguments are optional. That is, if you say `ESO` then that's like using a +non-magical `E` in: `E|ESO|ZSO`. + +### But I have optional arguments?! + +You can provide more than one signature by separating them with pipes `|`. +If any signature matches the arguments then they'll be considered valid. + +So for example, say you wanted to write a signature for +`fs.createWriteStream`. The docs for it describe it thusly: + +``` +fs.createWriteStream(path[, options]) +``` + +This would be a signature of `SO|S`. That is, a string and and object, or +just a string. + +Now, if you read the full `fs` docs, you'll see that actually path can ALSO +be a buffer. And options can be a string, that is: +``` +path | +options | +``` + +To reproduce this you have to fully enumerate all of the possible +combinations and that implies a signature of `SO|SS|OO|OS|S|O`. The +awkwardness is a feature: It reminds you of the complexity you're adding to +your API when you do this sort of thing. + + +### Browser support + +This has no dependencies and should work in browsers, though you'll have +noisier stack traces. + +### Why this exists + +I wanted a very simple argument validator. It needed to do two things: + +1. Be more concise and easier to use than assertions + +2. Not encourage an infinite bikeshed of DSLs + +This is why types are specified by a single character and there's no such +thing as an optional argument. + +This is not intended to validate user data. This is specifically about +asserting the interface of your functions. + +If you need greater validation, I encourage you to write them by hand or +look elsewhere. + diff --git a/node_modules/libnpmteam/node_modules/aproba/index.js b/node_modules/libnpmteam/node_modules/aproba/index.js new file mode 100644 index 0000000000000..fd947481ba557 --- /dev/null +++ b/node_modules/libnpmteam/node_modules/aproba/index.js @@ -0,0 +1,105 @@ +'use strict' +module.exports = validate + +function isArguments (thingy) { + return thingy != null && typeof thingy === 'object' && thingy.hasOwnProperty('callee') +} + +const types = { + '*': {label: 'any', check: () => true}, + A: {label: 'array', check: _ => Array.isArray(_) || isArguments(_)}, + S: {label: 'string', check: _ => typeof _ === 'string'}, + N: {label: 'number', check: _ => typeof _ === 'number'}, + F: {label: 'function', check: _ => typeof _ === 'function'}, + O: {label: 'object', check: _ => typeof _ === 'object' && _ != null && !types.A.check(_) && !types.E.check(_)}, + B: {label: 'boolean', check: _ => typeof _ === 'boolean'}, + E: {label: 'error', check: _ => _ instanceof Error}, + Z: {label: 'null', check: _ => _ == null} +} + +function addSchema (schema, arity) { + const group = arity[schema.length] = arity[schema.length] || [] + if (group.indexOf(schema) === -1) group.push(schema) +} + +function validate (rawSchemas, args) { + if (arguments.length !== 2) throw wrongNumberOfArgs(['SA'], arguments.length) + if (!rawSchemas) throw missingRequiredArg(0, 'rawSchemas') + if (!args) throw missingRequiredArg(1, 'args') + if (!types.S.check(rawSchemas)) throw invalidType(0, ['string'], rawSchemas) + if (!types.A.check(args)) throw invalidType(1, ['array'], args) + const schemas = rawSchemas.split('|') + const arity = {} + + schemas.forEach(schema => { + for (let ii = 0; ii < schema.length; ++ii) { + const type = schema[ii] + if (!types[type]) throw unknownType(ii, type) + } + if (/E.*E/.test(schema)) throw moreThanOneError(schema) + addSchema(schema, arity) + if (/E/.test(schema)) { + addSchema(schema.replace(/E.*$/, 'E'), arity) + addSchema(schema.replace(/E/, 'Z'), arity) + if (schema.length === 1) addSchema('', arity) + } + }) + let matching = arity[args.length] + if (!matching) { + throw wrongNumberOfArgs(Object.keys(arity), args.length) + } + for (let ii = 0; ii < args.length; ++ii) { + let newMatching = matching.filter(schema => { + const type = schema[ii] + const typeCheck = types[type].check + return typeCheck(args[ii]) + }) + if (!newMatching.length) { + const labels = matching.map(_ => types[_[ii]].label).filter(_ => _ != null) + throw invalidType(ii, labels, args[ii]) + } + matching = newMatching + } +} + +function missingRequiredArg (num) { + return newException('EMISSINGARG', 'Missing required argument #' + (num + 1)) +} + +function unknownType (num, type) { + return newException('EUNKNOWNTYPE', 'Unknown type ' + type + ' in argument #' + (num + 1)) +} + +function invalidType (num, expectedTypes, value) { + let valueType + Object.keys(types).forEach(typeCode => { + if (types[typeCode].check(value)) valueType = types[typeCode].label + }) + return newException('EINVALIDTYPE', 'Argument #' + (num + 1) + ': Expected ' + + englishList(expectedTypes) + ' but got ' + valueType) +} + +function englishList (list) { + return list.join(', ').replace(/, ([^,]+)$/, ' or $1') +} + +function wrongNumberOfArgs (expected, got) { + const english = englishList(expected) + const args = expected.every(ex => ex.length === 1) + ? 'argument' + : 'arguments' + return newException('EWRONGARGCOUNT', 'Expected ' + english + ' ' + args + ' but got ' + got) +} + +function moreThanOneError (schema) { + return newException('ETOOMANYERRORTYPES', + 'Only one error type per argument signature is allowed, more than one found in "' + schema + '"') +} + +function newException (code, msg) { + const err = new Error(msg) + err.code = code + /* istanbul ignore else */ + if (Error.captureStackTrace) Error.captureStackTrace(err, validate) + return err +} diff --git a/node_modules/libnpmteam/node_modules/aproba/package.json b/node_modules/libnpmteam/node_modules/aproba/package.json new file mode 100644 index 0000000000000..d941c6159ffe3 --- /dev/null +++ b/node_modules/libnpmteam/node_modules/aproba/package.json @@ -0,0 +1,66 @@ +{ + "_args": [ + [ + "aproba@2.0.0", + "/Users/zkat/Documents/code/work/npm" + ] + ], + "_from": "aproba@2.0.0", + "_id": "aproba@2.0.0", + "_inBundle": false, + "_integrity": "sha512-lYe4Gx7QT+MKGbDsA+Z+he/Wtef0BiwDOlK/XkBrdfsh9J/jPPXbX0tE9x9cl27Tmu5gg3QUbUrQYa/y+KOHPQ==", + "_location": "/libnpmteam/aproba", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "aproba@2.0.0", + "name": "aproba", + "escapedName": "aproba", + "rawSpec": "2.0.0", + "saveSpec": null, + "fetchSpec": "2.0.0" + }, + "_requiredBy": [ + "/libnpmteam" + ], + "_resolved": "https://registry.npmjs.org/aproba/-/aproba-2.0.0.tgz", + "_spec": "2.0.0", + "_where": "/Users/zkat/Documents/code/work/npm", + "author": { + "name": "Rebecca Turner", + "email": "me@re-becca.org" + }, + "bugs": { + "url": "https://github.com/iarna/aproba/issues" + }, + "dependencies": {}, + "description": "A ridiculously light-weight argument validator (now browser friendly)", + "devDependencies": { + "standard": "^11.0.1", + "tap": "^12.0.1" + }, + "directories": { + "test": "test" + }, + "files": [ + "index.js" + ], + "homepage": "https://github.com/iarna/aproba", + "keywords": [ + "argument", + "validate" + ], + "license": "ISC", + "main": "index.js", + "name": "aproba", + "repository": { + "type": "git", + "url": "git+https://github.com/iarna/aproba.git" + }, + "scripts": { + "pretest": "standard", + "test": "tap --100 -J test/*.js" + }, + "version": "2.0.0" +} diff --git a/node_modules/libnpmteam/package.json b/node_modules/libnpmteam/package.json new file mode 100644 index 0000000000000..8b9fcd60ea31c --- /dev/null +++ b/node_modules/libnpmteam/package.json @@ -0,0 +1,69 @@ +{ + "_args": [ + [ + "libnpmteam@1.0.1", + "/Users/zkat/Documents/code/work/npm" + ] + ], + "_from": "libnpmteam@1.0.1", + "_id": "libnpmteam@1.0.1", + "_inBundle": false, + "_integrity": "sha512-gDdrflKFCX7TNwOMX1snWojCoDE5LoRWcfOC0C/fqF7mBq8Uz9zWAX4B2RllYETNO7pBupBaSyBDkTAC15cAMg==", + "_location": "/libnpmteam", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "libnpmteam@1.0.1", + "name": "libnpmteam", + "escapedName": "libnpmteam", + "rawSpec": "1.0.1", + "saveSpec": null, + "fetchSpec": "1.0.1" + }, + "_requiredBy": [ + "/libnpm" + ], + "_resolved": "https://registry.npmjs.org/libnpmteam/-/libnpmteam-1.0.1.tgz", + "_spec": "1.0.1", + "_where": "/Users/zkat/Documents/code/work/npm", + "author": { + "name": "Kat Marchán", + "email": "kzm@zkat.tech" + }, + "bugs": { + "url": "https://github.com/npm/libnpmteam/issues" + }, + "dependencies": { + "aproba": "^2.0.0", + "figgy-pudding": "^3.4.1", + "get-stream": "^4.0.0", + "npm-registry-fetch": "^3.8.0" + }, + "description": "npm Team management APIs", + "devDependencies": { + "nock": "^9.6.1", + "standard": "*", + "standard-version": "*", + "tap": "*", + "weallbehave": "*", + "weallcontribute": "*" + }, + "homepage": "https://npmjs.com/package/libnpmteam", + "license": "ISC", + "name": "libnpmteam", + "repository": { + "type": "git", + "url": "git+https://github.com/npm/libnpmteam.git" + }, + "scripts": { + "postrelease": "npm publish && git push --follow-tags", + "prerelease": "npm t", + "pretest": "standard", + "release": "standard-version -s", + "test": "tap -J --100 test/*.js", + "update-coc": "weallbehave -o . && git add CODE_OF_CONDUCT.md && git commit -m 'docs(coc): updated CODE_OF_CONDUCT.md'", + "update-contrib": "weallcontribute -o . && git add CONTRIBUTING.md && git commit -m 'docs(contributing): updated CONTRIBUTING.md'" + }, + "version": "1.0.1" +} diff --git a/node_modules/libnpmteam/test/index.js b/node_modules/libnpmteam/test/index.js new file mode 100644 index 0000000000000..2271c28840dc3 --- /dev/null +++ b/node_modules/libnpmteam/test/index.js @@ -0,0 +1,138 @@ +'use strict' + +const figgyPudding = require('figgy-pudding') +const getStream = require('get-stream') +const {test} = require('tap') +const tnock = require('./util/tnock.js') + +const team = require('../index.js') + +const REG = 'http://localhost:1337' +const OPTS = figgyPudding({})({ + registry: REG +}) + +test('create', t => { + tnock(t, REG).put( + '/-/org/foo/team', {name: 'cli'} + ).reply(201, {name: 'cli'}) + return team.create('@foo:cli', OPTS).then(ret => { + t.deepEqual(ret, {name: 'cli'}, 'request succeeded') + }) +}) + +test('create bad entity name', t => { + return team.create('go away', OPTS).then( + () => { throw new Error('should not succeed') }, + err => { t.ok(err, 'error on bad entity name') } + ) +}) + +test('create empty entity', t => { + return team.create(undefined, OPTS).then( + () => { throw new Error('should not succeed') }, + err => { t.ok(err, 'error on bad entity name') } + ) +}) + +test('create w/ description', t => { + tnock(t, REG).put('/-/org/foo/team', { + name: 'cli', + description: 'just some cool folx' + }).reply(201, {name: 'cli'}) + return team.create('@foo:cli', OPTS.concat({ + description: 'just some cool folx' + })).then(ret => { + t.deepEqual(ret, {name: 'cli'}, 'no desc in return') + }) +}) + +test('destroy', t => { + tnock(t, REG).delete( + '/-/team/foo/cli' + ).reply(204, {}) + return team.destroy('@foo:cli', OPTS).then(ret => { + t.deepEqual(ret, {}, 'request succeeded') + }) +}) + +test('add', t => { + tnock(t, REG).put( + '/-/team/foo/cli/user', {user: 'zkat'} + ).reply(201, {}) + return team.add('zkat', '@foo:cli', OPTS).then(ret => { + t.deepEqual(ret, {}, 'request succeeded') + }) +}) + +test('rm', t => { + tnock(t, REG).delete( + '/-/team/foo/cli/user', {user: 'zkat'} + ).reply(204, {}) + return team.rm('zkat', '@foo:cli', OPTS).then(ret => { + t.deepEqual(ret, {}, 'request succeeded') + }) +}) + +test('lsTeams', t => { + tnock(t, REG).get( + '/-/org/foo/team?format=cli' + ).reply(200, ['foo:bar', 'foo:cli']) + return team.lsTeams('foo', OPTS).then(ret => { + t.deepEqual(ret, ['foo:bar', 'foo:cli'], 'got teams') + }) +}) + +test('lsTeams error', t => { + tnock(t, REG).get( + '/-/org/foo/team?format=cli' + ).reply(500) + return team.lsTeams('foo', OPTS).then( + () => { throw new Error('should not succeed') }, + err => { t.equal(err.code, 'E500', 'got error code') } + ) +}) + +test('lsTeams.stream', t => { + tnock(t, REG).get( + '/-/org/foo/team?format=cli' + ).reply(200, ['foo:bar', 'foo:cli']) + return getStream.array(team.lsTeams.stream('foo', OPTS)).then(ret => { + t.deepEqual(ret, ['foo:bar', 'foo:cli'], 'got teams') + }) +}) + +test('lsUsers', t => { + tnock(t, REG).get( + '/-/team/foo/cli/user?format=cli' + ).reply(500) + return team.lsUsers('@foo:cli', OPTS).then( + () => { throw new Error('should not succeed') }, + err => { t.equal(err.code, 'E500', 'got error code') } + ) +}) + +test('lsUsers error', t => { + tnock(t, REG).get( + '/-/team/foo/cli/user?format=cli' + ).reply(200, ['iarna', 'zkat']) + return team.lsUsers('@foo:cli', OPTS).then(ret => { + t.deepEqual(ret, ['iarna', 'zkat'], 'got team members') + }) +}) + +test('lsUsers.stream', t => { + tnock(t, REG).get( + '/-/team/foo/cli/user?format=cli' + ).reply(200, ['iarna', 'zkat']) + return getStream.array(team.lsUsers.stream('@foo:cli', OPTS)).then(ret => { + t.deepEqual(ret, ['iarna', 'zkat'], 'got team members') + }) +}) + +test('edit', t => { + t.throws(() => { + team.edit() + }, /not implemented/) + t.done() +}) diff --git a/node_modules/libnpmteam/test/util/tnock.js b/node_modules/libnpmteam/test/util/tnock.js new file mode 100644 index 0000000000000..00b6e160e1019 --- /dev/null +++ b/node_modules/libnpmteam/test/util/tnock.js @@ -0,0 +1,12 @@ +'use strict' + +const nock = require('nock') + +module.exports = tnock +function tnock (t, host) { + const server = nock(host) + t.tearDown(function () { + server.done() + }) + return server +} diff --git a/node_modules/licensee/LICENSE b/node_modules/licensee/LICENSE new file mode 100644 index 0000000000000..d645695673349 --- /dev/null +++ b/node_modules/licensee/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/node_modules/licensee/README.md b/node_modules/licensee/README.md new file mode 100644 index 0000000000000..e401e27d6c0bc --- /dev/null +++ b/node_modules/licensee/README.md @@ -0,0 +1,132 @@ +Check npm package dependency license metadata against rules. + +# Configuration + +Licensee accepts two kinds of configuration: + +1. a rule about permitted licenses +2. a package whitelist of name-and-range pairs + +You can set configuration with command flags or a `.licensee.json` +file at the root of your package, like so: + +```json +{ + "license": "(MIT OR BSD-2-Clause OR BSD-3-Clause OR Apache-2.0)", + "whitelist": { + "optimist": "<=0.6.1" + } +} +``` + +The `license` property is an SPDX license expression that +[spdx-expression-parse][parse] can parse. Any package with [standard +license metadata][metadata] that satisfies the SPDX license expression +according to [spdx-satisfies][satisfies] will not cause an error. + +[parse]: https://www.npmjs.com/package/spdx-expression-parse +[satisfies]: https://www.npmjs.com/package/spdx-satisfies + +The `whitelist` is a map from package name to a [node-semver][semver] +Semantic Versioning range. Packages whose license metadata don't match +the SPDX license expression in `license` but have a name and version +described in `whitelist` will not cause an error. + +[metadata]: https://docs.npmjs.com/files/package.json#license +[semver]: https://www.npmjs.com/package/semver + +# Use + +To install and use `licensee` globally: + +```bash +npm install --global licensee +cd your-package +licensee --init +licensee +``` + +The `licensee` script prints a report about dependencies and their +license terms to standard output. It exits with status `0` when all +packages in `./node_modules` meet the configured licensing criteria +and `1` when one or more do not. + +To install it as a development dependency of your package: + +```bash +cd your-package +npm install --save-dev licensee +``` + +Consider adding `licensee` to your npm scripts: + +```json +{ + "scripts": { + "posttest": "licensee" + } +} +``` + +For output as newline-delimited JSON objects, for further processing: + +```json +{ + "scripts": { + "posttest": "licensee --ndjson" + } +} +``` + +To skip the readout of license information: + +```json +{ + "scripts": { + "posttest": "licensee --quiet" + } +} +``` + +If you want a readout of dependency information, but don't want +your continuous integration going red, you can ignore `licensee`'s +exit code: + +```json +{ + "scripts": { + "posttest": "licensee || true" + } +} +``` + +To save the readout of license information to a file: + +```json +{ + "scripts": { + "posttest": "licensee | tee LICENSES || true" + } +} +``` + +Alternatively, for a readout of just packages without approved licenses: + +```json +{ + "scripts": { + "posttest": "licensee --errors-only" + } +} +``` + +# JavaScript Module + +The package exports an asynchronous function of three arguments: + +1. A configuration object in the same form as `.licensee.json`. + +2. The path of the package to check. + +3. An error-first callback that yields an array of objects, one per + dependency. diff --git a/node_modules/licensee/index.js b/node_modules/licensee/index.js new file mode 100644 index 0000000000000..fc02d0a269353 --- /dev/null +++ b/node_modules/licensee/index.js @@ -0,0 +1,212 @@ +module.exports = licensee + +var licenseSatisfies = require('spdx-satisfies') +var parseJSON = require('json-parse-errback') +var readPackageTree = require('read-package-tree') +var runParallel = require('run-parallel') +var satisfies = require('semver').satisfies +var simpleConcat = require('simple-concat') +var spawn = require('child_process').spawn +var validSPDX = require('spdx-expression-validate') + +function licensee (configuration, path, callback) { + if (!validConfiguration(configuration)) { + callback(new Error('Invalid configuration')) + } else if (!validSPDX(configuration.license)) { + callback(new Error('Invalid license expression')) + } else { + if (configuration.productionOnly) { + // In order to ignore devDependencies, we need to read: + // + // 1. the dependencies-only dependency graph, from + // `npm ls --json --production` + // + // 2. the structure of `node_modules` and `package.json` + // files within it, with read-package-tree. + // + // `npm ls` calls read-package-tree internally, but does + // lots of npm-specific post-processing to produce the + // dependency tree. Calling read-package-tree twice, at + // the same time, is far from efficient. But it works, + // and doing so helps keep this package small. + runParallel({ + dependencies: readDependencyList, + packages: readFilesystemTree + }, function (error, trees) { + if (error) callback(error) + else withTrees(trees.packages, trees.dependencies) + }) + } else { + // If we are analyzing _all_ installed dependencies, + // and don't care whether they're devDependencies + // or not, just read `node_modules`. We don't need + // the dependency graph. + readFilesystemTree(function (error, packages) { + if (error) callback(error) + else withTrees(packages, false) + }) + } + } + + function withTrees (packages, dependencies) { + callback(null, findIssues( + configuration, packages, dependencies, [] + )) + } + + function readDependencyList (done) { + var child = spawn( + 'npm', ['ls', '--production', '--json'], {cwd: path} + ) + var outputError + var json + simpleConcat(child.stdout, function (error, buffer) { + if (error) outputError = error + else json = buffer + }) + child.once('close', function (code) { + if (code !== 0) { + done(new Error('npm exited with status ' + code)) + } else if (outputError) { + done(outputError) + } else { + parseJSON(json, function (error, graph) { + if (error) return done(error) + if (!graph.hasOwnProperty('dependencies')) { + done(new Error('cannot interpret npm ls --json output')) + } else { + var flattened = {} + flattenDependencyTree(graph.dependencies, flattened) + done(null, flattened) + } + }) + } + }) + } + + function readFilesystemTree (done) { + readPackageTree(path, function (error, tree) { + if (error) return done(error) + done(null, tree.children) + }) + } +} + +var KEY_PREFIX = '.' + +function flattenDependencyTree (graph, object) { + Object.keys(graph).forEach(function (name) { + var node = graph[name] + var version = node.version + var key = KEY_PREFIX + name + if ( + object.hasOwnProperty(key) && + object[key].indexOf(version) === -1 + ) { + object[key].push(version) + } else { + object[key] = [version] + } + if (node.hasOwnProperty('dependencies')) { + flattenDependencyTree(node.dependencies, object) + } + }) +} + +function validConfiguration (configuration) { + return ( + isObject(configuration) && + // Validate `license` property. + configuration.hasOwnProperty('license') && + isString(configuration.license) && + configuration.license.length > 0 && ( + configuration.hasOwnProperty('whitelist') + ? ( + // Validate `whitelist` property. + isObject(configuration.whitelist) && + Object.keys(configuration.whitelist) + .every(function (key) { + return isString(configuration.whitelist[key]) + }) + ) : true + ) + ) +} + +function isObject (argument) { + return typeof argument === 'object' +} + +function isString (argument) { + return typeof argument === 'string' +} + +function findIssues (configuration, children, dependencies, results) { + if (Array.isArray(children)) { + children.forEach(function (child) { + if ( + !configuration.productionOnly || + appearsIn(child, dependencies) + ) { + results.push(resultForPackage(configuration, child)) + findIssues(configuration, child, dependencies, results) + } + if (child.children) { + findIssues(configuration, child.children, dependencies, results) + } + }) + return results + } else return results +} + +function appearsIn (installed, dependencies) { + var name = installed.package.name + var key = KEY_PREFIX + name + var version = installed.package.version + return ( + dependencies.hasOwnProperty(key) && + dependencies[key].indexOf(version) !== -1 + ) +} + +function resultForPackage (configuration, tree) { + var licenseExpression = configuration.license + var whitelist = configuration.whitelist || {} + var result = { + name: tree.package.name, + license: tree.package.license, + author: tree.package.author, + contributors: tree.package.contributors, + repository: tree.package.repository, + homepage: tree.package.homepage, + version: tree.package.version, + parent: tree.parent, + path: tree.path + } + var whitelisted = Object.keys(whitelist).some(function (name) { + return ( + tree.package.name === name && + satisfies(tree.package.version, whitelist[name]) === true + ) + }) + if (whitelisted) { + result.approved = true + result.whitelisted = true + } else { + var matchesRule = ( + licenseExpression && + validSPDX(licenseExpression) && + tree.package.license && + typeof tree.package.license === 'string' && + validSPDX(tree.package.license) && + licenseSatisfies(tree.package.license, licenseExpression) + ) + if (matchesRule) { + result.approved = true + result.rule = true + } else { + result.approved = false + } + } + return result +} diff --git a/node_modules/licensee/licensee b/node_modules/licensee/licensee new file mode 100755 index 0000000000000..297798ef0643f --- /dev/null +++ b/node_modules/licensee/licensee @@ -0,0 +1,242 @@ +#!/usr/bin/env node +var access = require('fs-access') +var docopt = require('docopt') +var fs = require('fs') +var path = require('path') +var validSPDX = require('spdx-expression-validate') + +var USAGE = [ + 'Check npm package dependency license metadata against rules.', + '', + 'Usage:', + ' licensee [options]', + ' licensee --license=EXPRESSION [--whitelist=LIST] [options]', + '', + 'Options:', + ' --init Create a .licensee.json file.', + ' --license EXPRESSION Permit licenses matching SPDX expression.', + ' --whitelist LIST Permit comma-delimited name@range.', + ' --errors-only Only show NOT APPROVED packages.', + ' --production Do not check devDependencies.', + ' --ndjson Print newline-delimited JSON objects.', + ' --quiet Quiet mode, only exit(0/1).', + ' -h, --help Print this screen to standard output.', + ' -v, --version Print version to standard output.' +].join('\n') + +var options = docopt.docopt(USAGE, { + version: require('./package.json').version +}) + +var cwd = process.cwd() +var configuration +var configurationPath = path.join(cwd, '.licensee.json') + +if (options['--init']) { + fs.writeFile( + configurationPath, + JSON.stringify({ + license: ( + options['--expression'] || + '(MIT OR BSD-2-Clause OR BSD-3-Clause OR Apache-2.0)' + ), + whitelist: ( + options['--whitelist'] + ? parseWhitelist(options['--whitelist']) + : {optimist: '<=0.6.1'} + ) + }, null, 2) + '\n', + { + encoding: 'utf8', + flag: 'wx' + }, + function (error) { + if (error) { + if (error.code === 'EEXIST') { + die(configurationPath + ' already exists.') + } else { + die('Could not create ' + configurationPath + '.') + } + } else { + process.stdout.write('Created ' + configurationPath + '.\n') + process.exit(0) + } + } + ) +} else if (options['--license'] || options['--whitelist']) { + configuration = { + license: options['--license'] || undefined, + whitelist: options['--whitelist'] + ? parseWhitelist(options['--whitelist']) + : {} + } + checkDependencies() +} else { + access(configurationPath, function (error) { + if (error) { + die( + [ + 'Cannot read ' + configurationPath + '.', + 'Create ' + configurationPath + ' with licensee --init', + 'or configure with --license and --whitelist.', + 'See licensee --help for more information.' + ].join('\n') + ) + } else { + fs.readFile(configurationPath, function (error, data) { + if (error) { + die('Error reading ' + configurationPath) + } else { + try { + configuration = JSON.parse(data) + } catch (error) { + die('Error parsing ' + configurationPath) + } + checkDependencies() + } + }) + } + }) +} + +function checkDependencies () { + configuration.productionOnly = options['--production'] + require('./')(configuration, cwd, function (error, dependencies) { + if (error) { + die(error.message + '\n') + } else { + if (dependencies.length === 0) { + process.exit(0) + } else { + var errorsOnly = !!options['--errors-only'] + var quiet = !!options['--quiet'] + var ndjson = !!options['--ndjson'] + var haveIssue = false + dependencies.forEach(function (dependency) { + if (!dependency.approved) { + haveIssue = true + } + if (!quiet) { + if (errorsOnly) { + if (!dependency.approved) { + print(dependency, ndjson) + } + } else { + print(dependency, ndjson) + } + } + }) + process.exit(haveIssue ? 1 : 0) + } + } + }) +} + +function print (dependency, ndjson) { + if (ndjson) { + process.stdout.write(toJSON(dependency) + '\n') + } else { + process.stdout.write(toText(dependency) + '\n') + } +} + +function toText (result) { + return ( + result.name + '@' + result.version + '\n' + + ( + result.approved + ? ( + ' Approved by ' + + (result.whitelisted ? 'whitelist' : 'rule') + '\n' + ) + : ' NOT APPROVED\n' + ) + + ' Terms: ' + displayLicense(result.license) + '\n' + + ' Repository: ' + formatRepo(result.repository) + '\n' + + ' Homepage: ' + formatRepo(result.homepage) + '\n' + + ' Author: ' + formatPerson(result.author) + '\n' + + ' Contributors:' + formatPeople(result.contributors) + '\n' + ) +} + +function toJSON (dependency) { + var returned = {} + Object.keys(dependency).forEach(function (key) { + if (key !== 'parent') { + returned[key] = dependency[key] + } + }) + return JSON.stringify(returned) +} + +function displayLicense (license) { + if (typeof license === 'string') { + if (validSPDX(license)) { + return license + } else { + return 'Invalid SPDX expression "' + license + '"' + } + } else if (Array.isArray(license)) { + return JSON.stringify(license) + } else { + return 'Invalid license metadata' + } +} + +function formatPeople (people) { + if (Array.isArray(people)) { + return '\n' + people + .map(function (person) { + return ' ' + formatPerson(person) + }) + .join('\n') + } else if (typeof people === 'string') { + return ' ' + people + } else { + return ' None listed' + } +} + +function formatPerson (person) { + if (!person) { + return 'None listed' + } else if (typeof person === 'string') { + return person + } else { + return ( + person.name + + (person.email ? ' <' + person.email + '>' : '') + + (person.url ? ' (' + person.url + ')' : '') + ) + } +} + +function formatRepo (repo) { + if (repo) { + if (typeof repo === 'string') { + return repo + } else if (repo.hasOwnProperty('url')) { + return repo.url + } + } else { + return 'None listed' + } +} + +function die (message) { + process.stderr.write(message + '\n') + process.exit(1) +} + +function parseWhitelist (string) { + return string + .split(',') + .map(function (string) { + return string.trim() + }) + .reduce(function (whitelist, string) { + var split = string.split('@') + whitelist[split[0]] = split[1] + return whitelist + }, {}) +} diff --git a/node_modules/licensee/package.json b/node_modules/licensee/package.json new file mode 100644 index 0000000000000..8319cbe87e88a --- /dev/null +++ b/node_modules/licensee/package.json @@ -0,0 +1,83 @@ +{ + "_args": [ + [ + "licensee@5.0.0", + "/Users/zkat/Documents/code/work/npm" + ] + ], + "_development": true, + "_from": "licensee@5.0.0", + "_id": "licensee@5.0.0", + "_inBundle": false, + "_integrity": "sha512-g243BLsJYWWyNhwDEMewc2f6Ebyy1yiJmMDgO8MCQtLOXA8JO4O2/kbJ1QwwWdlmrwDgYECdl9CJBrKsr4ZezA==", + "_location": "/licensee", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "licensee@5.0.0", + "name": "licensee", + "escapedName": "licensee", + "rawSpec": "5.0.0", + "saveSpec": null, + "fetchSpec": "5.0.0" + }, + "_requiredBy": [ + "#DEV:/" + ], + "_resolved": "https://registry.npmjs.org/licensee/-/licensee-5.0.0.tgz", + "_spec": "5.0.0", + "_where": "/Users/zkat/Documents/code/work/npm", + "author": { + "name": "Kyle E. Mitchell", + "email": "kyle@kemitchell.com", + "url": "https://kemitchell.com/" + }, + "bin": { + "licensee": "./licensee" + }, + "bugs": { + "url": "https://github.com/jslicense/licensee.js/issues" + }, + "contributors": [ + { + "name": "Jakob Krigovsky", + "email": "jakob@krigovsky.com" + } + ], + "dependencies": { + "docopt": "^0.6.2", + "fs-access": "^1.0.0", + "json-parse-errback": "^2.0.1", + "read-package-tree": "^5.2.1", + "run-parallel": "^1.1.9", + "semver": "^5.5.0", + "simple-concat": "^1.0.0", + "spdx-expression-validate": "^1.0.1", + "spdx-satisfies": "^4.0.0" + }, + "description": "check dependency licenses against rules", + "devDependencies": { + "spawn-sync": "^1.0.15", + "standard": "^11.0.1", + "tap": "^12.0.1" + }, + "files": [ + "LICENSE", + "NOTICE", + "index.js", + "licensee" + ], + "homepage": "https://github.com/jslicense/licensee.js#readme", + "license": "Apache-2.0", + "name": "licensee", + "repository": { + "type": "git", + "url": "git+https://github.com/jslicense/licensee.js.git" + }, + "scripts": { + "style": "standard", + "test": "tap tests/**/test.js" + }, + "version": "5.0.0" +} diff --git a/node_modules/null-check/index.js b/node_modules/null-check/index.js new file mode 100644 index 0000000000000..6befbeb3f9f42 --- /dev/null +++ b/node_modules/null-check/index.js @@ -0,0 +1,19 @@ +'use strict'; +module.exports = function (pth, cb) { + if (String(pth).indexOf('\u0000') !== -1) { + var err = new Error('Path must be a string without null bytes.'); + err.code = 'ENOENT'; + + if (typeof cb !== 'function') { + throw err; + } + + process.nextTick(function () { + cb(err); + }); + + return false; + } + + return true; +} diff --git a/node_modules/null-check/license b/node_modules/null-check/license new file mode 100644 index 0000000000000..654d0bfe94343 --- /dev/null +++ b/node_modules/null-check/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +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/node_modules/null-check/package.json b/node_modules/null-check/package.json new file mode 100644 index 0000000000000..e269dca66d02f --- /dev/null +++ b/node_modules/null-check/package.json @@ -0,0 +1,72 @@ +{ + "_args": [ + [ + "null-check@1.0.0", + "/Users/zkat/Documents/code/work/npm" + ] + ], + "_development": true, + "_from": "null-check@1.0.0", + "_id": "null-check@1.0.0", + "_inBundle": false, + "_integrity": "sha1-l33/1xdgErnsMNKjnbXPcqBDnt0=", + "_location": "/null-check", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "null-check@1.0.0", + "name": "null-check", + "escapedName": "null-check", + "rawSpec": "1.0.0", + "saveSpec": null, + "fetchSpec": "1.0.0" + }, + "_requiredBy": [ + "/fs-access" + ], + "_resolved": "https://registry.npmjs.org/null-check/-/null-check-1.0.0.tgz", + "_spec": "1.0.0", + "_where": "/Users/zkat/Documents/code/work/npm", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/sindresorhus/null-check/issues" + }, + "description": "Ensure a path doesn't contain null bytes", + "devDependencies": { + "ava": "0.0.4" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "homepage": "https://github.com/sindresorhus/null-check#readme", + "keywords": [ + "built-in", + "core", + "ponyfill", + "polyfill", + "shim", + "fs", + "path", + "null", + "bytes", + "check" + ], + "license": "MIT", + "name": "null-check", + "repository": { + "type": "git", + "url": "git+https://github.com/sindresorhus/null-check.git" + }, + "scripts": { + "test": "node test.js" + }, + "version": "1.0.0" +} diff --git a/node_modules/null-check/readme.md b/node_modules/null-check/readme.md new file mode 100644 index 0000000000000..dfb55a3101abe --- /dev/null +++ b/node_modules/null-check/readme.md @@ -0,0 +1,34 @@ +# null-check [![Build Status](https://travis-ci.org/sindresorhus/null-check.svg?branch=master)](https://travis-ci.org/sindresorhus/null-check) + +> Ensure a path doesn't contain [null bytes](http://en.wikipedia.org/wiki/Null_character) + +The same check as done in all the core [`fs` methods](https://github.com/iojs/io.js/blob/18d457bd3408557a48b453f13b2b99e1ab5e7159/lib/fs.js#L88-L102). + + +## Install + +``` +$ npm install --save null-check +``` + + +## Usage + +```js +var nullCheck = require('null-check'); + +nullCheck('unicorn.png\u0000', function (err) { + console.log(err); + //=> { [Error: Path must be a string without null bytes.] code: 'ENOENT' } +}); +//=> false + +// the method is sync without a callback +nullCheck('unicorn.png'); +//=> true +``` + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/node_modules/simple-concat/.travis.yml b/node_modules/simple-concat/.travis.yml new file mode 100644 index 0000000000000..f178ec0d85db2 --- /dev/null +++ b/node_modules/simple-concat/.travis.yml @@ -0,0 +1,3 @@ +language: node_js +node_js: + - 'node' diff --git a/node_modules/simple-concat/LICENSE b/node_modules/simple-concat/LICENSE new file mode 100644 index 0000000000000..c7e6852752b72 --- /dev/null +++ b/node_modules/simple-concat/LICENSE @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) Feross Aboukhadijeh + +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/node_modules/simple-concat/README.md b/node_modules/simple-concat/README.md new file mode 100644 index 0000000000000..572e99c7c2105 --- /dev/null +++ b/node_modules/simple-concat/README.md @@ -0,0 +1,42 @@ +# simple-concat [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] + +[travis-image]: https://img.shields.io/travis/feross/simple-concat/master.svg +[travis-url]: https://travis-ci.org/feross/simple-concat +[npm-image]: https://img.shields.io/npm/v/simple-concat.svg +[npm-url]: https://npmjs.org/package/simple-concat +[downloads-image]: https://img.shields.io/npm/dm/simple-concat.svg +[downloads-url]: https://npmjs.org/package/simple-concat + +### Super-minimalist version of `concat-stream`. Less than 15 lines! + +## install + +``` +npm install simple-concat +``` + +## usage + +This example is longer than the implementation. + +```js +var s = new stream.PassThrough() +concat(s, function (err, buf) { + if (err) throw err + console.error(buf) +}) +s.write('abc') +setTimeout(function () { + s.write('123') +}, 10) +setTimeout(function () { + s.write('456') +}, 20) +setTimeout(function () { + s.end('789') +}, 30) +``` + +## license + +MIT. Copyright (c) [Feross Aboukhadijeh](http://feross.org). diff --git a/node_modules/simple-concat/index.js b/node_modules/simple-concat/index.js new file mode 100644 index 0000000000000..c2d88600ca589 --- /dev/null +++ b/node_modules/simple-concat/index.js @@ -0,0 +1,14 @@ +module.exports = function (stream, cb) { + var chunks = [] + stream.on('data', function (chunk) { + chunks.push(chunk) + }) + stream.once('end', function () { + if (cb) cb(null, Buffer.concat(chunks)) + cb = null + }) + stream.once('error', function (err) { + if (cb) cb(err) + cb = null + }) +} diff --git a/node_modules/simple-concat/package.json b/node_modules/simple-concat/package.json new file mode 100644 index 0000000000000..81f0174e2e878 --- /dev/null +++ b/node_modules/simple-concat/package.json @@ -0,0 +1,62 @@ +{ + "_args": [ + [ + "simple-concat@1.0.0", + "/Users/zkat/Documents/code/work/npm" + ] + ], + "_development": true, + "_from": "simple-concat@1.0.0", + "_id": "simple-concat@1.0.0", + "_inBundle": false, + "_integrity": "sha1-c0TLuLbib7J9ZrL8hvn21Zl1IcY=", + "_location": "/simple-concat", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "simple-concat@1.0.0", + "name": "simple-concat", + "escapedName": "simple-concat", + "rawSpec": "1.0.0", + "saveSpec": null, + "fetchSpec": "1.0.0" + }, + "_requiredBy": [ + "/licensee" + ], + "_resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.0.tgz", + "_spec": "1.0.0", + "_where": "/Users/zkat/Documents/code/work/npm", + "author": { + "name": "Feross Aboukhadijeh", + "email": "feross@feross.org", + "url": "http://feross.org/" + }, + "bugs": { + "url": "https://github.com/feross/simple-concat/issues" + }, + "dependencies": {}, + "description": "Super-minimalist version of `concat-stream`. Less than 15 lines!", + "devDependencies": { + "standard": "^6.0.8", + "tape": "^4.0.0" + }, + "homepage": "https://github.com/feross/simple-concat", + "keywords": [ + "concat", + "concat-stream", + "concat stream" + ], + "license": "MIT", + "main": "index.js", + "name": "simple-concat", + "repository": { + "type": "git", + "url": "git://github.com/feross/simple-concat.git" + }, + "scripts": { + "test": "standard && tape test/*.js" + }, + "version": "1.0.0" +} diff --git a/node_modules/simple-concat/test/basic.js b/node_modules/simple-concat/test/basic.js new file mode 100644 index 0000000000000..f781294a3c8df --- /dev/null +++ b/node_modules/simple-concat/test/basic.js @@ -0,0 +1,41 @@ +var concat = require('../') +var stream = require('stream') +var test = require('tape') + +test('basic', function (t) { + t.plan(2) + var s = new stream.PassThrough() + concat(s, function (err, buf) { + t.error(err) + t.deepEqual(buf, new Buffer('abc123456789')) + }) + s.write('abc') + setTimeout(function () { + s.write('123') + }, 10) + setTimeout(function () { + s.write('456') + }, 20) + setTimeout(function () { + s.end('789') + }, 30) +}) + +test('error', function (t) { + t.plan(2) + var s = new stream.PassThrough() + concat(s, function (err, buf) { + t.ok(err, 'got expected error') + t.ok(!buf) + }) + s.write('abc') + setTimeout(function () { + s.write('123') + }, 10) + setTimeout(function () { + s.write('456') + }, 20) + setTimeout(function () { + s.emit('error', new Error('error')) + }, 30) +}) diff --git a/node_modules/spdx-compare/LICENSE.md b/node_modules/spdx-compare/LICENSE.md new file mode 100644 index 0000000000000..6c255589566ff --- /dev/null +++ b/node_modules/spdx-compare/LICENSE.md @@ -0,0 +1,9 @@ +The MIT License + +Copyright (c) 2015 Kyle E. Mitchell + +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/node_modules/spdx-compare/README.md b/node_modules/spdx-compare/README.md new file mode 100644 index 0000000000000..20d79c9bf34f1 --- /dev/null +++ b/node_modules/spdx-compare/README.md @@ -0,0 +1,20 @@ +```javascript +var assert = require('assert') +var compare = require('spdx-compare') + +assert(compare.gt('GPL-3.0', 'GPL-2.0')) +assert(compare.gt('GPL-3.0-only', 'GPL-2.0-only')) +assert(compare.gt('GPL-2.0-or-later', 'GPL-2.0-only')) +assert(compare.eq('GPL-3.0-or-later', 'GPL-3.0-only')) +assert(compare.lt('MPL-1.0', 'MPL-2.0')) + +assert(compare.gt('LPPL-1.3a', 'LPPL-1.0')) +assert(compare.gt('LPPL-1.3c', 'LPPL-1.3a')) +assert(!compare.gt('MIT', 'ISC')) +assert(!compare.gt('OSL-1.0', 'OPL-1.0')) +assert(compare.gt('AGPL-3.0', 'AGPL-1.0')) + +assert.throws(function () { + compare.gt('(MIT OR ISC)', 'GPL-3.0') +}, '"(MIT OR ISC)" is not a simple license identifier') +``` diff --git a/node_modules/spdx-compare/index.js b/node_modules/spdx-compare/index.js new file mode 100644 index 0000000000000..7b33349f8f650 --- /dev/null +++ b/node_modules/spdx-compare/index.js @@ -0,0 +1,60 @@ +var arrayFindIndex = require('array-find-index') +var parse = require('spdx-expression-parse') + +var ranges = require('spdx-ranges') + +var notALicenseIdentifier = ' is not a simple license identifier' + +var rangeComparison = function (comparison) { + return function (first, second) { + var firstAST = parse(first) + if (!firstAST.hasOwnProperty('license')) { + throw new Error('"' + first + '"' + notALicenseIdentifier) + } + var secondAST = parse(second) + if (!secondAST.hasOwnProperty('license')) { + throw new Error('"' + second + '"' + notALicenseIdentifier) + } + return ranges.some(function (range) { + var firstLicense = firstAST.license + var indexOfFirst = arrayFindIndex(range, function (element) { + return ( + element === firstLicense || + ( + Array.isArray(element) && + element.indexOf(firstLicense) !== -1 + ) + ) + }) + if (indexOfFirst < 0) { + return false + } + var secondLicense = secondAST.license + var indexOfSecond = arrayFindIndex(range, function (element) { + return ( + element === secondLicense || + ( + Array.isArray(element) && + element.indexOf(secondLicense) !== -1 + ) + ) + }) + if (indexOfSecond < 0) { + return false + } + return comparison(indexOfFirst, indexOfSecond) + }) + } +} + +exports.gt = rangeComparison(function (first, second) { + return first > second +}) + +exports.lt = rangeComparison(function (first, second) { + return first < second +}) + +exports.eq = rangeComparison(function (first, second) { + return first === second +}) diff --git a/node_modules/spdx-compare/package.json b/node_modules/spdx-compare/package.json new file mode 100644 index 0000000000000..82f0291cf4a3a --- /dev/null +++ b/node_modules/spdx-compare/package.json @@ -0,0 +1,69 @@ +{ + "_args": [ + [ + "spdx-compare@1.0.0", + "/Users/zkat/Documents/code/work/npm" + ] + ], + "_development": true, + "_from": "spdx-compare@1.0.0", + "_id": "spdx-compare@1.0.0", + "_inBundle": false, + "_integrity": "sha512-C1mDZOX0hnu0ep9dfmuoi03+eOdDoz2yvK79RxbcrVEG1NO1Ph35yW102DHWKN4pk80nwCgeMmSY5L25VE4D9A==", + "_location": "/spdx-compare", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "spdx-compare@1.0.0", + "name": "spdx-compare", + "escapedName": "spdx-compare", + "rawSpec": "1.0.0", + "saveSpec": null, + "fetchSpec": "1.0.0" + }, + "_requiredBy": [ + "/spdx-satisfies" + ], + "_resolved": "https://registry.npmjs.org/spdx-compare/-/spdx-compare-1.0.0.tgz", + "_spec": "1.0.0", + "_where": "/Users/zkat/Documents/code/work/npm", + "author": { + "name": "Kyle E. Mitchell", + "email": "kyle@kemitchell.com", + "url": "https://kemitchell.com" + }, + "bugs": { + "url": "https://github.com/kemitchell/spdx-compare.js/issues" + }, + "dependencies": { + "array-find-index": "^1.0.2", + "spdx-expression-parse": "^3.0.0", + "spdx-ranges": "^2.0.0" + }, + "description": "compare SPDX license expressions", + "devDependencies": { + "defence-cli": "^2.0.1" + }, + "homepage": "https://github.com/kemitchell/spdx-compare.js#readme", + "keywords": [ + "SPDX", + "law", + "legal", + "license", + "metadata", + "package", + "package.json", + "standards" + ], + "license": "MIT", + "name": "spdx-compare", + "repository": { + "type": "git", + "url": "git+https://github.com/kemitchell/spdx-compare.js.git" + }, + "scripts": { + "test": "defence -i javascript README.md | sed 's!spdx-compare!./!' | node" + }, + "version": "1.0.0" +} diff --git a/node_modules/spdx-compare/test.log b/node_modules/spdx-compare/test.log new file mode 100644 index 0000000000000..66ec4ccee4953 --- /dev/null +++ b/node_modules/spdx-compare/test.log @@ -0,0 +1,4 @@ + +> spdx-compare@0.1.2 test /home/kyle/spdx-compare.js +> defence -i javascript README.md | sed 's!spdx-compare!./!' | node + diff --git a/node_modules/spdx-expression-validate/LICENSE b/node_modules/spdx-expression-validate/LICENSE new file mode 100644 index 0000000000000..d3791f13c94aa --- /dev/null +++ b/node_modules/spdx-expression-validate/LICENSE @@ -0,0 +1,22 @@ +The MIT License + +Copyright (c) 2015 Kyle E. Mitchell + +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/node_modules/spdx-expression-validate/README.md b/node_modules/spdx-expression-validate/README.md new file mode 100644 index 0000000000000..489816777372b --- /dev/null +++ b/node_modules/spdx-expression-validate/README.md @@ -0,0 +1,44 @@ +```javascript +var assert = require('assert') +var valid = require('spdx-expression-validate') +``` + +# Simple License Expressions +```javascript +assert(!valid('Invalid-Identifier')) +assert(valid('GPL-2.0')) +assert(valid('GPL-2.0+')) +assert(valid('LicenseRef-23')) +assert(valid('LicenseRef-MIT-Style-1')) +assert(valid('DocumentRef-spdx-tool-1.2:LicenseRef-MIT-Style-2')) +``` + +# Composite License Expressions + +## Disjunctive `OR` Operator +```javascript +assert(valid('(LGPL-2.1 OR MIT)')) +assert(valid('(LGPL-2.1 OR MIT OR BSD-3-Clause)')) +``` + +## Conjunctive `AND` Operator +```javascript +assert(valid('(LGPL-2.1 AND MIT)')) +assert(valid('(LGPL-2.1 AND MIT AND BSD-2-Clause)')) +``` + +## Exception `WITH` Operator +```javascript +assert(valid('(GPL-2.0+ WITH Bison-exception-2.2)')) +``` + +# Strict Whitespace Rules +```javascript +assert(!valid('MIT ')) +assert(!valid(' MIT')) +assert(!valid('MIT AND BSD-3-Clause')) +``` + +--- + +[The Software Package Data Exchange (SPDX) specification](http://spdx.org) is the work of the [Linux Foundation](http://www.linuxfoundation.org) and its contributors, and is licensed under the terms of [the Creative Commons Attribution License 3.0 Unported (SPDX: "CC-BY-3.0")](http://spdx.org/licenses/CC-BY-3.0). "SPDX" is a United States federally registered trademark of the Linux Foundation. diff --git a/node_modules/spdx-expression-validate/index.js b/node_modules/spdx-expression-validate/index.js new file mode 100644 index 0000000000000..e01ec5df6453a --- /dev/null +++ b/node_modules/spdx-expression-validate/index.js @@ -0,0 +1,20 @@ +var parse = require('spdx-expression-parse') + +var containsRepeatedSpace = /\s{2,}/ + +module.exports = function spdxExpressionValidate (argument) { + var fatString = ( + argument.trim() !== argument || + containsRepeatedSpace.test(argument) + ) + if (fatString) { + return false + } else { + try { + parse(argument) + return true + } catch (e) { + return false + } + } +} diff --git a/node_modules/spdx-expression-validate/node_modules/spdx-expression-parse/AUTHORS b/node_modules/spdx-expression-validate/node_modules/spdx-expression-parse/AUTHORS new file mode 100644 index 0000000000000..155f0f66c076a --- /dev/null +++ b/node_modules/spdx-expression-validate/node_modules/spdx-expression-parse/AUTHORS @@ -0,0 +1,3 @@ +C. Scott Ananian (http://cscott.net) +Kyle E. Mitchell (https://kemitchell.com) +Shinnosuke Watanabe diff --git a/node_modules/spdx-expression-validate/node_modules/spdx-expression-parse/LICENSE b/node_modules/spdx-expression-validate/node_modules/spdx-expression-parse/LICENSE new file mode 100644 index 0000000000000..831618eaba6c8 --- /dev/null +++ b/node_modules/spdx-expression-validate/node_modules/spdx-expression-parse/LICENSE @@ -0,0 +1,22 @@ +The MIT License + +Copyright (c) 2015 Kyle E. Mitchell & other authors listed in AUTHORS + +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/node_modules/spdx-expression-validate/node_modules/spdx-expression-parse/README.md b/node_modules/spdx-expression-validate/node_modules/spdx-expression-parse/README.md new file mode 100644 index 0000000000000..9928cdccfcd8a --- /dev/null +++ b/node_modules/spdx-expression-validate/node_modules/spdx-expression-parse/README.md @@ -0,0 +1,83 @@ +This package parses SPDX license expression strings describing license terms, like [package.json license strings](https://docs.npmjs.com/files/package.json#license), into consistently structured ECMAScript objects. The npm command-line interface depends on this package, as do many automatic license-audit tools. + +In a nutshell: + +```javascript +var parse = require('spdx-expression-parse') +var assert = require('assert') + +assert.deepEqual( + // Licensed under the terms of the Two-Clause BSD License. + parse('BSD-2-Clause'), + {license: 'BSD-2-Clause'} +) + +assert.throws(function () { + // An invalid SPDX license expression. + // Should be `Apache-2.0`. + parse('Apache 2') +}) + +assert.deepEqual( + // Dual licensed under LGPL 2.1 or a combination of the Three-Clause + // BSD License and the MIT License. + parse('(LGPL-2.1 OR BSD-3-Clause AND MIT)'), + { + left: {license: 'LGPL-2.1'}, + conjunction: 'or', + right: { + left: {license: 'BSD-3-Clause'}, + conjunction: 'and', + right: {license: 'MIT'} + } + } +) +``` + +The syntax comes from the [Software Package Data eXchange (SPDX)](https://spdx.org/), a standard from the [Linux Foundation](https://www.linuxfoundation.org) for shareable data about software package license terms. SPDX aims to make sharing and auditing license data easy, especially for users of open-source software. + +The bulk of the SPDX standard describes syntax and semantics of XML metadata files. This package implements two lightweight, plain-text components of that larger standard: + +1. The [license list](https://spdx.org/licenses), a mapping from specific string identifiers, like `Apache-2.0`, to standard form license texts and bolt-on license exceptions. The [spdx-license-ids](https://www.npmjs.com/package/spdx-exceptions) and [spdx-exceptions](https://www.npmjs.com/package/spdx-license-ids) packages implement the license list. They are development dependencies of this package. + + Any license identifier from the license list is a valid license expression: + + ```javascript + require('spdx-license-ids').forEach(function (id) { + assert.deepEqual(parse(id), {license: id}) + }) + ``` + + So is any license identifier `WITH` a standardized license exception: + + ```javascript + require('spdx-license-ids').forEach(function (id) { + require('spdx-exceptions').forEach(function (e) { + assert.deepEqual( + parse(id + ' WITH ' + e), + {license: id, exception: e} + ) + }) + }) + ``` + +2. The license expression language, for describing simple and complex license terms, like `MIT` for MIT-licensed and `(GPL-2.0 OR Apache-2.0)` for dual-licensing under GPL 2.0 and Apache 2.0. This package implements the license expression language. + + ```javascript + assert.deepEqual( + // Licensed under a combination of the MIT License and a combination + // of LGPL 2.1 (or a later version) and the Three-Clause BSD License. + parse('(MIT AND (LGPL-2.1+ AND BSD-3-Clause))'), + { + left: {license: 'MIT'}, + conjunction: 'and', + right: { + left: {license: 'LGPL-2.1', plus: true}, + conjunction: 'and', + right: {license: 'BSD-3-Clause'} + } + } + ) + ``` + +The Linux Foundation and its contributors license the SPDX standard under the terms of [the Creative Commons Attribution License 3.0 Unported (SPDX: "CC-BY-3.0")](http://spdx.org/licenses/CC-BY-3.0). "SPDX" is a United States federally registered trademark of the Linux Foundation. The authors of this package license their work under the terms of the MIT License. diff --git a/node_modules/spdx-expression-validate/node_modules/spdx-expression-parse/index.js b/node_modules/spdx-expression-validate/node_modules/spdx-expression-parse/index.js new file mode 100644 index 0000000000000..56a9b50c659f5 --- /dev/null +++ b/node_modules/spdx-expression-validate/node_modules/spdx-expression-parse/index.js @@ -0,0 +1,5 @@ +var parser = require('./parser').parser + +module.exports = function (argument) { + return parser.parse(argument) +} diff --git a/node_modules/spdx-expression-validate/node_modules/spdx-expression-parse/package.json b/node_modules/spdx-expression-validate/node_modules/spdx-expression-parse/package.json new file mode 100644 index 0000000000000..64926dc22d7f8 --- /dev/null +++ b/node_modules/spdx-expression-validate/node_modules/spdx-expression-parse/package.json @@ -0,0 +1,93 @@ +{ + "_args": [ + [ + "spdx-expression-parse@1.0.4", + "/Users/zkat/Documents/code/work/npm" + ] + ], + "_development": true, + "_from": "spdx-expression-parse@1.0.4", + "_id": "spdx-expression-parse@1.0.4", + "_inBundle": false, + "_integrity": "sha1-m98vIOH0DtRH++JzJmGR/O1RYmw=", + "_location": "/spdx-expression-validate/spdx-expression-parse", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "spdx-expression-parse@1.0.4", + "name": "spdx-expression-parse", + "escapedName": "spdx-expression-parse", + "rawSpec": "1.0.4", + "saveSpec": null, + "fetchSpec": "1.0.4" + }, + "_requiredBy": [ + "/spdx-expression-validate" + ], + "_resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-1.0.4.tgz", + "_spec": "1.0.4", + "_where": "/Users/zkat/Documents/code/work/npm", + "author": { + "name": "Kyle E. Mitchell", + "email": "kyle@kemitchell.com", + "url": "http://kemitchell.com" + }, + "bugs": { + "url": "https://github.com/kemitchell/spdx-expression-parse.js/issues" + }, + "contributors": [ + { + "name": "C. Scott Ananian", + "email": "cscott@cscott.net", + "url": "http://cscott.net" + }, + { + "name": "Kyle E. Mitchell", + "email": "kyle@kemitchell.com", + "url": "https://kemitchell.com" + }, + { + "name": "Shinnosuke Watanabe", + "email": "snnskwtnb@gmail.com" + } + ], + "description": "parse SPDX license expressions", + "devDependencies": { + "defence-cli": "^1.0.1", + "jison": "^0.4.15", + "replace-require-self": "^1.0.0", + "spdx-exceptions": "^1.0.4", + "spdx-license-ids": "^1.0.0", + "standard": "^8.0.0" + }, + "files": [ + "AUTHORS", + "index.js", + "parser.js" + ], + "homepage": "https://github.com/kemitchell/spdx-expression-parse.js#readme", + "keywords": [ + "SPDX", + "law", + "legal", + "license", + "metadata", + "package", + "package.json", + "standards" + ], + "license": "(MIT AND CC-BY-3.0)", + "name": "spdx-expression-parse", + "repository": { + "type": "git", + "url": "git+https://github.com/kemitchell/spdx-expression-parse.js.git" + }, + "scripts": { + "lint": "standard", + "prepublish": "node generate-parser.js > parser.js", + "pretest": "npm run prepublish", + "test": "defence -i javascript README.md | replace-require-self | node" + }, + "version": "1.0.4" +} diff --git a/node_modules/spdx-expression-validate/node_modules/spdx-expression-parse/parser.js b/node_modules/spdx-expression-validate/node_modules/spdx-expression-parse/parser.js new file mode 100644 index 0000000000000..a5e2edbaa27e0 --- /dev/null +++ b/node_modules/spdx-expression-validate/node_modules/spdx-expression-parse/parser.js @@ -0,0 +1,1357 @@ +/* parser generated by jison 0.4.17 */ +/* + Returns a Parser object of the following structure: + + Parser: { + yy: {} + } + + Parser.prototype: { + yy: {}, + trace: function(), + symbols_: {associative list: name ==> number}, + terminals_: {associative list: number ==> name}, + productions_: [...], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$), + table: [...], + defaultActions: {...}, + parseError: function(str, hash), + parse: function(input), + + lexer: { + EOF: 1, + parseError: function(str, hash), + setInput: function(input), + input: function(), + unput: function(str), + more: function(), + less: function(n), + pastInput: function(), + upcomingInput: function(), + showPosition: function(), + test_match: function(regex_match_array, rule_index), + next: function(), + lex: function(), + begin: function(condition), + popState: function(), + _currentRules: function(), + topState: function(), + pushState: function(condition), + + options: { + ranges: boolean (optional: true ==> token location info will include a .range[] member) + flex: boolean (optional: true ==> flex-like lexing behaviour where the rules are tested exhaustively to find the longest match) + backtrack_lexer: boolean (optional: true ==> lexer regexes are tested in order and for each matching regex the action code is invoked; the lexer terminates the scan when a token is returned by the action code) + }, + + performAction: function(yy, yy_, $avoiding_name_collisions, YY_START), + rules: [...], + conditions: {associative list: name ==> set}, + } + } + + + token location info (@$, _$, etc.): { + first_line: n, + last_line: n, + first_column: n, + last_column: n, + range: [start_number, end_number] (where the numbers are indexes into the input string, regular zero-based) + } + + + the parseError function receives a 'hash' object with these members for lexer and parser errors: { + text: (matched text) + token: (the produced terminal token, if any) + line: (yylineno) + } + while parser (grammar) errors will also provide these members, i.e. parser errors deliver a superset of attributes: { + loc: (yylloc) + expected: (string describing the set of expected tokens) + recoverable: (boolean: TRUE when the parser has a error recovery rule available for this particular error) + } +*/ +var spdxparse = (function(){ +var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[1,5],$V1=[1,6],$V2=[1,7],$V3=[1,4],$V4=[1,9],$V5=[1,10],$V6=[5,14,15,17],$V7=[5,12,14,15,17]; +var parser = {trace: function trace() { }, +yy: {}, +symbols_: {"error":2,"start":3,"expression":4,"EOS":5,"simpleExpression":6,"LICENSE":7,"PLUS":8,"LICENSEREF":9,"DOCUMENTREF":10,"COLON":11,"WITH":12,"EXCEPTION":13,"AND":14,"OR":15,"OPEN":16,"CLOSE":17,"$accept":0,"$end":1}, +terminals_: {2:"error",5:"EOS",7:"LICENSE",8:"PLUS",9:"LICENSEREF",10:"DOCUMENTREF",11:"COLON",12:"WITH",13:"EXCEPTION",14:"AND",15:"OR",16:"OPEN",17:"CLOSE"}, +productions_: [0,[3,2],[6,1],[6,2],[6,1],[6,3],[4,1],[4,3],[4,3],[4,3],[4,3]], +performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) { +/* this == yyval */ + +var $0 = $$.length - 1; +switch (yystate) { +case 1: +return this.$ = $$[$0-1] +break; +case 2: case 4: case 5: +this.$ = {license: yytext} +break; +case 3: +this.$ = {license: $$[$0-1], plus: true} +break; +case 6: +this.$ = $$[$0] +break; +case 7: +this.$ = {exception: $$[$0]} +this.$.license = $$[$0-2].license +if ($$[$0-2].hasOwnProperty('plus')) { + this.$.plus = $$[$0-2].plus +} +break; +case 8: +this.$ = {conjunction: 'and', left: $$[$0-2], right: $$[$0]} +break; +case 9: +this.$ = {conjunction: 'or', left: $$[$0-2], right: $$[$0]} +break; +case 10: +this.$ = $$[$0-1] +break; +} +}, +table: [{3:1,4:2,6:3,7:$V0,9:$V1,10:$V2,16:$V3},{1:[3]},{5:[1,8],14:$V4,15:$V5},o($V6,[2,6],{12:[1,11]}),{4:12,6:3,7:$V0,9:$V1,10:$V2,16:$V3},o($V7,[2,2],{8:[1,13]}),o($V7,[2,4]),{11:[1,14]},{1:[2,1]},{4:15,6:3,7:$V0,9:$V1,10:$V2,16:$V3},{4:16,6:3,7:$V0,9:$V1,10:$V2,16:$V3},{13:[1,17]},{14:$V4,15:$V5,17:[1,18]},o($V7,[2,3]),{9:[1,19]},o($V6,[2,8]),o([5,15,17],[2,9],{14:$V4}),o($V6,[2,7]),o($V6,[2,10]),o($V7,[2,5])], +defaultActions: {8:[2,1]}, +parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + function _parseError (msg, hash) { + this.message = msg; + this.hash = hash; + } + _parseError.prototype = Error; + + throw new _parseError(str, hash); + } +}, +parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = '', yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer; + sharedState.yy.parser = this; + if (typeof lexer.yylloc == 'undefined') { + lexer.yylloc = {}; + } + var yyloc = lexer.yylloc; + lstack.push(yyloc); + var ranges = lexer.options && lexer.options.ranges; + if (typeof sharedState.yy.parseError === 'function') { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function popStack(n) { + stack.length = stack.length - 2 * n; + vstack.length = vstack.length - n; + lstack.length = lstack.length - n; + } + _token_stack: + var lex = function () { + var token; + token = lexer.lex() || EOF; + if (typeof token !== 'number') { + token = self.symbols_[token] || token; + } + return token; + }; + var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == 'undefined') { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === 'undefined' || !action.length || !action[0]) { + var errStr = ''; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push('\'' + this.terminals_[p] + '\''); + } + } + if (lexer.showPosition) { + errStr = 'Parse error on line ' + (yylineno + 1) + ':\n' + lexer.showPosition() + '\nExpecting ' + expected.join(', ') + ', got \'' + (this.terminals_[symbol] || symbol) + '\''; + } else { + errStr = 'Parse error on line ' + (yylineno + 1) + ': Unexpected ' + (symbol == EOF ? 'end of input' : '\'' + (this.terminals_[symbol] || symbol) + '\''); + } + this.parseError(errStr, { + text: lexer.match, + token: this.terminals_[symbol] || symbol, + line: lexer.yylineno, + loc: yyloc, + expected: expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer.yytext); + lstack.push(lexer.yylloc); + stack.push(action[1]); + symbol = null; + if (!preErrorSymbol) { + yyleng = lexer.yyleng; + yytext = lexer.yytext; + yylineno = lexer.yylineno; + yyloc = lexer.yylloc; + if (recovering > 0) { + recovering--; + } + } else { + symbol = preErrorSymbol; + preErrorSymbol = null; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== 'undefined') { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; +}}; +/* generated by jison-lex 0.3.4 */ +var lexer = (function(){ +var lexer = ({ + +EOF:1, + +parseError:function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + +// resets the lexer, sets new input +setInput:function (input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ''; + this.conditionStack = ['INITIAL']; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0,0]; + } + this.offset = 0; + return this; + }, + +// consumes and returns one char from the input +input:function () { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + + this._input = this._input.slice(1); + return ch; + }, + +// unshifts one char (or a string) into the input +unput:function (ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + //this.yyleng -= len; + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? + (lines.length === oldLines.length ? this.yylloc.first_column : 0) + + oldLines[oldLines.length - lines.length].length - lines[0].length : + this.yylloc.first_column - len + }; + + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + +// When called from action, caches matched text and appends it on next action +more:function () { + this._more = true; + return this; + }, + +// When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. +reject:function () { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n' + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + + } + return this; + }, + +// retain first n characters of the match +less:function (n) { + this.unput(this.match.slice(n)); + }, + +// displays already matched input, i.e. for error messages +pastInput:function () { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, ""); + }, + +// displays upcoming input, i.e. for error messages +upcomingInput:function () { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20-next.length); + } + return (next.substr(0,20) + (next.length > 20 ? '...' : '')).replace(/\n/g, ""); + }, + +// displays the character position where the lexing error occurred, i.e. for error messages +showPosition:function () { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + +// test the lexed token: return FALSE when not a match, otherwise return token +test_match:function (match, indexed_rule) { + var token, + lines, + backup; + + if (this.options.backtrack_lexer) { + // save context + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? + lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : + this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + // recover context + for (var k in backup) { + this[k] = backup[k]; + } + return false; // rule action called reject() implying the next rule should be tested instead. + } + return false; + }, + +// return next match in input +next:function () { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + + var token, + match, + tempMatch, + index; + if (!this._more) { + this.yytext = ''; + this.match = ''; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\n' + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + +// return next match that has a token +lex:function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + +// activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) +begin:function begin(condition) { + this.conditionStack.push(condition); + }, + +// pop the previously active lexer condition state off the condition stack +popState:function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + +// produce the lexer rule set which is active for the currently active lexer condition state +_currentRules:function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + +// return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available +topState:function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + +// alias for begin(condition) +pushState:function pushState(condition) { + this.begin(condition); + }, + +// return the number of states currently on the stack +stateStackSize:function stateStackSize() { + return this.conditionStack.length; + }, +options: {}, +performAction: function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) { +var YYSTATE=YY_START; +switch($avoiding_name_collisions) { +case 0:return 5 +break; +case 1:/* skip whitespace */ +break; +case 2:return 8 +break; +case 3:return 16 +break; +case 4:return 17 +break; +case 5:return 11 +break; +case 6:return 10 +break; +case 7:return 9 +break; +case 8:return 14 +break; +case 9:return 15 +break; +case 10:return 12 +break; +case 11:return 7 +break; +case 12:return 7 +break; +case 13:return 7 +break; +case 14:return 7 +break; +case 15:return 7 +break; +case 16:return 7 +break; +case 17:return 7 +break; +case 18:return 7 +break; +case 19:return 7 +break; +case 20:return 7 +break; +case 21:return 7 +break; +case 22:return 7 +break; +case 23:return 7 +break; +case 24:return 13 +break; +case 25:return 13 +break; +case 26:return 13 +break; +case 27:return 13 +break; +case 28:return 13 +break; +case 29:return 13 +break; +case 30:return 13 +break; +case 31:return 13 +break; +case 32:return 7 +break; +case 33:return 13 +break; +case 34:return 7 +break; +case 35:return 13 +break; +case 36:return 7 +break; +case 37:return 13 +break; +case 38:return 13 +break; +case 39:return 7 +break; +case 40:return 13 +break; +case 41:return 13 +break; +case 42:return 13 +break; +case 43:return 13 +break; +case 44:return 13 +break; +case 45:return 7 +break; +case 46:return 13 +break; +case 47:return 7 +break; +case 48:return 7 +break; +case 49:return 7 +break; +case 50:return 7 +break; +case 51:return 7 +break; +case 52:return 7 +break; +case 53:return 7 +break; +case 54:return 7 +break; +case 55:return 7 +break; +case 56:return 7 +break; +case 57:return 7 +break; +case 58:return 7 +break; +case 59:return 7 +break; +case 60:return 7 +break; +case 61:return 7 +break; +case 62:return 7 +break; +case 63:return 13 +break; +case 64:return 7 +break; +case 65:return 7 +break; +case 66:return 13 +break; +case 67:return 7 +break; +case 68:return 7 +break; +case 69:return 7 +break; +case 70:return 7 +break; +case 71:return 7 +break; +case 72:return 7 +break; +case 73:return 13 +break; +case 74:return 7 +break; +case 75:return 13 +break; +case 76:return 7 +break; +case 77:return 7 +break; +case 78:return 7 +break; +case 79:return 7 +break; +case 80:return 7 +break; +case 81:return 7 +break; +case 82:return 7 +break; +case 83:return 7 +break; +case 84:return 7 +break; +case 85:return 7 +break; +case 86:return 7 +break; +case 87:return 7 +break; +case 88:return 7 +break; +case 89:return 7 +break; +case 90:return 7 +break; +case 91:return 7 +break; +case 92:return 7 +break; +case 93:return 7 +break; +case 94:return 7 +break; +case 95:return 7 +break; +case 96:return 7 +break; +case 97:return 7 +break; +case 98:return 7 +break; +case 99:return 7 +break; +case 100:return 7 +break; +case 101:return 7 +break; +case 102:return 7 +break; +case 103:return 7 +break; +case 104:return 7 +break; +case 105:return 7 +break; +case 106:return 7 +break; +case 107:return 7 +break; +case 108:return 7 +break; +case 109:return 7 +break; +case 110:return 7 +break; +case 111:return 7 +break; +case 112:return 7 +break; +case 113:return 7 +break; +case 114:return 7 +break; +case 115:return 7 +break; +case 116:return 7 +break; +case 117:return 7 +break; +case 118:return 7 +break; +case 119:return 7 +break; +case 120:return 7 +break; +case 121:return 7 +break; +case 122:return 7 +break; +case 123:return 7 +break; +case 124:return 7 +break; +case 125:return 7 +break; +case 126:return 7 +break; +case 127:return 7 +break; +case 128:return 7 +break; +case 129:return 7 +break; +case 130:return 7 +break; +case 131:return 7 +break; +case 132:return 7 +break; +case 133:return 7 +break; +case 134:return 7 +break; +case 135:return 7 +break; +case 136:return 7 +break; +case 137:return 7 +break; +case 138:return 7 +break; +case 139:return 7 +break; +case 140:return 7 +break; +case 141:return 7 +break; +case 142:return 7 +break; +case 143:return 7 +break; +case 144:return 7 +break; +case 145:return 7 +break; +case 146:return 7 +break; +case 147:return 7 +break; +case 148:return 7 +break; +case 149:return 7 +break; +case 150:return 7 +break; +case 151:return 7 +break; +case 152:return 7 +break; +case 153:return 7 +break; +case 154:return 7 +break; +case 155:return 7 +break; +case 156:return 7 +break; +case 157:return 7 +break; +case 158:return 7 +break; +case 159:return 7 +break; +case 160:return 7 +break; +case 161:return 7 +break; +case 162:return 7 +break; +case 163:return 7 +break; +case 164:return 7 +break; +case 165:return 7 +break; +case 166:return 7 +break; +case 167:return 7 +break; +case 168:return 7 +break; +case 169:return 7 +break; +case 170:return 7 +break; +case 171:return 7 +break; +case 172:return 7 +break; +case 173:return 7 +break; +case 174:return 7 +break; +case 175:return 7 +break; +case 176:return 7 +break; +case 177:return 7 +break; +case 178:return 7 +break; +case 179:return 7 +break; +case 180:return 7 +break; +case 181:return 7 +break; +case 182:return 7 +break; +case 183:return 7 +break; +case 184:return 7 +break; +case 185:return 7 +break; +case 186:return 7 +break; +case 187:return 7 +break; +case 188:return 7 +break; +case 189:return 7 +break; +case 190:return 7 +break; +case 191:return 7 +break; +case 192:return 7 +break; +case 193:return 7 +break; +case 194:return 7 +break; +case 195:return 7 +break; +case 196:return 7 +break; +case 197:return 7 +break; +case 198:return 7 +break; +case 199:return 7 +break; +case 200:return 7 +break; +case 201:return 7 +break; +case 202:return 7 +break; +case 203:return 7 +break; +case 204:return 7 +break; +case 205:return 7 +break; +case 206:return 7 +break; +case 207:return 7 +break; +case 208:return 7 +break; +case 209:return 7 +break; +case 210:return 7 +break; +case 211:return 7 +break; +case 212:return 7 +break; +case 213:return 7 +break; +case 214:return 7 +break; +case 215:return 7 +break; +case 216:return 7 +break; +case 217:return 7 +break; +case 218:return 7 +break; +case 219:return 7 +break; +case 220:return 7 +break; +case 221:return 7 +break; +case 222:return 7 +break; +case 223:return 7 +break; +case 224:return 7 +break; +case 225:return 7 +break; +case 226:return 7 +break; +case 227:return 7 +break; +case 228:return 7 +break; +case 229:return 7 +break; +case 230:return 7 +break; +case 231:return 7 +break; +case 232:return 7 +break; +case 233:return 7 +break; +case 234:return 7 +break; +case 235:return 7 +break; +case 236:return 7 +break; +case 237:return 7 +break; +case 238:return 7 +break; +case 239:return 7 +break; +case 240:return 7 +break; +case 241:return 7 +break; +case 242:return 7 +break; +case 243:return 7 +break; +case 244:return 7 +break; +case 245:return 7 +break; +case 246:return 7 +break; +case 247:return 7 +break; +case 248:return 7 +break; +case 249:return 7 +break; +case 250:return 7 +break; +case 251:return 7 +break; +case 252:return 7 +break; +case 253:return 7 +break; +case 254:return 7 +break; +case 255:return 7 +break; +case 256:return 7 +break; +case 257:return 7 +break; +case 258:return 7 +break; +case 259:return 7 +break; +case 260:return 7 +break; +case 261:return 7 +break; +case 262:return 7 +break; +case 263:return 7 +break; +case 264:return 7 +break; +case 265:return 7 +break; +case 266:return 7 +break; +case 267:return 7 +break; +case 268:return 7 +break; +case 269:return 7 +break; +case 270:return 7 +break; +case 271:return 7 +break; +case 272:return 7 +break; +case 273:return 7 +break; +case 274:return 7 +break; +case 275:return 7 +break; +case 276:return 7 +break; +case 277:return 7 +break; +case 278:return 7 +break; +case 279:return 7 +break; +case 280:return 7 +break; +case 281:return 7 +break; +case 282:return 7 +break; +case 283:return 7 +break; +case 284:return 7 +break; +case 285:return 7 +break; +case 286:return 7 +break; +case 287:return 7 +break; +case 288:return 7 +break; +case 289:return 7 +break; +case 290:return 7 +break; +case 291:return 7 +break; +case 292:return 7 +break; +case 293:return 7 +break; +case 294:return 7 +break; +case 295:return 7 +break; +case 296:return 7 +break; +case 297:return 7 +break; +case 298:return 7 +break; +case 299:return 7 +break; +case 300:return 7 +break; +case 301:return 7 +break; +case 302:return 7 +break; +case 303:return 7 +break; +case 304:return 7 +break; +case 305:return 7 +break; +case 306:return 7 +break; +case 307:return 7 +break; +case 308:return 7 +break; +case 309:return 7 +break; +case 310:return 7 +break; +case 311:return 7 +break; +case 312:return 7 +break; +case 313:return 7 +break; +case 314:return 7 +break; +case 315:return 7 +break; +case 316:return 7 +break; +case 317:return 7 +break; +case 318:return 7 +break; +case 319:return 7 +break; +case 320:return 7 +break; +case 321:return 7 +break; +case 322:return 7 +break; +case 323:return 7 +break; +case 324:return 7 +break; +case 325:return 7 +break; +case 326:return 7 +break; +case 327:return 7 +break; +case 328:return 7 +break; +case 329:return 7 +break; +case 330:return 7 +break; +case 331:return 7 +break; +case 332:return 7 +break; +case 333:return 7 +break; +case 334:return 7 +break; +case 335:return 7 +break; +case 336:return 7 +break; +case 337:return 7 +break; +case 338:return 7 +break; +case 339:return 7 +break; +case 340:return 7 +break; +case 341:return 7 +break; +case 342:return 7 +break; +case 343:return 7 +break; +case 344:return 7 +break; +case 345:return 7 +break; +case 346:return 7 +break; +case 347:return 7 +break; +case 348:return 7 +break; +case 349:return 7 +break; +case 350:return 7 +break; +case 351:return 7 +break; +case 352:return 7 +break; +case 353:return 7 +break; +case 354:return 7 +break; +case 355:return 7 +break; +case 356:return 7 +break; +case 357:return 7 +break; +case 358:return 7 +break; +case 359:return 7 +break; +case 360:return 7 +break; +case 361:return 7 +break; +case 362:return 7 +break; +case 363:return 7 +break; +case 364:return 7 +break; +} +}, +rules: [/^(?:$)/,/^(?:\s+)/,/^(?:\+)/,/^(?:\()/,/^(?:\))/,/^(?::)/,/^(?:DocumentRef-([0-9A-Za-z-+.]+))/,/^(?:LicenseRef-([0-9A-Za-z-+.]+))/,/^(?:AND)/,/^(?:OR)/,/^(?:WITH)/,/^(?:BSD-3-Clause-No-Nuclear-License-2014)/,/^(?:BSD-3-Clause-No-Nuclear-Warranty)/,/^(?:GPL-2\.0-with-classpath-exception)/,/^(?:GPL-3\.0-with-autoconf-exception)/,/^(?:GPL-2\.0-with-autoconf-exception)/,/^(?:BSD-3-Clause-No-Nuclear-License)/,/^(?:MPL-2\.0-no-copyleft-exception)/,/^(?:GPL-2\.0-with-bison-exception)/,/^(?:GPL-2\.0-with-font-exception)/,/^(?:GPL-2\.0-with-GCC-exception)/,/^(?:CNRI-Python-GPL-Compatible)/,/^(?:GPL-3\.0-with-GCC-exception)/,/^(?:BSD-3-Clause-Attribution)/,/^(?:Classpath-exception-2\.0)/,/^(?:WxWindows-exception-3\.1)/,/^(?:freertos-exception-2\.0)/,/^(?:Autoconf-exception-3\.0)/,/^(?:i2p-gpl-java-exception)/,/^(?:gnu-javamail-exception)/,/^(?:Nokia-Qt-exception-1\.1)/,/^(?:Autoconf-exception-2\.0)/,/^(?:BSD-2-Clause-FreeBSD)/,/^(?:u-boot-exception-2\.0)/,/^(?:zlib-acknowledgement)/,/^(?:Bison-exception-2\.2)/,/^(?:BSD-2-Clause-NetBSD)/,/^(?:CLISP-exception-2\.0)/,/^(?:eCos-exception-2\.0)/,/^(?:BSD-3-Clause-Clear)/,/^(?:Font-exception-2\.0)/,/^(?:FLTK-exception-2\.0)/,/^(?:GCC-exception-2\.0)/,/^(?:Qwt-exception-1\.0)/,/^(?:Libtool-exception)/,/^(?:BSD-3-Clause-LBNL)/,/^(?:GCC-exception-3\.1)/,/^(?:Artistic-1\.0-Perl)/,/^(?:Artistic-1\.0-cl8)/,/^(?:CC-BY-NC-SA-2\.5)/,/^(?:MIT-advertising)/,/^(?:BSD-Source-Code)/,/^(?:CC-BY-NC-SA-4\.0)/,/^(?:LiLiQ-Rplus-1\.1)/,/^(?:CC-BY-NC-SA-3\.0)/,/^(?:BSD-4-Clause-UC)/,/^(?:CC-BY-NC-SA-2\.0)/,/^(?:CC-BY-NC-SA-1\.0)/,/^(?:CC-BY-NC-ND-4\.0)/,/^(?:CC-BY-NC-ND-3\.0)/,/^(?:CC-BY-NC-ND-2\.5)/,/^(?:CC-BY-NC-ND-2\.0)/,/^(?:CC-BY-NC-ND-1\.0)/,/^(?:LZMA-exception)/,/^(?:BitTorrent-1\.1)/,/^(?:CrystalStacker)/,/^(?:FLTK-exception)/,/^(?:SugarCRM-1\.1\.3)/,/^(?:BSD-Protection)/,/^(?:BitTorrent-1\.0)/,/^(?:HaskellReport)/,/^(?:Interbase-1\.0)/,/^(?:StandardML-NJ)/,/^(?:mif-exception)/,/^(?:Frameworx-1\.0)/,/^(?:389-exception)/,/^(?:CC-BY-NC-2\.0)/,/^(?:CC-BY-NC-2\.5)/,/^(?:CC-BY-NC-3\.0)/,/^(?:CC-BY-NC-4\.0)/,/^(?:W3C-19980720)/,/^(?:CC-BY-SA-1\.0)/,/^(?:CC-BY-SA-2\.0)/,/^(?:CC-BY-SA-2\.5)/,/^(?:CC-BY-ND-2\.0)/,/^(?:CC-BY-SA-4\.0)/,/^(?:CC-BY-SA-3\.0)/,/^(?:Artistic-1\.0)/,/^(?:Artistic-2\.0)/,/^(?:CC-BY-ND-2\.5)/,/^(?:CC-BY-ND-3\.0)/,/^(?:CC-BY-ND-4\.0)/,/^(?:CC-BY-ND-1\.0)/,/^(?:BSD-4-Clause)/,/^(?:BSD-3-Clause)/,/^(?:BSD-2-Clause)/,/^(?:CC-BY-NC-1\.0)/,/^(?:bzip2-1\.0\.6)/,/^(?:Unicode-TOU)/,/^(?:CNRI-Jython)/,/^(?:ImageMagick)/,/^(?:Adobe-Glyph)/,/^(?:CUA-OPL-1\.0)/,/^(?:OLDAP-2\.2\.2)/,/^(?:LiLiQ-R-1\.1)/,/^(?:bzip2-1\.0\.5)/,/^(?:LiLiQ-P-1\.1)/,/^(?:OLDAP-2\.0\.1)/,/^(?:OLDAP-2\.2\.1)/,/^(?:CNRI-Python)/,/^(?:XFree86-1\.1)/,/^(?:OSET-PL-2\.1)/,/^(?:Apache-2\.0)/,/^(?:Watcom-1\.0)/,/^(?:PostgreSQL)/,/^(?:Python-2\.0)/,/^(?:RHeCos-1\.1)/,/^(?:EUDatagrid)/,/^(?:Spencer-99)/,/^(?:Intel-ACPI)/,/^(?:CECILL-1\.0)/,/^(?:CECILL-1\.1)/,/^(?:JasPer-2\.0)/,/^(?:CECILL-2\.0)/,/^(?:CECILL-2\.1)/,/^(?:gSOAP-1\.3b)/,/^(?:Spencer-94)/,/^(?:Apache-1\.1)/,/^(?:Spencer-86)/,/^(?:Apache-1\.0)/,/^(?:ClArtistic)/,/^(?:TORQUE-1\.1)/,/^(?:CATOSL-1\.1)/,/^(?:Adobe-2006)/,/^(?:Zimbra-1\.4)/,/^(?:Zimbra-1\.3)/,/^(?:Condor-1\.1)/,/^(?:CC-BY-3\.0)/,/^(?:CC-BY-2\.5)/,/^(?:OLDAP-2\.4)/,/^(?:SGI-B-1\.1)/,/^(?:SISSL-1\.2)/,/^(?:SGI-B-1\.0)/,/^(?:OLDAP-2\.3)/,/^(?:CC-BY-4\.0)/,/^(?:Crossword)/,/^(?:SimPL-2\.0)/,/^(?:OLDAP-2\.2)/,/^(?:OLDAP-2\.1)/,/^(?:ErlPL-1\.1)/,/^(?:LPPL-1\.3a)/,/^(?:LPPL-1\.3c)/,/^(?:OLDAP-2\.0)/,/^(?:Leptonica)/,/^(?:CPOL-1\.02)/,/^(?:OLDAP-1\.4)/,/^(?:OLDAP-1\.3)/,/^(?:CC-BY-2\.0)/,/^(?:Unlicense)/,/^(?:OLDAP-2\.8)/,/^(?:OLDAP-1\.2)/,/^(?:MakeIndex)/,/^(?:OLDAP-2\.7)/,/^(?:OLDAP-1\.1)/,/^(?:Sleepycat)/,/^(?:D-FSL-1\.0)/,/^(?:CC-BY-1\.0)/,/^(?:OLDAP-2\.6)/,/^(?:WXwindows)/,/^(?:NPOSL-3\.0)/,/^(?:FreeImage)/,/^(?:SGI-B-2\.0)/,/^(?:OLDAP-2\.5)/,/^(?:Beerware)/,/^(?:Newsletr)/,/^(?:NBPL-1\.0)/,/^(?:NASA-1\.3)/,/^(?:NLOD-1\.0)/,/^(?:AGPL-1\.0)/,/^(?:OCLC-2\.0)/,/^(?:ODbL-1\.0)/,/^(?:PDDL-1\.0)/,/^(?:Motosoto)/,/^(?:Afmparse)/,/^(?:ANTLR-PD)/,/^(?:LPL-1\.02)/,/^(?:Abstyles)/,/^(?:eCos-2\.0)/,/^(?:APSL-1\.0)/,/^(?:LPPL-1\.2)/,/^(?:LPPL-1\.1)/,/^(?:LPPL-1\.0)/,/^(?:APSL-1\.1)/,/^(?:APSL-2\.0)/,/^(?:Info-ZIP)/,/^(?:Zend-2\.0)/,/^(?:IBM-pibs)/,/^(?:LGPL-2\.0)/,/^(?:LGPL-3\.0)/,/^(?:LGPL-2\.1)/,/^(?:GFDL-1\.3)/,/^(?:PHP-3\.01)/,/^(?:GFDL-1\.2)/,/^(?:GFDL-1\.1)/,/^(?:AGPL-3\.0)/,/^(?:Giftware)/,/^(?:EUPL-1\.1)/,/^(?:RPSL-1\.0)/,/^(?:EUPL-1\.0)/,/^(?:MIT-enna)/,/^(?:CECILL-B)/,/^(?:diffmark)/,/^(?:CECILL-C)/,/^(?:CDDL-1\.0)/,/^(?:Sendmail)/,/^(?:CDDL-1\.1)/,/^(?:CPAL-1\.0)/,/^(?:APSL-1\.2)/,/^(?:NPL-1\.1)/,/^(?:AFL-1\.2)/,/^(?:Caldera)/,/^(?:AFL-2\.0)/,/^(?:FSFULLR)/,/^(?:AFL-2\.1)/,/^(?:VSL-1\.0)/,/^(?:VOSTROM)/,/^(?:UPL-1\.0)/,/^(?:Dotseqn)/,/^(?:CPL-1\.0)/,/^(?:dvipdfm)/,/^(?:EPL-1\.0)/,/^(?:OCCT-PL)/,/^(?:ECL-1\.0)/,/^(?:Latex2e)/,/^(?:ECL-2\.0)/,/^(?:GPL-1\.0)/,/^(?:GPL-2\.0)/,/^(?:GPL-3\.0)/,/^(?:AFL-3\.0)/,/^(?:LAL-1\.2)/,/^(?:LAL-1\.3)/,/^(?:EFL-1\.0)/,/^(?:EFL-2\.0)/,/^(?:gnuplot)/,/^(?:Aladdin)/,/^(?:LPL-1\.0)/,/^(?:libtiff)/,/^(?:Entessa)/,/^(?:AMDPLPA)/,/^(?:IPL-1\.0)/,/^(?:OPL-1\.0)/,/^(?:OSL-1\.0)/,/^(?:OSL-1\.1)/,/^(?:OSL-2\.0)/,/^(?:OSL-2\.1)/,/^(?:OSL-3\.0)/,/^(?:OpenSSL)/,/^(?:ZPL-2\.1)/,/^(?:PHP-3\.0)/,/^(?:ZPL-2\.0)/,/^(?:ZPL-1\.1)/,/^(?:CC0-1\.0)/,/^(?:SPL-1\.0)/,/^(?:psutils)/,/^(?:MPL-1\.0)/,/^(?:QPL-1\.0)/,/^(?:MPL-1\.1)/,/^(?:MPL-2\.0)/,/^(?:APL-1\.0)/,/^(?:RPL-1\.1)/,/^(?:RPL-1\.5)/,/^(?:MIT-CMU)/,/^(?:Multics)/,/^(?:Eurosym)/,/^(?:BSL-1\.0)/,/^(?:MIT-feh)/,/^(?:Saxpath)/,/^(?:Borceux)/,/^(?:OFL-1\.1)/,/^(?:OFL-1\.0)/,/^(?:AFL-1\.1)/,/^(?:YPL-1\.1)/,/^(?:YPL-1\.0)/,/^(?:NPL-1\.0)/,/^(?:iMatix)/,/^(?:mpich2)/,/^(?:APAFML)/,/^(?:Bahyph)/,/^(?:RSA-MD)/,/^(?:psfrag)/,/^(?:Plexus)/,/^(?:eGenix)/,/^(?:Glulxe)/,/^(?:SAX-PD)/,/^(?:Imlib2)/,/^(?:Wsuipa)/,/^(?:LGPLLR)/,/^(?:Libpng)/,/^(?:xinetd)/,/^(?:MITNFA)/,/^(?:NetCDF)/,/^(?:Naumen)/,/^(?:SMPPL)/,/^(?:Nunit)/,/^(?:FSFUL)/,/^(?:GL2PS)/,/^(?:SMLNJ)/,/^(?:Rdisc)/,/^(?:Noweb)/,/^(?:Nokia)/,/^(?:SISSL)/,/^(?:Qhull)/,/^(?:Intel)/,/^(?:Glide)/,/^(?:Xerox)/,/^(?:AMPAS)/,/^(?:WTFPL)/,/^(?:MS-PL)/,/^(?:XSkat)/,/^(?:MS-RL)/,/^(?:MirOS)/,/^(?:RSCPL)/,/^(?:TMate)/,/^(?:OGTSL)/,/^(?:FSFAP)/,/^(?:NCSA)/,/^(?:Zlib)/,/^(?:SCEA)/,/^(?:SNIA)/,/^(?:NGPL)/,/^(?:NOSL)/,/^(?:ADSL)/,/^(?:MTLL)/,/^(?:NLPL)/,/^(?:Ruby)/,/^(?:JSON)/,/^(?:Barr)/,/^(?:0BSD)/,/^(?:Xnet)/,/^(?:Cube)/,/^(?:curl)/,/^(?:DSDP)/,/^(?:Fair)/,/^(?:HPND)/,/^(?:TOSL)/,/^(?:IJG)/,/^(?:SWL)/,/^(?:Vim)/,/^(?:FTL)/,/^(?:ICU)/,/^(?:OML)/,/^(?:NRL)/,/^(?:DOC)/,/^(?:TCL)/,/^(?:W3C)/,/^(?:NTP)/,/^(?:IPA)/,/^(?:ISC)/,/^(?:X11)/,/^(?:AAL)/,/^(?:AML)/,/^(?:xpp)/,/^(?:Zed)/,/^(?:MIT)/,/^(?:Mup)/], +conditions: {"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,307,308,309,310,311,312,313,314,315,316,317,318,319,320,321,322,323,324,325,326,327,328,329,330,331,332,333,334,335,336,337,338,339,340,341,342,343,344,345,346,347,348,349,350,351,352,353,354,355,356,357,358,359,360,361,362,363,364],"inclusive":true}} +}); +return lexer; +})(); +parser.lexer = lexer; +function Parser () { + this.yy = {}; +} +Parser.prototype = parser;parser.Parser = Parser; +return new Parser; +})(); + + +if (typeof require !== 'undefined' && typeof exports !== 'undefined') { +exports.parser = spdxparse; +exports.Parser = spdxparse.Parser; +exports.parse = function () { return spdxparse.parse.apply(spdxparse, arguments); }; +exports.main = function commonjsMain(args) { + if (!args[1]) { + console.log('Usage: '+args[0]+' FILE'); + process.exit(1); + } + var source = require('fs').readFileSync(require('path').normalize(args[1]), "utf8"); + return exports.parser.parse(source); +}; +if (typeof module !== 'undefined' && require.main === module) { + exports.main(process.argv.slice(1)); +} +} diff --git a/node_modules/spdx-expression-validate/package.json b/node_modules/spdx-expression-validate/package.json new file mode 100644 index 0000000000000..530b3f515620d --- /dev/null +++ b/node_modules/spdx-expression-validate/package.json @@ -0,0 +1,73 @@ +{ + "_args": [ + [ + "spdx-expression-validate@1.0.2", + "/Users/zkat/Documents/code/work/npm" + ] + ], + "_development": true, + "_from": "spdx-expression-validate@1.0.2", + "_id": "spdx-expression-validate@1.0.2", + "_inBundle": false, + "_integrity": "sha1-Wk5NdhbtHJuIFQNmtCF/dnwn6eM=", + "_location": "/spdx-expression-validate", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "spdx-expression-validate@1.0.2", + "name": "spdx-expression-validate", + "escapedName": "spdx-expression-validate", + "rawSpec": "1.0.2", + "saveSpec": null, + "fetchSpec": "1.0.2" + }, + "_requiredBy": [ + "/licensee" + ], + "_resolved": "https://registry.npmjs.org/spdx-expression-validate/-/spdx-expression-validate-1.0.2.tgz", + "_spec": "1.0.2", + "_where": "/Users/zkat/Documents/code/work/npm", + "author": { + "name": "Kyle E. Mitchell", + "email": "kyle@kemitchell.com", + "url": "http://kemitchell.com" + }, + "bugs": { + "url": "https://github.com/kemitchell/spdx-expression-validate.js/issues" + }, + "dependencies": { + "spdx-expression-parse": "^1.0.0" + }, + "description": "validate SPDX license expressions", + "devDependencies": { + "defence-cli": "^1.0.1", + "replace-require-self": "^1.0.0", + "standard": "^8.3.0" + }, + "files": [ + "index.js" + ], + "homepage": "https://github.com/kemitchell/spdx.js", + "keywords": [ + "SPDX", + "law", + "legal", + "license", + "metadata", + "package", + "package.json", + "standards" + ], + "license": "(MIT AND CC-BY-3.0)", + "name": "spdx-expression-validate", + "repository": { + "type": "git", + "url": "git+https://github.com/kemitchell/spdx-expression-validate.js.git" + }, + "scripts": { + "lint": "standard", + "test": "defence -i javascript README.md | replace-require-self | node" + }, + "version": "1.0.2" +} diff --git a/node_modules/spdx-ranges/LICENSE.md b/node_modules/spdx-ranges/LICENSE.md new file mode 100644 index 0000000000000..6c255589566ff --- /dev/null +++ b/node_modules/spdx-ranges/LICENSE.md @@ -0,0 +1,9 @@ +The MIT License + +Copyright (c) 2015 Kyle E. Mitchell + +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/node_modules/spdx-ranges/README.md b/node_modules/spdx-ranges/README.md new file mode 100644 index 0000000000000..46c95af1d4da2 --- /dev/null +++ b/node_modules/spdx-ranges/README.md @@ -0,0 +1,38 @@ +```javascript +var assert = require('assert') +var ranges = require('spdx-ranges') + +assert( + Array.isArray(ranges), + 'module is an Array' +) + +assert( + ranges.length > 0, + 'the Array has elements' +) + +assert( + ranges.every(function (e) { + return Array.isArray(e) + }), + 'each Array element is an Array' +) + +assert( + ranges.every(function (range) { + return range.every(function (element) { + return ( + typeof element === 'string' || + ( + Array.isArray(element) && + element.every(function (element) { + return typeof element === 'string' + }) + ) + ) + }) + }), + 'elements of Array-elements are strings or Arrays of Strings' +) +``` diff --git a/node_modules/spdx-ranges/index.json b/node_modules/spdx-ranges/index.json new file mode 100644 index 0000000000000..5593f89bf5169 --- /dev/null +++ b/node_modules/spdx-ranges/index.json @@ -0,0 +1,233 @@ +[ + [ + "AFL-1.1", + "AFL-1.2", + "AFL-2.0", + "AFL-2.1", + "AFL-3.0" + ], + [ + "AGPL-1.0", + [ + "AGPL-3.0", + "AGPL-3.0-only" + ] + ], + [ + "Apache-1.0", + "Apache-1.1", + "Apache-2.0" + ], + [ + "APSL-1.0", + "APSL-1.1", + "APSL-1.2", + "APSL-2.0" + ], + [ + "Artistic-1.0", + "Artistic-2.0" + ], + [ + "BitTorrent-1.0", + "BitTorrent-1.1" + ], + [ + "CC-BY-1.0", + "CC-BY-2.0", + "CC-BY-2.5", + "CC-BY-3.0", + "CC-BY-4.0" + ], + [ + "CC-BY-NC-1.0", + "CC-BY-NC-2.0", + "CC-BY-NC-2.5", + "CC-BY-NC-3.0", + "CC-BY-NC-4.0" + ], + [ + "CC-BY-NC-ND-1.0", + "CC-BY-NC-ND-2.0", + "CC-BY-NC-ND-2.5", + "CC-BY-NC-ND-3.0", + "CC-BY-NC-ND-4.0" + ], + [ + "CC-BY-NC-SA-1.0", + "CC-BY-NC-SA-2.0", + "CC-BY-NC-SA-2.5", + "CC-BY-NC-SA-3.0", + "CC-BY-NC-SA-4.0" + ], + [ + "CC-BY-ND-1.0", + "CC-BY-ND-2.0", + "CC-BY-ND-2.5", + "CC-BY-ND-3.0", + "CC-BY-ND-4.0" + ], + [ + "CC-BY-SA-1.0", + "CC-BY-SA-2.0", + "CC-BY-SA-2.5", + "CC-BY-SA-3.0", + "CC-BY-SA-4.0" + ], + [ + "CDDL-1.0", + "CDDL-1.1" + ], + [ + "CECILL-1.0", + "CECILL-1.1", + "CECILL-2.0" + ], + [ + "ECL-1.0", + "ECL-2.0" + ], + [ + "EFL-1.0", + "EFL-2.0" + ], + [ + "EUPL-1.0", + "EUPL-1.1" + ], + [ + [ + "GFDL-1.1", + "GFDL-1.1-only" + ], + [ + "GFDL-1.2", + "GFDL-1.2-only" + ], + [ + "GFDL-1.1-or-later", + "GFDL-1.2-or-later", + "GFDL-1.3", + "GFDL-1.3-only", + "GFDL-1.3-or-later" + ] + ], + [ + [ + "GPL-1.0", + "GPL-1.0-only" + ], + [ + "GPL-2.0", + "GPL-2.0-only" + ], + [ + "GPL-1.0-or-later", + "GPL-2.0-or-later", + "GPL-3.0", + "GPL-3.0-only", + "GPL-3.0-or-later" + ] + ], + [ + [ + "LGPL-2.0", + "LGPL-2.0-only" + ], + [ + "LGPL-2.1", + "LGPL-2.1-only" + ], + [ + "LGPL-2.0-or-later", + "LGPL-2.1-or-later", + "LGPL-3.0", + "LGPL-3.0-only", + "LGPL-3.0-or-later" + ] + ], + [ + "LPL-1.0", + "LPL-1.02" + ], + [ + "LPPL-1.0", + "LPPL-1.1", + "LPPL-1.2", + "LPPL-1.3a", + "LPPL-1.3c" + ], + [ + "MPL-1.0", + "MPL-1.1", + "MPL-2.0" + ], + [ + "MPL-1.0", + "MPL-1.1", + "MPL-2.0-no-copyleft-exception" + ], + [ + "NPL-1.0", + "NPL-1.1" + ], + [ + "OFL-1.0", + "OFL-1.1" + ], + [ + "OLDAP-1.1", + "OLDAP-1.2", + "OLDAP-1.3", + "OLDAP-1.4", + "OLDAP-2.0", + "OLDAP-2.0.1", + "OLDAP-2.1", + "OLDAP-2.2", + "OLDAP-2.2.1", + "OLDAP-2.2.2", + "OLDAP-2.3", + "OLDAP-2.4", + "OLDAP-2.5", + "OLDAP-2.6", + "OLDAP-2.7", + "OLDAP-2.8" + ], + [ + "OSL-1.0", + "OSL-1.1", + "OSL-2.0", + "OSL-2.1", + "OSL-3.0" + ], + [ + "PHP-3.0", + "PHP-3.01" + ], + [ + "RPL-1.1", + "RPL-1.5" + ], + [ + "SGI-B-1.0", + "SGI-B-1.1", + "SGI-B-2.0" + ], + [ + "YPL-1.0", + "YPL-1.1" + ], + [ + "ZPL-1.1", + "ZPL-2.0", + "ZPL-2.1" + ], + [ + "Zimbra-1.3", + "Zimbra-1.4" + ], + [ + "bzip2-1.0.5", + "bzip2-1.0.6" + ] +] diff --git a/node_modules/spdx-ranges/package.json b/node_modules/spdx-ranges/package.json new file mode 100644 index 0000000000000..6dd46a69ace28 --- /dev/null +++ b/node_modules/spdx-ranges/package.json @@ -0,0 +1,60 @@ +{ + "_args": [ + [ + "spdx-ranges@2.0.0", + "/Users/zkat/Documents/code/work/npm" + ] + ], + "_development": true, + "_from": "spdx-ranges@2.0.0", + "_id": "spdx-ranges@2.0.0", + "_inBundle": false, + "_integrity": "sha512-AUUXLfqkwD7GlzZkXv8ePPCpPjeVWI9xJCfysL8re/uKb6H10umMnC7bFRsHmLJan4fslUtekAgpHlSgLc/7mA==", + "_location": "/spdx-ranges", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "spdx-ranges@2.0.0", + "name": "spdx-ranges", + "escapedName": "spdx-ranges", + "rawSpec": "2.0.0", + "saveSpec": null, + "fetchSpec": "2.0.0" + }, + "_requiredBy": [ + "/spdx-compare", + "/spdx-satisfies" + ], + "_resolved": "https://registry.npmjs.org/spdx-ranges/-/spdx-ranges-2.0.0.tgz", + "_spec": "2.0.0", + "_where": "/Users/zkat/Documents/code/work/npm", + "author": { + "name": "The Linux Foundation" + }, + "bugs": { + "url": "https://github.com/kemitchell/spdx-ranges.js/issues" + }, + "contributors": [ + { + "name": "Kyle E. Mitchell", + "email": "kyle@kemitchell.com", + "url": "https://kemitchell.com/" + } + ], + "description": "list of SPDX standard license ranges", + "devDependencies": { + "defence-cli": "^1.0.1" + }, + "homepage": "https://github.com/kemitchell/spdx-ranges.js#readme", + "license": "CC-BY-3.0", + "name": "spdx-ranges", + "repository": { + "type": "git", + "url": "git+https://github.com/kemitchell/spdx-ranges.js.git" + }, + "scripts": { + "test": "defence -i javascript README.md | sed 's!spdx-ranges!./!' | node" + }, + "version": "2.0.0" +} diff --git a/node_modules/spdx-ranges/test.log b/node_modules/spdx-ranges/test.log new file mode 100644 index 0000000000000..90608d1cbe7cf --- /dev/null +++ b/node_modules/spdx-ranges/test.log @@ -0,0 +1,4 @@ + +> spdx-ranges@1.0.1 test /home/kyle/spdx-ranges.js +> defence -i javascript README.md | sed 's!spdx-ranges!./!' | node + diff --git a/node_modules/spdx-satisfies/LICENSE.md b/node_modules/spdx-satisfies/LICENSE.md new file mode 100644 index 0000000000000..6c255589566ff --- /dev/null +++ b/node_modules/spdx-satisfies/LICENSE.md @@ -0,0 +1,9 @@ +The MIT License + +Copyright (c) 2015 Kyle E. Mitchell + +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/node_modules/spdx-satisfies/README.md b/node_modules/spdx-satisfies/README.md new file mode 100644 index 0000000000000..2d175ea8a1aae --- /dev/null +++ b/node_modules/spdx-satisfies/README.md @@ -0,0 +1,31 @@ +```javascript +var assert = require('assert') +var satisfies = require('spdx-satisfies') + +assert(satisfies('MIT', 'MIT')) + +assert(satisfies('MIT', '(ISC OR MIT)')) +assert(satisfies('Zlib', '(ISC OR (MIT OR Zlib))')) +assert(!satisfies('GPL-3.0', '(ISC OR MIT)')) + +assert(satisfies('GPL-2.0', 'GPL-2.0+')) +assert(satisfies('GPL-3.0', 'GPL-2.0+')) +assert(satisfies('GPL-1.0+', 'GPL-2.0+')) +assert(!satisfies('GPL-1.0', 'GPL-2.0+')) +assert(satisfies('GPL-2.0-only', 'GPL-2.0-only')) +assert(satisfies('GPL-3.0-only', 'GPL-2.0+')) + +assert(!satisfies( + 'GPL-2.0', + 'GPL-2.0+ WITH Bison-exception-2.2' +)) + +assert(satisfies( + 'GPL-3.0 WITH Bison-exception-2.2', + 'GPL-2.0+ WITH Bison-exception-2.2' +)) + +assert(satisfies('(MIT OR GPL-2.0)', '(ISC OR MIT)')) +assert(satisfies('(MIT AND GPL-2.0)', '(MIT OR GPL-2.0)')) +assert(!satisfies('(MIT AND GPL-2.0)', '(ISC OR GPL-2.0)')) +``` diff --git a/node_modules/spdx-satisfies/index.js b/node_modules/spdx-satisfies/index.js new file mode 100644 index 0000000000000..2eb22a6b37cc1 --- /dev/null +++ b/node_modules/spdx-satisfies/index.js @@ -0,0 +1,112 @@ +var compare = require('spdx-compare') +var parse = require('spdx-expression-parse') +var ranges = require('spdx-ranges') + +var rangesAreCompatible = function (first, second) { + return ( + first.license === second.license || + ranges.some(function (range) { + return ( + licenseInRange(first.license, range) && + licenseInRange(second.license, range) + ) + }) + ) +} + +function licenseInRange (license, range) { + return ( + range.indexOf(license) !== -1 || + range.some(function (element) { + return ( + Array.isArray(element) && + element.indexOf(license) !== -1 + ) + }) + ) +} + +var identifierInRange = function (identifier, range) { + return ( + identifier.license === range.license || + compare.gt(identifier.license, range.license) || + compare.eq(identifier.license, range.license) + ) +} + +var licensesAreCompatible = function (first, second) { + if (first.exception !== second.exception) { + return false + } else if (second.hasOwnProperty('license')) { + if (second.hasOwnProperty('plus')) { + if (first.hasOwnProperty('plus')) { + // first+, second+ + return rangesAreCompatible(first, second) + } else { + // first, second+ + return identifierInRange(first, second) + } + } else { + if (first.hasOwnProperty('plus')) { + // first+, second + return identifierInRange(second, first) + } else { + // first, second + return first.license === second.license + } + } + } +} + +var recurseLeftAndRight = function (first, second) { + var firstConjunction = first.conjunction + if (firstConjunction === 'and') { + return ( + recurse(first.left, second) && + recurse(first.right, second) + ) + } else if (firstConjunction === 'or') { + return ( + recurse(first.left, second) || + recurse(first.right, second) + ) + } +} + +var recurse = function (first, second) { + if (first.hasOwnProperty('conjunction')) { + return recurseLeftAndRight(first, second) + } else if (second.hasOwnProperty('conjunction')) { + return recurseLeftAndRight(second, first) + } else { + return licensesAreCompatible(first, second) + } +} + +function normalizeGPLIdentifiers (argument) { + var license = argument.license + if (license) { + if (endsWith(license, '-or-later')) { + argument.license = license.replace('-or-later', '') + argument.plus = true + } else if (endsWith(license, '-only')) { + argument.license = license.replace('-or-later', '') + delete argument.plus + } + } else { + argument.left = normalizeGPLIdentifiers(argument.left) + argument.right = normalizeGPLIdentifiers(argument.right) + } + return argument +} + +function endsWith (string, substring) { + return string.indexOf(substring) === string.length - 1 +} + +module.exports = function (first, second) { + return recurse( + normalizeGPLIdentifiers(parse(first)), + normalizeGPLIdentifiers(parse(second)) + ) +} diff --git a/node_modules/spdx-satisfies/package.json b/node_modules/spdx-satisfies/package.json new file mode 100644 index 0000000000000..3354a86bcd227 --- /dev/null +++ b/node_modules/spdx-satisfies/package.json @@ -0,0 +1,72 @@ +{ + "_args": [ + [ + "spdx-satisfies@4.0.0", + "/Users/zkat/Documents/code/work/npm" + ] + ], + "_development": true, + "_from": "spdx-satisfies@4.0.0", + "_id": "spdx-satisfies@4.0.0", + "_inBundle": false, + "_integrity": "sha512-OcARj6U1OuVv98SVrRqgrR30sVocONtoPpnX8Xz4vXNrFVedqtbgkA+0KmQoXIQ2xjfltPPRVIMeNzKEFLWWKQ==", + "_location": "/spdx-satisfies", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "spdx-satisfies@4.0.0", + "name": "spdx-satisfies", + "escapedName": "spdx-satisfies", + "rawSpec": "4.0.0", + "saveSpec": null, + "fetchSpec": "4.0.0" + }, + "_requiredBy": [ + "/licensee" + ], + "_resolved": "https://registry.npmjs.org/spdx-satisfies/-/spdx-satisfies-4.0.0.tgz", + "_spec": "4.0.0", + "_where": "/Users/zkat/Documents/code/work/npm", + "author": { + "name": "Kyle E. Mitchell", + "email": "kyle@kemitchell.com", + "url": "https://kemitchell.com" + }, + "bugs": { + "url": "https://github.com/kemitchell/spdx-satisfies.js/issues" + }, + "dependencies": { + "spdx-compare": "^1.0.0", + "spdx-expression-parse": "^3.0.0", + "spdx-ranges": "^2.0.0" + }, + "description": "test whether SPDX expressions satisfy licensing criteria", + "devDependencies": { + "defence-cli": "^2.0.1", + "replace-require-self": "^1.1.1", + "standard": "^11.0.0" + }, + "homepage": "https://github.com/kemitchell/spdx-satisfies.js#readme", + "keywords": [ + "SPDX", + "law", + "legal", + "license", + "metadata", + "package", + "package.json", + "standards" + ], + "license": "MIT", + "name": "spdx-satisfies", + "repository": { + "type": "git", + "url": "git+https://github.com/kemitchell/spdx-satisfies.js.git" + }, + "scripts": { + "lint": "standard", + "test": "defence -i javascript README.md | replace-require-self | node" + }, + "version": "4.0.0" +} diff --git a/package.json b/package.json index e180a6aafa38c..1dcb9feb003b5 100644 --- a/package.json +++ b/package.json @@ -97,7 +97,6 @@ "npm-package-arg": "^6.1.0", "npm-packlist": "^1.1.12", "npm-pick-manifest": "^2.1.0", - "npm-profile": "^4.0.1", "npm-registry-fetch": "^3.8.0", "npm-user-validate": "~1.0.0", "npmlog": "~4.1.2",