Compare commits
No commits in common. "main" and "pages" have entirely different histories.
|
|
@ -1 +0,0 @@
|
||||||
* @mathdoggy
|
|
||||||
0
public/.gitignore → .gitignore
vendored
21
LICENSE
|
|
@ -1,21 +0,0 @@
|
||||||
MIT License
|
|
||||||
|
|
||||||
Copyright (c) 2025 Mathrew Xian
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
||||||
12
README.md
|
|
@ -1,12 +0,0 @@
|
||||||
# Mathrew Xian
|
|
||||||
|
|
||||||
This repository is for [Mathrew Xian](https://mathdoggy.gitnet.page/) and [Mathdoggy on Gitnet](https://gitnet.fr/mathdoggy/pages/).
|
|
||||||
|
|
||||||
## Using
|
|
||||||
|
|
||||||
1. [Install Hugo](https://gohugo.io/overview/installing/)
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
- [MIT LICENSE](https://gitnet.fr/mathdoggy/pages/main/LICENSE) : © 2025 Mathrew Xian
|
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
|
|
@ -1,5 +0,0 @@
|
||||||
+++
|
|
||||||
date = '{{ .Date }}'
|
|
||||||
draft = true
|
|
||||||
title = '{{ replace .File.ContentBaseName "-" " " | title }}'
|
|
||||||
+++
|
|
||||||
|
Before Width: | Height: | Size: 776 B After Width: | Height: | Size: 776 B |
|
|
@ -1,3 +0,0 @@
|
||||||
+++
|
|
||||||
author = "lee.so"
|
|
||||||
+++
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
+++
|
|
||||||
title = "About"
|
|
||||||
description = "Hugo, the world's fastest framework for building websites"
|
|
||||||
date = "2019-02-28"
|
|
||||||
aliases = ["about-us", "about-hugo", "contact"]
|
|
||||||
author = "lee.so"
|
|
||||||
+++
|
|
||||||
|
|
||||||
Written in Go, Hugo is an open source static site generator available under the [Apache Licence 2.0.](https://github.com/gohugoio/hugo/blob/master/LICENSE) Hugo supports TOML, YAML and JSON data file types, Markdown and HTML content files and uses shortcodes to add rich content. Other notable features are taxonomies, multilingual mode, image processing, custom output formats, HTML/CSS/JS minification and support for Sass SCSS workflows.
|
|
||||||
|
|
||||||
Hugo makes use of a variety of open source projects including:
|
|
||||||
|
|
||||||
- https://github.com/yuin/goldmark
|
|
||||||
- https://github.com/alecthomas/chroma
|
|
||||||
- https://github.com/muesli/smartcrop
|
|
||||||
- https://github.com/spf13/cobra
|
|
||||||
- https://github.com/spf13/viper
|
|
||||||
|
|
||||||
Hugo is ideal for blogs, corporate websites, creative portfolios, online magazines, single page applications or even a website with thousands of pages.
|
|
||||||
|
|
||||||
Hugo is for people who want to hand code their own website without worrying about setting up complicated runtimes, dependencies and databases.
|
|
||||||
|
|
||||||
Websites built with Hugo are extremely fast, secure and can be deployed anywhere including, AWS, GitHub Pages, Heroku, Netlify and any other hosting provider.
|
|
||||||
|
|
||||||
Learn more and contribute on [GitHub](https://github.com/gohugoio).
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
---
|
|
||||||
date: 2019-05-28
|
|
||||||
type: section
|
|
||||||
layout: 'archives'
|
|
||||||
---
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
+++
|
|
||||||
title = "Contact"
|
|
||||||
description = "Hugo, the world's fastest framework for building websites"
|
|
||||||
date = "2019-02-28"
|
|
||||||
aliases = ["about-us", "about-hugo", "contact"]
|
|
||||||
author = "lee.so"
|
|
||||||
+++
|
|
||||||
|
|
||||||
- [github.com/nanxiaobei](https://github.com/nanxiaobei)
|
|
||||||
- [lee.so](https://lee.so)
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
---
|
|
||||||
title: 'Our Difference'
|
|
||||||
button: 'About us'
|
|
||||||
weight: 2
|
|
||||||
---
|
|
||||||
|
|
||||||
Lorem ipsum dolor sit amet, et essent mediocritatem quo, choro volumus oporteat an mei. Ipsum dolor sit amet, et essent mediocritatem quo.
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
---
|
|
||||||
headless: true
|
|
||||||
---
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
---
|
|
||||||
title: 'We Help Business Grow'
|
|
||||||
button: 'Our Work'
|
|
||||||
weight: 1
|
|
||||||
---
|
|
||||||
|
|
||||||
Lorem ipsum dolor sit amet, et essent mediocritatem quo, choro volumus oporteat an mei. Numquam dolores mel eu, mea docendi omittantur et, mea ea duis erat. Elit melius cu ius. Per ex novum tantas putant, ei his nullam aliquam apeirian. Aeterno quaestio constituto sea an, no eum intellegat assueverit.
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
+++
|
|
||||||
aliases = ["posts", "articles", "blog", "showcase", "docs"]
|
|
||||||
title = "Posts"
|
|
||||||
author = "lee.so"
|
|
||||||
tags = ["index"]
|
|
||||||
+++
|
|
||||||
|
|
@ -1,50 +0,0 @@
|
||||||
+++
|
|
||||||
author = "lee.so"
|
|
||||||
title = "Emoji Support"
|
|
||||||
date = "2019-03-05"
|
|
||||||
description = "Guide to emoji usage in Hugo"
|
|
||||||
tags = [
|
|
||||||
"emoji",
|
|
||||||
]
|
|
||||||
+++
|
|
||||||
|
|
||||||
Emoji can be enabled in a Hugo project in a number of ways.
|
|
||||||
|
|
||||||
<!--more-->
|
|
||||||
|
|
||||||
The [`emojify`](https://gohugo.io/functions/emojify/) function can be called directly in templates or [Inline Shortcodes](https://gohugo.io/templates/shortcode-templates/#inline-shortcodes).
|
|
||||||
|
|
||||||
To enable emoji globally, set `enableEmoji` to `true` in your site's [configuration](https://gohugo.io/getting-started/configuration/) and then you can type emoji shorthand codes directly in content files; e.g.
|
|
||||||
|
|
||||||
<p><span class="nowrap"><span class="emojify">🙈</span> <code>:see_no_evil:</code></span> <span class="nowrap"><span class="emojify">🙉</span> <code>:hear_no_evil:</code></span> <span class="nowrap"><span class="emojify">🙊</span> <code>:speak_no_evil:</code></span></p>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
The [Emoji cheat sheet](http://www.emoji-cheat-sheet.com/) is a useful reference for emoji shorthand codes.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**N.B.** The above steps enable Unicode Standard emoji characters and sequences in Hugo, however the rendering of these glyphs depends on the browser and the platform. To style the emoji you can either use a third party emoji font or a font stack; e.g.
|
|
||||||
|
|
||||||
{{< highlight html >}}
|
|
||||||
.emoji {
|
|
||||||
font-family: Apple Color Emoji, Segoe UI Emoji, NotoColorEmoji, Segoe UI Symbol, Android Emoji, EmojiSymbols;
|
|
||||||
}
|
|
||||||
{{< /highlight >}}
|
|
||||||
|
|
||||||
{{< css.inline >}}
|
|
||||||
|
|
||||||
<style>
|
|
||||||
.emojify {
|
|
||||||
font-family: Apple Color Emoji, Segoe UI Emoji, NotoColorEmoji, Segoe UI Symbol, Android Emoji, EmojiSymbols;
|
|
||||||
font-size: 2rem;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
@media screen and (max-width:650px) {
|
|
||||||
.nowrap {
|
|
||||||
display: block;
|
|
||||||
margin: 25px 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
{{< /css.inline >}}
|
|
||||||
|
|
@ -1,156 +0,0 @@
|
||||||
+++
|
|
||||||
author = "lee.so"
|
|
||||||
title = "Markdown Syntax Guide"
|
|
||||||
date = "2019-03-11"
|
|
||||||
description = "Sample article showcasing basic Markdown syntax and formatting for HTML elements."
|
|
||||||
tags = [
|
|
||||||
"markdown",
|
|
||||||
"css",
|
|
||||||
"html",
|
|
||||||
]
|
|
||||||
categories = [
|
|
||||||
"themes",
|
|
||||||
"syntax",
|
|
||||||
]
|
|
||||||
series = ["Themes Guide"]
|
|
||||||
aliases = ["migrate-from-jekyl"]
|
|
||||||
+++
|
|
||||||
|
|
||||||
This article offers a sample of basic Markdown syntax that can be used in Hugo content files, also it shows whether basic HTML elements are decorated with CSS in a Hugo theme.
|
|
||||||
|
|
||||||
<!--more-->
|
|
||||||
|
|
||||||
## Headings
|
|
||||||
|
|
||||||
The following HTML `<h1>`—`<h6>` elements represent six levels of section headings. `<h1>` is the highest section level while `<h6>` is the lowest.
|
|
||||||
|
|
||||||
# H1
|
|
||||||
|
|
||||||
## H2
|
|
||||||
|
|
||||||
### H3
|
|
||||||
|
|
||||||
#### H4
|
|
||||||
|
|
||||||
##### H5
|
|
||||||
|
|
||||||
###### H6
|
|
||||||
|
|
||||||
## Paragraph
|
|
||||||
|
|
||||||
Xerum, quo qui aut unt expliquam qui dolut labo. Aque venitatiusda cum, voluptionse latur sitiae dolessi aut parist aut dollo enim qui voluptate ma dolestendit peritin re plis aut quas inctum laceat est volestemque commosa as cus endigna tectur, offic to cor sequas etum rerum idem sintibus eiur? Quianimin porecus evelectur, cum que nis nust voloribus ratem aut omnimi, sitatur? Quiatem. Nam, omnis sum am facea corem alique molestrunt et eos evelece arcillit ut aut eos eos nus, sin conecerem erum fuga. Ri oditatquam, ad quibus unda veliamenimin cusam et facea ipsamus es exerum sitate dolores editium rerore eost, temped molorro ratiae volorro te reribus dolorer sperchicium faceata tiustia prat.
|
|
||||||
|
|
||||||
Itatur? Quiatae cullecum rem ent aut odis in re eossequodi nonsequ idebis ne sapicia is sinveli squiatum, core et que aut hariosam ex eat.
|
|
||||||
|
|
||||||
## Blockquotes
|
|
||||||
|
|
||||||
The blockquote element represents content that is quoted from another source, optionally with a citation which must be within a `footer` or `cite` element, and optionally with in-line changes such as annotations and abbreviations.
|
|
||||||
|
|
||||||
#### Blockquote without attribution
|
|
||||||
|
|
||||||
> Tiam, ad mint andaepu dandae nostion secatur sequo quae.
|
|
||||||
> **Note** that you can use _Markdown syntax_ within a blockquote.
|
|
||||||
|
|
||||||
#### Blockquote with attribution
|
|
||||||
|
|
||||||
> Don't communicate by sharing memory, share memory by communicating.<br>
|
|
||||||
> — <cite>Rob Pike[^1]</cite>
|
|
||||||
|
|
||||||
[^1]: The above quote is excerpted from Rob Pike's [talk](https://www.youtube.com/watch?v=PAAkCSZUG1c) during Gopherfest, November 18, 2015.
|
|
||||||
|
|
||||||
## Tables
|
|
||||||
|
|
||||||
Tables aren't part of the core Markdown spec, but Hugo supports supports them out-of-the-box.
|
|
||||||
|
|
||||||
| Name | Age |
|
|
||||||
| ----- | --- |
|
|
||||||
| Bob | 27 |
|
|
||||||
| Alice | 23 |
|
|
||||||
|
|
||||||
#### Inline Markdown within tables
|
|
||||||
|
|
||||||
| Italics | Bold | Code |
|
|
||||||
| --------- | -------- | ------ |
|
|
||||||
| _italics_ | **bold** | `code` |
|
|
||||||
|
|
||||||
## Code Blocks
|
|
||||||
|
|
||||||
#### Code block with backticks
|
|
||||||
|
|
||||||
```html
|
|
||||||
<!doctype html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<title>Example HTML5 Document</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<p>Test</p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Code block indented with four spaces
|
|
||||||
|
|
||||||
<!doctype html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>Example HTML5 Document</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<p>Test</p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
||||||
#### Code block with Hugo's internal highlight shortcode
|
|
||||||
|
|
||||||
{{< highlight html >}}
|
|
||||||
|
|
||||||
<!doctype html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>Example HTML5 Document</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<p>Test</p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
{{< /highlight >}}
|
|
||||||
|
|
||||||
## List Types
|
|
||||||
|
|
||||||
#### Ordered List
|
|
||||||
|
|
||||||
1. First item
|
|
||||||
2. Second item
|
|
||||||
3. Third item
|
|
||||||
|
|
||||||
#### Unordered List
|
|
||||||
|
|
||||||
- List item
|
|
||||||
- Another item
|
|
||||||
- And another item
|
|
||||||
|
|
||||||
#### Nested list
|
|
||||||
|
|
||||||
- Fruit
|
|
||||||
- Apple
|
|
||||||
- Orange
|
|
||||||
- Banana
|
|
||||||
- Dairy
|
|
||||||
- Milk
|
|
||||||
- Cheese
|
|
||||||
|
|
||||||
## Other Elements — abbr, sub, sup, kbd, mark
|
|
||||||
|
|
||||||
<abbr title="Graphics Interchange Format">GIF</abbr> is a bitmap image format.
|
|
||||||
|
|
||||||
H<sub>2</sub>O
|
|
||||||
|
|
||||||
X<sup>n</sup> + Y<sup>n</sup> = Z<sup>n</sup>
|
|
||||||
|
|
||||||
Press <kbd><kbd>CTRL</kbd>+<kbd>ALT</kbd>+<kbd>Delete</kbd></kbd> to end the session.
|
|
||||||
|
|
||||||
Most <mark>salamanders</mark> are nocturnal, and hunt for insects, worms, and other small creatures.
|
|
||||||
|
|
@ -1,48 +0,0 @@
|
||||||
---
|
|
||||||
author: lee.so
|
|
||||||
title: Math Typesetting
|
|
||||||
date: 2019-03-08
|
|
||||||
description: A brief guide to setup KaTeX
|
|
||||||
math: true
|
|
||||||
---
|
|
||||||
|
|
||||||
Mathematical notation in a Hugo project can be enabled by using third party JavaScript libraries.
|
|
||||||
|
|
||||||
<!--more-->
|
|
||||||
|
|
||||||
In this example we will be using [KaTeX](https://katex.org/)
|
|
||||||
|
|
||||||
- Create a partial under `/layouts/partials/math.html`
|
|
||||||
- Within this partial reference the [Auto-render Extension](https://katex.org/docs/autorender.html) or host these scripts locally.
|
|
||||||
- Include the partial in your templates like so:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
{{ if or .Params.math .Site.Params.math }}
|
|
||||||
{{ partial "math.html" . }}
|
|
||||||
{{ end }}
|
|
||||||
```
|
|
||||||
|
|
||||||
- To enable KaTeX globally set the parameter `math` to `true` in a project's configuration
|
|
||||||
- To enable KaTeX on a per page basis include the parameter `math: true` in content files
|
|
||||||
|
|
||||||
**Note:** Use the online reference of [Supported TeX Functions](https://katex.org/docs/supported.html)
|
|
||||||
|
|
||||||
{{< math.inline >}}
|
|
||||||
|
|
||||||
{{</ math.inline >}}
|
|
||||||
|
|
||||||
### Examples
|
|
||||||
|
|
||||||
{{< math.inline >}}
|
|
||||||
|
|
||||||
<p>
|
|
||||||
Inline math: \(\varphi = \dfrac{1+\sqrt5}{2}= 1.6180339887…\)
|
|
||||||
</p>
|
|
||||||
|
|
||||||
{{</ math.inline >}}
|
|
||||||
|
|
||||||
Block math:
|
|
||||||
|
|
||||||
$$
|
|
||||||
\varphi = 1+\frac{1} {1+\frac{1} {1+\frac{1} {1+\cdots} } }
|
|
||||||
$$
|
|
||||||
|
|
@ -1,48 +0,0 @@
|
||||||
+++
|
|
||||||
author = "lee.so"
|
|
||||||
title = "Placeholder Text"
|
|
||||||
date = "2019-03-09"
|
|
||||||
description = "Lorem Ipsum Dolor Si Amet"
|
|
||||||
tags = [
|
|
||||||
"markdown",
|
|
||||||
"text",
|
|
||||||
]
|
|
||||||
weight = 10
|
|
||||||
+++
|
|
||||||
|
|
||||||
Lorem est tota propiore conpellat pectoribus de pectora summo. <!--more-->Redit teque digerit hominumque toris verebor lumina non cervice subde tollit usus habet Arctonque, furores quas nec ferunt. Quoque montibus nunc caluere tempus inhospita parcite confusaque translucet patri vestro qui optatis lumine cognoscere flos nubis! Fronde ipsamque patulos Dryopen deorum.
|
|
||||||
|
|
||||||
1. Exierant elisi ambit vivere dedere
|
|
||||||
2. Duce pollice
|
|
||||||
3. Eris modo
|
|
||||||
4. Spargitque ferrea quos palude
|
|
||||||
|
|
||||||
Rursus nulli murmur; hastile inridet ut ab gravi sententia! Nomine potitus silentia flumen, sustinet placuit petis in dilapsa erat sunt. Atria tractus malis.
|
|
||||||
|
|
||||||
1. Comas hunc haec pietate fetum procerum dixit
|
|
||||||
2. Post torum vates letum Tiresia
|
|
||||||
3. Flumen querellas
|
|
||||||
4. Arcanaque montibus omnes
|
|
||||||
5. Quidem et
|
|
||||||
|
|
||||||
# Vagus elidunt
|
|
||||||
|
|
||||||
<svg class="canon" xmlns="http://www.w3.org/2000/svg" overflow="visible" viewBox="0 0 496 373" height="373" width="496"><g fill="none"><path stroke="#000" stroke-width=".75" d="M.599 372.348L495.263 1.206M.312.633l494.95 370.853M.312 372.633L247.643.92M248.502.92l246.76 370.566M330.828 123.869V1.134M330.396 1.134L165.104 124.515"></path><path stroke="#ED1C24" stroke-width=".75" d="M275.73 41.616h166.224v249.05H275.73zM54.478 41.616h166.225v249.052H54.478z"></path><path stroke="#000" stroke-width=".75" d="M.479.375h495v372h-495zM247.979.875v372"></path><ellipse cx="498.729" cy="177.625" rx=".75" ry="1.25"></ellipse><ellipse cx="247.229" cy="377.375" rx=".75" ry="1.25"></ellipse></g></svg>
|
|
||||||
|
|
||||||
[The Van de Graaf Canon](https://en.wikipedia.org/wiki/Canons_of_page_construction#Van_de_Graaf_canon)
|
|
||||||
|
|
||||||
## Mane refeci capiebant unda mulcebat
|
|
||||||
|
|
||||||
Victa caducifer, malo vulnere contra dicere aurato, ludit regale, voca! Retorsit colit est profanae esse virescere furit nec; iaculi matertera et visa est, viribus. Divesque creatis, tecta novat collumque vulnus est, parvas. **Faces illo pepulere** tempus adest. Tendit flamma, ab opes virum sustinet, sidus sequendo urbis.
|
|
||||||
|
|
||||||
Iubar proles corpore raptos vero auctor imperium; sed et huic: manus caeli Lelegas tu lux. Verbis obstitit intus oblectamina fixis linguisque ausus sperare Echionides cornuaque tenent clausit possit. Omnia putatur. Praeteritae refert ausus; ferebant e primus lora nutat, vici quae mea ipse. Et iter nil spectatae vulnus haerentia iuste et exercebat, sui et.
|
|
||||||
|
|
||||||
Eurytus Hector, materna ipsumque ut Politen, nec, nate, ignari, vernum cohaesit sequitur. Vel **mitis temploque** vocatus, inque alis, _oculos nomen_ non silvis corpore coniunx ne displicet illa. Crescunt non unus, vidit visa quantum inmiti flumina mortis facto sic: undique a alios vincula sunt iactata abdita! Suspenderat ego fuit tendit: luna, ante urbem Propoetides **parte**.
|
|
||||||
|
|
||||||
{{< css.inline >}}
|
|
||||||
|
|
||||||
<style>
|
|
||||||
.canon { background: white; width: 100%; height: auto; }
|
|
||||||
</style>
|
|
||||||
|
|
||||||
{{< /css.inline >}}
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
+++
|
|
||||||
author = "lee.so"
|
|
||||||
title = "Rich Content"
|
|
||||||
date = "2019-03-10"
|
|
||||||
description = "A brief description of Hugo Shortcodes"
|
|
||||||
tags = [
|
|
||||||
"shortcodes",
|
|
||||||
"privacy",
|
|
||||||
]
|
|
||||||
+++
|
|
||||||
|
|
||||||
Hugo ships with several [Built-in Shortcodes](https://gohugo.io/content-management/shortcodes/#use-hugos-built-in-shortcodes) for rich content, along with a [Privacy Config](https://gohugo.io/about/hugo-and-gdpr/) and a set of Simple Shortcodes that enable static and no-JS versions of various social media embeds.
|
|
||||||
|
|
||||||
## <!--more-->
|
|
||||||
|
|
||||||
## YouTube Privacy Enhanced Shortcode
|
|
||||||
|
|
||||||
{{< youtube ZJthWmvUzzc >}}
|
|
||||||
|
Before Width: | Height: | Size: 971 B After Width: | Height: | Size: 971 B |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
5
go.mod
|
|
@ -1,5 +0,0 @@
|
||||||
module gitnet.fr/mathdoggy/pages
|
|
||||||
|
|
||||||
go 1.25.0
|
|
||||||
|
|
||||||
require github.com/nanxiaobei/hugo-paper v0.0.0-20250419060945-8c75cdd9ce53 // indirect
|
|
||||||
2
go.sum
|
|
@ -1,2 +0,0 @@
|
||||||
github.com/nanxiaobei/hugo-paper v0.0.0-20250419060945-8c75cdd9ce53 h1:VoP3cjNl0DDqtPIMIFDs3vSKmmgXBDrQD6mTOICgf/k=
|
|
||||||
github.com/nanxiaobei/hugo-paper v0.0.0-20250419060945-8c75cdd9ce53/go.mod h1:cS2hTYPgmZ2FkPTQbOiX6vB0yLQcWD067kJx2lkRPVQ=
|
|
||||||
0
public/highlight.min.js → highlight.min.js
vendored
123
hugo.toml
|
|
@ -1,123 +0,0 @@
|
||||||
[build]
|
|
||||||
writeStats = true
|
|
||||||
[build.buildStats]
|
|
||||||
enable = false
|
|
||||||
|
|
||||||
baseURL = 'https://mathdoggy.gitnet.page/'
|
|
||||||
title = 'Mathrew Xian Hugo Site'
|
|
||||||
author = 'Mathrew Xian'
|
|
||||||
copyright = '© 2025, Mathrew Xian'
|
|
||||||
languageCode = 'en'
|
|
||||||
DefaultContentLanguage = 'en'
|
|
||||||
theme = 'paper'
|
|
||||||
|
|
||||||
[frontmatter]
|
|
||||||
date = ['mydate', 'date']
|
|
||||||
|
|
||||||
[HTTPCache]
|
|
||||||
[HTTPCache.cache]
|
|
||||||
[HTTPCache.cache.for]
|
|
||||||
excludes = ['**']
|
|
||||||
includes = []
|
|
||||||
|
|
||||||
[pagination]
|
|
||||||
disableAliases = false
|
|
||||||
pagerSize = 10
|
|
||||||
|
|
||||||
[page]
|
|
||||||
nextPrevInSectionSortOrder = 'desc'
|
|
||||||
nextPrevSortOrder = 'desc'
|
|
||||||
|
|
||||||
[blog]
|
|
||||||
nextPrevInSectionSortOrder = 'desc'
|
|
||||||
nextPrevSortOrder = 'desc'
|
|
||||||
|
|
||||||
[params]
|
|
||||||
color = 'light-blue'
|
|
||||||
mastodon = '@mstdn.plus@mathdoggy'
|
|
||||||
github = 'mathdoggy'
|
|
||||||
|
|
||||||
[permalinks]
|
|
||||||
[permalinks.page]
|
|
||||||
[permalinks.section]
|
|
||||||
[permalinks.taxonomy]
|
|
||||||
[permalinks.term]
|
|
||||||
|
|
||||||
[markup]
|
|
||||||
[markup.goldmark]
|
|
||||||
duplicateResourceFiles = false
|
|
||||||
[markup.goldmark.extensions]
|
|
||||||
definitionList = true
|
|
||||||
footnote = true
|
|
||||||
linkify = true
|
|
||||||
linkifyProtocol = 'https'
|
|
||||||
strikethrough = true
|
|
||||||
table = true
|
|
||||||
[markup.goldmark.parser]
|
|
||||||
autoDefinitionTermID = false
|
|
||||||
autoHeadingID = true
|
|
||||||
autoIDType = 'gitnet'
|
|
||||||
wrapStandAloneImageWithinParagraph = true
|
|
||||||
[markup.goldmark.parser.attribute]
|
|
||||||
block = false
|
|
||||||
title = true
|
|
||||||
[markup.goldmark.renderHooks]
|
|
||||||
[markup.goldmark.renderHooks.image]
|
|
||||||
enableDafault = false
|
|
||||||
useEmbedded = 'auto'
|
|
||||||
[markup.goldmark.renderHooks.link]
|
|
||||||
enableDefault = false
|
|
||||||
useEmbedded = 'auto'
|
|
||||||
[markup.goldmark.renderer]
|
|
||||||
hardWraps = false
|
|
||||||
unsafe = false
|
|
||||||
xhtml = false
|
|
||||||
|
|
||||||
[menu]
|
|
||||||
[[menu.main]]
|
|
||||||
name = 'Home'
|
|
||||||
pageRef = '/'
|
|
||||||
weight = 10
|
|
||||||
[[menu.main]]
|
|
||||||
name = 'Blogs'
|
|
||||||
pageRef = '/blogs'
|
|
||||||
weight = 10
|
|
||||||
[[menu.main]]
|
|
||||||
name = 'Pages'
|
|
||||||
pageRef = '/pages'
|
|
||||||
weight = 1
|
|
||||||
[[menu.main]]
|
|
||||||
name = 'Mathrew Xian'
|
|
||||||
pre = '<i class="fa fa-heart"></i>'
|
|
||||||
url = 'https://mathdoggy.gitnet.page/'
|
|
||||||
weight = 20
|
|
||||||
[menu.main.params]
|
|
||||||
rel = 'external'
|
|
||||||
|
|
||||||
[[menu.footer]]
|
|
||||||
name = 'Terms'
|
|
||||||
pageRef = '/terms'
|
|
||||||
weight = 1
|
|
||||||
[[menu.footer]]
|
|
||||||
name = 'Privacy'
|
|
||||||
pageRef = '/privacy'
|
|
||||||
weight = 10
|
|
||||||
|
|
||||||
[taxonomies]
|
|
||||||
author = 'authors'
|
|
||||||
category = 'categories'
|
|
||||||
blog = 'blogs'
|
|
||||||
page = 'pages'
|
|
||||||
site = 'sites'
|
|
||||||
tag = 'tags'
|
|
||||||
series = 'series'
|
|
||||||
|
|
||||||
[privacy]
|
|
||||||
|
|
||||||
[services]
|
|
||||||
[services.googleAnalytics]
|
|
||||||
ID = 'G-ZZYG7KM2RT'
|
|
||||||
|
|
||||||
[module]
|
|
||||||
[[module.imports]]
|
|
||||||
path = 'github.com/nanxiaobei/hugo-paper'
|
|
||||||
222
hugo_stats.json
|
|
@ -1,222 +0,0 @@
|
||||||
{
|
|
||||||
"htmlElements": {
|
|
||||||
"tags": [
|
|
||||||
"a",
|
|
||||||
"article",
|
|
||||||
"blockquote",
|
|
||||||
"body",
|
|
||||||
"code",
|
|
||||||
"div",
|
|
||||||
"em",
|
|
||||||
"footer",
|
|
||||||
"h1",
|
|
||||||
"h2",
|
|
||||||
"h3",
|
|
||||||
"h4",
|
|
||||||
"h5",
|
|
||||||
"h6",
|
|
||||||
"head",
|
|
||||||
"header",
|
|
||||||
"hr",
|
|
||||||
"html",
|
|
||||||
"iframe",
|
|
||||||
"li",
|
|
||||||
"link",
|
|
||||||
"main",
|
|
||||||
"meta",
|
|
||||||
"nav",
|
|
||||||
"ol",
|
|
||||||
"p",
|
|
||||||
"pre",
|
|
||||||
"script",
|
|
||||||
"section",
|
|
||||||
"span",
|
|
||||||
"strong",
|
|
||||||
"sup",
|
|
||||||
"table",
|
|
||||||
"tbody",
|
|
||||||
"td",
|
|
||||||
"th",
|
|
||||||
"thead",
|
|
||||||
"time",
|
|
||||||
"title",
|
|
||||||
"tr",
|
|
||||||
"ul"
|
|
||||||
],
|
|
||||||
"classes": [
|
|
||||||
"*:flex",
|
|
||||||
"*:font-medium",
|
|
||||||
"*:items-center",
|
|
||||||
"*:no-underline",
|
|
||||||
"*:p-5",
|
|
||||||
"*:w-1/2",
|
|
||||||
"-translate-y-[1px]",
|
|
||||||
"[&>*:hover]:bg-black/[2%]",
|
|
||||||
"[-webkit-tap-highlight-color:transparent]",
|
|
||||||
"[background:url(./theme.png)_left_center/_auto_theme('spacing.6')_no-repeat]",
|
|
||||||
"[background:var(--url)_center_center/cover_no-repeat]",
|
|
||||||
"[transition:_background-position_0.4s_steps(5)]",
|
|
||||||
"absolute",
|
|
||||||
"antialiased",
|
|
||||||
"bg-(--bg)",
|
|
||||||
"bg-black/[3%]",
|
|
||||||
"block",
|
|
||||||
"bottom-20",
|
|
||||||
"btn-dark",
|
|
||||||
"btn-menu",
|
|
||||||
"cursor-pointer",
|
|
||||||
"dark:[&>*:hover]:bg-white/[3%]",
|
|
||||||
"dark:[background-position:right]",
|
|
||||||
"dark:bg-white/[8%]",
|
|
||||||
"dark:hover:bg-white/[12%]",
|
|
||||||
"dark:invert",
|
|
||||||
"dark:prose-invert",
|
|
||||||
"dark:text-white",
|
|
||||||
"duration-200",
|
|
||||||
"ease-out",
|
|
||||||
"first-of-type:mt-0",
|
|
||||||
"fixed",
|
|
||||||
"flex",
|
|
||||||
"flex-col",
|
|
||||||
"flex-wrap",
|
|
||||||
"font-medium",
|
|
||||||
"footnote-backref",
|
|
||||||
"footnote-ref",
|
|
||||||
"footnotes",
|
|
||||||
"gap-2.5",
|
|
||||||
"h-6",
|
|
||||||
"h-7",
|
|
||||||
"h-[4.5rem]",
|
|
||||||
"h-full",
|
|
||||||
"highlight",
|
|
||||||
"hover:bg-black/[6%]",
|
|
||||||
"inline-block",
|
|
||||||
"inset-0",
|
|
||||||
"inset-x-0",
|
|
||||||
"inset-x-8",
|
|
||||||
"items-center",
|
|
||||||
"justify-center",
|
|
||||||
"justify-end",
|
|
||||||
"last-of-type:mb-0",
|
|
||||||
"leading-[1.2]!",
|
|
||||||
"leading-[5rem]",
|
|
||||||
"lg:bg-transparent!",
|
|
||||||
"lg:flex",
|
|
||||||
"lg:flex-row",
|
|
||||||
"lg:font-normal",
|
|
||||||
"lg:h-6",
|
|
||||||
"lg:h-auto",
|
|
||||||
"lg:hidden",
|
|
||||||
"lg:items-center",
|
|
||||||
"lg:justify-center",
|
|
||||||
"lg:ml-12",
|
|
||||||
"lg:mt-0",
|
|
||||||
"lg:pb-0",
|
|
||||||
"lg:space-x-10",
|
|
||||||
"lg:static",
|
|
||||||
"lg:text-base",
|
|
||||||
"lg:transition-none",
|
|
||||||
"lg:w-6",
|
|
||||||
"link",
|
|
||||||
"ltr:-mr-8",
|
|
||||||
"ltr:lg:ml-14",
|
|
||||||
"ltr:ml-1.5",
|
|
||||||
"ltr:ml-4",
|
|
||||||
"ltr:ml-auto",
|
|
||||||
"ltr:mr-1.5",
|
|
||||||
"ltr:mr-auto",
|
|
||||||
"ltr:pr-3",
|
|
||||||
"max-w-(--w)",
|
|
||||||
"mb-1",
|
|
||||||
"mb-1.5",
|
|
||||||
"mb-14",
|
|
||||||
"min-h-[calc(100vh-9rem)]",
|
|
||||||
"mr-auto",
|
|
||||||
"mt-12",
|
|
||||||
"mt-24",
|
|
||||||
"mx-1",
|
|
||||||
"mx-6",
|
|
||||||
"mx-auto",
|
|
||||||
"my-0!",
|
|
||||||
"my-10",
|
|
||||||
"nav-wrapper",
|
|
||||||
"no-underline",
|
|
||||||
"not-ready",
|
|
||||||
"opacity-60",
|
|
||||||
"overflow-hidden",
|
|
||||||
"pb-16",
|
|
||||||
"pb-2.5",
|
|
||||||
"pl-3",
|
|
||||||
"prose",
|
|
||||||
"prose-neutral",
|
|
||||||
"pt-14",
|
|
||||||
"px-5",
|
|
||||||
"px-8",
|
|
||||||
"py-1",
|
|
||||||
"relative",
|
|
||||||
"rounded-lg",
|
|
||||||
"rounded-xl",
|
|
||||||
"rtl:-ml-8",
|
|
||||||
"rtl:lg:mr-14",
|
|
||||||
"rtl:ml-1.5",
|
|
||||||
"rtl:ml-auto",
|
|
||||||
"rtl:mr-1.5",
|
|
||||||
"rtl:mr-4",
|
|
||||||
"rtl:mr-auto",
|
|
||||||
"rtl:pl-3",
|
|
||||||
"rtl:space-x-reverse",
|
|
||||||
"select-none",
|
|
||||||
"shrink-0",
|
|
||||||
"space-x-10",
|
|
||||||
"text-2xl",
|
|
||||||
"text-9xl",
|
|
||||||
"text-[0px]",
|
|
||||||
"text-black",
|
|
||||||
"text-center",
|
|
||||||
"text-lg",
|
|
||||||
"text-orange-500",
|
|
||||||
"text-xl",
|
|
||||||
"text-xs",
|
|
||||||
"top-0",
|
|
||||||
"top-full",
|
|
||||||
"tracking-wider",
|
|
||||||
"uppercase",
|
|
||||||
"w-6",
|
|
||||||
"w-7",
|
|
||||||
"w-[5rem]",
|
|
||||||
"whitespace-nowrap",
|
|
||||||
"z-40",
|
|
||||||
"z-50"
|
|
||||||
],
|
|
||||||
"ids": [
|
|
||||||
"blockquote-with-attribution",
|
|
||||||
"blockquote-without-attribution",
|
|
||||||
"blockquotes",
|
|
||||||
"code-block-indented-with-four-spaces",
|
|
||||||
"code-block-with-backticks",
|
|
||||||
"code-block-with-hugos-internal-highlight-shortcode",
|
|
||||||
"code-blocks",
|
|
||||||
"examples",
|
|
||||||
"fn:1",
|
|
||||||
"fnref:1",
|
|
||||||
"h1",
|
|
||||||
"h2",
|
|
||||||
"h3",
|
|
||||||
"h4",
|
|
||||||
"h5",
|
|
||||||
"h6",
|
|
||||||
"headings",
|
|
||||||
"inline-markdown-within-tables",
|
|
||||||
"list-types",
|
|
||||||
"mane-refeci-capiebant-unda-mulcebat",
|
|
||||||
"nested-list",
|
|
||||||
"ordered-list",
|
|
||||||
"other-elements--abbr-sub-sup-kbd-mark",
|
|
||||||
"paragraph",
|
|
||||||
"tables",
|
|
||||||
"unordered-list",
|
|
||||||
"vagus-elidunt",
|
|
||||||
"youtube-privacy-enhanced-shortcode"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Before Width: | Height: | Size: 862 B After Width: | Height: | Size: 862 B |
|
Before Width: | Height: | Size: 1 KiB After Width: | Height: | Size: 1 KiB |
0
public/main.min.css → main.min.css
vendored
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
1
node_modules/.bin/autoprefixer
generated
vendored
|
|
@ -1 +0,0 @@
|
||||||
../autoprefixer/bin/autoprefixer
|
|
||||||
1
node_modules/.bin/browserslist
generated
vendored
|
|
@ -1 +0,0 @@
|
||||||
../browserslist/cli.js
|
|
||||||
1
node_modules/.bin/cssesc
generated
vendored
|
|
@ -1 +0,0 @@
|
||||||
../cssesc/bin/cssesc
|
|
||||||
1
node_modules/.bin/glob
generated
vendored
|
|
@ -1 +0,0 @@
|
||||||
../glob/dist/esm/bin.mjs
|
|
||||||
1
node_modules/.bin/nanoid
generated
vendored
|
|
@ -1 +0,0 @@
|
||||||
../nanoid/bin/nanoid.cjs
|
|
||||||
1
node_modules/.bin/node-which
generated
vendored
|
|
@ -1 +0,0 @@
|
||||||
../which/bin/node-which
|
|
||||||
1
node_modules/.bin/postcss
generated
vendored
|
|
@ -1 +0,0 @@
|
||||||
../postcss-cli/index.js
|
|
||||||
1
node_modules/.bin/purgecss
generated
vendored
|
|
@ -1 +0,0 @@
|
||||||
../purgecss/bin/purgecss.js
|
|
||||||
1
node_modules/.bin/rtlcss
generated
vendored
|
|
@ -1 +0,0 @@
|
||||||
../rtlcss/bin/rtlcss.js
|
|
||||||
1
node_modules/.bin/update-browserslist-db
generated
vendored
|
|
@ -1 +0,0 @@
|
||||||
../update-browserslist-db/cli.js
|
|
||||||
1
node_modules/.bin/yaml
generated
vendored
|
|
@ -1 +0,0 @@
|
||||||
../yaml/bin.mjs
|
|
||||||
1443
node_modules/.package-lock.json
generated
vendored
139
node_modules/@fullhuman/postcss-purgecss/README.md
generated
vendored
|
|
@ -1,139 +0,0 @@
|
||||||
# PostCSS Purgecss
|
|
||||||

|
|
||||||

|
|
||||||

|
|
||||||

|
|
||||||

|
|
||||||
|
|
||||||
[PostCSS] plugin for PurgeCSS.
|
|
||||||
|
|
||||||
[PostCSS]: https://github.com/postcss/postcss
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
```
|
|
||||||
npm i -D @fullhuman/postcss-purgecss postcss
|
|
||||||
```
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
```js
|
|
||||||
const purgecss = require('@fullhuman/postcss-purgecss')
|
|
||||||
postcss([
|
|
||||||
purgecss({
|
|
||||||
content: ['./src/**/*.html']
|
|
||||||
})
|
|
||||||
])
|
|
||||||
```
|
|
||||||
|
|
||||||
See [PostCSS] docs for examples for your environment.
|
|
||||||
|
|
||||||
## Options
|
|
||||||
|
|
||||||
All of the options of purgecss are available to use with the plugins.
|
|
||||||
You will find below the main options available. For the complete list, go to the [purgecss documentation website](https://www.purgecss.com/configuration.html#options).
|
|
||||||
|
|
||||||
### `content` (**required** or use `contentFunction` instead)
|
|
||||||
Type: `Array<string>`
|
|
||||||
|
|
||||||
You can specify content that should be analyzed by Purgecss with an array of filenames or globs. The files can be HTML, Pug, Blade, etc.
|
|
||||||
|
|
||||||
### `contentFunction` (as alternative to `content`)
|
|
||||||
Type: `(sourceInputFile: string) => Array<string>`
|
|
||||||
|
|
||||||
The function receives the current source input file. With this you may provide a specific array of globs for each input. E.g. for
|
|
||||||
an angular application only scan the components template counterpart for every component scss file:
|
|
||||||
|
|
||||||
```js
|
|
||||||
purgecss({
|
|
||||||
contentFunction: (sourceInputFileName: string) => {
|
|
||||||
if (/component\.scss$/.test(sourceInputFileName))
|
|
||||||
return [sourceInputFileName.replace(/scss$/, 'html')]
|
|
||||||
else
|
|
||||||
return ['./src/**/*.html']
|
|
||||||
},
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
### `extractors`
|
|
||||||
Type: `Array<Object>`
|
|
||||||
|
|
||||||
Purgecss can be adapted to suit your needs. If you notice a lot of unused CSS is not being removed, you might want to use a custom extractor.
|
|
||||||
More information about extractors [here](https://www.purgecss.com/extractors.html).
|
|
||||||
|
|
||||||
### `safelist`
|
|
||||||
|
|
||||||
You can indicate which selectors are safe to leave in the final CSS. This can be accomplished with the option `safelist`.
|
|
||||||
|
|
||||||
Two forms are available for this option.
|
|
||||||
|
|
||||||
```ts
|
|
||||||
safelist: ['random', 'yep', 'button', /^nav-/]
|
|
||||||
```
|
|
||||||
|
|
||||||
In this form, safelist is an array that can take a string or a regex.
|
|
||||||
|
|
||||||
The _complex_ form is:
|
|
||||||
|
|
||||||
```ts
|
|
||||||
safelist: {
|
|
||||||
standard: ['random', 'yep', 'button', /^nav-/],
|
|
||||||
deep: [],
|
|
||||||
greedy: [],
|
|
||||||
keyframes: [],
|
|
||||||
variables: []
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### `blocklist`
|
|
||||||
|
|
||||||
Blocklist will block the CSS selectors from appearing in the final output CSS. The selectors will be removed even when they are seen as used by PurgeCSS.
|
|
||||||
|
|
||||||
```ts
|
|
||||||
blocklist: ['usedClass', /^nav-/]
|
|
||||||
```
|
|
||||||
Even if nav-links and usedClass are found by an extractor, they will be removed.
|
|
||||||
|
|
||||||
### `skippedContentGlobs`
|
|
||||||
|
|
||||||
If you provide globs for the `content` parameter, you can use this option to exclude certain files or folders that would otherwise be scanned. Pass an array of globs matching items that should be excluded. (Note: this option has no effect if `content` is not globs.)
|
|
||||||
|
|
||||||
```ts
|
|
||||||
skippedContentGlobs: ['node_modules/**', 'components/**']
|
|
||||||
```
|
|
||||||
Here, PurgeCSS will not scan anything in the "node_modules" and "components" folders.
|
|
||||||
|
|
||||||
|
|
||||||
### `rejected`
|
|
||||||
Type: `boolean`
|
|
||||||
Default value: `false`
|
|
||||||
|
|
||||||
If true, purged selectors will be captured and rendered as PostCSS messages.
|
|
||||||
Use with a PostCSS reporter plugin like [`postcss-reporter`](https://github.com/postcss/postcss-reporter)
|
|
||||||
to print the purged selectors to the console as they are processed.
|
|
||||||
|
|
||||||
### `keyframes`
|
|
||||||
Type: `boolean`
|
|
||||||
Default value: `false`
|
|
||||||
|
|
||||||
If you are using a CSS animation library such as animate.css, you can remove unused keyframes by setting the keyframes option to true.
|
|
||||||
|
|
||||||
#### `fontFace`
|
|
||||||
Type: `boolean`
|
|
||||||
Default value: `false`
|
|
||||||
|
|
||||||
If there are any unused @font-face rules in your css, you can remove them by setting the fontFace option to true.
|
|
||||||
|
|
||||||
## Contributing
|
|
||||||
|
|
||||||
Please read [CONTRIBUTING.md](./../../CONTRIBUTING.md) for details on our code of
|
|
||||||
conduct, and the process for submitting pull requests to us.
|
|
||||||
|
|
||||||
## Versioning
|
|
||||||
|
|
||||||
postcss-purgecss use [SemVer](http://semver.org/) for versioning.
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
This project is licensed under the MIT License - see the [LICENSE](./../../LICENSE) file
|
|
||||||
for details.
|
|
||||||
164
node_modules/@fullhuman/postcss-purgecss/lib/postcss-purgecss.d.ts
generated
vendored
|
|
@ -1,164 +0,0 @@
|
||||||
/**
|
|
||||||
* PostCSS Plugin for PurgeCSS
|
|
||||||
*
|
|
||||||
* Most bundlers and frameworks to build websites are using PostCSS.
|
|
||||||
* The easiest way to configure PurgeCSS is with its PostCSS plugin.
|
|
||||||
*
|
|
||||||
* @packageDocumentation
|
|
||||||
*/
|
|
||||||
|
|
||||||
import * as postcss from 'postcss';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @public
|
|
||||||
*/
|
|
||||||
export declare type ComplexSafelist = {
|
|
||||||
standard?: StringRegExpArray;
|
|
||||||
/**
|
|
||||||
* You can safelist selectors and their children based on a regular
|
|
||||||
* expression with `safelist.deep`
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
*
|
|
||||||
* ```ts
|
|
||||||
* const purgecss = await new PurgeCSS().purge({
|
|
||||||
* content: [],
|
|
||||||
* css: [],
|
|
||||||
* safelist: {
|
|
||||||
* deep: [/red$/]
|
|
||||||
* }
|
|
||||||
* })
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* In this example, selectors such as `.bg-red .child-of-bg` will be left
|
|
||||||
* in the final CSS, even if `child-of-bg` is not found.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
deep?: RegExp[];
|
|
||||||
greedy?: RegExp[];
|
|
||||||
variables?: StringRegExpArray;
|
|
||||||
keyframes?: StringRegExpArray;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @public
|
|
||||||
*/
|
|
||||||
export declare type ExtractorFunction<T = string> = (content: T) => ExtractorResult;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @public
|
|
||||||
*/
|
|
||||||
export declare type ExtractorResult = ExtractorResultDetailed | string[];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @public
|
|
||||||
*/
|
|
||||||
export declare interface ExtractorResultDetailed {
|
|
||||||
attributes: {
|
|
||||||
names: string[];
|
|
||||||
values: string[];
|
|
||||||
};
|
|
||||||
classes: string[];
|
|
||||||
ids: string[];
|
|
||||||
tags: string[];
|
|
||||||
undetermined: string[];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @public
|
|
||||||
*/
|
|
||||||
export declare interface Extractors {
|
|
||||||
extensions: string[];
|
|
||||||
extractor: ExtractorFunction;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PostCSS Plugin for PurgeCSS
|
|
||||||
*
|
|
||||||
* @param opts - PurgeCSS Options
|
|
||||||
* @returns the postCSS plugin
|
|
||||||
*
|
|
||||||
* @public
|
|
||||||
*/
|
|
||||||
declare const purgeCSSPlugin: postcss.PluginCreator<UserDefinedOptions>;
|
|
||||||
export default purgeCSSPlugin;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Options used by PurgeCSS to remove unused CSS
|
|
||||||
*
|
|
||||||
* @public
|
|
||||||
*/
|
|
||||||
export declare interface PurgeCSSUserDefinedOptions {
|
|
||||||
/** {@inheritDoc purgecss#Options.content} */
|
|
||||||
content: Array<string | RawContent>;
|
|
||||||
/** {@inheritDoc purgecss#Options.css} */
|
|
||||||
css: Array<string | RawCSS>;
|
|
||||||
/** {@inheritDoc purgecss#Options.defaultExtractor} */
|
|
||||||
defaultExtractor?: ExtractorFunction;
|
|
||||||
/** {@inheritDoc purgecss#Options.extractors} */
|
|
||||||
extractors?: Array<Extractors>;
|
|
||||||
/** {@inheritDoc purgecss#Options.fontFace} */
|
|
||||||
fontFace?: boolean;
|
|
||||||
/** {@inheritDoc purgecss#Options.keyframes} */
|
|
||||||
keyframes?: boolean;
|
|
||||||
/** {@inheritDoc purgecss#Options.output} */
|
|
||||||
output?: string;
|
|
||||||
/** {@inheritDoc purgecss#Options.rejected} */
|
|
||||||
rejected?: boolean;
|
|
||||||
/** {@inheritDoc purgecss#Options.rejectedCss} */
|
|
||||||
rejectedCss?: boolean;
|
|
||||||
/** {@inheritDoc purgecss#Options.sourceMap } */
|
|
||||||
sourceMap?: boolean | (postcss.SourceMapOptions & { to?: string });
|
|
||||||
/** {@inheritDoc purgecss#Options.stdin} */
|
|
||||||
stdin?: boolean;
|
|
||||||
/** {@inheritDoc purgecss#Options.stdout} */
|
|
||||||
stdout?: boolean;
|
|
||||||
/** {@inheritDoc purgecss#Options.variables} */
|
|
||||||
variables?: boolean;
|
|
||||||
/** {@inheritDoc purgecss#Options.safelist} */
|
|
||||||
safelist?: UserDefinedSafelist;
|
|
||||||
/** {@inheritDoc purgecss#Options.blocklist} */
|
|
||||||
blocklist?: StringRegExpArray;
|
|
||||||
/** {@inheritDoc purgecss#Options.skippedContentGlobs} */
|
|
||||||
skippedContentGlobs?: Array<string>;
|
|
||||||
/** {@inheritDoc purgecss#Options.dynamicAttributes} */
|
|
||||||
dynamicAttributes?: string[];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @public
|
|
||||||
*/
|
|
||||||
export declare interface RawContent<T = string> {
|
|
||||||
extension: string;
|
|
||||||
raw: T;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @public
|
|
||||||
*/
|
|
||||||
export declare interface RawCSS {
|
|
||||||
raw: string;
|
|
||||||
name?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @public
|
|
||||||
*/
|
|
||||||
export declare type StringRegExpArray = Array<RegExp | string>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc purgecss#UserDefinedOptions}
|
|
||||||
*
|
|
||||||
* @public
|
|
||||||
*/
|
|
||||||
export declare interface UserDefinedOptions extends Omit<PurgeCSSUserDefinedOptions, "content" | "css"> {
|
|
||||||
content?: PurgeCSSUserDefinedOptions["content"];
|
|
||||||
contentFunction?: (sourceFile: string) => Array<string | RawContent>;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @public
|
|
||||||
*/
|
|
||||||
export declare type UserDefinedSafelist = StringRegExpArray | ComplexSafelist;
|
|
||||||
|
|
||||||
export { }
|
|
||||||
1
node_modules/@fullhuman/postcss-purgecss/lib/postcss-purgecss.esm.js
generated
vendored
|
|
@ -1 +0,0 @@
|
||||||
import*as e from"path";import{PurgeCSS as s,defaultOptions as t,standardizeSafelist as o,mergeExtractorSelectors as r}from"purgecss";const n=function(n){if(void 0===n)throw new Error("PurgeCSS plugin does not have the correct options");return{postcssPlugin:"postcss-purgecss",OnceExit:(c,i)=>async function(n,c,{result:i}){const a=new s;let l;try{const s=e.resolve(process.cwd(),"purgecss.config.js");l=await import(s)}catch{}const p={...t,...l,...n,safelist:o((null==n?void 0:n.safelist)||(null==l?void 0:l.safelist))};n&&"function"==typeof n.contentFunction&&(p.content=n.contentFunction(c.source&&c.source.input.file||"")),a.options=p,p.variables&&(a.variablesStructure.safelist=p.safelist.variables||[]);const{content:u,extractors:f}=p,m=u.filter((e=>"string"==typeof e)),g=u.filter((e=>"object"==typeof e)),v=await a.extractSelectorsFromFiles(m,f),d=await a.extractSelectorsFromString(g,f),S=r(v,d);a.walkThroughCSS(c,S),a.options.fontFace&&a.removeUnusedFontFaces(),a.options.keyframes&&a.removeUnusedKeyframes(),a.options.variables&&a.removeUnusedCSSVariables(),a.options.rejected&&a.selectorsRemoved.size>0&&(i.messages.push({type:"purgecss",plugin:"postcss-purgecss",text:`purging ${a.selectorsRemoved.size} selectors:\n ${Array.from(a.selectorsRemoved).map((e=>e.trim())).join("\n ")}`}),a.selectorsRemoved.clear())}(n,c,i)}};n.postcss=!0;export{n as default};
|
|
||||||
1
node_modules/@fullhuman/postcss-purgecss/lib/postcss-purgecss.js
generated
vendored
|
|
@ -1 +0,0 @@
|
||||||
"use strict";var e=require("path"),t=require("purgecss");function r(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var s=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,s.get?s:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var s=r(e);const o=function(e){if(void 0===e)throw new Error("PurgeCSS plugin does not have the correct options");return{postcssPlugin:"postcss-purgecss",OnceExit:(o,n)=>async function(e,o,{result:n}){const c=new t.PurgeCSS;let i;try{const e=s.resolve(process.cwd(),"purgecss.config.js");i=await function(e){return Promise.resolve().then((function(){return r(require(e))}))}(e)}catch{}const a={...t.defaultOptions,...i,...e,safelist:t.standardizeSafelist((null==e?void 0:e.safelist)||(null==i?void 0:i.safelist))};e&&"function"==typeof e.contentFunction&&(a.content=e.contentFunction(o.source&&o.source.input.file||"")),c.options=a,a.variables&&(c.variablesStructure.safelist=a.safelist.variables||[]);const{content:u,extractors:l}=a,f=u.filter((e=>"string"==typeof e)),p=u.filter((e=>"object"==typeof e)),d=await c.extractSelectorsFromFiles(f,l),g=await c.extractSelectorsFromString(p,l),v=t.mergeExtractorSelectors(d,g);c.walkThroughCSS(o,v),c.options.fontFace&&c.removeUnusedFontFaces(),c.options.keyframes&&c.removeUnusedKeyframes(),c.options.variables&&c.removeUnusedCSSVariables(),c.options.rejected&&c.selectorsRemoved.size>0&&(n.messages.push({type:"purgecss",plugin:"postcss-purgecss",text:`purging ${c.selectorsRemoved.size} selectors:\n ${Array.from(c.selectorsRemoved).map((e=>e.trim())).join("\n ")}`}),c.selectorsRemoved.clear())}(e,o,n)}};o.postcss=!0,module.exports=o;
|
|
||||||
42
node_modules/@fullhuman/postcss-purgecss/package.json
generated
vendored
|
|
@ -1,42 +0,0 @@
|
||||||
{
|
|
||||||
"name": "@fullhuman/postcss-purgecss",
|
|
||||||
"version": "6.0.0",
|
|
||||||
"description": "PostCSS plugin for PurgeCSS",
|
|
||||||
"author": "FoundrySH <no-reply@foundry.sh>",
|
|
||||||
"homepage": "https://purgecss.com",
|
|
||||||
"license": "MIT",
|
|
||||||
"main": "lib/postcss-purgecss.js",
|
|
||||||
"module": "lib/postcss-purgecss.esm.js",
|
|
||||||
"types": "lib/postcss-purgecss.d.ts",
|
|
||||||
"directories": {
|
|
||||||
"lib": "lib",
|
|
||||||
"test": "__tests__"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"lib"
|
|
||||||
],
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/FullHuman/purgecss.git"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"build": "ts-node build.ts",
|
|
||||||
"test": "jest"
|
|
||||||
},
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/FullHuman/purgecss/issues"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"purgecss": "^6.0.0"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"postcss": "^8.4.4"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"postcss": "^8.0.0"
|
|
||||||
},
|
|
||||||
"publishConfig": {
|
|
||||||
"access": "public",
|
|
||||||
"registry": "https://registry.npmjs.org/"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
3
node_modules/@hbstack/node-packages/.github/FUNDING.yml
generated
vendored
|
|
@ -1,3 +0,0 @@
|
||||||
github: razonyang
|
|
||||||
custom:
|
|
||||||
- https://paypal.me/razonyang
|
|
||||||
33
node_modules/@hbstack/node-packages/.github/workflows/release-please.yml
generated
vendored
|
|
@ -1,33 +0,0 @@
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
pull-requests: write
|
|
||||||
|
|
||||||
name: release-please
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
release-please:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: googleapis/release-please-action@v4
|
|
||||||
id: release
|
|
||||||
with:
|
|
||||||
command: manifest
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
if: ${{ steps.release.outputs.release_created }}
|
|
||||||
- uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: 20
|
|
||||||
registry-url: 'https://registry.npmjs.org'
|
|
||||||
if: ${{ steps.release.outputs.release_created }}
|
|
||||||
- run: npm ci
|
|
||||||
if: ${{ steps.release.outputs.release_created }}
|
|
||||||
- run: npm publish
|
|
||||||
env:
|
|
||||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
||||||
if: ${{ steps.release.outputs.release_created }}
|
|
||||||
|
|
||||||
14
node_modules/@hbstack/node-packages/.mergify.yml
generated
vendored
|
|
@ -1,14 +0,0 @@
|
||||||
pull_request_rules:
|
|
||||||
- name: Automatic merge for Renovate pull requests
|
|
||||||
conditions:
|
|
||||||
- author=renovate[bot]
|
|
||||||
actions:
|
|
||||||
merge:
|
|
||||||
method: rebase
|
|
||||||
|
|
||||||
- name: Automatic merge on approval
|
|
||||||
conditions:
|
|
||||||
- "#approved-reviews-by>=1"
|
|
||||||
actions:
|
|
||||||
merge:
|
|
||||||
method: rebase
|
|
||||||
3
node_modules/@hbstack/node-packages/.release-please-manifest.json
generated
vendored
|
|
@ -1,3 +0,0 @@
|
||||||
{
|
|
||||||
".": "0.1.5"
|
|
||||||
}
|
|
||||||
43
node_modules/@hbstack/node-packages/CHANGELOG.md
generated
vendored
|
|
@ -1,43 +0,0 @@
|
||||||
# Changelog
|
|
||||||
|
|
||||||
## [0.1.5](https://github.com/hbstack/node-packages/compare/node-packages-v0.1.4...node-packages-v0.1.5) (2024-08-02)
|
|
||||||
|
|
||||||
|
|
||||||
### Continuous Integration
|
|
||||||
|
|
||||||
* **deps:** update dependency autoprefixer to v10.4.20 ([aa7cd52](https://github.com/hbstack/node-packages/commit/aa7cd528cc933c23d56014bf1114c717c1a68f3e))
|
|
||||||
|
|
||||||
## [0.1.4](https://github.com/hbstack/node-packages/compare/node-packages-v0.1.3...node-packages-v0.1.4) (2024-07-25)
|
|
||||||
|
|
||||||
|
|
||||||
### Continuous Integration
|
|
||||||
|
|
||||||
* **deps:** update dependency rtlcss to v4.2.0 ([610b814](https://github.com/hbstack/node-packages/commit/610b8144fe01793d7313074b656fd073eeb1fb18))
|
|
||||||
|
|
||||||
## [0.1.3](https://github.com/hbstack/node-packages/compare/node-packages-v0.1.2...node-packages-v0.1.3) (2024-05-27)
|
|
||||||
|
|
||||||
|
|
||||||
### Continuous Integration
|
|
||||||
|
|
||||||
* fix .github/workflows/release-please.yml ([f70320f](https://github.com/hbstack/node-packages/commit/f70320f3a36bf2189c0eb12d4f2d2f1246d05cdc))
|
|
||||||
|
|
||||||
## [0.1.2](https://github.com/hbstack/node-packages/compare/node-packages-v0.1.1...node-packages-v0.1.2) (2024-05-26)
|
|
||||||
|
|
||||||
|
|
||||||
### Bug Fixes 🐞
|
|
||||||
|
|
||||||
* binaries setting ([1694856](https://github.com/hbstack/node-packages/commit/1694856fe0a22ea79fdffce50e1724d5f089079c))
|
|
||||||
|
|
||||||
## [0.1.1](https://github.com/hbstack/node-packages/compare/node-packages/v0.1.0...node-packages-v0.1.1) (2024-05-25)
|
|
||||||
|
|
||||||
|
|
||||||
### Continuous Integration
|
|
||||||
|
|
||||||
* update renovate.json ([0c1aa37](https://github.com/hbstack/node-packages/commit/0c1aa370d67fdaba65edbc80119b4a5478f35c3e))
|
|
||||||
|
|
||||||
## [0.1.0](https://github.com/hbstack/node-packages/compare/node-packages-v0.0.1...node-packages/v0.1.0) (2024-05-25)
|
|
||||||
|
|
||||||
|
|
||||||
### Features ✨
|
|
||||||
|
|
||||||
* first version ([01912e6](https://github.com/hbstack/node-packages/commit/01912e63ae915c91744a783988f29a07121e5af6))
|
|
||||||
21
node_modules/@hbstack/node-packages/LICENSE
generated
vendored
|
|
@ -1,21 +0,0 @@
|
||||||
MIT License
|
|
||||||
|
|
||||||
Copyright (c) 2024 HB Framework Authors
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
||||||
7
node_modules/@hbstack/node-packages/README.md
generated
vendored
|
|
@ -1,7 +0,0 @@
|
||||||
# HB Node Packages
|
|
||||||
|
|
||||||
This package includes all required Node.js packages for HB Framework.
|
|
||||||
|
|
||||||
[](https://github.com/hbstack/node-packages/blob/main/LICENSE)
|
|
||||||
[](https://www.npmjs.com/package/@hbstack/node-packages)
|
|
||||||
[](https://www.npmjs.com/package/@hbstack/node-packages)
|
|
||||||
3
node_modules/@hbstack/node-packages/go.mod
generated
vendored
|
|
@ -1,3 +0,0 @@
|
||||||
module github.com/hbstack/node-packages
|
|
||||||
|
|
||||||
go 1.19
|
|
||||||
0
node_modules/@hbstack/node-packages/hugo.toml
generated
vendored
21
node_modules/@hbstack/node-packages/package.json
generated
vendored
|
|
@ -1,21 +0,0 @@
|
||||||
{
|
|
||||||
"name": "@hbstack/node-packages",
|
|
||||||
"description": "Node packages for HB Framework",
|
|
||||||
"version": "0.1.5",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/hbstack/node-packages.git"
|
|
||||||
},
|
|
||||||
"author": "Razon Yang <razonyang@gmail.com>",
|
|
||||||
"license": "MIT",
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/hbstack/node-packages/issues"
|
|
||||||
},
|
|
||||||
"homepage": "https://github.com/hbstack/node-packages",
|
|
||||||
"dependencies": {
|
|
||||||
"@fullhuman/postcss-purgecss": "^6.0.0",
|
|
||||||
"autoprefixer": "^10.4.19",
|
|
||||||
"postcss-cli": "^11.0.0",
|
|
||||||
"rtlcss": "^4.1.1"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
22
node_modules/@hbstack/node-packages/release-please-config.json
generated
vendored
|
|
@ -1,22 +0,0 @@
|
||||||
{
|
|
||||||
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
|
|
||||||
"release-type": "node",
|
|
||||||
"bootstrap-sha": "0431988f7a404d173cd18b6eb8ad1564e8be9a0b",
|
|
||||||
"monorepo-tags": false,
|
|
||||||
"changelog-sections": [
|
|
||||||
{ "type": "chore", "section": "Miscellaneous Chores", "hidden": true },
|
|
||||||
{ "type": "ci", "section": "Continuous Integration" },
|
|
||||||
{ "type": "docs", "section": "Documentation 📝" },
|
|
||||||
{ "type": "feat", "section": "Features ✨" },
|
|
||||||
{ "type": "feature", "section": "Features ✨" },
|
|
||||||
{ "type": "fix", "section": "Bug Fixes 🐞" },
|
|
||||||
{ "type": "perf", "section": "Performance Improvements ⚡️" },
|
|
||||||
{ "type": "style", "section": "Styles 🎨" }
|
|
||||||
],
|
|
||||||
"packages": {
|
|
||||||
".": {
|
|
||||||
"exclude-paths": [
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
15
node_modules/@hbstack/node-packages/renovate.json
generated
vendored
|
|
@ -1,15 +0,0 @@
|
||||||
{
|
|
||||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
|
||||||
"extends": [
|
|
||||||
"config:base",
|
|
||||||
":dependencyDashboard"
|
|
||||||
],
|
|
||||||
"packageRules": [
|
|
||||||
{
|
|
||||||
"matchManagers": ["npm"],
|
|
||||||
"matchDepTypes": ["dependencies"],
|
|
||||||
"enabled": true,
|
|
||||||
"semanticCommitType": "ci"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
14
node_modules/@isaacs/cliui/LICENSE.txt
generated
vendored
|
|
@ -1,14 +0,0 @@
|
||||||
Copyright (c) 2015, Contributors
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
|
||||||
for any purpose with or without fee is hereby granted, provided
|
|
||||||
that the above copyright notice and this permission notice
|
|
||||||
appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
|
||||||
OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE
|
|
||||||
LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
|
|
||||||
OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
|
||||||
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
|
||||||
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
143
node_modules/@isaacs/cliui/README.md
generated
vendored
|
|
@ -1,143 +0,0 @@
|
||||||
# @isaacs/cliui
|
|
||||||
|
|
||||||
Temporary fork of [cliui](http://npm.im/cliui).
|
|
||||||
|
|
||||||

|
|
||||||
[](https://www.npmjs.com/package/cliui)
|
|
||||||
[](https://conventionalcommits.org)
|
|
||||||

|
|
||||||
|
|
||||||
easily create complex multi-column command-line-interfaces.
|
|
||||||
|
|
||||||
## Example
|
|
||||||
|
|
||||||
```js
|
|
||||||
const ui = require('cliui')()
|
|
||||||
|
|
||||||
ui.div('Usage: $0 [command] [options]')
|
|
||||||
|
|
||||||
ui.div({
|
|
||||||
text: 'Options:',
|
|
||||||
padding: [2, 0, 1, 0]
|
|
||||||
})
|
|
||||||
|
|
||||||
ui.div(
|
|
||||||
{
|
|
||||||
text: "-f, --file",
|
|
||||||
width: 20,
|
|
||||||
padding: [0, 4, 0, 4]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: "the file to load." +
|
|
||||||
chalk.green("(if this description is long it wraps).")
|
|
||||||
,
|
|
||||||
width: 20
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: chalk.red("[required]"),
|
|
||||||
align: 'right'
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
console.log(ui.toString())
|
|
||||||
```
|
|
||||||
|
|
||||||
## Deno/ESM Support
|
|
||||||
|
|
||||||
As of `v7` `cliui` supports [Deno](https://github.com/denoland/deno) and
|
|
||||||
[ESM](https://nodejs.org/api/esm.html#esm_ecmascript_modules):
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
import cliui from "https://deno.land/x/cliui/deno.ts";
|
|
||||||
|
|
||||||
const ui = cliui({})
|
|
||||||
|
|
||||||
ui.div('Usage: $0 [command] [options]')
|
|
||||||
|
|
||||||
ui.div({
|
|
||||||
text: 'Options:',
|
|
||||||
padding: [2, 0, 1, 0]
|
|
||||||
})
|
|
||||||
|
|
||||||
ui.div({
|
|
||||||
text: "-f, --file",
|
|
||||||
width: 20,
|
|
||||||
padding: [0, 4, 0, 4]
|
|
||||||
})
|
|
||||||
|
|
||||||
console.log(ui.toString())
|
|
||||||
```
|
|
||||||
|
|
||||||
<img width="500" src="screenshot.png">
|
|
||||||
|
|
||||||
## Layout DSL
|
|
||||||
|
|
||||||
cliui exposes a simple layout DSL:
|
|
||||||
|
|
||||||
If you create a single `ui.div`, passing a string rather than an
|
|
||||||
object:
|
|
||||||
|
|
||||||
* `\n`: characters will be interpreted as new rows.
|
|
||||||
* `\t`: characters will be interpreted as new columns.
|
|
||||||
* `\s`: characters will be interpreted as padding.
|
|
||||||
|
|
||||||
**as an example...**
|
|
||||||
|
|
||||||
```js
|
|
||||||
var ui = require('./')({
|
|
||||||
width: 60
|
|
||||||
})
|
|
||||||
|
|
||||||
ui.div(
|
|
||||||
'Usage: node ./bin/foo.js\n' +
|
|
||||||
' <regex>\t provide a regex\n' +
|
|
||||||
' <glob>\t provide a glob\t [required]'
|
|
||||||
)
|
|
||||||
|
|
||||||
console.log(ui.toString())
|
|
||||||
```
|
|
||||||
|
|
||||||
**will output:**
|
|
||||||
|
|
||||||
```shell
|
|
||||||
Usage: node ./bin/foo.js
|
|
||||||
<regex> provide a regex
|
|
||||||
<glob> provide a glob [required]
|
|
||||||
```
|
|
||||||
|
|
||||||
## Methods
|
|
||||||
|
|
||||||
```js
|
|
||||||
cliui = require('cliui')
|
|
||||||
```
|
|
||||||
|
|
||||||
### cliui({width: integer})
|
|
||||||
|
|
||||||
Specify the maximum width of the UI being generated.
|
|
||||||
If no width is provided, cliui will try to get the current window's width and use it, and if that doesn't work, width will be set to `80`.
|
|
||||||
|
|
||||||
### cliui({wrap: boolean})
|
|
||||||
|
|
||||||
Enable or disable the wrapping of text in a column.
|
|
||||||
|
|
||||||
### cliui.div(column, column, column)
|
|
||||||
|
|
||||||
Create a row with any number of columns, a column
|
|
||||||
can either be a string, or an object with the following
|
|
||||||
options:
|
|
||||||
|
|
||||||
* **text:** some text to place in the column.
|
|
||||||
* **width:** the width of a column.
|
|
||||||
* **align:** alignment, `right` or `center`.
|
|
||||||
* **padding:** `[top, right, bottom, left]`.
|
|
||||||
* **border:** should a border be placed around the div?
|
|
||||||
|
|
||||||
### cliui.span(column, column, column)
|
|
||||||
|
|
||||||
Similar to `div`, except the next row will be appended without
|
|
||||||
a new line being created.
|
|
||||||
|
|
||||||
### cliui.resetOutput()
|
|
||||||
|
|
||||||
Resets the UI elements of the current cliui instance, maintaining the values
|
|
||||||
set for `width` and `wrap`.
|
|
||||||
317
node_modules/@isaacs/cliui/build/index.cjs
generated
vendored
|
|
@ -1,317 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
const align = {
|
|
||||||
right: alignRight,
|
|
||||||
center: alignCenter
|
|
||||||
};
|
|
||||||
const top = 0;
|
|
||||||
const right = 1;
|
|
||||||
const bottom = 2;
|
|
||||||
const left = 3;
|
|
||||||
class UI {
|
|
||||||
constructor(opts) {
|
|
||||||
var _a;
|
|
||||||
this.width = opts.width;
|
|
||||||
/* c8 ignore start */
|
|
||||||
this.wrap = (_a = opts.wrap) !== null && _a !== void 0 ? _a : true;
|
|
||||||
/* c8 ignore stop */
|
|
||||||
this.rows = [];
|
|
||||||
}
|
|
||||||
span(...args) {
|
|
||||||
const cols = this.div(...args);
|
|
||||||
cols.span = true;
|
|
||||||
}
|
|
||||||
resetOutput() {
|
|
||||||
this.rows = [];
|
|
||||||
}
|
|
||||||
div(...args) {
|
|
||||||
if (args.length === 0) {
|
|
||||||
this.div('');
|
|
||||||
}
|
|
||||||
if (this.wrap && this.shouldApplyLayoutDSL(...args) && typeof args[0] === 'string') {
|
|
||||||
return this.applyLayoutDSL(args[0]);
|
|
||||||
}
|
|
||||||
const cols = args.map(arg => {
|
|
||||||
if (typeof arg === 'string') {
|
|
||||||
return this.colFromString(arg);
|
|
||||||
}
|
|
||||||
return arg;
|
|
||||||
});
|
|
||||||
this.rows.push(cols);
|
|
||||||
return cols;
|
|
||||||
}
|
|
||||||
shouldApplyLayoutDSL(...args) {
|
|
||||||
return args.length === 1 && typeof args[0] === 'string' &&
|
|
||||||
/[\t\n]/.test(args[0]);
|
|
||||||
}
|
|
||||||
applyLayoutDSL(str) {
|
|
||||||
const rows = str.split('\n').map(row => row.split('\t'));
|
|
||||||
let leftColumnWidth = 0;
|
|
||||||
// simple heuristic for layout, make sure the
|
|
||||||
// second column lines up along the left-hand.
|
|
||||||
// don't allow the first column to take up more
|
|
||||||
// than 50% of the screen.
|
|
||||||
rows.forEach(columns => {
|
|
||||||
if (columns.length > 1 && mixin.stringWidth(columns[0]) > leftColumnWidth) {
|
|
||||||
leftColumnWidth = Math.min(Math.floor(this.width * 0.5), mixin.stringWidth(columns[0]));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// generate a table:
|
|
||||||
// replacing ' ' with padding calculations.
|
|
||||||
// using the algorithmically generated width.
|
|
||||||
rows.forEach(columns => {
|
|
||||||
this.div(...columns.map((r, i) => {
|
|
||||||
return {
|
|
||||||
text: r.trim(),
|
|
||||||
padding: this.measurePadding(r),
|
|
||||||
width: (i === 0 && columns.length > 1) ? leftColumnWidth : undefined
|
|
||||||
};
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
return this.rows[this.rows.length - 1];
|
|
||||||
}
|
|
||||||
colFromString(text) {
|
|
||||||
return {
|
|
||||||
text,
|
|
||||||
padding: this.measurePadding(text)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
measurePadding(str) {
|
|
||||||
// measure padding without ansi escape codes
|
|
||||||
const noAnsi = mixin.stripAnsi(str);
|
|
||||||
return [0, noAnsi.match(/\s*$/)[0].length, 0, noAnsi.match(/^\s*/)[0].length];
|
|
||||||
}
|
|
||||||
toString() {
|
|
||||||
const lines = [];
|
|
||||||
this.rows.forEach(row => {
|
|
||||||
this.rowToString(row, lines);
|
|
||||||
});
|
|
||||||
// don't display any lines with the
|
|
||||||
// hidden flag set.
|
|
||||||
return lines
|
|
||||||
.filter(line => !line.hidden)
|
|
||||||
.map(line => line.text)
|
|
||||||
.join('\n');
|
|
||||||
}
|
|
||||||
rowToString(row, lines) {
|
|
||||||
this.rasterize(row).forEach((rrow, r) => {
|
|
||||||
let str = '';
|
|
||||||
rrow.forEach((col, c) => {
|
|
||||||
const { width } = row[c]; // the width with padding.
|
|
||||||
const wrapWidth = this.negatePadding(row[c]); // the width without padding.
|
|
||||||
let ts = col; // temporary string used during alignment/padding.
|
|
||||||
if (wrapWidth > mixin.stringWidth(col)) {
|
|
||||||
ts += ' '.repeat(wrapWidth - mixin.stringWidth(col));
|
|
||||||
}
|
|
||||||
// align the string within its column.
|
|
||||||
if (row[c].align && row[c].align !== 'left' && this.wrap) {
|
|
||||||
const fn = align[row[c].align];
|
|
||||||
ts = fn(ts, wrapWidth);
|
|
||||||
if (mixin.stringWidth(ts) < wrapWidth) {
|
|
||||||
/* c8 ignore start */
|
|
||||||
const w = width || 0;
|
|
||||||
/* c8 ignore stop */
|
|
||||||
ts += ' '.repeat(w - mixin.stringWidth(ts) - 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// apply border and padding to string.
|
|
||||||
const padding = row[c].padding || [0, 0, 0, 0];
|
|
||||||
if (padding[left]) {
|
|
||||||
str += ' '.repeat(padding[left]);
|
|
||||||
}
|
|
||||||
str += addBorder(row[c], ts, '| ');
|
|
||||||
str += ts;
|
|
||||||
str += addBorder(row[c], ts, ' |');
|
|
||||||
if (padding[right]) {
|
|
||||||
str += ' '.repeat(padding[right]);
|
|
||||||
}
|
|
||||||
// if prior row is span, try to render the
|
|
||||||
// current row on the prior line.
|
|
||||||
if (r === 0 && lines.length > 0) {
|
|
||||||
str = this.renderInline(str, lines[lines.length - 1]);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// remove trailing whitespace.
|
|
||||||
lines.push({
|
|
||||||
text: str.replace(/ +$/, ''),
|
|
||||||
span: row.span
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return lines;
|
|
||||||
}
|
|
||||||
// if the full 'source' can render in
|
|
||||||
// the target line, do so.
|
|
||||||
renderInline(source, previousLine) {
|
|
||||||
const match = source.match(/^ */);
|
|
||||||
/* c8 ignore start */
|
|
||||||
const leadingWhitespace = match ? match[0].length : 0;
|
|
||||||
/* c8 ignore stop */
|
|
||||||
const target = previousLine.text;
|
|
||||||
const targetTextWidth = mixin.stringWidth(target.trimEnd());
|
|
||||||
if (!previousLine.span) {
|
|
||||||
return source;
|
|
||||||
}
|
|
||||||
// if we're not applying wrapping logic,
|
|
||||||
// just always append to the span.
|
|
||||||
if (!this.wrap) {
|
|
||||||
previousLine.hidden = true;
|
|
||||||
return target + source;
|
|
||||||
}
|
|
||||||
if (leadingWhitespace < targetTextWidth) {
|
|
||||||
return source;
|
|
||||||
}
|
|
||||||
previousLine.hidden = true;
|
|
||||||
return target.trimEnd() + ' '.repeat(leadingWhitespace - targetTextWidth) + source.trimStart();
|
|
||||||
}
|
|
||||||
rasterize(row) {
|
|
||||||
const rrows = [];
|
|
||||||
const widths = this.columnWidths(row);
|
|
||||||
let wrapped;
|
|
||||||
// word wrap all columns, and create
|
|
||||||
// a data-structure that is easy to rasterize.
|
|
||||||
row.forEach((col, c) => {
|
|
||||||
// leave room for left and right padding.
|
|
||||||
col.width = widths[c];
|
|
||||||
if (this.wrap) {
|
|
||||||
wrapped = mixin.wrap(col.text, this.negatePadding(col), { hard: true }).split('\n');
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
wrapped = col.text.split('\n');
|
|
||||||
}
|
|
||||||
if (col.border) {
|
|
||||||
wrapped.unshift('.' + '-'.repeat(this.negatePadding(col) + 2) + '.');
|
|
||||||
wrapped.push("'" + '-'.repeat(this.negatePadding(col) + 2) + "'");
|
|
||||||
}
|
|
||||||
// add top and bottom padding.
|
|
||||||
if (col.padding) {
|
|
||||||
wrapped.unshift(...new Array(col.padding[top] || 0).fill(''));
|
|
||||||
wrapped.push(...new Array(col.padding[bottom] || 0).fill(''));
|
|
||||||
}
|
|
||||||
wrapped.forEach((str, r) => {
|
|
||||||
if (!rrows[r]) {
|
|
||||||
rrows.push([]);
|
|
||||||
}
|
|
||||||
const rrow = rrows[r];
|
|
||||||
for (let i = 0; i < c; i++) {
|
|
||||||
if (rrow[i] === undefined) {
|
|
||||||
rrow.push('');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
rrow.push(str);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return rrows;
|
|
||||||
}
|
|
||||||
negatePadding(col) {
|
|
||||||
/* c8 ignore start */
|
|
||||||
let wrapWidth = col.width || 0;
|
|
||||||
/* c8 ignore stop */
|
|
||||||
if (col.padding) {
|
|
||||||
wrapWidth -= (col.padding[left] || 0) + (col.padding[right] || 0);
|
|
||||||
}
|
|
||||||
if (col.border) {
|
|
||||||
wrapWidth -= 4;
|
|
||||||
}
|
|
||||||
return wrapWidth;
|
|
||||||
}
|
|
||||||
columnWidths(row) {
|
|
||||||
if (!this.wrap) {
|
|
||||||
return row.map(col => {
|
|
||||||
return col.width || mixin.stringWidth(col.text);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
let unset = row.length;
|
|
||||||
let remainingWidth = this.width;
|
|
||||||
// column widths can be set in config.
|
|
||||||
const widths = row.map(col => {
|
|
||||||
if (col.width) {
|
|
||||||
unset--;
|
|
||||||
remainingWidth -= col.width;
|
|
||||||
return col.width;
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
});
|
|
||||||
// any unset widths should be calculated.
|
|
||||||
/* c8 ignore start */
|
|
||||||
const unsetWidth = unset ? Math.floor(remainingWidth / unset) : 0;
|
|
||||||
/* c8 ignore stop */
|
|
||||||
return widths.map((w, i) => {
|
|
||||||
if (w === undefined) {
|
|
||||||
return Math.max(unsetWidth, _minWidth(row[i]));
|
|
||||||
}
|
|
||||||
return w;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function addBorder(col, ts, style) {
|
|
||||||
if (col.border) {
|
|
||||||
if (/[.']-+[.']/.test(ts)) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
if (ts.trim().length !== 0) {
|
|
||||||
return style;
|
|
||||||
}
|
|
||||||
return ' ';
|
|
||||||
}
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
// calculates the minimum width of
|
|
||||||
// a column, based on padding preferences.
|
|
||||||
function _minWidth(col) {
|
|
||||||
const padding = col.padding || [];
|
|
||||||
const minWidth = 1 + (padding[left] || 0) + (padding[right] || 0);
|
|
||||||
if (col.border) {
|
|
||||||
return minWidth + 4;
|
|
||||||
}
|
|
||||||
return minWidth;
|
|
||||||
}
|
|
||||||
function getWindowWidth() {
|
|
||||||
/* c8 ignore start */
|
|
||||||
if (typeof process === 'object' && process.stdout && process.stdout.columns) {
|
|
||||||
return process.stdout.columns;
|
|
||||||
}
|
|
||||||
return 80;
|
|
||||||
}
|
|
||||||
/* c8 ignore stop */
|
|
||||||
function alignRight(str, width) {
|
|
||||||
str = str.trim();
|
|
||||||
const strWidth = mixin.stringWidth(str);
|
|
||||||
if (strWidth < width) {
|
|
||||||
return ' '.repeat(width - strWidth) + str;
|
|
||||||
}
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
function alignCenter(str, width) {
|
|
||||||
str = str.trim();
|
|
||||||
const strWidth = mixin.stringWidth(str);
|
|
||||||
/* c8 ignore start */
|
|
||||||
if (strWidth >= width) {
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
/* c8 ignore stop */
|
|
||||||
return ' '.repeat((width - strWidth) >> 1) + str;
|
|
||||||
}
|
|
||||||
let mixin;
|
|
||||||
function cliui(opts, _mixin) {
|
|
||||||
mixin = _mixin;
|
|
||||||
return new UI({
|
|
||||||
/* c8 ignore start */
|
|
||||||
width: (opts === null || opts === void 0 ? void 0 : opts.width) || getWindowWidth(),
|
|
||||||
wrap: opts === null || opts === void 0 ? void 0 : opts.wrap
|
|
||||||
/* c8 ignore stop */
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bootstrap cliui with CommonJS dependencies:
|
|
||||||
const stringWidth = require('string-width-cjs');
|
|
||||||
const stripAnsi = require('strip-ansi-cjs');
|
|
||||||
const wrap = require('wrap-ansi-cjs');
|
|
||||||
function ui(opts) {
|
|
||||||
return cliui(opts, {
|
|
||||||
stringWidth,
|
|
||||||
stripAnsi,
|
|
||||||
wrap
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = ui;
|
|
||||||
43
node_modules/@isaacs/cliui/build/index.d.cts
generated
vendored
|
|
@ -1,43 +0,0 @@
|
||||||
interface UIOptions {
|
|
||||||
width: number;
|
|
||||||
wrap?: boolean;
|
|
||||||
rows?: string[];
|
|
||||||
}
|
|
||||||
interface Column {
|
|
||||||
text: string;
|
|
||||||
width?: number;
|
|
||||||
align?: "right" | "left" | "center";
|
|
||||||
padding: number[];
|
|
||||||
border?: boolean;
|
|
||||||
}
|
|
||||||
interface ColumnArray extends Array<Column> {
|
|
||||||
span: boolean;
|
|
||||||
}
|
|
||||||
interface Line {
|
|
||||||
hidden?: boolean;
|
|
||||||
text: string;
|
|
||||||
span?: boolean;
|
|
||||||
}
|
|
||||||
declare class UI {
|
|
||||||
width: number;
|
|
||||||
wrap: boolean;
|
|
||||||
rows: ColumnArray[];
|
|
||||||
constructor(opts: UIOptions);
|
|
||||||
span(...args: ColumnArray): void;
|
|
||||||
resetOutput(): void;
|
|
||||||
div(...args: (Column | string)[]): ColumnArray;
|
|
||||||
private shouldApplyLayoutDSL;
|
|
||||||
private applyLayoutDSL;
|
|
||||||
private colFromString;
|
|
||||||
private measurePadding;
|
|
||||||
toString(): string;
|
|
||||||
rowToString(row: ColumnArray, lines: Line[]): Line[];
|
|
||||||
// if the full 'source' can render in
|
|
||||||
// the target line, do so.
|
|
||||||
private renderInline;
|
|
||||||
private rasterize;
|
|
||||||
private negatePadding;
|
|
||||||
private columnWidths;
|
|
||||||
}
|
|
||||||
declare function ui(opts: UIOptions): UI;
|
|
||||||
export { ui as default };
|
|
||||||
302
node_modules/@isaacs/cliui/build/lib/index.js
generated
vendored
|
|
@ -1,302 +0,0 @@
|
||||||
'use strict';
|
|
||||||
const align = {
|
|
||||||
right: alignRight,
|
|
||||||
center: alignCenter
|
|
||||||
};
|
|
||||||
const top = 0;
|
|
||||||
const right = 1;
|
|
||||||
const bottom = 2;
|
|
||||||
const left = 3;
|
|
||||||
export class UI {
|
|
||||||
constructor(opts) {
|
|
||||||
var _a;
|
|
||||||
this.width = opts.width;
|
|
||||||
/* c8 ignore start */
|
|
||||||
this.wrap = (_a = opts.wrap) !== null && _a !== void 0 ? _a : true;
|
|
||||||
/* c8 ignore stop */
|
|
||||||
this.rows = [];
|
|
||||||
}
|
|
||||||
span(...args) {
|
|
||||||
const cols = this.div(...args);
|
|
||||||
cols.span = true;
|
|
||||||
}
|
|
||||||
resetOutput() {
|
|
||||||
this.rows = [];
|
|
||||||
}
|
|
||||||
div(...args) {
|
|
||||||
if (args.length === 0) {
|
|
||||||
this.div('');
|
|
||||||
}
|
|
||||||
if (this.wrap && this.shouldApplyLayoutDSL(...args) && typeof args[0] === 'string') {
|
|
||||||
return this.applyLayoutDSL(args[0]);
|
|
||||||
}
|
|
||||||
const cols = args.map(arg => {
|
|
||||||
if (typeof arg === 'string') {
|
|
||||||
return this.colFromString(arg);
|
|
||||||
}
|
|
||||||
return arg;
|
|
||||||
});
|
|
||||||
this.rows.push(cols);
|
|
||||||
return cols;
|
|
||||||
}
|
|
||||||
shouldApplyLayoutDSL(...args) {
|
|
||||||
return args.length === 1 && typeof args[0] === 'string' &&
|
|
||||||
/[\t\n]/.test(args[0]);
|
|
||||||
}
|
|
||||||
applyLayoutDSL(str) {
|
|
||||||
const rows = str.split('\n').map(row => row.split('\t'));
|
|
||||||
let leftColumnWidth = 0;
|
|
||||||
// simple heuristic for layout, make sure the
|
|
||||||
// second column lines up along the left-hand.
|
|
||||||
// don't allow the first column to take up more
|
|
||||||
// than 50% of the screen.
|
|
||||||
rows.forEach(columns => {
|
|
||||||
if (columns.length > 1 && mixin.stringWidth(columns[0]) > leftColumnWidth) {
|
|
||||||
leftColumnWidth = Math.min(Math.floor(this.width * 0.5), mixin.stringWidth(columns[0]));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// generate a table:
|
|
||||||
// replacing ' ' with padding calculations.
|
|
||||||
// using the algorithmically generated width.
|
|
||||||
rows.forEach(columns => {
|
|
||||||
this.div(...columns.map((r, i) => {
|
|
||||||
return {
|
|
||||||
text: r.trim(),
|
|
||||||
padding: this.measurePadding(r),
|
|
||||||
width: (i === 0 && columns.length > 1) ? leftColumnWidth : undefined
|
|
||||||
};
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
return this.rows[this.rows.length - 1];
|
|
||||||
}
|
|
||||||
colFromString(text) {
|
|
||||||
return {
|
|
||||||
text,
|
|
||||||
padding: this.measurePadding(text)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
measurePadding(str) {
|
|
||||||
// measure padding without ansi escape codes
|
|
||||||
const noAnsi = mixin.stripAnsi(str);
|
|
||||||
return [0, noAnsi.match(/\s*$/)[0].length, 0, noAnsi.match(/^\s*/)[0].length];
|
|
||||||
}
|
|
||||||
toString() {
|
|
||||||
const lines = [];
|
|
||||||
this.rows.forEach(row => {
|
|
||||||
this.rowToString(row, lines);
|
|
||||||
});
|
|
||||||
// don't display any lines with the
|
|
||||||
// hidden flag set.
|
|
||||||
return lines
|
|
||||||
.filter(line => !line.hidden)
|
|
||||||
.map(line => line.text)
|
|
||||||
.join('\n');
|
|
||||||
}
|
|
||||||
rowToString(row, lines) {
|
|
||||||
this.rasterize(row).forEach((rrow, r) => {
|
|
||||||
let str = '';
|
|
||||||
rrow.forEach((col, c) => {
|
|
||||||
const { width } = row[c]; // the width with padding.
|
|
||||||
const wrapWidth = this.negatePadding(row[c]); // the width without padding.
|
|
||||||
let ts = col; // temporary string used during alignment/padding.
|
|
||||||
if (wrapWidth > mixin.stringWidth(col)) {
|
|
||||||
ts += ' '.repeat(wrapWidth - mixin.stringWidth(col));
|
|
||||||
}
|
|
||||||
// align the string within its column.
|
|
||||||
if (row[c].align && row[c].align !== 'left' && this.wrap) {
|
|
||||||
const fn = align[row[c].align];
|
|
||||||
ts = fn(ts, wrapWidth);
|
|
||||||
if (mixin.stringWidth(ts) < wrapWidth) {
|
|
||||||
/* c8 ignore start */
|
|
||||||
const w = width || 0;
|
|
||||||
/* c8 ignore stop */
|
|
||||||
ts += ' '.repeat(w - mixin.stringWidth(ts) - 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// apply border and padding to string.
|
|
||||||
const padding = row[c].padding || [0, 0, 0, 0];
|
|
||||||
if (padding[left]) {
|
|
||||||
str += ' '.repeat(padding[left]);
|
|
||||||
}
|
|
||||||
str += addBorder(row[c], ts, '| ');
|
|
||||||
str += ts;
|
|
||||||
str += addBorder(row[c], ts, ' |');
|
|
||||||
if (padding[right]) {
|
|
||||||
str += ' '.repeat(padding[right]);
|
|
||||||
}
|
|
||||||
// if prior row is span, try to render the
|
|
||||||
// current row on the prior line.
|
|
||||||
if (r === 0 && lines.length > 0) {
|
|
||||||
str = this.renderInline(str, lines[lines.length - 1]);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// remove trailing whitespace.
|
|
||||||
lines.push({
|
|
||||||
text: str.replace(/ +$/, ''),
|
|
||||||
span: row.span
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return lines;
|
|
||||||
}
|
|
||||||
// if the full 'source' can render in
|
|
||||||
// the target line, do so.
|
|
||||||
renderInline(source, previousLine) {
|
|
||||||
const match = source.match(/^ */);
|
|
||||||
/* c8 ignore start */
|
|
||||||
const leadingWhitespace = match ? match[0].length : 0;
|
|
||||||
/* c8 ignore stop */
|
|
||||||
const target = previousLine.text;
|
|
||||||
const targetTextWidth = mixin.stringWidth(target.trimEnd());
|
|
||||||
if (!previousLine.span) {
|
|
||||||
return source;
|
|
||||||
}
|
|
||||||
// if we're not applying wrapping logic,
|
|
||||||
// just always append to the span.
|
|
||||||
if (!this.wrap) {
|
|
||||||
previousLine.hidden = true;
|
|
||||||
return target + source;
|
|
||||||
}
|
|
||||||
if (leadingWhitespace < targetTextWidth) {
|
|
||||||
return source;
|
|
||||||
}
|
|
||||||
previousLine.hidden = true;
|
|
||||||
return target.trimEnd() + ' '.repeat(leadingWhitespace - targetTextWidth) + source.trimStart();
|
|
||||||
}
|
|
||||||
rasterize(row) {
|
|
||||||
const rrows = [];
|
|
||||||
const widths = this.columnWidths(row);
|
|
||||||
let wrapped;
|
|
||||||
// word wrap all columns, and create
|
|
||||||
// a data-structure that is easy to rasterize.
|
|
||||||
row.forEach((col, c) => {
|
|
||||||
// leave room for left and right padding.
|
|
||||||
col.width = widths[c];
|
|
||||||
if (this.wrap) {
|
|
||||||
wrapped = mixin.wrap(col.text, this.negatePadding(col), { hard: true }).split('\n');
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
wrapped = col.text.split('\n');
|
|
||||||
}
|
|
||||||
if (col.border) {
|
|
||||||
wrapped.unshift('.' + '-'.repeat(this.negatePadding(col) + 2) + '.');
|
|
||||||
wrapped.push("'" + '-'.repeat(this.negatePadding(col) + 2) + "'");
|
|
||||||
}
|
|
||||||
// add top and bottom padding.
|
|
||||||
if (col.padding) {
|
|
||||||
wrapped.unshift(...new Array(col.padding[top] || 0).fill(''));
|
|
||||||
wrapped.push(...new Array(col.padding[bottom] || 0).fill(''));
|
|
||||||
}
|
|
||||||
wrapped.forEach((str, r) => {
|
|
||||||
if (!rrows[r]) {
|
|
||||||
rrows.push([]);
|
|
||||||
}
|
|
||||||
const rrow = rrows[r];
|
|
||||||
for (let i = 0; i < c; i++) {
|
|
||||||
if (rrow[i] === undefined) {
|
|
||||||
rrow.push('');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
rrow.push(str);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return rrows;
|
|
||||||
}
|
|
||||||
negatePadding(col) {
|
|
||||||
/* c8 ignore start */
|
|
||||||
let wrapWidth = col.width || 0;
|
|
||||||
/* c8 ignore stop */
|
|
||||||
if (col.padding) {
|
|
||||||
wrapWidth -= (col.padding[left] || 0) + (col.padding[right] || 0);
|
|
||||||
}
|
|
||||||
if (col.border) {
|
|
||||||
wrapWidth -= 4;
|
|
||||||
}
|
|
||||||
return wrapWidth;
|
|
||||||
}
|
|
||||||
columnWidths(row) {
|
|
||||||
if (!this.wrap) {
|
|
||||||
return row.map(col => {
|
|
||||||
return col.width || mixin.stringWidth(col.text);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
let unset = row.length;
|
|
||||||
let remainingWidth = this.width;
|
|
||||||
// column widths can be set in config.
|
|
||||||
const widths = row.map(col => {
|
|
||||||
if (col.width) {
|
|
||||||
unset--;
|
|
||||||
remainingWidth -= col.width;
|
|
||||||
return col.width;
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
});
|
|
||||||
// any unset widths should be calculated.
|
|
||||||
/* c8 ignore start */
|
|
||||||
const unsetWidth = unset ? Math.floor(remainingWidth / unset) : 0;
|
|
||||||
/* c8 ignore stop */
|
|
||||||
return widths.map((w, i) => {
|
|
||||||
if (w === undefined) {
|
|
||||||
return Math.max(unsetWidth, _minWidth(row[i]));
|
|
||||||
}
|
|
||||||
return w;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function addBorder(col, ts, style) {
|
|
||||||
if (col.border) {
|
|
||||||
if (/[.']-+[.']/.test(ts)) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
if (ts.trim().length !== 0) {
|
|
||||||
return style;
|
|
||||||
}
|
|
||||||
return ' ';
|
|
||||||
}
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
// calculates the minimum width of
|
|
||||||
// a column, based on padding preferences.
|
|
||||||
function _minWidth(col) {
|
|
||||||
const padding = col.padding || [];
|
|
||||||
const minWidth = 1 + (padding[left] || 0) + (padding[right] || 0);
|
|
||||||
if (col.border) {
|
|
||||||
return minWidth + 4;
|
|
||||||
}
|
|
||||||
return minWidth;
|
|
||||||
}
|
|
||||||
function getWindowWidth() {
|
|
||||||
/* c8 ignore start */
|
|
||||||
if (typeof process === 'object' && process.stdout && process.stdout.columns) {
|
|
||||||
return process.stdout.columns;
|
|
||||||
}
|
|
||||||
return 80;
|
|
||||||
}
|
|
||||||
/* c8 ignore stop */
|
|
||||||
function alignRight(str, width) {
|
|
||||||
str = str.trim();
|
|
||||||
const strWidth = mixin.stringWidth(str);
|
|
||||||
if (strWidth < width) {
|
|
||||||
return ' '.repeat(width - strWidth) + str;
|
|
||||||
}
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
function alignCenter(str, width) {
|
|
||||||
str = str.trim();
|
|
||||||
const strWidth = mixin.stringWidth(str);
|
|
||||||
/* c8 ignore start */
|
|
||||||
if (strWidth >= width) {
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
/* c8 ignore stop */
|
|
||||||
return ' '.repeat((width - strWidth) >> 1) + str;
|
|
||||||
}
|
|
||||||
let mixin;
|
|
||||||
export function cliui(opts, _mixin) {
|
|
||||||
mixin = _mixin;
|
|
||||||
return new UI({
|
|
||||||
/* c8 ignore start */
|
|
||||||
width: (opts === null || opts === void 0 ? void 0 : opts.width) || getWindowWidth(),
|
|
||||||
wrap: opts === null || opts === void 0 ? void 0 : opts.wrap
|
|
||||||
/* c8 ignore stop */
|
|
||||||
});
|
|
||||||
}
|
|
||||||
14
node_modules/@isaacs/cliui/index.mjs
generated
vendored
|
|
@ -1,14 +0,0 @@
|
||||||
// Bootstrap cliui with ESM dependencies:
|
|
||||||
import { cliui } from './build/lib/index.js'
|
|
||||||
|
|
||||||
import stringWidth from 'string-width'
|
|
||||||
import stripAnsi from 'strip-ansi'
|
|
||||||
import wrap from 'wrap-ansi'
|
|
||||||
|
|
||||||
export default function ui (opts) {
|
|
||||||
return cliui(opts, {
|
|
||||||
stringWidth,
|
|
||||||
stripAnsi,
|
|
||||||
wrap
|
|
||||||
})
|
|
||||||
}
|
|
||||||
86
node_modules/@isaacs/cliui/package.json
generated
vendored
|
|
@ -1,86 +0,0 @@
|
||||||
{
|
|
||||||
"name": "@isaacs/cliui",
|
|
||||||
"version": "8.0.2",
|
|
||||||
"description": "easily create complex multi-column command-line-interfaces",
|
|
||||||
"main": "build/index.cjs",
|
|
||||||
"exports": {
|
|
||||||
".": [
|
|
||||||
{
|
|
||||||
"import": "./index.mjs",
|
|
||||||
"require": "./build/index.cjs"
|
|
||||||
},
|
|
||||||
"./build/index.cjs"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"type": "module",
|
|
||||||
"module": "./index.mjs",
|
|
||||||
"scripts": {
|
|
||||||
"check": "standardx '**/*.ts' && standardx '**/*.js' && standardx '**/*.cjs'",
|
|
||||||
"fix": "standardx --fix '**/*.ts' && standardx --fix '**/*.js' && standardx --fix '**/*.cjs'",
|
|
||||||
"pretest": "rimraf build && tsc -p tsconfig.test.json && cross-env NODE_ENV=test npm run build:cjs",
|
|
||||||
"test": "c8 mocha ./test/*.cjs",
|
|
||||||
"test:esm": "c8 mocha ./test/**/*.mjs",
|
|
||||||
"postest": "check",
|
|
||||||
"coverage": "c8 report --check-coverage",
|
|
||||||
"precompile": "rimraf build",
|
|
||||||
"compile": "tsc",
|
|
||||||
"postcompile": "npm run build:cjs",
|
|
||||||
"build:cjs": "rollup -c",
|
|
||||||
"prepare": "npm run compile"
|
|
||||||
},
|
|
||||||
"repository": "yargs/cliui",
|
|
||||||
"standard": {
|
|
||||||
"ignore": [
|
|
||||||
"**/example/**"
|
|
||||||
],
|
|
||||||
"globals": [
|
|
||||||
"it"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"keywords": [
|
|
||||||
"cli",
|
|
||||||
"command-line",
|
|
||||||
"layout",
|
|
||||||
"design",
|
|
||||||
"console",
|
|
||||||
"wrap",
|
|
||||||
"table"
|
|
||||||
],
|
|
||||||
"author": "Ben Coe <ben@npmjs.com>",
|
|
||||||
"license": "ISC",
|
|
||||||
"dependencies": {
|
|
||||||
"string-width": "^5.1.2",
|
|
||||||
"string-width-cjs": "npm:string-width@^4.2.0",
|
|
||||||
"strip-ansi": "^7.0.1",
|
|
||||||
"strip-ansi-cjs": "npm:strip-ansi@^6.0.1",
|
|
||||||
"wrap-ansi": "^8.1.0",
|
|
||||||
"wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@types/node": "^14.0.27",
|
|
||||||
"@typescript-eslint/eslint-plugin": "^4.0.0",
|
|
||||||
"@typescript-eslint/parser": "^4.0.0",
|
|
||||||
"c8": "^7.3.0",
|
|
||||||
"chai": "^4.2.0",
|
|
||||||
"chalk": "^4.1.0",
|
|
||||||
"cross-env": "^7.0.2",
|
|
||||||
"eslint": "^7.6.0",
|
|
||||||
"eslint-plugin-import": "^2.22.0",
|
|
||||||
"eslint-plugin-node": "^11.1.0",
|
|
||||||
"gts": "^3.0.0",
|
|
||||||
"mocha": "^10.0.0",
|
|
||||||
"rimraf": "^3.0.2",
|
|
||||||
"rollup": "^2.23.1",
|
|
||||||
"rollup-plugin-ts": "^3.0.2",
|
|
||||||
"standardx": "^7.0.0",
|
|
||||||
"typescript": "^4.0.0"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"build",
|
|
||||||
"index.mjs",
|
|
||||||
"!*.d.ts"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">=12"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
14
node_modules/@pkgjs/parseargs/.editorconfig
generated
vendored
|
|
@ -1,14 +0,0 @@
|
||||||
# EditorConfig is awesome: http://EditorConfig.org
|
|
||||||
|
|
||||||
# top-most EditorConfig file
|
|
||||||
root = true
|
|
||||||
|
|
||||||
# Copied from Node.js to ease compatibility in PR.
|
|
||||||
[*]
|
|
||||||
charset = utf-8
|
|
||||||
end_of_line = lf
|
|
||||||
indent_size = 2
|
|
||||||
indent_style = space
|
|
||||||
insert_final_newline = true
|
|
||||||
trim_trailing_whitespace = true
|
|
||||||
quote_type = single
|
|
||||||
147
node_modules/@pkgjs/parseargs/CHANGELOG.md
generated
vendored
|
|
@ -1,147 +0,0 @@
|
||||||
# Changelog
|
|
||||||
|
|
||||||
## [0.11.0](https://github.com/pkgjs/parseargs/compare/v0.10.0...v0.11.0) (2022-10-08)
|
|
||||||
|
|
||||||
|
|
||||||
### Features
|
|
||||||
|
|
||||||
* add `default` option parameter ([#142](https://github.com/pkgjs/parseargs/issues/142)) ([cd20847](https://github.com/pkgjs/parseargs/commit/cd20847a00b2f556aa9c085ac83b942c60868ec1))
|
|
||||||
|
|
||||||
## [0.10.0](https://github.com/pkgjs/parseargs/compare/v0.9.1...v0.10.0) (2022-07-21)
|
|
||||||
|
|
||||||
|
|
||||||
### Features
|
|
||||||
|
|
||||||
* add parsed meta-data to returned properties ([#129](https://github.com/pkgjs/parseargs/issues/129)) ([91bfb4d](https://github.com/pkgjs/parseargs/commit/91bfb4d3f7b6937efab1b27c91c45d1205f1497e))
|
|
||||||
|
|
||||||
## [0.9.1](https://github.com/pkgjs/parseargs/compare/v0.9.0...v0.9.1) (2022-06-20)
|
|
||||||
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* **runtime:** support node 14+ ([#135](https://github.com/pkgjs/parseargs/issues/135)) ([6a1c5a6](https://github.com/pkgjs/parseargs/commit/6a1c5a6f7cadf2f035e004027e2742e3c4ce554b))
|
|
||||||
|
|
||||||
## [0.9.0](https://github.com/pkgjs/parseargs/compare/v0.8.0...v0.9.0) (2022-05-23)
|
|
||||||
|
|
||||||
|
|
||||||
### ⚠ BREAKING CHANGES
|
|
||||||
|
|
||||||
* drop handling of electron arguments (#121)
|
|
||||||
|
|
||||||
### Code Refactoring
|
|
||||||
|
|
||||||
* drop handling of electron arguments ([#121](https://github.com/pkgjs/parseargs/issues/121)) ([a2ffd53](https://github.com/pkgjs/parseargs/commit/a2ffd537c244a062371522b955acb45a404fc9f2))
|
|
||||||
|
|
||||||
## [0.8.0](https://github.com/pkgjs/parseargs/compare/v0.7.1...v0.8.0) (2022-05-16)
|
|
||||||
|
|
||||||
|
|
||||||
### ⚠ BREAKING CHANGES
|
|
||||||
|
|
||||||
* switch type:string option arguments to greedy, but with error for suspect cases in strict mode (#88)
|
|
||||||
* positionals now opt-in when strict:true (#116)
|
|
||||||
* create result.values with null prototype (#111)
|
|
||||||
|
|
||||||
### Features
|
|
||||||
|
|
||||||
* create result.values with null prototype ([#111](https://github.com/pkgjs/parseargs/issues/111)) ([9d539c3](https://github.com/pkgjs/parseargs/commit/9d539c3d57f269c160e74e0656ad4fa84ff92ec2))
|
|
||||||
* positionals now opt-in when strict:true ([#116](https://github.com/pkgjs/parseargs/issues/116)) ([3643338](https://github.com/pkgjs/parseargs/commit/364333826b746e8a7dc5505b4b22fd19ac51df3b))
|
|
||||||
* switch type:string option arguments to greedy, but with error for suspect cases in strict mode ([#88](https://github.com/pkgjs/parseargs/issues/88)) ([c2b5e72](https://github.com/pkgjs/parseargs/commit/c2b5e72161991dfdc535909f1327cc9b970fe7e8))
|
|
||||||
|
|
||||||
### [0.7.1](https://github.com/pkgjs/parseargs/compare/v0.7.0...v0.7.1) (2022-04-15)
|
|
||||||
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* resist pollution ([#106](https://github.com/pkgjs/parseargs/issues/106)) ([ecf2dec](https://github.com/pkgjs/parseargs/commit/ecf2dece0a9f2a76d789384d5d71c68ffe64022a))
|
|
||||||
|
|
||||||
## [0.7.0](https://github.com/pkgjs/parseargs/compare/v0.6.0...v0.7.0) (2022-04-13)
|
|
||||||
|
|
||||||
|
|
||||||
### Features
|
|
||||||
|
|
||||||
* Add strict mode to parser ([#74](https://github.com/pkgjs/parseargs/issues/74)) ([8267d02](https://github.com/pkgjs/parseargs/commit/8267d02083a87b8b8a71fcce08348d1e031ea91c))
|
|
||||||
|
|
||||||
## [0.6.0](https://github.com/pkgjs/parseargs/compare/v0.5.0...v0.6.0) (2022-04-11)
|
|
||||||
|
|
||||||
|
|
||||||
### ⚠ BREAKING CHANGES
|
|
||||||
|
|
||||||
* rework results to remove redundant `flags` property and store value true for boolean options (#83)
|
|
||||||
* switch to existing ERR_INVALID_ARG_VALUE (#97)
|
|
||||||
|
|
||||||
### Code Refactoring
|
|
||||||
|
|
||||||
* rework results to remove redundant `flags` property and store value true for boolean options ([#83](https://github.com/pkgjs/parseargs/issues/83)) ([be153db](https://github.com/pkgjs/parseargs/commit/be153dbed1d488cb7b6e27df92f601ba7337713d))
|
|
||||||
* switch to existing ERR_INVALID_ARG_VALUE ([#97](https://github.com/pkgjs/parseargs/issues/97)) ([084a23f](https://github.com/pkgjs/parseargs/commit/084a23f9fde2da030b159edb1c2385f24579ce40))
|
|
||||||
|
|
||||||
## [0.5.0](https://github.com/pkgjs/parseargs/compare/v0.4.0...v0.5.0) (2022-04-10)
|
|
||||||
|
|
||||||
|
|
||||||
### ⚠ BREAKING CHANGES
|
|
||||||
|
|
||||||
* Require type to be specified for each supplied option (#95)
|
|
||||||
|
|
||||||
### Features
|
|
||||||
|
|
||||||
* Require type to be specified for each supplied option ([#95](https://github.com/pkgjs/parseargs/issues/95)) ([02cd018](https://github.com/pkgjs/parseargs/commit/02cd01885b8aaa59f2db8308f2d4479e64340068))
|
|
||||||
|
|
||||||
## [0.4.0](https://github.com/pkgjs/parseargs/compare/v0.3.0...v0.4.0) (2022-03-12)
|
|
||||||
|
|
||||||
|
|
||||||
### ⚠ BREAKING CHANGES
|
|
||||||
|
|
||||||
* parsing, revisit short option groups, add support for combined short and value (#75)
|
|
||||||
* restructure configuration to take options bag (#63)
|
|
||||||
|
|
||||||
### Code Refactoring
|
|
||||||
|
|
||||||
* parsing, revisit short option groups, add support for combined short and value ([#75](https://github.com/pkgjs/parseargs/issues/75)) ([a92600f](https://github.com/pkgjs/parseargs/commit/a92600fa6c214508ab1e016fa55879a314f541af))
|
|
||||||
* restructure configuration to take options bag ([#63](https://github.com/pkgjs/parseargs/issues/63)) ([b412095](https://github.com/pkgjs/parseargs/commit/b4120957d90e809ee8b607b06e747d3e6a6b213e))
|
|
||||||
|
|
||||||
## [0.3.0](https://github.com/pkgjs/parseargs/compare/v0.2.0...v0.3.0) (2022-02-06)
|
|
||||||
|
|
||||||
|
|
||||||
### Features
|
|
||||||
|
|
||||||
* **parser:** support short-option groups ([#59](https://github.com/pkgjs/parseargs/issues/59)) ([882067b](https://github.com/pkgjs/parseargs/commit/882067bc2d7cbc6b796f8e5a079a99bc99d4e6ba))
|
|
||||||
|
|
||||||
## [0.2.0](https://github.com/pkgjs/parseargs/compare/v0.1.1...v0.2.0) (2022-02-05)
|
|
||||||
|
|
||||||
|
|
||||||
### Features
|
|
||||||
|
|
||||||
* basic support for shorts ([#50](https://github.com/pkgjs/parseargs/issues/50)) ([a2f36d7](https://github.com/pkgjs/parseargs/commit/a2f36d7da4145af1c92f76806b7fe2baf6beeceb))
|
|
||||||
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* always store value for a=b ([#43](https://github.com/pkgjs/parseargs/issues/43)) ([a85e8dc](https://github.com/pkgjs/parseargs/commit/a85e8dc06379fd2696ee195cc625de8fac6aee42))
|
|
||||||
* support single dash as positional ([#49](https://github.com/pkgjs/parseargs/issues/49)) ([d795bf8](https://github.com/pkgjs/parseargs/commit/d795bf877d068fd67aec381f30b30b63f97109ad))
|
|
||||||
|
|
||||||
### [0.1.1](https://github.com/pkgjs/parseargs/compare/v0.1.0...v0.1.1) (2022-01-25)
|
|
||||||
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* only use arrays in results for multiples ([#42](https://github.com/pkgjs/parseargs/issues/42)) ([c357584](https://github.com/pkgjs/parseargs/commit/c357584847912506319ed34a0840080116f4fd65))
|
|
||||||
|
|
||||||
## 0.1.0 (2022-01-22)
|
|
||||||
|
|
||||||
|
|
||||||
### Features
|
|
||||||
|
|
||||||
* expand scenarios covered by default arguments for environments ([#20](https://github.com/pkgjs/parseargs/issues/20)) ([582ada7](https://github.com/pkgjs/parseargs/commit/582ada7be0eca3a73d6e0bd016e7ace43449fa4c))
|
|
||||||
* update readme and include contributing guidelines ([8edd6fc](https://github.com/pkgjs/parseargs/commit/8edd6fc863cd705f6fac732724159ebe8065a2b0))
|
|
||||||
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* do not strip excess leading dashes on long option names ([#21](https://github.com/pkgjs/parseargs/issues/21)) ([f848590](https://github.com/pkgjs/parseargs/commit/f848590ebf3249ed5979ff47e003fa6e1a8ec5c0))
|
|
||||||
* name & readme ([3f057c1](https://github.com/pkgjs/parseargs/commit/3f057c1b158a1bdbe878c64b57460c58e56e465f))
|
|
||||||
* package.json values ([9bac300](https://github.com/pkgjs/parseargs/commit/9bac300e00cd76c77076bf9e75e44f8929512da9))
|
|
||||||
* update readme name ([957d8d9](https://github.com/pkgjs/parseargs/commit/957d8d96e1dcb48297c0a14345d44c0123b2883e))
|
|
||||||
|
|
||||||
|
|
||||||
### Build System
|
|
||||||
|
|
||||||
* first release as minor ([421c6e2](https://github.com/pkgjs/parseargs/commit/421c6e2569a8668ad14fac5a5af5be60479a7571))
|
|
||||||
201
node_modules/@pkgjs/parseargs/LICENSE
generated
vendored
|
|
@ -1,201 +0,0 @@
|
||||||
Apache License
|
|
||||||
Version 2.0, January 2004
|
|
||||||
http://www.apache.org/licenses/
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
||||||
|
|
||||||
1. Definitions.
|
|
||||||
|
|
||||||
"License" shall mean the terms and conditions for use, reproduction,
|
|
||||||
and distribution as defined by Sections 1 through 9 of this document.
|
|
||||||
|
|
||||||
"Licensor" shall mean the copyright owner or entity authorized by
|
|
||||||
the copyright owner that is granting the License.
|
|
||||||
|
|
||||||
"Legal Entity" shall mean the union of the acting entity and all
|
|
||||||
other entities that control, are controlled by, or are under common
|
|
||||||
control with that entity. For the purposes of this definition,
|
|
||||||
"control" means (i) the power, direct or indirect, to cause the
|
|
||||||
direction or management of such entity, whether by contract or
|
|
||||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
||||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
||||||
|
|
||||||
"You" (or "Your") shall mean an individual or Legal Entity
|
|
||||||
exercising permissions granted by this License.
|
|
||||||
|
|
||||||
"Source" form shall mean the preferred form for making modifications,
|
|
||||||
including but not limited to software source code, documentation
|
|
||||||
source, and configuration files.
|
|
||||||
|
|
||||||
"Object" form shall mean any form resulting from mechanical
|
|
||||||
transformation or translation of a Source form, including but
|
|
||||||
not limited to compiled object code, generated documentation,
|
|
||||||
and conversions to other media types.
|
|
||||||
|
|
||||||
"Work" shall mean the work of authorship, whether in Source or
|
|
||||||
Object form, made available under the License, as indicated by a
|
|
||||||
copyright notice that is included in or attached to the work
|
|
||||||
(an example is provided in the Appendix below).
|
|
||||||
|
|
||||||
"Derivative Works" shall mean any work, whether in Source or Object
|
|
||||||
form, that is based on (or derived from) the Work and for which the
|
|
||||||
editorial revisions, annotations, elaborations, or other modifications
|
|
||||||
represent, as a whole, an original work of authorship. For the purposes
|
|
||||||
of this License, Derivative Works shall not include works that remain
|
|
||||||
separable from, or merely link (or bind by name) to the interfaces of,
|
|
||||||
the Work and Derivative Works thereof.
|
|
||||||
|
|
||||||
"Contribution" shall mean any work of authorship, including
|
|
||||||
the original version of the Work and any modifications or additions
|
|
||||||
to that Work or Derivative Works thereof, that is intentionally
|
|
||||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
||||||
or by an individual or Legal Entity authorized to submit on behalf of
|
|
||||||
the copyright owner. For the purposes of this definition, "submitted"
|
|
||||||
means any form of electronic, verbal, or written communication sent
|
|
||||||
to the Licensor or its representatives, including but not limited to
|
|
||||||
communication on electronic mailing lists, source code control systems,
|
|
||||||
and issue tracking systems that are managed by, or on behalf of, the
|
|
||||||
Licensor for the purpose of discussing and improving the Work, but
|
|
||||||
excluding communication that is conspicuously marked or otherwise
|
|
||||||
designated in writing by the copyright owner as "Not a Contribution."
|
|
||||||
|
|
||||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
||||||
on behalf of whom a Contribution has been received by Licensor and
|
|
||||||
subsequently incorporated within the Work.
|
|
||||||
|
|
||||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
copyright license to reproduce, prepare Derivative Works of,
|
|
||||||
publicly display, publicly perform, sublicense, and distribute the
|
|
||||||
Work and such Derivative Works in Source or Object form.
|
|
||||||
|
|
||||||
3. Grant of Patent License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
(except as stated in this section) patent license to make, have made,
|
|
||||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
||||||
where such license applies only to those patent claims licensable
|
|
||||||
by such Contributor that are necessarily infringed by their
|
|
||||||
Contribution(s) alone or by combination of their Contribution(s)
|
|
||||||
with the Work to which such Contribution(s) was submitted. If You
|
|
||||||
institute patent litigation against any entity (including a
|
|
||||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
||||||
or a Contribution incorporated within the Work constitutes direct
|
|
||||||
or contributory patent infringement, then any patent licenses
|
|
||||||
granted to You under this License for that Work shall terminate
|
|
||||||
as of the date such litigation is filed.
|
|
||||||
|
|
||||||
4. Redistribution. You may reproduce and distribute copies of the
|
|
||||||
Work or Derivative Works thereof in any medium, with or without
|
|
||||||
modifications, and in Source or Object form, provided that You
|
|
||||||
meet the following conditions:
|
|
||||||
|
|
||||||
(a) You must give any other recipients of the Work or
|
|
||||||
Derivative Works a copy of this License; and
|
|
||||||
|
|
||||||
(b) You must cause any modified files to carry prominent notices
|
|
||||||
stating that You changed the files; and
|
|
||||||
|
|
||||||
(c) You must retain, in the Source form of any Derivative Works
|
|
||||||
that You distribute, all copyright, patent, trademark, and
|
|
||||||
attribution notices from the Source form of the Work,
|
|
||||||
excluding those notices that do not pertain to any part of
|
|
||||||
the Derivative Works; and
|
|
||||||
|
|
||||||
(d) If the Work includes a "NOTICE" text file as part of its
|
|
||||||
distribution, then any Derivative Works that You distribute must
|
|
||||||
include a readable copy of the attribution notices contained
|
|
||||||
within such NOTICE file, excluding those notices that do not
|
|
||||||
pertain to any part of the Derivative Works, in at least one
|
|
||||||
of the following places: within a NOTICE text file distributed
|
|
||||||
as part of the Derivative Works; within the Source form or
|
|
||||||
documentation, if provided along with the Derivative Works; or,
|
|
||||||
within a display generated by the Derivative Works, if and
|
|
||||||
wherever such third-party notices normally appear. The contents
|
|
||||||
of the NOTICE file are for informational purposes only and
|
|
||||||
do not modify the License. You may add Your own attribution
|
|
||||||
notices within Derivative Works that You distribute, alongside
|
|
||||||
or as an addendum to the NOTICE text from the Work, provided
|
|
||||||
that such additional attribution notices cannot be construed
|
|
||||||
as modifying the License.
|
|
||||||
|
|
||||||
You may add Your own copyright statement to Your modifications and
|
|
||||||
may provide additional or different license terms and conditions
|
|
||||||
for use, reproduction, or distribution of Your modifications, or
|
|
||||||
for any such Derivative Works as a whole, provided Your use,
|
|
||||||
reproduction, and distribution of the Work otherwise complies with
|
|
||||||
the conditions stated in this License.
|
|
||||||
|
|
||||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
||||||
any Contribution intentionally submitted for inclusion in the Work
|
|
||||||
by You to the Licensor shall be under the terms and conditions of
|
|
||||||
this License, without any additional terms or conditions.
|
|
||||||
Notwithstanding the above, nothing herein shall supersede or modify
|
|
||||||
the terms of any separate license agreement you may have executed
|
|
||||||
with Licensor regarding such Contributions.
|
|
||||||
|
|
||||||
6. Trademarks. This License does not grant permission to use the trade
|
|
||||||
names, trademarks, service marks, or product names of the Licensor,
|
|
||||||
except as required for reasonable and customary use in describing the
|
|
||||||
origin of the Work and reproducing the content of the NOTICE file.
|
|
||||||
|
|
||||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
||||||
agreed to in writing, Licensor provides the Work (and each
|
|
||||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
||||||
implied, including, without limitation, any warranties or conditions
|
|
||||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
||||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
||||||
appropriateness of using or redistributing the Work and assume any
|
|
||||||
risks associated with Your exercise of permissions under this License.
|
|
||||||
|
|
||||||
8. Limitation of Liability. In no event and under no legal theory,
|
|
||||||
whether in tort (including negligence), contract, or otherwise,
|
|
||||||
unless required by applicable law (such as deliberate and grossly
|
|
||||||
negligent acts) or agreed to in writing, shall any Contributor be
|
|
||||||
liable to You for damages, including any direct, indirect, special,
|
|
||||||
incidental, or consequential damages of any character arising as a
|
|
||||||
result of this License or out of the use or inability to use the
|
|
||||||
Work (including but not limited to damages for loss of goodwill,
|
|
||||||
work stoppage, computer failure or malfunction, or any and all
|
|
||||||
other commercial damages or losses), even if such Contributor
|
|
||||||
has been advised of the possibility of such damages.
|
|
||||||
|
|
||||||
9. Accepting Warranty or Additional Liability. While redistributing
|
|
||||||
the Work or Derivative Works thereof, You may choose to offer,
|
|
||||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
||||||
or other liability obligations and/or rights consistent with this
|
|
||||||
License. However, in accepting such obligations, You may act only
|
|
||||||
on Your own behalf and on Your sole responsibility, not on behalf
|
|
||||||
of any other Contributor, and only if You agree to indemnify,
|
|
||||||
defend, and hold each Contributor harmless for any liability
|
|
||||||
incurred by, or claims asserted against, such Contributor by reason
|
|
||||||
of your accepting any such warranty or additional liability.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
APPENDIX: How to apply the Apache License to your work.
|
|
||||||
|
|
||||||
To apply the Apache License to your work, attach the following
|
|
||||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
||||||
replaced with your own identifying information. (Don't include
|
|
||||||
the brackets!) The text should be enclosed in the appropriate
|
|
||||||
comment syntax for the file format. We also recommend that a
|
|
||||||
file or class name and description of purpose be included on the
|
|
||||||
same "printed page" as the copyright notice for easier
|
|
||||||
identification within third-party archives.
|
|
||||||
|
|
||||||
Copyright [yyyy] [name of copyright owner]
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
413
node_modules/@pkgjs/parseargs/README.md
generated
vendored
|
|
@ -1,413 +0,0 @@
|
||||||
<!-- omit in toc -->
|
|
||||||
# parseArgs
|
|
||||||
|
|
||||||
[![Coverage][coverage-image]][coverage-url]
|
|
||||||
|
|
||||||
Polyfill of `util.parseArgs()`
|
|
||||||
|
|
||||||
## `util.parseArgs([config])`
|
|
||||||
|
|
||||||
<!-- YAML
|
|
||||||
added: v18.3.0
|
|
||||||
changes:
|
|
||||||
- version: REPLACEME
|
|
||||||
pr-url: https://github.com/nodejs/node/pull/43459
|
|
||||||
description: add support for returning detailed parse information
|
|
||||||
using `tokens` in input `config` and returned properties.
|
|
||||||
-->
|
|
||||||
|
|
||||||
> Stability: 1 - Experimental
|
|
||||||
|
|
||||||
* `config` {Object} Used to provide arguments for parsing and to configure
|
|
||||||
the parser. `config` supports the following properties:
|
|
||||||
* `args` {string\[]} array of argument strings. **Default:** `process.argv`
|
|
||||||
with `execPath` and `filename` removed.
|
|
||||||
* `options` {Object} Used to describe arguments known to the parser.
|
|
||||||
Keys of `options` are the long names of options and values are an
|
|
||||||
{Object} accepting the following properties:
|
|
||||||
* `type` {string} Type of argument, which must be either `boolean` or `string`.
|
|
||||||
* `multiple` {boolean} Whether this option can be provided multiple
|
|
||||||
times. If `true`, all values will be collected in an array. If
|
|
||||||
`false`, values for the option are last-wins. **Default:** `false`.
|
|
||||||
* `short` {string} A single character alias for the option.
|
|
||||||
* `default` {string | boolean | string\[] | boolean\[]} The default option
|
|
||||||
value when it is not set by args. It must be of the same type as the
|
|
||||||
the `type` property. When `multiple` is `true`, it must be an array.
|
|
||||||
* `strict` {boolean} Should an error be thrown when unknown arguments
|
|
||||||
are encountered, or when arguments are passed that do not match the
|
|
||||||
`type` configured in `options`.
|
|
||||||
**Default:** `true`.
|
|
||||||
* `allowPositionals` {boolean} Whether this command accepts positional
|
|
||||||
arguments.
|
|
||||||
**Default:** `false` if `strict` is `true`, otherwise `true`.
|
|
||||||
* `tokens` {boolean} Return the parsed tokens. This is useful for extending
|
|
||||||
the built-in behavior, from adding additional checks through to reprocessing
|
|
||||||
the tokens in different ways.
|
|
||||||
**Default:** `false`.
|
|
||||||
|
|
||||||
* Returns: {Object} The parsed command line arguments:
|
|
||||||
* `values` {Object} A mapping of parsed option names with their {string}
|
|
||||||
or {boolean} values.
|
|
||||||
* `positionals` {string\[]} Positional arguments.
|
|
||||||
* `tokens` {Object\[] | undefined} See [parseArgs tokens](#parseargs-tokens)
|
|
||||||
section. Only returned if `config` includes `tokens: true`.
|
|
||||||
|
|
||||||
Provides a higher level API for command-line argument parsing than interacting
|
|
||||||
with `process.argv` directly. Takes a specification for the expected arguments
|
|
||||||
and returns a structured object with the parsed options and positionals.
|
|
||||||
|
|
||||||
```mjs
|
|
||||||
import { parseArgs } from 'node:util';
|
|
||||||
const args = ['-f', '--bar', 'b'];
|
|
||||||
const options = {
|
|
||||||
foo: {
|
|
||||||
type: 'boolean',
|
|
||||||
short: 'f'
|
|
||||||
},
|
|
||||||
bar: {
|
|
||||||
type: 'string'
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const {
|
|
||||||
values,
|
|
||||||
positionals
|
|
||||||
} = parseArgs({ args, options });
|
|
||||||
console.log(values, positionals);
|
|
||||||
// Prints: [Object: null prototype] { foo: true, bar: 'b' } []
|
|
||||||
```
|
|
||||||
|
|
||||||
```cjs
|
|
||||||
const { parseArgs } = require('node:util');
|
|
||||||
const args = ['-f', '--bar', 'b'];
|
|
||||||
const options = {
|
|
||||||
foo: {
|
|
||||||
type: 'boolean',
|
|
||||||
short: 'f'
|
|
||||||
},
|
|
||||||
bar: {
|
|
||||||
type: 'string'
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const {
|
|
||||||
values,
|
|
||||||
positionals
|
|
||||||
} = parseArgs({ args, options });
|
|
||||||
console.log(values, positionals);
|
|
||||||
// Prints: [Object: null prototype] { foo: true, bar: 'b' } []
|
|
||||||
```
|
|
||||||
|
|
||||||
`util.parseArgs` is experimental and behavior may change. Join the
|
|
||||||
conversation in [pkgjs/parseargs][] to contribute to the design.
|
|
||||||
|
|
||||||
### `parseArgs` `tokens`
|
|
||||||
|
|
||||||
Detailed parse information is available for adding custom behaviours by
|
|
||||||
specifying `tokens: true` in the configuration.
|
|
||||||
The returned tokens have properties describing:
|
|
||||||
|
|
||||||
* all tokens
|
|
||||||
* `kind` {string} One of 'option', 'positional', or 'option-terminator'.
|
|
||||||
* `index` {number} Index of element in `args` containing token. So the
|
|
||||||
source argument for a token is `args[token.index]`.
|
|
||||||
* option tokens
|
|
||||||
* `name` {string} Long name of option.
|
|
||||||
* `rawName` {string} How option used in args, like `-f` of `--foo`.
|
|
||||||
* `value` {string | undefined} Option value specified in args.
|
|
||||||
Undefined for boolean options.
|
|
||||||
* `inlineValue` {boolean | undefined} Whether option value specified inline,
|
|
||||||
like `--foo=bar`.
|
|
||||||
* positional tokens
|
|
||||||
* `value` {string} The value of the positional argument in args (i.e. `args[index]`).
|
|
||||||
* option-terminator token
|
|
||||||
|
|
||||||
The returned tokens are in the order encountered in the input args. Options
|
|
||||||
that appear more than once in args produce a token for each use. Short option
|
|
||||||
groups like `-xy` expand to a token for each option. So `-xxx` produces
|
|
||||||
three tokens.
|
|
||||||
|
|
||||||
For example to use the returned tokens to add support for a negated option
|
|
||||||
like `--no-color`, the tokens can be reprocessed to change the value stored
|
|
||||||
for the negated option.
|
|
||||||
|
|
||||||
```mjs
|
|
||||||
import { parseArgs } from 'node:util';
|
|
||||||
|
|
||||||
const options = {
|
|
||||||
'color': { type: 'boolean' },
|
|
||||||
'no-color': { type: 'boolean' },
|
|
||||||
'logfile': { type: 'string' },
|
|
||||||
'no-logfile': { type: 'boolean' },
|
|
||||||
};
|
|
||||||
const { values, tokens } = parseArgs({ options, tokens: true });
|
|
||||||
|
|
||||||
// Reprocess the option tokens and overwrite the returned values.
|
|
||||||
tokens
|
|
||||||
.filter((token) => token.kind === 'option')
|
|
||||||
.forEach((token) => {
|
|
||||||
if (token.name.startsWith('no-')) {
|
|
||||||
// Store foo:false for --no-foo
|
|
||||||
const positiveName = token.name.slice(3);
|
|
||||||
values[positiveName] = false;
|
|
||||||
delete values[token.name];
|
|
||||||
} else {
|
|
||||||
// Resave value so last one wins if both --foo and --no-foo.
|
|
||||||
values[token.name] = token.value ?? true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const color = values.color;
|
|
||||||
const logfile = values.logfile ?? 'default.log';
|
|
||||||
|
|
||||||
console.log({ logfile, color });
|
|
||||||
```
|
|
||||||
|
|
||||||
```cjs
|
|
||||||
const { parseArgs } = require('node:util');
|
|
||||||
|
|
||||||
const options = {
|
|
||||||
'color': { type: 'boolean' },
|
|
||||||
'no-color': { type: 'boolean' },
|
|
||||||
'logfile': { type: 'string' },
|
|
||||||
'no-logfile': { type: 'boolean' },
|
|
||||||
};
|
|
||||||
const { values, tokens } = parseArgs({ options, tokens: true });
|
|
||||||
|
|
||||||
// Reprocess the option tokens and overwrite the returned values.
|
|
||||||
tokens
|
|
||||||
.filter((token) => token.kind === 'option')
|
|
||||||
.forEach((token) => {
|
|
||||||
if (token.name.startsWith('no-')) {
|
|
||||||
// Store foo:false for --no-foo
|
|
||||||
const positiveName = token.name.slice(3);
|
|
||||||
values[positiveName] = false;
|
|
||||||
delete values[token.name];
|
|
||||||
} else {
|
|
||||||
// Resave value so last one wins if both --foo and --no-foo.
|
|
||||||
values[token.name] = token.value ?? true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const color = values.color;
|
|
||||||
const logfile = values.logfile ?? 'default.log';
|
|
||||||
|
|
||||||
console.log({ logfile, color });
|
|
||||||
```
|
|
||||||
|
|
||||||
Example usage showing negated options, and when an option is used
|
|
||||||
multiple ways then last one wins.
|
|
||||||
|
|
||||||
```console
|
|
||||||
$ node negate.js
|
|
||||||
{ logfile: 'default.log', color: undefined }
|
|
||||||
$ node negate.js --no-logfile --no-color
|
|
||||||
{ logfile: false, color: false }
|
|
||||||
$ node negate.js --logfile=test.log --color
|
|
||||||
{ logfile: 'test.log', color: true }
|
|
||||||
$ node negate.js --no-logfile --logfile=test.log --color --no-color
|
|
||||||
{ logfile: 'test.log', color: false }
|
|
||||||
```
|
|
||||||
|
|
||||||
-----
|
|
||||||
|
|
||||||
<!-- omit in toc -->
|
|
||||||
## Table of Contents
|
|
||||||
- [`util.parseArgs([config])`](#utilparseargsconfig)
|
|
||||||
- [Scope](#scope)
|
|
||||||
- [Version Matchups](#version-matchups)
|
|
||||||
- [🚀 Getting Started](#-getting-started)
|
|
||||||
- [🙌 Contributing](#-contributing)
|
|
||||||
- [💡 `process.mainArgs` Proposal](#-processmainargs-proposal)
|
|
||||||
- [Implementation:](#implementation)
|
|
||||||
- [📃 Examples](#-examples)
|
|
||||||
- [F.A.Qs](#faqs)
|
|
||||||
- [Links & Resources](#links--resources)
|
|
||||||
|
|
||||||
-----
|
|
||||||
|
|
||||||
## Scope
|
|
||||||
|
|
||||||
It is already possible to build great arg parsing modules on top of what Node.js provides; the prickly API is abstracted away by these modules. Thus, process.parseArgs() is not necessarily intended for library authors; it is intended for developers of simple CLI tools, ad-hoc scripts, deployed Node.js applications, and learning materials.
|
|
||||||
|
|
||||||
It is exceedingly difficult to provide an API which would both be friendly to these Node.js users while being extensible enough for libraries to build upon. We chose to prioritize these use cases because these are currently not well-served by Node.js' API.
|
|
||||||
|
|
||||||
----
|
|
||||||
|
|
||||||
## Version Matchups
|
|
||||||
|
|
||||||
| Node.js | @pkgjs/parseArgs |
|
|
||||||
| -- | -- |
|
|
||||||
| [v18.3.0](https://nodejs.org/docs/latest-v18.x/api/util.html#utilparseargsconfig) | [v0.9.1](https://github.com/pkgjs/parseargs/tree/v0.9.1#utilparseargsconfig) |
|
|
||||||
| [v16.17.0](https://nodejs.org/dist/latest-v16.x/docs/api/util.html#utilparseargsconfig), [v18.7.0](https://nodejs.org/docs/latest-v18.x/api/util.html#utilparseargsconfig) | [0.10.0](https://github.com/pkgjs/parseargs/tree/v0.10.0#utilparseargsconfig) |
|
|
||||||
|
|
||||||
----
|
|
||||||
|
|
||||||
## 🚀 Getting Started
|
|
||||||
|
|
||||||
1. **Install dependencies.**
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npm install
|
|
||||||
```
|
|
||||||
|
|
||||||
2. **Open the index.js file and start editing!**
|
|
||||||
|
|
||||||
3. **Test your code by calling parseArgs through our test file**
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npm test
|
|
||||||
```
|
|
||||||
|
|
||||||
----
|
|
||||||
|
|
||||||
## 🙌 Contributing
|
|
||||||
|
|
||||||
Any person who wants to contribute to the initiative is welcome! Please first read the [Contributing Guide](CONTRIBUTING.md)
|
|
||||||
|
|
||||||
Additionally, reading the [`Examples w/ Output`](#-examples-w-output) section of this document will be the best way to familiarize yourself with the target expected behavior for parseArgs() once it is fully implemented.
|
|
||||||
|
|
||||||
This package was implemented using [tape](https://www.npmjs.com/package/tape) as its test harness.
|
|
||||||
|
|
||||||
----
|
|
||||||
|
|
||||||
## 💡 `process.mainArgs` Proposal
|
|
||||||
|
|
||||||
> Note: This can be moved forward independently of the `util.parseArgs()` proposal/work.
|
|
||||||
|
|
||||||
### Implementation:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
process.mainArgs = process.argv.slice(process._exec ? 1 : 2)
|
|
||||||
```
|
|
||||||
|
|
||||||
----
|
|
||||||
|
|
||||||
## 📃 Examples
|
|
||||||
|
|
||||||
```js
|
|
||||||
const { parseArgs } = require('@pkgjs/parseargs');
|
|
||||||
```
|
|
||||||
|
|
||||||
```js
|
|
||||||
const { parseArgs } = require('@pkgjs/parseargs');
|
|
||||||
// specify the options that may be used
|
|
||||||
const options = {
|
|
||||||
foo: { type: 'string'},
|
|
||||||
bar: { type: 'boolean' },
|
|
||||||
};
|
|
||||||
const args = ['--foo=a', '--bar'];
|
|
||||||
const { values, positionals } = parseArgs({ args, options });
|
|
||||||
// values = { foo: 'a', bar: true }
|
|
||||||
// positionals = []
|
|
||||||
```
|
|
||||||
|
|
||||||
```js
|
|
||||||
const { parseArgs } = require('@pkgjs/parseargs');
|
|
||||||
// type:string & multiple
|
|
||||||
const options = {
|
|
||||||
foo: {
|
|
||||||
type: 'string',
|
|
||||||
multiple: true,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
const args = ['--foo=a', '--foo', 'b'];
|
|
||||||
const { values, positionals } = parseArgs({ args, options });
|
|
||||||
// values = { foo: [ 'a', 'b' ] }
|
|
||||||
// positionals = []
|
|
||||||
```
|
|
||||||
|
|
||||||
```js
|
|
||||||
const { parseArgs } = require('@pkgjs/parseargs');
|
|
||||||
// shorts
|
|
||||||
const options = {
|
|
||||||
foo: {
|
|
||||||
short: 'f',
|
|
||||||
type: 'boolean'
|
|
||||||
},
|
|
||||||
};
|
|
||||||
const args = ['-f', 'b'];
|
|
||||||
const { values, positionals } = parseArgs({ args, options, allowPositionals: true });
|
|
||||||
// values = { foo: true }
|
|
||||||
// positionals = ['b']
|
|
||||||
```
|
|
||||||
|
|
||||||
```js
|
|
||||||
const { parseArgs } = require('@pkgjs/parseargs');
|
|
||||||
// unconfigured
|
|
||||||
const options = {};
|
|
||||||
const args = ['-f', '--foo=a', '--bar', 'b'];
|
|
||||||
const { values, positionals } = parseArgs({ strict: false, args, options, allowPositionals: true });
|
|
||||||
// values = { f: true, foo: 'a', bar: true }
|
|
||||||
// positionals = ['b']
|
|
||||||
```
|
|
||||||
|
|
||||||
----
|
|
||||||
|
|
||||||
## F.A.Qs
|
|
||||||
|
|
||||||
- Is `cmd --foo=bar baz` the same as `cmd baz --foo=bar`?
|
|
||||||
- yes
|
|
||||||
- Does the parser execute a function?
|
|
||||||
- no
|
|
||||||
- Does the parser execute one of several functions, depending on input?
|
|
||||||
- no
|
|
||||||
- Can subcommands take options that are distinct from the main command?
|
|
||||||
- no
|
|
||||||
- Does it output generated help when no options match?
|
|
||||||
- no
|
|
||||||
- Does it generated short usage? Like: `usage: ls [-ABCFGHLOPRSTUWabcdefghiklmnopqrstuwx1] [file ...]`
|
|
||||||
- no (no usage/help at all)
|
|
||||||
- Does the user provide the long usage text? For each option? For the whole command?
|
|
||||||
- no
|
|
||||||
- Do subcommands (if implemented) have their own usage output?
|
|
||||||
- no
|
|
||||||
- Does usage print if the user runs `cmd --help`?
|
|
||||||
- no
|
|
||||||
- Does it set `process.exitCode`?
|
|
||||||
- no
|
|
||||||
- Does usage print to stderr or stdout?
|
|
||||||
- N/A
|
|
||||||
- Does it check types? (Say, specify that an option is a boolean, number, etc.)
|
|
||||||
- no
|
|
||||||
- Can an option have more than one type? (string or false, for example)
|
|
||||||
- no
|
|
||||||
- Can the user define a type? (Say, `type: path` to call `path.resolve()` on the argument.)
|
|
||||||
- no
|
|
||||||
- Does a `--foo=0o22` mean 0, 22, 18, or "0o22"?
|
|
||||||
- `"0o22"`
|
|
||||||
- Does it coerce types?
|
|
||||||
- no
|
|
||||||
- Does `--no-foo` coerce to `--foo=false`? For all options? Only boolean options?
|
|
||||||
- no, it sets `{values:{'no-foo': true}}`
|
|
||||||
- Is `--foo` the same as `--foo=true`? Only for known booleans? Only at the end?
|
|
||||||
- no, they are not the same. There is no special handling of `true` as a value so it is just another string.
|
|
||||||
- Does it read environment variables? Ie, is `FOO=1 cmd` the same as `cmd --foo=1`?
|
|
||||||
- no
|
|
||||||
- Do unknown arguments raise an error? Are they parsed? Are they treated as positional arguments?
|
|
||||||
- no, they are parsed, not treated as positionals
|
|
||||||
- Does `--` signal the end of options?
|
|
||||||
- yes
|
|
||||||
- Is `--` included as a positional?
|
|
||||||
- no
|
|
||||||
- Is `program -- foo` the same as `program foo`?
|
|
||||||
- yes, both store `{positionals:['foo']}`
|
|
||||||
- Does the API specify whether a `--` was present/relevant?
|
|
||||||
- no
|
|
||||||
- Is `-bar` the same as `--bar`?
|
|
||||||
- no, `-bar` is a short option or options, with expansion logic that follows the
|
|
||||||
[Utility Syntax Guidelines in POSIX.1-2017](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html). `-bar` expands to `-b`, `-a`, `-r`.
|
|
||||||
- Is `---foo` the same as `--foo`?
|
|
||||||
- no
|
|
||||||
- the first is a long option named `'-foo'`
|
|
||||||
- the second is a long option named `'foo'`
|
|
||||||
- Is `-` a positional? ie, `bash some-test.sh | tap -`
|
|
||||||
- yes
|
|
||||||
|
|
||||||
## Links & Resources
|
|
||||||
|
|
||||||
* [Initial Tooling Issue](https://github.com/nodejs/tooling/issues/19)
|
|
||||||
* [Initial Proposal](https://github.com/nodejs/node/pull/35015)
|
|
||||||
* [parseArgs Proposal](https://github.com/nodejs/node/pull/42675)
|
|
||||||
|
|
||||||
[coverage-image]: https://img.shields.io/nycrc/pkgjs/parseargs
|
|
||||||
[coverage-url]: https://github.com/pkgjs/parseargs/blob/main/.nycrc
|
|
||||||
[pkgjs/parseargs]: https://github.com/pkgjs/parseargs
|
|
||||||
25
node_modules/@pkgjs/parseargs/examples/is-default-value.js
generated
vendored
|
|
@ -1,25 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
// This example shows how to understand if a default value is used or not.
|
|
||||||
|
|
||||||
// 1. const { parseArgs } = require('node:util'); // from node
|
|
||||||
// 2. const { parseArgs } = require('@pkgjs/parseargs'); // from package
|
|
||||||
const { parseArgs } = require('..'); // in repo
|
|
||||||
|
|
||||||
const options = {
|
|
||||||
file: { short: 'f', type: 'string', default: 'FOO' },
|
|
||||||
};
|
|
||||||
|
|
||||||
const { values, tokens } = parseArgs({ options, tokens: true });
|
|
||||||
|
|
||||||
const isFileDefault = !tokens.some((token) => token.kind === 'option' &&
|
|
||||||
token.name === 'file'
|
|
||||||
);
|
|
||||||
|
|
||||||
console.log(values);
|
|
||||||
console.log(`Is the file option [${values.file}] the default value? ${isFileDefault}`);
|
|
||||||
|
|
||||||
// Try the following:
|
|
||||||
// node is-default-value.js
|
|
||||||
// node is-default-value.js -f FILE
|
|
||||||
// node is-default-value.js --file FILE
|
|
||||||