remark-cli
Advanced tools
Comparing version 11.0.0 to 12.0.0
57
cli.js
#!/usr/bin/env node | ||
import {createRequire} from 'node:module' | ||
/** | ||
* @typedef Pack | ||
* @property {string} name | ||
* @property {string} version | ||
* @property {string} description | ||
*/ | ||
import fs from 'node:fs/promises' | ||
import {resolve} from 'import-meta-resolve' | ||
import markdownExtensions from 'markdown-extensions' | ||
import {remark} from 'remark' | ||
import {args} from 'unified-args' | ||
import {remark} from 'remark' | ||
const require = createRequire(import.meta.url) | ||
/** @type {Pack} */ | ||
const proc = JSON.parse( | ||
String( | ||
await fs.readFile( | ||
new URL('package.json', resolve('remark', import.meta.url)) | ||
) | ||
) | ||
) | ||
const proc = require('remark/package.json') | ||
const cli = require('./package.json') | ||
/** @type {Pack} */ | ||
const cli = JSON.parse( | ||
String(await fs.readFile(new URL('package.json', import.meta.url))) | ||
) | ||
// To do: enable `markdown-extensions` once it supports ESM. | ||
const extensions = [ | ||
'md', | ||
'markdown', | ||
'mdown', | ||
'mkdn', | ||
'mkd', | ||
'mdwn', | ||
'mkdown', | ||
'ron' | ||
] | ||
args({ | ||
description: cli.description, | ||
extensions: markdownExtensions, | ||
ignoreName: '.' + proc.name + 'ignore', | ||
name: proc.name, | ||
packageField: proc.name + 'Config', | ||
pluginPrefix: proc.name, | ||
processor: remark, | ||
name: proc.name, | ||
description: cli.description, | ||
rcName: '.' + proc.name + 'rc', | ||
version: [ | ||
proc.name + ': ' + proc.version, | ||
cli.name + ': ' + cli.version | ||
].join(', '), | ||
pluginPrefix: proc.name, | ||
packageField: proc.name + 'Config', | ||
rcName: '.' + proc.name + 'rc', | ||
ignoreName: '.' + proc.name + 'ignore', | ||
extensions | ||
].join(', ') | ||
}) |
{ | ||
"name": "remark-cli", | ||
"version": "11.0.0", | ||
"description": "Command line interface to inspect and change markdown files with remark", | ||
"version": "12.0.0", | ||
"description": "CLI to process markdown with remark", | ||
"license": "MIT", | ||
"keywords": [ | ||
"unified", | ||
"remark", | ||
"bin", | ||
"cli", | ||
"markdown", | ||
"mdast", | ||
"cli", | ||
"bin" | ||
"remark", | ||
"unified" | ||
], | ||
@@ -26,3 +26,3 @@ "homepage": "https://remark.js.org", | ||
"type": "module", | ||
"main": "index.js", | ||
"exports": [], | ||
"bin": { | ||
@@ -35,16 +35,17 @@ "remark": "cli.js" | ||
"dependencies": { | ||
"remark": "^14.0.0", | ||
"unified-args": "^10.0.0" | ||
"import-meta-resolve": "^3.0.0", | ||
"markdown-extensions": "^2.0.0", | ||
"remark": "^15.0.0", | ||
"unified-args": "^11.0.0" | ||
}, | ||
"scripts": { | ||
"build": "rimraf \"*.d.ts\" && tsc && type-coverage", | ||
"test": "node --conditions development test.js" | ||
}, | ||
"xo": false, | ||
"scripts": {}, | ||
"typeCoverage": { | ||
"atLeast": 100, | ||
"detail": true, | ||
"strict": true, | ||
"ignoreCatch": true | ||
"ignoreCatch": true, | ||
"strict": true | ||
}, | ||
"xo": { | ||
"prettier": true | ||
} | ||
} |
110
readme.md
@@ -32,6 +32,5 @@ # remark-cli | ||
or in npm scripts and the like to inspect and change markdown files. | ||
This CLI is built around remark, which is a very popular ecosystem of plugins | ||
that work with markdown as structured data, specifically ASTs (abstract syntax | ||
trees). | ||
You can choose from the 150+ plugins that already exist or make your own. | ||
This CLI is built around remark, which is an ecosystem of plugins that work with | ||
markdown as structured data, specifically ASTs (abstract syntax trees). | ||
You can choose from the 150+ existing plugins or make your own. | ||
@@ -50,4 +49,4 @@ See [the monorepo readme][remark] for info on what the remark ecosystem is. | ||
This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c). | ||
In Node.js (version 14.14+, or 16.0+), install with [npm][]: | ||
This package is [ESM only][esm]. | ||
In Node.js (version 16+), install with [npm][]: | ||
@@ -63,3 +62,3 @@ ```sh | ||
```sh | ||
remark readme.md --use remark-toc --output | ||
remark readme.md --output --use remark-toc | ||
``` | ||
@@ -86,27 +85,28 @@ | ||
--[no-]color specify color in report (on by default) | ||
--[no-]config search for configuration files (on by default) | ||
-e --ext <extensions> specify extensions | ||
--file-path <path> specify path to process as | ||
-f --frail exit with 1 on warnings | ||
-h --help output usage information | ||
-v --version output version number | ||
--[no-]ignore search for ignore files (on by default) | ||
-i --ignore-path <path> specify ignore file | ||
--ignore-path-resolve-from cwd|dir resolve patterns in `ignore-path` from its directory or cwd | ||
--ignore-pattern <globs> specify ignore patterns | ||
--inspect output formatted syntax tree | ||
-o --output [path] specify output location | ||
-q --quiet output only warnings and errors | ||
-r --rc-path <path> specify configuration file | ||
-i --ignore-path <path> specify ignore file | ||
--report <reporter> specify reporter | ||
-s --setting <settings> specify settings | ||
-e --ext <extensions> specify extensions | ||
-u --use <plugins> use plugins | ||
-w --watch watch for changes and reprocess | ||
-q --quiet output only warnings and errors | ||
-S --silent output only errors | ||
-f --frail exit with 1 on warnings | ||
--silently-ignore do not fail when given ignored files | ||
--[no-]stdout specify writing to stdout (on by default) | ||
-t --tree specify input and output as syntax tree | ||
--report <reporter> specify reporter | ||
--file-path <path> specify path to process as | ||
--ignore-path-resolve-from dir|cwd resolve patterns in `ignore-path` from its directory or cwd | ||
--ignore-pattern <globs> specify ignore patterns | ||
--silently-ignore do not fail when given ignored files | ||
--tree-in specify input as syntax tree | ||
--tree-out output syntax tree | ||
--inspect output formatted syntax tree | ||
--[no-]stdout specify writing to stdout (on by default) | ||
--[no-]color specify color in report (on by default) | ||
--[no-]config search for configuration files (on by default) | ||
--[no-]ignore search for ignore files (on by default) | ||
-u --use <plugins> use plugins | ||
--verbose report extra info for messages | ||
-v --version output version number | ||
-w --watch watch for changes and reprocess | ||
@@ -125,13 +125,13 @@ Examples: | ||
More information on all these options is available at | ||
[`unified-args`][unified-args], which does the work. | ||
More info on all these options is available at [`unified-args`][unified-args], | ||
which does the work. | ||
`remark-cli` is `unified-args` preconfigured to: | ||
* Load `remark-` plugins | ||
* Search for markdown extensions | ||
* load `remark-` plugins | ||
* search for markdown extensions | ||
([`.md`, `.markdown`, etc][markdown-extensions]) | ||
* Ignore paths found in [`.remarkignore` files][ignore-file] | ||
* Load configuration from | ||
* ignore paths found in [`.remarkignore` files][ignore-file] | ||
* load configuration from | ||
[`.remarkrc`, `.remarkrc.js`, etc files][config-file] | ||
* Use configuration from | ||
* use configuration from | ||
[`remarkConfig` fields in `package.json` files][config-file] | ||
@@ -146,9 +146,9 @@ | ||
First, install the CLI and plugins: | ||
Install the CLI and plugins: | ||
```sh | ||
npm install remark-cli remark-toc remark-preset-lint-consistent remark-preset-lint-recommended --save-dev | ||
npm install remark-cli remark-preset-lint-consistent remark-preset-lint-recommended remark-toc --save-dev | ||
``` | ||
Now, add an npm script in your `package.json`: | ||
…then add an npm script in your `package.json`: | ||
@@ -167,3 +167,3 @@ ```js | ||
Observe that the above change adds a `format` script, which can be run with | ||
The above change adds a `format` script, which can be run with | ||
`npm run format`. | ||
@@ -198,3 +198,3 @@ It runs remark on all markdown files (`.`) and rewrites them (`--output`). | ||
> 👉 **Note**: you must remove the comments in the above examples when | ||
> copy/pasting them, as comments are not supported in `package.json` files. | ||
> copy/pasting them as comments are not supported in `package.json` files. | ||
@@ -280,6 +280,6 @@ Finally, you can run the npm script to check and format markdown files in your | ||
1. `.remarkrc` (JSON) | ||
3. `.remarkrc.cjs` (CJS) | ||
5. `.remarkrc.js` (CJS or ESM, depending on `type: 'module'` in `package.json`) | ||
2. `.remarkrc.json` (JSON) | ||
3. `.remarkrc.cjs` (CJS) | ||
4. `.remarkrc.mjs` (ESM) | ||
5. `.remarkrc.js` (CJS or ESM, depending on `type: 'module'` in `package.json`) | ||
6. `.remarkrc.yaml` (YAML) | ||
@@ -291,7 +291,10 @@ 7. `.remarkrc.yml` (YAML) | ||
Projects maintained by the unified collective are compatible with all maintained | ||
Projects maintained by the unified collective are compatible with maintained | ||
versions of Node.js. | ||
As of now, that is Node.js 14.14+, and 16.0+. | ||
Our projects sometimes work with older versions, but this is not guaranteed. | ||
When we cut a new major release, we drop support for unmaintained versions of | ||
Node. | ||
This means we try to keep the current release line, `remark-cli@^12`, | ||
compatible with Node.js 16. | ||
## Security | ||
@@ -324,4 +327,2 @@ | ||
<!--lint ignore no-html--> | ||
<table> | ||
@@ -375,2 +376,6 @@ <tr valign="middle"> | ||
<td width="10%" align="center"> | ||
<a href="https://markdown.space">Markdown Space</a><br><br> | ||
<a href="https://markdown.space"><img src="https://images.opencollective.com/markdown-space/e1038ed/logo/128.png" width="64"></a> | ||
</td> | ||
<td width="10%" align="center"> | ||
<a href="https://www.holloway.com">Holloway</a><br><br> | ||
@@ -381,3 +386,2 @@ <a href="https://www.holloway.com"><img src="https://avatars1.githubusercontent.com/u/35904294?s=128&v=4" width="64"></a> | ||
<td width="10%"></td> | ||
<td width="10%"></td> | ||
</tr> | ||
@@ -437,4 +441,6 @@ <tr valign="middle"> | ||
[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting | ||
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c | ||
[markdown-extensions]: https://github.com/sindresorhus/markdown-extensions | ||
[rehype]: https://github.com/rehypejs/rehype | ||
@@ -446,14 +452,14 @@ | ||
[markdown-extensions]: https://github.com/sindresorhus/markdown-extensions | ||
[remark-core]: ../remark/ | ||
[config-file]: https://github.com/unifiedjs/unified-engine/blob/main/doc/configure.md | ||
[remark-toc]: https://github.com/remarkjs/remark-toc | ||
[ignore-file]: https://github.com/unifiedjs/unified-engine/blob/main/doc/ignore.md | ||
[config-file]: https://github.com/unifiedjs/unified-engine#config-files | ||
[ignore-file]: https://github.com/unifiedjs/unified-engine#ignore-files | ||
[unified-args]: https://github.com/unifiedjs/unified-args#cli | ||
[remark-core]: ../remark | ||
[markdown-style-guide]: https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide | ||
[remark-toc]: https://github.com/remarkjs/remark-toc | ||
[markdown-style-guide]: https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide | ||
[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting |
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
18561
38
451
4
+ Addedimport-meta-resolve@^3.0.0
+ Addedmarkdown-extensions@^2.0.0
+ Added@npmcli/config@8.3.4(transitive)
+ Added@npmcli/git@5.0.8(transitive)
+ Added@npmcli/package-json@5.2.0(transitive)
+ Added@npmcli/promise-spawn@7.0.2(transitive)
+ Added@types/mdast@4.0.4(transitive)
+ Added@types/node@20.16.5(transitive)
+ Added@types/unist@3.0.3(transitive)
+ Addedcomma-separated-tokens@2.0.3(transitive)
+ Addeddevlop@1.1.0(transitive)
+ Addedemoji-regex@10.4.0(transitive)
+ Addederr-code@2.0.3(transitive)
+ Addedhosted-git-info@7.0.2(transitive)
+ Addedimport-meta-resolve@3.1.14.1.0(transitive)
+ Addedisexe@3.1.1(transitive)
+ Addedload-plugin@6.0.3(transitive)
+ Addedmarkdown-extensions@2.0.0(transitive)
+ Addedmdast-util-from-markdown@2.0.1(transitive)
+ Addedmdast-util-phrasing@4.1.0(transitive)
+ Addedmdast-util-to-markdown@2.1.0(transitive)
+ Addedmdast-util-to-string@4.0.0(transitive)
+ Addedmicromark@4.0.0(transitive)
+ Addedmicromark-core-commonmark@2.0.1(transitive)
+ Addedmicromark-factory-destination@2.0.0(transitive)
+ Addedmicromark-factory-label@2.0.0(transitive)
+ Addedmicromark-factory-space@2.0.0(transitive)
+ Addedmicromark-factory-title@2.0.0(transitive)
+ Addedmicromark-factory-whitespace@2.0.0(transitive)
+ Addedmicromark-util-character@2.1.0(transitive)
+ Addedmicromark-util-chunked@2.0.0(transitive)
+ Addedmicromark-util-classify-character@2.0.0(transitive)
+ Addedmicromark-util-combine-extensions@2.0.0(transitive)
+ Addedmicromark-util-decode-numeric-character-reference@2.0.1(transitive)
+ Addedmicromark-util-decode-string@2.0.0(transitive)
+ Addedmicromark-util-encode@2.0.0(transitive)
+ Addedmicromark-util-html-tag-name@2.0.0(transitive)
+ Addedmicromark-util-normalize-identifier@2.0.0(transitive)
+ Addedmicromark-util-resolve-all@2.0.0(transitive)
+ Addedmicromark-util-sanitize-uri@2.0.0(transitive)
+ Addedmicromark-util-subtokenize@2.0.1(transitive)
+ Addedmicromark-util-symbol@2.0.0(transitive)
+ Addedmicromark-util-types@2.0.0(transitive)
+ Addednormalize-package-data@6.0.2(transitive)
+ Addednpm-install-checks@6.3.0(transitive)
+ Addednpm-package-arg@11.0.3(transitive)
+ Addednpm-pick-manifest@9.1.0(transitive)
+ Addedparse-json@7.1.1(transitive)
+ Addedproc-log@4.2.0(transitive)
+ Addedpromise-inflight@1.0.1(transitive)
+ Addedpromise-retry@2.0.1(transitive)
+ Addedremark@15.0.1(transitive)
+ Addedremark-parse@11.0.0(transitive)
+ Addedremark-stringify@11.0.0(transitive)
+ Addedretry@0.12.0(transitive)
+ Addedspdx-correct@3.2.0(transitive)
+ Addedspdx-exceptions@2.5.0(transitive)
+ Addedspdx-expression-parse@3.0.1(transitive)
+ Addedspdx-license-ids@3.0.20(transitive)
+ Addedstring-width@6.1.0(transitive)
+ Addedtype-fest@3.13.1(transitive)
+ Addedundici-types@6.19.8(transitive)
+ Addedunified@11.0.5(transitive)
+ Addedunified-args@11.0.1(transitive)
+ Addedunified-engine@11.2.1(transitive)
+ Addedunist-util-inspect@8.1.0(transitive)
+ Addedunist-util-is@6.0.0(transitive)
+ Addedunist-util-stringify-position@4.0.0(transitive)
+ Addedunist-util-visit@5.0.0(transitive)
+ Addedunist-util-visit-parents@6.0.1(transitive)
+ Addedvalidate-npm-package-license@3.0.4(transitive)
+ Addedvalidate-npm-package-name@5.0.1(transitive)
+ Addedvfile@6.0.3(transitive)
+ Addedvfile-message@4.0.2(transitive)
+ Addedvfile-reporter@8.1.1(transitive)
+ Addedvfile-sort@4.0.0(transitive)
+ Addedvfile-statistics@3.0.0(transitive)
+ Addedwhich@4.0.0(transitive)
- Removed@npmcli/config@6.4.1(transitive)
- Removed@types/mdast@3.0.15(transitive)
- Removed@types/node@18.19.50(transitive)
- Removed@types/unist@2.0.11(transitive)
- Removedcamelcase@7.0.1(transitive)
- Removeddiff@5.2.0(transitive)
- Removedfault@2.0.1(transitive)
- Removedformat@0.2.2(transitive)
- Removedfs.realpath@1.0.0(transitive)
- Removedglob@8.1.0(transitive)
- Removedimport-meta-resolve@2.2.2(transitive)
- Removedinflight@1.0.6(transitive)
- Removedis-buffer@2.0.5(transitive)
- Removedjson-parse-even-better-errors@2.3.1(transitive)
- Removedkleur@4.1.5(transitive)
- Removedload-plugin@5.1.0(transitive)
- Removedmdast-util-from-markdown@1.3.1(transitive)
- Removedmdast-util-phrasing@3.0.1(transitive)
- Removedmdast-util-to-markdown@1.5.0(transitive)
- Removedmdast-util-to-string@3.2.0(transitive)
- Removedmicromark@3.2.0(transitive)
- Removedmicromark-core-commonmark@1.1.0(transitive)
- Removedmicromark-factory-destination@1.1.0(transitive)
- Removedmicromark-factory-label@1.1.0(transitive)
- Removedmicromark-factory-space@1.1.0(transitive)
- Removedmicromark-factory-title@1.1.0(transitive)
- Removedmicromark-factory-whitespace@1.1.0(transitive)
- Removedmicromark-util-character@1.2.0(transitive)
- Removedmicromark-util-chunked@1.1.0(transitive)
- Removedmicromark-util-classify-character@1.1.0(transitive)
- Removedmicromark-util-combine-extensions@1.1.0(transitive)
- Removedmicromark-util-decode-numeric-character-reference@1.1.0(transitive)
- Removedmicromark-util-decode-string@1.1.0(transitive)
- Removedmicromark-util-encode@1.1.0(transitive)
- Removedmicromark-util-html-tag-name@1.2.0(transitive)
- Removedmicromark-util-normalize-identifier@1.1.0(transitive)
- Removedmicromark-util-resolve-all@1.1.0(transitive)
- Removedmicromark-util-sanitize-uri@1.2.0(transitive)
- Removedmicromark-util-subtokenize@1.1.0(transitive)
- Removedmicromark-util-symbol@1.1.0(transitive)
- Removedmicromark-util-types@1.1.0(transitive)
- Removedminimatch@5.1.6(transitive)
- Removedmri@1.2.0(transitive)
- Removedonce@1.4.0(transitive)
- Removedparse-json@6.0.2(transitive)
- Removedproc-log@3.0.0(transitive)
- Removedremark@14.0.3(transitive)
- Removedremark-parse@10.0.2(transitive)
- Removedremark-stringify@10.0.3(transitive)
- Removedsade@1.8.1(transitive)
- Removedto-vfile@7.2.4(transitive)
- Removedundici-types@5.26.5(transitive)
- Removedunified@10.1.2(transitive)
- Removedunified-args@10.0.0(transitive)
- Removedunified-engine@10.1.0(transitive)
- Removedunist-util-inspect@7.0.2(transitive)
- Removedunist-util-is@5.2.1(transitive)
- Removedunist-util-stringify-position@3.0.3(transitive)
- Removedunist-util-visit@4.1.2(transitive)
- Removedunist-util-visit-parents@5.1.3(transitive)
- Removeduvu@0.5.6(transitive)
- Removedvfile@5.3.7(transitive)
- Removedvfile-message@3.1.4(transitive)
- Removedvfile-reporter@7.0.5(transitive)
- Removedvfile-sort@3.0.1(transitive)
- Removedvfile-statistics@2.0.1(transitive)
- Removedwrappy@1.0.2(transitive)
Updatedremark@^15.0.0
Updatedunified-args@^11.0.0