diff --git a/.eslintignore b/.eslintignore index 66b21bd2db56eeb9efc8e7d1e2ac9c6216c190b8..ed3673606a3424362ff8ccae2d04d00f80cacbca 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,3 +1,2 @@ -node_modules -coverage -out +.vscode/* +coverage/* diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 2ad01bd3c8fb1c7cd08ab2530cff527eec361b02..0000000000000000000000000000000000000000 --- a/.eslintrc +++ /dev/null @@ -1,38 +0,0 @@ -{ - "env": { - "node": true, - "es6": true, - "jasmine": true - }, - "rules": { - "array-bracket-spacing": [2, "always"], - "block-scoped-var": 2, - "brace-style": [2, "1tbs", { "allowSingleLine": true }], - "camelcase": 1, - "computed-property-spacing": [2, "never"], - "curly": 2, - "eol-last": 2, - "eqeqeq": [2, "smart"], - "indent": ["error", 2], - "max-depth": [1, 5], - "new-cap": 1, - "no-extend-native": 2, - "no-mixed-spaces-and-tabs": 2, - "no-trailing-spaces": 2, - "no-unused-vars": 1, - "no-use-before-define": [2, "nofunc"], - "no-undef": 2, - "object-curly-spacing": [2, "always"], - "quotes": [2, "single", "avoid-escape"], - "semi": [2, "always"], - "keyword-spacing": [2, { - "before": true, - "after": true - }], - "space-unary-ops": 2, - "comma-spacing": ["error", { "before": false, "after": true }], - "space-before-function-paren": ["error", "never"], - "arrow-spacing": "error", - "arrow-parens": ["error", "as-needed"] - } -} diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000000000000000000000000000000000000..fd6e0c605cc2b785fe8c8a85387b88072ed34af7 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,58 @@ +/* + * Copyright 2018 Adobe. All rights reserved. + * This file is licensed to you 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 REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ + +module.exports = { + 'env': { + 'node': true, + 'es6': true + }, + // this is the root project for all sub modules. stop searching for any + // eslintrc files in parent directories. + 'root': true, + 'parserOptions': { + 'sourceType': 'script', + 'ecmaVersion': 10, + }, + 'plugins': [ + 'header', + ], + 'extends': 'airbnb', + 'rules': { + 'strict': 0, + + // Forbid multiple statements in one line + 'max-statements-per-line': ["error", { "max": 1 }], + + // Allow for-of loops + 'no-restricted-syntax': ['error', 'ForInStatement', 'LabeledStatement', 'WithStatement'], + + // Allow return before else & redundant else statements + 'no-else-return': 'off', + + // allow dangling underscores for 'fields' + 'no-underscore-dangle': ['error', {'allowAfterThis': true}], + + // enforce license header (todo: improve plugin to support patterns for multi-lines) + 'header/header': [2, 'block', ['', + ' * Copyright 2019 Adobe. All rights reserved.', + ' * This file is licensed to you 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 REPRESENTATIONS', + ' * OF ANY KIND, either express or implied. See the License for the specific language', + ' * governing permissions and limitations under the License.', + ' ', + ]] + } +}; diff --git a/cli.js b/cli.js index 135ff07920d9a09d53b991276ea557e3498592d9..6e0e776c8d3427a7607f8eb260f1dc6d95371907 100755 --- a/cli.js +++ b/cli.js @@ -1,24 +1,29 @@ #! /usr/bin/env node -/** - * Copyright 2017 Adobe Systems Incorporated. All rights reserved. +/* + * Copyright 2019 Adobe. All rights reserved. * This file is licensed to you 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 REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. */ -var Promise = require('bluebird'); -var path = require('path'); -var _ = require('lodash'); -var fs = Promise.promisifyAll(require('fs')); -var readdirp = require('readdirp'); -var Ajv = require('ajv'); -var logger = require('winston'); +const Promise = require('bluebird'); +const path = require('path'); +const _ = require('lodash'); +const fs = Promise.promisifyAll(require('fs')); +const readdirp = require('readdirp'); +const Ajv = require('ajv'); +const logger = require('winston'); -var Schema = require('./lib/schema'); -var readSchemaFile = require('./lib/readSchemaFile'); +const Schema = require('./lib/schema'); +const readSchemaFile = require('./lib/readSchemaFile'); // parse/process command line arguments -var argv = require('optimist') +const { argv } = require('optimist') .usage('Generate Markdown documentation from JSON Schema.\n\nUsage: $0') .demand('d') .alias('d', 'input') @@ -41,12 +46,12 @@ var argv = require('optimist') .default('v', '07') .describe('n', 'Do not generate a README.md file in the output directory') .describe('link-*', 'Add this file as a link the explain the * attribute, e.g. --link-abstract=abstract.md') - .check(function(args) { + .check((args) => { if (!fs.existsSync(args.input)) { - throw 'Input file "' + args.input + '" does not exist!'; + throw `Input file "${args.input}" does not exist!`; } if (args.s && !fs.existsSync(args.s)) { - throw 'Meta schema file "' + args.s + '" does not exist!'; + throw `Meta schema file "${args.s}" does not exist!`; } }) .alias('i', 'i18n') @@ -56,79 +61,81 @@ var argv = require('optimist') .default('h', true) .argv; -const docs = _.fromPairs(_.toPairs(argv).filter(([ key, value ]) => { return key.startsWith('link-'); }).map(([ key, value ]) => { return [ key.substr(5), value ];})); +const docs = _.fromPairs(_.toPairs(argv).filter(([key, value]) => key.startsWith('link-')).map(([key, value]) => [key.substr(5), value])); const i18n = require('i18n'); logger.configure({ level: 'info', format: logger.format.combine( logger.format.splat(), - logger.format.simple() + logger.format.simple(), ), transports: [ - new logger.transports.Console({}) - ] + new logger.transports.Console({}), + ], }); -var ajv = new Ajv({ allErrors: true, messages:true, schemaId: 'auto', logger: logger }); +const ajv = new Ajv({ + allErrors: true, messages: true, schemaId: 'auto', logger, +}); console.log(argv.v); -if (argv.v === '06'||argv.v === 6) { +if (argv.v === '06' || argv.v === 6) { console.log('enabling draft-06 support'); ajv.addMetaSchema(require('ajv/lib/refs/json-schema-draft-06.json')); } else if (argv.v === '04' || argv.v === 4) { ajv.addMetaSchema(require('ajv/lib/refs/json-schema-draft-04.json')); } -var schemaPathMap = {}; -var metaElements = {}; -var schemaPath = path.resolve(argv.d); -var outDir = path.resolve(argv.o); -var schemaDir = argv.x === '-' ? '' : argv.x ? path.resolve(argv.x) : outDir; -var target = fs.statSync(schemaPath); +const schemaPathMap = {}; +const metaElements = {}; +const schemaPath = path.resolve(argv.d); +const outDir = path.resolve(argv.o); +const schemaDir = argv.x === '-' ? '' : argv.x ? path.resolve(argv.x) : outDir; +const target = fs.statSync(schemaPath); const readme = argv.n !== true; const schemaExtension = argv.e || 'schema.json'; -if (argv.s){ +if (argv.s) { ajv.addMetaSchema(require(path.resolve(argv.s))); } if (argv.m) { - if (_.isArray(argv.m)){ - _.each(argv.m, function(item){ - var meta=item.split('='); + if (_.isArray(argv.m)) { + _.each(argv.m, (item) => { + const meta = item.split('='); if (meta.length === 2) { metaElements[meta[0]] = meta[1]; } }); } else { - var meta=(argv.m).split('='); + const meta = (argv.m).split('='); if (meta.length === 2) { metaElements[meta[0]] = meta[1]; } } } let i18nPath; -if (argv !== undefined && argv.i !== undefined){ - i18nPath=path.resolve(argv.i) ; +if (argv !== undefined && argv.i !== undefined) { + i18nPath = path.resolve(argv.i); } else { - i18nPath=path.resolve(path.join(__dirname, 'lib/locales')); + i18nPath = path.resolve(path.join(__dirname, 'lib/locales')); } i18n.configure({ // setup some locales - other locales default to en silently - locales:[ 'en' ], + locales: ['en'], // where to store json files - defaults to './locales' relative to modules directory directory: i18nPath, - defaultLocale: 'en' + defaultLocale: 'en', }); logger.info('output directory: %s', outDir); if (target.isDirectory()) { // the ajv json validator will be passed into the main module to help with processing - var files=[]; + const files = []; readdirp(schemaPath, { root: schemaPath, fileFilter: `*.${schemaExtension}` }) - .on('data', entry => { + .on('data', (entry) => { files.push(entry.fullPath); try { ajv.addSchema(require(entry.fullPath), entry.fullPath); - } catch (e){ + } catch (e) { logger.error('Ajv processing error for schema at path %s', entry.fullPath); logger.error(e); process.exit(1); @@ -138,25 +145,25 @@ if (target.isDirectory()) { Schema.setAjv(ajv); Schema.setSchemaPathMap(schemaPathMap); return Promise.reduce(files, readSchemaFile, schemaPathMap) - .then(schemaMap => { + .then((schemaMap) => { logger.info('finished reading all *.%s files in %s, beginning processing….', schemaExtension, schemaPath); return Schema.process(schemaMap, schemaPath, outDir, schemaDir, metaElements, readme, docs, argv); }) .then(() => { logger.info('Processing complete.'); }) - .catch(err => { + .catch((err) => { logger.error(err); process.exit(1); }); }) - .on('error', err => { + .on('error', (err) => { logger.error(err); process.exit(1); }); } else { readSchemaFile(schemaPathMap, schemaPath) - .then(schemaMap => { + .then((schemaMap) => { ajv.addSchema(require(schemaPath), schemaPath); Schema.setAjv(ajv); Schema.setSchemaPathMap(schemaPathMap); @@ -166,7 +173,7 @@ if (target.isDirectory()) { .then(() => { logger.info('Processing complete.'); }) - .catch(err => { + .catch((err) => { logger.error(err); process.exit(1); }); diff --git a/lib/header.js b/lib/header.js index 94ba76105d7ed5dc7d883767f72b28c92687d46a..693faf79ce663c4b61559a864b13f23d5a750511 100644 --- a/lib/header.js +++ b/lib/header.js @@ -1,8 +1,13 @@ -/** - * Copyright 2018 Adobe Systems Incorporated. All rights reserved. +/* + * Copyright 2019 Adobe. All rights reserved. * This file is licensed to you 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 REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. */ const _ = require('lodash'); @@ -11,7 +16,7 @@ const path = require('path'); function custom(schema) { if (schema.allOf) { - for (let i=0; i<schema.allOf.length; i++) { + for (let i = 0; i < schema.allOf.length; i++) { if (schema.allOf[i].$ref && schema.allOf[i].$ref === 'https://ns.adobe.com/xdm/common/extensible.schema.json#/definitions/@context') { return true; } @@ -24,11 +29,11 @@ function schemaProps(schema, schemaPath, filename) { return { // if there are definitions, but no properties abstract: (schema.definitions !== undefined && _.keys(schema.properties).length === 0) ? i18n.__('header.tabel.abstractNo') : i18n.__('header.tabel.abstractYes'), - extensible: (schema.definitions !== undefined || schema['meta:extensible'] === true) ? i18n.__('header.tabel.extensibleYes') : i18n.__('header.tabel.extensibleNo'), + extensible: (schema.definitions !== undefined || schema['meta:extensible'] === true) ? i18n.__('header.tabel.extensibleYes') : i18n.__('header.tabel.extensibleNo'), status: schema['meta:status'] !== undefined ? (schema['meta:status'].charAt(0).toUpperCase() + schema['meta:status'].slice(1)) : i18n.__('header.tabel.statusExperimental'), custom: custom(schema) ? i18n.__('header.tabel.customPropertiesYes') : i18n.__('header.tabel.customPropertiesNo'), original: filename.substr(schemaPath.length).substr(1).replace(/\\/g, '/'), - additionalProperties:schema.additionalProperties===false ? i18n.__('header.tabel.additionalPropertiesNo'): i18n.__('header.tabel.additionalPropertiesYes'), + additionalProperties: schema.additionalProperties === false ? i18n.__('header.tabel.additionalPropertiesNo') : i18n.__('header.tabel.additionalPropertiesYes'), }; } @@ -45,7 +50,7 @@ class Header { } render(text, link, base) { - return function() { + return function () { if (link) { return `[${text}](${base}${link})`; } else { @@ -62,8 +67,8 @@ function header(name, docs, value, links) { this.links = links; - this.render = function(text, link) { - return function() { + this.render = function (text, link) { + return function () { if (link) { return `[${text}](${link})`; } else { @@ -89,7 +94,7 @@ function isIdentifiable(schema) { if (!schema.properties) { return 'Unknown'; } - if (schema.properties['@id']&&schema.properties['@id'].type==='string'&&schema.properties['@id'].format==='uri') { + if (schema.properties['@id'] && schema.properties['@id'].type === 'string' && schema.properties['@id'].format === 'uri') { return 'Yes'; } else { return 'No'; @@ -98,39 +103,39 @@ function isIdentifiable(schema) { function headers(schema, indir, filename, docs) { const props = schemaProps(schema, indir, filename); - this.doclinks = docs ? docs : {}; + this.doclinks = docs || {}; this.myheaders = []; - this.myheaders.push(new Header(i18n.__('header.tabel.abstract'), link(indir, filename, this.doclinks['abstract']), props.abstract)); - this.myheaders.push(new Header(i18n.__('header.tabel.extensible'), link(indir, filename, this.doclinks['extensible']), props.extensible)); - this.myheaders.push(new Header(i18n.__('header.tabel.status'), link(indir, filename, this.doclinks['status']), props.status)); - this.myheaders.push(new Header(i18n.__('header.tabel.identifiable'), link(indir, filename, this.doclinks['id']), isIdentifiable(schema))); - this.myheaders.push(new Header(i18n.__('header.tabel.customProperties'), link(indir, filename, this.doclinks['custom']), props.custom)); - this.myheaders.push(new Header(i18n.__('header.tabel.additionalProperties'), link(indir, filename, this.doclinks['additional']), props.additionalProperties)); + this.myheaders.push(new Header(i18n.__('header.tabel.abstract'), link(indir, filename, this.doclinks.abstract), props.abstract)); + this.myheaders.push(new Header(i18n.__('header.tabel.extensible'), link(indir, filename, this.doclinks.extensible), props.extensible)); + this.myheaders.push(new Header(i18n.__('header.tabel.status'), link(indir, filename, this.doclinks.status), props.status)); + this.myheaders.push(new Header(i18n.__('header.tabel.identifiable'), link(indir, filename, this.doclinks.id), isIdentifiable(schema))); + this.myheaders.push(new Header(i18n.__('header.tabel.customProperties'), link(indir, filename, this.doclinks.custom), props.custom)); + this.myheaders.push(new Header(i18n.__('header.tabel.additionalProperties'), link(indir, filename, this.doclinks.additional), props.additionalProperties)); this.myheaders.push(new Header(i18n.__('header.tabel.definedIn'), undefined, props.original, path.basename(props.original))); - this.render = function() { - var buf = ''; + this.render = function () { + let buf = ''; - //header + // header buf += '|'; - _.forEach(this.myheaders, myheader => { - buf += ' ' + myheader.renderHeader() + ' |'; + _.forEach(this.myheaders, (myheader) => { + buf += ` ${myheader.renderHeader()} |`; }); buf += '\n'; - //divider + // divider buf += '|'; - _.forEach(this.myheaders, myheader => { - buf += '-' + myheader.renderHeader().replace(/./g, '-') + '-|'; + _.forEach(this.myheaders, (myheader) => { + buf += `-${myheader.renderHeader().replace(/./g, '-')}-|`; }); buf += '\n'; - //body + // body buf += '|'; - _.forEach(this.myheaders, myheader => { - buf += ' ' + myheader.renderValue() + ' |'; + _.forEach(this.myheaders, (myheader) => { + buf += ` ${myheader.renderValue()} |`; }); diff --git a/lib/main.js b/lib/main.js index 9ce1b84660146314a874c846ab63cdc250c955df..e0559f21c0c401777a8c7c0fa606a8291dfba3ae 100644 --- a/lib/main.js +++ b/lib/main.js @@ -1,12 +1,17 @@ -/** - * Copyright 2017 Adobe Systems Incorporated. All rights reserved. +/* + * Copyright 2019 Adobe. All rights reserved. * This file is licensed to you 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 REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. */ module.exports = { - writer:require('./writeFiles'), - reader:require('./readSchemaFile'), - schema:require('./schema') + writer: require('./writeFiles'), + reader: require('./readSchemaFile'), + schema: require('./schema'), }; diff --git a/lib/markdownWriter.js b/lib/markdownWriter.js index 39eabb90927542778b8b983d2b7ed2a098aaac84..71f5c5b1902d97c71528ee0dee77c6b36c029102 100644 --- a/lib/markdownWriter.js +++ b/lib/markdownWriter.js @@ -1,32 +1,38 @@ -/** - * Copyright 2017 Adobe Systems Incorporated. All rights reserved. +/* + * Copyright 2019 Adobe. All rights reserved. * This file is licensed to you 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 REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. */ const i18n = require('i18n'); -const writeFile = require('./writeFiles'); -const prettyMarkdown = require('./prettyMarkdown'); -var Promise=require('bluebird'); -var path = require('path'); -var _ = require('lodash'); -var ejs = require('ejs'); +const Promise = require('bluebird'); +const path = require('path'); +const _ = require('lodash'); +const ejs = require('ejs'); + const pejs = Promise.promisifyAll(ejs); -// var validUrl = require('valid-url'); +const validUrl = require('valid-url'); +const GithubSlugger = require('github-slugger'); const { headers } = require('./header'); -var GithubSlugger = require('github-slugger'); +const prettyMarkdown = require('./prettyMarkdown'); +const writeFile = require('./writeFiles'); -function createGithubSlugs(names){ - var slugger = new GithubSlugger(); +function createGithubSlugs(names) { + const slugger = new GithubSlugger(); slugger.reset(); names = names.sort(); - return names.reduce(function(result, item) { + return names.reduce((result, item) => { result[item] = slugger.slug(item); return result; }, {}); } -function render([ template, context ]) { +function render([template, context]) { return pejs.renderFileAsync(template, context, { debug: false }); } @@ -35,7 +41,7 @@ function build(total, fragment) { } function assoc(obj, key, value) { - if (obj==null) { + if (obj == null) { return assoc({}, key, value); } obj[key] = value; @@ -46,7 +52,7 @@ function flatten(dependencies) { let deps = []; if (dependencies) { const key = _.keys(dependencies)[0]; - deps = _.toPairs(dependencies[key]).map(([ first, second ]) => { + deps = _.toPairs(dependencies[key]).map(([first, second]) => { second.$id = first; return second; }); @@ -57,12 +63,10 @@ function flatten(dependencies) { function stringifyExamples(examples) { if (examples) { if (typeof examples === 'string') { - examples = [ examples ]; + examples = [examples]; } - //console.log(examples); - return examples.map(example => { - return JSON.stringify(example, null, 2); - }); + // console.log(examples); + return examples.map(example => JSON.stringify(example, null, 2)); } else { return false; } @@ -73,46 +77,46 @@ function stringifyExamples(examples) { * @param {object} prop - a JSON Schema property definition */ function simpletype(prop) { - const type = prop.type; - if (prop.$ref!==undefined) { - if (prop.$linkVal!==undefined) { + const { type } = prop; + if (prop.$ref !== undefined) { + if (prop.$linkVal !== undefined) { prop.simpletype = prop.$linkVal; } else { - console.log('unresolved reference: ' + prop.$ref); + console.log(`unresolved reference: ${prop.$ref}`); prop.simpletype = 'reference'; } - } else if (prop.enum!==undefined) { + } else if (prop.enum !== undefined) { prop.simpletype = '`enum`'; - if (prop['meta:enum']===undefined) { + if (prop['meta:enum'] === undefined) { prop['meta:enum'] = {}; } - for (let i=0;i<prop.enum.length;i++) { - if (prop['meta:enum'][prop.enum[i]]===undefined) { - //setting an empty description for each unknown enum + for (let i = 0; i < prop.enum.length; i++) { + if (prop['meta:enum'][prop.enum[i]] === undefined) { + // setting an empty description for each unknown enum prop['meta:enum'][prop.enum[i]] = ''; } } - } else if (prop.const!==undefined) { + } else if (prop.const !== undefined) { prop.simpletype = '`const`'; - } else if (type==='string') { + } else if (type === 'string') { prop.simpletype = '`string`'; - } else if (type==='number') { + } else if (type === 'number') { prop.simpletype = '`number`'; - } else if (type==='boolean') { + } else if (type === 'boolean') { prop.simpletype = '`boolean`'; - } else if (type==='integer') { + } else if (type === 'integer') { prop.simpletype = '`integer`'; - } else if (type==='object') { + } else if (type === 'object') { prop.simpletype = '`object`'; - } else if (type==='null') { + } else if (type === 'null') { prop.simpletype = '`null`'; - } else if (type==='array') { - if (prop.items!==undefined) { + } else if (type === 'array') { + if (prop.items !== undefined) { const innertype = simpletype(prop.items); - if (innertype.simpletype==='complex') { + if (innertype.simpletype === 'complex') { prop.simpletype = '`array`'; } else { - //console.log(prop.title); + // console.log(prop.title); prop.simpletype = innertype.simpletype.replace(/(`)$/, '[]$1'); } } else { @@ -120,15 +124,15 @@ function simpletype(prop) { } } else if (Array.isArray(type)) { function nullfilter(str) { - return str!=='null'; + return str !== 'null'; } - var filtered = type.filter(nullfilter); + const filtered = type.filter(nullfilter); if (type.length - 1 === filtered.length) { prop.nullable = true; } - if (filtered.length===1) { + if (filtered.length === 1) { prop.type = filtered[0]; - prop.simpletype = '`' + filtered[0] + '`'; + prop.simpletype = `\`${filtered[0]}\``; } else { prop.type = filtered; prop.simpletype = 'multiple'; @@ -147,7 +151,7 @@ function simpletype(prop) { */ function requiredProperties(properties, required) { if (required) { - for (let i=0;i<required.length;i++) { + for (let i = 0; i < required.length; i++) { if (properties[required[i]]) { properties[required[i]].isrequired = true; } @@ -157,22 +161,13 @@ function requiredProperties(properties, required) { } function ejsRender(template, ctx) { - let p = pejs.renderFileAsync(path.join(__dirname, '../templates/md/' + template + '.ejs'), ctx, { debug: false }); + const p = pejs.renderFileAsync(path.join(__dirname, `../templates/md/${template}.ejs`), ctx, { debug: false }); return p.value(); - //return JSON.stringify(obj, null, 2); + // return JSON.stringify(obj, null, 2); } -const generateMarkdown = function(filename, schema, schemaPath, outDir, dependencyMap, docs, consoleArgs) { - //var ctx = { - // schema: schema, - // _: _, - // validUrl: validUrl, - // dependencyMap:dependencyMap - //}; - - outDir = outDir ? outDir : path.resolve(path.join('.', 'out')); - console.log(filename); - //console.log(dependencyMap); +const generateMarkdown = (filename, schema, schemaPath, outDir, dependencyMap, docs, consoleArgs) => { + outDir = outDir || path.resolve(path.join('.', 'out')); // this structure allows us to have separate templates for each element. Instead of having // one huge template, each block can be built individually outDir = outDir ? outDir : path.resolve(path.join('.', 'out')); @@ -185,126 +180,123 @@ const generateMarkdown = function(filename, schema, schemaPath, outDir, dependen dependencies: flatten(dependencyMap), table: headers(schema, schemaPath, filename, docs).render() } ]); } - //multi.push(['divider.ejs', null ]); - //multi.push(['topSchema.ejs', ctx ]); multi.push([ 'examples.ejs', { examples: stringifyExamples(schema.examples), title: schema.title, i18n: i18n } ]); const required = []; //to store required of whole schema, even those in definitions // Processing schema.definitions before schema.properties to get any required properties present in definitions if (_.keys(schema.definitions).length > 0) { const abstract = {}; - for (let i=0; i<_.keys(schema.definitions).length;i++) { - if (schema.definitions[_.keys(schema.definitions)[i]].properties!==undefined) { + for (let i = 0; i < _.keys(schema.definitions).length; i++) { + if (schema.definitions[_.keys(schema.definitions)[i]].properties !== undefined) { const definition = schema.definitions[_.keys(schema.definitions)[i]].properties; - let tempRequired = schema.definitions[_.keys(schema.definitions)[i]].required; - let hasRequiredProperties = (tempRequired !== undefined) ? true : false; - for (let j=0; j<_.keys(definition).length;j++) { + const tempRequired = schema.definitions[_.keys(schema.definitions)[i]].required; + const hasRequiredProperties = (tempRequired !== undefined); + for (let j = 0; j < _.keys(definition).length; j++) { const name = _.keys(definition)[j]; const property = definition[_.keys(definition)[j]]; - if (hasRequiredProperties && tempRequired.includes(name)){ + if (hasRequiredProperties && tempRequired.includes(name)) { required.push(name); } - //console.log('Checking ' + name + ' against ' + _.keys(schema.properties)); - if (_.keys(schema.properties).indexOf(name)=== -1) { + // console.log('Checking ' + name + ' against ' + _.keys(schema.properties)); + if (_.keys(schema.properties).indexOf(name) === -1) { property.definitiongroup = _.keys(schema.definitions)[i]; abstract[name] = property; } } } } - let propertiesSlugs = createGithubSlugs(_.keys(abstract)); - if (_.keys(abstract).length>0) { - //console.log('I got definitions!', abstract); - multi.push([ 'definitions.ejs', { + const propertiesSlugs = createGithubSlugs(_.keys(abstract)); + if (_.keys(abstract).length > 0) { + // console.log('I got definitions!', abstract); + multi.push(['definitions.ejs', { props: requiredProperties(abstract, required), title: schema.title, id: schema.$id, - propertiesSlugs:propertiesSlugs, - i18n: i18n - } ]); - for (let i=0; i<_.keys(abstract).length;i++) { + propertiesSlugs, + i18n, + }]); + for (let i = 0; i < _.keys(abstract).length; i++) { const name = _.keys(abstract).sort()[i]; - multi.push( [ 'property.ejs', { - name: name, + multi.push(['property.ejs', { + name, required: required.includes(name), ejs: ejsRender, - examples: stringifyExamples(abstract[name]['examples']), + examples: stringifyExamples(abstract[name].examples), schema: simpletype(abstract[name]), nameSlug: propertiesSlugs[name], - i18n: i18n - } ]); + i18n, + }]); } } } - let propertiesSlugs = createGithubSlugs(_.keys(schema.properties)); + const propertiesSlugs = createGithubSlugs(_.keys(schema.properties)); if (_.keys(schema.properties).length > 0) { - if (schema.required === undefined){schema.required = [];} + if (schema.required === undefined) { schema.required = []; } schema.required = _.union(schema.required, required); - //table of contents - multi.push([ 'properties.ejs', { + // table of contents + multi.push(['properties.ejs', { props: requiredProperties(schema.properties, schema.required), pprops: _.mapValues(schema.patternProperties, simpletype), title: schema.title, additional: schema.additionalProperties, - propertiesSlugs: propertiesSlugs, - i18n: i18n - } ]); - //regular properties - for (let i=0; i<_.keys(schema.properties).length;i++) { + propertiesSlugs, + i18n, + }]); + // regular properties + for (let i = 0; i < _.keys(schema.properties).length; i++) { const name = _.keys(schema.properties).sort()[i]; - multi.push( [ 'property.ejs', { - name: name, + multi.push(['property.ejs', { + name, required: schema.required ? schema.required.includes(name) : false, - examples: stringifyExamples(schema.properties[name]['examples']), + examples: stringifyExamples(schema.properties[name].examples), ejs: ejsRender, schema: simpletype(schema.properties[name]), nameSlug: propertiesSlugs[name], - i18n: i18n - } ]); + i18n, + }]); } } if (_.keys(schema.patternProperties).length > 0) { - //patterns properties - for (let i=0; i<_.keys(schema.patternProperties).length;i++) { + // patterns properties + for (let i = 0; i < _.keys(schema.patternProperties).length; i++) { const name = _.keys(schema.patternProperties)[i]; - multi.push( [ 'pattern-property.ejs', { - name: name, - examples: stringifyExamples(schema.patternProperties[name]['examples']), + multi.push(['pattern-property.ejs', { + name, + examples: stringifyExamples(schema.patternProperties[name].examples), ejs: ejsRender, schema: simpletype(schema.patternProperties[name]), - i18n: i18n } ]); + i18n, + }]); } } // Handles join-type properties // If the schema contains a 'oneOf', 'allOf' or 'anyOf'. - const joinTypeKey = Object.keys(schema).find(key => [ 'oneOf', 'allOf', 'anyOf' ].indexOf(key) > -1); + const joinTypeKey = Object.keys(schema).find(key => ['oneOf', 'allOf', 'anyOf'].indexOf(key) > -1); if (!_.isUndefined(joinTypeKey)) { const joinType = schema[joinTypeKey]; if (joinType.length > 0) { - multi.push( [ 'join-type.ejs', { + multi.push(['join-type.ejs', { ejs: ejsRender, schemas: simpletype(joinType), schema: simpletype(schema), - i18n: i18n } ]); + i18n, + }]); } } - //find definitions that contain properties that are not part of the main schema - multi = multi.map(([ template, context ]) => { - return [ - path.join(__dirname, '../templates/md/' + template), - assoc(assoc(context, '_', _), 'simpletype', simpletype) - ]; - }); + // find definitions that contain properties that are not part of the main schema + multi = multi.map(([template, context]) => [ + path.join(__dirname, `../templates/md/${template}`), + assoc(assoc(context, '_', _), 'simpletype', simpletype), + ]); - return Promise.reduce(Promise.map(multi, render), build, '').then(str => { - const mdfile = path.basename(filename).slice(0, -5)+ '.md'; + return Promise.reduce(Promise.map(multi, render), build, '').then((str) => { + const mdfile = `${path.basename(filename).slice(0, -5)}.md`; return writeFile(path.join(path.join(outDir), path.dirname(filename.substr(schemaPath.length))), mdfile, prettyMarkdown(str)); - }).then(out => { - //console.log('markdown written (promise)', out); - return out; - }); + }).then(out => + // console.log('markdown written (promise)', out); + out); }; module.exports = generateMarkdown; diff --git a/lib/prettyMarkdown.js b/lib/prettyMarkdown.js index 328deb276691fdb5d81d2bfcd6036d9c442b97dd..f47b710fb60ef4628bc1bfc75564ebfe28a4bdd3 100644 --- a/lib/prettyMarkdown.js +++ b/lib/prettyMarkdown.js @@ -1,13 +1,18 @@ -/** - * Copyright 2017 Adobe Systems Incorporated. All rights reserved. +/* + * Copyright 2019 Adobe. All rights reserved. * This file is licensed to you 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 REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. */ -var prettier = require('prettier'); +const prettier = require('prettier'); -const prettyMarkdown = function(str) { +const prettyMarkdown = function (str) { return prettier.format(str, { parser: 'markdown', proseWrap: 'always', printWidth: 119 }); }; diff --git a/lib/readSchemaFile.js b/lib/readSchemaFile.js index e0d8909445cdaf9ac3fc84820b29c1c57fddd891..3a8002ef393d4d69c7843496bfb35a1a07247546 100644 --- a/lib/readSchemaFile.js +++ b/lib/readSchemaFile.js @@ -1,12 +1,17 @@ -/** - * Copyright 2017 Adobe Systems Incorporated. All rights reserved. +/* + * Copyright 2019 Adobe. All rights reserved. * This file is licensed to you 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 REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. */ -var Promise=require('bluebird'); -var fs = Promise.promisifyAll(require('fs')); +const Promise = require('bluebird'); +const fs = Promise.promisifyAll(require('fs')); // Reads a schema file and modifies a schema path map object based on the schema file. // Returns the schema path map object. @@ -22,19 +27,19 @@ module.exports = function readSchemaFile(schemaPathMap, fullPath) { schemaPathMap = {}; } return fs.readFileAsync(fullPath) - .then(data => { - let schema = JSON.parse(data); - let obj = {}; + .then((data) => { + const schema = JSON.parse(data); + const obj = {}; obj.filePath = fullPath; obj.jsonSchema = schema; - if (schema['$id'] && schema['$id'].length > 0) { - if (!schemaPathMap[schema['$id']]) { - schemaPathMap[schema['$id']] = obj; + if (schema.$id && schema.$id.length > 0) { + if (!schemaPathMap[schema.$id]) { + schemaPathMap[schema.$id] = obj; } // TODO err - //TODO check Missing Specific properties to throw warning // function for warning + // TODO check Missing Specific properties to throw warning // function for warning } else { - console.warn('schema ' + fullPath + ' has no $id'); + console.warn(`schema ${fullPath} has no $id`); schemaPathMap[fullPath] = obj; } return schemaPathMap; diff --git a/lib/readmeWriter.js b/lib/readmeWriter.js index b10c6afcfdb213e3f4dbf2a1a55f07ec9d0fde94..98062032ae784802d4e28b1e88bfbdc7ba4e6cb3 100644 --- a/lib/readmeWriter.js +++ b/lib/readmeWriter.js @@ -1,24 +1,30 @@ -/** - * Copyright 2017 Adobe Systems Incorporated. All rights reserved. +/* + * Copyright 2019 Adobe. All rights reserved. * This file is licensed to you 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 REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. */ -const writeFile = require('./writeFiles'); -const prettyMarkdown = require('./prettyMarkdown'); -var Promise=require('bluebird'); -var _ = require('lodash'); -var ejs = require('ejs'); -var path = require('path'); +const Promise = require('bluebird'); +const _ = require('lodash'); +const ejs = require('ejs'); +const path = require('path'); + const pejs = Promise.promisifyAll(ejs); -var validUrl = require('valid-url'); +const validUrl = require('valid-url'); const i18n = require('i18n'); +const prettyMarkdown = require('./prettyMarkdown'); +const writeFile = require('./writeFiles'); function relativePath(full, base) { full = full.replace(/\\/g, '/'); base = base.replace(/\\/g, '/'); - if (full.indexOf(base)===0) { + if (full.indexOf(base) === 0) { return full.substr(base.length).replace(/\.json$/, ''); } else { return full; @@ -36,35 +42,31 @@ function directory(full, base) { * @param {string} out - output directory * @param {string} base - schema base directory */ -const generateReadme = function(paths, schemas, out, base) { - const coreinfo = _.values(schemas).map(schema => { - return { - id: schema.jsonSchema.$id, - title: schema.jsonSchema.title, - full: schema.filePath, - status: schema.jsonSchema['meta:status'] !== undefined ? (schema.jsonSchema['meta:status'].charAt(0).toUpperCase() + schema.jsonSchema['meta:status'].slice(1)) : 'Unknown', - relative: relativePath(schema.filePath, base), - dir: directory(schema.filePath, base), - i18n:i18n, - }; - }); +const generateReadme = function (paths, schemas, out, base) { + const coreinfo = _.values(schemas).map(schema => ({ + id: schema.jsonSchema.$id, + title: schema.jsonSchema.title, + full: schema.filePath, + status: schema.jsonSchema['meta:status'] !== undefined ? (schema.jsonSchema['meta:status'].charAt(0).toUpperCase() + schema.jsonSchema['meta:status'].slice(1)) : 'Unknown', + relative: relativePath(schema.filePath, base), + dir: directory(schema.filePath, base), + i18n, + })); const ctx = { - paths: paths, - i18n:i18n, - _: _, - validUrl: validUrl, - schemas: schemas, + paths, + i18n, + _, + validUrl, + schemas, core: coreinfo, - groups: _.groupBy(coreinfo, key => { return key.dir; }) + groups: _.groupBy(coreinfo, key => key.dir), }; - return pejs.renderFileAsync(path.join(__dirname, '../templates/md/readme.ejs'), ctx, { debug: false }, i18n).then(str => { + return pejs.renderFileAsync(path.join(__dirname, '../templates/md/readme.ejs'), ctx, { debug: false }, i18n).then((str) => { console.log('Writing README'); return writeFile(out, 'README.md', prettyMarkdown(str)); - }).then(out => { - //console.log('markdown written (promise)', out); - return out; - }); + }).then(out => + // console.log('markdown written (promise)', out); + out); }; module.exports = generateReadme; - diff --git a/lib/schema.js b/lib/schema.js index 580ceaaa77514575acc9bcfd4c420fed0b6473f6..e8c7ec42d51425b2e19766814dd7e31415b86ef8 100644 --- a/lib/schema.js +++ b/lib/schema.js @@ -1,132 +1,137 @@ -/** - * Copyright 2017 Adobe Systems Incorporated. All rights reserved. +/* + * Copyright 2019 Adobe. All rights reserved. * This file is licensed to you 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 REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. */ -var path = require('path'); -var _ = require('lodash'); -var logger = require('winston'); -var readdirp = require('readdirp'); -var Promise=require('bluebird'); -var fs = Promise.promisifyAll(require('fs')); -const markdownWriter=require('./markdownWriter'); -const schemaWriter=require('./schemaWriter'); -const readmeWriter=require('./readmeWriter'); -var deff='#/definitions/'; -var absUrlRegex = new RegExp('^(?:[a-z]+:)?//', 'i'); -var pointer = require('json-pointer'); -var smap; //TODO remove global -var sPath; -var wmap={}; -function get$refType(refValue){ - var startpart = '', endpart = '', refType = ''; - var arr = refValue.split('#'); - if (arr.length > 1) {endpart=arr[1];} - - startpart=arr[0]; - //TODO yRelNoDef - //relative-- yRelWithDef, yRelNoDef, - //absolute-- yAbsWithDef, yAbsFSchema, yAbsWithFragment - var refType=''; - var deff='/definitions/'; - - //if( absUrlRegex.test(refVal) ){ - if (startpart.length > 1){ - if (startpart in smap){ - if (endpart.startsWith(deff)){ +const path = require('path'); +const _ = require('lodash'); +const logger = require('winston'); +const readdirp = require('readdirp'); +const Promise = require('bluebird'); +const fs = Promise.promisifyAll(require('fs')); +const markdownWriter = require('./markdownWriter'); +const schemaWriter = require('./schemaWriter'); +const readmeWriter = require('./readmeWriter'); + +const deff = '#/definitions/'; +const absUrlRegex = new RegExp('^(?:[a-z]+:)?//', 'i'); +const pointer = require('json-pointer'); + +let smap; // TODO remove global +let sPath; +const wmap = {}; +function get$refType(refValue) { + let startpart = ''; let endpart = ''; var + refType = ''; + const arr = refValue.split('#'); + if (arr.length > 1) { endpart = arr[1]; } + + startpart = arr[0]; + // TODO yRelNoDef + // relative-- yRelWithDef, yRelNoDef, + // absolute-- yAbsWithDef, yAbsFSchema, yAbsWithFragment + var refType = ''; + const deff = '/definitions/'; + + // if( absUrlRegex.test(refVal) ){ + if (startpart.length > 1) { + if (startpart in smap) { + if (endpart.startsWith(deff)) { refType = 'yAbsWithDef'; + } else if (endpart.length === 0) { + refType = 'yAbsFSchema'; } else { - if (endpart.length === 0) { - refType = 'yAbsFSchema'; - } else { - refType = 'yAbsWithFragment'; - } + refType = 'yAbsWithFragment'; } } - } else { - if (endpart.startsWith(deff)){ - refType = 'yRelWithDef'; - } + } else if (endpart.startsWith(deff)) { + refType = 'yRelWithDef'; } // } return { startpart, endpart, refType }; } -function normaliseLinks(obj, refArr){ - let basepath = refArr.startpart ; - let $linkVal = '', $linkPath = ''; - if (basepath in smap){ - let newpath = path.relative(path.dirname(sPath), smap[basepath].filePath).replace(/\\/g, '/'); //to cater windows paths - let temp = newpath.slice(0, -5).split('/'); - $linkVal = obj['title'] ? obj['title'] : path.basename(newpath).slice(0, -5); - $linkPath = temp.join('/')+'.md'; +function normaliseLinks(obj, refArr) { + const basepath = refArr.startpart; + let $linkVal = ''; let + $linkPath = ''; + if (basepath in smap) { + const newpath = path.relative(path.dirname(sPath), smap[basepath].filePath).replace(/\\/g, '/'); // to cater windows paths + const temp = newpath.slice(0, -5).split('/'); + $linkVal = obj.title ? obj.title : path.basename(newpath).slice(0, -5); + $linkPath = `${temp.join('/')}.md`; return { $linkVal, $linkPath }; } } -var resolve$ref = Promise.method(function(val, base$id){ - let obj, link; - if (!(base$id in wmap) ) {wmap[base$id] = {};} - let refArr = get$refType(val['$ref']); - if (refArr.refType === 'yRelWithDef'){ +const resolve$ref = Promise.method((val, base$id) => { + let obj; let + link; + if (!(base$id in wmap)) { wmap[base$id] = {}; } + const refArr = get$refType(val.$ref); + if (refArr.refType === 'yRelWithDef') { refArr.startpart = base$id; } - if (smap[refArr.startpart]){ - obj=smap[refArr.startpart].jsonSchema; - if (refArr.refType !== 'yRelWithDef'){ + if (smap[refArr.startpart]) { + obj = smap[refArr.startpart].jsonSchema; + if (refArr.refType !== 'yRelWithDef') { link = normaliseLinks(obj, refArr); - if (!wmap[base$id][refArr.startpart]){ - wmap[base$id][refArr.startpart]=link; + if (!wmap[base$id][refArr.startpart]) { + wmap[base$id][refArr.startpart] = link; } - } - if (refArr.refType === 'yAbsFSchema'){ + if (refArr.refType === 'yAbsFSchema') { val.type = link.$linkVal; val.$linkVal = link.$linkVal; val.$linkPath = link.$linkPath; return val; } - if (pointer.has(obj, refArr.endpart)){ - var ischema = _.cloneDeep(pointer.get(obj, refArr.endpart)); + if (pointer.has(obj, refArr.endpart)) { + const ischema = _.cloneDeep(pointer.get(obj, refArr.endpart)); _.forOwn(val, (v, k) => { - if (k !== '$ref'){ - ischema[k]=v; + if (k !== '$ref') { + ischema[k] = v; } }); return processISchema(ischema, refArr.startpart); } } }); -var processFurther = Promise.method(function(val, key, $id){ - let base$id =$id; - if (val['$ref']){ +var processFurther = Promise.method((val, key, $id) => { + const base$id = $id; + if (val.$ref) { return resolve$ref(val, base$id); } else { - if (val['items'] && val['type'] === 'array'){ - if (val['items']['$ref']){ - resolve$ref(val['items']).then(s => { + if (val.items && val.type === 'array') { + if (val.items.$ref) { + resolve$ref(val.items).then((s) => { _.forOwn(s, (v, k) => { - if (k !== '$ref'){ - val['items'][k]=v; + if (k !== '$ref') { + val.items[k] = v; } }); }); } - } else if (val['properties'] && val['type'] === 'object') { - _.each(_.entries(val['properties']), function(property) { - const [ propertyKey, propertyValue ] = property; - if (propertyValue['$ref']) { - resolve$ref(propertyValue).then(s => { + } else if (val.properties && val.type === 'object') { + _.each(_.entries(val.properties), (property) => { + const [propertyKey, propertyValue] = property; + if (propertyValue.$ref) { + resolve$ref(propertyValue).then((s) => { _.forOwn(s, (v, k) => { - if (k !== '$ref'){ - val['properties'][propertyKey][k] = v; + if (k !== '$ref') { + val.properties[propertyKey][k] = v; } }); }); } else { - //type is object but property does not contain a $ref + // type is object but property does not contain a $ref // go recursively down to check for a $ref return processFurther(propertyValue, propertyKey, base$id); } @@ -134,27 +139,27 @@ var processFurther = Promise.method(function(val, key, $id){ return val; } - //TODO if any other keyword + // TODO if any other keyword return val; } }); -function processISchema() {}; // define w/ function so it gets hoisted and we avoid eslint errors about what is defined first: processISchema or resolve$ref. Both rely on each other! -processISchema = Promise.method(function(schema, base$id){ - if (!(base$id in wmap) ) {wmap[base$id] = {};} - if (schema['anyOf'] || schema['oneOf']){ +function processISchema() {} // define w/ function so it gets hoisted and we avoid eslint errors about what is defined first: processISchema or resolve$ref. Both rely on each other! +processISchema = Promise.method((schema, base$id) => { + if (!(base$id in wmap)) { wmap[base$id] = {}; } + if (schema.anyOf || schema.oneOf) { // var $definitions=[] - schema['type'] = schema['anyOf'] ? 'anyOf' : 'oneOf'; - let arr = schema['anyOf']? schema['anyOf'] : schema['oneOf']; - _.each(arr, function(value, index) { - if (value['$ref']){ - resolve$ref(value, base$id).then(piSchema => { + schema.type = schema.anyOf ? 'anyOf' : 'oneOf'; + const arr = schema.anyOf ? schema.anyOf : schema.oneOf; + _.each(arr, (value, index) => { + if (value.$ref) { + resolve$ref(value, base$id).then((piSchema) => { delete arr[index]; - arr[index]=piSchema; + arr[index] = piSchema; }); } else { - processISchema(value, base$id).then(piSchema => { + processISchema(value, base$id).then((piSchema) => { delete arr[index]; - arr[index]=piSchema; + arr[index] = piSchema; }); } }); @@ -162,123 +167,109 @@ processISchema = Promise.method(function(schema, base$id){ return schema; } - if (schema['items'] ){ - - let val=schema['items']; - if (!schema['type']) {schema['type'] = 'array';} - if (_.isArray(val)){ - //TODO + if (schema.items) { + const val = schema.items; + if (!schema.type) { schema.type = 'array'; } + if (_.isArray(val)) { + // TODO + } else if (val.$ref) { + resolve$ref(val, base$id).then((piSchema) => { // check // not sending correct id + schema.items = piSchema; + }); } else { - if (val['$ref']){ - resolve$ref(val, base$id).then(piSchema => {//check // not sending correct id - schema['items']=piSchema; - }); - } else { - //TODO if such a scenario - } + // TODO if such a scenario } } // schema.$definitions = $definitions return schema; }); -function processSchema(schema){ +function processSchema(schema) { return new Promise((resolve, reject) => { - if (!schema.properties) {schema.properties={};} - var $id = schema['$id'] || schema['id']; - var base$id = $id; - if (!(base$id in wmap)) {wmap[base$id] = {};} - if (schema['allOf']){ - _.each(schema['allOf'], function(value) { - if (value['$ref']){ - let obj, link; - var refArr = get$refType(value['$ref']); - if (refArr.refType === 'yRelWithDef'){ + if (!schema.properties) { schema.properties = {}; } + const $id = schema.$id || schema.id; + const base$id = $id; + if (!(base$id in wmap)) { wmap[base$id] = {}; } + if (schema.allOf) { + _.each(schema.allOf, (value) => { + if (value.$ref) { + let obj; let + link; + const refArr = get$refType(value.$ref); + if (refArr.refType === 'yRelWithDef') { refArr.startpart = base$id; } - if (smap[refArr.startpart]){ - obj=smap[refArr.startpart].jsonSchema; - if (refArr.refType !== 'yRelWithDef'){ - link=normaliseLinks(obj, refArr); - if (!wmap[base$id][refArr.startpart]){ - wmap[base$id][refArr.startpart]=link; + if (smap[refArr.startpart]) { + obj = smap[refArr.startpart].jsonSchema; + if (refArr.refType !== 'yRelWithDef') { + link = normaliseLinks(obj, refArr); + if (!wmap[base$id][refArr.startpart]) { + wmap[base$id][refArr.startpart] = link; } } - if (pointer.has(obj, refArr.endpart)){ - var ischema = _.cloneDeep(pointer.get(obj, refArr.endpart)); - if (refArr.refType === 'yAbsFSchema'){ - processSchema(ischema).then(psSchema => { - if ( psSchema['properties'] ){ - _.forOwn(psSchema['properties'], (val, key) => { - processFurther(val, key, refArr.startpart).then(pfSchema => { - if (pfSchema){ + if (pointer.has(obj, refArr.endpart)) { + const ischema = _.cloneDeep(pointer.get(obj, refArr.endpart)); + if (refArr.refType === 'yAbsFSchema') { + processSchema(ischema).then((psSchema) => { + if (psSchema.properties) { + _.forOwn(psSchema.properties, (val, key) => { + processFurther(val, key, refArr.startpart).then((pfSchema) => { + if (pfSchema) { schema.properties[key] = pfSchema; - schema.properties[key].$oSchema={}; - schema.properties[key].$oSchema.$linkVal=link.$linkVal; - schema.properties[key].$oSchema.$linkPath=link.$linkPath; + schema.properties[key].$oSchema = {}; + schema.properties[key].$oSchema.$linkVal = link.$linkVal; + schema.properties[key].$oSchema.$linkPath = link.$linkPath; - if (pfSchema['required']){ - if (key in pfSchema['required']){ + if (pfSchema.required) { + if (key in pfSchema.required) { schema.required.push(key); } } } - }); - }); } }); - - } else { - if ( ischema['properties'] ){ - _.forOwn(ischema['properties'], (val, key) => { - processFurther(val, key, refArr.startpart).then(pfSchema => { - if (pfSchema){ - schema.properties[key] = pfSchema; - if (refArr.refType === 'yAbsWithDef'){ - schema.properties[key].$oSchema={}; - schema.properties[key].$oSchema.$linkVal=link.$linkVal; - schema.properties[key].$oSchema.$linkPath=link.$linkPath; - - } - if (ischema['required']){ - if (key in ischema['required']) {schema.required.push(key);} - } - } else { - reject('No further schema found'); + } else if (ischema.properties) { + _.forOwn(ischema.properties, (val, key) => { + processFurther(val, key, refArr.startpart).then((pfSchema) => { + if (pfSchema) { + schema.properties[key] = pfSchema; + if (refArr.refType === 'yAbsWithDef') { + schema.properties[key].$oSchema = {}; + schema.properties[key].$oSchema.$linkVal = link.$linkVal; + schema.properties[key].$oSchema.$linkPath = link.$linkPath; } - }); - + if (ischema.required) { + if (key in ischema.required) { schema.required.push(key); } + } + } else { + reject('No further schema found'); + } }); - } - + }); } } - } - } else { - - _.forOwn(value, function(val, key){ - schema[key]=val; + _.forOwn(value, (val, key) => { + schema[key] = val; // }); // TODO add properties if there // behaviour to be decided } - }); resolve(schema); - } else if (schema['properties']){ - _.forOwn(schema['properties'], (val, key) => { - processFurther(val, key, base$id).then(pfSchema => { - if (pfSchema){ + } else if (schema.properties) { + _.forOwn(schema.properties, (val, key) => { + processFurther(val, key, base$id).then((pfSchema) => { + if (pfSchema) { schema.properties[key] = pfSchema; - if (pfSchema['required']){ - if (key in pfSchema['required']){ + if (pfSchema.required) { + if (key in pfSchema.required) { schema.required.push(key); } } @@ -286,55 +277,50 @@ function processSchema(schema){ }); }); - //TODO check if something missing left here + // TODO check if something missing left here resolve(schema); } - }); - - //generic $ref resolve present in top properties + // generic $ref resolve present in top properties } -var Schema=function(ajv, schemaMap){ +const Schema = function (ajv, schemaMap) { this._ajv = ajv; - this._schemaPathMap=schemaMap; + this._schemaPathMap = schemaMap; }; -Schema.resolveRef=function(key, obj, currpath){ - if (key === '$ref'){ - var refVal = obj[key]; - var temp; - if ( absUrlRegex.test(refVal) ){ - let parsedUrl = refVal.split('#'); - let basepath = parsedUrl[0] ; - if (basepath in this._schemaPathMap){ - let newpath = path.relative(path.dirname(currpath), this._schemaPathMap[basepath].filePath).replace(/\\/g, '/'); //to cater windows paths - obj['$ref'] = newpath; +Schema.resolveRef = function (key, obj, currpath) { + if (key === '$ref') { + const refVal = obj[key]; + let temp; + if (absUrlRegex.test(refVal)) { + const parsedUrl = refVal.split('#'); + const basepath = parsedUrl[0]; + if (basepath in this._schemaPathMap) { + const newpath = path.relative(path.dirname(currpath), this._schemaPathMap[basepath].filePath).replace(/\\/g, '/'); // to cater windows paths + obj.$ref = newpath; temp = newpath.slice(0, -5).split('/'); obj.$linkVal = path.basename(newpath).slice(0, -5); - obj.$linkPath = temp.join('/')+'.md'; - //TODO display with title or file path name title + obj.$linkPath = `${temp.join('/')}.md`; + // TODO display with title or file path name title } else { obj.$linkPath = refVal; temp = refVal.split('/'); obj.$linkVal = temp.pop() || temp.pop(); } - } else if (refVal.startsWith(deff)) { obj.$linkVal = refVal.slice(deff.length); - obj.$linkPath = '#'+obj.$linkVal.replace(/ /g, '-'); - } else if (refVal.endsWith('json')){ + obj.$linkPath = `#${obj.$linkVal.replace(/ /g, '-')}`; + } else if (refVal.endsWith('json')) { temp = refVal.slice(0, -5).split('/'); obj.$linkVal = temp[temp.length - 1]; - obj.$linkPath = temp.join('/')+'.md'; + obj.$linkPath = `${temp.join('/')}.md`; } } - if (key === 'anyOf' || key === 'oneOf' || key === 'allOf') {obj.$type=key;} - - return; + if (key === 'anyOf' || key === 'oneOf' || key === 'allOf') { obj.$type = key; } }; /* The following function does not seem to be used anymore! @@ -355,62 +341,54 @@ var traverseSchema = function(object,schemaFilePath){ }; */ -Schema.getExamples = function(filePath, schema){ - var exampleFileNames=[]; - var examples=[]; - var dirname=path.dirname(filePath); - var filename=path.basename(filePath, path.extname(filePath)); - filename=filename.split('.')[0]+'.example.*.json'; +Schema.getExamples = function (filePath, schema) { + const exampleFileNames = []; + let examples = []; + const dirname = path.dirname(filePath); + let filename = path.basename(filePath, path.extname(filePath)); + filename = `${filename.split('.')[0]}.example.*.json`; return new Promise((resolve, reject) => { readdirp(dirname, { root: dirname, fileFilter: filename }) .on('data', entry => exampleFileNames.push(entry.fullPath)) .on('end', () => resolve(exampleFileNames)) .on('error', err => reject(err)); - }).then(exampleFileNames => { - if (exampleFileNames.length > 0){ - var validate=this._ajv.compile(schema); - return Promise.map(exampleFileNames, entry => { - return fs.readFileAsync(entry).then(example => { - var data = JSON.parse(example.toString()); - var valid = validate(data); - if (valid) {examples.push({ filename: entry, data: data });} else {logger.error(entry+' is an invalid Example');} - }); - }).then(() => { + }).then((exampleFileNames) => { + if (exampleFileNames.length > 0) { + const validate = this._ajv.compile(schema); + return Promise.map(exampleFileNames, entry => fs.readFileAsync(entry).then((example) => { + const data = JSON.parse(example.toString()); + const valid = validate(data); + if (valid) { examples.push({ filename: entry, data }); } else { logger.error(`${entry} is an invalid Example`); } + })).then(() => { // Sort according to filenames in order not to have random prints - examples.sort(function(a, b) { - return a.filename > b.filename ? 1 : -1; - }); + examples.sort((a, b) => (a.filename > b.filename ? 1 : -1)); logger.error(examples); - examples = examples.map(function(element) {return element.data; }); - schema.examples=examples; + examples = examples.map(element => element.data); + schema.examples = examples; return schema; }); - } else {return schema;} + } else { return schema; } }); }; -Schema.getDescription = function(filePath, schema){ - - var temp=path.basename(filePath, path.extname(filePath)); - //TODO should err be thrown here? - temp=temp.split('.')[0]+'.description.md'; +Schema.getDescription = function (filePath, schema) { + let temp = path.basename(filePath, path.extname(filePath)); + // TODO should err be thrown here? + temp = `${temp.split('.')[0]}.description.md`; return fs.readFileAsync(path.resolve(path.dirname(filePath), temp), 'utf8') - .then(description => { - schema.description=description; + .then((description) => { + schema.description = description; return schema; }) - .catch(() => { - return schema; - }); - + .catch(() => schema); }; -Schema.setAjv=function(ajv){ - this._ajv=ajv; +Schema.setAjv = function (ajv) { + this._ajv = ajv; }; -Schema.setSchemaPathMap=function(schemaMap){ - this._schemaPathMap=schemaMap; +Schema.setSchemaPathMap = function (schemaMap) { + this._schemaPathMap = schemaMap; }; /** * Loads a schema file for processing into a given target directory @@ -422,52 +400,51 @@ Schema.setSchemaPathMap=function(schemaMap){ * @param {boolean} readme - generate a README.md directory listing * @param {map} docs - a map of documentation links for headers */ -Schema.process = function(schemaMap, schemaPath, docDir, schemaDir, metaElements, readme, docs, consoleArgs) { - smap=schemaMap; - let keys = Object.keys(schemaMap); - return Promise.mapSeries(keys, schemaKey => { - - var props = Object.keys(wmap); - for (var i = 0; i < props.length; i++) { +Schema.process = function (schemaMap, schemaPath, docDir, schemaDir, metaElements, readme, docs, consoleArgs) { + smap = schemaMap; + const keys = Object.keys(schemaMap); + return Promise.mapSeries(keys, (schemaKey) => { + const props = Object.keys(wmap); + for (let i = 0; i < props.length; i++) { delete wmap[props[i]]; } - let schema = schemaMap[schemaKey].jsonSchema; + const schema = schemaMap[schemaKey].jsonSchema; sPath = schemaMap[schemaKey].filePath; return Schema.getExamples(schemaMap[schemaKey].filePath, schema) .then(egsSchema => Schema.getDescription(schemaMap[schemaKey].filePath, egsSchema)) - .then(allSchema => { - var schemaClone = _.cloneDeep(allSchema); + .then((allSchema) => { + const schemaClone = _.cloneDeep(allSchema); // return Promise.props({ // wSchema:schemaClone, // mSchema:traverseSchema(allSchema,schemaMap[schemaKey].filePath) // }) - return processSchema(schemaClone).then(mSchema => { - mSchema.metaElements=metaElements; - return { mSchema:mSchema, wSchema:allSchema, dep:wmap }; + return processSchema(schemaClone).then((mSchema) => { + mSchema.metaElements = metaElements; + return { mSchema, wSchema: allSchema, dep: wmap }; }); - }).then(object => { - const outputTasks = [ markdownWriter(schemaMap[schemaKey].filePath, object.mSchema, schemaPath, docDir, object.dep, docs, consoleArgs) ]; + }).then((object) => { + const outputTasks = [markdownWriter(schemaMap[schemaKey].filePath, object.mSchema, schemaPath, docDir, object.dep, docs, consoleArgs)]; if (schemaDir !== '') { outputTasks.push(schemaWriter(schemaMap[schemaKey].filePath, object.wSchema, schemaPath, schemaDir)); } return Promise.all(outputTasks); - }).catch(err => { + }) + .catch((err) => { logger.error('Error occured in processing schema at path %s', sPath); logger.error(err); // should we exit here or allow processing of other schemas? process.exit(1); }); - }).then(result => { + }).then((result) => { if (readme) { console.log('Output processed. Trying to make a README.md now'); - const markdowns = result.map(r => { return r[0];}); + const markdowns = result.map(r => r[0]); return readmeWriter(markdowns, schemaMap, docDir, schemaPath); } else { console.log('Output processed.'); } }); - }; diff --git a/lib/schemaWriter.js b/lib/schemaWriter.js index e768f68b4669311f3cf67ada3fcbb19c53727697..c06d24055ec3d48ddccd4155ff891d772b960a9e 100644 --- a/lib/schemaWriter.js +++ b/lib/schemaWriter.js @@ -1,16 +1,20 @@ -/** - * Copyright 2017 Adobe Systems Incorporated. All rights reserved. +/* + * Copyright 2019 Adobe. All rights reserved. * This file is licensed to you 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 REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. */ +const path = require('path'); const writeFile = require('./writeFiles'); -var path = require('path'); -const generateNewSchemaFiles = function(filename, schema, schemaPath, outDir) { +const generateNewSchemaFiles = function (filename, schema, schemaPath, outDir) { return writeFile(path.join(path.join(outDir), path.dirname(filename.substr(schemaPath.length))), path.basename(filename), JSON.stringify(schema, null, 4)); - }; module.exports = generateNewSchemaFiles; diff --git a/lib/writeFiles.js b/lib/writeFiles.js index 600ce136149e6d71a7f9a4154eab18f2f9c986e8..b4cf524bce7da347622833070065d960e0bb7965 100644 --- a/lib/writeFiles.js +++ b/lib/writeFiles.js @@ -1,24 +1,26 @@ -/** - * Copyright 2017 Adobe Systems Incorporated. All rights reserved. +/* + * Copyright 2019 Adobe. All rights reserved. * This file is licensed to you 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 REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. */ -var Promise=require('bluebird'); -var fs = Promise.promisifyAll(require('fs')); -var path = require('path'); -var mkdirp = Promise.promisify(require('mkdirp')); +const Promise = require('bluebird'); +const fs = Promise.promisifyAll(require('fs')); +const path = require('path'); +const mkdirp = Promise.promisify(require('mkdirp')); -const writeFile = function(outputDir, fileName, data) { - if (!fs.existsSync(outputDir)){ - return mkdirp(outputDir).then(() => { - return fs.writeFileAsync(path.join(outputDir, fileName), data).then(() => { return path.join(outputDir, fileName ); }); - }); +const writeFile = function (outputDir, fileName, data) { + if (!fs.existsSync(outputDir)) { + return mkdirp(outputDir).then(() => fs.writeFileAsync(path.join(outputDir, fileName), data).then(() => path.join(outputDir, fileName))); } else { - return fs.writeFileAsync(path.join(outputDir, fileName), data).then(() => { return path.join(outputDir, fileName ); }); + return fs.writeFileAsync(path.join(outputDir, fileName), data).then(() => path.join(outputDir, fileName)); } - }; module.exports = writeFile; diff --git a/package-lock.json b/package-lock.json index 1fc198f9c853c0091174716e1961410026b88343..06b09c8ba3036ca3132fee8623b5fb5760f23cc6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,6 +24,15 @@ "js-tokens": "^4.0.0" } }, + "@babel/runtime": { + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.5.5.tgz", + "integrity": "sha512-28QvEGyQyNkB0/m2B4FU7IEZGK2NUrcMtT6BZEFALTguLk+AUT6ofsHtPk5QyjAdUkpMJ+/Em+quwz4HOt30AQ==", + "dev": true, + "requires": { + "regenerator-runtime": "^0.13.2" + } + }, "@commitlint/execute-rule": { "version": "8.1.0", "resolved": "https://registry.npmjs.org/@commitlint/execute-rule/-/execute-rule-8.1.0.tgz", @@ -251,7 +260,7 @@ "@samverschueren/stream-to-observable": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/@samverschueren/stream-to-observable/-/stream-to-observable-0.3.0.tgz", - "integrity": "sha1-7N9I1TLFjqR3rPyrgDSEJPjQZi8=", + "integrity": "sha512-MI4Xx6LHs4Webyvi6EbspgyAb4D2Q2VtnCQ1blOJcoLS6mVa8lNN2rkIy1CVxfTUpoyIbCTkXES1rLXztFD1lg==", "dev": true, "requires": { "any-observable": "^0.3.0" @@ -743,7 +752,7 @@ "JSONStream": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz", - "integrity": "sha1-MgjB8I06TZkmGrZPkjArwV4RHKA=", + "integrity": "sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==", "dev": true, "requires": { "jsonparse": "^1.2.0", @@ -764,7 +773,7 @@ "acorn-jsx": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.0.1.tgz", - "integrity": "sha1-MqBk/ZJUKSFqCbFBECv90YX65A4=", + "integrity": "sha512-HJ7CfNHrfJLlNTzIEUTj43LNWGkqpRLxm3YjAlcD0ACydk9XynzYsCBHxut+iqt+1aBXkx9UP/w/ZqMr13XIzg==", "dev": true }, "agent-base": { @@ -863,7 +872,7 @@ "any-observable": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/any-observable/-/any-observable-0.3.0.tgz", - "integrity": "sha1-r5M0deWAamfQ198JDdXovvZdEZs=", + "integrity": "sha512-/FQM1EDkTsf63Ub2C6O7GuYFDsSXUwsaZDurV0np41ocwq0jthUAYCmhBX9f+KwlaCgIuWyr/4WlUQUBfKfZog==", "dev": true }, "argparse": { @@ -880,6 +889,16 @@ "integrity": "sha1-oMoMvCmltz6Dbuvhy/bF4OTrgvk=", "dev": true }, + "aria-query": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-3.0.0.tgz", + "integrity": "sha1-ZbP8wcoRVajJrmTW7uKX8V1RM8w=", + "dev": true, + "requires": { + "ast-types-flow": "0.0.7", + "commander": "^2.11.0" + } + }, "arr-diff": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", @@ -910,6 +929,16 @@ "integrity": "sha1-nlKHYrSpBmrRY6aWKjZEGOlibs4=", "dev": true }, + "array-includes": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.0.3.tgz", + "integrity": "sha1-GEtI9i2S10UrsxsyMWXH+L0CJm0=", + "dev": true, + "requires": { + "define-properties": "^1.1.2", + "es-abstract": "^1.7.0" + } + }, "array-union": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", @@ -934,10 +963,16 @@ "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=", "dev": true }, + "ast-types-flow": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/ast-types-flow/-/ast-types-flow-0.0.7.tgz", + "integrity": "sha1-9wtzXGvKGlycItmCw+Oef+ujva0=", + "dev": true + }, "astral-regex": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-1.0.0.tgz", - "integrity": "sha1-bIw/uCfdQ+45GPJ7gngqt2WKb9k=", + "integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==", "dev": true }, "async": { @@ -957,6 +992,15 @@ "integrity": "sha1-D+9a1G8b16hQLGVyfwNn1e5D1pY=", "dev": true }, + "axobject-query": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-2.0.2.tgz", + "integrity": "sha512-MCeek8ZH7hKyO1rWUbKNQBbl4l2eY0ntk7OGi+q0RlafrCnfPxC06WZA+uebCfmYp4mNU9jRBP1AhGyf8+W3ww==", + "dev": true, + "requires": { + "ast-types-flow": "0.0.7" + } + }, "babel-runtime": { "version": "6.26.0", "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz", @@ -1379,7 +1423,7 @@ "color": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/color/-/color-3.0.0.tgz", - "integrity": "sha1-2SC0Mo1TSjrIKV1o971LpsQnvpo=", + "integrity": "sha512-jCpd5+s0s0t7p3pHQKpnJ0TpQKKdleP71LWcA0aqiljpiuAkOSUFN/dyH8ZwF0hRmFlrIuRhufds1QyEP9EB+w==", "requires": { "color-convert": "^1.9.1", "color-string": "^1.5.2" @@ -1401,7 +1445,7 @@ "color-string": { "version": "1.5.3", "resolved": "https://registry.npmjs.org/color-string/-/color-string-1.5.3.tgz", - "integrity": "sha1-ybvF8BtYtUkvPWhXRZy2WQziBMw=", + "integrity": "sha512-dC2C5qeWoYkxki5UAXapdjqO672AM4vZuPGRQfO8b5HKuKGBbKWpITyDYN7TOFKvRW7kOgAn3746clDBMDJyQw==", "requires": { "color-name": "^1.0.0", "simple-swizzle": "^0.2.2" @@ -1430,8 +1474,7 @@ "version": "2.17.1", "resolved": "https://registry.npmjs.org/commander/-/commander-2.17.1.tgz", "integrity": "sha1-vXerfebelCBc6sxy8XFtKfIKd78=", - "dev": true, - "optional": true + "dev": true }, "commitizen": { "version": "4.0.3", @@ -1585,10 +1628,22 @@ "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" }, + "confusing-browser-globals": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/confusing-browser-globals/-/confusing-browser-globals-1.0.7.tgz", + "integrity": "sha512-cgHI1azax5ATrZ8rJ+ODDML9Fvu67PimB6aNxBrc/QwSaDaM9eTfIEUHx3bBLJJ82ioSb+/5zfsMCCEJax3ByQ==", + "dev": true + }, + "contains-path": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/contains-path/-/contains-path-0.1.0.tgz", + "integrity": "sha1-/ozxhP9mcLa67wGp1IYaXL7EEgo=", + "dev": true + }, "conventional-changelog-angular": { "version": "5.0.3", "resolved": "https://registry.npmjs.org/conventional-changelog-angular/-/conventional-changelog-angular-5.0.3.tgz", - "integrity": "sha1-KZ/dQ99aHwlSg6wWru37CmguyrA=", + "integrity": "sha512-YD1xzH7r9yXQte/HF9JBuEDfvjxxwDGGwZU1+ndanbY0oFgA+Po1T9JDSpPLdP0pZT6MhCAsdvFKC4TJ4MTJTA==", "dev": true, "requires": { "compare-func": "^1.3.1", @@ -1666,7 +1721,7 @@ "conventional-commits-filter": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/conventional-commits-filter/-/conventional-commits-filter-2.0.1.tgz", - "integrity": "sha1-VaE13hgC9lELZ1jgpqqeCyhhjbM=", + "integrity": "sha512-92OU8pz/977udhBjgPEbg3sbYzIxMDFTlQT97w7KdhR9igNqdJvy8smmedAAgn4tPiqseFloKkrVfbXCVd+E7A==", "dev": true, "requires": { "is-subset": "^0.1.1", @@ -1676,7 +1731,7 @@ "conventional-commits-parser": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/conventional-commits-parser/-/conventional-commits-parser-3.0.1.tgz", - "integrity": "sha1-/hxJdT3z+Y7bIoWl5IXhH/p/Lkw=", + "integrity": "sha512-P6U5UOvDeidUJ8ebHVDIoXzI7gMlQ1OF/id6oUvp8cnZvOXMt1n8nYl74Ey9YMn0uVQtxmCtjPQawpsssBWtGg==", "dev": true, "requires": { "JSONStream": "^1.0.4", @@ -1952,16 +2007,22 @@ } } }, + "damerau-levenshtein": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/damerau-levenshtein/-/damerau-levenshtein-1.0.5.tgz", + "integrity": "sha512-CBCRqFnpu715iPmw1KrdOrzRqbdFwQTwAWyyyYS42+iAgHCuXZ+/TdMgQkUENPomxEz9z1BEzuQU2Xw0kUuAgA==", + "dev": true + }, "date-fns": { "version": "1.30.1", "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-1.30.1.tgz", - "integrity": "sha1-LnG/CxGRU9u0zE6I2epaz7UNwFw=", + "integrity": "sha512-hBSVCvSmWC+QypYObzwGOd9wqdDpOt+0wl0KbU+R+uuZBS1jN8VsD1ss3irQDknRj5NvxiTF6oj/nDRnN/UQNw==", "dev": true }, "dateformat": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-3.0.3.tgz", - "integrity": "sha1-puN0maTZqc+F71hyBE1ikByYia4=", + "integrity": "sha512-jyCETtSl3VMZMWeRo7iY1FL19ges1t55hMo5yaam4Jrsm5EPL89UQkoQRyiI+Yf4k8r2ZpdngkV8hr1lIdjb3Q==", "dev": true }, "debug": { @@ -2011,7 +2072,7 @@ "deep-extend": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", - "integrity": "sha1-xPp8lUBKF6nD6Mp+FTcxK3NjMKw=", + "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==", "dev": true }, "deep-is": { @@ -2026,6 +2087,15 @@ "integrity": "sha512-YZ1rOP5+kHor4hMAH+HRQnBQHg+wvS1un1hAOuIcxcBy0hzcUf6Jg2a1w65kpoOUnurOfZbERwjI1TfZxNjcww==", "dev": true }, + "define-properties": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", + "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", + "dev": true, + "requires": { + "object-keys": "^1.0.12" + } + }, "define-property": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz", @@ -2101,7 +2171,7 @@ "diagnostics": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/diagnostics/-/diagnostics-1.1.1.tgz", - "integrity": "sha1-yrasM99wydmnJ0kK5DrJladpsio=", + "integrity": "sha512-8wn1PmdunLJ9Tqbx+Fx/ZEuHfJf4NKSN2ZBj7SJC/OWRWha843+WsTjqMe1B5E3p28jqBlp+mJ2fPVxPyNgYKQ==", "requires": { "colorspace": "1.1.x", "enabled": "1.0.x", @@ -2134,7 +2204,7 @@ "doctrine": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", - "integrity": "sha1-rd6+rXKmV023g2OdyHoSF3OXOWE=", + "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", "dev": true, "requires": { "esutils": "^2.0.2" @@ -2217,7 +2287,7 @@ "env-variable": { "version": "0.0.5", "resolved": "https://registry.npmjs.org/env-variable/-/env-variable-0.0.5.tgz", - "integrity": "sha1-kT3YML7xHpagOcA41BMGBOujf4g=" + "integrity": "sha512-zoB603vQReOFvTg5xMl9I1P2PnHsHQQKTEowsKKD7nseUfJq6UWzK+4YtlWUO1nhiQUxe6XMkk+JleSZD1NZFA==" }, "errlop": { "version": "1.1.1", @@ -2253,6 +2323,31 @@ } } }, + "es-abstract": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.13.0.tgz", + "integrity": "sha512-vDZfg/ykNxQVwup/8E1BZhVzFfBxs9NqMzGcvIJrqg5k2/5Za2bWo40dK2J1pgLngZ7c+Shh8lwYtLGyrwPutg==", + "dev": true, + "requires": { + "es-to-primitive": "^1.2.0", + "function-bind": "^1.1.1", + "has": "^1.0.3", + "is-callable": "^1.1.4", + "is-regex": "^1.0.4", + "object-keys": "^1.0.12" + } + }, + "es-to-primitive": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.0.tgz", + "integrity": "sha512-qZryBOJjV//LaxLTV6UC//WewneB3LcXOL9NP++ozKVXsIIIpm/2c13UDiD9Jp2eThsecw9m3jPqDwTyobcdbg==", + "dev": true, + "requires": { + "is-callable": "^1.1.4", + "is-date-object": "^1.0.1", + "is-symbol": "^1.0.2" + } + }, "es6-promise": { "version": "4.2.8", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz", @@ -2311,9 +2406,9 @@ } }, "eslint": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-6.1.0.tgz", - "integrity": "sha512-QhrbdRD7ofuV09IuE2ySWBz0FyXCq0rriLTZXZqaWSI79CVtHVRdkFuFTViiqzZhkCgfOh9USpriuGN2gIpZDQ==", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-6.0.1.tgz", + "integrity": "sha512-DyQRaMmORQ+JsWShYsSg4OPTjY56u1nCjAmICrE8vLWqyLKxhFXOthwMj1SA8xwfrv0CofLNVnqbfyhwCkaO0w==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", @@ -2322,7 +2417,7 @@ "cross-spawn": "^6.0.5", "debug": "^4.0.1", "doctrine": "^3.0.0", - "eslint-scope": "^5.0.0", + "eslint-scope": "^4.0.3", "eslint-utils": "^1.3.1", "eslint-visitor-keys": "^1.0.0", "espree": "^6.0.0", @@ -2330,37 +2425,30 @@ "esutils": "^2.0.2", "file-entry-cache": "^5.0.1", "functional-red-black-tree": "^1.0.1", - "glob-parent": "^5.0.0", + "glob-parent": "^3.1.0", "globals": "^11.7.0", "ignore": "^4.0.6", "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", - "inquirer": "^6.4.1", + "inquirer": "^6.2.2", "is-glob": "^4.0.0", "js-yaml": "^3.13.1", "json-stable-stringify-without-jsonify": "^1.0.1", "levn": "^0.3.0", - "lodash": "^4.17.14", + "lodash": "^4.17.11", "minimatch": "^3.0.4", "mkdirp": "^0.5.1", "natural-compare": "^1.4.0", "optionator": "^0.8.2", "progress": "^2.0.0", "regexpp": "^2.0.1", - "semver": "^6.1.2", - "strip-ansi": "^5.2.0", - "strip-json-comments": "^3.0.1", + "semver": "^5.5.1", + "strip-ansi": "^4.0.0", + "strip-json-comments": "^2.0.1", "table": "^5.2.3", - "text-table": "^0.2.0", - "v8-compile-cache": "^2.0.3" + "text-table": "^0.2.0" }, "dependencies": { - "ansi-regex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", - "dev": true - }, "debug": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", @@ -2371,21 +2459,22 @@ } }, "glob-parent": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.0.0.tgz", - "integrity": "sha512-Z2RwiujPRGluePM6j699ktJYxmPpJKCfpGA13jz2hmFZC7gKetzrWvg5KN3+OsIFmydGyZ1AVwERCq1w/ZZwRg==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", + "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", "dev": true, "requires": { - "is-glob": "^4.0.1" + "is-glob": "^3.1.0", + "path-dirname": "^1.0.0" }, "dependencies": { "is-glob": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", - "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", + "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", "dev": true, "requires": { - "is-extglob": "^2.1.1" + "is-extglob": "^2.1.0" } } } @@ -2400,45 +2489,236 @@ "esprima": "^4.0.0" } }, - "lodash": { - "version": "4.17.15", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", - "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", - "dev": true - }, "ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true + } + } + }, + "eslint-config-airbnb": { + "version": "17.1.1", + "resolved": "https://registry.npmjs.org/eslint-config-airbnb/-/eslint-config-airbnb-17.1.1.tgz", + "integrity": "sha512-xCu//8a/aWqagKljt+1/qAM62BYZeNq04HmdevG5yUGWpja0I/xhqd6GdLRch5oetEGFiJAnvtGuTEAese53Qg==", + "dev": true, + "requires": { + "eslint-config-airbnb-base": "^13.2.0", + "object.assign": "^4.1.0", + "object.entries": "^1.1.0" + } + }, + "eslint-config-airbnb-base": { + "version": "13.2.0", + "resolved": "https://registry.npmjs.org/eslint-config-airbnb-base/-/eslint-config-airbnb-base-13.2.0.tgz", + "integrity": "sha512-1mg/7eoB4AUeB0X1c/ho4vb2gYkNH8Trr/EgCT/aGmKhhG+F6vF5s8+iRBlWAzFIAphxIdp3YfEKgEl0f9Xg+w==", + "dev": true, + "requires": { + "confusing-browser-globals": "^1.0.5", + "object.assign": "^4.1.0", + "object.entries": "^1.1.0" + } + }, + "eslint-import-resolver-node": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.2.tgz", + "integrity": "sha512-sfmTqJfPSizWu4aymbPr4Iidp5yKm8yDkHp+Ir3YiTHiiDfxh69mOUsmiqW6RZ9zRXFaF64GtYmN7e+8GHBv6Q==", + "dev": true, + "requires": { + "debug": "^2.6.9", + "resolve": "^1.5.0" + }, + "dependencies": { + "resolve": { + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz", + "integrity": "sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==", + "dev": true, + "requires": { + "path-parse": "^1.0.6" + } + } + } + }, + "eslint-module-utils": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.4.1.tgz", + "integrity": "sha512-H6DOj+ejw7Tesdgbfs4jeS4YMFrT8uI8xwd1gtQqXssaR0EQ26L+2O/w6wkYFy2MymON0fTwHmXBvvfLNZVZEw==", + "dev": true, + "requires": { + "debug": "^2.6.8", + "pkg-dir": "^2.0.0" + } + }, + "eslint-plugin-header": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-header/-/eslint-plugin-header-3.0.0.tgz", + "integrity": "sha512-OIu2ciVW8jK4Ove4JHm1I7X0C98PZuLCyCsoUhAm2HpyGS+zr34qLM6iV06unnDvssvvEh5BkOfaLRF+N7cGoQ==", + "dev": true + }, + "eslint-plugin-import": { + "version": "2.18.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.18.0.tgz", + "integrity": "sha512-PZpAEC4gj/6DEMMoU2Df01C5c50r7zdGIN52Yfi7CvvWaYssG7Jt5R9nFG5gmqodxNOz9vQS87xk6Izdtpdrig==", + "dev": true, + "requires": { + "array-includes": "^3.0.3", + "contains-path": "^0.1.0", + "debug": "^2.6.9", + "doctrine": "1.5.0", + "eslint-import-resolver-node": "^0.3.2", + "eslint-module-utils": "^2.4.0", + "has": "^1.0.3", + "lodash": "^4.17.11", + "minimatch": "^3.0.4", + "read-pkg-up": "^2.0.0", + "resolve": "^1.11.0" + }, + "dependencies": { + "doctrine": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-1.5.0.tgz", + "integrity": "sha1-N53Ocw9hZvds76TmcHoVmwLFpvo=", + "dev": true, + "requires": { + "esutils": "^2.0.2", + "isarray": "^1.0.0" + } }, - "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "load-json-file": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", + "integrity": "sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "parse-json": "^2.2.0", + "pify": "^2.0.0", + "strip-bom": "^3.0.0" + } + }, + "parse-json": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", + "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", + "dev": true, + "requires": { + "error-ex": "^1.2.0" + } + }, + "path-type": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-2.0.0.tgz", + "integrity": "sha1-8BLMuEFbcJb8LaoQVMPXI4lZTHM=", + "dev": true, + "requires": { + "pify": "^2.0.0" + } + }, + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", "dev": true }, - "strip-ansi": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", - "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "read-pkg": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz", + "integrity": "sha1-jvHAYjxqbbDcZxPEv6xGMysjaPg=", "dev": true, "requires": { - "ansi-regex": "^4.1.0" + "load-json-file": "^2.0.0", + "normalize-package-data": "^2.3.2", + "path-type": "^2.0.0" } }, - "strip-json-comments": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.0.1.tgz", - "integrity": "sha512-VTyMAUfdm047mwKl+u79WIdrZxtFtn+nBxHeb844XBQ9uMNTuTHdx2hc5RiAJYqwTj3wc/xe5HLSdJSkJ+WfZw==", + "read-pkg-up": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-2.0.0.tgz", + "integrity": "sha1-a3KoBImE4MQeeVEP1en6mbO1Sb4=", + "dev": true, + "requires": { + "find-up": "^2.0.0", + "read-pkg": "^2.0.0" + } + }, + "resolve": { + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz", + "integrity": "sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==", + "dev": true, + "requires": { + "path-parse": "^1.0.6" + } + } + } + }, + "eslint-plugin-jsx-a11y": { + "version": "6.2.3", + "resolved": "https://registry.npmjs.org/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.2.3.tgz", + "integrity": "sha512-CawzfGt9w83tyuVekn0GDPU9ytYtxyxyFZ3aSWROmnRRFQFT2BiPJd7jvRdzNDi6oLWaS2asMeYSNMjWTV4eNg==", + "dev": true, + "requires": { + "@babel/runtime": "^7.4.5", + "aria-query": "^3.0.0", + "array-includes": "^3.0.3", + "ast-types-flow": "^0.0.7", + "axobject-query": "^2.0.2", + "damerau-levenshtein": "^1.0.4", + "emoji-regex": "^7.0.2", + "has": "^1.0.3", + "jsx-ast-utils": "^2.2.1" + }, + "dependencies": { + "emoji-regex": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", + "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", "dev": true } } }, + "eslint-plugin-react": { + "version": "7.14.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.14.2.tgz", + "integrity": "sha512-jZdnKe3ip7FQOdjxks9XPN0pjUKZYq48OggNMd16Sk+8VXx6JOvXmlElxROCgp7tiUsTsze3jd78s/9AFJP2mA==", + "dev": true, + "requires": { + "array-includes": "^3.0.3", + "doctrine": "^2.1.0", + "has": "^1.0.3", + "jsx-ast-utils": "^2.1.0", + "object.entries": "^1.1.0", + "object.fromentries": "^2.0.0", + "object.values": "^1.1.0", + "prop-types": "^15.7.2", + "resolve": "^1.10.1" + }, + "dependencies": { + "doctrine": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", + "dev": true, + "requires": { + "esutils": "^2.0.2" + } + }, + "resolve": { + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz", + "integrity": "sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==", + "dev": true, + "requires": { + "path-parse": "^1.0.6" + } + } + } + }, "eslint-scope": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.0.0.tgz", - "integrity": "sha512-oYrhJW7S0bxAFDvWqzvMPRm6pcgcnWc4QnofCAqRTRfQC0JcwenzGglTtsLyIuuWFfkqDG9vz67cnttSd53djw==", + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-4.0.3.tgz", + "integrity": "sha512-p7VutNr1O/QrxysMo3E45FjYDTeXBy0iTltPFNSqKAIfjDSXC+4dj+qfyuD8bfAXrW/y6lW3O76VaYNPKfpKrg==", "dev": true, "requires": { "esrecurse": "^4.1.0", @@ -2457,7 +2737,7 @@ "eslint-visitor-keys": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz", - "integrity": "sha1-PzGA+y4pEBdxastMnW1bXDSmqB0=", + "integrity": "sha512-qzm/XxIbxm/FHyH341ZrbnMUpe+5Bocte9xkmFMzPMjRaZMcXww+MpBptFvtU+79L362nqiLhekCxCxDPaUMBQ==", "dev": true }, "espree": { @@ -2479,7 +2759,7 @@ "esquery": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.0.1.tgz", - "integrity": "sha1-QGxRZYsfWZGl+bYrHcJbAOPlxwg=", + "integrity": "sha512-SmiyZ5zIWH9VM+SRUReLS5Q8a7GxtRdxEBVZpm98rJM7Sb+A9DVCndXfkeFUd3byderg+EbDkfnevfCwynWaNA==", "dev": true, "requires": { "estraverse": "^4.0.0" @@ -2488,7 +2768,7 @@ "esrecurse": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", - "integrity": "sha1-AHo7n9vCs7uH5IeeoZyS/b05Qs8=", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", "dev": true, "requires": { "estraverse": "^4.1.0" @@ -2779,7 +3059,7 @@ "fast-safe-stringify": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.0.6.tgz", - "integrity": "sha1-BLJhBsxWaB9RoETPwNds8ACKwsI=" + "integrity": "sha512-q8BZ89jjc+mz08rSxROs8VsrBBcn1SIw1kq9NjolL509tkABRk9io01RAjSaEv1Xb2uFLt8VtRiZbGp5H8iDtg==" }, "fastq": { "version": "1.6.0", @@ -2793,7 +3073,7 @@ "fecha": { "version": "2.3.3", "resolved": "https://registry.npmjs.org/fecha/-/fecha-2.3.3.tgz", - "integrity": "sha1-lI50FX3xoy/RsSw6PDzctuydls0=" + "integrity": "sha512-lUGBnIamTAwk4znq5BcqsDaxSmZ9nDVJaij6NvRt/Tg4R69gERA+otPKbS86ROw9nxVMw2/mp1fnaiWqbs6Sdg==" }, "figures": { "version": "2.0.0", @@ -2807,7 +3087,7 @@ "file-entry-cache": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-5.0.1.tgz", - "integrity": "sha1-yg9u+m3T1WEzP7FFFQZcL6/fQ5w=", + "integrity": "sha512-bCg29ictuBaKUwwArK4ouCaqDgLZcysCFLmM/Yn/FDoqndh/9vNuQfXRDvTuXKLxfD/JtZQGKFT8MGcJBK644g==", "dev": true, "requires": { "flat-cache": "^2.0.1" @@ -2918,7 +3198,7 @@ "flat-cache": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-2.0.1.tgz", - "integrity": "sha1-XSltbwS9pEpGMKMBQTvbwuwIXsA=", + "integrity": "sha512-LoQe6yDuUMDzQAEH8sgmh4Md6oZnc/7PjtwjNFSzveXqSHt6ka9fPBuso7IGf9Rz4uqnSnWiFH2B/zj24a5ReA==", "dev": true, "requires": { "flatted": "^2.0.0", @@ -2987,6 +3267,12 @@ "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", "dev": true }, + "function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", + "dev": true + }, "functional-red-black-tree": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", @@ -3002,7 +3288,7 @@ "get-own-enumerable-property-symbols": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/get-own-enumerable-property-symbols/-/get-own-enumerable-property-symbols-3.0.0.tgz", - "integrity": "sha1-uHe0mlwWrvrDZV8u0upbaE340gM=", + "integrity": "sha512-CIJYJC4GGF06TakLg8z4GQKvDsx9EMspVxOYih7LerEL/WosUnFIww45CGfxfeKHqlg3twgUrYRT1O3WQqjGCg==", "dev": true }, "get-stream": { @@ -3204,6 +3490,15 @@ } } }, + "has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "dev": true, + "requires": { + "function-bind": "^1.1.1" + } + }, "has-ansi": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", @@ -3226,6 +3521,12 @@ "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" }, + "has-symbols": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.0.tgz", + "integrity": "sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q=", + "dev": true + }, "has-value": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz", @@ -3285,7 +3586,7 @@ "http-proxy-agent": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-2.1.0.tgz", - "integrity": "sha1-5IIb7vWyFCogJr1zkm/lN2McVAU=", + "integrity": "sha512-qwHbBLV7WviBl0rQsOzH6o5lwyOIvwp/BdFnvVxXORldu5TmjFfjzBcWUWS5kWAZhmv+JtiDhSuQCp4sBfbIgg==", "dev": true, "requires": { "agent-base": "4", @@ -3295,7 +3596,7 @@ "debug": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha1-W7WgZyYotkFJVmuhaBnmFRjGcmE=", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", "dev": true, "requires": { "ms": "2.0.0" @@ -3355,7 +3656,7 @@ "ignore": { "version": "4.0.6", "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", - "integrity": "sha1-dQ49tYYgh7RzfrrIIH/9HvJ7Jfw=", + "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", "dev": true }, "ignorefs": { @@ -3456,12 +3757,6 @@ "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", "dev": true }, - "lodash": { - "version": "4.17.15", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", - "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", - "dev": true - }, "strip-ansi": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", @@ -3512,7 +3807,7 @@ "is-arrayish": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.3.2.tgz", - "integrity": "sha1-RXSirlb3qyBolvtDHq7tBm/fjwM=" + "integrity": "sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ==" }, "is-buffer": { "version": "1.1.6", @@ -3520,6 +3815,12 @@ "integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=", "dev": true }, + "is-callable": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.4.tgz", + "integrity": "sha512-r5p9sxJjYnArLjObpjA4xu5EKI3CuKHkJXMhT7kwbpUyIFD1n5PMAsoPvWnvtZiNz7LjkYDRZhd7FlI0eMijEA==", + "dev": true + }, "is-data-descriptor": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", @@ -3540,6 +3841,12 @@ } } }, + "is-date-object": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.1.tgz", + "integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY=", + "dev": true + }, "is-descriptor": { "version": "0.1.6", "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", @@ -3620,7 +3927,7 @@ "is-observable": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-observable/-/is-observable-1.1.0.tgz", - "integrity": "sha1-s+mGyPRN6VCGfKtUA/WjRlAFl14=", + "integrity": "sha512-NqCa4Sa2d+u7BWc6CukaObG3Fh+CU9bvixbpcXYhy2VvYS7vVGIdAgnIS5Ks3A/cqk4rebLJ9s8zBstT2aKnIA==", "dev": true, "requires": { "symbol-observable": "^1.1.0" @@ -3629,13 +3936,13 @@ "is-path-cwd": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-2.2.0.tgz", - "integrity": "sha1-Z9Q7gmZKe1GR/ZEZEn6zAASKn9s=", + "integrity": "sha512-w942bTcih8fdJPJmQHFzkS76NEP8Kzzvmw92cXsazb8intwLqPibPPdXf4ANdKV3rYMuuQYGIWtvz9JilB3NFQ==", "dev": true }, "is-path-in-cwd": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-path-in-cwd/-/is-path-in-cwd-2.1.0.tgz", - "integrity": "sha1-v+Lcomxp85cmWkAJljYCk1oFOss=", + "integrity": "sha512-rNocXHgipO+rvnP6dk3zI20RpOtrAM/kzbB258Uw5BWr3TpXi861yzjo16Dn4hUox07iw5AyeMLHWsujkjzvRQ==", "dev": true, "requires": { "is-path-inside": "^2.1.0" @@ -3644,7 +3951,7 @@ "is-path-inside": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-2.1.0.tgz", - "integrity": "sha1-fJgQWH1lmkDSe8201WFuqwWUlLI=", + "integrity": "sha512-wiyhTzfDWsvwAW53OBWF5zuvaOGlZ6PwYxAbPVDhpm+gM09xKQGjBq/8uYN12aDvMxnAnq3dxTyoSoRNmg5YFg==", "dev": true, "requires": { "path-is-inside": "^1.0.2" @@ -3671,6 +3978,15 @@ "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=", "dev": true }, + "is-regex": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz", + "integrity": "sha1-VRdIm1RwkbCTDglWVM7SXul+lJE=", + "dev": true, + "requires": { + "has": "^1.0.1" + } + }, "is-regexp": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-regexp/-/is-regexp-1.0.0.tgz", @@ -3688,6 +4004,15 @@ "integrity": "sha1-ilkRfZMt4d4A8kX83TnOQ/HpOaY=", "dev": true }, + "is-symbol": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.2.tgz", + "integrity": "sha512-HS8bZ9ox60yCJLH9snBpIwv9pYUAkcuLhSA1oero1UB5y9aiQpRA8y2ex945AOtCZL1lJDeIk3G5LthswI46Lw==", + "dev": true, + "requires": { + "has-symbols": "^1.0.0" + } + }, "is-text-path": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-text-path/-/is-text-path-1.0.1.tgz", @@ -3860,7 +4185,7 @@ "js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", - "integrity": "sha1-GSA/tZmR35jjoocFDUZHzerzJJk=", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", "dev": true }, "js-yaml": { @@ -3917,6 +4242,16 @@ "integrity": "sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA=", "dev": true }, + "jsx-ast-utils": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-2.2.1.tgz", + "integrity": "sha512-v3FxCcAf20DayI+uxnCuw795+oOIkVu6EnJ1+kSzhqqTZHNkTZ7B66ZgLp4oLJ/gbA64cI0B7WRoHZMSRdyVRQ==", + "dev": true, + "requires": { + "array-includes": "^3.0.3", + "object.assign": "^4.1.0" + } + }, "kind-of": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", @@ -3926,7 +4261,7 @@ "kuler": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/kuler/-/kuler-1.0.1.tgz", - "integrity": "sha1-73x4TzbJ+24W3TFQ0VJneysCKKY=", + "integrity": "sha512-J9nVUucG1p/skKul6DU3PUZrhs0LPulNaeUOox0IyXDi8S4CztTHs1gQphhuZmzXG7VOQSf6NJfKuzteQLv9gQ==", "requires": { "colornames": "^1.1.1" } @@ -4105,7 +4440,7 @@ "listr": { "version": "0.14.3", "resolved": "https://registry.npmjs.org/listr/-/listr-0.14.3.tgz", - "integrity": "sha1-L+qQlgTkNL5GTFC926DUlpKPpYY=", + "integrity": "sha512-RmAl7su35BFd/xoMamRjpIE4j3v+L28o8CT5YhAXQJm1fD+1l9ngXY8JAQRJ+tFK2i5njvi0iRUKV09vPwA0iA==", "dev": true, "requires": { "@samverschueren/stream-to-observable": "^0.3.0", @@ -4128,7 +4463,7 @@ "listr-update-renderer": { "version": "0.5.0", "resolved": "https://registry.npmjs.org/listr-update-renderer/-/listr-update-renderer-0.5.0.tgz", - "integrity": "sha1-Tqg2hUinuK7LfgbYyVy0WuLt5qI=", + "integrity": "sha512-tKRsZpKz8GSGqoI/+caPmfrypiaq+OQCbd+CovEC24uk1h952lVj5sC7SqyFUm+OaJ5HN/a1YLt5cit2FMNsFA==", "dev": true, "requires": { "chalk": "^1.1.3", @@ -4205,7 +4540,7 @@ "listr-verbose-renderer": { "version": "0.5.0", "resolved": "https://registry.npmjs.org/listr-verbose-renderer/-/listr-verbose-renderer-0.5.0.tgz", - "integrity": "sha1-8RMhZ1NepMEmEQK58o2sfLoeA9s=", + "integrity": "sha512-04PDPqSlsqIOaaaGZ+41vq5FejI9auqTInicFRndCBgE3bXG8D6W1I+mWhk+1nqbHmyhla/6BUrd5OSiHwKRXw==", "dev": true, "requires": { "chalk": "^2.4.1", @@ -4332,7 +4667,7 @@ "log-symbols": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-3.0.0.tgz", - "integrity": "sha1-86CFFqXeqJMzan3uFNGKHP2rd8Q=", + "integrity": "sha512-dSkNGuI7iG3mfvDzUuYZyvk5dD9ocYCYzNU6CYDE6+Xqd+gwme6Z00NS3dUh8mq/73HaEtT7m6W+yUPtU6BZnQ==", "dev": true, "requires": { "chalk": "^2.4.2" @@ -4374,6 +4709,15 @@ "integrity": "sha1-eB4YMpaqlPbU2RbcM10NF676I/g=", "dev": true }, + "loose-envify": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "dev": true, + "requires": { + "js-tokens": "^3.0.0 || ^4.0.0" + } + }, "loud-rejection": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/loud-rejection/-/loud-rejection-1.6.0.tgz", @@ -4473,7 +4817,7 @@ "meow": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/meow/-/meow-4.0.1.tgz", - "integrity": "sha1-1IWY9vSxRy81v2MXqVlFrONH+XU=", + "integrity": "sha512-xcSBHD5Z86zaOc+781KrupuHAzeGXSLtiAOmBsiLDiPSaYSB6hdew2ng9EBAnZ62jagG9MHAOdxpDi/lWBFJ/A==", "dev": true, "requires": { "camelcase-keys": "^4.0.0", @@ -4514,7 +4858,7 @@ "merge-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", - "integrity": "sha1-UoI2KaFN0AyXcPtq1H3GMQ8sH2A=", + "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", "dev": true }, "merge2": { @@ -4603,7 +4947,7 @@ "minimist-options": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/minimist-options/-/minimist-options-3.0.2.tgz", - "integrity": "sha1-+6TIGRM54T7PTWG+sD8HAQPz2VQ=", + "integrity": "sha512-FyBrT/d0d4+uiZRbqznPXqw3IpZZG3gl3wKWiX784FycUKVwBt0uLBFkQrtE4tZOrgo78nZp2jnKz3L65T5LdQ==", "dev": true, "requires": { "arrify": "^1.0.1", @@ -4642,7 +4986,7 @@ "modify-values": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/modify-values/-/modify-values-1.0.1.tgz", - "integrity": "sha1-s5OfpgVUZHTj4+PGPWS9Q7TuYCI=", + "integrity": "sha512-xV2bxeN6F7oYjZWTe/YPAy6MN2M+sL4u/Rlm2AHCIVGfo2p1yGmBHQ6vHehl4bRTZBdHu3TSkWdYgkwpYzAGSw==", "dev": true }, "ms": { @@ -4707,7 +5051,7 @@ "node-emoji": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/node-emoji/-/node-emoji-1.10.0.tgz", - "integrity": "sha1-iIar0l2ce7YYAqZYUj0fjSqJsto=", + "integrity": "sha512-Yt3384If5H6BYGVHiHwTL+99OzJKHhgp82S8/dktEK73T26BazdgZ4JZh92xSVtGNJvz9UbXdNAc5hcrXV42vw==", "dev": true, "requires": { "lodash.toarray": "^4.4.0" @@ -4730,7 +5074,7 @@ "normalize-package-data": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", - "integrity": "sha1-5m2xg4sgDB38IzIl0SyzZSDiNKg=", + "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", "dev": true, "requires": { "hosted-git-info": "^2.1.4", @@ -8289,6 +8633,12 @@ } } }, + "object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", + "dev": true + }, "object-visit": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz", @@ -8298,6 +8648,42 @@ "isobject": "^3.0.0" } }, + "object.assign": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.0.tgz", + "integrity": "sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w==", + "dev": true, + "requires": { + "define-properties": "^1.1.2", + "function-bind": "^1.1.1", + "has-symbols": "^1.0.0", + "object-keys": "^1.0.11" + } + }, + "object.entries": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/object.entries/-/object.entries-1.1.0.tgz", + "integrity": "sha512-l+H6EQ8qzGRxbkHOd5I/aHRhHDKoQXQ8g0BYt4uSweQU1/J6dZUOyWh9a2Vky35YCKjzmgxOzta2hH6kf9HuXA==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.12.0", + "function-bind": "^1.1.1", + "has": "^1.0.3" + } + }, + "object.fromentries": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/object.fromentries/-/object.fromentries-2.0.0.tgz", + "integrity": "sha512-9iLiI6H083uiqUuvzyY6qrlmc/Gz8hLQFOcb/Ri/0xXFkSNS3ctV+CbE6yM2+AnkYfOB3dGjdzC0wrMLIhQICA==", + "dev": true, + "requires": { + "define-properties": "^1.1.2", + "es-abstract": "^1.11.0", + "function-bind": "^1.1.1", + "has": "^1.0.1" + } + }, "object.pick": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", @@ -8307,10 +8693,22 @@ "isobject": "^3.0.1" } }, + "object.values": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/object.values/-/object.values-1.1.0.tgz", + "integrity": "sha512-8mf0nKLAoFX6VlNVdhGj31SVYpaNFtUnuoOXWyFEstsWRgU837AK+JYM0iAxwkSzGRbwn8cbFmgbyxj1j4VbXg==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.12.0", + "function-bind": "^1.1.1", + "has": "^1.0.3" + } + }, "octokit-pagination-methods": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/octokit-pagination-methods/-/octokit-pagination-methods-1.1.0.tgz", - "integrity": "sha1-z0cu3J1VEFX573P25CtNu0yAvqQ=", + "integrity": "sha512-fZ4qZdQ2nxJvtcasX7Ghl+WlWS/d9IgnBIwFZXVNNZUmzpno91SX5bc5vuxiuKoCtK78XxGGNuSCrDC7xYB3OQ==", "dev": true }, "once": { @@ -8444,7 +8842,7 @@ "p-limit": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", - "integrity": "sha1-uGvV8MJWkJEcdZD8v8IBDVSzzLg=", + "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==", "dev": true, "requires": { "p-try": "^1.0.0" @@ -8515,7 +8913,7 @@ "parse-github-url": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/parse-github-url/-/parse-github-url-1.0.2.tgz", - "integrity": "sha1-JC07ZcvN2hS7UEOeMkKs9pcds5U=", + "integrity": "sha512-kgBf6avCbO3Cn6+RnzRGLkUsv4ZVqv/VfAYkRsyBcgkshNvVBkRn1FEZcW0Jb+npXQWm2vHPnnOqFteZxRRGNw==", "dev": true }, "parse-json": { @@ -8539,6 +8937,12 @@ "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=", "dev": true }, + "path-dirname": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/path-dirname/-/path-dirname-1.0.2.tgz", + "integrity": "sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA=", + "dev": true + }, "path-exists": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", @@ -8565,7 +8969,7 @@ "path-parse": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", - "integrity": "sha1-1i27VnlAXXLEc37FhgDp3c8G0kw=", + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", "dev": true }, "path-type": { @@ -8598,6 +9002,15 @@ "load-json-file": "^4.0.0" } }, + "pkg-dir": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-2.0.0.tgz", + "integrity": "sha1-9tXREJ4Z1j7fQo4L1X4Sd3YVM0s=", + "dev": true, + "requires": { + "find-up": "^2.1.0" + } + }, "please-upgrade-node": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/please-upgrade-node/-/please-upgrade-node-3.2.0.tgz", @@ -8632,9 +9045,20 @@ "progress": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", - "integrity": "sha1-foz42PW48jnBvGi+tOt4Vn1XLvg=", + "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", "dev": true }, + "prop-types": { + "version": "15.7.2", + "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.7.2.tgz", + "integrity": "sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==", + "dev": true, + "requires": { + "loose-envify": "^1.4.0", + "object-assign": "^4.1.1", + "react-is": "^16.8.1" + } + }, "pump": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", @@ -8665,7 +9089,7 @@ "rc": { "version": "1.2.8", "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", - "integrity": "sha1-zZJL9SAKB1uDwYjNa54hG3/A0+0=", + "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", "dev": true, "requires": { "deep-extend": "^0.6.0", @@ -8682,6 +9106,12 @@ } } }, + "react-is": { + "version": "16.9.0", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.9.0.tgz", + "integrity": "sha512-tJBzzzIgnnRfEm046qRcURvwQnZVXmuCbscxUO5RWrGTXpon2d4c8mI0D8WE6ydVIm29JiLB6+RslkIvym9Rjw==", + "dev": true + }, "read-pkg": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz", @@ -8819,6 +9249,12 @@ "esprima": "~4.0.0" } }, + "regenerator-runtime": { + "version": "0.13.3", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.3.tgz", + "integrity": "sha512-naKIZz2GQ8JWh///G7L3X6LaQUAMp2lvb1rvwwsURe/VXwD6VMfr+/1NuNw3ag8v2kY1aQ/go5SNn79O9JU7yw==", + "dev": true + }, "regex-not": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz", @@ -8832,7 +9268,7 @@ "regexpp": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-2.0.1.tgz", - "integrity": "sha1-jRnTHPYySCtYkEn4KB+T28uk0H8=", + "integrity": "sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==", "dev": true }, "registry-auth-token": { @@ -9126,7 +9562,7 @@ "semver-regex": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/semver-regex/-/semver-regex-2.0.0.tgz", - "integrity": "sha1-qTwsWERTmncCMzeRB7OMe0rJ0zg=", + "integrity": "sha512-mUdIBBvdn0PLOeP3TEkMH7HHeUP3GjsXCwKarjv/kGmUFOYg1VqEemKhoQpWMu6X2I8kHeuVdGibLGkVK+/5Qw==", "dev": true }, "set-blocking": { @@ -9193,7 +9629,7 @@ "signale": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/signale/-/signale-1.4.0.tgz", - "integrity": "sha1-xL5YMC+wJirAD8PYhqfBE3WQQvE=", + "integrity": "sha512-iuh+gPf28RkltuJC7W5MRi6XAjTDCAPC/prJUpQoG4vIP3MJZ+GTydVnodXA7pwvTKb2cA0m9OFZW/cdWy/I/w==", "dev": true, "requires": { "chalk": "^2.3.2", @@ -9218,7 +9654,7 @@ "slice-ansi": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-2.1.0.tgz", - "integrity": "sha1-ys12k0YaY3pXiNkqfdT7oGjoFjY=", + "integrity": "sha512-Qu+VC3EwYLldKa1fCxuuvULvSJOKEgk9pi8dZeCVK7TqBfUNTH4sFkk4joj8afVSfAYgJoSOetjx9QWOJ5mYoQ==", "dev": true, "requires": { "ansi-styles": "^3.2.0", @@ -9373,7 +9809,7 @@ "spdx-correct": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.1.0.tgz", - "integrity": "sha1-+4PlBERSaPFUsHTiGMh8ADzTHfQ=", + "integrity": "sha512-lr2EZCctC2BNR7j7WzJ2FpDznxky1sjfxvvYEyzxNyb6lZXHODmEoJeFu4JupYlkfha1KZpJyoqiJ7pgA1qq8Q==", "dev": true, "requires": { "spdx-expression-parse": "^3.0.0", @@ -9383,13 +9819,13 @@ "spdx-exceptions": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.2.0.tgz", - "integrity": "sha1-LqRQrudPKom/uUUZwH/Nb0EyKXc=", + "integrity": "sha512-2XQACfElKi9SlVb1CYadKDXvoajPgBVPn/gOQLrTvHdElaVhr7ZEbqJaRnJLVNeaI4cMEAgVCeBMKF6MWRDCRA==", "dev": true }, "spdx-expression-parse": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", - "integrity": "sha1-meEZt6XaAOBUkcn6M4t5BII7QdA=", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", "dev": true, "requires": { "spdx-exceptions": "^2.1.0", @@ -9405,7 +9841,7 @@ "split": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/split/-/split-1.0.1.tgz", - "integrity": "sha1-YFvZvjA6pZ+zX5Ip++oN3snqB9k=", + "integrity": "sha512-mTyOoPbrivtXnwnIxZRFYRrPNtEFKlpB2fvjSnCQUiAA6qAZzqwna5envK4uk6OIeP17CsdF3rSBGYVBsU0Tkg==", "dev": true, "requires": { "through": "2" @@ -9423,7 +9859,7 @@ "split2": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/split2/-/split2-2.2.0.tgz", - "integrity": "sha1-GGsldbz4PoW30YRldWI47k7kJJM=", + "integrity": "sha512-RAb22TG39LhI31MbreBgIuKiIKhVsawfTgEGqKHTK87aG+ul/PB8Sqoi3I7kVdRWiCfrKxK3uo4/YUkpNvhPbw==", "dev": true, "requires": { "through2": "^2.0.2" @@ -9473,7 +9909,7 @@ "string-argv": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/string-argv/-/string-argv-0.3.0.tgz", - "integrity": "sha1-Dqmeclf+pel6G/zfwZzxLWjm7Go=", + "integrity": "sha512-NGZHq3nkSXVtGZXTBjFru3MNfoZyIzN25T7BmvdgnSC0LCJczAGLLMQLyjywSIaAoqSemgLzBRHOsnrHbt60+Q==", "dev": true }, "string-width": { @@ -9497,7 +9933,7 @@ "stringify-object": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/stringify-object/-/stringify-object-3.3.0.tgz", - "integrity": "sha1-cDBlrvyhkwDTzoivT1s5VtdVZik=", + "integrity": "sha512-rHqiFh1elqCQ9WPLIC8I0Q/g/wj5J1eMkyoiD6eoQApWHP0FtlK7rqnhmabL5VUY9JQCcqwwvlOaSuutekgyrw==", "dev": true, "requires": { "get-own-enumerable-property-symbols": "^3.0.0", @@ -9529,7 +9965,7 @@ "strip-final-newline": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", - "integrity": "sha1-ibhS+y/L6Tb29LMYevsKEsGrWK0=", + "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==", "dev": true }, "strip-indent": { @@ -9555,7 +9991,7 @@ "supports-hyperlinks": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/supports-hyperlinks/-/supports-hyperlinks-1.0.1.tgz", - "integrity": "sha1-cdrt82zBBgrFEAw1G7PaSMKcDvc=", + "integrity": "sha512-HHi5kVSefKaJkGYXbDuKbUGRVxqnWGn3J2e39CYcNJEfWciGq2zYtOhXLTlvrOZW1QU7VX67w7fMmWafHX9Pfw==", "dev": true, "requires": { "has-flag": "^2.0.0", @@ -9573,13 +10009,13 @@ "symbol-observable": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.2.0.tgz", - "integrity": "sha1-wiaIrtTqs83C3+rLtWFmBWCgCAQ=", + "integrity": "sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ==", "dev": true }, "table": { - "version": "5.4.4", - "resolved": "https://registry.npmjs.org/table/-/table-5.4.4.tgz", - "integrity": "sha512-IIfEAUx5QlODLblLrGTTLJA7Tk0iLSGBvgY8essPRVNGHAzThujww1YqHLs6h3HfTg55h++RzLHH5Xw/rfv+mg==", + "version": "5.4.5", + "resolved": "https://registry.npmjs.org/table/-/table-5.4.5.tgz", + "integrity": "sha512-oGa2Hl7CQjfoaogtrOHEJroOcYILTx7BZWLGsJIlzoWmB2zmguhNfPJZsWPKYek/MgCxfco54gEi31d1uN2hFA==", "dev": true, "requires": { "ajv": "^6.10.2", @@ -9652,13 +10088,13 @@ "text-extensions": { "version": "1.9.0", "resolved": "https://registry.npmjs.org/text-extensions/-/text-extensions-1.9.0.tgz", - "integrity": "sha1-GFPkX+45yUXOb2w2stZZtaq8KiY=", + "integrity": "sha512-wiBrwC1EhBelW12Zy26JeOUkQ5mRu+5o8rpsJk5+2t+Y5vE7e842qtZDQ2g1NpX/29HdyFeJ4nSIhI47ENSxlQ==", "dev": true }, "text-hex": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/text-hex/-/text-hex-1.0.0.tgz", - "integrity": "sha1-adycGxdEbueakr9biEu0uRJ1BvU=" + "integrity": "sha512-uuVGNWzgJ4yhRaNSiubPY7OjISw4sw4E5Uv0wbjp+OzcbmVU/rsT8ujgcXJhn9ypzsgr5vlzpPqP+MBBKcGvbg==" }, "text-table": { "version": "0.2.0", @@ -9675,7 +10111,7 @@ "through2": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", - "integrity": "sha1-AcHjnrMdB8t9A6lqcIIyYLIxMs0=", + "integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==", "dev": true, "requires": { "readable-stream": "~2.3.6", @@ -9754,7 +10190,7 @@ "triple-beam": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/triple-beam/-/triple-beam-1.3.0.tgz", - "integrity": "sha1-pZUhTHKY24M57u7gg+TRC9jLjdk=" + "integrity": "sha512-XrHUvV5HpdLmIj4uVMxHggLbFSZYIn7HEWsqePZcI50pco+MPqJ50wMGY794X7AOOhxOBAjbkqfAbEe/QMp2Lw==" }, "tslib": { "version": "1.9.3", @@ -9906,12 +10342,6 @@ "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" }, - "v8-compile-cache": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.0.3.tgz", - "integrity": "sha512-CNmdbwQMBjwr9Gsmohvm0pbL954tJrNzf6gWL3K+QMQf00PF7ERGrEiLgjuU3mKreLC2MeGhUsNV9ybTbLgd3w==", - "dev": true - }, "valid-url": { "version": "1.0.9", "resolved": "https://registry.npmjs.org/valid-url/-/valid-url-1.0.9.tgz", @@ -9920,7 +10350,7 @@ "validate-npm-package-license": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", - "integrity": "sha1-/JH2uce6FchX9MssXe/uw51PQQo=", + "integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==", "dev": true, "requires": { "spdx-correct": "^3.0.0", @@ -10039,7 +10469,7 @@ "write": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/write/-/write-1.0.3.tgz", - "integrity": "sha1-CADhRSO5I6OH5BUSPIZWFqrg9cM=", + "integrity": "sha512-/lg70HAjtkUgWPVZhZcm+T4hkL8Zbtp1nFNOn3lRrxnlv50SRBv7cR7RqR+GMsd3hUXy9hWBo4CHTbFTcOYwig==", "dev": true, "requires": { "mkdirp": "^0.5.1" @@ -10064,7 +10494,7 @@ "y18n": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", - "integrity": "sha1-le+U+F7MgdAHwmThkKEg8KPIVms=", + "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==", "dev": true }, "yallist": { diff --git a/package.json b/package.json index 01f698b8404350013eed0e64cd882db97b679631..eeb30194dc693d267663ca4493b4abb859d3d922 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,12 @@ "@semantic-release/github": "^5.4.2", "commitizen": "^4.0.3", "cz-conventional-changelog": "^3.0.2", - "eslint": "^6.1.0", + "eslint": "6.0.1", + "eslint-config-airbnb": "17.1.1", + "eslint-plugin-header": "3.0.0", + "eslint-plugin-import": "2.18.0", + "eslint-plugin-jsx-a11y": "6.2.3", + "eslint-plugin-react": "7.14.2", "ghooks": "^2.0.4", "istanbul": "^0.4.5", "jasmine": "~3.4.0", diff --git a/spec/lib/header.spec.js b/spec/lib/header.spec.js index 0fcd8348ed4cf944a39e5b72114b17481834fbf7..a7f38ce991391dd44a20a688f53f97234fb7793c 100644 --- a/spec/lib/header.spec.js +++ b/spec/lib/header.spec.js @@ -1,19 +1,33 @@ -const { Header, headers } = require('../../lib/header'); +/* + * Copyright 2019 Adobe. All rights reserved. + * This file is licensed to you 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 REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ + +/* eslint-env jasmine */ + const i18n = require('i18n'); -var path = require('path'); +const path = require('path'); +const { Header, headers } = require('../../lib/header'); -beforeEach(function() { +beforeEach(() => { jasmine.addMatchers(require('jasmine-diff')(jasmine, { colors: true, - inline: true + inline: true, })); - let i18nPath=path.resolve(path.join(__dirname, '../../lib/locales')); + const i18nPath = path.resolve(path.join(__dirname, '../../lib/locales')); i18n.configure({ // setup some locales - other locales default to en silently - locales:[ 'en' ], + locales: ['en'], // where to store json files - defaults to './locales' relative to modules directory directory: i18nPath, - defaultLocale: 'en' + defaultLocale: 'en', }); }); @@ -44,7 +58,7 @@ describe('Headers Integration Test', () => { const schema = { additionalProperties: true, 'meta:extensible': false, - properties: { 'foo':'bar', 'bar': 'baz' } + properties: { foo: 'bar', bar: 'baz' }, }; const h = headers(schema, '/home/lars', '/home/lars/complex.schema.json'); @@ -59,7 +73,7 @@ describe('Headers Integration Test', () => { const schema = { additionalProperties: true, 'meta:extensible': false, - properties: { 'foo':'bar', 'bar': 'baz' } + properties: { foo: 'bar', bar: 'baz' }, }; const h = headers(schema, '/home/lars', '/home/lars/some/deep/path/complex.schema.json'); @@ -69,5 +83,4 @@ describe('Headers Integration Test', () => { | Can be instantiated | No | Experimental | No | Forbidden | Permitted | [some/deep/path/complex.schema.json](complex.schema.json) |`; expect(h.render()).toEqual(result); }); - }); diff --git a/spec/lib/integrationTest.spec.js b/spec/lib/integrationTest.spec.js index 1631b83c5c9810ea9a9cebf5138bbbd57e6c8e2c..9b07850f4c912bf3208ca262f8a9c9550bc86a23 100644 --- a/spec/lib/integrationTest.spec.js +++ b/spec/lib/integrationTest.spec.js @@ -1,20 +1,33 @@ +/* + * Copyright 2019 Adobe. All rights reserved. + * This file is licensed to you 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 REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ + +/* eslint-env jasmine */ + const { spawn } = require('child_process'); const path = require('path'); const { readFileSync, readdirSync, statSync } = require('fs'); -beforeEach(function() { +beforeEach(() => { jasmine.DEFAULT_TIMEOUT_INTERVAL = 20000; jasmine.addMatchers( require('jasmine-diff')(jasmine, { colors: true, - inline: true - }) + inline: true, + }), ); }); describe('Compare results', () => { - - it('Run jsonschema2md for custom file extension', done => { + it('Run jsonschema2md for custom file extension', (done) => { const ls = spawn('node', [ 'cli.js', '-d', @@ -24,17 +37,17 @@ describe('Compare results', () => { '-x', 'examples/generated-schemas', '-e', - 'js' + 'js', ]); - ls.on('close', code => { + ls.on('close', (code) => { expect(code).toEqual(0); done(); }); }); - it('Run jsonschema2md on example schemas', done => { + it('Run jsonschema2md on example schemas', (done) => { const ls = spawn('node', [ 'cli.js', '-d', @@ -51,16 +64,15 @@ describe('Compare results', () => { 'abstract.md', '--link-status', 'status.md', - '-v', '06' + '-v', '06', ]); - ls.on('close', code => { + ls.on('close', (code) => { expect(code).toEqual(0); const files = readdirSync('./spec/examples').filter(item => !(/(^|\/)\.[^\/\.]/g).test(item)); expect(files.length).toEqual(23); - //console.log(readFileSync(path.resolve('./examples/schemas/', 'definitions.schema.json')).toString()); - files.forEach(file => { - if (statSync('./spec/examples/' + file).isFile()) { + files.forEach((file) => { + if (statSync(`./spec/examples/${file}`).isFile()) { const expectedstr = readFileSync(path.resolve('./spec/examples/', file)).toString(); let actualstr = readFileSync(path.resolve('./examples/docs/', file)).toString(); actualstr=actualstr.replace(/\r\n/g, '\n'); diff --git a/spec/lib/readSchemaFile.spec.js b/spec/lib/readSchemaFile.spec.js index 9f2f29257039c964b7c9704c3a3f8bcf935d0d2c..813e4ec21bf7090f8c53ea02a44bf21d6097418b 100644 --- a/spec/lib/readSchemaFile.spec.js +++ b/spec/lib/readSchemaFile.spec.js @@ -1,26 +1,33 @@ -/** - * Copyright 2017 Adobe Systems Incorporated. All rights reserved. +/* + * Copyright 2019 Adobe. All rights reserved. * This file is licensed to you 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 REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. */ -var Promise = require('bluebird'); -var fs = Promise.promisifyAll(require('fs')); -var readSchemaFile = require('../../lib/readSchemaFile'); +/* eslint-env jasmine */ + +const Promise = require('bluebird'); +const fs = Promise.promisifyAll(require('fs')); +const readSchemaFile = require('../../lib/readSchemaFile'); describe('readSchemaFile module', () => { - var fakePath = 'some/path'; + const fakePath = 'some/path'; beforeEach(() => { spyOn(fs, 'readFileAsync').and.returnValue(Promise.resolve('{"schema":"yes"}')); }); describe('reading schema files without an $id key', () => { - it('should return a schema path map with path to the file as a key, and object value with path and json schema', done => { + it('should return a schema path map with path to the file as a key, and object value with path and json schema', (done) => { readSchemaFile({}, fakePath) - .then(map => { + .then((map) => { expect(map[fakePath]).toBeDefined(); expect(map[fakePath].filePath).toEqual(fakePath); - expect(map[fakePath].jsonSchema).toEqual({ schema:'yes' }); + expect(map[fakePath].jsonSchema).toEqual({ schema: 'yes' }); }) .catch(fail) .done(done); @@ -30,22 +37,22 @@ describe('readSchemaFile module', () => { beforeEach(() => { fs.readFileAsync.and.returnValue(Promise.resolve('{"$id":"allyourbase"}')); }); - it('should return a schema path map with $id value as a key, and object value with path and json schema', done => { + it('should return a schema path map with $id value as a key, and object value with path and json schema', (done) => { readSchemaFile({}, fakePath) - .then(map => { - expect(map['allyourbase']).toBeDefined(); - expect(map['allyourbase'].filePath).toEqual(fakePath); - expect(map['allyourbase'].jsonSchema).toEqual({ $id:'allyourbase' }); + .then((map) => { + expect(map.allyourbase).toBeDefined(); + expect(map.allyourbase.filePath).toEqual(fakePath); + expect(map.allyourbase.jsonSchema).toEqual({ $id: 'allyourbase' }); }) .catch(fail) .done(done); }); - it('should not overwrite the value for an existing $id key in the schema path map', done => { - readSchemaFile({ allyourbase:{} }, fakePath) - .then(map => { - expect(map['allyourbase']).toBeDefined(); - expect(map['allyourbase'].filePath).not.toBeDefined(); - expect(map['allyourbase'].jsonSchema).not.toBeDefined(); + it('should not overwrite the value for an existing $id key in the schema path map', (done) => { + readSchemaFile({ allyourbase: {} }, fakePath) + .then((map) => { + expect(map.allyourbase).toBeDefined(); + expect(map.allyourbase.filePath).not.toBeDefined(); + expect(map.allyourbase.jsonSchema).not.toBeDefined(); }) .catch(fail) .done(done); diff --git a/spec/lib/schema.spec.js b/spec/lib/schema.spec.js index 2d9e7b68173f3cd01ed921974641d0f91013a995..c05b17f4beb16280eaf6ae36b0243274abd3dcee 100644 --- a/spec/lib/schema.spec.js +++ b/spec/lib/schema.spec.js @@ -1,25 +1,32 @@ -/** - * Copyright 2017 Adobe Systems Incorporated. All rights reserved. +/* + * Copyright 2019 Adobe. All rights reserved. * This file is licensed to you 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 REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. */ -var Promise = require('bluebird'); -var fs = Promise.promisifyAll(require('fs')); -var schema = require('../../lib/schema'); +/* eslint-env jasmine */ + +const Promise = require('bluebird'); +const fs = Promise.promisifyAll(require('fs')); +const schema = require('../../lib/schema'); describe('schema module', () => { describe('getDescription method', () => { beforeEach(() => { spyOn(fs, 'readFileAsync'); }); - it('should read a description.md file based on provided file path and tack it onto a provided schema', done => { - var fakeContents = 'IMPORTANT CONTENTS!'; + it('should read a description.md file based on provided file path and tack it onto a provided schema', (done) => { + const fakeContents = 'IMPORTANT CONTENTS!'; fs.readFileAsync.and.returnValue(Promise.resolve(fakeContents)); - var skeem = {}; + const skeem = {}; schema.getDescription('/some/path', skeem) - .then(returnedSchema => { + .then((returnedSchema) => { expect(returnedSchema.description).toEqual(fakeContents); expect(skeem.description).toEqual(fakeContents); }).catch(() => { diff --git a/spec/lib/writeFiles.spec.js b/spec/lib/writeFiles.spec.js index 900d9564740d6a1525e53c6e69504f8447d83b98..509b07da3ae07e810127fcceb32656ffa5c1d244 100644 --- a/spec/lib/writeFiles.spec.js +++ b/spec/lib/writeFiles.spec.js @@ -1,12 +1,19 @@ -/** - * Copyright 2017 Adobe Systems Incorporated. All rights reserved. +/* + * Copyright 2019 Adobe. All rights reserved. * This file is licensed to you 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 REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. */ -var markdownWriter = require('../../lib/markdownWriter'); -var ejs = require('ejs'); +/* eslint-env jasmine */ + +const ejs = require('ejs'); +const markdownWriter = require('../../lib/markdownWriter'); describe('writeFiles module', () => { describe('generateMarkdown method', () => { @@ -14,8 +21,8 @@ describe('writeFiles module', () => { spyOn(ejs, 'renderFile'); }); it('should invoke ejs.renderFile with the topSchema ejs template', () => { - markdownWriter('somefile.schema.json', { '$id': 'myschema', 'my':'schema' }, 'some/path'); - var renderArgs = ejs.renderFile.calls.argsFor(0); + markdownWriter('somefile.schema.json', { $id: 'myschema', my: 'schema' }, 'some/path'); + const renderArgs = ejs.renderFile.calls.argsFor(0); expect(renderArgs); }); });