new license file version [CI SKIP]
This commit is contained in:
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"PartitionPattern.d.ts","sourceRoot":"","sources":["../../../../../packages/ecma402-abstract/PartitionPattern.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,EAC/C,OAAO,EAAE,MAAM,GACd,KAAK,CAAC;IAAC,IAAI,EAAE,CAAC,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;CAAC,CAAC,CA6B7C"}
|
||||
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* The base implementation of `_.slice` without an iteratee call guard.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to slice.
|
||||
* @param {number} [start=0] The start position.
|
||||
* @param {number} [end=array.length] The end position.
|
||||
* @returns {Array} Returns the slice of `array`.
|
||||
*/
|
||||
function baseSlice(array, start, end) {
|
||||
var index = -1,
|
||||
length = array.length;
|
||||
|
||||
if (start < 0) {
|
||||
start = -start > length ? 0 : (length + start);
|
||||
}
|
||||
end = end > length ? length : end;
|
||||
if (end < 0) {
|
||||
end += length;
|
||||
}
|
||||
length = start > end ? 0 : ((end - start) >>> 0);
|
||||
start >>>= 0;
|
||||
|
||||
var result = Array(length);
|
||||
while (++index < length) {
|
||||
result[index] = array[index + start];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
module.exports = baseSlice;
|
||||
@@ -0,0 +1,272 @@
|
||||
/**
|
||||
* `list` type prompt
|
||||
*/
|
||||
|
||||
import chalk from 'chalk';
|
||||
import cliCursor from 'cli-cursor';
|
||||
import figures from 'figures';
|
||||
import { map, takeUntil } from 'rxjs';
|
||||
import Base from './base.js';
|
||||
import observe from '../utils/events.js';
|
||||
import Paginator from '../utils/paginator.js';
|
||||
import incrementListIndex from '../utils/incrementListIndex.js';
|
||||
|
||||
export default class CheckboxPrompt extends Base {
|
||||
constructor(questions, rl, answers) {
|
||||
super(questions, rl, answers);
|
||||
|
||||
if (!this.opt.choices) {
|
||||
this.throwParamError('choices');
|
||||
}
|
||||
|
||||
if (Array.isArray(this.opt.default)) {
|
||||
this.opt.choices.forEach(function (choice) {
|
||||
if (this.opt.default.indexOf(choice.value) >= 0) {
|
||||
choice.checked = true;
|
||||
}
|
||||
}, this);
|
||||
}
|
||||
|
||||
this.pointer = 0;
|
||||
|
||||
// Make sure no default is set (so it won't be printed)
|
||||
this.opt.default = null;
|
||||
|
||||
const shouldLoop = this.opt.loop === undefined ? true : this.opt.loop;
|
||||
this.paginator = new Paginator(this.screen, { isInfinite: shouldLoop });
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the Inquiry session
|
||||
* @param {Function} cb Callback when prompt is done
|
||||
* @return {this}
|
||||
*/
|
||||
|
||||
_run(cb) {
|
||||
this.done = cb;
|
||||
|
||||
const events = observe(this.rl);
|
||||
|
||||
const validation = this.handleSubmitEvents(
|
||||
events.line.pipe(map(this.getCurrentValue.bind(this)))
|
||||
);
|
||||
validation.success.forEach(this.onEnd.bind(this));
|
||||
validation.error.forEach(this.onError.bind(this));
|
||||
|
||||
events.normalizedUpKey
|
||||
.pipe(takeUntil(validation.success))
|
||||
.forEach(this.onUpKey.bind(this));
|
||||
events.normalizedDownKey
|
||||
.pipe(takeUntil(validation.success))
|
||||
.forEach(this.onDownKey.bind(this));
|
||||
events.numberKey
|
||||
.pipe(takeUntil(validation.success))
|
||||
.forEach(this.onNumberKey.bind(this));
|
||||
events.spaceKey
|
||||
.pipe(takeUntil(validation.success))
|
||||
.forEach(this.onSpaceKey.bind(this));
|
||||
events.aKey.pipe(takeUntil(validation.success)).forEach(this.onAllKey.bind(this));
|
||||
events.iKey.pipe(takeUntil(validation.success)).forEach(this.onInverseKey.bind(this));
|
||||
|
||||
// Init the prompt
|
||||
cliCursor.hide();
|
||||
this.render();
|
||||
this.firstRender = false;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the prompt to screen
|
||||
* @return {CheckboxPrompt} self
|
||||
*/
|
||||
|
||||
render(error) {
|
||||
// Render question
|
||||
let message = this.getQuestion();
|
||||
let bottomContent = '';
|
||||
|
||||
if (!this.dontShowHints) {
|
||||
message +=
|
||||
'(Press ' +
|
||||
chalk.cyan.bold('<space>') +
|
||||
' to select, ' +
|
||||
chalk.cyan.bold('<a>') +
|
||||
' to toggle all, ' +
|
||||
chalk.cyan.bold('<i>') +
|
||||
' to invert selection, and ' +
|
||||
chalk.cyan.bold('<enter>') +
|
||||
' to proceed)';
|
||||
}
|
||||
|
||||
// Render choices or answer depending on the state
|
||||
if (this.status === 'answered') {
|
||||
message += chalk.cyan(this.selection.join(', '));
|
||||
} else {
|
||||
const choicesStr = renderChoices(this.opt.choices, this.pointer);
|
||||
const indexPosition = this.opt.choices.indexOf(
|
||||
this.opt.choices.getChoice(this.pointer)
|
||||
);
|
||||
const realIndexPosition =
|
||||
this.opt.choices.reduce((acc, value, i) => {
|
||||
// Dont count lines past the choice we are looking at
|
||||
if (i > indexPosition) {
|
||||
return acc;
|
||||
}
|
||||
// Add line if it's a separator
|
||||
if (value.type === 'separator') {
|
||||
return acc + 1;
|
||||
}
|
||||
|
||||
let l = value.name;
|
||||
// Non-strings take up one line
|
||||
if (typeof l !== 'string') {
|
||||
return acc + 1;
|
||||
}
|
||||
|
||||
// Calculate lines taken up by string
|
||||
l = l.split('\n');
|
||||
return acc + l.length;
|
||||
}, 0) - 1;
|
||||
message +=
|
||||
'\n' + this.paginator.paginate(choicesStr, realIndexPosition, this.opt.pageSize);
|
||||
}
|
||||
|
||||
if (error) {
|
||||
bottomContent = chalk.red('>> ') + error;
|
||||
}
|
||||
|
||||
this.screen.render(message, bottomContent);
|
||||
}
|
||||
|
||||
/**
|
||||
* When user press `enter` key
|
||||
*/
|
||||
|
||||
onEnd(state) {
|
||||
this.status = 'answered';
|
||||
this.dontShowHints = true;
|
||||
// Rerender prompt (and clean subline error)
|
||||
this.render();
|
||||
|
||||
this.screen.done();
|
||||
cliCursor.show();
|
||||
this.done(state.value);
|
||||
}
|
||||
|
||||
onError(state) {
|
||||
this.render(state.isValid);
|
||||
}
|
||||
|
||||
getCurrentValue() {
|
||||
const choices = this.opt.choices.filter(
|
||||
(choice) => Boolean(choice.checked) && !choice.disabled
|
||||
);
|
||||
|
||||
this.selection = choices.map((choice) => choice.short);
|
||||
return choices.map((choice) => choice.value);
|
||||
}
|
||||
|
||||
onUpKey() {
|
||||
this.pointer = incrementListIndex(this.pointer, 'up', this.opt);
|
||||
this.render();
|
||||
}
|
||||
|
||||
onDownKey() {
|
||||
this.pointer = incrementListIndex(this.pointer, 'down', this.opt);
|
||||
this.render();
|
||||
}
|
||||
|
||||
onNumberKey(input) {
|
||||
if (input <= this.opt.choices.realLength) {
|
||||
this.pointer = input - 1;
|
||||
this.toggleChoice(this.pointer);
|
||||
}
|
||||
|
||||
this.render();
|
||||
}
|
||||
|
||||
onSpaceKey() {
|
||||
this.toggleChoice(this.pointer);
|
||||
this.render();
|
||||
}
|
||||
|
||||
onAllKey() {
|
||||
const shouldBeChecked = Boolean(
|
||||
this.opt.choices.find((choice) => choice.type !== 'separator' && !choice.checked)
|
||||
);
|
||||
|
||||
this.opt.choices.forEach((choice) => {
|
||||
if (choice.type !== 'separator') {
|
||||
choice.checked = shouldBeChecked;
|
||||
}
|
||||
});
|
||||
|
||||
this.render();
|
||||
}
|
||||
|
||||
onInverseKey() {
|
||||
this.opt.choices.forEach((choice) => {
|
||||
if (choice.type !== 'separator') {
|
||||
choice.checked = !choice.checked;
|
||||
}
|
||||
});
|
||||
|
||||
this.render();
|
||||
}
|
||||
|
||||
toggleChoice(index) {
|
||||
const item = this.opt.choices.getChoice(index);
|
||||
if (item !== undefined) {
|
||||
this.opt.choices.getChoice(index).checked = !item.checked;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function for rendering checkbox choices
|
||||
* @param {Number} pointer Position of the pointer
|
||||
* @return {String} Rendered content
|
||||
*/
|
||||
|
||||
function renderChoices(choices, pointer) {
|
||||
let output = '';
|
||||
let separatorOffset = 0;
|
||||
|
||||
choices.forEach((choice, i) => {
|
||||
if (choice.type === 'separator') {
|
||||
separatorOffset++;
|
||||
output += ' ' + choice + '\n';
|
||||
return;
|
||||
}
|
||||
|
||||
if (choice.disabled) {
|
||||
separatorOffset++;
|
||||
output += ' - ' + choice.name;
|
||||
output += ` (${
|
||||
typeof choice.disabled === 'string' ? choice.disabled : 'Disabled'
|
||||
})`;
|
||||
} else {
|
||||
const line = getCheckbox(choice.checked) + ' ' + choice.name;
|
||||
if (i - separatorOffset === pointer) {
|
||||
output += chalk.cyan(figures.pointer + line);
|
||||
} else {
|
||||
output += ' ' + line;
|
||||
}
|
||||
}
|
||||
|
||||
output += '\n';
|
||||
});
|
||||
|
||||
return output.replace(/\n$/, '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the checkbox
|
||||
* @param {Boolean} checked - add a X or not to the checkbox
|
||||
* @return {String} Composited checkbox string
|
||||
*/
|
||||
|
||||
function getCheckbox(checked) {
|
||||
return checked ? chalk.green(figures.radioOn) : figures.radioOff;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
var convert = require('./convert'),
|
||||
func = convert('sortedIndexOf', require('../sortedIndexOf'));
|
||||
|
||||
func.placeholder = require('./placeholder');
|
||||
module.exports = func;
|
||||
@@ -0,0 +1,200 @@
|
||||
# crc32
|
||||
|
||||
Standard CRC-32 algorithm implementation in JS (for the browser and nodejs).
|
||||
Emphasis on correctness, performance, and IE6+ support.
|
||||
|
||||
## Installation
|
||||
|
||||
With [npm](https://www.npmjs.org/package/crc-32):
|
||||
|
||||
```bash
|
||||
$ npm install crc-32
|
||||
```
|
||||
|
||||
When installed globally, npm installs a script `crc32` that computes the
|
||||
checksum for a specified file or standard input.
|
||||
|
||||
<details>
|
||||
<summary><b>CDN Availability</b> (click to show)</summary>
|
||||
|
||||
| CDN | URL |
|
||||
|-----------:|:-------------------------------------------|
|
||||
| `unpkg` | <https://unpkg.com/crc-32/> |
|
||||
| `jsDelivr` | <https://jsdelivr.com/package/npm/crc-32> |
|
||||
| `CDNjs` | <https://cdnjs.com/libraries/crc-32> |
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
## Integration
|
||||
|
||||
Using NodeJS or a bundler:
|
||||
|
||||
```js
|
||||
var CRC32 = require("crc-32");
|
||||
```
|
||||
|
||||
In the browser, the `crc32.js` script can be loaded directly:
|
||||
|
||||
```html
|
||||
<script src="crc32.js"></script>
|
||||
```
|
||||
|
||||
The browser script exposes a variable `CRC32`.
|
||||
|
||||
The script will manipulate `module.exports` if available . This is not always
|
||||
desirable. To prevent the behavior, define `DO_NOT_EXPORT_CRC`.
|
||||
|
||||
### CRC32C (Castagnoli)
|
||||
|
||||
The module and CDNs also include a parallel script for CRC32C calculations.
|
||||
|
||||
Using NodeJS or a bundler:
|
||||
|
||||
```js
|
||||
var CRC32C = require("crc-32/crc32c");
|
||||
```
|
||||
|
||||
In the browser, the `crc32c.js` script can be loaded directly:
|
||||
|
||||
```html
|
||||
<script src="crc32c.js"></script>
|
||||
```
|
||||
|
||||
The browser exposes a variable `CRC32C`.
|
||||
|
||||
The script will manipulate `module.exports` if available . This is not always
|
||||
desirable. To prevent the behavior, define `DO_NOT_EXPORT_CRC`.
|
||||
|
||||
## Usage
|
||||
|
||||
In all cases, the relevant function takes an argument representing data and an
|
||||
optional second argument representing the starting "seed" (for rolling CRC).
|
||||
|
||||
The return value is a signed 32-bit integer.
|
||||
|
||||
- `CRC32.buf(byte array or buffer[, seed])` assumes the argument is a sequence
|
||||
of 8-bit unsigned integers (nodejs `Buffer`, `Uint8Array` or array of bytes).
|
||||
|
||||
- `CRC32.bstr(binary string[, seed])` assumes the argument is a binary string
|
||||
where byte `i` is the low byte of the UCS-2 char: `str.charCodeAt(i) & 0xFF`
|
||||
|
||||
- `CRC32.str(string[, seed])` assumes the argument is a standard JS string and
|
||||
calculates the hash of the UTF-8 encoding.
|
||||
|
||||
For example:
|
||||
|
||||
```js
|
||||
// var CRC32 = require('crc-32'); // uncomment this line if in node
|
||||
CRC32.str("SheetJS") // -1647298270
|
||||
CRC32.bstr("SheetJS") // -1647298270
|
||||
CRC32.buf([ 83, 104, 101, 101, 116, 74, 83 ]) // -1647298270
|
||||
|
||||
crc32 = CRC32.buf([83, 104]) // -1826163454 "Sh"
|
||||
crc32 = CRC32.str("eet", crc32) // 1191034598 "Sheet"
|
||||
CRC32.bstr("JS", crc32) // -1647298270 "SheetJS"
|
||||
|
||||
[CRC32.str("\u2603"), CRC32.str("\u0003")] // [ -1743909036, 1259060791 ]
|
||||
[CRC32.bstr("\u2603"), CRC32.bstr("\u0003")] // [ 1259060791, 1259060791 ]
|
||||
[CRC32.buf([0x2603]), CRC32.buf([0x0003])] // [ 1259060791, 1259060791 ]
|
||||
|
||||
// var CRC32C = require('crc-32/crc32c'); // uncomment this line if in node
|
||||
CRC32C.str("SheetJS") // -284764294
|
||||
CRC32C.bstr("SheetJS") // -284764294
|
||||
CRC32C.buf([ 83, 104, 101, 101, 116, 74, 83 ]) // -284764294
|
||||
|
||||
crc32c = CRC32C.buf([83, 104]) // -297065629 "Sh"
|
||||
crc32c = CRC32C.str("eet", crc32c) // 1241364256 "Sheet"
|
||||
CRC32C.bstr("JS", crc32c) // -284764294 "SheetJS"
|
||||
|
||||
[CRC32C.str("\u2603"), CRC32C.str("\u0003")] // [ 1253703093, 1093509285 ]
|
||||
[CRC32C.bstr("\u2603"), CRC32C.bstr("\u0003")] // [ 1093509285, 1093509285 ]
|
||||
[CRC32C.buf([0x2603]), CRC32C.buf([0x0003])] // [ 1093509285, 1093509285 ]
|
||||
```
|
||||
|
||||
### Best Practices
|
||||
|
||||
Even though the initial seed is optional, for performance reasons it is highly
|
||||
recommended to explicitly pass the default seed 0.
|
||||
|
||||
In NodeJS with the native Buffer implementation, it is oftentimes faster to
|
||||
convert binary strings with `Buffer.from(bstr, "binary")` first:
|
||||
|
||||
```js
|
||||
/* Frequently slower in NodeJS */
|
||||
crc32 = CRC32.bstr(bstr, 0);
|
||||
/* Frequently faster in NodeJS */
|
||||
crc32 = CRC32.buf(Buffer.from(bstr, "binary"), 0);
|
||||
```
|
||||
|
||||
This does not apply to browser `Buffer` shims, and thus is not implemented in
|
||||
the library directly.
|
||||
|
||||
## Testing
|
||||
|
||||
`make test` will run the nodejs-based test.
|
||||
|
||||
To run the in-browser tests, run a local server and go to the `ctest` directory.
|
||||
`make ctestserv` will start a python `SimpleHTTPServer` server on port 8000.
|
||||
|
||||
To update the browser artifacts, run `make ctest`.
|
||||
|
||||
To generate the bits file, use the `crc32` function from python `zlib`:
|
||||
|
||||
```python
|
||||
>>> from zlib import crc32
|
||||
>>> x="foo bar baz٪☃🍣"
|
||||
>>> crc32(x)
|
||||
1531648243
|
||||
>>> crc32(x+x)
|
||||
-218791105
|
||||
>>> crc32(x+x+x)
|
||||
1834240887
|
||||
```
|
||||
|
||||
The included `crc32.njs` script can process files or standard input:
|
||||
|
||||
```bash
|
||||
$ echo "this is a test" > t.txt
|
||||
$ bin/crc32.njs t.txt
|
||||
1912935186
|
||||
```
|
||||
|
||||
For comparison, the included `crc32.py` script uses python `zlib`:
|
||||
|
||||
```bash
|
||||
$ bin/crc32.py t.txt
|
||||
1912935186
|
||||
```
|
||||
|
||||
On OSX the command `cksum` generates unsigned CRC-32 with Algorithm 3:
|
||||
|
||||
```bash
|
||||
$ cksum -o 3 < IE8.Win7.For.Windows.VMware.zip
|
||||
1891069052 4161613172
|
||||
$ crc32 --unsigned ~/Downloads/IE8.Win7.For.Windows.VMware.zip
|
||||
1891069052
|
||||
```
|
||||
|
||||
## Performance
|
||||
|
||||
`make perf` will run algorithmic performance tests (which should justify certain
|
||||
decisions in the code).
|
||||
|
||||
The [`adler-32` project](http://git.io/adler32) has more performance notes
|
||||
|
||||
## License
|
||||
|
||||
Please consult the attached LICENSE file for details. All rights not explicitly
|
||||
granted by the Apache 2.0 license are reserved by the Original Author.
|
||||
|
||||
## Badges
|
||||
|
||||
[](https://saucelabs.com/u/crc32)
|
||||
|
||||
[](https://travis-ci.org/SheetJS/js-crc32)
|
||||
[](https://coveralls.io/r/SheetJS/js-crc32?branch=master)
|
||||
[](https://david-dm.org/sheetjs/js-crc32)
|
||||
[](https://npmjs.org/package/crc-32)
|
||||
[](https://ghit.me/repo/sheetjs/js-xlsx)
|
||||
[](https://github.com/SheetJS/js-crc32)
|
||||
@@ -0,0 +1,5 @@
|
||||
var convert = require('./convert'),
|
||||
func = convert('replace', require('../replace'));
|
||||
|
||||
func.placeholder = require('./placeholder');
|
||||
module.exports = func;
|
||||
@@ -0,0 +1,155 @@
|
||||
import { bytes as assertBytes } from './_assert.js';
|
||||
import { hkdf } from './hkdf.js';
|
||||
import { sha256 } from './sha256.js';
|
||||
import { pbkdf2 as _pbkdf2 } from './pbkdf2.js';
|
||||
import { scrypt as _scrypt } from './scrypt.js';
|
||||
import { bytesToHex, createView, hexToBytes, toBytes } from './utils.js';
|
||||
// A tiny KDF for various applications like AES key-gen.
|
||||
// Uses HKDF in a non-standard way, so it's not "KDF-secure", only "PRF-secure".
|
||||
// Which is good enough: assume sha2-256 retained preimage resistance.
|
||||
const SCRYPT_FACTOR = 2 ** 19;
|
||||
const PBKDF2_FACTOR = 2 ** 17;
|
||||
// Scrypt KDF
|
||||
export function scrypt(password, salt) {
|
||||
return _scrypt(password, salt, { N: SCRYPT_FACTOR, r: 8, p: 1, dkLen: 32 });
|
||||
}
|
||||
// PBKDF2-HMAC-SHA256
|
||||
export function pbkdf2(password, salt) {
|
||||
return _pbkdf2(sha256, password, salt, { c: PBKDF2_FACTOR, dkLen: 32 });
|
||||
}
|
||||
// Combines two 32-byte byte arrays
|
||||
function xor32(a, b) {
|
||||
assertBytes(a, 32);
|
||||
assertBytes(b, 32);
|
||||
const arr = new Uint8Array(32);
|
||||
for (let i = 0; i < 32; i++) {
|
||||
arr[i] = a[i] ^ b[i];
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
function strHasLength(str, min, max) {
|
||||
return typeof str === 'string' && str.length >= min && str.length <= max;
|
||||
}
|
||||
/**
|
||||
* Derives main seed. Takes a lot of time. Prefer `eskdf` method instead.
|
||||
*/
|
||||
export function deriveMainSeed(username, password) {
|
||||
if (!strHasLength(username, 8, 255))
|
||||
throw new Error('invalid username');
|
||||
if (!strHasLength(password, 8, 255))
|
||||
throw new Error('invalid password');
|
||||
const scr = scrypt(password + '\u{1}', username + '\u{1}');
|
||||
const pbk = pbkdf2(password + '\u{2}', username + '\u{2}');
|
||||
const res = xor32(scr, pbk);
|
||||
scr.fill(0);
|
||||
pbk.fill(0);
|
||||
return res;
|
||||
}
|
||||
/**
|
||||
* Converts protocol & accountId pair to HKDF salt & info params.
|
||||
*/
|
||||
function getSaltInfo(protocol, accountId = 0) {
|
||||
// Note that length here also repeats two lines below
|
||||
// We do an additional length check here to reduce the scope of DoS attacks
|
||||
if (!(strHasLength(protocol, 3, 15) && /^[a-z0-9]{3,15}$/.test(protocol))) {
|
||||
throw new Error('invalid protocol');
|
||||
}
|
||||
// Allow string account ids for some protocols
|
||||
const allowsStr = /^password\d{0,3}|ssh|tor|file$/.test(protocol);
|
||||
let salt; // Extract salt. Default is undefined.
|
||||
if (typeof accountId === 'string') {
|
||||
if (!allowsStr)
|
||||
throw new Error('accountId must be a number');
|
||||
if (!strHasLength(accountId, 1, 255))
|
||||
throw new Error('accountId must be valid string');
|
||||
salt = toBytes(accountId);
|
||||
}
|
||||
else if (Number.isSafeInteger(accountId)) {
|
||||
if (accountId < 0 || accountId > 2 ** 32 - 1)
|
||||
throw new Error('invalid accountId');
|
||||
// Convert to Big Endian Uint32
|
||||
salt = new Uint8Array(4);
|
||||
createView(salt).setUint32(0, accountId, false);
|
||||
}
|
||||
else {
|
||||
throw new Error(`accountId must be a number${allowsStr ? ' or string' : ''}`);
|
||||
}
|
||||
const info = toBytes(protocol);
|
||||
return { salt, info };
|
||||
}
|
||||
function countBytes(num) {
|
||||
if (typeof num !== 'bigint' || num <= BigInt(128))
|
||||
throw new Error('invalid number');
|
||||
return Math.ceil(num.toString(2).length / 8);
|
||||
}
|
||||
/**
|
||||
* Parses keyLength and modulus options to extract length of result key.
|
||||
* If modulus is used, adds 64 bits to it as per FIPS 186 B.4.1 to combat modulo bias.
|
||||
*/
|
||||
function getKeyLength(options) {
|
||||
if (!options || typeof options !== 'object')
|
||||
return 32;
|
||||
const hasLen = 'keyLength' in options;
|
||||
const hasMod = 'modulus' in options;
|
||||
if (hasLen && hasMod)
|
||||
throw new Error('cannot combine keyLength and modulus options');
|
||||
if (!hasLen && !hasMod)
|
||||
throw new Error('must have either keyLength or modulus option');
|
||||
// FIPS 186 B.4.1 requires at least 64 more bits
|
||||
const l = hasMod ? countBytes(options.modulus) + 8 : options.keyLength;
|
||||
if (!(typeof l === 'number' && l >= 16 && l <= 8192))
|
||||
throw new Error('invalid keyLength');
|
||||
return l;
|
||||
}
|
||||
/**
|
||||
* Converts key to bigint and divides it by modulus. Big Endian.
|
||||
* Implements FIPS 186 B.4.1, which removes 0 and modulo bias from output.
|
||||
*/
|
||||
function modReduceKey(key, modulus) {
|
||||
const _1 = BigInt(1);
|
||||
const num = BigInt('0x' + bytesToHex(key)); // check for ui8a, then bytesToNumber()
|
||||
const res = (num % (modulus - _1)) + _1; // Remove 0 from output
|
||||
if (res < _1)
|
||||
throw new Error('expected positive number'); // Guard against bad values
|
||||
const len = key.length - 8; // FIPS requires 64 more bits = 8 bytes
|
||||
const hex = res.toString(16).padStart(len * 2, '0'); // numberToHex()
|
||||
const bytes = hexToBytes(hex);
|
||||
if (bytes.length !== len)
|
||||
throw new Error('invalid length of result key');
|
||||
return bytes;
|
||||
}
|
||||
/**
|
||||
* ESKDF
|
||||
* @param username - username, email, or identifier, min: 8 characters, should have enough entropy
|
||||
* @param password - password, min: 8 characters, should have enough entropy
|
||||
* @example
|
||||
* const kdf = await eskdf('example-university', 'beginning-new-example');
|
||||
* const key = kdf.deriveChildKey('aes', 0);
|
||||
* console.log(kdf.fingerprint);
|
||||
* kdf.expire();
|
||||
*/
|
||||
export async function eskdf(username, password) {
|
||||
// We are using closure + object instead of class because
|
||||
// we want to make `seed` non-accessible for any external function.
|
||||
let seed = deriveMainSeed(username, password);
|
||||
function deriveCK(protocol, accountId = 0, options) {
|
||||
assertBytes(seed, 32);
|
||||
const { salt, info } = getSaltInfo(protocol, accountId); // validate protocol & accountId
|
||||
const keyLength = getKeyLength(options); // validate options
|
||||
const key = hkdf(sha256, seed, salt, info, keyLength);
|
||||
// Modulus has already been validated
|
||||
return options && 'modulus' in options ? modReduceKey(key, options.modulus) : key;
|
||||
}
|
||||
function expire() {
|
||||
if (seed)
|
||||
seed.fill(1);
|
||||
seed = undefined;
|
||||
}
|
||||
// prettier-ignore
|
||||
const fingerprint = Array.from(deriveCK('fingerprint', 0))
|
||||
.slice(0, 6)
|
||||
.map((char) => char.toString(16).padStart(2, '0').toUpperCase())
|
||||
.join(':');
|
||||
return Object.freeze({ deriveChildKey: deriveCK, expire, fingerprint });
|
||||
}
|
||||
//# sourceMappingURL=eskdf.js.map
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={C:{"11":0.00772,"36":0.00386,"43":0.01931,"44":0.00386,"48":0.00386,"52":0.04633,"56":0.00386,"59":0.00386,"68":0.00386,"72":0.00386,"78":0.03475,"79":0.00386,"80":0.00386,"81":0.00386,"82":0.00386,"83":0.00386,"87":0.01544,"88":0.00772,"91":0.01158,"93":0.00772,"94":0.01158,"99":0.00386,"100":0.00386,"101":0.00386,"102":0.09653,"103":0.04247,"104":0.00772,"105":0.01158,"106":0.01544,"107":0.01931,"108":0.0695,"109":1.22008,"110":0.81467,"111":0.00772,_:"2 3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 37 38 39 40 41 42 45 46 47 49 50 51 53 54 55 57 58 60 61 62 63 64 65 66 67 69 70 71 73 74 75 76 77 84 85 86 89 90 92 95 96 97 98 112 3.5 3.6"},D:{"34":0.00386,"35":0.00386,"38":0.01544,"40":0.01544,"43":0.00772,"47":0.00772,"48":0.01931,"49":0.03861,"52":0.00772,"53":0.00772,"55":0.00772,"56":0.0695,"57":0.00386,"60":0.01544,"61":0.00772,"63":0.00772,"65":0.00772,"66":0.02703,"67":0.00772,"68":0.01158,"69":0.05405,"70":0.01931,"71":0.01544,"72":0.02317,"73":0.01158,"74":0.04247,"75":0.04633,"76":0.04247,"77":0.01544,"78":0.03089,"79":0.12741,"80":0.03861,"81":0.04247,"83":0.07336,"84":0.04247,"85":0.0888,"86":0.07722,"87":0.08108,"88":0.02703,"89":0.03861,"90":0.04633,"91":0.08494,"92":0.05019,"93":0.06564,"94":0.04633,"95":0.01931,"96":0.03861,"97":0.05019,"98":0.09266,"99":0.05019,"100":0.05792,"101":0.06178,"102":0.08494,"103":0.23552,"104":0.08494,"105":0.13127,"106":0.10039,"107":0.19305,"108":0.98456,"109":12.40539,"110":7.25482,"111":0.01544,"112":0.01931,_:"4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 36 37 39 41 42 44 45 46 50 51 54 58 59 62 64 113"},F:{"28":0.00386,"31":0.00386,"36":0.00772,"40":0.00386,"46":0.01158,"85":0.00772,"89":0.00386,"93":0.0695,"94":0.64865,"95":0.37066,_:"9 11 12 15 16 17 18 19 20 21 22 23 24 25 26 27 29 30 32 33 34 35 37 38 39 41 42 43 44 45 47 48 49 50 51 52 53 54 55 56 57 58 60 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 86 87 88 90 91 92 9.5-9.6 10.5 10.6 11.1 11.5 11.6 12.1","10.0-10.1":0},B:{"12":0.00386,"15":0.00386,"17":0.00386,"18":0.01544,"84":0.00772,"85":0.00386,"86":0.00386,"87":0.00386,"89":0.00772,"92":0.00772,"103":0.00772,"104":0.00386,"105":0.00772,"106":0.01158,"107":0.07336,"108":0.11197,"109":1.66023,"110":2.23552,_:"13 14 16 79 80 81 83 88 90 91 93 94 95 96 97 98 99 100 101 102"},E:{"4":0,"13":0.01931,"14":0.09653,"15":0.02317,_:"0 5 6 7 8 9 10 11 12 3.1 3.2 6.1 7.1 10.1 16.4","5.1":0.00772,"9.1":0.05792,"11.1":0.00772,"12.1":0.03089,"13.1":0.16988,"14.1":0.25869,"15.1":0.04247,"15.2-15.3":0.03475,"15.4":0.0888,"15.5":0.16988,"15.6":0.85714,"16.0":0.0888,"16.1":0.29344,"16.2":0.92278,"16.3":0.62162},G:{"8":0,"3.2":0,"4.0-4.1":0,"4.2-4.3":0.00157,"5.0-5.1":0.00313,"6.0-6.1":0.00313,"7.0-7.1":0.01253,"8.1-8.4":0.00627,"9.0-9.2":0.01723,"9.3":0.0564,"10.0-10.2":0.0047,"10.3":0.09871,"11.0-11.2":0.02507,"11.3-11.4":0.0235,"12.0-12.1":0.02194,"12.2-12.5":0.39483,"13.0-13.1":0.01567,"13.2":0.03604,"13.3":0.03447,"13.4-13.7":0.10811,"14.0-14.4":0.28202,"14.5-14.8":0.53271,"15.0-15.1":0.15355,"15.2-15.3":0.19585,"15.4":0.23345,"15.5":0.41207,"15.6":1.40071,"16.0":1.43988,"16.1":3.51431,"16.2":3.62556,"16.3":2.04623,"16.4":0.0094},P:{"4":0.16637,"20":0.77987,"5.0-5.4":0,"6.2-6.4":0,"7.2-7.4":0.05199,"8.2":0,"9.2":0.01024,"10.1":0,"11.1-11.2":0.03119,"12.0":0.0104,"13.0":0.03119,"14.0":0.03119,"15.0":0.0208,"16.0":0.07279,"17.0":0.07279,"18.0":0.09358,"19.0":1.32058},I:{"0":0,"3":0,"4":0.0197,"2.1":0,"2.2":0,"2.3":0,"4.1":0.07878,"4.2-4.3":0.06894,"4.4":0,"4.4.3-4.4.4":0.30529},K:{_:"0 10 11 12 11.1 11.5 12.1"},A:{"8":0.0478,"9":0.05736,"10":0.00956,"11":0.48759,_:"6 7 5.5"},N:{"10":0,"11":0},S:{"2.5":0.07981,_:"3.0-3.1"},J:{"7":0,"10":0},O:{"0":0.89629},H:{"0":0.99385},L:{"0":42.62898},R:{_:"0"},M:{"0":0.29467},Q:{"13.1":0.12278}};
|
||||
@@ -0,0 +1,2 @@
|
||||
import type { FormDataEncoderHeaders, RawHeaders } from "./Headers.js";
|
||||
export declare const proxyHeaders: (object: RawHeaders) => FormDataEncoderHeaders;
|
||||
@@ -0,0 +1,4 @@
|
||||
import Tag from './shared/Tag';
|
||||
export default class RawMustacheTag extends Tag {
|
||||
type: 'RawMustacheTag';
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"name": "windows-release",
|
||||
"version": "5.1.0",
|
||||
"description": "Get the name of a Windows version from the release number: `5.1.2600` → `XP`",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/windows-release",
|
||||
"funding": "https://github.com/sponsors/sindresorhus",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "https://sindresorhus.com"
|
||||
},
|
||||
"type": "module",
|
||||
"exports": "./index.js",
|
||||
"engines": {
|
||||
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"os",
|
||||
"win",
|
||||
"win32",
|
||||
"windows",
|
||||
"operating",
|
||||
"system",
|
||||
"platform",
|
||||
"name",
|
||||
"title",
|
||||
"release",
|
||||
"version"
|
||||
],
|
||||
"dependencies": {
|
||||
"execa": "^5.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "^3.15.0",
|
||||
"tsd": "^0.17.0",
|
||||
"xo": "^0.44.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,917 @@
|
||||
# Commander.js
|
||||
|
||||
[](https://github.com/tj/commander.js/actions?query=workflow%3A%22build%22)
|
||||
[](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)
|
||||
- [Required option](#required-option)
|
||||
- [Variadic option](#variadic-option)
|
||||
- [Version option](#version-option)
|
||||
- [More configuration](#more-configuration)
|
||||
- [Custom option processing](#custom-option-processing)
|
||||
- [Commands](#commands)
|
||||
- [Specify the argument syntax](#specify-the-argument-syntax)
|
||||
- [Action handler](#action-handler)
|
||||
- [Stand-alone executable (sub)commands](#stand-alone-executable-subcommands)
|
||||
- [Automated help](#automated-help)
|
||||
- [Custom help](#custom-help)
|
||||
- [Display help from code](#display-help-from-code)
|
||||
- [.usage and .name](#usage-and-name)
|
||||
- [.helpOption(flags, description)](#helpoptionflags-description)
|
||||
- [.addHelpCommand()](#addhelpcommand)
|
||||
- [More configuration](#more-configuration-1)
|
||||
- [Custom event listeners](#custom-event-listeners)
|
||||
- [Bits and pieces](#bits-and-pieces)
|
||||
- [.parse() and .parseAsync()](#parse-and-parseasync)
|
||||
- [Parsing Configuration](#parsing-configuration)
|
||||
- [Legacy options as properties](#legacy-options-as-properties)
|
||||
- [TypeScript](#typescript)
|
||||
- [createCommand()](#createcommand)
|
||||
- [Node options such as `--harmony`](#node-options-such-as---harmony)
|
||||
- [Debugging stand-alone executable subcommands](#debugging-stand-alone-executable-subcommands)
|
||||
- [Override exit and output handling](#override-exit-and-output-handling)
|
||||
- [Additional documentation](#additional-documentation)
|
||||
- [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');
|
||||
```
|
||||
|
||||
For named imports in ECMAScript modules, import from `commander/esm.mjs`.
|
||||
|
||||
```js
|
||||
// index.mjs
|
||||
import { Command } from 'commander/esm.mjs';
|
||||
const program = new Command();
|
||||
```
|
||||
|
||||
And in TypeScript:
|
||||
|
||||
```ts
|
||||
// index.ts
|
||||
import { Command } from 'commander';
|
||||
const program = new Command();
|
||||
```
|
||||
|
||||
|
||||
## 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 parsed options can be accessed by calling `.opts()` on a `Command` object, and are passed to the action handler. Multi-word options such as "--template-engine" are camel-cased, becoming `program.opts().templateEngine` etc.
|
||||
|
||||
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.
|
||||
|
||||
By default 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);
|
||||
|
||||
const options = program.opts();
|
||||
if (options.debug) console.log(options);
|
||||
console.log('pizza details:');
|
||||
if (options.small) console.log('- small pizza size');
|
||||
if (options.pizzaType) console.log(`- ${options.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. The parameter is optional and defaults to `process.argv`.
|
||||
|
||||
### 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();
|
||||
|
||||
console.log(`cheese: ${program.opts().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();
|
||||
|
||||
const options = program.opts();
|
||||
const sauceStr = options.sauce ? 'sauce' : 'no sauce';
|
||||
const cheeseStr = (options.cheese === false) ? 'no cheese' : `${options.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);
|
||||
|
||||
const options = program.opts();
|
||||
if (options.cheese === undefined) console.log('no cheese');
|
||||
else if (options.cheese === true) console.log('add cheese');
|
||||
else console.log(`add cheese type ${options.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).
|
||||
|
||||
### 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();
|
||||
```
|
||||
|
||||
```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');
|
||||
```
|
||||
|
||||
### More configuration
|
||||
|
||||
You can add most options using the `.option()` method, but there are some additional features available
|
||||
by constructing an `Option` explicitly for less common cases.
|
||||
|
||||
Example file: [options-extra.js](./examples/options-extra.js)
|
||||
|
||||
```js
|
||||
program
|
||||
.addOption(new Option('-s, --secret').hideHelp())
|
||||
.addOption(new Option('-t, --timeout <delay>', 'timeout in seconds').default(60, 'one minute'))
|
||||
.addOption(new Option('-d, --drink <size>', 'drink size').choices(['small', 'medium', 'large']));
|
||||
```
|
||||
|
||||
```bash
|
||||
$ extra --help
|
||||
Usage: help [options]
|
||||
|
||||
Options:
|
||||
-t, --timeout <delay> timeout in seconds (default: one minute)
|
||||
-d, --drink <size> drink cup size (choices: "small", "medium", "large")
|
||||
-h, --help display help for command
|
||||
|
||||
$ extra --drink huge
|
||||
error: option '-d, --drink <size>' argument 'huge' is invalid. Allowed choices are small, medium, large.
|
||||
```
|
||||
|
||||
### 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 a radix
|
||||
const parsedValue = parseInt(value, 10);
|
||||
if (isNaN(parsedValue)) {
|
||||
throw new commander.InvalidOptionArgumentError('Not a number.');
|
||||
}
|
||||
return parsedValue;
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
const options = program.opts();
|
||||
if (options.float !== undefined) console.log(`float: ${options.float}`);
|
||||
if (options.integer !== undefined) console.log(`integer: ${options.integer}`);
|
||||
if (options.verbose > 0) console.log(`verbosity: ${options.verbose}`);
|
||||
if (options.collect.length > 0) console.log(options.collect);
|
||||
if (options.list !== undefined) console.log(options.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' ]
|
||||
```
|
||||
|
||||
## 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: [arguments.js](./examples/arguments.js)
|
||||
|
||||
```js
|
||||
program
|
||||
.version('0.1.0')
|
||||
.arguments('<username> [password]')
|
||||
.description('test command', {
|
||||
username: 'user to login',
|
||||
password: 'password for user, if required'
|
||||
})
|
||||
.action((username, password) => {
|
||||
console.log('username:', username);
|
||||
console.log('environment:', password || 'no password given');
|
||||
});
|
||||
```
|
||||
|
||||
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
|
||||
program
|
||||
.version('0.1.0')
|
||||
.command('rmdir <dirs...>')
|
||||
.action(function (dirs) {
|
||||
dirs.forEach((dir) => {
|
||||
console.log('rmdir %s', dir);
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
The variadic argument is passed to the action handler as an array.
|
||||
|
||||
### Action handler
|
||||
|
||||
The action handler gets passed a parameter for each command-argument you declared, and two additional parameters
|
||||
which are the parsed options and the command object itself.
|
||||
|
||||
Example file: [thank.js](./examples/thank.js)
|
||||
|
||||
```js
|
||||
program
|
||||
.arguments('<name>')
|
||||
.option('-t, --title <honorific>', 'title to use before name')
|
||||
.option('-d, --debug', 'display some debugging')
|
||||
.action((name, options, command) => {
|
||||
if (options.debug) {
|
||||
console.error('Called %s with options %o', command.name(), options);
|
||||
}
|
||||
const title = options.title ? `${options.title} ` : '';
|
||||
console.log(`Thank-you ${title}${name}`);
|
||||
});
|
||||
```
|
||||
|
||||
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 and arguments on the command line are validated when the command is used. Any unknown options or missing arguments will be reported as an error. You can suppress the unknown option checks with `.allowUnknownOption()`. By default it is not an error to
|
||||
pass more arguments than declared, but you can make this an error with `.allowExcessArguments(false)`.
|
||||
|
||||
### 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 pizza ordering
|
||||
|
||||
Options:
|
||||
-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 add extra text to be displayed along with the built-in help.
|
||||
|
||||
Example file: [custom-help](./examples/custom-help)
|
||||
|
||||
```js
|
||||
program
|
||||
.option('-f, --foo', 'enable some foo');
|
||||
|
||||
program.addHelpText('after', `
|
||||
|
||||
Example call:
|
||||
$ 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
|
||||
```
|
||||
|
||||
The positions in order displayed are:
|
||||
|
||||
- `beforeAll`: add to the program for a global banner or header
|
||||
- `before`: display extra information before built-in help
|
||||
- `after`: display extra information after built-in help
|
||||
- `afterAll`: add to the program for a global footer (epilog)
|
||||
|
||||
The positions "beforeAll" and "afterAll" apply to the command and all its subcommands.
|
||||
|
||||
The second parameter can be a string, or a function returning a string. The function is passed a context object for your convenience. The properties are:
|
||||
|
||||
- error: a boolean for whether the help is being displayed due to a usage error
|
||||
- command: the Command which is displaying the help
|
||||
|
||||
### Display help from code
|
||||
|
||||
`.help()`: display help information and exit immediately. You can optionally pass `{ error: true }` to display on stderr and exit with an error status.
|
||||
|
||||
`.outputHelp()`: output help information without exiting. You can optionally pass `{ error: true }` to display on stderr.
|
||||
|
||||
`.helpInformation()`: get the built-in command help information as a string for processing or displaying yourself.
|
||||
|
||||
### .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
|
||||
```
|
||||
|
||||
### .helpOption(flags, description)
|
||||
|
||||
By default every command has a help option. 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()
|
||||
|
||||
A help command is added by default if your command has subcommands. 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');
|
||||
```
|
||||
|
||||
### More configuration
|
||||
|
||||
The built-in help is formatted using the Help class.
|
||||
You can configure the Help behaviour by modifying data properties and methods using `.configureHelp()`, or by subclassing using `.createHelp()` if you prefer.
|
||||
|
||||
The data properties are:
|
||||
|
||||
- `helpWidth`: specify the wrap width, useful for unit tests
|
||||
- `sortSubcommands`: sort the subcommands alphabetically
|
||||
- `sortOptions`: sort the options alphabetically
|
||||
|
||||
There are methods getting the visible lists of arguments, options, and subcommands. There are methods for formatting the items in the lists, with each item having a _term_ and _description_. Take a look at `.formatHelp()` to see how they are used.
|
||||
|
||||
Example file: [configure-help.js](./examples/configure-help.js)
|
||||
|
||||
```
|
||||
program.configureHelp({
|
||||
sortSubcommands: true,
|
||||
subcommandTerm: (cmd) => cmd.name() // Just show the name, instead of short usage.
|
||||
});
|
||||
```
|
||||
|
||||
## 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.opts().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' });
|
||||
```
|
||||
|
||||
### Parsing Configuration
|
||||
|
||||
If the default parsing does not suit your needs, there are some behaviours to support other usage patterns.
|
||||
|
||||
By default program options are recognised before and after subcommands. To only look for program options before subcommands, use `.enablePositionalOptions()`. This lets you use
|
||||
an option for a different purpose in subcommands.
|
||||
|
||||
Example file: [positional-options.js](./examples/positional-options.js)
|
||||
|
||||
With positional options, the `-b` is a program option in the first line and a subcommand option in the second line:
|
||||
|
||||
```sh
|
||||
program -b subcommand
|
||||
program subcommand -b
|
||||
```
|
||||
|
||||
By default options are recognised before and after command-arguments. To only process options that come
|
||||
before the command-arguments, use `.passThroughOptions()`. This lets you pass the arguments and following options through to another program
|
||||
without needing to use `--` to end the option processing.
|
||||
To use pass through options in a subcommand, the program needs to enable positional options.
|
||||
|
||||
Example file: [pass-through-options.js](./examples/pass-through-options.js)
|
||||
|
||||
With pass through options, the `--port=80` is a program option in the first line and passed through as a command-argument in the second line:
|
||||
|
||||
```sh
|
||||
program --port=80 arg
|
||||
program arg --port=80
|
||||
```
|
||||
|
||||
By default the option processing shows an error for an unknown option. To have an unknown option treated as an ordinary command-argument and continue looking for options, use `.allowUnknownOption()`. This lets you mix known and unknown options.
|
||||
|
||||
By default the argument processing does not display an error for more command-arguments than expected.
|
||||
To display an error for excess arguments, use`.allowExcessArguments(false)`.
|
||||
|
||||
### Legacy options as properties
|
||||
|
||||
Before Commander 7, the option values were stored as properties on the command.
|
||||
This was convenient to code but the downside was possible clashes with
|
||||
existing properties of `Command`. You can revert to the old behaviour to run unmodified legacy code by using `.storeOptionsAsProperties()`.
|
||||
|
||||
```js
|
||||
program
|
||||
.storeOptionsAsProperties()
|
||||
.option('-d, --debug')
|
||||
.action((commandAndOptions) => {
|
||||
if (commandAndOptions.debug) {
|
||||
console.error(`Called ${commandAndOptions.name()}`);
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
### TypeScript
|
||||
|
||||
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 (example file [custom-command-class.js](./examples/custom-command-class.js)).
|
||||
|
||||
### 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 and output 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...
|
||||
}
|
||||
```
|
||||
|
||||
By default Commander is configured for a command-line application and writes to stdout and stderr.
|
||||
You can modify this behaviour for custom applications. In addition, you can modify the display of error messages.
|
||||
|
||||
Example file: [configure-output.js](./examples/configure-output.js)
|
||||
|
||||
|
||||
```js
|
||||
function errorColor(str) {
|
||||
// Add ANSI escape codes to display text in red.
|
||||
return `\x1b[31m${str}\x1b[0m`;
|
||||
}
|
||||
|
||||
program
|
||||
.configureOutput({
|
||||
// Visibly override write routines as example!
|
||||
writeOut: (str) => process.stdout.write(`[OUT] ${str}`),
|
||||
writeErr: (str) => process.stdout.write(`[ERR] ${str}`),
|
||||
// Highlight errors in color.
|
||||
outputError: (str, write) => write(errorColor(str))
|
||||
});
|
||||
```
|
||||
|
||||
### Additional documentation
|
||||
|
||||
There is more information available about:
|
||||
|
||||
- [deprecated](./docs/deprecated.md) features still supported for backwards compatibility
|
||||
- [options taking varying arguments](./docs/options-taking-varying-arguments.md)
|
||||
|
||||
## Examples
|
||||
|
||||
In a single command program, you might not need an action handler.
|
||||
|
||||
Example file: [pizza](./examples/pizza)
|
||||
|
||||
```js
|
||||
const { program } = require('commander');
|
||||
|
||||
program
|
||||
.description('An application for pizza ordering')
|
||||
.option('-p, --peppers', 'Add peppers')
|
||||
.option('-c, --cheese <type>', 'Add the specified type of cheese', 'marble')
|
||||
.option('-C, --no-cheese', 'You do not want any cheese');
|
||||
|
||||
program.parse();
|
||||
|
||||
const options = program.opts();
|
||||
console.log('you ordered a pizza with:');
|
||||
if (options.peppers) console.log(' - peppers');
|
||||
const cheese = !options.cheese ? 'no' : options.cheese;
|
||||
console.log(' - %s cheese', cheese);
|
||||
```
|
||||
|
||||
In a multi-command program, you will have action handlers for each command (or stand-alone executables for the commands).
|
||||
|
||||
Example file: [deploy](./examples/deploy)
|
||||
|
||||
```js
|
||||
const { Command } = require('commander');
|
||||
const program = new Command();
|
||||
|
||||
program
|
||||
.version('0.0.1')
|
||||
.option('-c, --config <path>', 'set config path', './deploy.conf');
|
||||
|
||||
program
|
||||
.command('setup [env]')
|
||||
.description('run setup commands for all envs')
|
||||
.option('-s, --setup_mode <mode>', 'Which setup mode to use', 'normal')
|
||||
.action((env, options) => {
|
||||
env = env || 'all';
|
||||
console.log('read config from %s', program.opts().config);
|
||||
console.log('setup for %s env(s) with %s mode', env, options.setup_mode);
|
||||
});
|
||||
|
||||
program
|
||||
.command('exec <script>')
|
||||
.alias('ex')
|
||||
.description('execute the given remote cmd')
|
||||
.option('-e, --exec_mode <mode>', 'Which exec mode to use', 'fast')
|
||||
.action((script, options) => {
|
||||
console.log('read config from %s', program.opts().config);
|
||||
console.log('exec "%s" using %s mode and config %s', script, options.exec_mode, program.opts().config);
|
||||
}).addHelpText('after', `
|
||||
Examples:
|
||||
$ deploy exec sequential
|
||||
$ deploy exec async`
|
||||
);
|
||||
|
||||
program.parse(process.argv);
|
||||
```
|
||||
|
||||
More samples 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 requires at least node v10.
|
||||
(For older versions of node, use an older version of Commander. Commander version 2.x has the widest support.)
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,3 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = require('./async').eachSeries;
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sources":["../dist-src/VERSION.js"],"sourcesContent":["export const VERSION = \"0.0.0-development\";\n"],"names":[],"mappings":"AAAY,MAAC,OAAO,GAAG;;;;"}
|
||||
@@ -0,0 +1,239 @@
|
||||
#!/usr/bin/env node
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
|
||||
const _arg = /*#__PURE__*/ _interopRequireDefault(require("arg"));
|
||||
const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
|
||||
const _build = require("./build");
|
||||
const _help = require("./help");
|
||||
const _init = require("./init");
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
function isESM() {
|
||||
const pkgPath = _path.default.resolve("./package.json");
|
||||
try {
|
||||
let pkg = JSON.parse(_fs.default.readFileSync(pkgPath, "utf8"));
|
||||
return pkg.type && pkg.type === "module";
|
||||
} catch (err) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
let configs = isESM() ? {
|
||||
tailwind: "tailwind.config.cjs",
|
||||
postcss: "postcss.config.cjs"
|
||||
} : {
|
||||
tailwind: "tailwind.config.js",
|
||||
postcss: "postcss.config.js"
|
||||
};
|
||||
// ---
|
||||
function oneOf(...options) {
|
||||
return Object.assign((value = true)=>{
|
||||
for (let option of options){
|
||||
let parsed = option(value);
|
||||
if (parsed === value) {
|
||||
return parsed;
|
||||
}
|
||||
}
|
||||
throw new Error("...");
|
||||
}, {
|
||||
manualParsing: true
|
||||
});
|
||||
}
|
||||
let commands = {
|
||||
init: {
|
||||
run: _init.init,
|
||||
args: {
|
||||
"--full": {
|
||||
type: Boolean,
|
||||
description: `Initialize a full \`${configs.tailwind}\` file`
|
||||
},
|
||||
"--postcss": {
|
||||
type: Boolean,
|
||||
description: `Initialize a \`${configs.postcss}\` file`
|
||||
},
|
||||
"-f": "--full",
|
||||
"-p": "--postcss"
|
||||
}
|
||||
},
|
||||
build: {
|
||||
run: _build.build,
|
||||
args: {
|
||||
"--input": {
|
||||
type: String,
|
||||
description: "Input file"
|
||||
},
|
||||
"--output": {
|
||||
type: String,
|
||||
description: "Output file"
|
||||
},
|
||||
"--watch": {
|
||||
type: oneOf(String, Boolean),
|
||||
description: "Watch for changes and rebuild as needed"
|
||||
},
|
||||
"--poll": {
|
||||
type: Boolean,
|
||||
description: "Use polling instead of filesystem events when watching"
|
||||
},
|
||||
"--content": {
|
||||
type: String,
|
||||
description: "Content paths to use for removing unused classes"
|
||||
},
|
||||
"--purge": {
|
||||
type: String,
|
||||
deprecated: true
|
||||
},
|
||||
"--postcss": {
|
||||
type: oneOf(String, Boolean),
|
||||
description: "Load custom PostCSS configuration"
|
||||
},
|
||||
"--minify": {
|
||||
type: Boolean,
|
||||
description: "Minify the output"
|
||||
},
|
||||
"--config": {
|
||||
type: String,
|
||||
description: "Path to a custom config file"
|
||||
},
|
||||
"--no-autoprefixer": {
|
||||
type: Boolean,
|
||||
description: "Disable autoprefixer"
|
||||
},
|
||||
"-c": "--config",
|
||||
"-i": "--input",
|
||||
"-o": "--output",
|
||||
"-m": "--minify",
|
||||
"-w": "--watch",
|
||||
"-p": "--poll"
|
||||
}
|
||||
}
|
||||
};
|
||||
let sharedFlags = {
|
||||
"--help": {
|
||||
type: Boolean,
|
||||
description: "Display usage information"
|
||||
},
|
||||
"-h": "--help"
|
||||
};
|
||||
if (process.stdout.isTTY /* Detect redirecting output to a file */ && (process.argv[2] === undefined || process.argv.slice(2).every((flag)=>sharedFlags[flag] !== undefined))) {
|
||||
(0, _help.help)({
|
||||
usage: [
|
||||
"tailwindcss [--input input.css] [--output output.css] [--watch] [options...]",
|
||||
"tailwindcss init [--full] [--postcss] [options...]"
|
||||
],
|
||||
commands: Object.keys(commands).filter((command)=>command !== "build").map((command)=>`${command} [options]`),
|
||||
options: {
|
||||
...commands.build.args,
|
||||
...sharedFlags
|
||||
}
|
||||
});
|
||||
process.exit(0);
|
||||
}
|
||||
let command = ((arg = "")=>arg.startsWith("-") ? undefined : arg)(process.argv[2]) || "build";
|
||||
if (commands[command] === undefined) {
|
||||
if (_fs.default.existsSync(_path.default.resolve(command))) {
|
||||
// TODO: Deprecate this in future versions
|
||||
// Check if non-existing command, might be a file.
|
||||
command = "build";
|
||||
} else {
|
||||
(0, _help.help)({
|
||||
message: `Invalid command: ${command}`,
|
||||
usage: [
|
||||
"tailwindcss <command> [options]"
|
||||
],
|
||||
commands: Object.keys(commands).filter((command)=>command !== "build").map((command)=>`${command} [options]`),
|
||||
options: sharedFlags
|
||||
});
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
// Execute command
|
||||
let { args: flags , run } = commands[command];
|
||||
let args = (()=>{
|
||||
try {
|
||||
let result = (0, _arg.default)(Object.fromEntries(Object.entries({
|
||||
...flags,
|
||||
...sharedFlags
|
||||
}).filter(([_key, value])=>{
|
||||
var _value_type;
|
||||
return !(value === null || value === void 0 ? void 0 : (_value_type = value.type) === null || _value_type === void 0 ? void 0 : _value_type.manualParsing);
|
||||
}).map(([key, value])=>[
|
||||
key,
|
||||
typeof value === "object" ? value.type : value
|
||||
])), {
|
||||
permissive: true
|
||||
});
|
||||
// Manual parsing of flags to allow for special flags like oneOf(Boolean, String)
|
||||
for(let i = result["_"].length - 1; i >= 0; --i){
|
||||
let flag = result["_"][i];
|
||||
if (!flag.startsWith("-")) continue;
|
||||
let [flagName, flagValue] = flag.split("=");
|
||||
let handler = flags[flagName];
|
||||
// Resolve flagName & handler
|
||||
while(typeof handler === "string"){
|
||||
flagName = handler;
|
||||
handler = flags[handler];
|
||||
}
|
||||
if (!handler) continue;
|
||||
let args = [];
|
||||
let offset = i + 1;
|
||||
// --flag value syntax was used so we need to pull `value` from `args`
|
||||
if (flagValue === undefined) {
|
||||
// Parse args for current flag
|
||||
while(result["_"][offset] && !result["_"][offset].startsWith("-")){
|
||||
args.push(result["_"][offset++]);
|
||||
}
|
||||
// Cleanup manually parsed flags + args
|
||||
result["_"].splice(i, 1 + args.length);
|
||||
// No args were provided, use default value defined in handler
|
||||
// One arg was provided, use that directly
|
||||
// Multiple args were provided so pass them all in an array
|
||||
flagValue = args.length === 0 ? undefined : args.length === 1 ? args[0] : args;
|
||||
} else {
|
||||
// Remove the whole flag from the args array
|
||||
result["_"].splice(i, 1);
|
||||
}
|
||||
// Set the resolved value in the `result` object
|
||||
result[flagName] = handler.type(flagValue, flagName);
|
||||
}
|
||||
// Ensure that the `command` is always the first argument in the `args`.
|
||||
// This is important so that we don't have to check if a default command
|
||||
// (build) was used or not from within each plugin.
|
||||
//
|
||||
// E.g.: tailwindcss input.css -> _: ['build', 'input.css']
|
||||
// E.g.: tailwindcss build input.css -> _: ['build', 'input.css']
|
||||
if (result["_"][0] !== command) {
|
||||
result["_"].unshift(command);
|
||||
}
|
||||
return result;
|
||||
} catch (err) {
|
||||
if (err.code === "ARG_UNKNOWN_OPTION") {
|
||||
(0, _help.help)({
|
||||
message: err.message,
|
||||
usage: [
|
||||
"tailwindcss <command> [options]"
|
||||
],
|
||||
options: sharedFlags
|
||||
});
|
||||
process.exit(1);
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
})();
|
||||
if (args["--help"]) {
|
||||
(0, _help.help)({
|
||||
options: {
|
||||
...flags,
|
||||
...sharedFlags
|
||||
},
|
||||
usage: [
|
||||
`tailwindcss ${command} [options]`
|
||||
]
|
||||
});
|
||||
process.exit(0);
|
||||
}
|
||||
run(args, configs);
|
||||
@@ -0,0 +1,304 @@
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var common = require('./common');
|
||||
|
||||
common.register('cp', _cp, {
|
||||
cmdOptions: {
|
||||
'f': '!no_force',
|
||||
'n': 'no_force',
|
||||
'u': 'update',
|
||||
'R': 'recursive',
|
||||
'r': 'recursive',
|
||||
'L': 'followsymlink',
|
||||
'P': 'noFollowsymlink',
|
||||
},
|
||||
wrapOutput: false,
|
||||
});
|
||||
|
||||
// Buffered file copy, synchronous
|
||||
// (Using readFileSync() + writeFileSync() could easily cause a memory overflow
|
||||
// with large files)
|
||||
function copyFileSync(srcFile, destFile, options) {
|
||||
if (!fs.existsSync(srcFile)) {
|
||||
common.error('copyFileSync: no such file or directory: ' + srcFile);
|
||||
}
|
||||
|
||||
var isWindows = process.platform === 'win32';
|
||||
|
||||
// Check the mtimes of the files if the '-u' flag is provided
|
||||
try {
|
||||
if (options.update && common.statFollowLinks(srcFile).mtime < fs.statSync(destFile).mtime) {
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
// If we're here, destFile probably doesn't exist, so just do a normal copy
|
||||
}
|
||||
|
||||
if (common.statNoFollowLinks(srcFile).isSymbolicLink() && !options.followsymlink) {
|
||||
try {
|
||||
common.statNoFollowLinks(destFile);
|
||||
common.unlinkSync(destFile); // re-link it
|
||||
} catch (e) {
|
||||
// it doesn't exist, so no work needs to be done
|
||||
}
|
||||
|
||||
var symlinkFull = fs.readlinkSync(srcFile);
|
||||
fs.symlinkSync(symlinkFull, destFile, isWindows ? 'junction' : null);
|
||||
} else {
|
||||
var buf = common.buffer();
|
||||
var bufLength = buf.length;
|
||||
var bytesRead = bufLength;
|
||||
var pos = 0;
|
||||
var fdr = null;
|
||||
var fdw = null;
|
||||
|
||||
try {
|
||||
fdr = fs.openSync(srcFile, 'r');
|
||||
} catch (e) {
|
||||
/* istanbul ignore next */
|
||||
common.error('copyFileSync: could not read src file (' + srcFile + ')');
|
||||
}
|
||||
|
||||
try {
|
||||
fdw = fs.openSync(destFile, 'w');
|
||||
} catch (e) {
|
||||
/* istanbul ignore next */
|
||||
common.error('copyFileSync: could not write to dest file (code=' + e.code + '):' + destFile);
|
||||
}
|
||||
|
||||
while (bytesRead === bufLength) {
|
||||
bytesRead = fs.readSync(fdr, buf, 0, bufLength, pos);
|
||||
fs.writeSync(fdw, buf, 0, bytesRead);
|
||||
pos += bytesRead;
|
||||
}
|
||||
|
||||
fs.closeSync(fdr);
|
||||
fs.closeSync(fdw);
|
||||
|
||||
fs.chmodSync(destFile, common.statFollowLinks(srcFile).mode);
|
||||
}
|
||||
}
|
||||
|
||||
// Recursively copies 'sourceDir' into 'destDir'
|
||||
// Adapted from https://github.com/ryanmcgrath/wrench-js
|
||||
//
|
||||
// Copyright (c) 2010 Ryan McGrath
|
||||
// Copyright (c) 2012 Artur Adib
|
||||
//
|
||||
// Licensed under the MIT License
|
||||
// http://www.opensource.org/licenses/mit-license.php
|
||||
function cpdirSyncRecursive(sourceDir, destDir, currentDepth, opts) {
|
||||
if (!opts) opts = {};
|
||||
|
||||
// Ensure there is not a run away recursive copy
|
||||
if (currentDepth >= common.config.maxdepth) return;
|
||||
currentDepth++;
|
||||
|
||||
var isWindows = process.platform === 'win32';
|
||||
|
||||
// Create the directory where all our junk is moving to; read the mode of the
|
||||
// source directory and mirror it
|
||||
try {
|
||||
fs.mkdirSync(destDir);
|
||||
} catch (e) {
|
||||
// if the directory already exists, that's okay
|
||||
if (e.code !== 'EEXIST') throw e;
|
||||
}
|
||||
|
||||
var files = fs.readdirSync(sourceDir);
|
||||
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
var srcFile = sourceDir + '/' + files[i];
|
||||
var destFile = destDir + '/' + files[i];
|
||||
var srcFileStat = common.statNoFollowLinks(srcFile);
|
||||
|
||||
var symlinkFull;
|
||||
if (opts.followsymlink) {
|
||||
if (cpcheckcycle(sourceDir, srcFile)) {
|
||||
// Cycle link found.
|
||||
console.error('Cycle link found.');
|
||||
symlinkFull = fs.readlinkSync(srcFile);
|
||||
fs.symlinkSync(symlinkFull, destFile, isWindows ? 'junction' : null);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (srcFileStat.isDirectory()) {
|
||||
/* recursion this thing right on back. */
|
||||
cpdirSyncRecursive(srcFile, destFile, currentDepth, opts);
|
||||
} else if (srcFileStat.isSymbolicLink() && !opts.followsymlink) {
|
||||
symlinkFull = fs.readlinkSync(srcFile);
|
||||
try {
|
||||
common.statNoFollowLinks(destFile);
|
||||
common.unlinkSync(destFile); // re-link it
|
||||
} catch (e) {
|
||||
// it doesn't exist, so no work needs to be done
|
||||
}
|
||||
fs.symlinkSync(symlinkFull, destFile, isWindows ? 'junction' : null);
|
||||
} else if (srcFileStat.isSymbolicLink() && opts.followsymlink) {
|
||||
srcFileStat = common.statFollowLinks(srcFile);
|
||||
if (srcFileStat.isDirectory()) {
|
||||
cpdirSyncRecursive(srcFile, destFile, currentDepth, opts);
|
||||
} else {
|
||||
copyFileSync(srcFile, destFile, opts);
|
||||
}
|
||||
} else {
|
||||
/* At this point, we've hit a file actually worth copying... so copy it on over. */
|
||||
if (fs.existsSync(destFile) && opts.no_force) {
|
||||
common.log('skipping existing file: ' + files[i]);
|
||||
} else {
|
||||
copyFileSync(srcFile, destFile, opts);
|
||||
}
|
||||
}
|
||||
} // for files
|
||||
|
||||
// finally change the mode for the newly created directory (otherwise, we
|
||||
// couldn't add files to a read-only directory).
|
||||
var checkDir = common.statFollowLinks(sourceDir);
|
||||
fs.chmodSync(destDir, checkDir.mode);
|
||||
} // cpdirSyncRecursive
|
||||
|
||||
// Checks if cureent file was created recently
|
||||
function checkRecentCreated(sources, index) {
|
||||
var lookedSource = sources[index];
|
||||
return sources.slice(0, index).some(function (src) {
|
||||
return path.basename(src) === path.basename(lookedSource);
|
||||
});
|
||||
}
|
||||
|
||||
function cpcheckcycle(sourceDir, srcFile) {
|
||||
var srcFileStat = common.statNoFollowLinks(srcFile);
|
||||
if (srcFileStat.isSymbolicLink()) {
|
||||
// Do cycle check. For example:
|
||||
// $ mkdir -p 1/2/3/4
|
||||
// $ cd 1/2/3/4
|
||||
// $ ln -s ../../3 link
|
||||
// $ cd ../../../..
|
||||
// $ cp -RL 1 copy
|
||||
var cyclecheck = common.statFollowLinks(srcFile);
|
||||
if (cyclecheck.isDirectory()) {
|
||||
var sourcerealpath = fs.realpathSync(sourceDir);
|
||||
var symlinkrealpath = fs.realpathSync(srcFile);
|
||||
var re = new RegExp(symlinkrealpath);
|
||||
if (re.test(sourcerealpath)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//@
|
||||
//@ ### cp([options,] source [, source ...], dest)
|
||||
//@ ### cp([options,] source_array, dest)
|
||||
//@
|
||||
//@ Available options:
|
||||
//@
|
||||
//@ + `-f`: force (default behavior)
|
||||
//@ + `-n`: no-clobber
|
||||
//@ + `-u`: only copy if `source` is newer than `dest`
|
||||
//@ + `-r`, `-R`: recursive
|
||||
//@ + `-L`: follow symlinks
|
||||
//@ + `-P`: don't follow symlinks
|
||||
//@
|
||||
//@ Examples:
|
||||
//@
|
||||
//@ ```javascript
|
||||
//@ cp('file1', 'dir1');
|
||||
//@ cp('-R', 'path/to/dir/', '~/newCopy/');
|
||||
//@ cp('-Rf', '/tmp/*', '/usr/local/*', '/home/tmp');
|
||||
//@ cp('-Rf', ['/tmp/*', '/usr/local/*'], '/home/tmp'); // same as above
|
||||
//@ ```
|
||||
//@
|
||||
//@ Copies files.
|
||||
function _cp(options, sources, dest) {
|
||||
// If we're missing -R, it actually implies -L (unless -P is explicit)
|
||||
if (options.followsymlink) {
|
||||
options.noFollowsymlink = false;
|
||||
}
|
||||
if (!options.recursive && !options.noFollowsymlink) {
|
||||
options.followsymlink = true;
|
||||
}
|
||||
|
||||
// Get sources, dest
|
||||
if (arguments.length < 3) {
|
||||
common.error('missing <source> and/or <dest>');
|
||||
} else {
|
||||
sources = [].slice.call(arguments, 1, arguments.length - 1);
|
||||
dest = arguments[arguments.length - 1];
|
||||
}
|
||||
|
||||
var destExists = fs.existsSync(dest);
|
||||
var destStat = destExists && common.statFollowLinks(dest);
|
||||
|
||||
// Dest is not existing dir, but multiple sources given
|
||||
if ((!destExists || !destStat.isDirectory()) && sources.length > 1) {
|
||||
common.error('dest is not a directory (too many sources)');
|
||||
}
|
||||
|
||||
// Dest is an existing file, but -n is given
|
||||
if (destExists && destStat.isFile() && options.no_force) {
|
||||
return new common.ShellString('', '', 0);
|
||||
}
|
||||
|
||||
sources.forEach(function (src, srcIndex) {
|
||||
if (!fs.existsSync(src)) {
|
||||
if (src === '') src = "''"; // if src was empty string, display empty string
|
||||
common.error('no such file or directory: ' + src, { continue: true });
|
||||
return; // skip file
|
||||
}
|
||||
var srcStat = common.statFollowLinks(src);
|
||||
if (!options.noFollowsymlink && srcStat.isDirectory()) {
|
||||
if (!options.recursive) {
|
||||
// Non-Recursive
|
||||
common.error("omitting directory '" + src + "'", { continue: true });
|
||||
} else {
|
||||
// Recursive
|
||||
// 'cp /a/source dest' should create 'source' in 'dest'
|
||||
var newDest = (destStat && destStat.isDirectory()) ?
|
||||
path.join(dest, path.basename(src)) :
|
||||
dest;
|
||||
|
||||
try {
|
||||
common.statFollowLinks(path.dirname(dest));
|
||||
cpdirSyncRecursive(src, newDest, 0, { no_force: options.no_force, followsymlink: options.followsymlink });
|
||||
} catch (e) {
|
||||
/* istanbul ignore next */
|
||||
common.error("cannot create directory '" + dest + "': No such file or directory");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// If here, src is a file
|
||||
|
||||
// When copying to '/path/dir':
|
||||
// thisDest = '/path/dir/file1'
|
||||
var thisDest = dest;
|
||||
if (destStat && destStat.isDirectory()) {
|
||||
thisDest = path.normalize(dest + '/' + path.basename(src));
|
||||
}
|
||||
|
||||
var thisDestExists = fs.existsSync(thisDest);
|
||||
if (thisDestExists && checkRecentCreated(sources, srcIndex)) {
|
||||
// cannot overwrite file created recently in current execution, but we want to continue copying other files
|
||||
if (!options.no_force) {
|
||||
common.error("will not overwrite just-created '" + thisDest + "' with '" + src + "'", { continue: true });
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (thisDestExists && options.no_force) {
|
||||
return; // skip file
|
||||
}
|
||||
|
||||
if (path.relative(src, thisDest) === '') {
|
||||
// a file cannot be copied to itself, but we want to continue copying other files
|
||||
common.error("'" + thisDest + "' and '" + src + "' are the same file", { continue: true });
|
||||
return;
|
||||
}
|
||||
|
||||
copyFileSync(src, thisDest, options);
|
||||
}
|
||||
}); // forEach(src)
|
||||
|
||||
return new common.ShellString('', common.state.error, common.state.errorCode);
|
||||
}
|
||||
module.exports = _cp;
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={C:{"40":0.00804,"52":0.04019,"55":0.00402,"57":0.00402,"60":0.00402,"68":0.00804,"78":0.00804,"87":0.22908,"89":0.00804,"91":0.02411,"96":0.00804,"98":0.00402,"99":0.00402,"101":0.01206,"102":0.20899,"103":0.00804,"104":0.01608,"105":0.0201,"106":0.01608,"107":0.03215,"108":0.04823,"109":1.12934,"110":0.61089,_:"2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 50 51 53 54 56 58 59 61 62 63 64 65 66 67 69 70 71 72 73 74 75 76 77 79 80 81 82 83 84 85 86 88 90 92 93 94 95 97 100 111 112 3.5","3.6":0.04823},D:{"33":0.0201,"44":0.00804,"45":0.00402,"47":0.00402,"49":0.08842,"51":0.01608,"53":0.00402,"56":0.02813,"58":0.00402,"59":0.00804,"63":0.00804,"64":0.00402,"67":0.01206,"70":0.00402,"71":0.00804,"74":0.00402,"75":0.01206,"77":0.00402,"78":0.01206,"79":0.03215,"80":0.04823,"81":0.00402,"83":0.01206,"84":0.01608,"85":0.05627,"86":0.01608,"87":0.03617,"88":0.01206,"89":0.00804,"90":0.01206,"91":0.01608,"92":0.12057,"93":0.00804,"94":0.00402,"95":0.01206,"96":0.0643,"97":0.0643,"98":0.0201,"99":0.04019,"100":0.05225,"101":0.04823,"102":0.11655,"103":0.0844,"104":0.04421,"105":0.0844,"106":0.18889,"107":0.12459,"108":0.66314,"109":17.55097,"110":8.79357,"111":0.00804,"112":0.01608,_:"4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 34 35 36 37 38 39 40 41 42 43 46 48 50 52 54 55 57 60 61 62 65 66 68 69 72 73 76 113"},F:{"28":0.00402,"46":0.00804,"63":0.03617,"70":0.01206,"74":0.01206,"79":0.01608,"85":0.04421,"87":0.01608,"90":0.00402,"93":0.07234,"94":1.2901,"95":1.10924,_:"9 11 12 15 16 17 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 47 48 49 50 51 52 53 54 55 56 57 58 60 62 64 65 66 67 68 69 71 72 73 75 76 77 78 80 81 82 83 84 86 88 89 91 92 9.5-9.6 10.5 10.6 11.1 11.5 11.6 12.1","10.0-10.1":0},B:{"18":0.00402,"92":0.00804,"106":0.01206,"107":0.01206,"108":0.04421,"109":0.64304,"110":1.02886,_:"12 13 14 15 16 17 79 80 81 83 84 85 86 87 88 89 90 91 93 94 95 96 97 98 99 100 101 102 103 104 105"},E:{"4":0,"14":0.03215,"15":0.00804,_:"0 5 6 7 8 9 10 11 12 13 3.1 3.2 6.1 7.1 9.1 10.1 11.1 16.4","5.1":0.00402,"12.1":0.00804,"13.1":0.03215,"14.1":0.08038,"15.1":0.02411,"15.2-15.3":0.01608,"15.4":0.05225,"15.5":0.03215,"15.6":0.22105,"16.0":0.03617,"16.1":0.09646,"16.2":0.20497,"16.3":0.16478},G:{"8":0,"3.2":0,"4.0-4.1":0,"4.2-4.3":0,"5.0-5.1":0,"6.0-6.1":0,"7.0-7.1":0.00564,"8.1-8.4":0.00564,"9.0-9.2":0,"9.3":0.01693,"10.0-10.2":0.00141,"10.3":0.01552,"11.0-11.2":0.00564,"11.3-11.4":0.00847,"12.0-12.1":0.00847,"12.2-12.5":0.20463,"13.0-13.1":0.00564,"13.2":0.00564,"13.3":0.01129,"13.4-13.7":0.04657,"14.0-14.4":0.15664,"14.5-14.8":0.39091,"15.0-15.1":0.10725,"15.2-15.3":0.11572,"15.4":0.17076,"15.5":0.4022,"15.6":1.08946,"16.0":2.14645,"16.1":3.14982,"16.2":3.30929,"16.3":1.87268,"16.4":0.01693},P:{"4":0.11352,"20":0.78434,"5.0-5.4":0.01042,"6.2-6.4":0.01025,"7.2-7.4":0.03096,"8.2":0.02044,"9.2":0.02064,"10.1":0.0217,"11.1-11.2":0.04128,"12.0":0.02048,"13.0":0.02064,"14.0":0.02064,"15.0":0.01019,"16.0":0.0516,"17.0":0.06192,"18.0":0.08256,"19.0":1.33132},I:{"0":0,"3":0,"4":0,"2.1":0,"2.2":0,"2.3":0,"4.1":0.01123,"4.2-4.3":0.00817,"4.4":0,"4.4.3-4.4.4":0.02246},K:{_:"0 10 11 12 11.1 11.5 12.1"},A:{"8":0.04888,"9":0.00407,"10":0.00815,"11":0.24033,_:"6 7 5.5"},N:{"10":0.02102,"11":0.02035},S:{"2.5":0,_:"3.0-3.1"},J:{"7":0,"10":0},O:{"0":0.07774},H:{"0":0.2944},L:{"0":44.87278},R:{_:"0"},M:{"0":0.16744},Q:{"13.1":0}};
|
||||
@@ -0,0 +1,10 @@
|
||||
var SubscriptionLog = (function () {
|
||||
function SubscriptionLog(subscribedFrame, unsubscribedFrame) {
|
||||
if (unsubscribedFrame === void 0) { unsubscribedFrame = Infinity; }
|
||||
this.subscribedFrame = subscribedFrame;
|
||||
this.unsubscribedFrame = unsubscribedFrame;
|
||||
}
|
||||
return SubscriptionLog;
|
||||
}());
|
||||
export { SubscriptionLog };
|
||||
//# sourceMappingURL=SubscriptionLog.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"argsArgArrayOrObject.js","sourceRoot":"","sources":["../../../../src/internal/util/argsArgArrayOrObject.ts"],"names":[],"mappings":";;;AAAQ,IAAA,OAAO,GAAK,KAAK,QAAV,CAAW;AAClB,IAAA,cAAc,GAA4C,MAAM,eAAlD,EAAa,WAAW,GAAoB,MAAM,UAA1B,EAAQ,OAAO,GAAK,MAAM,KAAX,CAAY;AAQzE,SAAgB,oBAAoB,CAAiC,IAAuB;IAC1F,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;QACrB,IAAM,OAAK,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACtB,IAAI,OAAO,CAAC,OAAK,CAAC,EAAE;YAClB,OAAO,EAAE,IAAI,EAAE,OAAK,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;SACpC;QACD,IAAI,MAAM,CAAC,OAAK,CAAC,EAAE;YACjB,IAAM,IAAI,GAAG,OAAO,CAAC,OAAK,CAAC,CAAC;YAC5B,OAAO;gBACL,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,UAAC,GAAG,IAAK,OAAA,OAAK,CAAC,GAAG,CAAC,EAAV,CAAU,CAAC;gBACnC,IAAI,MAAA;aACL,CAAC;SACH;KACF;IAED,OAAO,EAAE,IAAI,EAAE,IAAW,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AAC3C,CAAC;AAhBD,oDAgBC;AAED,SAAS,MAAM,CAAC,GAAQ;IACtB,OAAO,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,cAAc,CAAC,GAAG,CAAC,KAAK,WAAW,CAAC;AAC/E,CAAC"}
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"defer.js","sourceRoot":"","sources":["../../../../src/internal/observable/defer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAkDxC,MAAM,UAAU,KAAK,CAAiC,iBAA0B;IAC9E,OAAO,IAAI,UAAU,CAAqB,UAAC,UAAU;QACnD,SAAS,CAAC,iBAAiB,EAAE,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;AACL,CAAC"}
|
||||
@@ -0,0 +1,79 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [v1.0.5](https://github.com/inspect-js/available-typed-arrays/compare/v1.0.4...v1.0.5) - 2021-08-30
|
||||
|
||||
### Fixed
|
||||
|
||||
- [Refactor] use `globalThis` if available [`#12`](https://github.com/inspect-js/available-typed-arrays/issues/12)
|
||||
|
||||
### Commits
|
||||
|
||||
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape` [`1199790`](https://github.com/inspect-js/available-typed-arrays/commit/1199790ab5841517ad04827fab3f135d2dc5cfb7)
|
||||
|
||||
## [v1.0.4](https://github.com/inspect-js/available-typed-arrays/compare/v1.0.3...v1.0.4) - 2021-05-25
|
||||
|
||||
### Commits
|
||||
|
||||
- [Refactor] Remove `array.prototype.filter` dependency [`f39c90e`](https://github.com/inspect-js/available-typed-arrays/commit/f39c90ecb1907de28ee2d3577b7da37ae12aac56)
|
||||
- [Dev Deps] update `eslint`, `auto-changelog` [`b2e3a03`](https://github.com/inspect-js/available-typed-arrays/commit/b2e3a035e8cd3ddfd7b565249e1651c6419a34d0)
|
||||
- [meta] create `FUNDING.yml` [`8c0e758`](https://github.com/inspect-js/available-typed-arrays/commit/8c0e758c6ec80adbb3770554653cdc3aa16beb55)
|
||||
- [Tests] fix harmony test matrix [`ef96549`](https://github.com/inspect-js/available-typed-arrays/commit/ef96549df171776267529413240a2219cb59d5ce)
|
||||
- [meta] add `sideEffects` flag [`288cca0`](https://github.com/inspect-js/available-typed-arrays/commit/288cca0fbd214bec706447851bb8bccc4b899a48)
|
||||
|
||||
## [v1.0.3](https://github.com/inspect-js/available-typed-arrays/compare/v1.0.2...v1.0.3) - 2021-05-19
|
||||
|
||||
### Commits
|
||||
|
||||
- [Tests] migrate tests to Github Actions [`3ef082c`](https://github.com/inspect-js/available-typed-arrays/commit/3ef082caaa153b49f4c37c85bbd5c4b13fe4f638)
|
||||
- [meta] do not publish github action workflow files [`fd95ffd`](https://github.com/inspect-js/available-typed-arrays/commit/fd95ffdaca759eca81cb4c5d5772ee863dfea501)
|
||||
- [actions] use `node/install` instead of `node/run`; use `codecov` action [`eb6bd65`](https://github.com/inspect-js/available-typed-arrays/commit/eb6bd659a31c92a6a178c71a89fe0d5261413e6c)
|
||||
- [Tests] run `nyc` on all tests [`636c946`](https://github.com/inspect-js/available-typed-arrays/commit/636c94657b532599ef90a214aaa12639d11b0161)
|
||||
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `auto-changelog`, `tape` [`70a3b61`](https://github.com/inspect-js/available-typed-arrays/commit/70a3b61367b318fb883c2f35b8f2d539849a23b6)
|
||||
- [actions] add "Allow Edits" workflow [`bd09c45`](https://github.com/inspect-js/available-typed-arrays/commit/bd09c45299e396fa5bbd5be4c58b1aedcb372a82)
|
||||
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `array.prototype.every`, `aud`, `tape` [`8f97523`](https://github.com/inspect-js/available-typed-arrays/commit/8f9752308390a79068cd431436bbfd77bca15647)
|
||||
- [readme] fix URLs [`75418e2`](https://github.com/inspect-js/available-typed-arrays/commit/75418e20b57f4ad5e65d8c2e1864efd14eaa2e65)
|
||||
- [readme] add actions and codecov badges [`4a8bc30`](https://github.com/inspect-js/available-typed-arrays/commit/4a8bc30af2ce1f48e2b28ab3db5be9589bd6f2d0)
|
||||
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud` [`65198ac`](https://github.com/inspect-js/available-typed-arrays/commit/65198ace335a013ef49b6bd722bc80bbbc6be784)
|
||||
- [actions] update workflows [`7f816eb`](https://github.com/inspect-js/available-typed-arrays/commit/7f816eb231131e53ced2572ba6c6c6a00f975789)
|
||||
- [Refactor] use `array.prototype.filter` instead of `array-filter` [`2dd1038`](https://github.com/inspect-js/available-typed-arrays/commit/2dd1038d71ce48b5650687691cf8fe09795a6d30)
|
||||
- [actions] switch Automatic Rease workflow to `pull_request_target` event [`9b45e91`](https://github.com/inspect-js/available-typed-arrays/commit/9b45e914fcb08bdaaaa0166b41716e51f400d1c6)
|
||||
- [Dev Deps] update `auto-changelog`, `tape` [`0003a5b`](https://github.com/inspect-js/available-typed-arrays/commit/0003a5b122a0724db5499c114104eeeb396b2f67)
|
||||
- [meta] use `prepublishOnly` script for npm 7+ [`d884dd1`](https://github.com/inspect-js/available-typed-arrays/commit/d884dd1c1117411f35d9fbc07f513a1a85ccdead)
|
||||
- [readme] remove travis badge [`9da2b3c`](https://github.com/inspect-js/available-typed-arrays/commit/9da2b3c29706340fada995137aba12cfae4d6f37)
|
||||
- [Dev Deps] update `auto-changelog`; add `aud` [`41b1336`](https://github.com/inspect-js/available-typed-arrays/commit/41b13369c71b0e3e57b9de0f4fb1e4d67950d74a)
|
||||
- [Tests] only audit prod deps [`2571826`](https://github.com/inspect-js/available-typed-arrays/commit/2571826a5d121eeeeccf4c711e3f9e4616685d50)
|
||||
|
||||
## [v1.0.2](https://github.com/inspect-js/available-typed-arrays/compare/v1.0.1...v1.0.2) - 2020-01-26
|
||||
|
||||
### Commits
|
||||
|
||||
- [actions] add automatic rebasing / merge commit blocking [`3229a74`](https://github.com/inspect-js/available-typed-arrays/commit/3229a74bda60f24e2257efc40ddff9a3ce98de76)
|
||||
- [Dev Deps] update `@ljharb/eslint-config` [`9579abe`](https://github.com/inspect-js/available-typed-arrays/commit/9579abecc196088561d3aedf27cad45b56f8e18b)
|
||||
- [Fix] remove `require` condition to avoid experimental warning [`2cade6b`](https://github.com/inspect-js/available-typed-arrays/commit/2cade6b56d6a508a950c7da27d038bee496e716b)
|
||||
|
||||
## [v1.0.1](https://github.com/inspect-js/available-typed-arrays/compare/v1.0.0...v1.0.1) - 2020-01-24
|
||||
|
||||
### Commits
|
||||
|
||||
- [meta] add "exports" [`5942917`](https://github.com/inspect-js/available-typed-arrays/commit/5942917aafb56c6bce80f01b7ae6a9b46bc72c69)
|
||||
|
||||
## v1.0.0 - 2020-01-24
|
||||
|
||||
### Commits
|
||||
|
||||
- Initial commit [`2bc5144`](https://github.com/inspect-js/available-typed-arrays/commit/2bc514459c9f65756adfbd9964abf433183d78f6)
|
||||
- readme [`31e4796`](https://github.com/inspect-js/available-typed-arrays/commit/31e4796379eba4a16d3c6a8e9baf6eb3f39e33d1)
|
||||
- npm init [`9194266`](https://github.com/inspect-js/available-typed-arrays/commit/9194266b471a2a2dd5e6969bc40358ceb346e21e)
|
||||
- Tests [`b539830`](https://github.com/inspect-js/available-typed-arrays/commit/b539830c3213f90de42b4d6e62803f52daf61a6d)
|
||||
- Implementation [`6577df2`](https://github.com/inspect-js/available-typed-arrays/commit/6577df244ea146ef5ec16858044c8955e0fc445c)
|
||||
- [meta] add `auto-changelog` [`7b43310`](https://github.com/inspect-js/available-typed-arrays/commit/7b43310be76f00fe60b74a2fd6d0e46ac1d01f3e)
|
||||
- [Tests] add `npm run lint` [`dedfbc1`](https://github.com/inspect-js/available-typed-arrays/commit/dedfbc1592f86ac1636267d3965f2345df43815b)
|
||||
- [Tests] use shared travis-ci configs [`c459d78`](https://github.com/inspect-js/available-typed-arrays/commit/c459d78bf2efa9d777f88599ae71a796dbfcb70f)
|
||||
- Only apps should have lockfiles [`d294668`](https://github.com/inspect-js/available-typed-arrays/commit/d294668422cf35f5e7716a85bfd204e62b01c056)
|
||||
- [meta] add `funding` field [`6e70bc1`](https://github.com/inspect-js/available-typed-arrays/commit/6e70bc1fb199c7898165aaf05c25bb49f4062e53)
|
||||
- [meta] add `safe-publish-latest` [`dd89ca2`](https://github.com/inspect-js/available-typed-arrays/commit/dd89ca2c6842f0f3e82958df2b2bd0fc0c929c51)
|
||||
@@ -0,0 +1,24 @@
|
||||
'use strict';
|
||||
|
||||
// https://262.ecma-international.org/5.1/#sec-8
|
||||
|
||||
module.exports = function Type(x) {
|
||||
if (x === null) {
|
||||
return 'Null';
|
||||
}
|
||||
if (typeof x === 'undefined') {
|
||||
return 'Undefined';
|
||||
}
|
||||
if (typeof x === 'function' || typeof x === 'object') {
|
||||
return 'Object';
|
||||
}
|
||||
if (typeof x === 'number') {
|
||||
return 'Number';
|
||||
}
|
||||
if (typeof x === 'boolean') {
|
||||
return 'Boolean';
|
||||
}
|
||||
if (typeof x === 'string') {
|
||||
return 'String';
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
import { EnsureBaseOptions, EnsureIsOptional, EnsureDefault } from '../ensure';
|
||||
|
||||
declare function ensureBigInt(value: any, options?: EnsureBaseOptions): bigint;
|
||||
declare function ensureBigInt(value: any, options?: EnsureBaseOptions & EnsureIsOptional): bigint | null;
|
||||
declare function ensureBigInt(value: any, options?: EnsureBaseOptions & EnsureIsOptional & EnsureDefault<bigint>): bigint;
|
||||
|
||||
export default ensureBigInt;
|
||||
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
module.exports = require("./is-implemented")() ? Math.cbrt : require("./shim");
|
||||
@@ -0,0 +1,48 @@
|
||||
export const completionShTemplate = `###-begin-{{app_name}}-completions-###
|
||||
#
|
||||
# yargs command completion script
|
||||
#
|
||||
# Installation: {{app_path}} {{completion_command}} >> ~/.bashrc
|
||||
# or {{app_path}} {{completion_command}} >> ~/.bash_profile on OSX.
|
||||
#
|
||||
_{{app_name}}_yargs_completions()
|
||||
{
|
||||
local cur_word args type_list
|
||||
|
||||
cur_word="\${COMP_WORDS[COMP_CWORD]}"
|
||||
args=("\${COMP_WORDS[@]}")
|
||||
|
||||
# ask yargs to generate completions.
|
||||
type_list=$({{app_path}} --get-yargs-completions "\${args[@]}")
|
||||
|
||||
COMPREPLY=( $(compgen -W "\${type_list}" -- \${cur_word}) )
|
||||
|
||||
# if no match was found, fall back to filename completion
|
||||
if [ \${#COMPREPLY[@]} -eq 0 ]; then
|
||||
COMPREPLY=()
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
complete -o bashdefault -o default -F _{{app_name}}_yargs_completions {{app_name}}
|
||||
###-end-{{app_name}}-completions-###
|
||||
`;
|
||||
export const completionZshTemplate = `#compdef {{app_name}}
|
||||
###-begin-{{app_name}}-completions-###
|
||||
#
|
||||
# yargs command completion script
|
||||
#
|
||||
# Installation: {{app_path}} {{completion_command}} >> ~/.zshrc
|
||||
# or {{app_path}} {{completion_command}} >> ~/.zprofile on OSX.
|
||||
#
|
||||
_{{app_name}}_yargs_completions()
|
||||
{
|
||||
local reply
|
||||
local si=$IFS
|
||||
IFS=$'\n' reply=($(COMP_CWORD="$((CURRENT-1))" COMP_LINE="$BUFFER" COMP_POINT="$CURSOR" {{app_path}} --get-yargs-completions "\${words[@]}"))
|
||||
IFS=$si
|
||||
_describe 'values' reply
|
||||
}
|
||||
compdef _{{app_name}}_yargs_completions {{app_name}}
|
||||
###-end-{{app_name}}-completions-###
|
||||
`;
|
||||
@@ -0,0 +1,144 @@
|
||||
let Browsers = require('./browsers')
|
||||
let vendor = require('./vendor')
|
||||
let utils = require('./utils')
|
||||
|
||||
/**
|
||||
* Recursively clone objects
|
||||
*/
|
||||
function clone(obj, parent) {
|
||||
let cloned = new obj.constructor()
|
||||
|
||||
for (let i of Object.keys(obj || {})) {
|
||||
let value = obj[i]
|
||||
if (i === 'parent' && typeof value === 'object') {
|
||||
if (parent) {
|
||||
cloned[i] = parent
|
||||
}
|
||||
} else if (i === 'source' || i === null) {
|
||||
cloned[i] = value
|
||||
} else if (Array.isArray(value)) {
|
||||
cloned[i] = value.map(x => clone(x, cloned))
|
||||
} else if (
|
||||
i !== '_autoprefixerPrefix' &&
|
||||
i !== '_autoprefixerValues' &&
|
||||
i !== 'proxyCache'
|
||||
) {
|
||||
if (typeof value === 'object' && value !== null) {
|
||||
value = clone(value, cloned)
|
||||
}
|
||||
cloned[i] = value
|
||||
}
|
||||
}
|
||||
|
||||
return cloned
|
||||
}
|
||||
|
||||
class Prefixer {
|
||||
/**
|
||||
* Add hack to selected names
|
||||
*/
|
||||
static hack(klass) {
|
||||
if (!this.hacks) {
|
||||
this.hacks = {}
|
||||
}
|
||||
return klass.names.map(name => {
|
||||
this.hacks[name] = klass
|
||||
return this.hacks[name]
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Load hacks for some names
|
||||
*/
|
||||
static load(name, prefixes, all) {
|
||||
let Klass = this.hacks && this.hacks[name]
|
||||
if (Klass) {
|
||||
return new Klass(name, prefixes, all)
|
||||
} else {
|
||||
return new this(name, prefixes, all)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone node and clean autprefixer custom caches
|
||||
*/
|
||||
static clone(node, overrides) {
|
||||
let cloned = clone(node)
|
||||
for (let name in overrides) {
|
||||
cloned[name] = overrides[name]
|
||||
}
|
||||
return cloned
|
||||
}
|
||||
|
||||
constructor(name, prefixes, all) {
|
||||
this.prefixes = prefixes
|
||||
this.name = name
|
||||
this.all = all
|
||||
}
|
||||
|
||||
/**
|
||||
* Find prefix in node parents
|
||||
*/
|
||||
parentPrefix(node) {
|
||||
let prefix
|
||||
|
||||
if (typeof node._autoprefixerPrefix !== 'undefined') {
|
||||
prefix = node._autoprefixerPrefix
|
||||
} else if (node.type === 'decl' && node.prop[0] === '-') {
|
||||
prefix = vendor.prefix(node.prop)
|
||||
} else if (node.type === 'root') {
|
||||
prefix = false
|
||||
} else if (
|
||||
node.type === 'rule' &&
|
||||
node.selector.includes(':-') &&
|
||||
/:(-\w+-)/.test(node.selector)
|
||||
) {
|
||||
prefix = node.selector.match(/:(-\w+-)/)[1]
|
||||
} else if (node.type === 'atrule' && node.name[0] === '-') {
|
||||
prefix = vendor.prefix(node.name)
|
||||
} else {
|
||||
prefix = this.parentPrefix(node.parent)
|
||||
}
|
||||
|
||||
if (!Browsers.prefixes().includes(prefix)) {
|
||||
prefix = false
|
||||
}
|
||||
|
||||
node._autoprefixerPrefix = prefix
|
||||
|
||||
return node._autoprefixerPrefix
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone node with prefixes
|
||||
*/
|
||||
process(node, result) {
|
||||
if (!this.check(node)) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
let parent = this.parentPrefix(node)
|
||||
|
||||
let prefixes = this.prefixes.filter(
|
||||
prefix => !parent || parent === utils.removeNote(prefix)
|
||||
)
|
||||
|
||||
let added = []
|
||||
for (let prefix of prefixes) {
|
||||
if (this.add(node, prefix, added.concat([prefix]), result)) {
|
||||
added.push(prefix)
|
||||
}
|
||||
}
|
||||
|
||||
return added
|
||||
}
|
||||
|
||||
/**
|
||||
* Shortcut for Prefixer.clone
|
||||
*/
|
||||
clone(node, overrides) {
|
||||
return Prefixer.clone(node, overrides)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Prefixer
|
||||
@@ -0,0 +1,20 @@
|
||||
import { identity } from './identity';
|
||||
export function pipe() {
|
||||
var fns = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
fns[_i] = arguments[_i];
|
||||
}
|
||||
return pipeFromArray(fns);
|
||||
}
|
||||
export function pipeFromArray(fns) {
|
||||
if (fns.length === 0) {
|
||||
return identity;
|
||||
}
|
||||
if (fns.length === 1) {
|
||||
return fns[0];
|
||||
}
|
||||
return function piped(input) {
|
||||
return fns.reduce(function (prev, fn) { return fn(prev); }, input);
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=pipe.js.map
|
||||
@@ -0,0 +1,25 @@
|
||||
'use strict'
|
||||
|
||||
const path = require('path')
|
||||
|
||||
// get drive on windows
|
||||
function getRootPath (p) {
|
||||
p = path.normalize(path.resolve(p)).split(path.sep)
|
||||
if (p.length > 0) return p[0]
|
||||
return null
|
||||
}
|
||||
|
||||
// http://stackoverflow.com/a/62888/10333 contains more accurate
|
||||
// TODO: expand to include the rest
|
||||
const INVALID_PATH_CHARS = /[<>:"|?*]/
|
||||
|
||||
function invalidWin32Path (p) {
|
||||
const rp = getRootPath(p)
|
||||
p = p.replace(rp, '')
|
||||
return INVALID_PATH_CHARS.test(p)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getRootPath,
|
||||
invalidWin32Path
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import { ObservableInputTuple, OperatorFunction, SchedulerLike } from '../types';
|
||||
/** @deprecated Replaced with {@link concatWith}. Will be removed in v8. */
|
||||
export declare function concat<T, A extends readonly unknown[]>(...sources: [...ObservableInputTuple<A>]): OperatorFunction<T, T | A[number]>;
|
||||
/** @deprecated Replaced with {@link concatWith}. Will be removed in v8. */
|
||||
export declare function concat<T, A extends readonly unknown[]>(...sourcesAndScheduler: [...ObservableInputTuple<A>, SchedulerLike]): OperatorFunction<T, T | A[number]>;
|
||||
//# sourceMappingURL=concat.d.ts.map
|
||||
@@ -0,0 +1,55 @@
|
||||
import { Action } from './scheduler/Action';
|
||||
import { Subscription } from './Subscription';
|
||||
import { SchedulerLike, SchedulerAction } from './types';
|
||||
/**
|
||||
* An execution context and a data structure to order tasks and schedule their
|
||||
* execution. Provides a notion of (potentially virtual) time, through the
|
||||
* `now()` getter method.
|
||||
*
|
||||
* Each unit of work in a Scheduler is called an `Action`.
|
||||
*
|
||||
* ```ts
|
||||
* class Scheduler {
|
||||
* now(): number;
|
||||
* schedule(work, delay?, state?): Subscription;
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @class Scheduler
|
||||
* @deprecated Scheduler is an internal implementation detail of RxJS, and
|
||||
* should not be used directly. Rather, create your own class and implement
|
||||
* {@link SchedulerLike}. Will be made internal in v8.
|
||||
*/
|
||||
export declare class Scheduler implements SchedulerLike {
|
||||
private schedulerActionCtor;
|
||||
static now: () => number;
|
||||
constructor(schedulerActionCtor: typeof Action, now?: () => number);
|
||||
/**
|
||||
* A getter method that returns a number representing the current time
|
||||
* (at the time this function was called) according to the scheduler's own
|
||||
* internal clock.
|
||||
* @return {number} A number that represents the current time. May or may not
|
||||
* have a relation to wall-clock time. May or may not refer to a time unit
|
||||
* (e.g. milliseconds).
|
||||
*/
|
||||
now: () => number;
|
||||
/**
|
||||
* Schedules a function, `work`, for execution. May happen at some point in
|
||||
* the future, according to the `delay` parameter, if specified. May be passed
|
||||
* some context object, `state`, which will be passed to the `work` function.
|
||||
*
|
||||
* The given arguments will be processed an stored as an Action object in a
|
||||
* queue of actions.
|
||||
*
|
||||
* @param {function(state: ?T): ?Subscription} work A function representing a
|
||||
* task, or some unit of work to be executed by the Scheduler.
|
||||
* @param {number} [delay] Time to wait before executing the work, where the
|
||||
* time unit is implicit and defined by the Scheduler itself.
|
||||
* @param {T} [state] Some contextual data that the `work` function uses when
|
||||
* called by the Scheduler.
|
||||
* @return {Subscription} A subscription in order to be able to unsubscribe
|
||||
* the scheduled work.
|
||||
*/
|
||||
schedule<T>(work: (this: SchedulerAction<T>, state?: T) => void, delay?: number, state?: T): Subscription;
|
||||
}
|
||||
//# sourceMappingURL=Scheduler.d.ts.map
|
||||
@@ -0,0 +1,17 @@
|
||||
import process from 'node:process';
|
||||
|
||||
export default function isUnicodeSupported() {
|
||||
if (process.platform !== 'win32') {
|
||||
return process.env.TERM !== 'linux'; // Linux console (kernel)
|
||||
}
|
||||
|
||||
return Boolean(process.env.CI)
|
||||
|| Boolean(process.env.WT_SESSION) // Windows Terminal
|
||||
|| Boolean(process.env.TERMINUS_SUBLIME) // Terminus (<0.2.27)
|
||||
|| process.env.ConEmuTask === '{cmd::Cmder}' // ConEmu and cmder
|
||||
|| process.env.TERM_PROGRAM === 'Terminus-Sublime'
|
||||
|| process.env.TERM_PROGRAM === 'vscode'
|
||||
|| process.env.TERM === 'xterm-256color'
|
||||
|| process.env.TERM === 'alacritty'
|
||||
|| process.env.TERMINAL_EMULATOR === 'JetBrains-JediTerm';
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import packageJson from 'package-json';
|
||||
|
||||
export default async function latestVersion(packageName, options) {
|
||||
const {version} = await packageJson(packageName.toLowerCase(), options);
|
||||
return version;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "default", {
|
||||
enumerable: true,
|
||||
get: ()=>escapeClassName
|
||||
});
|
||||
const _postcssSelectorParser = /*#__PURE__*/ _interopRequireDefault(require("postcss-selector-parser"));
|
||||
const _escapeCommas = /*#__PURE__*/ _interopRequireDefault(require("./escapeCommas"));
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
function escapeClassName(className) {
|
||||
var _node_raws;
|
||||
let node = _postcssSelectorParser.default.className();
|
||||
node.value = className;
|
||||
var _node_raws_value;
|
||||
return (0, _escapeCommas.default)((_node_raws_value = node === null || node === void 0 ? void 0 : (_node_raws = node.raws) === null || _node_raws === void 0 ? void 0 : _node_raws.value) !== null && _node_raws_value !== void 0 ? _node_raws_value : node.value);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"root": true,
|
||||
|
||||
"extends": "@ljharb",
|
||||
|
||||
"rules": {
|
||||
"id-length": 0,
|
||||
"strict": 0,
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
module.exports = require('./lodash');
|
||||
@@ -0,0 +1,14 @@
|
||||
export class Deprecation extends Error {
|
||||
constructor(message) {
|
||||
super(message); // Maintains proper stack trace (only available on V8)
|
||||
|
||||
/* istanbul ignore next */
|
||||
|
||||
if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(this, this.constructor);
|
||||
}
|
||||
|
||||
this.name = 'Deprecation';
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"empty.d.ts","sourceRoot":"","sources":["../../../../src/internal/observable/empty.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AACH,eAAO,MAAM,KAAK,mBAA+D,CAAC;AAElF;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,SAAS,CAAC,EAAE,aAAa,qBAE9C"}
|
||||
@@ -0,0 +1 @@
|
||||
{"name":"normalize-path","version":"3.0.0","files":{"LICENSE":{"checkedAt":1678883670920,"integrity":"sha512-n8vl3Ia8M7208SVVnnZ8OqrZTHxLIbgLaU2bAVjuDxDuU7Enwr8F25dor9rx+2d4/QihlBL7PBra1lWGPmw1HQ==","mode":420,"size":1088},"package.json":{"checkedAt":1678883672874,"integrity":"sha512-u3l/gCnqSSxolOXztDsiCQ0JD0nfAIyCzBD0rAf8dX7zY+JuWDK4xAm5VbN4DbNNZ1X9uCBaM+GvB9zuGaHRFg==","mode":420,"size":1666},"index.js":{"checkedAt":1678883672874,"integrity":"sha512-nvPxxpQLrswH9LSh4BxBj59nStOL0I94QgLGq53a5VJlLO9mGtjucrY2w2aTDdEH/XU6/i/bYy3Z/0noZk3yLQ==","mode":420,"size":1024},"README.md":{"checkedAt":1678883672874,"integrity":"sha512-TyoL2GoalOb+M6GLtMLPby2BmpF1F07F6YFYyS4CHTPZcpozAWUQrYNeAHOFmEt7soitPZ3TJnA1JQbkIVyGhA==","mode":420,"size":5441}}}
|
||||
@@ -0,0 +1,164 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var bluebird_1 = __importDefault(require("bluebird"));
|
||||
var os_1 = require("os");
|
||||
var Result = /** @class */ (function () {
|
||||
function Result(converter) {
|
||||
this.converter = converter;
|
||||
this.finalResult = [];
|
||||
}
|
||||
Object.defineProperty(Result.prototype, "needEmitLine", {
|
||||
get: function () {
|
||||
return !!this.converter.parseRuntime.subscribe && !!this.converter.parseRuntime.subscribe.onNext || this.needPushDownstream;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(Result.prototype, "needPushDownstream", {
|
||||
get: function () {
|
||||
if (this._needPushDownstream === undefined) {
|
||||
this._needPushDownstream = this.converter.listeners("data").length > 0 || this.converter.listeners("readable").length > 0;
|
||||
}
|
||||
return this._needPushDownstream;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(Result.prototype, "needEmitAll", {
|
||||
get: function () {
|
||||
return !!this.converter.parseRuntime.then && this.converter.parseParam.needEmitAll;
|
||||
// return !!this.converter.parseRuntime.then;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Result.prototype.processResult = function (resultLines) {
|
||||
var _this = this;
|
||||
var startPos = this.converter.parseRuntime.parsedLineNumber;
|
||||
if (this.needPushDownstream && this.converter.parseParam.downstreamFormat === "array") {
|
||||
if (startPos === 0) {
|
||||
pushDownstream(this.converter, "[" + os_1.EOL);
|
||||
}
|
||||
}
|
||||
// let prom: P<any>;
|
||||
return new bluebird_1.default(function (resolve, reject) {
|
||||
if (_this.needEmitLine) {
|
||||
processLineByLine(resultLines, _this.converter, 0, _this.needPushDownstream, function (err) {
|
||||
if (err) {
|
||||
reject(err);
|
||||
}
|
||||
else {
|
||||
_this.appendFinalResult(resultLines);
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
// resolve();
|
||||
}
|
||||
else {
|
||||
_this.appendFinalResult(resultLines);
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
};
|
||||
Result.prototype.appendFinalResult = function (lines) {
|
||||
if (this.needEmitAll) {
|
||||
this.finalResult = this.finalResult.concat(lines);
|
||||
}
|
||||
this.converter.parseRuntime.parsedLineNumber += lines.length;
|
||||
};
|
||||
Result.prototype.processError = function (err) {
|
||||
if (this.converter.parseRuntime.subscribe && this.converter.parseRuntime.subscribe.onError) {
|
||||
this.converter.parseRuntime.subscribe.onError(err);
|
||||
}
|
||||
if (this.converter.parseRuntime.then && this.converter.parseRuntime.then.onrejected) {
|
||||
this.converter.parseRuntime.then.onrejected(err);
|
||||
}
|
||||
};
|
||||
Result.prototype.endProcess = function () {
|
||||
if (this.converter.parseRuntime.then && this.converter.parseRuntime.then.onfulfilled) {
|
||||
if (this.needEmitAll) {
|
||||
this.converter.parseRuntime.then.onfulfilled(this.finalResult);
|
||||
}
|
||||
else {
|
||||
this.converter.parseRuntime.then.onfulfilled([]);
|
||||
}
|
||||
}
|
||||
if (this.converter.parseRuntime.subscribe && this.converter.parseRuntime.subscribe.onCompleted) {
|
||||
this.converter.parseRuntime.subscribe.onCompleted();
|
||||
}
|
||||
if (this.needPushDownstream && this.converter.parseParam.downstreamFormat === "array") {
|
||||
pushDownstream(this.converter, "]" + os_1.EOL);
|
||||
}
|
||||
};
|
||||
return Result;
|
||||
}());
|
||||
exports.Result = Result;
|
||||
function processLineByLine(lines, conv, offset, needPushDownstream, cb) {
|
||||
if (offset >= lines.length) {
|
||||
cb();
|
||||
}
|
||||
else {
|
||||
if (conv.parseRuntime.subscribe && conv.parseRuntime.subscribe.onNext) {
|
||||
var hook_1 = conv.parseRuntime.subscribe.onNext;
|
||||
var nextLine_1 = lines[offset];
|
||||
var res = hook_1(nextLine_1, conv.parseRuntime.parsedLineNumber + offset);
|
||||
offset++;
|
||||
// if (isAsync === undefined) {
|
||||
if (res && res.then) {
|
||||
res.then(function () {
|
||||
processRecursive(lines, hook_1, conv, offset, needPushDownstream, cb, nextLine_1);
|
||||
}, cb);
|
||||
}
|
||||
else {
|
||||
// processRecursive(lines, hook, conv, offset, needPushDownstream, cb, nextLine, false);
|
||||
if (needPushDownstream) {
|
||||
pushDownstream(conv, nextLine_1);
|
||||
}
|
||||
while (offset < lines.length) {
|
||||
var line = lines[offset];
|
||||
hook_1(line, conv.parseRuntime.parsedLineNumber + offset);
|
||||
offset++;
|
||||
if (needPushDownstream) {
|
||||
pushDownstream(conv, line);
|
||||
}
|
||||
}
|
||||
cb();
|
||||
}
|
||||
// } else if (isAsync === true) {
|
||||
// (res as PromiseLike<void>).then(function () {
|
||||
// processRecursive(lines, hook, conv, offset, needPushDownstream, cb, nextLine, true);
|
||||
// }, cb);
|
||||
// } else if (isAsync === false) {
|
||||
// processRecursive(lines, hook, conv, offset, needPushDownstream, cb, nextLine, false);
|
||||
// }
|
||||
}
|
||||
else {
|
||||
if (needPushDownstream) {
|
||||
while (offset < lines.length) {
|
||||
var line = lines[offset++];
|
||||
pushDownstream(conv, line);
|
||||
}
|
||||
}
|
||||
cb();
|
||||
}
|
||||
}
|
||||
}
|
||||
function processRecursive(lines, hook, conv, offset, needPushDownstream, cb, res) {
|
||||
if (needPushDownstream) {
|
||||
pushDownstream(conv, res);
|
||||
}
|
||||
processLineByLine(lines, conv, offset, needPushDownstream, cb);
|
||||
}
|
||||
function pushDownstream(conv, res) {
|
||||
if (typeof res === "object" && !conv.options.objectMode) {
|
||||
var data = JSON.stringify(res);
|
||||
conv.push(data + (conv.parseParam.downstreamFormat === "array" ? "," + os_1.EOL : os_1.EOL), "utf8");
|
||||
}
|
||||
else {
|
||||
conv.push(res);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=Result.js.map
|
||||
@@ -0,0 +1,61 @@
|
||||
{
|
||||
"name": "open",
|
||||
"version": "8.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": ">=12"
|
||||
},
|
||||
"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": {
|
||||
"define-lazy-prop": "^2.0.0",
|
||||
"is-docker": "^2.1.1",
|
||||
"is-wsl": "^2.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^15.0.0",
|
||||
"ava": "^3.15.0",
|
||||
"tsd": "^0.14.0",
|
||||
"xo": "^0.39.1"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
export declare function scrypt(password: string, salt: string): Uint8Array;
|
||||
export declare function pbkdf2(password: string, salt: string): Uint8Array;
|
||||
/**
|
||||
* Derives main seed. Takes a lot of time. Prefer `eskdf` method instead.
|
||||
*/
|
||||
export declare function deriveMainSeed(username: string, password: string): Uint8Array;
|
||||
declare type AccountID = number | string;
|
||||
declare type OptsLength = {
|
||||
keyLength: number;
|
||||
};
|
||||
declare type OptsMod = {
|
||||
modulus: bigint;
|
||||
};
|
||||
declare type KeyOpts = undefined | OptsLength | OptsMod;
|
||||
declare type ESKDF = Promise<Readonly<{
|
||||
/**
|
||||
* Derives a child key. Child key will not be associated with any
|
||||
* other child key because of properties of underlying KDF.
|
||||
*
|
||||
* @param protocol - 3-15 character protocol name
|
||||
* @param accountId - numeric identifier of account
|
||||
* @param options - `keyLength: 64` or `modulus: 41920438n`
|
||||
* @example deriveChildKey('aes', 0)
|
||||
*/
|
||||
deriveChildKey: (protocol: string, accountId: AccountID, options?: KeyOpts) => Uint8Array;
|
||||
/**
|
||||
* Deletes the main seed from eskdf instance
|
||||
*/
|
||||
expire: () => void;
|
||||
/**
|
||||
* Account fingerprint
|
||||
*/
|
||||
fingerprint: string;
|
||||
}>>;
|
||||
/**
|
||||
* ESKDF
|
||||
* @param username - username, email, or identifier, min: 8 characters, should have enough entropy
|
||||
* @param password - password, min: 8 characters, should have enough entropy
|
||||
* @example
|
||||
* const kdf = await eskdf('example-university', 'beginning-new-example');
|
||||
* const key = kdf.deriveChildKey('aes', 0);
|
||||
* console.log(kdf.fingerprint);
|
||||
* kdf.expire();
|
||||
*/
|
||||
export declare function eskdf(username: string, password: string): ESKDF;
|
||||
export {};
|
||||
Reference in New Issue
Block a user