@form8ion/core
Advanced tools
Comparing version 1.4.2 to 1.5.0
@@ -8,2 +8,4 @@ 'use strict'; | ||
var spdxLicenseList = require('spdx-license-list/simple'); | ||
var deepmerge = require('deepmerge'); | ||
var cliMessages = require('@travi/cli-messages'); | ||
@@ -13,2 +15,3 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var spdxLicenseList__default = /*#__PURE__*/_interopDefaultLegacy(spdxLicenseList); | ||
var deepmerge__default = /*#__PURE__*/_interopDefaultLegacy(deepmerge); | ||
@@ -76,3 +79,3 @@ async function exists (path) { | ||
when: licenseChoicesShouldBePresented, | ||
choices: Array.from(spdxLicenseList__default['default']), | ||
choices: Array.from(spdxLicenseList__default["default"]), | ||
default: 'MIT' | ||
@@ -109,2 +112,62 @@ }, { | ||
function ownKeys(object, enumerableOnly) { | ||
var keys = Object.keys(object); | ||
if (Object.getOwnPropertySymbols) { | ||
var symbols = Object.getOwnPropertySymbols(object); | ||
enumerableOnly && (symbols = symbols.filter(function (sym) { | ||
return Object.getOwnPropertyDescriptor(object, sym).enumerable; | ||
})), keys.push.apply(keys, symbols); | ||
} | ||
return keys; | ||
} | ||
function _objectSpread2(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = null != arguments[i] ? arguments[i] : {}; | ||
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { | ||
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); | ||
}); | ||
} | ||
return target; | ||
} | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
} | ||
async function enhancerApplier ({ | ||
results, | ||
enhancers = {}, | ||
options | ||
}) { | ||
cliMessages.info('Applying Enhancers'); | ||
return Object.values(enhancers).reduce(async (acc, enhancer) => { | ||
if (await enhancer.test(options)) { | ||
const previousResults = await acc; | ||
return deepmerge__default["default"](previousResults, await enhancer.lift(_objectSpread2({ | ||
results: previousResults | ||
}, options))); | ||
} | ||
return acc; | ||
}, results); | ||
} | ||
exports.applyEnhancers = enhancerApplier; | ||
exports.directoryExists = directoryExists; | ||
@@ -111,0 +174,0 @@ exports.fileExists = fileExists; |
import { promises } from 'fs'; | ||
import { basename } from 'path'; | ||
import spdxLicenseList from 'spdx-license-list/simple'; | ||
import deepmerge from 'deepmerge'; | ||
import { info } from '@travi/cli-messages'; | ||
@@ -98,3 +100,62 @@ async function exists (path) { | ||
export { directoryExists, fileExists, questionNames, questionsForBaseDetails }; | ||
function ownKeys(object, enumerableOnly) { | ||
var keys = Object.keys(object); | ||
if (Object.getOwnPropertySymbols) { | ||
var symbols = Object.getOwnPropertySymbols(object); | ||
enumerableOnly && (symbols = symbols.filter(function (sym) { | ||
return Object.getOwnPropertyDescriptor(object, sym).enumerable; | ||
})), keys.push.apply(keys, symbols); | ||
} | ||
return keys; | ||
} | ||
function _objectSpread2(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = null != arguments[i] ? arguments[i] : {}; | ||
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { | ||
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); | ||
}); | ||
} | ||
return target; | ||
} | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
} | ||
async function enhancerApplier ({ | ||
results, | ||
enhancers = {}, | ||
options | ||
}) { | ||
info('Applying Enhancers'); | ||
return Object.values(enhancers).reduce(async (acc, enhancer) => { | ||
if (await enhancer.test(options)) { | ||
const previousResults = await acc; | ||
return deepmerge(previousResults, await enhancer.lift(_objectSpread2({ | ||
results: previousResults | ||
}, options))); | ||
} | ||
return acc; | ||
}, results); | ||
} | ||
export { enhancerApplier as applyEnhancers, directoryExists, fileExists, questionNames, questionsForBaseDetails }; | ||
//# sourceMappingURL=index.es.js.map |
@@ -5,3 +5,3 @@ { | ||
"license": "MIT", | ||
"version": "1.4.2", | ||
"version": "1.5.0", | ||
"files": [ | ||
@@ -43,41 +43,43 @@ "example.js", | ||
"prepack": "run-s build", | ||
"test:unit": "nyc run-s test:unit:base", | ||
"coverage:report": "nyc report --reporter=text-lcov > coverage.lcov && codecov", | ||
"test:unit": "cross-env NODE_ENV=test c8 run-s test:unit:base", | ||
"test:unit:base": "DEBUG=any mocha 'src/**/*-test.js'", | ||
"lint:peer": "npm ls >/dev/null" | ||
"lint:peer": "npm ls >/dev/null", | ||
"prepare": "husky install" | ||
}, | ||
"devDependencies": { | ||
"@babel/register": "7.12.10", | ||
"@form8ion/babel-preset": "1.6.41", | ||
"@form8ion/commitlint-config": "1.0.14", | ||
"@form8ion/eslint-config": "1.7.5", | ||
"@babel/register": "7.16.9", | ||
"@cucumber/cucumber": "7.3.2", | ||
"@form8ion/babel-preset": "1.6.75", | ||
"@form8ion/commitlint-config": "1.0.26", | ||
"@form8ion/eslint-config": "2.0.3", | ||
"@form8ion/eslint-config-cucumber": "1.4.0", | ||
"@form8ion/eslint-config-mocha": "1.2.9", | ||
"@form8ion/remark-lint-preset": "1.0.11", | ||
"@rollup/plugin-babel": "5.2.2", | ||
"@travi/any": "2.0.15", | ||
"ban-sensitive-files": "1.9.14", | ||
"chai": "4.2.0", | ||
"codecov": "3.8.1", | ||
"cucumber": "6.0.5", | ||
"@form8ion/eslint-config-mocha": "1.2.16", | ||
"@form8ion/remark-lint-preset": "2.1.7", | ||
"@rollup/plugin-babel": "5.3.0", | ||
"@travi/any": "2.0.19", | ||
"ban-sensitive-files": "1.9.16", | ||
"c8": "7.11.0", | ||
"chai": "4.3.4", | ||
"cross-env": "7.0.3", | ||
"cz-conventional-changelog": "3.3.0", | ||
"gherkin-lint": "4.1.3", | ||
"husky": "5.0.6", | ||
"lockfile-lint": "4.3.7", | ||
"mocha": "8.2.1", | ||
"mock-fs": "4.13.0", | ||
"gherkin-lint": "4.2.2", | ||
"husky": "7.0.4", | ||
"lockfile-lint": "4.6.2", | ||
"mocha": "9.1.3", | ||
"mock-fs": "5.1.2", | ||
"npm-run-all": "4.1.5", | ||
"nyc": "15.1.0", | ||
"package-preview": "3.0.0", | ||
"remark-cli": "9.0.0", | ||
"remark-toc": "7.0.0", | ||
"remark-usage": "9.0.0", | ||
"package-preview": "4.0.0", | ||
"remark-cli": "10.0.1", | ||
"remark-toc": "8.0.1", | ||
"remark-usage": "10.0.1", | ||
"rimraf": "3.0.2", | ||
"rollup": "2.38.0", | ||
"rollup": "2.63.0", | ||
"rollup-plugin-auto-external": "2.0.0", | ||
"sinon": "9.2.4" | ||
"sinon": "12.0.1" | ||
}, | ||
"dependencies": { | ||
"@travi/cli-messages": "^1.0.5", | ||
"deepmerge": "^4.2.2", | ||
"spdx-license-list": "6.4.0" | ||
} | ||
} |
@@ -63,2 +63,28 @@ # core | ||
#### `applyEnhancers` | ||
Processes scaffolding results by applying a list of enhancers (lifters) as a | ||
chain, returning the enhanced results. | ||
Each enhancer is applied conditionally, based on the results of the predicate | ||
supplied with each enhancer. | ||
Takes a single options object as an argument, containing: | ||
##### `results` __object__ (_required_) | ||
Result object from scaffolder execution | ||
##### `enhancers` __array__ (_required_) | ||
List of plugins with `lift` and `test` properties for processing the provided | ||
`results`. | ||
The `test` property is a predicate that determines if the enhancer is | ||
applicable to the current project. | ||
The `lift` property processes the `results` if the `test` predicate returns | ||
`true`. | ||
##### `options` __object__ (_required_) | ||
Options to be provided to the `test` and `lift` functions of each enhancer. | ||
## Contributing | ||
@@ -65,0 +91,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
35889
292
153
3
+ Added@travi/cli-messages@^1.0.5
+ Addeddeepmerge@^4.2.2
+ Added@travi/cli-messages@1.1.1(transitive)
+ Addedansi-styles@4.3.0(transitive)
+ Addedchalk@4.1.2(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addeddeepmerge@4.3.1(transitive)
+ Addedhas-flag@4.0.0(transitive)
+ Addedis-unicode-supported@0.1.0(transitive)
+ Addedlog-symbols@4.1.0(transitive)
+ Addedsupports-color@7.2.0(transitive)