mirror of
https://github.com/robonen/tools.git
synced 2026-03-20 10:54:44 +00:00
feat(repo): cli tool, base tscofig
This commit is contained in:
47
node_modules/.pnpm/consola@3.2.3/node_modules/consola/LICENSE
generated
vendored
Normal file
47
node_modules/.pnpm/consola@3.2.3/node_modules/consola/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Pooya Parsa <pooya@pi0.io>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
---
|
||||
|
||||
Prompt support is based on https://github.com/natemoo-re/clack
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (c) Nate Moore
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
---
|
||||
|
||||
Color support is based on https://github.com/jorgebucaran/colorette
|
||||
|
||||
Copyright © Jorge Bucaran <https://jorgebucaran.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
318
node_modules/.pnpm/consola@3.2.3/node_modules/consola/README.md
generated
vendored
Normal file
318
node_modules/.pnpm/consola@3.2.3/node_modules/consola/README.md
generated
vendored
Normal file
@@ -0,0 +1,318 @@
|
||||
# 🐨 Consola
|
||||
|
||||
> Elegant Console Wrapper
|
||||
|
||||
[![npm version][npm-version-src]][npm-version-href]
|
||||
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
||||
[![bundle][bundle-src]][bundle-href]
|
||||
|
||||
<!-- [![Codecov][codecov-src]][codecov-href] -->
|
||||
|
||||
## Why Consola?
|
||||
|
||||
👌 Easy to use<br>
|
||||
💅 Fancy output with fallback for minimal environments<br>
|
||||
🔌 Pluggable reporters<br>
|
||||
💻 Consistent command line interface (CLI) experience<br>
|
||||
🏷 Tag support<br>
|
||||
🚏 Redirect `console` and `stdout/stderr` to consola and easily restore redirect.<br>
|
||||
🌐 Browser support<br>
|
||||
⏯ Pause/Resume support<br>
|
||||
👻 Mocking support<br>
|
||||
👮♂️ Spam prevention by throttling logs<br>
|
||||
❯ Interactive prompt support powered by [`clack`](https://github.com/natemoo-re/clack)<br>
|
||||
|
||||
## Installation
|
||||
|
||||
Using npm:
|
||||
|
||||
```bash
|
||||
npm i consola
|
||||
```
|
||||
|
||||
Using yarn:
|
||||
|
||||
```bash
|
||||
yarn add consola
|
||||
```
|
||||
|
||||
Using pnpm:
|
||||
|
||||
```bash
|
||||
pnpm i consola
|
||||
```
|
||||
|
||||
## Getting Started
|
||||
|
||||
```js
|
||||
// ESM
|
||||
import { consola, createConsola } from "consola";
|
||||
|
||||
// CommonJS
|
||||
const { consola, createConsola } = require("consola");
|
||||
|
||||
consola.info("Using consola 3.0.0");
|
||||
consola.start("Building project...");
|
||||
consola.warn("A new version of consola is available: 3.0.1");
|
||||
consola.success("Project built!");
|
||||
consola.error(new Error("This is an example error. Everything is fine!"));
|
||||
consola.box("I am a simple box");
|
||||
await consola.prompt("Deploy to the production?", {
|
||||
type: "confirm",
|
||||
});
|
||||
```
|
||||
|
||||
Will display in the terminal:
|
||||
|
||||
<img width="760" alt="image" src="https://user-images.githubusercontent.com/5158436/231029244-abc79f48-ca16-4eaa-b592-7abd271ecb1f.png">
|
||||
|
||||
You can use smaller core builds without fancy reporter to save 80% of the bundle size:
|
||||
|
||||
```ts
|
||||
import { consola, createConsola } from "consola/basic";
|
||||
import { consola, createConsola } from "consola/browser";
|
||||
import { createConsola } from "consola/core";
|
||||
```
|
||||
|
||||
## Consola Methods
|
||||
|
||||
#### `<type>(logObject)` `<type>(args...)`
|
||||
|
||||
Log to all reporters.
|
||||
|
||||
Example: `consola.info('Message')`
|
||||
|
||||
#### `await prompt(message, { type })`
|
||||
|
||||
Show an input prompt. Type can either of `text`, `confirm`, `select` or `multiselect`.
|
||||
|
||||
See [examples/prompt.ts](./examples/prompt.ts) for usage examples.
|
||||
|
||||
#### `addReporter(reporter)`
|
||||
|
||||
- Aliases: `add`
|
||||
|
||||
Register a custom reporter instance.
|
||||
|
||||
#### `removeReporter(reporter?)`
|
||||
|
||||
- Aliases: `remove`, `clear`
|
||||
|
||||
Remove a registered reporter.
|
||||
|
||||
If no arguments are passed all reporters will be removed.
|
||||
|
||||
#### `setReporters(reporter|reporter[])`
|
||||
|
||||
Replace all reporters.
|
||||
|
||||
#### `create(options)`
|
||||
|
||||
Create a new `Consola` instance and inherit all parent options for defaults.
|
||||
|
||||
#### `withDefaults(defaults)`
|
||||
|
||||
Create a new `Consola` instance with provided defaults
|
||||
|
||||
#### `withTag(tag)`
|
||||
|
||||
- Aliases: `withScope`
|
||||
|
||||
Create a new `Consola` instance with that tag.
|
||||
|
||||
#### `wrapConsole()` `restoreConsole()`
|
||||
|
||||
Globally redirect all `console.log`, etc calls to consola handlers.
|
||||
|
||||
#### `wrapStd()` `restoreStd()`
|
||||
|
||||
Globally redirect all stdout/stderr outputs to consola.
|
||||
|
||||
#### `wrapAll()` `restoreAll()`
|
||||
|
||||
Wrap both, std and console.
|
||||
|
||||
console uses std in the underlying so calling `wrapStd` redirects console too.
|
||||
Benefit of this function is that things like `console.info` will be correctly redirected to the corresponding type.
|
||||
|
||||
#### `pauseLogs()` `resumeLogs()`
|
||||
|
||||
- Aliases: `pause`/`resume`
|
||||
|
||||
**Globally** pause and resume logs.
|
||||
|
||||
Consola will enqueue all logs when paused and then sends them to the reported when resumed.
|
||||
|
||||
#### `mockTypes`
|
||||
|
||||
- Aliases: `mock`
|
||||
|
||||
Mock all types. Useful for using with tests.
|
||||
|
||||
The first argument passed to `mockTypes` should be a callback function accepting `(typeName, type)` and returning the mocked value:
|
||||
|
||||
```js
|
||||
consola.mockTypes((typeName, type) => jest.fn());
|
||||
```
|
||||
|
||||
Please note that with the example above, everything is mocked independently for each type. If you need one mocked fn create it outside:
|
||||
|
||||
```js
|
||||
const fn = jest.fn();
|
||||
consola.mockTypes(() => fn);
|
||||
```
|
||||
|
||||
If callback function returns a _falsy_ value, that type won't be mocked.
|
||||
|
||||
For example if you just need to mock `consola.fatal`:
|
||||
|
||||
```js
|
||||
consola.mockTypes((typeName) => typeName === "fatal" && jest.fn());
|
||||
```
|
||||
|
||||
**NOTE:** Any instance of consola that inherits the mocked instance, will apply provided callback again.
|
||||
This way, mocking works for `withTag` scoped loggers without need to extra efforts.
|
||||
|
||||
## Custom Reporters
|
||||
|
||||
Consola ships with 3 built-in reporters out of the box. A fancy colored reporter by default and fallsback to a basic reporter if running in a testing or CI environment detected using [unjs/std-env](https://github.com/unjs/std-env) and a basic browser reporter.
|
||||
|
||||
You can create a new reporter object that implements `{ log(logObject): () => { } }` interface.
|
||||
|
||||
**Example:** Simple JSON reporter
|
||||
|
||||
```ts
|
||||
import { createConsola } from "consola";
|
||||
|
||||
const consola = createConsola({
|
||||
reporters: [
|
||||
{
|
||||
log: (logObj) => {
|
||||
console.log(JSON.stringify(logObj));
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
// Prints {"date":"2023-04-18T12:43:38.693Z","args":["foo bar"],"type":"log","level":2,"tag":""}
|
||||
consola.log("foo bar");
|
||||
```
|
||||
|
||||
## Log Level
|
||||
|
||||
Consola only shows logs with configured log level or below. (Default is `3`)
|
||||
|
||||
Available log levels:
|
||||
|
||||
- `0`: Fatal and Error
|
||||
- `1`: Warnings
|
||||
- `2`: Normal logs
|
||||
- `3`: Informational logs, success, fail, ready, start, ...
|
||||
- `4`: Debug logs
|
||||
- `5`: Trace logs
|
||||
- `-999`: Silent
|
||||
- `+999`: Verbose logs
|
||||
|
||||
You can set the log level by either:
|
||||
|
||||
- Passing `level` option to `createConsola`
|
||||
- Setting `consola.level` on instance
|
||||
- Using the `CONSOLA_LEVEL` environment variable (not supported for browser and core builds).
|
||||
|
||||
## Log Types
|
||||
|
||||
Log types are exposed as `consola.[type](...)` and each is a preset of styles and log level.
|
||||
|
||||
A list of all available built-in types is [available here](./src/constants.ts).
|
||||
|
||||
## Creating a new instance
|
||||
|
||||
Consola has a global instance and is recommended to use everywhere.
|
||||
In case more control is needed, create a new instance.
|
||||
|
||||
```js
|
||||
import { createConsola } from "consola";
|
||||
|
||||
const logger = createConsola({
|
||||
// level: 4,
|
||||
// fancy: true | false
|
||||
// formatOptions: {
|
||||
// columns: 80,
|
||||
// colors: false,
|
||||
// compact: false,
|
||||
// date: false,
|
||||
// },
|
||||
});
|
||||
```
|
||||
|
||||
## Integrations
|
||||
|
||||
### With jest or vitest
|
||||
|
||||
```js
|
||||
describe("your-consola-mock-test", () => {
|
||||
beforeAll(() => {
|
||||
// Redirect std and console to consola too
|
||||
// Calling this once is sufficient
|
||||
consola.wrapAll();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
// Re-mock consola before each test call to remove
|
||||
// calls from before
|
||||
consola.mockTypes(() => jest.fn());
|
||||
});
|
||||
|
||||
test("your test", async () => {
|
||||
// Some code here
|
||||
|
||||
// Let's retrieve all messages of `consola.log`
|
||||
// Get the mock and map all calls to their first argument
|
||||
const consolaMessages = consola.log.mock.calls.map((c) => c[0]);
|
||||
expect(consolaMessages).toContain("your message");
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
### With jsdom
|
||||
|
||||
```js
|
||||
{
|
||||
virtualConsole: new jsdom.VirtualConsole().sendTo(consola);
|
||||
}
|
||||
```
|
||||
|
||||
## Console Utils
|
||||
|
||||
```ts
|
||||
// ESM
|
||||
import {
|
||||
stripAnsi,
|
||||
centerAlign,
|
||||
rightAlign,
|
||||
leftAlign,
|
||||
align,
|
||||
box,
|
||||
colors,
|
||||
getColor,
|
||||
colorize,
|
||||
} from "consola/utils";
|
||||
|
||||
// CommonJS
|
||||
const { stripAnsi } = require("consola/utils");
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
|
||||
<!-- Badges -->
|
||||
|
||||
[npm-version-src]: https://img.shields.io/npm/v/consola?style=flat&colorA=18181B&colorB=F0DB4F
|
||||
[npm-version-href]: https://npmjs.com/package/consola
|
||||
[npm-downloads-src]: https://img.shields.io/npm/dm/consola?style=flat&colorA=18181B&colorB=F0DB4F
|
||||
[npm-downloads-href]: https://npmjs.com/package/consola
|
||||
[codecov-src]: https://img.shields.io/codecov/c/gh/unjs/consola/main?style=flat&colorA=18181B&colorB=F0DB4F
|
||||
[codecov-href]: https://codecov.io/gh/unjs/consola
|
||||
[bundle-src]: https://img.shields.io/bundlephobia/min/consola?style=flat&colorA=18181B&colorB=F0DB4F
|
||||
[bundle-href]: https://bundlephobia.com/result?p=consola
|
||||
1
node_modules/.pnpm/consola@3.2.3/node_modules/consola/core.d.ts
generated
vendored
Normal file
1
node_modules/.pnpm/consola@3.2.3/node_modules/consola/core.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./dist/core";
|
||||
32
node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/basic.cjs
generated
vendored
Normal file
32
node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/basic.cjs
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
const core = require('./core.cjs');
|
||||
const basic = require('./shared/consola.deac7d5a.cjs');
|
||||
require('node:util');
|
||||
require('node:path');
|
||||
|
||||
function createConsola(options = {}) {
|
||||
let level = core.LogLevels.info;
|
||||
if (process.env.CONSOLA_LEVEL) {
|
||||
level = Number.parseInt(process.env.CONSOLA_LEVEL) ?? level;
|
||||
}
|
||||
const consola2 = core.createConsola({
|
||||
level,
|
||||
defaults: { level },
|
||||
stdout: process.stdout,
|
||||
stderr: process.stderr,
|
||||
reporters: options.reporters || [new basic.BasicReporter()],
|
||||
...options
|
||||
});
|
||||
return consola2;
|
||||
}
|
||||
const consola = createConsola();
|
||||
|
||||
exports.Consola = core.Consola;
|
||||
exports.LogLevels = core.LogLevels;
|
||||
exports.LogTypes = core.LogTypes;
|
||||
exports.consola = consola;
|
||||
exports.createConsola = createConsola;
|
||||
exports.default = consola;
|
||||
9
node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/basic.d.ts
generated
vendored
Normal file
9
node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/basic.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import { ConsolaOptions, ConsolaInstance } from './core.js';
|
||||
export { Consola, ConsolaReporter, FormatOptions, InputLogObject, LogLevel, LogLevels, LogObject, LogType, LogTypes } from './core.js';
|
||||
|
||||
declare function createConsola(options?: Partial<ConsolaOptions & {
|
||||
fancy: boolean;
|
||||
}>): ConsolaInstance;
|
||||
declare const consola: ConsolaInstance;
|
||||
|
||||
export { ConsolaInstance, ConsolaOptions, consola, createConsola, consola as default };
|
||||
24
node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/basic.mjs
generated
vendored
Normal file
24
node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/basic.mjs
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
import { LogLevels, createConsola as createConsola$1 } from './core.mjs';
|
||||
export { Consola, LogTypes } from './core.mjs';
|
||||
import { B as BasicReporter } from './shared/consola.06ad8a64.mjs';
|
||||
import 'node:util';
|
||||
import 'node:path';
|
||||
|
||||
function createConsola(options = {}) {
|
||||
let level = LogLevels.info;
|
||||
if (process.env.CONSOLA_LEVEL) {
|
||||
level = Number.parseInt(process.env.CONSOLA_LEVEL) ?? level;
|
||||
}
|
||||
const consola2 = createConsola$1({
|
||||
level,
|
||||
defaults: { level },
|
||||
stdout: process.stdout,
|
||||
stderr: process.stderr,
|
||||
reporters: options.reporters || [new BasicReporter()],
|
||||
...options
|
||||
});
|
||||
return consola2;
|
||||
}
|
||||
const consola = createConsola();
|
||||
|
||||
export { LogLevels, consola, createConsola, consola as default };
|
||||
80
node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/browser.cjs
generated
vendored
Normal file
80
node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/browser.cjs
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
const core = require('./core.cjs');
|
||||
|
||||
class BrowserReporter {
|
||||
constructor(options) {
|
||||
this.options = { ...options };
|
||||
this.defaultColor = "#7f8c8d";
|
||||
this.levelColorMap = {
|
||||
0: "#c0392b",
|
||||
// Red
|
||||
1: "#f39c12",
|
||||
// Yellow
|
||||
3: "#00BCD4"
|
||||
// Cyan
|
||||
};
|
||||
this.typeColorMap = {
|
||||
success: "#2ecc71"
|
||||
// Green
|
||||
};
|
||||
}
|
||||
_getLogFn(level) {
|
||||
if (level < 1) {
|
||||
return console.__error || console.error;
|
||||
}
|
||||
if (level === 1) {
|
||||
return console.__warn || console.warn;
|
||||
}
|
||||
return console.__log || console.log;
|
||||
}
|
||||
log(logObj) {
|
||||
const consoleLogFn = this._getLogFn(logObj.level);
|
||||
const type = logObj.type === "log" ? "" : logObj.type;
|
||||
const tag = logObj.tag || "";
|
||||
const color = this.typeColorMap[logObj.type] || this.levelColorMap[logObj.level] || this.defaultColor;
|
||||
const style = `
|
||||
background: ${color};
|
||||
border-radius: 0.5em;
|
||||
color: white;
|
||||
font-weight: bold;
|
||||
padding: 2px 0.5em;
|
||||
`;
|
||||
const badge = `%c${[tag, type].filter(Boolean).join(":")}`;
|
||||
if (typeof logObj.args[0] === "string") {
|
||||
consoleLogFn(
|
||||
`${badge}%c ${logObj.args[0]}`,
|
||||
style,
|
||||
// Empty string as style resets to default console style
|
||||
"",
|
||||
...logObj.args.slice(1)
|
||||
);
|
||||
} else {
|
||||
consoleLogFn(badge, style, ...logObj.args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function createConsola(options = {}) {
|
||||
const consola2 = core.createConsola({
|
||||
reporters: options.reporters || [new BrowserReporter({})],
|
||||
prompt(message, options2 = {}) {
|
||||
if (options2.type === "confirm") {
|
||||
return Promise.resolve(confirm(message));
|
||||
}
|
||||
return Promise.resolve(prompt(message));
|
||||
},
|
||||
...options
|
||||
});
|
||||
return consola2;
|
||||
}
|
||||
const consola = createConsola();
|
||||
|
||||
exports.Consola = core.Consola;
|
||||
exports.LogLevels = core.LogLevels;
|
||||
exports.LogTypes = core.LogTypes;
|
||||
exports.consola = consola;
|
||||
exports.createConsola = createConsola;
|
||||
exports.default = consola;
|
||||
7
node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/browser.d.ts
generated
vendored
Normal file
7
node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/browser.d.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import { ConsolaOptions, ConsolaInstance } from './core.js';
|
||||
export { Consola, ConsolaReporter, FormatOptions, InputLogObject, LogLevel, LogLevels, LogObject, LogType, LogTypes } from './core.js';
|
||||
|
||||
declare function createConsola(options?: Partial<ConsolaOptions>): ConsolaInstance;
|
||||
declare const consola: ConsolaInstance;
|
||||
|
||||
export { ConsolaInstance, ConsolaOptions, consola, createConsola, consola as default };
|
||||
72
node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/browser.mjs
generated
vendored
Normal file
72
node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/browser.mjs
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
import { createConsola as createConsola$1 } from './core.mjs';
|
||||
export { Consola, LogLevels, LogTypes } from './core.mjs';
|
||||
|
||||
class BrowserReporter {
|
||||
constructor(options) {
|
||||
this.options = { ...options };
|
||||
this.defaultColor = "#7f8c8d";
|
||||
this.levelColorMap = {
|
||||
0: "#c0392b",
|
||||
// Red
|
||||
1: "#f39c12",
|
||||
// Yellow
|
||||
3: "#00BCD4"
|
||||
// Cyan
|
||||
};
|
||||
this.typeColorMap = {
|
||||
success: "#2ecc71"
|
||||
// Green
|
||||
};
|
||||
}
|
||||
_getLogFn(level) {
|
||||
if (level < 1) {
|
||||
return console.__error || console.error;
|
||||
}
|
||||
if (level === 1) {
|
||||
return console.__warn || console.warn;
|
||||
}
|
||||
return console.__log || console.log;
|
||||
}
|
||||
log(logObj) {
|
||||
const consoleLogFn = this._getLogFn(logObj.level);
|
||||
const type = logObj.type === "log" ? "" : logObj.type;
|
||||
const tag = logObj.tag || "";
|
||||
const color = this.typeColorMap[logObj.type] || this.levelColorMap[logObj.level] || this.defaultColor;
|
||||
const style = `
|
||||
background: ${color};
|
||||
border-radius: 0.5em;
|
||||
color: white;
|
||||
font-weight: bold;
|
||||
padding: 2px 0.5em;
|
||||
`;
|
||||
const badge = `%c${[tag, type].filter(Boolean).join(":")}`;
|
||||
if (typeof logObj.args[0] === "string") {
|
||||
consoleLogFn(
|
||||
`${badge}%c ${logObj.args[0]}`,
|
||||
style,
|
||||
// Empty string as style resets to default console style
|
||||
"",
|
||||
...logObj.args.slice(1)
|
||||
);
|
||||
} else {
|
||||
consoleLogFn(badge, style, ...logObj.args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function createConsola(options = {}) {
|
||||
const consola2 = createConsola$1({
|
||||
reporters: options.reporters || [new BrowserReporter({})],
|
||||
prompt(message, options2 = {}) {
|
||||
if (options2.type === "confirm") {
|
||||
return Promise.resolve(confirm(message));
|
||||
}
|
||||
return Promise.resolve(prompt(message));
|
||||
},
|
||||
...options
|
||||
});
|
||||
return consola2;
|
||||
}
|
||||
const consola = createConsola();
|
||||
|
||||
export { consola, createConsola, consola as default };
|
||||
436
node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/chunks/prompt.cjs
generated
vendored
Normal file
436
node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/chunks/prompt.cjs
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
429
node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/chunks/prompt.mjs
generated
vendored
Normal file
429
node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/chunks/prompt.mjs
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
415
node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/core.cjs
generated
vendored
Normal file
415
node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/core.cjs
generated
vendored
Normal file
@@ -0,0 +1,415 @@
|
||||
'use strict';
|
||||
|
||||
const LogLevels = {
|
||||
silent: Number.NEGATIVE_INFINITY,
|
||||
fatal: 0,
|
||||
error: 0,
|
||||
warn: 1,
|
||||
log: 2,
|
||||
info: 3,
|
||||
success: 3,
|
||||
fail: 3,
|
||||
ready: 3,
|
||||
start: 3,
|
||||
box: 3,
|
||||
debug: 4,
|
||||
trace: 5,
|
||||
verbose: Number.POSITIVE_INFINITY
|
||||
};
|
||||
const LogTypes = {
|
||||
// Silent
|
||||
silent: {
|
||||
level: -1
|
||||
},
|
||||
// Level 0
|
||||
fatal: {
|
||||
level: LogLevels.fatal
|
||||
},
|
||||
error: {
|
||||
level: LogLevels.error
|
||||
},
|
||||
// Level 1
|
||||
warn: {
|
||||
level: LogLevels.warn
|
||||
},
|
||||
// Level 2
|
||||
log: {
|
||||
level: LogLevels.log
|
||||
},
|
||||
// Level 3
|
||||
info: {
|
||||
level: LogLevels.info
|
||||
},
|
||||
success: {
|
||||
level: LogLevels.success
|
||||
},
|
||||
fail: {
|
||||
level: LogLevels.fail
|
||||
},
|
||||
ready: {
|
||||
level: LogLevels.info
|
||||
},
|
||||
start: {
|
||||
level: LogLevels.info
|
||||
},
|
||||
box: {
|
||||
level: LogLevels.info
|
||||
},
|
||||
// Level 4
|
||||
debug: {
|
||||
level: LogLevels.debug
|
||||
},
|
||||
// Level 5
|
||||
trace: {
|
||||
level: LogLevels.trace
|
||||
},
|
||||
// Verbose
|
||||
verbose: {
|
||||
level: LogLevels.verbose
|
||||
}
|
||||
};
|
||||
|
||||
function isObject(value) {
|
||||
return value !== null && typeof value === "object";
|
||||
}
|
||||
function _defu(baseObject, defaults, namespace = ".", merger) {
|
||||
if (!isObject(defaults)) {
|
||||
return _defu(baseObject, {}, namespace, merger);
|
||||
}
|
||||
const object = Object.assign({}, defaults);
|
||||
for (const key in baseObject) {
|
||||
if (key === "__proto__" || key === "constructor") {
|
||||
continue;
|
||||
}
|
||||
const value = baseObject[key];
|
||||
if (value === null || value === void 0) {
|
||||
continue;
|
||||
}
|
||||
if (merger && merger(object, key, value, namespace)) {
|
||||
continue;
|
||||
}
|
||||
if (Array.isArray(value) && Array.isArray(object[key])) {
|
||||
object[key] = [...value, ...object[key]];
|
||||
} else if (isObject(value) && isObject(object[key])) {
|
||||
object[key] = _defu(
|
||||
value,
|
||||
object[key],
|
||||
(namespace ? `${namespace}.` : "") + key.toString(),
|
||||
merger
|
||||
);
|
||||
} else {
|
||||
object[key] = value;
|
||||
}
|
||||
}
|
||||
return object;
|
||||
}
|
||||
function createDefu(merger) {
|
||||
return (...arguments_) => (
|
||||
// eslint-disable-next-line unicorn/no-array-reduce
|
||||
arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
|
||||
);
|
||||
}
|
||||
const defu = createDefu();
|
||||
|
||||
function isPlainObject(obj) {
|
||||
return Object.prototype.toString.call(obj) === "[object Object]";
|
||||
}
|
||||
function isLogObj(arg) {
|
||||
if (!isPlainObject(arg)) {
|
||||
return false;
|
||||
}
|
||||
if (!arg.message && !arg.args) {
|
||||
return false;
|
||||
}
|
||||
if (arg.stack) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
let paused = false;
|
||||
const queue = [];
|
||||
class Consola {
|
||||
constructor(options = {}) {
|
||||
const types = options.types || LogTypes;
|
||||
this.options = defu(
|
||||
{
|
||||
...options,
|
||||
defaults: { ...options.defaults },
|
||||
level: _normalizeLogLevel(options.level, types),
|
||||
reporters: [...options.reporters || []]
|
||||
},
|
||||
{
|
||||
types: LogTypes,
|
||||
throttle: 1e3,
|
||||
throttleMin: 5,
|
||||
formatOptions: {
|
||||
date: true,
|
||||
colors: false,
|
||||
compact: true
|
||||
}
|
||||
}
|
||||
);
|
||||
for (const type in types) {
|
||||
const defaults = {
|
||||
type,
|
||||
...this.options.defaults,
|
||||
...types[type]
|
||||
};
|
||||
this[type] = this._wrapLogFn(defaults);
|
||||
this[type].raw = this._wrapLogFn(
|
||||
defaults,
|
||||
true
|
||||
);
|
||||
}
|
||||
if (this.options.mockFn) {
|
||||
this.mockTypes();
|
||||
}
|
||||
this._lastLog = {};
|
||||
}
|
||||
get level() {
|
||||
return this.options.level;
|
||||
}
|
||||
set level(level) {
|
||||
this.options.level = _normalizeLogLevel(
|
||||
level,
|
||||
this.options.types,
|
||||
this.options.level
|
||||
);
|
||||
}
|
||||
prompt(message, opts) {
|
||||
if (!this.options.prompt) {
|
||||
throw new Error("prompt is not supported!");
|
||||
}
|
||||
return this.options.prompt(message, opts);
|
||||
}
|
||||
create(options) {
|
||||
const instance = new Consola({
|
||||
...this.options,
|
||||
...options
|
||||
});
|
||||
if (this._mockFn) {
|
||||
instance.mockTypes(this._mockFn);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
withDefaults(defaults) {
|
||||
return this.create({
|
||||
...this.options,
|
||||
defaults: {
|
||||
...this.options.defaults,
|
||||
...defaults
|
||||
}
|
||||
});
|
||||
}
|
||||
withTag(tag) {
|
||||
return this.withDefaults({
|
||||
tag: this.options.defaults.tag ? this.options.defaults.tag + ":" + tag : tag
|
||||
});
|
||||
}
|
||||
addReporter(reporter) {
|
||||
this.options.reporters.push(reporter);
|
||||
return this;
|
||||
}
|
||||
removeReporter(reporter) {
|
||||
if (reporter) {
|
||||
const i = this.options.reporters.indexOf(reporter);
|
||||
if (i >= 0) {
|
||||
return this.options.reporters.splice(i, 1);
|
||||
}
|
||||
} else {
|
||||
this.options.reporters.splice(0);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
setReporters(reporters) {
|
||||
this.options.reporters = Array.isArray(reporters) ? reporters : [reporters];
|
||||
return this;
|
||||
}
|
||||
wrapAll() {
|
||||
this.wrapConsole();
|
||||
this.wrapStd();
|
||||
}
|
||||
restoreAll() {
|
||||
this.restoreConsole();
|
||||
this.restoreStd();
|
||||
}
|
||||
wrapConsole() {
|
||||
for (const type in this.options.types) {
|
||||
if (!console["__" + type]) {
|
||||
console["__" + type] = console[type];
|
||||
}
|
||||
console[type] = this[type].raw;
|
||||
}
|
||||
}
|
||||
restoreConsole() {
|
||||
for (const type in this.options.types) {
|
||||
if (console["__" + type]) {
|
||||
console[type] = console["__" + type];
|
||||
delete console["__" + type];
|
||||
}
|
||||
}
|
||||
}
|
||||
wrapStd() {
|
||||
this._wrapStream(this.options.stdout, "log");
|
||||
this._wrapStream(this.options.stderr, "log");
|
||||
}
|
||||
_wrapStream(stream, type) {
|
||||
if (!stream) {
|
||||
return;
|
||||
}
|
||||
if (!stream.__write) {
|
||||
stream.__write = stream.write;
|
||||
}
|
||||
stream.write = (data) => {
|
||||
this[type].raw(String(data).trim());
|
||||
};
|
||||
}
|
||||
restoreStd() {
|
||||
this._restoreStream(this.options.stdout);
|
||||
this._restoreStream(this.options.stderr);
|
||||
}
|
||||
_restoreStream(stream) {
|
||||
if (!stream) {
|
||||
return;
|
||||
}
|
||||
if (stream.__write) {
|
||||
stream.write = stream.__write;
|
||||
delete stream.__write;
|
||||
}
|
||||
}
|
||||
pauseLogs() {
|
||||
paused = true;
|
||||
}
|
||||
resumeLogs() {
|
||||
paused = false;
|
||||
const _queue = queue.splice(0);
|
||||
for (const item of _queue) {
|
||||
item[0]._logFn(item[1], item[2]);
|
||||
}
|
||||
}
|
||||
mockTypes(mockFn) {
|
||||
const _mockFn = mockFn || this.options.mockFn;
|
||||
this._mockFn = _mockFn;
|
||||
if (typeof _mockFn !== "function") {
|
||||
return;
|
||||
}
|
||||
for (const type in this.options.types) {
|
||||
this[type] = _mockFn(type, this.options.types[type]) || this[type];
|
||||
this[type].raw = this[type];
|
||||
}
|
||||
}
|
||||
_wrapLogFn(defaults, isRaw) {
|
||||
return (...args) => {
|
||||
if (paused) {
|
||||
queue.push([this, defaults, args, isRaw]);
|
||||
return;
|
||||
}
|
||||
return this._logFn(defaults, args, isRaw);
|
||||
};
|
||||
}
|
||||
_logFn(defaults, args, isRaw) {
|
||||
if ((defaults.level || 0) > this.level) {
|
||||
return false;
|
||||
}
|
||||
const logObj = {
|
||||
date: /* @__PURE__ */ new Date(),
|
||||
args: [],
|
||||
...defaults,
|
||||
level: _normalizeLogLevel(defaults.level, this.options.types)
|
||||
};
|
||||
if (!isRaw && args.length === 1 && isLogObj(args[0])) {
|
||||
Object.assign(logObj, args[0]);
|
||||
} else {
|
||||
logObj.args = [...args];
|
||||
}
|
||||
if (logObj.message) {
|
||||
logObj.args.unshift(logObj.message);
|
||||
delete logObj.message;
|
||||
}
|
||||
if (logObj.additional) {
|
||||
if (!Array.isArray(logObj.additional)) {
|
||||
logObj.additional = logObj.additional.split("\n");
|
||||
}
|
||||
logObj.args.push("\n" + logObj.additional.join("\n"));
|
||||
delete logObj.additional;
|
||||
}
|
||||
logObj.type = typeof logObj.type === "string" ? logObj.type.toLowerCase() : "log";
|
||||
logObj.tag = typeof logObj.tag === "string" ? logObj.tag : "";
|
||||
const resolveLog = (newLog = false) => {
|
||||
const repeated = (this._lastLog.count || 0) - this.options.throttleMin;
|
||||
if (this._lastLog.object && repeated > 0) {
|
||||
const args2 = [...this._lastLog.object.args];
|
||||
if (repeated > 1) {
|
||||
args2.push(`(repeated ${repeated} times)`);
|
||||
}
|
||||
this._log({ ...this._lastLog.object, args: args2 });
|
||||
this._lastLog.count = 1;
|
||||
}
|
||||
if (newLog) {
|
||||
this._lastLog.object = logObj;
|
||||
this._log(logObj);
|
||||
}
|
||||
};
|
||||
clearTimeout(this._lastLog.timeout);
|
||||
const diffTime = this._lastLog.time && logObj.date ? logObj.date.getTime() - this._lastLog.time.getTime() : 0;
|
||||
this._lastLog.time = logObj.date;
|
||||
if (diffTime < this.options.throttle) {
|
||||
try {
|
||||
const serializedLog = JSON.stringify([
|
||||
logObj.type,
|
||||
logObj.tag,
|
||||
logObj.args
|
||||
]);
|
||||
const isSameLog = this._lastLog.serialized === serializedLog;
|
||||
this._lastLog.serialized = serializedLog;
|
||||
if (isSameLog) {
|
||||
this._lastLog.count = (this._lastLog.count || 0) + 1;
|
||||
if (this._lastLog.count > this.options.throttleMin) {
|
||||
this._lastLog.timeout = setTimeout(
|
||||
resolveLog,
|
||||
this.options.throttle
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
resolveLog(true);
|
||||
}
|
||||
_log(logObj) {
|
||||
for (const reporter of this.options.reporters) {
|
||||
reporter.log(logObj, {
|
||||
options: this.options
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
function _normalizeLogLevel(input, types = {}, defaultLevel = 3) {
|
||||
if (input === void 0) {
|
||||
return defaultLevel;
|
||||
}
|
||||
if (typeof input === "number") {
|
||||
return input;
|
||||
}
|
||||
if (types[input] && types[input].level !== void 0) {
|
||||
return types[input].level;
|
||||
}
|
||||
return defaultLevel;
|
||||
}
|
||||
Consola.prototype.add = Consola.prototype.addReporter;
|
||||
Consola.prototype.remove = Consola.prototype.removeReporter;
|
||||
Consola.prototype.clear = Consola.prototype.removeReporter;
|
||||
Consola.prototype.withScope = Consola.prototype.withTag;
|
||||
Consola.prototype.mock = Consola.prototype.mockTypes;
|
||||
Consola.prototype.pause = Consola.prototype.pauseLogs;
|
||||
Consola.prototype.resume = Consola.prototype.resumeLogs;
|
||||
function createConsola(options = {}) {
|
||||
return new Consola(options);
|
||||
}
|
||||
|
||||
exports.Consola = Consola;
|
||||
exports.LogLevels = LogLevels;
|
||||
exports.LogTypes = LogTypes;
|
||||
exports.createConsola = createConsola;
|
||||
124
node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/core.d.ts
generated
vendored
Normal file
124
node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/core.d.ts
generated
vendored
Normal file
@@ -0,0 +1,124 @@
|
||||
type SelectOption = {
|
||||
label: string;
|
||||
value: string;
|
||||
hint?: string;
|
||||
};
|
||||
type TextOptions = {
|
||||
type?: "text";
|
||||
default?: string;
|
||||
placeholder?: string;
|
||||
initial?: string;
|
||||
};
|
||||
type ConfirmOptions = {
|
||||
type: "confirm";
|
||||
initial?: boolean;
|
||||
};
|
||||
type SelectOptions = {
|
||||
type: "select";
|
||||
initial?: string;
|
||||
options: (string | SelectOption)[];
|
||||
};
|
||||
type MultiSelectOptions = {
|
||||
type: "multiselect";
|
||||
initial?: string;
|
||||
options: string[] | SelectOption[];
|
||||
required?: boolean;
|
||||
};
|
||||
type PromptOptions = TextOptions | ConfirmOptions | SelectOptions | MultiSelectOptions;
|
||||
type inferPromptReturnType<T extends PromptOptions> = T extends TextOptions ? string : T extends ConfirmOptions ? boolean : T extends SelectOptions ? T["options"][number] : T extends MultiSelectOptions ? T["options"] : unknown;
|
||||
declare function prompt<_ = any, __ = any, T extends PromptOptions = TextOptions>(message: string, opts?: PromptOptions): Promise<inferPromptReturnType<T>>;
|
||||
|
||||
type LogLevel = 0 | 1 | 2 | 3 | 4 | 5 | (number & {});
|
||||
declare const LogLevels: Record<LogType, number>;
|
||||
type LogType = "silent" | "fatal" | "error" | "warn" | "log" | "info" | "success" | "fail" | "ready" | "start" | "box" | "debug" | "trace" | "verbose";
|
||||
declare const LogTypes: Record<LogType, Partial<LogObject>>;
|
||||
|
||||
interface ConsolaOptions {
|
||||
reporters: ConsolaReporter[];
|
||||
types: Record<LogType, InputLogObject>;
|
||||
level: LogLevel;
|
||||
defaults: InputLogObject;
|
||||
throttle: number;
|
||||
throttleMin: number;
|
||||
stdout?: NodeJS.WriteStream;
|
||||
stderr?: NodeJS.WriteStream;
|
||||
mockFn?: (type: LogType, defaults: InputLogObject) => (...args: any) => void;
|
||||
prompt?: typeof prompt | undefined;
|
||||
formatOptions: FormatOptions;
|
||||
}
|
||||
/**
|
||||
* @see https://nodejs.org/api/util.html#util_util_inspect_object_showhidden_depth_colors
|
||||
*/
|
||||
interface FormatOptions {
|
||||
columns?: number;
|
||||
date?: boolean;
|
||||
colors?: boolean;
|
||||
compact?: boolean | number;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
interface InputLogObject {
|
||||
level?: LogLevel;
|
||||
tag?: string;
|
||||
type?: LogType;
|
||||
message?: string;
|
||||
additional?: string | string[];
|
||||
args?: any[];
|
||||
date?: Date;
|
||||
}
|
||||
interface LogObject extends InputLogObject {
|
||||
level: LogLevel;
|
||||
type: LogType;
|
||||
tag: string;
|
||||
args: any[];
|
||||
date: Date;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
interface ConsolaReporter {
|
||||
log: (logObj: LogObject, ctx: {
|
||||
options: ConsolaOptions;
|
||||
}) => void;
|
||||
}
|
||||
|
||||
declare class Consola {
|
||||
options: ConsolaOptions;
|
||||
_lastLog: {
|
||||
serialized?: string;
|
||||
object?: LogObject;
|
||||
count?: number;
|
||||
time?: Date;
|
||||
timeout?: ReturnType<typeof setTimeout>;
|
||||
};
|
||||
_mockFn?: ConsolaOptions["mockFn"];
|
||||
constructor(options?: Partial<ConsolaOptions>);
|
||||
get level(): LogLevel;
|
||||
set level(level: LogLevel);
|
||||
prompt<T extends PromptOptions>(message: string, opts?: T): Promise<T extends TextOptions ? string : T extends ConfirmOptions ? boolean : T extends SelectOptions ? T["options"][number] : T extends MultiSelectOptions ? T["options"] : unknown>;
|
||||
create(options: Partial<ConsolaOptions>): ConsolaInstance;
|
||||
withDefaults(defaults: InputLogObject): ConsolaInstance;
|
||||
withTag(tag: string): ConsolaInstance;
|
||||
addReporter(reporter: ConsolaReporter): this;
|
||||
removeReporter(reporter: ConsolaReporter): ConsolaReporter[] | this;
|
||||
setReporters(reporters: ConsolaReporter[]): this;
|
||||
wrapAll(): void;
|
||||
restoreAll(): void;
|
||||
wrapConsole(): void;
|
||||
restoreConsole(): void;
|
||||
wrapStd(): void;
|
||||
_wrapStream(stream: NodeJS.WriteStream | undefined, type: LogType): void;
|
||||
restoreStd(): void;
|
||||
_restoreStream(stream?: NodeJS.WriteStream): void;
|
||||
pauseLogs(): void;
|
||||
resumeLogs(): void;
|
||||
mockTypes(mockFn?: ConsolaOptions["mockFn"]): void;
|
||||
_wrapLogFn(defaults: InputLogObject, isRaw?: boolean): (...args: any[]) => false | undefined;
|
||||
_logFn(defaults: InputLogObject, args: any[], isRaw?: boolean): false | undefined;
|
||||
_log(logObj: LogObject): void;
|
||||
}
|
||||
interface LogFn {
|
||||
(message: InputLogObject | any, ...args: any[]): void;
|
||||
raw: (...args: any[]) => void;
|
||||
}
|
||||
type ConsolaInstance = Consola & Record<LogType, LogFn>;
|
||||
declare function createConsola(options?: Partial<ConsolaOptions>): ConsolaInstance;
|
||||
|
||||
export { Consola, ConsolaInstance, ConsolaOptions, ConsolaReporter, FormatOptions, InputLogObject, LogLevel, LogLevels, LogObject, LogType, LogTypes, createConsola };
|
||||
410
node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/core.mjs
generated
vendored
Normal file
410
node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/core.mjs
generated
vendored
Normal file
@@ -0,0 +1,410 @@
|
||||
const LogLevels = {
|
||||
silent: Number.NEGATIVE_INFINITY,
|
||||
fatal: 0,
|
||||
error: 0,
|
||||
warn: 1,
|
||||
log: 2,
|
||||
info: 3,
|
||||
success: 3,
|
||||
fail: 3,
|
||||
ready: 3,
|
||||
start: 3,
|
||||
box: 3,
|
||||
debug: 4,
|
||||
trace: 5,
|
||||
verbose: Number.POSITIVE_INFINITY
|
||||
};
|
||||
const LogTypes = {
|
||||
// Silent
|
||||
silent: {
|
||||
level: -1
|
||||
},
|
||||
// Level 0
|
||||
fatal: {
|
||||
level: LogLevels.fatal
|
||||
},
|
||||
error: {
|
||||
level: LogLevels.error
|
||||
},
|
||||
// Level 1
|
||||
warn: {
|
||||
level: LogLevels.warn
|
||||
},
|
||||
// Level 2
|
||||
log: {
|
||||
level: LogLevels.log
|
||||
},
|
||||
// Level 3
|
||||
info: {
|
||||
level: LogLevels.info
|
||||
},
|
||||
success: {
|
||||
level: LogLevels.success
|
||||
},
|
||||
fail: {
|
||||
level: LogLevels.fail
|
||||
},
|
||||
ready: {
|
||||
level: LogLevels.info
|
||||
},
|
||||
start: {
|
||||
level: LogLevels.info
|
||||
},
|
||||
box: {
|
||||
level: LogLevels.info
|
||||
},
|
||||
// Level 4
|
||||
debug: {
|
||||
level: LogLevels.debug
|
||||
},
|
||||
// Level 5
|
||||
trace: {
|
||||
level: LogLevels.trace
|
||||
},
|
||||
// Verbose
|
||||
verbose: {
|
||||
level: LogLevels.verbose
|
||||
}
|
||||
};
|
||||
|
||||
function isObject(value) {
|
||||
return value !== null && typeof value === "object";
|
||||
}
|
||||
function _defu(baseObject, defaults, namespace = ".", merger) {
|
||||
if (!isObject(defaults)) {
|
||||
return _defu(baseObject, {}, namespace, merger);
|
||||
}
|
||||
const object = Object.assign({}, defaults);
|
||||
for (const key in baseObject) {
|
||||
if (key === "__proto__" || key === "constructor") {
|
||||
continue;
|
||||
}
|
||||
const value = baseObject[key];
|
||||
if (value === null || value === void 0) {
|
||||
continue;
|
||||
}
|
||||
if (merger && merger(object, key, value, namespace)) {
|
||||
continue;
|
||||
}
|
||||
if (Array.isArray(value) && Array.isArray(object[key])) {
|
||||
object[key] = [...value, ...object[key]];
|
||||
} else if (isObject(value) && isObject(object[key])) {
|
||||
object[key] = _defu(
|
||||
value,
|
||||
object[key],
|
||||
(namespace ? `${namespace}.` : "") + key.toString(),
|
||||
merger
|
||||
);
|
||||
} else {
|
||||
object[key] = value;
|
||||
}
|
||||
}
|
||||
return object;
|
||||
}
|
||||
function createDefu(merger) {
|
||||
return (...arguments_) => (
|
||||
// eslint-disable-next-line unicorn/no-array-reduce
|
||||
arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
|
||||
);
|
||||
}
|
||||
const defu = createDefu();
|
||||
|
||||
function isPlainObject(obj) {
|
||||
return Object.prototype.toString.call(obj) === "[object Object]";
|
||||
}
|
||||
function isLogObj(arg) {
|
||||
if (!isPlainObject(arg)) {
|
||||
return false;
|
||||
}
|
||||
if (!arg.message && !arg.args) {
|
||||
return false;
|
||||
}
|
||||
if (arg.stack) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
let paused = false;
|
||||
const queue = [];
|
||||
class Consola {
|
||||
constructor(options = {}) {
|
||||
const types = options.types || LogTypes;
|
||||
this.options = defu(
|
||||
{
|
||||
...options,
|
||||
defaults: { ...options.defaults },
|
||||
level: _normalizeLogLevel(options.level, types),
|
||||
reporters: [...options.reporters || []]
|
||||
},
|
||||
{
|
||||
types: LogTypes,
|
||||
throttle: 1e3,
|
||||
throttleMin: 5,
|
||||
formatOptions: {
|
||||
date: true,
|
||||
colors: false,
|
||||
compact: true
|
||||
}
|
||||
}
|
||||
);
|
||||
for (const type in types) {
|
||||
const defaults = {
|
||||
type,
|
||||
...this.options.defaults,
|
||||
...types[type]
|
||||
};
|
||||
this[type] = this._wrapLogFn(defaults);
|
||||
this[type].raw = this._wrapLogFn(
|
||||
defaults,
|
||||
true
|
||||
);
|
||||
}
|
||||
if (this.options.mockFn) {
|
||||
this.mockTypes();
|
||||
}
|
||||
this._lastLog = {};
|
||||
}
|
||||
get level() {
|
||||
return this.options.level;
|
||||
}
|
||||
set level(level) {
|
||||
this.options.level = _normalizeLogLevel(
|
||||
level,
|
||||
this.options.types,
|
||||
this.options.level
|
||||
);
|
||||
}
|
||||
prompt(message, opts) {
|
||||
if (!this.options.prompt) {
|
||||
throw new Error("prompt is not supported!");
|
||||
}
|
||||
return this.options.prompt(message, opts);
|
||||
}
|
||||
create(options) {
|
||||
const instance = new Consola({
|
||||
...this.options,
|
||||
...options
|
||||
});
|
||||
if (this._mockFn) {
|
||||
instance.mockTypes(this._mockFn);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
withDefaults(defaults) {
|
||||
return this.create({
|
||||
...this.options,
|
||||
defaults: {
|
||||
...this.options.defaults,
|
||||
...defaults
|
||||
}
|
||||
});
|
||||
}
|
||||
withTag(tag) {
|
||||
return this.withDefaults({
|
||||
tag: this.options.defaults.tag ? this.options.defaults.tag + ":" + tag : tag
|
||||
});
|
||||
}
|
||||
addReporter(reporter) {
|
||||
this.options.reporters.push(reporter);
|
||||
return this;
|
||||
}
|
||||
removeReporter(reporter) {
|
||||
if (reporter) {
|
||||
const i = this.options.reporters.indexOf(reporter);
|
||||
if (i >= 0) {
|
||||
return this.options.reporters.splice(i, 1);
|
||||
}
|
||||
} else {
|
||||
this.options.reporters.splice(0);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
setReporters(reporters) {
|
||||
this.options.reporters = Array.isArray(reporters) ? reporters : [reporters];
|
||||
return this;
|
||||
}
|
||||
wrapAll() {
|
||||
this.wrapConsole();
|
||||
this.wrapStd();
|
||||
}
|
||||
restoreAll() {
|
||||
this.restoreConsole();
|
||||
this.restoreStd();
|
||||
}
|
||||
wrapConsole() {
|
||||
for (const type in this.options.types) {
|
||||
if (!console["__" + type]) {
|
||||
console["__" + type] = console[type];
|
||||
}
|
||||
console[type] = this[type].raw;
|
||||
}
|
||||
}
|
||||
restoreConsole() {
|
||||
for (const type in this.options.types) {
|
||||
if (console["__" + type]) {
|
||||
console[type] = console["__" + type];
|
||||
delete console["__" + type];
|
||||
}
|
||||
}
|
||||
}
|
||||
wrapStd() {
|
||||
this._wrapStream(this.options.stdout, "log");
|
||||
this._wrapStream(this.options.stderr, "log");
|
||||
}
|
||||
_wrapStream(stream, type) {
|
||||
if (!stream) {
|
||||
return;
|
||||
}
|
||||
if (!stream.__write) {
|
||||
stream.__write = stream.write;
|
||||
}
|
||||
stream.write = (data) => {
|
||||
this[type].raw(String(data).trim());
|
||||
};
|
||||
}
|
||||
restoreStd() {
|
||||
this._restoreStream(this.options.stdout);
|
||||
this._restoreStream(this.options.stderr);
|
||||
}
|
||||
_restoreStream(stream) {
|
||||
if (!stream) {
|
||||
return;
|
||||
}
|
||||
if (stream.__write) {
|
||||
stream.write = stream.__write;
|
||||
delete stream.__write;
|
||||
}
|
||||
}
|
||||
pauseLogs() {
|
||||
paused = true;
|
||||
}
|
||||
resumeLogs() {
|
||||
paused = false;
|
||||
const _queue = queue.splice(0);
|
||||
for (const item of _queue) {
|
||||
item[0]._logFn(item[1], item[2]);
|
||||
}
|
||||
}
|
||||
mockTypes(mockFn) {
|
||||
const _mockFn = mockFn || this.options.mockFn;
|
||||
this._mockFn = _mockFn;
|
||||
if (typeof _mockFn !== "function") {
|
||||
return;
|
||||
}
|
||||
for (const type in this.options.types) {
|
||||
this[type] = _mockFn(type, this.options.types[type]) || this[type];
|
||||
this[type].raw = this[type];
|
||||
}
|
||||
}
|
||||
_wrapLogFn(defaults, isRaw) {
|
||||
return (...args) => {
|
||||
if (paused) {
|
||||
queue.push([this, defaults, args, isRaw]);
|
||||
return;
|
||||
}
|
||||
return this._logFn(defaults, args, isRaw);
|
||||
};
|
||||
}
|
||||
_logFn(defaults, args, isRaw) {
|
||||
if ((defaults.level || 0) > this.level) {
|
||||
return false;
|
||||
}
|
||||
const logObj = {
|
||||
date: /* @__PURE__ */ new Date(),
|
||||
args: [],
|
||||
...defaults,
|
||||
level: _normalizeLogLevel(defaults.level, this.options.types)
|
||||
};
|
||||
if (!isRaw && args.length === 1 && isLogObj(args[0])) {
|
||||
Object.assign(logObj, args[0]);
|
||||
} else {
|
||||
logObj.args = [...args];
|
||||
}
|
||||
if (logObj.message) {
|
||||
logObj.args.unshift(logObj.message);
|
||||
delete logObj.message;
|
||||
}
|
||||
if (logObj.additional) {
|
||||
if (!Array.isArray(logObj.additional)) {
|
||||
logObj.additional = logObj.additional.split("\n");
|
||||
}
|
||||
logObj.args.push("\n" + logObj.additional.join("\n"));
|
||||
delete logObj.additional;
|
||||
}
|
||||
logObj.type = typeof logObj.type === "string" ? logObj.type.toLowerCase() : "log";
|
||||
logObj.tag = typeof logObj.tag === "string" ? logObj.tag : "";
|
||||
const resolveLog = (newLog = false) => {
|
||||
const repeated = (this._lastLog.count || 0) - this.options.throttleMin;
|
||||
if (this._lastLog.object && repeated > 0) {
|
||||
const args2 = [...this._lastLog.object.args];
|
||||
if (repeated > 1) {
|
||||
args2.push(`(repeated ${repeated} times)`);
|
||||
}
|
||||
this._log({ ...this._lastLog.object, args: args2 });
|
||||
this._lastLog.count = 1;
|
||||
}
|
||||
if (newLog) {
|
||||
this._lastLog.object = logObj;
|
||||
this._log(logObj);
|
||||
}
|
||||
};
|
||||
clearTimeout(this._lastLog.timeout);
|
||||
const diffTime = this._lastLog.time && logObj.date ? logObj.date.getTime() - this._lastLog.time.getTime() : 0;
|
||||
this._lastLog.time = logObj.date;
|
||||
if (diffTime < this.options.throttle) {
|
||||
try {
|
||||
const serializedLog = JSON.stringify([
|
||||
logObj.type,
|
||||
logObj.tag,
|
||||
logObj.args
|
||||
]);
|
||||
const isSameLog = this._lastLog.serialized === serializedLog;
|
||||
this._lastLog.serialized = serializedLog;
|
||||
if (isSameLog) {
|
||||
this._lastLog.count = (this._lastLog.count || 0) + 1;
|
||||
if (this._lastLog.count > this.options.throttleMin) {
|
||||
this._lastLog.timeout = setTimeout(
|
||||
resolveLog,
|
||||
this.options.throttle
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
resolveLog(true);
|
||||
}
|
||||
_log(logObj) {
|
||||
for (const reporter of this.options.reporters) {
|
||||
reporter.log(logObj, {
|
||||
options: this.options
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
function _normalizeLogLevel(input, types = {}, defaultLevel = 3) {
|
||||
if (input === void 0) {
|
||||
return defaultLevel;
|
||||
}
|
||||
if (typeof input === "number") {
|
||||
return input;
|
||||
}
|
||||
if (types[input] && types[input].level !== void 0) {
|
||||
return types[input].level;
|
||||
}
|
||||
return defaultLevel;
|
||||
}
|
||||
Consola.prototype.add = Consola.prototype.addReporter;
|
||||
Consola.prototype.remove = Consola.prototype.removeReporter;
|
||||
Consola.prototype.clear = Consola.prototype.removeReporter;
|
||||
Consola.prototype.withScope = Consola.prototype.withTag;
|
||||
Consola.prototype.mock = Consola.prototype.mockTypes;
|
||||
Consola.prototype.pause = Consola.prototype.pauseLogs;
|
||||
Consola.prototype.resume = Consola.prototype.resumeLogs;
|
||||
function createConsola(options = {}) {
|
||||
return new Consola(options);
|
||||
}
|
||||
|
||||
export { Consola, LogLevels, LogTypes, createConsola };
|
||||
21
node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/index.cjs
generated
vendored
Normal file
21
node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/index.cjs
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
const index = require('./shared/consola.4bbae468.cjs');
|
||||
const core = require('./core.cjs');
|
||||
require('./shared/consola.deac7d5a.cjs');
|
||||
require('node:process');
|
||||
require('./utils.cjs');
|
||||
require('node:tty');
|
||||
require('node:util');
|
||||
require('node:path');
|
||||
|
||||
|
||||
|
||||
exports.consola = index.consola;
|
||||
exports.createConsola = index.createConsola;
|
||||
exports.default = index.consola;
|
||||
exports.Consola = core.Consola;
|
||||
exports.LogLevels = core.LogLevels;
|
||||
exports.LogTypes = core.LogTypes;
|
||||
9
node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/index.d.ts
generated
vendored
Normal file
9
node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import { ConsolaOptions, ConsolaInstance } from './core.js';
|
||||
export { Consola, ConsolaReporter, FormatOptions, InputLogObject, LogLevel, LogLevels, LogObject, LogType, LogTypes } from './core.js';
|
||||
|
||||
declare function createConsola(options?: Partial<ConsolaOptions & {
|
||||
fancy: boolean;
|
||||
}>): ConsolaInstance;
|
||||
declare const consola: ConsolaInstance;
|
||||
|
||||
export { ConsolaInstance, ConsolaOptions, consola, createConsola, consola as default };
|
||||
8
node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/index.mjs
generated
vendored
Normal file
8
node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
export { a as consola, c as createConsola, a as default } from './shared/consola.36c0034f.mjs';
|
||||
export { Consola, LogLevels, LogTypes } from './core.mjs';
|
||||
import './shared/consola.06ad8a64.mjs';
|
||||
import 'node:process';
|
||||
import './utils.mjs';
|
||||
import 'node:tty';
|
||||
import 'node:util';
|
||||
import 'node:path';
|
||||
62
node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/shared/consola.06ad8a64.mjs
generated
vendored
Normal file
62
node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/shared/consola.06ad8a64.mjs
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
import { formatWithOptions } from 'node:util';
|
||||
import { sep } from 'node:path';
|
||||
|
||||
function parseStack(stack) {
|
||||
const cwd = process.cwd() + sep;
|
||||
const lines = stack.split("\n").splice(1).map((l) => l.trim().replace("file://", "").replace(cwd, ""));
|
||||
return lines;
|
||||
}
|
||||
|
||||
function writeStream(data, stream) {
|
||||
const write = stream.__write || stream.write;
|
||||
return write.call(stream, data);
|
||||
}
|
||||
|
||||
const bracket = (x) => x ? `[${x}]` : "";
|
||||
class BasicReporter {
|
||||
formatStack(stack, opts) {
|
||||
return " " + parseStack(stack).join("\n ");
|
||||
}
|
||||
formatArgs(args, opts) {
|
||||
const _args = args.map((arg) => {
|
||||
if (arg && typeof arg.stack === "string") {
|
||||
return arg.message + "\n" + this.formatStack(arg.stack, opts);
|
||||
}
|
||||
return arg;
|
||||
});
|
||||
return formatWithOptions(opts, ..._args);
|
||||
}
|
||||
formatDate(date, opts) {
|
||||
return opts.date ? date.toLocaleTimeString() : "";
|
||||
}
|
||||
filterAndJoin(arr) {
|
||||
return arr.filter(Boolean).join(" ");
|
||||
}
|
||||
formatLogObj(logObj, opts) {
|
||||
const message = this.formatArgs(logObj.args, opts);
|
||||
if (logObj.type === "box") {
|
||||
return "\n" + [
|
||||
bracket(logObj.tag),
|
||||
logObj.title && logObj.title,
|
||||
...message.split("\n")
|
||||
].filter(Boolean).map((l) => " > " + l).join("\n") + "\n";
|
||||
}
|
||||
return this.filterAndJoin([
|
||||
bracket(logObj.type),
|
||||
bracket(logObj.tag),
|
||||
message
|
||||
]);
|
||||
}
|
||||
log(logObj, ctx) {
|
||||
const line = this.formatLogObj(logObj, {
|
||||
columns: ctx.options.stdout.columns || 0,
|
||||
...ctx.options.formatOptions
|
||||
});
|
||||
return writeStream(
|
||||
line + "\n",
|
||||
logObj.level < 2 ? ctx.options.stderr || process.stderr : ctx.options.stdout || process.stdout
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export { BasicReporter as B, parseStack as p };
|
||||
636
node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/shared/consola.36c0034f.mjs
generated
vendored
Normal file
636
node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/shared/consola.36c0034f.mjs
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
645
node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/shared/consola.4bbae468.cjs
generated
vendored
Normal file
645
node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/shared/consola.4bbae468.cjs
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
65
node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/shared/consola.deac7d5a.cjs
generated
vendored
Normal file
65
node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/shared/consola.deac7d5a.cjs
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
'use strict';
|
||||
|
||||
const node_util = require('node:util');
|
||||
const node_path = require('node:path');
|
||||
|
||||
function parseStack(stack) {
|
||||
const cwd = process.cwd() + node_path.sep;
|
||||
const lines = stack.split("\n").splice(1).map((l) => l.trim().replace("file://", "").replace(cwd, ""));
|
||||
return lines;
|
||||
}
|
||||
|
||||
function writeStream(data, stream) {
|
||||
const write = stream.__write || stream.write;
|
||||
return write.call(stream, data);
|
||||
}
|
||||
|
||||
const bracket = (x) => x ? `[${x}]` : "";
|
||||
class BasicReporter {
|
||||
formatStack(stack, opts) {
|
||||
return " " + parseStack(stack).join("\n ");
|
||||
}
|
||||
formatArgs(args, opts) {
|
||||
const _args = args.map((arg) => {
|
||||
if (arg && typeof arg.stack === "string") {
|
||||
return arg.message + "\n" + this.formatStack(arg.stack, opts);
|
||||
}
|
||||
return arg;
|
||||
});
|
||||
return node_util.formatWithOptions(opts, ..._args);
|
||||
}
|
||||
formatDate(date, opts) {
|
||||
return opts.date ? date.toLocaleTimeString() : "";
|
||||
}
|
||||
filterAndJoin(arr) {
|
||||
return arr.filter(Boolean).join(" ");
|
||||
}
|
||||
formatLogObj(logObj, opts) {
|
||||
const message = this.formatArgs(logObj.args, opts);
|
||||
if (logObj.type === "box") {
|
||||
return "\n" + [
|
||||
bracket(logObj.tag),
|
||||
logObj.title && logObj.title,
|
||||
...message.split("\n")
|
||||
].filter(Boolean).map((l) => " > " + l).join("\n") + "\n";
|
||||
}
|
||||
return this.filterAndJoin([
|
||||
bracket(logObj.type),
|
||||
bracket(logObj.tag),
|
||||
message
|
||||
]);
|
||||
}
|
||||
log(logObj, ctx) {
|
||||
const line = this.formatLogObj(logObj, {
|
||||
columns: ctx.options.stdout.columns || 0,
|
||||
...ctx.options.formatOptions
|
||||
});
|
||||
return writeStream(
|
||||
line + "\n",
|
||||
logObj.level < 2 ? ctx.options.stderr || process.stderr : ctx.options.stdout || process.stdout
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
exports.BasicReporter = BasicReporter;
|
||||
exports.parseStack = parseStack;
|
||||
308
node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/utils.cjs
generated
vendored
Normal file
308
node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/utils.cjs
generated
vendored
Normal file
@@ -0,0 +1,308 @@
|
||||
'use strict';
|
||||
|
||||
const tty = require('node:tty');
|
||||
|
||||
function _interopNamespaceCompat(e) {
|
||||
if (e && typeof e === 'object' && 'default' in e) return e;
|
||||
const n = Object.create(null);
|
||||
if (e) {
|
||||
for (const k in e) {
|
||||
n[k] = e[k];
|
||||
}
|
||||
}
|
||||
n.default = e;
|
||||
return n;
|
||||
}
|
||||
|
||||
const tty__namespace = /*#__PURE__*/_interopNamespaceCompat(tty);
|
||||
|
||||
const {
|
||||
env = {},
|
||||
argv = [],
|
||||
platform = ""
|
||||
} = typeof process === "undefined" ? {} : process;
|
||||
const isDisabled = "NO_COLOR" in env || argv.includes("--no-color");
|
||||
const isForced = "FORCE_COLOR" in env || argv.includes("--color");
|
||||
const isWindows = platform === "win32";
|
||||
const isDumbTerminal = env.TERM === "dumb";
|
||||
const isCompatibleTerminal = tty__namespace && tty__namespace.isatty && tty__namespace.isatty(1) && env.TERM && !isDumbTerminal;
|
||||
const isCI = "CI" in env && ("GITHUB_ACTIONS" in env || "GITLAB_CI" in env || "CIRCLECI" in env);
|
||||
const isColorSupported = !isDisabled && (isForced || isWindows && !isDumbTerminal || isCompatibleTerminal || isCI);
|
||||
function replaceClose(index, string, close, replace, head = string.slice(0, Math.max(0, index)) + replace, tail = string.slice(Math.max(0, index + close.length)), next = tail.indexOf(close)) {
|
||||
return head + (next < 0 ? tail : replaceClose(next, tail, close, replace));
|
||||
}
|
||||
function clearBleed(index, string, open, close, replace) {
|
||||
return index < 0 ? open + string + close : open + replaceClose(index, string, close, replace) + close;
|
||||
}
|
||||
function filterEmpty(open, close, replace = open, at = open.length + 1) {
|
||||
return (string) => string || !(string === "" || string === void 0) ? clearBleed(
|
||||
("" + string).indexOf(close, at),
|
||||
string,
|
||||
open,
|
||||
close,
|
||||
replace
|
||||
) : "";
|
||||
}
|
||||
function init(open, close, replace) {
|
||||
return filterEmpty(`\x1B[${open}m`, `\x1B[${close}m`, replace);
|
||||
}
|
||||
const colorDefs = {
|
||||
reset: init(0, 0),
|
||||
bold: init(1, 22, "\x1B[22m\x1B[1m"),
|
||||
dim: init(2, 22, "\x1B[22m\x1B[2m"),
|
||||
italic: init(3, 23),
|
||||
underline: init(4, 24),
|
||||
inverse: init(7, 27),
|
||||
hidden: init(8, 28),
|
||||
strikethrough: init(9, 29),
|
||||
black: init(30, 39),
|
||||
red: init(31, 39),
|
||||
green: init(32, 39),
|
||||
yellow: init(33, 39),
|
||||
blue: init(34, 39),
|
||||
magenta: init(35, 39),
|
||||
cyan: init(36, 39),
|
||||
white: init(37, 39),
|
||||
gray: init(90, 39),
|
||||
bgBlack: init(40, 49),
|
||||
bgRed: init(41, 49),
|
||||
bgGreen: init(42, 49),
|
||||
bgYellow: init(43, 49),
|
||||
bgBlue: init(44, 49),
|
||||
bgMagenta: init(45, 49),
|
||||
bgCyan: init(46, 49),
|
||||
bgWhite: init(47, 49),
|
||||
blackBright: init(90, 39),
|
||||
redBright: init(91, 39),
|
||||
greenBright: init(92, 39),
|
||||
yellowBright: init(93, 39),
|
||||
blueBright: init(94, 39),
|
||||
magentaBright: init(95, 39),
|
||||
cyanBright: init(96, 39),
|
||||
whiteBright: init(97, 39),
|
||||
bgBlackBright: init(100, 49),
|
||||
bgRedBright: init(101, 49),
|
||||
bgGreenBright: init(102, 49),
|
||||
bgYellowBright: init(103, 49),
|
||||
bgBlueBright: init(104, 49),
|
||||
bgMagentaBright: init(105, 49),
|
||||
bgCyanBright: init(106, 49),
|
||||
bgWhiteBright: init(107, 49)
|
||||
};
|
||||
function createColors(useColor = isColorSupported) {
|
||||
return useColor ? colorDefs : Object.fromEntries(Object.keys(colorDefs).map((key) => [key, String]));
|
||||
}
|
||||
const colors = createColors();
|
||||
function getColor(color, fallback = "reset") {
|
||||
return colors[color] || colors[fallback];
|
||||
}
|
||||
function colorize(color, text) {
|
||||
return getColor(color)(text);
|
||||
}
|
||||
|
||||
const ansiRegex = [
|
||||
"[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
|
||||
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"
|
||||
].join("|");
|
||||
function stripAnsi(text) {
|
||||
return text.replace(new RegExp(ansiRegex, "g"), "");
|
||||
}
|
||||
function centerAlign(str, len, space = " ") {
|
||||
const free = len - str.length;
|
||||
if (free <= 0) {
|
||||
return str;
|
||||
}
|
||||
const freeLeft = Math.floor(free / 2);
|
||||
let _str = "";
|
||||
for (let i = 0; i < len; i++) {
|
||||
_str += i < freeLeft || i >= freeLeft + str.length ? space : str[i - freeLeft];
|
||||
}
|
||||
return _str;
|
||||
}
|
||||
function rightAlign(str, len, space = " ") {
|
||||
const free = len - str.length;
|
||||
if (free <= 0) {
|
||||
return str;
|
||||
}
|
||||
let _str = "";
|
||||
for (let i = 0; i < len; i++) {
|
||||
_str += i < free ? space : str[i - free];
|
||||
}
|
||||
return _str;
|
||||
}
|
||||
function leftAlign(str, len, space = " ") {
|
||||
let _str = "";
|
||||
for (let i = 0; i < len; i++) {
|
||||
_str += i < str.length ? str[i] : space;
|
||||
}
|
||||
return _str;
|
||||
}
|
||||
function align(alignment, str, len, space = " ") {
|
||||
switch (alignment) {
|
||||
case "left": {
|
||||
return leftAlign(str, len, space);
|
||||
}
|
||||
case "right": {
|
||||
return rightAlign(str, len, space);
|
||||
}
|
||||
case "center": {
|
||||
return centerAlign(str, len, space);
|
||||
}
|
||||
default: {
|
||||
return str;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const boxStylePresets = {
|
||||
solid: {
|
||||
tl: "\u250C",
|
||||
tr: "\u2510",
|
||||
bl: "\u2514",
|
||||
br: "\u2518",
|
||||
h: "\u2500",
|
||||
v: "\u2502"
|
||||
},
|
||||
double: {
|
||||
tl: "\u2554",
|
||||
tr: "\u2557",
|
||||
bl: "\u255A",
|
||||
br: "\u255D",
|
||||
h: "\u2550",
|
||||
v: "\u2551"
|
||||
},
|
||||
doubleSingle: {
|
||||
tl: "\u2553",
|
||||
tr: "\u2556",
|
||||
bl: "\u2559",
|
||||
br: "\u255C",
|
||||
h: "\u2500",
|
||||
v: "\u2551"
|
||||
},
|
||||
doubleSingleRounded: {
|
||||
tl: "\u256D",
|
||||
tr: "\u256E",
|
||||
bl: "\u2570",
|
||||
br: "\u256F",
|
||||
h: "\u2500",
|
||||
v: "\u2551"
|
||||
},
|
||||
singleThick: {
|
||||
tl: "\u250F",
|
||||
tr: "\u2513",
|
||||
bl: "\u2517",
|
||||
br: "\u251B",
|
||||
h: "\u2501",
|
||||
v: "\u2503"
|
||||
},
|
||||
singleDouble: {
|
||||
tl: "\u2552",
|
||||
tr: "\u2555",
|
||||
bl: "\u2558",
|
||||
br: "\u255B",
|
||||
h: "\u2550",
|
||||
v: "\u2502"
|
||||
},
|
||||
singleDoubleRounded: {
|
||||
tl: "\u256D",
|
||||
tr: "\u256E",
|
||||
bl: "\u2570",
|
||||
br: "\u256F",
|
||||
h: "\u2550",
|
||||
v: "\u2502"
|
||||
},
|
||||
rounded: {
|
||||
tl: "\u256D",
|
||||
tr: "\u256E",
|
||||
bl: "\u2570",
|
||||
br: "\u256F",
|
||||
h: "\u2500",
|
||||
v: "\u2502"
|
||||
}
|
||||
};
|
||||
const defaultStyle = {
|
||||
borderColor: "white",
|
||||
borderStyle: "rounded",
|
||||
valign: "center",
|
||||
padding: 2,
|
||||
marginLeft: 1,
|
||||
marginTop: 1,
|
||||
marginBottom: 1
|
||||
};
|
||||
function box(text, _opts = {}) {
|
||||
const opts = {
|
||||
..._opts,
|
||||
style: {
|
||||
...defaultStyle,
|
||||
..._opts.style
|
||||
}
|
||||
};
|
||||
const textLines = text.split("\n");
|
||||
const boxLines = [];
|
||||
const _color = getColor(opts.style.borderColor);
|
||||
const borderStyle = {
|
||||
...typeof opts.style.borderStyle === "string" ? boxStylePresets[opts.style.borderStyle] || boxStylePresets.solid : opts.style.borderStyle
|
||||
};
|
||||
if (_color) {
|
||||
for (const key in borderStyle) {
|
||||
borderStyle[key] = _color(
|
||||
borderStyle[key]
|
||||
);
|
||||
}
|
||||
}
|
||||
const paddingOffset = opts.style.padding % 2 === 0 ? opts.style.padding : opts.style.padding + 1;
|
||||
const height = textLines.length + paddingOffset;
|
||||
const width = Math.max(...textLines.map((line) => line.length)) + paddingOffset;
|
||||
const widthOffset = width + paddingOffset;
|
||||
const leftSpace = opts.style.marginLeft > 0 ? " ".repeat(opts.style.marginLeft) : "";
|
||||
if (opts.style.marginTop > 0) {
|
||||
boxLines.push("".repeat(opts.style.marginTop));
|
||||
}
|
||||
if (opts.title) {
|
||||
const left = borderStyle.h.repeat(
|
||||
Math.floor((width - stripAnsi(opts.title).length) / 2)
|
||||
);
|
||||
const right = borderStyle.h.repeat(
|
||||
width - stripAnsi(opts.title).length - stripAnsi(left).length + paddingOffset
|
||||
);
|
||||
boxLines.push(
|
||||
`${leftSpace}${borderStyle.tl}${left}${opts.title}${right}${borderStyle.tr}`
|
||||
);
|
||||
} else {
|
||||
boxLines.push(
|
||||
`${leftSpace}${borderStyle.tl}${borderStyle.h.repeat(widthOffset)}${borderStyle.tr}`
|
||||
);
|
||||
}
|
||||
const valignOffset = opts.style.valign === "center" ? Math.floor((height - textLines.length) / 2) : opts.style.valign === "top" ? height - textLines.length - paddingOffset : height - textLines.length;
|
||||
for (let i = 0; i < height; i++) {
|
||||
if (i < valignOffset || i >= valignOffset + textLines.length) {
|
||||
boxLines.push(
|
||||
`${leftSpace}${borderStyle.v}${" ".repeat(widthOffset)}${borderStyle.v}`
|
||||
);
|
||||
} else {
|
||||
const line = textLines[i - valignOffset];
|
||||
const left = " ".repeat(paddingOffset);
|
||||
const right = " ".repeat(width - stripAnsi(line).length);
|
||||
boxLines.push(
|
||||
`${leftSpace}${borderStyle.v}${left}${line}${right}${borderStyle.v}`
|
||||
);
|
||||
}
|
||||
}
|
||||
boxLines.push(
|
||||
`${leftSpace}${borderStyle.bl}${borderStyle.h.repeat(widthOffset)}${borderStyle.br}`
|
||||
);
|
||||
if (opts.style.marginBottom > 0) {
|
||||
boxLines.push("".repeat(opts.style.marginBottom));
|
||||
}
|
||||
return boxLines.join("\n");
|
||||
}
|
||||
|
||||
exports.align = align;
|
||||
exports.box = box;
|
||||
exports.centerAlign = centerAlign;
|
||||
exports.colorize = colorize;
|
||||
exports.colors = colors;
|
||||
exports.getColor = getColor;
|
||||
exports.leftAlign = leftAlign;
|
||||
exports.rightAlign = rightAlign;
|
||||
exports.stripAnsi = stripAnsi;
|
||||
169
node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/utils.d.ts
generated
vendored
Normal file
169
node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/utils.d.ts
generated
vendored
Normal file
@@ -0,0 +1,169 @@
|
||||
type BoxBorderStyle = {
|
||||
/**
|
||||
* Top left corner
|
||||
* @example `┌`
|
||||
* @example `╔`
|
||||
* @example `╓`
|
||||
*/
|
||||
tl: string;
|
||||
/**
|
||||
* Top right corner
|
||||
* @example `┐`
|
||||
* @example `╗`
|
||||
* @example `╖`
|
||||
*/
|
||||
tr: string;
|
||||
/**
|
||||
* Bottom left corner
|
||||
* @example `└`
|
||||
* @example `╚`
|
||||
* @example `╙`
|
||||
*/
|
||||
bl: string;
|
||||
/**
|
||||
* Bottom right corner
|
||||
* @example `┘`
|
||||
* @example `╝`
|
||||
* @example `╜`
|
||||
*/
|
||||
br: string;
|
||||
/**
|
||||
* Horizontal line
|
||||
* @example `─`
|
||||
* @example `═`
|
||||
* @example `─`
|
||||
*/
|
||||
h: string;
|
||||
/**
|
||||
* Vertical line
|
||||
* @example `│`
|
||||
* @example `║`
|
||||
* @example `║`
|
||||
*/
|
||||
v: string;
|
||||
};
|
||||
declare const boxStylePresets: Record<string, BoxBorderStyle>;
|
||||
type BoxStyle = {
|
||||
/**
|
||||
* The border color
|
||||
* @default 'white'
|
||||
*/
|
||||
borderColor: "black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white" | "gray" | "blackBright" | "redBright" | "greenBright" | "yellowBright" | "blueBright" | "magentaBright" | "cyanBright" | "whiteBright";
|
||||
/**
|
||||
* The border style
|
||||
* @default 'solid'
|
||||
* @example 'single-double-rounded'
|
||||
* @example
|
||||
* ```ts
|
||||
* {
|
||||
* tl: '┌',
|
||||
* tr: '┐',
|
||||
* bl: '└',
|
||||
* br: '┘',
|
||||
* h: '─',
|
||||
* v: '│',
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
borderStyle: BoxBorderStyle | keyof typeof boxStylePresets;
|
||||
/**
|
||||
* The vertical alignment of the text
|
||||
* @default 'center'
|
||||
*/
|
||||
valign: "top" | "center" | "bottom";
|
||||
/**
|
||||
* The padding of the box
|
||||
* @default 2
|
||||
*/
|
||||
padding: number;
|
||||
/**
|
||||
* The left margin of the box
|
||||
* @default 1
|
||||
*/
|
||||
marginLeft: number;
|
||||
/**
|
||||
* The top margin of the box
|
||||
* @default 1
|
||||
*/
|
||||
marginTop: number;
|
||||
/**
|
||||
* The top margin of the box
|
||||
* @default 1
|
||||
*/
|
||||
marginBottom: number;
|
||||
};
|
||||
/**
|
||||
* The border options of the box
|
||||
*/
|
||||
type BoxOpts = {
|
||||
/**
|
||||
* Title that will be displayed on top of the box
|
||||
* @example 'Hello World'
|
||||
* @example 'Hello {name}'
|
||||
*/
|
||||
title?: string;
|
||||
style?: Partial<BoxStyle>;
|
||||
};
|
||||
declare function box(text: string, _opts?: BoxOpts): string;
|
||||
|
||||
/**
|
||||
* Based on https://github.com/jorgebucaran/colorette
|
||||
* Read LICENSE file for more information
|
||||
* https://github.com/jorgebucaran/colorette/blob/20fc196d07d0f87c61e0256eadd7831c79b24108/index.js
|
||||
*/
|
||||
declare const colorDefs: {
|
||||
reset: (string: string) => string;
|
||||
bold: (string: string) => string;
|
||||
dim: (string: string) => string;
|
||||
italic: (string: string) => string;
|
||||
underline: (string: string) => string;
|
||||
inverse: (string: string) => string;
|
||||
hidden: (string: string) => string;
|
||||
strikethrough: (string: string) => string;
|
||||
black: (string: string) => string;
|
||||
red: (string: string) => string;
|
||||
green: (string: string) => string;
|
||||
yellow: (string: string) => string;
|
||||
blue: (string: string) => string;
|
||||
magenta: (string: string) => string;
|
||||
cyan: (string: string) => string;
|
||||
white: (string: string) => string;
|
||||
gray: (string: string) => string;
|
||||
bgBlack: (string: string) => string;
|
||||
bgRed: (string: string) => string;
|
||||
bgGreen: (string: string) => string;
|
||||
bgYellow: (string: string) => string;
|
||||
bgBlue: (string: string) => string;
|
||||
bgMagenta: (string: string) => string;
|
||||
bgCyan: (string: string) => string;
|
||||
bgWhite: (string: string) => string;
|
||||
blackBright: (string: string) => string;
|
||||
redBright: (string: string) => string;
|
||||
greenBright: (string: string) => string;
|
||||
yellowBright: (string: string) => string;
|
||||
blueBright: (string: string) => string;
|
||||
magentaBright: (string: string) => string;
|
||||
cyanBright: (string: string) => string;
|
||||
whiteBright: (string: string) => string;
|
||||
bgBlackBright: (string: string) => string;
|
||||
bgRedBright: (string: string) => string;
|
||||
bgGreenBright: (string: string) => string;
|
||||
bgYellowBright: (string: string) => string;
|
||||
bgBlueBright: (string: string) => string;
|
||||
bgMagentaBright: (string: string) => string;
|
||||
bgCyanBright: (string: string) => string;
|
||||
bgWhiteBright: (string: string) => string;
|
||||
};
|
||||
type ColorName = keyof typeof colorDefs;
|
||||
type ColorFunction = (text: string | number) => string;
|
||||
declare const colors: Record<"reset" | "bold" | "dim" | "italic" | "underline" | "inverse" | "hidden" | "strikethrough" | "black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white" | "gray" | "bgBlack" | "bgRed" | "bgGreen" | "bgYellow" | "bgBlue" | "bgMagenta" | "bgCyan" | "bgWhite" | "blackBright" | "redBright" | "greenBright" | "yellowBright" | "blueBright" | "magentaBright" | "cyanBright" | "whiteBright" | "bgBlackBright" | "bgRedBright" | "bgGreenBright" | "bgYellowBright" | "bgBlueBright" | "bgMagentaBright" | "bgCyanBright" | "bgWhiteBright", ColorFunction>;
|
||||
declare function getColor(color: ColorName, fallback?: ColorName): ColorFunction;
|
||||
declare function colorize(color: ColorName, text: string | number): string;
|
||||
|
||||
declare function stripAnsi(text: string): string;
|
||||
declare function centerAlign(str: string, len: number, space?: string): string;
|
||||
declare function rightAlign(str: string, len: number, space?: string): string;
|
||||
declare function leftAlign(str: string, len: number, space?: string): string;
|
||||
declare function align(alignment: "left" | "right" | "center", str: string, len: number, space?: string): string;
|
||||
|
||||
export { BoxBorderStyle, BoxOpts, BoxStyle, ColorFunction, ColorName, align, box, centerAlign, colorize, colors, getColor, leftAlign, rightAlign, stripAnsi };
|
||||
284
node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/utils.mjs
generated
vendored
Normal file
284
node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/utils.mjs
generated
vendored
Normal file
@@ -0,0 +1,284 @@
|
||||
import * as tty from 'node:tty';
|
||||
|
||||
const {
|
||||
env = {},
|
||||
argv = [],
|
||||
platform = ""
|
||||
} = typeof process === "undefined" ? {} : process;
|
||||
const isDisabled = "NO_COLOR" in env || argv.includes("--no-color");
|
||||
const isForced = "FORCE_COLOR" in env || argv.includes("--color");
|
||||
const isWindows = platform === "win32";
|
||||
const isDumbTerminal = env.TERM === "dumb";
|
||||
const isCompatibleTerminal = tty && tty.isatty && tty.isatty(1) && env.TERM && !isDumbTerminal;
|
||||
const isCI = "CI" in env && ("GITHUB_ACTIONS" in env || "GITLAB_CI" in env || "CIRCLECI" in env);
|
||||
const isColorSupported = !isDisabled && (isForced || isWindows && !isDumbTerminal || isCompatibleTerminal || isCI);
|
||||
function replaceClose(index, string, close, replace, head = string.slice(0, Math.max(0, index)) + replace, tail = string.slice(Math.max(0, index + close.length)), next = tail.indexOf(close)) {
|
||||
return head + (next < 0 ? tail : replaceClose(next, tail, close, replace));
|
||||
}
|
||||
function clearBleed(index, string, open, close, replace) {
|
||||
return index < 0 ? open + string + close : open + replaceClose(index, string, close, replace) + close;
|
||||
}
|
||||
function filterEmpty(open, close, replace = open, at = open.length + 1) {
|
||||
return (string) => string || !(string === "" || string === void 0) ? clearBleed(
|
||||
("" + string).indexOf(close, at),
|
||||
string,
|
||||
open,
|
||||
close,
|
||||
replace
|
||||
) : "";
|
||||
}
|
||||
function init(open, close, replace) {
|
||||
return filterEmpty(`\x1B[${open}m`, `\x1B[${close}m`, replace);
|
||||
}
|
||||
const colorDefs = {
|
||||
reset: init(0, 0),
|
||||
bold: init(1, 22, "\x1B[22m\x1B[1m"),
|
||||
dim: init(2, 22, "\x1B[22m\x1B[2m"),
|
||||
italic: init(3, 23),
|
||||
underline: init(4, 24),
|
||||
inverse: init(7, 27),
|
||||
hidden: init(8, 28),
|
||||
strikethrough: init(9, 29),
|
||||
black: init(30, 39),
|
||||
red: init(31, 39),
|
||||
green: init(32, 39),
|
||||
yellow: init(33, 39),
|
||||
blue: init(34, 39),
|
||||
magenta: init(35, 39),
|
||||
cyan: init(36, 39),
|
||||
white: init(37, 39),
|
||||
gray: init(90, 39),
|
||||
bgBlack: init(40, 49),
|
||||
bgRed: init(41, 49),
|
||||
bgGreen: init(42, 49),
|
||||
bgYellow: init(43, 49),
|
||||
bgBlue: init(44, 49),
|
||||
bgMagenta: init(45, 49),
|
||||
bgCyan: init(46, 49),
|
||||
bgWhite: init(47, 49),
|
||||
blackBright: init(90, 39),
|
||||
redBright: init(91, 39),
|
||||
greenBright: init(92, 39),
|
||||
yellowBright: init(93, 39),
|
||||
blueBright: init(94, 39),
|
||||
magentaBright: init(95, 39),
|
||||
cyanBright: init(96, 39),
|
||||
whiteBright: init(97, 39),
|
||||
bgBlackBright: init(100, 49),
|
||||
bgRedBright: init(101, 49),
|
||||
bgGreenBright: init(102, 49),
|
||||
bgYellowBright: init(103, 49),
|
||||
bgBlueBright: init(104, 49),
|
||||
bgMagentaBright: init(105, 49),
|
||||
bgCyanBright: init(106, 49),
|
||||
bgWhiteBright: init(107, 49)
|
||||
};
|
||||
function createColors(useColor = isColorSupported) {
|
||||
return useColor ? colorDefs : Object.fromEntries(Object.keys(colorDefs).map((key) => [key, String]));
|
||||
}
|
||||
const colors = createColors();
|
||||
function getColor(color, fallback = "reset") {
|
||||
return colors[color] || colors[fallback];
|
||||
}
|
||||
function colorize(color, text) {
|
||||
return getColor(color)(text);
|
||||
}
|
||||
|
||||
const ansiRegex = [
|
||||
"[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
|
||||
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"
|
||||
].join("|");
|
||||
function stripAnsi(text) {
|
||||
return text.replace(new RegExp(ansiRegex, "g"), "");
|
||||
}
|
||||
function centerAlign(str, len, space = " ") {
|
||||
const free = len - str.length;
|
||||
if (free <= 0) {
|
||||
return str;
|
||||
}
|
||||
const freeLeft = Math.floor(free / 2);
|
||||
let _str = "";
|
||||
for (let i = 0; i < len; i++) {
|
||||
_str += i < freeLeft || i >= freeLeft + str.length ? space : str[i - freeLeft];
|
||||
}
|
||||
return _str;
|
||||
}
|
||||
function rightAlign(str, len, space = " ") {
|
||||
const free = len - str.length;
|
||||
if (free <= 0) {
|
||||
return str;
|
||||
}
|
||||
let _str = "";
|
||||
for (let i = 0; i < len; i++) {
|
||||
_str += i < free ? space : str[i - free];
|
||||
}
|
||||
return _str;
|
||||
}
|
||||
function leftAlign(str, len, space = " ") {
|
||||
let _str = "";
|
||||
for (let i = 0; i < len; i++) {
|
||||
_str += i < str.length ? str[i] : space;
|
||||
}
|
||||
return _str;
|
||||
}
|
||||
function align(alignment, str, len, space = " ") {
|
||||
switch (alignment) {
|
||||
case "left": {
|
||||
return leftAlign(str, len, space);
|
||||
}
|
||||
case "right": {
|
||||
return rightAlign(str, len, space);
|
||||
}
|
||||
case "center": {
|
||||
return centerAlign(str, len, space);
|
||||
}
|
||||
default: {
|
||||
return str;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const boxStylePresets = {
|
||||
solid: {
|
||||
tl: "\u250C",
|
||||
tr: "\u2510",
|
||||
bl: "\u2514",
|
||||
br: "\u2518",
|
||||
h: "\u2500",
|
||||
v: "\u2502"
|
||||
},
|
||||
double: {
|
||||
tl: "\u2554",
|
||||
tr: "\u2557",
|
||||
bl: "\u255A",
|
||||
br: "\u255D",
|
||||
h: "\u2550",
|
||||
v: "\u2551"
|
||||
},
|
||||
doubleSingle: {
|
||||
tl: "\u2553",
|
||||
tr: "\u2556",
|
||||
bl: "\u2559",
|
||||
br: "\u255C",
|
||||
h: "\u2500",
|
||||
v: "\u2551"
|
||||
},
|
||||
doubleSingleRounded: {
|
||||
tl: "\u256D",
|
||||
tr: "\u256E",
|
||||
bl: "\u2570",
|
||||
br: "\u256F",
|
||||
h: "\u2500",
|
||||
v: "\u2551"
|
||||
},
|
||||
singleThick: {
|
||||
tl: "\u250F",
|
||||
tr: "\u2513",
|
||||
bl: "\u2517",
|
||||
br: "\u251B",
|
||||
h: "\u2501",
|
||||
v: "\u2503"
|
||||
},
|
||||
singleDouble: {
|
||||
tl: "\u2552",
|
||||
tr: "\u2555",
|
||||
bl: "\u2558",
|
||||
br: "\u255B",
|
||||
h: "\u2550",
|
||||
v: "\u2502"
|
||||
},
|
||||
singleDoubleRounded: {
|
||||
tl: "\u256D",
|
||||
tr: "\u256E",
|
||||
bl: "\u2570",
|
||||
br: "\u256F",
|
||||
h: "\u2550",
|
||||
v: "\u2502"
|
||||
},
|
||||
rounded: {
|
||||
tl: "\u256D",
|
||||
tr: "\u256E",
|
||||
bl: "\u2570",
|
||||
br: "\u256F",
|
||||
h: "\u2500",
|
||||
v: "\u2502"
|
||||
}
|
||||
};
|
||||
const defaultStyle = {
|
||||
borderColor: "white",
|
||||
borderStyle: "rounded",
|
||||
valign: "center",
|
||||
padding: 2,
|
||||
marginLeft: 1,
|
||||
marginTop: 1,
|
||||
marginBottom: 1
|
||||
};
|
||||
function box(text, _opts = {}) {
|
||||
const opts = {
|
||||
..._opts,
|
||||
style: {
|
||||
...defaultStyle,
|
||||
..._opts.style
|
||||
}
|
||||
};
|
||||
const textLines = text.split("\n");
|
||||
const boxLines = [];
|
||||
const _color = getColor(opts.style.borderColor);
|
||||
const borderStyle = {
|
||||
...typeof opts.style.borderStyle === "string" ? boxStylePresets[opts.style.borderStyle] || boxStylePresets.solid : opts.style.borderStyle
|
||||
};
|
||||
if (_color) {
|
||||
for (const key in borderStyle) {
|
||||
borderStyle[key] = _color(
|
||||
borderStyle[key]
|
||||
);
|
||||
}
|
||||
}
|
||||
const paddingOffset = opts.style.padding % 2 === 0 ? opts.style.padding : opts.style.padding + 1;
|
||||
const height = textLines.length + paddingOffset;
|
||||
const width = Math.max(...textLines.map((line) => line.length)) + paddingOffset;
|
||||
const widthOffset = width + paddingOffset;
|
||||
const leftSpace = opts.style.marginLeft > 0 ? " ".repeat(opts.style.marginLeft) : "";
|
||||
if (opts.style.marginTop > 0) {
|
||||
boxLines.push("".repeat(opts.style.marginTop));
|
||||
}
|
||||
if (opts.title) {
|
||||
const left = borderStyle.h.repeat(
|
||||
Math.floor((width - stripAnsi(opts.title).length) / 2)
|
||||
);
|
||||
const right = borderStyle.h.repeat(
|
||||
width - stripAnsi(opts.title).length - stripAnsi(left).length + paddingOffset
|
||||
);
|
||||
boxLines.push(
|
||||
`${leftSpace}${borderStyle.tl}${left}${opts.title}${right}${borderStyle.tr}`
|
||||
);
|
||||
} else {
|
||||
boxLines.push(
|
||||
`${leftSpace}${borderStyle.tl}${borderStyle.h.repeat(widthOffset)}${borderStyle.tr}`
|
||||
);
|
||||
}
|
||||
const valignOffset = opts.style.valign === "center" ? Math.floor((height - textLines.length) / 2) : opts.style.valign === "top" ? height - textLines.length - paddingOffset : height - textLines.length;
|
||||
for (let i = 0; i < height; i++) {
|
||||
if (i < valignOffset || i >= valignOffset + textLines.length) {
|
||||
boxLines.push(
|
||||
`${leftSpace}${borderStyle.v}${" ".repeat(widthOffset)}${borderStyle.v}`
|
||||
);
|
||||
} else {
|
||||
const line = textLines[i - valignOffset];
|
||||
const left = " ".repeat(paddingOffset);
|
||||
const right = " ".repeat(width - stripAnsi(line).length);
|
||||
boxLines.push(
|
||||
`${leftSpace}${borderStyle.v}${left}${line}${right}${borderStyle.v}`
|
||||
);
|
||||
}
|
||||
}
|
||||
boxLines.push(
|
||||
`${leftSpace}${borderStyle.bl}${borderStyle.h.repeat(widthOffset)}${borderStyle.br}`
|
||||
);
|
||||
if (opts.style.marginBottom > 0) {
|
||||
boxLines.push("".repeat(opts.style.marginBottom));
|
||||
}
|
||||
return boxLines.join("\n");
|
||||
}
|
||||
|
||||
export { align, box, centerAlign, colorize, colors, getColor, leftAlign, rightAlign, stripAnsi };
|
||||
9
node_modules/.pnpm/consola@3.2.3/node_modules/consola/lib/index.cjs
generated
vendored
Normal file
9
node_modules/.pnpm/consola@3.2.3/node_modules/consola/lib/index.cjs
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
const lib = require("../dist/index.cjs");
|
||||
|
||||
module.exports = lib.consola;
|
||||
|
||||
for (const key in lib) {
|
||||
if (!(key in module.exports)) {
|
||||
module.exports[key] = lib[key];
|
||||
}
|
||||
}
|
||||
101
node_modules/.pnpm/consola@3.2.3/node_modules/consola/package.json
generated
vendored
Normal file
101
node_modules/.pnpm/consola@3.2.3/node_modules/consola/package.json
generated
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
{
|
||||
"name": "consola",
|
||||
"version": "3.2.3",
|
||||
"description": "Elegant Console Wrapper",
|
||||
"keywords": [
|
||||
"console",
|
||||
"logger",
|
||||
"reporter",
|
||||
"elegant",
|
||||
"cli",
|
||||
"universal",
|
||||
"unified",
|
||||
"prompt",
|
||||
"clack",
|
||||
"format",
|
||||
"error",
|
||||
"stacktrace"
|
||||
],
|
||||
"repository": "unjs/consola",
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": {
|
||||
"node": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"import": "./dist/index.mjs",
|
||||
"require": "./lib/index.cjs"
|
||||
},
|
||||
"default": {
|
||||
"types": "./dist/browser.d.ts",
|
||||
"import": "./dist/browser.mjs"
|
||||
}
|
||||
},
|
||||
"./browser": {
|
||||
"types": "./dist/browser.d.ts",
|
||||
"import": "./dist/browser.mjs"
|
||||
},
|
||||
"./basic": {
|
||||
"node": {
|
||||
"types": "./dist/basic.d.ts",
|
||||
"import": "./dist/basic.mjs",
|
||||
"require": "./dist/basic.cjs"
|
||||
},
|
||||
"default": {
|
||||
"types": "./dist/browser.d.ts",
|
||||
"import": "./dist/browser.mjs"
|
||||
}
|
||||
},
|
||||
"./core": {
|
||||
"types": "./dist/core.d.ts",
|
||||
"import": "./dist/core.mjs",
|
||||
"require": "./dist/core.cjs"
|
||||
},
|
||||
"./utils": {
|
||||
"types": "./dist/utils.d.ts",
|
||||
"import": "./dist/utils.mjs",
|
||||
"require": "./dist/utils.cjs"
|
||||
}
|
||||
},
|
||||
"main": "./lib/index.cjs",
|
||||
"module": "./dist/index.mjs",
|
||||
"browser": "./dist/browser.mjs",
|
||||
"types": "./dist/index.d.ts",
|
||||
"files": [
|
||||
"dist",
|
||||
"lib",
|
||||
"*.d.ts"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "unbuild",
|
||||
"dev": "vitest",
|
||||
"lint": "eslint . && prettier -c src examples test",
|
||||
"lint:fix": "eslint . --fix && prettier -w src examples test",
|
||||
"release": "pnpm test && pnpm build && changelogen --release --push && npm publish",
|
||||
"test": "pnpm lint && pnpm vitest run --coverage"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@clack/core": "^0.3.2",
|
||||
"@types/node": "^20.3.3",
|
||||
"@vitest/coverage-v8": "^0.32.2",
|
||||
"changelogen": "^0.5.3",
|
||||
"defu": "^6.1.2",
|
||||
"eslint": "^8.44.0",
|
||||
"eslint-config-unjs": "^0.2.1",
|
||||
"is-unicode-supported": "^1.3.0",
|
||||
"jiti": "^1.18.2",
|
||||
"lodash": "^4.17.21",
|
||||
"prettier": "^3.0.0",
|
||||
"sentencer": "^0.2.1",
|
||||
"sisteransi": "^1.0.5",
|
||||
"std-env": "^3.3.3",
|
||||
"string-width": "^6.1.0",
|
||||
"typescript": "^5.1.6",
|
||||
"unbuild": "^1.2.1",
|
||||
"vitest": "^0.32.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14.18.0 || >=16.10.0"
|
||||
},
|
||||
"packageManager": "pnpm@8.6.5"
|
||||
}
|
||||
1
node_modules/.pnpm/consola@3.2.3/node_modules/consola/utils.d.ts
generated
vendored
Normal file
1
node_modules/.pnpm/consola@3.2.3/node_modules/consola/utils.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./dist/utils";
|
||||
Reference in New Issue
Block a user