Website Structure
This commit is contained in:
parent
62812f2090
commit
71f0676a62
22365 changed files with 4265753 additions and 791 deletions
176
Frontend-Learner/node_modules/tailwind-config-viewer/README.md
generated
vendored
Normal file
176
Frontend-Learner/node_modules/tailwind-config-viewer/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,176 @@
|
|||
# Tailwind Config Viewer
|
||||
|
||||

|
||||
|
||||
Tailwind Config Viewer is a local UI tool for visualizing your Tailwind CSS configuration file. Keep it open during development to quickly reference custom Tailwind values/classes. Easily navigate between sections of the configuration and copy class names to your clipboard by clicking on them.
|
||||
|
||||
**[Demo using the default Tailwind config](https://rogden.github.io/tailwind-config-viewer/)**
|
||||
|
||||
## Installation
|
||||
|
||||
### NPX
|
||||
Run `npx tailwind-config-viewer` from within the directory that contains your Tailwind configuration file.
|
||||
|
||||
### Globally
|
||||
`npm i tailwind-config-viewer -g`
|
||||
|
||||
### Locally
|
||||
`npm i tailwind-config-viewer -D`
|
||||
|
||||
When installing locally, you can add an entry into the package.json scripts field to run and open the viewer:
|
||||
|
||||
```json
|
||||
"scripts": {
|
||||
"tailwind-config-viewer": "tailwind-config-viewer -o"
|
||||
}
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Run the `tailwind-config-viewer` command from within the directory that contains your Tailwind configuration file.
|
||||
|
||||
## Commands
|
||||
|
||||
### serve (default)
|
||||
|
||||
The `serve` command is the default command. Running `tailwind-config-viewer` is the same as `tailwind-config-viewer serve`.
|
||||
|
||||
**Options**
|
||||
|
||||
|Option|Default|Description|
|
||||
|----|----|----|
|
||||
|-p, --port|`3000`|The port to run the viewer on. If occupied it will use next available port.|
|
||||
|-o, --open|`false`|Open the viewer in default browser|
|
||||
|-c, --config|`tailwind.config.js`|Path to your Tailwind config file|
|
||||
|
||||
### export
|
||||
|
||||
Exports the viewer to a directory that can be uploaded to a static host. It accepts the output directory path as its sole argument.
|
||||
|
||||
`tailwind-config-viewer export ./output-dir`
|
||||
|
||||
If an output directory isn't specificied it will be output to `tcv-build`.
|
||||
|
||||
**Options**
|
||||
|
||||
|Option|Default|Description|
|
||||
|----|----|----|
|
||||
|-c, --config|`tailwind.config.js`|Path to your Tailwind config file|
|
||||
|
||||
## Configuration
|
||||
|
||||
You can declare a `configViewer` property in your Tailwind configuration's theme object in order to customize certain aspects of the config viewer.
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
theme: {
|
||||
// ...your Tailwind theme config
|
||||
configViewer: {
|
||||
// ... configViewer Options
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
### themeReplacements
|
||||
|
||||
In some instances you may want to replace values used in your Tailwind config when it is displayed in the config viewer. One scenario where this is necessary is when you are using CSS variables for your theme values:
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
theme: {
|
||||
colors: {
|
||||
black: 'var(--color-black)'
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
In order for the config viewer to properly display this color, you need to provide a replacement for it:
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
theme: {
|
||||
colors: {
|
||||
black: 'var(--color-black)'
|
||||
},
|
||||
configViewer: {
|
||||
themeReplacements: {
|
||||
'var(--color-black)': '#000000'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
You can replace any value in your theme for display in the config viewer by setting the corresponding `valueToFind: valueToReplace` in the `themeReplacements` object.
|
||||
|
||||
### baseFontSize
|
||||
|
||||
The config viewer displays the pixel equivalent of any rem values. By default `baseFontSize` is set to 16 to mirror the default root element font size in most browsers. If you plan on using a different root font size in your project, you should set the value of `baseFontSize` to match.
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
theme: {
|
||||
// ...your Tailwind theme config
|
||||
configViewer: {
|
||||
baseFontSize: 20 // default is 16
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### typographyExample
|
||||
|
||||
You can change the default sentence used in the typography sections (Font Size, Letter Spacing etc.)
|
||||
by setting the `typographyExample` option:
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
theme: {
|
||||
// ...your Tailwind theme config
|
||||
configViewer: {
|
||||
typographyExample: 'The quick brown fox jumps over the lazy dog.'
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### fonts
|
||||
|
||||
You can add custom fonts to the config viewer that are used in your Tailwind config by passing in a font url as a string, or an array of font urls.
|
||||
|
||||
**Notes**
|
||||
|
||||
* If multiple font weights are provided in a single url (see example) only the last weight will be used.
|
||||
* If fonts are in your Tailwind theme config but urls are not provided they will not display correctly (currently with no warning).
|
||||
* Fonts can only be provided via urls not local files. If this something you need, please open a ticket or a pull request.
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
theme: {
|
||||
// ...your Tailwind theme config
|
||||
configViewer: {
|
||||
// single font
|
||||
fonts: "https://fonts.googleapis.com/css2?family=Open+Sans&display=swap"
|
||||
// or multiple fonts
|
||||
fonts: [
|
||||
"https://fonts.googleapis.com/css2?family=Open+Sans&display=swap",
|
||||
"https://fonts.googleapis.com/css2?family=Roboto:wght@100;500&display=swap" // <- only 500 will be used
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Usage Tips
|
||||
|
||||
- `Shift+Click` on the Tailwind class names to copy multiple to your clipboard at once
|
||||
|
||||
## Roadmap
|
||||
|
||||
- [x] Add static export
|
||||
- [x] Add Transition section
|
||||
- [x] Dark Mode toggle
|
||||
- [x] Add support for loading custom fonts / font family section
|
||||
31
Frontend-Learner/node_modules/tailwind-config-viewer/cli/export.js
generated
vendored
Normal file
31
Frontend-Learner/node_modules/tailwind-config-viewer/cli/export.js
generated
vendored
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
const fs = require('fs-extra')
|
||||
const path = require('path')
|
||||
const crypto = require('crypto')
|
||||
const replace = require('replace-in-file')
|
||||
const { resolveConfigToJson } = require('../lib/tailwindConfigUtils')
|
||||
|
||||
module.exports = async function (outputDir, configPath) {
|
||||
outputDir = path.resolve(process.cwd(), outputDir)
|
||||
|
||||
fs.removeSync(outputDir)
|
||||
fs.mkdirSync(outputDir)
|
||||
|
||||
const configJson = await resolveConfigToJson(configPath)
|
||||
const configFileName = generateConfigFileNameFromJson(configJson)
|
||||
|
||||
fs.writeFileSync(path.resolve(outputDir, configFileName), configJson)
|
||||
|
||||
fs.copySync(path.resolve(__dirname, '../dist'), outputDir)
|
||||
|
||||
replace.sync({
|
||||
files: `${outputDir}/index.html`,
|
||||
from: 'config.json',
|
||||
to: configFileName
|
||||
})
|
||||
}
|
||||
|
||||
function generateConfigFileNameFromJson (configJson) {
|
||||
const configFileHash = crypto.createHash('md5').update(configJson).digest('hex')
|
||||
|
||||
return `config.${configFileHash.substr(0, 8)}.json`
|
||||
}
|
||||
36
Frontend-Learner/node_modules/tailwind-config-viewer/cli/index.js
generated
vendored
Normal file
36
Frontend-Learner/node_modules/tailwind-config-viewer/cli/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#!/usr/bin/env node
|
||||
const { pathToFileURL } = require('url')
|
||||
const { resolveConfigPath } = require('../lib/tailwindConfigUtils')
|
||||
const program = require('commander')
|
||||
program
|
||||
.option('-c, --config <path>', 'Path to your Tailwind config file', './tailwind.config.js')
|
||||
|
||||
program
|
||||
.command('serve', { isDefault: true })
|
||||
.description('Serve the viewer')
|
||||
.option('-p, --port <port>', 'Port to run the viewer on', 3000)
|
||||
.option('-o, --open', 'Open the viewer in default browser')
|
||||
.action(args => {
|
||||
require('../server')({
|
||||
port: args.port,
|
||||
tailwindConfigProvider: async () => {
|
||||
const configPath = resolveConfigPath(program.config)
|
||||
const configHref = pathToFileURL(configPath).href
|
||||
delete require.cache[configHref]
|
||||
const config = await import(configHref)
|
||||
return config.default || config
|
||||
},
|
||||
shouldOpen: args.open
|
||||
}).start()
|
||||
})
|
||||
|
||||
program
|
||||
.command('export [outputDir]')
|
||||
.description('Create a static export of the viewer')
|
||||
.action((outputDir = './tcv-build') => {
|
||||
const configPath = resolveConfigPath(program.config)
|
||||
const configHref = pathToFileURL(configPath).href
|
||||
require('./export')(outputDir, configHref)
|
||||
})
|
||||
|
||||
program.parse(process.argv)
|
||||
3
Frontend-Learner/node_modules/tailwind-config-viewer/dist/css/app.a4ea028b.css
generated
vendored
Normal file
3
Frontend-Learner/node_modules/tailwind-config-viewer/dist/css/app.a4ea028b.css
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
BIN
Frontend-Learner/node_modules/tailwind-config-viewer/dist/favicon.ico
generated
vendored
Normal file
BIN
Frontend-Learner/node_modules/tailwind-config-viewer/dist/favicon.ico
generated
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
3
Frontend-Learner/node_modules/tailwind-config-viewer/dist/index.html
generated
vendored
Normal file
3
Frontend-Learner/node_modules/tailwind-config-viewer/dist/index.html
generated
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=favicon.ico><title>tailwind-config-viewer</title><script>window.__TCV_CONFIG = {
|
||||
configPath: './config.json'
|
||||
}</script><link href=css/app.a4ea028b.css rel=preload as=style><link href=js/app.5db1c92a.js rel=preload as=script><link href=js/chunk-vendors.6cab5322.js rel=preload as=script><link href=css/app.a4ea028b.css rel=stylesheet></head><body><noscript><strong>We're sorry but tailwind-config-viewer doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=js/chunk-vendors.6cab5322.js></script><script src=js/app.5db1c92a.js></script></body></html>
|
||||
2
Frontend-Learner/node_modules/tailwind-config-viewer/dist/js/app.5db1c92a.js
generated
vendored
Normal file
2
Frontend-Learner/node_modules/tailwind-config-viewer/dist/js/app.5db1c92a.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
Frontend-Learner/node_modules/tailwind-config-viewer/dist/js/app.5db1c92a.js.map
generated
vendored
Normal file
1
Frontend-Learner/node_modules/tailwind-config-viewer/dist/js/app.5db1c92a.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
8
Frontend-Learner/node_modules/tailwind-config-viewer/dist/js/chunk-vendors.6cab5322.js
generated
vendored
Normal file
8
Frontend-Learner/node_modules/tailwind-config-viewer/dist/js/chunk-vendors.6cab5322.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
Frontend-Learner/node_modules/tailwind-config-viewer/dist/js/chunk-vendors.6cab5322.js.map
generated
vendored
Normal file
1
Frontend-Learner/node_modules/tailwind-config-viewer/dist/js/chunk-vendors.6cab5322.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
87
Frontend-Learner/node_modules/tailwind-config-viewer/lib/tailwindConfigUtils.js
generated
vendored
Normal file
87
Frontend-Learner/node_modules/tailwind-config-viewer/lib/tailwindConfigUtils.js
generated
vendored
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
const path = require('path')
|
||||
/**
|
||||
* Force loading tailwindcss module installed in current working directory.
|
||||
* This is required for running the config viewer directly with npx without
|
||||
* locally installing it
|
||||
*/
|
||||
const tailwindPackageJsonPath = require.resolve('tailwindcss/package.json', { paths: [__dirname, process.cwd()] })
|
||||
const tailwindVersion = require(tailwindPackageJsonPath).version
|
||||
const tailwindResolveConfigPath = require.resolve('tailwindcss/resolveConfig', { paths: [__dirname, process.cwd()] })
|
||||
const resolveTailwindConfig = require(tailwindResolveConfigPath)
|
||||
const flattenColorPalettePath = require.resolve('tailwindcss/lib/util/flattenColorPalette', { paths: [__dirname, process.cwd()] })
|
||||
const flattenColorPalette = require(flattenColorPalettePath).default
|
||||
|
||||
const resolveConfigPath = configPath => path.resolve(process.cwd(), configPath)
|
||||
|
||||
const resolveConfig = config => {
|
||||
return transformConfig(resolveTailwindConfig(config))
|
||||
}
|
||||
|
||||
const resolveConfigToJson = async (configPath) => {
|
||||
const config = await import(configPath)
|
||||
return JSON.stringify(resolveConfig(config.default || config))
|
||||
}
|
||||
|
||||
const transformConfig = config => {
|
||||
config.tailwindVersion = tailwindVersion
|
||||
config.theme = replaceWithOverrides(config.theme)
|
||||
config.theme.colors = flattenColorPalette(config.theme.colors)
|
||||
config.theme.backgroundColor = flattenColorPalette(config.theme.backgroundColor)
|
||||
config.theme.textColor = flattenColorPalette(config.theme.textColor)
|
||||
config.theme.borderColor = flattenColorPalette(config.theme.borderColor)
|
||||
|
||||
removeDisabledCorePlugins(config)
|
||||
|
||||
removeConfigProps(config, [
|
||||
'variants',
|
||||
'purge',
|
||||
'plugins',
|
||||
'corePlugins',
|
||||
'target'
|
||||
])
|
||||
|
||||
return config
|
||||
}
|
||||
|
||||
const replaceWithOverrides = (theme) => {
|
||||
if (theme.configViewer && theme.configViewer.themeReplacements) {
|
||||
Object.keys(theme.configViewer.themeReplacements).forEach(key => {
|
||||
theme = findAndReplaceRecursively(theme, key, theme.configViewer.themeReplacements[key])
|
||||
})
|
||||
}
|
||||
|
||||
return theme
|
||||
}
|
||||
|
||||
function findAndReplaceRecursively (target, find, replaceWith) {
|
||||
if (typeof target !== 'object') {
|
||||
if (target === find) return replaceWith
|
||||
return target
|
||||
}
|
||||
|
||||
return Object.keys(target)
|
||||
.reduce((carry, key) => {
|
||||
const val = target[key]
|
||||
carry[key] = findAndReplaceRecursively(val, find, replaceWith)
|
||||
return carry
|
||||
}, {})
|
||||
}
|
||||
|
||||
const removeConfigProps = (config, props) => {
|
||||
props.forEach(prop => delete config[prop])
|
||||
}
|
||||
|
||||
const removeDisabledCorePlugins = (config) => {
|
||||
Object.keys(config.corePlugins).forEach(key => {
|
||||
if (config.corePlugins[key] === false) {
|
||||
delete config.theme[key]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
resolveConfig,
|
||||
resolveConfigPath,
|
||||
resolveConfigToJson,
|
||||
transformConfig
|
||||
}
|
||||
16
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/.bin/is-docker
generated
vendored
Normal file
16
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/.bin/is-docker
generated
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#!/bin/sh
|
||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||
|
||||
case `uname` in
|
||||
*CYGWIN*|*MINGW*|*MSYS*)
|
||||
if command -v cygpath > /dev/null 2>&1; then
|
||||
basedir=`cygpath -w "$basedir"`
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -x "$basedir/node" ]; then
|
||||
exec "$basedir/node" "$basedir/../is-docker/cli.js" "$@"
|
||||
else
|
||||
exec node "$basedir/../is-docker/cli.js" "$@"
|
||||
fi
|
||||
17
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/.bin/is-docker.cmd
generated
vendored
Normal file
17
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/.bin/is-docker.cmd
generated
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
@ECHO off
|
||||
GOTO start
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
:start
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\is-docker\cli.js" %*
|
||||
28
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/.bin/is-docker.ps1
generated
vendored
Normal file
28
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/.bin/is-docker.ps1
generated
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#!/usr/bin/env pwsh
|
||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||
|
||||
$exe=""
|
||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||
# Fix case when both the Windows and Linux builds of Node
|
||||
# are installed in the same directory
|
||||
$exe=".exe"
|
||||
}
|
||||
$ret=0
|
||||
if (Test-Path "$basedir/node$exe") {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "$basedir/node$exe" "$basedir/../is-docker/cli.js" $args
|
||||
} else {
|
||||
& "$basedir/node$exe" "$basedir/../is-docker/cli.js" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "node$exe" "$basedir/../is-docker/cli.js" $args
|
||||
} else {
|
||||
& "node$exe" "$basedir/../is-docker/cli.js" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
||||
361
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/commander/CHANGELOG.md
generated
vendored
Normal file
361
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/commander/CHANGELOG.md
generated
vendored
Normal file
|
|
@ -0,0 +1,361 @@
|
|||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
||||
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). (Format adopted after v3.0.0.)
|
||||
|
||||
<!-- markdownlint-disable MD024 -->
|
||||
<!-- markdownlint-disable MD004 -->
|
||||
|
||||
## [6.2.1] (2020-12-13)
|
||||
|
||||
### Fixed
|
||||
|
||||
- some tests failed if directory path included a space ([1390])
|
||||
|
||||
## [6.2.0] (2020-10-25)
|
||||
|
||||
### Added
|
||||
|
||||
- added 'tsx' file extension for stand-alone executable subcommands ([#1368])
|
||||
- documented second parameter to `.description()` to describe command arguments ([#1353])
|
||||
- documentation of special cases with options taking varying numbers of option-arguments ([#1332])
|
||||
- documentation for terminology ([#1361])
|
||||
|
||||
### Fixed
|
||||
|
||||
- add missing TypeScript definition for `.addHelpCommand()' ([#1375])
|
||||
- removed blank line after "Arguments:" in help, to match "Options:" and "Commands:" ([#1360])
|
||||
|
||||
### Changed
|
||||
|
||||
- update dependencies
|
||||
|
||||
## [6.1.0] (2020-08-28)
|
||||
|
||||
### Added
|
||||
|
||||
- include URL to relevant section of README for error for potential conflict between Command properties and option values ([#1306])
|
||||
- `.combineFlagAndOptionalValue(false)` to ease upgrade path from older versions of Commander ([#1326])
|
||||
- allow disabling the built-in help option using `.helpOption(false)` ([#1325])
|
||||
- allow just some arguments in `argumentDescription` to `.description()` ([#1323])
|
||||
|
||||
### Changed
|
||||
|
||||
- tidy async test and remove lint override ([#1312])
|
||||
|
||||
### Fixed
|
||||
|
||||
- executable subcommand launching when script path not known ([#1322])
|
||||
|
||||
## [6.0.0] (2020-07-21)
|
||||
|
||||
### Added
|
||||
|
||||
- add support for variadic options ([#1250])
|
||||
- allow options to be added with just a short flag ([#1256])
|
||||
- *Breaking* the option property has same case as flag. e.g. flag `-n` accessed as `opts().n` (previously uppercase)
|
||||
- *Breaking* throw an error if there might be a clash between option name and a Command property, with advice on how to resolve ([#1275])
|
||||
|
||||
### Fixed
|
||||
|
||||
- Options which contain -no- in the middle of the option flag should not be treated as negatable. ([#1301])
|
||||
|
||||
## [6.0.0-0] (2020-06-20)
|
||||
|
||||
(Released in 6.0.0)
|
||||
|
||||
## [5.1.0] (2020-04-25)
|
||||
|
||||
### Added
|
||||
|
||||
- support for multiple command aliases, the first of which is shown in the auto-generated help ([#531], [#1236])
|
||||
- configuration support in `addCommand()` for `hidden` and `isDefault` ([#1232])
|
||||
|
||||
### Fixed
|
||||
|
||||
- omit masked help flags from the displayed help ([#645], [#1247])
|
||||
- remove old short help flag when change help flags using `helpOption` ([#1248])
|
||||
|
||||
### Changed
|
||||
|
||||
- remove use of `arguments` to improve auto-generated help in editors ([#1235])
|
||||
- rename `.command()` configuration `noHelp` to `hidden` (but not remove old support) ([#1232])
|
||||
- improvements to documentation
|
||||
- update dependencies
|
||||
- update tested versions of node
|
||||
- eliminate lint errors in TypeScript ([#1208])
|
||||
|
||||
## [5.0.0] (2020-03-14)
|
||||
|
||||
### Added
|
||||
|
||||
* support for nested commands with action-handlers ([#1] [#764] [#1149])
|
||||
* `.addCommand()` for adding a separately configured command ([#764] [#1149])
|
||||
* allow a non-executable to be set as the default command ([#742] [#1149])
|
||||
* implicit help command when there are subcommands (previously only if executables) ([#1149])
|
||||
* customise implicit help command with `.addHelpCommand()` ([#1149])
|
||||
* display error message for unknown subcommand, by default ([#432] [#1088] [#1149])
|
||||
* display help for missing subcommand, by default ([#1088] [#1149])
|
||||
* combined short options as single argument may include boolean flags and value flag and value (e.g. `-a -b -p 80` can be written as `-abp80`) ([#1145])
|
||||
* `.parseOption()` includes short flag and long flag expansions ([#1145])
|
||||
* `.helpInformation()` returns help text as a string, previously a private routine ([#1169])
|
||||
* `.parse()` implicitly uses `process.argv` if arguments not specified ([#1172])
|
||||
* optionally specify where `.parse()` arguments "from", if not following node conventions ([#512] [#1172])
|
||||
* suggest help option along with unknown command error ([#1179])
|
||||
* TypeScript definition for `commands` property of `Command` ([#1184])
|
||||
* export `program` property ([#1195])
|
||||
* `createCommand` factory method to simplify subclassing ([#1191])
|
||||
|
||||
### Fixed
|
||||
|
||||
* preserve argument order in subcommands ([#508] [#962] [#1138])
|
||||
* do not emit `command:*` for executable subcommands ([#809] [#1149])
|
||||
* action handler called whether or not there are non-option arguments ([#1062] [#1149])
|
||||
* combining option short flag and value in single argument now works for subcommands ([#1145])
|
||||
* only add implicit help command when it will not conflict with other uses of argument ([#1153] [#1149])
|
||||
* implicit help command works with command aliases ([#948] [#1149])
|
||||
* options are validated whether or not there is an action handler ([#1149])
|
||||
|
||||
### Changed
|
||||
|
||||
* *Breaking* `.args` contains command arguments with just recognised options removed ([#1032] [#1138])
|
||||
* *Breaking* display error if required argument for command is missing ([#995] [#1149])
|
||||
* tighten TypeScript definition of custom option processing function passed to `.option()` ([#1119])
|
||||
* *Breaking* `.allowUnknownOption()` ([#802] [#1138])
|
||||
* unknown options included in arguments passed to command action handler
|
||||
* unknown options included in `.args`
|
||||
* only recognised option short flags and long flags are expanded (e.g. `-ab` or `--foo=bar`) ([#1145])
|
||||
* *Breaking* `.parseOptions()` ([#1138])
|
||||
* `args` in returned result renamed `operands` and does not include anything after first unknown option
|
||||
* `unknown` in returned result has arguments after first unknown option including operands, not just options and values
|
||||
* *Breaking* `.on('command:*', callback)` and other command events passed (changed) results from `.parseOptions`, i.e. operands and unknown ([#1138])
|
||||
* refactor Option from prototype to class ([#1133])
|
||||
* refactor Command from prototype to class ([#1159])
|
||||
* changes to error handling ([#1165])
|
||||
* throw for author error, not just display message
|
||||
* preflight for variadic error
|
||||
* add tips to missing subcommand executable
|
||||
* TypeScript fluent return types changed to be more subclass friendly, return `this` rather than `Command` ([#1180])
|
||||
* `.parseAsync` returns `Promise<this>` to be consistent with `.parse()` ([#1180])
|
||||
* update dependencies
|
||||
|
||||
### Removed
|
||||
|
||||
* removed EventEmitter from TypeScript definition for Command, eliminating implicit peer dependency on `@types/node` ([#1146])
|
||||
* removed private function `normalize` (the functionality has been integrated into `parseOptions`) ([#1145])
|
||||
* `parseExpectedArgs` is now private ([#1149])
|
||||
|
||||
### Migration Tips
|
||||
|
||||
If you use `.on('command:*')` or more complicated tests to detect an unrecognised subcommand, you may be able to delete the code and rely on the default behaviour.
|
||||
|
||||
If you use `program.args` or more complicated tests to detect a missing subcommand, you may be able to delete the code and rely on the default behaviour.
|
||||
|
||||
If you use `.command('*')` to add a default command, you may be be able to switch to `isDefault:true` with a named command.
|
||||
|
||||
If you want to continue combining short options with optional values as though they were boolean flags, set `combineFlagAndOptionalValue(false)`
|
||||
to expand `-fb` to `-f -b` rather than `-f b`.
|
||||
|
||||
## [5.0.0-4] (2020-03-03)
|
||||
|
||||
(Released in 5.0.0)
|
||||
|
||||
## [5.0.0-3] (2020-02-20)
|
||||
|
||||
(Released in 5.0.0)
|
||||
|
||||
## [5.0.0-2] (2020-02-10)
|
||||
|
||||
(Released in 5.0.0)
|
||||
|
||||
## [5.0.0-1] (2020-02-08)
|
||||
|
||||
(Released in 5.0.0)
|
||||
|
||||
## [5.0.0-0] (2020-02-02)
|
||||
|
||||
(Released in 5.0.0)
|
||||
|
||||
## [4.1.1] (2020-02-02)
|
||||
|
||||
### Fixed
|
||||
|
||||
* TypeScript definition for `.action()` should include Promise for async ([#1157])
|
||||
|
||||
## [4.1.0] (2020-01-06)
|
||||
|
||||
### Added
|
||||
|
||||
* two routines to change how option values are handled, and eliminate name clashes with command properties ([#933] [#1102])
|
||||
* see storeOptionsAsProperties and passCommandToAction in README
|
||||
* `.parseAsync` to use instead of `.parse` if supply async action handlers ([#806] [#1118])
|
||||
|
||||
### Fixed
|
||||
|
||||
* Remove trailing blanks from wrapped help text ([#1096])
|
||||
|
||||
### Changed
|
||||
|
||||
* update dependencies
|
||||
* extend security coverage for Commander 2.x to 2020-02-03
|
||||
* improvements to README
|
||||
* improvements to TypeScript definition documentation
|
||||
* move old versions out of main CHANGELOG
|
||||
* removed explicit use of `ts-node` in tests
|
||||
|
||||
## [4.0.1] (2019-11-12)
|
||||
|
||||
### Fixed
|
||||
|
||||
* display help when requested, even if there are missing required options ([#1091])
|
||||
|
||||
## [4.0.0] (2019-11-02)
|
||||
|
||||
### Added
|
||||
|
||||
* automatically wrap and indent help descriptions for options and commands ([#1051])
|
||||
* `.exitOverride()` allows override of calls to `process.exit` for additional error handling and to keep program running ([#1040])
|
||||
* support for declaring required options with `.requiredOptions()` ([#1071])
|
||||
* GitHub Actions support ([#1027])
|
||||
* translation links in README
|
||||
|
||||
### Changed
|
||||
|
||||
* dev: switch tests from Sinon+Should to Jest with major rewrite of tests ([#1035])
|
||||
* call default subcommand even when there are unknown options ([#1047])
|
||||
* *Breaking* Commander is only officially supported on Node 8 and above, and requires Node 6 ([#1053])
|
||||
|
||||
### Fixed
|
||||
|
||||
* *Breaking* keep command object out of program.args when action handler called ([#1048])
|
||||
* also, action handler now passed array of unknown arguments
|
||||
* complain about unknown options when program argument supplied and action handler ([#1049])
|
||||
* this changes parameters to `command:*` event to include unknown arguments
|
||||
* removed deprecated `customFds` option from call to `child_process.spawn` ([#1052])
|
||||
* rework TypeScript declarations to bring all types into imported namespace ([#1081])
|
||||
|
||||
### Migration Tips
|
||||
|
||||
#### Testing for no arguments
|
||||
|
||||
If you were previously using code like:
|
||||
|
||||
```js
|
||||
if (!program.args.length) ...
|
||||
```
|
||||
|
||||
a partial replacement is:
|
||||
|
||||
```js
|
||||
if (program.rawArgs.length < 3) ...
|
||||
```
|
||||
|
||||
## [4.0.0-1] Prerelease (2019-10-08)
|
||||
|
||||
(Released in 4.0.0)
|
||||
|
||||
## [4.0.0-0] Prerelease (2019-10-01)
|
||||
|
||||
(Released in 4.0.0)
|
||||
|
||||
## Older versions
|
||||
|
||||
* [3.x](./changelogs/CHANGELOG-3.md)
|
||||
* [2.x](./changelogs/CHANGELOG-2.md)
|
||||
* [1.x](./changelogs/CHANGELOG-1.md)
|
||||
* [0.x](./changelogs/CHANGELOG-0.md)
|
||||
|
||||
[#1]: https://github.com/tj/commander.js/issues/1
|
||||
[#432]: https://github.com/tj/commander.js/issues/432
|
||||
[#508]: https://github.com/tj/commander.js/issues/508
|
||||
[#512]: https://github.com/tj/commander.js/issues/512
|
||||
[#531]: https://github.com/tj/commander.js/issues/531
|
||||
[#645]: https://github.com/tj/commander.js/issues/645
|
||||
[#742]: https://github.com/tj/commander.js/issues/742
|
||||
[#764]: https://github.com/tj/commander.js/issues/764
|
||||
[#802]: https://github.com/tj/commander.js/issues/802
|
||||
[#806]: https://github.com/tj/commander.js/issues/806
|
||||
[#809]: https://github.com/tj/commander.js/issues/809
|
||||
[#948]: https://github.com/tj/commander.js/issues/948
|
||||
[#962]: https://github.com/tj/commander.js/issues/962
|
||||
[#995]: https://github.com/tj/commander.js/issues/995
|
||||
[#1027]: https://github.com/tj/commander.js/pull/1027
|
||||
[#1032]: https://github.com/tj/commander.js/issues/1032
|
||||
[#1035]: https://github.com/tj/commander.js/pull/1035
|
||||
[#1040]: https://github.com/tj/commander.js/pull/1040
|
||||
[#1047]: https://github.com/tj/commander.js/pull/1047
|
||||
[#1048]: https://github.com/tj/commander.js/pull/1048
|
||||
[#1049]: https://github.com/tj/commander.js/pull/1049
|
||||
[#1051]: https://github.com/tj/commander.js/pull/1051
|
||||
[#1052]: https://github.com/tj/commander.js/pull/1052
|
||||
[#1053]: https://github.com/tj/commander.js/pull/1053
|
||||
[#1062]: https://github.com/tj/commander.js/pull/1062
|
||||
[#1071]: https://github.com/tj/commander.js/pull/1071
|
||||
[#1081]: https://github.com/tj/commander.js/pull/1081
|
||||
[#1088]: https://github.com/tj/commander.js/issues/1088
|
||||
[#1091]: https://github.com/tj/commander.js/pull/1091
|
||||
[#1096]: https://github.com/tj/commander.js/pull/1096
|
||||
[#1102]: https://github.com/tj/commander.js/pull/1102
|
||||
[#1118]: https://github.com/tj/commander.js/pull/1118
|
||||
[#1119]: https://github.com/tj/commander.js/pull/1119
|
||||
[#1133]: https://github.com/tj/commander.js/pull/1133
|
||||
[#1138]: https://github.com/tj/commander.js/pull/1138
|
||||
[#1145]: https://github.com/tj/commander.js/pull/1145
|
||||
[#1146]: https://github.com/tj/commander.js/pull/1146
|
||||
[#1149]: https://github.com/tj/commander.js/pull/1149
|
||||
[#1153]: https://github.com/tj/commander.js/issues/1153
|
||||
[#1157]: https://github.com/tj/commander.js/pull/1157
|
||||
[#1159]: https://github.com/tj/commander.js/pull/1159
|
||||
[#1165]: https://github.com/tj/commander.js/pull/1165
|
||||
[#1169]: https://github.com/tj/commander.js/pull/1169
|
||||
[#1172]: https://github.com/tj/commander.js/pull/1172
|
||||
[#1179]: https://github.com/tj/commander.js/pull/1179
|
||||
[#1180]: https://github.com/tj/commander.js/pull/1180
|
||||
[#1184]: https://github.com/tj/commander.js/pull/1184
|
||||
[#1191]: https://github.com/tj/commander.js/pull/1191
|
||||
[#1195]: https://github.com/tj/commander.js/pull/1195
|
||||
[#1208]: https://github.com/tj/commander.js/pull/1208
|
||||
[#1232]: https://github.com/tj/commander.js/pull/1232
|
||||
[#1235]: https://github.com/tj/commander.js/pull/1235
|
||||
[#1236]: https://github.com/tj/commander.js/pull/1236
|
||||
[#1247]: https://github.com/tj/commander.js/pull/1247
|
||||
[#1248]: https://github.com/tj/commander.js/pull/1248
|
||||
[#1250]: https://github.com/tj/commander.js/pull/1250
|
||||
[#1256]: https://github.com/tj/commander.js/pull/1256
|
||||
[#1275]: https://github.com/tj/commander.js/pull/1275
|
||||
[#1301]: https://github.com/tj/commander.js/issues/1301
|
||||
[#1306]: https://github.com/tj/commander.js/pull/1306
|
||||
[#1312]: https://github.com/tj/commander.js/pull/1312
|
||||
[#1322]: https://github.com/tj/commander.js/pull/1322
|
||||
[#1323]: https://github.com/tj/commander.js/pull/1323
|
||||
[#1325]: https://github.com/tj/commander.js/pull/1325
|
||||
[#1326]: https://github.com/tj/commander.js/pull/1326
|
||||
[#1332]: https://github.com/tj/commander.js/pull/1332
|
||||
[#1353]: https://github.com/tj/commander.js/pull/1353
|
||||
[#1360]: https://github.com/tj/commander.js/pull/1360
|
||||
[#1361]: https://github.com/tj/commander.js/pull/1361
|
||||
[#1368]: https://github.com/tj/commander.js/pull/1368
|
||||
[#1375]: https://github.com/tj/commander.js/pull/1375
|
||||
[#1390]: https://github.com/tj/commander.js/pull/1390
|
||||
|
||||
[Unreleased]: https://github.com/tj/commander.js/compare/master...develop
|
||||
[6.2.1]: https://github.com/tj/commander.js/compare/v6.2.0..v6.2.1
|
||||
[6.2.0]: https://github.com/tj/commander.js/compare/v6.1.0..v6.2.0
|
||||
[6.1.0]: https://github.com/tj/commander.js/compare/v6.0.0..v6.1.0
|
||||
[6.0.0]: https://github.com/tj/commander.js/compare/v5.1.0..v6.0.0
|
||||
[6.0.0-0]: https://github.com/tj/commander.js/compare/v5.1.0..v6.0.0-0
|
||||
[5.1.0]: https://github.com/tj/commander.js/compare/v5.0.0..v5.1.0
|
||||
[5.0.0]: https://github.com/tj/commander.js/compare/v4.1.1..v5.0.0
|
||||
[5.0.0-4]: https://github.com/tj/commander.js/compare/v5.0.0-3..v5.0.0-4
|
||||
[5.0.0-3]: https://github.com/tj/commander.js/compare/v5.0.0-2..v5.0.0-3
|
||||
[5.0.0-2]: https://github.com/tj/commander.js/compare/v5.0.0-1..v5.0.0-2
|
||||
[5.0.0-1]: https://github.com/tj/commander.js/compare/v5.0.0-0..v5.0.0-1
|
||||
[5.0.0-0]: https://github.com/tj/commander.js/compare/v4.1.1..v5.0.0-0
|
||||
[4.1.1]: https://github.com/tj/commander.js/compare/v4.1.0..v4.1.1
|
||||
[4.1.0]: https://github.com/tj/commander.js/compare/v4.0.1..v4.1.0
|
||||
[4.0.1]: https://github.com/tj/commander.js/compare/v4.0.0..v4.0.1
|
||||
[4.0.0]: https://github.com/tj/commander.js/compare/v3.0.2..v4.0.0
|
||||
[4.0.0-1]: https://github.com/tj/commander.js/compare/v4.0.0-0..v4.0.0-1
|
||||
[4.0.0-0]: https://github.com/tj/commander.js/compare/v3.0.2...v4.0.0-0
|
||||
22
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/commander/LICENSE
generated
vendored
Normal file
22
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/commander/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
(The MIT License)
|
||||
|
||||
Copyright (c) 2011 TJ Holowaychuk <tj@vision-media.ca>
|
||||
|
||||
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.
|
||||
791
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/commander/Readme.md
generated
vendored
Normal file
791
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/commander/Readme.md
generated
vendored
Normal file
|
|
@ -0,0 +1,791 @@
|
|||
# Commander.js
|
||||
|
||||
[](http://travis-ci.org/tj/commander.js)
|
||||
[](https://www.npmjs.org/package/commander)
|
||||
[](https://npmcharts.com/compare/commander?minimal=true)
|
||||
[](https://packagephobia.now.sh/result?p=commander)
|
||||
|
||||
The complete solution for [node.js](http://nodejs.org) command-line interfaces.
|
||||
|
||||
Read this in other languages: English | [简体中文](./Readme_zh-CN.md)
|
||||
|
||||
- [Commander.js](#commanderjs)
|
||||
- [Installation](#installation)
|
||||
- [Declaring _program_ variable](#declaring-program-variable)
|
||||
- [Options](#options)
|
||||
- [Common option types, boolean and value](#common-option-types-boolean-and-value)
|
||||
- [Default option value](#default-option-value)
|
||||
- [Other option types, negatable boolean and boolean|value](#other-option-types-negatable-boolean-and-booleanvalue)
|
||||
- [Custom option processing](#custom-option-processing)
|
||||
- [Required option](#required-option)
|
||||
- [Variadic option](#variadic-option)
|
||||
- [Version option](#version-option)
|
||||
- [Commands](#commands)
|
||||
- [Specify the argument syntax](#specify-the-argument-syntax)
|
||||
- [Action handler (sub)commands](#action-handler-subcommands)
|
||||
- [Stand-alone executable (sub)commands](#stand-alone-executable-subcommands)
|
||||
- [Automated help](#automated-help)
|
||||
- [Custom help](#custom-help)
|
||||
- [.usage and .name](#usage-and-name)
|
||||
- [.help(cb)](#helpcb)
|
||||
- [.outputHelp(cb)](#outputhelpcb)
|
||||
- [.helpInformation()](#helpinformation)
|
||||
- [.helpOption(flags, description)](#helpoptionflags-description)
|
||||
- [.addHelpCommand()](#addhelpcommand)
|
||||
- [Custom event listeners](#custom-event-listeners)
|
||||
- [Bits and pieces](#bits-and-pieces)
|
||||
- [.parse() and .parseAsync()](#parse-and-parseasync)
|
||||
- [Avoiding option name clashes](#avoiding-option-name-clashes)
|
||||
- [TypeScript](#typescript)
|
||||
- [createCommand()](#createcommand)
|
||||
- [Import into ECMAScript Module](#import-into-ecmascript-module)
|
||||
- [Node options such as `--harmony`](#node-options-such-as---harmony)
|
||||
- [Debugging stand-alone executable subcommands](#debugging-stand-alone-executable-subcommands)
|
||||
- [Override exit handling](#override-exit-handling)
|
||||
- [Examples](#examples)
|
||||
- [Support](#support)
|
||||
- [Commander for enterprise](#commander-for-enterprise)
|
||||
|
||||
For information about terms used in this document see: [terminology](./docs/terminology.md)
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install commander
|
||||
```
|
||||
|
||||
## Declaring _program_ variable
|
||||
|
||||
Commander exports a global object which is convenient for quick programs.
|
||||
This is used in the examples in this README for brevity.
|
||||
|
||||
```js
|
||||
const { program } = require('commander');
|
||||
program.version('0.0.1');
|
||||
```
|
||||
|
||||
For larger programs which may use commander in multiple ways, including unit testing, it is better to create a local Command object to use.
|
||||
|
||||
```js
|
||||
const { Command } = require('commander');
|
||||
const program = new Command();
|
||||
program.version('0.0.1');
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
Options are defined with the `.option()` method, also serving as documentation for the options. Each option can have a short flag (single character) and a long name, separated by a comma or space or vertical bar ('|').
|
||||
|
||||
The options can be accessed as properties on the Command object. Multi-word options such as "--template-engine" are camel-cased, becoming `program.templateEngine` etc. See also optional new behaviour to [avoid name clashes](#avoiding-option-name-clashes).
|
||||
|
||||
Multiple short flags may optionally be combined in a single argument following the dash: boolean flags, followed by a single option taking a value (possibly followed by the value).
|
||||
For example `-a -b -p 80` may be written as `-ab -p80` or even `-abp80`.
|
||||
|
||||
You can use `--` to indicate the end of the options, and any remaining arguments will be used without being interpreted.
|
||||
|
||||
Options on the command line are not positional, and can be specified before or after other arguments.
|
||||
|
||||
### Common option types, boolean and value
|
||||
|
||||
The two most used option types are a boolean option, and an option which takes its value
|
||||
from the following argument (declared with angle brackets like `--expect <value>`). Both are `undefined` unless specified on command line.
|
||||
|
||||
Example file: [options-common.js](./examples/options-common.js)
|
||||
|
||||
```js
|
||||
program
|
||||
.option('-d, --debug', 'output extra debugging')
|
||||
.option('-s, --small', 'small pizza size')
|
||||
.option('-p, --pizza-type <type>', 'flavour of pizza');
|
||||
|
||||
program.parse(process.argv);
|
||||
|
||||
if (program.debug) console.log(program.opts());
|
||||
console.log('pizza details:');
|
||||
if (program.small) console.log('- small pizza size');
|
||||
if (program.pizzaType) console.log(`- ${program.pizzaType}`);
|
||||
```
|
||||
|
||||
```bash
|
||||
$ pizza-options -d
|
||||
{ debug: true, small: undefined, pizzaType: undefined }
|
||||
pizza details:
|
||||
$ pizza-options -p
|
||||
error: option '-p, --pizza-type <type>' argument missing
|
||||
$ pizza-options -ds -p vegetarian
|
||||
{ debug: true, small: true, pizzaType: 'vegetarian' }
|
||||
pizza details:
|
||||
- small pizza size
|
||||
- vegetarian
|
||||
$ pizza-options --pizza-type=cheese
|
||||
pizza details:
|
||||
- cheese
|
||||
```
|
||||
|
||||
`program.parse(arguments)` processes the arguments, leaving any args not consumed by the program options in the `program.args` array.
|
||||
|
||||
### Default option value
|
||||
|
||||
You can specify a default value for an option which takes a value.
|
||||
|
||||
Example file: [options-defaults.js](./examples/options-defaults.js)
|
||||
|
||||
```js
|
||||
program
|
||||
.option('-c, --cheese <type>', 'add the specified type of cheese', 'blue');
|
||||
|
||||
program.parse(process.argv);
|
||||
|
||||
console.log(`cheese: ${program.cheese}`);
|
||||
```
|
||||
|
||||
```bash
|
||||
$ pizza-options
|
||||
cheese: blue
|
||||
$ pizza-options --cheese stilton
|
||||
cheese: stilton
|
||||
```
|
||||
|
||||
### Other option types, negatable boolean and boolean|value
|
||||
|
||||
You can define a boolean option long name with a leading `no-` to set the option value to false when used.
|
||||
Defined alone this also makes the option true by default.
|
||||
|
||||
If you define `--foo` first, adding `--no-foo` does not change the default value from what it would
|
||||
otherwise be. You can specify a default boolean value for a boolean option and it can be overridden on command line.
|
||||
|
||||
Example file: [options-negatable.js](./examples/options-negatable.js)
|
||||
|
||||
```js
|
||||
program
|
||||
.option('--no-sauce', 'Remove sauce')
|
||||
.option('--cheese <flavour>', 'cheese flavour', 'mozzarella')
|
||||
.option('--no-cheese', 'plain with no cheese')
|
||||
.parse(process.argv);
|
||||
|
||||
const sauceStr = program.sauce ? 'sauce' : 'no sauce';
|
||||
const cheeseStr = (program.cheese === false) ? 'no cheese' : `${program.cheese} cheese`;
|
||||
console.log(`You ordered a pizza with ${sauceStr} and ${cheeseStr}`);
|
||||
```
|
||||
|
||||
```bash
|
||||
$ pizza-options
|
||||
You ordered a pizza with sauce and mozzarella cheese
|
||||
$ pizza-options --sauce
|
||||
error: unknown option '--sauce'
|
||||
$ pizza-options --cheese=blue
|
||||
You ordered a pizza with sauce and blue cheese
|
||||
$ pizza-options --no-sauce --no-cheese
|
||||
You ordered a pizza with no sauce and no cheese
|
||||
```
|
||||
|
||||
You can specify an option which may be used as a boolean option but may optionally take an option-argument
|
||||
(declared with square brackets like `--optional [value]`).
|
||||
|
||||
Example file: [options-boolean-or-value.js](./examples/options-boolean-or-value.js)
|
||||
|
||||
```js
|
||||
program
|
||||
.option('-c, --cheese [type]', 'Add cheese with optional type');
|
||||
|
||||
program.parse(process.argv);
|
||||
|
||||
if (program.cheese === undefined) console.log('no cheese');
|
||||
else if (program.cheese === true) console.log('add cheese');
|
||||
else console.log(`add cheese type ${program.cheese}`);
|
||||
```
|
||||
|
||||
```bash
|
||||
$ pizza-options
|
||||
no cheese
|
||||
$ pizza-options --cheese
|
||||
add cheese
|
||||
$ pizza-options --cheese mozzarella
|
||||
add cheese type mozzarella
|
||||
```
|
||||
|
||||
For information about possible ambiguous cases, see [options taking varying arguments](./docs/options-taking-varying-arguments.md).
|
||||
|
||||
### Custom option processing
|
||||
|
||||
You may specify a function to do custom processing of option-arguments. The callback function receives two parameters,
|
||||
the user specified option-argument and the previous value for the option. It returns the new value for the option.
|
||||
|
||||
This allows you to coerce the option-argument to the desired type, or accumulate values, or do entirely custom processing.
|
||||
|
||||
You can optionally specify the default/starting value for the option after the function parameter.
|
||||
|
||||
Example file: [options-custom-processing.js](./examples/options-custom-processing.js)
|
||||
|
||||
```js
|
||||
function myParseInt(value, dummyPrevious) {
|
||||
// parseInt takes a string and an optional radix
|
||||
return parseInt(value);
|
||||
}
|
||||
|
||||
function increaseVerbosity(dummyValue, previous) {
|
||||
return previous + 1;
|
||||
}
|
||||
|
||||
function collect(value, previous) {
|
||||
return previous.concat([value]);
|
||||
}
|
||||
|
||||
function commaSeparatedList(value, dummyPrevious) {
|
||||
return value.split(',');
|
||||
}
|
||||
|
||||
program
|
||||
.option('-f, --float <number>', 'float argument', parseFloat)
|
||||
.option('-i, --integer <number>', 'integer argument', myParseInt)
|
||||
.option('-v, --verbose', 'verbosity that can be increased', increaseVerbosity, 0)
|
||||
.option('-c, --collect <value>', 'repeatable value', collect, [])
|
||||
.option('-l, --list <items>', 'comma separated list', commaSeparatedList)
|
||||
;
|
||||
|
||||
program.parse(process.argv);
|
||||
|
||||
if (program.float !== undefined) console.log(`float: ${program.float}`);
|
||||
if (program.integer !== undefined) console.log(`integer: ${program.integer}`);
|
||||
if (program.verbose > 0) console.log(`verbosity: ${program.verbose}`);
|
||||
if (program.collect.length > 0) console.log(program.collect);
|
||||
if (program.list !== undefined) console.log(program.list);
|
||||
```
|
||||
|
||||
```bash
|
||||
$ custom -f 1e2
|
||||
float: 100
|
||||
$ custom --integer 2
|
||||
integer: 2
|
||||
$ custom -v -v -v
|
||||
verbose: 3
|
||||
$ custom -c a -c b -c c
|
||||
[ 'a', 'b', 'c' ]
|
||||
$ custom --list x,y,z
|
||||
[ 'x', 'y', 'z' ]
|
||||
```
|
||||
|
||||
### Required option
|
||||
|
||||
You may specify a required (mandatory) option using `.requiredOption`. The option must have a value after parsing, usually specified on the command line, or perhaps from a default value (say from environment). The method is otherwise the same as `.option` in format, taking flags and description, and optional default value or custom processing.
|
||||
|
||||
Example file: [options-required.js](./examples/options-required.js)
|
||||
|
||||
```js
|
||||
program
|
||||
.requiredOption('-c, --cheese <type>', 'pizza must have cheese');
|
||||
|
||||
program.parse(process.argv);
|
||||
```
|
||||
|
||||
```bash
|
||||
$ pizza
|
||||
error: required option '-c, --cheese <type>' not specified
|
||||
```
|
||||
|
||||
### Variadic option
|
||||
|
||||
You may make an option variadic by appending `...` to the value placeholder when declaring the option. On the command line you
|
||||
can then specify multiple option-arguments, and the parsed option value will be an array. The extra arguments
|
||||
are read until the first argument starting with a dash. The special argument `--` stops option processing entirely. If a value
|
||||
is specified in the same argument as the option then no further values are read.
|
||||
|
||||
Example file: [options-variadic.js](./examples/options-variadic.js)
|
||||
|
||||
```js
|
||||
program
|
||||
.option('-n, --number <numbers...>', 'specify numbers')
|
||||
.option('-l, --letter [letters...]', 'specify letters');
|
||||
|
||||
program.parse();
|
||||
|
||||
console.log('Options: ', program.opts());
|
||||
console.log('Remaining arguments: ', program.args);
|
||||
```
|
||||
|
||||
```bash
|
||||
$ collect -n 1 2 3 --letter a b c
|
||||
Options: { number: [ '1', '2', '3' ], letter: [ 'a', 'b', 'c' ] }
|
||||
Remaining arguments: []
|
||||
$ collect --letter=A -n80 operand
|
||||
Options: { number: [ '80' ], letter: [ 'A' ] }
|
||||
Remaining arguments: [ 'operand' ]
|
||||
$ collect --letter -n 1 -n 2 3 -- operand
|
||||
Options: { number: [ '1', '2', '3' ], letter: true }
|
||||
Remaining arguments: [ 'operand' ]
|
||||
```
|
||||
|
||||
For information about possible ambiguous cases, see [options taking varying arguments](./docs/options-taking-varying-arguments.md).
|
||||
|
||||
### Version option
|
||||
|
||||
The optional `version` method adds handling for displaying the command version. The default option flags are `-V` and `--version`, and when present the command prints the version number and exits.
|
||||
|
||||
```js
|
||||
program.version('0.0.1');
|
||||
```
|
||||
|
||||
```bash
|
||||
$ ./examples/pizza -V
|
||||
0.0.1
|
||||
```
|
||||
|
||||
You may change the flags and description by passing additional parameters to the `version` method, using
|
||||
the same syntax for flags as the `option` method.
|
||||
|
||||
```js
|
||||
program.version('0.0.1', '-v, --vers', 'output the current version');
|
||||
```
|
||||
|
||||
## Commands
|
||||
|
||||
You can specify (sub)commands using `.command()` or `.addCommand()`. There are two ways these can be implemented: using an action handler attached to the command, or as a stand-alone executable file (described in more detail later). The subcommands may be nested ([example](./examples/nestedCommands.js)).
|
||||
|
||||
In the first parameter to `.command()` you specify the command name and any command-arguments. The arguments may be `<required>` or `[optional]`, and the last argument may also be `variadic...`.
|
||||
|
||||
You can use `.addCommand()` to add an already configured subcommand to the program.
|
||||
|
||||
For example:
|
||||
|
||||
```js
|
||||
// Command implemented using action handler (description is supplied separately to `.command`)
|
||||
// Returns new command for configuring.
|
||||
program
|
||||
.command('clone <source> [destination]')
|
||||
.description('clone a repository into a newly created directory')
|
||||
.action((source, destination) => {
|
||||
console.log('clone command called');
|
||||
});
|
||||
|
||||
// Command implemented using stand-alone executable file (description is second parameter to `.command`)
|
||||
// Returns `this` for adding more commands.
|
||||
program
|
||||
.command('start <service>', 'start named service')
|
||||
.command('stop [service]', 'stop named service, or all if no name supplied');
|
||||
|
||||
// Command prepared separately.
|
||||
// Returns `this` for adding more commands.
|
||||
program
|
||||
.addCommand(build.makeBuildCommand());
|
||||
```
|
||||
|
||||
Configuration options can be passed with the call to `.command()` and `.addCommand()`. Specifying `hidden: true` will
|
||||
remove the command from the generated help output. Specifying `isDefault: true` will run the subcommand if no other
|
||||
subcommand is specified ([example](./examples/defaultCommand.js)).
|
||||
|
||||
### Specify the argument syntax
|
||||
|
||||
You use `.arguments` to specify the expected command-arguments for the top-level command, and for subcommands they are usually
|
||||
included in the `.command` call. Angled brackets (e.g. `<required>`) indicate required command-arguments.
|
||||
Square brackets (e.g. `[optional]`) indicate optional command-arguments.
|
||||
You can optionally describe the arguments in the help by supplying a hash as second parameter to `.description()`.
|
||||
|
||||
Example file: [env](./examples/env)
|
||||
|
||||
```js
|
||||
program
|
||||
.version('0.1.0')
|
||||
.arguments('<cmd> [env]')
|
||||
.description('test command', {
|
||||
cmd: 'command to run',
|
||||
env: 'environment to run test in'
|
||||
})
|
||||
.action(function (cmd, env) {
|
||||
console.log('command:', cmd);
|
||||
console.log('environment:', env || 'no environment given');
|
||||
});
|
||||
|
||||
program.parse(process.argv);
|
||||
```
|
||||
|
||||
The last argument of a command can be variadic, and only the last argument. To make an argument variadic you
|
||||
append `...` to the argument name. For example:
|
||||
|
||||
```js
|
||||
const { program } = require('commander');
|
||||
|
||||
program
|
||||
.version('0.1.0')
|
||||
.command('rmdir <dir> [otherDirs...]')
|
||||
.action(function (dir, otherDirs) {
|
||||
console.log('rmdir %s', dir);
|
||||
if (otherDirs) {
|
||||
otherDirs.forEach(function (oDir) {
|
||||
console.log('rmdir %s', oDir);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
program.parse(process.argv);
|
||||
```
|
||||
|
||||
The variadic argument is passed to the action handler as an array.
|
||||
|
||||
### Action handler (sub)commands
|
||||
|
||||
You can add options to a command that uses an action handler.
|
||||
The action handler gets passed a parameter for each argument you declared, and one additional argument which is the
|
||||
command object itself. This command argument has the values for the command-specific options added as properties.
|
||||
|
||||
```js
|
||||
const { program } = require('commander');
|
||||
|
||||
program
|
||||
.command('rm <dir>')
|
||||
.option('-r, --recursive', 'Remove recursively')
|
||||
.action(function (dir, cmdObj) {
|
||||
console.log('remove ' + dir + (cmdObj.recursive ? ' recursively' : ''))
|
||||
})
|
||||
|
||||
program.parse(process.argv)
|
||||
```
|
||||
|
||||
You may supply an `async` action handler, in which case you call `.parseAsync` rather than `.parse`.
|
||||
|
||||
```js
|
||||
async function run() { /* code goes here */ }
|
||||
|
||||
async function main() {
|
||||
program
|
||||
.command('run')
|
||||
.action(run);
|
||||
await program.parseAsync(process.argv);
|
||||
}
|
||||
```
|
||||
|
||||
A command's options on the command line are validated when the command is used. Any unknown options will be reported as an error.
|
||||
|
||||
### Stand-alone executable (sub)commands
|
||||
|
||||
When `.command()` is invoked with a description argument, this tells Commander that you're going to use stand-alone executables for subcommands.
|
||||
Commander will search the executables in the directory of the entry script (like `./examples/pm`) with the name `program-subcommand`, like `pm-install`, `pm-search`.
|
||||
You can specify a custom name with the `executableFile` configuration option.
|
||||
|
||||
You handle the options for an executable (sub)command in the executable, and don't declare them at the top-level.
|
||||
|
||||
Example file: [pm](./examples/pm)
|
||||
|
||||
```js
|
||||
program
|
||||
.version('0.1.0')
|
||||
.command('install [name]', 'install one or more packages')
|
||||
.command('search [query]', 'search with optional query')
|
||||
.command('update', 'update installed packages', { executableFile: 'myUpdateSubCommand' })
|
||||
.command('list', 'list packages installed', { isDefault: true });
|
||||
|
||||
program.parse(process.argv);
|
||||
```
|
||||
|
||||
If the program is designed to be installed globally, make sure the executables have proper modes, like `755`.
|
||||
|
||||
## Automated help
|
||||
|
||||
The help information is auto-generated based on the information commander already knows about your program. The default
|
||||
help option is `-h,--help`.
|
||||
|
||||
Example file: [pizza](./examples/pizza)
|
||||
|
||||
```bash
|
||||
$ node ./examples/pizza --help
|
||||
Usage: pizza [options]
|
||||
|
||||
An application for pizzas ordering
|
||||
|
||||
Options:
|
||||
-V, --version output the version number
|
||||
-p, --peppers Add peppers
|
||||
-c, --cheese <type> Add the specified type of cheese (default: "marble")
|
||||
-C, --no-cheese You do not want any cheese
|
||||
-h, --help display help for command
|
||||
```
|
||||
|
||||
A `help` command is added by default if your command has subcommands. It can be used alone, or with a subcommand name to show
|
||||
further help for the subcommand. These are effectively the same if the `shell` program has implicit help:
|
||||
|
||||
```bash
|
||||
shell help
|
||||
shell --help
|
||||
|
||||
shell help spawn
|
||||
shell spawn --help
|
||||
```
|
||||
|
||||
### Custom help
|
||||
|
||||
You can display extra information by listening for "--help".
|
||||
|
||||
Example file: [custom-help](./examples/custom-help)
|
||||
|
||||
```js
|
||||
program
|
||||
.option('-f, --foo', 'enable some foo');
|
||||
|
||||
// must be before .parse()
|
||||
program.on('--help', () => {
|
||||
console.log('');
|
||||
console.log('Example call:');
|
||||
console.log(' $ custom-help --help');
|
||||
});
|
||||
```
|
||||
|
||||
Yields the following help output:
|
||||
|
||||
```Text
|
||||
Usage: custom-help [options]
|
||||
|
||||
Options:
|
||||
-f, --foo enable some foo
|
||||
-h, --help display help for command
|
||||
|
||||
Example call:
|
||||
$ custom-help --help
|
||||
```
|
||||
|
||||
### .usage and .name
|
||||
|
||||
These allow you to customise the usage description in the first line of the help. The name is otherwise
|
||||
deduced from the (full) program arguments. Given:
|
||||
|
||||
```js
|
||||
program
|
||||
.name("my-command")
|
||||
.usage("[global options] command")
|
||||
```
|
||||
|
||||
The help will start with:
|
||||
|
||||
```Text
|
||||
Usage: my-command [global options] command
|
||||
```
|
||||
|
||||
### .help(cb)
|
||||
|
||||
Output help information and exit immediately. Optional callback cb allows post-processing of help text before it is displayed.
|
||||
|
||||
### .outputHelp(cb)
|
||||
|
||||
Output help information without exiting.
|
||||
Optional callback cb allows post-processing of help text before it is displayed.
|
||||
|
||||
### .helpInformation()
|
||||
|
||||
Get the command help information as a string for processing or displaying yourself. (The text does not include the custom help
|
||||
from `--help` listeners.)
|
||||
|
||||
### .helpOption(flags, description)
|
||||
|
||||
Override the default help flags and description. Pass false to disable the built-in help option.
|
||||
|
||||
```js
|
||||
program
|
||||
.helpOption('-e, --HELP', 'read more information');
|
||||
```
|
||||
|
||||
### .addHelpCommand()
|
||||
|
||||
You can explicitly turn on or off the implicit help command with `.addHelpCommand()` and `.addHelpCommand(false)`.
|
||||
|
||||
You can both turn on and customise the help command by supplying the name and description:
|
||||
|
||||
```js
|
||||
program.addHelpCommand('assist [command]', 'show assistance');
|
||||
```
|
||||
|
||||
## Custom event listeners
|
||||
|
||||
You can execute custom actions by listening to command and option events.
|
||||
|
||||
```js
|
||||
program.on('option:verbose', function () {
|
||||
process.env.VERBOSE = this.verbose;
|
||||
});
|
||||
|
||||
program.on('command:*', function (operands) {
|
||||
console.error(`error: unknown command '${operands[0]}'`);
|
||||
const availableCommands = program.commands.map(cmd => cmd.name());
|
||||
mySuggestBestMatch(operands[0], availableCommands);
|
||||
process.exitCode = 1;
|
||||
});
|
||||
```
|
||||
|
||||
## Bits and pieces
|
||||
|
||||
### .parse() and .parseAsync()
|
||||
|
||||
The first argument to `.parse` is the array of strings to parse. You may omit the parameter to implicitly use `process.argv`.
|
||||
|
||||
If the arguments follow different conventions than node you can pass a `from` option in the second parameter:
|
||||
|
||||
- 'node': default, `argv[0]` is the application and `argv[1]` is the script being run, with user parameters after that
|
||||
- 'electron': `argv[1]` varies depending on whether the electron application is packaged
|
||||
- 'user': all of the arguments from the user
|
||||
|
||||
For example:
|
||||
|
||||
```js
|
||||
program.parse(process.argv); // Explicit, node conventions
|
||||
program.parse(); // Implicit, and auto-detect electron
|
||||
program.parse(['-f', 'filename'], { from: 'user' });
|
||||
```
|
||||
|
||||
### Avoiding option name clashes
|
||||
|
||||
The original and default behaviour is that the option values are stored
|
||||
as properties on the program, and the action handler is passed a
|
||||
command object with the options values stored as properties.
|
||||
This is very convenient to code, but the downside is possible clashes with
|
||||
existing properties of Command.
|
||||
|
||||
There are two new routines to change the behaviour, and the default behaviour may change in the future:
|
||||
|
||||
- `storeOptionsAsProperties`: whether to store option values as properties on command object, or store separately (specify false) and access using `.opts()`
|
||||
- `passCommandToAction`: whether to pass command to action handler,
|
||||
or just the options (specify false)
|
||||
|
||||
Example file: [storeOptionsAsProperties-action.js](./examples/storeOptionsAsProperties-action.js)
|
||||
|
||||
```js
|
||||
program
|
||||
.storeOptionsAsProperties(false)
|
||||
.passCommandToAction(false);
|
||||
|
||||
program
|
||||
.name('my-program-name')
|
||||
.option('-n,--name <name>');
|
||||
|
||||
program
|
||||
.command('show')
|
||||
.option('-a,--action <action>')
|
||||
.action((options) => {
|
||||
console.log(options.action);
|
||||
});
|
||||
|
||||
program.parse(process.argv);
|
||||
|
||||
const programOptions = program.opts();
|
||||
console.log(programOptions.name);
|
||||
```
|
||||
|
||||
### TypeScript
|
||||
|
||||
The Commander package includes its TypeScript Definition file.
|
||||
|
||||
If you use `ts-node` and stand-alone executable subcommands written as `.ts` files, you need to call your program through node to get the subcommands called correctly. e.g.
|
||||
|
||||
```bash
|
||||
node -r ts-node/register pm.ts
|
||||
```
|
||||
|
||||
### createCommand()
|
||||
|
||||
This factory function creates a new command. It is exported and may be used instead of using `new`, like:
|
||||
|
||||
```js
|
||||
const { createCommand } = require('commander');
|
||||
const program = createCommand();
|
||||
```
|
||||
|
||||
`createCommand` is also a method of the Command object, and creates a new command rather than a subcommand. This gets used internally
|
||||
when creating subcommands using `.command()`, and you may override it to
|
||||
customise the new subcommand (examples using [subclass](./examples/custom-command-class.js) and [function](./examples/custom-command-function.js)).
|
||||
|
||||
### Import into ECMAScript Module
|
||||
|
||||
Commander is currently a CommonJS package, and the default export can be imported into an ES Module:
|
||||
|
||||
```js
|
||||
// index.mjs
|
||||
import commander from 'commander';
|
||||
const program = commander.program;
|
||||
const newCommand = new commander.Command();
|
||||
```
|
||||
|
||||
### Node options such as `--harmony`
|
||||
|
||||
You can enable `--harmony` option in two ways:
|
||||
|
||||
- Use `#! /usr/bin/env node --harmony` in the subcommands scripts. (Note Windows does not support this pattern.)
|
||||
- Use the `--harmony` option when call the command, like `node --harmony examples/pm publish`. The `--harmony` option will be preserved when spawning subcommand process.
|
||||
|
||||
### Debugging stand-alone executable subcommands
|
||||
|
||||
An executable subcommand is launched as a separate child process.
|
||||
|
||||
If you are using the node inspector for [debugging](https://nodejs.org/en/docs/guides/debugging-getting-started/) executable subcommands using `node --inspect` et al,
|
||||
the inspector port is incremented by 1 for the spawned subcommand.
|
||||
|
||||
If you are using VSCode to debug executable subcommands you need to set the `"autoAttachChildProcesses": true` flag in your launch.json configuration.
|
||||
|
||||
### Override exit handling
|
||||
|
||||
By default Commander calls `process.exit` when it detects errors, or after displaying the help or version. You can override
|
||||
this behaviour and optionally supply a callback. The default override throws a `CommanderError`.
|
||||
|
||||
The override callback is passed a `CommanderError` with properties `exitCode` number, `code` string, and `message`. The default override behaviour is to throw the error, except for async handling of executable subcommand completion which carries on. The normal display of error messages or version or help
|
||||
is not affected by the override which is called after the display.
|
||||
|
||||
```js
|
||||
program.exitOverride();
|
||||
|
||||
try {
|
||||
program.parse(process.argv);
|
||||
} catch (err) {
|
||||
// custom processing...
|
||||
}
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
Example file: [deploy](./examples/deploy)
|
||||
|
||||
```js
|
||||
const { program } = require('commander');
|
||||
|
||||
program
|
||||
.version('0.1.0')
|
||||
.option('-C, --chdir <path>', 'change the working directory')
|
||||
.option('-c, --config <path>', 'set config path. defaults to ./deploy.conf')
|
||||
.option('-T, --no-tests', 'ignore test hook');
|
||||
|
||||
program
|
||||
.command('setup [env]')
|
||||
.description('run setup commands for all envs')
|
||||
.option("-s, --setup_mode [mode]", "Which setup mode to use")
|
||||
.action(function(env, options){
|
||||
const mode = options.setup_mode || "normal";
|
||||
env = env || 'all';
|
||||
console.log('setup for %s env(s) with %s mode', env, mode);
|
||||
});
|
||||
|
||||
program
|
||||
.command('exec <cmd>')
|
||||
.alias('ex')
|
||||
.description('execute the given remote cmd')
|
||||
.option("-e, --exec_mode <mode>", "Which exec mode to use")
|
||||
.action(function(cmd, options){
|
||||
console.log('exec "%s" using %s mode', cmd, options.exec_mode);
|
||||
}).on('--help', function() {
|
||||
console.log('');
|
||||
console.log('Examples:');
|
||||
console.log('');
|
||||
console.log(' $ deploy exec sequential');
|
||||
console.log(' $ deploy exec async');
|
||||
});
|
||||
|
||||
program.parse(process.argv);
|
||||
```
|
||||
|
||||
More Demos can be found in the [examples](https://github.com/tj/commander.js/tree/master/examples) directory.
|
||||
|
||||
## Support
|
||||
|
||||
The current version of Commander is fully supported on Long Term Support versions of Node, and is likely to work with Node 6 but not tested.
|
||||
(For versions of Node below Node 6, use Commander 3.x or 2.x.)
|
||||
|
||||
The main forum for free and community support is the project [Issues](https://github.com/tj/commander.js/issues) on GitHub.
|
||||
|
||||
### Commander for enterprise
|
||||
|
||||
Available as part of the Tidelift Subscription
|
||||
|
||||
The maintainers of Commander and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-commander?utm_source=npm-commander&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
||||
1881
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/commander/index.js
generated
vendored
Normal file
1881
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/commander/index.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
51
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/commander/package.json
generated
vendored
Normal file
51
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/commander/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
{
|
||||
"name": "commander",
|
||||
"version": "6.2.1",
|
||||
"description": "the complete solution for node.js command-line programs",
|
||||
"keywords": [
|
||||
"commander",
|
||||
"command",
|
||||
"option",
|
||||
"parser",
|
||||
"cli",
|
||||
"argument",
|
||||
"args",
|
||||
"argv"
|
||||
],
|
||||
"author": "TJ Holowaychuk <tj@vision-media.ca>",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/tj/commander.js.git"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "eslint index.js \"tests/**/*.js\"",
|
||||
"typescript-lint": "eslint typings/*.ts",
|
||||
"test": "jest && npm run test-typings",
|
||||
"test-typings": "tsc -p tsconfig.json"
|
||||
},
|
||||
"main": "index",
|
||||
"files": [
|
||||
"index.js",
|
||||
"typings/index.d.ts"
|
||||
],
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^26.0.15",
|
||||
"@types/node": "^14.14.2",
|
||||
"@typescript-eslint/eslint-plugin": "^4.5.0",
|
||||
"eslint": "^7.11.0",
|
||||
"eslint-config-standard-with-typescript": "^19.0.1",
|
||||
"eslint-plugin-jest": "^24.1.0",
|
||||
"jest": "^26.6.0",
|
||||
"standard": "^15.0.0",
|
||||
"typescript": "^4.0.3"
|
||||
},
|
||||
"typings": "typings/index.d.ts",
|
||||
"jest": {
|
||||
"collectCoverage": true
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6"
|
||||
}
|
||||
}
|
||||
410
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/commander/typings/index.d.ts
generated
vendored
Normal file
410
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/commander/typings/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,410 @@
|
|||
// Type definitions for commander
|
||||
// Original definitions by: Alan Agius <https://github.com/alan-agius4>, Marcelo Dezem <https://github.com/mdezem>, vvakame <https://github.com/vvakame>, Jules Randolph <https://github.com/sveinburne>
|
||||
|
||||
declare namespace commander {
|
||||
|
||||
interface CommanderError extends Error {
|
||||
code: string;
|
||||
exitCode: number;
|
||||
message: string;
|
||||
nestedError?: string;
|
||||
}
|
||||
type CommanderErrorConstructor = new (exitCode: number, code: string, message: string) => CommanderError;
|
||||
|
||||
interface Option {
|
||||
flags: string;
|
||||
required: boolean; // A value must be supplied when the option is specified.
|
||||
optional: boolean; // A value is optional when the option is specified.
|
||||
mandatory: boolean; // The option must have a value after parsing, which usually means it must be specified on command line.
|
||||
bool: boolean;
|
||||
short?: string;
|
||||
long: string;
|
||||
description: string;
|
||||
}
|
||||
type OptionConstructor = new (flags: string, description?: string) => Option;
|
||||
|
||||
interface ParseOptions {
|
||||
from: 'node' | 'electron' | 'user';
|
||||
}
|
||||
|
||||
interface Command {
|
||||
[key: string]: any; // options as properties
|
||||
|
||||
args: string[];
|
||||
|
||||
commands: Command[];
|
||||
|
||||
/**
|
||||
* Set the program version to `str`.
|
||||
*
|
||||
* This method auto-registers the "-V, --version" flag
|
||||
* which will print the version number when passed.
|
||||
*
|
||||
* You can optionally supply the flags and description to override the defaults.
|
||||
*/
|
||||
version(str: string, flags?: string, description?: string): this;
|
||||
|
||||
/**
|
||||
* Define a command, implemented using an action handler.
|
||||
*
|
||||
* @remarks
|
||||
* The command description is supplied using `.description`, not as a parameter to `.command`.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* program
|
||||
* .command('clone <source> [destination]')
|
||||
* .description('clone a repository into a newly created directory')
|
||||
* .action((source, destination) => {
|
||||
* console.log('clone command called');
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* @param nameAndArgs - command name and arguments, args are `<required>` or `[optional]` and last may also be `variadic...`
|
||||
* @param opts - configuration options
|
||||
* @returns new command
|
||||
*/
|
||||
command(nameAndArgs: string, opts?: CommandOptions): ReturnType<this['createCommand']>;
|
||||
/**
|
||||
* Define a command, implemented in a separate executable file.
|
||||
*
|
||||
* @remarks
|
||||
* The command description is supplied as the second parameter to `.command`.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* program
|
||||
* .command('start <service>', 'start named service')
|
||||
* .command('stop [service]', 'stop named service, or all if no name supplied');
|
||||
* ```
|
||||
*
|
||||
* @param nameAndArgs - command name and arguments, args are `<required>` or `[optional]` and last may also be `variadic...`
|
||||
* @param description - description of executable command
|
||||
* @param opts - configuration options
|
||||
* @returns `this` command for chaining
|
||||
*/
|
||||
command(nameAndArgs: string, description: string, opts?: commander.ExecutableCommandOptions): this;
|
||||
|
||||
/**
|
||||
* Factory routine to create a new unattached command.
|
||||
*
|
||||
* See .command() for creating an attached subcommand, which uses this routine to
|
||||
* create the command. You can override createCommand to customise subcommands.
|
||||
*/
|
||||
createCommand(name?: string): Command;
|
||||
|
||||
/**
|
||||
* Add a prepared subcommand.
|
||||
*
|
||||
* See .command() for creating an attached subcommand which inherits settings from its parent.
|
||||
*
|
||||
* @returns `this` command for chaining
|
||||
*/
|
||||
addCommand(cmd: Command, opts?: CommandOptions): this;
|
||||
|
||||
/**
|
||||
* Define argument syntax for command.
|
||||
*
|
||||
* @returns `this` command for chaining
|
||||
*/
|
||||
arguments(desc: string): this;
|
||||
|
||||
/**
|
||||
* Override default decision whether to add implicit help command.
|
||||
*
|
||||
* addHelpCommand() // force on
|
||||
* addHelpCommand(false); // force off
|
||||
* addHelpCommand('help [cmd]', 'display help for [cmd]'); // force on with custom details
|
||||
*
|
||||
* @returns `this` command for chaining
|
||||
*/
|
||||
addHelpCommand(enableOrNameAndArgs?: string | boolean, description?: string): this;
|
||||
|
||||
/**
|
||||
* Register callback to use as replacement for calling process.exit.
|
||||
*/
|
||||
exitOverride(callback?: (err: CommanderError) => never|void): this;
|
||||
|
||||
/**
|
||||
* Register callback `fn` for the command.
|
||||
*
|
||||
* @example
|
||||
* program
|
||||
* .command('help')
|
||||
* .description('display verbose help')
|
||||
* .action(function() {
|
||||
* // output help here
|
||||
* });
|
||||
*
|
||||
* @returns `this` command for chaining
|
||||
*/
|
||||
action(fn: (...args: any[]) => void | Promise<void>): this;
|
||||
|
||||
/**
|
||||
* Define option with `flags`, `description` and optional
|
||||
* coercion `fn`.
|
||||
*
|
||||
* The `flags` string should contain both the short and long flags,
|
||||
* separated by comma, a pipe or space. The following are all valid
|
||||
* all will output this way when `--help` is used.
|
||||
*
|
||||
* "-p, --pepper"
|
||||
* "-p|--pepper"
|
||||
* "-p --pepper"
|
||||
*
|
||||
* @example
|
||||
* // simple boolean defaulting to false
|
||||
* program.option('-p, --pepper', 'add pepper');
|
||||
*
|
||||
* --pepper
|
||||
* program.pepper
|
||||
* // => Boolean
|
||||
*
|
||||
* // simple boolean defaulting to true
|
||||
* program.option('-C, --no-cheese', 'remove cheese');
|
||||
*
|
||||
* program.cheese
|
||||
* // => true
|
||||
*
|
||||
* --no-cheese
|
||||
* program.cheese
|
||||
* // => false
|
||||
*
|
||||
* // required argument
|
||||
* program.option('-C, --chdir <path>', 'change the working directory');
|
||||
*
|
||||
* --chdir /tmp
|
||||
* program.chdir
|
||||
* // => "/tmp"
|
||||
*
|
||||
* // optional argument
|
||||
* program.option('-c, --cheese [type]', 'add cheese [marble]');
|
||||
*
|
||||
* @returns `this` command for chaining
|
||||
*/
|
||||
option(flags: string, description?: string, defaultValue?: string | boolean): this;
|
||||
option(flags: string, description: string, regexp: RegExp, defaultValue?: string | boolean): this;
|
||||
option<T>(flags: string, description: string, fn: (value: string, previous: T) => T, defaultValue?: T): this;
|
||||
|
||||
/**
|
||||
* Define a required option, which must have a value after parsing. This usually means
|
||||
* the option must be specified on the command line. (Otherwise the same as .option().)
|
||||
*
|
||||
* The `flags` string should contain both the short and long flags, separated by comma, a pipe or space.
|
||||
*/
|
||||
requiredOption(flags: string, description?: string, defaultValue?: string | boolean): this;
|
||||
requiredOption(flags: string, description: string, regexp: RegExp, defaultValue?: string | boolean): this;
|
||||
requiredOption<T>(flags: string, description: string, fn: (value: string, previous: T) => T, defaultValue?: T): this;
|
||||
|
||||
/**
|
||||
* Whether to store option values as properties on command object,
|
||||
* or store separately (specify false). In both cases the option values can be accessed using .opts().
|
||||
*
|
||||
* @returns `this` command for chaining
|
||||
*/
|
||||
storeOptionsAsProperties(value?: boolean): this;
|
||||
|
||||
/**
|
||||
* Whether to pass command to action handler,
|
||||
* or just the options (specify false).
|
||||
*
|
||||
* @returns `this` command for chaining
|
||||
*/
|
||||
passCommandToAction(value?: boolean): this;
|
||||
|
||||
/**
|
||||
* Alter parsing of short flags with optional values.
|
||||
*
|
||||
* @example
|
||||
* // for `.option('-f,--flag [value]'):
|
||||
* .combineFlagAndOptionalValue(true) // `-f80` is treated like `--flag=80`, this is the default behaviour
|
||||
* .combineFlagAndOptionalValue(false) // `-fb` is treated like `-f -b`
|
||||
*
|
||||
* @returns `this` command for chaining
|
||||
*/
|
||||
combineFlagAndOptionalValue(arg?: boolean): this;
|
||||
|
||||
/**
|
||||
* Allow unknown options on the command line.
|
||||
*
|
||||
* @param [arg] if `true` or omitted, no error will be thrown for unknown options.
|
||||
* @returns `this` command for chaining
|
||||
*/
|
||||
allowUnknownOption(arg?: boolean): this;
|
||||
|
||||
/**
|
||||
* Parse `argv`, setting options and invoking commands when defined.
|
||||
*
|
||||
* The default expectation is that the arguments are from node and have the application as argv[0]
|
||||
* and the script being run in argv[1], with user parameters after that.
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* program.parse(process.argv);
|
||||
* program.parse(); // implicitly use process.argv and auto-detect node vs electron conventions
|
||||
* program.parse(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
|
||||
*
|
||||
* @returns `this` command for chaining
|
||||
*/
|
||||
parse(argv?: string[], options?: ParseOptions): this;
|
||||
|
||||
/**
|
||||
* Parse `argv`, setting options and invoking commands when defined.
|
||||
*
|
||||
* Use parseAsync instead of parse if any of your action handlers are async. Returns a Promise.
|
||||
*
|
||||
* The default expectation is that the arguments are from node and have the application as argv[0]
|
||||
* and the script being run in argv[1], with user parameters after that.
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* program.parseAsync(process.argv);
|
||||
* program.parseAsync(); // implicitly use process.argv and auto-detect node vs electron conventions
|
||||
* program.parseAsync(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
|
||||
*
|
||||
* @returns Promise
|
||||
*/
|
||||
parseAsync(argv?: string[], options?: ParseOptions): Promise<this>;
|
||||
|
||||
/**
|
||||
* Parse options from `argv` removing known options,
|
||||
* and return argv split into operands and unknown arguments.
|
||||
*
|
||||
* @example
|
||||
* argv => operands, unknown
|
||||
* --known kkk op => [op], []
|
||||
* op --known kkk => [op], []
|
||||
* sub --unknown uuu op => [sub], [--unknown uuu op]
|
||||
* sub -- --unknown uuu op => [sub --unknown uuu op], []
|
||||
*/
|
||||
parseOptions(argv: string[]): commander.ParseOptionsResult;
|
||||
|
||||
/**
|
||||
* Return an object containing options as key-value pairs
|
||||
*/
|
||||
opts(): { [key: string]: any };
|
||||
|
||||
/**
|
||||
* Set the description.
|
||||
*
|
||||
* @returns `this` command for chaining
|
||||
*/
|
||||
description(str: string, argsDescription?: {[argName: string]: string}): this;
|
||||
/**
|
||||
* Get the description.
|
||||
*/
|
||||
description(): string;
|
||||
|
||||
/**
|
||||
* Set an alias for the command.
|
||||
*
|
||||
* You may call more than once to add multiple aliases. Only the first alias is shown in the auto-generated help.
|
||||
*
|
||||
* @returns `this` command for chaining
|
||||
*/
|
||||
alias(alias: string): this;
|
||||
/**
|
||||
* Get alias for the command.
|
||||
*/
|
||||
alias(): string;
|
||||
|
||||
/**
|
||||
* Set aliases for the command.
|
||||
*
|
||||
* Only the first alias is shown in the auto-generated help.
|
||||
*
|
||||
* @returns `this` command for chaining
|
||||
*/
|
||||
aliases(aliases: string[]): this;
|
||||
/**
|
||||
* Get aliases for the command.
|
||||
*/
|
||||
aliases(): string[];
|
||||
|
||||
/**
|
||||
* Set the command usage.
|
||||
*
|
||||
* @returns `this` command for chaining
|
||||
*/
|
||||
usage(str: string): this;
|
||||
/**
|
||||
* Get the command usage.
|
||||
*/
|
||||
usage(): string;
|
||||
|
||||
/**
|
||||
* Set the name of the command.
|
||||
*
|
||||
* @returns `this` command for chaining
|
||||
*/
|
||||
name(str: string): this;
|
||||
/**
|
||||
* Get the name of the command.
|
||||
*/
|
||||
name(): string;
|
||||
|
||||
/**
|
||||
* Output help information for this command.
|
||||
*
|
||||
* When listener(s) are available for the helpLongFlag
|
||||
* those callbacks are invoked.
|
||||
*/
|
||||
outputHelp(cb?: (str: string) => string): void;
|
||||
|
||||
/**
|
||||
* Return command help documentation.
|
||||
*/
|
||||
helpInformation(): string;
|
||||
|
||||
/**
|
||||
* You can pass in flags and a description to override the help
|
||||
* flags and help description for your command. Pass in false
|
||||
* to disable the built-in help option.
|
||||
*/
|
||||
helpOption(flags?: string | boolean, description?: string): this;
|
||||
|
||||
/**
|
||||
* Output help information and exit.
|
||||
*/
|
||||
help(cb?: (str: string) => string): never;
|
||||
|
||||
/**
|
||||
* Add a listener (callback) for when events occur. (Implemented using EventEmitter.)
|
||||
*
|
||||
* @example
|
||||
* program
|
||||
* .on('--help', () -> {
|
||||
* console.log('See web site for more information.');
|
||||
* });
|
||||
*/
|
||||
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
}
|
||||
type CommandConstructor = new (name?: string) => Command;
|
||||
|
||||
interface CommandOptions {
|
||||
noHelp?: boolean; // old name for hidden
|
||||
hidden?: boolean;
|
||||
isDefault?: boolean;
|
||||
}
|
||||
interface ExecutableCommandOptions extends CommandOptions {
|
||||
executableFile?: string;
|
||||
}
|
||||
|
||||
interface ParseOptionsResult {
|
||||
operands: string[];
|
||||
unknown: string[];
|
||||
}
|
||||
|
||||
interface CommanderStatic extends Command {
|
||||
program: Command;
|
||||
Command: CommandConstructor;
|
||||
Option: OptionConstructor;
|
||||
CommanderError: CommanderErrorConstructor;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Declaring namespace AND global
|
||||
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
||||
declare const commander: commander.CommanderStatic;
|
||||
export = commander;
|
||||
5
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/is-docker/cli.js
generated
vendored
Normal file
5
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/is-docker/cli.js
generated
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
const isDocker = require('.');
|
||||
|
||||
process.exitCode = isDocker() ? 0 : 2;
|
||||
15
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/is-docker/index.d.ts
generated
vendored
Normal file
15
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/is-docker/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
/**
|
||||
Check if the process is running inside a Docker container.
|
||||
|
||||
@example
|
||||
```
|
||||
import isDocker = require('is-docker');
|
||||
|
||||
if (isDocker()) {
|
||||
console.log('Running inside a Docker container');
|
||||
}
|
||||
```
|
||||
*/
|
||||
declare function isDocker(): boolean;
|
||||
|
||||
export = isDocker;
|
||||
29
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/is-docker/index.js
generated
vendored
Normal file
29
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/is-docker/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
'use strict';
|
||||
const fs = require('fs');
|
||||
|
||||
let isDocker;
|
||||
|
||||
function hasDockerEnv() {
|
||||
try {
|
||||
fs.statSync('/.dockerenv');
|
||||
return true;
|
||||
} catch (_) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function hasDockerCGroup() {
|
||||
try {
|
||||
return fs.readFileSync('/proc/self/cgroup', 'utf8').includes('docker');
|
||||
} catch (_) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = () => {
|
||||
if (isDocker === undefined) {
|
||||
isDocker = hasDockerEnv() || hasDockerCGroup();
|
||||
}
|
||||
|
||||
return isDocker;
|
||||
};
|
||||
9
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/is-docker/license
generated
vendored
Normal file
9
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/is-docker/license
generated
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
||||
|
||||
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.
|
||||
42
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/is-docker/package.json
generated
vendored
Normal file
42
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/is-docker/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
{
|
||||
"name": "is-docker",
|
||||
"version": "2.2.1",
|
||||
"description": "Check if the process is running inside a Docker container",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/is-docker",
|
||||
"funding": "https://github.com/sponsors/sindresorhus",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "https://sindresorhus.com"
|
||||
},
|
||||
"bin": "cli.js",
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts",
|
||||
"cli.js"
|
||||
],
|
||||
"keywords": [
|
||||
"detect",
|
||||
"docker",
|
||||
"dockerized",
|
||||
"container",
|
||||
"inside",
|
||||
"is",
|
||||
"env",
|
||||
"environment",
|
||||
"process"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "^1.4.1",
|
||||
"sinon": "^7.3.2",
|
||||
"tsd": "^0.7.2",
|
||||
"xo": "^0.24.0"
|
||||
}
|
||||
}
|
||||
27
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/is-docker/readme.md
generated
vendored
Normal file
27
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/is-docker/readme.md
generated
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
# is-docker
|
||||
|
||||
> Check if the process is running inside a Docker container
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install is-docker
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const isDocker = require('is-docker');
|
||||
|
||||
if (isDocker()) {
|
||||
console.log('Running inside a Docker container');
|
||||
}
|
||||
```
|
||||
|
||||
## CLI
|
||||
|
||||
```
|
||||
$ is-docker
|
||||
```
|
||||
|
||||
Exits with code 0 if inside a Docker container and 2 if not.
|
||||
15
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/is-wsl/index.d.ts
generated
vendored
Normal file
15
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/is-wsl/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
/**
|
||||
Check if the process is running inside [Windows Subsystem for Linux](https://msdn.microsoft.com/commandline/wsl/about) (Bash on Windows).
|
||||
|
||||
@example
|
||||
```
|
||||
import isWsl = require('is-wsl');
|
||||
|
||||
// When running inside Windows Subsystem for Linux
|
||||
console.log(isWsl);
|
||||
//=> true
|
||||
```
|
||||
*/
|
||||
declare const isWsl: boolean;
|
||||
|
||||
export = isWsl;
|
||||
31
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/is-wsl/index.js
generated
vendored
Normal file
31
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/is-wsl/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
'use strict';
|
||||
const os = require('os');
|
||||
const fs = require('fs');
|
||||
const isDocker = require('is-docker');
|
||||
|
||||
const isWsl = () => {
|
||||
if (process.platform !== 'linux') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (os.release().toLowerCase().includes('microsoft')) {
|
||||
if (isDocker()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
return fs.readFileSync('/proc/version', 'utf8').toLowerCase().includes('microsoft') ?
|
||||
!isDocker() : false;
|
||||
} catch (_) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
if (process.env.__IS_WSL_TEST__) {
|
||||
module.exports = isWsl;
|
||||
} else {
|
||||
module.exports = isWsl();
|
||||
}
|
||||
9
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/is-wsl/license
generated
vendored
Normal file
9
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/is-wsl/license
generated
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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.
|
||||
45
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/is-wsl/package.json
generated
vendored
Normal file
45
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/is-wsl/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
{
|
||||
"name": "is-wsl",
|
||||
"version": "2.2.0",
|
||||
"description": "Check if the process is running inside Windows Subsystem for Linux (Bash on Windows)",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/is-wsl",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"check",
|
||||
"wsl",
|
||||
"windows",
|
||||
"subsystem",
|
||||
"linux",
|
||||
"detect",
|
||||
"bash",
|
||||
"process",
|
||||
"console",
|
||||
"terminal",
|
||||
"is"
|
||||
],
|
||||
"dependencies": {
|
||||
"is-docker": "^2.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "^1.4.1",
|
||||
"clear-module": "^3.2.0",
|
||||
"proxyquire": "^2.1.0",
|
||||
"tsd": "^0.7.2",
|
||||
"xo": "^0.24.0"
|
||||
}
|
||||
}
|
||||
36
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/is-wsl/readme.md
generated
vendored
Normal file
36
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/is-wsl/readme.md
generated
vendored
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
# is-wsl [](https://travis-ci.org/sindresorhus/is-wsl)
|
||||
|
||||
> Check if the process is running inside [Windows Subsystem for Linux](https://msdn.microsoft.com/commandline/wsl/about) (Bash on Windows)
|
||||
|
||||
Can be useful if you need to work around unimplemented or buggy features in WSL. Supports both WSL 1 and WSL 2.
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install is-wsl
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const isWsl = require('is-wsl');
|
||||
|
||||
// When running inside Windows Subsystem for Linux
|
||||
console.log(isWsl);
|
||||
//=> true
|
||||
```
|
||||
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
<b>
|
||||
<a href="https://tidelift.com/subscription/pkg/npm-is-wsl?utm_source=npm-is-wsl&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
|
||||
</b>
|
||||
<br>
|
||||
<sub>
|
||||
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
|
||||
</sub>
|
||||
</div>
|
||||
88
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/open/index.d.ts
generated
vendored
Normal file
88
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/open/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
/// <reference types="node"/>
|
||||
import {ChildProcess} from 'child_process';
|
||||
|
||||
declare namespace open {
|
||||
interface Options {
|
||||
/**
|
||||
Wait for the opened app to exit before fulfilling the promise. If `false` it's fulfilled immediately when opening the app.
|
||||
|
||||
Note that it waits for the app to exit, not just for the window to close.
|
||||
|
||||
On Windows, you have to explicitly specify an app for it to be able to wait.
|
||||
|
||||
@default false
|
||||
*/
|
||||
readonly wait?: boolean;
|
||||
|
||||
/**
|
||||
__macOS only__
|
||||
|
||||
Do not bring the app to the foreground.
|
||||
|
||||
@default false
|
||||
*/
|
||||
readonly background?: boolean;
|
||||
|
||||
/**
|
||||
Specify the app to open the `target` with, or an array with the app and app arguments.
|
||||
|
||||
The app name is platform dependent. Don't hard code it in reusable modules. For example, Chrome is `google chrome` on macOS, `google-chrome` on Linux and `chrome` on Windows.
|
||||
|
||||
You may also pass in the app's full path. For example on WSL, this can be `/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe` for the Windows installation of Chrome.
|
||||
*/
|
||||
readonly app?: string | readonly string[];
|
||||
|
||||
/**
|
||||
__deprecated__
|
||||
|
||||
This option will be removed in the next major release.
|
||||
*/
|
||||
readonly url?: boolean;
|
||||
|
||||
/**
|
||||
Allow the opened app to exit with nonzero exit code when the `wait` option is `true`.
|
||||
|
||||
We do not recommend setting this option. The convention for success is exit code zero.
|
||||
|
||||
@default false
|
||||
*/
|
||||
readonly allowNonzeroExitCode?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Open stuff like URLs, files, executables. Cross-platform.
|
||||
|
||||
Uses the command `open` on OS X, `start` on Windows and `xdg-open` on other platforms.
|
||||
|
||||
There is a caveat for [double-quotes on Windows](https://github.com/sindresorhus/open#double-quotes-on-windows) where all double-quotes are stripped from the `target`.
|
||||
|
||||
@param target - The thing you want to open. Can be a URL, file, or executable. Opens in the default app for the file type. For example, URLs open in your default browser.
|
||||
@returns The [spawned child process](https://nodejs.org/api/child_process.html#child_process_class_childprocess). You would normally not need to use this for anything, but it can be useful if you'd like to attach custom event listeners or perform other operations directly on the spawned process.
|
||||
|
||||
@example
|
||||
```
|
||||
import open = require('open');
|
||||
|
||||
// Opens the image in the default image viewer
|
||||
(async () => {
|
||||
await open('unicorn.png', {wait: true});
|
||||
console.log('The image viewer app closed');
|
||||
|
||||
// Opens the url in the default browser
|
||||
await open('https://sindresorhus.com');
|
||||
|
||||
// Specify the app to open in
|
||||
await open('https://sindresorhus.com', {app: 'firefox'});
|
||||
|
||||
// Specify app arguments
|
||||
await open('https://sindresorhus.com', {app: ['google chrome', '--incognito']});
|
||||
})();
|
||||
```
|
||||
*/
|
||||
declare function open(
|
||||
target: string,
|
||||
options?: open.Options
|
||||
): Promise<ChildProcess>;
|
||||
|
||||
export = open;
|
||||
195
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/open/index.js
generated
vendored
Normal file
195
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/open/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,195 @@
|
|||
'use strict';
|
||||
const {promisify} = require('util');
|
||||
const path = require('path');
|
||||
const childProcess = require('child_process');
|
||||
const fs = require('fs');
|
||||
const isWsl = require('is-wsl');
|
||||
const isDocker = require('is-docker');
|
||||
|
||||
const pAccess = promisify(fs.access);
|
||||
const pReadFile = promisify(fs.readFile);
|
||||
|
||||
// Path to included `xdg-open`.
|
||||
const localXdgOpenPath = path.join(__dirname, 'xdg-open');
|
||||
|
||||
/**
|
||||
Get the mount point for fixed drives in WSL.
|
||||
|
||||
@inner
|
||||
@returns {string} The mount point.
|
||||
*/
|
||||
const getWslDrivesMountPoint = (() => {
|
||||
// Default value for "root" param
|
||||
// according to https://docs.microsoft.com/en-us/windows/wsl/wsl-config
|
||||
const defaultMountPoint = '/mnt/';
|
||||
|
||||
let mountPoint;
|
||||
|
||||
return async function () {
|
||||
if (mountPoint) {
|
||||
// Return memoized mount point value
|
||||
return mountPoint;
|
||||
}
|
||||
|
||||
const configFilePath = '/etc/wsl.conf';
|
||||
|
||||
let isConfigFileExists = false;
|
||||
try {
|
||||
await pAccess(configFilePath, fs.constants.F_OK);
|
||||
isConfigFileExists = true;
|
||||
} catch (_) {}
|
||||
|
||||
if (!isConfigFileExists) {
|
||||
return defaultMountPoint;
|
||||
}
|
||||
|
||||
const configContent = await pReadFile(configFilePath, {encoding: 'utf8'});
|
||||
const configMountPoint = /root\s*=\s*(.*)/g.exec(configContent);
|
||||
|
||||
if (!configMountPoint) {
|
||||
return defaultMountPoint;
|
||||
}
|
||||
|
||||
mountPoint = configMountPoint[1].trim();
|
||||
mountPoint = mountPoint.endsWith('/') ? mountPoint : mountPoint + '/';
|
||||
|
||||
return mountPoint;
|
||||
};
|
||||
})();
|
||||
|
||||
module.exports = async (target, options) => {
|
||||
if (typeof target !== 'string') {
|
||||
throw new TypeError('Expected a `target`');
|
||||
}
|
||||
|
||||
options = {
|
||||
wait: false,
|
||||
background: false,
|
||||
allowNonzeroExitCode: false,
|
||||
...options
|
||||
};
|
||||
|
||||
let command;
|
||||
let {app} = options;
|
||||
let appArguments = [];
|
||||
const cliArguments = [];
|
||||
const childProcessOptions = {};
|
||||
|
||||
if (Array.isArray(app)) {
|
||||
appArguments = app.slice(1);
|
||||
app = app[0];
|
||||
}
|
||||
|
||||
if (process.platform === 'darwin') {
|
||||
command = 'open';
|
||||
|
||||
if (options.wait) {
|
||||
cliArguments.push('--wait-apps');
|
||||
}
|
||||
|
||||
if (options.background) {
|
||||
cliArguments.push('--background');
|
||||
}
|
||||
|
||||
if (app) {
|
||||
cliArguments.push('-a', app);
|
||||
}
|
||||
} else if (process.platform === 'win32' || (isWsl && !isDocker())) {
|
||||
const mountPoint = await getWslDrivesMountPoint();
|
||||
|
||||
command = isWsl ?
|
||||
`${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe` :
|
||||
`${process.env.SYSTEMROOT}\\System32\\WindowsPowerShell\\v1.0\\powershell`;
|
||||
|
||||
cliArguments.push(
|
||||
'-NoProfile',
|
||||
'-NonInteractive',
|
||||
'–ExecutionPolicy',
|
||||
'Bypass',
|
||||
'-EncodedCommand'
|
||||
);
|
||||
|
||||
if (!isWsl) {
|
||||
childProcessOptions.windowsVerbatimArguments = true;
|
||||
}
|
||||
|
||||
const encodedArguments = ['Start'];
|
||||
|
||||
if (options.wait) {
|
||||
encodedArguments.push('-Wait');
|
||||
}
|
||||
|
||||
if (app) {
|
||||
// Double quote with double quotes to ensure the inner quotes are passed through.
|
||||
// Inner quotes are delimited for PowerShell interpretation with backticks.
|
||||
encodedArguments.push(`"\`"${app}\`""`, '-ArgumentList');
|
||||
appArguments.unshift(target);
|
||||
} else {
|
||||
encodedArguments.push(`"${target}"`);
|
||||
}
|
||||
|
||||
if (appArguments.length > 0) {
|
||||
appArguments = appArguments.map(arg => `"\`"${arg}\`""`);
|
||||
encodedArguments.push(appArguments.join(','));
|
||||
}
|
||||
|
||||
// Using Base64-encoded command, accepted by PowerShell, to allow special characters.
|
||||
target = Buffer.from(encodedArguments.join(' '), 'utf16le').toString('base64');
|
||||
} else {
|
||||
if (app) {
|
||||
command = app;
|
||||
} else {
|
||||
// When bundled by Webpack, there's no actual package file path and no local `xdg-open`.
|
||||
const isBundled = !__dirname || __dirname === '/';
|
||||
|
||||
// Check if local `xdg-open` exists and is executable.
|
||||
let exeLocalXdgOpen = false;
|
||||
try {
|
||||
await pAccess(localXdgOpenPath, fs.constants.X_OK);
|
||||
exeLocalXdgOpen = true;
|
||||
} catch (_) {}
|
||||
|
||||
const useSystemXdgOpen = process.versions.electron ||
|
||||
process.platform === 'android' || isBundled || !exeLocalXdgOpen;
|
||||
command = useSystemXdgOpen ? 'xdg-open' : localXdgOpenPath;
|
||||
}
|
||||
|
||||
if (appArguments.length > 0) {
|
||||
cliArguments.push(...appArguments);
|
||||
}
|
||||
|
||||
if (!options.wait) {
|
||||
// `xdg-open` will block the process unless stdio is ignored
|
||||
// and it's detached from the parent even if it's unref'd.
|
||||
childProcessOptions.stdio = 'ignore';
|
||||
childProcessOptions.detached = true;
|
||||
}
|
||||
}
|
||||
|
||||
cliArguments.push(target);
|
||||
|
||||
if (process.platform === 'darwin' && appArguments.length > 0) {
|
||||
cliArguments.push('--args', ...appArguments);
|
||||
}
|
||||
|
||||
const subprocess = childProcess.spawn(command, cliArguments, childProcessOptions);
|
||||
|
||||
if (options.wait) {
|
||||
return new Promise((resolve, reject) => {
|
||||
subprocess.once('error', reject);
|
||||
|
||||
subprocess.once('close', exitCode => {
|
||||
if (options.allowNonzeroExitCode && exitCode > 0) {
|
||||
reject(new Error(`Exited with code ${exitCode}`));
|
||||
return;
|
||||
}
|
||||
|
||||
resolve(subprocess);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
subprocess.unref();
|
||||
|
||||
return subprocess;
|
||||
};
|
||||
9
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/open/license
generated
vendored
Normal file
9
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/open/license
generated
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
||||
|
||||
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.
|
||||
60
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/open/package.json
generated
vendored
Normal file
60
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/open/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
{
|
||||
"name": "open",
|
||||
"version": "7.4.2",
|
||||
"description": "Open stuff like URLs, files, executables. Cross-platform.",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/open",
|
||||
"funding": "https://github.com/sponsors/sindresorhus",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "https://sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts",
|
||||
"xdg-open"
|
||||
],
|
||||
"keywords": [
|
||||
"app",
|
||||
"open",
|
||||
"opener",
|
||||
"opens",
|
||||
"launch",
|
||||
"start",
|
||||
"xdg-open",
|
||||
"xdg",
|
||||
"default",
|
||||
"cmd",
|
||||
"browser",
|
||||
"editor",
|
||||
"executable",
|
||||
"exe",
|
||||
"url",
|
||||
"urls",
|
||||
"arguments",
|
||||
"args",
|
||||
"spawn",
|
||||
"exec",
|
||||
"child",
|
||||
"process",
|
||||
"website",
|
||||
"file"
|
||||
],
|
||||
"dependencies": {
|
||||
"is-docker": "^2.0.0",
|
||||
"is-wsl": "^2.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^12.7.5",
|
||||
"ava": "^2.3.0",
|
||||
"tsd": "^0.11.0",
|
||||
"xo": "^0.25.3"
|
||||
}
|
||||
}
|
||||
154
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/open/readme.md
generated
vendored
Normal file
154
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/open/readme.md
generated
vendored
Normal file
|
|
@ -0,0 +1,154 @@
|
|||
# open
|
||||
|
||||
> Open stuff like URLs, files, executables. Cross-platform.
|
||||
|
||||
This is meant to be used in command-line tools and scripts, not in the browser.
|
||||
|
||||
If you need this for Electron, use [`shell.openPath()`](https://www.electronjs.org/docs/api/shell#shellopenpathpath) instead.
|
||||
|
||||
Note: The original [`open` package](https://github.com/pwnall/node-open) was previously deprecated in favor of this package, and we got the name, so this package is now named `open` instead of `opn`. If you're upgrading from the original `open` package (`open@0.0.5` or lower), keep in mind that the API is different.
|
||||
|
||||
#### Why?
|
||||
|
||||
- Actively maintained.
|
||||
- Supports app arguments.
|
||||
- Safer as it uses `spawn` instead of `exec`.
|
||||
- Fixes most of the open original `node-open` issues.
|
||||
- Includes the latest [`xdg-open` script](https://cgit.freedesktop.org/xdg/xdg-utils/commit/?id=c55122295c2a480fa721a9614f0e2d42b2949c18) for Linux.
|
||||
- Supports WSL paths to Windows apps.
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install open
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const open = require('open');
|
||||
|
||||
(async () => {
|
||||
// Opens the image in the default image viewer and waits for the opened app to quit.
|
||||
await open('unicorn.png', {wait: true});
|
||||
console.log('The image viewer app quit');
|
||||
|
||||
// Opens the URL in the default browser.
|
||||
await open('https://sindresorhus.com');
|
||||
|
||||
// Opens the URL in a specified browser.
|
||||
await open('https://sindresorhus.com', {app: 'firefox'});
|
||||
|
||||
// Specify app arguments.
|
||||
await open('https://sindresorhus.com', {app: ['google chrome', '--incognito']});
|
||||
})();
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
It uses the command `open` on macOS, `start` on Windows and `xdg-open` on other platforms.
|
||||
|
||||
### open(target, options?)
|
||||
|
||||
Returns a promise for the [spawned child process](https://nodejs.org/api/child_process.html#child_process_class_childprocess). You would normally not need to use this for anything, but it can be useful if you'd like to attach custom event listeners or perform other operations directly on the spawned process.
|
||||
|
||||
#### target
|
||||
|
||||
Type: `string`
|
||||
|
||||
The thing you want to open. Can be a URL, file, or executable.
|
||||
|
||||
Opens in the default app for the file type. For example, URLs opens in your default browser.
|
||||
|
||||
#### options
|
||||
|
||||
Type: `object`
|
||||
|
||||
##### wait
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `false`
|
||||
|
||||
Wait for the opened app to exit before fulfilling the promise. If `false` it's fulfilled immediately when opening the app.
|
||||
|
||||
Note that it waits for the app to exit, not just for the window to close.
|
||||
|
||||
On Windows, you have to explicitly specify an app for it to be able to wait.
|
||||
|
||||
##### background <sup>(macOS only)</sup>
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `false`
|
||||
|
||||
Do not bring the app to the foreground.
|
||||
|
||||
##### app
|
||||
|
||||
Type: `string | string[]`
|
||||
|
||||
Specify the app to open the `target` with, or an array with the app and app arguments.
|
||||
|
||||
The app name is platform dependent. Don't hard code it in reusable modules. For example, Chrome is `google chrome` on macOS, `google-chrome` on Linux and `chrome` on Windows.
|
||||
|
||||
You may also pass in the app's full path. For example on WSL, this can be `/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe` for the Windows installation of Chrome.
|
||||
|
||||
##### url
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `false`
|
||||
|
||||
Uses `URL` to encode the target before executing it.<br>
|
||||
We do not recommend using it on targets that are not URLs.
|
||||
|
||||
Especially useful when dealing with the [double-quotes on Windows](#double-quotes-on-windows) caveat.
|
||||
|
||||
##### allowNonzeroExitCode
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `false`
|
||||
|
||||
Allow the opened app to exit with nonzero exit code when the `wait` option is `true`.
|
||||
|
||||
We do not recommend setting this option. The convention for success is exit code zero.
|
||||
|
||||
## Caveats
|
||||
|
||||
### Double-quotes on Windows
|
||||
|
||||
TL;DR: All double-quotes are stripped from the `target` and do not get to your desired destination (on Windows!).
|
||||
|
||||
Due to specific behaviors of Window's Command Prompt (`cmd.exe`) regarding ampersand (`&`) characters breaking commands and URLs, double-quotes are now a special case.
|
||||
|
||||
The solution ([#146](https://github.com/sindresorhus/open/pull/146)) to this and other problems was to leverage the fact that `cmd.exe` interprets a double-quoted argument as a plain text argument just by quoting it (like Node.js already does). Unfortunately, `cmd.exe` can only do **one** of two things: handle them all **OR** not handle them at all. As per its own documentation:
|
||||
|
||||
>*If /C or /K is specified, then the remainder of the command line after the switch is processed as a command line, where the following logic is used to process quote (") characters:*
|
||||
>
|
||||
> 1. *If all of the following conditions are met, then quote characters on the command line are preserved:*
|
||||
> - *no /S switch*
|
||||
> - *exactly two quote characters*
|
||||
> - *no special characters between the two quote characters, where special is one of: &<>()@^|*
|
||||
> - *there are one or more whitespace characters between the two quote characters*
|
||||
> - *the string between the two quote characters is the name of an executable file.*
|
||||
>
|
||||
> 2. *Otherwise, old behavior is to see if the first character is a quote character and if so, strip the leading character and remove the last quote character on the command line, preserving any text after the last quote character.*
|
||||
|
||||
The option that solved all of the problems was the second one, and for additional behavior consistency we're also now using the `/S` switch, so we **always** get the second option. The caveat is that this built-in double-quotes handling ends up stripping all of them from the command line and so far we weren't able to find an escaping method that works (if you do, please feel free to contribute!).
|
||||
|
||||
To make this caveat somewhat less impactful (at least for URLs), check out the [url option](#url). Double-quotes will be "preserved" when using it with an URL.
|
||||
|
||||
## Related
|
||||
|
||||
- [open-cli](https://github.com/sindresorhus/open-cli) - CLI for this module
|
||||
- [open-editor](https://github.com/sindresorhus/open-editor) - Open files in your editor at a specific line and column
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
<b>
|
||||
<a href="https://tidelift.com/subscription/pkg/npm-opn?utm_source=npm-opn&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
|
||||
</b>
|
||||
<br>
|
||||
<sub>
|
||||
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
|
||||
</sub>
|
||||
</div>
|
||||
1066
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/open/xdg-open
generated
vendored
Normal file
1066
Frontend-Learner/node_modules/tailwind-config-viewer/node_modules/open/xdg-open
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
72
Frontend-Learner/node_modules/tailwind-config-viewer/package.json
generated
vendored
Normal file
72
Frontend-Learner/node_modules/tailwind-config-viewer/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
{
|
||||
"name": "tailwind-config-viewer",
|
||||
"version": "2.0.4",
|
||||
"description": "View your Tailwind CSS config file...visually!",
|
||||
"author": {
|
||||
"name": "Ryan Ogden",
|
||||
"email": "ryaneogden@gmail.com"
|
||||
},
|
||||
"scripts": {
|
||||
"serve": "node cli/index.js -c tailwind.config.sample.js & vue-cli-service serve",
|
||||
"build": "vue-cli-service build",
|
||||
"build:docs": "npm run build && node ./cli export ./docs -c tailwind.config.sample.js",
|
||||
"prepublishOnly": "npm run lint --no-fix && npm run build",
|
||||
"lint": "vue-cli-service lint",
|
||||
"test": "echo \"No test specified\"",
|
||||
"version": "npm run build:docs && git add docs"
|
||||
},
|
||||
"bin": {
|
||||
"tailwind-config-viewer": "./cli/index.js",
|
||||
"tailwindcss-config-viewer": "./cli/index.js"
|
||||
},
|
||||
"repository": "github:rogden/tailwind-config-viewer",
|
||||
"bugs": {
|
||||
"url": "https://github.com/rogden/tailwind-config-viewer/issues"
|
||||
},
|
||||
"keywords": [
|
||||
"tailwind",
|
||||
"tailwindcss"
|
||||
],
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"server",
|
||||
"cli",
|
||||
"dist",
|
||||
"lib"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=13"
|
||||
},
|
||||
"dependencies": {
|
||||
"@koa/router": "^12.0.1",
|
||||
"commander": "^6.0.0",
|
||||
"fs-extra": "^9.0.1",
|
||||
"koa": "^2.14.2",
|
||||
"koa-static": "^5.0.0",
|
||||
"open": "^7.0.4",
|
||||
"portfinder": "^1.0.26",
|
||||
"replace-in-file": "^6.1.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"tailwindcss": "1 || 2 || 2.0.1-compat || 3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vue/cli-plugin-babel": "^3.7.0",
|
||||
"@vue/cli-plugin-eslint": "^3.7.0",
|
||||
"@vue/cli-service": "^3.7.0",
|
||||
"@vue/eslint-config-standard": "^4.0.0",
|
||||
"babel-eslint": "^10.0.1",
|
||||
"core-js": "^2.6.5",
|
||||
"defu": "^3.2.2",
|
||||
"eslint": "^5.16.0",
|
||||
"eslint-plugin-vue": "^5.0.0",
|
||||
"sass": "^1.26.10",
|
||||
"sass-loader": "^9.0.3",
|
||||
"tailwindcss": "^1.4.4",
|
||||
"tailwindcss-dark-mode": "^1.1.6",
|
||||
"vue": "^2.6.10",
|
||||
"vue-draggable-resizable": "^2.2.0",
|
||||
"vue-intersect": "^1.1.6",
|
||||
"vue-template-compiler": "^2.5.21"
|
||||
}
|
||||
}
|
||||
53
Frontend-Learner/node_modules/tailwind-config-viewer/server/index.js
generated
vendored
Normal file
53
Frontend-Learner/node_modules/tailwind-config-viewer/server/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
const Koa = require('koa')
|
||||
const serve = require('koa-static')
|
||||
const Router = require('@koa/router')
|
||||
const portfinder = require('portfinder')
|
||||
const open = require('open')
|
||||
const { resolveConfig } = require('../lib/tailwindConfigUtils')
|
||||
|
||||
function createServer ({
|
||||
port = 3000,
|
||||
tailwindConfigProvider,
|
||||
shouldOpen,
|
||||
routerPrefix = ''
|
||||
}) {
|
||||
const app = new Koa()
|
||||
|
||||
const router = new Router({ prefix: routerPrefix })
|
||||
|
||||
router.get('/config.json', async (ctx) => {
|
||||
const config = await tailwindConfigProvider()
|
||||
ctx.body = resolveConfig(config)
|
||||
})
|
||||
|
||||
app
|
||||
.use(serve(`${__dirname}/../dist`))
|
||||
.use(router.routes())
|
||||
.use(router.allowedMethods())
|
||||
|
||||
return {
|
||||
app,
|
||||
asMiddleware: () => {
|
||||
return app.callback()
|
||||
},
|
||||
start: () => {
|
||||
portfinder.getPort({
|
||||
port
|
||||
}, (err, port) => {
|
||||
if (err) {
|
||||
throw (err)
|
||||
}
|
||||
|
||||
app.listen(port, async () => {
|
||||
console.log('Server Started ∹ http://localhost:' + port.toString())
|
||||
|
||||
if (shouldOpen) {
|
||||
open('http://localhost:' + port.toString())
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = createServer
|
||||
Loading…
Add table
Add a link
Reference in a new issue