Skip to content

Commit

Permalink
Refactor build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Aug 28, 2023
1 parent 33ce9ad commit 7d770ea
Show file tree
Hide file tree
Showing 93 changed files with 3,072 additions and 3,216 deletions.
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
ignore-scripts=true
package-lock=false
13 changes: 10 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,21 @@
"bail": "^2.0.0",
"bytes": "^3.0.0",
"c8": "^8.0.0",
"chalk": "^5.0.0",
"comment-parser": "^1.0.0",
"estree-util-is-identifier-name": "^3.0.0",
"github-slugger": "^2.0.0",
"hast-util-to-html": "^9.0.0",
"hastscript": "^8.0.0",
"html-minifier": "^4.0.0",
"is-hidden": "^2.0.0",
"mdast-util-find-and-replace": "^3.0.0",
"mdast-util-from-markdown": "^2.0.0",
"mdast-util-gfm": "^3.0.0",
"mdast-util-to-markdown": "^2.0.0",
"mdast-util-to-string": "^4.0.0",
"mdast-zone": "^6.0.0",
"micromark-extension-gfm": "^3.0.0",
"micromark-util-normalize-identifier": "^2.0.0",
"parse-author": "^2.0.0",
"prettier": "^3.0.0",
"property-information": "^6.0.0",
Expand All @@ -84,9 +90,7 @@
"rehype-format": "^4.0.0",
"rehype-parse": "^9.0.0",
"rehype-stringify": "^10.0.0",
"remark": "^14.0.0",
"remark-cli": "^11.0.0",
"remark-parse": "^10.0.0",
"remark-preset-wooorm": "^9.0.0",
"strip-indent": "^4.0.0",
"tape": "^5.0.0",
Expand All @@ -99,8 +103,11 @@
"undici": "^5.0.0",
"unified": "^11.0.0",
"unist-builder": "^4.0.0",
"unist-util-visit": "^5.0.0",
"vfile": "^6.0.0",
"vfile-find-down": "^7.0.0",
"vfile-reporter": "^8.0.0",
"vfile-sort": "^4.0.0",
"xo": "^0.56.0"
},
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions packages/hast-util-from-string/.npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
ignore-scripts=true
package-lock=false
26 changes: 15 additions & 11 deletions packages/hast-util-from-string/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,40 +49,44 @@
*
* ###### Parameters
*
* * `node` (`Node`) — hast node
* * `value` (`string`, optional) — new text
* * `node` (`Node`) — node to change.
* * `value` (`string`, default: `''`) — value to use
*
* ###### Returns
*
* The given node (`Node`).
* Given node (`Node`).
*/

/**
* @typedef {import('hast').Root} Root
* @typedef {Root|Root['children'][number]} Node
* @typedef {import('hast').Nodes} Nodes
*/

// To do: remove return result.
/**
* Set the plain-text value of a hast node.
* This is like the DOMs `Node#textContent` setter.
* The given node is returned.
*
* @template {Node} Thing
* @template {Nodes} Thing
* Node kind.
* @param {Thing} node
* @param {string|null|undefined} [d]
* Node to change.
* @param {string | null | undefined} [value='']
* Value to use (default: `''`)
* @returns {Thing}
* Given node.
*/
export function fromString(node, d) {
const value = d === undefined || d === null ? '' : String(d)
export function fromString(node, value) {
const normalized = value === undefined || value === null ? '' : String(value)

if ('children' in node) {
node.children = []

if (value) {
node.children.push({type: 'text', value})
node.children.push({type: 'text', value: normalized})
}
} else if (node.type !== 'doctype') {
node.value = value
node.value = normalized
}

return node
Expand Down
68 changes: 34 additions & 34 deletions packages/hast-util-from-string/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
[![Coverage][coverage-badge]][coverage]
[![Downloads][downloads-badge]][downloads]
[![Size][size-badge]][size]
[![Sponsors][sponsors-badge]][collective]
[![Backers][backers-badge]][collective]
[![Sponsors][funding-sponsors-badge]][funding]
[![Backers][funding-backers-badge]][funding]
[![Chat][chat-badge]][chat]

[`hast`][hast] utility to set the plain-text value of a node.
Expand Down Expand Up @@ -47,19 +47,19 @@ characters.
## Install

This package is [ESM only][esm].
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
In Node.js (version 16+), install with [npm][]:

```sh
npm install hast-util-from-string
```

In Deno with [`esm.sh`][esmsh]:
In Deno with [`esm.sh`][esm-sh]:

```js
import {fromString} from 'https://esm.sh/hast-util-from-string@2'
```

In browsers with [`esm.sh`][esmsh]:
In browsers with [`esm.sh`][esm-sh]:

```html
<script type="module">
Expand Down Expand Up @@ -103,12 +103,12 @@ Set the plain-text value of a node.

###### Parameters

* `node` (`Node`) — hast node
* `value` (`string`, optional) — new text
* `node` (`Node`) — node to change.
* `value` (`string`, default: `''`) — value to use

###### Returns

The given node (`Node`).
Given node (`Node`).

## Syntax

Expand All @@ -132,7 +132,7 @@ Our projects sometimes work with older versions, but this is not guaranteed.

## Security

As **rehype** works on HTML, and improper use of HTML can open you up to a
As **rehype** works on HTML and improper use of HTML can open you up to a
[cross-site scripting (XSS)][xss] attack, use of rehype can also be unsafe.
Use [`rehype-sanitize`][rehype-sanitize] to make the tree safe.

Expand All @@ -150,54 +150,54 @@ abide by its terms.

[MIT][license] © [Titus Wormer][author]

[build-badge]: https://github.com/rehypejs/rehype-minify/workflows/main/badge.svg
[author]: https://wooorm.com

[build]: https://github.com/rehypejs/rehype-minify/actions

[coverage-badge]: https://img.shields.io/codecov/c/github/rehypejs/rehype-minify.svg

[coverage]: https://codecov.io/github/rehypejs/rehype-minify

[downloads-badge]: https://img.shields.io/npm/dm/hast-util-from-string.svg
[build-badge]: https://github.com/rehypejs/rehype-minify/workflows/main/badge.svg

[downloads]: https://www.npmjs.com/package/hast-util-from-string
[chat]: https://github.com/rehypejs/rehype/discussions

[size-badge]: https://img.shields.io/bundlephobia/minzip/hast-util-from-string.svg
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg

[size]: https://bundlephobia.com/result?p=hast-util-from-string
[coc]: https://github.com/rehypejs/.github/blob/main/code-of-conduct.md

[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
[contributing]: https://github.com/rehypejs/.github/blob/main/contributing.md

[backers-badge]: https://opencollective.com/unified/backers/badge.svg
[coverage]: https://codecov.io/github/rehypejs/rehype-minify

[collective]: https://opencollective.com/unified
[coverage-badge]: https://img.shields.io/codecov/c/github/rehypejs/rehype-minify.svg

[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
[downloads]: https://www.npmjs.com/package/hast-util-from-string

[chat]: https://github.com/rehypejs/rehype/discussions
[downloads-badge]: https://img.shields.io/npm/dm/hast-util-from-string.svg

[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c

[npm]: https://docs.npmjs.com/cli/install
[esm-sh]: https://esm.sh

[esmsh]: https://esm.sh
[funding]: https://opencollective.com/unified

[typescript]: https://www.typescriptlang.org
[funding-backers-badge]: https://opencollective.com/unified/backers/badge.svg

[rehype-sanitize]: https://github.com/rehypejs/rehype-sanitize
[funding-sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg

[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting
[hast]: https://github.com/syntax-tree/hast

[health]: https://github.com/rehypejs/.github

[contributing]: https://github.com/rehypejs/.github/blob/main/contributing.md
[license]: https://github.com/rehypejs/rehype-minify/blob/main/license

[support]: https://github.com/rehypejs/.github/blob/main/support.md
[npm]: https://docs.npmjs.com/cli/install

[coc]: https://github.com/rehypejs/.github/blob/main/code-of-conduct.md
[rehype-sanitize]: https://github.com/rehypejs/rehype-sanitize

[license]: https://github.com/rehypejs/rehype-minify/blob/main/license
[size]: https://bundlephobia.com/result?p=hast-util-from-string

[author]: https://wooorm.com
[size-badge]: https://img.shields.io/bundlephobia/minzip/hast-util-from-string.svg

[hast]: https://github.com/syntax-tree/hast
[support]: https://github.com/rehypejs/.github/blob/main/support.md

[typescript]: https://www.typescriptlang.org

[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting
1 change: 1 addition & 0 deletions packages/hast-util-is-body-ok-link/.npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
ignore-scripts=true
package-lock=false
62 changes: 31 additions & 31 deletions packages/hast-util-is-body-ok-link/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
[![Coverage][coverage-badge]][coverage]
[![Downloads][downloads-badge]][downloads]
[![Size][size-badge]][size]
[![Sponsors][sponsors-badge]][collective]
[![Backers][backers-badge]][collective]
[![Sponsors][funding-sponsors-badge]][funding]
[![Backers][funding-backers-badge]][funding]
[![Chat][chat-badge]][chat]

[`hast`][hast] utility to check if a `link` element is “body OK”.
Expand Down Expand Up @@ -41,19 +41,19 @@ You can use this package to check whether links can exist inside `<body>`
## Install

This package is [ESM only][esm].
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
In Node.js (version 16+), install with [npm][]:

```sh
npm install hast-util-is-body-ok-link
```

In Deno with [`esm.sh`][esmsh]:
In Deno with [`esm.sh`][esm-sh]:

```js
import {isBodyOkLink} from 'https://esm.sh/hast-util-is-body-ok-link@2'
```

In browsers with [`esm.sh`][esmsh]:
In browsers with [`esm.sh`][esm-sh]:

```html
<script type="module">
Expand Down Expand Up @@ -116,7 +116,7 @@ Our projects sometimes work with older versions, but this is not guaranteed.

## Security

As **rehype** works on HTML, and improper use of HTML can open you up to a
As **rehype** works on HTML and improper use of HTML can open you up to a
[cross-site scripting (XSS)][xss] attack, use of rehype can also be unsafe.
Use [`rehype-sanitize`][rehype-sanitize] to make the tree safe.

Expand All @@ -134,54 +134,54 @@ abide by its terms.

[MIT][license] © [Titus Wormer][author]

[build-badge]: https://github.com/rehypejs/rehype-minify/workflows/main/badge.svg
[author]: https://wooorm.com

[build]: https://github.com/rehypejs/rehype-minify/actions

[coverage-badge]: https://img.shields.io/codecov/c/github/rehypejs/rehype-minify.svg

[coverage]: https://codecov.io/github/rehypejs/rehype-minify

[downloads-badge]: https://img.shields.io/npm/dm/hast-util-is-body-ok-link.svg
[build-badge]: https://github.com/rehypejs/rehype-minify/workflows/main/badge.svg

[downloads]: https://www.npmjs.com/package/hast-util-is-body-ok-link
[chat]: https://github.com/rehypejs/rehype/discussions

[size-badge]: https://img.shields.io/bundlephobia/minzip/hast-util-is-body-ok-link.svg
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg

[size]: https://bundlephobia.com/result?p=hast-util-is-body-ok-link
[coc]: https://github.com/rehypejs/.github/blob/main/code-of-conduct.md

[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
[contributing]: https://github.com/rehypejs/.github/blob/main/contributing.md

[backers-badge]: https://opencollective.com/unified/backers/badge.svg
[coverage]: https://codecov.io/github/rehypejs/rehype-minify

[collective]: https://opencollective.com/unified
[coverage-badge]: https://img.shields.io/codecov/c/github/rehypejs/rehype-minify.svg

[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
[downloads]: https://www.npmjs.com/package/hast-util-is-body-ok-link

[chat]: https://github.com/rehypejs/rehype/discussions
[downloads-badge]: https://img.shields.io/npm/dm/hast-util-is-body-ok-link.svg

[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c

[npm]: https://docs.npmjs.com/cli/install
[esm-sh]: https://esm.sh

[esmsh]: https://esm.sh
[funding]: https://opencollective.com/unified

[typescript]: https://www.typescriptlang.org
[funding-backers-badge]: https://opencollective.com/unified/backers/badge.svg

[rehype-sanitize]: https://github.com/rehypejs/rehype-sanitize
[funding-sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg

[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting
[hast]: https://github.com/syntax-tree/hast

[health]: https://github.com/rehypejs/.github

[contributing]: https://github.com/rehypejs/.github/blob/main/contributing.md
[license]: https://github.com/rehypejs/rehype-minify/blob/main/license

[support]: https://github.com/rehypejs/.github/blob/main/support.md
[npm]: https://docs.npmjs.com/cli/install

[coc]: https://github.com/rehypejs/.github/blob/main/code-of-conduct.md
[rehype-sanitize]: https://github.com/rehypejs/rehype-sanitize

[license]: https://github.com/rehypejs/rehype-minify/blob/main/license
[size]: https://bundlephobia.com/result?p=hast-util-is-body-ok-link

[author]: https://wooorm.com
[size-badge]: https://img.shields.io/bundlephobia/minzip/hast-util-is-body-ok-link.svg

[hast]: https://github.com/syntax-tree/hast
[support]: https://github.com/rehypejs/.github/blob/main/support.md

[typescript]: https://www.typescriptlang.org

[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting
1 change: 1 addition & 0 deletions packages/hast-util-is-conditional-comment/.npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
ignore-scripts=true
package-lock=false
Loading

0 comments on commit 7d770ea

Please sign in to comment.