diff --git a/README.md b/README.md index bda43d3..4bdc618 100644 --- a/README.md +++ b/README.md @@ -149,6 +149,8 @@ Este comando (`e`) es un CLI que se ejecuta en el contexto donde es ejecutado, o A.k.a: `executor.json` +![](docs/img/tool2.jpg) + Toda la magia se configura desde este archivo. Como mencione antes **no es necesario un proyecto "node"**, esta tool sirve para cualquier tipo de proyecto en el que quieras tener atajos de comandos. ## Json structure diff --git a/docs/img/tool2.jpg b/docs/img/tool2.jpg new file mode 100644 index 0000000..4a59e89 Binary files /dev/null and b/docs/img/tool2.jpg differ diff --git a/lib/builders.js b/lib/builders.js index 4d47366..38dca28 100644 --- a/lib/builders.js +++ b/lib/builders.js @@ -14,91 +14,6 @@ const buildConfig = (configDefault, config) => { }; -/** - * Interpolate all the inputs! - * - * Inputs in order: environment, predefined, template, shortcut - * And it allow to use nested object! (not for environment) - * - * Note: it can be changed to get better performance. - * - * @param config - * @returns {any} - */ -const buildInterpolateVariables = (config) => { - let shortcuts = config.shortcuts, - templates = config.templates || {}, - environments = config.environmentsRendered || [], - newShortcuts, newTemplates, newEnvironments; - - if (!shortcuts) { - throw new Error(messages.shortcuts.notFound); - } - - // copy structure to mutate in the easy way - newShortcuts = JSON.parse(JSON.stringify(shortcuts)); - newTemplates = JSON.parse(JSON.stringify(templates)); - - newEnvironments = _buildInterpolateEnvironmentVars(environments); - - // This is recursive and it is needed to pass on each stage - // to template - _buildInterpolateVariablesRecursive(newTemplates, newEnvironments); - _buildInterpolateVariablesRecursive(newTemplates, { predefined }); - _buildInterpolateVariablesRecursive(newTemplates, newTemplates); // yes to itself! - // to shortcuts - _buildInterpolateVariablesRecursive(newShortcuts, newEnvironments); - _buildInterpolateVariablesRecursive(newShortcuts, { predefined }); - _buildInterpolateVariablesRecursive(newShortcuts, newTemplates); - _buildInterpolateVariablesRecursive(newShortcuts, newShortcuts, true); // yes to itself! - - return newShortcuts; -}; - -/** - * It gets data from the external environment, and prepare it to use. - * - * @param environments - * @private - */ -const _buildInterpolateEnvironmentVars = (environments) => { - let environmentsToReturn = {}; - - environments.forEach(item => { - let key = Object.keys(item)[0]; - environmentsToReturn[key] = process.env[item[key]]; - }); - - return environmentsToReturn; -}; - -/** - * It does the magic recursively to replace the placeholders with values, even itself - * - * @param values are the data and you can use it so simple or you can mix with templates (by placeholders) - * @param templates are the reuse "snippet", you can use it on values and avoid to repeat your code! - * @param finalFlag at the final it will check if there are some placeholders without replaced - * @private - */ -const _buildInterpolateVariablesRecursive = (values, templates, finalFlag) => { - - Object.keys(values).forEach(item => { - - // be careful, it is a mutable object - if (isString(values[item])) { - values[item] = values[item].toTemplate(templates); - - if (finalFlag && values[item].match(/\${.+?}/g)) { - throw new Error(messages.templates.notFound.toTemplate({ template: values[item] })); - } - } else if (isObject(values[item]) && !isObjectEmpty(values[item])) { - _buildInterpolateVariablesRecursive(values[item], templates, finalFlag); - } else { - throw new Error(messages.templates.invalidFormat.toTemplate({ key: item, value: values[item] })); - } - }); -}; - /** * This build the command line joining all pieces recursively * @@ -108,7 +23,7 @@ const _buildInterpolateVariablesRecursive = (values, templates, finalFlag) => { */ const buildShortcutCommand = (shortcuts, shortcut) => { shortcut = shortcut.split(' '); - let log = messages.shortcut.notFoundFirstShortcut, + let log = messages.shortcut.notFoundFirstShortcut.toTemplate({shortcut}) + buildShortcutPossibilities(shortcuts), command = _buildShortcutRecursive(shortcuts, shortcut, log); // this add final arguments to the command line @@ -116,6 +31,28 @@ const buildShortcutCommand = (shortcuts, shortcut) => { return command; }; +/** + * This build the possibilities to use for output to user + * + * @param shortcuts + * @returns {string} + */ +const buildShortcutPossibilities = (shortcuts) => { + let r = ''; + + if (shortcuts) { + let shortcutsMap = Object.keys(shortcuts).map(item => { + return `"${item}"`; + }); + + if (shortcutsMap.length > 0) { + r = messages.shortcut.withoutArgumentsPossibleValues.toTemplate({ shortcuts: shortcutsMap.join(', ') }); + } + } + + return r; +}; + /** * The recursive method to chain the shortcut with its templates * @@ -135,11 +72,8 @@ const _buildShortcutRecursive = (shortcuts, shortcut, log) => { let log = messages.shortcut.notFound.toTemplate({ key }); - log += Object.keys(found).map(v => { - return ` "${v}"`; - }).join(','); - return _buildShortcutRecursive(found, shortcut, log); + return _buildShortcutRecursive(found, shortcut, log + buildShortcutPossibilities(found)); } return found; @@ -148,6 +82,6 @@ const _buildShortcutRecursive = (shortcuts, shortcut, log) => { module.exports = { buildConfig, - buildInterpolateVariables, - buildShortcutCommand + buildShortcutCommand, + buildShortcutPossibilities }; diff --git a/lib/command.js b/lib/command.js index 0b6e0ee..2f78ccc 100644 --- a/lib/command.js +++ b/lib/command.js @@ -1,7 +1,8 @@ const { validateAndBuildEnvironments, validateShortcut, validateShortcuts, validateTemplates, validateConfig } = require('./validators'); const { isTestRunning, setColors } = require('./utils'); -const { buildInterpolateVariables, buildShortcutCommand, buildConfig } = require('./builders'); +const { buildShortcutCommand, buildConfig, buildShortcutPossibilities } = require('./builders'); const { getConfigFromCWD } = require('./node'); +const { interpolateVariables } = require('./interpolate'); const { configDefault } = require('./defaults'); const { messages } = require('./i18n'); @@ -32,22 +33,14 @@ let buildCommandWithConfig = (shortcut, config) => { setColors(config.config); // validation tasks - let shortcutValid = validateShortcut(shortcut); + validateShortcut(shortcut, buildShortcutPossibilities(config.shortcuts)); validateConfig(config.config); config.environmentsRendered = validateAndBuildEnvironments(config.environments); validateTemplates(config.templates); validateShortcuts(config.shortcuts); - if(!shortcutValid) { - let shortcuts = Object.keys(config.shortcuts).map(item => { - return `"${item}"`; - }).join(', '); - - throw new Error(messages.shortcut.withoutArguments.toTemplate({shortcuts})); - } - // building tasks - config.shortcutsRendered = buildInterpolateVariables(config); + config.shortcutsRendered = interpolateVariables(config); let command = buildShortcutCommand(config.shortcutsRendered, shortcut).join(' '); diff --git a/lib/i18n.js b/lib/i18n.js index f880fbe..d563ec4 100644 --- a/lib/i18n.js +++ b/lib/i18n.js @@ -15,28 +15,29 @@ const messages = { } }, environments: { - invalidFormat: '[environments] The attribute "environments" should be an array with strings or simple object {key: value}' + invalidFormat: 'The attribute "environments" should be an array with strings or simple object {key: value}' }, config: { notFound: '"${fileName}" not found on this folder. Have you read the docs? Don\'t be lazy https://github.com/crystian/executor', - used: '[config] Config file used: "${configFileName}"', - invalidFormat: '[config] An invalid structure on config attribute', - invalidJson: '[config] Invalid json format on your configuration file: ${jsonFile}', - isNotAString: '[config] An invalid type on configuration file: "configFile" should be a string' + used: 'Config file used: "${configFileName}"', + invalidFormat: 'An invalid structure on config attribute', + invalidJson: 'Invalid json format on your configuration file: ${jsonFile}', + isNotAString: 'An invalid type on configuration file: "configFile" should be a string' }, templates: { - notFound: '[template] Key "${template}" not found (remember the order is important!)', - invalidData: '[template] The configurations of templates are invalid, should be an object or string', - invalidFormat: '[template] Invalid format, remember should be a pair key value (both should be strings): "${key}": "${value}"' + notFound: 'Key "${template}" not found (remember the order is important!)', + invalidData: 'The configurations of templates are invalid, should be an object or string', + invalidFormat: 'Invalid format, remember should be a pair key value (both should be strings): "${key}": "${value}"' }, shortcuts: { - notFound: '[shortcuts] The attribute "shortcuts" should exist and should be an object no empty.', - shouldBeAnObject: '[shortcuts] The attribute "shortcuts" should be an object, and the last attribute on it should be a string.' + notFound: 'The attribute "shortcuts" should exist and should be an object no empty.', + shouldBeAnObject: 'The attribute "shortcuts" should be an object, and the last attribute on it should be a string.' }, shortcut: { - withoutArguments: '[argument] coff coff ... and the "shortcut"?\nPossible shortcuts configured: ${shortcuts}', - notFoundFirstShortcut: '[argument] The "shortcut" does not found, check your spelling or your configuration file', - notFound: '[argument] The sub-arguments from "${key}" does not match with your configuration file, for your key you have the following arguments: ' + withoutArguments: 'coff coff ... and the "shortcut"?', + withoutArgumentsPossibleValues: '\n\nShortcuts configured: ${shortcuts}', + notFoundFirstShortcut: 'The shortcut: "${shortcut}" not found', + notFound: 'The sub-arguments from "${key}" does not match with your configuration file.' } }; diff --git a/lib/interpolate.js b/lib/interpolate.js new file mode 100644 index 0000000..51f622e --- /dev/null +++ b/lib/interpolate.js @@ -0,0 +1,94 @@ +const { isObject, isObjectEmpty, isString } = require('./utils'); +const { predefined } = require('./defaults'); +const { messages } = require('./i18n'); + + +/** + * Interpolate all the inputs! + * + * Inputs in order: environment, predefined, template, shortcut + * And it allow to use nested object! (not for environment) + * + * Note: it can be changed to get better performance. + * + * @param config + * @returns {any} + */ +const interpolateVariables = (config) => { + let shortcuts = config.shortcuts, + templates = config.templates || {}, + environments = config.environmentsRendered || [], + newShortcuts, newTemplates, newEnvironments; + + if (!shortcuts) { + throw new Error(messages.shortcuts.notFound); + } + + // copy structure to mutate in the easy way + newShortcuts = JSON.parse(JSON.stringify(shortcuts)); + newTemplates = JSON.parse(JSON.stringify(templates)); + + newEnvironments = _buildInterpolateEnvironmentVars(environments); + + // This is recursive and it is needed to pass on each stage + // to template + _buildInterpolateVariablesRecursive(newTemplates, newEnvironments); + _buildInterpolateVariablesRecursive(newTemplates, { predefined }); + _buildInterpolateVariablesRecursive(newTemplates, newTemplates); // yes to itself! + // to shortcuts + _buildInterpolateVariablesRecursive(newShortcuts, newEnvironments); + _buildInterpolateVariablesRecursive(newShortcuts, { predefined }); + _buildInterpolateVariablesRecursive(newShortcuts, newTemplates); + _buildInterpolateVariablesRecursive(newShortcuts, newShortcuts, true); // yes to itself! + + return newShortcuts; +}; + +/** + * It gets data from the external environment, and prepare it to use. + * + * @param environments + * @private + */ +const _buildInterpolateEnvironmentVars = (environments) => { + let environmentsToReturn = {}; + + environments.forEach(item => { + let key = Object.keys(item)[0]; + environmentsToReturn[key] = process.env[item[key]]; + }); + + return environmentsToReturn; +}; + +/** + * It does the magic recursively to replace the placeholders with values, even itself + * + * @param values are the data and you can use it so simple or you can mix with templates (by placeholders) + * @param templates are the reuse "snippet", you can use it on values and avoid to repeat your code! + * @param finalFlag at the final it will check if there are some placeholders without replaced + * @private + */ +const _buildInterpolateVariablesRecursive = (values, templates, finalFlag) => { + + Object.keys(values).forEach(item => { + + // be careful, it is a mutable object + if (isString(values[item])) { + values[item] = values[item].toTemplate(templates); + + if (finalFlag && values[item].match(/\${.+?}/g)) { + throw new Error(messages.templates.notFound.toTemplate({ template: values[item] })); + } + } else if (isObject(values[item]) && !isObjectEmpty(values[item])) { + _buildInterpolateVariablesRecursive(values[item], templates, finalFlag); + } else { + throw new Error(messages.templates.invalidFormat.toTemplate({ key: item, value: values[item] })); + } + }); +}; + + +module.exports = { + interpolateVariables +}; diff --git a/lib/node.js b/lib/node.js index 322e4d1..14d5c77 100644 --- a/lib/node.js +++ b/lib/node.js @@ -52,7 +52,7 @@ let getConfigFileName = (filePath) => { /* istanbul ignore if */ if (!isTestRunning()) { // it is ok, I can use "console.primary" because I don't have the configuration to finish with this - console.log('\x1b[37m%s\x1b[0m', `\n[${messages.app.name}]`, messages.config.used.toTemplate({configFileName})); + console.log('\x1b[37m%s\x1b[0m', `[${messages.app.name}]`, messages.config.used.toTemplate({configFileName})); } } diff --git a/lib/validators.js b/lib/validators.js index 18e53f9..8139cd4 100644 --- a/lib/validators.js +++ b/lib/validators.js @@ -5,9 +5,12 @@ const { messages } = require('./i18n'); * validate the input from the cli * * @param shortcut is the input from the user + * @param possibilities a string with possibilities to concatenate */ -const validateShortcut = (shortcut) => { - return !!(shortcut && shortcut !== '' && isString(shortcut)); +const validateShortcut = (shortcut, possibilities) => { + if (!(shortcut && shortcut !== '' && isString(shortcut))) { + throw new Error(messages.shortcut.withoutArguments + possibilities); + } }; diff --git a/package.json b/package.json index 34ceada..aadd355 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "executor", - "version": "0.0.8-beta", + "version": "0.0.9-beta", "license": "MIT", "description": "A powerful short-cutter to your console for you and your team", "scripts": { @@ -14,7 +14,7 @@ "devDependencies": { "chai": "4.1.2", "mocha": "5.1.1", - "nyc": "11.7.1" + "nyc": "11.7.3" }, "nyc": { "include": [ diff --git a/test/builders.spec.js b/test/builders.spec.js index 98448c3..609a901 100644 --- a/test/builders.spec.js +++ b/test/builders.spec.js @@ -1,5 +1,5 @@ const { assert } = require('chai'); -const { buildConfig, buildInterpolateVariables, buildShortcutCommand } = require('../lib/builders'); +const { buildConfig, buildShortcutCommand, buildShortcutPossibilities } = require('../lib/builders'); describe('buildConfig() results', function() { @@ -58,232 +58,6 @@ describe('buildConfig() results', function() { }); -describe('buildInterpolateVariables() throws', function() { - - // throws - - it('should throw an error by invalid arguments', function() { - assert.throw(() => { - let templates = { key1: [] }; - let shortcuts = templates; - let config = { templates, shortcuts }; - - buildInterpolateVariables(config); - }); - assert.throw(() => { - let templates = { key1: 1 }; - let shortcuts = templates; - let config = { templates, shortcuts }; - - buildInterpolateVariables(config); - }); - assert.throw(() => { - let templates = { key1: null }; - let shortcuts = templates; - let config = { templates, shortcuts }; - - buildInterpolateVariables(config); - }); - assert.throw(() => { - let templates = { key1: {} }; - let shortcuts = templates; - let config = { templates, shortcuts }; - - buildInterpolateVariables(config); - }); - }); - - it('should throw an error by key not found', function() { - assert.throw(() => { - let templates = { key1: 'value1 ${keyNotFound}' }; - let shortcuts = templates; - let config = { templates, shortcuts }; - - buildInterpolateVariables(config); - }); - }); - - it('should throw an error by not shortcuts loaded', function() { - assert.throw(() => { - let templates = { key1: 'value1 ${keyNotFound}' }; - let shortcuts = null; - let config = { templates, shortcuts }; - - buildInterpolateVariables(config); - }); - }); - - // does not throw - - it('should not throw an error by correct arguments', function() { - assert.doesNotThrow(() => { - let templates = { key1: 'value1', key2: 'value2' }; - let shortcuts = templates; - let config = { templates, shortcuts }; - - let r = buildInterpolateVariables(config); - - buildInterpolateVariables(config); - }); - }); -}); - -describe('buildInterpolateVariables() results', function() { - - it('should return a simple string without interpolate: 1 variable, 1 level', function() { - let templates = { template1: 'value1' }; - let shortcuts = { short1: 'short1s' }; - let config = { templates, shortcuts }; - - let r = buildInterpolateVariables(config); - - assert.hasAllKeys(r, ['short1']); - assert.equal(r.short1, 'short1s'); - }); - it('should return a simple string without interpolate: 2 variables, 1 level', function() { - let templates = { key1: 'value1', key2: 'value2' }; - let shortcuts = templates; - let config = { templates, shortcuts }; - - let r = buildInterpolateVariables(config); - - assert.hasAllKeys(r, ['key1', 'key2']); - assert.equal(r.key1, 'value1'); - assert.equal(r.key2, 'value2'); - }); - it('should return a simple string without interpolate: 1 variables, 2 level', function() { - let templates = { branchA: { branchAA: 'branchAAs' } }; - let shortcuts = templates; - let config = { templates, shortcuts }; - - let r = buildInterpolateVariables(config); - - assert.hasAllKeys(r, ['branchA']); - assert.deepNestedPropertyVal(r, 'branchA.branchAA', 'branchAAs'); - }); - - it('should interpolate variables: 1 variable, 1 level', function() { - let templates = { branchA: 'branchAs', branchB: '${branchA} branchBs' }; - let shortcuts = templates; - let config = { templates, shortcuts }; - - let r = buildInterpolateVariables(config); - - assert.equal(config.templates.branchB, '${branchA} branchBs'); - assert.equal(r.branchB, 'branchAs branchBs'); - }); - it('should interpolate variables: 1 variable, 1 level, 2 times', function() { - let templates = { branchA: 'branchAs', branchB: '${branchA} branchBs ${branchA}' }; - let shortcuts = templates; - let config = { templates, shortcuts }; - - let r = buildInterpolateVariables(config); - - assert.equal(config.templates.branchB, '${branchA} branchBs ${branchA}'); - assert.equal(r.branchB, 'branchAs branchBs branchAs'); - }); - it('should interpolate variables: 1 variable, 2 level', function() { - let templates = { branchA: { branchAA: 'branchAAs' }, branchB: { branchBB: '${branchA.branchAA} branchBBs' } }; - let shortcuts = templates; - let config = { templates, shortcuts }; - - let r = buildInterpolateVariables(config); - - assert.equal(templates.branchB.branchBB, '${branchA.branchAA} branchBBs'); - assert.equal(r.branchB.branchBB, 'branchAAs branchBBs'); - }); - - it('should interpolate variables: 1 variable, different sources: 2 level', function() { - let templates = { branchA: { branchAA: 'branchAAs' }, branchB: { branchBB: 'branchBBs' } }; - let shortcuts = { branchC: { branchCC: 'branchCCs' }, branchD: { branchDD: '${branchB.branchBB} branchDDs' } }; - let config = { templates, shortcuts }; - - let r = buildInterpolateVariables(config); - - assert.equal(shortcuts.branchD.branchDD, '${branchB.branchBB} branchDDs'); - assert.equal(r.branchD.branchDD, 'branchBBs branchDDs'); - }); - - it('should interpolate variables: 3 variables, same source: 1 level', function() { - let templates = { key1: 'value1', key2: '${key1} and value2', key3: '${key2} and value3', key4: 'without template' }; - let shortcuts = templates; - let config = { templates, shortcuts }; - - let r = buildInterpolateVariables(config); - - assert.hasAllKeys(r, ['key1', 'key2', 'key3', 'key4']); - assert.equal(r.key1, 'value1'); - assert.equal(r.key2, 'value1 and value2'); - assert.equal(r.key3, 'value1 and value2 and value3'); - assert.equal(r.key4, 'without template'); - }); - - it('should interpolate variables: 2 variables, between template and shortcuts: 1 level', function() { - let templates = { template1: 'value1', template2: '${template1} value2' }; - let shortcuts = { short1: '${template1} and short1s', short2: '${template1} and ${template2} and short1s' }; - let config = { templates, shortcuts }; - - let r = buildInterpolateVariables(config); - - assert.hasAllKeys(r, ['short1', 'short2']); - assert.equal(r.short1, 'value1 and short1s'); - assert.equal(r.short2, 'value1 and value1 value2 and short1s'); - }); - it('should interpolate variables: 2 variables, between template and shortcuts and itself: 1 level', function() { - let templates = { template1: 'value1', template2: 'value2', template3: 'value3' }; - let shortcuts = { short1: '${template1} and short1s', short2: '${template2} and ${template3} and ${short1}' }; - let config = { templates, shortcuts }; - - let r = buildInterpolateVariables(config); - - assert.hasAllKeys(r, ['short1', 'short2']); - assert.equal(r.short1, 'value1 and short1s'); - assert.equal(r.short2, 'value2 and value3 and value1 and short1s'); - }); - - it('should interpolate variables: 1 variable: 4 level', function() { - let templates = { branchA: { branchAA: { branchAAA: { branchAAAA: 'four As' } } } }; - let shortcuts = { short1: '${branchA.branchAA.branchAAA.branchAAAA} found' }; - let config = { templates, shortcuts }; - - let r = buildInterpolateVariables(config); - - assert.hasAllKeys(r, ['short1']); - assert.equal(r.short1, 'four As found'); - }); - it('should interpolate variables: 1 variable, 1 itself: 4 level', function() { - let templates = { branchA: { branchAA: { branchAAA: { branchAAAA: 'four As' } } } }; - let shortcuts = { short1: '${branchA.branchAA.branchAAA.branchAAAA} found', short2: '${short1} from other short' }; - let config = { templates, shortcuts }; - - let r = buildInterpolateVariables(config); - - assert.hasAllKeys(r, ['short1', 'short2']); - assert.equal(r.short1, 'four As found'); - assert.equal(r.short2, 'four As found from other short'); - }); - it('should interpolate variables: complex 1', function() { - let templates = { - branchA: { branchAA: { branchAAA: { branchAAAA: 'four As' } } }, - branchB: { branchBB: { branchBBB: { branchBBBB: 'four Bs and ${branchA.branchAA.branchAAA.branchAAAA}' } } } - }; - let shortcuts = { - short1: '${branchA.branchAA.branchAAA.branchAAAA} found', - short2: '${short1} from other short', - short3: 'from template B ${branchB.branchBB.branchBBB.branchBBBB} and from shortcuts ${short1}' - }; - let config = { templates, shortcuts }; - - let r = buildInterpolateVariables(config); - - assert.hasAllKeys(r, ['short1', 'short2', 'short3']); - assert.equal(r.short1, 'four As found'); - assert.equal(r.short2, 'four As found from other short'); - assert.equal(r.short3, 'from template B four Bs and four As and from shortcuts four As found'); - }); -}); - - describe('buildShortcutCommand() throws', function() { // throws @@ -408,3 +182,33 @@ describe('buildShortcutCommand() results', function() { assert.sameMembers(r, ['branchBBAs']); }); }); + + +describe('buildShortcutPosibilities() results', function() { + it('should return a string without possibilities', ()=>{ + let r = buildShortcutPossibilities(); + assert.equal(r, ''); + }); + it('should return a string without possibilities', ()=>{ + let r = buildShortcutPossibilities({}); + assert.equal(r, ''); + }); + it('should return a string without possibilities', ()=>{ + let r = buildShortcutPossibilities(1); + assert.equal(r, ''); + }); + it('should return a string without possibilities', ()=>{ + let r = buildShortcutPossibilities([]); + assert.equal(r, ''); + }); + + it('should return a string with a possibility', ()=>{ + let r = buildShortcutPossibilities({key1: 'key1'}); + assert.include(r, '"key1"'); + }); + it('should return a string with two possibility', ()=>{ + let r = buildShortcutPossibilities({key1: 'key1', key2: 'key2'}); + assert.include(r, '"key1"'); + assert.include(r, '"key2"'); + }); +}); diff --git a/test/interpolate.spec.js b/test/interpolate.spec.js new file mode 100644 index 0000000..64e0043 --- /dev/null +++ b/test/interpolate.spec.js @@ -0,0 +1,227 @@ +const { assert } = require('chai'); +const { interpolateVariables } = require('../lib/interpolate'); + +describe('interpolateVariables() throws', function() { + + // throws + + it('should throw an error by invalid arguments', function() { + assert.throw(() => { + let templates = { key1: [] }; + let shortcuts = templates; + let config = { templates, shortcuts }; + + interpolateVariables(config); + }); + assert.throw(() => { + let templates = { key1: 1 }; + let shortcuts = templates; + let config = { templates, shortcuts }; + + interpolateVariables(config); + }); + assert.throw(() => { + let templates = { key1: null }; + let shortcuts = templates; + let config = { templates, shortcuts }; + + interpolateVariables(config); + }); + assert.throw(() => { + let templates = { key1: {} }; + let shortcuts = templates; + let config = { templates, shortcuts }; + + interpolateVariables(config); + }); + }); + + it('should throw an error by key not found', function() { + assert.throw(() => { + let templates = { key1: 'value1 ${keyNotFound}' }; + let shortcuts = templates; + let config = { templates, shortcuts }; + + interpolateVariables(config); + }); + }); + + it('should throw an error by not shortcuts loaded', function() { + assert.throw(() => { + let templates = { key1: 'value1 ${keyNotFound}' }; + let shortcuts = null; + let config = { templates, shortcuts }; + + interpolateVariables(config); + }); + }); + + // does not throw + + it('should not throw an error by correct arguments', function() { + assert.doesNotThrow(() => { + let templates = { key1: 'value1', key2: 'value2' }; + let shortcuts = templates; + let config = { templates, shortcuts }; + + let r = interpolateVariables(config); + + interpolateVariables(config); + }); + }); +}); + +describe('interpolateVariables() results', function() { + + it('should return a simple string without interpolate: 1 variable, 1 level', function() { + let templates = { template1: 'value1' }; + let shortcuts = { short1: 'short1s' }; + let config = { templates, shortcuts }; + + let r = interpolateVariables(config); + + assert.hasAllKeys(r, ['short1']); + assert.equal(r.short1, 'short1s'); + }); + it('should return a simple string without interpolate: 2 variables, 1 level', function() { + let templates = { key1: 'value1', key2: 'value2' }; + let shortcuts = templates; + let config = { templates, shortcuts }; + + let r = interpolateVariables(config); + + assert.hasAllKeys(r, ['key1', 'key2']); + assert.equal(r.key1, 'value1'); + assert.equal(r.key2, 'value2'); + }); + it('should return a simple string without interpolate: 1 variables, 2 level', function() { + let templates = { branchA: { branchAA: 'branchAAs' } }; + let shortcuts = templates; + let config = { templates, shortcuts }; + + let r = interpolateVariables(config); + + assert.hasAllKeys(r, ['branchA']); + assert.deepNestedPropertyVal(r, 'branchA.branchAA', 'branchAAs'); + }); + + it('should interpolate variables: 1 variable, 1 level', function() { + let templates = { branchA: 'branchAs', branchB: '${branchA} branchBs' }; + let shortcuts = templates; + let config = { templates, shortcuts }; + + let r = interpolateVariables(config); + + assert.equal(config.templates.branchB, '${branchA} branchBs'); + assert.equal(r.branchB, 'branchAs branchBs'); + }); + it('should interpolate variables: 1 variable, 1 level, 2 times', function() { + let templates = { branchA: 'branchAs', branchB: '${branchA} branchBs ${branchA}' }; + let shortcuts = templates; + let config = { templates, shortcuts }; + + let r = interpolateVariables(config); + + assert.equal(config.templates.branchB, '${branchA} branchBs ${branchA}'); + assert.equal(r.branchB, 'branchAs branchBs branchAs'); + }); + it('should interpolate variables: 1 variable, 2 level', function() { + let templates = { branchA: { branchAA: 'branchAAs' }, branchB: { branchBB: '${branchA.branchAA} branchBBs' } }; + let shortcuts = templates; + let config = { templates, shortcuts }; + + let r = interpolateVariables(config); + + assert.equal(templates.branchB.branchBB, '${branchA.branchAA} branchBBs'); + assert.equal(r.branchB.branchBB, 'branchAAs branchBBs'); + }); + + it('should interpolate variables: 1 variable, different sources: 2 level', function() { + let templates = { branchA: { branchAA: 'branchAAs' }, branchB: { branchBB: 'branchBBs' } }; + let shortcuts = { branchC: { branchCC: 'branchCCs' }, branchD: { branchDD: '${branchB.branchBB} branchDDs' } }; + let config = { templates, shortcuts }; + + let r = interpolateVariables(config); + + assert.equal(shortcuts.branchD.branchDD, '${branchB.branchBB} branchDDs'); + assert.equal(r.branchD.branchDD, 'branchBBs branchDDs'); + }); + + it('should interpolate variables: 3 variables, same source: 1 level', function() { + let templates = { key1: 'value1', key2: '${key1} and value2', key3: '${key2} and value3', key4: 'without template' }; + let shortcuts = templates; + let config = { templates, shortcuts }; + + let r = interpolateVariables(config); + + assert.hasAllKeys(r, ['key1', 'key2', 'key3', 'key4']); + assert.equal(r.key1, 'value1'); + assert.equal(r.key2, 'value1 and value2'); + assert.equal(r.key3, 'value1 and value2 and value3'); + assert.equal(r.key4, 'without template'); + }); + + it('should interpolate variables: 2 variables, between template and shortcuts: 1 level', function() { + let templates = { template1: 'value1', template2: '${template1} value2' }; + let shortcuts = { short1: '${template1} and short1s', short2: '${template1} and ${template2} and short1s' }; + let config = { templates, shortcuts }; + + let r = interpolateVariables(config); + + assert.hasAllKeys(r, ['short1', 'short2']); + assert.equal(r.short1, 'value1 and short1s'); + assert.equal(r.short2, 'value1 and value1 value2 and short1s'); + }); + it('should interpolate variables: 2 variables, between template and shortcuts and itself: 1 level', function() { + let templates = { template1: 'value1', template2: 'value2', template3: 'value3' }; + let shortcuts = { short1: '${template1} and short1s', short2: '${template2} and ${template3} and ${short1}' }; + let config = { templates, shortcuts }; + + let r = interpolateVariables(config); + + assert.hasAllKeys(r, ['short1', 'short2']); + assert.equal(r.short1, 'value1 and short1s'); + assert.equal(r.short2, 'value2 and value3 and value1 and short1s'); + }); + + it('should interpolate variables: 1 variable: 4 level', function() { + let templates = { branchA: { branchAA: { branchAAA: { branchAAAA: 'four As' } } } }; + let shortcuts = { short1: '${branchA.branchAA.branchAAA.branchAAAA} found' }; + let config = { templates, shortcuts }; + + let r = interpolateVariables(config); + + assert.hasAllKeys(r, ['short1']); + assert.equal(r.short1, 'four As found'); + }); + it('should interpolate variables: 1 variable, 1 itself: 4 level', function() { + let templates = { branchA: { branchAA: { branchAAA: { branchAAAA: 'four As' } } } }; + let shortcuts = { short1: '${branchA.branchAA.branchAAA.branchAAAA} found', short2: '${short1} from other short' }; + let config = { templates, shortcuts }; + + let r = interpolateVariables(config); + + assert.hasAllKeys(r, ['short1', 'short2']); + assert.equal(r.short1, 'four As found'); + assert.equal(r.short2, 'four As found from other short'); + }); + it('should interpolate variables: complex 1', function() { + let templates = { + branchA: { branchAA: { branchAAA: { branchAAAA: 'four As' } } }, + branchB: { branchBB: { branchBBB: { branchBBBB: 'four Bs and ${branchA.branchAA.branchAAA.branchAAAA}' } } } + }; + let shortcuts = { + short1: '${branchA.branchAA.branchAAA.branchAAAA} found', + short2: '${short1} from other short', + short3: 'from template B ${branchB.branchBB.branchBBB.branchBBBB} and from shortcuts ${short1}' + }; + let config = { templates, shortcuts }; + + let r = interpolateVariables(config); + + assert.hasAllKeys(r, ['short1', 'short2', 'short3']); + assert.equal(r.short1, 'four As found'); + assert.equal(r.short2, 'four As found from other short'); + assert.equal(r.short3, 'from template B four Bs and four As and from shortcuts four As found'); + }); +}); diff --git a/test/validators.spec.js b/test/validators.spec.js index 8c5bc5f..c60f883 100644 --- a/test/validators.spec.js +++ b/test/validators.spec.js @@ -3,26 +3,27 @@ const { validateAndBuildEnvironments, validateConfig, validateTemplates, validat describe('validateShortcut() throws', function() { + // throws - // does not throw - it('should return a false value by empty arguments', function() { - assert.doesNotThrow(() => { - let r = validateShortcut(); - assert.equal(r, false); + it('should throw an error by empty arguments', function() { + assert.throw(() => { + validateShortcut(); }); - assert.doesNotThrow(() => { - let r = validateShortcut({}); - assert.equal(r, false); + }); + it('should throw an error by invalid arguments', function() { + assert.throw(() => { + validateShortcut({}); }); - assert.doesNotThrow(() => { - let r = validateShortcut(''); - assert.equal(r, false); + assert.throw(() => { + validateShortcut(''); }); - assert.doesNotThrow(() => { - let r = validateShortcut([]); - assert.equal(r, false); + assert.throw(() => { + validateShortcut([]); }); }); + + // does not throw + it('should not throw an error: 1 level', function() { assert.doesNotThrow(() => { validateShortcut('branchA'); diff --git a/yarn.lock b/yarn.lock index 033fe8a..f317d8b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -36,17 +36,11 @@ archy@^1.0.0: version "1.0.0" resolved "https://registry.npmjs.org/archy/-/archy-1.0.0.tgz#f9c8c13757cc1dd7bc379ac77b2c62a5c2868c40" -arr-diff@^2.0.0: - version "2.0.0" - resolved "https://registry.npmjs.org/arr-diff/-/arr-diff-2.0.0.tgz#8f3b827f955a8bd669697e4a4256ac3ceae356cf" - dependencies: - arr-flatten "^1.0.1" - arr-diff@^4.0.0: version "4.0.0" resolved "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz#d6461074febfec71e7e15235761a329a5dc7c520" -arr-flatten@^1.0.1, arr-flatten@^1.1.0: +arr-flatten@^1.1.0: version "1.1.0" resolved "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz#36048bbff4e7b47e136644316c99669ea5ae91f1" @@ -54,10 +48,6 @@ arr-union@^3.1.0: version "3.1.0" resolved "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz#e39b09aea9def866a8f206e288af63919bae39c4" -array-unique@^0.2.1: - version "0.2.1" - resolved "https://registry.npmjs.org/array-unique/-/array-unique-0.2.1.tgz#a1d97ccafcbc2625cc70fadceb36a50c58b01a53" - array-unique@^0.3.2: version "0.3.2" resolved "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz#a894b75d4bc4f6cd679ef3244a9fd8f46ae2d428" @@ -176,14 +166,6 @@ brace-expansion@^1.1.7: balanced-match "^1.0.0" concat-map "0.0.1" -braces@^1.8.2: - version "1.8.5" - resolved "https://registry.npmjs.org/braces/-/braces-1.8.5.tgz#ba77962e12dff969d6b76711e914b737857bf6a7" - dependencies: - expand-range "^1.8.1" - preserve "^0.2.0" - repeat-element "^1.1.2" - braces@^2.3.1: version "2.3.2" resolved "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz#5979fd3f14cd531565e5fa2df1abfff1dfaee729" @@ -439,12 +421,6 @@ execa@^0.7.0: signal-exit "^3.0.0" strip-eof "^1.0.0" -expand-brackets@^0.1.4: - version "0.1.5" - resolved "https://registry.npmjs.org/expand-brackets/-/expand-brackets-0.1.5.tgz#df07284e342a807cd733ac5af72411e581d1177b" - dependencies: - is-posix-bracket "^0.1.0" - expand-brackets@^2.1.4: version "2.1.4" resolved "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz#b77735e315ce30f6b6eff0f83b04151a22449622" @@ -457,12 +433,6 @@ expand-brackets@^2.1.4: snapdragon "^0.8.1" to-regex "^3.0.1" -expand-range@^1.8.1: - version "1.8.2" - resolved "https://registry.npmjs.org/expand-range/-/expand-range-1.8.2.tgz#a299effd335fe2721ebae8e257ec79644fc85337" - dependencies: - fill-range "^2.1.0" - extend-shallow@^2.0.1: version "2.0.1" resolved "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz#51af7d614ad9a9f610ea1bafbb989d6b1c56890f" @@ -476,12 +446,6 @@ extend-shallow@^3.0.0, extend-shallow@^3.0.2: assign-symbols "^1.0.0" is-extendable "^1.0.1" -extglob@^0.3.1: - version "0.3.2" - resolved "https://registry.npmjs.org/extglob/-/extglob-0.3.2.tgz#2e18ff3d2f49ab2765cec9023f011daa8d8349a1" - dependencies: - is-extglob "^1.0.0" - extglob@^2.0.4: version "2.0.4" resolved "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz#ad00fe4dc612a9232e8718711dc5cb5ab0285543" @@ -495,20 +459,6 @@ extglob@^2.0.4: snapdragon "^0.8.1" to-regex "^3.0.1" -filename-regex@^2.0.0: - version "2.0.1" - resolved "https://registry.npmjs.org/filename-regex/-/filename-regex-2.0.1.tgz#c1c4b9bee3e09725ddb106b75c1e301fe2f18b26" - -fill-range@^2.1.0: - version "2.2.3" - resolved "https://registry.npmjs.org/fill-range/-/fill-range-2.2.3.tgz#50b77dfd7e469bc7492470963699fe7a8485a723" - dependencies: - is-number "^2.1.0" - isobject "^2.0.0" - randomatic "^1.1.3" - repeat-element "^1.1.2" - repeat-string "^1.5.2" - fill-range@^4.0.0: version "4.0.0" resolved "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz#d544811d428f98eb06a63dc402d2403c328c38f7" @@ -539,16 +489,10 @@ find-up@^2.1.0: dependencies: locate-path "^2.0.0" -for-in@^1.0.1, for-in@^1.0.2: +for-in@^1.0.2: version "1.0.2" resolved "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80" -for-own@^0.1.4: - version "0.1.5" - resolved "https://registry.npmjs.org/for-own/-/for-own-0.1.5.tgz#5265c681a4f294dabbf17c9509b6763aa84510ce" - dependencies: - for-in "^1.0.1" - foreground-child@^1.5.3, foreground-child@^1.5.6: version "1.5.6" resolved "https://registry.npmjs.org/foreground-child/-/foreground-child-1.5.6.tgz#4fd71ad2dfde96789b980a5c0a295937cb2f5ce9" @@ -582,19 +526,6 @@ get-value@^2.0.3, get-value@^2.0.6: version "2.0.6" resolved "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz#dc15ca1c672387ca76bd37ac0a395ba2042a2c28" -glob-base@^0.3.0: - version "0.3.0" - resolved "https://registry.npmjs.org/glob-base/-/glob-base-0.3.0.tgz#dbb164f6221b1c0b1ccf82aea328b497df0ea3c4" - dependencies: - glob-parent "^2.0.0" - is-glob "^2.0.0" - -glob-parent@^2.0.0: - version "2.0.0" - resolved "https://registry.npmjs.org/glob-parent/-/glob-parent-2.0.0.tgz#81383d72db054fcccf5336daa902f182f6edbb28" - dependencies: - is-glob "^2.0.0" - glob@7.1.2, glob@^7.0.5, glob@^7.0.6: version "7.1.2" resolved "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15" @@ -756,16 +687,6 @@ is-descriptor@^1.0.0, is-descriptor@^1.0.2: is-data-descriptor "^1.0.0" kind-of "^6.0.2" -is-dotfile@^1.0.0: - version "1.0.3" - resolved "https://registry.npmjs.org/is-dotfile/-/is-dotfile-1.0.3.tgz#a6a2f32ffd2dfb04f5ca25ecd0f6b83cf798a1e1" - -is-equal-shallow@^0.1.3: - version "0.1.3" - resolved "https://registry.npmjs.org/is-equal-shallow/-/is-equal-shallow-0.1.3.tgz#2238098fc221de0bcfa5d9eac4c45d638aa1c534" - dependencies: - is-primitive "^2.0.0" - is-extendable@^0.1.0, is-extendable@^0.1.1: version "0.1.1" resolved "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89" @@ -776,10 +697,6 @@ is-extendable@^1.0.1: dependencies: is-plain-object "^2.0.4" -is-extglob@^1.0.0: - version "1.0.0" - resolved "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz#ac468177c4943405a092fc8f29760c6ffc6206c0" - is-finite@^1.0.0: version "1.0.2" resolved "https://registry.npmjs.org/is-finite/-/is-finite-1.0.2.tgz#cc6677695602be550ef11e8b4aa6305342b6d0aa" @@ -796,18 +713,6 @@ is-fullwidth-code-point@^2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f" -is-glob@^2.0.0, is-glob@^2.0.1: - version "2.0.1" - resolved "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz#d096f926a3ded5600f3fdfd91198cb0888c2d863" - dependencies: - is-extglob "^1.0.0" - -is-number@^2.1.0: - version "2.1.0" - resolved "https://registry.npmjs.org/is-number/-/is-number-2.1.0.tgz#01fcbbb393463a548f2f466cce16dece49db908f" - dependencies: - kind-of "^3.0.2" - is-number@^3.0.0: version "3.0.0" resolved "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz#24fd6201a4782cf50561c810276afc7d12d71195" @@ -830,14 +735,6 @@ is-plain-object@^2.0.1, is-plain-object@^2.0.3, is-plain-object@^2.0.4: dependencies: isobject "^3.0.1" -is-posix-bracket@^0.1.0: - version "0.1.1" - resolved "https://registry.npmjs.org/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz#3334dc79774368e92f016e6fbc0a88f5cd6e6bc4" - -is-primitive@^2.0.0: - version "2.0.0" - resolved "https://registry.npmjs.org/is-primitive/-/is-primitive-2.0.0.tgz#207bab91638499c07b2adf240a41a87210034575" - is-stream@^1.1.0: version "1.1.0" resolved "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" @@ -1017,31 +914,13 @@ mem@^1.1.0: dependencies: mimic-fn "^1.0.0" -merge-source-map@^1.0.2: +merge-source-map@^1.1.0: version "1.1.0" resolved "https://registry.npmjs.org/merge-source-map/-/merge-source-map-1.1.0.tgz#2fdde7e6020939f70906a68f2d7ae685e4c8c646" dependencies: source-map "^0.6.1" -micromatch@^2.3.11: - version "2.3.11" - resolved "https://registry.npmjs.org/micromatch/-/micromatch-2.3.11.tgz#86677c97d1720b363431d04d0d15293bd38c1565" - dependencies: - arr-diff "^2.0.0" - array-unique "^0.2.1" - braces "^1.8.2" - expand-brackets "^0.1.4" - extglob "^0.3.1" - filename-regex "^2.0.0" - is-extglob "^1.0.0" - is-glob "^2.0.1" - kind-of "^3.0.2" - normalize-path "^2.0.1" - object.omit "^2.0.0" - parse-glob "^3.0.4" - regex-cache "^0.4.2" - -micromatch@^3.1.8: +micromatch@^3.1.10, micromatch@^3.1.8: version "3.1.10" resolved "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz#70859bc95c9840952f359a068a3fc49f9ecfac23" dependencies: @@ -1136,12 +1015,6 @@ normalize-package-data@^2.3.2: semver "2 || 3 || 4 || 5" validate-npm-package-license "^3.0.1" -normalize-path@^2.0.1: - version "2.1.1" - resolved "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz#1ab28b556e198363a8c1a6f7e6fa20137fe6aed9" - dependencies: - remove-trailing-separator "^1.0.1" - npm-run-path@^2.0.0: version "2.0.2" resolved "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz#35a9232dfa35d7067b4cb2ddf2357b1871536c5f" @@ -1152,9 +1025,9 @@ number-is-nan@^1.0.0: version "1.0.1" resolved "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" -nyc@11.7.1: - version "11.7.1" - resolved "https://registry.npmjs.org/nyc/-/nyc-11.7.1.tgz#7cb0a422e501b88ff2c1634341dec2560299d67b" +nyc@11.7.3: + version "11.7.3" + resolved "https://registry.npmjs.org/nyc/-/nyc-11.7.3.tgz#164f4cfad84dee6d8f353824231d9dd683aa14ea" dependencies: archy "^1.0.0" arrify "^1.0.1" @@ -1173,11 +1046,11 @@ nyc@11.7.1: istanbul-lib-source-maps "^1.2.3" istanbul-reports "^1.4.0" md5-hex "^1.2.0" - merge-source-map "^1.0.2" - micromatch "^2.3.11" + merge-source-map "^1.1.0" + micromatch "^3.1.10" mkdirp "^0.5.0" resolve-from "^2.0.0" - rimraf "^2.5.4" + rimraf "^2.6.2" signal-exit "^3.0.1" spawn-wrap "^1.4.2" test-exclude "^4.2.0" @@ -1202,13 +1075,6 @@ object-visit@^1.0.0: dependencies: isobject "^3.0.0" -object.omit@^2.0.0: - version "2.0.1" - resolved "https://registry.npmjs.org/object.omit/-/object.omit-2.0.1.tgz#1a9c744829f39dbb858c76ca3579ae2a54ebd1fa" - dependencies: - for-own "^0.1.4" - is-extendable "^0.1.1" - object.pick@^1.3.0: version "1.3.0" resolved "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz#87a10ac4c1694bd2e1cbf53591a66141fb5dd747" @@ -1260,15 +1126,6 @@ p-try@^1.0.0: version "1.0.0" resolved "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz#cbc79cdbaf8fd4228e13f621f2b1a237c1b207b3" -parse-glob@^3.0.4: - version "3.0.4" - resolved "https://registry.npmjs.org/parse-glob/-/parse-glob-3.0.4.tgz#b2c376cfb11f35513badd173ef0bb6e3a388391c" - dependencies: - glob-base "^0.3.0" - is-dotfile "^1.0.0" - is-extglob "^1.0.0" - is-glob "^2.0.0" - parse-json@^2.2.0: version "2.2.0" resolved "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz#f480f40434ef80741f8469099f8dea18f55a4dc9" @@ -1337,21 +1194,10 @@ posix-character-classes@^0.1.0: version "0.1.1" resolved "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab" -preserve@^0.2.0: - version "0.2.0" - resolved "https://registry.npmjs.org/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b" - pseudomap@^1.0.2: version "1.0.2" resolved "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3" -randomatic@^1.1.3: - version "1.1.7" - resolved "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz#c7abe9cc8b87c0baa876b19fde83fd464797e38c" - dependencies: - is-number "^3.0.0" - kind-of "^4.0.0" - read-pkg-up@^1.0.1: version "1.0.1" resolved "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-1.0.1.tgz#9d63c13276c065918d57f002a57f40a1b643fb02" @@ -1371,12 +1217,6 @@ regenerator-runtime@^0.11.0: version "0.11.1" resolved "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9" -regex-cache@^0.4.2: - version "0.4.4" - resolved "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz#75bdc58a2a1496cec48a12835bc54c8d562336dd" - dependencies: - is-equal-shallow "^0.1.3" - regex-not@^1.0.0, regex-not@^1.0.2: version "1.0.2" resolved "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz#1f4ece27e00b0b65e0247a6810e6a85d83a5752c" @@ -1384,10 +1224,6 @@ regex-not@^1.0.0, regex-not@^1.0.2: extend-shallow "^3.0.2" safe-regex "^1.1.0" -remove-trailing-separator@^1.0.1: - version "1.1.0" - resolved "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz#c24bce2a283adad5bc3f58e0d48249b92379d8ef" - repeat-element@^1.1.2: version "1.1.2" resolved "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.2.tgz#ef089a178d1483baae4d93eb98b4f9e4e11d990a" @@ -1428,7 +1264,7 @@ right-align@^0.1.1: dependencies: align-text "^0.1.1" -rimraf@^2.5.4, rimraf@^2.6.1, rimraf@^2.6.2: +rimraf@^2.6.1, rimraf@^2.6.2: version "2.6.2" resolved "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36" dependencies: