πŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more β†’
Socket
Book a DemoInstallSign in
Socket

unified-engine

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unified-engine - npm Package Compare versions

Comparing version

to
10.0.0

29

lib/configuration.js

@@ -38,3 +38,3 @@ /**

import {pathToFileURL} from 'node:url'
import jsYaml from 'js-yaml'
import yaml from 'yaml'
import parseJson from 'parse-json'

@@ -203,4 +203,2 @@ import createDebug from 'debug'

// C8 bug on Node@12
/* c8 ignore next 2 */
return result

@@ -212,4 +210,2 @@ }

async function loadScriptOrModule(_, filePath) {
// C8 bug on Node@12
/* c8 ignore next 4 */
// @ts-expect-error: Assume it matches config.

@@ -221,7 +217,4 @@ // type-coverage:ignore-next-line

/** @type {Loader} */
async function loadYaml(buf, filePath) {
// C8 bug on Node@12
/* c8 ignore next 4 */
// @ts-expect-error: Assume it matches config.
return jsYaml.load(String(buf), {filename: path.basename(filePath)})
async function loadYaml(buf) {
return yaml.parse(String(buf))
}

@@ -234,4 +227,2 @@

// C8 bug on Node@12
/* c8 ignore next 8 */
// @ts-expect-error: Assume it matches config.

@@ -259,4 +250,2 @@ return path.basename(filePath) === 'package.json'

// C8 bug on Node@12
/* c8 ignore next 6 */
return target

@@ -281,4 +270,2 @@

target.settings = Object.assign({}, target.settings, result.settings)
// C8 bug on Node@12
/* c8 ignore next 6 */
}

@@ -302,4 +289,2 @@

}
// C8 bug on Node@12
/* c8 ignore next 6 */
}

@@ -321,4 +306,2 @@

}
// C8 bug on Node@12
/* c8 ignore next 7 */
}

@@ -338,4 +321,2 @@

}
// C8 bug on Node@12
/* c8 ignore next 7 */
}

@@ -383,4 +364,2 @@

}
// C8 bug on Node@12
/* c8 ignore next 8 */
}

@@ -455,4 +434,2 @@

return result.default
// C8 bug on Node@12
/* c8 ignore next 9 */
} catch (error) {

@@ -459,0 +436,0 @@ const exception = /** @type {Error} */ (error)

5

lib/file-pipeline/read.js

@@ -24,3 +24,6 @@ /**

if (file.value || file.data.unifiedEngineStreamIn) {
if (
(file.value !== null && file.value !== undefined) ||
file.data.unifiedEngineStreamIn
) {
debug('Not reading file `%s` with `value`', filePath)

@@ -27,0 +30,0 @@ next()

@@ -47,3 +47,3 @@ export class FileSet extends EventEmitter {

set: FileSet,
callback: (error?: Error | null | undefined) => void
callback: (error?: Error | null) => void
) => void

@@ -50,0 +50,0 @@ export type CompleterAsync = (set: FileSet) => Promise<void>

@@ -233,4 +233,2 @@ /**

file.fail('Cannot process specified file: it’s ignored')
// C8 bug on Node@12
/* c8 ignore next 1 */
} catch {}

@@ -244,4 +242,2 @@ }

)
// C8 bug on Node@12
/* c8 ignore next 1 */
} catch {}

@@ -290,3 +286,7 @@ }

if (typeof file === 'string' || !file.value) {
if (
typeof file === 'string' ||
file.value === null ||
file.value === undefined
) {
expected++

@@ -293,0 +293,0 @@ fs.stat(fp, (error, value) => {

@@ -31,4 +31,4 @@ /**

processor: Options['processor']
cwd: Exclude<Options['cwd'], undefined>
files: Exclude<Options['files'], undefined>
cwd: Exclude<Options['cwd'], undefined | URL>
files: Array<string | VFile>
extensions: Exclude<Options['extensions'], undefined>

@@ -81,7 +81,7 @@ streamIn: Exclude<Options['streamIn'], undefined>

*/
cwd?: string | undefined
cwd?: string | URL | undefined
/**
* Paths or globs to files and directories, or virtual files, to process.
*/
files?: (string | import('vfile').VFile)[] | undefined
files?: (string | import('vfile').VFile | URL)[] | undefined
/**

@@ -88,0 +88,0 @@ * If `files` matches directories, include `files` with `extensions`

@@ -24,4 +24,4 @@ /**

* @property {Options['processor']} processor
* @property {Exclude<Options['cwd'], undefined>} cwd
* @property {Exclude<Options['files'], undefined>} files
* @property {Exclude<Options['cwd'], undefined | URL>} cwd
* @property {Array<string|VFile>} files
* @property {Exclude<Options['extensions'], undefined>} extensions

@@ -66,6 +66,6 @@ * @property {Exclude<Options['streamIn'], undefined>} streamIn

* Unified processor to transform files
* @property {string} [cwd]
* @property {string|URL} [cwd]
* Directory to search files in, load plugins from, and more.
* Defaults to `process.cwd()`.
* @property {Array<string|VFile>} [files]
* @property {Array<string|URL|VFile>} [files]
* Paths or globs to files and directories, or virtual files, to process.

@@ -177,2 +177,3 @@ * @property {Array<string>} [extensions]

import {PassThrough} from 'node:stream'
import {fileURLToPath} from 'node:url'
import {statistics} from 'vfile-statistics'

@@ -220,6 +221,13 @@ import {fileSetPipeline} from './file-set-pipeline/index.js'

// Path to run as.
settings.cwd = options.cwd || process.cwd()
settings.cwd =
typeof options.cwd === 'object'
? fileURLToPath(options.cwd)
: options.cwd || process.cwd()
// Input.
settings.files = options.files || []
settings.files = (options.files || []).map((d) => {
return typeof d === 'object' && 'href' in d && !('path' in d)
? fileURLToPath(d)
: d
})
settings.extensions = (options.extensions || []).map((ext) =>

@@ -341,3 +349,3 @@ ext.charAt(0) === '.' ? ext : '.' + ext

// Process.
fileSetPipeline.run({files: options.files || []}, settings, next)
fileSetPipeline.run({files: settings.files}, settings, next)

@@ -344,0 +352,0 @@ /**

{
"name": "unified-engine",
"version": "9.1.0",
"version": "10.0.0",
"description": "Engine to process multiple files with unified",

@@ -35,3 +35,2 @@ "license": "MIT",

"@types/is-empty": "^1.0.0",
"@types/js-yaml": "^4.0.0",
"@types/node": "^17.0.0",

@@ -42,3 +41,3 @@ "@types/unist": "^2.0.0",

"fault": "^2.0.0",
"glob": "^7.0.0",
"glob": "^8.0.0",
"ignore": "^5.0.0",

@@ -48,4 +47,3 @@ "is-buffer": "^2.0.0",

"is-plain-obj": "^4.0.0",
"js-yaml": "^4.0.0",
"load-plugin": "^4.0.0",
"load-plugin": "^5.0.0",
"parse-json": "^6.0.0",

@@ -57,3 +55,4 @@ "to-vfile": "^7.0.0",

"vfile-reporter": "^7.0.0",
"vfile-statistics": "^2.0.0"
"vfile-statistics": "^2.0.0",
"yaml": "^2.0.0"
},

@@ -78,3 +77,3 @@ "devDependencies": {

"vfile-reporter-pretty": "^6.0.0",
"xo": "^0.48.0"
"xo": "^0.50.0"
},

@@ -81,0 +80,0 @@ "scripts": {

@@ -10,22 +10,48 @@ # unified-engine

Engine to process multiple files with [**unified**][unified], allowing users to
[configure][] from the file system.
**[unified][]** engine to process multiple files, lettings users [configure][]
from the file system.
## Projects
## Contents
The following projects wrap the engine:
* [What is this?](#what-is-this)
* [When should I use this?](#when-should-i-use-this)
* [Install](#install)
* [Use](#use)
* [API](#api)
* [`engine(options, callback)`](#engineoptions-callback)
* [Plugins](#plugins)
* [Configuration](#configuration)
* [Ignoring](#ignoring)
* [Types](#types)
* [Compatibility](#compatibility)
* [Security](#security)
* [Contribute](#contribute)
* [License](#license)
* [`unified-args`][args] β€” Create CLIs for processors
* [`unified-engine-gulp`][gulp] β€” Create Gulp plugins
* [`unified-engine-atom`][atom] β€” Create Atom Linters for processors
* [`unified-language-server`][language-server] β€” Create language servers for
processors
## What is this?
This package is the engine.
It’s what you use underneath when you use [`remark-cli`][remark-cli] or a
language server.
Compared to unified, this deals with multiple files, often from the file
system, and with configuration files and ignore files.
## When should I use this?
You typically use something that wraps this, such as:
* [`unified-args`][args]
β€” create CLIs
* [`unified-engine-gulp`][gulp]
β€” create Gulp plugins
* [`unified-language-server`][language-server]
β€” create language servers
You can use this to make such things.
## Install
This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c):
Node 12+ is needed to use it and it must be `import`ed instead of `require`d.
This package is [ESM only][esm].
In Node.js (version 14.14+, 16.0+, or 18.0+), install with [npm][]:
[npm][]:
```sh

@@ -38,3 +64,3 @@ npm install unified-engine

The following example processes all files in the current directory with a
Markdown extension with [**remark**][remark], allows [configuration][configure]
markdown extension with **[remark][]**, allows [configuration][configure]
from `.remarkrc` and `package.json` files, ignoring files from `.remarkignore`

@@ -44,2 +70,6 @@ files, and more.

```js
/**
* @typedef {import('unified-engine').Callback} Callback
*/
import {engine} from 'unified-engine'

@@ -62,2 +92,3 @@ import {remark} from 'remark'

/** @type {Callback} */
function done(error) {

@@ -68,16 +99,5 @@ if (error) throw error

## Contents
* [API](#api)
* [`engine(options, callback)`](#engineoptions-callback)
* [Plugins](#plugins)
* [Configuration](#configuration)
* [Ignoring](#ignoring)
* [Security](#security)
* [Contribute](#contribute)
* [License](#license)
## API
This package exports the following identifiers: `engine`.
This package exports the identifier `engine`.
There is no default export.

@@ -94,91 +114,92 @@

β€” unified processor to transform files
* [`cwd`][cwd] (`string`, default: `process.cwd()`)
β€” Directory to search files in, load plugins from, and more
* [`files`][files] (`Array<string|VFile>`, optional)
β€” Paths or globs to files and directories, or virtual files, to process
* [`cwd`][cwd] (`string` or `URL`, default: `process.cwd()`)
β€” directory to search files in, load plugins from, and more
* [`files`][files] (`Array<string|URL|VFile>`, optional)
β€” paths or globs to files and directories, virtual files, or URLs, to
process
* [`extensions`][extensions] (`Array<string>`, optional)
β€” If `files` matches directories, include files with `extensions`
β€” if `files` matches directories, include files with `extensions`
* [`streamIn`][stream-in] (`ReadableStream`, default: `process.stdin`)
β€” Stream to read from if no files are found or given
β€” stream to read from if no files are found or given
* [`filePath`][file-path] (`string`, optional)
β€” File path to process the given file on `streamIn` as
β€” file path to process the given file on `streamIn` as
* [`streamOut`][stream-out] (`WritableStream`, default: `process.stdout`)
β€” Stream to write processed files to
β€” stream to write processed files to
* [`streamError`][stream-error] (`WritableStream`, default: `process.stderr`)
β€” Stream to write the report (if any) to
β€” stream to write the report (if any) to
* [`out`][out] (`boolean`, default: depends)
β€” Whether to write the processed file to `streamOut`
β€” whether to write the processed file to `streamOut`
* [`output`][output] (`boolean` or `string`, default: `false`)
β€” Whether to write successfully processed files, and where to
β€” whether to write successfully processed files, and where to
* [`alwaysStringify`][always-stringify] (`boolean`, default: `false`)
β€” Whether to always serialize successfully processed files
β€” whether to always serialize successfully processed files
* [`tree`][tree] (`boolean`, default: `false`)
β€” Whether to treat both input and output as a syntax tree
β€” whether to treat both input and output as a syntax tree
* [`treeIn`][tree-in] (`boolean`, default: `tree`)
β€” Whether to treat input as a syntax tree
β€” whether to treat input as a syntax tree
* [`treeOut`][tree-out] (`boolean`, default: `tree`)
β€” Whether to treat output as a syntax tree
β€” whether to treat output as a syntax tree
* [`inspect`][inspect] (`boolean`, default: `false`)
β€” Whether to output a formatted syntax tree
β€” whether to output a formatted syntax tree
* [`rcName`][rc-name] (`string`, optional)
β€” Name of configuration files to load
β€” wame of configuration files to load
* [`packageField`][package-field] (`string`, optional)
β€” Property at which configuration can be found in `package.json` files
β€” property at which configuration can be found in `package.json` files
* [`detectConfig`][detect-config] (`boolean`, default: whether `rcName` or
`packageField` is given)
β€” Whether to search for configuration files
β€” whether to search for configuration files
* [`rcPath`][rc-path] (`string`, optional)
β€” Filepath to a configuration file to load
β€” filepath to a configuration file to load
* [`settings`][settings] (`Object`, optional)
β€” Configuration for the parser and compiler of the processor
β€” configuration for the parser and compiler of the processor
* [`ignoreName`][ignore-name] (`string`, optional)
β€” Name of ignore files to load
β€” name of ignore files to load
* [`detectIgnore`][detect-ignore] (`boolean`, default: whether `ignoreName`
is given)
β€” Whether to search for ignore files
β€” whether to search for ignore files
* [`ignorePath`][ignore-path] (`string`, optional)
β€” Filepath to an ignore file to load
β€” filepath to an ignore file to load
* [`ignorePathResolveFrom`][ignore-path-resolve-from] (`'dir'` or `'cwd'`,
default: `'dir'`)
β€” Resolve patterns in `ignorePath` from the current working directory or the
β€” resolve patterns in `ignorePath` from the current working directory or the
file’s directory
* [`ignorePatterns`][ignore-patterns] (`Array<string>`, optional)
β€” Patterns to ignore in addition to ignore files, if any
β€” patterns to ignore in addition to ignore files, if any
* [`ignoreUnconfigured`][ignore-unconfigured] (`boolean`, default: `false`)
β€” Ignore files that do not have an associated detected configuration file
β€” ignore files that do not have an associated detected configuration file
* [`silentlyIgnore`][silently-ignore] (`boolean`, default: `false`)
β€” Skip given files if they are ignored
β€” skip given files if they are ignored
* [`plugins`][options-plugins] (`Array|Object`, optional)
β€” Plugins to use
β€” plugins to use
* [`pluginPrefix`][plugin-prefix] (`string`, optional)
β€” Optional prefix to use when searching for plugins
β€” optional prefix to use when searching for plugins
* [`configTransform`][config-transform] (`Function`, optional)
β€” Transform config files from a different schema
β€” transform config files from a different schema
* [`reporter`][reporter] (`string` or `function`, default:
`import {reporter} from 'vfile-reporter'`)
β€” Reporter to use
β€” reporter to use
* [`reporterOptions`][reporteroptions] (`Object?`, optional)
β€” Config to pass to the used reporter
β€” config to pass to the used reporter
* [`color`][color] (`boolean`, default: `false`)
β€” Whether to report with ANSI color sequences
β€” whether to report with ANSI color sequences
* [`silent`][silent] (`boolean`, default: `false`)
β€” Report only fatal errors
β€” report only fatal errors
* [`quiet`][quiet] (`boolean`, default: `silent`)
β€” Do not report successful files
β€” do not report successful files
* [`frail`][frail] (`boolean`, default: `false`)
β€” Call back with an unsuccessful (`1`) code on warnings as well as errors
β€” call back with an unsuccessful (`1`) code on warnings as well as errors
#### `function callback(error[, code, context])`
Called when processing is complete, either with a fatal error if processing went
horribly wrong (probably due to incorrect configuration), or a status code and
the processing context.
Called when processing is complete, either with a fatal error if processing
went horribly wrong (probably due to incorrect configuration on your part as a
developer), or a status code and the processing context.
###### Parameters
* `error` (`Error`) β€” Fatal error
* `code` (`number`) β€” Either `0` if successful, or `1` if unsuccessful.
The latter occurs if [fatal][] errors happen when processing individual
* `error` (`Error`) β€” fatal error
* `code` (`number`) β€” either `0` if successful, or `1` if unsuccessful,
the latter occurs if [fatal][] errors happen when processing individual
files, or if [`frail`][frail] is set and warnings occur
* `context` (`Object`) β€” Processing context, containing internally used
* `context` (`Object`) β€” processing context, containing internally used
information and a `files` array with the processed files

@@ -200,2 +221,26 @@

## Types
This package is fully typed with [TypeScript][].
It additionally exports the following types:
* `VFileReporterOptions` β€” models options passed to vfile reporters
* `VFileReporter` β€” models the signature accepted as a vfile reporter
* `FileSet` β€” models what is passed to plugins as a second parameter
* `Completer` β€” models file set plugins
* `ResolveFrom` β€” models the enum allowed for `options.ignorePathResolveFrom`
* `ConfigTransform` β€” models the signature of `options.configTransform`
* `Preset` β€” models a preset, like `Preset` from `unified` but accepts
strings
* `Options` β€” models configuration
* `Context` β€” models the third parameter to `callback`
* `Callback` β€” models the signature of `callback`
## Compatibility
Projects maintained by the unified collective are compatible with all maintained
versions of Node.js.
As of now, that is Node.js 14.14+, 16.0+, and 18.0+.
Our projects sometimes work with older versions, but this is not guaranteed.
## Security

@@ -249,9 +294,13 @@

[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
[typescript]: https://www.typescriptlang.org
[health]: https://github.com/unifiedjs/.github
[contributing]: https://github.com/unifiedjs/.github/blob/HEAD/contributing.md
[contributing]: https://github.com/unifiedjs/.github/blob/main/contributing.md
[support]: https://github.com/unifiedjs/.github/blob/HEAD/support.md
[support]: https://github.com/unifiedjs/.github/blob/main/support.md
[coc]: https://github.com/unifiedjs/.github/blob/HEAD/code-of-conduct.md
[coc]: https://github.com/unifiedjs/.github/blob/main/code-of-conduct.md

@@ -352,4 +401,2 @@ [license]: license

[atom]: https://github.com/unifiedjs/unified-engine-atom
[gulp]: https://github.com/unifiedjs/unified-engine-gulp

@@ -360,1 +407,3 @@

[args]: https://github.com/unifiedjs/unified-args
[remark-cli]: https://github.com/remarkjs/remark/tree/main/packages/remark-cli#readme