core logic for form8ion tools
npm install @form8ion/corecore logic for form8ion tools
[![Codecov][coverage-badge]][coverage-link]
[![Node CI Workflow Status][github-actions-ci-badge]][github-actions-ci-link]
![SLSA Level 2][slsa-badge]
* Usage
* Installation
* Example
* API
* fileExists
* directoryExists
* validateOptions
* schema (_required_)
* options (_required_)
* applyEnhancers
* results __object__ (_required_)
* enhancers __array__ (_required_)
* options __object__ (_required_)
* writeConfigFile
* path __string__ (_required_)
* name __string__ (_required_)
* config __object__ (_required_)
* format __string__ (_required_)
* Constants
* fileTypes
* Contributing
* Dependencies
* Verification
[![MIT license][license-badge]][license-link]
[![npm][npm-badge]][npm-link]
[![Try @form8ion/core on RunKit][runkit-badge]][runkit-link]
![node][node-badge]
``sh`
$ npm install @form8ion/core --save-prod
`javascript
import {directoryExists, fileExists} from '@form8ion/core';
(async () => {
await fileExists('path/to/some/expected/file');
await directoryExists('path/to/some/expected/directory');
})();
`
#### fileExists
wrapper around fs.promises.stat()
to determine whether a file exists at a given path.
#### directoryExists
wrapper around fs.promises.stat()
to determine whether a directory exists at a given path.
#### validateOptions
Validates provided options against a joi schema.
##### schema (_required_)
joi schema
##### options (_required_)
options to compare to the provided schema
#### 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 providedresults.test
The property is a predicate that determines if the enhancer islift
applicable to the current project.
The property processes the results if the test predicate returnstrue.
##### options __object__ (_required_)
Options to be provided to the test and lift functions of each enhancer.
#### writeConfigFile
Writes a config file to the file system in the chosen format
Takes a single options object as an argument, containing:
##### path __string__ (_required_)
Path to the folder (without a trailing slash) that will contain the file to be
written
##### name __string__ (_required_)
Name of the file (without an extension)
##### config __object__ (_required_)
The config details to be written to the file
##### format __string__ (_required_)
The format for the config file to be written in. The formats from the
fileTypes constants that are currently supported include
fileTypes.JSON and fileTypes.YAML.
An error is thrown for unsupported formats.
#### fileTypes
Constants defined to describe file types used in various form8ion tools
[![PRs Welcome][PRs-badge]][PRs-link]
[![Conventional Commits][commit-convention-badge]][commit-convention-link]
[![Commitizen friendly][commitizen-badge]][commitizen-link]
[![semantic-release][semantic-release-badge]][semantic-release-link]
[![Renovate][renovate-badge]][renovate-link]
`sh`
$ nvm install
$ npm install
`sh``
$ npm test
[PRs-link]: http://makeapullrequest.com
[PRs-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg
[commit-convention-link]: https://conventionalcommits.org
[commit-convention-badge]: https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg
[commitizen-link]: http://commitizen.github.io/cz-cli/
[commitizen-badge]: https://img.shields.io/badge/commitizen-friendly-brightgreen.svg
[semantic-release-link]: https://github.com/semantic-release/semantic-release
[semantic-release-badge]: https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release
[renovate-link]: https://renovatebot.com
[renovate-badge]: https://img.shields.io/badge/renovate-enabled-brightgreen.svg?logo=renovatebot
[coverage-link]: https://codecov.io/github/form8ion/core
[coverage-badge]: https://img.shields.io/codecov/c/github/form8ion/core?logo=codecov
[license-link]: LICENSE
[license-badge]: https://img.shields.io/github/license/form8ion/core.svg?logo=opensourceinitiative
[npm-link]: https://www.npmjs.com/package/@form8ion/core
[npm-badge]: https://img.shields.io/npm/v/@form8ion/core?logo=npm
[runkit-link]: https://npm.runkit.com/@form8ion/core
[runkit-badge]: https://badge.runkitcdn.com/@form8ion/core.svg
[github-actions-ci-link]: https://github.com/form8ion/core/actions?query=workflow%3A%22Node.js+CI%22+branch%3Amaster
[github-actions-ci-badge]: https://img.shields.io/github/actions/workflow/status/form8ion/core/node-ci.yml.svg?branch=master&logo=github
[node-badge]: https://img.shields.io/node/v/@form8ion/core?logo=node.js
[slsa-badge]: https://slsa.dev/images/gh-badge-level2.svg